@gengage/assistant-fe 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +100 -0
  2. package/dist/assistant-fe.css +1 -1
  3. package/dist/chat/components/AIGroupingCards.d.ts.map +1 -1
  4. package/dist/chat/components/AITopPicks.d.ts.map +1 -1
  5. package/dist/chat/components/ChatDrawer.d.ts +12 -4
  6. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  7. package/dist/chat/components/ComparisonTable.d.ts +2 -7
  8. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  9. package/dist/chat/components/productMentionLinker.d.ts.map +1 -1
  10. package/dist/chat/index.d.ts +14 -1
  11. package/dist/chat/index.d.ts.map +1 -1
  12. package/dist/chat/locales/en.d.ts.map +1 -1
  13. package/dist/chat/locales/tr.d.ts.map +1 -1
  14. package/dist/chat/panel-manager.d.ts +6 -2
  15. package/dist/chat/panel-manager.d.ts.map +1 -1
  16. package/dist/chat/session-persistence.d.ts +1 -0
  17. package/dist/chat/session-persistence.d.ts.map +1 -1
  18. package/dist/chat/types.d.ts +4 -2
  19. package/dist/chat/types.d.ts.map +1 -1
  20. package/dist/chat.cjs +1 -1
  21. package/dist/chat.iife.js +29 -29
  22. package/dist/chat.iife.js.map +1 -1
  23. package/dist/chat.js +2 -2
  24. package/dist/common/events.d.ts.map +1 -1
  25. package/dist/common/index.d.ts +2 -0
  26. package/dist/common/index.d.ts.map +1 -1
  27. package/dist/common/indexed-db.d.ts +2 -0
  28. package/dist/common/indexed-db.d.ts.map +1 -1
  29. package/dist/common/native-webview.d.ts +61 -0
  30. package/dist/common/native-webview.d.ts.map +1 -0
  31. package/dist/common/overlay.d.ts +5 -0
  32. package/dist/common/overlay.d.ts.map +1 -1
  33. package/dist/common/v1-protocol-adapter.d.ts.map +1 -1
  34. package/dist/common.cjs +1 -1
  35. package/dist/common.cjs.map +1 -1
  36. package/dist/common.js +197 -426
  37. package/dist/common.js.map +1 -1
  38. package/dist/index-1yPxOqAw.cjs +13 -0
  39. package/dist/index-1yPxOqAw.cjs.map +1 -0
  40. package/dist/index-BH-V2lWn.js +510 -0
  41. package/dist/index-BH-V2lWn.js.map +1 -0
  42. package/dist/index-BelS6Vnv.cjs +2 -0
  43. package/dist/index-BelS6Vnv.cjs.map +1 -0
  44. package/dist/index-CERWfDdF.js +4571 -0
  45. package/dist/index-CERWfDdF.js.map +1 -0
  46. package/dist/index.cjs +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +55 -50
  50. package/dist/index.js.map +1 -1
  51. package/dist/native/index.d.ts +3 -0
  52. package/dist/native/index.d.ts.map +1 -0
  53. package/dist/native.cjs +2 -0
  54. package/dist/native.cjs.map +1 -0
  55. package/dist/native.iife.js +97 -0
  56. package/dist/native.iife.js.map +1 -0
  57. package/dist/native.js +9 -0
  58. package/dist/native.js.map +1 -0
  59. package/dist/qna/components/TextInput.d.ts.map +1 -1
  60. package/dist/qna/components/renderUISpec.d.ts.map +1 -1
  61. package/dist/qna/index.d.ts +1 -0
  62. package/dist/qna/index.d.ts.map +1 -1
  63. package/dist/qna/types.d.ts +1 -1
  64. package/dist/qna/types.d.ts.map +1 -1
  65. package/dist/qna.cjs +1 -1
  66. package/dist/qna.cjs.map +1 -1
  67. package/dist/qna.css +1 -1
  68. package/dist/qna.iife.js +20 -20
  69. package/dist/qna.iife.js.map +1 -1
  70. package/dist/qna.js +92 -80
  71. package/dist/qna.js.map +1 -1
  72. package/dist/schemas-DHzfUzwA.cjs +86 -0
  73. package/dist/schemas-DHzfUzwA.cjs.map +1 -0
  74. package/dist/{schemas-B9GN-J3e.js → schemas-yF4IOEUi.js} +1088 -987
  75. package/dist/schemas-yF4IOEUi.js.map +1 -0
  76. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  77. package/dist/simrel.cjs +1 -1
  78. package/dist/simrel.cjs.map +1 -1
  79. package/dist/simrel.css +1 -1
  80. package/dist/simrel.iife.js +20 -20
  81. package/dist/simrel.iife.js.map +1 -1
  82. package/dist/simrel.js +218 -214
  83. package/dist/simrel.js.map +1 -1
  84. package/package.json +9 -2
  85. package/dist/index-eefqsSOT.cjs +0 -13
  86. package/dist/index-eefqsSOT.cjs.map +0 -1
  87. package/dist/index-kp84NL1R.js +0 -4399
  88. package/dist/index-kp84NL1R.js.map +0 -1
  89. package/dist/schemas-B9GN-J3e.js.map +0 -1
  90. package/dist/schemas-tCxs1sED.cjs +0 -86
  91. package/dist/schemas-tCxs1sED.cjs.map +0 -1
package/dist/chat.iife.js CHANGED
@@ -1,15 +1,15 @@
1
- (function(fe){"use strict";const Yn=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const o=t(a);o&&n.appendChild(o)}return n};function Xn(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Yn,o=r=>{const s=e.spec.elements[r];if(!s)return null;const c=e.registry[s.type];return c?c({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:o}):a({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:o})},i=o(e.spec.root);return i&&t.appendChild(i),t}function Qn(e,t){if(!t)return e;const n={...e};for(const[a,o]of Object.entries(t))o&&(n[a]=o);return n}function ea(e,t){const n={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ta(e,t){const n={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(n.latency_ms=t.latency_ms);const a={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function na(e,t){const n={event_name:"stream.ui_spec",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,chunk_index:t.chunk_index,component_type:t.component_type}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function aa(e,t){const n={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function oa(e,t){const n={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ia(e,t){const n={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(n.provider=t.provider);const a={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ra(e,t){const n={event_name:"metering.increment",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function sa(e,t){const n={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ca(e,t){const n={event_name:"chat.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function la(e,t){const n={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function da(e,t){const n={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ee(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function bt(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function ga(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function pa(e){return{sessionId:e?.sessionId??ga(),...e}}const _t={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"14px","--gengage-simrel-card-radius":"14px"};function ua(e){return e?{..._t,...e}:{..._t}}const se="gengage-global-toast-root",vt="gengage-global-toast-style",Ge="gengage-global-toast-root--visible",ha=4200,fa=1500,ma=15e3;let yt=!1,me=null;function ba(){yt||typeof window>"u"||typeof document>"u"||(yt=!0,bt("gengage:global:error",e=>{_a(e)}))}function _a(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;ka();const n=wa();n.innerHTML="";const a=document.createElement("section");a.className="gengage-global-toast gengage-global-toast--error",a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=ya(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,a.appendChild(o),a.appendChild(i),n.appendChild(a),n.classList.add(Ge),me&&(clearTimeout(me),me=null),me=setTimeout(()=>{va()},xa(e.durationMs))}function va(){if(typeof document>"u")return;const e=document.getElementById(se);e&&(e.classList.remove(Ge),e.innerHTML="",me&&(clearTimeout(me),me=null))}function ya(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function wa(){const e=document.getElementById(se);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=se,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function xa(e){return typeof e!="number"||!Number.isFinite(e)?ha:Math.min(ma,Math.max(fa,Math.round(e)))}function ka(){if(document.getElementById(vt))return;const e=document.createElement("style");e.id=vt,e.textContent=`
2
- #${se} {
1
+ (function(be){"use strict";const ea=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const i=t(a);i&&n.appendChild(i)}return n};function ta(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??ea,i=r=>{const s=e.spec.elements[r];if(!s)return null;const c=e.registry[s.type];return c?c({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:i}):a({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:i})},o=i(e.spec.root);return o&&t.appendChild(o),t}function na(e,t){if(!t)return e;const n={...e};for(const[a,i]of Object.entries(t))i&&(n[a]=i);return n}function aa(e,t){const n={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ia(e,t){const n={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(n.latency_ms=t.latency_ms);const a={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function oa(e,t){const n={event_name:"stream.ui_spec",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,chunk_index:t.chunk_index,component_type:t.component_type}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ra(e,t){const n={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function sa(e,t){const n={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ca(e,t){const n={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(n.provider=t.provider);const a={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function la(e,t){const n={event_name:"metering.increment",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function da(e,t){const n={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ga(e,t){const n={event_name:"chat.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function pa(e,t){const n={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ua(e,t){const n={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ae(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function bt(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function ha(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function fa(e){return{sessionId:e?.sessionId??ha(),...e}}const _t={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"14px","--gengage-simrel-card-radius":"14px"};function ma(e){return e?{..._t,...e}:{..._t}}const de="gengage-global-toast-root",vt="gengage-global-toast-style",Ge="gengage-global-toast-root--visible",ba=4200,_a=1500,va=15e3;let yt=!1,_e=null;function ya(){yt||typeof window>"u"||typeof document>"u"||(yt=!0,bt("gengage:global:error",e=>{wa(e)}))}function wa(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;Sa();const n=Ca();n.innerHTML="";const a=document.createElement("section");a.className="gengage-global-toast gengage-global-toast--error",a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="gengage-global-toast-title",i.textContent=ka(e.source);const o=document.createElement("div");o.className="gengage-global-toast-message",o.textContent=t,a.appendChild(i),a.appendChild(o),n.appendChild(a),n.classList.add(Ge),_e&&(clearTimeout(_e),_e=null),_e=setTimeout(()=>{xa()},Ea(e.durationMs))}function xa(){if(typeof document>"u")return;const e=document.getElementById(de);e&&(e.classList.remove(Ge),e.innerHTML="",_e&&(clearTimeout(_e),_e=null))}function ka(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function Ca(){const e=document.getElementById(de);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=de,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Ea(e){return typeof e!="number"||!Number.isFinite(e)?ba:Math.min(va,Math.max(_a,Math.round(e)))}function Sa(){if(document.getElementById(vt))return;const e=document.createElement("style");e.id=vt,e.textContent=`
2
+ #${de} {
3
3
  position: fixed;
4
4
  top: 16px;
5
5
  right: 16px;
6
6
  z-index: 2147483646;
7
7
  pointer-events: none;
8
8
  }
9
- #${se}.${Ge} {
9
+ #${de}.${Ge} {
10
10
  pointer-events: auto;
11
11
  }
12
- #${se} .gengage-global-toast {
12
+ #${de} .gengage-global-toast {
13
13
  min-width: 260px;
14
14
  max-width: min(92vw, 420px);
15
15
  border-radius: 12px;
@@ -24,12 +24,12 @@
24
24
  line-height: 1.4;
25
25
  animation: gengage-global-toast-in 180ms ease-out forwards;
26
26
  }
27
- #${se} .gengage-global-toast-title {
27
+ #${de} .gengage-global-toast-title {
28
28
  margin: 0 0 4px;
29
29
  font-size: 12px;
30
30
  font-weight: 700;
31
31
  }
32
- #${se} .gengage-global-toast-message {
32
+ #${de} .gengage-global-toast-message {
33
33
  margin: 0;
34
34
  font-weight: 500;
35
35
  }
@@ -43,8 +43,8 @@
43
43
  transform: translateY(0);
44
44
  }
45
45
  }
46
- `,document.head.appendChild(e)}class Ca{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=ua(t.theme);this.config={...t,theme:n,session:pa(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ba();const a=bt("gengage:context:update",o=>this.update(o));this._cleanups.push(a);try{await this.onInit(this.config)}catch(o){throw this.destroy(),o}this.isInitialised=!0,this.emit("ready")}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const a=t==="start"?la:da;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(sa(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(a=>a(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,a]of Object.entries(t))if(a!==void 0){const o=n.startsWith("--")?n:`--gengage-${Ea(n)}`;this.root.style.setProperty(o,a)}}}}function Ea(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Sa(){const e=Date.now(),t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/2**40&255,t[1]=e/2**32&255,t[2]=e/2**24&255,t[3]=e/2**16&255,t[4]=e/2**8&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class Ta{constructor(t){this._handlers=new Map,this._destroyed=!1,this._namespace=t.namespace,this._allowedOrigins=t.allowedOrigins??["*"],this._onMessage=t.onMessage,this._allowedOrigins.includes("*"),this._messageListener=n=>this._handlePostMessage(n),window.addEventListener("message",this._messageListener)}send(t,n){if(this._destroyed)return;const a={namespace:this._namespace,type:t};n!==void 0&&(a.payload=n),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(t,n){this._handlers.has(t)||this._handlers.set(t,new Set);const a=this._handlers.get(t);return a.add(n),()=>{a.delete(n),a.size===0&&this._handlers.delete(t)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(t){if(this._destroyed||!this._isOriginAllowed(t.origin))return;const n=t.data;if(!Ia(n)||n.gengage!==this._namespace)return;const a={type:n.type};n.payload!==void 0&&(a.payload=n.payload),this._onMessage?.(a);const o=this._handlers.get(a.type);if(o)for(const i of o)i(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}function Ia(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const za=console;function Aa(e,t,n={}){const a=e.action,o=n.logger??za;switch(a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){ye(a,t,n,o);return}const i=typeof a.newTab=="boolean"?a.newTab:void 0;if(t.navigate){i!==void 0?t.navigate({url:a.url,newTab:i}):t.navigate({url:a.url});return}Na(a.url,i);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){ye(a,t,n,o);return}t.saveSession?.({sessionId:a.sessionId,sku:a.sku});return}case"add_to_cart":{if(typeof a.sku!="string"||typeof a.quantity!="number"||typeof a.cartCode!="string"){ye(a,t,n,o);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){ye(a,t,n,o);return}if(typeof a.name!="string"){ye(a,t,n,o);return}const i=Pa(a.payload)?a.payload:void 0;i!==void 0?t.scriptCall?.({name:a.name,payload:i}):t.scriptCall?.({name:a.name});return}default:ye(a,t,n,o)}}function ye(e,t,n,a){const o=n.unknownActionPolicy??"log-and-ignore";if(o==="delegate"){t.unknown?.(e),t.unknown||a.warn("[gengage] Unknown action received without delegate handler",e);return}if(o==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);a.warn("[gengage] Unknown action ignored",e)}function Na(e,t){if(!(typeof window>"u")){if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function Pa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const La=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),Ma=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta"]),wt={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function $a(e){return/^\s*javascript\s*:/i.test(e)}function We(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,a=n.tagName.toLowerCase();if(Ma.has(a)){n.parentNode?.removeChild(n);return}if(!La.has(a)){const c=Array.from(n.childNodes);for(const l of c)t.insertBefore(l,n);t.removeChild(n);for(const l of c)We(l,t);return}const o=wt["*"]??new Set,i=wt[a]??new Set,r=Array.from(n.attributes);for(const c of r){const l=c.name.toLowerCase();if(!o.has(l)&&!i.has(l)){n.removeAttribute(c.name);continue}if($a(c.value)){n.removeAttribute(c.name);continue}}if(a==="a"){const c=n.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(a==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const s=Array.from(n.childNodes);for(const c of s)We(c,n)}const xt=["http:","https:"];function re(e){try{return xt.includes(new URL(e).protocol)}catch{return!1}}function oe(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return xt.includes(t.protocol)}catch{return!1}}function H(e,t,n){(t==="href"||t==="src")&&!oe(n)||e.setAttribute(t,n)}function we(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const o of a)We(o,n);return n.innerHTML}const Oa=["image/jpeg","image/png","image/webp"],Da=5*1024*1024;function Ba(e){return Oa.includes(e.type)?e.size>Da?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function kt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Ra(e){const t=[];let n=0,a=!1,o=!1,i=0;for(let r=0;r<e.length;r++){const s=e[r];if(o){o=!1;continue}if(s==="\\"&&a){o=!0;continue}if(s==='"'){a=!a;continue}a||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(i,r+1)),i=r+1)))}return t.length>0?t:[e]}function Ct(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const a=n.startsWith("data: ")?n.slice(6):n;if(a==="[DONE]")return!0;try{const o=JSON.parse(a);return kt(o)?(t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Ra(a);if(o.length>1){for(const i of o)try{const r=JSON.parse(i);if(!kt(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Za(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),a=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,r=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let l;const d=await(i>0?Promise.race([c.then(f=>(clearTimeout(l),f)),new Promise(f=>{l=setTimeout(()=>f(r),i)})]):c);if(d===r){s=!0,await n.cancel();break}const{done:g,value:u}=d;if(g)break;o+=a.decode(u,{stream:!0});const p=o.split(`
47
- `);o=p.pop()??"";for(const f of p)if(Ct(f,t))return}if(o.trim()&&Ct(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}function Ua(e){if(typeof e.type!="string")return null;if(ja(e))return e;const n=e;switch(n.type){case"outputText":return Fa(n);case"suggestedActions":return qa(n);case"productList":return Ha(n);case"productDetails":return Va(n);case"productDetailsSimilars":return Ga(n);case"comparisonTable":return Wa(n);case"context":return Ka(n);case"chatStreamEnd":return Ja();case"loading":return Ya(n);case"panelLoading":return Xa(n);case"similarLoading":return Qa(n);case"redirect":return eo(n);case"error":return to(n);case"dummy":return no();case"launcherAction":return ao(n);case"text":return Ke(n);case"productItem":return oo(n);case"text_image":return Et(n);case"quick_qna":return St(n);case"reviewHighlights":return io(n);case"aiProductSuggestions":return co(n);case"aiProductGroupings":return lo(n);case"aiSuggestedSearches":return go(n);case"prosAndCons":return ro(n);case"getGroundingReview":return po(n);case"voice":return ho(n);case"visitorDataResponse":return so(n);case"productListPreview":return uo();case"groupList":return fo(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return mo(n);case"launcherContent":return _o(n);case"handoff":return bo(n);default:return null}}function ja(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const a=be(e.spec);return a?typeof a.root=="string"&&be(a.elements)!==null:!1}case"action":{const n=be(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Fa(e){const t=O(e.payload.text,e.payload.plain_text)??"",n=O(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const a={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(a.productMentions=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.sku=="string"&&typeof s.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(a.skuToProductItem=i);const r=e.payload.conversation_mode;return typeof r=="string"&&r&&(a.conversationMode=r),a}function qa(e){const t=(e.payload.actions??[]).map(n=>{const a=O(n.title)??"",o=ce(n.requestDetails,a),i=o?{label:a,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Tt(t.filter(zt),"chat")}function Ha(e){const t=It(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list})),t}function Va(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:xe(t)}}}},panelHint:"panel"}:yo("chat")}function Ga(e){const t=It(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Wa(e){const t=e.payload.multiple_product_details??[],n=e.payload.product_comparison_framework,a=e.payload.table,o=[];for(const f of t){const v=xe(f);o.push(v)}const i=[];if(a){const f=n?.criteria_view??n?.criteria_view_short??{},v=n?.compared_field_names??Object.keys(a);for(const y of v){const I=a[y];if(!I||!Array.isArray(I))continue;const z=f[y]??y;i.push({label:z,values:I.map(b=>typeof b=="string"?b:String(b??""))})}}let r;n?.recommended_choice_sku?r=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(r=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const s=r?o.find(f=>f.sku===r)??o[0]:o[0],c=[];if(Array.isArray(n?.key_differences))for(const f of n.key_differences)typeof f=="string"&&c.push(f);const l=[];if(n?.special_considerations)for(const f of n.special_considerations)typeof f=="string"&&l.push(f);const d=n?.recommended_choice,g=n?.winner_hits,u={};for(const f of o){const v=f.sku;v&&(u[v]={title:f.name??v,type:"launchSingleProduct",payload:{sku:v}})}const p={products:o,attributes:i,highlights:c,productActions:u};return s&&(p.recommended=s),l.length>0&&(p.specialCases=l),d&&(p.recommendedText=d),g&&(p.winnerHits=g),typeof n?.key_differences=="string"&&(p.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(p.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:p}}},panelHint:"panel"}}function Ka(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Ja(){return{type:"done"}}function Ya(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function Xa(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Qa(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function eo(e){const t=O(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:O(e.payload.to)}}}function to(e){return{type:"error",code:"BACKEND_ERROR",message:O(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function no(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function ao(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const i={action_list:t.action_list},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(i.type=r),s!==void 0&&(i.theme=s),St({payload:i})}const a=be(t.action);if(a){const i={action:a},r=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(i.text=r),s!==void 0&&(i.image_url=s),c!==void 0&&(i.theme=c),Et({payload:i})}const o=typeof t.text=="string"?t.text:"";if(o){const i={text:o},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,c=be(t.payload)??void 0;return r!==void 0&&(i.type=r),c!==void 0&&(i.payload=c),s!==void 0&&(i.theme=s),Ke({payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Ke(e){const t={text:O(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function oo(e){return vo(e.payload,"qna")}function Et(e){const t=O(e.payload.text)??"",n=ce(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const a={text:t};return typeof e.payload.theme=="string"&&(a.theme=e.payload.theme),Ke({payload:a})}function St(e){const t=(e.payload.action_list??[]).map(n=>{const a=O(n.title)??"",o=ce(n.requestDetails,a),i=o?{label:a,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Tt(t.filter(zt),"qna")}function io(e){const n={reviews:(e.payload.reviews??[]).map(a=>{const o={};return typeof a.review_class=="string"&&(o.review_class=a.review_class),typeof a.review_text=="string"&&(o.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(o.review_rating=a.review_rating),typeof a.review_tag=="string"&&(o.review_tag=a.review_tag),o})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function ro(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function so(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function co(e){const t=e.payload.product_suggestions??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=wo(o);if(!i)continue;const r={product:i},s=ce(o.requestDetails,i.name);s&&(r.action=s),typeof o.role=="string"&&(r.role=o.role),typeof o.reason=="string"&&(r.reason=o.reason),typeof o.review_highlight=="string"&&(r.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(r.labels=o.labels),typeof o.expert_quality_score=="number"&&(r.expertQualityScore=o.expert_quality_score),n.push(r)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function lo(e){const t=e.payload.product_groupings??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=O(o.name)??"",r=o.sku&&o.sku.length>0?{type:"findSimilar",payload:{sku:o.sku}}:void 0,s=ce(o.requestDetails??r,i);if(!s)continue;const c={name:i,action:s};if(Array.isArray(o.labels)){const l=o.labels.filter(d=>typeof d=="string");l.length>0&&(c.labels=l)}typeof o.image=="string"&&(c.image=o.image),n.push(c)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function go(e){const t=e.payload.suggested_searches??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=O(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Arama ${a+1}`,r={},s=O(o.detailed_user_message);s&&(r.text=s),o.group_skus&&Array.isArray(o.group_skus)&&(r.group_skus=o.group_skus);const c=O(o.sku,o.representative_product_sku);c&&(r.sku=c),r.is_suggested_text=1;const l={type:"inputText",payload:r},d=ce(o.requestDetails??l,i);if(!d)continue;const g={shortName:i,action:d},u=O(o.detailed_user_message);u&&u!==i&&(g.detailedMessage=u);const p=O(o.why_different);p&&(g.whyDifferent=p),typeof o.image=="string"&&(g.image=o.image),n.push(g)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function po(e){const t=ce(e.payload.requestDetails,O(e.payload.review_count,e.payload.text,e.payload.title)??"Urun yorumlarini goster");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function uo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function ho(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function fo(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",r=(o.product_list??[]).map(xe);n.push({groupName:i,products:r})}const a=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const r=ce(o.requestDetails,i),s={title:i};r&&(s.action=r),a.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:a}}}},panelHint:"panel"}}function mo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function bo(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function _o(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Tt(e,t){const n={},a=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const r=`action-${o}`;a.push(r);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),n[r]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function It(e,t){const n={},a=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const r=`product-${o}`;a.push(r),n[r]={type:"ProductCard",props:{product:xe(i),index:o}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function vo(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:xe(e),index:0}}}}}}function yo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function wo(e){const t=O(e.sku),n=O(e.short_name),a=be(e.product_item)??e;return xo(a,t,n)}function xo(e,t,n){const a=O(e.sku,t),o=O(e.name,n);if(!a||!o)return null;const i={sku:a,name:o},r=O(e.brand);r&&(i.brand=r);const s=O(e.url);s&&(i.url=s);const c=ko(e.images);if(c.length>0)i.images=c;else{const f=O(e.image,e.image_url,e.imageUrl);f&&(i.images=[f])}const l=ze(e.price_discounted);l!==void 0&&(i.price_discounted=l);const d=ze(e.price);d!==void 0&&(i.price=d);const g=ze(e.rating);g!==void 0&&(i.rating=g);const u=ze(e.review_count)??ze(e.reviewCount);u!==void 0&&(i.review_count=u);const p=O(e.cart_code,e.cartCode);return p&&(i.cart_code=p),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock),xe(i)}function ce(e,t){const n=be(e);if(!n)return null;const a=n.type;if(typeof a!="string"||a.length===0)return null;const o={title:t||a,type:a};return n.payload!==void 0&&(o.payload=n.payload),o}function be(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function O(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function ko(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ze(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function zt(e){return e!=null}function xe(e){const t=e.price_discounted!=null&&e.price_discounted>0?e.price_discounted:e.price,n=e.price_discounted!=null&&e.price_discounted>0&&e.price!=null?e.price:void 0;let a;n!=null&&t!=null&&n>0&&(a=Math.round((n-t)/n*100));const o=O(e.brand),i=O(e.name)??e.sku,r=o&&!i.toLowerCase().startsWith(o.toLowerCase())?`${o} ${i}`:i,s={sku:e.sku,name:r,url:O(e.url)??""},c=e.images?.[0];return c&&(s.imageUrl=c),e.images&&e.images.length>1&&(s.images=e.images),t!=null&&(s.price=String(t)),n!=null&&(s.originalPrice=String(n)),a!==void 0&&(s.discountPercent=a),o!==void 0&&(s.brand=o),e.rating!==void 0&&(s.rating=e.rating),e.review_count!==void 0&&(s.reviewCount=e.review_count),e.cart_code!==void 0&&(s.cartCode=e.cart_code),e.in_stock!==void 0&&(s.inStock=e.in_stock),e.variants&&e.variants.length>0&&(s.variants=e.variants),e.discount_reason!==void 0&&(s.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(s.promotions=e.promotions),s}const Co={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"},Eo={process_action:"/message",launcher_action:"/message"};function At(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function Nt(e,t){const n=At(t?.middlewareUrl);if(t.backendType==="acap"){const a=t.accountId??"",o=Eo[e];if(o)return`${n}/api/chat/${a}${o}`}return`${n}/chat${Co[e]}`}function So(e,t){const n=e.type,a=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},o=i=>{const r={...a};for(const[s,c]of Object.entries(i))s in r||(r[s]=c);return r};switch(n){case"inputText":{const i={is_launcher:0};return t.pageContext?.extra&&(i.page_details=t.pageContext.extra),"is_suggested_text"in a||(i.is_suggested_text=0),{...e,payload:o(i)}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title),e.title&&(i.input=e.title),{...e,payload:o(i)}}case"getComparisonTable":return e;case"addToCart":{const i={};return"error_message"in a||(i.error_message=""),{...e,payload:o(i)}}case"reviewSummary":{const i={};return t.pageContext?.sku&&!("sku"in a)&&(i.sku=t.pageContext.sku),Object.keys(i).length===0?e:{...e,payload:o(i)}}default:return e}}const To={user_message:"inputText"};function Io(e){const{action:t,type:n,payload:a,...o}=e,i=n??t?.type??"inputText",r=a??t?.payload,s=To[i]??i,c={...o,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function zo(e){const t=e.type??e.action?.type??"inputText",n=e.payload??e.action?.payload;let a=e.action?.title??"";(t==="inputText"||t==="user_message")&&(typeof n=="string"?a=n:n&&typeof n=="object"&&"text"in n&&(a=String(n.text)));const o={message:a,session_id:e.session_id};if(e.user_id&&(o.user_id=e.user_id),e.locale&&(o.output_language=e.locale),e.meta?.outputLanguage&&(o.output_language=e.meta.outputLanguage),e.sku||e.page_type){const i={};e.page_type&&(i.screen_type=e.page_type),e.sku&&(i.sku_list=[e.sku]),o.screen_context=i}return t!=="inputText"&&t!=="user_message"&&(o.action_type=t,n!==void 0&&(o.action_payload=typeof n=="string"?{text:n}:n)),JSON.stringify(o)}function Ao(e,t,n){const a=Nt("process_action",n),o=new AbortController;return(async()=>{try{const r=n.backendType==="acap"?zo(e):Io(e),s=n.attachment!==void 0;let c;if(s){const u=new FormData;u.append("request",r),n.attachment!==void 0&&u.append("attachment",n.attachment),c={method:"POST",body:u,signal:o.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:r,signal:o.signal};const l=await fetch(a,c);if(!l.ok){let u=l.statusText;try{const p=await l.json(),f=p.detail??p.message??p.error;typeof f=="string"&&(u=f)}catch{}t.onError(new Error(`HTTP ${l.status}: ${u}`));return}let d=!1;const g=()=>{d||(d=!0,t.onDone())};await Za(l,{onEvent:u=>{const p=Ua(u);if(p)switch(p.type){case"text_chunk":t.onTextChunk(p.content,p.final===!0,{productMentions:p.productMentions,skuToProductItem:p.skuToProductItem,conversationMode:p.conversationMode});break;case"ui_spec":t.onUISpec(p.spec,p.widget,p.panelHint);break;case"action":t.onAction(p);break;case"metadata":t.onMetadata(p);break;case"error":t.onError(new Error(p.message));break;case"done":g();break}},onError:t.onError,signal:o.signal}),g()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;t.onError(r instanceof Error?r:new Error(String(r)))}})(),o}async function No(e,t){const n=Nt("proactive_action",t);try{const a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return a.ok?await a.json():null}catch{return null}}const Je={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Powered by Gengage",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"Düşünüyorum...",productCtaLabel:"İncele",attachImageButton:"Resim ekle",removeAttachmentButton:"Resmi kaldır",invalidFileType:"Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",fileTooLarge:"Dosya boyutu 5 MB'dan küçük olmalıdır.",aiTopPicksTitle:"Sizin İçin En İyiler",roleWinner:"En Beğendiğim",roleBestValue:"En Uygun Fiyatlı",roleBestAlternative:"En İyi Alternatif",viewDetails:"Detayları Gör",groundingReviewCta:"Yorumları Oku",groundingReviewSubtitle:"{count} yorum mevcut",variantsLabel:"Varyantlar",sortRelated:"Önerilen",sortPriceAsc:"Fiyat ↑",sortPriceDesc:"Fiyat ↓",compareSelected:"Karşılaştır",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",choicePrompterHeading:"Kararsız mı kaldın?",choicePrompterSuggestion:"Ürünleri seçip karşılaştırabilirsin",choicePrompterCta:"Seç ve Karşılaştır",viewMoreLabel:"Daha Fazla Göster",similarProductsLabel:"Benzer Ürünler",addToCartButton:"Sepete Ekle",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor"},Po={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",sendButton:"Send",closeButton:"Close",openButton:"Open chat",newChatButton:"New chat",poweredBy:"Powered by Gengage",errorMessage:"Something went wrong. Please try again.",retryButton:"Retry",loadingMessage:"Thinking...",productCtaLabel:"View",attachImageButton:"Attach image",removeAttachmentButton:"Remove image",invalidFileType:"Only JPEG, PNG and WebP files are supported.",fileTooLarge:"File must be smaller than 5 MB.",aiTopPicksTitle:"Top Picks for You",roleWinner:"Top Pick",roleBestValue:"Best Value",roleBestAlternative:"Best Alternative",viewDetails:"View Details",groundingReviewCta:"Read Reviews",groundingReviewSubtitle:"{count} reviews available",variantsLabel:"Variants",sortRelated:"Related",sortPriceAsc:"Price ↑",sortPriceDesc:"Price ↓",compareSelected:"Compare",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent"};function Lo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Mo(e){return Lo(e)==="en"?Po:Je}function $o(){return Pt()!==null}function Pt(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class Oo{constructor(t,n){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this.callbacks=t,this.lang=n?.lang??"tr-TR",this.silenceTimeoutMs=n?.silenceTimeoutMs??1500,this.autoSubmit=n?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=Pt();if(!t){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const n=new t;n.continuous=!0,n.interimResults=!0,n.lang=this.lang,n.maxAlternatives=1,n.onstart=()=>{this.setState("listening")},n.onresult=a=>{this.clearSilenceTimer();let o="",i="";for(let r=a.resultIndex;r<a.results.length;r++){const s=a.results[r];if(!s)continue;const c=s[0];c&&(s.isFinal?i+=c.transcript:o+=c.transcript)}i&&(this.accumulatedTranscript+=i,this.callbacks.onFinal?.(this.accumulatedTranscript)),o&&this.callbacks.onInterim?.(this.accumulatedTranscript+o),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},n.onerror=a=>{const o=Do(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(o,a.message||a.error))},n.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){try{n.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=n;try{n.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}function Do(e){switch(e){case"not-allowed":return"not-allowed";case"no-speech":return"no-speech";case"audio-capture":return"no-microphone";case"network":return"network";case"aborted":return"aborted";default:return"unknown"}}function Bo(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner",t.setAttribute("role","alert");const n=document.createElement("div");n.className="gengage-chat-kvkk-content",n.innerHTML=we(e.htmlContent),t.appendChild(n);const a=document.createElement("button");return a.className="gengage-chat-kvkk-dismiss",a.type="button",a.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),a.textContent="×",a.addEventListener("click",e.onDismiss),t.appendChild(a),t}class Ro{constructor(t){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label","Back"),this._backBtn.textContent="←",this._backBtn.addEventListener("click",()=>t.onBack()),this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label","Forward"),this._forwardBtn.textContent="→",this._forwardBtn.addEventListener("click",()=>t.onForward()),this._el.appendChild(this._backBtn),this._el.appendChild(this._titleEl),this._el.appendChild(this._forwardBtn)}update(t,n,a){this._backBtn.disabled=!t,this._forwardBtn.disabled=!n,this._titleEl.textContent=a}getElement(){return this._el}}class Zo{constructor(t){this._onThumbnailClick=t.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(t){const n=new Set,a=[];for(const o of t)n.has(o.sku)||(n.add(o.sku),a.push(o));this._el.innerHTML="";for(const o of a){const i=document.createElement("button");if(i.type="button",i.className="gengage-chat-thumbnail-btn",i.title=o.sku,re(o.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-thumbnail-img",r.src=o.imageUrl,r.alt=o.sku,r.width=40,r.height=40,i.appendChild(r)}i.addEventListener("click",()=>{this._onThumbnailClick(o.threadId)}),this._el.appendChild(i)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}}const Lt={search:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',review:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',info:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',similar:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'},Uo=Je;class jo{constructor(t,n){this._panelVisible=!1,this._panelCollapsed=!1,this._panelForceExpanded=!1,this._onPanelToggle=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this.i18n={...Uo,...n.i18n},this.onSend=n.onSend,n.onPanelToggle!==void 0&&(this._onPanelToggle=n.onPanelToggle),n.onAttachment!==void 0&&(this._onAttachment=n.onAttachment),n.onRollback!==void 0&&(this._onRollback=n.onRollback),n.onLinkClick!==void 0&&(this._onLinkClick=n.onLinkClick),n.voiceEnabled&&(this._voiceEnabled=!0),n.voiceLang!==void 0&&(this._voiceLang=n.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a=document.createElement("div");a.className="gengage-chat-header";const o=document.createElement("div");if(o.className="gengage-chat-header-left",n.headerAvatarUrl){const h=document.createElement("img");h.className="gengage-chat-header-avatar",h.src=n.headerAvatarUrl,h.alt=n.headerTitle??"Assistant",o.appendChild(h)}const i=document.createElement("div");i.className="gengage-chat-header-info";const r=document.createElement("div");r.className="gengage-chat-header-title-row";const s=document.createElement("span");if(s.className="gengage-chat-header-title",s.textContent=n.headerTitle??this.i18n.headerTitle??"Gengage Asistanı",r.appendChild(s),n.headerBadge){const h=document.createElement("span");h.className="gengage-chat-header-badge",h.textContent=n.headerBadge,r.appendChild(h)}i.appendChild(r);const c=document.createElement("a");c.className="gengage-chat-header-powered",c.href="https://gengage.ai/",c.target="_blank",c.rel="noopener noreferrer",c.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage',i.appendChild(c),o.appendChild(i),a.appendChild(o);const l=document.createElement("div");if(l.className="gengage-chat-header-right",n.headerCartUrl){const h=document.createElement("a");h.className="gengage-chat-header-btn",h.href=n.headerCartUrl,h.target="_blank",h.rel="noopener noreferrer",h.setAttribute("aria-label","Sepetim"),h.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>',l.appendChild(h)}if(n.headerFavoritesToggle){const h=document.createElement("button");h.className="gengage-chat-header-btn",h.type="button",h.setAttribute("aria-label","Favorilerim"),h.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>',h.addEventListener("click",()=>n.onFavoritesClick?.()),l.appendChild(h)}const d=document.createElement("button");d.className="gengage-chat-close",d.type="button",d.setAttribute("aria-label",this.i18n.closeButton),d.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',d.addEventListener("click",n.onClose),l.appendChild(d),a.appendChild(l);const g=document.createElement("div");g.className="gengage-chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel",this._panelTopBar=new Ro({onBack:()=>n.onPanelBack?.(),onForward:()=>n.onPanelForward?.()}),this._panelEl.appendChild(this._panelTopBar.getElement()),g.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label","Toggle panel");const u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label","Toggle panel"),u.textContent="»",u.addEventListener("click",()=>{this.togglePanel(),this._onPanelToggle?.()}),this._dividerEl.appendChild(u),g.appendChild(this._dividerEl);const p=document.createElement("div");p.className="gengage-chat-conversation",p.appendChild(a),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",p.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.className="gengage-chat-messages",this.messagesEl.setAttribute("role","log"),this.messagesEl.setAttribute("aria-live","polite"),this.messagesEl.setAttribute("aria-label","Chat messages");let f=!1;this.messagesEl.addEventListener("scroll",()=>{f||(f=!0,requestAnimationFrame(()=>{f=!1;const{scrollTop:h,scrollHeight:k,clientHeight:C}=this.messagesEl;this._userScrolledUp=k-h-C>10}))},{passive:!0}),p.appendChild(this.messagesEl),this._thumbnailsColumn=new Zo({onThumbnailClick:h=>n.onThumbnailClick?.(h)}),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label","Suggestions"),this._pillsEl.style.display="none";const v=document.createElement("div");v.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(v);const y=document.createElement("button");y.className="gengage-chat-pills-arrow",y.type="button",y.setAttribute("aria-label","More suggestions"),y.textContent="›",y.addEventListener("click",()=>{v.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(y);let I=!1;v.addEventListener("scroll",()=>{I||(I=!0,requestAnimationFrame(()=>{I=!1;const h=v.scrollLeft+v.clientWidth>=v.scrollWidth-4;y.style.display=h?"none":""}))},{passive:!0}),p.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",p.appendChild(this._inputChipsEl);const z=document.createElement("div");z.className="gengage-chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{requestAnimationFrame(()=>{this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`})}),this.inputEl.addEventListener("keydown",h=>{h.key==="Enter"&&(window.innerWidth<768||!h.shiftKey)&&(h.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",h=>{const k=h.clipboardData?.files[0];k&&k.type.startsWith("image/")&&(h.preventDefault(),this._onAttachment?this._onAttachment(k):this.stageAttachment(k))}),this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.accept="image/jpeg,image/png,image/webp",this._fileInput.style.display="none",this._fileInput.addEventListener("change",()=>{const h=this._fileInput.files?.[0];h&&(this._onAttachment?this._onAttachment(h):this.stageAttachment(h)),this._fileInput.value=""});const b=document.createElement("button");b.className="gengage-chat-attach-btn",b.type="button",b.setAttribute("aria-label",this.i18n.attachImageButton),b.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',b.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const _=document.createElement("img");_.className="gengage-chat-attachment-preview-thumb",_.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const w=document.createElement("button");w.className="gengage-chat-attachment-remove",w.type="button",w.setAttribute("aria-label",this.i18n.removeAttachmentButton),w.textContent="×",w.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(_),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(w),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send",this.sendBtn.type="button",this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>',this.sendBtn.addEventListener("click",()=>this._submit()),z.addEventListener("dragover",h=>{h.preventDefault(),z.classList.add("gengage-chat-input-area--dragover")}),z.addEventListener("dragleave",()=>{z.classList.remove("gengage-chat-input-area--dragover")}),z.addEventListener("drop",h=>{h.preventDefault(),z.classList.remove("gengage-chat-input-area--dragover");const k=h.dataTransfer?.files[0];k&&(this._onAttachment?this._onAttachment(k):this.stageAttachment(k))});const E=document.createElement("div");E.className="gengage-chat-input-pill",E.appendChild(b),E.appendChild(this.inputEl),this._voiceEnabled&&$o()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn",this._micBtn.type="button",this._micBtn.setAttribute("aria-label",this.i18n.voiceButton),this._micBtn.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',this._micBtn.addEventListener("click",()=>this._toggleVoice()),E.appendChild(this._micBtn),this._voiceInput=new Oo({onInterim:h=>{this.inputEl.value=h,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:h=>{this.inputEl.value=h},onAutoSubmit:h=>{this.inputEl.value=h,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:h=>{h==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(h,k)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),E.appendChild(this.sendBtn),z.appendChild(this._previewStrip),z.appendChild(this._fileInput),z.appendChild(E),p.appendChild(z),g.appendChild(p),this.root.appendChild(g);const P=document.createElement("div");P.className="gengage-chat-footer",P.textContent=this.i18n.poweredBy,this.root.appendChild(P),this.root.addEventListener("keydown",h=>{h.key==="Escape"&&n.onClose()}),this._trapFocus(),t.appendChild(this.root)}addMessage(t){const n=document.createElement("div");if(n.className=`gengage-chat-bubble gengage-chat-bubble--${t.role}`,n.dataset.messageId=t.id,t.threadId&&(n.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&n.classList.add("gengage-chat-bubble--first"),t.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const o=URL.createObjectURL(t.attachment);a.src=o,a.alt=t.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(o),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(o),{once:!0}),n.insertBefore(a,n.firstChild)}if(t.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",t.role==="assistant"){if(a.innerHTML=we(t.content),this._onLinkClick){const o=a.querySelectorAll("a[href]");for(const i of o)i.addEventListener("click",r=>{r.preventDefault();const s=i.getAttribute("href");s&&this._onLinkClick?.(s)})}}else a.textContent=t.content;n.appendChild(a)}if(t.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn",a.type="button",a.setAttribute("aria-label","Rollback to this message"),a.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',a.addEventListener("click",o=>{o.stopPropagation(),this._onRollback?.(t.id)}),n.appendChild(a)}this.messagesEl.appendChild(n),this._scrollToBottom(t.role==="user")}showTypingIndicator(t){this.removeTypingIndicator();const n=document.createElement("div");if(n.className="gengage-chat-typing",n.dataset.typing="true",this._thinkingSteps.length>0)this._renderThinkingStepsInto(n);else{const a=document.createElement("div");a.className="gengage-chat-typing-dots";for(let o=0;o<3;o++)a.appendChild(document.createElement("span"));if(n.appendChild(a),t){const o=document.createElement("span");o.className="gengage-chat-typing-sparkle",o.textContent="✨",n.appendChild(o);const i=document.createElement("span");i.className="gengage-chat-typing-text",i.textContent=t,n.appendChild(i)}}this.messagesEl.appendChild(n),this._scrollToBottom(!0)}addThinkingStep(t){this._thinkingSteps.push(t),this._renderThinkingSteps()}removeTypingIndicator(){this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[]}showError(t,n){const a=document.createElement("div");a.className="gengage-chat-error";const o=document.createElement("span");if(o.textContent=t??this.i18n.errorMessage,a.appendChild(o),n){const i=document.createElement("button");i.className="gengage-chat-error-retry",i.textContent=this.i18n.retryButton??"Retry",i.addEventListener("click",()=>{a.remove(),n()}),a.appendChild(i)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}clearMessages(){this.messagesEl.innerHTML=""}setPills(t){const n=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const o of t){const i=document.createElement("button");if(i.className=o.image?"gengage-chat-pill gengage-chat-pill--rich":"gengage-chat-pill",i.type="button",o.icon){const s=Lt[o.icon];if(s){const c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,i.appendChild(c)}}if(o.image&&re(o.image)){const s=document.createElement("img");s.className="gengage-chat-pill-img",s.src=o.image,s.alt="",i.appendChild(s)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=o.label,i.appendChild(r),o.description){const s=document.createElement("span");s.className="gengage-chat-pill-desc",s.textContent=o.description,i.appendChild(s)}i.addEventListener("click",()=>o.onAction()),n.appendChild(i)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=n.scrollWidth>n.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,n){this._kvkkSlot.innerHTML="";const a=Bo({htmlContent:t,onDismiss:n});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}getElement(){return this.root}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const n=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");n&&(n.src&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),n.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden")}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden")}getPendingAttachment(){return this._pendingAttachment}setPanelContent(t){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed")}appendPanelContent(t){this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}getPanelContentElement(){const t=this._panelEl.children;for(let n=0;n<t.length;n++){const a=t[n];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-thumbnails-column")))return a}return null}hasPanelContent(){return this._panelVisible&&this._panelEl.childElementCount>2}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement());const n=document.createElement("div");switch(n.className="gengage-chat-panel-skeleton",t){case"productDetails":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",n.appendChild(a);for(let o=0;o<3;o++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",n.appendChild(i)}break}case"productList":case"groupList":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-grid";for(let o=0;o<6;o++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",a.appendChild(i)}n.appendChild(a);break}case"comparisonTable":{for(let a=0;a<4;a++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row",n.appendChild(o)}break}default:{for(let a=0;a<3;a++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",n.appendChild(o)}break}}this._panelEl.appendChild(n),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}updatePanelTopBar(t,n,a){this._panelTopBar.update(t,n,a)}clearPanel(){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelVisible=!1,this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}setForceExpanded(){this._panelForceExpanded=!0,this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}togglePanel(){this._panelForceExpanded||this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){if(this._panelForceExpanded)return;this._panelCollapsed=t,t?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const n=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");n&&(n.textContent=t?"«":"»")}persistPanelState(t){try{const n=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(n,"collapsed"):sessionStorage.removeItem(n)}catch{}}restorePanelState(t){try{const n=`gengage:panel:${t}`;sessionStorage.getItem(n)==="collapsed"&&(this._panelCollapsed=!0)}catch{}}_renderThinkingSteps(){const t=this.messagesEl.querySelector('[data-typing="true"]');if(!t){this.showTypingIndicator();return}t.innerHTML="",this._renderThinkingStepsInto(t),this._scrollToBottom(!1)}_renderThinkingStepsInto(t){const n=document.createElement("div");n.className="gengage-chat-thinking-steps";for(let a=0;a<this._thinkingSteps.length;a++){const o=document.createElement("div");o.className="gengage-chat-thinking-step";const i=document.createElement("span");i.className="gengage-chat-thinking-step-marker",a<this._thinkingSteps.length-1?(i.textContent="✓",i.classList.add("gengage-chat-thinking-step-marker--done")):(i.textContent="●",i.classList.add("gengage-chat-thinking-step-marker--active")),o.appendChild(i);const r=document.createElement("span");r.className="gengage-chat-thinking-step-text",r.textContent=this._thinkingSteps[a],o.appendChild(r),n.appendChild(o)}t.appendChild(n)}_trapFocus(){this.root.addEventListener("keydown",t=>{if(t.key!=="Tab")return;const n=this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(n.length===0)return;const a=n[0],o=n[n.length-1];if(!a||!o)return;const r=this.root.getRootNode().activeElement??document.activeElement;t.shiftKey?r===a&&(t.preventDefault(),o.focus()):r===o&&(t.preventDefault(),a.focus())})}_submit(){const t=this.inputEl.value.trim(),n=this._pendingAttachment;!t&&!n||(this.onSend(t,n??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment())}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const n=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);n&&n.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const n=t[t.length-1].getAttribute("data-thread-id");if(!n){this._scrollToBottom(!0);return}const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(n)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const n of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip",a.type="button",n.icon){const i=Lt[n.icon];if(i){const r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=i,a.appendChild(r)}}const o=document.createElement("span");o.textContent=n.label,a.appendChild(o),a.addEventListener("click",()=>n.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(t){this._thumbnailsColumn.setEntries(t),t.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide()}hideThumbnails(){this._thumbnailsColumn.hide()}}const Fo=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
46
+ `,document.head.appendChild(e)}class Ta{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=ma(t.theme);this.config={...t,theme:n,session:fa(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ya();const a=bt("gengage:context:update",i=>this.update(i));this._cleanups.push(a);try{await this.onInit(this.config)}catch(i){throw this.destroy(),i}this.isInitialised=!0,this.emit("ready")}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const a=t==="start"?pa:ua;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(da(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(a=>a(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,a]of Object.entries(t))if(a!==void 0){const i=n.startsWith("--")?n:`--gengage-${Ia(n)}`;this.root.style.setProperty(i,a)}}}}function Ia(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function za(){const e=Date.now(),t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/2**40&255,t[1]=e/2**32&255,t[2]=e/2**24&255,t[3]=e/2**16&255,t[4]=e/2**8&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class Pa{constructor(t){this._handlers=new Map,this._destroyed=!1,this._namespace=t.namespace,this._allowedOrigins=t.allowedOrigins??["*"],this._onMessage=t.onMessage,this._allowedOrigins.includes("*"),this._messageListener=n=>this._handlePostMessage(n),window.addEventListener("message",this._messageListener)}send(t,n){if(this._destroyed)return;const a={namespace:this._namespace,type:t};n!==void 0&&(a.payload=n),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(t,n){this._handlers.has(t)||this._handlers.set(t,new Set);const a=this._handlers.get(t);return a.add(n),()=>{a.delete(n),a.size===0&&this._handlers.delete(t)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(t){if(this._destroyed||!this._isOriginAllowed(t.origin))return;const n=t.data;if(!Aa(n)||n.gengage!==this._namespace)return;const a={type:n.type};n.payload!==void 0&&(a.payload=n.payload),this._onMessage?.(a);const i=this._handlers.get(a.type);if(i)for(const o of i)o(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}function Aa(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const Na=console;function La(e,t,n={}){const a=e.action,i=n.logger??Na;switch(a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){we(a,t,n,i);return}const o=typeof a.newTab=="boolean"?a.newTab:void 0;if(t.navigate){o!==void 0?t.navigate({url:a.url,newTab:o}):t.navigate({url:a.url});return}Ma(a.url,o);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){we(a,t,n,i);return}t.saveSession?.({sessionId:a.sessionId,sku:a.sku});return}case"add_to_cart":{if(typeof a.sku!="string"||typeof a.quantity!="number"||typeof a.cartCode!="string"){we(a,t,n,i);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){we(a,t,n,i);return}if(typeof a.name!="string"){we(a,t,n,i);return}const o=$a(a.payload)?a.payload:void 0;o!==void 0?t.scriptCall?.({name:a.name,payload:o}):t.scriptCall?.({name:a.name});return}default:we(a,t,n,i)}}function we(e,t,n,a){const i=n.unknownActionPolicy??"log-and-ignore";if(i==="delegate"){t.unknown?.(e),t.unknown||a.warn("[gengage] Unknown action received without delegate handler",e);return}if(i==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);a.warn("[gengage] Unknown action ignored",e)}function Ma(e,t){if(!(typeof window>"u")){if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function $a(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Oa=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),Ba=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta"]),wt={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function Da(e){return/^\s*javascript\s*:/i.test(e)}function We(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,a=n.tagName.toLowerCase();if(Ba.has(a)){n.parentNode?.removeChild(n);return}if(!Oa.has(a)){const c=Array.from(n.childNodes);for(const l of c)t.insertBefore(l,n);t.removeChild(n);for(const l of c)We(l,t);return}const i=wt["*"]??new Set,o=wt[a]??new Set,r=Array.from(n.attributes);for(const c of r){const l=c.name.toLowerCase();if(!i.has(l)&&!o.has(l)){n.removeAttribute(c.name);continue}if(Da(c.value)){n.removeAttribute(c.name);continue}}if(a==="a"){const c=n.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(a==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const s=Array.from(n.childNodes);for(const c of s)We(c,n)}const xt=["http:","https:"];function ce(e){try{return xt.includes(new URL(e).protocol)}catch{return!1}}function ie(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return xt.includes(t.protocol)}catch{return!1}}function V(e,t,n){(t==="href"||t==="src")&&!ie(n)||e.setAttribute(t,n)}function oe(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const i of a)We(i,n);return n.innerHTML}const Ra=["image/jpeg","image/png","image/webp"],Ua=5*1024*1024;function Za(e){return Ra.includes(e.type)?e.size>Ua?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function kt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function ja(e){const t=[];let n=0,a=!1,i=!1,o=0;for(let r=0;r<e.length;r++){const s=e[r];if(i){i=!1;continue}if(s==="\\"&&a){i=!0;continue}if(s==='"'){a=!a;continue}a||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(o,r+1)),o=r+1)))}return t.length>0?t:[e]}function Ct(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const a=n.startsWith("data: ")?n.slice(6):n;if(a==="[DONE]")return!0;try{const i=JSON.parse(a);return kt(i)?(t.onEvent(i),i.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const i=ja(a);if(i.length>1){for(const o of i)try{const r=JSON.parse(o);if(!kt(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Fa(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),a=new TextDecoder("utf-8");let i="";const o=t.idleTimeoutMs??6e4,r=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let l;const d=await(o>0?Promise.race([c.then(h=>(clearTimeout(l),h)),new Promise(h=>{l=setTimeout(()=>h(r),o)})]):c);if(d===r){s=!0,await n.cancel();break}const{done:u,value:g}=d;if(u)break;i+=a.decode(g,{stream:!0});const p=i.split(`
47
+ `);i=p.pop()??"";for(const h of p)if(Ct(h,t))return}if(i.trim()&&Ct(i,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}function qa(e){if(typeof e.type!="string")return null;if(Ha(e))return e;const n=e;switch(n.type){case"outputText":return Va(n);case"suggestedActions":return Ga(n);case"productList":return Wa(n);case"productDetails":return Ka(n);case"productDetailsSimilars":return Ja(n);case"comparisonTable":return Ya(n);case"context":return ti(n);case"chatStreamEnd":return ni();case"loading":return ai(n);case"panelLoading":return ii(n);case"similarLoading":return oi(n);case"redirect":return ri(n);case"error":return si(n);case"dummy":return ci();case"launcherAction":return li(n);case"text":return Ke(n);case"productItem":return di(n);case"text_image":return Et(n);case"quick_qna":return St(n);case"reviewHighlights":return gi(n);case"aiProductSuggestions":return hi(n);case"aiProductGroupings":return fi(n);case"aiSuggestedSearches":return mi(n);case"prosAndCons":return pi(n);case"getGroundingReview":return bi(n);case"voice":return vi(n);case"visitorDataResponse":return ui(n);case"productListPreview":return _i();case"groupList":return yi(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return wi(n);case"launcherContent":return ki(n);case"handoff":return xi(n);default:return null}}function Ha(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const a=le(e.spec);return a?typeof a.root=="string"&&le(a.elements)!==null:!1}case"action":{const n=le(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Va(e){const t=R(e.payload.text,e.payload.plain_text)??"",n=R(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const a={type:"text_chunk",content:t,final:!0},i=e.payload.product_mentions;Array.isArray(i)&&i.length>0&&(a.productMentions=i.filter(s=>typeof s=="object"&&s!==null&&typeof s.sku=="string"&&typeof s.short_name=="string"));const o=e.payload.sku_to_product_item;o&&typeof o=="object"&&!Array.isArray(o)&&(a.skuToProductItem=o);const r=e.payload.conversation_mode;return typeof r=="string"&&r&&(a.conversationMode=r),a}function Ga(e){const t=(e.payload.actions??[]).map(n=>{const a=R(n.title)??"",i=re(n.requestDetails,a),o=i?{label:a,action:i}:null;return o?(typeof n.icon=="string"&&(o.icon=n.icon),typeof n.image=="string"&&(o.image=n.image),o):null});return Tt(t.filter(zt),"chat")}function Wa(e){const t=It(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list}),typeof e.payload.title=="string"&&(n.props={...n.props,panelTitle:e.payload.title})),t}function Ka(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:xe(t)}}}},panelHint:"panel"}:Ei("chat")}function Ja(e){const t=It(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Ya(e){const t=e.payload.multiple_product_details??[],n=e.payload,a={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},i=e.payload.table,o=e.payload.features_list,r=[];for(const v of t){const E=xe(v);r.push(E)}const s=Xa(i,r,a,o);let c;a?.recommended_choice_sku?c=a.recommended_choice_sku:a?.winner_product&&a.winner_product.length>0&&(c=a.winner_product[0]?.product_detail?.sku??a.winner_product[0]?.sku);const l=c?r.find(v=>v.sku===c)??r[0]:r[0],d=[];if(Array.isArray(a?.key_differences))for(const v of a.key_differences)typeof v=="string"&&d.push(v);const u=zi(a?.special_considerations),g=a?.recommended_choice,p=a?.winner_hits,h={};for(const v of r){const E=v.sku;E&&(h[E]={title:v.name??E,type:"launchSingleProduct",payload:{sku:E}})}const _={products:r,attributes:s,highlights:d,productActions:h};return l&&(_.recommended=l),u.length>0&&(_.specialCases=u),g&&(_.recommendedText=g),p&&(_.winnerHits=p),typeof a?.key_differences=="string"&&(_.keyDifferencesHtml=a.key_differences),a?.special_considerations&&(_.specialConsiderations=a.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:_}}},panelHint:"panel"}}function Xa(e,t,n,a){if(!e)return[];const i=Object.entries(e);if(i.length===0)return[];const o=i[0]?.[1];if(Array.isArray(o)){const g=n.criteria_view??n.criteria_view_short??{},p=n.compared_field_names??Object.keys(e),h=[];for(const _ of p){const v=e[_];if(!v||!Array.isArray(v))continue;const E=g[_]??_;h.push({label:E,values:v.map(I=>typeof I=="string"?I:String(I??""))})}return h}const r=e,s=t.map(g=>String(g.sku??"")).filter(g=>g.length>0),c=n.criteria_view??n.criteria_view_short??{},d=(a&&a.length>0?a:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Qa(r)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),u=[];for(const g of d){const p=s.map(_=>{const v=r[_];if(!v||typeof v!="object")return"";const E=v[`${g}_short`],I=v[g];return ei(E??I)});if(p.every(_=>_.length===0))continue;const h=c[g]??g;u.push({label:h,values:p})}return u}function Qa(e){const t=[],n=new Set;for(const a of Object.values(e))if(!(!a||typeof a!="object"))for(const i of Object.keys(a))n.has(i)||(n.add(i),t.push(i));return t}function ei(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function ti(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function ni(){return{type:"done"}}function ai(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function ii(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function oi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function ri(e){const t=R(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:R(e.payload.to)}}}function si(e){return{type:"error",code:"BACKEND_ERROR",message:R(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function ci(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function li(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(o.type=r),s!==void 0&&(o.theme=s),St({payload:o})}const a=le(t.action);if(a){const o={action:a},r=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(o.text=r),s!==void 0&&(o.image_url=s),c!==void 0&&(o.theme=c),Et({payload:o})}const i=typeof t.text=="string"?t.text:"";if(i){const o={text:i},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,c=le(t.payload)??void 0;return r!==void 0&&(o.type=r),c!==void 0&&(o.payload=c),s!==void 0&&(o.theme=s),Ke({payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Ke(e){const t={text:R(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function di(e){return Ci(e.payload,"qna")}function Et(e){const t=R(e.payload.text)??"",n=re(e.payload.action,t);if(n){const i={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(i.image=e.payload.image_url),typeof e.payload.theme=="string"&&(i.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:i}}}}}const a={text:t};return typeof e.payload.theme=="string"&&(a.theme=e.payload.theme),Ke({payload:a})}function St(e){const t=(e.payload.action_list??[]).map(n=>{const a=R(n.title)??"",i=re(n.requestDetails,a),o=i?{label:a,action:i}:null;return o?(typeof n.icon=="string"&&(o.icon=n.icon),typeof n.image=="string"&&(o.image=n.image),o):null});return Tt(t.filter(zt),"qna")}function gi(e){const n={reviews:(e.payload.reviews??[]).map(a=>{const i={};return typeof a.review_class=="string"&&(i.review_class=a.review_class),typeof a.review_text=="string"&&(i.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(i.review_rating=a.review_rating),typeof a.review_tag=="string"&&(i.review_tag=a.review_tag),i})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function pi(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function ui(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function hi(e){const t=e.payload.product_suggestions??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=Si(i);if(!o)continue;const r={product:o},s=re(i.requestDetails,o.name);s&&(r.action=s),typeof i.role=="string"&&(r.role=i.role),typeof i.reason=="string"&&(r.reason=i.reason),typeof i.review_highlight=="string"&&(r.reviewHighlight=i.review_highlight),Array.isArray(i.labels)&&(r.labels=i.labels),typeof i.expert_quality_score=="number"&&(r.expertQualityScore=i.expert_quality_score),n.push(r)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function fi(e){const t=e.payload.product_groupings??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=R(i.name)??"",r=i.sku&&i.sku.length>0?{type:"findSimilar",payload:{sku:i.sku}}:void 0,s=re(i.requestDetails??r,o);if(!s)continue;const c={name:o,action:s};if(Array.isArray(i.labels)){const l=i.labels.filter(d=>typeof d=="string");l.length>0&&(c.labels=l)}typeof i.image=="string"&&(c.image=i.image),n.push(c)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function mi(e){const t=e.payload.suggested_searches??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=R(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Arama ${a+1}`,r={},s=R(i.detailed_user_message);s&&(r.text=s);const c=le(i.requestDetails),l=le(c?.payload),d=l?.group_skus;i.group_skus&&Array.isArray(i.group_skus)?r.group_skus=i.group_skus:Array.isArray(d)&&(r.group_skus=d.filter(I=>typeof I=="string"));const u=R(i.sku,i.representative_product_sku,l?.sku);u&&(r.sku=u),r.is_suggested_text=1;const g={type:"inputText",payload:r},p=re(i.requestDetails,o),h=p?.type==="findSimilar"&&typeof r.text=="string"?re(g,o):p??re(g,o);if(!h)continue;const _={shortName:o,action:h},v=R(i.detailed_user_message);v&&v!==o&&(_.detailedMessage=v);const E=R(i.why_different);E&&(_.whyDifferent=E),typeof i.image=="string"&&(_.image=i.image),n.push(_)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function bi(e){const t=re(e.payload.requestDetails,R(e.payload.review_count,e.payload.text,e.payload.title)??"Urun yorumlarini goster");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function _i(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function vi(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function yi(e){const t=e.payload.group_list??[],n=[];for(const i of t){const o=i.group_name??"",r=(i.product_list??[]).map(xe);n.push({groupName:o,products:r})}const a=[];for(const i of e.payload.filter_tags??[]){const o=i.title??"";if(!o)continue;const r=re(i.requestDetails,o),s={title:o};r&&(s.action=r),a.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:a}}}},panelHint:"panel"}}function wi(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function xi(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function ki(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Tt(e,t){const n={},a=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=`action-${i}`;a.push(r);const s={label:o.label,action:o.action};o.icon!==void 0&&(s.icon=o.icon),o.image!==void 0&&(s.image=o.image),o.description!==void 0&&(s.description=o.description),n[r]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(i=>{const o={label:i.label,action:i.action};return i.image!==void 0&&(o.image=i.image),i.description!==void 0&&(o.description=i.description),i.icon!==void 0&&(o.icon=i.icon),o})},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function It(e,t){const n={},a=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=`product-${i}`;a.push(r),n[r]={type:"ProductCard",props:{product:xe(o),index:i}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Ci(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:xe(e),index:0}}}}}}function Ei(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Si(e){const t=R(e.sku),n=R(e.short_name),a=le(e.product_item)??e;return Ti(a,t,n)}function Ti(e,t,n){const a=R(e.sku,t),i=R(e.name,n);if(!a||!i)return null;const o={sku:a,name:i},r=R(e.brand);r&&(o.brand=r);const s=R(e.url);s&&(o.url=s);const c=Ii(e.images);if(c.length>0)o.images=c;else{const h=R(e.image,e.image_url,e.imageUrl);h&&(o.images=[h])}const l=ze(e.price_discounted);l!==void 0&&(o.price_discounted=l);const d=ze(e.price);d!==void 0&&(o.price=d);const u=ze(e.rating);u!==void 0&&(o.rating=u);const g=ze(e.review_count)??ze(e.reviewCount);g!==void 0&&(o.review_count=g);const p=R(e.cart_code,e.cartCode);return p&&(o.cart_code=p),typeof e.in_stock=="boolean"&&(o.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(o.in_stock=e.inStock),xe(o)}function re(e,t){const n=le(e);if(!n)return null;const a=n.type;if(typeof a!="string"||a.length===0)return null;const i={title:t||a,type:a};return n.payload!==void 0&&(i.payload=n.payload),i}function le(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function R(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function Ii(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function zi(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function ze(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function zt(e){return e!=null}function xe(e){const t=e.price_discounted!=null&&e.price_discounted>0?e.price_discounted:e.price,n=e.price_discounted!=null&&e.price_discounted>0&&e.price!=null?e.price:void 0;let a;n!=null&&t!=null&&n>0&&(a=Math.round((n-t)/n*100));const i=R(e.brand),o=R(e.name)??e.sku,r=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,s={sku:e.sku,name:r,url:R(e.url)??""},c=e.images?.[0];return c&&(s.imageUrl=c),e.images&&e.images.length>1&&(s.images=e.images),t!=null&&(s.price=String(t)),n!=null&&(s.originalPrice=String(n)),a!==void 0&&(s.discountPercent=a),i!==void 0&&(s.brand=i),e.rating!==void 0&&(s.rating=e.rating),e.review_count!==void 0&&(s.reviewCount=e.review_count),e.cart_code!==void 0&&(s.cartCode=e.cart_code),e.in_stock!==void 0&&(s.inStock=e.in_stock),e.variants&&e.variants.length>0&&(s.variants=e.variants),e.discount_reason!==void 0&&(s.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(s.promotions=e.promotions),s}const Pi={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"},Ai={process_action:"/message",launcher_action:"/message"};function Pt(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function At(e,t){const n=Pt(t?.middlewareUrl);if(t.backendType==="acap"){const a=t.accountId??"",i=Ai[e];if(i)return`${n}/api/chat/${a}${i}`}return`${n}/chat${Pi[e]}`}function Ni(e,t){const n=e.type,a=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},i=o=>{const r={...a};for(const[s,c]of Object.entries(o))s in r||(r[s]=c);return r};switch(n){case"inputText":{const o={is_launcher:0};return t.pageContext?.extra&&(o.page_details=t.pageContext.extra),"is_suggested_text"in a||(o.is_suggested_text=0),{...e,payload:i(o)}}case"findSimilar":{const o={is_launcher:0};return e.title&&(o.text=e.title),e.title&&(o.input=e.title),{...e,payload:i(o)}}case"getComparisonTable":return e;case"addToCart":{const o={};return"error_message"in a||(o.error_message=""),{...e,payload:i(o)}}case"reviewSummary":{const o={};return t.pageContext?.sku&&!("sku"in a)&&(o.sku=t.pageContext.sku),Object.keys(o).length===0?e:{...e,payload:i(o)}}default:return e}}const Li={user_message:"inputText"};function Mi(e){const{action:t,type:n,payload:a,...i}=e,o=n??t?.type??"inputText",r=a??t?.payload,s=Li[o]??o,c={...i,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function $i(e){const t=e.type??e.action?.type??"inputText",n=e.payload??e.action?.payload;let a=e.action?.title??"";(t==="inputText"||t==="user_message")&&(typeof n=="string"?a=n:n&&typeof n=="object"&&"text"in n&&(a=String(n.text)));const i={message:a,session_id:e.session_id};if(e.user_id&&(i.user_id=e.user_id),e.locale&&(i.output_language=e.locale),e.meta?.outputLanguage&&(i.output_language=e.meta.outputLanguage),e.sku||e.page_type){const o={};e.page_type&&(o.screen_type=e.page_type),e.sku&&(o.sku_list=[e.sku]),i.screen_context=o}return t!=="inputText"&&t!=="user_message"&&(i.action_type=t,n!==void 0&&(i.action_payload=typeof n=="string"?{text:n}:n)),JSON.stringify(i)}function Oi(e,t,n){const a=At("process_action",n),i=new AbortController;return(async()=>{try{const r=n.backendType==="acap"?$i(e):Mi(e),s=n.attachment!==void 0;let c;if(s){const g=new FormData;g.append("request",r),n.attachment!==void 0&&g.append("attachment",n.attachment),c={method:"POST",body:g,signal:i.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:r,signal:i.signal};const l=await fetch(a,c);if(!l.ok){let g=l.statusText;try{const p=await l.json(),h=p.detail??p.message??p.error;typeof h=="string"&&(g=h)}catch{}t.onError(new Error(`HTTP ${l.status}: ${g}`));return}let d=!1;const u=()=>{d||(d=!0,t.onDone())};await Fa(l,{onEvent:g=>{const p=qa(g);if(p)switch(p.type){case"text_chunk":t.onTextChunk(p.content,p.final===!0,{productMentions:p.productMentions,skuToProductItem:p.skuToProductItem,conversationMode:p.conversationMode});break;case"ui_spec":t.onUISpec(p.spec,p.widget,p.panelHint);break;case"action":t.onAction(p);break;case"metadata":t.onMetadata(p);break;case"error":t.onError(new Error(p.message));break;case"done":u();break}},onError:t.onError,signal:i.signal}),u()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;t.onError(r instanceof Error?r:new Error(String(r)))}})(),i}async function Bi(e,t){const n=At("proactive_action",t);try{const a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return a.ok?await a.json():null}catch{return null}}const Je={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Powered by Gengage",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"Düşünüyorum...",productCtaLabel:"İncele",attachImageButton:"Resim ekle",removeAttachmentButton:"Resmi kaldır",invalidFileType:"Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",fileTooLarge:"Dosya boyutu 5 MB'dan küçük olmalıdır.",aiTopPicksTitle:"Sizin İçin En İyiler",roleWinner:"En Beğendiğim",roleBestValue:"En Uygun Fiyatlı",roleBestAlternative:"En İyi Alternatif",viewDetails:"Detayları Gör",groundingReviewCta:"Yorumları Oku",groundingReviewSubtitle:"{count} yorum mevcut",variantsLabel:"Varyantlar",sortRelated:"Önerilen",sortPriceAsc:"Fiyat ↑",sortPriceDesc:"Fiyat ↓",compareSelected:"Karşılaştır",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",panelTitleSearchResults:"Arama Sonuçları",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",choicePrompterHeading:"Kararsız mı kaldın?",choicePrompterSuggestion:"Ürünleri seçip karşılaştırabilirsin",choicePrompterCta:"Seç ve Karşılaştır",viewMoreLabel:"Daha Fazla Göster",similarProductsLabel:"Benzer Ürünler",addToCartButton:"Sepete Ekle",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor",productNotFoundMessage:"Bu ürün bilgisi şu an kullanılamıyor. Başka bir konuda yardımcı olabilirim."},Di={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",sendButton:"Send",closeButton:"Close",openButton:"Open chat",newChatButton:"New chat",poweredBy:"Powered by Gengage",errorMessage:"Something went wrong. Please try again.",retryButton:"Retry",loadingMessage:"Thinking...",productCtaLabel:"View",attachImageButton:"Attach image",removeAttachmentButton:"Remove image",invalidFileType:"Only JPEG, PNG and WebP files are supported.",fileTooLarge:"File must be smaller than 5 MB.",aiTopPicksTitle:"Top Picks for You",roleWinner:"Top Pick",roleBestValue:"Best Value",roleBestAlternative:"Best Alternative",viewDetails:"View Details",groundingReviewCta:"Read Reviews",groundingReviewSubtitle:"{count} reviews available",variantsLabel:"Variants",sortRelated:"Related",sortPriceAsc:"Price ↑",sortPriceDesc:"Price ↓",compareSelected:"Compare",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",panelTitleSearchResults:"Search Results",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent",productNotFoundMessage:"Product information is currently unavailable. I can help with something else."};function Ri(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Ui(e){return Ri(e)==="en"?Di:Je}function Zi(){return Nt()!==null}function Nt(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class ji{constructor(t,n){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this.callbacks=t,this.lang=n?.lang??"tr-TR",this.silenceTimeoutMs=n?.silenceTimeoutMs??1500,this.autoSubmit=n?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=Nt();if(!t){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const n=new t;n.continuous=!0,n.interimResults=!0,n.lang=this.lang,n.maxAlternatives=1,n.onstart=()=>{this.setState("listening")},n.onresult=a=>{this.clearSilenceTimer();let i="",o="";for(let r=a.resultIndex;r<a.results.length;r++){const s=a.results[r];if(!s)continue;const c=s[0];c&&(s.isFinal?o+=c.transcript:i+=c.transcript)}o&&(this.accumulatedTranscript+=o,this.callbacks.onFinal?.(this.accumulatedTranscript)),i&&this.callbacks.onInterim?.(this.accumulatedTranscript+i),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},n.onerror=a=>{const i=Fi(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(i,a.message||a.error))},n.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){try{n.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=n;try{n.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}function Fi(e){switch(e){case"not-allowed":return"not-allowed";case"no-speech":return"no-speech";case"audio-capture":return"no-microphone";case"network":return"network";case"aborted":return"aborted";default:return"unknown"}}function qi(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner",t.setAttribute("role","alert");const n=document.createElement("div");n.className="gengage-chat-kvkk-content",n.innerHTML=oe(e.htmlContent),t.appendChild(n);const a=document.createElement("button");return a.className="gengage-chat-kvkk-dismiss",a.type="button",a.setAttribute("aria-label",e.closeAriaLabel??"KVKK bildirimini kapat"),a.textContent="×",a.addEventListener("click",e.onDismiss),t.appendChild(a),t}class Hi{constructor(t){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label","Back"),this._backBtn.textContent="←",this._backBtn.addEventListener("click",()=>t.onBack()),this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label","Forward"),this._forwardBtn.textContent="→",this._forwardBtn.addEventListener("click",()=>t.onForward()),this._el.appendChild(this._backBtn),this._el.appendChild(this._titleEl),this._el.appendChild(this._forwardBtn)}update(t,n,a){this._backBtn.disabled=!t,this._forwardBtn.disabled=!n,this._titleEl.textContent=a}getElement(){return this._el}}class Vi{constructor(t){this._onThumbnailClick=t.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(t){const n=new Set,a=[];for(const i of t)n.has(i.sku)||(n.add(i.sku),a.push(i));this._el.innerHTML="";for(const i of a){const o=document.createElement("button");if(o.type="button",o.className="gengage-chat-thumbnail-btn",o.title=i.sku,ce(i.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-thumbnail-img",r.src=i.imageUrl,r.alt=i.sku,r.width=40,r.height=40,o.appendChild(r)}o.addEventListener("click",()=>{this._onThumbnailClick(i.threadId)}),this._el.appendChild(o)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}}const Lt={search:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',review:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',info:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',similar:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'},Gi=Je;class Wi{constructor(t,n){this._panelVisible=!1,this._panelCollapsed=!1,this._onPanelToggle=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this._ignoreNextDividerClick=!1,this.i18n={...Gi,...n.i18n},this.onSend=n.onSend,n.onPanelToggle!==void 0&&(this._onPanelToggle=n.onPanelToggle),n.onAttachment!==void 0&&(this._onAttachment=n.onAttachment),n.onRollback!==void 0&&(this._onRollback=n.onRollback),n.onLinkClick!==void 0&&(this._onLinkClick=n.onLinkClick),n.voiceEnabled&&(this._voiceEnabled=!0),n.voiceLang!==void 0&&(this._voiceLang=n.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a=document.createElement("div");a.className="gengage-chat-header";const i=document.createElement("div");if(i.className="gengage-chat-header-left",n.headerAvatarUrl){const w=document.createElement("img");w.className="gengage-chat-header-avatar",w.src=n.headerAvatarUrl,w.alt=n.headerTitle??"Assistant",i.appendChild(w)}const o=document.createElement("div");o.className="gengage-chat-header-info";const r=document.createElement("div");r.className="gengage-chat-header-title-row";const s=document.createElement("span");if(s.className="gengage-chat-header-title",s.textContent=n.headerTitle??this.i18n.headerTitle??"Gengage Asistanı",r.appendChild(s),n.headerBadge){const w=document.createElement("span");w.className="gengage-chat-header-badge",w.textContent=n.headerBadge,r.appendChild(w)}o.appendChild(r);const c=document.createElement("a");c.className="gengage-chat-header-powered",c.href="https://gengage.ai/",c.target="_blank",c.rel="noopener noreferrer",c.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage',o.appendChild(c),i.appendChild(o),a.appendChild(i);const l=document.createElement("div");if(l.className="gengage-chat-header-right",n.headerCartUrl){const w=document.createElement("a");w.className="gengage-chat-header-btn",w.href=n.headerCartUrl,w.target="_blank",w.rel="noopener noreferrer",w.setAttribute("aria-label","Sepetim"),w.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>',l.appendChild(w)}if(n.headerFavoritesToggle){const w=document.createElement("button");w.className="gengage-chat-header-btn",w.type="button",w.setAttribute("aria-label","Favorilerim"),w.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>',w.addEventListener("click",()=>n.onFavoritesClick?.()),l.appendChild(w)}const d=document.createElement("button");d.className="gengage-chat-close",d.type="button",d.setAttribute("aria-label",this.i18n.closeButton),d.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',d.addEventListener("click",n.onClose),l.appendChild(d),a.appendChild(l);const u=document.createElement("div");u.className="gengage-chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel",this._panelTopBar=new Hi({onBack:()=>n.onPanelBack?.(),onForward:()=>n.onPanelForward?.()}),this._panelEl.appendChild(this._panelTopBar.getElement()),u.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label","Toggle panel");const g=document.createElement("button");g.className="gengage-chat-panel-divider-toggle",g.type="button",g.setAttribute("aria-label","Toggle panel"),g.textContent="»",g.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let p=null,h=null;const _=24;this._dividerEl.addEventListener("touchstart",w=>{if(window.innerWidth>768)return;const M=w.changedTouches?.[0];M&&(p=M.clientX,h=M.clientY)},{passive:!0}),this._dividerEl.addEventListener("touchend",w=>{if(window.innerWidth>768||p===null||h===null)return;const M=w.changedTouches?.[0];if(!M)return;const z=M.clientX-p,N=M.clientY-h;if(p=null,h=null,Math.abs(N)<_||Math.abs(N)<Math.abs(z))return;const O=N<0;O!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(O),this._onPanelToggle?.())},{passive:!0}),this._dividerEl.appendChild(g),u.appendChild(this._dividerEl);const v=document.createElement("div");v.className="gengage-chat-conversation",v.appendChild(a),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",v.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.className="gengage-chat-messages",this.messagesEl.setAttribute("role","log"),this.messagesEl.setAttribute("aria-live","polite"),this.messagesEl.setAttribute("aria-label","Chat messages");let E=!1;this.messagesEl.addEventListener("scroll",()=>{E||(E=!0,requestAnimationFrame(()=>{E=!1;const{scrollTop:w,scrollHeight:M,clientHeight:z}=this.messagesEl;this._userScrolledUp=M-w-z>10}))},{passive:!0}),v.appendChild(this.messagesEl),this._thumbnailsColumn=new Vi({onThumbnailClick:w=>n.onThumbnailClick?.(w)}),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label","Suggestions"),this._pillsEl.style.display="none";const I=document.createElement("div");I.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(I);const T=document.createElement("button");T.className="gengage-chat-pills-arrow",T.type="button",T.setAttribute("aria-label","More suggestions"),T.textContent="›",T.addEventListener("click",()=>{I.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(T);let y=!1;I.addEventListener("scroll",()=>{y||(y=!0,requestAnimationFrame(()=>{y=!1;const w=I.scrollLeft+I.clientWidth>=I.scrollWidth-4;T.style.display=w?"none":""}))},{passive:!0}),v.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",v.appendChild(this._inputChipsEl);const f=document.createElement("div");f.className="gengage-chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{requestAnimationFrame(()=>{this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`})}),this.inputEl.addEventListener("keydown",w=>{w.key==="Enter"&&(window.innerWidth<768||!w.shiftKey)&&(w.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",w=>{const M=w.clipboardData?.files[0];M&&M.type.startsWith("image/")&&(w.preventDefault(),this._onAttachment?this._onAttachment(M):this.stageAttachment(M))}),this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.accept="image/jpeg,image/png,image/webp",this._fileInput.style.display="none",this._fileInput.addEventListener("change",()=>{const w=this._fileInput.files?.[0];w&&(this._onAttachment?this._onAttachment(w):this.stageAttachment(w)),this._fileInput.value=""});const P=document.createElement("button");P.className="gengage-chat-attach-btn",P.type="button",P.setAttribute("aria-label",this.i18n.attachImageButton),P.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',P.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const A=document.createElement("img");A.className="gengage-chat-attachment-preview-thumb",A.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const b=document.createElement("button");b.className="gengage-chat-attachment-remove",b.type="button",b.setAttribute("aria-label",this.i18n.removeAttachmentButton),b.textContent="×",b.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(A),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(b),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send",this.sendBtn.type="button",this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>',this.sendBtn.addEventListener("click",()=>this._submit()),f.addEventListener("dragover",w=>{w.preventDefault(),f.classList.add("gengage-chat-input-area--dragover")}),f.addEventListener("dragleave",()=>{f.classList.remove("gengage-chat-input-area--dragover")}),f.addEventListener("drop",w=>{w.preventDefault(),f.classList.remove("gengage-chat-input-area--dragover");const M=w.dataTransfer?.files[0];M&&(this._onAttachment?this._onAttachment(M):this.stageAttachment(M))});const x=document.createElement("div");x.className="gengage-chat-input-pill",x.appendChild(P),x.appendChild(this.inputEl),this._voiceEnabled&&Zi()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn",this._micBtn.type="button",this._micBtn.setAttribute("aria-label",this.i18n.voiceButton),this._micBtn.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',this._micBtn.addEventListener("click",()=>this._toggleVoice()),x.appendChild(this._micBtn),this._voiceInput=new ji({onInterim:w=>{this.inputEl.value=w,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:w=>{this.inputEl.value=w},onAutoSubmit:w=>{this.inputEl.value=w,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:w=>{w==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(w,M)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),x.appendChild(this.sendBtn),f.appendChild(this._previewStrip),f.appendChild(this._fileInput),f.appendChild(x),v.appendChild(f),u.appendChild(v),this.root.appendChild(u);const C=document.createElement("div");C.className="gengage-chat-footer",C.textContent=this.i18n.poweredBy,this.root.appendChild(C),this.root.addEventListener("keydown",w=>{w.key==="Escape"&&n.onClose()}),this._trapFocus(),t.appendChild(this.root)}addMessage(t){const n=document.createElement("div");if(n.className=`gengage-chat-bubble gengage-chat-bubble--${t.role}`,n.dataset.messageId=t.id,t.threadId&&(n.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&n.classList.add("gengage-chat-bubble--first"),t.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const i=URL.createObjectURL(t.attachment);a.src=i,a.alt=t.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(i),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(i),{once:!0}),n.insertBefore(a,n.firstChild)}if(t.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",t.role==="assistant"){if(a.innerHTML=oe(t.content),this._onLinkClick){const i=a.querySelectorAll("a[href]");for(const o of i)o.addEventListener("click",r=>{r.preventDefault();const s=o.getAttribute("href");s&&this._onLinkClick?.(s)})}}else a.textContent=t.content;n.appendChild(a)}if(t.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn",a.type="button",a.setAttribute("aria-label","Rollback to this message"),a.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',a.addEventListener("click",i=>{i.stopPropagation(),this._onRollback?.(t.id)}),n.appendChild(a)}this.messagesEl.appendChild(n),this._scrollToBottom(t.role==="user")}showTypingIndicator(t){this.removeTypingIndicator();const n=document.createElement("div");if(n.className="gengage-chat-typing",n.dataset.typing="true",this._thinkingSteps.length>0)this._renderThinkingStepsInto(n);else{const a=document.createElement("div");a.className="gengage-chat-typing-dots";for(let i=0;i<3;i++)a.appendChild(document.createElement("span"));if(n.appendChild(a),t){const i=document.createElement("span");i.className="gengage-chat-typing-sparkle",i.textContent="✨",n.appendChild(i);const o=document.createElement("span");o.className="gengage-chat-typing-text",o.textContent=t,n.appendChild(o)}}this.messagesEl.appendChild(n),this._scrollToBottom(!0)}addThinkingStep(t){this._thinkingSteps.push(t),this._renderThinkingSteps()}removeTypingIndicator(){this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[]}showError(t,n){const a=document.createElement("div");a.className="gengage-chat-error";const i=document.createElement("span");if(i.textContent=t??this.i18n.errorMessage,a.appendChild(i),n){const o=document.createElement("button");o.className="gengage-chat-error-retry",o.textContent=this.i18n.retryButton??"Retry",o.addEventListener("click",()=>{a.remove(),n()}),a.appendChild(o)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}clearMessages(){this.messagesEl.innerHTML=""}setPills(t){const n=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const i of t){const o=document.createElement("button");if(o.className=i.image?"gengage-chat-pill gengage-chat-pill--rich":"gengage-chat-pill",o.type="button",i.icon){const s=Lt[i.icon];if(s){const c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,o.appendChild(c)}}if(i.image&&ce(i.image)){const s=document.createElement("img");s.className="gengage-chat-pill-img",s.src=i.image,s.alt="",o.appendChild(s)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=i.label,o.appendChild(r),i.description){const s=document.createElement("span");s.className="gengage-chat-pill-desc",s.textContent=i.description,o.appendChild(s)}o.addEventListener("click",()=>i.onAction()),n.appendChild(o)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=n.scrollWidth>n.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,n){this._kvkkSlot.innerHTML="";const a=qi({htmlContent:t,onDismiss:n});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}getElement(){return this.root}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const n=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");n&&(n.src&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),n.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden")}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden")}getPendingAttachment(){return this._pendingAttachment}setPanelContent(t){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed")}appendPanelContent(t){this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}getPanelContentElement(){const t=this._panelEl.children;for(let n=0;n<t.length;n++){const a=t[n];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-thumbnails-column")))return a}return null}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement());const n=document.createElement("div");switch(n.className="gengage-chat-panel-skeleton",t){case"productDetails":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",n.appendChild(a);for(let i=0;i<3;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",n.appendChild(o)}break}case"productList":case"groupList":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-grid";for(let i=0;i<6;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",a.appendChild(o)}n.appendChild(a);break}case"comparisonTable":{for(let a=0;a<4;a++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row",n.appendChild(i)}break}default:{for(let a=0;a<3;a++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block",n.appendChild(i)}break}}this._panelEl.appendChild(n),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}updatePanelTopBar(t,n,a){this._panelTopBar.update(t,n,a)}clearPanel(){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}expandPanel(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}setForceExpanded(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden")}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){this._panelCollapsed=t,t?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const n=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");n&&(n.textContent=t?"«":"»")}persistPanelState(t){try{const n=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(n,"collapsed"):sessionStorage.removeItem(n)}catch{}}restorePanelState(t){try{const n=`gengage:panel:${t}`;if(sessionStorage.getItem(n)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_renderThinkingSteps(){const t=this.messagesEl.querySelector('[data-typing="true"]');if(!t){this.showTypingIndicator();return}t.innerHTML="",this._renderThinkingStepsInto(t),this._scrollToBottom(!1)}_renderThinkingStepsInto(t){const n=document.createElement("div");n.className="gengage-chat-thinking-steps";for(let a=0;a<this._thinkingSteps.length;a++){const i=document.createElement("div");i.className="gengage-chat-thinking-step";const o=document.createElement("span");o.className="gengage-chat-thinking-step-marker",a<this._thinkingSteps.length-1?(o.textContent="✓",o.classList.add("gengage-chat-thinking-step-marker--done")):(o.textContent="●",o.classList.add("gengage-chat-thinking-step-marker--active")),i.appendChild(o);const r=document.createElement("span");r.className="gengage-chat-thinking-step-text",r.textContent=this._thinkingSteps[a],i.appendChild(r),n.appendChild(i)}t.appendChild(n)}_trapFocus(){this.root.addEventListener("keydown",t=>{if(t.key!=="Tab")return;const n=this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(n.length===0)return;const a=n[0],i=n[n.length-1];if(!a||!i)return;const r=this.root.getRootNode().activeElement??document.activeElement;t.shiftKey?r===a&&(t.preventDefault(),i.focus()):r===i&&(t.preventDefault(),a.focus())})}_submit(){const t=this.inputEl.value.trim(),n=this._pendingAttachment;!t&&!n||(this.onSend(t,n??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment())}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(t,n){const a=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(!a)return;let i=a.querySelector(".gengage-chat-bubble-text");i||(i=document.createElement("div"),i.className="gengage-chat-bubble-text",a.appendChild(i)),i.innerHTML=oe(n),this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const n=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);n&&n.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const n=t[t.length-1].getAttribute("data-thread-id");if(!n){this._scrollToBottom(!0);return}const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(n)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const n of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip",a.type="button",n.icon){const o=Lt[n.icon];if(o){const r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=o,a.appendChild(r)}}const i=document.createElement("span");i.textContent=n.label,a.appendChild(i),a.addEventListener("click",()=>n.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(t){this._thumbnailsColumn.setEntries(t),t.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide()}hideThumbnails(){this._thumbnailsColumn.hide()}}const Ki=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
48
48
  <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
49
49
  <rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
50
50
  <circle cx="9" cy="13" r="1.5" fill="currentColor"/>
@@ -54,44 +54,44 @@
54
54
  <circle cx="12" cy="3" r="1" fill="currentColor"/>
55
55
  <path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
56
56
  <path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
57
- </svg>`;function qo(e){const t=document.createElement("div");t.className="gengage-chat-launcher-container";const n=document.createElement("div");n.className="gengage-chat-launcher-content-area",t.appendChild(n);const a=document.createElement("button");if(a.className="gengage-chat-launcher",a.type="button",a.setAttribute("aria-label",e.ariaLabel??"Open chat"),a.innerHTML=e.svgMarkup??Fo,e.tooltip!==void 0){const i=document.createElement("span");i.className="gengage-chat-launcher-tooltip",i.textContent=e.tooltip,a.appendChild(i)}e.hideMobile&&(t.dataset.hideMobile="1"),e.mobileBreakpoint!==void 0&&(t.dataset.mobileBreakpoint=String(e.mobileBreakpoint)),a.addEventListener("click",e.onClick),t.appendChild(a);const o=document.createElement("div");return o.className="gengage-chat-launcher-content-area-bottom",t.appendChild(o),{container:t,button:a,contentArea:n,contentAreaBottom:o}}function Ho(e){const t=document.createElement("div");t.className="gengage-chat-proactive";const n=document.createElement("p");n.className="gengage-chat-proactive-message",n.textContent=e.message,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-proactive-actions";let o=null;function i(){o!==null&&clearTimeout(o),t.remove()}if(e.actionButtons&&e.actionButtons.length>0)for(const c of e.actionButtons){const l=document.createElement("button");l.className="gengage-chat-proactive-accept",l.type="button",l.textContent=c.title,l.addEventListener("click",()=>{i(),c.onSelect()}),a.appendChild(l)}else{const c=document.createElement("button");c.className="gengage-chat-proactive-accept",c.type="button",c.textContent=e.acceptLabel??"Sohbete Başla",c.addEventListener("click",()=>{i(),e.onAccept()}),a.appendChild(c)}const r=document.createElement("button");r.className="gengage-chat-proactive-dismiss",r.type="button",r.textContent="×",r.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),r.addEventListener("click",()=>{i(),e.onDismiss()}),t.appendChild(r),t.appendChild(a);const s=e.autoDismissMs??15e3;return s>0&&(o=setTimeout(()=>{t.parentElement&&(t.remove(),e.onDismiss())},s)),requestAnimationFrame(()=>t.classList.add("gengage-chat-proactive--visible")),t}class Vo{constructor(t={}){this._idleTimer=null,this._maxScrollDepth=0,this._lastReportedDepth=0,this._listeners=[],this._destroyed=!1,this._idleThreshold=t.idleThresholdMs??3e4,this._scrollGranularity=t.scrollGranularity??25,this._onActivity=t.onActivity??null,this._setup()}_setup(){this._emit({type:"pageview",timestamp:Date.now()}),this._resetIdleTimer(),this._listen(window,"scroll",()=>this._onScroll(),{passive:!0}),this._listen(window,"mousemove",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"keydown",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"touchstart",()=>this._resetIdleTimer(),{passive:!0}),this._listen(document,"visibilitychange",()=>this._onVisibility())}_listen(t,n,a,o){t.addEventListener(n,a,o),this._listeners.push([t,n,a])}_resetIdleTimer(){this._idleTimer&&clearTimeout(this._idleTimer),this._idleTimer=setTimeout(()=>{this._emit({type:"idle",timestamp:Date.now()})},this._idleThreshold)}_onScroll(){const t=window.scrollY||document.documentElement.scrollTop,n=Math.max(document.documentElement.scrollHeight-window.innerHeight,1),a=Math.min(100,Math.round(t/n*100));a>this._maxScrollDepth&&(this._maxScrollDepth=a);const o=Math.floor(a/this._scrollGranularity)*this._scrollGranularity;o>this._lastReportedDepth&&(this._lastReportedDepth=o,this._emit({type:"scroll",timestamp:Date.now(),data:{depth:o}})),this._resetIdleTimer()}_onVisibility(){document.hidden?(this._emit({type:"blur",timestamp:Date.now()}),this._idleTimer&&clearTimeout(this._idleTimer)):(this._emit({type:"focus",timestamp:Date.now()}),this._resetIdleTimer())}_emit(t){this._destroyed||this._onActivity?.(t)}get maxScrollDepth(){return this._maxScrollDepth}destroy(){this._destroyed=!0,this._idleTimer&&clearTimeout(this._idleTimer);for(const[t,n,a]of this._listeners)t.removeEventListener(n,a);this._listeners=[]}}const Go=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]);function Wo(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!Go.has(n))return null;try{const a=new Audio(`data:${t};base64,${e}`);return a.play().catch(()=>{}),{stop:()=>{a.pause(),a.currentTime=0}}}catch{return null}}class Ko{constructor(t){this._timer=null,this._destroyed=!1,this._abortController=null,this._sessionStart=Date.now(),this._lastActivity=Date.now(),this._searchesCount=0,this._actionsCount=0,this._triggerFireCounts={},this._options=t;const n=At(t.middlewareUrl);this._endpoint=`${n}/v2/heartbeat`}start(){this._timer||this._destroyed||this._scheduleNext()}_scheduleNext(){this._destroyed||(this._timer=setTimeout(()=>{this._poll().finally(()=>this._scheduleNext())},this._options.intervalMs))}stop(){this._timer&&(clearTimeout(this._timer),this._timer=null)}recordAction(){this._actionsCount++,this._lastActivity=Date.now()}recordSearch(){this._searchesCount++,this._lastActivity=Date.now()}recordActivity(){this._lastActivity=Date.now()}destroy(){this._destroyed=!0,this._abortController?.abort(),this._abortController=null,this.stop()}async _poll(){if(this._destroyed)return;const t=Date.now(),n={account_id:this._options.accountId,thread_id:this._options.sessionId,output_language:this._options.locale.toUpperCase(),idle_seconds:(t-this._lastActivity)/1e3,page_type:this._options.getPageType(),current_sku:this._options.getCurrentSku(),cart_item_count:0,searches_count:this._searchesCount,actions_count:this._actionsCount,session_duration_seconds:(t-this._sessionStart)/1e3,trigger_fire_counts:{...this._triggerFireCounts}};this._abortController=new AbortController;try{const a=await fetch(this._endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:this._abortController.signal});if(this._destroyed||!a.ok)return;const o=await a.json();if(this._destroyed)return;o.action==="message"&&o.message&&(o.trigger_type&&(this._triggerFireCounts[o.trigger_type]=(this._triggerFireCounts[o.trigger_type]??0)+1),this._options.onMessage(o))}catch{}}}const Jo={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...Jo,...t},i=n%1!==0||a.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),r=i.indexOf("."),s=r===-1?i:i.slice(0,r),c=r===-1?void 0:i.slice(r+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousandsSeparator);let d;return c!==void 0?d=`${l}${a.decimalSeparator}${c}`:d=l,a.currencySymbol?a.currencyPosition==="prefix"?`${a.currencySymbol}${d}`:`${d} ${a.currencySymbol}`:d}const Yo={screen_size:"Ekran Boyutu",weight:"Ağırlık",battery_capacity:"Batarya Kapasitesi",battery_life:"Batarya Ömrü",storage:"Depolama",memory:"Bellek",ram:"RAM",processor:"İşlemci",camera:"Kamera",resolution:"Çözünürlük",display_type:"Ekran Tipi",refresh_rate:"Yenileme Hızı",color:"Renk",material:"Malzeme",dimensions:"Boyutlar",warranty:"Garanti",connectivity:"Bağlantı",water_resistance:"Su Dayanıklılığı",operating_system:"İşletim Sistemi",brand:"Marka",model:"Model",price:"Fiyat",energy_class:"Enerji Sınıfı",noise_level:"Gürültü Seviyesi",capacity:"Kapasite",power:"Güç",voltage:"Voltaj",width:"Genişlik",height:"Yükseklik",depth:"Derinlik"};function Xo(e){return Yo[e]??e.replace(/_/g," ").replace(/^\w/,t=>t.toUpperCase())}function Qo(e){const{recommended:t,products:n,attributes:a,highlights:o,specialCases:i,onProductClick:r,i18n:s}=e,c=document.createElement("div");c.className="gengage-chat-comparison";const l=document.createElement("h3");if(l.className="gengage-chat-comparison-heading",l.textContent=s?.comparisonHeading??"KARŞILAŞTIRMA SONUÇLARI",c.appendChild(l),t){const d=document.createElement("div");d.className="gengage-chat-comparison-recommended";const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Önerilen Seçim",d.appendChild(g);const u=document.createElement("div");if(u.className="gengage-chat-comparison-recommended-body",t.imageUrl&&re(t.imageUrl)){const y=document.createElement("img");y.src=t.imageUrl,y.alt=t.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),u.appendChild(y)}const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-info";const f=document.createElement("div");f.className="gengage-chat-comparison-recommended-title",f.textContent=t.name,p.appendChild(f);const v=document.createElement("div");if(v.className="gengage-chat-comparison-recommended-price",v.textContent=t.price,p.appendChild(v),u.appendChild(p),u.addEventListener("click",()=>{r(t.sku)}),u.style.cursor="pointer",d.appendChild(u),o.length>0){const y=document.createElement("div");y.className="gengage-chat-comparison-highlights";const I=document.createElement("div");I.className="gengage-chat-comparison-highlights-label",I.textContent=s?.highlightsLabel??"Öne Çıkan Özellikler",y.appendChild(I);const z=document.createElement("ul");for(const b of o){const _=document.createElement("li");_.textContent=b,z.appendChild(_)}y.appendChild(z),d.appendChild(y)}if(e.recommendedText){const y=document.createElement("div");y.className="gengage-chat-comparison-recommended-text",y.textContent=e.recommendedText,d.appendChild(y)}c.appendChild(d)}if(e.keyDifferencesHtml){const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences";const g=document.createElement("h4");g.textContent=s?.keyDifferencesLabel??"Temel Farklar",d.appendChild(g);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content",u.innerHTML=we(ei(e.keyDifferencesHtml)),d.appendChild(u),c.appendChild(d)}if(i&&i.length>0){const d=document.createElement("details");d.className="gengage-chat-comparison-special";const g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"Özel Durumlar İçin",d.appendChild(g);const u=document.createElement("ul");for(const p of i){const f=document.createElement("li");f.textContent=p,u.appendChild(f)}d.appendChild(u),c.appendChild(d)}if(n.length>0&&a.length>0){const d=document.createElement("table");d.className="gengage-chat-comparison-table";const g=document.createElement("thead"),u=document.createElement("tr"),p=document.createElement("th");u.appendChild(p);for(const v of n){const y=document.createElement("th");if(v.sku===t?.sku&&(y.className="gengage-chat-comparison-selected"),v.imageUrl&&re(v.imageUrl)){const b=document.createElement("img");b.src=v.imageUrl,b.alt=v.name,b.loading="lazy",b.addEventListener("error",()=>{b.style.display="none"},{once:!0}),y.appendChild(b)}const I=document.createElement("div");I.textContent=v.name,y.appendChild(I);const z=document.createElement("div");z.className="gengage-chat-comparison-table-price",z.textContent=v.price,y.appendChild(z),u.appendChild(y)}g.appendChild(u),d.appendChild(g);const f=document.createElement("tbody");for(const v of a){const y=document.createElement("tr"),I=document.createElement("td");I.className="gengage-chat-comparison-label",I.textContent=Xo(v.label),y.appendChild(I);for(let z=0;z<v.values.length;z++){const b=document.createElement("td");n[z]?.sku===t?.sku&&(b.className="gengage-chat-comparison-selected"),b.textContent=v.values[z]??"",y.appendChild(b)}f.appendChild(y)}d.appendChild(f),c.appendChild(d)}if(e.productActions){const d=document.createElement("div");d.className="gengage-chat-comparison-product-actions";for(const g of n)if(e.productActions[g.sku]){const p=document.createElement("button");p.className="gengage-chat-comparison-view-btn",p.type="button",p.textContent=g.name,p.addEventListener("click",()=>r(g.sku)),d.appendChild(p)}d.childElementCount>0&&c.appendChild(d)}return c}function ei(e){const t=e.split(`
58
- `).filter(n=>n.trim());return t.length<=1?e:"<ul>"+t.map(n=>`<li>${n.trim()}</li>`).join("")+"</ul>"}function ti(e,t){const n=document.createElement("div");n.className="gengage-chat-review-highlights";const a=e.props?.reviews;if(!Array.isArray(a)||a.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"Yorum özeti bulunamadı.",n.appendChild(u),n}const o=a.filter(u=>u!==null&&typeof u=="object"),i={all:o.length,positive:0,negative:0,neutral:0};for(const u of o)u.review_class==="positive"?i.positive++:u.review_class==="negative"?i.negative++:i.neutral++;const r=document.createElement("div");r.className="gengage-chat-review-tabs";const s=[{label:`Tümü (${i.all})`,filter:"all"}];i.positive>0&&s.push({label:`Olumlu (${i.positive})`,filter:"positive"}),i.negative>0&&s.push({label:`Olumsuz (${i.negative})`,filter:"negative"});let c="all";const l=document.createElement("div");l.className="gengage-chat-review-items";function d(){for(;l.firstChild;)l.removeChild(l.firstChild);const u=c==="all"?o:o.filter(p=>p.review_class===c);for(const p of u){const f=document.createElement("article");f.className="gengage-chat-review-item";const v=p.review_class;if((v==="positive"||v==="negative"||v==="neutral")&&(f.dataset.tone=v),typeof p.review_tag=="string"&&p.review_tag.length>0){const y=document.createElement("div");y.className="gengage-chat-review-tag",y.textContent=p.review_tag,f.appendChild(y)}if(typeof p.review_text=="string"&&p.review_text.length>0){const y=document.createElement("div");y.className="gengage-chat-review-text",y.textContent=p.review_text,f.appendChild(y)}if(p.review_rating!==void 0&&String(p.review_rating).length>0){const y=document.createElement("div");y.className="gengage-chat-review-rating",y.textContent=String(p.review_rating),f.appendChild(y)}l.appendChild(f)}}for(const u of s){const p=document.createElement("button");p.className="gengage-chat-review-tab",p.type="button",p.textContent=u.label,u.filter===c&&p.classList.add("gengage-chat-review-tab--active"),p.addEventListener("click",()=>{c=u.filter;for(const f of r.querySelectorAll(".gengage-chat-review-tab"))f.classList.toggle("gengage-chat-review-tab--active",f===p);d()}),r.appendChild(p)}n.appendChild(r);const g=new Map;for(const u of o)if(typeof u.review_tag=="string"&&u.review_tag.length>0){const p=g.get(u.review_tag);p?p.count++:g.set(u.review_tag,{count:1,sentiment:u.review_class??"neutral"})}if(g.size>0){const u=document.createElement("div");u.className="gengage-chat-review-pills";for(const[p,f]of g){const v=document.createElement("span");v.className="gengage-chat-review-pill",v.dataset.tone=f.sentiment;const y=document.createElement("span");y.className="gengage-chat-review-pill-icon",y.textContent=f.sentiment==="positive"?"✓":f.sentiment==="negative"?"✕":"●",v.appendChild(y);const I=document.createElement("span");if(I.textContent=p,v.appendChild(I),f.count>1){const z=document.createElement("span");z.className="gengage-chat-review-pill-count",z.textContent=String(f.count),v.appendChild(z)}u.appendChild(v)}n.appendChild(u)}return d(),n.appendChild(l),n}function Ye(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Xe(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mt(e,t=!0){const n=Ye(e);if(t){const o=Math.floor(n),i=n-o>=.5?1:0,r=5-o-i;return"★".repeat(o)+(i?"½":"")+"☆".repeat(r)}const a=Math.round(n);return"★".repeat(a)+"☆".repeat(5-a)}function _e(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}const ni={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function $t(e,t){if(!e||!t)return null;const n=ni[e];return n?t[n]??e:e}function ai(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-top-picks";const a=e.props?.suggestions??[];if(a.length===0)return n;const o=document.createElement("h3");o.className="gengage-chat-ai-top-picks-title",o.textContent=t.i18n?.aiTopPicksTitle??"Top Picks",n.appendChild(o);const i=document.createElement("div");i.className="gengage-chat-ai-top-picks-cards";for(let r=0;r<a.length;r++){const s=a[r],l=s.role==="winner"||r===0?oi(s,t):ii(s,t);i.appendChild(l)}return n.appendChild(i),n}function oi(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";const a=document.createElement("span");a.className="gengage-chat-ai-toppick-badge",a.textContent=$t(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH",n.appendChild(a);const o=e.product,i=o.discountPercent;if(typeof i=="number"&&i>0){const g=document.createElement("span");g.className="gengage-chat-ai-toppick-discount-badge",g.textContent=`%${Xe(i)}`,n.appendChild(g)}const r=o.imageUrl;if(r&&re(r)){const g=document.createElement("img");g.className="gengage-chat-ai-toppick-img",H(g,"src",r),g.alt=o.name??"",_e(g),n.appendChild(g)}const s=document.createElement("div");s.className="gengage-chat-ai-toppick-body";const c=o.name;if(c){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-name",g.textContent=c,s.appendChild(g)}if(e.reason){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-reason",g.textContent=e.reason,s.appendChild(g)}if(e.labels&&e.labels.length>0&&s.appendChild(Ot(e.labels)),typeof e.expertQualityScore=="number"){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-score",g.textContent=`${e.expertQualityScore}/10`,s.appendChild(g)}if(e.reviewHighlight){const g=document.createElement("blockquote");g.className="gengage-chat-ai-toppick-review",g.textContent=e.reviewHighlight,s.appendChild(g)}const l=o.price,d=o.originalPrice;if(l){const g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",d&&d!==l){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=J(d,t.pricing),g.appendChild(p),g.appendChild(document.createTextNode(" "))}const u=document.createElement("span");u.textContent=J(l,t.pricing),g.appendChild(u),s.appendChild(g)}if(n.appendChild(s),e.action){const g=o.sku??null,u=document.createElement("div");u.className="gengage-chat-ai-toppick-spinner",u.style.display=g&&t.topPicksLoadingSku===g?"":"none",n.appendChild(u);const p=document.createElement("button");p.className="gengage-chat-ai-toppick-cta",p.type="button",p.textContent=t.i18n?.viewDetails??"View Details",p.addEventListener("click",()=>{g&&(u.style.display=""),t.onAction(e.action)}),n.appendChild(p)}return n}function ii(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";const a=e.product,o=a.discountPercent;if(typeof o=="number"&&o>0){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-discount-badge",d.textContent=`%${Xe(o)}`,n.appendChild(d)}const i=a.imageUrl;if(i&&re(i)){const d=document.createElement("img");d.className="gengage-chat-ai-toppick-img",H(d,"src",i),d.alt=a.name??"",_e(d),n.appendChild(d)}const r=document.createElement("div");r.className="gengage-chat-ai-toppick-body";const s=$t(e.role,t.i18n);if(s){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-role",d.textContent=s,r.appendChild(d)}const c=a.name;if(c){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-name",d.textContent=c,r.appendChild(d)}if(e.reason){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-reason",d.textContent=e.reason,r.appendChild(d)}e.labels&&e.labels.length>0&&r.appendChild(Ot(e.labels));const l=a.price;if(l){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price",d.textContent=J(l,t.pricing),r.appendChild(d)}if(n.appendChild(r),e.action){const d=a.sku??null,g=document.createElement("div");g.className="gengage-chat-ai-toppick-spinner",g.style.display=d&&t.topPicksLoadingSku===d?"":"none",n.appendChild(g);const u=document.createElement("button");u.className="gengage-chat-ai-toppick-cta",u.type="button",u.textContent=t.i18n?.viewDetails??"View Details",u.addEventListener("click",()=>{d&&(g.style.display=""),t.onAction(e.action)}),n.appendChild(u)}return n}function Ot(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels";for(const n of e){const a=document.createElement("span");a.className="gengage-chat-ai-toppick-label",a.dataset.sentiment=n.sentiment??"neutral",a.textContent=n.label,t.appendChild(a)}return t}function ri(e,t){const n=document.createElement("div");n.className="gengage-chat-grounding-review";const a=e.props??{},o=a.title,i=a.reviewCount,r=a.action,s=t.i18n?.groundingReviewCta??"Yorumları Oku",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.textContent="📋",n.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body";const d=document.createElement("div");if(d.className="gengage-chat-grounding-review-title",d.textContent=o??"Müşteri Yorumları",l.appendChild(d),i){const u=document.createElement("div");u.className="gengage-chat-grounding-review-subtitle";const p=t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut";u.textContent=p.replace("{count}",i),l.appendChild(u)}n.appendChild(l);const g=document.createElement("span");return g.className="gengage-chat-grounding-review-cta",g.textContent=`${s} →`,n.appendChild(g),r&&(n.style.cursor="pointer",n.addEventListener("click",()=>t.onAction(r))),n}function si(e,t){const n=document.createElement("div");n.className="gengage-chat-grouping-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const o of a){const i=document.createElement("div");if(i.className="gengage-chat-grouping-card",i.style.cursor="pointer",i.addEventListener("click",()=>t.onAction(o.action)),o.image&&re(o.image)){const l=document.createElement("img");l.className="gengage-chat-grouping-card-img",l.src=o.image,l.alt=o.name,l.width=20,l.height=20,i.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-grouping-card-body";const s=document.createElement("span");if(s.className="gengage-chat-grouping-card-name",s.textContent=o.name,r.appendChild(s),o.description){const l=document.createElement("span");l.className="gengage-chat-grouping-card-desc",l.textContent=o.description,r.appendChild(l)}if(o.labels&&o.labels.length>0){const l=document.createElement("span");l.className="gengage-chat-grouping-card-labels",l.textContent=o.labels.slice(0,3).join(" · "),r.appendChild(l)}i.appendChild(r);const c=document.createElement("span");c.className="gengage-chat-grouping-card-arrow",c.textContent="↳",i.insertBefore(c,i.firstChild),n.appendChild(i)}return n}function ci(e,t){const n=document.createElement("div");n.className="gengage-chat-suggested-search-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const o of a){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card",i.style.cursor="pointer",i.addEventListener("click",()=>t.onAction(o.action)),o.image&&re(o.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.src=o.image,c.alt=o.shortName,c.width=40,c.height=40,i.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-suggested-search-card-body";const s=document.createElement("div");if(s.className="gengage-chat-suggested-search-card-name",s.textContent=o.shortName,r.appendChild(s),o.detailedMessage){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-desc",c.textContent=o.detailedMessage,r.appendChild(c)}if(o.whyDifferent){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-diff",c.textContent=o.whyDifferent,r.appendChild(c)}i.appendChild(r),n.appendChild(i)}return n}function li(e,t){const n=document.createElement("button");n.className="gengage-chat-comparison-floating-btn",n.type="button";const a=t.i18n?.compareSelected??"Karşılaştır";return n.textContent=`${a} (${e.length})`,n.addEventListener("click",()=>{t.onAction({title:a,type:"getComparisonTable",payload:{sku_list:[...e]}})}),n}function di(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons";const n=e.props?.productName;if(n){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=n,t.appendChild(i)}const a=e.props?.pros,o=e.props?.cons;if(a&&a.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list";for(const r of a){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(o&&o.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list";for(const r of o){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}function gi(e,t){const n=e.props?.groups??[],a=e.props?.filterTags??[],o=document.createElement("div");if(o.className="gengage-chat-categories",n.length===0)return o;const i=document.createElement("div");i.className="gengage-chat-categories-tabs",i.setAttribute("role","tablist");const r=[],s=[],c=l=>{for(let d=0;d<r.length;d++){const g=d===l;r[d].classList.toggle("gengage-chat-categories-tab--active",g),r[d].setAttribute("aria-selected",String(g)),r[d].tabIndex=g?0:-1,s[d].style.display=g?"":"none"}};for(let l=0;l<n.length;l++){const d=n[l],g=`gengage-cat-tab-${l}`,u=`gengage-cat-panel-${l}`,p=document.createElement("button");p.className="gengage-chat-categories-tab",p.type="button",p.id=g,p.setAttribute("role","tab"),p.setAttribute("aria-controls",u),p.setAttribute("aria-selected",String(l===0)),p.tabIndex=l===0?0:-1,l===0&&p.classList.add("gengage-chat-categories-tab--active"),p.textContent=d.groupName,p.addEventListener("click",()=>c(l)),p.addEventListener("keydown",v=>{let y=-1;v.key==="ArrowRight"||v.key==="ArrowDown"?y=(l+1)%n.length:v.key==="ArrowLeft"||v.key==="ArrowUp"?y=(l-1+n.length)%n.length:v.key==="Home"?y=0:v.key==="End"&&(y=n.length-1),y>=0&&(v.preventDefault(),c(y),r[y].focus())}),r.push(p),i.appendChild(p);const f=document.createElement("div");f.className="gengage-chat-categories-grid",f.id=u,f.setAttribute("role","tabpanel"),f.setAttribute("aria-labelledby",g),l!==0&&(f.style.display="none");for(const v of d.products){const y=pi(v,t);f.appendChild(y)}s.push(f)}o.appendChild(i);for(const l of s)o.appendChild(l);if(a.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags";for(const d of a){const g=document.createElement("button");g.className="gengage-chat-categories-filter-tag",g.type="button",g.textContent=d.title,d.action&&g.addEventListener("click",()=>{t.onAction(d.action)}),l.appendChild(g)}o.appendChild(l)}return o}function pi(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&re(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.src=e.imageUrl,i.alt=e.name,n.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-product-card-body";const o=document.createElement("div");if(o.className="gengage-chat-product-card-name",o.textContent=e.name,a.appendChild(o),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=e.price,a.appendChild(i)}return n.appendChild(a),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",()=>{t.onProductSelect?.(e)})),n}function ui(e,t){const n=document.createElement("div");n.className="gengage-chat-handoff-notice",n.setAttribute("role","alert");const a=document.createElement("span");a.className="gengage-chat-handoff-notice-icon",a.textContent="👤",a.setAttribute("aria-hidden","true"),n.appendChild(a);const o=document.createElement("h4");o.className="gengage-chat-handoff-notice-heading",o.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",n.appendChild(o);const i=e.props?.summary;if(i){const r=document.createElement("p");r.className="gengage-chat-handoff-notice-summary",r.textContent=i,n.appendChild(r)}return n}function hi(e,t){const n=e.props?.product??e.props,a=document.createElement("div");if(a.className="gengage-chat-product-summary",!n)return a;a.style.cursor="pointer",a.addEventListener("click",p=>{p.target.closest("a")||t.onProductSelect?.(n)});const o=n.imageUrl;if(o&&oe(o)){const p=document.createElement("div");p.className="gengage-chat-product-summary__image";const f=document.createElement("img");H(f,"src",o);const v=n.name;v&&(f.alt=v),_e(f),p.appendChild(f),a.appendChild(p)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content";const r=n.brand,s=n.name;if(s){const p=document.createElement("div");p.className="gengage-chat-product-summary__name";const f=r&&!s.toLowerCase().startsWith(r.toLowerCase());p.textContent=f?`${r} ${s}`:s,i.appendChild(p)}const c=n.rating,l=n.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__rating",p.textContent=Mt(Ye(c)),typeof l=="number"&&Number.isFinite(l)){const f=document.createElement("span");f.className="gengage-chat-product-summary__review-count",f.textContent=` (${l})`,p.appendChild(f)}i.appendChild(p)}const d=n.price,g=n.originalPrice;if(d){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__price",g&&g!==d){const v=document.createElement("span");v.className="gengage-chat-product-summary__price-original",v.textContent=J(g,t.pricing),p.appendChild(v),p.appendChild(document.createTextNode(" "))}const f=document.createElement("span");f.className="gengage-chat-product-summary__price-current",f.textContent=J(d,t.pricing),p.appendChild(f),i.appendChild(p)}a.appendChild(i);const u=n.url;if(u&&oe(u)){const p=document.createElement("a");p.className="gengage-chat-product-summary__cta",H(p,"href",u),H(p,"target","_blank"),H(p,"rel","noopener noreferrer"),p.textContent=t.i18n?.productCtaLabel??"İncele",a.appendChild(p)}return a}function Dt(e){const t=e.min??1,n=e.max??99,a=Math.min(t,n),o=Math.max(t,n),i=Math.max(a,Math.min(o,e.initial??a)),r=e.compact??!1;let s=i;const c=document.createElement("div");c.className=`gengage-qty-stepper${r?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=e.decreaseSymbol??"−",l.setAttribute("aria-label",e.decreaseLabel??"Azalt");const d=document.createElement("span");d.className="gengage-qty-value",d.textContent=String(s),d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true");const g=document.createElement("button");g.className="gengage-qty-btn",g.type="button",g.textContent=e.increaseSymbol??"+",g.setAttribute("aria-label",e.increaseLabel??"Artır");const u=document.createElement("button");u.className="gengage-qty-submit",u.type="button",r?(u.textContent=e.submitIcon??"🛒",u.title=e.label??"Sepete Ekle"):u.textContent=e.label??"Sepete Ekle";function p(){l.disabled=s<=a,g.disabled=s>=o}return l.addEventListener("click",f=>{f.stopPropagation(),s>a&&(s--,d.textContent=String(s),p())}),g.addEventListener("click",f=>{f.stopPropagation(),s<o&&(s++,d.textContent=String(s),p())}),u.addEventListener("click",f=>{f.stopPropagation(),e.onSubmit(s)}),c.addEventListener("click",f=>{f.stopPropagation()}),p(),c.appendChild(l),c.appendChild(d),c.appendChild(g),c.appendChild(u),c}function Bt(){return window.innerWidth<768}const Rt={ActionButtons:({element:e,context:t})=>fi(e,t),ActionButton:({element:e,context:t})=>mi(e,t),ProductCard:({element:e,context:t})=>bi(e,t),ProductDetailsPanel:({element:e,context:t})=>_i(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>wi(e,t,n,a),ReviewHighlights:({element:e,context:t})=>ti(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage}),ComparisonTable:({element:e,context:t})=>xi(e,t),AITopPicks:({element:e,context:t})=>ai(e,t),GroundingReviewCard:({element:e,context:t})=>ri(e,t),AIGroupingCards:({element:e,context:t})=>si(e,t),AISuggestedSearchCards:({element:e,context:t})=>ci(e,t),ProsAndCons:({element:e})=>di(e),CategoriesContainer:({element:e,context:t})=>gi(e,t),HandoffNotice:({element:e,context:t})=>ui(e,t),ProductSummaryCard:({element:e,context:t})=>hi(e,t),Divider:({element:e})=>ki(e)},Qe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const o=t(a);o&&n.appendChild(o)}return n};function Zt(){return{...Rt}}function Ut(e,t,n=Rt,a=Qe){return Xn({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function fi(e,t){const n=document.createElement("div");n.className="gengage-chat-action-buttons";const a=e.props?.buttons;if(a)for(const o of a){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=o.label,i.addEventListener("click",()=>t.onAction(o.action)),n.appendChild(i)}return n}function mi(e,t){const n=document.createElement("button");n.className="gengage-chat-action-btn";const a=e.props?.label;typeof a=="string"&&(n.textContent=a);const o=e.props?.action;return o&&n.addEventListener("click",()=>t.onAction(o)),n}function bi(e,t){const n=document.createElement("div");n.className="gengage-chat-product-card";const a=e.props?.product??e.props;if(!a)return n;const o=a.sku;o&&(n.dataset.sku=o),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",_=>{_.target.closest(".gengage-chat-product-card-atc")||_.target.closest(".gengage-chat-product-card-cta")||t.onProductSelect?.(a)}));const i=a.imageUrl;if(i&&oe(i)){const _=document.createElement("div");_.className="gengage-chat-product-card-img-wrapper";const w=document.createElement("img");w.className="gengage-chat-product-card-img",w.loading="lazy",H(w,"src",i);const E=a.name;E&&(w.alt=E),_e(w),_.appendChild(w);const P=a.discountPercent;if(typeof P=="number"&&P>0){const C=document.createElement("span");C.className="gengage-chat-product-card-discount-badge",C.textContent=`%${Xe(P)}`,_.appendChild(C)}const h=a.sku;if(h){const C=document.createElement("button");C.className="gengage-chat-find-similar-pill",C.type="button",C.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",C.addEventListener("click",A=>{A.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:h,...i?{image_url:i}:{}}})}),_.appendChild(C)}const k=a.sku;if(k&&t.onFavoriteToggle){const C=document.createElement("button");C.className="gengage-chat-favorite-btn",C.type="button",C.setAttribute("aria-label","Favorilere ekle");const A=t.favoritedSkus?.has(k)??!1;A&&C.classList.add("gengage-chat-favorite-btn--active");const $=A?"currentColor":"none";C.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${$}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,C.addEventListener("click",N=>{N.stopPropagation(),C.classList.toggle("gengage-chat-favorite-btn--active");const T=C.querySelector("svg");T&&T.setAttribute("fill",C.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(k,a)}),_.appendChild(C)}n.appendChild(_)}const r=document.createElement("div");r.className="gengage-chat-product-card-body";const s=a.brand;if(s){const _=document.createElement("div");_.className="gengage-chat-product-card-brand",_.textContent=s,r.appendChild(_)}const c=a.name;if(c){const _=document.createElement("div");_.className="gengage-chat-product-card-name",_.textContent=c,r.appendChild(_)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const _=document.createElement("div");if(_.className="gengage-chat-product-card-rating",_.textContent=Mt(l),typeof d=="number"&&Number.isFinite(d)){const w=document.createElement("span");w.className="gengage-chat-product-card-review-count",w.textContent=` (${d})`,_.appendChild(w)}r.appendChild(_)}const g=a.price,u=a.originalPrice;if(a.price_async===!0){const _=document.createElement("div");_.className="gengage-chat-product-card-price";const w=document.createElement("span");w.className="gengage-chat-price-skeleton",_.appendChild(w),r.appendChild(_),setTimeout(()=>{w.parentElement&&(g?w.replaceWith(document.createTextNode(J(g,t.pricing))):w.remove())},300)}else if(g){const _=document.createElement("div");if(_.className="gengage-chat-product-card-price",u&&u!==g){const E=document.createElement("span");E.className="gengage-chat-product-card-original-price",E.textContent=J(u,t.pricing),_.appendChild(E),_.appendChild(document.createTextNode(" "))}const w=document.createElement("span");w.textContent=J(g,t.pricing),_.appendChild(w),r.appendChild(_)}const f=a.inStock;if(typeof f=="boolean"){const _=document.createElement("div");_.className=`gengage-chat-product-card-stock ${f?"is-in-stock":"is-out-of-stock"}`,_.textContent=f?t.i18n?.inStockLabel??"Stokta":t.i18n?.outOfStockLabel??"Tükendi",r.appendChild(_)}const v=a.promotions;if(v&&v.length>0){const _=document.createElement("div");_.className="gengage-chat-product-card-promos";for(const w of v){const E=document.createElement("span");E.className="gengage-chat-product-card-promo-badge",E.textContent=w,_.appendChild(E)}r.appendChild(_)}n.appendChild(r);const y=a.url,I=a.sku,z=e.props?.action;if(z){const _=document.createElement("button");_.className="gengage-chat-product-card-cta",_.type="button",_.textContent=z.title||t.i18n?.productCtaLabel||"Incele",_.addEventListener("click",()=>t.onAction(z)),n.appendChild(_)}else if(y&&oe(y)){const _=document.createElement("a");_.className="gengage-chat-product-card-cta",H(_,"href",y),H(_,"target","_blank"),H(_,"rel","noopener noreferrer"),_.textContent=t.i18n?.productCtaLabel??"İncele",_.addEventListener("click",w=>{t.onProductClick&&I&&(w.preventDefault(),t.onProductClick({sku:I,url:y}))}),n.appendChild(_)}const b=a.cartCode;if(b&&I){const _=Dt({compact:!0,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:w=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:I,cartCode:b,quantity:w}})}});_.classList.add("gengage-chat-product-card-atc"),n.appendChild(_)}if(t.comparisonSelectMode&&I&&t.onToggleComparisonSku){const _=document.createElement("div");_.className="gengage-chat-comparison-select-wrapper";const w=document.createElement("input");return w.type="checkbox",w.className="gengage-chat-comparison-checkbox",w.checked=t.comparisonSelectedSkus?.includes(I)??!1,w.addEventListener("change",()=>{t.onToggleComparisonSku?.(I)}),_.appendChild(w),_.appendChild(n),_}return n}function _i(e,t){const n=document.createElement("article");n.className="gengage-chat-product-details-panel";const a=e.props?.product??e.props;if(!a)return n;const o=a.images,i=a.imageUrl,r=a.sku;if(o&&o.length>1){const h=document.createElement("div");h.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const k=document.createElement("img");k.className="gengage-chat-product-details-img";const C=o.find(q=>oe(q));C&&H(k,"src",C);const A=a.name;A&&(k.alt=A),_e(k),h.appendChild(k);const $=document.createElement("div");$.className="gengage-chat-product-gallery-thumbs";let N=null,T=0;for(let q=0;q<o.length;q++){const Q=o[q];if(!Q||!oe(Q))continue;const W=document.createElement("img");W.className="gengage-chat-product-gallery-thumb",q===0&&(W.classList.add("gengage-chat-product-gallery-thumb--active"),N=W),H(W,"src",Q),W.alt=`${A??"Product"} ${q+1}`,W.width=48,W.height=48,_e(W),W.addEventListener("click",()=>{H(k,"src",Q),N&&N.classList.remove("gengage-chat-product-gallery-thumb--active"),W.classList.add("gengage-chat-product-gallery-thumb--active"),N=W,T=q}),$.appendChild(W)}let j=0;const X=50;if(k.addEventListener("touchstart",q=>{j=q.changedTouches[0].clientX},{passive:!0}),k.addEventListener("touchend",q=>{const Q=q.changedTouches[0].clientX,W=j-Q;if(Math.abs(W)<X)return;const ft=$.querySelectorAll(".gengage-chat-product-gallery-thumb"),mt=W>0?Math.min(T+1,ft.length-1):Math.max(T-1,0);mt!==T&&ft[mt]&&ft[mt].click()}),h.appendChild($),r){const q=document.createElement("button");q.className="gengage-chat-find-similar-pill",q.type="button",q.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",q.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...C?{image_url:C}:{}}})}),h.appendChild(q)}n.appendChild(h)}else if(i&&oe(i)){const h=document.createElement("div");h.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const k=document.createElement("img");k.className="gengage-chat-product-details-img",k.loading="lazy",H(k,"src",i),_e(k);const C=a.name;if(C&&(k.alt=C),h.appendChild(k),r){const A=document.createElement("button");A.className="gengage-chat-find-similar-pill",A.type="button",A.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",A.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...i?{image_url:i}:{}}})}),h.appendChild(A)}n.appendChild(h)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const h=document.createElement("h3");h.className="gengage-chat-product-details-title",h.textContent=c,s.appendChild(h)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const h=document.createElement("div");if(h.className="gengage-chat-product-details-rating",h.textContent=`★ ${Ye(l).toFixed(1)}`,typeof d=="number"&&Number.isFinite(d)){const k=document.createElement("span");k.className="gengage-chat-product-details-review-count",k.textContent=` (${d})`,h.appendChild(k)}s.appendChild(h)}const g=a.price,u=a.originalPrice;if(a.price_async===!0){const h=document.createElement("div");h.className="gengage-chat-product-details-price";const k=document.createElement("span");k.className="gengage-chat-price-skeleton",h.appendChild(k),s.appendChild(h),setTimeout(()=>{if(k.parentElement)if(g){const C=document.createElement("span");C.className="gengage-chat-product-details-current-price",C.textContent=J(g,t.pricing),k.replaceWith(C)}else k.remove()},300)}else if(g){const h=document.createElement("div");if(h.className="gengage-chat-product-details-price",u&&u!==g){const C=document.createElement("span");C.className="gengage-chat-product-details-original-price",C.textContent=J(u,t.pricing),h.appendChild(C),h.appendChild(document.createTextNode(" "))}const k=document.createElement("span");k.className="gengage-chat-product-details-current-price",k.textContent=J(g,t.pricing),h.appendChild(k),s.appendChild(h)}const f=a.inStock;if(typeof f=="boolean"){const h=document.createElement("div");h.className=`gengage-chat-product-details-stock ${f?"is-in-stock":"is-out-of-stock"}`,h.textContent=f?"Stokta var":"Stokta yok",s.appendChild(h)}const v=a.promotions;if(v&&v.length>0){const h=document.createElement("div");h.className="gengage-chat-product-details-promos";for(const k of v){const C=document.createElement("span");C.className="gengage-chat-product-details-promo-badge",C.textContent=k,h.appendChild(C)}s.appendChild(h)}const y=a.variants;if(y&&y.length>0){const h=document.createElement("div");h.className="gengage-chat-product-variants";const k=document.createElement("div");k.className="gengage-chat-product-variants-label",k.textContent=t.i18n?.variantsLabel??"Varyantlar",h.appendChild(k);const C=document.createElement("div");C.className="gengage-chat-product-variants-list";for(const A of y){const $=A.name??A.variant_name,N=A.sku;if(!$&&!N)continue;const T=document.createElement("button");T.className="gengage-chat-product-variant-btn",T.type="button";const j=$??N??"",X=A.price;X&&String(X)!==String(g)?T.textContent=`${j} - ${J(String(X),t.pricing)}`:T.textContent=j,N&&T.addEventListener("click",()=>{t.onAction({title:j,type:"launchVariant",payload:{sku:N}})}),C.appendChild(T)}h.appendChild(C),s.appendChild(h)}const I=a.sku,z=a.cartCode,b=document.createElement("div");b.className="gengage-chat-product-details-actions";const _=e.props?.action;if(_){const h=document.createElement("button");h.className="gengage-chat-product-details-cta",h.type="button",h.textContent=_.title||t.i18n?.productCtaLabel||"Incele",h.addEventListener("click",()=>t.onAction(_)),b.appendChild(h)}else{const h=a.url;if(h&&oe(h)){const k=document.createElement("a");k.className="gengage-chat-product-details-cta",H(k,"href",h),H(k,"target","_blank"),H(k,"rel","noopener noreferrer"),k.textContent=t.i18n?.productCtaLabel??"Incele",k.addEventListener("click",C=>{t.onProductClick&&I&&(C.preventDefault(),t.onProductClick({sku:I,url:h}))}),b.appendChild(k)}}if(z&&I){const h=Dt({compact:!1,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:k=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:I,cartCode:z,quantity:k}})}});h.classList.add("gengage-chat-product-details-atc-stepper"),b.appendChild(h)}const w=a.url;if(w&&oe(w)){let h=function(T,j){const X=document.createElementNS($,"circle");X.setAttribute("cx",T),X.setAttribute("cy",j),X.setAttribute("r","3"),N.appendChild(X)},k=function(T,j,X,q){const Q=document.createElementNS($,"line");Q.setAttribute("x1",T),Q.setAttribute("y1",j),Q.setAttribute("x2",X),Q.setAttribute("y2",q),N.appendChild(Q)};const C=document.createElement("button");C.className="gengage-chat-product-details-share",C.type="button";const A=t.i18n?.shareButton??"Paylaş";C.title=A,C.setAttribute("aria-label",A);const $="http://www.w3.org/2000/svg",N=document.createElementNS($,"svg");N.setAttribute("width","18"),N.setAttribute("height","18"),N.setAttribute("viewBox","0 0 24 24"),N.setAttribute("fill","none"),N.setAttribute("stroke","currentColor"),N.setAttribute("stroke-width","2"),N.setAttribute("stroke-linecap","round"),N.setAttribute("stroke-linejoin","round"),h("18","5"),h("6","12"),h("18","19"),k("8.59","13.51","15.42","17.49"),k("15.41","6.51","8.59","10.49"),C.appendChild(N),C.addEventListener("click",async()=>{const T=a.name;try{navigator.share?await navigator.share({title:T??"",url:w}):navigator.clipboard&&(await navigator.clipboard.writeText(w),C.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>C.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),b.appendChild(C)}b.childElementCount>0&&s.appendChild(b),n.appendChild(s);const E=a.description,P=a.specifications;return(E||P)&&n.appendChild(vi(E,P,t)),n}function vi(e,t,n){const a=document.createElement("div");a.className="gengage-chat-product-detail-tabs";const o=document.createElement("div");o.className="gengage-chat-product-detail-tab-bar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active",s.type="button",s.textContent=n.i18n?.productInfoTab??"Ürün Bilgileri",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",c.textContent=e,i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab${e?"":" gengage-chat-product-detail-tab--active"}`,s.type="button",s.textContent=n.i18n?.specificationsTab??"Teknik Özellikler",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const d=Array.isArray(t)?t:Object.entries(t).map(([g,u])=>({key:g,value:u}));for(const g of d){const u=document.createElement("tr"),p=document.createElement("td");p.className="gengage-chat-product-specs-key",p.textContent=g.key;const f=document.createElement("td");f.className="gengage-chat-product-specs-value",f.textContent=g.value,u.appendChild(p),u.appendChild(f),l.appendChild(u)}c.appendChild(l),i.push(c)}const r=o.querySelectorAll(".gengage-chat-product-detail-tab");r.forEach((s,c)=>{s.addEventListener("click",()=>{r.forEach(l=>l.classList.remove("gengage-chat-product-detail-tab--active")),s.classList.add("gengage-chat-product-detail-tab--active"),i.forEach((l,d)=>{l.style.display=d===c?"":"none"})})}),a.appendChild(o);for(const s of i)a.appendChild(s);return a}function jt(e,t,n){if(!n||n.type==="related")return e;const a=e.map(o=>{const r=t.elements[o]?.props?.product,s=r?Number(r.price):NaN;return{id:o,price:Number.isFinite(s)?s:1/0}});return a.sort((o,i)=>o.price===1/0&&i.price===1/0?0:o.price===1/0?1:i.price===1/0?-1:n.direction==="desc"?i.price-o.price:o.price-i.price),a.map(o=>o.id)}function yi(e,t,n,a){const o=jt(t,n,a),i=new Map;for(const r of Array.from(e.children)){const s=r.dataset.elementId;s&&i.set(s,r)}for(const r of o){const s=i.get(r);s&&e.appendChild(s)}}function wi(e,t,n,a){const o=document.createElement("div");o.className="gengage-chat-product-grid-wrapper";const i=e.children??[];if(i.length>1&&a?.onSortChange){const l=document.createElement("div");l.className="gengage-chat-product-sort-toolbar";const d=a.productSort??{type:"related"},g=[{label:a.i18n?.sortRelated??"Önerilen",sortState:{type:"related"}},{label:a.i18n?.sortPriceAsc??"Fiyat ↑",sortState:{type:"price",direction:"asc"}},{label:a.i18n?.sortPriceDesc??"Fiyat ↓",sortState:{type:"price",direction:"desc"}}];for(const u of g){const p=document.createElement("button");p.className="gengage-chat-product-sort-btn",p.type="button",d.type===u.sortState.type&&d.direction===u.sortState.direction&&p.classList.add("gengage-chat-product-sort-btn--active"),p.textContent=u.label,p.addEventListener("click",()=>{a.onSortChange?.(u.sortState),yi(r,i,t,u.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(v=>v.classList.remove("gengage-chat-product-sort-btn--active")),p.classList.add("gengage-chat-product-sort-btn--active")}),l.appendChild(p)}if(a.onToggleComparisonSku){const u=document.createElement("div");u.className="gengage-chat-product-sort-separator",l.appendChild(u);const p=document.createElement("button");p.className="gengage-chat-comparison-toggle-btn",p.type="button",a.comparisonSelectMode&&p.classList.add("gengage-chat-comparison-toggle-btn--active"),p.textContent=a.i18n?.compareSelected??"Karşılaştır",p.addEventListener("click",()=>{a.onToggleComparisonSku?.("")}),l.appendChild(p)}o.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-product-grid";const s=jt(i,t,a?.productSort);for(const l of s){if(!t.elements[l])continue;const d=n(l);d&&(d.dataset.elementId=l,r.appendChild(d))}if(Bt()&&r.classList.add("gengage-chat-product-grid--mobile"),o.appendChild(r),e.props?.endOfList!==!0&&i.length>0){const l=document.createElement("button");l.className="gengage-chat-product-grid-view-more",l.type="button",l.textContent=a?.i18n?.viewMoreLabel??"Daha Fazla Göster",l.addEventListener("click",()=>{a?.onAction({title:"More",type:"moreProductList",payload:{}})}),o.appendChild(l)}if(a?.comparisonSelectMode&&a.comparisonSelectedSkus&&a.comparisonSelectedSkus.length>=2){const l=li(a.comparisonSelectedSkus,a);o.appendChild(l)}return o}function xi(e,t){const n=e.props??{},a=n.keyDifferencesHtml,o=n.recommended,i=n.products??[],r=n.attributes??[],s=n.highlights??[],c=n.specialCases,l=n.recommendedText,d=n.winnerHits,g=n.productActions;if(!o)return document.createElement("div");const u={recommended:o,products:i,attributes:r,highlights:s,specialCases:c,onProductClick:f=>{t.onProductClick?.({sku:f,url:""})}};l!==void 0&&(u.recommendedText=l),d!==void 0&&(u.winnerHits=d),g!==void 0&&(u.productActions=g),a!==void 0&&(u.keyDifferencesHtml=a),t.i18n&&(u.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const p=Qo(u);return Bt()&&p.classList.add("gengage-chat-comparison--mobile"),p}function ki(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const n=e.props?.label;if(n){const a=document.createElement("div");a.className="gengage-chat-divider-wrapper";const o=document.createElement("span");return o.className="gengage-chat-divider-label",o.textContent=n,a.appendChild(t),a.appendChild(o),a}return t}const Ci=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function Ei(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&Ci.has(a.tagName)?(n.length>0&&(t.push(n),n=[]),t.push([a])):n.push(a);return n.length>0&&t.push(n),t}function Si(e){for(const t of e)for(const n of t)if(n.nodeType===Node.ELEMENT_NODE&&(n.tagName==="TABLE"||n.querySelector?.("table")))return!0;return!1}function Ti(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ii(e){const{container:t,html:n,delayMs:a=30,onTick:o,onComplete:i}=e,r=document.createElement("template");r.innerHTML=n;const s=Ei(r.content.childNodes);if(Ti()||s.length<=1||Si(s))return t.innerHTML=n,i?.(),{complete(){},cancel(){},isRunning:!1};t.innerHTML="";let c=0,l=null,d=!0;function g(){if(!d||c>=s.length){d=!1,i?.();return}const u=s[c],p=document.createElement("span");p.className="gengage-chat-typewriter-block";for(const f of u)p.appendChild(f.cloneNode(!0));t.appendChild(p),c++,o?.(),c<s.length?l=setTimeout(g,a):(d=!1,i?.())}return g(),{complete(){d&&(l!==null&&clearTimeout(l),d=!1,t.innerHTML=n,i?.())},cancel(){l!==null&&clearTimeout(l),d=!1},get isRunning(){return d}}}function zi(e){const{container:t,mentions:n,onProductClick:a}=e;if(n.length===0)return;const o=new Map;for(const i of n)i.short_name.length!==0&&o.set(i.short_name.toLowerCase(),i);if(o.size!==0)for(const[i,r]of o){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),l=!1;for(;c&&!l;){const d=c.textContent??"",g=d.toLowerCase().indexOf(i);if(g===-1){c=s.nextNode();continue}const u=d.slice(0,g),p=d.slice(g,g+r.short_name.length),f=d.slice(g+r.short_name.length),v=c.parentNode;if(!v){c=s.nextNode();continue}const y=document.createElement("a");y.className="gengage-product-mention",y.textContent=p,y.href="#",y.addEventListener("click",I=>{I.preventDefault(),a(r.sku)}),u&&v.insertBefore(document.createTextNode(u),c),v.insertBefore(y,c),f&&v.insertBefore(document.createTextNode(f),c),v.removeChild(c),l=!0}}}const Ai=new Set(["search","info","review","similar"]),Ni=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function Pi(e){return!!(e.icon&&Ai.has(e.icon)||e.action?.type&&Ni.has(e.action.type))}const Ft="gengage_choice_prompter_dismissed";function Li(e){const t=document.createElement("div");t.className="gengage-chat-choice-prompter";const n=document.createElement("div");n.className="gengage-chat-choice-prompter-heading",n.textContent=e.heading,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-choice-prompter-suggestion",a.textContent=e.suggestion,t.appendChild(a);const o=document.createElement("button");o.type="button",o.className="gengage-chat-choice-prompter-cta",o.textContent=e.ctaLabel,o.addEventListener("click",()=>{qt(),t.remove(),e.onCtaClick()}),t.appendChild(o);const i=document.createElement("button");return i.type="button",i.className="gengage-chat-choice-prompter-dismiss",i.textContent="×",i.setAttribute("aria-label","Dismiss"),i.addEventListener("click",()=>{qt(),t.remove(),e.onDismiss?.()}),t.appendChild(i),t}function Mi(){try{return sessionStorage.getItem(Ft)==="1"}catch{return!1}}function qt(){try{sessionStorage.setItem(Ft,"1")}catch{}}const $i="gengage_assistant",Oi=3,le="sessions",te="context",ie="payload",ne="favorites";function Ae(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function ke(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Di{constructor(t=$i,n=Oi){this._db=null,this._dbName=t,this._version=n}async open(){return this._db?this._db:new Promise((t,n)=>{const a=indexedDB.open(this._dbName,this._version);a.onupgradeneeded=o=>{const i=a.result,r=o.oldVersion;r<1&&(i.createObjectStore(le,{keyPath:["userId","appId","sessionId"]}),i.createObjectStore(te,{keyPath:["sessionId","threadId"]}),i.createObjectStore(ie,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),i.createObjectStore(ne,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(i.objectStoreNames.contains(le)&&i.deleteObjectStore(le),i.objectStoreNames.contains(ie)&&i.deleteObjectStore(ie),i.createObjectStore(le,{keyPath:["userId","appId","sessionId"]}),i.createObjectStore(ie,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),i.objectStoreNames.contains(te)||i.createObjectStore(te,{keyPath:["sessionId","threadId"]})),r<3&&(i.objectStoreNames.contains(ne)||i.createObjectStore(ne,{keyPath:["userId","appId","sku"]}))},a.onsuccess=()=>{this._db=a.result,t(this._db)},a.onerror=()=>n(a.error)})}close(){this._db?.close(),this._db=null}async saveSession(t){const a=this._requireDb().transaction(le,"readwrite");a.objectStore(le).put(t),await ke(a)}async loadSession(t,n,a){const i=this._requireDb().transaction(le,"readonly");return await Ae(i.objectStore(le).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(te,"readwrite");a.objectStore(te).put(t),await ke(a)}async loadContext(t,n){const o=this._requireDb().transaction(te,"readonly");return await Ae(o.objectStore(te).get([t,n]))??null}async deleteContextsAfterThread(t,n){const o=this._requireDb().transaction(te,"readwrite"),r=o.objectStore(te).openCursor();await new Promise((s,c)=>{r.onsuccess=()=>{const l=r.result;if(!l){s();return}const d=l.value;if(d.sessionId===t&&d.threadId>n)try{l.delete()}catch{}l.continue()},r.onerror=()=>c(r.error)}),await ke(o)}async loadLatestContext(t){const o=this._requireDb().transaction(te,"readonly").objectStore(te),i=IDBKeyRange.bound([t,""],[t,"￿"]);return new Promise((r,s)=>{const c=o.openCursor(i,"prev");c.onsuccess=()=>{const l=c.result;r(l?l.value:null)},c.onerror=()=>s(c.error)})}async savePayload(t){const a=this._requireDb().transaction(ie,"readwrite");a.objectStore(ie).put(t),await ke(a)}async loadPayload(t,n){const o=this._requireDb().transaction(ie,"readonly");return await Ae(o.objectStore(ie).get([t,n]))??null}async loadPayloadsByThread(t){const o=this._requireDb().transaction(ie,"readonly").objectStore(ie).index("threadId"),i=[];return new Promise((r,s)=>{const c=o.openCursor(IDBKeyRange.only(t));c.onsuccess=()=>{const l=c.result;if(!l){r(i);return}i.push(l.value),l.continue()},c.onerror=()=>s(c.error)})}async saveFavorite(t){const a=this._requireDb().transaction(ne,"readwrite");a.objectStore(ne).put(t),await ke(a)}async removeFavorite(t,n,a){const i=this._requireDb().transaction(ne,"readwrite");i.objectStore(ne).delete([t,n,a]),await ke(i)}async loadFavorites(t,n){const o=this._requireDb().transaction(ne,"readonly");return(await Ae(o.objectStore(ne).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const i=this._requireDb().transaction(ne,"readonly");return await Ae(i.objectStore(ne).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const Bi=["comparisonTable","groupList","productDetailsSimilars","productList"];class Ri{constructor(t){this._lockCount=1,this._hiddenByUser=!1,this._lastPanelContentType=null,this._chatShown=!1,this._isFavoritesMode=!1,this._lastExtended=!1,this._onChange=t.onChange;const n=new Set(Bi);t.productDetailsInPanel&&n.add("productDetails"),this._panelContentTypes=n}get isExtended(){return this._lockCount===0&&!this._hiddenByUser&&!this._isFavoritesMode&&this._lastPanelContentType!==null&&this._panelContentTypes.has(this._lastPanelContentType)&&this._chatShown}unlock(){this._lockCount>0&&this._lockCount--,this._checkStateChange()}lock(){this._lockCount++,this._checkStateChange()}setHiddenByUser(t){this._hiddenByUser=t,this._checkStateChange()}setChatShown(t){this._chatShown=t,this._checkStateChange()}setFavoritesMode(t){this._isFavoritesMode=t,this._checkStateChange()}setPanelContentType(t){this._lastPanelContentType=t,this._checkStateChange()}_checkStateChange(){const t=this.isExtended;t!==this._lastExtended&&(this._lastExtended=t,this._onChange(t))}}class Zi{constructor(t){this.deps=t,this.snapshots=new Map,this.snapshotTypes=new Map,this.activePanelMessageId=null,this.currentType=null,this.threads=[]}snapshotForMessage(t){const n=this.deps.drawer();if(!n?.hasPanelContent()||n.isPanelLoading())return;const a=n.getPanelContentElement();if(!a)return;const o=a.cloneNode(!0);this.snapshots.set(t,o),this.currentType&&this.snapshotTypes.set(t,this.currentType)}attachClickHandler(t){const a=this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(t)}"]`);a&&(a.style.cursor="pointer",a.addEventListener("click",()=>this.restoreForMessage(t)))}restoreForMessage(t){const n=this.snapshots.get(t);if(!n)return!1;const a=this.deps.shadow(),o=this.deps.drawer();this.activePanelMessageId&&a?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"),a?.querySelector(`[data-message-id="${CSS.escape(t)}"]`)?.classList.add("gengage-chat-bubble--active"),this.activePanelMessageId=t,o?.setPanelContent(n.cloneNode(!0));const r=this.snapshotTypes.get(t);return r&&(this.currentType=r,this.updateTopBar(r)),!0}notifyExtension(t){const n=this.deps.bridge();t?setTimeout(()=>n?.send("maximize-pdp",{}),350):setTimeout(()=>n?.send("minify-pdp",{}),200)}titleForComponent(t){const n=this.deps.i18n();switch(t){case"ProductDetailsPanel":return n.panelTitleProductDetails;case"ProductGrid":return n.panelTitleSimilarProducts;case"ComparisonTable":return n.panelTitleComparisonResults;case"AIGroupingCards":return n.panelTitleCategories;default:return""}}updateTopBar(t){const n=this.deps.currentThreadId();if(!n)return;const a=this.threads.indexOf(n),o=a>0,i=a>=0&&a<this.threads.length-1,r=this.titleForComponent(t);this.deps.drawer()?.updatePanelTopBar(o,i,r)}updateTopBarForLoading(t){const n=this.deps.i18n(),o={productDetails:n.panelTitleProductDetails,productList:n.panelTitleSimilarProducts,comparisonTable:n.panelTitleComparisonResults,groupList:n.panelTitleCategories}[t]??"";if(o){const i=this.deps.currentThreadId(),r=i?this.threads.indexOf(i):-1,s=r>0,c=r>=0&&r<this.threads.length-1;this.deps.drawer()?.updatePanelTopBar(s,c,o)}}updateExtendedMode(t){const a={ComparisonTable:"comparisonTable",AIGroupingCards:"groupList",ProductDetailsPanel:"productDetails",ProductGrid:"productList"}[t]??null;this.deps.extendedModeManager()?.setPanelContentType(a)}navigateBack(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>0){const a=this.threads[n-1];a&&this.deps.rollbackToThread(a)}}navigateForward(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>=0&&n<this.threads.length-1){const a=this.threads[n+1];a&&this.deps.rollbackToThread(a)}}toPanelSpec(t){const n=t.elements[t.root];if(!n||n.type!=="ProductCard")return t;const a={...n,type:"ProductDetailsPanel"};return{root:t.root,elements:{...t.elements,[t.root]:a}}}destroy(){this.snapshots.clear(),this.snapshotTypes.clear(),this.activePanelMessageId=null,this.currentType=null,this.threads=[]}}class Ht{constructor(t){this.favoritedSkus=new Set,this._db=t}get db(){return this._db}set db(t){this._db=t}async persist(t){if(!this._db)return;const n=t.messages.map(o=>{const i={id:o.id,role:o.role,timestamp:o.timestamp,status:o.status==="streaming"?"done":o.status};return o.threadId!==void 0&&(i.threadId=o.threadId),o.content!==void 0&&(i.content=o.content),o.silent&&(i.silent=!0),i}),a={};for(const[o,i]of t.panelSnapshots)i.querySelector(".gengage-chat-panel-skeleton")||(a[o]=i.innerHTML);await this._db.saveSession({userId:t.userId,appId:t.appId,sessionId:t.sessionId,messages:n,currentThreadId:t.currentThreadId,lastThreadId:t.lastThreadId,createdAt:t.chatCreatedAt,panelThreads:t.panelThreads.length>0?t.panelThreads:void 0,thumbnailEntries:t.thumbnailEntries.length>0?t.thumbnailEntries:void 0,panelSnapshotHtml:Object.keys(a).length>0?a:void 0}),t.lastBackendContext&&t.currentThreadId&&await this._db.saveContext({sessionId:t.sessionId,threadId:t.currentThreadId,context:t.lastBackendContext});for(const o of t.messages)o.uiSpec&&o.threadId&&await this._db.savePayload({threadId:o.threadId,messageId:o.id,uiSpec:o.uiSpec});try{sessionStorage.setItem("gengage_restore_session_id",t.sessionId)}catch{}}async saveAndOpenURL(t,n,a){try{await n()}catch{}a?.send("openURLInNewTab",{url:t}),window.location.href=t}async loadPayload(t,n){if(!this._db)return null;for(let a=0;a<3;a++){try{const o=await this._db.loadPayload(t,n);if(o)return o.uiSpec}catch{}a<2&&await new Promise(o=>setTimeout(o,100))}return null}async loadFavorites(t,n){if(this._db)try{const a=await this._db.loadFavorites(t,n);for(const o of a)this.favoritedSkus.add(o.sku)}catch{}}async toggleFavorite(t,n,a,o){this._db&&(this.favoritedSkus.has(a)?(this.favoritedSkus.delete(a),await this._db.removeFavorite(t,n,a)):(this.favoritedSkus.add(a),await this._db.saveFavorite({userId:t,appId:n,sku:a,name:o.name,imageUrl:o.imageUrl,price:o.price,savedAt:new Date().toISOString()})))}close(){this._db?.close(),this._db=null}}const Vt="gengage_kvkk_shown",Ui=["kvkk","kişisel veri","kisisel veri"],ji=/\b6698\b/;function et(e){const t=e.toLowerCase();return Ui.some(n=>t.includes(n))||ji.test(t)}function Gt(e){try{return localStorage.getItem(`${Vt}_${e}`)==="1"}catch{return!1}}function Fi(e){try{localStorage.setItem(`${Vt}_${e}`,"1")}catch{}}function qi(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const o of a)if(et(o.textContent??"")){o.remove();break}return n.innerHTML.trim()}function Hi(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(et(n.textContent??""))return n.outerHTML;return null}const Vi={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function Gi(e){return e?Vi[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const Wi=':host{all:initial;font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px)}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 12px);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(15, 23, 42, .18));--_gengage-border-color: var(--gengage-border-color, #e5e7eb);--_gengage-discount-color: var(--gengage-discount-color, #ef4444);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #0f172a47;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #0f172a47}.gengage-chat-launcher svg{width:24px;height:24px}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:#1e293b;color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:#1e293b}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-proactive{position:fixed;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 14px);right:var(--_gengage-chat-launcher-right);width:280px;padding:16px 18px;border-radius:16px;background:#fff;box-shadow:0 8px 30px #0000001f,0 2px 8px #0000000f;opacity:0;transform:translateY(8px) scale(.96);transition:opacity .25s ease,transform .25s ease;z-index:2147483645}.gengage-chat-proactive--visible{opacity:1;transform:translateY(0) scale(1)}.gengage-chat-proactive-message{margin:0 0 12px;font-size:14px;line-height:1.5;color:#1f2937}.gengage-chat-proactive-actions{display:flex;gap:8px}.gengage-chat-proactive-accept{flex:1;padding:8px 16px;border:none;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .15s ease}.gengage-chat-proactive-accept:hover{filter:brightness(1.08)}.gengage-chat-proactive-dismiss{position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:transparent;color:#64748b;font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center}.gengage-chat-proactive-dismiss:hover{color:#475569;background:#f1f5f9}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform-origin:right center;clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:16px;bottom:calc(16px + env(safe-area-inset-bottom))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;border-top:1px solid rgba(0,0,0,.06);box-shadow:0 -4px 16px #0000001a,0 12px 40px #0f172a2e;padding-bottom:env(safe-area-inset-bottom,0px);clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile.gengage-chat-root--open:before{content:"";position:fixed;inset:0;background:#0000001f;z-index:-1;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0;border-top:none}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--_gengage-border-color, #e5e7eb);transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;border:2px solid rgba(255,255,255,.15)}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffbf;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-close{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;width:440px;min-width:440px;border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;background:#f8fafc}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:#e5e7eb;position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:24px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:#f1f5f9;color:#334155}.gengage-chat-panel--collapsed{flex:0 0 0px!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;border-right:none!important;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #fff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:#fff;padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #2563eb);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #fff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:#f3f4f6;color:#1f2937;border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #2563eb);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-accent-primary, #3b82f6);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:#f3f4f6;padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--gengage-chat-success, #4caf50)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-chat-primary, #1976d2);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:#991b1b;font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #fff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 2px #3b82f626}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:#1f2937;resize:none;overflow-y:hidden}@media(max-width:767px){.gengage-chat-input{max-height:40px;white-space:nowrap;overflow:hidden}.gengage-chat-send{width:44px;height:44px;min-width:44px}}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 4px #0000001f}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#d1d5db;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;gap:8px;padding:6px 0 4px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.gengage-chat-action-buttons::-webkit-scrollbar{display:none}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 16px #0000001f}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:#1f2937;line-height:1.35;margin-bottom:0;min-height:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-card-review-count{color:#64748b;font-size:10px}.gengage-chat-product-card-price{display:flex;align-items:baseline;justify-content:center;gap:4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:#64748b;font-weight:400;font-size:12px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #3b82f6);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid #f1f5f9;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #0b24d6);background:#f8fafc}.gengage-chat-product-card-cta:active{background:#f1f5f9}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid #f3f4f6;background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-product-summary__rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-summary__review-count{color:#6b7280;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:#6b7280;font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #2563eb);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #2563eb);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:#1f2937}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:#f8fafc}.gengage-chat-review-tab--active{background:#f1f5f9;border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;color:#334155;box-shadow:0 1px 2px #0000000a}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:#16a34a}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:#f1f5f9;color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:#00000073;z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid #f1f5f9;border-radius:0;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-weight:700;font-size:13px}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid #f1f5f9;border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #3b82f6);border-bottom-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:#f8fafc}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid #f1f5f9;width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:#1f2937;border-bottom:1px solid #f1f5f9}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}.gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(0 0 0 100%);opacity:0;pointer-events:none;box-shadow:none}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(100% 0 0 0);opacity:0;pointer-events:none;box-shadow:none}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #3b82f6);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}@media(max-width:768px){.gengage-chat-panel-divider{display:none}.gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:column}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:100%;min-width:0;max-width:none;max-height:30dvh;border-right:none;border-bottom:1px solid var(--_gengage-border-color);padding:0 12px 12px;margin:0;border-radius:0;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-product-details-media{min-height:140px}.gengage-chat-product-details-title{font-size:15px}.gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-product-card-img{height:180px}}@media(max-width:480px){.gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-bubble{max-width:100%}}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#92400e;font-size:16px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:#16a34a;text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:#f8fafc}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid #f1f5f9}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid #f1f5f9;vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:#f8fafc;margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #3b82f6);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:#f8fafc;color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-proactive,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-cards{display:flex;flex-direction:column;gap:10px}.gengage-chat-ai-toppick-discount-badge{position:absolute;top:8px;left:8px;background:var(--gengage-discount-bg, #ef4444);color:#fff;font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;z-index:1}.gengage-chat-ai-toppick-card--winner{position:relative;display:flex;flex-direction:column;border:2px solid var(--gengage-primary-color, #3b82f6);border-radius:12px;background:#fff;overflow:hidden;transition:box-shadow .2s ease}.gengage-chat-ai-toppick-card--winner:hover{box-shadow:0 4px 16px #3b82f626}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:140px;object-fit:contain;background:#f8fafc}.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;background:#fff;padding:10px;transition:box-shadow .2s ease,transform .15s ease}.gengage-chat-ai-toppick-card--compact:hover{box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:64px;height:64px;object-fit:contain;border-radius:8px;background:#f8fafc;flex-shrink:0}.gengage-chat-ai-toppick-badge{position:absolute;top:8px;left:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;text-transform:uppercase;padding:2px 8px;border-radius:4px;z-index:1;letter-spacing:.5px}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:4px;padding:10px;flex:1;min-width:0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0}.gengage-chat-ai-toppick-name{font-size:13px;font-weight:600;color:var(--gengage-text-primary, #1e293b);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #3b82f6);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:#f1f5f9;color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-ai-toppick-reason{font-size:12px;color:var(--gengage-chat-text-secondary, #666);line-height:1.4;margin-top:4px}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:2px 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b)}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 20px);margin:6px 10px 10px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:auto;margin:0;padding:6px 14px;flex-shrink:0;align-self:center}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:3}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}@media(max-width:768px){.gengage-chat-ai-top-picks-cards{flex-direction:row;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;gap:10px;padding-bottom:4px}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{min-width:280px;max-width:280px;flex-shrink:0;scroll-snap-align:start}.gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:100%;height:100px;border-radius:8px 8px 0 0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:6px 10px 10px;align-self:stretch}.gengage-chat-rollback-btn{left:-24px}}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #3b82f6);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #3b82f6);flex-shrink:0}.gengage-chat-grouping-card-img{width:20px;height:20px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active,.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;left:8px;z-index:2;width:18px;height:18px;cursor:pointer;accent-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-comparison-floating-btn{display:block;width:100%;margin-top:8px;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center}.gengage-chat-comparison-floating-btn:hover{background:var(--gengage-primary-hover, #2563eb)}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:#f8fafc;min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:#f3f4f6;border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #3b82f6);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #3b82f6);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:wrap}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:#f3f4f6;border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:6px;left:6px;padding:2px 6px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px}.gengage-chat-product-card-stock.is-in-stock{color:var(--_gengage-success-color)}.gengage-chat-product-card-stock.is-out-of-stock{color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:8px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap}.gengage-chat-thumbnails-column{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:4px;z-index:2;pointer-events:auto}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid #e5e7eb;border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:10;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:#1f2937;margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:4px;right:6px;padding:2px 6px;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:#f8fafc;border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:#16a34a;background:#dcfce7}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile .gengage-chat-comparison-table,.gengage-chat-comparison--mobile .gengage-chat-comparison-table thead,.gengage-chat-comparison--mobile .gengage-chat-comparison-table tbody{display:block}.gengage-chat-comparison--mobile .gengage-chat-comparison-table tr{display:flex;flex-wrap:wrap}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:#f3f4f6}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:#1f2937;-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #3b82f6);border-color:var(--gengage-primary-color, #3b82f6);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#1e293b;color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-proactive-accept:focus-visible,.gengage-chat-proactive-dismiss:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}';function Ki(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function V(e,t){const n={event:e,...t};Ki()&&window.dataLayer.push(n)}function Ji(e){V("gengage-on-init",{gengage_widget:e})}function Yi(e){V("gengage-show",{gengage_widget:e})}function Xi(e,t){V("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function Qi(e){V("gengage-find-similars",{gengage_sku:e})}function er(e){V("gengage-compare-preselection",{gengage_sku:e})}function Wt(e){V("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function tr(){V("gengage-compare-clear")}function nr(e){V("gengage-compare-received",{gengage_product_count:e})}function ar(e){V("gengage-like-product",{gengage_sku:e})}function or(){V("gengage-like-list")}function ir(e,t){V("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function rr(e,t){V("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function sr(e,t){V("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function cr(){V("gengage-message-sent")}function Kt(){V("gengage-message-received")}function lr(){V("gengage-conversation-start")}function dr(){V("gengage-voice-input")}function m(e,t,n){function a(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:r,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const l=r.prototype,d=Object.keys(l);for(let g=0;g<d.length;g++){const u=d[g];u in s||(s[u]=l[u].bind(s))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function r(s){var c;const l=n?.Parent?new i:this;a(l,s),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(r,"init",{value:a}),Object.defineProperty(r,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class Ce extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Jt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Yt={};function de(e){return Yt}function Xt(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,o])=>t.indexOf(+a)===-1).map(([a,o])=>o)}function tt(e,t){return typeof t=="bigint"?t.toString():t}function nt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function at(e){return e==null}function ot(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function gr(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let o=(a.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(a)){const c=a.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,r=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return r%s/10**i}const Qt=Symbol("evaluating");function M(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Qt)return a===void 0&&(a=Qt,a=n()),a},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ve(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ge(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function en(e){return JSON.stringify(e)}function pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const tn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ur=nt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ee(e){if($e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!($e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function nn(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e}const hr=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function S(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function fr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const mr={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 br(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=ge(e._zod.def,{get shape(){const r={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return ve(this,"shape",r),r},checks:[]});return pe(e,i)}function _r(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=ge(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return ve(this,"shape",r),r},checks:[]});return pe(e,i)}function vr(e,t){if(!Ee(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(i,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ge(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return ve(this,"shape",i),i}});return pe(e,o)}function yr(e,t){if(!Ee(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ge(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return ve(this,"shape",a),a}});return pe(e,n)}function wr(e,t){const n=ge(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return ve(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return pe(e,n)}function xr(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=ge(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(n)for(const l in n){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(const l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return ve(this,"shape",c),c},checks:[]});return pe(t,r)}function kr(e,t,n){const a=ge(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const r in n){if(!(r in i))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(i[r]=new e({type:"nonoptional",innerType:o[r]}))}else for(const r in o)i[r]=new e({type:"nonoptional",innerType:o[r]});return ve(this,"shape",i),i}});return pe(t,a)}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Te(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function De(e){return typeof e=="string"?e:e?.message}function ue(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const o=De(e.inst?._zod.def?.error?.(e))??De(t?.error?.(e))??De(n.customError?.(e))??De(n.localeError?.(e))??"Invalid input";a.message=o}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function it(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ne(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const an=(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,tt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},on=m("$ZodError",an),rn=m("$ZodError",an,{Parent:Error});function Cr(e,t=n=>n.message){const n={},a=[];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))):a.push(t(o));return{formErrors:a,fieldErrors:n}}function Er(e,t=n=>n.message){const n={_errors:[]},a=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(r=>a({issues:r}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let r=n,s=0;for(;s<i.path.length;){const c=i.path[s];s===i.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(i))):r[c]=r[c]||{_errors:[]},r=r[c],s++}}};return a(e),n}const rt=e=>(t,n,a,o)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new Ce;if(r.issues.length){const s=new(o?.Err??e)(r.issues.map(c=>ue(c,i,de())));throw tn(s,o?.callee),s}return r.value},st=e=>async(t,n,a,o)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise&&(r=await r),r.issues.length){const s=new(o?.Err??e)(r.issues.map(c=>ue(c,i,de())));throw tn(s,o?.callee),s}return r.value},Be=e=>(t,n,a)=>{const o=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ce;return i.issues.length?{success:!1,error:new(e??on)(i.issues.map(r=>ue(r,o,de())))}:{success:!0,data:i.value}},Sr=Be(rn),Re=e=>async(t,n,a)=>{const o=a?Object.assign(a,{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(r=>ue(r,o,de())))}:{success:!0,data:i.value}},Tr=Re(rn),Ir=e=>(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return rt(e)(t,n,o)},zr=e=>(t,n,a)=>rt(e)(t,n,a),Ar=e=>async(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return st(e)(t,n,o)},Nr=e=>async(t,n,a)=>st(e)(t,n,a),Pr=e=>(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Be(e)(t,n,o)},Lr=e=>(t,n,a)=>Be(e)(t,n,a),Mr=e=>async(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Re(e)(t,n,o)},$r=e=>async(t,n,a)=>Re(e)(t,n,a),Or=/^[cC][^\s-]{8,}$/,Dr=/^[0-9a-z]+$/,Br=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Rr=/^[0-9a-vA-V]{20}$/,Zr=/^[A-Za-z0-9]{27}$/,Ur=/^[a-zA-Z0-9_-]{21}$/,jr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fr=/^([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})$/,sn=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)$/,qr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Hr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vr(){return new RegExp(Hr,"u")}const Gr=/^(?:(?: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])$/,Wr=/^(([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}|:))$/,Kr=/^((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])$/,Jr=/^(([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])$/,Yr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,cn=/^[A-Za-z0-9_-]*$/,Xr=/^\+[1-9]\d{6,14}$/,ln="(?:(?:\\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])))",Qr=new RegExp(`^${ln}$`);function dn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function es(e){return new RegExp(`^${dn(e)}$`)}function ts(e){const t=dn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${ln}T(?:${a})$`)}const ns=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},as=/^-?\d+$/,gn=/^-?\d+(?:\.\d+)?$/,os=/^(?:true|false)$/i,is=/^[^A-Z]*$/,rs=/^[^a-z]*$/,K=m("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),pn={number:"number",bigint:"bigint",object:"date"},un=m("$ZodCheckLessThan",(e,t)=>{K.init(e,t);const n=pn[typeof t.value];e._zod.onattach.push(a=>{const o=a._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hn=m("$ZodCheckGreaterThan",(e,t)=>{K.init(e,t);const n=pn[typeof t.value];e._zod.onattach.push(a=>{const o=a._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ss=m("$ZodCheckMultipleOf",(e,t)=>{K.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.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.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):gr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cs=m("$ZodCheckNumberFormat",(e,t)=>{K.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[o,i]=mr[t.format];e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,n&&(s.pattern=as)}),e._zod.check=r=>{const s=r.value;if(n){if(!Number.isInteger(s)){r.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?r.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):r.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<o&&r.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&r.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ls=m("$ZodCheckMaxLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const o=a.value;if(o.length<=t.maximum)return;const r=it(o);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ds=m("$ZodCheckMinLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const o=a.value;if(o.length>=t.minimum)return;const r=it(o);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gs=m("$ZodCheckLengthEquals",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=a=>{const o=a.value,i=o.length;if(i===t.length)return;const r=it(o),s=i>t.length;a.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Ze=m("$ZodCheckStringFormat",(e,t)=>{var n,a;K.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),ps=m("$ZodCheckRegex",(e,t)=>{Ze.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})}}),us=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=is),Ze.init(e,t)}),hs=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rs),Ze.init(e,t)}),fs=m("$ZodCheckIncludes",(e,t)=>{K.init(e,t);const n=Oe(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),ms=m("$ZodCheckStartsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),bs=m("$ZodCheckEndsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),_s=m("$ZodCheckOverwrite",(e,t)=>{K.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vs{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
59
- `).filter(r=>r),o=Math.min(...a.map(r=>r.length-r.trimStart().length)),i=a.map(r=>r.slice(o)).map(r=>" ".repeat(this.indent*2)+r);for(const r of i)this.content.push(r)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
60
- `))}}const ys={major:4,minor:3,patch:6},Z=m("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ys;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const o of a)for(const i of o._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(r,s,c)=>{let l=Se(r),d;for(const g of s){if(g._zod.def.when){if(!g._zod.def.when(r))continue}else if(l)continue;const u=r.issues.length,p=g._zod.check(r);if(p instanceof Promise&&c?.async===!1)throw new Ce;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,r.issues.length!==u&&(l||(l=Se(r,u)))});else{if(r.issues.length===u)continue;l||(l=Se(r,u))}}return d?d.then(()=>r):r},i=(r,s,c)=>{if(Se(r))return r.aborted=!0,r;const l=o(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new Ce;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(r,s)=>{if(s.skipChecks)return e._zod.parse(r,s);if(s.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,r,s)):i(l,r,s)}const c=e._zod.parse(r,s);if(c instanceof Promise){if(s.async===!1)throw new Ce;return c.then(l=>o(l,a,s))}return o(c,a,s)}}M(e,"~standard",()=>({validate:o=>{try{const i=Sr(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Tr(e,o).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),ct=m("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ns(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),D=m("$ZodStringFormat",(e,t)=>{Ze.init(e,t),ct.init(e,t)}),ws=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fr),D.init(e,t)}),xs=m("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=sn(a))}else t.pattern??(t.pattern=sn());D.init(e,t)}),ks=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=qr),D.init(e,t)}),Cs=m("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),o=new URL(a);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})),t.normalize?n.value=o.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Es=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Vr()),D.init(e,t)}),Ss=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ur),D.init(e,t)}),Ts=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Or),D.init(e,t)}),Is=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dr),D.init(e,t)}),zs=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Br),D.init(e,t)}),As=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rr),D.init(e,t)}),Ns=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Zr),D.init(e,t)}),Ps=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ts(t)),D.init(e,t)}),Ls=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qr),D.init(e,t)}),Ms=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=es(t)),D.init(e,t)}),$s=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jr),D.init(e,t)}),Os=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gr),D.init(e,t),e._zod.bag.format="ipv4"}),Ds=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wr),D.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})}}}),Bs=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Kr),D.init(e,t)}),Rs=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Jr),D.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[o,i]=a;if(!i)throw new Error;const r=Number(i);if(`${r}`!==i)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function fn(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Zs=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yr),D.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{fn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Us(e){if(!cn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return fn(n)}const js=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=cn),D.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Us(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Fs=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xr),D.init(e,t)});function qs(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const o=JSON.parse(atob(a));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Hs=m("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=n=>{qs(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),mn=m("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??gn,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?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}}),Vs=m("$ZodNumberFormat",(e,t)=>{cs.init(e,t),mn.init(e,t)}),Gs=m("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=os,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ws=m("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),Ks=m("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function bn(e,t,n){e.issues.length&&t.issues.push(...Te(n,e.issues)),t.value[n]=e.value}const Js=m("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{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 r=0;r<o.length;r++){const s=o[r],c=t.element._zod.run({value:s,issues:[]},a);c instanceof Promise?i.push(c.then(l=>bn(l,n,r))):bn(c,n,r)}return i.length?Promise.all(i).then(()=>n):n}});function Ue(e,t,n,a,o){if(e.issues.length){if(o&&!(n in a))return;t.issues.push(...Te(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function _n(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=fr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function vn(e,t,n,a,o,i){const r=[],s=o.keySet,c=o.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const g in t){if(s.has(g))continue;if(l==="never"){r.push(g);continue}const u=c.run({value:t[g],issues:[]},a);u instanceof Promise?e.push(u.then(p=>Ue(p,n,g,t,d))):Ue(u,n,g,t,d)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Ys=m("$ZodObject",(e,t)=>{if(Z.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}const a=nt(()=>_n(t));M(e._zod,"propValues",()=>{const s=t.shape,c={};for(const l in s){const d=s[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const g of d.values)c[l].add(g)}}return c});const o=$e,i=t.catchall;let r;e._zod.parse=(s,c)=>{r??(r=a.value);const l=s.value;if(!o(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};const d=[],g=r.shape;for(const u of r.keys){const p=g[u],f=p._zod.optout==="optional",v=p._zod.run({value:l[u],issues:[]},c);v instanceof Promise?d.push(v.then(y=>Ue(y,s,u,l,f))):Ue(v,s,u,l,f)}return i?vn(d,l,s,c,a.value,e):d.length?Promise.all(d).then(()=>s):s}}),Xs=m("$ZodObjectJIT",(e,t)=>{Ys.init(e,t);const n=e._zod.parse,a=nt(()=>_n(t)),o=u=>{const p=new vs(["shape","payload","ctx"]),f=a.value,v=b=>{const _=en(b);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};p.write("const input = payload.value;");const y=Object.create(null);let I=0;for(const b of f.keys)y[b]=`key_${I++}`;p.write("const newResult = {};");for(const b of f.keys){const _=y[b],w=en(b),P=u[b]?._zod?.optout==="optional";p.write(`const ${_} = ${v(b)};`),P?p.write(`
61
- if (${_}.issues.length) {
62
- if (${w} in input) {
63
- payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
57
+ </svg>`;function Ji(e){const t=document.createElement("div");t.className="gengage-chat-launcher-container";const n=document.createElement("div");n.className="gengage-chat-launcher-content-area",t.appendChild(n);const a=document.createElement("button");if(a.className="gengage-chat-launcher",a.type="button",a.setAttribute("aria-label",e.ariaLabel??"Open chat"),a.innerHTML=e.svgMarkup??Ki,e.tooltip!==void 0){const o=document.createElement("span");o.className="gengage-chat-launcher-tooltip",o.textContent=e.tooltip,a.appendChild(o)}e.hideMobile&&(t.dataset.hideMobile="1"),e.mobileBreakpoint!==void 0&&(t.dataset.mobileBreakpoint=String(e.mobileBreakpoint)),a.addEventListener("click",e.onClick),t.appendChild(a);const i=document.createElement("div");return i.className="gengage-chat-launcher-content-area-bottom",t.appendChild(i),{container:t,button:a,contentArea:n,contentAreaBottom:i}}function Yi(e){const t=document.createElement("div");t.className="gengage-chat-proactive";const n=document.createElement("p");n.className="gengage-chat-proactive-message",n.textContent=e.message,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-proactive-actions";let i=null;function o(){i!==null&&clearTimeout(i),t.remove()}if(e.actionButtons&&e.actionButtons.length>0)for(const c of e.actionButtons){const l=document.createElement("button");l.className="gengage-chat-proactive-accept",l.type="button",l.textContent=c.title,l.addEventListener("click",()=>{o(),c.onSelect()}),a.appendChild(l)}else{const c=document.createElement("button");c.className="gengage-chat-proactive-accept",c.type="button",c.textContent=e.acceptLabel??"Sohbete Başla",c.addEventListener("click",()=>{o(),e.onAccept()}),a.appendChild(c)}const r=document.createElement("button");r.className="gengage-chat-proactive-dismiss",r.type="button",r.textContent="×",r.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),r.addEventListener("click",()=>{o(),e.onDismiss()}),t.appendChild(r),t.appendChild(a);const s=e.autoDismissMs??15e3;return s>0&&(i=setTimeout(()=>{t.parentElement&&(t.remove(),e.onDismiss())},s)),requestAnimationFrame(()=>t.classList.add("gengage-chat-proactive--visible")),t}class Xi{constructor(t={}){this._idleTimer=null,this._maxScrollDepth=0,this._lastReportedDepth=0,this._listeners=[],this._destroyed=!1,this._idleThreshold=t.idleThresholdMs??3e4,this._scrollGranularity=t.scrollGranularity??25,this._onActivity=t.onActivity??null,this._setup()}_setup(){this._emit({type:"pageview",timestamp:Date.now()}),this._resetIdleTimer(),this._listen(window,"scroll",()=>this._onScroll(),{passive:!0}),this._listen(window,"mousemove",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"keydown",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"touchstart",()=>this._resetIdleTimer(),{passive:!0}),this._listen(document,"visibilitychange",()=>this._onVisibility())}_listen(t,n,a,i){t.addEventListener(n,a,i),this._listeners.push([t,n,a])}_resetIdleTimer(){this._idleTimer&&clearTimeout(this._idleTimer),this._idleTimer=setTimeout(()=>{this._emit({type:"idle",timestamp:Date.now()})},this._idleThreshold)}_onScroll(){const t=window.scrollY||document.documentElement.scrollTop,n=Math.max(document.documentElement.scrollHeight-window.innerHeight,1),a=Math.min(100,Math.round(t/n*100));a>this._maxScrollDepth&&(this._maxScrollDepth=a);const i=Math.floor(a/this._scrollGranularity)*this._scrollGranularity;i>this._lastReportedDepth&&(this._lastReportedDepth=i,this._emit({type:"scroll",timestamp:Date.now(),data:{depth:i}})),this._resetIdleTimer()}_onVisibility(){document.hidden?(this._emit({type:"blur",timestamp:Date.now()}),this._idleTimer&&clearTimeout(this._idleTimer)):(this._emit({type:"focus",timestamp:Date.now()}),this._resetIdleTimer())}_emit(t){this._destroyed||this._onActivity?.(t)}get maxScrollDepth(){return this._maxScrollDepth}destroy(){this._destroyed=!0,this._idleTimer&&clearTimeout(this._idleTimer);for(const[t,n,a]of this._listeners)t.removeEventListener(n,a);this._listeners=[]}}const Qi=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]);function eo(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!Qi.has(n))return null;try{const a=new Audio(`data:${t};base64,${e}`);return a.play().catch(()=>{}),{stop:()=>{a.pause(),a.currentTime=0}}}catch{return null}}class to{constructor(t){this._timer=null,this._destroyed=!1,this._abortController=null,this._sessionStart=Date.now(),this._lastActivity=Date.now(),this._searchesCount=0,this._actionsCount=0,this._triggerFireCounts={},this._options=t;const n=Pt(t.middlewareUrl);this._endpoint=`${n}/v2/heartbeat`}start(){this._timer||this._destroyed||this._scheduleNext()}_scheduleNext(){this._destroyed||(this._timer=setTimeout(()=>{this._poll().finally(()=>this._scheduleNext())},this._options.intervalMs))}stop(){this._timer&&(clearTimeout(this._timer),this._timer=null)}recordAction(){this._actionsCount++,this._lastActivity=Date.now()}recordSearch(){this._searchesCount++,this._lastActivity=Date.now()}recordActivity(){this._lastActivity=Date.now()}destroy(){this._destroyed=!0,this._abortController?.abort(),this._abortController=null,this.stop()}async _poll(){if(this._destroyed)return;const t=Date.now(),n={account_id:this._options.accountId,thread_id:this._options.sessionId,output_language:this._options.locale.toUpperCase(),idle_seconds:(t-this._lastActivity)/1e3,page_type:this._options.getPageType(),current_sku:this._options.getCurrentSku(),cart_item_count:0,searches_count:this._searchesCount,actions_count:this._actionsCount,session_duration_seconds:(t-this._sessionStart)/1e3,trigger_fire_counts:{...this._triggerFireCounts}};this._abortController=new AbortController;try{const a=await fetch(this._endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:this._abortController.signal});if(this._destroyed||!a.ok)return;const i=await a.json();if(this._destroyed)return;i.action==="message"&&i.message&&(i.trigger_type&&(this._triggerFireCounts[i.trigger_type]=(this._triggerFireCounts[i.trigger_type]??0)+1),this._options.onMessage(i))}catch{}}}const no={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...no,...t},o=n%1!==0||a.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),r=o.indexOf("."),s=r===-1?o:o.slice(0,r),c=r===-1?void 0:o.slice(r+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousandsSeparator);let d;return c!==void 0?d=`${l}${a.decimalSeparator}${c}`:d=l,a.currencySymbol?a.currencyPosition==="prefix"?`${a.currencySymbol}${d}`:`${d} ${a.currencySymbol}`:d}const ao={screen_size:"Ekran Boyutu",weight:"Ağırlık",battery_capacity:"Batarya Kapasitesi",battery_life:"Batarya Ömrü",storage:"Depolama",memory:"Bellek",ram:"RAM",processor:"İşlemci",camera:"Kamera",resolution:"Çözünürlük",display_type:"Ekran Tipi",refresh_rate:"Yenileme Hızı",color:"Renk",material:"Malzeme",dimensions:"Boyutlar",warranty:"Garanti",connectivity:"Bağlantı",water_resistance:"Su Dayanıklılığı",operating_system:"İşletim Sistemi",brand:"Marka",model:"Model",price:"Fiyat",energy_class:"Enerji Sınıfı",noise_level:"Gürültü Seviyesi",capacity:"Kapasite",power:"Güç",voltage:"Voltaj",width:"Genişlik",height:"Yükseklik",depth:"Derinlik"};function io(e){return ao[e]??e.replace(/_/g," ").replace(/^\w/,t=>t.toUpperCase())}function oo(e){const{recommended:t,products:n,attributes:a,highlights:i,specialCases:o,onProductClick:r,i18n:s}=e,c=document.createElement("div");c.className="gengage-chat-comparison";const l=document.createElement("h3");if(l.className="gengage-chat-comparison-heading",l.textContent=s?.comparisonHeading??"KARŞILAŞTIRMA SONUÇLARI",c.appendChild(l),t){const d=document.createElement("div");d.className="gengage-chat-comparison-recommended";const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-label",u.textContent=s?.recommendedChoiceLabel??"Önerilen Seçim",d.appendChild(u);const g=document.createElement("div");if(g.className="gengage-chat-comparison-recommended-body",t.imageUrl&&ce(t.imageUrl)){const v=document.createElement("img");v.src=t.imageUrl,v.alt=t.name,v.loading="lazy",v.addEventListener("error",()=>{v.style.display="none"},{once:!0}),g.appendChild(v)}const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-info";const h=document.createElement("div");h.className="gengage-chat-comparison-recommended-title",h.textContent=t.name,p.appendChild(h);const _=document.createElement("div");if(_.className="gengage-chat-comparison-recommended-price",_.textContent=J(t.price,e.pricing),p.appendChild(_),g.appendChild(p),g.addEventListener("click",()=>{r(t.sku)}),g.style.cursor="pointer",d.appendChild(g),i.length>0){const v=document.createElement("div");v.className="gengage-chat-comparison-highlights";const E=document.createElement("div");E.className="gengage-chat-comparison-highlights-label",E.textContent=s?.highlightsLabel??"Öne Çıkan Özellikler",v.appendChild(E);const I=document.createElement("ul");for(const T of i){const y=document.createElement("li");y.textContent=T,I.appendChild(y)}v.appendChild(I),d.appendChild(v)}if(e.recommendedText){const v=document.createElement("div");v.className="gengage-chat-comparison-recommended-text",v.innerHTML=oe(e.recommendedText),d.appendChild(v)}c.appendChild(d)}if(e.keyDifferencesHtml){const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences";const u=document.createElement("h4");u.textContent=s?.keyDifferencesLabel??"Temel Farklar",d.appendChild(u);const g=document.createElement("div");g.className="gengage-chat-comparison-key-differences-content",g.innerHTML=oe(ro(e.keyDifferencesHtml)),d.appendChild(g),c.appendChild(d)}if(o&&o.length>0){const d=document.createElement("details");d.className="gengage-chat-comparison-special";const u=document.createElement("summary");u.textContent=s?.specialCasesLabel??"Özel Durumlar İçin",d.appendChild(u);const g=document.createElement("ul");for(const p of o)so(g,p);g.childElementCount>0&&d.appendChild(g),c.appendChild(d)}if(n.length>0&&a.length>0){const d=document.createElement("table");d.className="gengage-chat-comparison-table";const u=document.createElement("thead"),g=document.createElement("tr"),p=document.createElement("th");g.appendChild(p);for(const _ of n){const v=document.createElement("th");if(_.sku===t?.sku&&(v.className="gengage-chat-comparison-selected"),_.imageUrl&&ce(_.imageUrl)){const T=document.createElement("img");T.src=_.imageUrl,T.alt=_.name,T.loading="lazy",T.addEventListener("error",()=>{T.style.display="none"},{once:!0}),v.appendChild(T)}const E=document.createElement("div");E.textContent=_.name,v.appendChild(E);const I=document.createElement("div");I.className="gengage-chat-comparison-table-price",I.textContent=J(_.price,e.pricing),v.appendChild(I),g.appendChild(v)}u.appendChild(g),d.appendChild(u);const h=document.createElement("tbody");for(const _ of a){const v=document.createElement("tr"),E=document.createElement("td");E.className="gengage-chat-comparison-label",E.textContent=io(_.label),v.appendChild(E);for(let I=0;I<_.values.length;I++){const T=document.createElement("td");n[I]?.sku===t?.sku&&(T.className="gengage-chat-comparison-selected"),T.textContent=_.values[I]??"",v.appendChild(T)}h.appendChild(v)}d.appendChild(h),c.appendChild(d)}if(e.productActions){const d=document.createElement("div");d.className="gengage-chat-comparison-product-actions";for(const u of n)if(e.productActions[u.sku]){const p=document.createElement("button");p.className="gengage-chat-comparison-view-btn",p.type="button",p.textContent=u.name,p.addEventListener("click",()=>r(u.sku)),d.appendChild(p)}d.childElementCount>0&&c.appendChild(d)}return c}function ro(e){const t=e.split(`
58
+ `).filter(n=>n.trim());return t.length<=1?e:"<ul>"+t.map(n=>`<li>${n.trim()}</li>`).join("")+"</ul>"}function so(e,t){const n=oe(t);if(!n)return;const a=document.createElement("template");a.innerHTML=n;const i=Array.from(a.content.querySelectorAll("li"));if(i.length>0){for(const r of i){const s=document.createElement("li");s.innerHTML=oe(r.innerHTML),e.appendChild(s)}return}const o=document.createElement("li");co(t)?o.innerHTML=n:o.textContent=t,e.appendChild(o)}function co(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function lo(e,t){const n=document.createElement("div");n.className="gengage-chat-review-highlights";const a=e.props?.reviews;if(!Array.isArray(a)||a.length===0){const g=document.createElement("div");return g.className="gengage-chat-review-empty",g.textContent=t?.emptyReviewsMessage??"Yorum özeti bulunamadı.",n.appendChild(g),n}const i=a.filter(g=>g!==null&&typeof g=="object"),o={all:i.length,positive:0,negative:0,neutral:0};for(const g of i)g.review_class==="positive"?o.positive++:g.review_class==="negative"?o.negative++:o.neutral++;const r=document.createElement("div");r.className="gengage-chat-review-tabs";const s=[{label:`Tümü (${o.all})`,filter:"all"}];o.positive>0&&s.push({label:`Olumlu (${o.positive})`,filter:"positive"}),o.negative>0&&s.push({label:`Olumsuz (${o.negative})`,filter:"negative"});let c="all";const l=document.createElement("div");l.className="gengage-chat-review-items";function d(){for(;l.firstChild;)l.removeChild(l.firstChild);const g=c==="all"?i:i.filter(p=>p.review_class===c);for(const p of g){const h=document.createElement("article");h.className="gengage-chat-review-item";const _=p.review_class;if((_==="positive"||_==="negative"||_==="neutral")&&(h.dataset.tone=_),typeof p.review_tag=="string"&&p.review_tag.length>0){const v=document.createElement("div");v.className="gengage-chat-review-tag",v.textContent=p.review_tag,h.appendChild(v)}if(typeof p.review_text=="string"&&p.review_text.length>0){const v=document.createElement("div");v.className="gengage-chat-review-text",v.textContent=p.review_text,h.appendChild(v)}if(p.review_rating!==void 0&&String(p.review_rating).length>0){const v=document.createElement("div");v.className="gengage-chat-review-rating",v.textContent=String(p.review_rating),h.appendChild(v)}l.appendChild(h)}}for(const g of s){const p=document.createElement("button");p.className="gengage-chat-review-tab",p.type="button",p.textContent=g.label,g.filter===c&&p.classList.add("gengage-chat-review-tab--active"),p.addEventListener("click",()=>{c=g.filter;for(const h of r.querySelectorAll(".gengage-chat-review-tab"))h.classList.toggle("gengage-chat-review-tab--active",h===p);d()}),r.appendChild(p)}n.appendChild(r);const u=new Map;for(const g of i)if(typeof g.review_tag=="string"&&g.review_tag.length>0){const p=u.get(g.review_tag);p?p.count++:u.set(g.review_tag,{count:1,sentiment:g.review_class??"neutral"})}if(u.size>0){const g=document.createElement("div");g.className="gengage-chat-review-pills";for(const[p,h]of u){const _=document.createElement("span");_.className="gengage-chat-review-pill",_.dataset.tone=h.sentiment;const v=document.createElement("span");v.className="gengage-chat-review-pill-icon",v.textContent=h.sentiment==="positive"?"✓":h.sentiment==="negative"?"✕":"●",_.appendChild(v);const E=document.createElement("span");if(E.textContent=p,_.appendChild(E),h.count>1){const I=document.createElement("span");I.className="gengage-chat-review-pill-count",I.textContent=String(h.count),_.appendChild(I)}g.appendChild(_)}n.appendChild(g)}return d(),n.appendChild(l),n}function Ye(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Xe(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mt(e,t=!0){const n=Ye(e);if(t){const i=Math.floor(n),o=n-i>=.5?1:0,r=5-i-o;return"★".repeat(i)+(o?"½":"")+"☆".repeat(r)}const a=Math.round(n);return"★".repeat(a)+"☆".repeat(5-a)}function ve(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function $t(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const n=e.action?.payload;return n&&typeof n=="object"&&"sku"in n&&typeof n.sku=="string"?n.sku:null}const go={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function Ot(e,t){if(!e||!t)return null;const n=go[e];return n?t[n]??e:e}function po(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-top-picks";const a=e.props?.suggestions??[];if(a.length===0)return n;const i=document.createElement("h3");i.className="gengage-chat-ai-top-picks-title",i.textContent=t.i18n?.aiTopPicksTitle??"Top Picks",n.appendChild(i);const o=document.createElement("div");o.className="gengage-chat-ai-top-picks-cards";for(let r=0;r<a.length;r++){const s=a[r],l=s.role==="winner"||r===0?uo(s,t):ho(s,t);o.appendChild(l)}return n.appendChild(o),n}function uo(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";const a=document.createElement("span");a.className="gengage-chat-ai-toppick-badge",a.textContent=Ot(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH",n.appendChild(a);const i=e.product,o=i.discountPercent;if(typeof o=="number"&&o>0){const u=document.createElement("span");u.className="gengage-chat-ai-toppick-discount-badge",u.textContent=`%${Xe(o)}`,n.appendChild(u)}const r=i.imageUrl;if(r&&ce(r)){const u=document.createElement("img");u.className="gengage-chat-ai-toppick-img",V(u,"src",r),u.alt=i.name??"",ve(u),n.appendChild(u)}const s=document.createElement("div");s.className="gengage-chat-ai-toppick-body";const c=i.name;if(c){const u=document.createElement("div");u.className="gengage-chat-ai-toppick-name",u.textContent=c,s.appendChild(u)}if(e.reason){const u=document.createElement("div");u.className="gengage-chat-ai-toppick-reason",u.textContent=e.reason,s.appendChild(u)}if(e.labels&&e.labels.length>0&&s.appendChild(Bt(e.labels)),typeof e.expertQualityScore=="number"){const u=document.createElement("div");u.className="gengage-chat-ai-toppick-score";const g=e.expertQualityScore<=5?5:10;u.textContent=`${e.expertQualityScore}/${g}`,s.appendChild(u)}if(e.reviewHighlight){const u=document.createElement("blockquote");u.className="gengage-chat-ai-toppick-review",u.textContent=e.reviewHighlight,s.appendChild(u)}const l=i.price,d=i.originalPrice;if(l){const u=document.createElement("div");if(u.className="gengage-chat-ai-toppick-price",d&&d!==l){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=J(d,t.pricing),u.appendChild(p),u.appendChild(document.createTextNode(" "))}const g=document.createElement("span");g.textContent=J(l,t.pricing),u.appendChild(g),s.appendChild(u)}if(n.appendChild(s),e.action){const u=$t(e),g=i.url??"",p=document.createElement("div");p.className="gengage-chat-ai-toppick-spinner",p.style.display=u&&t.topPicksLoadingSku===u?"":"none",n.appendChild(p);const h=document.createElement("button");h.className="gengage-chat-ai-toppick-cta",h.type="button",h.textContent=t.i18n?.viewDetails??"View Details",h.addEventListener("click",()=>{if(e.action?.type==="findSimilar"&&u&&t.onProductClick){t.onProductClick({sku:u,url:g});return}t.onAction(e.action)}),n.appendChild(h)}return n}function ho(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";const a=e.product,i=a.discountPercent;if(typeof i=="number"&&i>0){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-discount-badge",d.textContent=`%${Xe(i)}`,n.appendChild(d)}const o=a.imageUrl;if(o&&ce(o)){const d=document.createElement("img");d.className="gengage-chat-ai-toppick-img",V(d,"src",o),d.alt=a.name??"",ve(d),n.appendChild(d)}const r=document.createElement("div");r.className="gengage-chat-ai-toppick-body";const s=Ot(e.role,t.i18n);if(s){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-role",d.textContent=s,r.appendChild(d)}const c=a.name;if(c){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-name",d.textContent=c,r.appendChild(d)}if(e.reason){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-reason",d.textContent=e.reason,r.appendChild(d)}e.labels&&e.labels.length>0&&r.appendChild(Bt(e.labels));const l=a.price;if(l){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price",d.textContent=J(l,t.pricing),r.appendChild(d)}if(n.appendChild(r),e.action){const d=$t(e),u=a.url??"",g=document.createElement("div");g.className="gengage-chat-ai-toppick-spinner",g.style.display=d&&t.topPicksLoadingSku===d?"":"none",n.appendChild(g);const p=document.createElement("button");p.className="gengage-chat-ai-toppick-cta",p.type="button",p.textContent=t.i18n?.viewDetails??"View Details",p.addEventListener("click",()=>{if(e.action?.type==="findSimilar"&&d&&t.onProductClick){t.onProductClick({sku:d,url:u});return}t.onAction(e.action)}),n.appendChild(p)}return n}function Bt(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels";for(const n of e){const a=document.createElement("span");a.className="gengage-chat-ai-toppick-label",a.dataset.sentiment=n.sentiment??"neutral",a.textContent=n.label,t.appendChild(a)}return t}function fo(e,t){const n=document.createElement("div");n.className="gengage-chat-grounding-review";const a=e.props??{},i=a.title,o=a.reviewCount,r=a.action,s=t.i18n?.groundingReviewCta??"Yorumları Oku",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.textContent="📋",n.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body";const d=document.createElement("div");if(d.className="gengage-chat-grounding-review-title",d.textContent=i??"Müşteri Yorumları",l.appendChild(d),o){const g=document.createElement("div");g.className="gengage-chat-grounding-review-subtitle";const p=t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut";g.textContent=p.replace("{count}",o),l.appendChild(g)}n.appendChild(l);const u=document.createElement("span");return u.className="gengage-chat-grounding-review-cta",u.textContent=`${s} →`,n.appendChild(u),r&&(n.style.cursor="pointer",n.addEventListener("click",()=>t.onAction(r))),n}function mo(e){if(e.action.type!=="findSimilar")return e.action;const t=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,n=typeof t?.input=="string"&&t.input.trim()||typeof t?.text=="string"&&t.text.trim()||e.name.trim();if(!n)return e.action;const a={text:n,is_suggested_text:1};if(typeof t?.sku=="string"&&t.sku.trim()&&(a.sku=t.sku),Array.isArray(t?.group_skus)){const i=t.group_skus.filter(o=>typeof o=="string"&&o.length>0);i.length>0&&(a.group_skus=i)}return{title:e.action.title,type:"inputText",payload:a}}function bo(e,t){const n=document.createElement("div");n.className="gengage-chat-grouping-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const i of a){const o=document.createElement("div");if(o.className="gengage-chat-grouping-card",o.style.cursor="pointer",o.addEventListener("click",()=>t.onAction(mo(i))),i.image&&ce(i.image)){const l=document.createElement("img");l.className="gengage-chat-grouping-card-img",l.src=i.image,l.alt=i.name,l.width=20,l.height=20,o.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-grouping-card-body";const s=document.createElement("span");if(s.className="gengage-chat-grouping-card-name",s.textContent=i.name,r.appendChild(s),i.description){const l=document.createElement("span");l.className="gengage-chat-grouping-card-desc",l.textContent=i.description,r.appendChild(l)}if(i.labels&&i.labels.length>0){const l=document.createElement("span");l.className="gengage-chat-grouping-card-labels",l.textContent=i.labels.slice(0,3).join(" · "),r.appendChild(l)}o.appendChild(r);const c=document.createElement("span");c.className="gengage-chat-grouping-card-arrow",c.textContent="↳",o.insertBefore(c,o.firstChild),n.appendChild(o)}return n}function _o(e,t){const n=document.createElement("div");n.className="gengage-chat-suggested-search-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const i of a){const o=document.createElement("div");if(o.className="gengage-chat-suggested-search-card",o.style.cursor="pointer",o.addEventListener("click",()=>t.onAction(i.action)),i.image&&ce(i.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.src=i.image,c.alt=i.shortName,c.width=40,c.height=40,o.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-suggested-search-card-body";const s=document.createElement("div");if(s.className="gengage-chat-suggested-search-card-name",s.textContent=i.shortName,r.appendChild(s),i.detailedMessage){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-desc",c.textContent=i.detailedMessage,r.appendChild(c)}if(i.whyDifferent){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-diff",c.textContent=i.whyDifferent,r.appendChild(c)}o.appendChild(r),n.appendChild(o)}return n}function vo(e,t){const n=document.createElement("button");n.className="gengage-chat-comparison-floating-btn",n.type="button";const a=t.i18n?.compareSelected??"Karşılaştır";return n.textContent=`${a} (${e.length})`,n.addEventListener("click",()=>{t.onAction({title:a,type:"getComparisonTable",payload:{sku_list:[...e]}})}),n}function yo(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons";const n=e.props?.productName;if(n){const o=document.createElement("h4");o.className="gengage-chat-pros-cons-heading",o.textContent=n,t.appendChild(o)}const a=e.props?.pros,i=e.props?.cons;if(a&&a.length>0){const o=document.createElement("ul");o.className="gengage-chat-pros-cons-list";for(const r of a){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),o.appendChild(s)}t.appendChild(o)}if(i&&i.length>0){const o=document.createElement("ul");o.className="gengage-chat-pros-cons-list";for(const r of i){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),o.appendChild(s)}t.appendChild(o)}return t}function wo(e,t){const n=e.props?.groups??[],a=e.props?.filterTags??[],i=document.createElement("div");if(i.className="gengage-chat-categories",n.length===0)return i;const o=document.createElement("div");o.className="gengage-chat-categories-tabs",o.setAttribute("role","tablist");const r=[],s=[],c=l=>{for(let d=0;d<r.length;d++){const u=d===l;r[d].classList.toggle("gengage-chat-categories-tab--active",u),r[d].setAttribute("aria-selected",String(u)),r[d].tabIndex=u?0:-1,s[d].style.display=u?"":"none"}};for(let l=0;l<n.length;l++){const d=n[l],u=`gengage-cat-tab-${l}`,g=`gengage-cat-panel-${l}`,p=document.createElement("button");p.className="gengage-chat-categories-tab",p.type="button",p.id=u,p.setAttribute("role","tab"),p.setAttribute("aria-controls",g),p.setAttribute("aria-selected",String(l===0)),p.tabIndex=l===0?0:-1,l===0&&p.classList.add("gengage-chat-categories-tab--active"),p.textContent=d.groupName,p.addEventListener("click",()=>c(l)),p.addEventListener("keydown",_=>{let v=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?v=(l+1)%n.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?v=(l-1+n.length)%n.length:_.key==="Home"?v=0:_.key==="End"&&(v=n.length-1),v>=0&&(_.preventDefault(),c(v),r[v].focus())}),r.push(p),o.appendChild(p);const h=document.createElement("div");h.className="gengage-chat-categories-grid",h.id=g,h.setAttribute("role","tabpanel"),h.setAttribute("aria-labelledby",u),l!==0&&(h.style.display="none");for(const _ of d.products){const v=xo(_,t);h.appendChild(v)}s.push(h)}i.appendChild(o);for(const l of s)i.appendChild(l);if(a.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags";for(const d of a){const u=document.createElement("button");u.className="gengage-chat-categories-filter-tag",u.type="button",u.textContent=d.title,d.action&&u.addEventListener("click",()=>{t.onAction(d.action)}),l.appendChild(u)}i.appendChild(l)}return i}function xo(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&ce(e.imageUrl)){const o=document.createElement("img");o.className="gengage-chat-product-card-img",o.src=e.imageUrl,o.alt=e.name,n.appendChild(o)}const a=document.createElement("div");a.className="gengage-chat-product-card-body";const i=document.createElement("div");if(i.className="gengage-chat-product-card-name",i.textContent=e.name,a.appendChild(i),e.price){const o=document.createElement("div");o.className="gengage-chat-product-card-price",o.textContent=e.price,a.appendChild(o)}return n.appendChild(a),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",()=>{t.onProductSelect?.(e)})),n}function ko(e,t){const n=document.createElement("div");n.className="gengage-chat-handoff-notice",n.setAttribute("role","alert");const a=document.createElement("span");a.className="gengage-chat-handoff-notice-icon",a.textContent="👤",a.setAttribute("aria-hidden","true"),n.appendChild(a);const i=document.createElement("h4");i.className="gengage-chat-handoff-notice-heading",i.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",n.appendChild(i);const o=e.props?.summary;if(o){const r=document.createElement("p");r.className="gengage-chat-handoff-notice-summary",r.textContent=o,n.appendChild(r)}return n}function Co(e,t){const n=e.props?.product??e.props,a=document.createElement("div");if(a.className="gengage-chat-product-summary",!n)return a;a.style.cursor="pointer",a.addEventListener("click",p=>{p.target.closest("a")||t.onProductSelect?.(n)});const i=n.imageUrl;if(i&&ie(i)){const p=document.createElement("div");p.className="gengage-chat-product-summary__image";const h=document.createElement("img");V(h,"src",i);const _=n.name;_&&(h.alt=_),ve(h),p.appendChild(h),a.appendChild(p)}const o=document.createElement("div");o.className="gengage-chat-product-summary__content";const r=n.brand,s=n.name;if(s){const p=document.createElement("div");p.className="gengage-chat-product-summary__name";const h=r&&!s.toLowerCase().startsWith(r.toLowerCase());p.textContent=h?`${r} ${s}`:s,o.appendChild(p)}const c=n.rating,l=n.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__rating",p.textContent=Mt(Ye(c)),typeof l=="number"&&Number.isFinite(l)){const h=document.createElement("span");h.className="gengage-chat-product-summary__review-count",h.textContent=` (${l})`,p.appendChild(h)}o.appendChild(p)}const d=n.price,u=n.originalPrice;if(d){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__price",u&&u!==d){const _=document.createElement("span");_.className="gengage-chat-product-summary__price-original",_.textContent=J(u,t.pricing),p.appendChild(_),p.appendChild(document.createTextNode(" "))}const h=document.createElement("span");h.className="gengage-chat-product-summary__price-current",h.textContent=J(d,t.pricing),p.appendChild(h),o.appendChild(p)}a.appendChild(o);const g=n.url;if(g&&ie(g)){const p=document.createElement("a");p.className="gengage-chat-product-summary__cta",V(p,"href",g),V(p,"target","_blank"),V(p,"rel","noopener noreferrer"),p.textContent=t.i18n?.productCtaLabel??"İncele",a.appendChild(p)}return a}function Dt(e){const t=e.min??1,n=e.max??99,a=Math.min(t,n),i=Math.max(t,n),o=Math.max(a,Math.min(i,e.initial??a)),r=e.compact??!1;let s=o;const c=document.createElement("div");c.className=`gengage-qty-stepper${r?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=e.decreaseSymbol??"−",l.setAttribute("aria-label",e.decreaseLabel??"Azalt");const d=document.createElement("span");d.className="gengage-qty-value",d.textContent=String(s),d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true");const u=document.createElement("button");u.className="gengage-qty-btn",u.type="button",u.textContent=e.increaseSymbol??"+",u.setAttribute("aria-label",e.increaseLabel??"Artır");const g=document.createElement("button");g.className="gengage-qty-submit",g.type="button",r?(g.textContent=e.submitIcon??"🛒",g.title=e.label??"Sepete Ekle"):g.textContent=e.label??"Sepete Ekle";function p(){l.disabled=s<=a,u.disabled=s>=i}return l.addEventListener("click",h=>{h.stopPropagation(),s>a&&(s--,d.textContent=String(s),p())}),u.addEventListener("click",h=>{h.stopPropagation(),s<i&&(s++,d.textContent=String(s),p())}),g.addEventListener("click",h=>{h.stopPropagation(),e.onSubmit(s)}),c.addEventListener("click",h=>{h.stopPropagation()}),p(),c.appendChild(l),c.appendChild(d),c.appendChild(u),c.appendChild(g),c}function Rt(){return window.innerWidth<768}const Ut={ActionButtons:({element:e,context:t})=>Eo(e,t),ActionButton:({element:e,context:t})=>So(e,t),ProductCard:({element:e,context:t})=>To(e,t),ProductDetailsPanel:({element:e,context:t})=>Io(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>Ao(e,t,n,a),ReviewHighlights:({element:e,context:t})=>lo(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage}),ComparisonTable:({element:e,context:t})=>No(e,t),AITopPicks:({element:e,context:t})=>po(e,t),GroundingReviewCard:({element:e,context:t})=>fo(e,t),AIGroupingCards:({element:e,context:t})=>bo(e,t),AISuggestedSearchCards:({element:e,context:t})=>_o(e,t),ProsAndCons:({element:e})=>yo(e),CategoriesContainer:({element:e,context:t})=>wo(e,t),HandoffNotice:({element:e,context:t})=>ko(e,t),ProductSummaryCard:({element:e,context:t})=>Co(e,t),Divider:({element:e})=>Lo(e)},Qe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const i=t(a);i&&n.appendChild(i)}return n};function Zt(){return{...Ut}}function jt(e,t,n=Ut,a=Qe){return ta({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function Eo(e,t){const n=document.createElement("div");n.className="gengage-chat-action-buttons";const a=e.props?.buttons;if(a)for(const i of a){const o=document.createElement("button");o.className="gengage-chat-action-btn",o.textContent=i.label,o.addEventListener("click",()=>t.onAction(i.action)),n.appendChild(o)}return n}function So(e,t){const n=document.createElement("button");n.className="gengage-chat-action-btn";const a=e.props?.label;typeof a=="string"&&(n.textContent=a);const i=e.props?.action;return i&&n.addEventListener("click",()=>t.onAction(i)),n}function To(e,t){const n=document.createElement("div");n.className="gengage-chat-product-card";const a=e.props?.product??e.props;if(!a)return n;const i=a.sku;i&&(n.dataset.sku=i),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",y=>{y.target.closest(".gengage-chat-product-card-atc")||y.target.closest(".gengage-chat-product-card-cta")||t.onProductSelect?.(a)}));const o=a.imageUrl;if(o&&ie(o)){const y=document.createElement("div");y.className="gengage-chat-product-card-img-wrapper";const f=document.createElement("img");f.className="gengage-chat-product-card-img",f.loading="lazy",V(f,"src",o);const P=a.name;P&&(f.alt=P),ve(f),y.appendChild(f);const A=a.discountPercent;if(typeof A=="number"&&A>0){const C=document.createElement("span");C.className="gengage-chat-product-card-discount-badge",C.textContent=`%${Xe(A)}`,y.appendChild(C)}const b=a.sku;if(b){const C=document.createElement("button");C.className="gengage-chat-find-similar-pill",C.type="button",C.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",C.addEventListener("click",w=>{w.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:b,...o?{image_url:o}:{}}})}),y.appendChild(C)}const x=a.sku;if(x&&t.onFavoriteToggle){const C=document.createElement("button");C.className="gengage-chat-favorite-btn",C.type="button",C.setAttribute("aria-label","Favorilere ekle");const w=t.favoritedSkus?.has(x)??!1;w&&C.classList.add("gengage-chat-favorite-btn--active");const M=w?"currentColor":"none";C.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${M}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,C.addEventListener("click",z=>{z.stopPropagation(),C.classList.toggle("gengage-chat-favorite-btn--active");const N=C.querySelector("svg");N&&N.setAttribute("fill",C.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(x,a)}),y.appendChild(C)}n.appendChild(y)}const r=document.createElement("div");r.className="gengage-chat-product-card-body";const s=a.brand;if(s){const y=document.createElement("div");y.className="gengage-chat-product-card-brand",y.textContent=s,r.appendChild(y)}const c=a.name;if(c){const y=document.createElement("div");y.className="gengage-chat-product-card-name",y.textContent=c,r.appendChild(y)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const y=document.createElement("div");if(y.className="gengage-chat-product-card-rating",y.textContent=Mt(l),typeof d=="number"&&Number.isFinite(d)){const f=document.createElement("span");f.className="gengage-chat-product-card-review-count",f.textContent=` (${d})`,y.appendChild(f)}r.appendChild(y)}const u=a.price,g=a.originalPrice;if(a.price_async===!0){const y=document.createElement("div");y.className="gengage-chat-product-card-price";const f=document.createElement("span");f.className="gengage-chat-price-skeleton",y.appendChild(f),r.appendChild(y),setTimeout(()=>{f.parentElement&&(u?f.replaceWith(document.createTextNode(J(u,t.pricing))):f.remove())},300)}else if(u){const y=document.createElement("div");if(y.className="gengage-chat-product-card-price",g&&g!==u){const P=document.createElement("span");P.className="gengage-chat-product-card-original-price",P.textContent=J(g,t.pricing),y.appendChild(P),y.appendChild(document.createTextNode(" "))}const f=document.createElement("span");f.textContent=J(u,t.pricing),y.appendChild(f),r.appendChild(y)}const h=a.inStock;if(typeof h=="boolean"){const y=document.createElement("div");y.className=`gengage-chat-product-card-stock ${h?"is-in-stock":"is-out-of-stock"}`,y.textContent=h?t.i18n?.inStockLabel??"Stokta":t.i18n?.outOfStockLabel??"Tükendi",r.appendChild(y)}const _=a.promotions;if(_&&_.length>0){const y=document.createElement("div");y.className="gengage-chat-product-card-promos";for(const f of _){const P=document.createElement("span");P.className="gengage-chat-product-card-promo-badge",P.textContent=f,y.appendChild(P)}r.appendChild(y)}n.appendChild(r);const v=a.url,E=a.sku,I=e.props?.action;if(I){const y=document.createElement("button");y.className="gengage-chat-product-card-cta",y.type="button",y.textContent=I.title||t.i18n?.productCtaLabel||"Incele",y.addEventListener("click",()=>t.onAction(I)),n.appendChild(y)}else if(v&&ie(v)){const y=document.createElement("a");y.className="gengage-chat-product-card-cta",V(y,"href",v),V(y,"target","_blank"),V(y,"rel","noopener noreferrer"),y.textContent=t.i18n?.productCtaLabel??"İncele",y.addEventListener("click",f=>{t.onProductClick&&E&&(f.preventDefault(),t.onProductClick({sku:E,url:v}))}),n.appendChild(y)}const T=a.cartCode;if(T&&E&&h!==!1){const y=Dt({compact:!0,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:f=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:E,cartCode:T,quantity:f}})}});y.classList.add("gengage-chat-product-card-atc"),n.appendChild(y)}if(t.comparisonSelectMode&&E&&t.onToggleComparisonSku){const y=document.createElement("div");y.className="gengage-chat-comparison-select-wrapper";const f=document.createElement("input");return f.type="checkbox",f.className="gengage-chat-comparison-checkbox",f.checked=t.comparisonSelectedSkus?.includes(E)??!1,f.addEventListener("change",()=>{t.onToggleComparisonSku?.(E)}),y.appendChild(f),y.appendChild(n),y}return n}function Io(e,t){const n=document.createElement("article");n.className="gengage-chat-product-details-panel";const a=e.props?.product??e.props;if(!a)return n;const i=a.images,o=a.imageUrl,r=a.sku;if(i&&i.length>1){const b=document.createElement("div");b.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const x=document.createElement("img");x.className="gengage-chat-product-details-img";const C=i.find(B=>ie(B));C&&V(x,"src",C);const w=a.name;w&&(x.alt=w),ve(x),b.appendChild(x);const M=document.createElement("div");M.className="gengage-chat-product-gallery-thumbs";let z=null,N=0;for(let B=0;B<i.length;B++){const Q=i[B];if(!Q||!ie(Q))continue;const K=document.createElement("img");K.className="gengage-chat-product-gallery-thumb",B===0&&(K.classList.add("gengage-chat-product-gallery-thumb--active"),z=K),V(K,"src",Q),K.alt=`${w??"Product"} ${B+1}`,K.width=48,K.height=48,ve(K),K.addEventListener("click",()=>{V(x,"src",Q),z&&z.classList.remove("gengage-chat-product-gallery-thumb--active"),K.classList.add("gengage-chat-product-gallery-thumb--active"),z=K,N=B}),M.appendChild(K)}let O=0;const L=50;if(x.addEventListener("touchstart",B=>{O=B.changedTouches[0].clientX},{passive:!0}),x.addEventListener("touchend",B=>{const Q=B.changedTouches[0].clientX,K=O-Q;if(Math.abs(K)<L)return;const ft=M.querySelectorAll(".gengage-chat-product-gallery-thumb"),mt=K>0?Math.min(N+1,ft.length-1):Math.max(N-1,0);mt!==N&&ft[mt]&&ft[mt].click()}),b.appendChild(M),r){const B=document.createElement("button");B.className="gengage-chat-find-similar-pill",B.type="button",B.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",B.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...C?{image_url:C}:{}}})}),b.appendChild(B)}n.appendChild(b)}else if(o&&ie(o)){const b=document.createElement("div");b.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const x=document.createElement("img");x.className="gengage-chat-product-details-img",x.loading="lazy",V(x,"src",o),ve(x);const C=a.name;if(C&&(x.alt=C),b.appendChild(x),r){const w=document.createElement("button");w.className="gengage-chat-find-similar-pill",w.type="button",w.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",w.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...o?{image_url:o}:{}}})}),b.appendChild(w)}n.appendChild(b)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const b=document.createElement("h3");b.className="gengage-chat-product-details-title",b.textContent=c,s.appendChild(b)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const b=document.createElement("div");if(b.className="gengage-chat-product-details-rating",b.textContent=`★ ${Ye(l).toFixed(1)}`,typeof d=="number"&&Number.isFinite(d)){const x=document.createElement("span");x.className="gengage-chat-product-details-review-count",x.textContent=` (${d})`,b.appendChild(x)}s.appendChild(b)}const u=a.price,g=a.originalPrice;if(a.price_async===!0){const b=document.createElement("div");b.className="gengage-chat-product-details-price";const x=document.createElement("span");x.className="gengage-chat-price-skeleton",b.appendChild(x),s.appendChild(b),setTimeout(()=>{if(x.parentElement)if(u){const C=document.createElement("span");C.className="gengage-chat-product-details-current-price",C.textContent=J(u,t.pricing),x.replaceWith(C)}else x.remove()},300)}else if(u){const b=document.createElement("div");if(b.className="gengage-chat-product-details-price",g&&g!==u){const C=document.createElement("span");C.className="gengage-chat-product-details-original-price",C.textContent=J(g,t.pricing),b.appendChild(C),b.appendChild(document.createTextNode(" "))}const x=document.createElement("span");x.className="gengage-chat-product-details-current-price",x.textContent=J(u,t.pricing),b.appendChild(x),s.appendChild(b)}const h=a.inStock;if(typeof h=="boolean"){const b=document.createElement("div");b.className=`gengage-chat-product-details-stock ${h?"is-in-stock":"is-out-of-stock"}`,b.textContent=h?"Stokta var":"Stokta yok",s.appendChild(b)}const _=a.promotions;if(_&&_.length>0){const b=document.createElement("div");b.className="gengage-chat-product-details-promos";for(const x of _){const C=document.createElement("span");C.className="gengage-chat-product-details-promo-badge",C.textContent=x,b.appendChild(C)}s.appendChild(b)}const v=a.variants;if(v&&v.length>0){const b=document.createElement("div");b.className="gengage-chat-product-variants";const x=document.createElement("div");x.className="gengage-chat-product-variants-label",x.textContent=t.i18n?.variantsLabel??"Varyantlar",b.appendChild(x);const C=document.createElement("div");C.className="gengage-chat-product-variants-list";for(const w of v){const M=w.name??w.variant_name,z=w.sku;if(!M&&!z)continue;const N=document.createElement("button");N.className="gengage-chat-product-variant-btn",N.type="button";const O=M??z??"",L=w.price;L&&String(L)!==String(u)?N.textContent=`${O} - ${J(String(L),t.pricing)}`:N.textContent=O,z&&N.addEventListener("click",()=>{t.onAction({title:O,type:"launchVariant",payload:{sku:z}})}),C.appendChild(N)}b.appendChild(C),s.appendChild(b)}const E=a.sku,I=a.cartCode,T=document.createElement("div");T.className="gengage-chat-product-details-actions";const y=e.props?.action;if(y){const b=document.createElement("button");b.className="gengage-chat-product-details-cta",b.type="button",b.textContent=y.title||t.i18n?.productCtaLabel||"Incele",b.addEventListener("click",()=>t.onAction(y)),T.appendChild(b)}else{const b=a.url;if(b&&ie(b)){const x=document.createElement("a");x.className="gengage-chat-product-details-cta",V(x,"href",b),V(x,"target","_blank"),V(x,"rel","noopener noreferrer"),x.textContent=t.i18n?.productCtaLabel??"Incele",x.addEventListener("click",C=>{t.onProductClick&&E&&(C.preventDefault(),t.onProductClick({sku:E,url:b}))}),T.appendChild(x)}}if(I&&E&&h!==!1){const b=Dt({compact:!1,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:x=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:E,cartCode:I,quantity:x}})}});b.classList.add("gengage-chat-product-details-atc-stepper"),T.appendChild(b)}const f=a.url;if(f&&ie(f)){let b=function(N,O){const L=document.createElementNS(M,"circle");L.setAttribute("cx",N),L.setAttribute("cy",O),L.setAttribute("r","3"),z.appendChild(L)},x=function(N,O,L,B){const Q=document.createElementNS(M,"line");Q.setAttribute("x1",N),Q.setAttribute("y1",O),Q.setAttribute("x2",L),Q.setAttribute("y2",B),z.appendChild(Q)};const C=document.createElement("button");C.className="gengage-chat-product-details-share",C.type="button";const w=t.i18n?.shareButton??"Paylaş";C.title=w,C.setAttribute("aria-label",w);const M="http://www.w3.org/2000/svg",z=document.createElementNS(M,"svg");z.setAttribute("width","18"),z.setAttribute("height","18"),z.setAttribute("viewBox","0 0 24 24"),z.setAttribute("fill","none"),z.setAttribute("stroke","currentColor"),z.setAttribute("stroke-width","2"),z.setAttribute("stroke-linecap","round"),z.setAttribute("stroke-linejoin","round"),b("18","5"),b("6","12"),b("18","19"),x("8.59","13.51","15.42","17.49"),x("15.41","6.51","8.59","10.49"),C.appendChild(z),C.addEventListener("click",async()=>{const N=a.name;try{navigator.share?await navigator.share({title:N??"",url:f}):navigator.clipboard&&(await navigator.clipboard.writeText(f),C.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>C.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),T.appendChild(C)}T.childElementCount>0&&s.appendChild(T),n.appendChild(s);const P=a.description,A=a.specifications;return(P||A)&&n.appendChild(zo(P,A,t)),n}function zo(e,t,n){const a=document.createElement("div");a.className="gengage-chat-product-detail-tabs";const i=document.createElement("div");i.className="gengage-chat-product-detail-tab-bar";const o=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active",s.type="button",s.textContent=n.i18n?.productInfoTab??"Ürün Bilgileri",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",c.textContent=e,o.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab${e?"":" gengage-chat-product-detail-tab--active"}`,s.type="button",s.textContent=n.i18n?.specificationsTab??"Teknik Özellikler",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const d=Array.isArray(t)?t:Object.entries(t).map(([u,g])=>({key:u,value:g}));for(const u of d){const g=document.createElement("tr"),p=document.createElement("td");p.className="gengage-chat-product-specs-key",p.textContent=u.key;const h=document.createElement("td");h.className="gengage-chat-product-specs-value",h.textContent=u.value,g.appendChild(p),g.appendChild(h),l.appendChild(g)}c.appendChild(l),o.push(c)}const r=i.querySelectorAll(".gengage-chat-product-detail-tab");r.forEach((s,c)=>{s.addEventListener("click",()=>{r.forEach(l=>l.classList.remove("gengage-chat-product-detail-tab--active")),s.classList.add("gengage-chat-product-detail-tab--active"),o.forEach((l,d)=>{l.style.display=d===c?"":"none"})})}),a.appendChild(i);for(const s of o)a.appendChild(s);return a}function Ft(e,t,n){if(!n||n.type==="related")return e;const a=e.map(i=>{const r=t.elements[i]?.props?.product,s=r?Number(r.price):NaN;return{id:i,price:Number.isFinite(s)?s:1/0}});return a.sort((i,o)=>i.price===1/0&&o.price===1/0?0:i.price===1/0?1:o.price===1/0?-1:n.direction==="desc"?o.price-i.price:i.price-o.price),a.map(i=>i.id)}function Po(e,t,n,a){const i=Ft(t,n,a),o=new Map;for(const r of Array.from(e.children)){const s=r.dataset.elementId;s&&o.set(s,r)}for(const r of i){const s=o.get(r);s&&e.appendChild(s)}}function Ao(e,t,n,a){const i=document.createElement("div");i.className="gengage-chat-product-grid-wrapper";const o=e.children??[];if(o.length>1&&a?.onSortChange){const l=document.createElement("div");l.className="gengage-chat-product-sort-toolbar";const d=a.productSort??{type:"related"},u=[{label:a.i18n?.sortRelated??"Önerilen",sortState:{type:"related"}},{label:a.i18n?.sortPriceAsc??"Fiyat ↑",sortState:{type:"price",direction:"asc"}},{label:a.i18n?.sortPriceDesc??"Fiyat ↓",sortState:{type:"price",direction:"desc"}}];for(const g of u){const p=document.createElement("button");p.className="gengage-chat-product-sort-btn",p.type="button",d.type===g.sortState.type&&d.direction===g.sortState.direction&&p.classList.add("gengage-chat-product-sort-btn--active"),p.textContent=g.label,p.addEventListener("click",()=>{a.onSortChange?.(g.sortState),Po(r,o,t,g.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(_=>_.classList.remove("gengage-chat-product-sort-btn--active")),p.classList.add("gengage-chat-product-sort-btn--active")}),l.appendChild(p)}if(a.onToggleComparisonSku){const g=document.createElement("div");g.className="gengage-chat-product-sort-separator",l.appendChild(g);const p=document.createElement("button");p.className="gengage-chat-comparison-toggle-btn",p.type="button",a.comparisonSelectMode&&p.classList.add("gengage-chat-comparison-toggle-btn--active"),p.textContent=a.i18n?.compareSelected??"Karşılaştır",p.addEventListener("click",()=>{a.onToggleComparisonSku?.("")}),l.appendChild(p)}i.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-product-grid";const s=Ft(o,t,a?.productSort);for(const l of s){if(!t.elements[l])continue;const d=n(l);d&&(d.dataset.elementId=l,r.appendChild(d))}if(Rt()&&r.classList.add("gengage-chat-product-grid--mobile"),i.appendChild(r),e.props?.endOfList!==!0&&o.length>0){const l=document.createElement("button");l.className="gengage-chat-product-grid-view-more",l.type="button",l.textContent=a?.i18n?.viewMoreLabel??"Daha Fazla Göster",l.addEventListener("click",()=>{a?.onAction({title:"More",type:"moreProductList",payload:{}})}),i.appendChild(l)}if(a?.comparisonSelectMode&&a.comparisonSelectedSkus&&a.comparisonSelectedSkus.length>=2){const l=vo(a.comparisonSelectedSkus,a);i.appendChild(l)}return i}function No(e,t){const n=e.props??{},a=n.keyDifferencesHtml,i=n.recommended,o=n.products??[],r=n.attributes??[],s=n.highlights??[],c=n.specialCases,l=n.recommendedText,d=n.winnerHits,u=n.productActions;if(!i)return document.createElement("div");const g={recommended:i,products:o,attributes:r,highlights:s,specialCases:c,onProductClick:h=>{t.onProductClick?.({sku:h,url:""})},pricing:t.pricing};l!==void 0&&(g.recommendedText=l),d!==void 0&&(g.winnerHits=d),u!==void 0&&(g.productActions=u),a!==void 0&&(g.keyDifferencesHtml=a),t.i18n&&(g.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const p=oo(g);return Rt()&&p.classList.add("gengage-chat-comparison--mobile"),p}function Lo(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const n=e.props?.label;if(n){const a=document.createElement("div");a.className="gengage-chat-divider-wrapper";const i=document.createElement("span");return i.className="gengage-chat-divider-label",i.textContent=n,a.appendChild(t),a.appendChild(i),a}return t}const Mo=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function $o(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&Mo.has(a.tagName)?(n.length>0&&(t.push(n),n=[]),t.push([a])):n.push(a);return n.length>0&&t.push(n),t}function Oo(e){for(const t of e)for(const n of t)if(n.nodeType===Node.ELEMENT_NODE&&(n.tagName==="TABLE"||n.querySelector?.("table")))return!0;return!1}function Bo(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Do(e){const{container:t,html:n,delayMs:a=30,onTick:i,onComplete:o}=e,r=document.createElement("template");r.innerHTML=n;const s=$o(r.content.childNodes);if(Bo()||s.length<=1||Oo(s))return t.innerHTML=n,o?.(),{complete(){},cancel(){},isRunning:!1};t.innerHTML="";let c=0,l=null,d=!0;function u(){if(!d||c>=s.length){d=!1,o?.();return}const g=s[c],p=document.createElement("span");p.className="gengage-chat-typewriter-block";for(const h of g)p.appendChild(h.cloneNode(!0));t.appendChild(p),c++,i?.(),c<s.length?l=setTimeout(u,a):(d=!1,o?.())}return u(),{complete(){d&&(l!==null&&clearTimeout(l),d=!1,t.innerHTML=n,o?.())},cancel(){l!==null&&clearTimeout(l),d=!1},get isRunning(){return d}}}function qt(e){return e!==void 0&&/[\p{L}\p{N}_]/u.test(e)}function Ro(e){const{container:t,mentions:n,onProductClick:a}=e;if(n.length===0)return;const i=new Map;for(const o of n)o.short_name.length!==0&&i.set(o.short_name.toLowerCase(),o);if(i.size!==0)for(const[o,r]of i){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),l=!1;for(;c&&!l;){const d=c.textContent??"",u=d.toLowerCase().indexOf(o);if(u===-1){c=s.nextNode();continue}const g=u>0?d[u-1]:void 0,p=d[u+r.short_name.length];if(qt(g)||qt(p)){c=s.nextNode();continue}const h=d.slice(0,u),_=d.slice(u,u+r.short_name.length),v=d.slice(u+r.short_name.length),E=c.parentNode;if(!E){c=s.nextNode();continue}const I=document.createElement("a");I.className="gengage-product-mention",I.textContent=_,I.href="#",I.addEventListener("click",T=>{T.preventDefault(),a(r.sku)}),h&&E.insertBefore(document.createTextNode(h),c),E.insertBefore(I,c),v&&E.insertBefore(document.createTextNode(v),c),E.removeChild(c),l=!0}}}const Uo=new Set(["search","info","review","similar"]),Zo=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function jo(e){return!!(e.icon&&Uo.has(e.icon)||e.action?.type&&Zo.has(e.action.type))}const Ht="gengage_choice_prompter_dismissed";function Fo(e){const t=document.createElement("div");t.className="gengage-chat-choice-prompter";const n=document.createElement("div");n.className="gengage-chat-choice-prompter-heading",n.textContent=e.heading,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-choice-prompter-suggestion",a.textContent=e.suggestion,t.appendChild(a);const i=document.createElement("button");i.type="button",i.className="gengage-chat-choice-prompter-cta",i.textContent=e.ctaLabel,i.addEventListener("click",()=>{Vt(),t.remove(),e.onCtaClick()}),t.appendChild(i);const o=document.createElement("button");return o.type="button",o.className="gengage-chat-choice-prompter-dismiss",o.textContent="×",o.setAttribute("aria-label","Dismiss"),o.addEventListener("click",()=>{Vt(),t.remove(),e.onDismiss?.()}),t.appendChild(o),t}function qo(){try{return sessionStorage.getItem(Ht)==="1"}catch{return!1}}function Vt(){try{sessionStorage.setItem(Ht,"1")}catch{}}const Ho="gengage_assistant",Vo=3,ge="sessions",ee="context",se="payload",te="favorites";function Pe(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function ke(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Go{constructor(t=Ho,n=Vo){this._db=null,this._dbName=t,this._version=n}async open(){return this._db?this._db:new Promise((t,n)=>{const a=indexedDB.open(this._dbName,this._version);a.onupgradeneeded=i=>{const o=a.result,r=i.oldVersion;r<1&&(o.createObjectStore(ge,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(ee,{keyPath:["sessionId","threadId"]}),o.createObjectStore(se,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.createObjectStore(te,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(o.objectStoreNames.contains(ge)&&o.deleteObjectStore(ge),o.objectStoreNames.contains(se)&&o.deleteObjectStore(se),o.createObjectStore(ge,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(se,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.objectStoreNames.contains(ee)||o.createObjectStore(ee,{keyPath:["sessionId","threadId"]})),r<3&&(o.objectStoreNames.contains(te)||o.createObjectStore(te,{keyPath:["userId","appId","sku"]}))},a.onsuccess=()=>{this._db=a.result,t(this._db)},a.onerror=()=>n(a.error)})}close(){this._db?.close(),this._db=null}async saveSession(t){const a=this._requireDb().transaction(ge,"readwrite");a.objectStore(ge).put(t),await ke(a)}async loadSession(t,n,a){const o=this._requireDb().transaction(ge,"readonly");return await Pe(o.objectStore(ge).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(ee,"readwrite");a.objectStore(ee).put(t),await ke(a)}async loadContext(t,n){const i=this._requireDb().transaction(ee,"readonly");return await Pe(i.objectStore(ee).get([t,n]))??null}async deleteContextsAfterThread(t,n){const i=this._requireDb().transaction(ee,"readwrite"),r=i.objectStore(ee).openCursor();await new Promise((s,c)=>{r.onsuccess=()=>{const l=r.result;if(!l){s();return}const d=l.value;if(d.sessionId===t&&d.threadId>n)try{l.delete()}catch{}l.continue()},r.onerror=()=>c(r.error)}),await ke(i)}async loadLatestContext(t){const i=this._requireDb().transaction(ee,"readonly").objectStore(ee),o=IDBKeyRange.bound([t,""],[t,"￿"]);return new Promise((r,s)=>{const c=i.openCursor(o,"prev");c.onsuccess=()=>{const l=c.result;r(l?l.value:null)},c.onerror=()=>s(c.error)})}async savePayload(t){const a=this._requireDb().transaction(se,"readwrite");a.objectStore(se).put(t),await ke(a)}async loadPayload(t,n){const i=this._requireDb().transaction(se,"readonly");return await Pe(i.objectStore(se).get([t,n]))??null}async loadPayloadsByThread(t){const i=this._requireDb().transaction(se,"readonly").objectStore(se).index("threadId"),o=[];return new Promise((r,s)=>{const c=i.openCursor(IDBKeyRange.only(t));c.onsuccess=()=>{const l=c.result;if(!l){r(o);return}o.push(l.value),l.continue()},c.onerror=()=>s(c.error)})}async saveFavorite(t){const a=this._requireDb().transaction(te,"readwrite");a.objectStore(te).put(t),await ke(a)}async removeFavorite(t,n,a){const o=this._requireDb().transaction(te,"readwrite");o.objectStore(te).delete([t,n,a]),await ke(o)}async loadFavorites(t,n){const i=this._requireDb().transaction(te,"readonly");return(await Pe(i.objectStore(te).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const o=this._requireDb().transaction(te,"readonly");return await Pe(o.objectStore(te).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const Wo=["comparisonTable","groupList","productDetailsSimilars","productList"];class Ko{constructor(t){this._lockCount=1,this._hiddenByUser=!1,this._lastPanelContentType=null,this._chatShown=!1,this._isFavoritesMode=!1,this._lastExtended=!1,this._onChange=t.onChange;const n=new Set(Wo);t.productDetailsInPanel&&n.add("productDetails"),this._panelContentTypes=n}get isExtended(){return this._lockCount===0&&!this._hiddenByUser&&!this._isFavoritesMode&&this._lastPanelContentType!==null&&this._panelContentTypes.has(this._lastPanelContentType)&&this._chatShown}unlock(){this._lockCount>0&&this._lockCount--,this._checkStateChange()}lock(){this._lockCount++,this._checkStateChange()}setHiddenByUser(t){this._hiddenByUser=t,this._checkStateChange()}setChatShown(t){this._chatShown=t,this._checkStateChange()}setFavoritesMode(t){this._isFavoritesMode=t,this._checkStateChange()}setPanelContentType(t){this._lastPanelContentType=t,this._checkStateChange()}_checkStateChange(){const t=this.isExtended;t!==this._lastExtended&&(this._lastExtended=t,this._onChange(t))}}class Jo{constructor(t){this.deps=t,this.snapshots=new Map,this.snapshotTypes=new Map,this.activePanelMessageId=null,this.currentType=null,this.threads=[],this.lastActionType=null}snapshotForMessage(t){const n=this.deps.drawer();if(!n?.hasPanelContent()||n.isPanelLoading())return;const a=n.getPanelContentElement();if(!a)return;const i=a.cloneNode(!0);this.snapshots.set(t,i),this.currentType&&this.snapshotTypes.set(t,this.currentType)}attachClickHandler(t){const a=this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(t)}"]`);a&&(a.style.cursor="pointer",a.addEventListener("click",()=>this.restoreForMessage(t)))}restoreForMessage(t){const n=this.snapshots.get(t);if(!n)return!1;const a=this.deps.shadow(),i=this.deps.drawer();this.activePanelMessageId&&a?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"),a?.querySelector(`[data-message-id="${CSS.escape(t)}"]`)?.classList.add("gengage-chat-bubble--active"),this.activePanelMessageId=t,i?.setPanelContent(n.cloneNode(!0));const r=this.snapshotTypes.get(t);return r&&(this.currentType=r,this.updateTopBar(r)),!0}notifyExtension(t){const n=this.deps.bridge();t?setTimeout(()=>n?.send("maximize-pdp",{}),350):setTimeout(()=>n?.send("minify-pdp",{}),200)}titleForComponent(t,n){if(n)return n;const a=this.deps.i18n();switch(t){case"ProductDetailsPanel":return a.panelTitleProductDetails;case"ProductGrid":return Gt(this.lastActionType)?a.panelTitleSearchResults:a.panelTitleSimilarProducts;case"ComparisonTable":return a.panelTitleComparisonResults;case"AIGroupingCards":return a.panelTitleCategories;default:return""}}updateTopBar(t,n){const a=this.deps.currentThreadId();if(!a)return;const i=this.threads.indexOf(a),o=i>0,r=i>=0&&i<this.threads.length-1,s=this.titleForComponent(t,n);this.deps.drawer()?.updatePanelTopBar(o,r,s)}updateTopBarForLoading(t){const n=this.deps.i18n(),i={productDetails:n.panelTitleProductDetails,productList:Gt(this.lastActionType)?n.panelTitleSearchResults:n.panelTitleSimilarProducts,comparisonTable:n.panelTitleComparisonResults,groupList:n.panelTitleCategories}[t]??"";if(i){const o=this.deps.currentThreadId(),r=o?this.threads.indexOf(o):-1,s=r>0,c=r>=0&&r<this.threads.length-1;this.deps.drawer()?.updatePanelTopBar(s,c,i)}}updateExtendedMode(t){const a={ComparisonTable:"comparisonTable",AIGroupingCards:"groupList",ProductDetailsPanel:"productDetails",ProductGrid:"productList"}[t]??null;this.deps.extendedModeManager()?.setPanelContentType(a)}navigateBack(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>0){const a=this.threads[n-1];a&&this.deps.rollbackToThread(a)}}navigateForward(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>=0&&n<this.threads.length-1){const a=this.threads[n+1];a&&this.deps.rollbackToThread(a)}}toPanelSpec(t){const n=t.elements[t.root];if(!n||n.type!=="ProductCard")return t;const a={...n,type:"ProductDetailsPanel"};return{root:t.root,elements:{...t.elements,[t.root]:a}}}destroy(){this.snapshots.clear(),this.snapshotTypes.clear(),this.activePanelMessageId=null,this.currentType=null,this.threads=[]}}function Gt(e){return e==="user_message"||e==="inputText"}class Wt{constructor(t){this.favoritedSkus=new Set,this._db=t}get db(){return this._db}set db(t){this._db=t}async persist(t){if(!this._db)return;const n=t.messages.map(i=>{const o={id:i.id,role:i.role,timestamp:i.timestamp,status:i.status==="streaming"?"done":i.status};return i.threadId!==void 0&&(o.threadId=i.threadId),i.content!==void 0&&(o.content=i.content),i.silent&&(o.silent=!0),o}),a={};for(const[i,o]of t.panelSnapshots)o.querySelector(".gengage-chat-panel-skeleton")||(a[i]=o.innerHTML);await this._db.saveSession({userId:t.userId,appId:t.appId,sessionId:t.sessionId,messages:n,currentThreadId:t.currentThreadId,lastThreadId:t.lastThreadId,createdAt:t.chatCreatedAt,panelThreads:t.panelThreads.length>0?t.panelThreads:void 0,thumbnailEntries:t.thumbnailEntries.length>0?t.thumbnailEntries:void 0,panelSnapshotHtml:Object.keys(a).length>0?a:void 0,sku:t.sku}),t.lastBackendContext&&t.currentThreadId&&await this._db.saveContext({sessionId:t.sessionId,threadId:t.currentThreadId,context:t.lastBackendContext});for(const i of t.messages)i.uiSpec&&i.threadId&&await this._db.savePayload({threadId:i.threadId,messageId:i.id,uiSpec:i.uiSpec})}async saveAndOpenURL(t,n,a){try{await n()}catch{}a?.send("openURLInNewTab",{url:t}),window.location.href=t}async loadPayload(t,n){if(!this._db)return null;for(let a=0;a<3;a++){try{const i=await this._db.loadPayload(t,n);if(i)return i.uiSpec}catch{}a<2&&await new Promise(i=>setTimeout(i,100))}return null}async loadFavorites(t,n){if(this._db)try{const a=await this._db.loadFavorites(t,n);for(const i of a)this.favoritedSkus.add(i.sku)}catch{}}async toggleFavorite(t,n,a,i){this._db&&(this.favoritedSkus.has(a)?(this.favoritedSkus.delete(a),await this._db.removeFavorite(t,n,a)):(this.favoritedSkus.add(a),await this._db.saveFavorite({userId:t,appId:n,sku:a,name:i.name,imageUrl:i.imageUrl,price:i.price,savedAt:new Date().toISOString()})))}close(){this._db?.close(),this._db=null}}const Kt="gengage_kvkk_shown",Yo=["kvkk","kişisel veri","kisisel veri"],Xo=/\b6698\b/;function et(e){const t=e.toLowerCase();return Yo.some(n=>t.includes(n))||Xo.test(t)}function Jt(e){try{return localStorage.getItem(`${Kt}_${e}`)==="1"}catch{return!1}}function Qo(e){try{localStorage.setItem(`${Kt}_${e}`,"1")}catch{}}function er(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const i of a)if(et(i.textContent??"")){i.remove();break}return n.innerHTML.trim()}function tr(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(et(n.textContent??""))return n.outerHTML;return null}const nr={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function ar(e){return e?nr[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const ir=':host{all:initial;font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px)}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 12px);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(15, 23, 42, .18));--_gengage-border-color: var(--gengage-border-color, #e5e7eb);--_gengage-discount-color: var(--gengage-discount-color, #ef4444);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-root--open .gengage-chat-launcher-container{pointer-events:none;opacity:0;transition:opacity .2s ease}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #0f172a47;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #0f172a47}.gengage-chat-launcher svg{width:24px;height:24px}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:#1e293b;color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:#1e293b}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-proactive{position:fixed;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 14px);right:var(--_gengage-chat-launcher-right);width:280px;padding:16px 18px;border-radius:16px;background:#fff;box-shadow:0 8px 30px #0000001f,0 2px 8px #0000000f;opacity:0;transform:translateY(8px) scale(.96);transition:opacity .25s ease,transform .25s ease;z-index:2147483645}.gengage-chat-proactive--visible{opacity:1;transform:translateY(0) scale(1)}.gengage-chat-proactive-message{margin:0 0 12px;font-size:14px;line-height:1.5;color:#1f2937}.gengage-chat-proactive-actions{display:flex;gap:8px}.gengage-chat-proactive-accept{flex:1;padding:8px 16px;border:none;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .15s ease}.gengage-chat-proactive-accept:hover{filter:brightness(1.08)}.gengage-chat-proactive-dismiss{position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:transparent;color:#64748b;font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center}.gengage-chat-proactive-dismiss:hover{color:#475569;background:#f1f5f9}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:16px;bottom:calc(16px + env(safe-area-inset-bottom))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;border-top:1px solid rgba(0,0,0,.06);box-shadow:0 -4px 16px #0000001a,0 12px 40px #0f172a2e;padding-bottom:env(safe-area-inset-bottom,0px)}.gengage-chat-root--mobile.gengage-chat-root--open:before{content:"";position:fixed;inset:0;background:#0000001f;z-index:-1;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0;border-top:none}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--_gengage-border-color, #e5e7eb);transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;border:2px solid rgba(255,255,255,.15)}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffbf;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-close{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;box-sizing:border-box;width:440px;min-width:440px;border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;background:#f8fafc}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:#e5e7eb;position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:24px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:#f1f5f9;color:#334155}.gengage-chat-panel--collapsed{flex:0 0 0px!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;border-right:none!important;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #fff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:#fff;padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #2563eb);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #fff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:#f3f4f6;color:#1f2937;border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #2563eb);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-accent-primary, #3b82f6);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:#f3f4f6;padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--gengage-chat-success, #4caf50)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-chat-primary, #1976d2);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:#991b1b;font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #fff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 2px #3b82f626}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:#1f2937;resize:none;overflow-y:hidden}@media(max-width:767px){.gengage-chat-input-pill{height:52px;padding:3px 8px}.gengage-chat-input{min-height:44px;max-height:44px;font-size:16px;white-space:nowrap;overflow:hidden}.gengage-chat-input::placeholder{font-size:15px}}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 4px #0000001f}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#d1d5db;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;gap:8px;padding:6px 0 4px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.gengage-chat-action-buttons::-webkit-scrollbar{display:none}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 16px #0000001f}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:#1f2937;line-height:1.35;margin-bottom:0;min-height:0;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-card-review-count{color:#64748b;font-size:10px}.gengage-chat-product-card-price{display:flex;align-items:baseline;justify-content:center;gap:4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:#64748b;font-weight:400;font-size:12px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #3b82f6);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid #f1f5f9;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #0b24d6);background:#f8fafc}.gengage-chat-product-card-cta:active{background:#f1f5f9}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid #f3f4f6;background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-product-summary__rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-summary__review-count{color:#6b7280;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:#6b7280;font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #2563eb);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #2563eb);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:#1f2937}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:#f8fafc}.gengage-chat-review-tab--active{background:#f1f5f9;border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;color:#334155;box-shadow:0 1px 2px #0000000a}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:#16a34a}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:#f1f5f9;color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:#00000073;z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2;line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid #f1f5f9;border-radius:0;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-weight:700;font-size:13px}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid #f1f5f9;border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #3b82f6);border-bottom-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:#f8fafc}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid #f1f5f9;width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:#1f2937;border-bottom:1px solid #f1f5f9}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}.gengage-chat-drawer.gengage-chat-drawer--hidden,.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{display:none!important;pointer-events:none;box-shadow:none}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #3b82f6);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}@media(max-width:768px){.gengage-chat-root{--_gengage-qty-btn-size: 44px;--_gengage-qty-btn-size-compact: 44px}.gengage-chat-header-btn,.gengage-chat-close{width:44px;height:44px;border-radius:12px}.gengage-chat-attach-btn,.gengage-chat-mic-btn,.gengage-chat-send{width:44px;height:44px;min-width:44px}.gengage-chat-attach-btn svg,.gengage-chat-mic-btn svg{width:22px;height:22px}.gengage-chat-panel-divider{display:flex;width:100%;height:20px;align-items:center;justify-content:center;cursor:ns-resize;background:transparent;touch-action:pan-y;position:relative;overflow:visible}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:column}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:100%;min-width:0;max-width:none;max-height:30dvh;border-right:none;border-bottom:1px solid var(--_gengage-border-color);padding:0 12px 12px;margin:0;border-radius:0;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:100%;height:20px;background:transparent;border-bottom:1px solid rgba(148,163,184,.22)}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:44px;border:none;border-radius:0;background:transparent;box-shadow:none;color:transparent;font-size:0;line-height:0;padding:0}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:before{content:"";display:block;width:52px;height:5px;margin:0 auto;border-radius:999px;background:#94a3b8;box-shadow:0 1px #64748b59;transition:background .15s ease}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover,.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:active{background:transparent;color:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover:before,.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:active:before{background:#64748b}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:100%;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:50%;transform:translate(-50%,-50%)}.gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-qty-stepper--compact .gengage-qty-value{min-width:24px;font-size:13px}.gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px;padding:0 12px;font-size:13px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{min-height:44px;padding:0 16px}.gengage-chat-product-details-share{width:44px;height:44px}.gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-product-details-media{min-height:140px}.gengage-chat-product-details-title{font-size:15px}.gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-product-card-img{height:180px}}@media(max-width:480px){.gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-bubble{max-width:100%}}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#92400e;font-size:16px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:#16a34a;text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:#f8fafc}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid #f1f5f9}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid #f1f5f9;vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:#f8fafc;margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #3b82f6);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:#f8fafc;color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-proactive,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-cards{display:flex;flex-direction:column;gap:10px}.gengage-chat-ai-toppick-discount-badge{position:absolute;top:8px;left:8px;background:var(--gengage-discount-bg, #ef4444);color:#fff;font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;z-index:1}.gengage-chat-ai-toppick-card--winner{position:relative;display:flex;flex-direction:column;border:2px solid var(--gengage-primary-color, #3b82f6);border-radius:12px;background:#fff;overflow:hidden;transition:box-shadow .2s ease}.gengage-chat-ai-toppick-card--winner:hover{box-shadow:0 4px 16px #3b82f626}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:140px;object-fit:contain;background:#f8fafc}.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;background:#fff;padding:10px;transition:box-shadow .2s ease,transform .15s ease}.gengage-chat-ai-toppick-card--compact:hover{box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:64px;height:64px;object-fit:contain;border-radius:8px;background:#f8fafc;flex-shrink:0}.gengage-chat-ai-toppick-badge{position:absolute;top:8px;left:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;text-transform:uppercase;padding:2px 8px;border-radius:4px;z-index:1;letter-spacing:.5px}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:4px;padding:10px;flex:1;min-width:0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0}.gengage-chat-ai-toppick-name{font-size:13px;font-weight:600;color:var(--gengage-text-primary, #1e293b);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #3b82f6);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:#f1f5f9;color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-ai-toppick-reason{font-size:12px;color:var(--gengage-chat-text-secondary, #666);line-height:1.4;margin-top:4px}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:2px 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b)}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 20px);margin:6px 10px 10px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:auto;margin:0;padding:6px 14px;flex-shrink:0;align-self:center}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:3}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}@media(max-width:768px){.gengage-chat-ai-top-picks-cards{flex-direction:row;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;gap:10px;padding-bottom:4px}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{min-width:280px;max-width:280px;flex-shrink:0;scroll-snap-align:start}.gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:100%;height:100px;border-radius:8px 8px 0 0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:6px 10px 10px;align-self:stretch}.gengage-chat-rollback-btn{left:-24px}}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #3b82f6);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #3b82f6);flex-shrink:0}.gengage-chat-grouping-card-img{width:20px;height:20px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active,.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;left:8px;z-index:2;width:18px;height:18px;cursor:pointer;accent-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-comparison-floating-btn{display:block;width:100%;margin-top:8px;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center}.gengage-chat-comparison-floating-btn:hover{background:var(--gengage-primary-hover, #2563eb)}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:#f8fafc;min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:#f3f4f6;border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #3b82f6);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #3b82f6);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:wrap}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:#f3f4f6;border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:6px;left:6px;padding:2px 6px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px}.gengage-chat-product-card-stock.is-in-stock{color:var(--_gengage-success-color)}.gengage-chat-product-card-stock.is-out-of-stock{color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:8px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap}.gengage-chat-thumbnails-column{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:4px;z-index:2;pointer-events:auto}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid #e5e7eb;border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:10;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:#1f2937;margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:4px;right:6px;padding:2px 6px;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:#f8fafc;border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:#16a34a;background:#dcfce7}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile{overflow-x:auto;-webkit-overflow-scrolling:touch}.gengage-chat-comparison--mobile .gengage-chat-comparison-table{min-width:480px}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:#f3f4f6}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:#1f2937;-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #3b82f6);border-color:var(--gengage-primary-color, #3b82f6);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#1e293b;color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-proactive-accept:focus-visible,.gengage-chat-proactive-dismiss:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}@media(max-width:768px){.gengage-chat-choice-prompter{left:12px;right:12px;width:auto;max-width:none;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 12px + env(safe-area-inset-bottom,0px))}.gengage-chat-product-sort-btn,.gengage-chat-comparison-toggle-btn{min-height:40px}.gengage-chat-input-chip{min-height:40px;padding:8px 12px}.gengage-chat-choice-prompter-dismiss{width:32px;height:32px}.gengage-chat-panel-divider-toggle{min-height:44px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:44px;height:44px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit,.gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px}.gengage-qty-stepper--compact .gengage-qty-submit{min-width:44px;padding:0 10px}.gengage-qty-stepper--compact .gengage-qty-btn{width:44px;height:44px;font-size:14px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:24px;font-size:13px}.gengage-chat-product-card-cta,.gengage-chat-choice-prompter-cta,.gengage-chat-product-grid-view-more{min-height:44px;display:flex;align-items:center;justify-content:center}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward,.gengage-chat-favorite-btn,.gengage-chat-product-details-share{width:44px;height:44px}}';function or(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function G(e,t){const n={event:e,...t};or()&&window.dataLayer.push(n)}function rr(e){G("gengage-on-init",{gengage_widget:e})}function sr(e){G("gengage-show",{gengage_widget:e})}function cr(e,t){G("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function lr(e){G("gengage-find-similars",{gengage_sku:e})}function dr(e){G("gengage-compare-preselection",{gengage_sku:e})}function Yt(e){G("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function gr(){G("gengage-compare-clear")}function pr(e){G("gengage-compare-received",{gengage_product_count:e})}function ur(e){G("gengage-like-product",{gengage_sku:e})}function hr(){G("gengage-like-list")}function fr(e,t){G("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function mr(e,t){G("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function br(e,t){G("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function _r(){G("gengage-message-sent")}function Xt(){G("gengage-message-received")}function vr(){G("gengage-conversation-start")}function yr(){G("gengage-voice-input")}function m(e,t,n){function a(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:r,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const l=r.prototype,d=Object.keys(l);for(let u=0;u<d.length;u++){const g=d[u];g in s||(s[g]=l[g].bind(s))}}const i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function r(s){var c;const l=n?.Parent?new o:this;a(l,s),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(r,"init",{value:a}),Object.defineProperty(r,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class Ce extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Qt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const en={};function pe(e){return en}function tn(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function tt(e,t){return typeof t=="bigint"?t.toString():t}function nt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function at(e){return e==null}function it(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function wr(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let i=(a.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(a)){const c=a.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}const o=n>i?n:i,r=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return r%s/10**o}const nn=Symbol("evaluating");function D(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==nn)return a===void 0&&(a=nn,a=n()),a},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function ye(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ue(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function an(e){return JSON.stringify(e)}function xr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const on="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const kr=nt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ee(e){if($e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!($e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function rn(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e}const Cr=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function he(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function S(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Er(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sr={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 Tr(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=ue(e._zod.def,{get shape(){const r={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return ye(this,"shape",r),r},checks:[]});return he(e,o)}function Ir(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=ue(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return ye(this,"shape",r),r},checks:[]});return he(e,o)}function zr(e,t){if(!Ee(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(o,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=ue(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return ye(this,"shape",o),o}});return he(e,i)}function Pr(e,t){if(!Ee(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ue(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return ye(this,"shape",a),a}});return he(e,n)}function Ar(e,t){const n=ue(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return ye(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return he(e,n)}function Nr(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=ue(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(n)for(const l in n){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(const l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return ye(this,"shape",c),c},checks:[]});return he(t,r)}function Lr(e,t,n){const a=ue(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};if(n)for(const r in n){if(!(r in o))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(o[r]=new e({type:"nonoptional",innerType:i[r]}))}else for(const r in i)o[r]=new e({type:"nonoptional",innerType:i[r]});return ye(this,"shape",o),o}});return he(t,a)}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Te(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Be(e){return typeof e=="string"?e:e?.message}function fe(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const i=Be(e.inst?._zod.def?.error?.(e))??Be(t?.error?.(e))??Be(n.customError?.(e))??Be(n.localeError?.(e))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function ot(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ae(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const sn=(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,tt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},cn=m("$ZodError",sn),ln=m("$ZodError",sn,{Parent:Error});function Mr(e,t=n=>n.message){const n={},a=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:n}}function $r(e,t=n=>n.message){const n={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(r=>a({issues:r}));else if(o.code==="invalid_key")a({issues:o.issues});else if(o.code==="invalid_element")a({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let r=n,s=0;for(;s<o.path.length;){const c=o.path[s];s===o.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(o))):r[c]=r[c]||{_errors:[]},r=r[c],s++}}};return a(e),n}const rt=e=>(t,n,a,i)=>{const o=a?Object.assign(a,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new Ce;if(r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>fe(c,o,pe())));throw on(s,i?.callee),s}return r.value},st=e=>async(t,n,a,i)=>{const o=a?Object.assign(a,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise&&(r=await r),r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>fe(c,o,pe())));throw on(s,i?.callee),s}return r.value},De=e=>(t,n,a)=>{const i=a?{...a,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Ce;return o.issues.length?{success:!1,error:new(e??cn)(o.issues.map(r=>fe(r,i,pe())))}:{success:!0,data:o.value}},Or=De(ln),Re=e=>async(t,n,a)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(r=>fe(r,i,pe())))}:{success:!0,data:o.value}},Br=Re(ln),Dr=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return rt(e)(t,n,i)},Rr=e=>(t,n,a)=>rt(e)(t,n,a),Ur=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return st(e)(t,n,i)},Zr=e=>async(t,n,a)=>st(e)(t,n,a),jr=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return De(e)(t,n,i)},Fr=e=>(t,n,a)=>De(e)(t,n,a),qr=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Re(e)(t,n,i)},Hr=e=>async(t,n,a)=>Re(e)(t,n,a),Vr=/^[cC][^\s-]{8,}$/,Gr=/^[0-9a-z]+$/,Wr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Kr=/^[0-9a-vA-V]{20}$/,Jr=/^[A-Za-z0-9]{27}$/,Yr=/^[a-zA-Z0-9_-]{21}$/,Xr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qr=/^([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})$/,dn=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)$/,es=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ts="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ns(){return new RegExp(ts,"u")}const as=/^(?:(?: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])$/,is=/^(([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}|:))$/,os=/^((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])$/,rs=/^(([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])$/,ss=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gn=/^[A-Za-z0-9_-]*$/,cs=/^\+[1-9]\d{6,14}$/,pn="(?:(?:\\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])))",ls=new RegExp(`^${pn}$`);function un(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ds(e){return new RegExp(`^${un(e)}$`)}function gs(e){const t=un({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${pn}T(?:${a})$`)}const ps=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},us=/^-?\d+$/,hn=/^-?\d+(?:\.\d+)?$/,hs=/^(?:true|false)$/i,fs=/^[^A-Z]*$/,ms=/^[^a-z]*$/,Y=m("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fn={number:"number",bigint:"bigint",object:"date"},mn=m("$ZodCheckLessThan",(e,t)=>{Y.init(e,t);const n=fn[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bn=m("$ZodCheckGreaterThan",(e,t)=>{Y.init(e,t);const n=fn[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bs=m("$ZodCheckMultipleOf",(e,t)=>{Y.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.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.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):wr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),_s=m("$ZodCheckNumberFormat",(e,t)=>{Y.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[i,o]=Sr[t.format];e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,n&&(s.pattern=us)}),e._zod.check=r=>{const s=r.value;if(n){if(!Number.isInteger(s)){r.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?r.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):r.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<i&&r.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&r.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),vs=m("$ZodCheckMaxLength",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!at(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const i=a.value;if(i.length<=t.maximum)return;const r=ot(i);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ys=m("$ZodCheckMinLength",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!at(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const i=a.value;if(i.length>=t.minimum)return;const r=ot(i);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ws=m("$ZodCheckLengthEquals",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!at(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=a=>{const i=a.value,o=i.length;if(o===t.length)return;const r=ot(i),s=o>t.length;a.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Ue=m("$ZodCheckStringFormat",(e,t)=>{var n,a;Y.init(e,t),e._zod.onattach.push(i=>{const o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),xs=m("$ZodCheckRegex",(e,t)=>{Ue.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})}}),ks=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fs),Ue.init(e,t)}),Cs=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ms),Ue.init(e,t)}),Es=m("$ZodCheckIncludes",(e,t)=>{Y.init(e,t);const n=Oe(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(a)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Ss=m("$ZodCheckStartsWith",(e,t)=>{Y.init(e,t);const n=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),Ts=m("$ZodCheckEndsWith",(e,t)=>{Y.init(e,t);const n=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),Is=m("$ZodCheckOverwrite",(e,t)=>{Y.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class zs{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
59
+ `).filter(r=>r),i=Math.min(...a.map(r=>r.length-r.trimStart().length)),o=a.map(r=>r.slice(i)).map(r=>" ".repeat(this.indent*2)+r);for(const r of o)this.content.push(r)}compile(){const t=Function,n=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,i.join(`
60
+ `))}}const Ps={major:4,minor:3,patch:6},F=m("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ps;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const i of a)for(const o of i._zod.onattach)o(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(r,s,c)=>{let l=Se(r),d;for(const u of s){if(u._zod.def.when){if(!u._zod.def.when(r))continue}else if(l)continue;const g=r.issues.length,p=u._zod.check(r);if(p instanceof Promise&&c?.async===!1)throw new Ce;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,r.issues.length!==g&&(l||(l=Se(r,g)))});else{if(r.issues.length===g)continue;l||(l=Se(r,g))}}return d?d.then(()=>r):r},o=(r,s,c)=>{if(Se(r))return r.aborted=!0,r;const l=i(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new Ce;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(r,s)=>{if(s.skipChecks)return e._zod.parse(r,s);if(s.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(d=>o(d,r,s)):o(l,r,s)}const c=e._zod.parse(r,s);if(c instanceof Promise){if(s.async===!1)throw new Ce;return c.then(l=>i(l,a,s))}return i(c,a,s)}}D(e,"~standard",()=>({validate:i=>{try{const o=Or(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Br(e,i).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),ct=m("$ZodString",(e,t)=>{F.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ps(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),U=m("$ZodStringFormat",(e,t)=>{Ue.init(e,t),ct.init(e,t)}),As=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qr),U.init(e,t)}),Ns=m("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=dn(a))}else t.pattern??(t.pattern=dn());U.init(e,t)}),Ls=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=es),U.init(e,t)}),Ms=m("$ZodURL",(e,t)=>{U.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$s=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ns()),U.init(e,t)}),Os=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Yr),U.init(e,t)}),Bs=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Vr),U.init(e,t)}),Ds=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Gr),U.init(e,t)}),Rs=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wr),U.init(e,t)}),Us=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Kr),U.init(e,t)}),Zs=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Jr),U.init(e,t)}),js=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=gs(t)),U.init(e,t)}),Fs=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ls),U.init(e,t)}),qs=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ds(t)),U.init(e,t)}),Hs=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Xr),U.init(e,t)}),Vs=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=as),U.init(e,t),e._zod.bag.format="ipv4"}),Gs=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=is),U.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})}}}),Ws=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=os),U.init(e,t)}),Ks=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=rs),U.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[i,o]=a;if(!o)throw new Error;const r=Number(o);if(`${r}`!==o)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function _n(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Js=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ss),U.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{_n(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ys(e){if(!gn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return _n(n)}const Xs=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=gn),U.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Ys(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Qs=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=cs),U.init(e,t)});function ec(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const tc=m("$ZodJWT",(e,t)=>{U.init(e,t),e._zod.check=n=>{ec(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vn=m("$ZodNumber",(e,t)=>{F.init(e,t),e._zod.pattern=e._zod.bag.pattern??hn,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),nc=m("$ZodNumberFormat",(e,t)=>{_s.init(e,t),vn.init(e,t)}),ac=m("$ZodBoolean",(e,t)=>{F.init(e,t),e._zod.pattern=hs,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),ic=m("$ZodUnknown",(e,t)=>{F.init(e,t),e._zod.parse=n=>n}),oc=m("$ZodNever",(e,t)=>{F.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function yn(e,t,n){e.issues.length&&t.issues.push(...Te(n,e.issues)),t.value[n]=e.value}const rc=m("$ZodArray",(e,t)=>{F.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let r=0;r<i.length;r++){const s=i[r],c=t.element._zod.run({value:s,issues:[]},a);c instanceof Promise?o.push(c.then(l=>yn(l,n,r))):yn(c,n,r)}return o.length?Promise.all(o).then(()=>n):n}});function Ze(e,t,n,a,i){if(e.issues.length){if(i&&!(n in a))return;t.issues.push(...Te(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function wn(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Er(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xn(e,t,n,a,i,o){const r=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const u in t){if(s.has(u))continue;if(l==="never"){r.push(u);continue}const g=c.run({value:t[u],issues:[]},a);g instanceof Promise?e.push(g.then(p=>Ze(p,n,u,t,d))):Ze(g,n,u,t,d)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const sc=m("$ZodObject",(e,t)=>{if(F.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}const a=nt(()=>wn(t));D(e._zod,"propValues",()=>{const s=t.shape,c={};for(const l in s){const d=s[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const u of d.values)c[l].add(u)}}return c});const i=$e,o=t.catchall;let r;e._zod.parse=(s,c)=>{r??(r=a.value);const l=s.value;if(!i(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};const d=[],u=r.shape;for(const g of r.keys){const p=u[g],h=p._zod.optout==="optional",_=p._zod.run({value:l[g],issues:[]},c);_ instanceof Promise?d.push(_.then(v=>Ze(v,s,g,l,h))):Ze(_,s,g,l,h)}return o?xn(d,l,s,c,a.value,e):d.length?Promise.all(d).then(()=>s):s}}),cc=m("$ZodObjectJIT",(e,t)=>{sc.init(e,t);const n=e._zod.parse,a=nt(()=>wn(t)),i=g=>{const p=new zs(["shape","payload","ctx"]),h=a.value,_=T=>{const y=an(T);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};p.write("const input = payload.value;");const v=Object.create(null);let E=0;for(const T of h.keys)v[T]=`key_${E++}`;p.write("const newResult = {};");for(const T of h.keys){const y=v[T],f=an(T),A=g[T]?._zod?.optout==="optional";p.write(`const ${y} = ${_(T)};`),A?p.write(`
61
+ if (${y}.issues.length) {
62
+ if (${f} in input) {
63
+ payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
64
64
  ...iss,
65
- path: iss.path ? [${w}, ...iss.path] : [${w}]
65
+ path: iss.path ? [${f}, ...iss.path] : [${f}]
66
66
  })));
67
67
  }
68
68
  }
69
69
 
70
- if (${_}.value === undefined) {
71
- if (${w} in input) {
72
- newResult[${w}] = undefined;
70
+ if (${y}.value === undefined) {
71
+ if (${f} in input) {
72
+ newResult[${f}] = undefined;
73
73
  }
74
74
  } else {
75
- newResult[${w}] = ${_}.value;
75
+ newResult[${f}] = ${y}.value;
76
76
  }
77
77
 
78
78
  `):p.write(`
79
- if (${_}.issues.length) {
80
- payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
79
+ if (${y}.issues.length) {
80
+ payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
81
81
  ...iss,
82
- path: iss.path ? [${w}, ...iss.path] : [${w}]
82
+ path: iss.path ? [${f}, ...iss.path] : [${f}]
83
83
  })));
84
84
  }
85
85
 
86
- if (${_}.value === undefined) {
87
- if (${w} in input) {
88
- newResult[${w}] = undefined;
86
+ if (${y}.value === undefined) {
87
+ if (${f} in input) {
88
+ newResult[${f}] = undefined;
89
89
  }
90
90
  } else {
91
- newResult[${w}] = ${_}.value;
91
+ newResult[${f}] = ${y}.value;
92
92
  }
93
93
 
94
- `)}p.write("payload.value = newResult;"),p.write("return payload;");const z=p.compile();return(b,_)=>z(u,b,_)};let i;const r=$e,s=!Yt.jitless,l=s&&ur.value,d=t.catchall;let g;e._zod.parse=(u,p)=>{g??(g=a.value);const f=u.value;return r(f)?s&&l&&p?.async===!1&&p.jitless!==!0?(i||(i=o(t.shape)),u=i(u,p),d?vn([],f,u,p,g,e):u):n(u,p):(u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u)}});function yn(e,t,n,a){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Se(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(r=>ue(r,a,de())))}),t)}const Qs=m("$ZodUnion",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),M(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),M(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),M(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ot(i.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return a(o,i);let r=!1;const s=[];for(const c of t.options){const l=c._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)s.push(l),r=!0;else{if(l.issues.length===0)return l;s.push(l)}}return r?Promise.all(s).then(c=>yn(c,o,e,i)):yn(s,o,e,i)}}),ec=m("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},a),r=t.right._zod.run({value:o,issues:[]},a);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([c,l])=>wn(n,c,l)):wn(n,i,r)}});function lt(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(Ee(e)&&Ee(t)){const n=Object.keys(t),a=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of a){const r=lt(e[i],t[i]);if(!r.valid)return{valid:!1,mergeErrorPath:[i,...r.mergeErrorPath]};o[i]=r.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 a=0;a<e.length;a++){const o=e[a],i=t[a],r=lt(o,i);if(!r.valid)return{valid:!1,mergeErrorPath:[a,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function wn(e,t,n){const a=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).r=!0;else e.issues.push(s);const i=[...a].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),Se(e))return e;const r=lt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const tc=m("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value;if(!Ee(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],r=t.keyType._zod.values;if(r){n.value={};const s=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:o[l],issues:[]},a);d instanceof Promise?i.push(d.then(g=>{g.issues.length&&n.issues.push(...Te(l,g.issues)),n.value[l]=g.value})):(d.issues.length&&n.issues.push(...Te(l,d.issues)),n.value[l]=d.value)}let c;for(const l in o)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},a);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&gn.test(s)&&c.issues.length){const g=t.keyType._zod.run({value:Number(s),issues:[]},a);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){t.mode==="loose"?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>ue(g,a,de())),input:s,path:[s],inst:e});continue}const d=t.valueType._zod.run({value:o[s],issues:[]},a);d instanceof Promise?i.push(d.then(g=>{g.issues.length&&n.issues.push(...Te(s,g.issues)),n.value[c.value]=g.value})):(d.issues.length&&n.issues.push(...Te(s,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),nc=m("$ZodEnum",(e,t)=>{Z.init(e,t);const n=Xt(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(o=>hr.has(typeof o)).map(o=>typeof o=="string"?Oe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return a.has(r)||o.issues.push({code:"invalid_value",values:n,input:r,inst:e}),o}}),ac=m("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Jt(e.constructor.name);const o=t.transform(n.value,n);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(r=>(n.value=r,n));if(o instanceof Promise)throw new Ce;return n.value=o,n}});function xn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const kn=m("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",M(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),M(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ot(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>xn(i,n.value)):xn(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),oc=m("$ZodExactOptional",(e,t)=>{kn.init(e,t),M(e._zod,"values",()=>t.innerType._zod.values),M(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),ic=m("$ZodNullable",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.innerType._zod.optin),M(e._zod,"optout",()=>t.innerType._zod.optout),M(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ot(n.source)}|null)$`):void 0}),M(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),rc=m("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>Cn(i,t)):Cn(o,t)}});function Cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const sc=m("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),cc=m("$ZodNonOptional",(e,t)=>{Z.init(e,t),M(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>En(i,e)):En(o,e)}});function En(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const lc=m("$ZodCatch",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.innerType._zod.optin),M(e._zod,"optout",()=>t.innerType._zod.optout),M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(r=>ue(r,a,de()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>ue(i,a,de()))},input:n.value}),n.issues=[]),n)}}),dc=m("$ZodPipe",(e,t)=>{Z.init(e,t),M(e._zod,"values",()=>t.in._zod.values),M(e._zod,"optin",()=>t.in._zod.optin),M(e._zod,"optout",()=>t.out._zod.optout),M(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const i=t.out._zod.run(n,a);return i instanceof Promise?i.then(r=>je(r,t.in,a)):je(i,t.in,a)}const o=t.in._zod.run(n,a);return o instanceof Promise?o.then(i=>je(i,t.out,a)):je(o,t.out,a)}});function je(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const gc=m("$ZodReadonly",(e,t)=>{Z.init(e,t),M(e._zod,"propValues",()=>t.innerType._zod.propValues),M(e._zod,"values",()=>t.innerType._zod.values),M(e._zod,"optin",()=>t.innerType?._zod?.optin),M(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(Sn):Sn(o)}});function Sn(e){return e.value=Object.freeze(e.value),e}const pc=m("$ZodCustom",(e,t)=>{K.init(e,t),Z.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,o=t.fn(a);if(o instanceof Promise)return o.then(i=>Tn(i,n,a,e));Tn(o,n,a,e)}});function Tn(e,t,n,a){if(!e){const o={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(o.params=a._zod.def.params),t.issues.push(Ne(o))}}var In;class uc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const o={...a,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function hc(){return new uc}(In=globalThis).__zod_globalRegistry??(In.__zod_globalRegistry=hc());const Pe=globalThis.__zod_globalRegistry;function fc(e,t){return new e({type:"string",...S(t)})}function mc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function zn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function bc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function _c(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function vc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function yc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function wc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function xc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function kc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function Cc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function Ec(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function Sc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function Tc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function Ic(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function zc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function Ac(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function Nc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function Pc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function Lc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function Mc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function $c(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function Oc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function Dc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function Bc(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function Rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function Zc(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function Uc(e,t){return new e({type:"number",checks:[],...S(t)})}function jc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function Fc(e,t){return new e({type:"boolean",...S(t)})}function qc(e){return new e({type:"unknown"})}function Hc(e,t){return new e({type:"never",...S(t)})}function An(e,t){return new un({check:"less_than",...S(t),value:e,inclusive:!1})}function dt(e,t){return new un({check:"less_than",...S(t),value:e,inclusive:!0})}function Nn(e,t){return new hn({check:"greater_than",...S(t),value:e,inclusive:!1})}function gt(e,t){return new hn({check:"greater_than",...S(t),value:e,inclusive:!0})}function Pn(e,t){return new ss({check:"multiple_of",...S(t),value:e})}function Ln(e,t){return new ls({check:"max_length",...S(t),maximum:e})}function Fe(e,t){return new ds({check:"min_length",...S(t),minimum:e})}function Mn(e,t){return new gs({check:"length_equals",...S(t),length:e})}function Vc(e,t){return new ps({check:"string_format",format:"regex",...S(t),pattern:e})}function Gc(e){return new us({check:"string_format",format:"lowercase",...S(e)})}function Wc(e){return new hs({check:"string_format",format:"uppercase",...S(e)})}function Kc(e,t){return new fs({check:"string_format",format:"includes",...S(t),includes:e})}function Jc(e,t){return new ms({check:"string_format",format:"starts_with",...S(t),prefix:e})}function Yc(e,t){return new bs({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Ie(e){return new _s({check:"overwrite",tx:e})}function Xc(e){return Ie(t=>t.normalize(e))}function Qc(){return Ie(e=>e.trim())}function el(){return Ie(e=>e.toLowerCase())}function tl(){return Ie(e=>e.toUpperCase())}function nl(){return Ie(e=>pr(e))}function al(e,t,n){return new e({type:"array",element:t,...S(n)})}function ol(e,t,n){return new e({type:"custom",check:"custom",fn:t,...S(n)})}function il(e){const t=rl(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ne(a,n.value,t._zod.def));else{const o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Ne(o))}},e(n.value,n)));return t}function rl(e,t){const n=new K({check:"custom",...S(t)});return n._zod.check=e,n}function $n(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Pe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function F(e,t,n={path:[],schemaPath:[]}){var a;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 r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const s=e._zod.toJSONSchema?.();if(s)r.schema=s;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const u=r.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,u,d)}const g=e._zod.parent;g&&(r.ref||(r.ref=g),F(g,t,d),t.seen.get(g).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&G(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((a=r.schema).default??(a.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function On(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const r of e.seen.entries()){const s=e.metadataRegistry.get(r[0])?.id;if(s){const c=a.get(s);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,r[0])}}const o=r=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=e.external.registry.get(r[0])?.id,u=e.external.uri??(f=>f);if(g)return{ref:u(g)};const p=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=p,{defId:p,ref:`${u("__shared")}#/${s}/${p}`}}if(r[1]===n)return{ref:"#"};const l=`#/${s}/`,d=r[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},i=r=>{if(r[1].schema.$ref)return;const s=r[1],{ref:c,defId:l}=o(r);s.def={...s.schema},l&&(s.defId=l);const d=s.schema;for(const g in d)delete d[g];d.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const s=r[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
94
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const I=p.compile();return(T,y)=>I(g,T,y)};let o;const r=$e,s=!en.jitless,l=s&&kr.value,d=t.catchall;let u;e._zod.parse=(g,p)=>{u??(u=a.value);const h=g.value;return r(h)?s&&l&&p?.async===!1&&p.jitless!==!0?(o||(o=i(t.shape)),g=o(g,p),d?xn([],h,g,p,u,e):g):n(g,p):(g.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),g)}});function kn(e,t,n,a){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!Se(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(r=>fe(r,a,pe())))}),t)}const lc=m("$ZodUnion",(e,t)=>{F.init(e,t),D(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),D(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),D(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),D(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>it(o.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return a(i,o);let r=!1;const s=[];for(const c of t.options){const l=c._zod.run({value:i.value,issues:[]},o);if(l instanceof Promise)s.push(l),r=!0;else{if(l.issues.length===0)return l;s.push(l)}}return r?Promise.all(s).then(c=>kn(c,i,e,o)):kn(s,i,e,o)}}),dc=m("$ZodIntersection",(e,t)=>{F.init(e,t),e._zod.parse=(n,a)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},a),r=t.right._zod.run({value:i,issues:[]},a);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then(([c,l])=>Cn(n,c,l)):Cn(n,o,r)}});function lt(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(Ee(e)&&Ee(t)){const n=Object.keys(t),a=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of a){const r=lt(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 n=[];for(let a=0;a<e.length;a++){const i=e[a],o=t[a],r=lt(i,o);if(!r.valid)return{valid:!1,mergeErrorPath:[a,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Cn(e,t,n){const a=new Map;let i;for(const s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).r=!0;else e.issues.push(s);const o=[...a].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(o.length&&i&&e.issues.push({...i,keys:o}),Se(e))return e;const r=lt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const gc=m("$ZodRecord",(e,t)=>{F.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!Ee(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],r=t.keyType._zod.values;if(r){n.value={};const s=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:i[l],issues:[]},a);d instanceof Promise?o.push(d.then(u=>{u.issues.length&&n.issues.push(...Te(l,u.issues)),n.value[l]=u.value})):(d.issues.length&&n.issues.push(...Te(l,d.issues)),n.value[l]=d.value)}let c;for(const l in i)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},a);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&hn.test(s)&&c.issues.length){const u=t.keyType._zod.run({value:Number(s),issues:[]},a);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");u.issues.length===0&&(c=u)}if(c.issues.length){t.mode==="loose"?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(u=>fe(u,a,pe())),input:s,path:[s],inst:e});continue}const d=t.valueType._zod.run({value:i[s],issues:[]},a);d instanceof Promise?o.push(d.then(u=>{u.issues.length&&n.issues.push(...Te(s,u.issues)),n.value[c.value]=u.value})):(d.issues.length&&n.issues.push(...Te(s,d.issues)),n.value[c.value]=d.value)}}return o.length?Promise.all(o).then(()=>n):n}}),pc=m("$ZodEnum",(e,t)=>{F.init(e,t);const n=tn(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(i=>Cr.has(typeof i)).map(i=>typeof i=="string"?Oe(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const r=i.value;return a.has(r)||i.issues.push({code:"invalid_value",values:n,input:r,inst:e}),i}}),uc=m("$ZodTransform",(e,t)=>{F.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Qt(e.constructor.name);const i=t.transform(n.value,n);if(a.async)return(i instanceof Promise?i:Promise.resolve(i)).then(r=>(n.value=r,n));if(i instanceof Promise)throw new Ce;return n.value=i,n}});function En(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Sn=m("$ZodOptional",(e,t)=>{F.init(e,t),e._zod.optin="optional",e._zod.optout="optional",D(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),D(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${it(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>En(o,n.value)):En(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),hc=m("$ZodExactOptional",(e,t)=>{Sn.init(e,t),D(e._zod,"values",()=>t.innerType._zod.values),D(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),fc=m("$ZodNullable",(e,t)=>{F.init(e,t),D(e._zod,"optin",()=>t.innerType._zod.optin),D(e._zod,"optout",()=>t.innerType._zod.optout),D(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${it(n.source)}|null)$`):void 0}),D(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),mc=m("$ZodDefault",(e,t)=>{F.init(e,t),e._zod.optin="optional",D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>Tn(o,t)):Tn(i,t)}});function Tn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const bc=m("$ZodPrefault",(e,t)=>{F.init(e,t),e._zod.optin="optional",D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),_c=m("$ZodNonOptional",(e,t)=>{F.init(e,t),D(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>In(o,e)):In(i,e)}});function In(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const vc=m("$ZodCatch",(e,t)=>{F.init(e,t),D(e._zod,"optin",()=>t.innerType._zod.optin),D(e._zod,"optout",()=>t.innerType._zod.optout),D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(r=>fe(r,a,pe()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>fe(o,a,pe()))},input:n.value}),n.issues=[]),n)}}),yc=m("$ZodPipe",(e,t)=>{F.init(e,t),D(e._zod,"values",()=>t.in._zod.values),D(e._zod,"optin",()=>t.in._zod.optin),D(e._zod,"optout",()=>t.out._zod.optout),D(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const o=t.out._zod.run(n,a);return o instanceof Promise?o.then(r=>je(r,t.in,a)):je(o,t.in,a)}const i=t.in._zod.run(n,a);return i instanceof Promise?i.then(o=>je(o,t.out,a)):je(i,t.out,a)}});function je(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const wc=m("$ZodReadonly",(e,t)=>{F.init(e,t),D(e._zod,"propValues",()=>t.innerType._zod.propValues),D(e._zod,"values",()=>t.innerType._zod.values),D(e._zod,"optin",()=>t.innerType?._zod?.optin),D(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(zn):zn(i)}});function zn(e){return e.value=Object.freeze(e.value),e}const xc=m("$ZodCustom",(e,t)=>{Y.init(e,t),F.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,i=t.fn(a);if(i instanceof Promise)return i.then(o=>Pn(o,n,a,e));Pn(i,n,a,e)}});function Pn(e,t,n,a){if(!e){const i={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(Ae(i))}}var An;class kc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const i={...a,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Cc(){return new kc}(An=globalThis).__zod_globalRegistry??(An.__zod_globalRegistry=Cc());const Ne=globalThis.__zod_globalRegistry;function Ec(e,t){return new e({type:"string",...S(t)})}function Sc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function Nn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function Tc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function Ic(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function zc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function Pc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function Ac(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function Nc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function Lc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function Mc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function $c(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function Oc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function Bc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function Dc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function Rc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function Uc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function Zc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function jc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function Fc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function qc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function Hc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function Vc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function Gc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function Wc(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function Kc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function Jc(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function Yc(e,t){return new e({type:"number",checks:[],...S(t)})}function Xc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function Qc(e,t){return new e({type:"boolean",...S(t)})}function el(e){return new e({type:"unknown"})}function tl(e,t){return new e({type:"never",...S(t)})}function Ln(e,t){return new mn({check:"less_than",...S(t),value:e,inclusive:!1})}function dt(e,t){return new mn({check:"less_than",...S(t),value:e,inclusive:!0})}function Mn(e,t){return new bn({check:"greater_than",...S(t),value:e,inclusive:!1})}function gt(e,t){return new bn({check:"greater_than",...S(t),value:e,inclusive:!0})}function $n(e,t){return new bs({check:"multiple_of",...S(t),value:e})}function On(e,t){return new vs({check:"max_length",...S(t),maximum:e})}function Fe(e,t){return new ys({check:"min_length",...S(t),minimum:e})}function Bn(e,t){return new ws({check:"length_equals",...S(t),length:e})}function nl(e,t){return new xs({check:"string_format",format:"regex",...S(t),pattern:e})}function al(e){return new ks({check:"string_format",format:"lowercase",...S(e)})}function il(e){return new Cs({check:"string_format",format:"uppercase",...S(e)})}function ol(e,t){return new Es({check:"string_format",format:"includes",...S(t),includes:e})}function rl(e,t){return new Ss({check:"string_format",format:"starts_with",...S(t),prefix:e})}function sl(e,t){return new Ts({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Ie(e){return new Is({check:"overwrite",tx:e})}function cl(e){return Ie(t=>t.normalize(e))}function ll(){return Ie(e=>e.trim())}function dl(){return Ie(e=>e.toLowerCase())}function gl(){return Ie(e=>e.toUpperCase())}function pl(){return Ie(e=>xr(e))}function ul(e,t,n){return new e({type:"array",element:t,...S(n)})}function hl(e,t,n){return new e({type:"custom",check:"custom",fn:t,...S(n)})}function fl(e){const t=ml(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ae(a,n.value,t._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Ae(i))}},e(n.value,n)));return t}function ml(e,t){const n=new Y({check:"custom",...S(t)});return n._zod.check=e,n}function Dn(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ne,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function H(e,t,n={path:[],schemaPath:[]}){var a;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const s=e._zod.toJSONSchema?.();if(s)r.schema=s;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const g=r.schema,p=t.processors[i.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);p(e,t,g,d)}const u=e._zod.parent;u&&(r.ref||(r.ref=u),H(u,t,d),t.seen.get(u).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&W(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((a=r.schema).default??(a.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function Rn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const r of e.seen.entries()){const s=e.metadataRegistry.get(r[0])?.id;if(s){const c=a.get(s);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,r[0])}}const i=r=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const u=e.external.registry.get(r[0])?.id,g=e.external.uri??(h=>h);if(u)return{ref:g(u)};const p=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=p,{defId:p,ref:`${g("__shared")}#/${s}/${p}`}}if(r[1]===n)return{ref:"#"};const l=`#/${s}/`,d=r[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},o=r=>{if(r[1].schema.$ref)return;const s=r[1],{ref:c,defId:l}=i(r);s.def={...s.schema},l&&(s.defId=l);const d=s.schema;for(const u in d)delete d[u];d.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const s=r[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
95
95
 
96
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const s=r[1];if(t===r[0]){i(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){i(r);continue}}if(e.metadataRegistry.get(r[0])?.id){i(r);continue}if(s.cycle){i(r);continue}if(s.count>1&&e.reused==="ref"){i(r);continue}}}function Dn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=r=>{const s=e.seen.get(r);if(s.ref===null)return;const c=s.def??s.schema,l={...c},d=s.ref;if(s.ref=null,d){a(d);const u=e.seen.get(d),p=u.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):Object.assign(c,p),Object.assign(c,l),r._zod.parent===d)for(const v in c)v==="$ref"||v==="allOf"||v in l||delete c[v];if(p.$ref&&u.def)for(const v in c)v==="$ref"||v==="allOf"||v in u.def&&JSON.stringify(c[v])===JSON.stringify(u.def[v])&&delete c[v]}const g=r._zod.parent;if(g&&g!==d){a(g);const u=e.seen.get(g);if(u?.schema.$ref&&(c.$ref=u.schema.$ref,u.def))for(const p in c)p==="$ref"||p==="allOf"||p in u.def&&JSON.stringify(c[p])===JSON.stringify(u.def[p])&&delete c[p]}e.override({zodSchema:r,jsonSchema:c,path:s.path??[]})};for(const r of[...e.seen.entries()].reverse())a(r[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$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");o.$id=e.external.uri(r)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const r of e.seen.entries()){const s=r[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const r=JSON.parse(JSON.stringify(o));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:qe(t,"input",e.processors),output:qe(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function G(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return G(a.element,n);if(a.type==="set")return G(a.valueType,n);if(a.type==="lazy")return G(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return G(a.innerType,n);if(a.type==="intersection")return G(a.left,n)||G(a.right,n);if(a.type==="record"||a.type==="map")return G(a.keyType,n)||G(a.valueType,n);if(a.type==="pipe")return G(a.in,n)||G(a.out,n);if(a.type==="object"){for(const o in a.shape)if(G(a.shape[o],n))return!0;return!1}if(a.type==="union"){for(const o of a.options)if(G(o,n))return!0;return!1}if(a.type==="tuple"){for(const o of a.items)if(G(o,n))return!0;return!!(a.rest&&G(a.rest,n))}return!1}const sl=(e,t={})=>n=>{const a=$n({...n,processors:t});return F(e,a),On(a,e),Dn(a,e)},qe=(e,t,n={})=>a=>{const{libraryOptions:o,target:i}=a??{},r=$n({...o??{},target:i,io:t,processors:n});return F(e,r),On(r,e),Dn(r,e)},cl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ll=(e,t,n,a)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof r=="number"&&(o.maxLength=r),s&&(o.format=cl[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},dl=(e,t,n,a)=>{const o=n,{minimum:i,maximum:r,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l),typeof r=="number"&&(o.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},gl=(e,t,n,a)=>{n.type="boolean"},pl=(e,t,n,a)=>{n.not={}},ul=(e,t,n,a)=>{},hl=(e,t,n,a)=>{const o=e._zod.def,i=Xt(o.entries);i.every(r=>typeof r=="number")&&(n.type="number"),i.every(r=>typeof r=="string")&&(n.type="string"),n.enum=i},fl=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ml=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bl=(e,t,n,a)=>{const o=n,i=e._zod.def,{minimum:r,maximum:s}=e._zod.bag;typeof r=="number"&&(o.minItems=r),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=F(i.element,t,{...a,path:[...a.path,"items"]})},_l=(e,t,n,a)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const r=i.shape;for(const l in r)o.properties[l]=F(r[l],t,{...a,path:[...a.path,"properties",l]});const s=new Set(Object.keys(r)),c=new Set([...s].filter(l=>{const d=i.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=F(i.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},vl=(e,t,n,a)=>{const o=e._zod.def,i=o.inclusive===!1,r=o.options.map((s,c)=>F(s,t,{...a,path:[...a.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=r:n.anyOf=r},yl=(e,t,n,a)=>{const o=e._zod.def,i=F(o.left,t,{...a,path:[...a.path,"allOf",0]}),r=F(o.right,t,{...a,path:[...a.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(i)?i.allOf:[i],...s(r)?r.allOf:[r]];n.allOf=c},wl=(e,t,n,a)=>{const o=n,i=e._zod.def;o.type="object";const r=i.keyType,c=r._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=F(i.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});o.patternProperties={};for(const g of c)o.patternProperties[g.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=F(i.keyType,t,{...a,path:[...a.path,"propertyNames"]})),o.additionalProperties=F(i.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const l=r._zod.values;if(l){const d=[...l].filter(g=>typeof g=="string"||typeof g=="number");d.length>0&&(o.required=d)}},xl=(e,t,n,a)=>{const o=e._zod.def,i=F(o.innerType,t,a),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},kl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType},Cl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},El=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Sl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType;let r;try{r=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Tl=(e,t,n,a)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;F(i,t,a);const r=t.seen.get(e);r.ref=i},Il=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Bn=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType},zl=m("ZodISODateTime",(e,t)=>{Ps.init(e,t),R.init(e,t)});function Al(e){return Dc(zl,e)}const Nl=m("ZodISODate",(e,t)=>{Ls.init(e,t),R.init(e,t)});function Pl(e){return Bc(Nl,e)}const Ll=m("ZodISOTime",(e,t)=>{Ms.init(e,t),R.init(e,t)});function Ml(e){return Rc(Ll,e)}const $l=m("ZodISODuration",(e,t)=>{$s.init(e,t),R.init(e,t)});function Ol(e){return Zc($l,e)}const Y=m("ZodError",(e,t)=>{on.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Er(e,n)},flatten:{value:n=>Cr(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,tt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,tt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Dl=rt(Y),Bl=st(Y),Rl=Be(Y),Zl=Re(Y),Ul=Ir(Y),jl=zr(Y),Fl=Ar(Y),ql=Nr(Y),Hl=Pr(Y),Vl=Lr(Y),Gl=Mr(Y),Wl=$r(Y),U=m("ZodType",(e,t)=>(Z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:qe(e,"input"),output:qe(e,"output")}}),e.toJSONSchema=sl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ge(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>pe(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Dl(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>Rl(e,n,a),e.parseAsync=async(n,a)=>Bl(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>Zl(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Ul(e,n,a),e.decode=(n,a)=>jl(e,n,a),e.encodeAsync=async(n,a)=>Fl(e,n,a),e.decodeAsync=async(n,a)=>ql(e,n,a),e.safeEncode=(n,a)=>Hl(e,n,a),e.safeDecode=(n,a)=>Vl(e,n,a),e.safeEncodeAsync=async(n,a)=>Gl(e,n,a),e.safeDecodeAsync=async(n,a)=>Wl(e,n,a),e.refine=(n,a)=>e.check(Zd(n,a)),e.superRefine=n=>e.check(Ud(n)),e.overwrite=n=>e.check(Ie(n)),e.optional=()=>qn(e),e.exactOptional=()=>Td(e),e.nullable=()=>Hn(e),e.nullish=()=>qn(Hn(e)),e.nonoptional=n=>Ld(e,n),e.array=()=>B(e),e.or=n=>Ve([e,n]),e.and=n=>xd(e,n),e.transform=n=>Gn(e,Ed(n)),e.default=n=>Ad(e,n),e.prefault=n=>Pd(e,n),e.catch=n=>$d(e,n),e.pipe=n=>Gn(e,n),e.readonly=()=>Bd(e),e.describe=n=>{const a=e.clone();return Pe.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Pe.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Pe.get(e);const a=e.clone();return Pe.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Rn=m("_ZodString",(e,t)=>{ct.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>ll(e,a,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(Vc(...a)),e.includes=(...a)=>e.check(Kc(...a)),e.startsWith=(...a)=>e.check(Jc(...a)),e.endsWith=(...a)=>e.check(Yc(...a)),e.min=(...a)=>e.check(Fe(...a)),e.max=(...a)=>e.check(Ln(...a)),e.length=(...a)=>e.check(Mn(...a)),e.nonempty=(...a)=>e.check(Fe(1,...a)),e.lowercase=a=>e.check(Gc(a)),e.uppercase=a=>e.check(Wc(a)),e.trim=()=>e.check(Qc()),e.normalize=(...a)=>e.check(Xc(...a)),e.toLowerCase=()=>e.check(el()),e.toUpperCase=()=>e.check(tl()),e.slugify=()=>e.check(nl())}),Kl=m("ZodString",(e,t)=>{ct.init(e,t),Rn.init(e,t),e.email=n=>e.check(mc(Jl,n)),e.url=n=>e.check(wc(Yl,n)),e.jwt=n=>e.check(Oc(pd,n)),e.emoji=n=>e.check(xc(Xl,n)),e.guid=n=>e.check(zn(Zn,n)),e.uuid=n=>e.check(bc(He,n)),e.uuidv4=n=>e.check(_c(He,n)),e.uuidv6=n=>e.check(vc(He,n)),e.uuidv7=n=>e.check(yc(He,n)),e.nanoid=n=>e.check(kc(Ql,n)),e.guid=n=>e.check(zn(Zn,n)),e.cuid=n=>e.check(Cc(ed,n)),e.cuid2=n=>e.check(Ec(td,n)),e.ulid=n=>e.check(Sc(nd,n)),e.base64=n=>e.check(Lc(ld,n)),e.base64url=n=>e.check(Mc(dd,n)),e.xid=n=>e.check(Tc(ad,n)),e.ksuid=n=>e.check(Ic(od,n)),e.ipv4=n=>e.check(zc(id,n)),e.ipv6=n=>e.check(Ac(rd,n)),e.cidrv4=n=>e.check(Nc(sd,n)),e.cidrv6=n=>e.check(Pc(cd,n)),e.e164=n=>e.check($c(gd,n)),e.datetime=n=>e.check(Al(n)),e.date=n=>e.check(Pl(n)),e.time=n=>e.check(Ml(n)),e.duration=n=>e.check(Ol(n))});function x(e){return fc(Kl,e)}const R=m("ZodStringFormat",(e,t)=>{D.init(e,t),Rn.init(e,t)}),Jl=m("ZodEmail",(e,t)=>{ks.init(e,t),R.init(e,t)}),Zn=m("ZodGUID",(e,t)=>{ws.init(e,t),R.init(e,t)}),He=m("ZodUUID",(e,t)=>{xs.init(e,t),R.init(e,t)}),Yl=m("ZodURL",(e,t)=>{Cs.init(e,t),R.init(e,t)}),Xl=m("ZodEmoji",(e,t)=>{Es.init(e,t),R.init(e,t)}),Ql=m("ZodNanoID",(e,t)=>{Ss.init(e,t),R.init(e,t)}),ed=m("ZodCUID",(e,t)=>{Ts.init(e,t),R.init(e,t)}),td=m("ZodCUID2",(e,t)=>{Is.init(e,t),R.init(e,t)}),nd=m("ZodULID",(e,t)=>{zs.init(e,t),R.init(e,t)}),ad=m("ZodXID",(e,t)=>{As.init(e,t),R.init(e,t)}),od=m("ZodKSUID",(e,t)=>{Ns.init(e,t),R.init(e,t)}),id=m("ZodIPv4",(e,t)=>{Os.init(e,t),R.init(e,t)}),rd=m("ZodIPv6",(e,t)=>{Ds.init(e,t),R.init(e,t)}),sd=m("ZodCIDRv4",(e,t)=>{Bs.init(e,t),R.init(e,t)}),cd=m("ZodCIDRv6",(e,t)=>{Rs.init(e,t),R.init(e,t)}),ld=m("ZodBase64",(e,t)=>{Zs.init(e,t),R.init(e,t)}),dd=m("ZodBase64URL",(e,t)=>{js.init(e,t),R.init(e,t)}),gd=m("ZodE164",(e,t)=>{Fs.init(e,t),R.init(e,t)}),pd=m("ZodJWT",(e,t)=>{Hs.init(e,t),R.init(e,t)}),Un=m("ZodNumber",(e,t)=>{mn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>dl(e,a,o),e.gt=(a,o)=>e.check(Nn(a,o)),e.gte=(a,o)=>e.check(gt(a,o)),e.min=(a,o)=>e.check(gt(a,o)),e.lt=(a,o)=>e.check(An(a,o)),e.lte=(a,o)=>e.check(dt(a,o)),e.max=(a,o)=>e.check(dt(a,o)),e.int=a=>e.check(jn(a)),e.safe=a=>e.check(jn(a)),e.positive=a=>e.check(Nn(0,a)),e.nonnegative=a=>e.check(gt(0,a)),e.negative=a=>e.check(An(0,a)),e.nonpositive=a=>e.check(dt(0,a)),e.multipleOf=(a,o)=>e.check(Pn(a,o)),e.step=(a,o)=>e.check(Pn(a,o)),e.finite=()=>e;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 he(e){return Uc(Un,e)}const ud=m("ZodNumberFormat",(e,t)=>{Vs.init(e,t),Un.init(e,t)});function jn(e){return jc(ud,e)}const hd=m("ZodBoolean",(e,t)=>{Gs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>gl(e,n,a)});function pt(e){return Fc(hd,e)}const fd=m("ZodUnknown",(e,t)=>{Ws.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>ul()});function ae(){return qc(fd)}const md=m("ZodNever",(e,t)=>{Ks.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>pl(e,n,a)});function bd(e){return Hc(md,e)}const _d=m("ZodArray",(e,t)=>{Js.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>bl(e,n,a,o),e.element=t.element,e.min=(n,a)=>e.check(Fe(n,a)),e.nonempty=n=>e.check(Fe(1,n)),e.max=(n,a)=>e.check(Ln(n,a)),e.length=(n,a)=>e.check(Mn(n,a)),e.unwrap=()=>e.element});function B(e,t){return al(_d,e,t)}const vd=m("ZodObject",(e,t)=>{Xs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>_l(e,n,a,o),M(e,"shape",()=>t.shape),e.keyof=()=>ht(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ae()}),e.loose=()=>e.clone({...e._zod.def,catchall:ae()}),e.strict=()=>e.clone({...e._zod.def,catchall:bd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>vr(e,n),e.safeExtend=n=>yr(e,n),e.merge=n=>wr(e,n),e.pick=n=>br(e,n),e.omit=n=>_r(e,n),e.partial=(...n)=>xr(Fn,e,n[0]),e.required=(...n)=>kr(Vn,e,n[0])});function L(e,t){const n={type:"object",shape:e??{},...S(t)};return new vd(n)}const yd=m("ZodUnion",(e,t)=>{Qs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>vl(e,n,a,o),e.options=t.options});function Ve(e,t){return new yd({type:"union",options:e,...S(t)})}const wd=m("ZodIntersection",(e,t)=>{ec.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>yl(e,n,a,o)});function xd(e,t){return new wd({type:"intersection",left:e,right:t})}const kd=m("ZodRecord",(e,t)=>{tc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>wl(e,n,a,o),e.keyType=t.keyType,e.valueType=t.valueType});function Le(e,t,n){return new kd({type:"record",keyType:e,valueType:t,...S(n)})}const ut=m("ZodEnum",(e,t)=>{nc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>hl(e,a,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,o)=>{const i={};for(const r of a)if(n.has(r))i[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...S(o),entries:i})},e.exclude=(a,o)=>{const i={...t.entries};for(const r of a)if(n.has(r))delete i[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...S(o),entries:i})}});function ht(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new ut({type:"enum",entries:n,...S(t)})}const Cd=m("ZodTransform",(e,t)=>{ac.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>ml(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Jt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ne(i,n.value,t));else{const r=i;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(Ne(r))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Ed(e){return new Cd({type:"transform",transform:e})}const Fn=m("ZodOptional",(e,t)=>{kn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Bn(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function qn(e){return new Fn({type:"optional",innerType:e})}const Sd=m("ZodExactOptional",(e,t)=>{oc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Bn(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Td(e){return new Sd({type:"optional",innerType:e})}const Id=m("ZodNullable",(e,t)=>{ic.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>xl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Hn(e){return new Id({type:"nullable",innerType:e})}const zd=m("ZodDefault",(e,t)=>{rc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Cl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ad(e,t){return new zd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():nn(t)}})}const Nd=m("ZodPrefault",(e,t)=>{sc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>El(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Pd(e,t){return new Nd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():nn(t)}})}const Vn=m("ZodNonOptional",(e,t)=>{cc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>kl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e,t){return new Vn({type:"nonoptional",innerType:e,...S(t)})}const Md=m("ZodCatch",(e,t)=>{lc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Sl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $d(e,t){return new Md({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Od=m("ZodPipe",(e,t)=>{dc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Tl(e,n,a,o),e.in=t.in,e.out=t.out});function Gn(e,t){return new Od({type:"pipe",in:e,out:t})}const Dd=m("ZodReadonly",(e,t)=>{gc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Il(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Bd(e){return new Dd({type:"readonly",innerType:e})}const Rd=m("ZodCustom",(e,t)=>{pc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>fl(e,n)});function Zd(e,t={}){return ol(Rd,e,t)}function Ud(e){return il(e)}const jd=L({role:ht(["user","assistant"]),content:x(),timestamp:he().optional()}),Fd=L({sku:x(),name:x(),imageUrl:x().url().optional(),price:x().optional(),originalPrice:x().optional(),url:x().url(),ctaLabel:x().optional()}),qd=L({buttons:B(L({label:x(),action:L({title:x(),type:x(),payload:ae().optional()})}))}),Hd=L({}),Vd=L({label:x().optional()}),Wn=L({sku:x(),name:x(),price:x(),imageUrl:x().optional(),rating:he().optional(),reviewCount:he().optional()}),Gd=L({recommended:Wn,products:B(Wn),attributes:B(L({label:x(),values:B(x())})),highlights:B(x()),specialCases:B(x()).optional(),recommendedText:x().optional(),winnerHits:Le(x(),L({positive:B(x()).optional(),negative:B(x()).optional()})).optional(),productActions:Le(x(),L({title:x(),type:x(),payload:ae().optional()})).optional()}),Wd=L({label:x(),sentiment:ht(["positive","negative","neutral"]).optional()}),Kd=L({product:Le(x(),ae()),role:x().optional(),reason:x().optional(),labels:B(Wd).optional(),expertQualityScore:he().optional(),reviewHighlight:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()}).optional()}),Jd=L({suggestions:B(Kd)}),Yd=L({title:x().optional(),text:x().optional(),reviewCount:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()})}),Xd=L({entries:B(L({name:x(),image:x().optional(),description:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()})}))}),Qd=L({entries:B(L({shortName:x(),detailedMessage:x().optional(),whyDifferent:x().optional(),image:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()})}))}),Kn=L({title:x(),type:x(),payload:ae().optional()}),eg=L({name:x().optional(),variant_name:x().optional(),sku:x().optional(),price:Ve([he(),x()]).optional()}),tg=L({product:L({sku:x().optional(),name:x().optional(),images:B(x()).optional(),imageUrl:x().optional(),rating:he().optional(),reviewCount:he().optional(),price:x().optional(),originalPrice:x().optional(),price_async:pt().optional(),inStock:pt().optional(),promotions:B(x()).optional(),variants:B(eg).optional(),url:x().optional(),cartCode:x().optional(),description:x().optional(),specifications:Ve([Le(x(),x()),B(L({key:x(),value:x()}))]).optional()}).optional(),action:Kn.optional()}),ng=L({endOfList:pt().optional()}),ag=L({review_class:x().optional(),review_text:x().optional(),review_rating:Ve([x(),he()]).optional(),review_tag:x().optional()}),og=L({reviews:B(ag).optional()}),ig=L({productName:x().optional(),pros:B(x()).optional(),cons:B(x()).optional()}),rg=L({groups:B(L({groupName:x(),products:B(Le(x(),ae())).optional()})).optional(),filterTags:B(L({title:x(),action:Kn.optional()})).optional()}),sg=L({summary:x().optional(),products_discussed:B(x()).optional(),user_sentiment:x().optional()}),cg={components:{MessageBubble:{schema:jd,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:Fd,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:qd,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:Hd,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:Vd,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:Gd,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:Jd,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:Yd,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:Xd,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:Qd,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:tg,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:ng,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:og,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:ig,description:"A pros and cons list for a product."},CategoriesContainer:{schema:rg,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:sg,description:"A notice shown when the conversation is escalated to a human agent."}}};function lg(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function Me(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}class Jn extends Ca{constructor(){super(...arguments),this._shadow=null,this._rootEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._activityTracker=null,this._heartbeat=null,this._proactiveShown=!1,this._drawerVisible=!1,this._messages=[],this._currentMessageId=0,this._abortControllers=new Set,this._currentThreadId=null,this._lastThreadId=null,this._chatCreatedAt="",this._lastBackendContext=null,this._productSort={type:"related"},this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._pdpLaunched=!1,this._i18n=Je,this._extendedModeManager=null,this._activeTypewriter=null,this._activeTtsHandle=null,this._activeRequestThreadId=null,this._skuToProductItem={},this._conversationMode=null,this._initComplete=!1,this._pendingActions=[],this._bridgeContext=null,this._cartQuantity=null,this._threadsWithFirstBot=new Set,this._panel=null,this._session=null,this._eventCallbacks=new Map}async onInit(t){this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),this._shadow=this.root.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Wi,this._shadow.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-root",this._rootEl=a,this._shadow.appendChild(a);const o=t.variant??"floating";if(o==="floating"){const d={onClick:()=>this.open(),ariaLabel:this._i18n.openButton};t.launcherSvg!==void 0&&(d.svgMarkup=t.launcherSvg),t.hideMobileLauncher!==void 0&&(d.hideMobile=t.hideMobileLauncher),t.mobileBreakpoint!==void 0&&(d.mobileBreakpoint=t.mobileBreakpoint),t.launcherTooltip!==void 0&&(d.tooltip=t.launcherTooltip),this._launcher=qo(d),a.appendChild(this._launcher.container)}o==="overlay"&&a.classList.add("gengage-chat--overlay");const i=document.createElement("div");a.appendChild(i),this._drawer=new jo(i,{i18n:this._i18n,onSend:(d,g)=>this._sendMessage(d,g),onClose:()=>this.close(),onAttachment:d=>this._handleAttachment(d),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onRollback:d=>this._handleRollback(d),onPanelBack:()=>this._panel?.navigateBack(),onPanelForward:()=>this._panel?.navigateForward(),headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,headerFavoritesToggle:t.headerFavoritesToggle,onFavoritesClick:()=>{or(),t.onFavoritesClick?.()},onThumbnailClick:d=>this._rollbackToThread(d),onLinkClick:d=>{this._saveSessionAndOpenURL(d)},voiceEnabled:t.voiceEnabled,voiceLang:t.locale?`${t.locale.split("-")[0]??"tr"}-${(t.locale.split("-")[1]??t.locale.split("-")[0]??"TR").toUpperCase()}`:void 0}),this._extendedModeManager=new Ri({onChange:d=>this._panel?.notifyExtension(d),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new Zi({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:d=>this._rollbackToThread(d)}),o!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"),this._drawer.restorePanelState(t.accountId),(t.panelMode??"auto")==="collapsed"?this._drawer.setPanelCollapsed(!0):this._drawer.setForceExpanded();const s=sessionStorage.getItem("gengage_restore_session_id"),c=sessionStorage.getItem("gengage_restore_sku");s&&c&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const d=new Di;await d.open(),this._session=new Ht(d),await this._restoreFromIndexedDB()}catch{this._session=new Ht(null)}this._registerPublicAPI(),t.mobileInitialState!==void 0&&(this._openState=t.mobileInitialState),this._mobileBreakpoint=t.mobileBreakpoint??768,this._syncViewportState();const l=()=>this._syncViewportState();if(window.addEventListener("resize",l,{passive:!0}),this.addCleanup(()=>window.removeEventListener("resize",l)),window.visualViewport){const d=()=>{if(!this._drawerVisible||!this._isMobileViewport)return;const g=this._drawer?.getElement();if(!g)return;const u=window.innerHeight-(window.visualViewport?.height??window.innerHeight);g.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,u)}px`)};window.visualViewport.addEventListener("resize",d),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",d))}o==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses()),this._bridge=new Ta({namespace:"chat",onMessage:d=>this._handleBridgeMessage(d)}),this._activityTracker=new Vo({idleThresholdMs:t.proactiveDelayMs??3e4,onActivity:d=>{if(d.type==="idle"&&!this._proactiveShown&&!this._drawerVisible){const g=t.proactiveMinScrollDepth??0;if(g>0&&(this._activityTracker?.maxScrollDepth??0)<g*100)return;try{if(sessionStorage.getItem("gengage_proactive_shown"))return}catch{}if(this._isProactiveCooldownActive())return;t.proactiveFetchActions?this._fetchAndShowProactive():t.proactiveMessage&&this._showProactivePopup(t.proactiveMessage)}}}),this.addCleanup(()=>this._activityTracker?.destroy()),t.enableHeartbeat&&(this._heartbeat=new Ko({middlewareUrl:t.middlewareUrl,accountId:t.accountId,sessionId:t.session?.sessionId??"",locale:t.locale??"tr",intervalMs:t.heartbeatIntervalMs??3e4,getPageType:()=>this.config.pageContext?.pageType??"other",getCurrentSku:()=>this.config.pageContext?.sku??"",onMessage:d=>{if(!this._proactiveShown&&!this._drawerVisible&&d.message){const g=[];if(d.suggested_actions&&Array.isArray(d.suggested_actions))for(const u of d.suggested_actions)u.title&&Me(u.requestDetails)&&g.push({title:u.title,onSelect:()=>{this.openWithAction(u.requestDetails)}});this._showProactivePopup(d.message,g.length>0?g:void 0)}}}),this._heartbeat.start(),this.addCleanup(()=>this._heartbeat?.destroy())),this._initComplete=!0;for(const d of this._pendingActions)this._sendAction(d.action,d.options);this._pendingActions=[],ee("gengage:chat:ready",{}),Ji("chat"),t.onReady?.()}onUpdate(t){}onShow(){this._showDrawer(),this.emit("open"),ee("gengage:chat:open",{state:this._openState}),Yi("chat"),this.config.onOpen?.(),!this._pdpLaunched&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku}},{silent:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),ee("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._bridge?.destroy(),this._bridge=null,this._extendedModeManager=null,this._panel?.destroy(),this._panel=null,this._session?.close(),this._session=null,window.gengage&&delete window.gengage.chat,this._shadow&&(this._shadow.innerHTML="",this._shadow=null),this._rootEl=null}open(t){t?.state!==void 0&&(this._openState=t.state,this._drawerVisible&&this._applyOpenStateClasses()),this.show(),t?.initialMessage!==void 0&&this._sendMessage(t.initialMessage)}openWithAction(t,n){n?.sku!==void 0&&this.update({sku:n.sku}),this._pdpLaunched=!0,n?.state!==void 0?this._openState=n.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,n){this._sendAction(t,n)}close(){this.hide()}saveSession(t,n){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",n)}get isOpen(){return this._drawerVisible}addCallback(t,n){let a=this._eventCallbacks.get(t);return a||(a=new Set,this._eventCallbacks.set(t,a)),a.add(n),()=>{a.delete(n),a.size===0&&this._eventCallbacks.delete(t)}}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const n=t.payload,a=n?.action,o=Me(a)?a:Me(n)?n:null;o&&this._sendAction(o,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const n=t.payload;if(n&&typeof n=="object"){this._bridgeContext=n;const a=n.sku;if(a&&this.update({sku:a}),Me(n.action)){this._pdpLaunched=!0,this.open(),this._sendAction(n.action);break}}this.open();break}case"launcherAction":{const a=t.payload?.action;a&&typeof a=="object"&&"type"in a&&this._sendAction(a);break}case"scrollToBottom":this._drawer?.scrollToBottomIfNeeded();break;case"addToCardHandler":{this._bridge?.send("addToCardResult",t.payload);break}case"cartQuantityHandler":{const n=t.payload;n&&"quantity"in n&&typeof n.quantity=="number"&&(this._cartQuantity=n.quantity);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&lg(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,n)=>this.openWithAction(t,n),sendMessage:t=>this.sendMessage(t),sendAction:(t,n)=>this.sendAction(t,n),close:()=>this.close(),saveSession:(t,n)=>this.saveSession(t,n),get isOpen(){return!1},on:(t,n)=>this.on(t,n),trackCheckout:(t,n)=>this.trackCheckout(t,n),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,n)=>this.addCallback(t,n)},Object.defineProperty(window.gengage.chat,"isOpen",{get:()=>this._drawerVisible})}_showDrawer(){if(this._drawerVisible)return;this._drawerVisible=!0;const t=this._drawer?.getElement();t&&t.classList.remove("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._isMobileViewport&&this._openState==="half"||this._drawer?.focusInput(),this._extendedModeManager?.setChatShown(!0)}_showProactivePopup(t,n){if(this._proactiveShown||!this._rootEl)return;this._proactiveShown=!0;try{sessionStorage.setItem("gengage_proactive_shown","1")}catch{}this._setProactiveCooldown();const a={message:t,onAccept:()=>this.open(),onDismiss:()=>{},...n&&n.length>0&&{actionButtons:n}};this.config.proactiveAcceptLabel!==void 0&&(a.acceptLabel=this.config.proactiveAcceptLabel);const o=Ho(a);this._rootEl.appendChild(o)}async _fetchAndShowProactive(){if(!this._proactiveShown)try{const t={middlewareUrl:this.config.middlewareUrl,accountId:this.config.accountId,backendType:this.config.backendType??"v1"},n=this.config.pageContext?.sku,a=this.config.pageContext?.pageType,o=this.config.locale,i=await No({account_id:this.config.accountId,...n&&{sku:n},...a&&{page_type:a},...o&&{output_language:o}},t);if(!i)return;const r=i.question??i.title??"";if(!r)return;const s=[];if(i.actions&&Array.isArray(i.actions))for(const c of i.actions){const l=c,d=l.title;if(d&&Me(l.requestDetails)){const g=l.requestDetails;s.push({title:d,onSelect:()=>{this.openWithAction(g)}})}}this._showProactivePopup(r,s)}catch{}}_proactiveCooldownKey(){return`gengage_proactive_time_${this.config.accountId}`}_isProactiveCooldownActive(){try{const t=localStorage.getItem(this._proactiveCooldownKey());if(t){const n=Date.now()-parseInt(t,10),a=this.config.proactiveCooldownMs??36e5;return n<a}}catch{}return!1}_setProactiveCooldown(){try{localStorage.setItem(this._proactiveCooldownKey(),String(Date.now()))}catch{}}_hideDrawer(){if(!this._drawerVisible)return;this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawerVisible=!1,this._openState="full",this._drawer?.clearPanel();const t=this._drawer?.getElement();t&&t.classList.add("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._extendedModeManager?.setChatShown(!1)}_syncViewportState(){if(this._rootEl){if(this._isMobileViewport=window.innerWidth<=this._mobileBreakpoint,this._rootEl.classList.toggle("gengage-chat-root--mobile",this._isMobileViewport),this._launcher){const t=this._isMobileViewport&&this.config.hideMobileLauncher===!0;this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile",t)}this._applyOpenStateClasses()}}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",n=this._drawerVisible&&this._isMobileViewport&&this._openState==="full";this._rootEl.classList.toggle("gengage-chat-root--open",this._drawerVisible),this._rootEl.classList.toggle("gengage-chat-root--mobile-half",t),this._rootEl.classList.toggle("gengage-chat-root--mobile-full",n)}_handleAttachment(t){const n=Ba(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;ee("gengage:global:error",{message:a,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,n){cr(),this._messages.some(i=>i.role==="user")||lr();const o={title:t,type:"user_message",payload:t};n!==void 0?this._sendAction(o,{attachment:n}):this._sendAction(o)}_sendAction(t,n){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:n});return}if(this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const b=this._currentThreadId,_=this._messages.filter(E=>E.threadId!==void 0&&E.threadId>b);this._messages=this._messages.filter(E=>!E.threadId||E.threadId<=b);for(const E of _)this._shadow?.querySelector(`[data-message-id="${CSS.escape(E.id)}"]`)?.remove(),this._panel.snapshots.delete(E.id),this._panel.snapshotTypes.delete(E.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(E=>{E instanceof HTMLElement&&E.dataset.threadId&&E.dataset.threadId>b&&E.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=Sa();this._currentThreadId=a,this._lastThreadId=a;const o=n?.preservePanel===!0;if(o||(this._activeRequestThreadId=a),!n?.silent){const b=this._createMessage("user",typeof t.payload=="string"?t.payload:t.title);b.threadId=a,n?.attachment!==void 0&&(b.attachment=n.attachment),this._drawer?.addMessage(b),this._messages.push(b)}n?.preservePanel||(this._drawer?.hasPanelContent()?this._drawer.showPanelLoading():this._drawer?.clearPanel()),this._drawer?.showTypingIndicator();let i="";const r=this._createMessage("assistant","");r.threadId=a,r.status="streaming",this._messages.push(r),n?.preservePanel||(this._abortControllers.forEach(b=>b.abort()),this._abortControllers.clear());const s={middlewareUrl:this.config.middlewareUrl,...this.config.backendType?{backendType:this.config.backendType}:{},...this.config.accountId?{accountId:this.config.accountId}:{}};n?.attachment!==void 0&&(s.attachment=n.attachment);const l=this._getVisibleMessages().filter(b=>b.content).slice(-50).map(b=>({role:b.role==="user"?"user":"model",content:b.content??""})),d={outputLanguage:Gi(this.config.locale),parentUrl:window.location.href,windowWidth:String(window.innerWidth),windowHeight:String(window.innerHeight),selfUrl:"",id:this.config.session?.sessionId??"",userId:this.config.session?.userId??"",appId:this.config.accountId,threads:[],createdAt:this._chatCreatedAt,kvkkApproved:Gt(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:a,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this.config.session?.viewId!==void 0&&(d.viewId=this.config.session.viewId);const g=So(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),u={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:g.type,locale:this.config.locale??"tr",meta:d,context:{...this._lastBackendContext??{},messages:l,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(u.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(u.view_id=this.config.session.viewId),g.payload!==void 0&&(u.payload=g.payload),this.config.pageContext?.sku!==void 0&&(u.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(u.page_type=this.config.pageContext.pageType);const p=crypto.randomUUID(),f=Date.now();let v=0,y=!1,I=!1;this.track(ea(this.analyticsContext(),{endpoint:"process_action",request_id:p,widget:"chat"}));let z=null;z=Ao(u,{onTextChunk:(b,_,w)=>{if(!o&&a!==this._activeRequestThreadId||(i+=b,this._drawer?.removeTypingIndicator(),w?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...w.skuToProductItem}),w?.conversationMode&&(this._conversationMode=w.conversationMode),this.track(ta(this.analyticsContext(),{request_id:p,chunk_index:v++,widget:"chat"})),!this._drawer))return;let E=i;if(_&&et(E)){const h=this.config.accountId;if(!Gt(h)){const k=Hi(E);k&&this._drawer?.showKvkkBanner(k,()=>{this._drawer?.hideKvkkBanner()}),Fi(h)}E=qi(E)}const P=this._shadow?.querySelector(`[data-message-id="${r.id}"] .gengage-chat-bubble-text`);if(P?P.innerHTML=we(E):(r.content=E,r.role==="assistant"&&r.threadId&&!this._threadsWithFirstBot.has(r.threadId)&&(this._threadsWithFirstBot.add(r.threadId),this._drawer.markFirstBotMessage(r.id)),this._drawer.addMessage(r)),_){r.content=E,r.status="done",Kt();const h=this._shadow?.querySelector(`[data-message-id="${r.id}"] .gengage-chat-bubble-text`);if(h){this._activeTypewriter?.cancel();const k=w?.productMentions;this._activeTypewriter=Ii({container:h,html:we(E),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,k&&k.length>0&&h&&zi({container:h,mentions:k,onProductClick:C=>{this._sendAction({title:k.find(A=>A.sku===C)?.short_name??C,type:"launchSingleProduct",payload:{sku:C}})}})}})}}},onUISpec:(b,_,w)=>{if(!o&&a!==this._activeRequestThreadId||_!=="chat")return;const E=b.elements[b.root],P=E?.type??"unknown";this.track(na(this.analyticsContext(),{request_id:p,chunk_index:v,component_type:P,widget:"chat"}));const h=this._buildRenderContext();if(P==="ComparisonTable"){const A=E?.props?.products;nr(Array.isArray(A)?A.length:0)}if(P==="ProductGrid"){const A=E?.children?.length??0;ir(void 0,A)}const k=w==="panel"&&this._panel?this._panel.toPanelSpec(b):b,C=!r.silent&&(w!=="panel"||P==="ProductCard")&&P!=="ActionButtons";if(w==="panel"&&this._panel){I=!0,E?.props?.similarsAppend===!0&&this._panel.currentType==="ProductDetailsPanel"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._appendSimilarsToPanel(k,h):P==="ProductGrid"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._drawer.appendPanelContent(this._renderUISpec(k,h)):(this._drawer?.setPanelContent(this._renderUISpec(k,h)),this._panel.currentType=P),r.threadId&&!this._panel.threads.includes(r.threadId)&&this._panel.threads.push(r.threadId);const A=this._panel.currentType??P;this._panel.updateTopBar(A),this._panel.updateExtendedMode(P)}if(P==="ProductDetailsPanel"&&!r.silent&&w==="panel"){const A=E?.props?.product;if(A){const $={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:A}}}},N=this._shadow?.querySelector(".gengage-chat-messages");if(N){const T=this._renderUISpec($,h);r.threadId&&(T.dataset.threadId=r.threadId),N.appendChild(T),T.scrollIntoView({behavior:"auto",block:"end"})}}}if(C){const A=this._shadow?.querySelector(".gengage-chat-messages");if(A){const $=this._renderUISpec(b,h);r.threadId&&($.dataset.threadId=r.threadId),A.appendChild($),$.scrollIntoView({behavior:"auto",block:"end"})}}if((P==="ProductGrid"||P==="ProductCard")&&r.threadId){const A=E?.children??[],$=P==="ProductGrid"?A.map(N=>b.elements[N]?.props?.product).filter(Boolean):[E?.props?.product].filter(Boolean);for(const N of $){const T=N.sku,j=N.imageUrl;T&&j&&this._thumbnailEntries.push({sku:T,imageUrl:j,threadId:r.threadId})}this._drawer?.setThumbnails(this._thumbnailEntries)}if(P==="ProductGrid"||P==="ProductDetailsPanel"){const $=(P==="ProductGrid"?(E?.children??[]).map(N=>b.elements[N]?.props?.product).filter(Boolean):[E?.props?.product??E?.props].filter(Boolean)).map(N=>N.imageUrl).filter(N=>typeof N=="string").slice(0,5);$.length>0&&this._bridge?.send("previewImages",{images:$})}if(P==="ProductGrid"&&w==="panel"&&!this._comparisonSelectMode&&!Mi()&&(this._choicePrompterEl?.remove(),this._choicePrompterEl=Li({heading:this._i18n.choicePrompterHeading,suggestion:this._i18n.choicePrompterSuggestion,ctaLabel:this._i18n.choicePrompterCta,onCtaClick:()=>{this._comparisonSelectMode=!0,this._choicePrompterEl=null,this._refreshComparisonUI()},onDismiss:()=>{this._choicePrompterEl=null}}),this._shadow?.querySelector(".gengage-chat-panel")?.appendChild(this._choicePrompterEl)),P==="ActionButtons"){const A=E?.props?.buttons;if(A&&A.length>0){const $=[],N=[];for(const T of A)if(Pi(T)){const j={label:T.label,action:T.action};T.icon&&(j.icon=T.icon),$.push(j)}else N.push(T);$.length>0&&this._drawer?.setInputAreaChips($.map(T=>({label:T.label,onAction:()=>this._sendAction(T.action),...T.icon?{icon:T.icon}:{}}))),N.length>0&&this._drawer?.setPills(N.map(T=>{const j={label:T.label,onAction:()=>this._sendAction(T.action)};return T.icon&&(j.icon=T.icon),T.image&&(j.image=T.image),T.description&&(j.description=T.description),j}))}}r.uiSpec=b},onAction:b=>{if(!(!o&&a!==this._activeRequestThreadId)&&b.type==="action"){const _={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(_.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(_.allowScriptCall=this.config.actionHandling.allowScriptCall),Aa(b,{openChat:()=>this.open(),navigate:w=>{this._bridge?.send("navigate",w),w.newTab?window.open(w.url,"_blank","noopener,noreferrer"):window.location.href=w.url},saveSession:w=>this.saveSession(w.sessionId,w.sku),addToCart:w=>{ee("gengage:similar:add-to-cart",w)},scriptCall:w=>{ee("gengage:chat:script-call",w),this.config.onScriptCall?.(w)}},_)}},onMetadata:b=>{if(!(!o&&a!==this._activeRequestThreadId)&&b.type==="metadata"&&b.meta){if((b.meta.panel!==void 0||b.meta.messages!==void 0||b.meta.message_id!==void 0)&&(this._lastBackendContext=b.meta),b.meta.panelLoading){y=!0,I=!1;const w=typeof b.meta.panelPendingType=="string"?b.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(w),w&&this._panel?.updateTopBarForLoading(w)}if(b.meta.voice){const w=new CustomEvent("gengage:chat:voice",{detail:{payload:b.meta.voice},bubbles:!1,cancelable:!0}),E=window.dispatchEvent(w);if(dr(),E){const P=b.meta.voice;P.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=Wo(P.audio_base64,P.content_type??"audio/ogg"))}}(b.meta.redirectTarget||b.meta.redirect)&&ee("gengage:chat:redirect",{target:b.meta.redirectTarget??null,payload:b.meta.redirect??null}),b.meta.analyzeAnimation&&(y=!0,I=!1,this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),b.meta.loading&&typeof b.meta.loadingText=="string"&&(this._drawer?.addThinkingStep(b.meta.loadingText),this._bridge?.send("loadingMessage",{text:b.meta.loadingText})),b.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",b.meta.visitorDataResponse),b.meta.formType&&this._bridge?.send("glovOtokoc",{type:b.meta.formType,data:b.meta.formPayload}),b.meta.launcherContent&&this._bridge?.send("launcherContent",b.meta.launcherContent),ee("gengage:chat:metadata",{payload:b.meta});const _=b.meta;typeof _.prompt_tokens=="number"&&typeof _.completion_tokens=="number"&&this.track(ia(this.analyticsContext(),{model:b.model??"unknown",prompt_tokens:_.prompt_tokens,completion_tokens:_.completion_tokens,total_tokens:_.total_tokens??_.prompt_tokens+_.completion_tokens}))}},onError:b=>{z&&this._abortControllers.delete(z),!(!o&&a!==this._activeRequestThreadId)&&(this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),y&&!I&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),y=!1,I=!1,ee("gengage:global:error",{source:"chat",code:"STREAM_ERROR",message:this._i18n.errorMessage}),this.emit("error",b),this._drawer?.showError(b.message),r.status==="streaming"&&(r.status="error"),this.track(oa(this.analyticsContext(),{request_id:p,error_code:"STREAM_ERROR",error_message:b.message,widget:"chat"})))},onDone:()=>{z&&this._abortControllers.delete(z),!(!o&&a!==this._activeRequestThreadId)&&(this._activeRequestThreadId=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),y&&!I&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),y=!1,I=!1,r.status==="streaming"&&(r.status="done",Kt()),this.emit("message",r),this._panel?.snapshotForMessage(r.id),this._panel?.attachClickHandler(r.id),this.track(aa(this.analyticsContext(),{request_id:p,latency_ms:Date.now()-f,chunk_count:v,widget:"chat"})),this.track(ra(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(ca(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{}))}},s),this._abortControllers.add(z)}_getVisibleMessages(){const t=this._messages.filter(a=>!a.silent);if(!this._currentThreadId)return t;const n=this._currentThreadId;return t.filter(a=>!a.threadId||a.threadId<=n)}_appendSimilarsToPanel(t,n){if(!this._drawer)return;const a=this._drawer.getPanelContentElement();if(!a)return;const o=document.createElement("h3");o.className="gengage-chat-product-details-similars-heading",o.textContent=this._i18n.similarProductsLabel??"Benzer Ürünler",a.appendChild(o);const i=this._renderUISpec(t,n);i.classList.add("gengage-chat-product-details-similars"),a.appendChild(i)}_handleRollback(t){const n=this._messages.find(a=>a.id===t);n?.threadId&&this._rollbackToThread(n.threadId)}_rollbackToThread(t){this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1);for(const i of this._messages){const r=this._shadow?.querySelector(`[data-message-id="${CSS.escape(i.id)}"]`);r&&(i.threadId&&i.threadId>t?r.classList.add("gengage-chat-bubble--hidden"):r.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(i=>{i instanceof HTMLElement&&i.dataset.threadId&&i.dataset.threadId>t?i.classList.add("gengage-chat-bubble--hidden"):i instanceof HTMLElement&&i.classList.remove("gengage-chat-bubble--hidden")});const n=this._messages.find(i=>i.role==="assistant"&&i.threadId===t);n&&this._panel?.restoreForMessage(n.id)||this._drawer?.clearPanel();const o=this._panel.currentType??"";this._panel?.updateTopBar(o),this._drawer?.setPills([]),this._session?.db&&this.config.session?.sessionId&&this._session?.db.loadContext(this.config.session.sessionId,t).then(i=>{i&&(this._lastBackendContext=i.context)}).catch(()=>{}),this._session?.db&&this.config.session?.sessionId&&this._session?.db.deleteContextsAfterThread(this.config.session.sessionId,t).catch(()=>{})}async _persistToIndexedDB(){!this._session||!this.config.session?.sessionId||await this._session.persist({userId:this.config.session.userId??"",appId:this.config.accountId,sessionId:this.config.session.sessionId,messages:this._messages,currentThreadId:this._currentThreadId,lastThreadId:this._lastThreadId,chatCreatedAt:this._chatCreatedAt,panelSnapshots:this._panel?.snapshots??new Map,panelThreads:this._panel?.threads??[],thumbnailEntries:this._thumbnailEntries,lastBackendContext:this._lastBackendContext})}_isSameOriginUrl(t){try{return new URL(t,window.location.href).origin===window.location.origin}catch{return!1}}async _saveSessionAndOpenURL(t){this._session&&await this._session.saveAndOpenURL(t,()=>this._persistToIndexedDB(),this._bridge)}async _loadPayload(t,n){return this._session?this._session.loadPayload(t,n):null}async _restoreFromIndexedDB(){if(!this._session?.db)return;const t=this.config.session?.sessionId;if(!t)return;const n=this.config.session?.userId??"",a=this.config.accountId;await this._session.loadFavorites(n,a);const o=await this._session.db?.loadSession(n,a,t);if(!o||o.messages.length===0)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=o.currentThreadId,this._lastThreadId=o.lastThreadId,this._chatCreatedAt=o.createdAt,o.panelThreads&&(this._panel.threads=o.panelThreads),o.thumbnailEntries&&(this._thumbnailEntries=o.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),o.panelSnapshotHtml)for(const[r,s]of Object.entries(o.panelSnapshotHtml)){const c=document.createElement("div");c.innerHTML=we(s),this._panel.snapshots.set(r,c)}let i=0;for(const r of o.messages){const s={id:r.id,role:r.role,timestamp:r.timestamp,status:r.status};if(r.threadId!==void 0&&(s.threadId=r.threadId),r.content!==void 0&&(s.content=r.content),r.silent&&(s.silent=!0),this._messages.push(s),s.silent)continue;s.role==="assistant"&&s.threadId&&!this._threadsWithFirstBot.has(s.threadId)&&(this._threadsWithFirstBot.add(s.threadId),this._drawer?.markFirstBotMessage(s.id)),this._drawer?.addMessage(s);const c=parseInt(r.id.replace("msg-",""),10);if(!isNaN(c)&&c>i&&(i=c),s.role==="assistant"&&s.threadId){const l=await this._loadPayload(s.threadId,s.id);l&&(s.uiSpec=l,this._restoreInlineUISpec(s),this._panel?.attachClickHandler(s.id),delete s.uiSpec)}}if(i>this._currentMessageId&&(this._currentMessageId=i),this._currentThreadId){let r=await this._session.db?.loadContext(t,this._currentThreadId);r||(r=await this._session.db?.loadLatestContext(t)),r&&(this._lastBackendContext=r.context)}if(this._currentThreadId){const r=[...this._messages].reverse().find(s=>s.role==="assistant"&&s.threadId===this._currentThreadId&&!s.silent);r&&this._panel.snapshots.has(r.id)&&this._panel?.restoreForMessage(r.id)}if(this._currentThreadId){const r=this._currentThreadId;for(const s of this._messages)s.threadId&&s.threadId>r&&this._shadow?.querySelector(`[data-message-id="${CSS.escape(s.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");this._shadow?.querySelectorAll("[data-thread-id]").forEach(s=>{s instanceof HTMLElement&&s.dataset.threadId&&s.dataset.threadId>r&&s.classList.add("gengage-chat-bubble--hidden")})}if(this._panel.threads.length>0&&this._currentThreadId){const r=this._panel.threads[this._panel.threads.length-1];if(r){const s=[...this._messages].reverse().find(c=>c.role==="assistant"&&c.threadId===r);if(s?.threadId){const c=await this._loadPayload(s.threadId,s.id);if(c){const l=c.elements[c.root];l&&this._panel?.updateTopBar(l.type)}}}}setTimeout(()=>{this._drawer?.scrollToLastThread()},550)}_toggleComparisonSku(t){t===""?(this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectMode||(this._comparisonSelectedSkus=[],tr())):this._comparisonSelectedSkus.indexOf(t)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],er(t)),this._refreshComparisonUI()}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t)return;const n=t.querySelector(".gengage-chat-product-grid-wrapper");if(!n)return;const a=n.querySelector(".gengage-chat-product-grid");if(!a)return;const o=n.querySelector(".gengage-chat-comparison-toggle-btn");if(o&&o.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const r=a.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const s of r){if(s.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const g=s.parentElement.querySelector(".gengage-chat-comparison-checkbox");g&&(g.checked=this._comparisonSelectedSkus.includes(s.dataset.sku));continue}const c=s.dataset.sku,l=document.createElement("div");l.className="gengage-chat-comparison-select-wrapper";const d=document.createElement("input");d.type="checkbox",d.className="gengage-chat-comparison-checkbox",d.checked=this._comparisonSelectedSkus.includes(c),d.addEventListener("change",()=>{this._toggleComparisonSku(c)}),s.parentNode.insertBefore(l,s),l.appendChild(d),l.appendChild(s)}}else{const r=a.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const s of r){const c=s.querySelector(".gengage-chat-product-card");c&&s.parentNode&&(s.parentNode.insertBefore(c,s),s.remove())}}const i=n.querySelector(".gengage-chat-comparison-floating-btn");if(this._comparisonSelectMode&&this._comparisonSelectedSkus.length>=2){const r=this._i18n.compareSelected??"Karşılaştır",s=`${r} (${this._comparisonSelectedSkus.length})`;if(i)i.textContent=s;else{const c=document.createElement("button");c.className="gengage-chat-comparison-floating-btn",c.type="button",c.textContent=s,c.addEventListener("click",()=>{Wt(this._comparisonSelectedSkus),this._sendAction({title:r,type:"getComparisonTable",payload:{sku_list:[...this._comparisonSelectedSkus]}})}),n.appendChild(c)}}else i?.remove()}_buildRenderContext(){const t={onAction:n=>{if(Xi(n.title,n.type),n.type==="findSimilar"){const o=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";Qi(o)}n.type==="getComparisonTable"&&Wt(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{rr(n.sku),ee("gengage:similar:product-click",{sku:n.sku,url:n.url,sessionId:this.config.session?.sessionId??null}),this.config.isDemoWebsite===!0||!this._isSameOriginUrl(n.url)?this._sendAction({title:n.sku,type:"launchSingleProduct",payload:{sku:n.sku}}):this._saveSessionAndOpenURL(n.url)},onAddToCart:n=>{sr(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};ee("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",n),this._runEventCallbacks("gengage-cart-add",a),this._sendAction({title:"Sepete Ekle",type:"addToCart",payload:{sku:n.sku,cart_code:n.cartCode,quantity:n.quantity}},{preservePanel:!0})},onProductSelect:n=>{const a={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:n}}}};this._drawer?.setPanelContent(this._renderUISpec(a,t))},i18n:this._i18n,pricing:this.config.pricing,productSort:this._productSort,onSortChange:n=>{this._productSort=n},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,onToggleComparisonSku:n=>{this._toggleComparisonSku(n)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(n,a)=>{ar(n),this._toggleFavorite(n,a);const o=a.name??n;this._sendAction({title:o,type:"like",payload:{sku:n}},{preservePanel:!0})}};return t}async _toggleFavorite(t,n){if(!this._session)return;const a=this.config.session?.userId??"",o=this.config.accountId;await this._session.toggleFavorite(a,o,t,n)}async _runEventCallbacks(t,n){const a=this._eventCallbacks.get(t);if(!(!a||a.size===0))for(const o of a)try{const i=o(n);if((i instanceof Promise?await i:i)===!1){this._handleCallbackFailure(t,n);return}}catch{this._handleCallbackFailure(t,n);return}}_handleCallbackFailure(t,n){if(t==="gengage-cart-add"){const o=this._createMessage("assistant","Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.");this._currentThreadId&&(o.threadId=this._currentThreadId),this._messages.push(o),this._drawer?.addMessage(o)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const n=t.uiSpec,a=n.elements[n.root];if(!a)return;const o=a.type;if(o==="ActionButtons"||o==="ComparisonTable"||o==="ProductGrid"&&a.props?.similarsAppend===!0)return;const i=this._buildRenderContext(),r=this._shadow?.querySelector(".gengage-chat-messages");if(!r)return;if(o==="ProductDetailsPanel"){const c=a.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},d=this._renderUISpec(l,i);t.threadId&&(d.dataset.threadId=t.threadId),r.appendChild(d);return}const s=this._renderUISpec(n,i);t.threadId&&(s.dataset.threadId=t.threadId),r.appendChild(s)}_createMessage(t,n){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:n,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...Mo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Zt();return Qn(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??Qe,i=(c,l)=>Ut(c,l,a,o),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:o,defaultRender:i}):i(t,n)}}function dg(){return new Jn}fe.GengageChat=Jn,fe.chatCatalog=cg,fe.createChatWidget=dg,fe.createDefaultChatUISpecRegistry=Zt,fe.defaultChatUnknownUISpecRenderer=Qe,fe.renderUISpec=Ut,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
96
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const s=r[1];if(t===r[0]){o(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){o(r);continue}}if(e.metadataRegistry.get(r[0])?.id){o(r);continue}if(s.cycle){o(r);continue}if(s.count>1&&e.reused==="ref"){o(r);continue}}}function Un(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=r=>{const s=e.seen.get(r);if(s.ref===null)return;const c=s.def??s.schema,l={...c},d=s.ref;if(s.ref=null,d){a(d);const g=e.seen.get(d),p=g.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):Object.assign(c,p),Object.assign(c,l),r._zod.parent===d)for(const _ in c)_==="$ref"||_==="allOf"||_ in l||delete c[_];if(p.$ref&&g.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in g.def&&JSON.stringify(c[_])===JSON.stringify(g.def[_])&&delete c[_]}const u=r._zod.parent;if(u&&u!==d){a(u);const g=e.seen.get(u);if(g?.schema.$ref&&(c.$ref=g.schema.$ref,g.def))for(const p in c)p==="$ref"||p==="allOf"||p in g.def&&JSON.stringify(c[p])===JSON.stringify(g.def[p])&&delete c[p]}e.override({zodSchema:r,jsonSchema:c,path:s.path??[]})};for(const r of[...e.seen.entries()].reverse())a(r[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?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,n.def??n.schema);const o=e.external?.defs??{};for(const r of e.seen.entries()){const s=r[1];s.def&&s.defId&&(o[s.defId]=s.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const r=JSON.parse(JSON.stringify(i));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:qe(t,"input",e.processors),output:qe(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function W(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return W(a.element,n);if(a.type==="set")return W(a.valueType,n);if(a.type==="lazy")return W(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return W(a.innerType,n);if(a.type==="intersection")return W(a.left,n)||W(a.right,n);if(a.type==="record"||a.type==="map")return W(a.keyType,n)||W(a.valueType,n);if(a.type==="pipe")return W(a.in,n)||W(a.out,n);if(a.type==="object"){for(const i in a.shape)if(W(a.shape[i],n))return!0;return!1}if(a.type==="union"){for(const i of a.options)if(W(i,n))return!0;return!1}if(a.type==="tuple"){for(const i of a.items)if(W(i,n))return!0;return!!(a.rest&&W(a.rest,n))}return!1}const bl=(e,t={})=>n=>{const a=Dn({...n,processors:t});return H(e,a),Rn(a,e),Un(a,e)},qe=(e,t,n={})=>a=>{const{libraryOptions:i,target:o}=a??{},r=Dn({...i??{},target:o,io:t,processors:n});return H(e,r),Rn(r,e),Un(r,e)},_l={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vl=(e,t,n,a)=>{const i=n;i.type="string";const{minimum:o,maximum:r,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof r=="number"&&(i.maxLength=r),s&&(i.format=_l[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(u=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},yl=(e,t,n,a)=>{const i=n,{minimum:o,maximum:r,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof o=="number"&&(i.minimum=o,typeof d=="number"&&t.target!=="draft-04"&&(d>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof r=="number"&&(i.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},wl=(e,t,n,a)=>{n.type="boolean"},xl=(e,t,n,a)=>{n.not={}},kl=(e,t,n,a)=>{},Cl=(e,t,n,a)=>{const i=e._zod.def,o=tn(i.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},El=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Sl=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Tl=(e,t,n,a)=>{const i=n,o=e._zod.def,{minimum:r,maximum:s}=e._zod.bag;typeof r=="number"&&(i.minItems=r),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=H(o.element,t,{...a,path:[...a.path,"items"]})},Il=(e,t,n,a)=>{const i=n,o=e._zod.def;i.type="object",i.properties={};const r=o.shape;for(const l in r)i.properties[l]=H(r[l],t,{...a,path:[...a.path,"properties",l]});const s=new Set(Object.keys(r)),c=new Set([...s].filter(l=>{const d=o.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=H(o.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},zl=(e,t,n,a)=>{const i=e._zod.def,o=i.inclusive===!1,r=i.options.map((s,c)=>H(s,t,{...a,path:[...a.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},Pl=(e,t,n,a)=>{const i=e._zod.def,o=H(i.left,t,{...a,path:[...a.path,"allOf",0]}),r=H(i.right,t,{...a,path:[...a.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(o)?o.allOf:[o],...s(r)?r.allOf:[r]];n.allOf=c},Al=(e,t,n,a)=>{const i=n,o=e._zod.def;i.type="object";const r=o.keyType,c=r._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){const d=H(o.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});i.patternProperties={};for(const u of c)i.patternProperties[u.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=H(o.keyType,t,{...a,path:[...a.path,"propertyNames"]})),i.additionalProperties=H(o.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const l=r._zod.values;if(l){const d=[...l].filter(u=>typeof u=="string"||typeof u=="number");d.length>0&&(i.required=d)}},Nl=(e,t,n,a)=>{const i=e._zod.def,o=H(i.innerType,t,a),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Ll=(e,t,n,a)=>{const i=e._zod.def;H(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},Ml=(e,t,n,a)=>{const i=e._zod.def;H(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},$l=(e,t,n,a)=>{const i=e._zod.def;H(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ol=(e,t,n,a)=>{const i=e._zod.def;H(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType;let r;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Bl=(e,t,n,a)=>{const i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;H(o,t,a);const r=t.seen.get(e);r.ref=o},Dl=(e,t,n,a)=>{const i=e._zod.def;H(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Zn=(e,t,n,a)=>{const i=e._zod.def;H(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},Rl=m("ZodISODateTime",(e,t)=>{js.init(e,t),j.init(e,t)});function Ul(e){return Gc(Rl,e)}const Zl=m("ZodISODate",(e,t)=>{Fs.init(e,t),j.init(e,t)});function jl(e){return Wc(Zl,e)}const Fl=m("ZodISOTime",(e,t)=>{qs.init(e,t),j.init(e,t)});function ql(e){return Kc(Fl,e)}const Hl=m("ZodISODuration",(e,t)=>{Hs.init(e,t),j.init(e,t)});function Vl(e){return Jc(Hl,e)}const X=m("ZodError",(e,t)=>{cn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>$r(e,n)},flatten:{value:n=>Mr(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,tt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,tt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Gl=rt(X),Wl=st(X),Kl=De(X),Jl=Re(X),Yl=Dr(X),Xl=Rr(X),Ql=Ur(X),ed=Zr(X),td=jr(X),nd=Fr(X),ad=qr(X),id=Hr(X),q=m("ZodType",(e,t)=>(F.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:qe(e,"input"),output:qe(e,"output")}}),e.toJSONSchema=bl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ue(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>he(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Gl(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>Kl(e,n,a),e.parseAsync=async(n,a)=>Wl(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>Jl(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Yl(e,n,a),e.decode=(n,a)=>Xl(e,n,a),e.encodeAsync=async(n,a)=>Ql(e,n,a),e.decodeAsync=async(n,a)=>ed(e,n,a),e.safeEncode=(n,a)=>td(e,n,a),e.safeDecode=(n,a)=>nd(e,n,a),e.safeEncodeAsync=async(n,a)=>ad(e,n,a),e.safeDecodeAsync=async(n,a)=>id(e,n,a),e.refine=(n,a)=>e.check(Jd(n,a)),e.superRefine=n=>e.check(Yd(n)),e.overwrite=n=>e.check(Ie(n)),e.optional=()=>Gn(e),e.exactOptional=()=>Bd(e),e.nullable=()=>Wn(e),e.nullish=()=>Gn(Wn(e)),e.nonoptional=n=>Fd(e,n),e.array=()=>Z(e),e.or=n=>Ve([e,n]),e.and=n=>Nd(e,n),e.transform=n=>Jn(e,$d(n)),e.default=n=>Ud(e,n),e.prefault=n=>jd(e,n),e.catch=n=>Hd(e,n),e.pipe=n=>Jn(e,n),e.readonly=()=>Wd(e),e.describe=n=>{const a=e.clone();return Ne.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Ne.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Ne.get(e);const a=e.clone();return Ne.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),jn=m("_ZodString",(e,t)=>{ct.init(e,t),q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>vl(e,a,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(nl(...a)),e.includes=(...a)=>e.check(ol(...a)),e.startsWith=(...a)=>e.check(rl(...a)),e.endsWith=(...a)=>e.check(sl(...a)),e.min=(...a)=>e.check(Fe(...a)),e.max=(...a)=>e.check(On(...a)),e.length=(...a)=>e.check(Bn(...a)),e.nonempty=(...a)=>e.check(Fe(1,...a)),e.lowercase=a=>e.check(al(a)),e.uppercase=a=>e.check(il(a)),e.trim=()=>e.check(ll()),e.normalize=(...a)=>e.check(cl(...a)),e.toLowerCase=()=>e.check(dl()),e.toUpperCase=()=>e.check(gl()),e.slugify=()=>e.check(pl())}),od=m("ZodString",(e,t)=>{ct.init(e,t),jn.init(e,t),e.email=n=>e.check(Sc(rd,n)),e.url=n=>e.check(Ac(sd,n)),e.jwt=n=>e.check(Vc(xd,n)),e.emoji=n=>e.check(Nc(cd,n)),e.guid=n=>e.check(Nn(Fn,n)),e.uuid=n=>e.check(Tc(He,n)),e.uuidv4=n=>e.check(Ic(He,n)),e.uuidv6=n=>e.check(zc(He,n)),e.uuidv7=n=>e.check(Pc(He,n)),e.nanoid=n=>e.check(Lc(ld,n)),e.guid=n=>e.check(Nn(Fn,n)),e.cuid=n=>e.check(Mc(dd,n)),e.cuid2=n=>e.check($c(gd,n)),e.ulid=n=>e.check(Oc(pd,n)),e.base64=n=>e.check(Fc(vd,n)),e.base64url=n=>e.check(qc(yd,n)),e.xid=n=>e.check(Bc(ud,n)),e.ksuid=n=>e.check(Dc(hd,n)),e.ipv4=n=>e.check(Rc(fd,n)),e.ipv6=n=>e.check(Uc(md,n)),e.cidrv4=n=>e.check(Zc(bd,n)),e.cidrv6=n=>e.check(jc(_d,n)),e.e164=n=>e.check(Hc(wd,n)),e.datetime=n=>e.check(Ul(n)),e.date=n=>e.check(jl(n)),e.time=n=>e.check(ql(n)),e.duration=n=>e.check(Vl(n))});function k(e){return Ec(od,e)}const j=m("ZodStringFormat",(e,t)=>{U.init(e,t),jn.init(e,t)}),rd=m("ZodEmail",(e,t)=>{Ls.init(e,t),j.init(e,t)}),Fn=m("ZodGUID",(e,t)=>{As.init(e,t),j.init(e,t)}),He=m("ZodUUID",(e,t)=>{Ns.init(e,t),j.init(e,t)}),sd=m("ZodURL",(e,t)=>{Ms.init(e,t),j.init(e,t)}),cd=m("ZodEmoji",(e,t)=>{$s.init(e,t),j.init(e,t)}),ld=m("ZodNanoID",(e,t)=>{Os.init(e,t),j.init(e,t)}),dd=m("ZodCUID",(e,t)=>{Bs.init(e,t),j.init(e,t)}),gd=m("ZodCUID2",(e,t)=>{Ds.init(e,t),j.init(e,t)}),pd=m("ZodULID",(e,t)=>{Rs.init(e,t),j.init(e,t)}),ud=m("ZodXID",(e,t)=>{Us.init(e,t),j.init(e,t)}),hd=m("ZodKSUID",(e,t)=>{Zs.init(e,t),j.init(e,t)}),fd=m("ZodIPv4",(e,t)=>{Vs.init(e,t),j.init(e,t)}),md=m("ZodIPv6",(e,t)=>{Gs.init(e,t),j.init(e,t)}),bd=m("ZodCIDRv4",(e,t)=>{Ws.init(e,t),j.init(e,t)}),_d=m("ZodCIDRv6",(e,t)=>{Ks.init(e,t),j.init(e,t)}),vd=m("ZodBase64",(e,t)=>{Js.init(e,t),j.init(e,t)}),yd=m("ZodBase64URL",(e,t)=>{Xs.init(e,t),j.init(e,t)}),wd=m("ZodE164",(e,t)=>{Qs.init(e,t),j.init(e,t)}),xd=m("ZodJWT",(e,t)=>{tc.init(e,t),j.init(e,t)}),qn=m("ZodNumber",(e,t)=>{vn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>yl(e,a,i),e.gt=(a,i)=>e.check(Mn(a,i)),e.gte=(a,i)=>e.check(gt(a,i)),e.min=(a,i)=>e.check(gt(a,i)),e.lt=(a,i)=>e.check(Ln(a,i)),e.lte=(a,i)=>e.check(dt(a,i)),e.max=(a,i)=>e.check(dt(a,i)),e.int=a=>e.check(Hn(a)),e.safe=a=>e.check(Hn(a)),e.positive=a=>e.check(Mn(0,a)),e.nonnegative=a=>e.check(gt(0,a)),e.negative=a=>e.check(Ln(0,a)),e.nonpositive=a=>e.check(dt(0,a)),e.multipleOf=(a,i)=>e.check($n(a,i)),e.step=(a,i)=>e.check($n(a,i)),e.finite=()=>e;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 me(e){return Yc(qn,e)}const kd=m("ZodNumberFormat",(e,t)=>{nc.init(e,t),qn.init(e,t)});function Hn(e){return Xc(kd,e)}const Cd=m("ZodBoolean",(e,t)=>{ac.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wl(e,n,a)});function pt(e){return Qc(Cd,e)}const Ed=m("ZodUnknown",(e,t)=>{ic.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>kl()});function ne(){return el(Ed)}const Sd=m("ZodNever",(e,t)=>{oc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xl(e,n,a)});function Td(e){return tl(Sd,e)}const Id=m("ZodArray",(e,t)=>{rc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Tl(e,n,a,i),e.element=t.element,e.min=(n,a)=>e.check(Fe(n,a)),e.nonempty=n=>e.check(Fe(1,n)),e.max=(n,a)=>e.check(On(n,a)),e.length=(n,a)=>e.check(Bn(n,a)),e.unwrap=()=>e.element});function Z(e,t){return ul(Id,e,t)}const zd=m("ZodObject",(e,t)=>{cc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Il(e,n,a,i),D(e,"shape",()=>t.shape),e.keyof=()=>ht(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ne()}),e.loose=()=>e.clone({...e._zod.def,catchall:ne()}),e.strict=()=>e.clone({...e._zod.def,catchall:Td()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>zr(e,n),e.safeExtend=n=>Pr(e,n),e.merge=n=>Ar(e,n),e.pick=n=>Tr(e,n),e.omit=n=>Ir(e,n),e.partial=(...n)=>Nr(Vn,e,n[0]),e.required=(...n)=>Lr(Kn,e,n[0])});function $(e,t){const n={type:"object",shape:e??{},...S(t)};return new zd(n)}const Pd=m("ZodUnion",(e,t)=>{lc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>zl(e,n,a,i),e.options=t.options});function Ve(e,t){return new Pd({type:"union",options:e,...S(t)})}const Ad=m("ZodIntersection",(e,t)=>{dc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Pl(e,n,a,i)});function Nd(e,t){return new Ad({type:"intersection",left:e,right:t})}const Ld=m("ZodRecord",(e,t)=>{gc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Al(e,n,a,i),e.keyType=t.keyType,e.valueType=t.valueType});function Le(e,t,n){return new Ld({type:"record",keyType:e,valueType:t,...S(n)})}const ut=m("ZodEnum",(e,t)=>{pc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>Cl(e,a,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,i)=>{const o={};for(const r of a)if(n.has(r))o[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...S(i),entries:o})},e.exclude=(a,i)=>{const o={...t.entries};for(const r of a)if(n.has(r))delete o[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...S(i),entries:o})}});function ht(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new ut({type:"enum",entries:n,...S(t)})}const Md=m("ZodTransform",(e,t)=>{uc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Sl(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Qt(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ae(o,n.value,t));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(Ae(r))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function $d(e){return new Md({type:"transform",transform:e})}const Vn=m("ZodOptional",(e,t)=>{Sn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Zn(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Gn(e){return new Vn({type:"optional",innerType:e})}const Od=m("ZodExactOptional",(e,t)=>{hc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Zn(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Bd(e){return new Od({type:"optional",innerType:e})}const Dd=m("ZodNullable",(e,t)=>{fc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Nl(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Wn(e){return new Dd({type:"nullable",innerType:e})}const Rd=m("ZodDefault",(e,t)=>{mc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ml(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ud(e,t){return new Rd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():rn(t)}})}const Zd=m("ZodPrefault",(e,t)=>{bc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>$l(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function jd(e,t){return new Zd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():rn(t)}})}const Kn=m("ZodNonOptional",(e,t)=>{_c.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ll(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Fd(e,t){return new Kn({type:"nonoptional",innerType:e,...S(t)})}const qd=m("ZodCatch",(e,t)=>{vc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ol(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hd(e,t){return new qd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Vd=m("ZodPipe",(e,t)=>{yc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Bl(e,n,a,i),e.in=t.in,e.out=t.out});function Jn(e,t){return new Vd({type:"pipe",in:e,out:t})}const Gd=m("ZodReadonly",(e,t)=>{wc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Dl(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Wd(e){return new Gd({type:"readonly",innerType:e})}const Kd=m("ZodCustom",(e,t)=>{xc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>El(e,n)});function Jd(e,t={}){return hl(Kd,e,t)}function Yd(e){return fl(e)}const Xd=$({role:ht(["user","assistant"]),content:k(),timestamp:me().optional()}),Qd=$({sku:k(),name:k(),imageUrl:k().url().optional(),price:k().optional(),originalPrice:k().optional(),url:k().url(),ctaLabel:k().optional()}),eg=$({buttons:Z($({label:k(),action:$({title:k(),type:k(),payload:ne().optional()})}))}),tg=$({}),ng=$({label:k().optional()}),Yn=$({sku:k(),name:k(),price:k(),imageUrl:k().optional(),rating:me().optional(),reviewCount:me().optional()}),ag=$({recommended:Yn,products:Z(Yn),attributes:Z($({label:k(),values:Z(k())})),highlights:Z(k()),specialCases:Z(k()).optional(),recommendedText:k().optional(),winnerHits:Le(k(),$({positive:Z(k()).optional(),negative:Z(k()).optional()})).optional(),productActions:Le(k(),$({title:k(),type:k(),payload:ne().optional()})).optional()}),ig=$({label:k(),sentiment:ht(["positive","negative","neutral"]).optional()}),og=$({product:Le(k(),ne()),role:k().optional(),reason:k().optional(),labels:Z(ig).optional(),expertQualityScore:me().optional(),reviewHighlight:k().optional(),action:$({title:k(),type:k(),payload:ne().optional()}).optional()}),rg=$({suggestions:Z(og)}),sg=$({title:k().optional(),text:k().optional(),reviewCount:k().optional(),action:$({title:k(),type:k(),payload:ne().optional()})}),cg=$({entries:Z($({name:k(),image:k().optional(),description:k().optional(),action:$({title:k(),type:k(),payload:ne().optional()})}))}),lg=$({entries:Z($({shortName:k(),detailedMessage:k().optional(),whyDifferent:k().optional(),image:k().optional(),action:$({title:k(),type:k(),payload:ne().optional()})}))}),Xn=$({title:k(),type:k(),payload:ne().optional()}),dg=$({name:k().optional(),variant_name:k().optional(),sku:k().optional(),price:Ve([me(),k()]).optional()}),gg=$({product:$({sku:k().optional(),name:k().optional(),images:Z(k()).optional(),imageUrl:k().optional(),rating:me().optional(),reviewCount:me().optional(),price:k().optional(),originalPrice:k().optional(),price_async:pt().optional(),inStock:pt().optional(),promotions:Z(k()).optional(),variants:Z(dg).optional(),url:k().optional(),cartCode:k().optional(),description:k().optional(),specifications:Ve([Le(k(),k()),Z($({key:k(),value:k()}))]).optional()}).optional(),action:Xn.optional()}),pg=$({endOfList:pt().optional()}),ug=$({review_class:k().optional(),review_text:k().optional(),review_rating:Ve([k(),me()]).optional(),review_tag:k().optional()}),hg=$({reviews:Z(ug).optional()}),fg=$({productName:k().optional(),pros:Z(k()).optional(),cons:Z(k()).optional()}),mg=$({groups:Z($({groupName:k(),products:Z(Le(k(),ne())).optional()})).optional(),filterTags:Z($({title:k(),action:Xn.optional()})).optional()}),bg=$({summary:k().optional(),products_discussed:Z(k()).optional(),user_sentiment:k().optional()}),_g={components:{MessageBubble:{schema:Xd,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:Qd,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:eg,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:tg,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:ng,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:ag,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:rg,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:sg,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:cg,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:lg,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:gg,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:pg,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:hg,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:fg,description:"A pros and cons list for a product."},CategoriesContainer:{schema:mg,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:bg,description:"A notice shown when the conversation is escalated to a human agent."}}};function vg(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function Me(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}class Qn extends Ta{constructor(){super(...arguments),this._shadow=null,this._rootEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._activityTracker=null,this._heartbeat=null,this._proactiveShown=!1,this._drawerVisible=!1,this._messages=[],this._currentMessageId=0,this._abortControllers=new Set,this._currentThreadId=null,this._lastThreadId=null,this._chatCreatedAt="",this._lastBackendContext=null,this._productSort={type:"related"},this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._pdpLaunched=!1,this._pdpPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._i18n=Je,this._extendedModeManager=null,this._activeTypewriter=null,this._activeTtsHandle=null,this._activeRequestThreadId=null,this._skuToProductItem={},this._conversationMode=null,this._initComplete=!1,this._pendingActions=[],this._bridgeContext=null,this._cartQuantity=null,this._threadsWithFirstBot=new Set,this._panel=null,this._session=null,this._eventCallbacks=new Map}async onInit(t){this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),this._shadow=this.root.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=ir,this._shadow.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-root",this._rootEl=a,this._shadow.appendChild(a);const i=t.variant??"floating";if(i==="floating"){const g={onClick:()=>this.open(),ariaLabel:this._i18n.openButton};t.launcherSvg!==void 0&&(g.svgMarkup=t.launcherSvg),t.hideMobileLauncher!==void 0&&(g.hideMobile=t.hideMobileLauncher),t.mobileBreakpoint!==void 0&&(g.mobileBreakpoint=t.mobileBreakpoint),t.launcherTooltip!==void 0&&(g.tooltip=t.launcherTooltip),this._launcher=Ji(g),a.appendChild(this._launcher.container)}i==="overlay"&&a.classList.add("gengage-chat--overlay");const o=document.createElement("div");a.appendChild(o),this._drawer=new Wi(o,{i18n:this._i18n,onSend:(g,p)=>this._sendMessage(g,p),onClose:()=>this.close(),onAttachment:g=>this._handleAttachment(g),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onRollback:g=>this._handleRollback(g),onPanelBack:()=>this._panel?.navigateBack(),onPanelForward:()=>this._panel?.navigateForward(),headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,headerFavoritesToggle:t.headerFavoritesToggle,onFavoritesClick:()=>{hr(),t.onFavoritesClick?.()},onThumbnailClick:g=>this._rollbackToThread(g),onLinkClick:g=>{this._saveSessionAndOpenURL(g)},voiceEnabled:t.voiceEnabled,voiceLang:t.locale?`${t.locale.split("-")[0]??"tr"}-${(t.locale.split("-")[1]??t.locale.split("-")[0]??"TR").toUpperCase()}`:void 0}),this._extendedModeManager=new Ko({onChange:g=>this._panel?.notifyExtension(g),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new Jo({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:g=>this._rollbackToThread(g)}),i!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden");const r=this._drawer.restorePanelState(t.accountId),s=t.panelMode??"auto";s==="collapsed"?this._drawer.setPanelCollapsed(!0):s==="expanded"?this._drawer.setForceExpanded():r||this._drawer.expandPanel();const c=sessionStorage.getItem("gengage_restore_session_id"),l=sessionStorage.getItem("gengage_restore_sku"),d=!!(c&&l);d&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const g=new Go;await g.open(),this._session=new Wt(g),await this._restoreFromIndexedDB(d)}catch{this._session=new Wt(null)}this._registerPublicAPI(),t.mobileInitialState!==void 0&&(this._openState=t.mobileInitialState),this._mobileBreakpoint=t.mobileBreakpoint??768,this._syncViewportState();const u=()=>this._syncViewportState();if(window.addEventListener("resize",u,{passive:!0}),this.addCleanup(()=>window.removeEventListener("resize",u)),window.visualViewport){const g=()=>{if(!this._drawerVisible||!this._isMobileViewport)return;const p=this._drawer?.getElement();if(!p)return;const h=window.innerHeight-(window.visualViewport?.height??window.innerHeight);p.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,h)}px`)};window.visualViewport.addEventListener("resize",g),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",g))}i==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses()),this._bridge=new Pa({namespace:"chat",onMessage:g=>this._handleBridgeMessage(g)}),this._activityTracker=new Xi({idleThresholdMs:t.proactiveDelayMs??3e4,onActivity:g=>{if(g.type==="idle"&&!this._proactiveShown&&!this._drawerVisible){const p=t.proactiveMinScrollDepth??0;if(p>0&&(this._activityTracker?.maxScrollDepth??0)<p*100)return;try{if(sessionStorage.getItem("gengage_proactive_shown"))return}catch{}if(this._isProactiveCooldownActive())return;t.proactiveFetchActions?this._fetchAndShowProactive():t.proactiveMessage&&this._showProactivePopup(t.proactiveMessage)}}}),this.addCleanup(()=>this._activityTracker?.destroy()),t.enableHeartbeat&&(this._heartbeat=new to({middlewareUrl:t.middlewareUrl,accountId:t.accountId,sessionId:t.session?.sessionId??"",locale:t.locale??"tr",intervalMs:t.heartbeatIntervalMs??3e4,getPageType:()=>this.config.pageContext?.pageType??"other",getCurrentSku:()=>this.config.pageContext?.sku??"",onMessage:g=>{if(!this._proactiveShown&&!this._drawerVisible&&g.message){const p=[];if(g.suggested_actions&&Array.isArray(g.suggested_actions))for(const h of g.suggested_actions)h.title&&Me(h.requestDetails)&&p.push({title:h.title,onSelect:()=>{this.openWithAction(h.requestDetails)}});this._showProactivePopup(g.message,p.length>0?p:void 0)}}}),this._heartbeat.start(),this.addCleanup(()=>this._heartbeat?.destroy())),this._lastSku=this.config.pageContext?.sku,this._initComplete=!0;for(const g of this._pendingActions)this._sendAction(g.action,g.options);this._pendingActions=[],ae("gengage:chat:ready",{}),rr("chat"),t.onReady?.()}onUpdate(t){t.sku!==void 0&&t.sku!==this._lastSku&&(this._lastSku=t.sku,this._resetForNewPage())}onShow(){this._showDrawer(),this.emit("open"),ae("gengage:chat:open",{state:this._openState}),sr("chat"),this.config.onOpen?.(),!this._pdpLaunched&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._pdpPrimingInFlight=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku}},{silent:!0,isPdpPrime:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),ae("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._bridge?.destroy(),this._bridge=null,this._extendedModeManager=null,this._panel?.destroy(),this._panel=null,this._session?.close(),this._session=null,window.gengage&&delete window.gengage.chat,this._shadow&&(this._shadow.innerHTML="",this._shadow=null),this._rootEl=null}open(t){t?.state!==void 0&&(this._openState=t.state,this._drawerVisible&&this._applyOpenStateClasses()),this.show(),t?.initialMessage!==void 0&&this._sendMessage(t.initialMessage)}openWithAction(t,n){n?.sku!==void 0&&this.update({sku:n.sku}),this._pdpLaunched=!0,n?.state!==void 0?this._openState=n.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,n){this._sendAction(t,n)}close(){this.hide()}saveSession(t,n){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",n)}get isOpen(){return this._drawerVisible}addCallback(t,n){let a=this._eventCallbacks.get(t);return a||(a=new Set,this._eventCallbacks.set(t,a)),a.add(n),()=>{a.delete(n),a.size===0&&this._eventCallbacks.delete(t)}}_resetForNewPage(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._messages.length=0,this._drawer?.clearMessages(),this._drawer?.clearPanel(),this._panel.snapshots.clear(),this._panel.threads=[],this._thumbnailEntries=[],this._drawer?.setThumbnails([]),this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._currentThreadId=null,this._lastThreadId=null,this._lastBackendContext=null,this._chatCreatedAt=new Date().toISOString(),this._pdpLaunched=!1,this._pdpPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const n=t.payload,a=n?.action,i=Me(a)?a:Me(n)?n:null;i&&this._sendAction(i,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const n=t.payload;if(n&&typeof n=="object"){this._bridgeContext=n;const a=n.sku;if(a&&this.update({sku:a}),Me(n.action)){this._pdpLaunched=!0,this.open(),this._sendAction(n.action);break}}this.open();break}case"launcherAction":{const a=t.payload?.action;a&&typeof a=="object"&&"type"in a&&this._sendAction(a);break}case"scrollToBottom":this._drawer?.scrollToBottomIfNeeded();break;case"addToCardHandler":{this._bridge?.send("addToCardResult",t.payload);break}case"cartQuantityHandler":{const n=t.payload;n&&"quantity"in n&&typeof n.quantity=="number"&&(this._cartQuantity=n.quantity);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&vg(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,n)=>this.openWithAction(t,n),sendMessage:t=>this.sendMessage(t),sendAction:(t,n)=>this.sendAction(t,n),close:()=>this.close(),saveSession:(t,n)=>this.saveSession(t,n),get isOpen(){return!1},on:(t,n)=>this.on(t,n),trackCheckout:(t,n)=>this.trackCheckout(t,n),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,n)=>this.addCallback(t,n)},Object.defineProperty(window.gengage.chat,"isOpen",{get:()=>this._drawerVisible})}_showDrawer(){if(this._drawerVisible)return;this._drawerVisible=!0;const t=this._drawer?.getElement();t&&t.classList.remove("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._isMobileViewport&&this._openState==="half"||this._drawer?.focusInput(),this._extendedModeManager?.setChatShown(!0)}_showProactivePopup(t,n){if(this._proactiveShown||!this._rootEl)return;this._proactiveShown=!0;try{sessionStorage.setItem("gengage_proactive_shown","1")}catch{}this._setProactiveCooldown();const a={message:t,onAccept:()=>this.open(),onDismiss:()=>{},...n&&n.length>0&&{actionButtons:n}};this.config.proactiveAcceptLabel!==void 0&&(a.acceptLabel=this.config.proactiveAcceptLabel);const i=Yi(a);this._rootEl.appendChild(i)}async _fetchAndShowProactive(){if(!this._proactiveShown)try{const t={middlewareUrl:this.config.middlewareUrl,accountId:this.config.accountId,backendType:this.config.backendType??"v1"},n=this.config.pageContext?.sku,a=this.config.pageContext?.pageType,i=this.config.locale,o=await Bi({account_id:this.config.accountId,...n&&{sku:n},...a&&{page_type:a},...i&&{output_language:i}},t);if(!o)return;const r=o.question??o.title??"";if(!r)return;const s=[];if(o.actions&&Array.isArray(o.actions))for(const c of o.actions){const l=c,d=l.title;if(d&&Me(l.requestDetails)){const u=l.requestDetails;s.push({title:d,onSelect:()=>{this.openWithAction(u)}})}}this._showProactivePopup(r,s)}catch{}}_proactiveCooldownKey(){return`gengage_proactive_time_${this.config.accountId}`}_isProactiveCooldownActive(){try{const t=localStorage.getItem(this._proactiveCooldownKey());if(t){const n=Date.now()-parseInt(t,10),a=this.config.proactiveCooldownMs??36e5;return n<a}}catch{}return!1}_setProactiveCooldown(){try{localStorage.setItem(this._proactiveCooldownKey(),String(Date.now()))}catch{}}_hideDrawer(){if(!this._drawerVisible)return;this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawerVisible=!1,this._openState="full";const t=this._drawer?.getElement();t&&t.classList.add("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._extendedModeManager?.setChatShown(!1)}_syncViewportState(){if(this._rootEl){if(this._isMobileViewport=window.innerWidth<=this._mobileBreakpoint,this._rootEl.classList.toggle("gengage-chat-root--mobile",this._isMobileViewport),this._launcher){const t=this._isMobileViewport&&this.config.hideMobileLauncher===!0;this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile",t)}this._applyOpenStateClasses()}}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",n=this._drawerVisible&&this._isMobileViewport&&this._openState==="full";this._rootEl.classList.toggle("gengage-chat-root--open",this._drawerVisible),this._rootEl.classList.toggle("gengage-chat-root--mobile-half",t),this._rootEl.classList.toggle("gengage-chat-root--mobile-full",n)}_handleAttachment(t){const n=Za(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;ae("gengage:global:error",{message:a,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,n){if(this._pdpPrimingInFlight){this._queuedUserMessages.push(n!==void 0?{text:t,attachment:n}:{text:t});return}_r(),this._messages.some(o=>o.role==="user")||vr();const i={title:t,type:"user_message",payload:t};n!==void 0?this._sendAction(i,{attachment:n}):this._sendAction(i)}_flushQueuedUserMessages(){if(this._pdpPrimingInFlight||this._queuedUserMessages.length===0)return;const t=[...this._queuedUserMessages];this._queuedUserMessages=[];for(const n of t)this._sendMessage(n.text,n.attachment)}_sendAction(t,n){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:n});return}if(this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const f=this._currentThreadId,P=this._messages.filter(b=>b.threadId!==void 0&&b.threadId>f);this._messages=this._messages.filter(b=>!b.threadId||b.threadId<=f);for(const b of P)this._shadow?.querySelector(`[data-message-id="${CSS.escape(b.id)}"]`)?.remove(),this._panel.snapshots.delete(b.id),this._panel.snapshotTypes.delete(b.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(b=>{b instanceof HTMLElement&&b.dataset.threadId&&b.dataset.threadId>f&&b.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=za();this._currentThreadId=a,this._lastThreadId=a,this._panel&&t.type!=="launchSingleProduct"&&(this._panel.lastActionType=t.type);const i=n?.preservePanel===!0,o=t.type==="launchSingleProduct"&&n?.silent===!0&&n?.isPdpPrime===!0;if(i||(this._activeRequestThreadId=a),!n?.silent){const f=this._createMessage("user",typeof t.payload=="string"?t.payload:t.title);f.threadId=a,n?.attachment!==void 0&&(f.attachment=n.attachment),this._drawer?.addMessage(f),this._messages.push(f)}if(!n?.silent&&this._hasUnavailableProductContext()&&(t.type==="user_message"||t.type==="inputText")){const f=this._i18n.productNotFoundMessage,P=this._createMessage("assistant",f);P.threadId=a,P.status="done",this._messages.push(P),this._ensureAssistantMessageRendered(P),this._drawer?.updateBotMessage(P.id,f),this._bridge?.send("isResponding",!1),this.emit("message",P),this._persistToIndexedDB().catch(()=>{});return}n?.preservePanel||(this._drawer?.hasPanelContent()?this._drawer.showPanelLoading():this._drawer?.clearPanel()),this._drawer?.showTypingIndicator();let s="";const c=this._createMessage("assistant","");c.threadId=a,c.status="streaming",n?.silent&&(c.silent=!0),this._messages.push(c),n?.preservePanel||(this._abortControllers.forEach(f=>f.abort()),this._abortControllers.clear());const l={middlewareUrl:this.config.middlewareUrl,...this.config.backendType?{backendType:this.config.backendType}:{},...this.config.accountId?{accountId:this.config.accountId}:{}};n?.attachment!==void 0&&(l.attachment=n.attachment);const u=this._getVisibleMessages().filter(f=>f.content).slice(-50).map(f=>({role:f.role==="user"?"user":"model",content:f.content??""})),g={outputLanguage:ar(this.config.locale),parentUrl:window.location.href,windowWidth:String(window.innerWidth),windowHeight:String(window.innerHeight),selfUrl:"",id:this.config.session?.sessionId??"",userId:this.config.session?.userId??"",appId:this.config.accountId,threads:[],createdAt:this._chatCreatedAt,kvkkApproved:Jt(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:a,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this.config.session?.viewId!==void 0&&(g.viewId=this.config.session.viewId);const p=Ni(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),h={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:p.type,locale:this.config.locale??"tr",meta:g,context:{...this._lastBackendContext??{},messages:u,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(h.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(h.view_id=this.config.session.viewId),p.payload!==void 0&&(h.payload=p.payload),this.config.pageContext?.sku!==void 0&&(h.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(h.page_type=this.config.pageContext.pageType);const _=crypto.randomUUID(),v=Date.now();let E=0,I=!1,T=!1;this.track(aa(this.analyticsContext(),{endpoint:"process_action",request_id:_,widget:"chat"}));let y=null;y=Oi(h,{onTextChunk:(f,P,A)=>{if(!i&&a!==this._activeRequestThreadId||(s+=f,this._drawer?.removeTypingIndicator(),A?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...A.skuToProductItem}),A?.conversationMode&&(this._conversationMode=A.conversationMode),this.track(ia(this.analyticsContext(),{request_id:_,chunk_index:E++,widget:"chat"})),!this._drawer))return;let b=s;if(P&&et(b)){const C=this.config.accountId;if(!Jt(C)){const w=tr(b);w&&this._drawer?.showKvkkBanner(w,()=>{this._drawer?.hideKvkkBanner()}),Qo(C)}b=er(b)}const x=this._shadow?.querySelector(`[data-message-id="${c.id}"] .gengage-chat-bubble-text`);if(x?x.innerHTML=oe(b):(c.content=b,c.role==="assistant"&&c.threadId&&!this._threadsWithFirstBot.has(c.threadId)&&(this._threadsWithFirstBot.add(c.threadId),this._drawer.markFirstBotMessage(c.id)),this._drawer.addMessage(c)),P){c.content=b,c.status="done",Xt();const C=this._shadow?.querySelector(`[data-message-id="${c.id}"] .gengage-chat-bubble-text`);if(C){this._activeTypewriter?.cancel();const w=A?.productMentions;this._activeTypewriter=Do({container:C,html:oe(b),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,w&&w.length>0&&C&&Ro({container:C,mentions:w,onProductClick:M=>{this._sendAction({title:w.find(z=>z.sku===M)?.short_name??M,type:"launchSingleProduct",payload:{sku:M}})}})}})}}},onUISpec:(f,P,A)=>{if(!i&&a!==this._activeRequestThreadId||P!=="chat")return;const b=f.elements[f.root],x=b?.type??"unknown";this.track(oa(this.analyticsContext(),{request_id:_,chunk_index:E,component_type:x,widget:"chat"}));const C=this._buildRenderContext();if(x==="ComparisonTable"){const z=b?.props?.products;pr(Array.isArray(z)?z.length:0)}if(x==="ProductGrid"){const z=b?.children?.length??0;fr(void 0,z)}const w=A==="panel"&&this._panel?this._panel.toPanelSpec(f):f,M=!c.silent&&(A!=="panel"||x==="ProductCard")&&x!=="ActionButtons";if(A==="panel"&&this._panel){T=!0,b?.props?.similarsAppend===!0&&this._panel.currentType==="ProductDetailsPanel"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._appendSimilarsToPanel(w,C):x==="ProductGrid"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._drawer.appendPanelContent(this._renderUISpec(w,C)):(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._drawer?.setPanelContent(this._renderUISpec(w,C)),this._panel.currentType=x),x==="ProductDetailsPanel"&&t.type==="launchSingleProduct"&&this._clearUnavailableProductContext(),c.threadId&&!this._panel.threads.includes(c.threadId)&&this._panel.threads.push(c.threadId);const z=this._panel.currentType??x,N=b?.props?.panelTitle;this._panel.updateTopBar(z,N),this._panel.updateExtendedMode(x)}if(x==="ProductDetailsPanel"&&!c.silent&&A==="panel"){const z=b?.props?.product;if(z){const N={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:z}}}},O=this._shadow?.querySelector(".gengage-chat-messages");if(O){const L=this._renderUISpec(N,C);c.threadId&&(L.dataset.threadId=c.threadId),O.appendChild(L),L.scrollIntoView({behavior:"auto",block:"end"})}}}if(M){const z=this._shadow?.querySelector(".gengage-chat-messages");if(z){const N=this._renderUISpec(f,C);c.threadId&&(N.dataset.threadId=c.threadId),z.appendChild(N),N.scrollIntoView({behavior:"auto",block:"end"})}}if((x==="ProductGrid"||x==="ProductCard")&&c.threadId){const z=b?.children??[],N=x==="ProductGrid"?z.map(O=>f.elements[O]?.props?.product).filter(Boolean):[b?.props?.product].filter(Boolean);for(const O of N){const L=O.sku,B=O.imageUrl;L&&B&&this._thumbnailEntries.push({sku:L,imageUrl:B,threadId:c.threadId})}this._drawer?.setThumbnails(this._thumbnailEntries)}if(x==="ProductGrid"||x==="ProductDetailsPanel"){const N=(x==="ProductGrid"?(b?.children??[]).map(O=>f.elements[O]?.props?.product).filter(Boolean):[b?.props?.product??b?.props].filter(Boolean)).map(O=>O.imageUrl).filter(O=>typeof O=="string").slice(0,5);N.length>0&&this._bridge?.send("previewImages",{images:N})}if(x==="ProductGrid"&&A==="panel"&&!this._comparisonSelectMode&&!qo()){this._choicePrompterEl?.remove(),this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach(L=>L.remove()),this._choicePrompterEl=Fo({heading:this._i18n.choicePrompterHeading,suggestion:this._i18n.choicePrompterSuggestion,ctaLabel:this._i18n.choicePrompterCta,onCtaClick:()=>{this._comparisonSelectMode=!0,this._choicePrompterEl=null,this._refreshComparisonUI()},onDismiss:()=>{this._choicePrompterEl=null}});const N=this._isMobileViewport||this._drawer?.isPanelCollapsed()?".gengage-chat-conversation":".gengage-chat-panel",O=this._shadow?.querySelector(N);O?O.appendChild(this._choicePrompterEl):this._choicePrompterEl=null}if(x==="ActionButtons"){const z=b?.props?.buttons;if(z&&z.length>0){const N=[],O=[];for(const L of z)if(jo(L)){const B={label:L.label,action:L.action};L.icon&&(B.icon=L.icon),N.push(B)}else O.push(L);N.length>0&&this._drawer?.setInputAreaChips(N.map(L=>({label:L.label,onAction:()=>this._sendAction(L.action),...L.icon?{icon:L.icon}:{}}))),O.length>0&&this._drawer?.setPills(O.map(L=>{const B={label:L.label,onAction:()=>this._sendAction(L.action)};return L.icon&&(B.icon=L.icon),L.image&&(B.image=L.image),L.description&&(B.description=L.description),B}))}}c.uiSpec=f},onAction:f=>{if(!(!i&&a!==this._activeRequestThreadId)&&f.type==="action"){const P={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(P.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(P.allowScriptCall=this.config.actionHandling.allowScriptCall),La(f,{openChat:()=>this.open(),navigate:A=>{this._bridge?.send("navigate",A),A.newTab?window.open(A.url,"_blank","noopener,noreferrer"):window.location.href=A.url},saveSession:A=>this.saveSession(A.sessionId,A.sku),addToCart:A=>{ae("gengage:similar:add-to-cart",A)},scriptCall:A=>{ae("gengage:chat:script-call",A),this.config.onScriptCall?.(A)}},P)}},onMetadata:f=>{if(!(!i&&a!==this._activeRequestThreadId)&&f.type==="metadata"&&f.meta){if((f.meta.panel!==void 0||f.meta.messages!==void 0||f.meta.message_id!==void 0)&&(this._lastBackendContext=f.meta),f.meta.panelLoading){I=!0,T=!1;const A=typeof f.meta.panelPendingType=="string"?f.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(A),A&&this._panel?.updateTopBarForLoading(A)}if(f.meta.voice){const A=new CustomEvent("gengage:chat:voice",{detail:{payload:f.meta.voice},bubbles:!1,cancelable:!0}),b=window.dispatchEvent(A);if(yr(),b){const x=f.meta.voice;x.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=eo(x.audio_base64,x.content_type??"audio/ogg"))}}(f.meta.redirectTarget||f.meta.redirect)&&ae("gengage:chat:redirect",{target:f.meta.redirectTarget??null,payload:f.meta.redirect??null}),f.meta.analyzeAnimation&&(I=!0,T=!1,this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),f.meta.loading&&typeof f.meta.loadingText=="string"&&(this._drawer?.addThinkingStep(f.meta.loadingText),this._bridge?.send("loadingMessage",{text:f.meta.loadingText})),f.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",f.meta.visitorDataResponse),f.meta.formType&&this._bridge?.send("glovOtokoc",{type:f.meta.formType,data:f.meta.formPayload}),f.meta.launcherContent&&this._bridge?.send("launcherContent",f.meta.launcherContent),ae("gengage:chat:metadata",{payload:f.meta});const P=f.meta;typeof P.prompt_tokens=="number"&&typeof P.completion_tokens=="number"&&this.track(ca(this.analyticsContext(),{model:f.model??"unknown",prompt_tokens:P.prompt_tokens,completion_tokens:P.completion_tokens,total_tokens:P.total_tokens??P.prompt_tokens+P.completion_tokens}))}},onError:f=>{if(y&&this._abortControllers.delete(y),!i&&a!==this._activeRequestThreadId)return;this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator();const P=T;if(I&&!T&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),I=!1,T=!1,!(c.silent||c.content!=null&&c.content.length>0||s.length>0||P))if(o||this._hasUnavailableProductContext()){const b=this._i18n.productNotFoundMessage;c.content=b,c.status="done",this._ensureAssistantMessageRendered(c),this._drawer?.updateBotMessage(c.id,b),this._markUnavailableProductContext()}else this.emit("error",f),this._drawer?.showError(this._i18n.errorMessage);o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),c.status==="streaming"&&(c.status="error"),this.track(sa(this.analyticsContext(),{request_id:_,error_code:"STREAM_ERROR",error_message:f.message,widget:"chat"}))},onDone:()=>{if(y&&this._abortControllers.delete(y),!(!i&&a!==this._activeRequestThreadId)){if(this._activeRequestThreadId=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),I&&!T&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),I=!1,T=!1,o&&!s&&!T){const f=this._i18n.productNotFoundMessage;c.content=f,this._ensureAssistantMessageRendered(c),this._drawer?.updateBotMessage(c.id,f),this._markUnavailableProductContext()}o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),c.status==="streaming"&&(c.status="done",Xt()),this.emit("message",c),this._panel?.snapshotForMessage(c.id),this._panel?.attachClickHandler(c.id),this.track(ra(this.analyticsContext(),{request_id:_,latency_ms:Date.now()-v,chunk_count:E,widget:"chat"})),this.track(la(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(ga(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{})}}},l),this._abortControllers.add(y)}_getVisibleMessages(){const t=this._messages.filter(a=>!a.silent);if(!this._currentThreadId)return t;const n=this._currentThreadId;return t.filter(a=>!a.threadId||a.threadId<=n)}_appendSimilarsToPanel(t,n){if(!this._drawer)return;const a=this._drawer.getPanelContentElement();if(!a)return;const i=document.createElement("h3");i.className="gengage-chat-product-details-similars-heading",i.textContent=this._i18n.similarProductsLabel??"Benzer Ürünler",a.appendChild(i);const o=this._renderUISpec(t,n);o.classList.add("gengage-chat-product-details-similars"),a.appendChild(o)}_handleRollback(t){const n=this._messages.find(a=>a.id===t);n?.threadId&&this._rollbackToThread(n.threadId)}_rollbackToThread(t){this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1);for(const o of this._messages){const r=this._shadow?.querySelector(`[data-message-id="${CSS.escape(o.id)}"]`);r&&(o.threadId&&o.threadId>t?r.classList.add("gengage-chat-bubble--hidden"):r.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(o=>{o instanceof HTMLElement&&o.dataset.threadId&&o.dataset.threadId>t?o.classList.add("gengage-chat-bubble--hidden"):o instanceof HTMLElement&&o.classList.remove("gengage-chat-bubble--hidden")});const n=this._messages.find(o=>o.role==="assistant"&&o.threadId===t);n&&this._panel?.restoreForMessage(n.id)||this._drawer?.clearPanel();const i=this._panel.currentType??"";this._panel?.updateTopBar(i),this._drawer?.setPills([]),this._session?.db&&this.config.session?.sessionId&&this._session?.db.loadContext(this.config.session.sessionId,t).then(o=>{o&&(this._lastBackendContext=o.context)}).catch(()=>{}),this._session?.db&&this.config.session?.sessionId&&this._session?.db.deleteContextsAfterThread(this.config.session.sessionId,t).catch(()=>{})}async _persistToIndexedDB(){!this._session||!this.config.session?.sessionId||await this._session.persist({userId:this.config.session.userId??"",appId:this.config.accountId,sessionId:this.config.session.sessionId,messages:this._messages,currentThreadId:this._currentThreadId,lastThreadId:this._lastThreadId,chatCreatedAt:this._chatCreatedAt,panelSnapshots:this._panel?.snapshots??new Map,panelThreads:this._panel?.threads??[],thumbnailEntries:this._thumbnailEntries,lastBackendContext:this._lastBackendContext,sku:this.config.pageContext?.sku})}_isSameOriginUrl(t){try{return t.trim()?new URL(t,window.location.href).origin===window.location.origin:!1}catch{return!1}}_markUnavailableProductContext(){this._productContextUnavailableSku=this.config.pageContext?.sku??null}_clearUnavailableProductContext(){this._productContextUnavailableSku=null}_hasUnavailableProductContext(){const t=this.config.pageContext?.sku;return t!==void 0&&t.length>0&&this._productContextUnavailableSku===t}_ensureAssistantMessageRendered(t){if(!(this._shadow?.querySelector(`[data-message-id="${CSS.escape(t.id)}"]`)||!this._drawer)){if(t.role==="assistant"&&t.threadId&&!this._threadsWithFirstBot.has(t.threadId)){this._threadsWithFirstBot.add(t.threadId),this._drawer.addMessage(t),this._drawer.markFirstBotMessage(t.id);return}this._drawer.addMessage(t)}}async _saveSessionAndOpenURL(t){this._session&&await this._session.saveAndOpenURL(t,()=>this._persistToIndexedDB(),this._bridge)}async _loadPayload(t,n){return this._session?this._session.loadPayload(t,n):null}async _restoreFromIndexedDB(t){if(!this._session?.db)return;const n=this.config.session?.sessionId;if(!n)return;const a=this.config.session?.userId??"",i=this.config.accountId;if(await this._session.loadFavorites(a,i),!t)return;const o=await this._session.db?.loadSession(a,i,n);if(!o||o.messages.length===0)return;const r=this.config.pageContext?.sku;if(r&&o.sku&&o.sku!==r)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=o.currentThreadId,this._lastThreadId=o.lastThreadId,this._chatCreatedAt=o.createdAt,o.panelThreads&&(this._panel.threads=o.panelThreads),o.thumbnailEntries&&(this._thumbnailEntries=o.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),o.panelSnapshotHtml)for(const[c,l]of Object.entries(o.panelSnapshotHtml)){const d=document.createElement("div");d.innerHTML=oe(l),this._panel.snapshots.set(c,d)}let s=0;for(const c of o.messages){const l={id:c.id,role:c.role,timestamp:c.timestamp,status:c.status};if(c.threadId!==void 0&&(l.threadId=c.threadId),c.content!==void 0&&(l.content=c.content),c.silent&&(l.silent=!0),this._messages.push(l),l.silent)continue;l.role==="assistant"&&l.threadId&&!this._threadsWithFirstBot.has(l.threadId)&&(this._threadsWithFirstBot.add(l.threadId),this._drawer?.markFirstBotMessage(l.id)),this._drawer?.addMessage(l);const d=parseInt(c.id.replace("msg-",""),10);if(!isNaN(d)&&d>s&&(s=d),l.role==="assistant"&&l.threadId){const u=await this._loadPayload(l.threadId,l.id);u&&(l.uiSpec=u,this._restoreInlineUISpec(l),this._panel?.attachClickHandler(l.id),delete l.uiSpec)}}if(s>this._currentMessageId&&(this._currentMessageId=s),this._currentThreadId){let c=await this._session.db?.loadContext(n,this._currentThreadId);c||(c=await this._session.db?.loadLatestContext(n)),c&&(this._lastBackendContext=c.context)}if(this._currentThreadId){const c=[...this._messages].reverse().find(l=>l.role==="assistant"&&l.threadId===this._currentThreadId&&!l.silent);c&&this._panel.snapshots.has(c.id)&&this._panel?.restoreForMessage(c.id)}if(this._currentThreadId){const c=this._currentThreadId;for(const l of this._messages)l.threadId&&l.threadId>c&&this._shadow?.querySelector(`[data-message-id="${CSS.escape(l.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");this._shadow?.querySelectorAll("[data-thread-id]").forEach(l=>{l instanceof HTMLElement&&l.dataset.threadId&&l.dataset.threadId>c&&l.classList.add("gengage-chat-bubble--hidden")})}if(this._panel.threads.length>0&&this._currentThreadId){const c=this._panel.threads[this._panel.threads.length-1];if(c){const l=[...this._messages].reverse().find(d=>d.role==="assistant"&&d.threadId===c);if(l?.threadId){const d=await this._loadPayload(l.threadId,l.id);if(d){const u=d.elements[d.root];u&&this._panel?.updateTopBar(u.type)}}}}setTimeout(()=>{this._drawer?.scrollToLastThread()},550)}_toggleComparisonSku(t){t===""?(this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectMode||(this._comparisonSelectedSkus=[],gr())):this._comparisonSelectedSkus.indexOf(t)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],dr(t)),this._refreshComparisonUI()}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t)return;const n=t.querySelector(".gengage-chat-product-grid-wrapper");if(!n)return;const a=n.querySelector(".gengage-chat-product-grid");if(!a)return;const i=n.querySelector(".gengage-chat-comparison-toggle-btn");if(i&&i.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const r=a.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const s of r){if(s.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const u=s.parentElement.querySelector(".gengage-chat-comparison-checkbox");u&&(u.checked=this._comparisonSelectedSkus.includes(s.dataset.sku));continue}const c=s.dataset.sku,l=document.createElement("div");l.className="gengage-chat-comparison-select-wrapper";const d=document.createElement("input");d.type="checkbox",d.className="gengage-chat-comparison-checkbox",d.checked=this._comparisonSelectedSkus.includes(c),d.addEventListener("change",()=>{this._toggleComparisonSku(c)}),s.parentNode.insertBefore(l,s),l.appendChild(d),l.appendChild(s)}}else{const r=a.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const s of r){const c=s.querySelector(".gengage-chat-product-card");c&&s.parentNode&&(s.parentNode.insertBefore(c,s),s.remove())}}const o=n.querySelector(".gengage-chat-comparison-floating-btn");if(this._comparisonSelectMode&&this._comparisonSelectedSkus.length>=2){const r=this._i18n.compareSelected??"Karşılaştır",s=`${r} (${this._comparisonSelectedSkus.length})`;if(o)o.textContent=s;else{const c=document.createElement("button");c.className="gengage-chat-comparison-floating-btn",c.type="button",c.textContent=s,c.addEventListener("click",()=>{Yt(this._comparisonSelectedSkus),this._sendAction({title:r,type:"getComparisonTable",payload:{sku_list:[...this._comparisonSelectedSkus]}})}),n.appendChild(c)}}else o?.remove()}_buildRenderContext(){const t={onAction:n=>{if(cr(n.title,n.type),n.type==="findSimilar"){const i=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";lr(i)}n.type==="getComparisonTable"&&Yt(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{mr(n.sku),this.config.isDemoWebsite!==!0&&this._isSameOriginUrl(n.url)?(ae("gengage:similar:product-click",{sku:n.sku,url:n.url,sessionId:this.config.session?.sessionId??null}),this._saveSessionAndOpenURL(n.url)):this._sendAction({title:n.sku,type:"launchSingleProduct",payload:{sku:n.sku}})},onAddToCart:n=>{br(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};ae("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",n),this._runEventCallbacks("gengage-cart-add",a),this._sendAction({title:"Sepete Ekle",type:"addToCart",payload:{sku:n.sku,cart_code:n.cartCode,quantity:n.quantity}},{preservePanel:!0})},onProductSelect:n=>{const a={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:n}}}};this._drawer?.setPanelContent(this._renderUISpec(a,t))},i18n:this._i18n,pricing:this.config.pricing,productSort:this._productSort,onSortChange:n=>{this._productSort=n},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,onToggleComparisonSku:n=>{this._toggleComparisonSku(n)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(n,a)=>{ur(n),this._toggleFavorite(n,a);const i=a.name??n;this._sendAction({title:i,type:"like",payload:{sku:n}},{preservePanel:!0})}};return t}async _toggleFavorite(t,n){if(!this._session)return;const a=this.config.session?.userId??"",i=this.config.accountId;await this._session.toggleFavorite(a,i,t,n)}async _runEventCallbacks(t,n){const a=this._eventCallbacks.get(t);if(!(!a||a.size===0))for(const i of a)try{const o=i(n);if((o instanceof Promise?await o:o)===!1){this._handleCallbackFailure(t,n);return}}catch{this._handleCallbackFailure(t,n);return}}_handleCallbackFailure(t,n){if(t==="gengage-cart-add"){const i=this._createMessage("assistant","Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.");this._currentThreadId&&(i.threadId=this._currentThreadId),this._messages.push(i),this._drawer?.addMessage(i)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const n=t.uiSpec,a=n.elements[n.root];if(!a)return;const i=a.type;if(i==="ActionButtons"||i==="ComparisonTable"||i==="ProductGrid"&&a.props?.similarsAppend===!0)return;const o=this._buildRenderContext(),r=this._shadow?.querySelector(".gengage-chat-messages");if(!r)return;if(i==="ProductDetailsPanel"){const c=a.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},d=this._renderUISpec(l,o);t.threadId&&(d.dataset.threadId=t.threadId),r.appendChild(d);return}const s=this._renderUISpec(n,o);t.threadId&&(s.dataset.threadId=t.threadId),r.appendChild(s)}_createMessage(t,n){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:n,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...Ui(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Zt();return na(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),i=this.config.renderer?.unknownRenderer??Qe,o=(c,l)=>jt(c,l,a,i),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:i,defaultRender:o}):o(t,n)}}function yg(){return new Qn}be.GengageChat=Qn,be.chatCatalog=_g,be.createChatWidget=yg,be.createDefaultChatUISpecRegistry=Zt,be.defaultChatUnknownUISpecRenderer=Qe,be.renderUISpec=jt,Object.defineProperty(be,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
97
97
  //# sourceMappingURL=chat.iife.js.map