@gengage/assistant-fe 0.1.6 → 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 (75) hide show
  1. package/README.md +100 -0
  2. package/dist/assistant-fe.css +1 -1
  3. package/dist/chat/components/ChatDrawer.d.ts +8 -4
  4. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  5. package/dist/chat/index.d.ts +5 -0
  6. package/dist/chat/index.d.ts.map +1 -1
  7. package/dist/chat/types.d.ts +1 -1
  8. package/dist/chat.cjs +1 -1
  9. package/dist/chat.iife.js +16 -16
  10. package/dist/chat.iife.js.map +1 -1
  11. package/dist/chat.js +2 -2
  12. package/dist/common/events.d.ts.map +1 -1
  13. package/dist/common/index.d.ts +2 -0
  14. package/dist/common/index.d.ts.map +1 -1
  15. package/dist/common/native-webview.d.ts +61 -0
  16. package/dist/common/native-webview.d.ts.map +1 -0
  17. package/dist/common/overlay.d.ts +5 -0
  18. package/dist/common/overlay.d.ts.map +1 -1
  19. package/dist/common.cjs +1 -1
  20. package/dist/common.cjs.map +1 -1
  21. package/dist/common.js +197 -426
  22. package/dist/common.js.map +1 -1
  23. package/dist/index-1yPxOqAw.cjs +13 -0
  24. package/dist/index-1yPxOqAw.cjs.map +1 -0
  25. package/dist/index-BH-V2lWn.js +510 -0
  26. package/dist/index-BH-V2lWn.js.map +1 -0
  27. package/dist/index-BelS6Vnv.cjs +2 -0
  28. package/dist/index-BelS6Vnv.cjs.map +1 -0
  29. package/dist/index-CERWfDdF.js +4571 -0
  30. package/dist/index-CERWfDdF.js.map +1 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +55 -50
  35. package/dist/index.js.map +1 -1
  36. package/dist/native/index.d.ts +3 -0
  37. package/dist/native/index.d.ts.map +1 -0
  38. package/dist/native.cjs +2 -0
  39. package/dist/native.cjs.map +1 -0
  40. package/dist/native.iife.js +97 -0
  41. package/dist/native.iife.js.map +1 -0
  42. package/dist/native.js +9 -0
  43. package/dist/native.js.map +1 -0
  44. package/dist/qna/components/TextInput.d.ts.map +1 -1
  45. package/dist/qna/components/renderUISpec.d.ts.map +1 -1
  46. package/dist/qna/index.d.ts +1 -0
  47. package/dist/qna/index.d.ts.map +1 -1
  48. package/dist/qna/types.d.ts +1 -1
  49. package/dist/qna/types.d.ts.map +1 -1
  50. package/dist/qna.cjs +1 -1
  51. package/dist/qna.cjs.map +1 -1
  52. package/dist/qna.css +1 -1
  53. package/dist/qna.iife.js +14 -14
  54. package/dist/qna.iife.js.map +1 -1
  55. package/dist/qna.js +92 -80
  56. package/dist/qna.js.map +1 -1
  57. package/dist/{schemas-DhaO7I0-.cjs → schemas-DHzfUzwA.cjs} +22 -22
  58. package/dist/schemas-DHzfUzwA.cjs.map +1 -0
  59. package/dist/{schemas-BlkBmaA5.js → schemas-yF4IOEUi.js} +807 -755
  60. package/dist/schemas-yF4IOEUi.js.map +1 -0
  61. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  62. package/dist/simrel.cjs +1 -1
  63. package/dist/simrel.cjs.map +1 -1
  64. package/dist/simrel.css +1 -1
  65. package/dist/simrel.iife.js +8 -8
  66. package/dist/simrel.iife.js.map +1 -1
  67. package/dist/simrel.js +218 -214
  68. package/dist/simrel.js.map +1 -1
  69. package/package.json +9 -2
  70. package/dist/index-B8EeSm-F.cjs +0 -13
  71. package/dist/index-B8EeSm-F.cjs.map +0 -1
  72. package/dist/index-BSpLCzAK.js +0 -4523
  73. package/dist/index-BSpLCzAK.js.map +0 -1
  74. package/dist/schemas-BlkBmaA5.js.map +0 -1
  75. package/dist/schemas-DhaO7I0-.cjs.map +0 -1
@@ -0,0 +1,97 @@
1
+ (function(ye){"use strict";const $a=({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 Je(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??$a,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 Ye(e,t){if(!t)return e;const n={...e};for(const[a,i]of Object.entries(t))i&&(n[a]=i);return n}function Qe(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 Da(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 Ua(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 Le(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 Xe(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 qa(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 ja(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 Fa(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 Za(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 et(e,t){const n={event_name:"widget.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.widget,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 Ha(e,t){const n={event_name:"basket.add",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,sku:t.sku}};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 Va(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 Wa(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 H(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Me(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Ga(e){if(e.type!=="user_message"&&e.type!=="inputText")return null;if(typeof e.payload=="string"&&e.payload.trim().length>0)return e.payload.trim();if(typeof e.payload=="object"&&e.payload!==null&&typeof e.payload.text=="string"){const t=String(e.payload.text).trim();if(t.length>0)return t}return typeof e.title=="string"&&e.title.trim().length>0?e.title.trim():null}function Ka(e){let t=!1;const n=[];let a=0,i=null,o=0;const r=100,s=5e3;function c(){return window.gengage?.chat??null}function l(){t||(console.warn("[gengage] QNA tried to open chat, but chat widget is not initialized. Ensure GengageChat is initialized before calling wireQNAToChat()."),t=!0)}function d(m,w){const C=Ga(w);if(C&&m.sendMessage){m.open?.(),m.sendMessage(C);return}m.openWithAction?.(w)}function u(){i!==null&&(window.clearInterval(i),i=null)}function g(){const m=c();if(!m)return!1;if(a>0&&(m.open?.(),a=0),n.length>0){const w=n.splice(0,n.length);for(const C of w)d(m,C)}return u(),!0}function p(){i===null&&(o=Date.now(),i=window.setInterval(()=>{g()||Date.now()-o>=s&&(n.length=0,a=0,u())},r))}const h=Me("gengage:qna:action",m=>{const w=c();if(w){d(w,m);return}l(),n.length>=20&&n.shift(),n.push(m),p()}),f=Me("gengage:qna:open-chat",()=>{const m=c();if(m){m.open?.();return}l(),a+=1,p()});return()=>{h(),f(),n.length=0,a=0,u()}}function Ja(){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 It(e){return{sessionId:e?.sessionId??Ja(),...e}}const At={"--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 Ya(e){return e?{...At,...e}:{...At}}const ce="gengage-global-toast-root",Nt="gengage-global-toast-style",tt="gengage-global-toast-root--visible",Qa=4200,Xa=1500,ei=15e3;let Pt=!1,he=null;function zt(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Baglanti sorunu olustu. Lutfen tekrar deneyin.":"Connection issue. Please try again."}function ti(){Pt||typeof window>"u"||typeof document>"u"||(Pt=!0,Me("gengage:global:error",e=>{ni(e)}))}function ni(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;si();const n=oi();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=ii(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(tt),he&&(clearTimeout(he),he=null),he=setTimeout(()=>{ai()},ri(e.durationMs))}function ai(){if(typeof document>"u")return;const e=document.getElementById(ce);e&&(e.classList.remove(tt),e.innerHTML="",he&&(clearTimeout(he),he=null))}function ii(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function oi(){const e=document.getElementById(ce);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=ce,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function ri(e){return typeof e!="number"||!Number.isFinite(e)?Qa:Math.min(ei,Math.max(Xa,Math.round(e)))}function si(){if(document.getElementById(Nt))return;const e=document.createElement("style");e.id=Nt,e.textContent=`
2
+ #${ce} {
3
+ position: fixed;
4
+ top: 16px;
5
+ right: 16px;
6
+ z-index: 2147483646;
7
+ pointer-events: none;
8
+ }
9
+ #${ce}.${tt} {
10
+ pointer-events: auto;
11
+ }
12
+ #${ce} .gengage-global-toast {
13
+ min-width: 260px;
14
+ max-width: min(92vw, 420px);
15
+ border-radius: 12px;
16
+ border: 1px solid #f5c2c7;
17
+ border-left: 4px solid #d93025;
18
+ background: #fff9f9;
19
+ color: #4a1f21;
20
+ box-shadow: 0 10px 30px rgba(38, 18, 18, 0.18);
21
+ padding: 10px 12px;
22
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
23
+ font-size: 13px;
24
+ line-height: 1.4;
25
+ animation: gengage-global-toast-in 180ms ease-out forwards;
26
+ }
27
+ #${ce} .gengage-global-toast-title {
28
+ margin: 0 0 4px;
29
+ font-size: 12px;
30
+ font-weight: 700;
31
+ }
32
+ #${ce} .gengage-global-toast-message {
33
+ margin: 0;
34
+ font-weight: 500;
35
+ }
36
+ @keyframes gengage-global-toast-in {
37
+ from {
38
+ opacity: 0;
39
+ transform: translateY(-8px);
40
+ }
41
+ to {
42
+ opacity: 1;
43
+ transform: translateY(0);
44
+ }
45
+ }
46
+ `,document.head.appendChild(e)}class nt{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=Ya(t.theme);this.config={...t,theme:n,session:It(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ti();const a=Me("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"?Va:Wa;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(Fa(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-${ci(n)}`;this.root.style.setProperty(i,a)}}}}function ci(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function li(){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 di{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(!gi(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 gi(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const pi=console;function ui(e,t,n={}){const a=e.action,i=n.logger??pi;switch(a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){ve(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}hi(a.url,o);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){ve(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"){ve(a,t,n,i);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){ve(a,t,n,i);return}if(typeof a.name!="string"){ve(a,t,n,i);return}const o=fi(a.payload)?a.payload:void 0;o!==void 0?t.scriptCall?.({name:a.name,payload:o}):t.scriptCall?.({name:a.name});return}default:ve(a,t,n,i)}}function ve(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 hi(e,t){if(!(typeof window>"u")){if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function fi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const mi=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"]),bi=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta"]),Lt={"*":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 _i(e){return/^\s*javascript\s*:/i.test(e)}function at(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(bi.has(a)){n.parentNode?.removeChild(n);return}if(!mi.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)at(l,t);return}const i=Lt["*"]??new Set,o=Lt[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(_i(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)at(c,n)}const Mt=["http:","https:"];function ne(e){try{return Mt.includes(new URL(e).protocol)}catch{return!1}}function ae(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return Mt.includes(t.protocol)}catch{return!1}}function j(e,t,n){(t==="href"||t==="src")&&!ae(n)||e.setAttribute(t,n)}function Q(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const i of a)at(i,n);return n.innerHTML}const yi=["image/jpeg","image/png","image/webp"],vi=5*1024*1024;function wi(e){return yi.includes(e.type)?e.size>vi?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function Rt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function xi(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 Ot(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 Rt(i)?(t.onEvent(i),i.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const i=xi(a);if(i.length>1){for(const o of i)try{const r=JSON.parse(o);if(!Rt(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Re(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(Ot(h,t))return}if(i.trim()&&Ot(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 Oe(e){if(typeof e.type!="string")return null;if(ki(e))return e;const n=e;switch(n.type){case"outputText":return Ci(n);case"suggestedActions":return Ei(n);case"productList":return Si(n);case"productDetails":return Ti(n);case"productDetailsSimilars":return Ii(n);case"comparisonTable":return Ai(n);case"context":return Li(n);case"chatStreamEnd":return Mi();case"loading":return Ri(n);case"panelLoading":return Oi(n);case"similarLoading":return Bi(n);case"redirect":return $i(n);case"error":return Di(n);case"dummy":return Ui();case"launcherAction":return qi(n);case"text":return it(n);case"productItem":return ji(n);case"text_image":return Bt(n);case"quick_qna":return $t(n);case"reviewHighlights":return Fi(n);case"aiProductSuggestions":return Vi(n);case"aiProductGroupings":return Wi(n);case"aiSuggestedSearches":return Gi(n);case"prosAndCons":return Zi(n);case"getGroundingReview":return Ki(n);case"voice":return Yi(n);case"visitorDataResponse":return Hi(n);case"productListPreview":return Ji();case"groupList":return Qi(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Xi(n);case"launcherContent":return to(n);case"handoff":return eo(n);default:return null}}function ki(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=re(e.spec);return a?typeof a.root=="string"&&re(a.elements)!==null:!1}case"action":{const n=re(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 Ci(e){const t=B(e.payload.text,e.payload.plain_text)??"",n=B(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 Ei(e){const t=(e.payload.actions??[]).map(n=>{const a=B(n.title)??"",i=ie(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 Dt(t.filter(qt),"chat")}function Si(e){const t=Ut(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 Ti(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:le(t)}}}},panelHint:"panel"}:ao("chat")}function Ii(e){const t=Ut(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Ai(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 m of t){const w=le(m);r.push(w)}const s=Ni(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(m=>m.sku===c)??r[0]:r[0],d=[];if(Array.isArray(a?.key_differences))for(const m of a.key_differences)typeof m=="string"&&d.push(m);const u=so(a?.special_considerations),g=a?.recommended_choice,p=a?.winner_hits,h={};for(const m of r){const w=m.sku;w&&(h[w]={title:m.name??w,type:"launchSingleProduct",payload:{sku:w}})}const f={products:r,attributes:s,highlights:d,productActions:h};return l&&(f.recommended=l),u.length>0&&(f.specialCases=u),g&&(f.recommendedText=g),p&&(f.winnerHits=p),typeof a?.key_differences=="string"&&(f.keyDifferencesHtml=a.key_differences),a?.special_considerations&&(f.specialConsiderations=a.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:f}}},panelHint:"panel"}}function Ni(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 f of p){const m=e[f];if(!m||!Array.isArray(m))continue;const w=g[f]??f;h.push({label:w,values:m.map(C=>typeof C=="string"?C:String(C??""))})}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:Pi(r)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),u=[];for(const g of d){const p=s.map(f=>{const m=r[f];if(!m||typeof m!="object")return"";const w=m[`${g}_short`],C=m[g];return zi(w??C)});if(p.every(f=>f.length===0))continue;const h=c[g]??g;u.push({label:h,values:p})}return u}function Pi(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 zi(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Li(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Mi(){return{type:"done"}}function Ri(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 Oi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Bi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function $i(e){const t=B(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:B(e.payload.to)}}}function Di(e){return{type:"error",code:"BACKEND_ERROR",message:B(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Ui(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function qi(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),$t({payload:o})}const a=re(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),Bt({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=re(t.payload)??void 0;return r!==void 0&&(o.type=r),c!==void 0&&(o.payload=c),s!==void 0&&(o.theme=s),it({payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function it(e){const t={text:B(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 ji(e){return no(e.payload,"qna")}function Bt(e){const t=B(e.payload.text)??"",n=ie(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),it({payload:a})}function $t(e){const t=(e.payload.action_list??[]).map(n=>{const a=B(n.title)??"",i=ie(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 Dt(t.filter(qt),"qna")}function Fi(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 Zi(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 Hi(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Vi(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=io(i);if(!o)continue;const r={product:o},s=ie(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 Wi(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=B(i.name)??"",r=i.sku&&i.sku.length>0?{type:"findSimilar",payload:{sku:i.sku}}:void 0,s=ie(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 Gi(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=B(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Arama ${a+1}`,r={},s=B(i.detailed_user_message);s&&(r.text=s);const c=re(i.requestDetails),l=re(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(C=>typeof C=="string"));const u=B(i.sku,i.representative_product_sku,l?.sku);u&&(r.sku=u),r.is_suggested_text=1;const g={type:"inputText",payload:r},p=ie(i.requestDetails,o),h=p?.type==="findSimilar"&&typeof r.text=="string"?ie(g,o):p??ie(g,o);if(!h)continue;const f={shortName:o,action:h},m=B(i.detailed_user_message);m&&m!==o&&(f.detailedMessage=m);const w=B(i.why_different);w&&(f.whyDifferent=w),typeof i.image=="string"&&(f.image=i.image),n.push(f)}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 Ki(e){const t=ie(e.payload.requestDetails,B(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 Ji(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Yi(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Qi(e){const t=e.payload.group_list??[],n=[];for(const i of t){const o=i.group_name??"",r=(i.product_list??[]).map(le);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=ie(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 Xi(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function eo(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 to(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Dt(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 Ut(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:le(o),index:i}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function no(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:le(e),index:0}}}}}}function ao(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function io(e){const t=B(e.sku),n=B(e.short_name),a=re(e.product_item)??e;return oo(a,t,n)}function oo(e,t,n){const a=B(e.sku,t),i=B(e.name,n);if(!a||!i)return null;const o={sku:a,name:i},r=B(e.brand);r&&(o.brand=r);const s=B(e.url);s&&(o.url=s);const c=ro(e.images);if(c.length>0)o.images=c;else{const h=B(e.image,e.image_url,e.imageUrl);h&&(o.images=[h])}const l=Se(e.price_discounted);l!==void 0&&(o.price_discounted=l);const d=Se(e.price);d!==void 0&&(o.price=d);const u=Se(e.rating);u!==void 0&&(o.rating=u);const g=Se(e.review_count)??Se(e.reviewCount);g!==void 0&&(o.review_count=g);const p=B(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),le(o)}function ie(e,t){const n=re(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 re(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function B(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function ro(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function so(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 Se(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 qt(e){return e!=null}function le(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=B(e.brand),o=B(e.name)??e.sku,r=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,s={sku:e.sku,name:r,url:B(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}function co(e){return e.results.map(le)}function lo(e){return e.product_groupings.map(t=>{const n={name:t.name,products:(t.group_products??[]).map(le)};return t.highlight!==void 0&&(n.highlight=t.highlight),n})}const go={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"},po={process_action:"/message",launcher_action:"/message"};function jt(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 Te(e,t){const n=jt(t?.middlewareUrl);if(t.backendType==="acap"){const a=t.accountId??"",i=po[e];if(i)return`${n}/api/chat/${a}${i}`}return`${n}/chat${go[e]}`}function uo(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 ho={user_message:"inputText"};function fo(e){const{action:t,type:n,payload:a,...i}=e,o=n??t?.type??"inputText",r=a??t?.payload,s=ho[o]??o,c={...i,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function mo(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 bo(e,t,n){const a=Te("process_action",n),i=new AbortController;return(async()=>{try{const r=n.backendType==="acap"?mo(e):fo(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 Re(l,{onEvent:g=>{const p=Oe(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 _o(e,t){const n=Te("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 ot={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."},yo={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 vo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function wo(e){return vo(e)==="en"?yo:ot}function xo(){return Ft()!==null}function Ft(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class ko{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=Ft();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=Co(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 Co(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 Eo(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=Q(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 So{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 To{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,ne(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 Zt={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>'},Io=ot;class Ao{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={...Io,...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 x=document.createElement("img");x.className="gengage-chat-header-avatar",x.src=n.headerAvatarUrl,x.alt=n.headerTitle??"Assistant",i.appendChild(x)}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 x=document.createElement("span");x.className="gengage-chat-header-badge",x.textContent=n.headerBadge,r.appendChild(x)}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 x=document.createElement("a");x.className="gengage-chat-header-btn",x.href=n.headerCartUrl,x.target="_blank",x.rel="noopener noreferrer",x.setAttribute("aria-label","Sepetim"),x.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(x)}if(n.headerFavoritesToggle){const x=document.createElement("button");x.className="gengage-chat-header-btn",x.type="button",x.setAttribute("aria-label","Favorilerim"),x.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>',x.addEventListener("click",()=>n.onFavoritesClick?.()),l.appendChild(x)}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 So({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 f=24;this._dividerEl.addEventListener("touchstart",x=>{if(window.innerWidth>768)return;const L=x.changedTouches?.[0];L&&(p=L.clientX,h=L.clientY)},{passive:!0}),this._dividerEl.addEventListener("touchend",x=>{if(window.innerWidth>768||p===null||h===null)return;const L=x.changedTouches?.[0];if(!L)return;const I=L.clientX-p,P=L.clientY-h;if(p=null,h=null,Math.abs(P)<f||Math.abs(P)<Math.abs(I))return;const M=P<0;M!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(M),this._onPanelToggle?.())},{passive:!0}),this._dividerEl.appendChild(g),u.appendChild(this._dividerEl);const m=document.createElement("div");m.className="gengage-chat-conversation",m.appendChild(a),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",m.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 w=!1;this.messagesEl.addEventListener("scroll",()=>{w||(w=!0,requestAnimationFrame(()=>{w=!1;const{scrollTop:x,scrollHeight:L,clientHeight:I}=this.messagesEl;this._userScrolledUp=L-x-I>10}))},{passive:!0}),m.appendChild(this.messagesEl),this._thumbnailsColumn=new To({onThumbnailClick:x=>n.onThumbnailClick?.(x)}),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 C=document.createElement("div");C.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(C);const S=document.createElement("button");S.className="gengage-chat-pills-arrow",S.type="button",S.setAttribute("aria-label","More suggestions"),S.textContent="›",S.addEventListener("click",()=>{C.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(S);let y=!1;C.addEventListener("scroll",()=>{y||(y=!0,requestAnimationFrame(()=>{y=!1;const x=C.scrollLeft+C.clientWidth>=C.scrollWidth-4;S.style.display=x?"none":""}))},{passive:!0}),m.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",m.appendChild(this._inputChipsEl);const b=document.createElement("div");b.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",x=>{x.key==="Enter"&&(window.innerWidth<768||!x.shiftKey)&&(x.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",x=>{const L=x.clipboardData?.files[0];L&&L.type.startsWith("image/")&&(x.preventDefault(),this._onAttachment?this._onAttachment(L):this.stageAttachment(L))}),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 x=this._fileInput.files?.[0];x&&(this._onAttachment?this._onAttachment(x):this.stageAttachment(x)),this._fileInput.value=""});const A=document.createElement("button");A.className="gengage-chat-attach-btn",A.type="button",A.setAttribute("aria-label",this.i18n.attachImageButton),A.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>',A.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const N=document.createElement("img");N.className="gengage-chat-attachment-preview-thumb",N.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const v=document.createElement("button");v.className="gengage-chat-attachment-remove",v.type="button",v.setAttribute("aria-label",this.i18n.removeAttachmentButton),v.textContent="×",v.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(N),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(v),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()),b.addEventListener("dragover",x=>{x.preventDefault(),b.classList.add("gengage-chat-input-area--dragover")}),b.addEventListener("dragleave",()=>{b.classList.remove("gengage-chat-input-area--dragover")}),b.addEventListener("drop",x=>{x.preventDefault(),b.classList.remove("gengage-chat-input-area--dragover");const L=x.dataTransfer?.files[0];L&&(this._onAttachment?this._onAttachment(L):this.stageAttachment(L))});const k=document.createElement("div");k.className="gengage-chat-input-pill",k.appendChild(A),k.appendChild(this.inputEl),this._voiceEnabled&&xo()&&(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()),k.appendChild(this._micBtn),this._voiceInput=new ko({onInterim:x=>{this.inputEl.value=x,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:x=>{this.inputEl.value=x},onAutoSubmit:x=>{this.inputEl.value=x,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:x=>{x==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(x,L)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),k.appendChild(this.sendBtn),b.appendChild(this._previewStrip),b.appendChild(this._fileInput),b.appendChild(k),m.appendChild(b),u.appendChild(m),this.root.appendChild(u);const E=document.createElement("div");E.className="gengage-chat-footer",E.textContent=this.i18n.poweredBy,this.root.appendChild(E),this.root.addEventListener("keydown",x=>{x.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=Q(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=Zt[i.icon];if(s){const c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,o.appendChild(c)}}if(i.image&&ne(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=Eo({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=Q(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=Zt[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 No=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
48
+ <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
49
+ <rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
50
+ <circle cx="9" cy="13" r="1.5" fill="currentColor"/>
51
+ <circle cx="15" cy="13" r="1.5" fill="currentColor"/>
52
+ <path d="M9.5 17C10.3 17.6 11.1 18 12 18C12.9 18 13.7 17.6 14.5 17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
53
+ <path d="M12 7V4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
54
+ <circle cx="12" cy="3" r="1" fill="currentColor"/>
55
+ <path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
56
+ <path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
57
+ </svg>`;function Po(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??No,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 zo(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 Lo{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 Mo=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]);function Ro(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!Mo.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 Oo{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=jt(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 Bo={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function V(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...Bo,...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 $o={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 Do(e){return $o[e]??e.replace(/_/g," ").replace(/^\w/,t=>t.toUpperCase())}function Uo(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&&ne(t.imageUrl)){const m=document.createElement("img");m.src=t.imageUrl,m.alt=t.name,m.loading="lazy",m.addEventListener("error",()=>{m.style.display="none"},{once:!0}),g.appendChild(m)}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 f=document.createElement("div");if(f.className="gengage-chat-comparison-recommended-price",f.textContent=V(t.price,e.pricing),p.appendChild(f),g.appendChild(p),g.addEventListener("click",()=>{r(t.sku)}),g.style.cursor="pointer",d.appendChild(g),i.length>0){const m=document.createElement("div");m.className="gengage-chat-comparison-highlights";const w=document.createElement("div");w.className="gengage-chat-comparison-highlights-label",w.textContent=s?.highlightsLabel??"Öne Çıkan Özellikler",m.appendChild(w);const C=document.createElement("ul");for(const S of i){const y=document.createElement("li");y.textContent=S,C.appendChild(y)}m.appendChild(C),d.appendChild(m)}if(e.recommendedText){const m=document.createElement("div");m.className="gengage-chat-comparison-recommended-text",m.innerHTML=Q(e.recommendedText),d.appendChild(m)}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=Q(qo(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)jo(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 f of n){const m=document.createElement("th");if(f.sku===t?.sku&&(m.className="gengage-chat-comparison-selected"),f.imageUrl&&ne(f.imageUrl)){const S=document.createElement("img");S.src=f.imageUrl,S.alt=f.name,S.loading="lazy",S.addEventListener("error",()=>{S.style.display="none"},{once:!0}),m.appendChild(S)}const w=document.createElement("div");w.textContent=f.name,m.appendChild(w);const C=document.createElement("div");C.className="gengage-chat-comparison-table-price",C.textContent=V(f.price,e.pricing),m.appendChild(C),g.appendChild(m)}u.appendChild(g),d.appendChild(u);const h=document.createElement("tbody");for(const f of a){const m=document.createElement("tr"),w=document.createElement("td");w.className="gengage-chat-comparison-label",w.textContent=Do(f.label),m.appendChild(w);for(let C=0;C<f.values.length;C++){const S=document.createElement("td");n[C]?.sku===t?.sku&&(S.className="gengage-chat-comparison-selected"),S.textContent=f.values[C]??"",m.appendChild(S)}h.appendChild(m)}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 qo(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 jo(e,t){const n=Q(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=Q(r.innerHTML),e.appendChild(s)}return}const o=document.createElement("li");Fo(t)?o.innerHTML=n:o.textContent=t,e.appendChild(o)}function Fo(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function Zo(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 f=p.review_class;if((f==="positive"||f==="negative"||f==="neutral")&&(h.dataset.tone=f),typeof p.review_tag=="string"&&p.review_tag.length>0){const m=document.createElement("div");m.className="gengage-chat-review-tag",m.textContent=p.review_tag,h.appendChild(m)}if(typeof p.review_text=="string"&&p.review_text.length>0){const m=document.createElement("div");m.className="gengage-chat-review-text",m.textContent=p.review_text,h.appendChild(m)}if(p.review_rating!==void 0&&String(p.review_rating).length>0){const m=document.createElement("div");m.className="gengage-chat-review-rating",m.textContent=String(p.review_rating),h.appendChild(m)}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 f=document.createElement("span");f.className="gengage-chat-review-pill",f.dataset.tone=h.sentiment;const m=document.createElement("span");m.className="gengage-chat-review-pill-icon",m.textContent=h.sentiment==="positive"?"✓":h.sentiment==="negative"?"✕":"●",f.appendChild(m);const w=document.createElement("span");if(w.textContent=p,f.appendChild(w),h.count>1){const C=document.createElement("span");C.className="gengage-chat-review-pill-count",C.textContent=String(h.count),f.appendChild(C)}g.appendChild(f)}n.appendChild(g)}return d(),n.appendChild(l),n}function rt(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Be(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function st(e,t=!0){const n=rt(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 de(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function Ht(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 Ho={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function Vt(e,t){if(!e||!t)return null;const n=Ho[e];return n?t[n]??e:e}function Vo(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?Wo(s,t):Go(s,t);o.appendChild(l)}return n.appendChild(o),n}function Wo(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=Vt(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=`%${Be(o)}`,n.appendChild(u)}const r=i.imageUrl;if(r&&ne(r)){const u=document.createElement("img");u.className="gengage-chat-ai-toppick-img",j(u,"src",r),u.alt=i.name??"",de(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(Wt(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=V(d,t.pricing),u.appendChild(p),u.appendChild(document.createTextNode(" "))}const g=document.createElement("span");g.textContent=V(l,t.pricing),u.appendChild(g),s.appendChild(u)}if(n.appendChild(s),e.action){const u=Ht(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 Go(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=`%${Be(i)}`,n.appendChild(d)}const o=a.imageUrl;if(o&&ne(o)){const d=document.createElement("img");d.className="gengage-chat-ai-toppick-img",j(d,"src",o),d.alt=a.name??"",de(d),n.appendChild(d)}const r=document.createElement("div");r.className="gengage-chat-ai-toppick-body";const s=Vt(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(Wt(e.labels));const l=a.price;if(l){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price",d.textContent=V(l,t.pricing),r.appendChild(d)}if(n.appendChild(r),e.action){const d=Ht(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 Wt(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 Ko(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 Jo(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 Yo(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(Jo(i))),i.image&&ne(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 Qo(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&&ne(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 Xo(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 er(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 tr(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",f=>{let m=-1;f.key==="ArrowRight"||f.key==="ArrowDown"?m=(l+1)%n.length:f.key==="ArrowLeft"||f.key==="ArrowUp"?m=(l-1+n.length)%n.length:f.key==="Home"?m=0:f.key==="End"&&(m=n.length-1),m>=0&&(f.preventDefault(),c(m),r[m].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 f of d.products){const m=nr(f,t);h.appendChild(m)}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 nr(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&ne(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 ar(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 ir(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&&ae(i)){const p=document.createElement("div");p.className="gengage-chat-product-summary__image";const h=document.createElement("img");j(h,"src",i);const f=n.name;f&&(h.alt=f),de(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=st(rt(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 f=document.createElement("span");f.className="gengage-chat-product-summary__price-original",f.textContent=V(u,t.pricing),p.appendChild(f),p.appendChild(document.createTextNode(" "))}const h=document.createElement("span");h.className="gengage-chat-product-summary__price-current",h.textContent=V(d,t.pricing),p.appendChild(h),o.appendChild(p)}a.appendChild(o);const g=n.url;if(g&&ae(g)){const p=document.createElement("a");p.className="gengage-chat-product-summary__cta",j(p,"href",g),j(p,"target","_blank"),j(p,"rel","noopener noreferrer"),p.textContent=t.i18n?.productCtaLabel??"İncele",a.appendChild(p)}return a}function ct(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 Gt(){return window.innerWidth<768}const Kt={ActionButtons:({element:e,context:t})=>sr(e,t),ActionButton:({element:e,context:t})=>cr(e,t),ProductCard:({element:e,context:t})=>lr(e,t),ProductDetailsPanel:({element:e,context:t})=>dr(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>ur(e,t,n,a),ReviewHighlights:({element:e,context:t})=>Zo(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage}),ComparisonTable:({element:e,context:t})=>hr(e,t),AITopPicks:({element:e,context:t})=>Vo(e,t),GroundingReviewCard:({element:e,context:t})=>Ko(e,t),AIGroupingCards:({element:e,context:t})=>Yo(e,t),AISuggestedSearchCards:({element:e,context:t})=>Qo(e,t),ProsAndCons:({element:e})=>er(e),CategoriesContainer:({element:e,context:t})=>tr(e,t),HandoffNotice:({element:e,context:t})=>ar(e,t),ProductSummaryCard:({element:e,context:t})=>ir(e,t),Divider:({element:e})=>fr(e)},Jt=({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 or(){return{...Kt}}function rr(e,t,n=Kt,a=Jt){return Je({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function sr(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 cr(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 lr(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&&ae(o)){const y=document.createElement("div");y.className="gengage-chat-product-card-img-wrapper";const b=document.createElement("img");b.className="gengage-chat-product-card-img",b.loading="lazy",j(b,"src",o);const A=a.name;A&&(b.alt=A),de(b),y.appendChild(b);const N=a.discountPercent;if(typeof N=="number"&&N>0){const E=document.createElement("span");E.className="gengage-chat-product-card-discount-badge",E.textContent=`%${Be(N)}`,y.appendChild(E)}const v=a.sku;if(v){const E=document.createElement("button");E.className="gengage-chat-find-similar-pill",E.type="button",E.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",E.addEventListener("click",x=>{x.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:v,...o?{image_url:o}:{}}})}),y.appendChild(E)}const k=a.sku;if(k&&t.onFavoriteToggle){const E=document.createElement("button");E.className="gengage-chat-favorite-btn",E.type="button",E.setAttribute("aria-label","Favorilere ekle");const x=t.favoritedSkus?.has(k)??!1;x&&E.classList.add("gengage-chat-favorite-btn--active");const L=x?"currentColor":"none";E.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${L}" 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>`,E.addEventListener("click",I=>{I.stopPropagation(),E.classList.toggle("gengage-chat-favorite-btn--active");const P=E.querySelector("svg");P&&P.setAttribute("fill",E.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(k,a)}),y.appendChild(E)}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=st(l),typeof d=="number"&&Number.isFinite(d)){const b=document.createElement("span");b.className="gengage-chat-product-card-review-count",b.textContent=` (${d})`,y.appendChild(b)}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 b=document.createElement("span");b.className="gengage-chat-price-skeleton",y.appendChild(b),r.appendChild(y),setTimeout(()=>{b.parentElement&&(u?b.replaceWith(document.createTextNode(V(u,t.pricing))):b.remove())},300)}else if(u){const y=document.createElement("div");if(y.className="gengage-chat-product-card-price",g&&g!==u){const A=document.createElement("span");A.className="gengage-chat-product-card-original-price",A.textContent=V(g,t.pricing),y.appendChild(A),y.appendChild(document.createTextNode(" "))}const b=document.createElement("span");b.textContent=V(u,t.pricing),y.appendChild(b),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 f=a.promotions;if(f&&f.length>0){const y=document.createElement("div");y.className="gengage-chat-product-card-promos";for(const b of f){const A=document.createElement("span");A.className="gengage-chat-product-card-promo-badge",A.textContent=b,y.appendChild(A)}r.appendChild(y)}n.appendChild(r);const m=a.url,w=a.sku,C=e.props?.action;if(C){const y=document.createElement("button");y.className="gengage-chat-product-card-cta",y.type="button",y.textContent=C.title||t.i18n?.productCtaLabel||"Incele",y.addEventListener("click",()=>t.onAction(C)),n.appendChild(y)}else if(m&&ae(m)){const y=document.createElement("a");y.className="gengage-chat-product-card-cta",j(y,"href",m),j(y,"target","_blank"),j(y,"rel","noopener noreferrer"),y.textContent=t.i18n?.productCtaLabel??"İncele",y.addEventListener("click",b=>{t.onProductClick&&w&&(b.preventDefault(),t.onProductClick({sku:w,url:m}))}),n.appendChild(y)}const S=a.cartCode;if(S&&w&&h!==!1){const y=ct({compact:!0,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:b=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:w,cartCode:S,quantity:b}})}});y.classList.add("gengage-chat-product-card-atc"),n.appendChild(y)}if(t.comparisonSelectMode&&w&&t.onToggleComparisonSku){const y=document.createElement("div");y.className="gengage-chat-comparison-select-wrapper";const b=document.createElement("input");return b.type="checkbox",b.className="gengage-chat-comparison-checkbox",b.checked=t.comparisonSelectedSkus?.includes(w)??!1,b.addEventListener("change",()=>{t.onToggleComparisonSku?.(w)}),y.appendChild(b),y.appendChild(n),y}return n}function dr(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 v=document.createElement("div");v.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 E=i.find(R=>ae(R));E&&j(k,"src",E);const x=a.name;x&&(k.alt=x),de(k),v.appendChild(k);const L=document.createElement("div");L.className="gengage-chat-product-gallery-thumbs";let I=null,P=0;for(let R=0;R<i.length;R++){const Y=i[R];if(!Y||!ae(Y))continue;const G=document.createElement("img");G.className="gengage-chat-product-gallery-thumb",R===0&&(G.classList.add("gengage-chat-product-gallery-thumb--active"),I=G),j(G,"src",Y),G.alt=`${x??"Product"} ${R+1}`,G.width=48,G.height=48,de(G),G.addEventListener("click",()=>{j(k,"src",Y),I&&I.classList.remove("gengage-chat-product-gallery-thumb--active"),G.classList.add("gengage-chat-product-gallery-thumb--active"),I=G,P=R}),L.appendChild(G)}let M=0;const z=50;if(k.addEventListener("touchstart",R=>{M=R.changedTouches[0].clientX},{passive:!0}),k.addEventListener("touchend",R=>{const Y=R.changedTouches[0].clientX,G=M-Y;if(Math.abs(G)<z)return;const St=L.querySelectorAll(".gengage-chat-product-gallery-thumb"),Tt=G>0?Math.min(P+1,St.length-1):Math.max(P-1,0);Tt!==P&&St[Tt]&&St[Tt].click()}),v.appendChild(L),r){const R=document.createElement("button");R.className="gengage-chat-find-similar-pill",R.type="button",R.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",R.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...E?{image_url:E}:{}}})}),v.appendChild(R)}n.appendChild(v)}else if(o&&ae(o)){const v=document.createElement("div");v.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",j(k,"src",o),de(k);const E=a.name;if(E&&(k.alt=E),v.appendChild(k),r){const x=document.createElement("button");x.className="gengage-chat-find-similar-pill",x.type="button",x.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",x.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...o?{image_url:o}:{}}})}),v.appendChild(x)}n.appendChild(v)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const v=document.createElement("h3");v.className="gengage-chat-product-details-title",v.textContent=c,s.appendChild(v)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const v=document.createElement("div");if(v.className="gengage-chat-product-details-rating",v.textContent=`★ ${rt(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})`,v.appendChild(k)}s.appendChild(v)}const u=a.price,g=a.originalPrice;if(a.price_async===!0){const v=document.createElement("div");v.className="gengage-chat-product-details-price";const k=document.createElement("span");k.className="gengage-chat-price-skeleton",v.appendChild(k),s.appendChild(v),setTimeout(()=>{if(k.parentElement)if(u){const E=document.createElement("span");E.className="gengage-chat-product-details-current-price",E.textContent=V(u,t.pricing),k.replaceWith(E)}else k.remove()},300)}else if(u){const v=document.createElement("div");if(v.className="gengage-chat-product-details-price",g&&g!==u){const E=document.createElement("span");E.className="gengage-chat-product-details-original-price",E.textContent=V(g,t.pricing),v.appendChild(E),v.appendChild(document.createTextNode(" "))}const k=document.createElement("span");k.className="gengage-chat-product-details-current-price",k.textContent=V(u,t.pricing),v.appendChild(k),s.appendChild(v)}const h=a.inStock;if(typeof h=="boolean"){const v=document.createElement("div");v.className=`gengage-chat-product-details-stock ${h?"is-in-stock":"is-out-of-stock"}`,v.textContent=h?"Stokta var":"Stokta yok",s.appendChild(v)}const f=a.promotions;if(f&&f.length>0){const v=document.createElement("div");v.className="gengage-chat-product-details-promos";for(const k of f){const E=document.createElement("span");E.className="gengage-chat-product-details-promo-badge",E.textContent=k,v.appendChild(E)}s.appendChild(v)}const m=a.variants;if(m&&m.length>0){const v=document.createElement("div");v.className="gengage-chat-product-variants";const k=document.createElement("div");k.className="gengage-chat-product-variants-label",k.textContent=t.i18n?.variantsLabel??"Varyantlar",v.appendChild(k);const E=document.createElement("div");E.className="gengage-chat-product-variants-list";for(const x of m){const L=x.name??x.variant_name,I=x.sku;if(!L&&!I)continue;const P=document.createElement("button");P.className="gengage-chat-product-variant-btn",P.type="button";const M=L??I??"",z=x.price;z&&String(z)!==String(u)?P.textContent=`${M} - ${V(String(z),t.pricing)}`:P.textContent=M,I&&P.addEventListener("click",()=>{t.onAction({title:M,type:"launchVariant",payload:{sku:I}})}),E.appendChild(P)}v.appendChild(E),s.appendChild(v)}const w=a.sku,C=a.cartCode,S=document.createElement("div");S.className="gengage-chat-product-details-actions";const y=e.props?.action;if(y){const v=document.createElement("button");v.className="gengage-chat-product-details-cta",v.type="button",v.textContent=y.title||t.i18n?.productCtaLabel||"Incele",v.addEventListener("click",()=>t.onAction(y)),S.appendChild(v)}else{const v=a.url;if(v&&ae(v)){const k=document.createElement("a");k.className="gengage-chat-product-details-cta",j(k,"href",v),j(k,"target","_blank"),j(k,"rel","noopener noreferrer"),k.textContent=t.i18n?.productCtaLabel??"Incele",k.addEventListener("click",E=>{t.onProductClick&&w&&(E.preventDefault(),t.onProductClick({sku:w,url:v}))}),S.appendChild(k)}}if(C&&w&&h!==!1){const v=ct({compact:!1,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:k=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:w,cartCode:C,quantity:k}})}});v.classList.add("gengage-chat-product-details-atc-stepper"),S.appendChild(v)}const b=a.url;if(b&&ae(b)){let v=function(P,M){const z=document.createElementNS(L,"circle");z.setAttribute("cx",P),z.setAttribute("cy",M),z.setAttribute("r","3"),I.appendChild(z)},k=function(P,M,z,R){const Y=document.createElementNS(L,"line");Y.setAttribute("x1",P),Y.setAttribute("y1",M),Y.setAttribute("x2",z),Y.setAttribute("y2",R),I.appendChild(Y)};const E=document.createElement("button");E.className="gengage-chat-product-details-share",E.type="button";const x=t.i18n?.shareButton??"Paylaş";E.title=x,E.setAttribute("aria-label",x);const L="http://www.w3.org/2000/svg",I=document.createElementNS(L,"svg");I.setAttribute("width","18"),I.setAttribute("height","18"),I.setAttribute("viewBox","0 0 24 24"),I.setAttribute("fill","none"),I.setAttribute("stroke","currentColor"),I.setAttribute("stroke-width","2"),I.setAttribute("stroke-linecap","round"),I.setAttribute("stroke-linejoin","round"),v("18","5"),v("6","12"),v("18","19"),k("8.59","13.51","15.42","17.49"),k("15.41","6.51","8.59","10.49"),E.appendChild(I),E.addEventListener("click",async()=>{const P=a.name;try{navigator.share?await navigator.share({title:P??"",url:b}):navigator.clipboard&&(await navigator.clipboard.writeText(b),E.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>E.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),S.appendChild(E)}S.childElementCount>0&&s.appendChild(S),n.appendChild(s);const A=a.description,N=a.specifications;return(A||N)&&n.appendChild(gr(A,N,t)),n}function gr(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 Yt(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 pr(e,t,n,a){const i=Yt(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 ur(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),pr(r,o,t,g.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(f=>f.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=Yt(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(Gt()&&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=Xo(a.comparisonSelectedSkus,a);i.appendChild(l)}return i}function hr(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=Uo(g);return Gt()&&p.classList.add("gengage-chat-comparison--mobile"),p}function fr(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 mr=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function br(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&mr.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 _r(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 yr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function vr(e){const{container:t,html:n,delayMs:a=30,onTick:i,onComplete:o}=e,r=document.createElement("template");r.innerHTML=n;const s=br(r.content.childNodes);if(yr()||s.length<=1||_r(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 wr(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),f=d.slice(u,u+r.short_name.length),m=d.slice(u+r.short_name.length),w=c.parentNode;if(!w){c=s.nextNode();continue}const C=document.createElement("a");C.className="gengage-product-mention",C.textContent=f,C.href="#",C.addEventListener("click",S=>{S.preventDefault(),a(r.sku)}),h&&w.insertBefore(document.createTextNode(h),c),w.insertBefore(C,c),m&&w.insertBefore(document.createTextNode(m),c),w.removeChild(c),l=!0}}}const xr=new Set(["search","info","review","similar"]),kr=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function Cr(e){return!!(e.icon&&xr.has(e.icon)||e.action?.type&&kr.has(e.action.type))}const Xt="gengage_choice_prompter_dismissed";function Er(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",()=>{en(),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",()=>{en(),t.remove(),e.onDismiss?.()}),t.appendChild(o),t}function Sr(){try{return sessionStorage.getItem(Xt)==="1"}catch{return!1}}function en(){try{sessionStorage.setItem(Xt,"1")}catch{}}const Tr="gengage_assistant",Ir=3,ge="sessions",X="context",oe="payload",ee="favorites";function Ie(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function we(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Ar{constructor(t=Tr,n=Ir){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(X,{keyPath:["sessionId","threadId"]}),o.createObjectStore(oe,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.createObjectStore(ee,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(o.objectStoreNames.contains(ge)&&o.deleteObjectStore(ge),o.objectStoreNames.contains(oe)&&o.deleteObjectStore(oe),o.createObjectStore(ge,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(oe,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.objectStoreNames.contains(X)||o.createObjectStore(X,{keyPath:["sessionId","threadId"]})),r<3&&(o.objectStoreNames.contains(ee)||o.createObjectStore(ee,{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 we(a)}async loadSession(t,n,a){const o=this._requireDb().transaction(ge,"readonly");return await Ie(o.objectStore(ge).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(X,"readwrite");a.objectStore(X).put(t),await we(a)}async loadContext(t,n){const i=this._requireDb().transaction(X,"readonly");return await Ie(i.objectStore(X).get([t,n]))??null}async deleteContextsAfterThread(t,n){const i=this._requireDb().transaction(X,"readwrite"),r=i.objectStore(X).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 we(i)}async loadLatestContext(t){const i=this._requireDb().transaction(X,"readonly").objectStore(X),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(oe,"readwrite");a.objectStore(oe).put(t),await we(a)}async loadPayload(t,n){const i=this._requireDb().transaction(oe,"readonly");return await Ie(i.objectStore(oe).get([t,n]))??null}async loadPayloadsByThread(t){const i=this._requireDb().transaction(oe,"readonly").objectStore(oe).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(ee,"readwrite");a.objectStore(ee).put(t),await we(a)}async removeFavorite(t,n,a){const o=this._requireDb().transaction(ee,"readwrite");o.objectStore(ee).delete([t,n,a]),await we(o)}async loadFavorites(t,n){const i=this._requireDb().transaction(ee,"readonly");return(await Ie(i.objectStore(ee).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const o=this._requireDb().transaction(ee,"readonly");return await Ie(o.objectStore(ee).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const Nr=["comparisonTable","groupList","productDetailsSimilars","productList"];class Pr{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(Nr);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 zr{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 tn(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:tn(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 tn(e){return e==="user_message"||e==="inputText"}class nn{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 an="gengage_kvkk_shown",Lr=["kvkk","kişisel veri","kisisel veri"],Mr=/\b6698\b/;function lt(e){const t=e.toLowerCase();return Lr.some(n=>t.includes(n))||Mr.test(t)}function on(e){try{return localStorage.getItem(`${an}_${e}`)==="1"}catch{return!1}}function Rr(e){try{localStorage.setItem(`${an}_${e}`,"1")}catch{}}function Or(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const i of a)if(lt(i.textContent??"")){i.remove();break}return n.innerHTML.trim()}function Br(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(lt(n.textContent??""))return n.outerHTML;return null}const $r={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function Dr(e){return e?$r[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const Ur=':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 qr(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function F(e,t){const n={event:e,...t};qr()&&window.dataLayer.push(n)}function dt(e){F("gengage-on-init",{gengage_widget:e})}function $e(e){F("gengage-show",{gengage_widget:e})}function rn(e,t){F("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function jr(e){F("gengage-find-similars",{gengage_sku:e})}function Fr(e){F("gengage-compare-preselection",{gengage_sku:e})}function sn(e){F("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function Zr(){F("gengage-compare-clear")}function Hr(e){F("gengage-compare-received",{gengage_product_count:e})}function Vr(e){F("gengage-like-product",{gengage_sku:e})}function Wr(){F("gengage-like-list")}function Gr(e,t){F("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function cn(e,t){F("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function ln(e,t){F("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function Kr(){F("gengage-message-sent")}function dn(){F("gengage-message-received")}function Jr(){F("gengage-conversation-start")}function Yr(){F("gengage-voice-input")}function _(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 xe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const pn={};function fe(e){return pn}function un(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 gt(e,t){return typeof t=="bigint"?t.toString():t}function pt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ut(e){return e==null}function ht(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Qr(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 hn=Symbol("evaluating");function O(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==hn)return a===void 0&&(a=hn,a=n()),a},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function me(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pe(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function fn(e){return JSON.stringify(e)}function Xr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const mn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const es=pt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ae(e){if(De(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(De(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function bn(e){return Ae(e)?{...e}:Array.isArray(e)?[...e]:e}const ts=new Set(["string","number","symbol"]);function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ue(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function T(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 ns(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const as={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 is(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=pe(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 me(this,"shape",r),r},checks:[]});return ue(e,o)}function os(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=pe(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 me(this,"shape",r),r},checks:[]});return ue(e,o)}function rs(e,t){if(!Ae(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=pe(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return me(this,"shape",o),o}});return ue(e,i)}function ss(e,t){if(!Ae(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pe(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return me(this,"shape",a),a}});return ue(e,n)}function cs(e,t){const n=pe(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return me(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ue(e,n)}function ls(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=pe(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 me(this,"shape",c),c},checks:[]});return ue(t,r)}function ds(e,t,n){const a=pe(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 me(this,"shape",o),o}});return ue(t,a)}function Ce(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 _n(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Ue(e){return typeof e=="string"?e:e?.message}function be(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const i=Ue(e.inst?._zod.def?.error?.(e))??Ue(t?.error?.(e))??Ue(n.customError?.(e))??Ue(n.localeError?.(e))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function ft(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 yn=(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,gt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vn=_("$ZodError",yn),wn=_("$ZodError",yn,{Parent:Error});function gs(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 ps(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 mt=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 xe;if(r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>be(c,o,fe())));throw mn(s,i?.callee),s}return r.value},bt=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=>be(c,o,fe())));throw mn(s,i?.callee),s}return r.value},qe=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 xe;return o.issues.length?{success:!1,error:new(e??vn)(o.issues.map(r=>be(r,i,fe())))}:{success:!0,data:o.value}},us=qe(wn),je=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=>be(r,i,fe())))}:{success:!0,data:o.value}},hs=je(wn),fs=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return mt(e)(t,n,i)},ms=e=>(t,n,a)=>mt(e)(t,n,a),bs=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return bt(e)(t,n,i)},_s=e=>async(t,n,a)=>bt(e)(t,n,a),ys=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return qe(e)(t,n,i)},vs=e=>(t,n,a)=>qe(e)(t,n,a),ws=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return je(e)(t,n,i)},xs=e=>async(t,n,a)=>je(e)(t,n,a),ks=/^[cC][^\s-]{8,}$/,Cs=/^[0-9a-z]+$/,Es=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ss=/^[0-9a-vA-V]{20}$/,Ts=/^[A-Za-z0-9]{27}$/,Is=/^[a-zA-Z0-9_-]{21}$/,As=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ns=/^([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})$/,xn=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)$/,Ps=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ls(){return new RegExp(zs,"u")}const Ms=/^(?:(?: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])$/,Rs=/^(([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])$/,Bs=/^(([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])$/,$s=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kn=/^[A-Za-z0-9_-]*$/,Ds=/^\+[1-9]\d{6,14}$/,Cn="(?:(?:\\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])))",Us=new RegExp(`^${Cn}$`);function En(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 qs(e){return new RegExp(`^${En(e)}$`)}function js(e){const t=En({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${Cn}T(?:${a})$`)}const Fs=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Zs=/^-?\d+$/,Hs=/^-?\d+(?:\.\d+)?$/,Vs=/^(?:true|false)$/i,Ws=/^[^A-Z]*$/,Gs=/^[^a-z]*$/,K=_("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Sn={number:"number",bigint:"bigint",object:"date"},Tn=_("$ZodCheckLessThan",(e,t)=>{K.init(e,t);const n=Sn[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})}}),In=_("$ZodCheckGreaterThan",(e,t)=>{K.init(e,t);const n=Sn[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})}}),Ks=_("$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):Qr(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})}}),Js=_("$ZodCheckNumberFormat",(e,t)=>{K.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[i,o]=as[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=Zs)}),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})}}),Ys=_("$ZodCheckMaxLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!ut(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=ft(i);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Qs=_("$ZodCheckMinLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!ut(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=ft(i);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Xs=_("$ZodCheckLengthEquals",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!ut(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=ft(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})}}),Fe=_("$ZodCheckStringFormat",(e,t)=>{var n,a;K.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=()=>{})}),ec=_("$ZodCheckRegex",(e,t)=>{Fe.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})}}),tc=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ws),Fe.init(e,t)}),nc=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Gs),Fe.init(e,t)}),ac=_("$ZodCheckIncludes",(e,t)=>{K.init(e,t);const n=ke(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})}}),ic=_("$ZodCheckStartsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`^${ke(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})}}),oc=_("$ZodCheckEndsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`.*${ke(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})}}),rc=_("$ZodCheckOverwrite",(e,t)=>{K.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sc{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 cc={major:4,minor:3,patch:6},U=_("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=cc;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=Ce(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 xe;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,r.issues.length!==g&&(l||(l=Ce(r,g)))});else{if(r.issues.length===g)continue;l||(l=Ce(r,g))}}return d?d.then(()=>r):r},o=(r,s,c)=>{if(Ce(r))return r.aborted=!0,r;const l=i(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new xe;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 xe;return c.then(l=>i(l,a,s))}return i(c,a,s)}}O(e,"~standard",()=>({validate:i=>{try{const o=us(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return hs(e,i).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),_t=_("$ZodString",(e,t)=>{U.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Fs(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}}),$=_("$ZodStringFormat",(e,t)=>{Fe.init(e,t),_t.init(e,t)}),lc=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ns),$.init(e,t)}),dc=_("$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=xn(a))}else t.pattern??(t.pattern=xn());$.init(e,t)}),gc=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ps),$.init(e,t)}),pc=_("$ZodURL",(e,t)=>{$.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})}}}),uc=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ls()),$.init(e,t)}),hc=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Is),$.init(e,t)}),fc=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ks),$.init(e,t)}),mc=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Cs),$.init(e,t)}),bc=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Es),$.init(e,t)}),_c=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ss),$.init(e,t)}),yc=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ts),$.init(e,t)}),vc=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=js(t)),$.init(e,t)}),wc=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Us),$.init(e,t)}),xc=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qs(t)),$.init(e,t)}),kc=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=As),$.init(e,t)}),Cc=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ms),$.init(e,t),e._zod.bag.format="ipv4"}),Ec=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Rs),$.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})}}}),Sc=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Os),$.init(e,t)}),Tc=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Bs),$.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 An(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ic=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$s),$.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{An(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ac(e){if(!kn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return An(n)}const Nc=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=kn),$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Ac(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Pc=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ds),$.init(e,t)});function zc(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 Lc=_("$ZodJWT",(e,t)=>{$.init(e,t),e._zod.check=n=>{zc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Nn=_("$ZodNumber",(e,t)=>{U.init(e,t),e._zod.pattern=e._zod.bag.pattern??Hs,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}}),Mc=_("$ZodNumberFormat",(e,t)=>{Js.init(e,t),Nn.init(e,t)}),Rc=_("$ZodBoolean",(e,t)=>{U.init(e,t),e._zod.pattern=Vs,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}}),Oc=_("$ZodUnknown",(e,t)=>{U.init(e,t),e._zod.parse=n=>n}),Bc=_("$ZodNever",(e,t)=>{U.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Pn(e,t,n){e.issues.length&&t.issues.push(..._n(n,e.issues)),t.value[n]=e.value}const $c=_("$ZodArray",(e,t)=>{U.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=>Pn(l,n,r))):Pn(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(..._n(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function zn(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=ns(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ln(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 Dc=_("$ZodObject",(e,t)=>{if(U.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=pt(()=>zn(t));O(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=De,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",f=p._zod.run({value:l[g],issues:[]},c);f instanceof Promise?d.push(f.then(m=>Ze(m,s,g,l,h))):Ze(f,s,g,l,h)}return o?Ln(d,l,s,c,a.value,e):d.length?Promise.all(d).then(()=>s):s}}),Uc=_("$ZodObjectJIT",(e,t)=>{Dc.init(e,t);const n=e._zod.parse,a=pt(()=>zn(t)),i=g=>{const p=new sc(["shape","payload","ctx"]),h=a.value,f=S=>{const y=fn(S);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};p.write("const input = payload.value;");const m=Object.create(null);let w=0;for(const S of h.keys)m[S]=`key_${w++}`;p.write("const newResult = {};");for(const S of h.keys){const y=m[S],b=fn(S),N=g[S]?._zod?.optout==="optional";p.write(`const ${y} = ${f(S)};`),N?p.write(`
61
+ if (${y}.issues.length) {
62
+ if (${b} in input) {
63
+ payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
64
+ ...iss,
65
+ path: iss.path ? [${b}, ...iss.path] : [${b}]
66
+ })));
67
+ }
68
+ }
69
+
70
+ if (${y}.value === undefined) {
71
+ if (${b} in input) {
72
+ newResult[${b}] = undefined;
73
+ }
74
+ } else {
75
+ newResult[${b}] = ${y}.value;
76
+ }
77
+
78
+ `):p.write(`
79
+ if (${y}.issues.length) {
80
+ payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
81
+ ...iss,
82
+ path: iss.path ? [${b}, ...iss.path] : [${b}]
83
+ })));
84
+ }
85
+
86
+ if (${y}.value === undefined) {
87
+ if (${b} in input) {
88
+ newResult[${b}] = undefined;
89
+ }
90
+ } else {
91
+ newResult[${b}] = ${y}.value;
92
+ }
93
+
94
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const C=p.compile();return(S,y)=>C(g,S,y)};let o;const r=De,s=!pn.jitless,l=s&&es.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?Ln([],h,g,p,u,e):g):n(g,p):(g.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),g)}});function Mn(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=>!Ce(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=>be(r,a,fe())))}),t)}const qc=_("$ZodUnion",(e,t)=>{U.init(e,t),O(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),O(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),O(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),O(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=>ht(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=>Mn(c,i,e,o)):Mn(s,i,e,o)}}),jc=_("$ZodIntersection",(e,t)=>{U.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])=>Rn(n,c,l)):Rn(n,o,r)}});function yt(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(Ae(e)&&Ae(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=yt(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=yt(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 Rn(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}),Ce(e))return e;const r=yt(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 Fc=_("$ZodEnum",(e,t)=>{U.init(e,t);const n=un(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(i=>ts.has(typeof i)).map(i=>typeof i=="string"?ke(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}}),Zc=_("$ZodLiteral",(e,t)=>{if(U.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(a=>typeof a=="string"?ke(a):a?ke(a.toString()):String(a)).join("|")})$`),e._zod.parse=(a,i)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),a}}),Hc=_("$ZodTransform",(e,t)=>{U.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new gn(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 xe;return n.value=i,n}});function On(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Bn=_("$ZodOptional",(e,t)=>{U.init(e,t),e._zod.optin="optional",e._zod.optout="optional",O(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),O(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ht(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=>On(o,n.value)):On(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),Vc=_("$ZodExactOptional",(e,t)=>{Bn.init(e,t),O(e._zod,"values",()=>t.innerType._zod.values),O(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),Wc=_("$ZodNullable",(e,t)=>{U.init(e,t),O(e._zod,"optin",()=>t.innerType._zod.optin),O(e._zod,"optout",()=>t.innerType._zod.optout),O(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ht(n.source)}|null)$`):void 0}),O(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)}),Gc=_("$ZodDefault",(e,t)=>{U.init(e,t),e._zod.optin="optional",O(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=>$n(o,t)):$n(i,t)}});function $n(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Kc=_("$ZodPrefault",(e,t)=>{U.init(e,t),e._zod.optin="optional",O(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))}),Jc=_("$ZodNonOptional",(e,t)=>{U.init(e,t),O(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=>Dn(o,e)):Dn(i,e)}});function Dn(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 Yc=_("$ZodCatch",(e,t)=>{U.init(e,t),O(e._zod,"optin",()=>t.innerType._zod.optin),O(e._zod,"optout",()=>t.innerType._zod.optout),O(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=>be(r,a,fe()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>be(o,a,fe()))},input:n.value}),n.issues=[]),n)}}),Qc=_("$ZodPipe",(e,t)=>{U.init(e,t),O(e._zod,"values",()=>t.in._zod.values),O(e._zod,"optin",()=>t.in._zod.optin),O(e._zod,"optout",()=>t.out._zod.optout),O(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=>He(r,t.in,a)):He(o,t.in,a)}const i=t.in._zod.run(n,a);return i instanceof Promise?i.then(o=>He(o,t.out,a)):He(i,t.out,a)}});function He(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Xc=_("$ZodReadonly",(e,t)=>{U.init(e,t),O(e._zod,"propValues",()=>t.innerType._zod.propValues),O(e._zod,"values",()=>t.innerType._zod.values),O(e._zod,"optin",()=>t.innerType?._zod?.optin),O(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(Un):Un(i)}});function Un(e){return e.value=Object.freeze(e.value),e}const el=_("$ZodCustom",(e,t)=>{K.init(e,t),U.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=>qn(o,n,a,e));qn(i,n,a,e)}});function qn(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(Ne(i))}}var jn;class tl{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 nl(){return new tl}(jn=globalThis).__zod_globalRegistry??(jn.__zod_globalRegistry=nl());const Pe=globalThis.__zod_globalRegistry;function al(e,t){return new e({type:"string",...T(t)})}function il(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function Fn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function rl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function ll(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function dl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function gl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function pl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function ul(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function hl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function fl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function ml(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function bl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function _l(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function yl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function vl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function wl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function xl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function kl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function Cl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function El(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function Sl(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function Tl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function Il(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function Al(e,t){return new e({type:"number",checks:[],...T(t)})}function Nl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function Pl(e,t){return new e({type:"boolean",...T(t)})}function zl(e){return new e({type:"unknown"})}function Ll(e,t){return new e({type:"never",...T(t)})}function Zn(e,t){return new Tn({check:"less_than",...T(t),value:e,inclusive:!1})}function vt(e,t){return new Tn({check:"less_than",...T(t),value:e,inclusive:!0})}function Hn(e,t){return new In({check:"greater_than",...T(t),value:e,inclusive:!1})}function wt(e,t){return new In({check:"greater_than",...T(t),value:e,inclusive:!0})}function Vn(e,t){return new Ks({check:"multiple_of",...T(t),value:e})}function Wn(e,t){return new Ys({check:"max_length",...T(t),maximum:e})}function Ve(e,t){return new Qs({check:"min_length",...T(t),minimum:e})}function Gn(e,t){return new Xs({check:"length_equals",...T(t),length:e})}function Ml(e,t){return new ec({check:"string_format",format:"regex",...T(t),pattern:e})}function Rl(e){return new tc({check:"string_format",format:"lowercase",...T(e)})}function Ol(e){return new nc({check:"string_format",format:"uppercase",...T(e)})}function Bl(e,t){return new ac({check:"string_format",format:"includes",...T(t),includes:e})}function $l(e,t){return new ic({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Dl(e,t){return new oc({check:"string_format",format:"ends_with",...T(t),suffix:e})}function Ee(e){return new rc({check:"overwrite",tx:e})}function Ul(e){return Ee(t=>t.normalize(e))}function ql(){return Ee(e=>e.trim())}function jl(){return Ee(e=>e.toLowerCase())}function Fl(){return Ee(e=>e.toUpperCase())}function Zl(){return Ee(e=>Xr(e))}function Hl(e,t,n){return new e({type:"array",element:t,...T(n)})}function Vl(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}function Wl(e){const t=Gl(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ne(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(Ne(i))}},e(n.value,n)));return t}function Gl(e,t){const n=new K({check:"custom",...T(t)});return n._zod.check=e,n}function Kn(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 Z(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),Z(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 Jn(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
+
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 Yn(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 f in c)f==="$ref"||f==="allOf"||f in l||delete c[f];if(p.$ref&&g.def)for(const f in c)f==="$ref"||f==="allOf"||f in g.def&&JSON.stringify(c[f])===JSON.stringify(g.def[f])&&delete c[f]}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:We(t,"input",e.processors),output:We(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 Kl=(e,t={})=>n=>{const a=Kn({...n,processors:t});return Z(e,a),Jn(a,e),Yn(a,e)},We=(e,t,n={})=>a=>{const{libraryOptions:i,target:o}=a??{},r=Kn({...i??{},target:o,io:t,processors:n});return Z(e,r),Jn(r,e),Yn(r,e)},Jl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yl=(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=Jl[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}))])}},Ql=(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)},Xl=(e,t,n,a)=>{n.type="boolean"},ed=(e,t,n,a)=>{n.not={}},td=(e,t,n,a)=>{},nd=(e,t,n,a)=>{const i=e._zod.def,o=un(i.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},ad=(e,t,n,a)=>{const i=e._zod.def,o=[];for(const r of i.values)if(r===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof r=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(r))}else o.push(r);if(o.length!==0)if(o.length===1){const r=o[0];n.type=r===null?"null":typeof r,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[r]:n.const=r}else o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),o.every(r=>typeof r=="boolean")&&(n.type="boolean"),o.every(r=>r===null)&&(n.type="null"),n.enum=o},id=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},od=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},rd=(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=Z(o.element,t,{...a,path:[...a.path,"items"]})},sd=(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]=Z(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=Z(o.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},cd=(e,t,n,a)=>{const i=e._zod.def,o=i.inclusive===!1,r=i.options.map((s,c)=>Z(s,t,{...a,path:[...a.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},ld=(e,t,n,a)=>{const i=e._zod.def,o=Z(i.left,t,{...a,path:[...a.path,"allOf",0]}),r=Z(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},dd=(e,t,n,a)=>{const i=e._zod.def,o=Z(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"}]},gd=(e,t,n,a)=>{const i=e._zod.def;Z(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},pd=(e,t,n,a)=>{const i=e._zod.def;Z(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ud=(e,t,n,a)=>{const i=e._zod.def;Z(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)))},hd=(e,t,n,a)=>{const i=e._zod.def;Z(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},fd=(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;Z(o,t,a);const r=t.seen.get(e);r.ref=o},md=(e,t,n,a)=>{const i=e._zod.def;Z(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Qn=(e,t,n,a)=>{const i=e._zod.def;Z(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},bd=_("ZodISODateTime",(e,t)=>{vc.init(e,t),D.init(e,t)});function _d(e){return El(bd,e)}const yd=_("ZodISODate",(e,t)=>{wc.init(e,t),D.init(e,t)});function vd(e){return Sl(yd,e)}const wd=_("ZodISOTime",(e,t)=>{xc.init(e,t),D.init(e,t)});function xd(e){return Tl(wd,e)}const kd=_("ZodISODuration",(e,t)=>{kc.init(e,t),D.init(e,t)});function Cd(e){return Il(kd,e)}const J=_("ZodError",(e,t)=>{vn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ps(e,n)},flatten:{value:n=>gs(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,gt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,gt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ed=mt(J),Sd=bt(J),Td=qe(J),Id=je(J),Ad=fs(J),Nd=ms(J),Pd=bs(J),zd=_s(J),Ld=ys(J),Md=vs(J),Rd=ws(J),Od=xs(J),q=_("ZodType",(e,t)=>(U.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:We(e,"input"),output:We(e,"output")}}),e.toJSONSchema=Kl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(pe(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)=>ue(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Ed(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>Td(e,n,a),e.parseAsync=async(n,a)=>Sd(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>Id(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Ad(e,n,a),e.decode=(n,a)=>Nd(e,n,a),e.encodeAsync=async(n,a)=>Pd(e,n,a),e.decodeAsync=async(n,a)=>zd(e,n,a),e.safeEncode=(n,a)=>Ld(e,n,a),e.safeDecode=(n,a)=>Md(e,n,a),e.safeEncodeAsync=async(n,a)=>Rd(e,n,a),e.safeDecodeAsync=async(n,a)=>Od(e,n,a),e.refine=(n,a)=>e.check(Pg(n,a)),e.superRefine=n=>e.check(zg(n)),e.overwrite=n=>e.check(Ee(n)),e.optional=()=>ra(e),e.exactOptional=()=>_g(e),e.nullable=()=>sa(e),e.nullish=()=>ra(sa(e)),e.nonoptional=n=>Cg(e,n),e.array=()=>sg(e),e.or=n=>dg([e,n]),e.and=n=>pg(e,n),e.transform=n=>la(e,mg(n)),e.default=n=>wg(e,n),e.prefault=n=>kg(e,n),e.catch=n=>Sg(e,n),e.pipe=n=>la(e,n),e.readonly=()=>Ag(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)),Xn=_("_ZodString",(e,t)=>{_t.init(e,t),q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>Yl(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(Ml(...a)),e.includes=(...a)=>e.check(Bl(...a)),e.startsWith=(...a)=>e.check($l(...a)),e.endsWith=(...a)=>e.check(Dl(...a)),e.min=(...a)=>e.check(Ve(...a)),e.max=(...a)=>e.check(Wn(...a)),e.length=(...a)=>e.check(Gn(...a)),e.nonempty=(...a)=>e.check(Ve(1,...a)),e.lowercase=a=>e.check(Rl(a)),e.uppercase=a=>e.check(Ol(a)),e.trim=()=>e.check(ql()),e.normalize=(...a)=>e.check(Ul(...a)),e.toLowerCase=()=>e.check(jl()),e.toUpperCase=()=>e.check(Fl()),e.slugify=()=>e.check(Zl())}),Bd=_("ZodString",(e,t)=>{_t.init(e,t),Xn.init(e,t),e.email=n=>e.check(il($d,n)),e.url=n=>e.check(ll(Dd,n)),e.jwt=n=>e.check(Cl(eg,n)),e.emoji=n=>e.check(dl(Ud,n)),e.guid=n=>e.check(Fn(ea,n)),e.uuid=n=>e.check(ol(Ge,n)),e.uuidv4=n=>e.check(rl(Ge,n)),e.uuidv6=n=>e.check(sl(Ge,n)),e.uuidv7=n=>e.check(cl(Ge,n)),e.nanoid=n=>e.check(gl(qd,n)),e.guid=n=>e.check(Fn(ea,n)),e.cuid=n=>e.check(pl(jd,n)),e.cuid2=n=>e.check(ul(Fd,n)),e.ulid=n=>e.check(hl(Zd,n)),e.base64=n=>e.check(wl(Yd,n)),e.base64url=n=>e.check(xl(Qd,n)),e.xid=n=>e.check(fl(Hd,n)),e.ksuid=n=>e.check(ml(Vd,n)),e.ipv4=n=>e.check(bl(Wd,n)),e.ipv6=n=>e.check(_l(Gd,n)),e.cidrv4=n=>e.check(yl(Kd,n)),e.cidrv6=n=>e.check(vl(Jd,n)),e.e164=n=>e.check(kl(Xd,n)),e.datetime=n=>e.check(_d(n)),e.date=n=>e.check(vd(n)),e.time=n=>e.check(xd(n)),e.duration=n=>e.check(Cd(n))});function te(e){return al(Bd,e)}const D=_("ZodStringFormat",(e,t)=>{$.init(e,t),Xn.init(e,t)}),$d=_("ZodEmail",(e,t)=>{gc.init(e,t),D.init(e,t)}),ea=_("ZodGUID",(e,t)=>{lc.init(e,t),D.init(e,t)}),Ge=_("ZodUUID",(e,t)=>{dc.init(e,t),D.init(e,t)}),Dd=_("ZodURL",(e,t)=>{pc.init(e,t),D.init(e,t)}),Ud=_("ZodEmoji",(e,t)=>{uc.init(e,t),D.init(e,t)}),qd=_("ZodNanoID",(e,t)=>{hc.init(e,t),D.init(e,t)}),jd=_("ZodCUID",(e,t)=>{fc.init(e,t),D.init(e,t)}),Fd=_("ZodCUID2",(e,t)=>{mc.init(e,t),D.init(e,t)}),Zd=_("ZodULID",(e,t)=>{bc.init(e,t),D.init(e,t)}),Hd=_("ZodXID",(e,t)=>{_c.init(e,t),D.init(e,t)}),Vd=_("ZodKSUID",(e,t)=>{yc.init(e,t),D.init(e,t)}),Wd=_("ZodIPv4",(e,t)=>{Cc.init(e,t),D.init(e,t)}),Gd=_("ZodIPv6",(e,t)=>{Ec.init(e,t),D.init(e,t)}),Kd=_("ZodCIDRv4",(e,t)=>{Sc.init(e,t),D.init(e,t)}),Jd=_("ZodCIDRv6",(e,t)=>{Tc.init(e,t),D.init(e,t)}),Yd=_("ZodBase64",(e,t)=>{Ic.init(e,t),D.init(e,t)}),Qd=_("ZodBase64URL",(e,t)=>{Nc.init(e,t),D.init(e,t)}),Xd=_("ZodE164",(e,t)=>{Pc.init(e,t),D.init(e,t)}),eg=_("ZodJWT",(e,t)=>{Lc.init(e,t),D.init(e,t)}),ta=_("ZodNumber",(e,t)=>{Nn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>Ql(e,a,i),e.gt=(a,i)=>e.check(Hn(a,i)),e.gte=(a,i)=>e.check(wt(a,i)),e.min=(a,i)=>e.check(wt(a,i)),e.lt=(a,i)=>e.check(Zn(a,i)),e.lte=(a,i)=>e.check(vt(a,i)),e.max=(a,i)=>e.check(vt(a,i)),e.int=a=>e.check(aa(a)),e.safe=a=>e.check(aa(a)),e.positive=a=>e.check(Hn(0,a)),e.nonnegative=a=>e.check(wt(0,a)),e.negative=a=>e.check(Zn(0,a)),e.nonpositive=a=>e.check(vt(0,a)),e.multipleOf=(a,i)=>e.check(Vn(a,i)),e.step=(a,i)=>e.check(Vn(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 na(e){return Al(ta,e)}const tg=_("ZodNumberFormat",(e,t)=>{Mc.init(e,t),ta.init(e,t)});function aa(e){return Nl(tg,e)}const ng=_("ZodBoolean",(e,t)=>{Rc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Xl(e,n,a)});function _e(e){return Pl(ng,e)}const ag=_("ZodUnknown",(e,t)=>{Oc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>td()});function ia(){return zl(ag)}const ig=_("ZodNever",(e,t)=>{Bc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>ed(e,n,a)});function og(e){return Ll(ig,e)}const rg=_("ZodArray",(e,t)=>{$c.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>rd(e,n,a,i),e.element=t.element,e.min=(n,a)=>e.check(Ve(n,a)),e.nonempty=n=>e.check(Ve(1,n)),e.max=(n,a)=>e.check(Wn(n,a)),e.length=(n,a)=>e.check(Gn(n,a)),e.unwrap=()=>e.element});function sg(e,t){return Hl(rg,e,t)}const cg=_("ZodObject",(e,t)=>{Uc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>sd(e,n,a,i),O(e,"shape",()=>t.shape),e.keyof=()=>kt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ia()}),e.loose=()=>e.clone({...e._zod.def,catchall:ia()}),e.strict=()=>e.clone({...e._zod.def,catchall:og()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>rs(e,n),e.safeExtend=n=>ss(e,n),e.merge=n=>cs(e,n),e.pick=n=>is(e,n),e.omit=n=>os(e,n),e.partial=(...n)=>ls(oa,e,n[0]),e.required=(...n)=>ds(ca,e,n[0])});function se(e,t){const n={type:"object",shape:e??{},...T(t)};return new cg(n)}const lg=_("ZodUnion",(e,t)=>{qc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>cd(e,n,a,i),e.options=t.options});function dg(e,t){return new lg({type:"union",options:e,...T(t)})}const gg=_("ZodIntersection",(e,t)=>{jc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>ld(e,n,a,i)});function pg(e,t){return new gg({type:"intersection",left:e,right:t})}const xt=_("ZodEnum",(e,t)=>{Fc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>nd(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 xt({...t,checks:[],...T(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 xt({...t,checks:[],...T(i),entries:o})}});function kt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new xt({type:"enum",entries:n,...T(t)})}const ug=_("ZodLiteral",(e,t)=>{Zc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>ad(e,n,a),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function hg(e,t){return new ug({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}const fg=_("ZodTransform",(e,t)=>{Hc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>od(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new gn(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ne(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(Ne(r))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function mg(e){return new fg({type:"transform",transform:e})}const oa=_("ZodOptional",(e,t)=>{Bn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Qn(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function ra(e){return new oa({type:"optional",innerType:e})}const bg=_("ZodExactOptional",(e,t)=>{Vc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Qn(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function _g(e){return new bg({type:"optional",innerType:e})}const yg=_("ZodNullable",(e,t)=>{Wc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>dd(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function sa(e){return new yg({type:"nullable",innerType:e})}const vg=_("ZodDefault",(e,t)=>{Gc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>pd(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wg(e,t){return new vg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():bn(t)}})}const xg=_("ZodPrefault",(e,t)=>{Kc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>ud(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function kg(e,t){return new xg({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():bn(t)}})}const ca=_("ZodNonOptional",(e,t)=>{Jc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>gd(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Cg(e,t){return new ca({type:"nonoptional",innerType:e,...T(t)})}const Eg=_("ZodCatch",(e,t)=>{Yc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>hd(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Sg(e,t){return new Eg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Tg=_("ZodPipe",(e,t)=>{Qc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>fd(e,n,a,i),e.in=t.in,e.out=t.out});function la(e,t){return new Tg({type:"pipe",in:e,out:t})}const Ig=_("ZodReadonly",(e,t)=>{Xc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>md(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Ag(e){return new Ig({type:"readonly",innerType:e})}const Ng=_("ZodCustom",(e,t)=>{el.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>id(e,n)});function Pg(e,t={}){return Vl(Ng,e,t)}function zg(e){return Wl(e)}function Lg(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function ze(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}class Mg extends nt{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=ot,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=Ur,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=Po(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 Ao(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:()=>{Wr(),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 Pr({onChange:g=>this._panel?.notifyExtension(g),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new zr({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 Ar;await g.open(),this._session=new nn(g),await this._restoreFromIndexedDB(d)}catch{this._session=new nn(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 di({namespace:"chat",onMessage:g=>this._handleBridgeMessage(g)}),this._activityTracker=new Lo({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 Oo({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&&ze(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=[],H("gengage:chat:ready",{}),dt("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"),H("gengage:chat:open",{state:this._openState}),$e("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"),H("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=ze(a)?a:ze(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}),ze(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 i=zo(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 _o({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&&ze(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=wi(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;H("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}Kr(),this._messages.some(o=>o.role==="user")||Jr();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 b=this._currentThreadId,A=this._messages.filter(v=>v.threadId!==void 0&&v.threadId>b);this._messages=this._messages.filter(v=>!v.threadId||v.threadId<=b);for(const v of A)this._shadow?.querySelector(`[data-message-id="${CSS.escape(v.id)}"]`)?.remove(),this._panel.snapshots.delete(v.id),this._panel.snapshotTypes.delete(v.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(v=>{v instanceof HTMLElement&&v.dataset.threadId&&v.dataset.threadId>b&&v.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=li();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 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)}if(!n?.silent&&this._hasUnavailableProductContext()&&(t.type==="user_message"||t.type==="inputText")){const b=this._i18n.productNotFoundMessage,A=this._createMessage("assistant",b);A.threadId=a,A.status="done",this._messages.push(A),this._ensureAssistantMessageRendered(A),this._drawer?.updateBotMessage(A.id,b),this._bridge?.send("isResponding",!1),this.emit("message",A),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(b=>b.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(b=>b.content).slice(-50).map(b=>({role:b.role==="user"?"user":"model",content:b.content??""})),g={outputLanguage:Dr(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:on(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=uo(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 f=crypto.randomUUID(),m=Date.now();let w=0,C=!1,S=!1;this.track(Qe(this.analyticsContext(),{endpoint:"process_action",request_id:f,widget:"chat"}));let y=null;y=bo(h,{onTextChunk:(b,A,N)=>{if(!i&&a!==this._activeRequestThreadId||(s+=b,this._drawer?.removeTypingIndicator(),N?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...N.skuToProductItem}),N?.conversationMode&&(this._conversationMode=N.conversationMode),this.track(Da(this.analyticsContext(),{request_id:f,chunk_index:w++,widget:"chat"})),!this._drawer))return;let v=s;if(A&&lt(v)){const E=this.config.accountId;if(!on(E)){const x=Br(v);x&&this._drawer?.showKvkkBanner(x,()=>{this._drawer?.hideKvkkBanner()}),Rr(E)}v=Or(v)}const k=this._shadow?.querySelector(`[data-message-id="${c.id}"] .gengage-chat-bubble-text`);if(k?k.innerHTML=Q(v):(c.content=v,c.role==="assistant"&&c.threadId&&!this._threadsWithFirstBot.has(c.threadId)&&(this._threadsWithFirstBot.add(c.threadId),this._drawer.markFirstBotMessage(c.id)),this._drawer.addMessage(c)),A){c.content=v,c.status="done",dn();const E=this._shadow?.querySelector(`[data-message-id="${c.id}"] .gengage-chat-bubble-text`);if(E){this._activeTypewriter?.cancel();const x=N?.productMentions;this._activeTypewriter=vr({container:E,html:Q(v),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,x&&x.length>0&&E&&wr({container:E,mentions:x,onProductClick:L=>{this._sendAction({title:x.find(I=>I.sku===L)?.short_name??L,type:"launchSingleProduct",payload:{sku:L}})}})}})}}},onUISpec:(b,A,N)=>{if(!i&&a!==this._activeRequestThreadId||A!=="chat")return;const v=b.elements[b.root],k=v?.type??"unknown";this.track(Ua(this.analyticsContext(),{request_id:f,chunk_index:w,component_type:k,widget:"chat"}));const E=this._buildRenderContext();if(k==="ComparisonTable"){const I=v?.props?.products;Hr(Array.isArray(I)?I.length:0)}if(k==="ProductGrid"){const I=v?.children?.length??0;Gr(void 0,I)}const x=N==="panel"&&this._panel?this._panel.toPanelSpec(b):b,L=!c.silent&&(N!=="panel"||k==="ProductCard")&&k!=="ActionButtons";if(N==="panel"&&this._panel){S=!0,v?.props?.similarsAppend===!0&&this._panel.currentType==="ProductDetailsPanel"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._appendSimilarsToPanel(x,E):k==="ProductGrid"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._drawer.appendPanelContent(this._renderUISpec(x,E)):(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._drawer?.setPanelContent(this._renderUISpec(x,E)),this._panel.currentType=k),k==="ProductDetailsPanel"&&t.type==="launchSingleProduct"&&this._clearUnavailableProductContext(),c.threadId&&!this._panel.threads.includes(c.threadId)&&this._panel.threads.push(c.threadId);const I=this._panel.currentType??k,P=v?.props?.panelTitle;this._panel.updateTopBar(I,P),this._panel.updateExtendedMode(k)}if(k==="ProductDetailsPanel"&&!c.silent&&N==="panel"){const I=v?.props?.product;if(I){const P={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:I}}}},M=this._shadow?.querySelector(".gengage-chat-messages");if(M){const z=this._renderUISpec(P,E);c.threadId&&(z.dataset.threadId=c.threadId),M.appendChild(z),z.scrollIntoView({behavior:"auto",block:"end"})}}}if(L){const I=this._shadow?.querySelector(".gengage-chat-messages");if(I){const P=this._renderUISpec(b,E);c.threadId&&(P.dataset.threadId=c.threadId),I.appendChild(P),P.scrollIntoView({behavior:"auto",block:"end"})}}if((k==="ProductGrid"||k==="ProductCard")&&c.threadId){const I=v?.children??[],P=k==="ProductGrid"?I.map(M=>b.elements[M]?.props?.product).filter(Boolean):[v?.props?.product].filter(Boolean);for(const M of P){const z=M.sku,R=M.imageUrl;z&&R&&this._thumbnailEntries.push({sku:z,imageUrl:R,threadId:c.threadId})}this._drawer?.setThumbnails(this._thumbnailEntries)}if(k==="ProductGrid"||k==="ProductDetailsPanel"){const P=(k==="ProductGrid"?(v?.children??[]).map(M=>b.elements[M]?.props?.product).filter(Boolean):[v?.props?.product??v?.props].filter(Boolean)).map(M=>M.imageUrl).filter(M=>typeof M=="string").slice(0,5);P.length>0&&this._bridge?.send("previewImages",{images:P})}if(k==="ProductGrid"&&N==="panel"&&!this._comparisonSelectMode&&!Sr()){this._choicePrompterEl?.remove(),this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach(z=>z.remove()),this._choicePrompterEl=Er({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 P=this._isMobileViewport||this._drawer?.isPanelCollapsed()?".gengage-chat-conversation":".gengage-chat-panel",M=this._shadow?.querySelector(P);M?M.appendChild(this._choicePrompterEl):this._choicePrompterEl=null}if(k==="ActionButtons"){const I=v?.props?.buttons;if(I&&I.length>0){const P=[],M=[];for(const z of I)if(Cr(z)){const R={label:z.label,action:z.action};z.icon&&(R.icon=z.icon),P.push(R)}else M.push(z);P.length>0&&this._drawer?.setInputAreaChips(P.map(z=>({label:z.label,onAction:()=>this._sendAction(z.action),...z.icon?{icon:z.icon}:{}}))),M.length>0&&this._drawer?.setPills(M.map(z=>{const R={label:z.label,onAction:()=>this._sendAction(z.action)};return z.icon&&(R.icon=z.icon),z.image&&(R.image=z.image),z.description&&(R.description=z.description),R}))}}c.uiSpec=b},onAction:b=>{if(!(!i&&a!==this._activeRequestThreadId)&&b.type==="action"){const A={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(A.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(A.allowScriptCall=this.config.actionHandling.allowScriptCall),ui(b,{openChat:()=>this.open(),navigate:N=>{this._bridge?.send("navigate",N),N.newTab?window.open(N.url,"_blank","noopener,noreferrer"):window.location.href=N.url},saveSession:N=>this.saveSession(N.sessionId,N.sku),addToCart:N=>{H("gengage:similar:add-to-cart",N)},scriptCall:N=>{H("gengage:chat:script-call",N),this.config.onScriptCall?.(N)}},A)}},onMetadata:b=>{if(!(!i&&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){C=!0,S=!1;const N=typeof b.meta.panelPendingType=="string"?b.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(N),N&&this._panel?.updateTopBarForLoading(N)}if(b.meta.voice){const N=new CustomEvent("gengage:chat:voice",{detail:{payload:b.meta.voice},bubbles:!1,cancelable:!0}),v=window.dispatchEvent(N);if(Yr(),v){const k=b.meta.voice;k.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=Ro(k.audio_base64,k.content_type??"audio/ogg"))}}(b.meta.redirectTarget||b.meta.redirect)&&H("gengage:chat:redirect",{target:b.meta.redirectTarget??null,payload:b.meta.redirect??null}),b.meta.analyzeAnimation&&(C=!0,S=!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),H("gengage:chat:metadata",{payload:b.meta});const A=b.meta;typeof A.prompt_tokens=="number"&&typeof A.completion_tokens=="number"&&this.track(qa(this.analyticsContext(),{model:b.model??"unknown",prompt_tokens:A.prompt_tokens,completion_tokens:A.completion_tokens,total_tokens:A.total_tokens??A.prompt_tokens+A.completion_tokens}))}},onError:b=>{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 A=S;if(C&&!S&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),C=!1,S=!1,!(c.silent||c.content!=null&&c.content.length>0||s.length>0||A))if(o||this._hasUnavailableProductContext()){const v=this._i18n.productNotFoundMessage;c.content=v,c.status="done",this._ensureAssistantMessageRendered(c),this._drawer?.updateBotMessage(c.id,v),this._markUnavailableProductContext()}else this.emit("error",b),this._drawer?.showError(this._i18n.errorMessage);o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),c.status==="streaming"&&(c.status="error"),this.track(Xe(this.analyticsContext(),{request_id:f,error_code:"STREAM_ERROR",error_message:b.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(),C&&!S&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),C=!1,S=!1,o&&!s&&!S){const b=this._i18n.productNotFoundMessage;c.content=b,this._ensureAssistantMessageRendered(c),this._drawer?.updateBotMessage(c.id,b),this._markUnavailableProductContext()}o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),c.status==="streaming"&&(c.status="done",dn()),this.emit("message",c),this._panel?.snapshotForMessage(c.id),this._panel?.attachClickHandler(c.id),this.track(Le(this.analyticsContext(),{request_id:f,latency_ms:Date.now()-m,chunk_count:w,widget:"chat"})),this.track(ja(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(Za(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=Q(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=[],Zr())):this._comparisonSelectedSkus.indexOf(t)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],Fr(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",()=>{sn(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(rn(n.title,n.type),n.type==="findSimilar"){const i=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";jr(i)}n.type==="getComparisonTable"&&sn(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{cn(n.sku),this.config.isDemoWebsite!==!0&&this._isSameOriginUrl(n.url)?(H("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=>{ln(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};H("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)=>{Vr(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{...wo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=or();return Ye(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),i=this.config.renderer?.unknownRenderer??Jt,o=(c,l)=>rr(c,l,a,i),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:i,defaultRender:o}):o(t,n)}}async function Rg(e,t,n){const a=Te("launcher_action",t),i={uiSpecs:[],actions:[]},o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(o.signal=n);const r=await fetch(a,o);if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);const s={onEvent:c=>{const l=Oe(c);if(l&&(l.type==="ui_spec"&&i.uiSpecs.push(l.spec),l.type==="ui_spec"&&l.spec.elements)){for(const d of Object.values(l.spec.elements))if(d.type==="ActionButton"&&d.props?.action){const u=d.props.action;i.actions.push(u)}}}};return n!==void 0&&(s.signal=n),await Re(r,s),i}function da(e){const t=document.createElement("div");t.className="gengage-qna-buttons",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const a=document.createElement("button");a.className="gengage-qna-button",a.textContent=n.title,a.type="button",a.addEventListener("click",()=>{const i={title:n.title,type:n.type};n.payload!==void 0&&(i.payload=n.payload),e.onAction(i)}),t.appendChild(a)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Başka bir şey sor",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function Og(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper";const n=document.createElement("input");n.type="text",n.className="gengage-qna-input",n.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const a=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Bir soru sorun..."];let i=0;n.placeholder=a[0]??"";let o=null,r=null;a.length>1&&(o=setInterval(()=>{n.classList.add("gengage-qna-input--fade"),r=setTimeout(()=>{i=(i+1)%a.length,n.placeholder=a[i]??"",n.classList.remove("gengage-qna-input--fade")},180)},3e3));const s=document.createElement("button");s.className="gengage-qna-send",s.type="button",s.textContent=e.ctaLabel??e.sendButtonText??"Sor",s.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question");const c=()=>{const l=n.value.trim();l&&(e.onSubmit({title:l,type:"user_message",payload:l}),n.value="")};return s.addEventListener("click",c),n.addEventListener("keydown",l=>{l.key==="Enter"&&(l.preventDefault(),c())}),t.appendChild(n),t.appendChild(s),t._cleanup=()=>{o&&clearInterval(o),r&&clearTimeout(r)},t}function Ke(e,t){if(!e||typeof e!="object")return null;const n=e,a=n.type;if(typeof a!="string"||a.length===0)return null;const i=n.title,o=n.payload,r=typeof i=="string"&&i.length>0?i:t;if(!r)return null;const s={title:r,type:a};return o!==void 0&&(s.payload=o),s}function ga(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function pa(e,t){const n=[],a=e.props?.actions;if(Array.isArray(a))for(const r of a){const s=Ke(r);s&&n.push(s)}const i=e.props?.buttons;if(Array.isArray(i))for(const r of i){if(!r||typeof r!="object")continue;const s=r,c=typeof s.label=="string"?s.label:void 0,l=Ke(s.action,c);l&&n.push(l)}if(e.children)for(const r of e.children){const s=t.elements[r];if(!s||s.type!=="ActionButton")continue;const c=typeof s.props?.label=="string"?s.props.label:void 0,l=Ke(s.props?.action,c);l&&n.push(l)}const o=new Set;return n.filter(r=>o.has(r.title)?!1:(o.add(r.title),!0))}const ua={ButtonRow:({element:e,spec:t,context:n})=>{const a=pa(e,t).map(ga),i=e.props?.orientation,o={actions:a,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(o.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(o.ctaText=n.ctaText),(i==="horizontal"||i==="vertical")&&(o.orientation=i),da(o)},ActionButtons:({element:e,spec:t,context:n})=>{const i={actions:pa(e,t).map(ga),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),da(i)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button",n.type="button";const a=e.props?.label;typeof a=="string"?n.textContent=a:n.textContent=t.i18n.defaultCtaText;const i=Ke(e.props?.action,typeof a=="string"?a:void 0);return i&&n.addEventListener("click",()=>t.onAction(i)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,a=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,i=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,o={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return a!==void 0&&(o.placeholders=a),i!==void 0&&(o.ctaLabel=i),Og(o)},QuestionHeading:({element:e})=>{const t=document.createElement("h3");t.className="gengage-qna-heading";const n=e.props?.text;return t.textContent=typeof n=="string"?n:"",t},ProductCard:()=>null},ha=({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 Bg(){return{...ua}}function $g(e,t,n=ua,a=ha){return Je({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:a})}const fa={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},Dg={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function Ug(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function qg(e){return Ug(e)==="en"?Dg:fa}class jg extends nt{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=fa,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(t){this._i18n=this._resolveI18n(t),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const n=t.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),this.isVisible=!0,dt("qna")}onUpdate(t){const n=t.sku;!n||n===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=n,this._fetchAndRender(n)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_cleanupTextInputTimers(){if(!this._contentEl)return;const t=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const n of t)n._cleanup?.()}async _fetchAndRender(t){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const n=this._createLoadingIndicator();this._contentEl.appendChild(n);const a={middlewareUrl:this.config.middlewareUrl},i=crypto.randomUUID(),o=Date.now();this.track(Qe(this.analyticsContext(),{endpoint:"launcher_action",request_id:i,widget:"qna"}));try{const r={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:t,locale:this.config.locale??"tr"},s=this.config.pageContext?.pageType;s!==void 0&&(r.page_type=s);const c=await Rg(r,a,this._abortController.signal);if(this.track(Le(this.analyticsContext(),{request_id:i,latency_ms:Date.now()-o,chunk_count:c.actions.length,widget:"qna"})),this.track(et(this.analyticsContext(),{message_count:c.actions.length,history_ref:i,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(c.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const w=document.createElement("h3");w.className="gengage-qna-heading",w.textContent=this.config.staticQuestionText,this._contentEl.appendChild(w)}const d=this.config.inputPlaceholder,u=c.actions.length>0&&d===!0?c.actions.map(w=>w.title):d===!0?this._i18n.defaultInputPlaceholder:d??this._i18n.defaultInputPlaceholder,g={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler};this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText),u!==void 0&&(g.inputPlaceholder=u);const p=this._buildFallbackActionsSpec(c.actions),f=(c.uiSpecs.length>0?c.uiSpecs:[p]).filter(w=>Object.keys(w.elements).length>0);for(const w of f){const C=this._renderUISpec(w,g);this._contentEl.appendChild(C)}f.length>0&&$e("qna"),!this._specIncludesType(f,"TextInput")&&this._appendStandaloneInput(g,u)}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;if(H("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:zt(this.config.locale)}),this.track(Xe(this.analyticsContext(),{request_id:i,error_code:"FETCH_ERROR",error_message:r instanceof Error?r.message:String(r),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const s=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,c={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler};this.config.ctaText!==void 0&&(c.ctaText=this.config.ctaText),this._appendStandaloneInput(c,s)}}}_createLoadingIndicator(){const t=document.createElement("div");t.className="gengage-qna-loading";for(let n=0;n<3;n++){const a=document.createElement("div");a.className="gengage-qna-loading-dot",t.appendChild(a)}return t}_resolveI18n(t){return{...qg(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Bg();return Ye(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),i=this.config.renderer?.unknownRenderer??ha,o=(c,l)=>$g(c,l,a,i),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:i,defaultRender:o}):o(t,n)}_specIncludesType(t,n){for(const a of t)for(const i of Object.values(a.elements))if(i.type===n)return!0;return!1}_buildFallbackActionsSpec(t){if(t.length===0)return{root:"root",elements:{}};const n={},a=[];for(let i=0;i<t.length;i++){const o=t[i],r=`action-${i}`;a.push(r),n[r]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return n.root={type:"ButtonRow",children:a},{root:"root",elements:n}}_appendStandaloneInput(t,n){if(!this._contentEl)return;const a={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},i=this._renderUISpec(a,t);this._contentEl.appendChild(i)}_handleAction(t){rn(t.title,t.type),this.config.onActionSelected?.(t),H("gengage:qna:action",t)}_handleOpenChat(){const t=this._contentEl?.querySelector(".gengage-qna-input");t&&t.focus(),this.config.onOpenChat?.(),H("gengage:qna:open-chat",{})}}function ma(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function Fg(e,t){const n=[],a={onEvent:i=>{const o=Oe(i);if(!(!o||o.type!=="ui_spec")){for(const r of Object.values(o.spec.elements))if(r.type==="ProductCard"&&r.props){const s=r.props.product??r.props;typeof s.sku=="string"&&typeof s.name=="string"&&n.push(s)}}}};return t!==void 0&&(a.signal=t),await Re(e,a),n}async function Zg(e,t,n){const a=Te("similar_products",t),i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const o=await fetch(a,i);if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);if(ma(o))return Fg(o,n);const r=await o.text();if(!r)return[];try{return co(JSON.parse(r))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function Hg(e,t){const n=[];let a=null;const i={onEvent:o=>{const r=Oe(o);if(r){if(r.type==="metadata"&&r.meta){const s=r.meta.group_name;if(typeof s=="string"){a={name:s,products:[]};const c=r.meta.highlight;typeof c=="string"&&(a.highlight=c),n.push(a)}}if(r.type==="ui_spec"&&a){for(const s of Object.values(r.spec.elements))if(s.type==="ProductCard"&&s.props){const c=s.props.product??s.props;typeof c.sku=="string"&&typeof c.name=="string"&&a.products.push(c)}}}}};return t!==void 0&&(i.signal=t),await Re(e,i),n}async function Vg(e,t,n){const a=Te("product_groupings",t),i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const o=await fetch(a,i);if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);if(ma(o))return Hg(o,n);const r=await o.text();if(!r)return[];try{return lo(JSON.parse(r))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}function ba(e){const{product:t,index:n,discountType:a,onClick:i,onAddToCart:o,renderCard:r}=e,s=e.i18n,c=e.pricing;if(r){const f=document.createElement("div");return f.className="gengage-simrel-card gengage-simrel-card--custom",f.innerHTML=Q(r(t,n)),f.addEventListener("click",m=>{m.target.closest(".gengage-simrel-atc")||m.target.closest(".gengage-chat-product-card-atc")||i(t)}),f}const l=document.createElement("article");l.className="gengage-simrel-card gengage-chat-product-card",l.setAttribute("role","listitem"),l.dataset.sku=t.sku;const d=document.createElement("div");if(d.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",t.imageUrl&&ne(t.imageUrl)){const f=document.createElement("img");f.className="gengage-chat-product-card-img",f.src=t.imageUrl,f.alt=t.name,f.loading="lazy",de(f),d.appendChild(f)}if(a==="badge"&&t.discountPercent&&t.discountPercent>0){const f=document.createElement("span");f.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",f.textContent=`%${Be(t.discountPercent)}`,d.appendChild(f)}l.appendChild(d);const u=document.createElement("div");if(u.className="gengage-simrel-card-info gengage-chat-product-card-body",t.brand){const f=document.createElement("div");f.className="gengage-simrel-card-brand gengage-chat-product-card-brand",f.textContent=t.brand,u.appendChild(f)}const g=document.createElement("div");if(g.className="gengage-simrel-card-name gengage-chat-product-card-name",g.textContent=t.name,u.appendChild(g),t.rating!=null&&t.rating>0){const f=document.createElement("div");if(f.className="gengage-simrel-card-rating gengage-chat-product-card-rating",f.textContent=st(t.rating),t.reviewCount!=null){const m=document.createElement("span");m.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",m.textContent=` (${t.reviewCount})`,f.appendChild(m)}u.appendChild(f)}const p=document.createElement("div");if(p.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(a==="strike-through"||!a)){const f=document.createElement("span");f.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",f.textContent=V(t.originalPrice,c),p.appendChild(f)}if(t.price){const f=document.createElement("span");f.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",f.textContent=V(t.price,c),p.appendChild(f)}u.appendChild(p),l.appendChild(u);const h=document.createElement("button");if(h.className="gengage-simrel-card-cta gengage-chat-product-card-cta",h.type="button",h.textContent="İncele",h.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),i(t)}),l.appendChild(h),t.cartCode&&t.inStock!==!1){const f=t.cartCode,m=ct({compact:!0,label:s?.addToCartButton??"Sepete Ekle",onSubmit:w=>{o({sku:t.sku,quantity:w,cartCode:f})}});m.classList.add("gengage-simrel-atc","gengage-chat-product-card-atc"),l.appendChild(m)}return l.addEventListener("click",f=>{f.target.closest(".gengage-simrel-atc")||f.target.closest(".gengage-chat-product-card-atc")||f.target.closest(".gengage-chat-product-card-cta")||i(t)}),l}function _a(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let n=0;n<e.products.length;n++){const i={product:e.products[n],index:n,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(i.i18n=e.i18n),e.discountType!==void 0&&(i.discountType=e.discountType),e.renderCard!==void 0&&(i.renderCard=e.renderCard);const o=ba(i);t.appendChild(o)}if(e.products.length===0){const n=document.createElement("div");n.className="gengage-simrel-empty",n.textContent=e.i18n?.emptyStateMessage??"Benzer ürün bulunamadı.",t.appendChild(n)}return t}let Wg=0;function Gg(e){const t=Wg++,n=document.createElement("div");if(n.className="gengage-simrel-groups",e.groups.length===0){const d=document.createElement("div");return d.className="gengage-simrel-empty",d.textContent=e.i18n?.emptyStateMessage??"Benzer ürün bulunamadı.",n.appendChild(d),n}const a=document.createElement("div");a.className="gengage-simrel-tabs",a.setAttribute("role","tablist");const i=[],o=[],r=d=>{const u={products:d.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(u.i18n=e.i18n),e.discountType!==void 0&&(u.discountType=e.discountType),e.renderCard!==void 0&&(u.renderCard=e.renderCard),u},s=d=>{for(let h=0;h<i.length;h++){const f=h===d;i[h].classList.toggle("gengage-simrel-tab--active",f),i[h].setAttribute("aria-selected",String(f)),i[h].tabIndex=f?0:-1}const u=e.groups[d],g=o[d];g.innerHTML="";const p=_a(r(u));g.appendChild(p);for(let h=0;h<o.length;h++){const f=h===d;o[h].style.display=f?"":"none",o[h].tabIndex=f?0:-1}};for(let d=0;d<e.groups.length;d++){const u=e.groups[d],g=`gengage-simrel-tab-${t}-${d}`,p=`gengage-simrel-panel-${t}-${d}`,h=document.createElement("button");h.className="gengage-simrel-tab",h.type="button",h.id=g,h.textContent=u.name,h.setAttribute("role","tab"),h.setAttribute("aria-controls",p),h.setAttribute("aria-selected",String(d===0)),h.tabIndex=d===0?0:-1,d===0&&h.classList.add("gengage-simrel-tab--active"),h.addEventListener("click",()=>s(d)),h.addEventListener("keydown",m=>{let w=-1;m.key==="ArrowRight"||m.key==="ArrowDown"?w=(d+1)%e.groups.length:m.key==="ArrowLeft"||m.key==="ArrowUp"?w=(d-1+e.groups.length)%e.groups.length:m.key==="Home"?w=0:m.key==="End"&&(w=e.groups.length-1),w>=0&&(m.preventDefault(),s(w),i[w].focus())}),i.push(h),a.appendChild(h);const f=document.createElement("div");f.className="gengage-simrel-tab-panel",f.id=p,f.setAttribute("role","tabpanel"),f.setAttribute("aria-labelledby",g),f.tabIndex=d===0?0:-1,d!==0&&(f.style.display="none"),o.push(f)}n.appendChild(a);const c=o[0],l=_a(r(e.groups[0]));c.appendChild(l);for(const d of o)n.appendChild(d);return n}function ya(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const n={sku:t.sku,name:t.name,url:t.url},a=t.imageUrl;typeof a=="string"&&(n.imageUrl=a);const i=t.price;typeof i=="string"&&(n.price=i);const o=t.originalPrice;typeof o=="string"&&(n.originalPrice=o);const r=t.discountPercent;typeof r=="number"&&(n.discountPercent=r);const s=t.brand;typeof s=="string"&&(n.brand=s);const c=t.rating;typeof c=="number"&&(n.rating=c);const l=t.reviewCount;typeof l=="number"&&(n.reviewCount=l);const d=t.cartCode;typeof d=="string"&&(n.cartCode=d);const u=t.inStock;return typeof u=="boolean"&&(n.inStock=u),n}function Kg(e){if(!e||typeof e!="object")return null;const t=e,n=t.title,a=t.type;if(typeof n!="string"||typeof a!="string")return null;const i={title:n,type:a};return t.payload!==void 0&&(i.payload=t.payload),i}const va={ProductGrid:({element:e,renderElement:t,context:n})=>{const a=document.createElement("div");a.className="gengage-simrel-grid",a.setAttribute("role","list");const i=e.props?.columns;typeof i=="number"&&Number.isFinite(i)&&i>0&&a.style.setProperty("--gengage-simrel-columns",String(i));for(const o of e.children??[]){const r=t(o);r&&a.appendChild(r)}if(a.children.length===0){const o=document.createElement("div");o.className="gengage-simrel-empty",o.textContent=n.i18n.emptyStateMessage,a.appendChild(o)}return a},ProductCard:({element:e,context:t})=>{const n=e.props?.product??e.props,a=ya(n);if(!a)return null;const i=e.props?.index,o=typeof i=="number"&&Number.isFinite(i)?i:0,r=e.props?.discountType,s=r==="strike-through"||r==="badge"?r:t.discountType,c={product:a,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return s!==void 0&&(c.discountType=s),t.renderCard!==void 0&&(c.renderCard=t.renderCard),t.pricing!==void 0&&(c.pricing=t.pricing),ba(c)},GroupTabs:({element:e,context:t})=>{const n=e.props?.groups;if(!Array.isArray(n))return null;const a=[];for(const o of n){if(!o||typeof o!="object")continue;const r=o;if(typeof r.name!="string")continue;const s=[];if(Array.isArray(r.products))for(const l of r.products){const d=ya(l);d&&s.push(d)}const c={name:r.name,products:s};typeof r.highlight=="string"&&(c.highlight=r.highlight),a.push(c)}const i={groups:a,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return t.discountType!==void 0&&(i.discountType=t.discountType),t.renderCard!==void 0&&(i.renderCard=t.renderCard),Gg(i)},EmptyState:({element:e,context:t})=>{const n=document.createElement("div");n.className="gengage-simrel-empty";const a=e.props?.message;return n.textContent=typeof a=="string"?a:t.i18n.emptyStateMessage,n},AddToCartButton:({element:e,context:t})=>{const n=e.props?.sku,a=e.props?.cartCode;if(typeof n!="string"||typeof a!="string")return null;const i=document.createElement("button");i.className="gengage-simrel-atc gengage-chat-product-card-cta",i.type="button";const o=e.props?.label;return i.textContent=typeof o=="string"?o:t.i18n.addToCartButton,i.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),t.onAddToCart({sku:n,quantity:1,cartCode:a})}),i},QuickActions:({element:e,context:t})=>{const n=document.createElement("div");n.className="gengage-simrel-quick-actions";const a=e.props?.actions;if(!Array.isArray(a)||!t.onAction)return n;for(const i of a){if(!i||typeof i!="object")continue;const o=i,r=o.label,s=Kg(o.action);if(typeof r!="string"||!s)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=r,c.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),t.onAction?.(s)}),n.appendChild(c)}return n}},wa=({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 Jg(){return{...va}}function Yg(e,t,n=va,a=wa){return Je({spec:e,context:t,registry:n,containerClassName:"gengage-simrel-uispec",unknownRenderer:a})}const xa={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",priceSuffix:" TL"},Qg={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",priceSuffix:""};function Xg(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function ep(e){return Xg(e)==="en"?Qg:xa}class tp extends nt{constructor(){super(...arguments),this._abortController=null,this._contentEl=null,this._i18n=xa}async onInit(t){this._i18n=this._resolveI18n(t),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this.root.appendChild(this._contentEl),this._lastSku=t.sku,await this._fetchAndRender(t.sku),this.isVisible=!0,dt("simrel")}onUpdate(t){const n=t.sku;!n||n===this._lastSku||(this._lastSku=n,this._fetchAndRender(n))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(t){const n={sku:t.sku,name:t.name,url:t.url};if(t.imageUrl!==void 0&&(n.imageUrl=t.imageUrl),t.price!==void 0&&(n.price=t.price),t.originalPrice!==void 0&&(n.originalPrice=t.originalPrice),t.discountPercent!==void 0&&(n.discountPercent=t.discountPercent),t.brand!==void 0&&(n.brand=t.brand),t.rating!==void 0&&(n.rating=t.rating),t.reviewCount!==void 0&&(n.reviewCount=t.reviewCount),t.cartCode!==void 0&&(n.cartCode=t.cartCode),t.inStock!==void 0&&(n.inStock=t.inStock),this.config.onProductClick?.(n)===!1)return;cn(t.sku,t.name);const a=this.config.session?.sessionId??null;H("gengage:similar:product-click",{sku:t.sku,url:t.url,sessionId:a}),this.config.onProductNavigate?.(t.url,t.sku,a)}_handleAddToCart(t){ln(t.sku,t.quantity),this.config.onAddToCart?.(t),H("gengage:similar:add-to-cart",t),this.track(Ha(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:"TRY",line_items:t.quantity,sku:t.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}async _fetchAndRender(t){this._abort(),this._abortController=new AbortController;const n=this._abortController.signal;if(!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const a=document.createElement("div");a.className="gengage-simrel-loading";const i=document.createElement("div");i.className="gengage-simrel-spinner",a.appendChild(i),this._contentEl.appendChild(a);const o={middlewareUrl:this.config.middlewareUrl},r=crypto.randomUUID(),s=Date.now();this.track(Qe(this.analyticsContext(),{endpoint:"similar_products",request_id:r,widget:"simrel"}));try{const c={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:t};this.config.domain!==void 0&&(c.domain=this.config.domain);const l=await Zg(c,o,n);if(!this._contentEl)return;if(this._contentEl.innerHTML="",l.length>0)try{const d=l.map(g=>g.sku),u=await Vg({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:d},o,n);if(u.length>0&&this._contentEl){const g=this._buildGroupsSpec(u),p=this._renderUISpec(g);this._contentEl.appendChild(p),$e("simrel"),this.track(Le(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-s,chunk_count:u.reduce((h,f)=>h+f.products.length,0),widget:"simrel"})),this.track(et(this.analyticsContext(),{message_count:u.reduce((h,f)=>h+f.products.length,0),history_ref:r,redaction_level:"none",widget:"simrel"}));return}}catch{}if(this._contentEl){const d=this._buildProductsSpec(l),u=this._renderUISpec(d);this._contentEl.appendChild(u)}l.length>0&&$e("simrel"),this.track(Le(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-s,chunk_count:l.length,widget:"simrel"})),this.track(et(this.analyticsContext(),{message_count:l.length,history_ref:r,redaction_level:"none",widget:"simrel"}))}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;H("gengage:global:error",{source:"simrel",code:"FETCH_ERROR",message:zt(this.config.locale)}),this.track(Xe(this.analyticsContext(),{request_id:r,error_code:"FETCH_ERROR",error_message:c instanceof Error?c.message:String(c),widget:"simrel"})),this._contentEl&&(this._contentEl.innerHTML="",this._contentEl.style.display="none")}}_resolveI18n(t){return{...ep(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Jg();return Ye(t,this.config.renderer?.registry)}_buildRenderContext(){const t=this.config.renderCard,n={onClick:a=>this._handleProductClick(a),onAddToCart:a=>this._handleAddToCart(a),i18n:this._i18n};return this.config.discountType!==void 0&&(n.discountType=this.config.discountType),t!==void 0&&(n.renderCard=t),this.config.pricing!==void 0&&(n.pricing=this.config.pricing),n}_renderUISpec(t){const n=this._resolveUISpecRegistry(),a=this._buildRenderContext(),i=this.config.renderer?.unknownRenderer??wa,o=(c,l)=>Yg(c,l,n,i),r=this.config.renderer?.renderUISpec;return r?r(t,a,{registry:n,unknownRenderer:i,defaultRender:o}):o(t,a)}_buildProductsSpec(t){const n={},a=[];for(let i=0;i<t.length;i++){const o=t[i],r=`product-${i}`;a.push(r),n[r]={type:"ProductCard",props:{product:o,index:i,discountType:this.config.discountType}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{root:"root",elements:n}}_buildGroupsSpec(t){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:t}}}}}}const Ct=se({enabled:_e().default(!0)}),np=se({chat:te().optional(),qna:te().optional(),simrel:te().optional()}),ap=se({}),ip=kt(["none","x-api-key-header","bearer-header","body-api-key"]),op=se({mode:ip.default("none"),key:te().optional(),headerName:te().optional(),bodyField:te().default("api_key")}),rp=se({enabled:_e().default(!0),endpoint:te().default("/analytics"),auth:op.default({mode:"none",bodyField:"api_key"}),fireAndForget:_e().default(!0),useBeacon:_e().default(!0),keepaliveFetch:_e().default(!0),timeoutMs:na().int().positive().default(4e3),maxRetries:na().int().min(0).max(5).default(1)}),ka="__gengageWidgetsInit",sp=se({idempotencyKey:te().default(ka),requireDomReady:_e().default(!0)}),cp=kt(["log-and-ignore","throw","delegate"]),lp=se({unknownActionPolicy:cp.default("log-and-ignore"),allowScriptCall:_e().default(!1)});se({version:hg("1"),accountId:te().min(1),middlewareUrl:te().url(),locale:te().optional(),widgets:se({chat:Ct.default({enabled:!0}),qna:Ct.default({enabled:!0}),simrel:Ct.default({enabled:!0})}),mounts:np.default({}),transport:ap.default({}),analytics:rp.default({enabled:!0,endpoint:"/analytics",auth:{mode:"none",bodyField:"api_key"},fireAndForget:!0,useBeacon:!0,keepaliveFetch:!0,timeoutMs:4e3,maxRetries:1}),gtm:sp.default({idempotencyKey:"__gengageWidgetsInit",requireDomReady:!0}),actionHandling:lp.default({unknownActionPolicy:"log-and-ignore",allowScriptCall:!1})});const dp=`${ka}_overlay_`,gp="#gengage-qna",pp="#gengage-simrel";function Ca(){const e=window;return e.__gengageOverlayRegistry||(e.__gengageOverlayRegistry={instances:{},pending:{}}),e.__gengageOverlayRegistry}function up(e){const t={pageType:e.pageContext?.pageType??(e.sku!==void 0?"pdp":"other")},n=e.pageContext;return n?.sku!==void 0&&(t.sku=n.sku),n?.price!==void 0&&(t.price=n.price),n?.categoryTree!==void 0&&(t.categoryTree=n.categoryTree),n?.url!==void 0&&(t.url=n.url),n?.extra!==void 0&&(t.extra=n.extra),e.sku!==void 0&&(t.sku=e.sku),t}function hp(e,t){const n={...e,...t,pageType:t.pageType??e.pageType};return t.sku===void 0&&e.sku!==void 0&&(n.sku=e.sku),n}function Ea(e){return e instanceof HTMLElement||document.querySelector(e)?e:null}function Sa(e){return e.idempotencyKey??`${dp}${e.accountId}`}class fp{constructor(t,n){this.options=t,this.onDestroy=n,this._chat=null,this._qna=null,this._simrel=null,this._analyticsClient=null,this._offQnaWire=null,this._destroyed=!1,this._queue=Promise.resolve(),this._warnedQnaMountMissing=!1,this._warnedSimRelMountMissing=!1,this.idempotencyKey=Sa(t),this.session=It(t.session),this._pageContext=up(t)}get chat(){return this._chat}get qna(){return this._qna}get simrel(){return this._simrel}get analyticsClient(){return this._analyticsClient}async init(){window.gengage||(window.gengage={}),window.gengage.sessionId=this.session.sessionId,window.gengage.pageContext=this._pageContext,await this._initChat(),this.options.wireQnaToChat!==!1&&(this._offQnaWire=Ka()),await this._syncPdpWidgets(),window.gengage.overlay=this}openChat(t){this._chat?.open(t)}closeChat(){this._chat?.close()}async updateContext(t){this._destroyed||await this._enqueue(async()=>{this._pageContext=hp(this._pageContext,t),window.gengage||(window.gengage={}),window.gengage.pageContext=this._pageContext,this._chat?.update(t),this._qna?.update(t),this._simrel?.update(t),await this._syncPdpWidgets()})}async updateSku(t,n="pdp"){await this.updateContext({sku:t,pageType:n})}destroy(){this._destroyed||(this._destroyed=!0,this._offQnaWire?.(),this._offQnaWire=null,this._chat?.destroy(),this._qna?.destroy(),this._simrel?.destroy(),this._chat=null,this._qna=null,this._simrel=null,window.gengage?.overlay===this&&delete window.gengage.overlay,this.onDestroy())}async _initChat(){if(this.options.chat?.enabled===!1)return;const t=this.options.middlewareUrl,n={accountId:this.options.accountId,middlewareUrl:t,session:this.session,pageContext:this._pageContext,variant:this.options.chat?.variant??"floating"};this.options.theme!==void 0&&(n.theme=this.options.theme),this.options.locale!==void 0&&(n.locale=this.options.locale),this.options.pricing!==void 0&&(n.pricing=this.options.pricing),this.options.chat?.mountTarget!==void 0&&(n.mountTarget=this.options.chat.mountTarget),this.options.chat?.launcherSvg!==void 0&&(n.launcherSvg=this.options.chat.launcherSvg),this.options.chat?.headerTitle!==void 0&&(n.headerTitle=this.options.chat.headerTitle),this.options.chat?.headerAvatarUrl!==void 0&&(n.headerAvatarUrl=this.options.chat.headerAvatarUrl),this.options.chat?.headerBadge!==void 0&&(n.headerBadge=this.options.chat.headerBadge),this.options.chat?.headerCartUrl!==void 0&&(n.headerCartUrl=this.options.chat.headerCartUrl),this.options.chat?.headerFavoritesToggle!==void 0&&(n.headerFavoritesToggle=this.options.chat.headerFavoritesToggle),this.options.chat?.hideMobileLauncher!==void 0&&(n.hideMobileLauncher=this.options.chat.hideMobileLauncher),this.options.chat?.mobileBreakpoint!==void 0&&(n.mobileBreakpoint=this.options.chat.mobileBreakpoint),this.options.chat?.mobileInitialState!==void 0&&(n.mobileInitialState=this.options.chat.mobileInitialState),this.options.chat?.i18n!==void 0&&(n.i18n=this.options.chat.i18n),this.options.chat?.actionHandling!==void 0&&(n.actionHandling=this.options.chat.actionHandling),this.options.onScriptCall!==void 0&&(n.onScriptCall=this.options.onScriptCall),this._chat=new Mg,await this._chat.init(n)}async _syncPdpWidgets(){if(this._destroyed)return;const t=this._pageContext.sku;if(!(this._pageContext.pageType==="pdp"&&t!==void 0&&t.length>0)){this._destroyPdpWidgets();return}const a=this.options.middlewareUrl;if(this.options.qna?.enabled!==!1){const i=this.options.qna?.mountTarget??gp,o=Ea(i);if(o)if(this._warnedQnaMountMissing=!1,this._qna)this._qna.show(),this._qna.update({pageType:"pdp",sku:t});else{const r=new jg,s={accountId:this.options.accountId,middlewareUrl:a,session:this.session,pageContext:{pageType:"pdp",sku:t},mountTarget:o};this.options.theme!==void 0&&(s.theme=this.options.theme),this.options.qna?.ctaText!==void 0&&(s.ctaText=this.options.qna.ctaText),this.options.qna?.inputPlaceholder!==void 0&&(s.inputPlaceholder=this.options.qna.inputPlaceholder),await r.init(s),this._qna=r}else this._qna?.destroy(),this._qna=null,this._warnedQnaMountMissing||(console.warn(`[gengage] QNA mount target not found: ${i}`),this._warnedQnaMountMissing=!0)}else this._qna?.destroy(),this._qna=null;if(this.options.simrel?.enabled!==!1){const i=this.options.simrel?.mountTarget??pp,o=Ea(i);if(o)if(this._warnedSimRelMountMissing=!1,this._simrel)this._simrel.show(),this._simrel.update({pageType:"pdp",sku:t});else{const r=new tp,s={accountId:this.options.accountId,middlewareUrl:a,session:this.session,sku:t,mountTarget:o};this.options.theme!==void 0&&(s.theme=this.options.theme),this.options.pricing!==void 0&&(s.pricing=this.options.pricing),this.options.simrel?.discountType!==void 0&&(s.discountType=this.options.simrel.discountType),this.options.onAddToCart!==void 0&&(s.onAddToCart=this.options.onAddToCart),this.options.onProductNavigate!==void 0?s.onProductNavigate=this.options.onProductNavigate:s.onProductNavigate=(c,l,d)=>{this._chat?.saveSession(d??this.session.sessionId,l),window.location.href=c},await r.init(s),this._simrel=r}else this._simrel?.destroy(),this._simrel=null,this._warnedSimRelMountMissing||(console.warn(`[gengage] SimRel mount target not found: ${i}`),this._warnedSimRelMountMissing=!0)}else this._simrel?.destroy(),this._simrel=null}_destroyPdpWidgets(){this._qna?.destroy(),this._simrel?.destroy(),this._qna=null,this._simrel=null}_enqueue(t){const n=this._queue.then(t);return this._queue=n.catch(a=>{}),n}}async function mp(e){const t=Sa(e),n=Ca(),a=n.instances[t];if(a)return a;const i=n.pending[t];if(i)return i;const o=new fp(e,()=>{const s=Ca();delete s.instances[t],delete s.pending[t]}),r=o.init().then(()=>(n.instances[t]=o,delete n.pending[t],o)).catch(s=>{throw delete n.pending[t],s});return n.pending[t]=r,r}const Ta=["gengage:chat:open","gengage:chat:close","gengage:chat:ready","gengage:chat:add-to-cart","gengage:qna:action","gengage:qna:open-chat","gengage:similar:product-click","gengage:similar:add-to-cart","gengage:global:error","gengage:context:update"],bp=32,Ia="#gengage-qna",Aa="#gengage-simrel";function xp(e){return e}function _p(e){let t=e;if(typeof e=="string"){const o=e.trim();if(o.length===0)return null;if(!o.startsWith("{")&&!o.startsWith("["))return{type:o};try{t=JSON.parse(o)}catch{return null}}if(!t||typeof t!="object")return null;const n=t,a=[n.type,n.command,n.action,n.event].find(o=>typeof o=="string"&&o.length>0);if(!a)return null;let i=n.payload;if(i===void 0&&"data"in n&&(i=n.data),a==="setSession"&&i===void 0){const o={};typeof n.sessionId=="string"&&(o.sessionId=n.sessionId),typeof n.userId=="string"&&(o.userId=n.userId),(o.sessionId!==void 0||o.userId!==void 0)&&(i=o)}return i===void 0?{type:a}:{type:a,payload:i}}function yp(e){if(typeof e=="string"&&e.length>0)return{sku:e};if(e&&typeof e=="object"&&"sku"in e){const t=e.sku;if(typeof t=="string"&&t.length>0){const n=e.pageType;return n!==void 0?{sku:t,pageType:n}:{sku:t}}}return null}function Et(e,t){return t instanceof HTMLElement?!0:typeof t!="string"?!1:e.document.querySelector(t)!==null}function Na(e,t,n){if(t instanceof HTMLElement||Et(e,t)||typeof t!="string")return t;if(t.startsWith("#")){const o=t.slice(1);if(o.length>0){const r=e.document.getElementById(o);if(r)return r;const s=e.document.createElement("div");return s.id=o,e.document.body.appendChild(s),s}}const a=e.document.getElementById(n);if(a)return a;const i=e.document.createElement("div");return i.id=n,e.document.body.appendChild(i),i}function Pa(e,t){const n=e.webkit?.messageHandlers?.[t];return n&&typeof n.postMessage=="function"?n.postMessage.bind(n):null}function za(e,t){const n=e[t];return n&&typeof n=="object"&&typeof n.postMessage=="function"?n:null}function La(e,t){return za(e,t)}function Ma(e,t){return za(e,t)}function Ra(e={}){const t=e.win??window,n=e.iosHandlerName??"gengage",a=e.androidInterfaceName??"GengageNative",i=e.reactNativeInterfaceName??"ReactNativeWebView";return Pa(t,n)?"ios":La(t,a)?"android":Ma(t,i)?"react-native":"browser"}function Oa(e,t={}){const n=t.win??window;if(e.sessionId!==void 0){n.__gengageSessionId=e.sessionId,n.gengage||(n.gengage={}),n.gengage.sessionId=e.sessionId;try{n.sessionStorage.setItem("gengage_session_id",e.sessionId)}catch{}}if(e.userId!==void 0){n.gengage||(n.gengage={});const a=n.gengage,i=a.session??{};i.userId=e.userId,a.session=i}}function Ba(e={}){const t=e.win??window,n=t;if(n.gengageNative)return n.gengageNative;const a=e.iosHandlerName??"gengage",i=e.androidInterfaceName??"GengageNative",o=e.reactNativeInterfaceName??"ReactNativeWebView",r=e.trackedEvents??[...Ta],s=Ra({win:t,iosHandlerName:a,androidInterfaceName:i,reactNativeInterfaceName:o});let c=t.gengage?.overlay??null;const l=[],d=(w,C)=>{const S=C===void 0?{type:w}:{type:w,payload:C};if(s==="ios"){Pa(t,a)?.(S);return}if(s==="android"){La(t,i)?.postMessage(JSON.stringify(S));return}if(s==="react-native"){Ma(t,o)?.postMessage(JSON.stringify(S));return}},u=w=>{const C=w.detail;!C||typeof C.namespace!="string"||typeof C.type!="string"||d("bridge_message",{namespace:C.namespace,type:C.type,payload:C.payload})};t.addEventListener("gengage:bridge:message",u);const g=r.map(w=>{const C=S=>{const y=S.detail;d("widget_event",{event:w,detail:y})};return t.addEventListener(w,C),{event:w,handler:C}}),p=w=>{l.length>=bp&&l.shift(),l.push(w)},h=()=>{if(!c||l.length===0)return;const w=l.splice(0,l.length);for(const C of w)f(C)},f=w=>{const C=_p(w);if(!C||typeof C.type!="string"){console.warn("[gengage:native-bridge] Invalid message:",w);return}const S=C.type,y=C.payload;switch(S){case"openChat":{c?c.openChat(y&&typeof y=="object"?y:y==="half"||y==="full"?{state:y}:void 0):p(C);return}case"closeChat":{c?c.closeChat():p(C);return}case"updateContext":{c&&y&&typeof y=="object"?c.updateContext(y):c?console.warn("[gengage:native-bridge] updateContext: missing payload"):p(C);return}case"updateSku":{const b=yp(y);if(c&&b){c.updateSku(b.sku,b.pageType);return}c?console.warn("[gengage:native-bridge] updateSku: missing sku"):p(C);return}case"setSession":{y&&typeof y=="object"&&Oa(y,{win:t});return}case"destroy":{c?.destroy();return}default:t.postMessage({gengage:"native",type:S,payload:y},t.location.origin),e.logUnhandled&&console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:",S)}},m={env:s,sendToNative:d,receive:f,setController(w){c=w,h()},destroy(){t.removeEventListener("gengage:bridge:message",u);for(const w of g)t.removeEventListener(w.event,w.handler);l.splice(0,l.length),t.gengageNative===m&&delete t.gengageNative}};return n.gengageNative=m,m}async function vp(e){const{nativeBridge:t,emitReadyEvent:n=!0,...a}=e,i=Ba(t),o={...a};o.onAddToCart||(o.onAddToCart=l=>{i.sendToNative("addToCart",{sku:l.sku,quantity:l.quantity,cartCode:l.cartCode})}),o.onProductNavigate||(o.onProductNavigate=(l,d,u)=>{i.sendToNative("productNavigate",{url:l,sku:d,sessionId:u})});const r=o.qna?.enabled===!0||o.qna?.mountTarget!==void 0;if(o.qna?.enabled!==!1)if(r){const l=Na(window,o.qna?.mountTarget??Ia,"gengage-qna");o.qna={...o.qna,enabled:!0,mountTarget:l}}else Et(window,Ia)||(o.qna={enabled:!1});const s=o.simrel?.enabled===!0||o.simrel?.mountTarget!==void 0;if(o.simrel?.enabled!==!1)if(s){const l=Na(window,o.simrel?.mountTarget??Aa,"gengage-simrel");o.simrel={...o.simrel,enabled:!0,mountTarget:l}}else Et(window,Aa)||(o.simrel={enabled:!1});const c=await mp(o);return i.setController(c),n&&i.sendToNative("ready",{sessionId:c.session.sessionId,widgets:{chat:c.chat!==null,qna:c.qna!==null,simrel:c.simrel!==null}}),{controller:c,bridge:i,destroy(){c.destroy(),i.destroy()}}}ye.DEFAULT_NATIVE_TRACKED_EVENTS=Ta,ye.applyNativeSession=Oa,ye.createNativeWebViewBridge=Ba,ye.detectNativeEnvironment=Ra,ye.initNativeOverlayWidgets=vp,Object.defineProperty(ye,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
97
+ //# sourceMappingURL=native.iife.js.map