@gengage/assistant-fe 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat.iife.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(fe){"use strict";const Jn=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const o=t(a);o&&n.appendChild(o)}return n};function Yn(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Jn,o=r=>{const s=e.spec.elements[r];if(!s)return null;const c=e.registry[s.type];return c?c({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:o}):a({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:o})},i=o(e.spec.root);return i&&t.appendChild(i),t}function Xn(e,t){if(!t)return e;const n={...e};for(const[a,o]of Object.entries(t))o&&(n[a]=o);return n}function Qn(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 ea(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 ta(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 na(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 aa(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 oa(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 ia(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 ra(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 sa(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 ca(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 la(e,t){const n={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ee(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function bt(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function da(){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 ga(e){return{sessionId:e?.sessionId??da(),...e}}const _t={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"14px","--gengage-simrel-card-radius":"14px"};function pa(e){return e?{..._t,...e}:{..._t}}const se="gengage-global-toast-root",vt="gengage-global-toast-style",Ge="gengage-global-toast-root--visible",ua=4200,ha=1500,fa=15e3;let yt=!1,me=null;function ma(){yt||typeof window>"u"||typeof document>"u"||(yt=!0,bt("gengage:global:error",e=>{ba(e)}))}function ba(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;xa();const n=ya();n.innerHTML="";const a=document.createElement("section");a.className="gengage-global-toast gengage-global-toast--error",a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=va(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,a.appendChild(o),a.appendChild(i),n.appendChild(a),n.classList.add(Ge),me&&(clearTimeout(me),me=null),me=setTimeout(()=>{_a()},wa(e.durationMs))}function _a(){if(typeof document>"u")return;const e=document.getElementById(se);e&&(e.classList.remove(Ge),e.innerHTML="",me&&(clearTimeout(me),me=null))}function va(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function ya(){const e=document.getElementById(se);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=se,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function wa(e){return typeof e!="number"||!Number.isFinite(e)?ua:Math.min(fa,Math.max(ha,Math.round(e)))}function xa(){if(document.getElementById(vt))return;const e=document.createElement("style");e.id=vt,e.textContent=`
1
+ (function(fe){"use strict";const Yn=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const o=t(a);o&&n.appendChild(o)}return n};function Xn(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Yn,o=r=>{const s=e.spec.elements[r];if(!s)return null;const c=e.registry[s.type];return c?c({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:o}):a({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:o})},i=o(e.spec.root);return i&&t.appendChild(i),t}function Qn(e,t){if(!t)return e;const n={...e};for(const[a,o]of Object.entries(t))o&&(n[a]=o);return n}function ea(e,t){const n={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ta(e,t){const n={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(n.latency_ms=t.latency_ms);const a={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function na(e,t){const n={event_name:"stream.ui_spec",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,chunk_index:t.chunk_index,component_type:t.component_type}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function aa(e,t){const n={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function oa(e,t){const n={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ia(e,t){const n={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(n.provider=t.provider);const a={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ra(e,t){const n={event_name:"metering.increment",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function sa(e,t){const n={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ca(e,t){const n={event_name:"chat.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function la(e,t){const n={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function da(e,t){const n={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ee(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function bt(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function ga(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function pa(e){return{sessionId:e?.sessionId??ga(),...e}}const _t={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"14px","--gengage-simrel-card-radius":"14px"};function ua(e){return e?{..._t,...e}:{..._t}}const se="gengage-global-toast-root",vt="gengage-global-toast-style",Ge="gengage-global-toast-root--visible",ha=4200,fa=1500,ma=15e3;let yt=!1,me=null;function ba(){yt||typeof window>"u"||typeof document>"u"||(yt=!0,bt("gengage:global:error",e=>{_a(e)}))}function _a(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;ka();const n=wa();n.innerHTML="";const a=document.createElement("section");a.className="gengage-global-toast gengage-global-toast--error",a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const o=document.createElement("div");o.className="gengage-global-toast-title",o.textContent=ya(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,a.appendChild(o),a.appendChild(i),n.appendChild(a),n.classList.add(Ge),me&&(clearTimeout(me),me=null),me=setTimeout(()=>{va()},xa(e.durationMs))}function va(){if(typeof document>"u")return;const e=document.getElementById(se);e&&(e.classList.remove(Ge),e.innerHTML="",me&&(clearTimeout(me),me=null))}function ya(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function wa(){const e=document.getElementById(se);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=se,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function xa(e){return typeof e!="number"||!Number.isFinite(e)?ha:Math.min(ma,Math.max(fa,Math.round(e)))}function ka(){if(document.getElementById(vt))return;const e=document.createElement("style");e.id=vt,e.textContent=`
2
2
  #${se} {
3
3
  position: fixed;
4
4
  top: 16px;
@@ -43,8 +43,8 @@
43
43
  transform: translateY(0);
44
44
  }
45
45
  }
46
- `,document.head.appendChild(e)}class ka{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=pa(t.theme);this.config={...t,theme:n,session:ga(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ma();const a=bt("gengage:context:update",o=>this.update(o));this._cleanups.push(a);try{await this.onInit(this.config)}catch(o){throw this.destroy(),o}this.isInitialised=!0,this.emit("ready")}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const a=t==="start"?ca:la;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(ra(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(a=>a(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,a]of Object.entries(t))if(a!==void 0){const o=n.startsWith("--")?n:`--gengage-${Ca(n)}`;this.root.style.setProperty(o,a)}}}}function Ca(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ea(){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 Sa{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(!Ta(n)||n.gengage!==this._namespace)return;const a={type:n.type};n.payload!==void 0&&(a.payload=n.payload),this._onMessage?.(a);const o=this._handlers.get(a.type);if(o)for(const i of o)i(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}function Ta(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const Ia=console;function za(e,t,n={}){const a=e.action,o=n.logger??Ia;switch(a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){ye(a,t,n,o);return}const i=typeof a.newTab=="boolean"?a.newTab:void 0;if(t.navigate){i!==void 0?t.navigate({url:a.url,newTab:i}):t.navigate({url:a.url});return}Aa(a.url,i);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){ye(a,t,n,o);return}t.saveSession?.({sessionId:a.sessionId,sku:a.sku});return}case"add_to_cart":{if(typeof a.sku!="string"||typeof a.quantity!="number"||typeof a.cartCode!="string"){ye(a,t,n,o);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){ye(a,t,n,o);return}if(typeof a.name!="string"){ye(a,t,n,o);return}const i=Na(a.payload)?a.payload:void 0;i!==void 0?t.scriptCall?.({name:a.name,payload:i}):t.scriptCall?.({name:a.name});return}default:ye(a,t,n,o)}}function ye(e,t,n,a){const o=n.unknownActionPolicy??"log-and-ignore";if(o==="delegate"){t.unknown?.(e),t.unknown||a.warn("[gengage] Unknown action received without delegate handler",e);return}if(o==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);a.warn("[gengage] Unknown action ignored",e)}function Aa(e,t){if(!(typeof window>"u")){if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function Na(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Pa=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"]),La=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta"]),wt={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function Ma(e){return/^\s*javascript\s*:/i.test(e)}function We(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,a=n.tagName.toLowerCase();if(La.has(a)){n.parentNode?.removeChild(n);return}if(!Pa.has(a)){const c=Array.from(n.childNodes);for(const l of c)t.insertBefore(l,n);t.removeChild(n);for(const l of c)We(l,t);return}const o=wt["*"]??new Set,i=wt[a]??new Set,r=Array.from(n.attributes);for(const c of r){const l=c.name.toLowerCase();if(!o.has(l)&&!i.has(l)){n.removeAttribute(c.name);continue}if(Ma(c.value)){n.removeAttribute(c.name);continue}}if(a==="a"){const c=n.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(a==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const s=Array.from(n.childNodes);for(const c of s)We(c,n)}const xt=["http:","https:"];function re(e){try{return xt.includes(new URL(e).protocol)}catch{return!1}}function oe(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return xt.includes(t.protocol)}catch{return!1}}function H(e,t,n){(t==="href"||t==="src")&&!oe(n)||e.setAttribute(t,n)}function we(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const o of a)We(o,n);return n.innerHTML}const $a=["image/jpeg","image/png","image/webp"],Oa=5*1024*1024;function Da(e){return $a.includes(e.type)?e.size>Oa?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function kt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Ba(e){const t=[];let n=0,a=!1,o=!1,i=0;for(let r=0;r<e.length;r++){const s=e[r];if(o){o=!1;continue}if(s==="\\"&&a){o=!0;continue}if(s==='"'){a=!a;continue}a||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(i,r+1)),i=r+1)))}return t.length>0?t:[e]}function Ct(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const a=n.startsWith("data: ")?n.slice(6):n;if(a==="[DONE]")return!0;try{const o=JSON.parse(a);return kt(o)?(t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Ba(a);if(o.length>1){for(const i of o)try{const r=JSON.parse(i);if(!kt(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Ra(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),a=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,r=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let l;const d=await(i>0?Promise.race([c.then(m=>(clearTimeout(l),m)),new Promise(m=>{l=setTimeout(()=>m(r),i)})]):c);if(d===r){s=!0,await n.cancel();break}const{done:p,value:u}=d;if(p)break;o+=a.decode(u,{stream:!0});const g=o.split(`
47
- `);o=g.pop()??"";for(const m of g)if(Ct(m,t))return}if(o.trim()&&Ct(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}function Za(e){if(typeof e.type!="string")return null;if(Ua(e))return e;const n=e;switch(n.type){case"outputText":return ja(n);case"suggestedActions":return Fa(n);case"productList":return qa(n);case"productDetails":return Ha(n);case"productDetailsSimilars":return Va(n);case"comparisonTable":return Ga(n);case"context":return Wa(n);case"chatStreamEnd":return Ka();case"loading":return Ja(n);case"panelLoading":return Ya(n);case"similarLoading":return Xa(n);case"redirect":return Qa(n);case"error":return eo(n);case"dummy":return to();case"launcherAction":return no(n);case"text":return Ke(n);case"productItem":return ao(n);case"text_image":return Et(n);case"quick_qna":return St(n);case"reviewHighlights":return oo(n);case"aiProductSuggestions":return so(n);case"aiProductGroupings":return co(n);case"aiSuggestedSearches":return lo(n);case"prosAndCons":return io(n);case"getGroundingReview":return go(n);case"voice":return uo(n);case"visitorDataResponse":return ro(n);case"productListPreview":return po();case"groupList":return ho(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return fo(n);case"launcherContent":return bo(n);case"handoff":return mo(n);default:return null}}function Ua(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const a=be(e.spec);return a?typeof a.root=="string"&&be(a.elements)!==null:!1}case"action":{const n=be(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function ja(e){const t=O(e.payload.text,e.payload.plain_text)??"",n=O(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const a={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(a.productMentions=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.sku=="string"&&typeof s.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(a.skuToProductItem=i);const r=e.payload.conversation_mode;return typeof r=="string"&&r&&(a.conversationMode=r),a}function Fa(e){const t=(e.payload.actions??[]).map(n=>{const a=O(n.title)??"",o=ce(n.requestDetails,a),i=o?{label:a,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Tt(t.filter(zt),"chat")}function qa(e){const t=It(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list})),t}function Ha(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:xe(t)}}}},panelHint:"panel"}:vo("chat")}function Va(e){const t=It(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Ga(e){const t=e.payload.multiple_product_details??[],n=e.payload.product_comparison_framework,a=e.payload.table,o=[];for(const m of t){const _=xe(m);o.push(_)}const i=[];if(a){const m=n?.criteria_view??n?.criteria_view_short??{},_=n?.compared_field_names??Object.keys(a);for(const y of _){const z=a[y];if(!z||!Array.isArray(z))continue;const I=m[y]??y;i.push({label:I,values:z.map(h=>typeof h=="string"?h:String(h??""))})}}let r;n?.recommended_choice_sku?r=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(r=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const s=r?o.find(m=>m.sku===r)??o[0]:o[0],c=[];if(Array.isArray(n?.key_differences))for(const m of n.key_differences)typeof m=="string"&&c.push(m);const l=[];if(n?.special_considerations)for(const m of n.special_considerations)typeof m=="string"&&l.push(m);const d=n?.recommended_choice,p=n?.winner_hits,u={};for(const m of o){const _=m.sku;_&&(u[_]={title:m.name??_,type:"launchSingleProduct",payload:{sku:_}})}const g={products:o,attributes:i,highlights:c,productActions:u};return s&&(g.recommended=s),l.length>0&&(g.specialCases=l),d&&(g.recommendedText=d),p&&(g.winnerHits=p),typeof n?.key_differences=="string"&&(g.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(g.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:g}}},panelHint:"panel"}}function Wa(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Ka(){return{type:"done"}}function Ja(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 Ya(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Xa(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Qa(e){const t=O(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:O(e.payload.to)}}}function eo(e){return{type:"error",code:"BACKEND_ERROR",message:O(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function to(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function no(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const i={action_list:t.action_list},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(i.type=r),s!==void 0&&(i.theme=s),St({payload:i})}const a=be(t.action);if(a){const i={action:a},r=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(i.text=r),s!==void 0&&(i.image_url=s),c!==void 0&&(i.theme=c),Et({payload:i})}const o=typeof t.text=="string"?t.text:"";if(o){const i={text:o},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,c=be(t.payload)??void 0;return r!==void 0&&(i.type=r),c!==void 0&&(i.payload=c),s!==void 0&&(i.theme=s),Ke({payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Ke(e){const t={text:O(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function ao(e){return _o(e.payload,"qna")}function Et(e){const t=O(e.payload.text)??"",n=ce(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const a={text:t};return typeof e.payload.theme=="string"&&(a.theme=e.payload.theme),Ke({payload:a})}function St(e){const t=(e.payload.action_list??[]).map(n=>{const a=O(n.title)??"",o=ce(n.requestDetails,a),i=o?{label:a,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Tt(t.filter(zt),"qna")}function oo(e){const n={reviews:(e.payload.reviews??[]).map(a=>{const o={};return typeof a.review_class=="string"&&(o.review_class=a.review_class),typeof a.review_text=="string"&&(o.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(o.review_rating=a.review_rating),typeof a.review_tag=="string"&&(o.review_tag=a.review_tag),o})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function io(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 ro(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function so(e){const t=e.payload.product_suggestions??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=yo(o);if(!i)continue;const r={product:i},s=ce(o.requestDetails,i.name);s&&(r.action=s),typeof o.role=="string"&&(r.role=o.role),typeof o.reason=="string"&&(r.reason=o.reason),typeof o.review_highlight=="string"&&(r.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(r.labels=o.labels),typeof o.expert_quality_score=="number"&&(r.expertQualityScore=o.expert_quality_score),n.push(r)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function co(e){const t=e.payload.product_groupings??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=O(o.name)??"",r=o.sku&&o.sku.length>0?{type:"findSimilar",payload:{sku:o.sku}}:void 0,s=ce(o.requestDetails??r,i);if(!s)continue;const c={name:i,action:s};if(Array.isArray(o.labels)){const l=o.labels.filter(d=>typeof d=="string");l.length>0&&(c.labels=l)}typeof o.image=="string"&&(c.image=o.image),n.push(c)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function lo(e){const t=e.payload.suggested_searches??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=O(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Arama ${a+1}`,r={},s=O(o.detailed_user_message);s&&(r.text=s),o.group_skus&&Array.isArray(o.group_skus)&&(r.group_skus=o.group_skus);const c=O(o.sku,o.representative_product_sku);c&&(r.sku=c),r.is_suggested_text=1;const l={type:"inputText",payload:r},d=ce(o.requestDetails??l,i);if(!d)continue;const p={shortName:i,action:d},u=O(o.detailed_user_message);u&&u!==i&&(p.detailedMessage=u);const g=O(o.why_different);g&&(p.whyDifferent=g),typeof o.image=="string"&&(p.image=o.image),n.push(p)}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 go(e){const t=ce(e.payload.requestDetails,O(e.payload.review_count,e.payload.text,e.payload.title)??"Urun yorumlarini goster");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function po(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function uo(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function ho(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",r=(o.product_list??[]).map(xe);n.push({groupName:i,products:r})}const a=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const r=ce(o.requestDetails,i),s={title:i};r&&(s.action=r),a.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:a}}}},panelHint:"panel"}}function fo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function mo(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 bo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Tt(e,t){const n={},a=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const r=`action-${o}`;a.push(r);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),n[r]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function It(e,t){const n={},a=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const r=`product-${o}`;a.push(r),n[r]={type:"ProductCard",props:{product:xe(i),index:o}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function _o(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:xe(e),index:0}}}}}}function vo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function yo(e){const t=O(e.sku),n=O(e.short_name),a=be(e.product_item)??e;return wo(a,t,n)}function wo(e,t,n){const a=O(e.sku,t),o=O(e.name,n);if(!a||!o)return null;const i={sku:a,name:o},r=O(e.brand);r&&(i.brand=r);const s=O(e.url);s&&(i.url=s);const c=xo(e.images);if(c.length>0)i.images=c;else{const m=O(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const l=ze(e.price_discounted);l!==void 0&&(i.price_discounted=l);const d=ze(e.price);d!==void 0&&(i.price=d);const p=ze(e.rating);p!==void 0&&(i.rating=p);const u=ze(e.review_count)??ze(e.reviewCount);u!==void 0&&(i.review_count=u);const g=O(e.cart_code,e.cartCode);return g&&(i.cart_code=g),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock),xe(i)}function ce(e,t){const n=be(e);if(!n)return null;const a=n.type;if(typeof a!="string"||a.length===0)return null;const o={title:t||a,type:a};return n.payload!==void 0&&(o.payload=n.payload),o}function be(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function O(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function xo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ze(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function zt(e){return e!=null}function xe(e){const t=e.price_discounted!=null&&e.price_discounted>0?e.price_discounted:e.price,n=e.price_discounted!=null&&e.price_discounted>0&&e.price!=null?e.price:void 0;let a;n!=null&&t!=null&&n>0&&(a=Math.round((n-t)/n*100));const o=O(e.brand),i=O(e.name)??e.sku,r=o&&!i.toLowerCase().startsWith(o.toLowerCase())?`${o} ${i}`:i,s={sku:e.sku,name:r,url:O(e.url)??""},c=e.images?.[0];return c&&(s.imageUrl=c),e.images&&e.images.length>1&&(s.images=e.images),t!=null&&(s.price=String(t)),n!=null&&(s.originalPrice=String(n)),a!==void 0&&(s.discountPercent=a),o!==void 0&&(s.brand=o),e.rating!==void 0&&(s.rating=e.rating),e.review_count!==void 0&&(s.reviewCount=e.review_count),e.cart_code!==void 0&&(s.cartCode=e.cart_code),e.in_stock!==void 0&&(s.inStock=e.in_stock),e.variants&&e.variants.length>0&&(s.variants=e.variants),e.discount_reason!==void 0&&(s.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(s.promotions=e.promotions),s}const ko={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"},Co={process_action:"/message",launcher_action:"/message"};function At(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function Nt(e,t){const n=At(t?.middlewareUrl);if(t.backendType==="acap"){const a=t.accountId??"",o=Co[e];if(o)return`${n}/api/chat/${a}${o}`}return`${n}/chat${ko[e]}`}function Eo(e,t){const n=e.type,a=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},o=i=>{const r={...a};for(const[s,c]of Object.entries(i))s in r||(r[s]=c);return r};switch(n){case"inputText":{const i={is_launcher:0};return t.pageContext?.extra&&(i.page_details=t.pageContext.extra),"is_suggested_text"in a||(i.is_suggested_text=0),{...e,payload:o(i)}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title),e.title&&(i.input=e.title),{...e,payload:o(i)}}case"getComparisonTable":return e;case"addToCart":{const i={};return"error_message"in a||(i.error_message=""),{...e,payload:o(i)}}case"reviewSummary":{const i={};return t.pageContext?.sku&&!("sku"in a)&&(i.sku=t.pageContext.sku),Object.keys(i).length===0?e:{...e,payload:o(i)}}default:return e}}const So={user_message:"inputText"};function To(e){const{action:t,type:n,payload:a,...o}=e,i=n??t?.type??"inputText",r=a??t?.payload,s=So[i]??i,c={...o,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function Io(e){const t=e.type??e.action?.type??"inputText",n=e.payload??e.action?.payload;let a=e.action?.title??"";(t==="inputText"||t==="user_message")&&(typeof n=="string"?a=n:n&&typeof n=="object"&&"text"in n&&(a=String(n.text)));const o={message:a,session_id:e.session_id};if(e.user_id&&(o.user_id=e.user_id),e.locale&&(o.output_language=e.locale),e.meta?.outputLanguage&&(o.output_language=e.meta.outputLanguage),e.sku||e.page_type){const i={};e.page_type&&(i.screen_type=e.page_type),e.sku&&(i.sku_list=[e.sku]),o.screen_context=i}return t!=="inputText"&&t!=="user_message"&&(o.action_type=t,n!==void 0&&(o.action_payload=typeof n=="string"?{text:n}:n)),JSON.stringify(o)}function zo(e,t,n){const a=Nt("process_action",n),o=new AbortController;return(async()=>{try{const r=n.backendType==="acap"?Io(e):To(e),s=n.attachment!==void 0;let c;if(s){const u=new FormData;u.append("request",r),n.attachment!==void 0&&u.append("attachment",n.attachment),c={method:"POST",body:u,signal:o.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:r,signal:o.signal};const l=await fetch(a,c);if(!l.ok){let u=l.statusText;try{const g=await l.json(),m=g.detail??g.message??g.error;typeof m=="string"&&(u=m)}catch{}t.onError(new Error(`HTTP ${l.status}: ${u}`));return}let d=!1;const p=()=>{d||(d=!0,t.onDone())};await Ra(l,{onEvent:u=>{const g=Za(u);if(g)switch(g.type){case"text_chunk":t.onTextChunk(g.content,g.final===!0,{productMentions:g.productMentions,skuToProductItem:g.skuToProductItem,conversationMode:g.conversationMode});break;case"ui_spec":t.onUISpec(g.spec,g.widget,g.panelHint);break;case"action":t.onAction(g);break;case"metadata":t.onMetadata(g);break;case"error":t.onError(new Error(g.message));break;case"done":p();break}},onError:t.onError,signal:o.signal}),p()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;t.onError(r instanceof Error?r:new Error(String(r)))}})(),o}async function Ao(e,t){const n=Nt("proactive_action",t);try{const a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return a.ok?await a.json():null}catch{return null}}const Je={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Powered by Gengage",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"Düşünüyorum...",productCtaLabel:"İncele",attachImageButton:"Resim ekle",removeAttachmentButton:"Resmi kaldır",invalidFileType:"Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",fileTooLarge:"Dosya boyutu 5 MB'dan küçük olmalıdır.",aiTopPicksTitle:"Sizin İçin En İyiler",roleWinner:"En Beğendiğim",roleBestValue:"En Uygun Fiyatlı",roleBestAlternative:"En İyi Alternatif",viewDetails:"Detayları Gör",groundingReviewCta:"Yorumları Oku",groundingReviewSubtitle:"{count} yorum mevcut",variantsLabel:"Varyantlar",sortRelated:"Önerilen",sortPriceAsc:"Fiyat ↑",sortPriceDesc:"Fiyat ↓",compareSelected:"Karşılaştır",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",choicePrompterHeading:"Kararsız mı kaldın?",choicePrompterSuggestion:"Ürünleri seçip karşılaştırabilirsin",choicePrompterCta:"Seç ve Karşılaştır",viewMoreLabel:"Daha Fazla Göster",similarProductsLabel:"Benzer Ürünler",addToCartButton:"Sepete Ekle",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor"},No={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",sendButton:"Send",closeButton:"Close",openButton:"Open chat",newChatButton:"New chat",poweredBy:"Powered by Gengage",errorMessage:"Something went wrong. Please try again.",retryButton:"Retry",loadingMessage:"Thinking...",productCtaLabel:"View",attachImageButton:"Attach image",removeAttachmentButton:"Remove image",invalidFileType:"Only JPEG, PNG and WebP files are supported.",fileTooLarge:"File must be smaller than 5 MB.",aiTopPicksTitle:"Top Picks for You",roleWinner:"Top Pick",roleBestValue:"Best Value",roleBestAlternative:"Best Alternative",viewDetails:"View Details",groundingReviewCta:"Read Reviews",groundingReviewSubtitle:"{count} reviews available",variantsLabel:"Variants",sortRelated:"Related",sortPriceAsc:"Price ↑",sortPriceDesc:"Price ↓",compareSelected:"Compare",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent"};function Po(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Lo(e){return Po(e)==="en"?No:Je}function Mo(){return Pt()!==null}function Pt(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class $o{constructor(t,n){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this.callbacks=t,this.lang=n?.lang??"tr-TR",this.silenceTimeoutMs=n?.silenceTimeoutMs??1500,this.autoSubmit=n?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=Pt();if(!t){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const n=new t;n.continuous=!0,n.interimResults=!0,n.lang=this.lang,n.maxAlternatives=1,n.onstart=()=>{this.setState("listening")},n.onresult=a=>{this.clearSilenceTimer();let o="",i="";for(let r=a.resultIndex;r<a.results.length;r++){const s=a.results[r];if(!s)continue;const c=s[0];c&&(s.isFinal?i+=c.transcript:o+=c.transcript)}i&&(this.accumulatedTranscript+=i,this.callbacks.onFinal?.(this.accumulatedTranscript)),o&&this.callbacks.onInterim?.(this.accumulatedTranscript+o),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},n.onerror=a=>{const o=Oo(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(o,a.message||a.error))},n.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){try{n.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=n;try{n.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}function Oo(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 Do(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner",t.setAttribute("role","alert");const n=document.createElement("div");n.className="gengage-chat-kvkk-content",n.innerHTML=we(e.htmlContent),t.appendChild(n);const a=document.createElement("button");return a.className="gengage-chat-kvkk-dismiss",a.type="button",a.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),a.textContent="×",a.addEventListener("click",e.onDismiss),t.appendChild(a),t}class Bo{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 Ro{constructor(t){this._onThumbnailClick=t.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(t){const n=new Set,a=[];for(const o of t)n.has(o.sku)||(n.add(o.sku),a.push(o));this._el.innerHTML="";for(const o of a){const i=document.createElement("button");if(i.type="button",i.className="gengage-chat-thumbnail-btn",i.title=o.sku,re(o.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-thumbnail-img",r.src=o.imageUrl,r.alt=o.sku,r.width=40,r.height=40,i.appendChild(r)}i.addEventListener("click",()=>{this._onThumbnailClick(o.threadId)}),this._el.appendChild(i)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}}const Lt={search:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',review:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',info:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',similar:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'},Zo=Je;class Uo{constructor(t,n){this._panelVisible=!1,this._panelCollapsed=!1,this._panelForceExpanded=!1,this._onPanelToggle=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this.i18n={...Zo,...n.i18n},this.onSend=n.onSend,n.onPanelToggle!==void 0&&(this._onPanelToggle=n.onPanelToggle),n.onAttachment!==void 0&&(this._onAttachment=n.onAttachment),n.onRollback!==void 0&&(this._onRollback=n.onRollback),n.onLinkClick!==void 0&&(this._onLinkClick=n.onLinkClick),n.voiceEnabled&&(this._voiceEnabled=!0),n.voiceLang!==void 0&&(this._voiceLang=n.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a=document.createElement("div");a.className="gengage-chat-header";const o=document.createElement("div");if(o.className="gengage-chat-header-left",n.headerAvatarUrl){const f=document.createElement("img");f.className="gengage-chat-header-avatar",f.src=n.headerAvatarUrl,f.alt=n.headerTitle??"Assistant",o.appendChild(f)}const i=document.createElement("div");i.className="gengage-chat-header-info";const r=document.createElement("div");r.className="gengage-chat-header-title-row";const s=document.createElement("span");if(s.className="gengage-chat-header-title",s.textContent=n.headerTitle??this.i18n.headerTitle??"Gengage Asistanı",r.appendChild(s),n.headerBadge){const f=document.createElement("span");f.className="gengage-chat-header-badge",f.textContent=n.headerBadge,r.appendChild(f)}i.appendChild(r);const c=document.createElement("a");c.className="gengage-chat-header-powered",c.href="https://gengage.ai/",c.target="_blank",c.rel="noopener noreferrer",c.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage',i.appendChild(c),o.appendChild(i),a.appendChild(o);const l=document.createElement("div");if(l.className="gengage-chat-header-right",n.headerCartUrl){const f=document.createElement("a");f.className="gengage-chat-header-btn",f.href=n.headerCartUrl,f.target="_blank",f.rel="noopener noreferrer",f.setAttribute("aria-label","Sepetim"),f.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(f)}if(n.headerFavoritesToggle){const f=document.createElement("button");f.className="gengage-chat-header-btn",f.type="button",f.setAttribute("aria-label","Favorilerim"),f.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>',f.addEventListener("click",()=>n.onFavoritesClick?.()),l.appendChild(f)}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 p=document.createElement("div");p.className="gengage-chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel",this._panelTopBar=new Bo({onBack:()=>n.onPanelBack?.(),onForward:()=>n.onPanelForward?.()}),this._panelEl.appendChild(this._panelTopBar.getElement()),p.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label","Toggle panel");const u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label","Toggle panel"),u.textContent="»",u.addEventListener("click",()=>{this.togglePanel(),this._onPanelToggle?.()}),this._dividerEl.appendChild(u),p.appendChild(this._dividerEl);const g=document.createElement("div");g.className="gengage-chat-conversation",g.appendChild(a),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",g.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 m=!1;this.messagesEl.addEventListener("scroll",()=>{m||(m=!0,requestAnimationFrame(()=>{m=!1;const{scrollTop:f,scrollHeight:v,clientHeight:S}=this.messagesEl;this._userScrolledUp=v-f-S>10}))},{passive:!0}),g.appendChild(this.messagesEl),this._thumbnailsColumn=new Ro({onThumbnailClick:f=>n.onThumbnailClick?.(f)}),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 _=document.createElement("div");_.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(_);const y=document.createElement("button");y.className="gengage-chat-pills-arrow",y.type="button",y.setAttribute("aria-label","More suggestions"),y.textContent="›",y.addEventListener("click",()=>{_.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(y);let z=!1;_.addEventListener("scroll",()=>{z||(z=!0,requestAnimationFrame(()=>{z=!1;const f=_.scrollLeft+_.clientWidth>=_.scrollWidth-4;y.style.display=f?"none":""}))},{passive:!0}),g.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",g.appendChild(this._inputChipsEl);const I=document.createElement("div");I.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",f=>{f.key==="Enter"&&(window.innerWidth<768||!f.shiftKey)&&(f.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",f=>{const v=f.clipboardData?.files[0];v&&v.type.startsWith("image/")&&(f.preventDefault(),this._onAttachment?this._onAttachment(v):this.stageAttachment(v))}),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 f=this._fileInput.files?.[0];f&&(this._onAttachment?this._onAttachment(f):this.stageAttachment(f)),this._fileInput.value=""});const h=document.createElement("button");h.className="gengage-chat-attach-btn",h.type="button",h.setAttribute("aria-label",this.i18n.attachImageButton),h.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>',h.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const x=document.createElement("img");x.className="gengage-chat-attachment-preview-thumb",x.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const k=document.createElement("button");k.className="gengage-chat-attachment-remove",k.type="button",k.setAttribute("aria-label",this.i18n.removeAttachmentButton),k.textContent="×",k.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(x),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(k),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()),I.addEventListener("dragover",f=>{f.preventDefault(),I.classList.add("gengage-chat-input-area--dragover")}),I.addEventListener("dragleave",()=>{I.classList.remove("gengage-chat-input-area--dragover")}),I.addEventListener("drop",f=>{f.preventDefault(),I.classList.remove("gengage-chat-input-area--dragover");const v=f.dataTransfer?.files[0];v&&(this._onAttachment?this._onAttachment(v):this.stageAttachment(v))});const E=document.createElement("div");E.className="gengage-chat-input-pill",E.appendChild(h),E.appendChild(this.inputEl),this._voiceEnabled&&Mo()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn",this._micBtn.type="button",this._micBtn.setAttribute("aria-label",this.i18n.voiceButton),this._micBtn.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',this._micBtn.addEventListener("click",()=>this._toggleVoice()),E.appendChild(this._micBtn),this._voiceInput=new $o({onInterim:f=>{this.inputEl.value=f,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:f=>{this.inputEl.value=f},onAutoSubmit:f=>{this.inputEl.value=f,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:f=>{f==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(f,v)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),E.appendChild(this.sendBtn),I.appendChild(this._previewStrip),I.appendChild(this._fileInput),I.appendChild(E),g.appendChild(I),p.appendChild(g),this.root.appendChild(p);const L=document.createElement("div");L.className="gengage-chat-footer",L.textContent=this.i18n.poweredBy,this.root.appendChild(L),this.root.addEventListener("keydown",f=>{f.key==="Escape"&&n.onClose()}),this._trapFocus(),t.appendChild(this.root)}addMessage(t){const n=document.createElement("div");if(n.className=`gengage-chat-bubble gengage-chat-bubble--${t.role}`,n.dataset.messageId=t.id,t.threadId&&(n.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&n.classList.add("gengage-chat-bubble--first"),t.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const o=URL.createObjectURL(t.attachment);a.src=o,a.alt=t.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(o),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(o),{once:!0}),n.insertBefore(a,n.firstChild)}if(t.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",t.role==="assistant"){if(a.innerHTML=we(t.content),this._onLinkClick){const o=a.querySelectorAll("a[href]");for(const i of o)i.addEventListener("click",r=>{r.preventDefault();const s=i.getAttribute("href");s&&this._onLinkClick?.(s)})}}else a.textContent=t.content;n.appendChild(a)}if(t.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn",a.type="button",a.setAttribute("aria-label","Rollback to this message"),a.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',a.addEventListener("click",o=>{o.stopPropagation(),this._onRollback?.(t.id)}),n.appendChild(a)}this.messagesEl.appendChild(n),this._scrollToBottom(t.role==="user")}showTypingIndicator(t){this.removeTypingIndicator();const n=document.createElement("div");if(n.className="gengage-chat-typing",n.dataset.typing="true",this._thinkingSteps.length>0)this._renderThinkingStepsInto(n);else{const a=document.createElement("div");a.className="gengage-chat-typing-dots";for(let o=0;o<3;o++)a.appendChild(document.createElement("span"));if(n.appendChild(a),t){const o=document.createElement("span");o.className="gengage-chat-typing-sparkle",o.textContent="✨",n.appendChild(o);const i=document.createElement("span");i.className="gengage-chat-typing-text",i.textContent=t,n.appendChild(i)}}this.messagesEl.appendChild(n),this._scrollToBottom(!0)}addThinkingStep(t){this._thinkingSteps.push(t),this._renderThinkingSteps()}removeTypingIndicator(){this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[]}showError(t,n){const a=document.createElement("div");a.className="gengage-chat-error";const o=document.createElement("span");if(o.textContent=t??this.i18n.errorMessage,a.appendChild(o),n){const i=document.createElement("button");i.className="gengage-chat-error-retry",i.textContent=this.i18n.retryButton??"Retry",i.addEventListener("click",()=>{a.remove(),n()}),a.appendChild(i)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}clearMessages(){this.messagesEl.innerHTML=""}setPills(t){const n=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const o of t){const i=document.createElement("button");if(i.className=o.image?"gengage-chat-pill gengage-chat-pill--rich":"gengage-chat-pill",i.type="button",o.icon){const s=Lt[o.icon];if(s){const c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,i.appendChild(c)}}if(o.image&&re(o.image)){const s=document.createElement("img");s.className="gengage-chat-pill-img",s.src=o.image,s.alt="",i.appendChild(s)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=o.label,i.appendChild(r),o.description){const s=document.createElement("span");s.className="gengage-chat-pill-desc",s.textContent=o.description,i.appendChild(s)}i.addEventListener("click",()=>o.onAction()),n.appendChild(i)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=n.scrollWidth>n.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,n){this._kvkkSlot.innerHTML="";const a=Do({htmlContent:t,onDismiss:n});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}getElement(){return this.root}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const n=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");n&&(n.src&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),n.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden")}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden")}getPendingAttachment(){return this._pendingAttachment}setPanelContent(t){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed")}appendPanelContent(t){this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}getPanelContentElement(){const t=this._panelEl.children;for(let n=0;n<t.length;n++){const a=t[n];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-thumbnails-column")))return a}return null}hasPanelContent(){return this._panelVisible&&this._panelEl.childElementCount>2}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement());const n=document.createElement("div");switch(n.className="gengage-chat-panel-skeleton",t){case"productDetails":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",n.appendChild(a);for(let o=0;o<3;o++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",n.appendChild(i)}break}case"productList":case"groupList":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-grid";for(let o=0;o<6;o++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",a.appendChild(i)}n.appendChild(a);break}case"comparisonTable":{for(let a=0;a<4;a++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row",n.appendChild(o)}break}default:{for(let a=0;a<3;a++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",n.appendChild(o)}break}}this._panelEl.appendChild(n),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}updatePanelTopBar(t,n,a){this._panelTopBar.update(t,n,a)}clearPanel(){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelVisible=!1,this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}setForceExpanded(){this._panelForceExpanded=!0,this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}togglePanel(){this._panelForceExpanded||this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){if(this._panelForceExpanded)return;this._panelCollapsed=t,t?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const n=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");n&&(n.textContent=t?"«":"»")}persistPanelState(t){try{const n=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(n,"collapsed"):sessionStorage.removeItem(n)}catch{}}restorePanelState(t){try{const n=`gengage:panel:${t}`;sessionStorage.getItem(n)==="collapsed"&&(this._panelCollapsed=!0)}catch{}}_renderThinkingSteps(){const t=this.messagesEl.querySelector('[data-typing="true"]');if(!t){this.showTypingIndicator();return}t.innerHTML="",this._renderThinkingStepsInto(t),this._scrollToBottom(!1)}_renderThinkingStepsInto(t){const n=document.createElement("div");n.className="gengage-chat-thinking-steps";for(let a=0;a<this._thinkingSteps.length;a++){const o=document.createElement("div");o.className="gengage-chat-thinking-step";const i=document.createElement("span");i.className="gengage-chat-thinking-step-marker",a<this._thinkingSteps.length-1?(i.textContent="✓",i.classList.add("gengage-chat-thinking-step-marker--done")):(i.textContent="●",i.classList.add("gengage-chat-thinking-step-marker--active")),o.appendChild(i);const r=document.createElement("span");r.className="gengage-chat-thinking-step-text",r.textContent=this._thinkingSteps[a],o.appendChild(r),n.appendChild(o)}t.appendChild(n)}_trapFocus(){this.root.addEventListener("keydown",t=>{if(t.key!=="Tab")return;const n=this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(n.length===0)return;const a=n[0],o=n[n.length-1];if(!a||!o)return;const r=this.root.getRootNode().activeElement??document.activeElement;t.shiftKey?r===a&&(t.preventDefault(),o.focus()):r===o&&(t.preventDefault(),a.focus())})}_submit(){const t=this.inputEl.value.trim(),n=this._pendingAttachment;!t&&!n||(this.onSend(t,n??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment())}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const n=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);n&&n.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const n=t[t.length-1].getAttribute("data-thread-id");if(!n){this._scrollToBottom(!0);return}const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(n)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const n of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip",a.type="button",n.icon){const i=Lt[n.icon];if(i){const r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=i,a.appendChild(r)}}const o=document.createElement("span");o.textContent=n.label,a.appendChild(o),a.addEventListener("click",()=>n.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(t){this._thumbnailsColumn.setEntries(t),t.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide()}hideThumbnails(){this._thumbnailsColumn.hide()}}const jo=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
46
+ `,document.head.appendChild(e)}class Ca{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=ua(t.theme);this.config={...t,theme:n,session:pa(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ba();const a=bt("gengage:context:update",o=>this.update(o));this._cleanups.push(a);try{await this.onInit(this.config)}catch(o){throw this.destroy(),o}this.isInitialised=!0,this.emit("ready")}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const a=t==="start"?la:da;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(sa(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(a=>a(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,a]of Object.entries(t))if(a!==void 0){const o=n.startsWith("--")?n:`--gengage-${Ea(n)}`;this.root.style.setProperty(o,a)}}}}function Ea(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Sa(){const e=Date.now(),t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/2**40&255,t[1]=e/2**32&255,t[2]=e/2**24&255,t[3]=e/2**16&255,t[4]=e/2**8&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class Ta{constructor(t){this._handlers=new Map,this._destroyed=!1,this._namespace=t.namespace,this._allowedOrigins=t.allowedOrigins??["*"],this._onMessage=t.onMessage,this._allowedOrigins.includes("*"),this._messageListener=n=>this._handlePostMessage(n),window.addEventListener("message",this._messageListener)}send(t,n){if(this._destroyed)return;const a={namespace:this._namespace,type:t};n!==void 0&&(a.payload=n),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(t,n){this._handlers.has(t)||this._handlers.set(t,new Set);const a=this._handlers.get(t);return a.add(n),()=>{a.delete(n),a.size===0&&this._handlers.delete(t)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(t){if(this._destroyed||!this._isOriginAllowed(t.origin))return;const n=t.data;if(!Ia(n)||n.gengage!==this._namespace)return;const a={type:n.type};n.payload!==void 0&&(a.payload=n.payload),this._onMessage?.(a);const o=this._handlers.get(a.type);if(o)for(const i of o)i(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}function Ia(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const za=console;function Aa(e,t,n={}){const a=e.action,o=n.logger??za;switch(a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){ye(a,t,n,o);return}const i=typeof a.newTab=="boolean"?a.newTab:void 0;if(t.navigate){i!==void 0?t.navigate({url:a.url,newTab:i}):t.navigate({url:a.url});return}Na(a.url,i);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){ye(a,t,n,o);return}t.saveSession?.({sessionId:a.sessionId,sku:a.sku});return}case"add_to_cart":{if(typeof a.sku!="string"||typeof a.quantity!="number"||typeof a.cartCode!="string"){ye(a,t,n,o);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){ye(a,t,n,o);return}if(typeof a.name!="string"){ye(a,t,n,o);return}const i=Pa(a.payload)?a.payload:void 0;i!==void 0?t.scriptCall?.({name:a.name,payload:i}):t.scriptCall?.({name:a.name});return}default:ye(a,t,n,o)}}function ye(e,t,n,a){const o=n.unknownActionPolicy??"log-and-ignore";if(o==="delegate"){t.unknown?.(e),t.unknown||a.warn("[gengage] Unknown action received without delegate handler",e);return}if(o==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);a.warn("[gengage] Unknown action ignored",e)}function Na(e,t){if(!(typeof window>"u")){if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function Pa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const La=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),Ma=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta"]),wt={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function $a(e){return/^\s*javascript\s*:/i.test(e)}function We(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,a=n.tagName.toLowerCase();if(Ma.has(a)){n.parentNode?.removeChild(n);return}if(!La.has(a)){const c=Array.from(n.childNodes);for(const l of c)t.insertBefore(l,n);t.removeChild(n);for(const l of c)We(l,t);return}const o=wt["*"]??new Set,i=wt[a]??new Set,r=Array.from(n.attributes);for(const c of r){const l=c.name.toLowerCase();if(!o.has(l)&&!i.has(l)){n.removeAttribute(c.name);continue}if($a(c.value)){n.removeAttribute(c.name);continue}}if(a==="a"){const c=n.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(a==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const s=Array.from(n.childNodes);for(const c of s)We(c,n)}const xt=["http:","https:"];function re(e){try{return xt.includes(new URL(e).protocol)}catch{return!1}}function oe(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return xt.includes(t.protocol)}catch{return!1}}function H(e,t,n){(t==="href"||t==="src")&&!oe(n)||e.setAttribute(t,n)}function we(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const o of a)We(o,n);return n.innerHTML}const Oa=["image/jpeg","image/png","image/webp"],Da=5*1024*1024;function Ba(e){return Oa.includes(e.type)?e.size>Da?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function kt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Ra(e){const t=[];let n=0,a=!1,o=!1,i=0;for(let r=0;r<e.length;r++){const s=e[r];if(o){o=!1;continue}if(s==="\\"&&a){o=!0;continue}if(s==='"'){a=!a;continue}a||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(i,r+1)),i=r+1)))}return t.length>0?t:[e]}function Ct(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const a=n.startsWith("data: ")?n.slice(6):n;if(a==="[DONE]")return!0;try{const o=JSON.parse(a);return kt(o)?(t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Ra(a);if(o.length>1){for(const i of o)try{const r=JSON.parse(i);if(!kt(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Za(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),a=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,r=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let l;const d=await(i>0?Promise.race([c.then(f=>(clearTimeout(l),f)),new Promise(f=>{l=setTimeout(()=>f(r),i)})]):c);if(d===r){s=!0,await n.cancel();break}const{done:g,value:u}=d;if(g)break;o+=a.decode(u,{stream:!0});const p=o.split(`
47
+ `);o=p.pop()??"";for(const f of p)if(Ct(f,t))return}if(o.trim()&&Ct(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}function Ua(e){if(typeof e.type!="string")return null;if(ja(e))return e;const n=e;switch(n.type){case"outputText":return Fa(n);case"suggestedActions":return qa(n);case"productList":return Ha(n);case"productDetails":return Va(n);case"productDetailsSimilars":return Ga(n);case"comparisonTable":return Wa(n);case"context":return Ka(n);case"chatStreamEnd":return Ja();case"loading":return Ya(n);case"panelLoading":return Xa(n);case"similarLoading":return Qa(n);case"redirect":return eo(n);case"error":return to(n);case"dummy":return no();case"launcherAction":return ao(n);case"text":return Ke(n);case"productItem":return oo(n);case"text_image":return Et(n);case"quick_qna":return St(n);case"reviewHighlights":return io(n);case"aiProductSuggestions":return co(n);case"aiProductGroupings":return lo(n);case"aiSuggestedSearches":return go(n);case"prosAndCons":return ro(n);case"getGroundingReview":return po(n);case"voice":return ho(n);case"visitorDataResponse":return so(n);case"productListPreview":return uo();case"groupList":return fo(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return mo(n);case"launcherContent":return _o(n);case"handoff":return bo(n);default:return null}}function ja(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const a=be(e.spec);return a?typeof a.root=="string"&&be(a.elements)!==null:!1}case"action":{const n=be(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Fa(e){const t=O(e.payload.text,e.payload.plain_text)??"",n=O(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const a={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(a.productMentions=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.sku=="string"&&typeof s.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(a.skuToProductItem=i);const r=e.payload.conversation_mode;return typeof r=="string"&&r&&(a.conversationMode=r),a}function qa(e){const t=(e.payload.actions??[]).map(n=>{const a=O(n.title)??"",o=ce(n.requestDetails,a),i=o?{label:a,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Tt(t.filter(zt),"chat")}function Ha(e){const t=It(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list})),t}function Va(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:xe(t)}}}},panelHint:"panel"}:yo("chat")}function Ga(e){const t=It(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Wa(e){const t=e.payload.multiple_product_details??[],n=e.payload.product_comparison_framework,a=e.payload.table,o=[];for(const f of t){const v=xe(f);o.push(v)}const i=[];if(a){const f=n?.criteria_view??n?.criteria_view_short??{},v=n?.compared_field_names??Object.keys(a);for(const y of v){const I=a[y];if(!I||!Array.isArray(I))continue;const z=f[y]??y;i.push({label:z,values:I.map(b=>typeof b=="string"?b:String(b??""))})}}let r;n?.recommended_choice_sku?r=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(r=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const s=r?o.find(f=>f.sku===r)??o[0]:o[0],c=[];if(Array.isArray(n?.key_differences))for(const f of n.key_differences)typeof f=="string"&&c.push(f);const l=[];if(n?.special_considerations)for(const f of n.special_considerations)typeof f=="string"&&l.push(f);const d=n?.recommended_choice,g=n?.winner_hits,u={};for(const f of o){const v=f.sku;v&&(u[v]={title:f.name??v,type:"launchSingleProduct",payload:{sku:v}})}const p={products:o,attributes:i,highlights:c,productActions:u};return s&&(p.recommended=s),l.length>0&&(p.specialCases=l),d&&(p.recommendedText=d),g&&(p.winnerHits=g),typeof n?.key_differences=="string"&&(p.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(p.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:p}}},panelHint:"panel"}}function Ka(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Ja(){return{type:"done"}}function Ya(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function Xa(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Qa(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function eo(e){const t=O(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:O(e.payload.to)}}}function to(e){return{type:"error",code:"BACKEND_ERROR",message:O(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function no(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function ao(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const i={action_list:t.action_list},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(i.type=r),s!==void 0&&(i.theme=s),St({payload:i})}const a=be(t.action);if(a){const i={action:a},r=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(i.text=r),s!==void 0&&(i.image_url=s),c!==void 0&&(i.theme=c),Et({payload:i})}const o=typeof t.text=="string"?t.text:"";if(o){const i={text:o},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,c=be(t.payload)??void 0;return r!==void 0&&(i.type=r),c!==void 0&&(i.payload=c),s!==void 0&&(i.theme=s),Ke({payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Ke(e){const t={text:O(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function oo(e){return vo(e.payload,"qna")}function Et(e){const t=O(e.payload.text)??"",n=ce(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const a={text:t};return typeof e.payload.theme=="string"&&(a.theme=e.payload.theme),Ke({payload:a})}function St(e){const t=(e.payload.action_list??[]).map(n=>{const a=O(n.title)??"",o=ce(n.requestDetails,a),i=o?{label:a,action:o}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Tt(t.filter(zt),"qna")}function io(e){const n={reviews:(e.payload.reviews??[]).map(a=>{const o={};return typeof a.review_class=="string"&&(o.review_class=a.review_class),typeof a.review_text=="string"&&(o.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(o.review_rating=a.review_rating),typeof a.review_tag=="string"&&(o.review_tag=a.review_tag),o})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function ro(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function so(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function co(e){const t=e.payload.product_suggestions??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=wo(o);if(!i)continue;const r={product:i},s=ce(o.requestDetails,i.name);s&&(r.action=s),typeof o.role=="string"&&(r.role=o.role),typeof o.reason=="string"&&(r.reason=o.reason),typeof o.review_highlight=="string"&&(r.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(r.labels=o.labels),typeof o.expert_quality_score=="number"&&(r.expertQualityScore=o.expert_quality_score),n.push(r)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function lo(e){const t=e.payload.product_groupings??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=O(o.name)??"",r=o.sku&&o.sku.length>0?{type:"findSimilar",payload:{sku:o.sku}}:void 0,s=ce(o.requestDetails??r,i);if(!s)continue;const c={name:i,action:s};if(Array.isArray(o.labels)){const l=o.labels.filter(d=>typeof d=="string");l.length>0&&(c.labels=l)}typeof o.image=="string"&&(c.image=o.image),n.push(c)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function go(e){const t=e.payload.suggested_searches??[],n=[];for(let a=0;a<t.length;a++){const o=t[a];if(!o)continue;const i=O(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Arama ${a+1}`,r={},s=O(o.detailed_user_message);s&&(r.text=s),o.group_skus&&Array.isArray(o.group_skus)&&(r.group_skus=o.group_skus);const c=O(o.sku,o.representative_product_sku);c&&(r.sku=c),r.is_suggested_text=1;const l={type:"inputText",payload:r},d=ce(o.requestDetails??l,i);if(!d)continue;const g={shortName:i,action:d},u=O(o.detailed_user_message);u&&u!==i&&(g.detailedMessage=u);const p=O(o.why_different);p&&(g.whyDifferent=p),typeof o.image=="string"&&(g.image=o.image),n.push(g)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function po(e){const t=ce(e.payload.requestDetails,O(e.payload.review_count,e.payload.text,e.payload.title)??"Urun yorumlarini goster");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function uo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function ho(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function fo(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",r=(o.product_list??[]).map(xe);n.push({groupName:i,products:r})}const a=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const r=ce(o.requestDetails,i),s={title:i};r&&(s.action=r),a.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:a}}}},panelHint:"panel"}}function mo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function bo(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function _o(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Tt(e,t){const n={},a=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const r=`action-${o}`;a.push(r);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),n[r]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function It(e,t){const n={},a=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const r=`product-${o}`;a.push(r),n[r]={type:"ProductCard",props:{product:xe(i),index:o}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function vo(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:xe(e),index:0}}}}}}function yo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function wo(e){const t=O(e.sku),n=O(e.short_name),a=be(e.product_item)??e;return xo(a,t,n)}function xo(e,t,n){const a=O(e.sku,t),o=O(e.name,n);if(!a||!o)return null;const i={sku:a,name:o},r=O(e.brand);r&&(i.brand=r);const s=O(e.url);s&&(i.url=s);const c=ko(e.images);if(c.length>0)i.images=c;else{const f=O(e.image,e.image_url,e.imageUrl);f&&(i.images=[f])}const l=ze(e.price_discounted);l!==void 0&&(i.price_discounted=l);const d=ze(e.price);d!==void 0&&(i.price=d);const g=ze(e.rating);g!==void 0&&(i.rating=g);const u=ze(e.review_count)??ze(e.reviewCount);u!==void 0&&(i.review_count=u);const p=O(e.cart_code,e.cartCode);return p&&(i.cart_code=p),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock),xe(i)}function ce(e,t){const n=be(e);if(!n)return null;const a=n.type;if(typeof a!="string"||a.length===0)return null;const o={title:t||a,type:a};return n.payload!==void 0&&(o.payload=n.payload),o}function be(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function O(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function ko(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ze(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function zt(e){return e!=null}function xe(e){const t=e.price_discounted!=null&&e.price_discounted>0?e.price_discounted:e.price,n=e.price_discounted!=null&&e.price_discounted>0&&e.price!=null?e.price:void 0;let a;n!=null&&t!=null&&n>0&&(a=Math.round((n-t)/n*100));const o=O(e.brand),i=O(e.name)??e.sku,r=o&&!i.toLowerCase().startsWith(o.toLowerCase())?`${o} ${i}`:i,s={sku:e.sku,name:r,url:O(e.url)??""},c=e.images?.[0];return c&&(s.imageUrl=c),e.images&&e.images.length>1&&(s.images=e.images),t!=null&&(s.price=String(t)),n!=null&&(s.originalPrice=String(n)),a!==void 0&&(s.discountPercent=a),o!==void 0&&(s.brand=o),e.rating!==void 0&&(s.rating=e.rating),e.review_count!==void 0&&(s.reviewCount=e.review_count),e.cart_code!==void 0&&(s.cartCode=e.cart_code),e.in_stock!==void 0&&(s.inStock=e.in_stock),e.variants&&e.variants.length>0&&(s.variants=e.variants),e.discount_reason!==void 0&&(s.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(s.promotions=e.promotions),s}const Co={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"},Eo={process_action:"/message",launcher_action:"/message"};function At(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function Nt(e,t){const n=At(t?.middlewareUrl);if(t.backendType==="acap"){const a=t.accountId??"",o=Eo[e];if(o)return`${n}/api/chat/${a}${o}`}return`${n}/chat${Co[e]}`}function So(e,t){const n=e.type,a=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},o=i=>{const r={...a};for(const[s,c]of Object.entries(i))s in r||(r[s]=c);return r};switch(n){case"inputText":{const i={is_launcher:0};return t.pageContext?.extra&&(i.page_details=t.pageContext.extra),"is_suggested_text"in a||(i.is_suggested_text=0),{...e,payload:o(i)}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title),e.title&&(i.input=e.title),{...e,payload:o(i)}}case"getComparisonTable":return e;case"addToCart":{const i={};return"error_message"in a||(i.error_message=""),{...e,payload:o(i)}}case"reviewSummary":{const i={};return t.pageContext?.sku&&!("sku"in a)&&(i.sku=t.pageContext.sku),Object.keys(i).length===0?e:{...e,payload:o(i)}}default:return e}}const To={user_message:"inputText"};function Io(e){const{action:t,type:n,payload:a,...o}=e,i=n??t?.type??"inputText",r=a??t?.payload,s=To[i]??i,c={...o,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function zo(e){const t=e.type??e.action?.type??"inputText",n=e.payload??e.action?.payload;let a=e.action?.title??"";(t==="inputText"||t==="user_message")&&(typeof n=="string"?a=n:n&&typeof n=="object"&&"text"in n&&(a=String(n.text)));const o={message:a,session_id:e.session_id};if(e.user_id&&(o.user_id=e.user_id),e.locale&&(o.output_language=e.locale),e.meta?.outputLanguage&&(o.output_language=e.meta.outputLanguage),e.sku||e.page_type){const i={};e.page_type&&(i.screen_type=e.page_type),e.sku&&(i.sku_list=[e.sku]),o.screen_context=i}return t!=="inputText"&&t!=="user_message"&&(o.action_type=t,n!==void 0&&(o.action_payload=typeof n=="string"?{text:n}:n)),JSON.stringify(o)}function Ao(e,t,n){const a=Nt("process_action",n),o=new AbortController;return(async()=>{try{const r=n.backendType==="acap"?zo(e):Io(e),s=n.attachment!==void 0;let c;if(s){const u=new FormData;u.append("request",r),n.attachment!==void 0&&u.append("attachment",n.attachment),c={method:"POST",body:u,signal:o.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:r,signal:o.signal};const l=await fetch(a,c);if(!l.ok){let u=l.statusText;try{const p=await l.json(),f=p.detail??p.message??p.error;typeof f=="string"&&(u=f)}catch{}t.onError(new Error(`HTTP ${l.status}: ${u}`));return}let d=!1;const g=()=>{d||(d=!0,t.onDone())};await Za(l,{onEvent:u=>{const p=Ua(u);if(p)switch(p.type){case"text_chunk":t.onTextChunk(p.content,p.final===!0,{productMentions:p.productMentions,skuToProductItem:p.skuToProductItem,conversationMode:p.conversationMode});break;case"ui_spec":t.onUISpec(p.spec,p.widget,p.panelHint);break;case"action":t.onAction(p);break;case"metadata":t.onMetadata(p);break;case"error":t.onError(new Error(p.message));break;case"done":g();break}},onError:t.onError,signal:o.signal}),g()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;t.onError(r instanceof Error?r:new Error(String(r)))}})(),o}async function No(e,t){const n=Nt("proactive_action",t);try{const a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return a.ok?await a.json():null}catch{return null}}const Je={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Powered by Gengage",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"Düşünüyorum...",productCtaLabel:"İncele",attachImageButton:"Resim ekle",removeAttachmentButton:"Resmi kaldır",invalidFileType:"Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",fileTooLarge:"Dosya boyutu 5 MB'dan küçük olmalıdır.",aiTopPicksTitle:"Sizin İçin En İyiler",roleWinner:"En Beğendiğim",roleBestValue:"En Uygun Fiyatlı",roleBestAlternative:"En İyi Alternatif",viewDetails:"Detayları Gör",groundingReviewCta:"Yorumları Oku",groundingReviewSubtitle:"{count} yorum mevcut",variantsLabel:"Varyantlar",sortRelated:"Önerilen",sortPriceAsc:"Fiyat ↑",sortPriceDesc:"Fiyat ↓",compareSelected:"Karşılaştır",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",choicePrompterHeading:"Kararsız mı kaldın?",choicePrompterSuggestion:"Ürünleri seçip karşılaştırabilirsin",choicePrompterCta:"Seç ve Karşılaştır",viewMoreLabel:"Daha Fazla Göster",similarProductsLabel:"Benzer Ürünler",addToCartButton:"Sepete Ekle",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor"},Po={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",sendButton:"Send",closeButton:"Close",openButton:"Open chat",newChatButton:"New chat",poweredBy:"Powered by Gengage",errorMessage:"Something went wrong. Please try again.",retryButton:"Retry",loadingMessage:"Thinking...",productCtaLabel:"View",attachImageButton:"Attach image",removeAttachmentButton:"Remove image",invalidFileType:"Only JPEG, PNG and WebP files are supported.",fileTooLarge:"File must be smaller than 5 MB.",aiTopPicksTitle:"Top Picks for You",roleWinner:"Top Pick",roleBestValue:"Best Value",roleBestAlternative:"Best Alternative",viewDetails:"View Details",groundingReviewCta:"Read Reviews",groundingReviewSubtitle:"{count} reviews available",variantsLabel:"Variants",sortRelated:"Related",sortPriceAsc:"Price ↑",sortPriceDesc:"Price ↓",compareSelected:"Compare",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent"};function Lo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Mo(e){return Lo(e)==="en"?Po:Je}function $o(){return Pt()!==null}function Pt(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class Oo{constructor(t,n){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this.callbacks=t,this.lang=n?.lang??"tr-TR",this.silenceTimeoutMs=n?.silenceTimeoutMs??1500,this.autoSubmit=n?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=Pt();if(!t){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const n=new t;n.continuous=!0,n.interimResults=!0,n.lang=this.lang,n.maxAlternatives=1,n.onstart=()=>{this.setState("listening")},n.onresult=a=>{this.clearSilenceTimer();let o="",i="";for(let r=a.resultIndex;r<a.results.length;r++){const s=a.results[r];if(!s)continue;const c=s[0];c&&(s.isFinal?i+=c.transcript:o+=c.transcript)}i&&(this.accumulatedTranscript+=i,this.callbacks.onFinal?.(this.accumulatedTranscript)),o&&this.callbacks.onInterim?.(this.accumulatedTranscript+o),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},n.onerror=a=>{const o=Do(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(o,a.message||a.error))},n.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){try{n.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=n;try{n.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}function Do(e){switch(e){case"not-allowed":return"not-allowed";case"no-speech":return"no-speech";case"audio-capture":return"no-microphone";case"network":return"network";case"aborted":return"aborted";default:return"unknown"}}function Bo(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner",t.setAttribute("role","alert");const n=document.createElement("div");n.className="gengage-chat-kvkk-content",n.innerHTML=we(e.htmlContent),t.appendChild(n);const a=document.createElement("button");return a.className="gengage-chat-kvkk-dismiss",a.type="button",a.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),a.textContent="×",a.addEventListener("click",e.onDismiss),t.appendChild(a),t}class Ro{constructor(t){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label","Back"),this._backBtn.textContent="←",this._backBtn.addEventListener("click",()=>t.onBack()),this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label","Forward"),this._forwardBtn.textContent="→",this._forwardBtn.addEventListener("click",()=>t.onForward()),this._el.appendChild(this._backBtn),this._el.appendChild(this._titleEl),this._el.appendChild(this._forwardBtn)}update(t,n,a){this._backBtn.disabled=!t,this._forwardBtn.disabled=!n,this._titleEl.textContent=a}getElement(){return this._el}}class Zo{constructor(t){this._onThumbnailClick=t.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(t){const n=new Set,a=[];for(const o of t)n.has(o.sku)||(n.add(o.sku),a.push(o));this._el.innerHTML="";for(const o of a){const i=document.createElement("button");if(i.type="button",i.className="gengage-chat-thumbnail-btn",i.title=o.sku,re(o.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-thumbnail-img",r.src=o.imageUrl,r.alt=o.sku,r.width=40,r.height=40,i.appendChild(r)}i.addEventListener("click",()=>{this._onThumbnailClick(o.threadId)}),this._el.appendChild(i)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}}const Lt={search:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',review:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',info:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',similar:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'},Uo=Je;class jo{constructor(t,n){this._panelVisible=!1,this._panelCollapsed=!1,this._panelForceExpanded=!1,this._onPanelToggle=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this.i18n={...Uo,...n.i18n},this.onSend=n.onSend,n.onPanelToggle!==void 0&&(this._onPanelToggle=n.onPanelToggle),n.onAttachment!==void 0&&(this._onAttachment=n.onAttachment),n.onRollback!==void 0&&(this._onRollback=n.onRollback),n.onLinkClick!==void 0&&(this._onLinkClick=n.onLinkClick),n.voiceEnabled&&(this._voiceEnabled=!0),n.voiceLang!==void 0&&(this._voiceLang=n.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a=document.createElement("div");a.className="gengage-chat-header";const o=document.createElement("div");if(o.className="gengage-chat-header-left",n.headerAvatarUrl){const h=document.createElement("img");h.className="gengage-chat-header-avatar",h.src=n.headerAvatarUrl,h.alt=n.headerTitle??"Assistant",o.appendChild(h)}const i=document.createElement("div");i.className="gengage-chat-header-info";const r=document.createElement("div");r.className="gengage-chat-header-title-row";const s=document.createElement("span");if(s.className="gengage-chat-header-title",s.textContent=n.headerTitle??this.i18n.headerTitle??"Gengage Asistanı",r.appendChild(s),n.headerBadge){const h=document.createElement("span");h.className="gengage-chat-header-badge",h.textContent=n.headerBadge,r.appendChild(h)}i.appendChild(r);const c=document.createElement("a");c.className="gengage-chat-header-powered",c.href="https://gengage.ai/",c.target="_blank",c.rel="noopener noreferrer",c.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage',i.appendChild(c),o.appendChild(i),a.appendChild(o);const l=document.createElement("div");if(l.className="gengage-chat-header-right",n.headerCartUrl){const h=document.createElement("a");h.className="gengage-chat-header-btn",h.href=n.headerCartUrl,h.target="_blank",h.rel="noopener noreferrer",h.setAttribute("aria-label","Sepetim"),h.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>',l.appendChild(h)}if(n.headerFavoritesToggle){const h=document.createElement("button");h.className="gengage-chat-header-btn",h.type="button",h.setAttribute("aria-label","Favorilerim"),h.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>',h.addEventListener("click",()=>n.onFavoritesClick?.()),l.appendChild(h)}const d=document.createElement("button");d.className="gengage-chat-close",d.type="button",d.setAttribute("aria-label",this.i18n.closeButton),d.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',d.addEventListener("click",n.onClose),l.appendChild(d),a.appendChild(l);const g=document.createElement("div");g.className="gengage-chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel",this._panelTopBar=new Ro({onBack:()=>n.onPanelBack?.(),onForward:()=>n.onPanelForward?.()}),this._panelEl.appendChild(this._panelTopBar.getElement()),g.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label","Toggle panel");const u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label","Toggle panel"),u.textContent="»",u.addEventListener("click",()=>{this.togglePanel(),this._onPanelToggle?.()}),this._dividerEl.appendChild(u),g.appendChild(this._dividerEl);const p=document.createElement("div");p.className="gengage-chat-conversation",p.appendChild(a),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",p.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.className="gengage-chat-messages",this.messagesEl.setAttribute("role","log"),this.messagesEl.setAttribute("aria-live","polite"),this.messagesEl.setAttribute("aria-label","Chat messages");let f=!1;this.messagesEl.addEventListener("scroll",()=>{f||(f=!0,requestAnimationFrame(()=>{f=!1;const{scrollTop:h,scrollHeight:k,clientHeight:C}=this.messagesEl;this._userScrolledUp=k-h-C>10}))},{passive:!0}),p.appendChild(this.messagesEl),this._thumbnailsColumn=new Zo({onThumbnailClick:h=>n.onThumbnailClick?.(h)}),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label","Suggestions"),this._pillsEl.style.display="none";const v=document.createElement("div");v.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(v);const y=document.createElement("button");y.className="gengage-chat-pills-arrow",y.type="button",y.setAttribute("aria-label","More suggestions"),y.textContent="›",y.addEventListener("click",()=>{v.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(y);let I=!1;v.addEventListener("scroll",()=>{I||(I=!0,requestAnimationFrame(()=>{I=!1;const h=v.scrollLeft+v.clientWidth>=v.scrollWidth-4;y.style.display=h?"none":""}))},{passive:!0}),p.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",p.appendChild(this._inputChipsEl);const z=document.createElement("div");z.className="gengage-chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{requestAnimationFrame(()=>{this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`})}),this.inputEl.addEventListener("keydown",h=>{h.key==="Enter"&&(window.innerWidth<768||!h.shiftKey)&&(h.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",h=>{const k=h.clipboardData?.files[0];k&&k.type.startsWith("image/")&&(h.preventDefault(),this._onAttachment?this._onAttachment(k):this.stageAttachment(k))}),this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.accept="image/jpeg,image/png,image/webp",this._fileInput.style.display="none",this._fileInput.addEventListener("change",()=>{const h=this._fileInput.files?.[0];h&&(this._onAttachment?this._onAttachment(h):this.stageAttachment(h)),this._fileInput.value=""});const b=document.createElement("button");b.className="gengage-chat-attach-btn",b.type="button",b.setAttribute("aria-label",this.i18n.attachImageButton),b.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',b.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const _=document.createElement("img");_.className="gengage-chat-attachment-preview-thumb",_.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const w=document.createElement("button");w.className="gengage-chat-attachment-remove",w.type="button",w.setAttribute("aria-label",this.i18n.removeAttachmentButton),w.textContent="×",w.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(_),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(w),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send",this.sendBtn.type="button",this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>',this.sendBtn.addEventListener("click",()=>this._submit()),z.addEventListener("dragover",h=>{h.preventDefault(),z.classList.add("gengage-chat-input-area--dragover")}),z.addEventListener("dragleave",()=>{z.classList.remove("gengage-chat-input-area--dragover")}),z.addEventListener("drop",h=>{h.preventDefault(),z.classList.remove("gengage-chat-input-area--dragover");const k=h.dataTransfer?.files[0];k&&(this._onAttachment?this._onAttachment(k):this.stageAttachment(k))});const E=document.createElement("div");E.className="gengage-chat-input-pill",E.appendChild(b),E.appendChild(this.inputEl),this._voiceEnabled&&$o()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn",this._micBtn.type="button",this._micBtn.setAttribute("aria-label",this.i18n.voiceButton),this._micBtn.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',this._micBtn.addEventListener("click",()=>this._toggleVoice()),E.appendChild(this._micBtn),this._voiceInput=new Oo({onInterim:h=>{this.inputEl.value=h,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:h=>{this.inputEl.value=h},onAutoSubmit:h=>{this.inputEl.value=h,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:h=>{h==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(h,k)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),E.appendChild(this.sendBtn),z.appendChild(this._previewStrip),z.appendChild(this._fileInput),z.appendChild(E),p.appendChild(z),g.appendChild(p),this.root.appendChild(g);const P=document.createElement("div");P.className="gengage-chat-footer",P.textContent=this.i18n.poweredBy,this.root.appendChild(P),this.root.addEventListener("keydown",h=>{h.key==="Escape"&&n.onClose()}),this._trapFocus(),t.appendChild(this.root)}addMessage(t){const n=document.createElement("div");if(n.className=`gengage-chat-bubble gengage-chat-bubble--${t.role}`,n.dataset.messageId=t.id,t.threadId&&(n.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&n.classList.add("gengage-chat-bubble--first"),t.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const o=URL.createObjectURL(t.attachment);a.src=o,a.alt=t.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(o),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(o),{once:!0}),n.insertBefore(a,n.firstChild)}if(t.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",t.role==="assistant"){if(a.innerHTML=we(t.content),this._onLinkClick){const o=a.querySelectorAll("a[href]");for(const i of o)i.addEventListener("click",r=>{r.preventDefault();const s=i.getAttribute("href");s&&this._onLinkClick?.(s)})}}else a.textContent=t.content;n.appendChild(a)}if(t.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn",a.type="button",a.setAttribute("aria-label","Rollback to this message"),a.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',a.addEventListener("click",o=>{o.stopPropagation(),this._onRollback?.(t.id)}),n.appendChild(a)}this.messagesEl.appendChild(n),this._scrollToBottom(t.role==="user")}showTypingIndicator(t){this.removeTypingIndicator();const n=document.createElement("div");if(n.className="gengage-chat-typing",n.dataset.typing="true",this._thinkingSteps.length>0)this._renderThinkingStepsInto(n);else{const a=document.createElement("div");a.className="gengage-chat-typing-dots";for(let o=0;o<3;o++)a.appendChild(document.createElement("span"));if(n.appendChild(a),t){const o=document.createElement("span");o.className="gengage-chat-typing-sparkle",o.textContent="✨",n.appendChild(o);const i=document.createElement("span");i.className="gengage-chat-typing-text",i.textContent=t,n.appendChild(i)}}this.messagesEl.appendChild(n),this._scrollToBottom(!0)}addThinkingStep(t){this._thinkingSteps.push(t),this._renderThinkingSteps()}removeTypingIndicator(){this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[]}showError(t,n){const a=document.createElement("div");a.className="gengage-chat-error";const o=document.createElement("span");if(o.textContent=t??this.i18n.errorMessage,a.appendChild(o),n){const i=document.createElement("button");i.className="gengage-chat-error-retry",i.textContent=this.i18n.retryButton??"Retry",i.addEventListener("click",()=>{a.remove(),n()}),a.appendChild(i)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}clearMessages(){this.messagesEl.innerHTML=""}setPills(t){const n=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const o of t){const i=document.createElement("button");if(i.className=o.image?"gengage-chat-pill gengage-chat-pill--rich":"gengage-chat-pill",i.type="button",o.icon){const s=Lt[o.icon];if(s){const c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,i.appendChild(c)}}if(o.image&&re(o.image)){const s=document.createElement("img");s.className="gengage-chat-pill-img",s.src=o.image,s.alt="",i.appendChild(s)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=o.label,i.appendChild(r),o.description){const s=document.createElement("span");s.className="gengage-chat-pill-desc",s.textContent=o.description,i.appendChild(s)}i.addEventListener("click",()=>o.onAction()),n.appendChild(i)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=n.scrollWidth>n.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,n){this._kvkkSlot.innerHTML="";const a=Bo({htmlContent:t,onDismiss:n});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}getElement(){return this.root}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const n=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");n&&(n.src&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),n.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden")}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden")}getPendingAttachment(){return this._pendingAttachment}setPanelContent(t){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed")}appendPanelContent(t){this._panelEl.appendChild(t),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}getPanelContentElement(){const t=this._panelEl.children;for(let n=0;n<t.length;n++){const a=t[n];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-thumbnails-column")))return a}return null}hasPanelContent(){return this._panelVisible&&this._panelEl.childElementCount>2}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement());const n=document.createElement("div");switch(n.className="gengage-chat-panel-skeleton",t){case"productDetails":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",n.appendChild(a);for(let o=0;o<3;o++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",n.appendChild(i)}break}case"productList":case"groupList":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-grid";for(let o=0;o<6;o++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",a.appendChild(i)}n.appendChild(a);break}case"comparisonTable":{for(let a=0;a<4;a++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row",n.appendChild(o)}break}default:{for(let a=0;a<3;a++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",n.appendChild(o)}break}}this._panelEl.appendChild(n),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}updatePanelTopBar(t,n,a){this._panelTopBar.update(t,n,a)}clearPanel(){this._panelEl.innerHTML="",this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelVisible=!1,this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}setForceExpanded(){this._panelForceExpanded=!0,this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden")}togglePanel(){this._panelForceExpanded||this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){if(this._panelForceExpanded)return;this._panelCollapsed=t,t?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const n=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");n&&(n.textContent=t?"«":"»")}persistPanelState(t){try{const n=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(n,"collapsed"):sessionStorage.removeItem(n)}catch{}}restorePanelState(t){try{const n=`gengage:panel:${t}`;sessionStorage.getItem(n)==="collapsed"&&(this._panelCollapsed=!0)}catch{}}_renderThinkingSteps(){const t=this.messagesEl.querySelector('[data-typing="true"]');if(!t){this.showTypingIndicator();return}t.innerHTML="",this._renderThinkingStepsInto(t),this._scrollToBottom(!1)}_renderThinkingStepsInto(t){const n=document.createElement("div");n.className="gengage-chat-thinking-steps";for(let a=0;a<this._thinkingSteps.length;a++){const o=document.createElement("div");o.className="gengage-chat-thinking-step";const i=document.createElement("span");i.className="gengage-chat-thinking-step-marker",a<this._thinkingSteps.length-1?(i.textContent="✓",i.classList.add("gengage-chat-thinking-step-marker--done")):(i.textContent="●",i.classList.add("gengage-chat-thinking-step-marker--active")),o.appendChild(i);const r=document.createElement("span");r.className="gengage-chat-thinking-step-text",r.textContent=this._thinkingSteps[a],o.appendChild(r),n.appendChild(o)}t.appendChild(n)}_trapFocus(){this.root.addEventListener("keydown",t=>{if(t.key!=="Tab")return;const n=this.root.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(n.length===0)return;const a=n[0],o=n[n.length-1];if(!a||!o)return;const r=this.root.getRootNode().activeElement??document.activeElement;t.shiftKey?r===a&&(t.preventDefault(),o.focus()):r===o&&(t.preventDefault(),a.focus())})}_submit(){const t=this.inputEl.value.trim(),n=this._pendingAttachment;!t&&!n||(this.onSend(t,n??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment())}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const n=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);n&&n.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const n=t[t.length-1].getAttribute("data-thread-id");if(!n){this._scrollToBottom(!0);return}const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(n)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const n of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip",a.type="button",n.icon){const i=Lt[n.icon];if(i){const r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=i,a.appendChild(r)}}const o=document.createElement("span");o.textContent=n.label,a.appendChild(o),a.addEventListener("click",()=>n.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(t){this._thumbnailsColumn.setEntries(t),t.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide()}hideThumbnails(){this._thumbnailsColumn.hide()}}const Fo=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
48
48
  <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
49
49
  <rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
50
50
  <circle cx="9" cy="13" r="1.5" fill="currentColor"/>
@@ -54,44 +54,44 @@
54
54
  <circle cx="12" cy="3" r="1" fill="currentColor"/>
55
55
  <path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
56
56
  <path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
57
- </svg>`;function Fo(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??jo,e.tooltip!==void 0){const i=document.createElement("span");i.className="gengage-chat-launcher-tooltip",i.textContent=e.tooltip,a.appendChild(i)}e.hideMobile&&(t.dataset.hideMobile="1"),e.mobileBreakpoint!==void 0&&(t.dataset.mobileBreakpoint=String(e.mobileBreakpoint)),a.addEventListener("click",e.onClick),t.appendChild(a);const o=document.createElement("div");return o.className="gengage-chat-launcher-content-area-bottom",t.appendChild(o),{container:t,button:a,contentArea:n,contentAreaBottom:o}}function qo(e){const t=document.createElement("div");t.className="gengage-chat-proactive";const n=document.createElement("p");n.className="gengage-chat-proactive-message",n.textContent=e.message,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-proactive-actions";let o=null;function i(){o!==null&&clearTimeout(o),t.remove()}if(e.actionButtons&&e.actionButtons.length>0)for(const c of e.actionButtons){const l=document.createElement("button");l.className="gengage-chat-proactive-accept",l.type="button",l.textContent=c.title,l.addEventListener("click",()=>{i(),c.onSelect()}),a.appendChild(l)}else{const c=document.createElement("button");c.className="gengage-chat-proactive-accept",c.type="button",c.textContent=e.acceptLabel??"Sohbete Başla",c.addEventListener("click",()=>{i(),e.onAccept()}),a.appendChild(c)}const r=document.createElement("button");r.className="gengage-chat-proactive-dismiss",r.type="button",r.textContent="×",r.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),r.addEventListener("click",()=>{i(),e.onDismiss()}),t.appendChild(r),t.appendChild(a);const s=e.autoDismissMs??15e3;return s>0&&(o=setTimeout(()=>{t.parentElement&&(t.remove(),e.onDismiss())},s)),requestAnimationFrame(()=>t.classList.add("gengage-chat-proactive--visible")),t}class Ho{constructor(t={}){this._idleTimer=null,this._maxScrollDepth=0,this._lastReportedDepth=0,this._listeners=[],this._destroyed=!1,this._idleThreshold=t.idleThresholdMs??3e4,this._scrollGranularity=t.scrollGranularity??25,this._onActivity=t.onActivity??null,this._setup()}_setup(){this._emit({type:"pageview",timestamp:Date.now()}),this._resetIdleTimer(),this._listen(window,"scroll",()=>this._onScroll(),{passive:!0}),this._listen(window,"mousemove",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"keydown",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"touchstart",()=>this._resetIdleTimer(),{passive:!0}),this._listen(document,"visibilitychange",()=>this._onVisibility())}_listen(t,n,a,o){t.addEventListener(n,a,o),this._listeners.push([t,n,a])}_resetIdleTimer(){this._idleTimer&&clearTimeout(this._idleTimer),this._idleTimer=setTimeout(()=>{this._emit({type:"idle",timestamp:Date.now()})},this._idleThreshold)}_onScroll(){const t=window.scrollY||document.documentElement.scrollTop,n=Math.max(document.documentElement.scrollHeight-window.innerHeight,1),a=Math.min(100,Math.round(t/n*100));a>this._maxScrollDepth&&(this._maxScrollDepth=a);const o=Math.floor(a/this._scrollGranularity)*this._scrollGranularity;o>this._lastReportedDepth&&(this._lastReportedDepth=o,this._emit({type:"scroll",timestamp:Date.now(),data:{depth:o}})),this._resetIdleTimer()}_onVisibility(){document.hidden?(this._emit({type:"blur",timestamp:Date.now()}),this._idleTimer&&clearTimeout(this._idleTimer)):(this._emit({type:"focus",timestamp:Date.now()}),this._resetIdleTimer())}_emit(t){this._destroyed||this._onActivity?.(t)}get maxScrollDepth(){return this._maxScrollDepth}destroy(){this._destroyed=!0,this._idleTimer&&clearTimeout(this._idleTimer);for(const[t,n,a]of this._listeners)t.removeEventListener(n,a);this._listeners=[]}}const Vo=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]);function Go(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!Vo.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 Wo{constructor(t){this._timer=null,this._destroyed=!1,this._abortController=null,this._sessionStart=Date.now(),this._lastActivity=Date.now(),this._searchesCount=0,this._actionsCount=0,this._triggerFireCounts={},this._options=t;const n=At(t.middlewareUrl);this._endpoint=`${n}/v2/heartbeat`}start(){this._timer||this._destroyed||this._scheduleNext()}_scheduleNext(){this._destroyed||(this._timer=setTimeout(()=>{this._poll().finally(()=>this._scheduleNext())},this._options.intervalMs))}stop(){this._timer&&(clearTimeout(this._timer),this._timer=null)}recordAction(){this._actionsCount++,this._lastActivity=Date.now()}recordSearch(){this._searchesCount++,this._lastActivity=Date.now()}recordActivity(){this._lastActivity=Date.now()}destroy(){this._destroyed=!0,this._abortController?.abort(),this._abortController=null,this.stop()}async _poll(){if(this._destroyed)return;const t=Date.now(),n={account_id:this._options.accountId,thread_id:this._options.sessionId,output_language:this._options.locale.toUpperCase(),idle_seconds:(t-this._lastActivity)/1e3,page_type:this._options.getPageType(),current_sku:this._options.getCurrentSku(),cart_item_count:0,searches_count:this._searchesCount,actions_count:this._actionsCount,session_duration_seconds:(t-this._sessionStart)/1e3,trigger_fire_counts:{...this._triggerFireCounts}};this._abortController=new AbortController;try{const a=await fetch(this._endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:this._abortController.signal});if(this._destroyed||!a.ok)return;const o=await a.json();if(this._destroyed)return;o.action==="message"&&o.message&&(o.trigger_type&&(this._triggerFireCounts[o.trigger_type]=(this._triggerFireCounts[o.trigger_type]??0)+1),this._options.onMessage(o))}catch{}}}const Ko={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...Ko,...t},i=n%1!==0||a.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),r=i.indexOf("."),s=r===-1?i:i.slice(0,r),c=r===-1?void 0:i.slice(r+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousandsSeparator);let d;return c!==void 0?d=`${l}${a.decimalSeparator}${c}`:d=l,a.currencySymbol?a.currencyPosition==="prefix"?`${a.currencySymbol}${d}`:`${d} ${a.currencySymbol}`:d}const Jo={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 Yo(e){return Jo[e]??e.replace(/_/g," ").replace(/^\w/,t=>t.toUpperCase())}function Xo(e){const{recommended:t,products:n,attributes:a,highlights:o,specialCases:i,onProductClick:r,i18n:s}=e,c=document.createElement("div");c.className="gengage-chat-comparison";const l=document.createElement("h3");if(l.className="gengage-chat-comparison-heading",l.textContent=s?.comparisonHeading??"KARŞILAŞTIRMA SONUÇLARI",c.appendChild(l),t){const d=document.createElement("div");d.className="gengage-chat-comparison-recommended";const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-label",p.textContent=s?.recommendedChoiceLabel??"Önerilen Seçim",d.appendChild(p);const u=document.createElement("div");if(u.className="gengage-chat-comparison-recommended-body",t.imageUrl&&re(t.imageUrl)){const y=document.createElement("img");y.src=t.imageUrl,y.alt=t.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),u.appendChild(y)}const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";const m=document.createElement("div");m.className="gengage-chat-comparison-recommended-title",m.textContent=t.name,g.appendChild(m);const _=document.createElement("div");if(_.className="gengage-chat-comparison-recommended-price",_.textContent=t.price,g.appendChild(_),u.appendChild(g),u.addEventListener("click",()=>{r(t.sku)}),u.style.cursor="pointer",d.appendChild(u),o.length>0){const y=document.createElement("div");y.className="gengage-chat-comparison-highlights";const z=document.createElement("div");z.className="gengage-chat-comparison-highlights-label",z.textContent=s?.highlightsLabel??"Öne Çıkan Özellikler",y.appendChild(z);const I=document.createElement("ul");for(const h of o){const x=document.createElement("li");x.textContent=h,I.appendChild(x)}y.appendChild(I),d.appendChild(y)}if(e.recommendedText){const y=document.createElement("div");y.className="gengage-chat-comparison-recommended-text",y.textContent=e.recommendedText,d.appendChild(y)}c.appendChild(d)}if(e.keyDifferencesHtml){const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences";const p=document.createElement("h4");p.textContent=s?.keyDifferencesLabel??"Temel Farklar",d.appendChild(p);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content",u.innerHTML=we(Qo(e.keyDifferencesHtml)),d.appendChild(u),c.appendChild(d)}if(i&&i.length>0){const d=document.createElement("details");d.className="gengage-chat-comparison-special";const p=document.createElement("summary");p.textContent=s?.specialCasesLabel??"Özel Durumlar İçin",d.appendChild(p);const u=document.createElement("ul");for(const g of i){const m=document.createElement("li");m.textContent=g,u.appendChild(m)}d.appendChild(u),c.appendChild(d)}if(n.length>0&&a.length>0){const d=document.createElement("table");d.className="gengage-chat-comparison-table";const p=document.createElement("thead"),u=document.createElement("tr"),g=document.createElement("th");u.appendChild(g);for(const _ of n){const y=document.createElement("th");if(_.sku===t?.sku&&(y.className="gengage-chat-comparison-selected"),_.imageUrl&&re(_.imageUrl)){const h=document.createElement("img");h.src=_.imageUrl,h.alt=_.name,h.loading="lazy",h.addEventListener("error",()=>{h.style.display="none"},{once:!0}),y.appendChild(h)}const z=document.createElement("div");z.textContent=_.name,y.appendChild(z);const I=document.createElement("div");I.className="gengage-chat-comparison-table-price",I.textContent=_.price,y.appendChild(I),u.appendChild(y)}p.appendChild(u),d.appendChild(p);const m=document.createElement("tbody");for(const _ of a){const y=document.createElement("tr"),z=document.createElement("td");z.className="gengage-chat-comparison-label",z.textContent=Yo(_.label),y.appendChild(z);for(let I=0;I<_.values.length;I++){const h=document.createElement("td");n[I]?.sku===t?.sku&&(h.className="gengage-chat-comparison-selected"),h.textContent=_.values[I]??"",y.appendChild(h)}m.appendChild(y)}d.appendChild(m),c.appendChild(d)}if(e.productActions){const d=document.createElement("div");d.className="gengage-chat-comparison-product-actions";for(const p of n)if(e.productActions[p.sku]){const g=document.createElement("button");g.className="gengage-chat-comparison-view-btn",g.type="button",g.textContent=p.name,g.addEventListener("click",()=>r(p.sku)),d.appendChild(g)}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 ei(e,t){const n=document.createElement("div");n.className="gengage-chat-review-highlights";const a=e.props?.reviews;if(!Array.isArray(a)||a.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"Yorum özeti bulunamadı.",n.appendChild(u),n}const o=a.filter(u=>u!==null&&typeof u=="object"),i={all:o.length,positive:0,negative:0,neutral:0};for(const u of o)u.review_class==="positive"?i.positive++:u.review_class==="negative"?i.negative++:i.neutral++;const r=document.createElement("div");r.className="gengage-chat-review-tabs";const s=[{label:`Tümü (${i.all})`,filter:"all"}];i.positive>0&&s.push({label:`Olumlu (${i.positive})`,filter:"positive"}),i.negative>0&&s.push({label:`Olumsuz (${i.negative})`,filter:"negative"});let c="all";const l=document.createElement("div");l.className="gengage-chat-review-items";function d(){for(;l.firstChild;)l.removeChild(l.firstChild);const u=c==="all"?o:o.filter(g=>g.review_class===c);for(const g of u){const m=document.createElement("article");m.className="gengage-chat-review-item";const _=g.review_class;if((_==="positive"||_==="negative"||_==="neutral")&&(m.dataset.tone=_),typeof g.review_tag=="string"&&g.review_tag.length>0){const y=document.createElement("div");y.className="gengage-chat-review-tag",y.textContent=g.review_tag,m.appendChild(y)}if(typeof g.review_text=="string"&&g.review_text.length>0){const y=document.createElement("div");y.className="gengage-chat-review-text",y.textContent=g.review_text,m.appendChild(y)}if(g.review_rating!==void 0&&String(g.review_rating).length>0){const y=document.createElement("div");y.className="gengage-chat-review-rating",y.textContent=String(g.review_rating),m.appendChild(y)}l.appendChild(m)}}for(const u of s){const g=document.createElement("button");g.className="gengage-chat-review-tab",g.type="button",g.textContent=u.label,u.filter===c&&g.classList.add("gengage-chat-review-tab--active"),g.addEventListener("click",()=>{c=u.filter;for(const m of r.querySelectorAll(".gengage-chat-review-tab"))m.classList.toggle("gengage-chat-review-tab--active",m===g);d()}),r.appendChild(g)}n.appendChild(r);const p=new Map;for(const u of o)if(typeof u.review_tag=="string"&&u.review_tag.length>0){const g=p.get(u.review_tag);g?g.count++:p.set(u.review_tag,{count:1,sentiment:u.review_class??"neutral"})}if(p.size>0){const u=document.createElement("div");u.className="gengage-chat-review-pills";for(const[g,m]of p){const _=document.createElement("span");_.className="gengage-chat-review-pill",_.dataset.tone=m.sentiment;const y=document.createElement("span");y.className="gengage-chat-review-pill-icon",y.textContent=m.sentiment==="positive"?"✓":m.sentiment==="negative"?"✕":"●",_.appendChild(y);const z=document.createElement("span");if(z.textContent=g,_.appendChild(z),m.count>1){const I=document.createElement("span");I.className="gengage-chat-review-pill-count",I.textContent=String(m.count),_.appendChild(I)}u.appendChild(_)}n.appendChild(u)}return d(),n.appendChild(l),n}function Ye(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Xe(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mt(e,t=!0){const n=Ye(e);if(t){const o=Math.floor(n),i=n-o>=.5?1:0,r=5-o-i;return"★".repeat(o)+(i?"½":"")+"☆".repeat(r)}const a=Math.round(n);return"★".repeat(a)+"☆".repeat(5-a)}function _e(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}const ti={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function $t(e,t){if(!e||!t)return null;const n=ti[e];return n?t[n]??e:e}function ni(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-top-picks";const a=e.props?.suggestions??[];if(a.length===0)return n;const o=document.createElement("h3");o.className="gengage-chat-ai-top-picks-title",o.textContent=t.i18n?.aiTopPicksTitle??"Top Picks",n.appendChild(o);const i=document.createElement("div");i.className="gengage-chat-ai-top-picks-cards";for(let r=0;r<a.length;r++){const s=a[r],l=s.role==="winner"||r===0?ai(s,t):oi(s,t);i.appendChild(l)}return n.appendChild(i),n}function ai(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";const a=document.createElement("span");a.className="gengage-chat-ai-toppick-badge",a.textContent=$t(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH",n.appendChild(a);const o=e.product,i=o.discountPercent;if(typeof i=="number"&&i>0){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-discount-badge",p.textContent=`%${Xe(i)}`,n.appendChild(p)}const r=o.imageUrl;if(r&&re(r)){const p=document.createElement("img");p.className="gengage-chat-ai-toppick-img",H(p,"src",r),p.alt=o.name??"",_e(p),n.appendChild(p)}const s=document.createElement("div");s.className="gengage-chat-ai-toppick-body";const c=o.name;if(c){const p=document.createElement("div");p.className="gengage-chat-ai-toppick-name",p.textContent=c,s.appendChild(p)}if(e.reason){const p=document.createElement("div");p.className="gengage-chat-ai-toppick-reason",p.textContent=e.reason,s.appendChild(p)}if(e.labels&&e.labels.length>0&&s.appendChild(Ot(e.labels)),typeof e.expertQualityScore=="number"){const p=document.createElement("div");p.className="gengage-chat-ai-toppick-score",p.textContent=`${e.expertQualityScore}/10`,s.appendChild(p)}if(e.reviewHighlight){const p=document.createElement("blockquote");p.className="gengage-chat-ai-toppick-review",p.textContent=e.reviewHighlight,s.appendChild(p)}const l=o.price,d=o.originalPrice;if(l){const p=document.createElement("div");if(p.className="gengage-chat-ai-toppick-price",d&&d!==l){const g=document.createElement("span");g.className="gengage-chat-ai-toppick-original-price",g.textContent=J(d,t.pricing),p.appendChild(g),p.appendChild(document.createTextNode(" "))}const u=document.createElement("span");u.textContent=J(l,t.pricing),p.appendChild(u),s.appendChild(p)}if(n.appendChild(s),e.action){const p=o.sku??null,u=document.createElement("div");u.className="gengage-chat-ai-toppick-spinner",u.style.display=p&&t.topPicksLoadingSku===p?"":"none",n.appendChild(u);const g=document.createElement("button");g.className="gengage-chat-ai-toppick-cta",g.type="button",g.textContent=t.i18n?.viewDetails??"View Details",g.addEventListener("click",()=>{p&&(u.style.display=""),t.onAction(e.action)}),n.appendChild(g)}return n}function oi(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";const a=e.product,o=a.discountPercent;if(typeof o=="number"&&o>0){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-discount-badge",d.textContent=`%${Xe(o)}`,n.appendChild(d)}const i=a.imageUrl;if(i&&re(i)){const d=document.createElement("img");d.className="gengage-chat-ai-toppick-img",H(d,"src",i),d.alt=a.name??"",_e(d),n.appendChild(d)}const r=document.createElement("div");r.className="gengage-chat-ai-toppick-body";const s=$t(e.role,t.i18n);if(s){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-role",d.textContent=s,r.appendChild(d)}const c=a.name;if(c){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-name",d.textContent=c,r.appendChild(d)}if(e.reason){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-reason",d.textContent=e.reason,r.appendChild(d)}e.labels&&e.labels.length>0&&r.appendChild(Ot(e.labels));const l=a.price;if(l){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price",d.textContent=J(l,t.pricing),r.appendChild(d)}if(n.appendChild(r),e.action){const d=a.sku??null,p=document.createElement("div");p.className="gengage-chat-ai-toppick-spinner",p.style.display=d&&t.topPicksLoadingSku===d?"":"none",n.appendChild(p);const u=document.createElement("button");u.className="gengage-chat-ai-toppick-cta",u.type="button",u.textContent=t.i18n?.viewDetails??"View Details",u.addEventListener("click",()=>{d&&(p.style.display=""),t.onAction(e.action)}),n.appendChild(u)}return n}function Ot(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels";for(const n of e){const a=document.createElement("span");a.className="gengage-chat-ai-toppick-label",a.dataset.sentiment=n.sentiment??"neutral",a.textContent=n.label,t.appendChild(a)}return t}function ii(e,t){const n=document.createElement("div");n.className="gengage-chat-grounding-review";const a=e.props??{},o=a.title,i=a.reviewCount,r=a.action,s=t.i18n?.groundingReviewCta??"Yorumları Oku",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.textContent="📋",n.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body";const d=document.createElement("div");if(d.className="gengage-chat-grounding-review-title",d.textContent=o??"Müşteri Yorumları",l.appendChild(d),i){const u=document.createElement("div");u.className="gengage-chat-grounding-review-subtitle";const g=t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut";u.textContent=g.replace("{count}",i),l.appendChild(u)}n.appendChild(l);const p=document.createElement("span");return p.className="gengage-chat-grounding-review-cta",p.textContent=`${s} →`,n.appendChild(p),r&&(n.style.cursor="pointer",n.addEventListener("click",()=>t.onAction(r))),n}function ri(e,t){const n=document.createElement("div");n.className="gengage-chat-grouping-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const o of a){const i=document.createElement("div");if(i.className="gengage-chat-grouping-card",i.style.cursor="pointer",i.addEventListener("click",()=>t.onAction(o.action)),o.image&&re(o.image)){const l=document.createElement("img");l.className="gengage-chat-grouping-card-img",l.src=o.image,l.alt=o.name,l.width=20,l.height=20,i.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-grouping-card-body";const s=document.createElement("span");if(s.className="gengage-chat-grouping-card-name",s.textContent=o.name,r.appendChild(s),o.description){const l=document.createElement("span");l.className="gengage-chat-grouping-card-desc",l.textContent=o.description,r.appendChild(l)}if(o.labels&&o.labels.length>0){const l=document.createElement("span");l.className="gengage-chat-grouping-card-labels",l.textContent=o.labels.slice(0,3).join(" · "),r.appendChild(l)}i.appendChild(r);const c=document.createElement("span");c.className="gengage-chat-grouping-card-arrow",c.textContent="↳",i.insertBefore(c,i.firstChild),n.appendChild(i)}return n}function si(e,t){const n=document.createElement("div");n.className="gengage-chat-suggested-search-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const o of a){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card",i.style.cursor="pointer",i.addEventListener("click",()=>t.onAction(o.action)),o.image&&re(o.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.src=o.image,c.alt=o.shortName,c.width=40,c.height=40,i.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-suggested-search-card-body";const s=document.createElement("div");if(s.className="gengage-chat-suggested-search-card-name",s.textContent=o.shortName,r.appendChild(s),o.detailedMessage){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-desc",c.textContent=o.detailedMessage,r.appendChild(c)}if(o.whyDifferent){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-diff",c.textContent=o.whyDifferent,r.appendChild(c)}i.appendChild(r),n.appendChild(i)}return n}function ci(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 li(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons";const n=e.props?.productName;if(n){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=n,t.appendChild(i)}const a=e.props?.pros,o=e.props?.cons;if(a&&a.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list";for(const r of a){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(o&&o.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list";for(const r of o){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}function di(e,t){const n=e.props?.groups??[],a=e.props?.filterTags??[],o=document.createElement("div");if(o.className="gengage-chat-categories",n.length===0)return o;const i=document.createElement("div");i.className="gengage-chat-categories-tabs",i.setAttribute("role","tablist");const r=[],s=[],c=l=>{for(let d=0;d<r.length;d++){const p=d===l;r[d].classList.toggle("gengage-chat-categories-tab--active",p),r[d].setAttribute("aria-selected",String(p)),r[d].tabIndex=p?0:-1,s[d].style.display=p?"":"none"}};for(let l=0;l<n.length;l++){const d=n[l],p=`gengage-cat-tab-${l}`,u=`gengage-cat-panel-${l}`,g=document.createElement("button");g.className="gengage-chat-categories-tab",g.type="button",g.id=p,g.setAttribute("role","tab"),g.setAttribute("aria-controls",u),g.setAttribute("aria-selected",String(l===0)),g.tabIndex=l===0?0:-1,l===0&&g.classList.add("gengage-chat-categories-tab--active"),g.textContent=d.groupName,g.addEventListener("click",()=>c(l)),g.addEventListener("keydown",_=>{let y=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?y=(l+1)%n.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?y=(l-1+n.length)%n.length:_.key==="Home"?y=0:_.key==="End"&&(y=n.length-1),y>=0&&(_.preventDefault(),c(y),r[y].focus())}),r.push(g),i.appendChild(g);const m=document.createElement("div");m.className="gengage-chat-categories-grid",m.id=u,m.setAttribute("role","tabpanel"),m.setAttribute("aria-labelledby",p),l!==0&&(m.style.display="none");for(const _ of d.products){const y=gi(_,t);m.appendChild(y)}s.push(m)}o.appendChild(i);for(const l of s)o.appendChild(l);if(a.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags";for(const d of a){const p=document.createElement("button");p.className="gengage-chat-categories-filter-tag",p.type="button",p.textContent=d.title,d.action&&p.addEventListener("click",()=>{t.onAction(d.action)}),l.appendChild(p)}o.appendChild(l)}return o}function gi(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&re(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.src=e.imageUrl,i.alt=e.name,n.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-product-card-body";const o=document.createElement("div");if(o.className="gengage-chat-product-card-name",o.textContent=e.name,a.appendChild(o),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=e.price,a.appendChild(i)}return n.appendChild(a),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",()=>{t.onProductSelect?.(e)})),n}function pi(e,t){const n=document.createElement("div");n.className="gengage-chat-handoff-notice",n.setAttribute("role","alert");const a=document.createElement("span");a.className="gengage-chat-handoff-notice-icon",a.textContent="👤",a.setAttribute("aria-hidden","true"),n.appendChild(a);const o=document.createElement("h4");o.className="gengage-chat-handoff-notice-heading",o.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",n.appendChild(o);const i=e.props?.summary;if(i){const r=document.createElement("p");r.className="gengage-chat-handoff-notice-summary",r.textContent=i,n.appendChild(r)}return n}function ui(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",g=>{g.target.closest("a")||t.onProductSelect?.(n)});const o=n.imageUrl;if(o&&oe(o)){const g=document.createElement("div");g.className="gengage-chat-product-summary__image";const m=document.createElement("img");H(m,"src",o);const _=n.name;_&&(m.alt=_),_e(m),g.appendChild(m),a.appendChild(g)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content";const r=n.brand,s=n.name;if(s){const g=document.createElement("div");g.className="gengage-chat-product-summary__name";const m=r&&!s.toLowerCase().startsWith(r.toLowerCase());g.textContent=m?`${r} ${s}`:s,i.appendChild(g)}const c=n.rating,l=n.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const g=document.createElement("div");if(g.className="gengage-chat-product-summary__rating",g.textContent=Mt(Ye(c)),typeof l=="number"&&Number.isFinite(l)){const m=document.createElement("span");m.className="gengage-chat-product-summary__review-count",m.textContent=` (${l})`,g.appendChild(m)}i.appendChild(g)}const d=n.price,p=n.originalPrice;if(d){const g=document.createElement("div");if(g.className="gengage-chat-product-summary__price",p&&p!==d){const _=document.createElement("span");_.className="gengage-chat-product-summary__price-original",_.textContent=J(p,t.pricing),g.appendChild(_),g.appendChild(document.createTextNode(" "))}const m=document.createElement("span");m.className="gengage-chat-product-summary__price-current",m.textContent=J(d,t.pricing),g.appendChild(m),i.appendChild(g)}a.appendChild(i);const u=n.url;if(u&&oe(u)){const g=document.createElement("a");g.className="gengage-chat-product-summary__cta",H(g,"href",u),H(g,"target","_blank"),H(g,"rel","noopener noreferrer"),g.textContent=t.i18n?.productCtaLabel??"İncele",a.appendChild(g)}return a}function Dt(e){const t=e.min??1,n=e.max??99,a=Math.min(t,n),o=Math.max(t,n),i=Math.max(a,Math.min(o,e.initial??a)),r=e.compact??!1;let s=i;const c=document.createElement("div");c.className=`gengage-qty-stepper${r?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=e.decreaseSymbol??"−",l.setAttribute("aria-label",e.decreaseLabel??"Azalt");const d=document.createElement("span");d.className="gengage-qty-value",d.textContent=String(s),d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true");const p=document.createElement("button");p.className="gengage-qty-btn",p.type="button",p.textContent=e.increaseSymbol??"+",p.setAttribute("aria-label",e.increaseLabel??"Artır");const u=document.createElement("button");u.className="gengage-qty-submit",u.type="button",r?(u.textContent=e.submitIcon??"🛒",u.title=e.label??"Sepete Ekle"):u.textContent=e.label??"Sepete Ekle";function g(){l.disabled=s<=a,p.disabled=s>=o}return l.addEventListener("click",m=>{m.stopPropagation(),s>a&&(s--,d.textContent=String(s),g())}),p.addEventListener("click",m=>{m.stopPropagation(),s<o&&(s++,d.textContent=String(s),g())}),u.addEventListener("click",m=>{m.stopPropagation(),e.onSubmit(s)}),c.addEventListener("click",m=>{m.stopPropagation()}),g(),c.appendChild(l),c.appendChild(d),c.appendChild(p),c.appendChild(u),c}function Bt(){return window.innerWidth<768}const Rt={ActionButtons:({element:e,context:t})=>hi(e,t),ActionButton:({element:e,context:t})=>fi(e,t),ProductCard:({element:e,context:t})=>mi(e,t),ProductDetailsPanel:({element:e,context:t})=>bi(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>yi(e,t,n,a),ReviewHighlights:({element:e,context:t})=>ei(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage}),ComparisonTable:({element:e,context:t})=>wi(e,t),AITopPicks:({element:e,context:t})=>ni(e,t),GroundingReviewCard:({element:e,context:t})=>ii(e,t),AIGroupingCards:({element:e,context:t})=>ri(e,t),AISuggestedSearchCards:({element:e,context:t})=>si(e,t),ProsAndCons:({element:e})=>li(e),CategoriesContainer:({element:e,context:t})=>di(e,t),HandoffNotice:({element:e,context:t})=>pi(e,t),ProductSummaryCard:({element:e,context:t})=>ui(e,t),Divider:({element:e})=>xi(e)},Qe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const o=t(a);o&&n.appendChild(o)}return n};function Zt(){return{...Rt}}function Ut(e,t,n=Rt,a=Qe){return Yn({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function hi(e,t){const n=document.createElement("div");n.className="gengage-chat-action-buttons";const a=e.props?.buttons;if(a)for(const o of a){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=o.label,i.addEventListener("click",()=>t.onAction(o.action)),n.appendChild(i)}return n}function fi(e,t){const n=document.createElement("button");n.className="gengage-chat-action-btn";const a=e.props?.label;typeof a=="string"&&(n.textContent=a);const o=e.props?.action;return o&&n.addEventListener("click",()=>t.onAction(o)),n}function mi(e,t){const n=document.createElement("div");n.className="gengage-chat-product-card";const a=e.props?.product??e.props;if(!a)return n;t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",h=>{h.target.closest(".gengage-chat-product-card-atc")||h.target.closest(".gengage-chat-product-card-cta")||t.onProductSelect?.(a)}));const o=a.imageUrl;if(o&&oe(o)){const h=document.createElement("div");h.className="gengage-chat-product-card-img-wrapper";const x=document.createElement("img");x.className="gengage-chat-product-card-img",x.loading="lazy",H(x,"src",o);const k=a.name;k&&(x.alt=k),_e(x),h.appendChild(x);const E=a.discountPercent;if(typeof E=="number"&&E>0){const v=document.createElement("span");v.className="gengage-chat-product-card-discount-badge",v.textContent=`%${Xe(E)}`,h.appendChild(v)}const L=a.sku;if(L){const v=document.createElement("button");v.className="gengage-chat-find-similar-pill",v.type="button",v.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",v.addEventListener("click",S=>{S.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:L,...o?{image_url:o}:{}}})}),h.appendChild(v)}const f=a.sku;if(f&&t.onFavoriteToggle){const v=document.createElement("button");v.className="gengage-chat-favorite-btn",v.type="button",v.setAttribute("aria-label","Favorilere ekle");const S=t.favoritedSkus?.has(f)??!1;S&&v.classList.add("gengage-chat-favorite-btn--active");const A=S?"currentColor":"none";v.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${A}" 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>`,v.addEventListener("click",$=>{$.stopPropagation(),v.classList.toggle("gengage-chat-favorite-btn--active");const N=v.querySelector("svg");N&&N.setAttribute("fill",v.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(f,a)}),h.appendChild(v)}n.appendChild(h)}const i=document.createElement("div");i.className="gengage-chat-product-card-body";const r=a.brand;if(r){const h=document.createElement("div");h.className="gengage-chat-product-card-brand",h.textContent=r,i.appendChild(h)}const s=a.name;if(s){const h=document.createElement("div");h.className="gengage-chat-product-card-name",h.textContent=s,i.appendChild(h)}const c=a.rating,l=a.reviewCount;if(typeof c=="number"&&Number.isFinite(c)){const h=document.createElement("div");if(h.className="gengage-chat-product-card-rating",h.textContent=Mt(c),typeof l=="number"&&Number.isFinite(l)){const x=document.createElement("span");x.className="gengage-chat-product-card-review-count",x.textContent=` (${l})`,h.appendChild(x)}i.appendChild(h)}const d=a.price,p=a.originalPrice;if(a.price_async===!0){const h=document.createElement("div");h.className="gengage-chat-product-card-price";const x=document.createElement("span");x.className="gengage-chat-price-skeleton",h.appendChild(x),i.appendChild(h),setTimeout(()=>{x.parentElement&&(d?x.replaceWith(document.createTextNode(J(d,t.pricing))):x.remove())},300)}else if(d){const h=document.createElement("div");if(h.className="gengage-chat-product-card-price",p&&p!==d){const k=document.createElement("span");k.className="gengage-chat-product-card-original-price",k.textContent=J(p,t.pricing),h.appendChild(k),h.appendChild(document.createTextNode(" "))}const x=document.createElement("span");x.textContent=J(d,t.pricing),h.appendChild(x),i.appendChild(h)}const g=a.inStock;if(typeof g=="boolean"){const h=document.createElement("div");h.className=`gengage-chat-product-card-stock ${g?"is-in-stock":"is-out-of-stock"}`,h.textContent=g?t.i18n?.inStockLabel??"Stokta":t.i18n?.outOfStockLabel??"Tükendi",i.appendChild(h)}const m=a.promotions;if(m&&m.length>0){const h=document.createElement("div");h.className="gengage-chat-product-card-promos";for(const x of m){const k=document.createElement("span");k.className="gengage-chat-product-card-promo-badge",k.textContent=x,h.appendChild(k)}i.appendChild(h)}n.appendChild(i);const _=a.url,y=a.sku,z=e.props?.action;if(z){const h=document.createElement("button");h.className="gengage-chat-product-card-cta",h.type="button",h.textContent=z.title||t.i18n?.productCtaLabel||"Incele",h.addEventListener("click",()=>t.onAction(z)),n.appendChild(h)}else if(_&&oe(_)){const h=document.createElement("a");h.className="gengage-chat-product-card-cta",H(h,"href",_),H(h,"target","_blank"),H(h,"rel","noopener noreferrer"),h.textContent=t.i18n?.productCtaLabel??"İncele",h.addEventListener("click",x=>{t.onProductClick&&y&&(x.preventDefault(),t.onProductClick({sku:y,url:_}))}),n.appendChild(h)}const I=a.cartCode;if(I&&y){const h=Dt({compact:!0,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:x=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:y,cartCode:I,quantity:x}})}});h.classList.add("gengage-chat-product-card-atc"),n.appendChild(h)}if(t.comparisonSelectMode&&y&&t.onToggleComparisonSku){const h=document.createElement("div");h.className="gengage-chat-comparison-select-wrapper";const x=document.createElement("input");return x.type="checkbox",x.className="gengage-chat-comparison-checkbox",x.checked=t.comparisonSelectedSkus?.includes(y)??!1,x.addEventListener("change",()=>{t.onToggleComparisonSku?.(y)}),h.appendChild(x),h.appendChild(n),h}return n}function bi(e,t){const n=document.createElement("article");n.className="gengage-chat-product-details-panel";const a=e.props?.product??e.props;if(!a)return n;const o=a.images,i=a.imageUrl,r=a.sku;if(o&&o.length>1){const f=document.createElement("div");f.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const v=document.createElement("img");v.className="gengage-chat-product-details-img";const S=o.find(q=>oe(q));S&&H(v,"src",S);const A=a.name;A&&(v.alt=A),_e(v),f.appendChild(v);const $=document.createElement("div");$.className="gengage-chat-product-gallery-thumbs";let N=null,T=0;for(let q=0;q<o.length;q++){const Q=o[q];if(!Q||!oe(Q))continue;const W=document.createElement("img");W.className="gengage-chat-product-gallery-thumb",q===0&&(W.classList.add("gengage-chat-product-gallery-thumb--active"),N=W),H(W,"src",Q),W.alt=`${A??"Product"} ${q+1}`,W.width=48,W.height=48,_e(W),W.addEventListener("click",()=>{H(v,"src",Q),N&&N.classList.remove("gengage-chat-product-gallery-thumb--active"),W.classList.add("gengage-chat-product-gallery-thumb--active"),N=W,T=q}),$.appendChild(W)}let j=0;const X=50;if(v.addEventListener("touchstart",q=>{j=q.changedTouches[0].clientX},{passive:!0}),v.addEventListener("touchend",q=>{const Q=q.changedTouches[0].clientX,W=j-Q;if(Math.abs(W)<X)return;const ft=$.querySelectorAll(".gengage-chat-product-gallery-thumb"),mt=W>0?Math.min(T+1,ft.length-1):Math.max(T-1,0);mt!==T&&ft[mt]&&ft[mt].click()}),f.appendChild($),r){const q=document.createElement("button");q.className="gengage-chat-find-similar-pill",q.type="button",q.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",q.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...S?{image_url:S}:{}}})}),f.appendChild(q)}n.appendChild(f)}else if(i&&oe(i)){const f=document.createElement("div");f.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const v=document.createElement("img");v.className="gengage-chat-product-details-img",v.loading="lazy",H(v,"src",i),_e(v);const S=a.name;if(S&&(v.alt=S),f.appendChild(v),r){const A=document.createElement("button");A.className="gengage-chat-find-similar-pill",A.type="button",A.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",A.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...i?{image_url:i}:{}}})}),f.appendChild(A)}n.appendChild(f)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const f=document.createElement("h3");f.className="gengage-chat-product-details-title",f.textContent=c,s.appendChild(f)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const f=document.createElement("div");if(f.className="gengage-chat-product-details-rating",f.textContent=`★ ${Ye(l).toFixed(1)}`,typeof d=="number"&&Number.isFinite(d)){const v=document.createElement("span");v.className="gengage-chat-product-details-review-count",v.textContent=` (${d})`,f.appendChild(v)}s.appendChild(f)}const p=a.price,u=a.originalPrice;if(a.price_async===!0){const f=document.createElement("div");f.className="gengage-chat-product-details-price";const v=document.createElement("span");v.className="gengage-chat-price-skeleton",f.appendChild(v),s.appendChild(f),setTimeout(()=>{if(v.parentElement)if(p){const S=document.createElement("span");S.className="gengage-chat-product-details-current-price",S.textContent=J(p,t.pricing),v.replaceWith(S)}else v.remove()},300)}else if(p){const f=document.createElement("div");if(f.className="gengage-chat-product-details-price",u&&u!==p){const S=document.createElement("span");S.className="gengage-chat-product-details-original-price",S.textContent=J(u,t.pricing),f.appendChild(S),f.appendChild(document.createTextNode(" "))}const v=document.createElement("span");v.className="gengage-chat-product-details-current-price",v.textContent=J(p,t.pricing),f.appendChild(v),s.appendChild(f)}const m=a.inStock;if(typeof m=="boolean"){const f=document.createElement("div");f.className=`gengage-chat-product-details-stock ${m?"is-in-stock":"is-out-of-stock"}`,f.textContent=m?"Stokta var":"Stokta yok",s.appendChild(f)}const _=a.promotions;if(_&&_.length>0){const f=document.createElement("div");f.className="gengage-chat-product-details-promos";for(const v of _){const S=document.createElement("span");S.className="gengage-chat-product-details-promo-badge",S.textContent=v,f.appendChild(S)}s.appendChild(f)}const y=a.variants;if(y&&y.length>0){const f=document.createElement("div");f.className="gengage-chat-product-variants";const v=document.createElement("div");v.className="gengage-chat-product-variants-label",v.textContent=t.i18n?.variantsLabel??"Varyantlar",f.appendChild(v);const S=document.createElement("div");S.className="gengage-chat-product-variants-list";for(const A of y){const $=A.name??A.variant_name,N=A.sku;if(!$&&!N)continue;const T=document.createElement("button");T.className="gengage-chat-product-variant-btn",T.type="button";const j=$??N??"",X=A.price;X&&String(X)!==String(p)?T.textContent=`${j} - ${J(String(X),t.pricing)}`:T.textContent=j,N&&T.addEventListener("click",()=>{t.onAction({title:j,type:"launchVariant",payload:{sku:N}})}),S.appendChild(T)}f.appendChild(S),s.appendChild(f)}const z=a.sku,I=a.cartCode,h=document.createElement("div");h.className="gengage-chat-product-details-actions";const x=e.props?.action;if(x){const f=document.createElement("button");f.className="gengage-chat-product-details-cta",f.type="button",f.textContent=x.title||t.i18n?.productCtaLabel||"Incele",f.addEventListener("click",()=>t.onAction(x)),h.appendChild(f)}else{const f=a.url;if(f&&oe(f)){const v=document.createElement("a");v.className="gengage-chat-product-details-cta",H(v,"href",f),H(v,"target","_blank"),H(v,"rel","noopener noreferrer"),v.textContent=t.i18n?.productCtaLabel??"Incele",v.addEventListener("click",S=>{t.onProductClick&&z&&(S.preventDefault(),t.onProductClick({sku:z,url:f}))}),h.appendChild(v)}}if(I&&z){const f=Dt({compact:!1,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:v=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:z,cartCode:I,quantity:v}})}});f.classList.add("gengage-chat-product-details-atc-stepper"),h.appendChild(f)}const k=a.url;if(k&&oe(k)){let f=function(T,j){const X=document.createElementNS($,"circle");X.setAttribute("cx",T),X.setAttribute("cy",j),X.setAttribute("r","3"),N.appendChild(X)},v=function(T,j,X,q){const Q=document.createElementNS($,"line");Q.setAttribute("x1",T),Q.setAttribute("y1",j),Q.setAttribute("x2",X),Q.setAttribute("y2",q),N.appendChild(Q)};const S=document.createElement("button");S.className="gengage-chat-product-details-share",S.type="button";const A=t.i18n?.shareButton??"Paylaş";S.title=A,S.setAttribute("aria-label",A);const $="http://www.w3.org/2000/svg",N=document.createElementNS($,"svg");N.setAttribute("width","18"),N.setAttribute("height","18"),N.setAttribute("viewBox","0 0 24 24"),N.setAttribute("fill","none"),N.setAttribute("stroke","currentColor"),N.setAttribute("stroke-width","2"),N.setAttribute("stroke-linecap","round"),N.setAttribute("stroke-linejoin","round"),f("18","5"),f("6","12"),f("18","19"),v("8.59","13.51","15.42","17.49"),v("15.41","6.51","8.59","10.49"),S.appendChild(N),S.addEventListener("click",async()=>{const T=a.name;try{navigator.share?await navigator.share({title:T??"",url:k}):navigator.clipboard&&(await navigator.clipboard.writeText(k),S.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>S.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),h.appendChild(S)}h.childElementCount>0&&s.appendChild(h),n.appendChild(s);const E=a.description,L=a.specifications;return(E||L)&&n.appendChild(_i(E,L,t)),n}function _i(e,t,n){const a=document.createElement("div");a.className="gengage-chat-product-detail-tabs";const o=document.createElement("div");o.className="gengage-chat-product-detail-tab-bar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active",s.type="button",s.textContent=n.i18n?.productInfoTab??"Ürün Bilgileri",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",c.textContent=e,i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab${e?"":" gengage-chat-product-detail-tab--active"}`,s.type="button",s.textContent=n.i18n?.specificationsTab??"Teknik Özellikler",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const d=Array.isArray(t)?t:Object.entries(t).map(([p,u])=>({key:p,value:u}));for(const p of d){const u=document.createElement("tr"),g=document.createElement("td");g.className="gengage-chat-product-specs-key",g.textContent=p.key;const m=document.createElement("td");m.className="gengage-chat-product-specs-value",m.textContent=p.value,u.appendChild(g),u.appendChild(m),l.appendChild(u)}c.appendChild(l),i.push(c)}const r=o.querySelectorAll(".gengage-chat-product-detail-tab");r.forEach((s,c)=>{s.addEventListener("click",()=>{r.forEach(l=>l.classList.remove("gengage-chat-product-detail-tab--active")),s.classList.add("gengage-chat-product-detail-tab--active"),i.forEach((l,d)=>{l.style.display=d===c?"":"none"})})}),a.appendChild(o);for(const s of i)a.appendChild(s);return a}function jt(e,t,n){if(!n||n.type==="related")return e;const a=e.map(o=>{const r=t.elements[o]?.props?.product,s=r?Number(r.price):NaN;return{id:o,price:Number.isFinite(s)?s:1/0}});return a.sort((o,i)=>o.price===1/0&&i.price===1/0?0:o.price===1/0?1:i.price===1/0?-1:n.direction==="desc"?i.price-o.price:o.price-i.price),a.map(o=>o.id)}function vi(e,t,n,a){const o=jt(t,n,a),i=new Map;for(const r of Array.from(e.children)){const s=r.dataset.elementId;s&&i.set(s,r)}for(const r of o){const s=i.get(r);s&&e.appendChild(s)}}function yi(e,t,n,a){const o=document.createElement("div");o.className="gengage-chat-product-grid-wrapper";const i=e.children??[];if(i.length>1&&a?.onSortChange){const l=document.createElement("div");l.className="gengage-chat-product-sort-toolbar";const d=a.productSort??{type:"related"},p=[{label:a.i18n?.sortRelated??"Önerilen",sortState:{type:"related"}},{label:a.i18n?.sortPriceAsc??"Fiyat ↑",sortState:{type:"price",direction:"asc"}},{label:a.i18n?.sortPriceDesc??"Fiyat ↓",sortState:{type:"price",direction:"desc"}}];for(const u of p){const g=document.createElement("button");g.className="gengage-chat-product-sort-btn",g.type="button",d.type===u.sortState.type&&d.direction===u.sortState.direction&&g.classList.add("gengage-chat-product-sort-btn--active"),g.textContent=u.label,g.addEventListener("click",()=>{a.onSortChange?.(u.sortState),vi(r,i,t,u.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(_=>_.classList.remove("gengage-chat-product-sort-btn--active")),g.classList.add("gengage-chat-product-sort-btn--active")}),l.appendChild(g)}if(a.onToggleComparisonSku){const u=document.createElement("div");u.className="gengage-chat-product-sort-separator",l.appendChild(u);const g=document.createElement("button");g.className="gengage-chat-comparison-toggle-btn",g.type="button",a.comparisonSelectMode&&g.classList.add("gengage-chat-comparison-toggle-btn--active"),g.textContent=a.i18n?.compareSelected??"Karşılaştır",g.addEventListener("click",()=>{a.onToggleComparisonSku?.("")}),l.appendChild(g)}o.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-product-grid";const s=jt(i,t,a?.productSort);for(const l of s){if(!t.elements[l])continue;const d=n(l);d&&(d.dataset.elementId=l,r.appendChild(d))}if(Bt()&&r.classList.add("gengage-chat-product-grid--mobile"),o.appendChild(r),e.props?.endOfList!==!0&&i.length>0){const l=document.createElement("button");l.className="gengage-chat-product-grid-view-more",l.type="button",l.textContent=a?.i18n?.viewMoreLabel??"Daha Fazla Göster",l.addEventListener("click",()=>{a?.onAction({title:"More",type:"moreProductList",payload:{}})}),o.appendChild(l)}if(a?.comparisonSelectMode&&a.comparisonSelectedSkus&&a.comparisonSelectedSkus.length>=2){const l=ci(a.comparisonSelectedSkus,a);o.appendChild(l)}return o}function wi(e,t){const n=e.props??{},a=n.keyDifferencesHtml,o=n.recommended,i=n.products??[],r=n.attributes??[],s=n.highlights??[],c=n.specialCases,l=n.recommendedText,d=n.winnerHits,p=n.productActions;if(!o)return document.createElement("div");const u={recommended:o,products:i,attributes:r,highlights:s,specialCases:c,onProductClick:m=>{t.onProductClick?.({sku:m,url:""})}};l!==void 0&&(u.recommendedText=l),d!==void 0&&(u.winnerHits=d),p!==void 0&&(u.productActions=p),a!==void 0&&(u.keyDifferencesHtml=a),t.i18n&&(u.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const g=Xo(u);return Bt()&&g.classList.add("gengage-chat-comparison--mobile"),g}function xi(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const n=e.props?.label;if(n){const a=document.createElement("div");a.className="gengage-chat-divider-wrapper";const o=document.createElement("span");return o.className="gengage-chat-divider-label",o.textContent=n,a.appendChild(t),a.appendChild(o),a}return t}const ki=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function Ci(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&ki.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 Ei(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 Si(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ti(e){const{container:t,html:n,delayMs:a=30,onTick:o,onComplete:i}=e,r=document.createElement("template");r.innerHTML=n;const s=Ci(r.content.childNodes);if(Si()||s.length<=1||Ei(s))return t.innerHTML=n,i?.(),{complete(){},cancel(){},isRunning:!1};t.innerHTML="";let c=0,l=null,d=!0;function p(){if(!d||c>=s.length){d=!1,i?.();return}const u=s[c],g=document.createElement("span");g.className="gengage-chat-typewriter-block";for(const m of u)g.appendChild(m.cloneNode(!0));t.appendChild(g),c++,o?.(),c<s.length?l=setTimeout(p,a):(d=!1,i?.())}return p(),{complete(){d&&(l!==null&&clearTimeout(l),d=!1,t.innerHTML=n,i?.())},cancel(){l!==null&&clearTimeout(l),d=!1},get isRunning(){return d}}}function Ii(e){const{container:t,mentions:n,onProductClick:a}=e;if(n.length===0)return;const o=new Map;for(const i of n)i.short_name.length!==0&&o.set(i.short_name.toLowerCase(),i);if(o.size!==0)for(const[i,r]of o){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),l=!1;for(;c&&!l;){const d=c.textContent??"",p=d.toLowerCase().indexOf(i);if(p===-1){c=s.nextNode();continue}const u=d.slice(0,p),g=d.slice(p,p+r.short_name.length),m=d.slice(p+r.short_name.length),_=c.parentNode;if(!_){c=s.nextNode();continue}const y=document.createElement("a");y.className="gengage-product-mention",y.textContent=g,y.href="#",y.addEventListener("click",z=>{z.preventDefault(),a(r.sku)}),u&&_.insertBefore(document.createTextNode(u),c),_.insertBefore(y,c),m&&_.insertBefore(document.createTextNode(m),c),_.removeChild(c),l=!0}}}const zi=new Set(["search","info","review","similar"]),Ai=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function Ni(e){return!!(e.icon&&zi.has(e.icon)||e.action?.type&&Ai.has(e.action.type))}const Ft="gengage_choice_prompter_dismissed";function Pi(e){const t=document.createElement("div");t.className="gengage-chat-choice-prompter";const n=document.createElement("div");n.className="gengage-chat-choice-prompter-heading",n.textContent=e.heading,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-choice-prompter-suggestion",a.textContent=e.suggestion,t.appendChild(a);const o=document.createElement("button");o.type="button",o.className="gengage-chat-choice-prompter-cta",o.textContent=e.ctaLabel,o.addEventListener("click",()=>{qt(),t.remove(),e.onCtaClick()}),t.appendChild(o);const i=document.createElement("button");return i.type="button",i.className="gengage-chat-choice-prompter-dismiss",i.textContent="×",i.setAttribute("aria-label","Dismiss"),i.addEventListener("click",()=>{qt(),t.remove(),e.onDismiss?.()}),t.appendChild(i),t}function Li(){try{return sessionStorage.getItem(Ft)==="1"}catch{return!1}}function qt(){try{sessionStorage.setItem(Ft,"1")}catch{}}const Mi="gengage_assistant",$i=3,le="sessions",te="context",ie="payload",ne="favorites";function Ae(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function ke(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Oi{constructor(t=Mi,n=$i){this._db=null,this._dbName=t,this._version=n}async open(){return this._db?this._db:new Promise((t,n)=>{const a=indexedDB.open(this._dbName,this._version);a.onupgradeneeded=o=>{const i=a.result,r=o.oldVersion;r<1&&(i.createObjectStore(le,{keyPath:["userId","appId","sessionId"]}),i.createObjectStore(te,{keyPath:["sessionId","threadId"]}),i.createObjectStore(ie,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),i.createObjectStore(ne,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(i.objectStoreNames.contains(le)&&i.deleteObjectStore(le),i.objectStoreNames.contains(ie)&&i.deleteObjectStore(ie),i.createObjectStore(le,{keyPath:["userId","appId","sessionId"]}),i.createObjectStore(ie,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),i.objectStoreNames.contains(te)||i.createObjectStore(te,{keyPath:["sessionId","threadId"]})),r<3&&(i.objectStoreNames.contains(ne)||i.createObjectStore(ne,{keyPath:["userId","appId","sku"]}))},a.onsuccess=()=>{this._db=a.result,t(this._db)},a.onerror=()=>n(a.error)})}close(){this._db?.close(),this._db=null}async saveSession(t){const a=this._requireDb().transaction(le,"readwrite");a.objectStore(le).put(t),await ke(a)}async loadSession(t,n,a){const i=this._requireDb().transaction(le,"readonly");return await Ae(i.objectStore(le).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(te,"readwrite");a.objectStore(te).put(t),await ke(a)}async loadContext(t,n){const o=this._requireDb().transaction(te,"readonly");return await Ae(o.objectStore(te).get([t,n]))??null}async deleteContextsAfterThread(t,n){const o=this._requireDb().transaction(te,"readwrite"),r=o.objectStore(te).openCursor();await new Promise((s,c)=>{r.onsuccess=()=>{const l=r.result;if(!l){s();return}const d=l.value;if(d.sessionId===t&&d.threadId>n)try{l.delete()}catch{}l.continue()},r.onerror=()=>c(r.error)}),await ke(o)}async loadLatestContext(t){const o=this._requireDb().transaction(te,"readonly").objectStore(te),i=IDBKeyRange.bound([t,""],[t,"￿"]);return new Promise((r,s)=>{const c=o.openCursor(i,"prev");c.onsuccess=()=>{const l=c.result;r(l?l.value:null)},c.onerror=()=>s(c.error)})}async savePayload(t){const a=this._requireDb().transaction(ie,"readwrite");a.objectStore(ie).put(t),await ke(a)}async loadPayload(t,n){const o=this._requireDb().transaction(ie,"readonly");return await Ae(o.objectStore(ie).get([t,n]))??null}async loadPayloadsByThread(t){const o=this._requireDb().transaction(ie,"readonly").objectStore(ie).index("threadId"),i=[];return new Promise((r,s)=>{const c=o.openCursor(IDBKeyRange.only(t));c.onsuccess=()=>{const l=c.result;if(!l){r(i);return}i.push(l.value),l.continue()},c.onerror=()=>s(c.error)})}async saveFavorite(t){const a=this._requireDb().transaction(ne,"readwrite");a.objectStore(ne).put(t),await ke(a)}async removeFavorite(t,n,a){const i=this._requireDb().transaction(ne,"readwrite");i.objectStore(ne).delete([t,n,a]),await ke(i)}async loadFavorites(t,n){const o=this._requireDb().transaction(ne,"readonly");return(await Ae(o.objectStore(ne).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const i=this._requireDb().transaction(ne,"readonly");return await Ae(i.objectStore(ne).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const Di=["comparisonTable","groupList","productDetailsSimilars","productList"];class Bi{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(Di);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 Ri{constructor(t){this.deps=t,this.snapshots=new Map,this.snapshotTypes=new Map,this.activePanelMessageId=null,this.currentType=null,this.threads=[]}snapshotForMessage(t){const n=this.deps.drawer();if(!n?.hasPanelContent()||n.isPanelLoading())return;const a=n.getPanelContentElement();if(!a)return;const o=a.cloneNode(!0);this.snapshots.set(t,o),this.currentType&&this.snapshotTypes.set(t,this.currentType)}attachClickHandler(t){const a=this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(t)}"]`);a&&(a.style.cursor="pointer",a.addEventListener("click",()=>this.restoreForMessage(t)))}restoreForMessage(t){const n=this.snapshots.get(t);if(!n)return!1;const a=this.deps.shadow(),o=this.deps.drawer();this.activePanelMessageId&&a?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"),a?.querySelector(`[data-message-id="${CSS.escape(t)}"]`)?.classList.add("gengage-chat-bubble--active"),this.activePanelMessageId=t,o?.setPanelContent(n.cloneNode(!0));const r=this.snapshotTypes.get(t);return r&&(this.currentType=r,this.updateTopBar(r)),!0}notifyExtension(t){const n=this.deps.bridge();t?setTimeout(()=>n?.send("maximize-pdp",{}),350):setTimeout(()=>n?.send("minify-pdp",{}),200)}titleForComponent(t){const n=this.deps.i18n();switch(t){case"ProductDetailsPanel":return n.panelTitleProductDetails;case"ProductGrid":return n.panelTitleSimilarProducts;case"ComparisonTable":return n.panelTitleComparisonResults;case"AIGroupingCards":return n.panelTitleCategories;default:return""}}updateTopBar(t){const n=this.deps.currentThreadId();if(!n)return;const a=this.threads.indexOf(n),o=a>0,i=a>=0&&a<this.threads.length-1,r=this.titleForComponent(t);this.deps.drawer()?.updatePanelTopBar(o,i,r)}updateTopBarForLoading(t){const n=this.deps.i18n(),o={productDetails:n.panelTitleProductDetails,productList:n.panelTitleSimilarProducts,comparisonTable:n.panelTitleComparisonResults,groupList:n.panelTitleCategories}[t]??"";if(o){const i=this.deps.currentThreadId(),r=i?this.threads.indexOf(i):-1,s=r>0,c=r>=0&&r<this.threads.length-1;this.deps.drawer()?.updatePanelTopBar(s,c,o)}}updateExtendedMode(t){const a={ComparisonTable:"comparisonTable",AIGroupingCards:"groupList",ProductDetailsPanel:"productDetails",ProductGrid:"productList"}[t]??null;this.deps.extendedModeManager()?.setPanelContentType(a)}navigateBack(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>0){const a=this.threads[n-1];a&&this.deps.rollbackToThread(a)}}navigateForward(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>=0&&n<this.threads.length-1){const a=this.threads[n+1];a&&this.deps.rollbackToThread(a)}}toPanelSpec(t){const n=t.elements[t.root];if(!n||n.type!=="ProductCard")return t;const a={...n,type:"ProductDetailsPanel"};return{root:t.root,elements:{...t.elements,[t.root]:a}}}destroy(){this.snapshots.clear(),this.snapshotTypes.clear(),this.activePanelMessageId=null,this.currentType=null,this.threads=[]}}class Ht{constructor(t){this.favoritedSkus=new Set,this._db=t}get db(){return this._db}set db(t){this._db=t}async persist(t){if(!this._db)return;const n=t.messages.map(o=>{const i={id:o.id,role:o.role,timestamp:o.timestamp,status:o.status==="streaming"?"done":o.status};return o.threadId!==void 0&&(i.threadId=o.threadId),o.content!==void 0&&(i.content=o.content),o.silent&&(i.silent=!0),i}),a={};for(const[o,i]of t.panelSnapshots)i.querySelector(".gengage-chat-panel-skeleton")||(a[o]=i.innerHTML);await this._db.saveSession({userId:t.userId,appId:t.appId,sessionId:t.sessionId,messages:n,currentThreadId:t.currentThreadId,lastThreadId:t.lastThreadId,createdAt:t.chatCreatedAt,panelThreads:t.panelThreads.length>0?t.panelThreads:void 0,thumbnailEntries:t.thumbnailEntries.length>0?t.thumbnailEntries:void 0,panelSnapshotHtml:Object.keys(a).length>0?a:void 0}),t.lastBackendContext&&t.currentThreadId&&await this._db.saveContext({sessionId:t.sessionId,threadId:t.currentThreadId,context:t.lastBackendContext});for(const o of t.messages)o.uiSpec&&o.threadId&&await this._db.savePayload({threadId:o.threadId,messageId:o.id,uiSpec:o.uiSpec});try{sessionStorage.setItem("gengage_restore_session_id",t.sessionId)}catch{}}async saveAndOpenURL(t,n,a){try{await n()}catch{}a?.send("openURLInNewTab",{url:t}),window.location.href=t}async loadPayload(t,n){if(!this._db)return null;for(let a=0;a<3;a++){try{const o=await this._db.loadPayload(t,n);if(o)return o.uiSpec}catch{}a<2&&await new Promise(o=>setTimeout(o,100))}return null}async loadFavorites(t,n){if(this._db)try{const a=await this._db.loadFavorites(t,n);for(const o of a)this.favoritedSkus.add(o.sku)}catch{}}async toggleFavorite(t,n,a,o){this._db&&(this.favoritedSkus.has(a)?(this.favoritedSkus.delete(a),await this._db.removeFavorite(t,n,a)):(this.favoritedSkus.add(a),await this._db.saveFavorite({userId:t,appId:n,sku:a,name:o.name,imageUrl:o.imageUrl,price:o.price,savedAt:new Date().toISOString()})))}close(){this._db?.close(),this._db=null}}const Vt="gengage_kvkk_shown",Zi=["kvkk","kişisel veri","kisisel veri"],Ui=/\b6698\b/;function et(e){const t=e.toLowerCase();return Zi.some(n=>t.includes(n))||Ui.test(t)}function Gt(e){try{return localStorage.getItem(`${Vt}_${e}`)==="1"}catch{return!1}}function ji(e){try{localStorage.setItem(`${Vt}_${e}`,"1")}catch{}}function Fi(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const o of a)if(et(o.textContent??"")){o.remove();break}return n.innerHTML.trim()}function qi(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(et(n.textContent??""))return n.outerHTML;return null}const Hi={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function Vi(e){return e?Hi[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const Gi=':host{all:initial;font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px)}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 12px);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(15, 23, 42, .18));--_gengage-border-color: var(--gengage-border-color, #e5e7eb);--_gengage-discount-color: var(--gengage-discount-color, #ef4444);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #0f172a47;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #0f172a47}.gengage-chat-launcher svg{width:24px;height:24px}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:#1e293b;color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:#1e293b}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-proactive{position:fixed;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 14px);right:var(--_gengage-chat-launcher-right);width:280px;padding:16px 18px;border-radius:16px;background:#fff;box-shadow:0 8px 30px #0000001f,0 2px 8px #0000000f;opacity:0;transform:translateY(8px) scale(.96);transition:opacity .25s ease,transform .25s ease;z-index:2147483645}.gengage-chat-proactive--visible{opacity:1;transform:translateY(0) scale(1)}.gengage-chat-proactive-message{margin:0 0 12px;font-size:14px;line-height:1.5;color:#1f2937}.gengage-chat-proactive-actions{display:flex;gap:8px}.gengage-chat-proactive-accept{flex:1;padding:8px 16px;border:none;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .15s ease}.gengage-chat-proactive-accept:hover{filter:brightness(1.08)}.gengage-chat-proactive-dismiss{position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:transparent;color:#64748b;font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center}.gengage-chat-proactive-dismiss:hover{color:#475569;background:#f1f5f9}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform-origin:right center;clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:16px;bottom:calc(16px + env(safe-area-inset-bottom))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;padding-bottom:env(safe-area-inset-bottom,0px);clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile.gengage-chat-root--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}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;border:2px solid rgba(255,255,255,.15)}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffbf;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-close{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;width:440px;min-width:440px;border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;background:#f8fafc}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:#e5e7eb;position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:24px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:#f1f5f9;color:#334155}.gengage-chat-panel--collapsed{flex:0 0 0px!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;border-right:none!important;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #fff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:#fff;padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #2563eb);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #fff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:#f3f4f6;color:#1f2937;border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #2563eb);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-accent-primary, #3b82f6);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:#f3f4f6;padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--gengage-chat-success, #4caf50)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-chat-primary, #1976d2);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:#991b1b;font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #fff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 2px #3b82f626}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:#1f2937;resize:none;overflow-y:hidden}@media(max-width:767px){.gengage-chat-input{max-height:40px;white-space:nowrap;overflow:hidden}.gengage-chat-send{width:44px;height:44px;min-width:44px}}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 4px #0000001f}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#d1d5db;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;gap:8px;padding:6px 0 4px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.gengage-chat-action-buttons::-webkit-scrollbar{display:none}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 16px #0000001f}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:#1f2937;line-height:1.35;margin-bottom:0;min-height:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-card-review-count{color:#64748b;font-size:10px}.gengage-chat-product-card-price{display:flex;align-items:baseline;justify-content:center;gap:4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:#64748b;font-weight:400;font-size:12px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #3b82f6);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid #f1f5f9;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #0b24d6);background:#f8fafc}.gengage-chat-product-card-cta:active{background:#f1f5f9}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid #f3f4f6;background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-product-summary__rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-summary__review-count{color:#6b7280;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:#6b7280;font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #2563eb);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #2563eb);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:#1f2937}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:#f8fafc}.gengage-chat-review-tab--active{background:#f1f5f9;border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;color:#334155;box-shadow:0 1px 2px #0000000a}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:#16a34a}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:#f1f5f9;color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:#00000073;z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid #f1f5f9;border-radius:0;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-weight:700;font-size:13px}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid #f1f5f9;border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #3b82f6);border-bottom-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:#f8fafc}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid #f1f5f9;width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:#1f2937;border-bottom:1px solid #f1f5f9}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}.gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(0 0 0 100%);opacity:0;pointer-events:none;box-shadow:none}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(100% 0 0 0);opacity:0;pointer-events:none;box-shadow:none}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #3b82f6);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}@media(max-width:768px){.gengage-chat-panel-divider{display:none}.gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:column}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:100%;min-width:0;max-width:none;max-height:30dvh;border-right:none;border-bottom:1px solid var(--_gengage-border-color);padding:0 12px 12px;margin:0;border-radius:0;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-product-details-media{min-height:140px}.gengage-chat-product-details-title{font-size:15px}.gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-product-card-img{height:180px}}@media(max-width:480px){.gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-bubble{max-width:100%}}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#92400e;font-size:16px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:#16a34a;text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:#f8fafc}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid #f1f5f9}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid #f1f5f9;vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:#f8fafc;margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #3b82f6);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:#f8fafc;color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-proactive,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-cards{display:flex;flex-direction:column;gap:10px}.gengage-chat-ai-toppick-discount-badge{position:absolute;top:8px;left:8px;background:var(--gengage-discount-bg, #ef4444);color:#fff;font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;z-index:1}.gengage-chat-ai-toppick-card--winner{position:relative;display:flex;flex-direction:column;border:2px solid var(--gengage-primary-color, #3b82f6);border-radius:12px;background:#fff;overflow:hidden;transition:box-shadow .2s ease}.gengage-chat-ai-toppick-card--winner:hover{box-shadow:0 4px 16px #3b82f626}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:140px;object-fit:contain;background:#f8fafc}.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;background:#fff;padding:10px;transition:box-shadow .2s ease,transform .15s ease}.gengage-chat-ai-toppick-card--compact:hover{box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:64px;height:64px;object-fit:contain;border-radius:8px;background:#f8fafc;flex-shrink:0}.gengage-chat-ai-toppick-badge{position:absolute;top:8px;left:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;text-transform:uppercase;padding:2px 8px;border-radius:4px;z-index:1;letter-spacing:.5px}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:4px;padding:10px;flex:1;min-width:0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0}.gengage-chat-ai-toppick-name{font-size:13px;font-weight:600;color:var(--gengage-text-primary, #1e293b);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #3b82f6);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:#f1f5f9;color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-ai-toppick-reason{font-size:12px;color:var(--gengage-chat-text-secondary, #666);line-height:1.4;margin-top:4px}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:2px 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b)}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 20px);margin:6px 10px 10px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:auto;margin:0;padding:6px 14px;flex-shrink:0;align-self:center}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:3}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}@media(max-width:768px){.gengage-chat-ai-top-picks-cards{flex-direction:row;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;gap:10px;padding-bottom:4px}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{min-width:280px;max-width:280px;flex-shrink:0;scroll-snap-align:start}.gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:100%;height:100px;border-radius:8px 8px 0 0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:6px 10px 10px;align-self:stretch}.gengage-chat-rollback-btn{left:-24px}}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #3b82f6);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #3b82f6);flex-shrink:0}.gengage-chat-grouping-card-img{width:20px;height:20px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active,.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;left:8px;z-index:2;width:18px;height:18px;cursor:pointer;accent-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-comparison-floating-btn{display:block;width:100%;margin-top:8px;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center}.gengage-chat-comparison-floating-btn:hover{background:var(--gengage-primary-hover, #2563eb)}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:#f8fafc;min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:#f3f4f6;border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #3b82f6);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #3b82f6);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:wrap}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:#f3f4f6;border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:6px;left:6px;padding:2px 6px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px}.gengage-chat-product-card-stock.is-in-stock{color:var(--_gengage-success-color)}.gengage-chat-product-card-stock.is-out-of-stock{color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:8px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap}.gengage-chat-thumbnails-column{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:4px;z-index:2;pointer-events:auto}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid #e5e7eb;border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:10;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:#1f2937;margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:4px;right:6px;padding:2px 6px;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:#f8fafc;border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:#16a34a;background:#dcfce7}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile .gengage-chat-comparison-table,.gengage-chat-comparison--mobile .gengage-chat-comparison-table thead,.gengage-chat-comparison--mobile .gengage-chat-comparison-table tbody{display:block}.gengage-chat-comparison--mobile .gengage-chat-comparison-table tr{display:flex;flex-wrap:wrap}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:#f3f4f6}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:#1f2937;-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #3b82f6);border-color:var(--gengage-primary-color, #3b82f6);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#1e293b;color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-proactive-accept:focus-visible,.gengage-chat-proactive-dismiss:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}';function Wi(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function V(e,t){const n={event:e,...t};Wi()&&window.dataLayer.push(n)}function Ki(e){V("gengage-on-init",{gengage_widget:e})}function Ji(e){V("gengage-show",{gengage_widget:e})}function Yi(e,t){V("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function Xi(e){V("gengage-find-similars",{gengage_sku:e})}function Qi(e){V("gengage-compare-preselection",{gengage_sku:e})}function er(e){V("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function tr(){V("gengage-compare-clear")}function nr(e){V("gengage-compare-received",{gengage_product_count:e})}function ar(e){V("gengage-like-product",{gengage_sku:e})}function or(){V("gengage-like-list")}function ir(e,t){V("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function rr(e,t){V("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function sr(e,t){V("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function cr(){V("gengage-message-sent")}function Wt(){V("gengage-message-received")}function lr(){V("gengage-conversation-start")}function dr(){V("gengage-voice-input")}function b(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 p=0;p<d.length;p++){const u=d[p];u in s||(s[u]=l[u].bind(s))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function r(s){var c;const l=n?.Parent?new i:this;a(l,s),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(r,"init",{value:a}),Object.defineProperty(r,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class Ce extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Kt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Jt={};function de(e){return Jt}function Yt(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,o])=>t.indexOf(+a)===-1).map(([a,o])=>o)}function tt(e,t){return typeof t=="bigint"?t.toString():t}function nt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function at(e){return e==null}function ot(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function gr(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let o=(a.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(a)){const c=a.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,r=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return r%s/10**i}const Xt=Symbol("evaluating");function M(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Xt)return a===void 0&&(a=Xt,a=n()),a},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ve(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ge(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Qt(e){return JSON.stringify(e)}function pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const en="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ur=nt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ee(e){if($e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!($e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tn(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e}const hr=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function C(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function fr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const mr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function br(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=ge(e._zod.def,{get shape(){const r={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return ve(this,"shape",r),r},checks:[]});return pe(e,i)}function _r(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=ge(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return ve(this,"shape",r),r},checks:[]});return pe(e,i)}function vr(e,t){if(!Ee(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(i,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ge(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return ve(this,"shape",i),i}});return pe(e,o)}function yr(e,t){if(!Ee(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ge(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return ve(this,"shape",a),a}});return pe(e,n)}function wr(e,t){const n=ge(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return ve(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return pe(e,n)}function xr(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=ge(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(n)for(const l in n){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(const l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return ve(this,"shape",c),c},checks:[]});return pe(t,r)}function kr(e,t,n){const a=ge(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const r in n){if(!(r in i))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(i[r]=new e({type:"nonoptional",innerType:o[r]}))}else for(const r in o)i[r]=new e({type:"nonoptional",innerType:o[r]});return ve(this,"shape",i),i}});return pe(t,a)}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Te(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function De(e){return typeof e=="string"?e:e?.message}function ue(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const o=De(e.inst?._zod.def?.error?.(e))??De(t?.error?.(e))??De(n.customError?.(e))??De(n.localeError?.(e))??"Invalid input";a.message=o}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function it(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ne(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const nn=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,tt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},an=b("$ZodError",nn),on=b("$ZodError",nn,{Parent:Error});function Cr(e,t=n=>n.message){const n={},a=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):a.push(t(o));return{formErrors:a,fieldErrors:n}}function Er(e,t=n=>n.message){const n={_errors:[]},a=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(r=>a({issues:r}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let r=n,s=0;for(;s<i.path.length;){const c=i.path[s];s===i.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(i))):r[c]=r[c]||{_errors:[]},r=r[c],s++}}};return a(e),n}const rt=e=>(t,n,a,o)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new Ce;if(r.issues.length){const s=new(o?.Err??e)(r.issues.map(c=>ue(c,i,de())));throw en(s,o?.callee),s}return r.value},st=e=>async(t,n,a,o)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise&&(r=await r),r.issues.length){const s=new(o?.Err??e)(r.issues.map(c=>ue(c,i,de())));throw en(s,o?.callee),s}return r.value},Be=e=>(t,n,a)=>{const o=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ce;return i.issues.length?{success:!1,error:new(e??an)(i.issues.map(r=>ue(r,o,de())))}:{success:!0,data:i.value}},Sr=Be(on),Re=e=>async(t,n,a)=>{const o=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(r=>ue(r,o,de())))}:{success:!0,data:i.value}},Tr=Re(on),Ir=e=>(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return rt(e)(t,n,o)},zr=e=>(t,n,a)=>rt(e)(t,n,a),Ar=e=>async(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return st(e)(t,n,o)},Nr=e=>async(t,n,a)=>st(e)(t,n,a),Pr=e=>(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Be(e)(t,n,o)},Lr=e=>(t,n,a)=>Be(e)(t,n,a),Mr=e=>async(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Re(e)(t,n,o)},$r=e=>async(t,n,a)=>Re(e)(t,n,a),Or=/^[cC][^\s-]{8,}$/,Dr=/^[0-9a-z]+$/,Br=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Rr=/^[0-9a-vA-V]{20}$/,Zr=/^[A-Za-z0-9]{27}$/,Ur=/^[a-zA-Z0-9_-]{21}$/,jr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,rn=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Hr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vr(){return new RegExp(Hr,"u")}const Gr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Kr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Jr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,sn=/^[A-Za-z0-9_-]*$/,Xr=/^\+[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])))",Qr=new RegExp(`^${cn}$`);function ln(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function es(e){return new RegExp(`^${ln(e)}$`)}function ts(e){const t=ln({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 ns=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},as=/^-?\d+$/,dn=/^-?\d+(?:\.\d+)?$/,os=/^(?:true|false)$/i,is=/^[^A-Z]*$/,rs=/^[^a-z]*$/,K=b("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),gn={number:"number",bigint:"bigint",object:"date"},pn=b("$ZodCheckLessThan",(e,t)=>{K.init(e,t);const n=gn[typeof t.value];e._zod.onattach.push(a=>{const o=a._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),un=b("$ZodCheckGreaterThan",(e,t)=>{K.init(e,t);const n=gn[typeof t.value];e._zod.onattach.push(a=>{const o=a._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ss=b("$ZodCheckMultipleOf",(e,t)=>{K.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):gr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cs=b("$ZodCheckNumberFormat",(e,t)=>{K.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[o,i]=mr[t.format];e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,n&&(s.pattern=as)}),e._zod.check=r=>{const s=r.value;if(n){if(!Number.isInteger(s)){r.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?r.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):r.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<o&&r.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&r.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ls=b("$ZodCheckMaxLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const o=a.value;if(o.length<=t.maximum)return;const r=it(o);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ds=b("$ZodCheckMinLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const o=a.value;if(o.length>=t.minimum)return;const r=it(o);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gs=b("$ZodCheckLengthEquals",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=a=>{const o=a.value,i=o.length;if(i===t.length)return;const r=it(o),s=i>t.length;a.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Ze=b("$ZodCheckStringFormat",(e,t)=>{var n,a;K.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),ps=b("$ZodCheckRegex",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),us=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=is),Ze.init(e,t)}),hs=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rs),Ze.init(e,t)}),fs=b("$ZodCheckIncludes",(e,t)=>{K.init(e,t);const n=Oe(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),ms=b("$ZodCheckStartsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),bs=b("$ZodCheckEndsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),_s=b("$ZodCheckOverwrite",(e,t)=>{K.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vs{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
57
+ </svg>`;function qo(e){const t=document.createElement("div");t.className="gengage-chat-launcher-container";const n=document.createElement("div");n.className="gengage-chat-launcher-content-area",t.appendChild(n);const a=document.createElement("button");if(a.className="gengage-chat-launcher",a.type="button",a.setAttribute("aria-label",e.ariaLabel??"Open chat"),a.innerHTML=e.svgMarkup??Fo,e.tooltip!==void 0){const i=document.createElement("span");i.className="gengage-chat-launcher-tooltip",i.textContent=e.tooltip,a.appendChild(i)}e.hideMobile&&(t.dataset.hideMobile="1"),e.mobileBreakpoint!==void 0&&(t.dataset.mobileBreakpoint=String(e.mobileBreakpoint)),a.addEventListener("click",e.onClick),t.appendChild(a);const o=document.createElement("div");return o.className="gengage-chat-launcher-content-area-bottom",t.appendChild(o),{container:t,button:a,contentArea:n,contentAreaBottom:o}}function Ho(e){const t=document.createElement("div");t.className="gengage-chat-proactive";const n=document.createElement("p");n.className="gengage-chat-proactive-message",n.textContent=e.message,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-proactive-actions";let o=null;function i(){o!==null&&clearTimeout(o),t.remove()}if(e.actionButtons&&e.actionButtons.length>0)for(const c of e.actionButtons){const l=document.createElement("button");l.className="gengage-chat-proactive-accept",l.type="button",l.textContent=c.title,l.addEventListener("click",()=>{i(),c.onSelect()}),a.appendChild(l)}else{const c=document.createElement("button");c.className="gengage-chat-proactive-accept",c.type="button",c.textContent=e.acceptLabel??"Sohbete Başla",c.addEventListener("click",()=>{i(),e.onAccept()}),a.appendChild(c)}const r=document.createElement("button");r.className="gengage-chat-proactive-dismiss",r.type="button",r.textContent="×",r.setAttribute("aria-label",e.closeAriaLabel??"Kapat"),r.addEventListener("click",()=>{i(),e.onDismiss()}),t.appendChild(r),t.appendChild(a);const s=e.autoDismissMs??15e3;return s>0&&(o=setTimeout(()=>{t.parentElement&&(t.remove(),e.onDismiss())},s)),requestAnimationFrame(()=>t.classList.add("gengage-chat-proactive--visible")),t}class Vo{constructor(t={}){this._idleTimer=null,this._maxScrollDepth=0,this._lastReportedDepth=0,this._listeners=[],this._destroyed=!1,this._idleThreshold=t.idleThresholdMs??3e4,this._scrollGranularity=t.scrollGranularity??25,this._onActivity=t.onActivity??null,this._setup()}_setup(){this._emit({type:"pageview",timestamp:Date.now()}),this._resetIdleTimer(),this._listen(window,"scroll",()=>this._onScroll(),{passive:!0}),this._listen(window,"mousemove",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"keydown",()=>this._resetIdleTimer(),{passive:!0}),this._listen(window,"touchstart",()=>this._resetIdleTimer(),{passive:!0}),this._listen(document,"visibilitychange",()=>this._onVisibility())}_listen(t,n,a,o){t.addEventListener(n,a,o),this._listeners.push([t,n,a])}_resetIdleTimer(){this._idleTimer&&clearTimeout(this._idleTimer),this._idleTimer=setTimeout(()=>{this._emit({type:"idle",timestamp:Date.now()})},this._idleThreshold)}_onScroll(){const t=window.scrollY||document.documentElement.scrollTop,n=Math.max(document.documentElement.scrollHeight-window.innerHeight,1),a=Math.min(100,Math.round(t/n*100));a>this._maxScrollDepth&&(this._maxScrollDepth=a);const o=Math.floor(a/this._scrollGranularity)*this._scrollGranularity;o>this._lastReportedDepth&&(this._lastReportedDepth=o,this._emit({type:"scroll",timestamp:Date.now(),data:{depth:o}})),this._resetIdleTimer()}_onVisibility(){document.hidden?(this._emit({type:"blur",timestamp:Date.now()}),this._idleTimer&&clearTimeout(this._idleTimer)):(this._emit({type:"focus",timestamp:Date.now()}),this._resetIdleTimer())}_emit(t){this._destroyed||this._onActivity?.(t)}get maxScrollDepth(){return this._maxScrollDepth}destroy(){this._destroyed=!0,this._idleTimer&&clearTimeout(this._idleTimer);for(const[t,n,a]of this._listeners)t.removeEventListener(n,a);this._listeners=[]}}const Go=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]);function Wo(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!Go.has(n))return null;try{const a=new Audio(`data:${t};base64,${e}`);return a.play().catch(()=>{}),{stop:()=>{a.pause(),a.currentTime=0}}}catch{return null}}class Ko{constructor(t){this._timer=null,this._destroyed=!1,this._abortController=null,this._sessionStart=Date.now(),this._lastActivity=Date.now(),this._searchesCount=0,this._actionsCount=0,this._triggerFireCounts={},this._options=t;const n=At(t.middlewareUrl);this._endpoint=`${n}/v2/heartbeat`}start(){this._timer||this._destroyed||this._scheduleNext()}_scheduleNext(){this._destroyed||(this._timer=setTimeout(()=>{this._poll().finally(()=>this._scheduleNext())},this._options.intervalMs))}stop(){this._timer&&(clearTimeout(this._timer),this._timer=null)}recordAction(){this._actionsCount++,this._lastActivity=Date.now()}recordSearch(){this._searchesCount++,this._lastActivity=Date.now()}recordActivity(){this._lastActivity=Date.now()}destroy(){this._destroyed=!0,this._abortController?.abort(),this._abortController=null,this.stop()}async _poll(){if(this._destroyed)return;const t=Date.now(),n={account_id:this._options.accountId,thread_id:this._options.sessionId,output_language:this._options.locale.toUpperCase(),idle_seconds:(t-this._lastActivity)/1e3,page_type:this._options.getPageType(),current_sku:this._options.getCurrentSku(),cart_item_count:0,searches_count:this._searchesCount,actions_count:this._actionsCount,session_duration_seconds:(t-this._sessionStart)/1e3,trigger_fire_counts:{...this._triggerFireCounts}};this._abortController=new AbortController;try{const a=await fetch(this._endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:this._abortController.signal});if(this._destroyed||!a.ok)return;const o=await a.json();if(this._destroyed)return;o.action==="message"&&o.message&&(o.trigger_type&&(this._triggerFireCounts[o.trigger_type]=(this._triggerFireCounts[o.trigger_type]??0)+1),this._options.onMessage(o))}catch{}}}const Jo={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...Jo,...t},i=n%1!==0||a.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),r=i.indexOf("."),s=r===-1?i:i.slice(0,r),c=r===-1?void 0:i.slice(r+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousandsSeparator);let d;return c!==void 0?d=`${l}${a.decimalSeparator}${c}`:d=l,a.currencySymbol?a.currencyPosition==="prefix"?`${a.currencySymbol}${d}`:`${d} ${a.currencySymbol}`:d}const Yo={screen_size:"Ekran Boyutu",weight:"Ağırlık",battery_capacity:"Batarya Kapasitesi",battery_life:"Batarya Ömrü",storage:"Depolama",memory:"Bellek",ram:"RAM",processor:"İşlemci",camera:"Kamera",resolution:"Çözünürlük",display_type:"Ekran Tipi",refresh_rate:"Yenileme Hızı",color:"Renk",material:"Malzeme",dimensions:"Boyutlar",warranty:"Garanti",connectivity:"Bağlantı",water_resistance:"Su Dayanıklılığı",operating_system:"İşletim Sistemi",brand:"Marka",model:"Model",price:"Fiyat",energy_class:"Enerji Sınıfı",noise_level:"Gürültü Seviyesi",capacity:"Kapasite",power:"Güç",voltage:"Voltaj",width:"Genişlik",height:"Yükseklik",depth:"Derinlik"};function Xo(e){return Yo[e]??e.replace(/_/g," ").replace(/^\w/,t=>t.toUpperCase())}function Qo(e){const{recommended:t,products:n,attributes:a,highlights:o,specialCases:i,onProductClick:r,i18n:s}=e,c=document.createElement("div");c.className="gengage-chat-comparison";const l=document.createElement("h3");if(l.className="gengage-chat-comparison-heading",l.textContent=s?.comparisonHeading??"KARŞILAŞTIRMA SONUÇLARI",c.appendChild(l),t){const d=document.createElement("div");d.className="gengage-chat-comparison-recommended";const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Önerilen Seçim",d.appendChild(g);const u=document.createElement("div");if(u.className="gengage-chat-comparison-recommended-body",t.imageUrl&&re(t.imageUrl)){const y=document.createElement("img");y.src=t.imageUrl,y.alt=t.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),u.appendChild(y)}const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-info";const f=document.createElement("div");f.className="gengage-chat-comparison-recommended-title",f.textContent=t.name,p.appendChild(f);const v=document.createElement("div");if(v.className="gengage-chat-comparison-recommended-price",v.textContent=t.price,p.appendChild(v),u.appendChild(p),u.addEventListener("click",()=>{r(t.sku)}),u.style.cursor="pointer",d.appendChild(u),o.length>0){const y=document.createElement("div");y.className="gengage-chat-comparison-highlights";const I=document.createElement("div");I.className="gengage-chat-comparison-highlights-label",I.textContent=s?.highlightsLabel??"Öne Çıkan Özellikler",y.appendChild(I);const z=document.createElement("ul");for(const b of o){const _=document.createElement("li");_.textContent=b,z.appendChild(_)}y.appendChild(z),d.appendChild(y)}if(e.recommendedText){const y=document.createElement("div");y.className="gengage-chat-comparison-recommended-text",y.textContent=e.recommendedText,d.appendChild(y)}c.appendChild(d)}if(e.keyDifferencesHtml){const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences";const g=document.createElement("h4");g.textContent=s?.keyDifferencesLabel??"Temel Farklar",d.appendChild(g);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content",u.innerHTML=we(ei(e.keyDifferencesHtml)),d.appendChild(u),c.appendChild(d)}if(i&&i.length>0){const d=document.createElement("details");d.className="gengage-chat-comparison-special";const g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"Özel Durumlar İçin",d.appendChild(g);const u=document.createElement("ul");for(const p of i){const f=document.createElement("li");f.textContent=p,u.appendChild(f)}d.appendChild(u),c.appendChild(d)}if(n.length>0&&a.length>0){const d=document.createElement("table");d.className="gengage-chat-comparison-table";const g=document.createElement("thead"),u=document.createElement("tr"),p=document.createElement("th");u.appendChild(p);for(const v of n){const y=document.createElement("th");if(v.sku===t?.sku&&(y.className="gengage-chat-comparison-selected"),v.imageUrl&&re(v.imageUrl)){const b=document.createElement("img");b.src=v.imageUrl,b.alt=v.name,b.loading="lazy",b.addEventListener("error",()=>{b.style.display="none"},{once:!0}),y.appendChild(b)}const I=document.createElement("div");I.textContent=v.name,y.appendChild(I);const z=document.createElement("div");z.className="gengage-chat-comparison-table-price",z.textContent=v.price,y.appendChild(z),u.appendChild(y)}g.appendChild(u),d.appendChild(g);const f=document.createElement("tbody");for(const v of a){const y=document.createElement("tr"),I=document.createElement("td");I.className="gengage-chat-comparison-label",I.textContent=Xo(v.label),y.appendChild(I);for(let z=0;z<v.values.length;z++){const b=document.createElement("td");n[z]?.sku===t?.sku&&(b.className="gengage-chat-comparison-selected"),b.textContent=v.values[z]??"",y.appendChild(b)}f.appendChild(y)}d.appendChild(f),c.appendChild(d)}if(e.productActions){const d=document.createElement("div");d.className="gengage-chat-comparison-product-actions";for(const g of n)if(e.productActions[g.sku]){const p=document.createElement("button");p.className="gengage-chat-comparison-view-btn",p.type="button",p.textContent=g.name,p.addEventListener("click",()=>r(g.sku)),d.appendChild(p)}d.childElementCount>0&&c.appendChild(d)}return c}function ei(e){const t=e.split(`
58
+ `).filter(n=>n.trim());return t.length<=1?e:"<ul>"+t.map(n=>`<li>${n.trim()}</li>`).join("")+"</ul>"}function ti(e,t){const n=document.createElement("div");n.className="gengage-chat-review-highlights";const a=e.props?.reviews;if(!Array.isArray(a)||a.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"Yorum özeti bulunamadı.",n.appendChild(u),n}const o=a.filter(u=>u!==null&&typeof u=="object"),i={all:o.length,positive:0,negative:0,neutral:0};for(const u of o)u.review_class==="positive"?i.positive++:u.review_class==="negative"?i.negative++:i.neutral++;const r=document.createElement("div");r.className="gengage-chat-review-tabs";const s=[{label:`Tümü (${i.all})`,filter:"all"}];i.positive>0&&s.push({label:`Olumlu (${i.positive})`,filter:"positive"}),i.negative>0&&s.push({label:`Olumsuz (${i.negative})`,filter:"negative"});let c="all";const l=document.createElement("div");l.className="gengage-chat-review-items";function d(){for(;l.firstChild;)l.removeChild(l.firstChild);const u=c==="all"?o:o.filter(p=>p.review_class===c);for(const p of u){const f=document.createElement("article");f.className="gengage-chat-review-item";const v=p.review_class;if((v==="positive"||v==="negative"||v==="neutral")&&(f.dataset.tone=v),typeof p.review_tag=="string"&&p.review_tag.length>0){const y=document.createElement("div");y.className="gengage-chat-review-tag",y.textContent=p.review_tag,f.appendChild(y)}if(typeof p.review_text=="string"&&p.review_text.length>0){const y=document.createElement("div");y.className="gengage-chat-review-text",y.textContent=p.review_text,f.appendChild(y)}if(p.review_rating!==void 0&&String(p.review_rating).length>0){const y=document.createElement("div");y.className="gengage-chat-review-rating",y.textContent=String(p.review_rating),f.appendChild(y)}l.appendChild(f)}}for(const u of s){const p=document.createElement("button");p.className="gengage-chat-review-tab",p.type="button",p.textContent=u.label,u.filter===c&&p.classList.add("gengage-chat-review-tab--active"),p.addEventListener("click",()=>{c=u.filter;for(const f of r.querySelectorAll(".gengage-chat-review-tab"))f.classList.toggle("gengage-chat-review-tab--active",f===p);d()}),r.appendChild(p)}n.appendChild(r);const g=new Map;for(const u of o)if(typeof u.review_tag=="string"&&u.review_tag.length>0){const p=g.get(u.review_tag);p?p.count++:g.set(u.review_tag,{count:1,sentiment:u.review_class??"neutral"})}if(g.size>0){const u=document.createElement("div");u.className="gengage-chat-review-pills";for(const[p,f]of g){const v=document.createElement("span");v.className="gengage-chat-review-pill",v.dataset.tone=f.sentiment;const y=document.createElement("span");y.className="gengage-chat-review-pill-icon",y.textContent=f.sentiment==="positive"?"✓":f.sentiment==="negative"?"✕":"●",v.appendChild(y);const I=document.createElement("span");if(I.textContent=p,v.appendChild(I),f.count>1){const z=document.createElement("span");z.className="gengage-chat-review-pill-count",z.textContent=String(f.count),v.appendChild(z)}u.appendChild(v)}n.appendChild(u)}return d(),n.appendChild(l),n}function Ye(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Xe(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mt(e,t=!0){const n=Ye(e);if(t){const o=Math.floor(n),i=n-o>=.5?1:0,r=5-o-i;return"★".repeat(o)+(i?"½":"")+"☆".repeat(r)}const a=Math.round(n);return"★".repeat(a)+"☆".repeat(5-a)}function _e(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}const ni={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function $t(e,t){if(!e||!t)return null;const n=ni[e];return n?t[n]??e:e}function ai(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-top-picks";const a=e.props?.suggestions??[];if(a.length===0)return n;const o=document.createElement("h3");o.className="gengage-chat-ai-top-picks-title",o.textContent=t.i18n?.aiTopPicksTitle??"Top Picks",n.appendChild(o);const i=document.createElement("div");i.className="gengage-chat-ai-top-picks-cards";for(let r=0;r<a.length;r++){const s=a[r],l=s.role==="winner"||r===0?oi(s,t):ii(s,t);i.appendChild(l)}return n.appendChild(i),n}function oi(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner";const a=document.createElement("span");a.className="gengage-chat-ai-toppick-badge",a.textContent=$t(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH",n.appendChild(a);const o=e.product,i=o.discountPercent;if(typeof i=="number"&&i>0){const g=document.createElement("span");g.className="gengage-chat-ai-toppick-discount-badge",g.textContent=`%${Xe(i)}`,n.appendChild(g)}const r=o.imageUrl;if(r&&re(r)){const g=document.createElement("img");g.className="gengage-chat-ai-toppick-img",H(g,"src",r),g.alt=o.name??"",_e(g),n.appendChild(g)}const s=document.createElement("div");s.className="gengage-chat-ai-toppick-body";const c=o.name;if(c){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-name",g.textContent=c,s.appendChild(g)}if(e.reason){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-reason",g.textContent=e.reason,s.appendChild(g)}if(e.labels&&e.labels.length>0&&s.appendChild(Ot(e.labels)),typeof e.expertQualityScore=="number"){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-score",g.textContent=`${e.expertQualityScore}/10`,s.appendChild(g)}if(e.reviewHighlight){const g=document.createElement("blockquote");g.className="gengage-chat-ai-toppick-review",g.textContent=e.reviewHighlight,s.appendChild(g)}const l=o.price,d=o.originalPrice;if(l){const g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",d&&d!==l){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=J(d,t.pricing),g.appendChild(p),g.appendChild(document.createTextNode(" "))}const u=document.createElement("span");u.textContent=J(l,t.pricing),g.appendChild(u),s.appendChild(g)}if(n.appendChild(s),e.action){const g=o.sku??null,u=document.createElement("div");u.className="gengage-chat-ai-toppick-spinner",u.style.display=g&&t.topPicksLoadingSku===g?"":"none",n.appendChild(u);const p=document.createElement("button");p.className="gengage-chat-ai-toppick-cta",p.type="button",p.textContent=t.i18n?.viewDetails??"View Details",p.addEventListener("click",()=>{g&&(u.style.display=""),t.onAction(e.action)}),n.appendChild(p)}return n}function ii(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";const a=e.product,o=a.discountPercent;if(typeof o=="number"&&o>0){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-discount-badge",d.textContent=`%${Xe(o)}`,n.appendChild(d)}const i=a.imageUrl;if(i&&re(i)){const d=document.createElement("img");d.className="gengage-chat-ai-toppick-img",H(d,"src",i),d.alt=a.name??"",_e(d),n.appendChild(d)}const r=document.createElement("div");r.className="gengage-chat-ai-toppick-body";const s=$t(e.role,t.i18n);if(s){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-role",d.textContent=s,r.appendChild(d)}const c=a.name;if(c){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-name",d.textContent=c,r.appendChild(d)}if(e.reason){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-reason",d.textContent=e.reason,r.appendChild(d)}e.labels&&e.labels.length>0&&r.appendChild(Ot(e.labels));const l=a.price;if(l){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price",d.textContent=J(l,t.pricing),r.appendChild(d)}if(n.appendChild(r),e.action){const d=a.sku??null,g=document.createElement("div");g.className="gengage-chat-ai-toppick-spinner",g.style.display=d&&t.topPicksLoadingSku===d?"":"none",n.appendChild(g);const u=document.createElement("button");u.className="gengage-chat-ai-toppick-cta",u.type="button",u.textContent=t.i18n?.viewDetails??"View Details",u.addEventListener("click",()=>{d&&(g.style.display=""),t.onAction(e.action)}),n.appendChild(u)}return n}function Ot(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels";for(const n of e){const a=document.createElement("span");a.className="gengage-chat-ai-toppick-label",a.dataset.sentiment=n.sentiment??"neutral",a.textContent=n.label,t.appendChild(a)}return t}function ri(e,t){const n=document.createElement("div");n.className="gengage-chat-grounding-review";const a=e.props??{},o=a.title,i=a.reviewCount,r=a.action,s=t.i18n?.groundingReviewCta??"Yorumları Oku",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.textContent="📋",n.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body";const d=document.createElement("div");if(d.className="gengage-chat-grounding-review-title",d.textContent=o??"Müşteri Yorumları",l.appendChild(d),i){const u=document.createElement("div");u.className="gengage-chat-grounding-review-subtitle";const p=t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut";u.textContent=p.replace("{count}",i),l.appendChild(u)}n.appendChild(l);const g=document.createElement("span");return g.className="gengage-chat-grounding-review-cta",g.textContent=`${s} →`,n.appendChild(g),r&&(n.style.cursor="pointer",n.addEventListener("click",()=>t.onAction(r))),n}function si(e,t){const n=document.createElement("div");n.className="gengage-chat-grouping-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const o of a){const i=document.createElement("div");if(i.className="gengage-chat-grouping-card",i.style.cursor="pointer",i.addEventListener("click",()=>t.onAction(o.action)),o.image&&re(o.image)){const l=document.createElement("img");l.className="gengage-chat-grouping-card-img",l.src=o.image,l.alt=o.name,l.width=20,l.height=20,i.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-grouping-card-body";const s=document.createElement("span");if(s.className="gengage-chat-grouping-card-name",s.textContent=o.name,r.appendChild(s),o.description){const l=document.createElement("span");l.className="gengage-chat-grouping-card-desc",l.textContent=o.description,r.appendChild(l)}if(o.labels&&o.labels.length>0){const l=document.createElement("span");l.className="gengage-chat-grouping-card-labels",l.textContent=o.labels.slice(0,3).join(" · "),r.appendChild(l)}i.appendChild(r);const c=document.createElement("span");c.className="gengage-chat-grouping-card-arrow",c.textContent="↳",i.insertBefore(c,i.firstChild),n.appendChild(i)}return n}function ci(e,t){const n=document.createElement("div");n.className="gengage-chat-suggested-search-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const o of a){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card",i.style.cursor="pointer",i.addEventListener("click",()=>t.onAction(o.action)),o.image&&re(o.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.src=o.image,c.alt=o.shortName,c.width=40,c.height=40,i.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-suggested-search-card-body";const s=document.createElement("div");if(s.className="gengage-chat-suggested-search-card-name",s.textContent=o.shortName,r.appendChild(s),o.detailedMessage){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-desc",c.textContent=o.detailedMessage,r.appendChild(c)}if(o.whyDifferent){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-diff",c.textContent=o.whyDifferent,r.appendChild(c)}i.appendChild(r),n.appendChild(i)}return n}function li(e,t){const n=document.createElement("button");n.className="gengage-chat-comparison-floating-btn",n.type="button";const a=t.i18n?.compareSelected??"Karşılaştır";return n.textContent=`${a} (${e.length})`,n.addEventListener("click",()=>{t.onAction({title:a,type:"getComparisonTable",payload:{sku_list:[...e]}})}),n}function di(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons";const n=e.props?.productName;if(n){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=n,t.appendChild(i)}const a=e.props?.pros,o=e.props?.cons;if(a&&a.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list";for(const r of a){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(o&&o.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list";for(const r of o){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=r,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}function gi(e,t){const n=e.props?.groups??[],a=e.props?.filterTags??[],o=document.createElement("div");if(o.className="gengage-chat-categories",n.length===0)return o;const i=document.createElement("div");i.className="gengage-chat-categories-tabs",i.setAttribute("role","tablist");const r=[],s=[],c=l=>{for(let d=0;d<r.length;d++){const g=d===l;r[d].classList.toggle("gengage-chat-categories-tab--active",g),r[d].setAttribute("aria-selected",String(g)),r[d].tabIndex=g?0:-1,s[d].style.display=g?"":"none"}};for(let l=0;l<n.length;l++){const d=n[l],g=`gengage-cat-tab-${l}`,u=`gengage-cat-panel-${l}`,p=document.createElement("button");p.className="gengage-chat-categories-tab",p.type="button",p.id=g,p.setAttribute("role","tab"),p.setAttribute("aria-controls",u),p.setAttribute("aria-selected",String(l===0)),p.tabIndex=l===0?0:-1,l===0&&p.classList.add("gengage-chat-categories-tab--active"),p.textContent=d.groupName,p.addEventListener("click",()=>c(l)),p.addEventListener("keydown",v=>{let y=-1;v.key==="ArrowRight"||v.key==="ArrowDown"?y=(l+1)%n.length:v.key==="ArrowLeft"||v.key==="ArrowUp"?y=(l-1+n.length)%n.length:v.key==="Home"?y=0:v.key==="End"&&(y=n.length-1),y>=0&&(v.preventDefault(),c(y),r[y].focus())}),r.push(p),i.appendChild(p);const f=document.createElement("div");f.className="gengage-chat-categories-grid",f.id=u,f.setAttribute("role","tabpanel"),f.setAttribute("aria-labelledby",g),l!==0&&(f.style.display="none");for(const v of d.products){const y=pi(v,t);f.appendChild(y)}s.push(f)}o.appendChild(i);for(const l of s)o.appendChild(l);if(a.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags";for(const d of a){const g=document.createElement("button");g.className="gengage-chat-categories-filter-tag",g.type="button",g.textContent=d.title,d.action&&g.addEventListener("click",()=>{t.onAction(d.action)}),l.appendChild(g)}o.appendChild(l)}return o}function pi(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&re(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.src=e.imageUrl,i.alt=e.name,n.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-product-card-body";const o=document.createElement("div");if(o.className="gengage-chat-product-card-name",o.textContent=e.name,a.appendChild(o),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=e.price,a.appendChild(i)}return n.appendChild(a),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",()=>{t.onProductSelect?.(e)})),n}function ui(e,t){const n=document.createElement("div");n.className="gengage-chat-handoff-notice",n.setAttribute("role","alert");const a=document.createElement("span");a.className="gengage-chat-handoff-notice-icon",a.textContent="👤",a.setAttribute("aria-hidden","true"),n.appendChild(a);const o=document.createElement("h4");o.className="gengage-chat-handoff-notice-heading",o.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",n.appendChild(o);const i=e.props?.summary;if(i){const r=document.createElement("p");r.className="gengage-chat-handoff-notice-summary",r.textContent=i,n.appendChild(r)}return n}function hi(e,t){const n=e.props?.product??e.props,a=document.createElement("div");if(a.className="gengage-chat-product-summary",!n)return a;a.style.cursor="pointer",a.addEventListener("click",p=>{p.target.closest("a")||t.onProductSelect?.(n)});const o=n.imageUrl;if(o&&oe(o)){const p=document.createElement("div");p.className="gengage-chat-product-summary__image";const f=document.createElement("img");H(f,"src",o);const v=n.name;v&&(f.alt=v),_e(f),p.appendChild(f),a.appendChild(p)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content";const r=n.brand,s=n.name;if(s){const p=document.createElement("div");p.className="gengage-chat-product-summary__name";const f=r&&!s.toLowerCase().startsWith(r.toLowerCase());p.textContent=f?`${r} ${s}`:s,i.appendChild(p)}const c=n.rating,l=n.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__rating",p.textContent=Mt(Ye(c)),typeof l=="number"&&Number.isFinite(l)){const f=document.createElement("span");f.className="gengage-chat-product-summary__review-count",f.textContent=` (${l})`,p.appendChild(f)}i.appendChild(p)}const d=n.price,g=n.originalPrice;if(d){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__price",g&&g!==d){const v=document.createElement("span");v.className="gengage-chat-product-summary__price-original",v.textContent=J(g,t.pricing),p.appendChild(v),p.appendChild(document.createTextNode(" "))}const f=document.createElement("span");f.className="gengage-chat-product-summary__price-current",f.textContent=J(d,t.pricing),p.appendChild(f),i.appendChild(p)}a.appendChild(i);const u=n.url;if(u&&oe(u)){const p=document.createElement("a");p.className="gengage-chat-product-summary__cta",H(p,"href",u),H(p,"target","_blank"),H(p,"rel","noopener noreferrer"),p.textContent=t.i18n?.productCtaLabel??"İncele",a.appendChild(p)}return a}function Dt(e){const t=e.min??1,n=e.max??99,a=Math.min(t,n),o=Math.max(t,n),i=Math.max(a,Math.min(o,e.initial??a)),r=e.compact??!1;let s=i;const c=document.createElement("div");c.className=`gengage-qty-stepper${r?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=e.decreaseSymbol??"−",l.setAttribute("aria-label",e.decreaseLabel??"Azalt");const d=document.createElement("span");d.className="gengage-qty-value",d.textContent=String(s),d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true");const g=document.createElement("button");g.className="gengage-qty-btn",g.type="button",g.textContent=e.increaseSymbol??"+",g.setAttribute("aria-label",e.increaseLabel??"Artır");const u=document.createElement("button");u.className="gengage-qty-submit",u.type="button",r?(u.textContent=e.submitIcon??"🛒",u.title=e.label??"Sepete Ekle"):u.textContent=e.label??"Sepete Ekle";function p(){l.disabled=s<=a,g.disabled=s>=o}return l.addEventListener("click",f=>{f.stopPropagation(),s>a&&(s--,d.textContent=String(s),p())}),g.addEventListener("click",f=>{f.stopPropagation(),s<o&&(s++,d.textContent=String(s),p())}),u.addEventListener("click",f=>{f.stopPropagation(),e.onSubmit(s)}),c.addEventListener("click",f=>{f.stopPropagation()}),p(),c.appendChild(l),c.appendChild(d),c.appendChild(g),c.appendChild(u),c}function Bt(){return window.innerWidth<768}const Rt={ActionButtons:({element:e,context:t})=>fi(e,t),ActionButton:({element:e,context:t})=>mi(e,t),ProductCard:({element:e,context:t})=>bi(e,t),ProductDetailsPanel:({element:e,context:t})=>_i(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>wi(e,t,n,a),ReviewHighlights:({element:e,context:t})=>ti(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage}),ComparisonTable:({element:e,context:t})=>xi(e,t),AITopPicks:({element:e,context:t})=>ai(e,t),GroundingReviewCard:({element:e,context:t})=>ri(e,t),AIGroupingCards:({element:e,context:t})=>si(e,t),AISuggestedSearchCards:({element:e,context:t})=>ci(e,t),ProsAndCons:({element:e})=>di(e),CategoriesContainer:({element:e,context:t})=>gi(e,t),HandoffNotice:({element:e,context:t})=>ui(e,t),ProductSummaryCard:({element:e,context:t})=>hi(e,t),Divider:({element:e})=>ki(e)},Qe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const o=t(a);o&&n.appendChild(o)}return n};function Zt(){return{...Rt}}function Ut(e,t,n=Rt,a=Qe){return Xn({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function fi(e,t){const n=document.createElement("div");n.className="gengage-chat-action-buttons";const a=e.props?.buttons;if(a)for(const o of a){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=o.label,i.addEventListener("click",()=>t.onAction(o.action)),n.appendChild(i)}return n}function mi(e,t){const n=document.createElement("button");n.className="gengage-chat-action-btn";const a=e.props?.label;typeof a=="string"&&(n.textContent=a);const o=e.props?.action;return o&&n.addEventListener("click",()=>t.onAction(o)),n}function bi(e,t){const n=document.createElement("div");n.className="gengage-chat-product-card";const a=e.props?.product??e.props;if(!a)return n;const o=a.sku;o&&(n.dataset.sku=o),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",_=>{_.target.closest(".gengage-chat-product-card-atc")||_.target.closest(".gengage-chat-product-card-cta")||t.onProductSelect?.(a)}));const i=a.imageUrl;if(i&&oe(i)){const _=document.createElement("div");_.className="gengage-chat-product-card-img-wrapper";const w=document.createElement("img");w.className="gengage-chat-product-card-img",w.loading="lazy",H(w,"src",i);const E=a.name;E&&(w.alt=E),_e(w),_.appendChild(w);const P=a.discountPercent;if(typeof P=="number"&&P>0){const C=document.createElement("span");C.className="gengage-chat-product-card-discount-badge",C.textContent=`%${Xe(P)}`,_.appendChild(C)}const h=a.sku;if(h){const C=document.createElement("button");C.className="gengage-chat-find-similar-pill",C.type="button",C.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",C.addEventListener("click",A=>{A.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:h,...i?{image_url:i}:{}}})}),_.appendChild(C)}const k=a.sku;if(k&&t.onFavoriteToggle){const C=document.createElement("button");C.className="gengage-chat-favorite-btn",C.type="button",C.setAttribute("aria-label","Favorilere ekle");const A=t.favoritedSkus?.has(k)??!1;A&&C.classList.add("gengage-chat-favorite-btn--active");const $=A?"currentColor":"none";C.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${$}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,C.addEventListener("click",N=>{N.stopPropagation(),C.classList.toggle("gengage-chat-favorite-btn--active");const T=C.querySelector("svg");T&&T.setAttribute("fill",C.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(k,a)}),_.appendChild(C)}n.appendChild(_)}const r=document.createElement("div");r.className="gengage-chat-product-card-body";const s=a.brand;if(s){const _=document.createElement("div");_.className="gengage-chat-product-card-brand",_.textContent=s,r.appendChild(_)}const c=a.name;if(c){const _=document.createElement("div");_.className="gengage-chat-product-card-name",_.textContent=c,r.appendChild(_)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const _=document.createElement("div");if(_.className="gengage-chat-product-card-rating",_.textContent=Mt(l),typeof d=="number"&&Number.isFinite(d)){const w=document.createElement("span");w.className="gengage-chat-product-card-review-count",w.textContent=` (${d})`,_.appendChild(w)}r.appendChild(_)}const g=a.price,u=a.originalPrice;if(a.price_async===!0){const _=document.createElement("div");_.className="gengage-chat-product-card-price";const w=document.createElement("span");w.className="gengage-chat-price-skeleton",_.appendChild(w),r.appendChild(_),setTimeout(()=>{w.parentElement&&(g?w.replaceWith(document.createTextNode(J(g,t.pricing))):w.remove())},300)}else if(g){const _=document.createElement("div");if(_.className="gengage-chat-product-card-price",u&&u!==g){const E=document.createElement("span");E.className="gengage-chat-product-card-original-price",E.textContent=J(u,t.pricing),_.appendChild(E),_.appendChild(document.createTextNode(" "))}const w=document.createElement("span");w.textContent=J(g,t.pricing),_.appendChild(w),r.appendChild(_)}const f=a.inStock;if(typeof f=="boolean"){const _=document.createElement("div");_.className=`gengage-chat-product-card-stock ${f?"is-in-stock":"is-out-of-stock"}`,_.textContent=f?t.i18n?.inStockLabel??"Stokta":t.i18n?.outOfStockLabel??"Tükendi",r.appendChild(_)}const v=a.promotions;if(v&&v.length>0){const _=document.createElement("div");_.className="gengage-chat-product-card-promos";for(const w of v){const E=document.createElement("span");E.className="gengage-chat-product-card-promo-badge",E.textContent=w,_.appendChild(E)}r.appendChild(_)}n.appendChild(r);const y=a.url,I=a.sku,z=e.props?.action;if(z){const _=document.createElement("button");_.className="gengage-chat-product-card-cta",_.type="button",_.textContent=z.title||t.i18n?.productCtaLabel||"Incele",_.addEventListener("click",()=>t.onAction(z)),n.appendChild(_)}else if(y&&oe(y)){const _=document.createElement("a");_.className="gengage-chat-product-card-cta",H(_,"href",y),H(_,"target","_blank"),H(_,"rel","noopener noreferrer"),_.textContent=t.i18n?.productCtaLabel??"İncele",_.addEventListener("click",w=>{t.onProductClick&&I&&(w.preventDefault(),t.onProductClick({sku:I,url:y}))}),n.appendChild(_)}const b=a.cartCode;if(b&&I){const _=Dt({compact:!0,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:w=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:I,cartCode:b,quantity:w}})}});_.classList.add("gengage-chat-product-card-atc"),n.appendChild(_)}if(t.comparisonSelectMode&&I&&t.onToggleComparisonSku){const _=document.createElement("div");_.className="gengage-chat-comparison-select-wrapper";const w=document.createElement("input");return w.type="checkbox",w.className="gengage-chat-comparison-checkbox",w.checked=t.comparisonSelectedSkus?.includes(I)??!1,w.addEventListener("change",()=>{t.onToggleComparisonSku?.(I)}),_.appendChild(w),_.appendChild(n),_}return n}function _i(e,t){const n=document.createElement("article");n.className="gengage-chat-product-details-panel";const a=e.props?.product??e.props;if(!a)return n;const o=a.images,i=a.imageUrl,r=a.sku;if(o&&o.length>1){const h=document.createElement("div");h.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const k=document.createElement("img");k.className="gengage-chat-product-details-img";const C=o.find(q=>oe(q));C&&H(k,"src",C);const A=a.name;A&&(k.alt=A),_e(k),h.appendChild(k);const $=document.createElement("div");$.className="gengage-chat-product-gallery-thumbs";let N=null,T=0;for(let q=0;q<o.length;q++){const Q=o[q];if(!Q||!oe(Q))continue;const W=document.createElement("img");W.className="gengage-chat-product-gallery-thumb",q===0&&(W.classList.add("gengage-chat-product-gallery-thumb--active"),N=W),H(W,"src",Q),W.alt=`${A??"Product"} ${q+1}`,W.width=48,W.height=48,_e(W),W.addEventListener("click",()=>{H(k,"src",Q),N&&N.classList.remove("gengage-chat-product-gallery-thumb--active"),W.classList.add("gengage-chat-product-gallery-thumb--active"),N=W,T=q}),$.appendChild(W)}let j=0;const X=50;if(k.addEventListener("touchstart",q=>{j=q.changedTouches[0].clientX},{passive:!0}),k.addEventListener("touchend",q=>{const Q=q.changedTouches[0].clientX,W=j-Q;if(Math.abs(W)<X)return;const ft=$.querySelectorAll(".gengage-chat-product-gallery-thumb"),mt=W>0?Math.min(T+1,ft.length-1):Math.max(T-1,0);mt!==T&&ft[mt]&&ft[mt].click()}),h.appendChild($),r){const q=document.createElement("button");q.className="gengage-chat-find-similar-pill",q.type="button",q.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",q.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...C?{image_url:C}:{}}})}),h.appendChild(q)}n.appendChild(h)}else if(i&&oe(i)){const h=document.createElement("div");h.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const k=document.createElement("img");k.className="gengage-chat-product-details-img",k.loading="lazy",H(k,"src",i),_e(k);const C=a.name;if(C&&(k.alt=C),h.appendChild(k),r){const A=document.createElement("button");A.className="gengage-chat-find-similar-pill",A.type="button",A.textContent=t.i18n?.findSimilarLabel??"Benzerlerini Bul",A.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Benzerlerini Bul",type:"findSimilar",payload:{sku:r,...i?{image_url:i}:{}}})}),h.appendChild(A)}n.appendChild(h)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const h=document.createElement("h3");h.className="gengage-chat-product-details-title",h.textContent=c,s.appendChild(h)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)){const h=document.createElement("div");if(h.className="gengage-chat-product-details-rating",h.textContent=`★ ${Ye(l).toFixed(1)}`,typeof d=="number"&&Number.isFinite(d)){const k=document.createElement("span");k.className="gengage-chat-product-details-review-count",k.textContent=` (${d})`,h.appendChild(k)}s.appendChild(h)}const g=a.price,u=a.originalPrice;if(a.price_async===!0){const h=document.createElement("div");h.className="gengage-chat-product-details-price";const k=document.createElement("span");k.className="gengage-chat-price-skeleton",h.appendChild(k),s.appendChild(h),setTimeout(()=>{if(k.parentElement)if(g){const C=document.createElement("span");C.className="gengage-chat-product-details-current-price",C.textContent=J(g,t.pricing),k.replaceWith(C)}else k.remove()},300)}else if(g){const h=document.createElement("div");if(h.className="gengage-chat-product-details-price",u&&u!==g){const C=document.createElement("span");C.className="gengage-chat-product-details-original-price",C.textContent=J(u,t.pricing),h.appendChild(C),h.appendChild(document.createTextNode(" "))}const k=document.createElement("span");k.className="gengage-chat-product-details-current-price",k.textContent=J(g,t.pricing),h.appendChild(k),s.appendChild(h)}const f=a.inStock;if(typeof f=="boolean"){const h=document.createElement("div");h.className=`gengage-chat-product-details-stock ${f?"is-in-stock":"is-out-of-stock"}`,h.textContent=f?"Stokta var":"Stokta yok",s.appendChild(h)}const v=a.promotions;if(v&&v.length>0){const h=document.createElement("div");h.className="gengage-chat-product-details-promos";for(const k of v){const C=document.createElement("span");C.className="gengage-chat-product-details-promo-badge",C.textContent=k,h.appendChild(C)}s.appendChild(h)}const y=a.variants;if(y&&y.length>0){const h=document.createElement("div");h.className="gengage-chat-product-variants";const k=document.createElement("div");k.className="gengage-chat-product-variants-label",k.textContent=t.i18n?.variantsLabel??"Varyantlar",h.appendChild(k);const C=document.createElement("div");C.className="gengage-chat-product-variants-list";for(const A of y){const $=A.name??A.variant_name,N=A.sku;if(!$&&!N)continue;const T=document.createElement("button");T.className="gengage-chat-product-variant-btn",T.type="button";const j=$??N??"",X=A.price;X&&String(X)!==String(g)?T.textContent=`${j} - ${J(String(X),t.pricing)}`:T.textContent=j,N&&T.addEventListener("click",()=>{t.onAction({title:j,type:"launchVariant",payload:{sku:N}})}),C.appendChild(T)}h.appendChild(C),s.appendChild(h)}const I=a.sku,z=a.cartCode,b=document.createElement("div");b.className="gengage-chat-product-details-actions";const _=e.props?.action;if(_){const h=document.createElement("button");h.className="gengage-chat-product-details-cta",h.type="button",h.textContent=_.title||t.i18n?.productCtaLabel||"Incele",h.addEventListener("click",()=>t.onAction(_)),b.appendChild(h)}else{const h=a.url;if(h&&oe(h)){const k=document.createElement("a");k.className="gengage-chat-product-details-cta",H(k,"href",h),H(k,"target","_blank"),H(k,"rel","noopener noreferrer"),k.textContent=t.i18n?.productCtaLabel??"Incele",k.addEventListener("click",C=>{t.onProductClick&&I&&(C.preventDefault(),t.onProductClick({sku:I,url:h}))}),b.appendChild(k)}}if(z&&I){const h=Dt({compact:!1,label:t.i18n?.addToCartButton??"Sepete Ekle",onSubmit:k=>{t.onAction({title:t.i18n?.addToCartButton??"Sepete Ekle",type:"addToCart",payload:{sku:I,cartCode:z,quantity:k}})}});h.classList.add("gengage-chat-product-details-atc-stepper"),b.appendChild(h)}const w=a.url;if(w&&oe(w)){let h=function(T,j){const X=document.createElementNS($,"circle");X.setAttribute("cx",T),X.setAttribute("cy",j),X.setAttribute("r","3"),N.appendChild(X)},k=function(T,j,X,q){const Q=document.createElementNS($,"line");Q.setAttribute("x1",T),Q.setAttribute("y1",j),Q.setAttribute("x2",X),Q.setAttribute("y2",q),N.appendChild(Q)};const C=document.createElement("button");C.className="gengage-chat-product-details-share",C.type="button";const A=t.i18n?.shareButton??"Paylaş";C.title=A,C.setAttribute("aria-label",A);const $="http://www.w3.org/2000/svg",N=document.createElementNS($,"svg");N.setAttribute("width","18"),N.setAttribute("height","18"),N.setAttribute("viewBox","0 0 24 24"),N.setAttribute("fill","none"),N.setAttribute("stroke","currentColor"),N.setAttribute("stroke-width","2"),N.setAttribute("stroke-linecap","round"),N.setAttribute("stroke-linejoin","round"),h("18","5"),h("6","12"),h("18","19"),k("8.59","13.51","15.42","17.49"),k("15.41","6.51","8.59","10.49"),C.appendChild(N),C.addEventListener("click",async()=>{const T=a.name;try{navigator.share?await navigator.share({title:T??"",url:w}):navigator.clipboard&&(await navigator.clipboard.writeText(w),C.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>C.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),b.appendChild(C)}b.childElementCount>0&&s.appendChild(b),n.appendChild(s);const E=a.description,P=a.specifications;return(E||P)&&n.appendChild(vi(E,P,t)),n}function vi(e,t,n){const a=document.createElement("div");a.className="gengage-chat-product-detail-tabs";const o=document.createElement("div");o.className="gengage-chat-product-detail-tab-bar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active",s.type="button",s.textContent=n.i18n?.productInfoTab??"Ürün Bilgileri",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",c.textContent=e,i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab${e?"":" gengage-chat-product-detail-tab--active"}`,s.type="button",s.textContent=n.i18n?.specificationsTab??"Teknik Özellikler",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const d=Array.isArray(t)?t:Object.entries(t).map(([g,u])=>({key:g,value:u}));for(const g of d){const u=document.createElement("tr"),p=document.createElement("td");p.className="gengage-chat-product-specs-key",p.textContent=g.key;const f=document.createElement("td");f.className="gengage-chat-product-specs-value",f.textContent=g.value,u.appendChild(p),u.appendChild(f),l.appendChild(u)}c.appendChild(l),i.push(c)}const r=o.querySelectorAll(".gengage-chat-product-detail-tab");r.forEach((s,c)=>{s.addEventListener("click",()=>{r.forEach(l=>l.classList.remove("gengage-chat-product-detail-tab--active")),s.classList.add("gengage-chat-product-detail-tab--active"),i.forEach((l,d)=>{l.style.display=d===c?"":"none"})})}),a.appendChild(o);for(const s of i)a.appendChild(s);return a}function jt(e,t,n){if(!n||n.type==="related")return e;const a=e.map(o=>{const r=t.elements[o]?.props?.product,s=r?Number(r.price):NaN;return{id:o,price:Number.isFinite(s)?s:1/0}});return a.sort((o,i)=>o.price===1/0&&i.price===1/0?0:o.price===1/0?1:i.price===1/0?-1:n.direction==="desc"?i.price-o.price:o.price-i.price),a.map(o=>o.id)}function yi(e,t,n,a){const o=jt(t,n,a),i=new Map;for(const r of Array.from(e.children)){const s=r.dataset.elementId;s&&i.set(s,r)}for(const r of o){const s=i.get(r);s&&e.appendChild(s)}}function wi(e,t,n,a){const o=document.createElement("div");o.className="gengage-chat-product-grid-wrapper";const i=e.children??[];if(i.length>1&&a?.onSortChange){const l=document.createElement("div");l.className="gengage-chat-product-sort-toolbar";const d=a.productSort??{type:"related"},g=[{label:a.i18n?.sortRelated??"Önerilen",sortState:{type:"related"}},{label:a.i18n?.sortPriceAsc??"Fiyat ↑",sortState:{type:"price",direction:"asc"}},{label:a.i18n?.sortPriceDesc??"Fiyat ↓",sortState:{type:"price",direction:"desc"}}];for(const u of g){const p=document.createElement("button");p.className="gengage-chat-product-sort-btn",p.type="button",d.type===u.sortState.type&&d.direction===u.sortState.direction&&p.classList.add("gengage-chat-product-sort-btn--active"),p.textContent=u.label,p.addEventListener("click",()=>{a.onSortChange?.(u.sortState),yi(r,i,t,u.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(v=>v.classList.remove("gengage-chat-product-sort-btn--active")),p.classList.add("gengage-chat-product-sort-btn--active")}),l.appendChild(p)}if(a.onToggleComparisonSku){const u=document.createElement("div");u.className="gengage-chat-product-sort-separator",l.appendChild(u);const p=document.createElement("button");p.className="gengage-chat-comparison-toggle-btn",p.type="button",a.comparisonSelectMode&&p.classList.add("gengage-chat-comparison-toggle-btn--active"),p.textContent=a.i18n?.compareSelected??"Karşılaştır",p.addEventListener("click",()=>{a.onToggleComparisonSku?.("")}),l.appendChild(p)}o.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-product-grid";const s=jt(i,t,a?.productSort);for(const l of s){if(!t.elements[l])continue;const d=n(l);d&&(d.dataset.elementId=l,r.appendChild(d))}if(Bt()&&r.classList.add("gengage-chat-product-grid--mobile"),o.appendChild(r),e.props?.endOfList!==!0&&i.length>0){const l=document.createElement("button");l.className="gengage-chat-product-grid-view-more",l.type="button",l.textContent=a?.i18n?.viewMoreLabel??"Daha Fazla Göster",l.addEventListener("click",()=>{a?.onAction({title:"More",type:"moreProductList",payload:{}})}),o.appendChild(l)}if(a?.comparisonSelectMode&&a.comparisonSelectedSkus&&a.comparisonSelectedSkus.length>=2){const l=li(a.comparisonSelectedSkus,a);o.appendChild(l)}return o}function xi(e,t){const n=e.props??{},a=n.keyDifferencesHtml,o=n.recommended,i=n.products??[],r=n.attributes??[],s=n.highlights??[],c=n.specialCases,l=n.recommendedText,d=n.winnerHits,g=n.productActions;if(!o)return document.createElement("div");const u={recommended:o,products:i,attributes:r,highlights:s,specialCases:c,onProductClick:f=>{t.onProductClick?.({sku:f,url:""})}};l!==void 0&&(u.recommendedText=l),d!==void 0&&(u.winnerHits=d),g!==void 0&&(u.productActions=g),a!==void 0&&(u.keyDifferencesHtml=a),t.i18n&&(u.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const p=Qo(u);return Bt()&&p.classList.add("gengage-chat-comparison--mobile"),p}function ki(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const n=e.props?.label;if(n){const a=document.createElement("div");a.className="gengage-chat-divider-wrapper";const o=document.createElement("span");return o.className="gengage-chat-divider-label",o.textContent=n,a.appendChild(t),a.appendChild(o),a}return t}const Ci=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function Ei(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&Ci.has(a.tagName)?(n.length>0&&(t.push(n),n=[]),t.push([a])):n.push(a);return n.length>0&&t.push(n),t}function Si(e){for(const t of e)for(const n of t)if(n.nodeType===Node.ELEMENT_NODE&&(n.tagName==="TABLE"||n.querySelector?.("table")))return!0;return!1}function Ti(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ii(e){const{container:t,html:n,delayMs:a=30,onTick:o,onComplete:i}=e,r=document.createElement("template");r.innerHTML=n;const s=Ei(r.content.childNodes);if(Ti()||s.length<=1||Si(s))return t.innerHTML=n,i?.(),{complete(){},cancel(){},isRunning:!1};t.innerHTML="";let c=0,l=null,d=!0;function g(){if(!d||c>=s.length){d=!1,i?.();return}const u=s[c],p=document.createElement("span");p.className="gengage-chat-typewriter-block";for(const f of u)p.appendChild(f.cloneNode(!0));t.appendChild(p),c++,o?.(),c<s.length?l=setTimeout(g,a):(d=!1,i?.())}return g(),{complete(){d&&(l!==null&&clearTimeout(l),d=!1,t.innerHTML=n,i?.())},cancel(){l!==null&&clearTimeout(l),d=!1},get isRunning(){return d}}}function zi(e){const{container:t,mentions:n,onProductClick:a}=e;if(n.length===0)return;const o=new Map;for(const i of n)i.short_name.length!==0&&o.set(i.short_name.toLowerCase(),i);if(o.size!==0)for(const[i,r]of o){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),l=!1;for(;c&&!l;){const d=c.textContent??"",g=d.toLowerCase().indexOf(i);if(g===-1){c=s.nextNode();continue}const u=d.slice(0,g),p=d.slice(g,g+r.short_name.length),f=d.slice(g+r.short_name.length),v=c.parentNode;if(!v){c=s.nextNode();continue}const y=document.createElement("a");y.className="gengage-product-mention",y.textContent=p,y.href="#",y.addEventListener("click",I=>{I.preventDefault(),a(r.sku)}),u&&v.insertBefore(document.createTextNode(u),c),v.insertBefore(y,c),f&&v.insertBefore(document.createTextNode(f),c),v.removeChild(c),l=!0}}}const Ai=new Set(["search","info","review","similar"]),Ni=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function Pi(e){return!!(e.icon&&Ai.has(e.icon)||e.action?.type&&Ni.has(e.action.type))}const Ft="gengage_choice_prompter_dismissed";function Li(e){const t=document.createElement("div");t.className="gengage-chat-choice-prompter";const n=document.createElement("div");n.className="gengage-chat-choice-prompter-heading",n.textContent=e.heading,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-choice-prompter-suggestion",a.textContent=e.suggestion,t.appendChild(a);const o=document.createElement("button");o.type="button",o.className="gengage-chat-choice-prompter-cta",o.textContent=e.ctaLabel,o.addEventListener("click",()=>{qt(),t.remove(),e.onCtaClick()}),t.appendChild(o);const i=document.createElement("button");return i.type="button",i.className="gengage-chat-choice-prompter-dismiss",i.textContent="×",i.setAttribute("aria-label","Dismiss"),i.addEventListener("click",()=>{qt(),t.remove(),e.onDismiss?.()}),t.appendChild(i),t}function Mi(){try{return sessionStorage.getItem(Ft)==="1"}catch{return!1}}function qt(){try{sessionStorage.setItem(Ft,"1")}catch{}}const $i="gengage_assistant",Oi=3,le="sessions",te="context",ie="payload",ne="favorites";function Ae(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function ke(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Di{constructor(t=$i,n=Oi){this._db=null,this._dbName=t,this._version=n}async open(){return this._db?this._db:new Promise((t,n)=>{const a=indexedDB.open(this._dbName,this._version);a.onupgradeneeded=o=>{const i=a.result,r=o.oldVersion;r<1&&(i.createObjectStore(le,{keyPath:["userId","appId","sessionId"]}),i.createObjectStore(te,{keyPath:["sessionId","threadId"]}),i.createObjectStore(ie,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),i.createObjectStore(ne,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(i.objectStoreNames.contains(le)&&i.deleteObjectStore(le),i.objectStoreNames.contains(ie)&&i.deleteObjectStore(ie),i.createObjectStore(le,{keyPath:["userId","appId","sessionId"]}),i.createObjectStore(ie,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),i.objectStoreNames.contains(te)||i.createObjectStore(te,{keyPath:["sessionId","threadId"]})),r<3&&(i.objectStoreNames.contains(ne)||i.createObjectStore(ne,{keyPath:["userId","appId","sku"]}))},a.onsuccess=()=>{this._db=a.result,t(this._db)},a.onerror=()=>n(a.error)})}close(){this._db?.close(),this._db=null}async saveSession(t){const a=this._requireDb().transaction(le,"readwrite");a.objectStore(le).put(t),await ke(a)}async loadSession(t,n,a){const i=this._requireDb().transaction(le,"readonly");return await Ae(i.objectStore(le).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(te,"readwrite");a.objectStore(te).put(t),await ke(a)}async loadContext(t,n){const o=this._requireDb().transaction(te,"readonly");return await Ae(o.objectStore(te).get([t,n]))??null}async deleteContextsAfterThread(t,n){const o=this._requireDb().transaction(te,"readwrite"),r=o.objectStore(te).openCursor();await new Promise((s,c)=>{r.onsuccess=()=>{const l=r.result;if(!l){s();return}const d=l.value;if(d.sessionId===t&&d.threadId>n)try{l.delete()}catch{}l.continue()},r.onerror=()=>c(r.error)}),await ke(o)}async loadLatestContext(t){const o=this._requireDb().transaction(te,"readonly").objectStore(te),i=IDBKeyRange.bound([t,""],[t,"￿"]);return new Promise((r,s)=>{const c=o.openCursor(i,"prev");c.onsuccess=()=>{const l=c.result;r(l?l.value:null)},c.onerror=()=>s(c.error)})}async savePayload(t){const a=this._requireDb().transaction(ie,"readwrite");a.objectStore(ie).put(t),await ke(a)}async loadPayload(t,n){const o=this._requireDb().transaction(ie,"readonly");return await Ae(o.objectStore(ie).get([t,n]))??null}async loadPayloadsByThread(t){const o=this._requireDb().transaction(ie,"readonly").objectStore(ie).index("threadId"),i=[];return new Promise((r,s)=>{const c=o.openCursor(IDBKeyRange.only(t));c.onsuccess=()=>{const l=c.result;if(!l){r(i);return}i.push(l.value),l.continue()},c.onerror=()=>s(c.error)})}async saveFavorite(t){const a=this._requireDb().transaction(ne,"readwrite");a.objectStore(ne).put(t),await ke(a)}async removeFavorite(t,n,a){const i=this._requireDb().transaction(ne,"readwrite");i.objectStore(ne).delete([t,n,a]),await ke(i)}async loadFavorites(t,n){const o=this._requireDb().transaction(ne,"readonly");return(await Ae(o.objectStore(ne).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const i=this._requireDb().transaction(ne,"readonly");return await Ae(i.objectStore(ne).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const Bi=["comparisonTable","groupList","productDetailsSimilars","productList"];class Ri{constructor(t){this._lockCount=1,this._hiddenByUser=!1,this._lastPanelContentType=null,this._chatShown=!1,this._isFavoritesMode=!1,this._lastExtended=!1,this._onChange=t.onChange;const n=new Set(Bi);t.productDetailsInPanel&&n.add("productDetails"),this._panelContentTypes=n}get isExtended(){return this._lockCount===0&&!this._hiddenByUser&&!this._isFavoritesMode&&this._lastPanelContentType!==null&&this._panelContentTypes.has(this._lastPanelContentType)&&this._chatShown}unlock(){this._lockCount>0&&this._lockCount--,this._checkStateChange()}lock(){this._lockCount++,this._checkStateChange()}setHiddenByUser(t){this._hiddenByUser=t,this._checkStateChange()}setChatShown(t){this._chatShown=t,this._checkStateChange()}setFavoritesMode(t){this._isFavoritesMode=t,this._checkStateChange()}setPanelContentType(t){this._lastPanelContentType=t,this._checkStateChange()}_checkStateChange(){const t=this.isExtended;t!==this._lastExtended&&(this._lastExtended=t,this._onChange(t))}}class Zi{constructor(t){this.deps=t,this.snapshots=new Map,this.snapshotTypes=new Map,this.activePanelMessageId=null,this.currentType=null,this.threads=[]}snapshotForMessage(t){const n=this.deps.drawer();if(!n?.hasPanelContent()||n.isPanelLoading())return;const a=n.getPanelContentElement();if(!a)return;const o=a.cloneNode(!0);this.snapshots.set(t,o),this.currentType&&this.snapshotTypes.set(t,this.currentType)}attachClickHandler(t){const a=this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(t)}"]`);a&&(a.style.cursor="pointer",a.addEventListener("click",()=>this.restoreForMessage(t)))}restoreForMessage(t){const n=this.snapshots.get(t);if(!n)return!1;const a=this.deps.shadow(),o=this.deps.drawer();this.activePanelMessageId&&a?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"),a?.querySelector(`[data-message-id="${CSS.escape(t)}"]`)?.classList.add("gengage-chat-bubble--active"),this.activePanelMessageId=t,o?.setPanelContent(n.cloneNode(!0));const r=this.snapshotTypes.get(t);return r&&(this.currentType=r,this.updateTopBar(r)),!0}notifyExtension(t){const n=this.deps.bridge();t?setTimeout(()=>n?.send("maximize-pdp",{}),350):setTimeout(()=>n?.send("minify-pdp",{}),200)}titleForComponent(t){const n=this.deps.i18n();switch(t){case"ProductDetailsPanel":return n.panelTitleProductDetails;case"ProductGrid":return n.panelTitleSimilarProducts;case"ComparisonTable":return n.panelTitleComparisonResults;case"AIGroupingCards":return n.panelTitleCategories;default:return""}}updateTopBar(t){const n=this.deps.currentThreadId();if(!n)return;const a=this.threads.indexOf(n),o=a>0,i=a>=0&&a<this.threads.length-1,r=this.titleForComponent(t);this.deps.drawer()?.updatePanelTopBar(o,i,r)}updateTopBarForLoading(t){const n=this.deps.i18n(),o={productDetails:n.panelTitleProductDetails,productList:n.panelTitleSimilarProducts,comparisonTable:n.panelTitleComparisonResults,groupList:n.panelTitleCategories}[t]??"";if(o){const i=this.deps.currentThreadId(),r=i?this.threads.indexOf(i):-1,s=r>0,c=r>=0&&r<this.threads.length-1;this.deps.drawer()?.updatePanelTopBar(s,c,o)}}updateExtendedMode(t){const a={ComparisonTable:"comparisonTable",AIGroupingCards:"groupList",ProductDetailsPanel:"productDetails",ProductGrid:"productList"}[t]??null;this.deps.extendedModeManager()?.setPanelContentType(a)}navigateBack(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>0){const a=this.threads[n-1];a&&this.deps.rollbackToThread(a)}}navigateForward(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>=0&&n<this.threads.length-1){const a=this.threads[n+1];a&&this.deps.rollbackToThread(a)}}toPanelSpec(t){const n=t.elements[t.root];if(!n||n.type!=="ProductCard")return t;const a={...n,type:"ProductDetailsPanel"};return{root:t.root,elements:{...t.elements,[t.root]:a}}}destroy(){this.snapshots.clear(),this.snapshotTypes.clear(),this.activePanelMessageId=null,this.currentType=null,this.threads=[]}}class Ht{constructor(t){this.favoritedSkus=new Set,this._db=t}get db(){return this._db}set db(t){this._db=t}async persist(t){if(!this._db)return;const n=t.messages.map(o=>{const i={id:o.id,role:o.role,timestamp:o.timestamp,status:o.status==="streaming"?"done":o.status};return o.threadId!==void 0&&(i.threadId=o.threadId),o.content!==void 0&&(i.content=o.content),o.silent&&(i.silent=!0),i}),a={};for(const[o,i]of t.panelSnapshots)i.querySelector(".gengage-chat-panel-skeleton")||(a[o]=i.innerHTML);await this._db.saveSession({userId:t.userId,appId:t.appId,sessionId:t.sessionId,messages:n,currentThreadId:t.currentThreadId,lastThreadId:t.lastThreadId,createdAt:t.chatCreatedAt,panelThreads:t.panelThreads.length>0?t.panelThreads:void 0,thumbnailEntries:t.thumbnailEntries.length>0?t.thumbnailEntries:void 0,panelSnapshotHtml:Object.keys(a).length>0?a:void 0}),t.lastBackendContext&&t.currentThreadId&&await this._db.saveContext({sessionId:t.sessionId,threadId:t.currentThreadId,context:t.lastBackendContext});for(const o of t.messages)o.uiSpec&&o.threadId&&await this._db.savePayload({threadId:o.threadId,messageId:o.id,uiSpec:o.uiSpec});try{sessionStorage.setItem("gengage_restore_session_id",t.sessionId)}catch{}}async saveAndOpenURL(t,n,a){try{await n()}catch{}a?.send("openURLInNewTab",{url:t}),window.location.href=t}async loadPayload(t,n){if(!this._db)return null;for(let a=0;a<3;a++){try{const o=await this._db.loadPayload(t,n);if(o)return o.uiSpec}catch{}a<2&&await new Promise(o=>setTimeout(o,100))}return null}async loadFavorites(t,n){if(this._db)try{const a=await this._db.loadFavorites(t,n);for(const o of a)this.favoritedSkus.add(o.sku)}catch{}}async toggleFavorite(t,n,a,o){this._db&&(this.favoritedSkus.has(a)?(this.favoritedSkus.delete(a),await this._db.removeFavorite(t,n,a)):(this.favoritedSkus.add(a),await this._db.saveFavorite({userId:t,appId:n,sku:a,name:o.name,imageUrl:o.imageUrl,price:o.price,savedAt:new Date().toISOString()})))}close(){this._db?.close(),this._db=null}}const Vt="gengage_kvkk_shown",Ui=["kvkk","kişisel veri","kisisel veri"],ji=/\b6698\b/;function et(e){const t=e.toLowerCase();return Ui.some(n=>t.includes(n))||ji.test(t)}function Gt(e){try{return localStorage.getItem(`${Vt}_${e}`)==="1"}catch{return!1}}function Fi(e){try{localStorage.setItem(`${Vt}_${e}`,"1")}catch{}}function qi(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const o of a)if(et(o.textContent??"")){o.remove();break}return n.innerHTML.trim()}function Hi(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(et(n.textContent??""))return n.outerHTML;return null}const Vi={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function Gi(e){return e?Vi[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const Wi=':host{all:initial;font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px)}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 12px);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(15, 23, 42, .18));--_gengage-border-color: var(--gengage-border-color, #e5e7eb);--_gengage-discount-color: var(--gengage-discount-color, #ef4444);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #0f172a47;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #0f172a47}.gengage-chat-launcher svg{width:24px;height:24px}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:#1e293b;color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:#1e293b}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-proactive{position:fixed;bottom:calc(var(--_gengage-chat-launcher-bottom) + var(--_gengage-chat-launcher-size) + 14px);right:var(--_gengage-chat-launcher-right);width:280px;padding:16px 18px;border-radius:16px;background:#fff;box-shadow:0 8px 30px #0000001f,0 2px 8px #0000000f;opacity:0;transform:translateY(8px) scale(.96);transition:opacity .25s ease,transform .25s ease;z-index:2147483645}.gengage-chat-proactive--visible{opacity:1;transform:translateY(0) scale(1)}.gengage-chat-proactive-message{margin:0 0 12px;font-size:14px;line-height:1.5;color:#1f2937}.gengage-chat-proactive-actions{display:flex;gap:8px}.gengage-chat-proactive-accept{flex:1;padding:8px 16px;border:none;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .15s ease}.gengage-chat-proactive-accept:hover{filter:brightness(1.08)}.gengage-chat-proactive-dismiss{position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:transparent;color:#64748b;font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center}.gengage-chat-proactive-dismiss:hover{color:#475569;background:#f1f5f9}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform-origin:right center;clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:16px;bottom:calc(16px + env(safe-area-inset-bottom))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;border-top:1px solid rgba(0,0,0,.06);box-shadow:0 -4px 16px #0000001a,0 12px 40px #0f172a2e;padding-bottom:env(safe-area-inset-bottom,0px);clip-path:inset(0);transition:clip-path .42s cubic-bezier(.25,.46,.45,.94),opacity .32s ease}.gengage-chat-root--mobile.gengage-chat-root--open:before{content:"";position:fixed;inset:0;background:#0000001f;z-index:-1;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0;border-top:none}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--_gengage-border-color, #e5e7eb);transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;border:2px solid rgba(255,255,255,.15)}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffbf;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-close{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;width:440px;min-width:440px;border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;background:#f8fafc}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:#e5e7eb;position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:24px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:#f1f5f9;color:#334155}.gengage-chat-panel--collapsed{flex:0 0 0px!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;border-right:none!important;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #fff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:#fff;padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #3b82f6);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #2563eb);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #fff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #fff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:#f3f4f6;color:#1f2937;border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #2563eb);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-accent-primary, #3b82f6);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:#f3f4f6;padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--gengage-chat-success, #4caf50)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-chat-primary, #1976d2);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:#991b1b;font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #fff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 2px #3b82f626}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:#1f2937;resize:none;overflow-y:hidden}@media(max-width:767px){.gengage-chat-input{max-height:40px;white-space:nowrap;overflow:hidden}.gengage-chat-send{width:44px;height:44px;min-width:44px}}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 4px #0000001f}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#d1d5db;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;gap:8px;padding:6px 0 4px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.gengage-chat-action-buttons::-webkit-scrollbar{display:none}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 16px #0000001f}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:#1f2937;line-height:1.35;margin-bottom:0;min-height:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-card-review-count{color:#64748b;font-size:10px}.gengage-chat-product-card-price{display:flex;align-items:baseline;justify-content:center;gap:4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:#64748b;font-weight:400;font-size:12px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #3b82f6);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid #f1f5f9;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #0b24d6);background:#f8fafc}.gengage-chat-product-card-cta:active{background:#f1f5f9}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid #f3f4f6;background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-product-summary__rating{font-size:11px;color:#f59e0b;line-height:1}.gengage-chat-product-summary__review-count{color:#6b7280;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:#6b7280;font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #2563eb);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #2563eb);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:#1f2937}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:#f8fafc}.gengage-chat-review-tab--active{background:#f1f5f9;border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;color:#334155;box-shadow:0 1px 2px #0000000a}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:#16a34a}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:#f1f5f9;color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:#00000073;z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid #f1f5f9;border-radius:0;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-weight:700;font-size:13px}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid #f1f5f9;border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #3b82f6);border-bottom-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:#f8fafc}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid #f1f5f9;width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:#1f2937;border-bottom:1px solid #f1f5f9}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}.gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(0 0 0 100%);opacity:0;pointer-events:none;box-shadow:none}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{clip-path:inset(100% 0 0 0);opacity:0;pointer-events:none;box-shadow:none}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:#f3f4f6;border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;padding:6px;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #3b82f6);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}@media(max-width:768px){.gengage-chat-panel-divider{display:none}.gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:column}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:100%;min-width:0;max-width:none;max-height:30dvh;border-right:none;border-bottom:1px solid var(--_gengage-border-color);padding:0 12px 12px;margin:0;border-radius:0;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-product-details-media{min-height:140px}.gengage-chat-product-details-title{font-size:15px}.gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-product-card-img{height:180px}}@media(max-width:480px){.gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-bubble{max-width:100%}}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#92400e;font-size:16px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:#16a34a;text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:#f8fafc}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid #f1f5f9}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid #f1f5f9;vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:#f8fafc;margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #3b82f6);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid #f1f5f9;background:var(--gengage-background-color, #fff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:#f8fafc;color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-proactive,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-cards{display:flex;flex-direction:column;gap:10px}.gengage-chat-ai-toppick-discount-badge{position:absolute;top:8px;left:8px;background:var(--gengage-discount-bg, #ef4444);color:#fff;font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;z-index:1}.gengage-chat-ai-toppick-card--winner{position:relative;display:flex;flex-direction:column;border:2px solid var(--gengage-primary-color, #3b82f6);border-radius:12px;background:#fff;overflow:hidden;transition:box-shadow .2s ease}.gengage-chat-ai-toppick-card--winner:hover{box-shadow:0 4px 16px #3b82f626}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:140px;object-fit:contain;background:#f8fafc}.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;background:#fff;padding:10px;transition:box-shadow .2s ease,transform .15s ease}.gengage-chat-ai-toppick-card--compact:hover{box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:64px;height:64px;object-fit:contain;border-radius:8px;background:#f8fafc;flex-shrink:0}.gengage-chat-ai-toppick-badge{position:absolute;top:8px;left:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:10px;font-weight:700;text-transform:uppercase;padding:2px 8px;border-radius:4px;z-index:1;letter-spacing:.5px}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:4px;padding:10px;flex:1;min-width:0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0}.gengage-chat-ai-toppick-name{font-size:13px;font-weight:600;color:var(--gengage-text-primary, #1e293b);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #3b82f6);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:#f1f5f9;color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-ai-toppick-reason{font-size:12px;color:var(--gengage-chat-text-secondary, #666);line-height:1.4;margin-top:4px}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:2px 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b)}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 20px);margin:6px 10px 10px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:auto;margin:0;padding:6px 14px;flex-shrink:0;align-self:center}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:3}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}@media(max-width:768px){.gengage-chat-ai-top-picks-cards{flex-direction:row;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;gap:10px;padding-bottom:4px}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{min-width:280px;max-width:280px;flex-shrink:0;scroll-snap-align:start}.gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img{width:100%;height:100px;border-radius:8px 8px 0 0}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:6px 10px 10px;align-self:stretch}.gengage-chat-rollback-btn{left:-24px}}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #3b82f6);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #3b82f6);flex-shrink:0}.gengage-chat-grouping-card-img{width:20px;height:20px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active,.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #3b82f6);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;left:8px;z-index:2;width:18px;height:18px;cursor:pointer;accent-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-comparison-floating-btn{display:block;width:100%;margin-top:8px;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center}.gengage-chat-comparison-floating-btn:hover{background:var(--gengage-primary-hover, #2563eb)}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:#f8fafc;min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:#f3f4f6;border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #3b82f6);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #3b82f6);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:wrap}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:#f3f4f6;border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:6px;left:6px;padding:2px 6px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px}.gengage-chat-product-card-stock.is-in-stock{color:var(--_gengage-success-color)}.gengage-chat-product-card-stock.is-out-of-stock{color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:8px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap}.gengage-chat-thumbnails-column{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:4px;z-index:2;pointer-events:auto}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid #e5e7eb;border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #3b82f6)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:10;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:#1f2937;margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #3b82f6);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:4px;right:6px;padding:2px 6px;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:#f8fafc;border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:#16a34a;background:#dcfce7}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile .gengage-chat-comparison-table,.gengage-chat-comparison--mobile .gengage-chat-comparison-table thead,.gengage-chat-comparison--mobile .gengage-chat-comparison-table tbody{display:block}.gengage-chat-comparison--mobile .gengage-chat-comparison-table tr{display:flex;flex-wrap:wrap}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:#f3f4f6}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:#1f2937;-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #3b82f6);border-color:var(--gengage-primary-color, #3b82f6);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#1e293b;color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-proactive-accept:focus-visible,.gengage-chat-proactive-dismiss:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}';function Ki(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function V(e,t){const n={event:e,...t};Ki()&&window.dataLayer.push(n)}function Ji(e){V("gengage-on-init",{gengage_widget:e})}function Yi(e){V("gengage-show",{gengage_widget:e})}function Xi(e,t){V("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function Qi(e){V("gengage-find-similars",{gengage_sku:e})}function er(e){V("gengage-compare-preselection",{gengage_sku:e})}function Wt(e){V("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function tr(){V("gengage-compare-clear")}function nr(e){V("gengage-compare-received",{gengage_product_count:e})}function ar(e){V("gengage-like-product",{gengage_sku:e})}function or(){V("gengage-like-list")}function ir(e,t){V("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function rr(e,t){V("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function sr(e,t){V("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function cr(){V("gengage-message-sent")}function Kt(){V("gengage-message-received")}function lr(){V("gengage-conversation-start")}function dr(){V("gengage-voice-input")}function m(e,t,n){function a(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:r,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const l=r.prototype,d=Object.keys(l);for(let g=0;g<d.length;g++){const u=d[g];u in s||(s[u]=l[u].bind(s))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function r(s){var c;const l=n?.Parent?new i:this;a(l,s),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(r,"init",{value:a}),Object.defineProperty(r,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class Ce extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Jt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Yt={};function de(e){return Yt}function Xt(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,o])=>t.indexOf(+a)===-1).map(([a,o])=>o)}function tt(e,t){return typeof t=="bigint"?t.toString():t}function nt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function at(e){return e==null}function ot(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function gr(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let o=(a.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(a)){const c=a.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,r=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return r%s/10**i}const Qt=Symbol("evaluating");function M(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Qt)return a===void 0&&(a=Qt,a=n()),a},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ve(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ge(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function en(e){return JSON.stringify(e)}function pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const tn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ur=nt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ee(e){if($e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!($e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function nn(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e}const hr=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function S(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function fr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const mr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function br(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=ge(e._zod.def,{get shape(){const r={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return ve(this,"shape",r),r},checks:[]});return pe(e,i)}function _r(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=ge(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return ve(this,"shape",r),r},checks:[]});return pe(e,i)}function vr(e,t){if(!Ee(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(i,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ge(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return ve(this,"shape",i),i}});return pe(e,o)}function yr(e,t){if(!Ee(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ge(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return ve(this,"shape",a),a}});return pe(e,n)}function wr(e,t){const n=ge(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return ve(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return pe(e,n)}function xr(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=ge(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(n)for(const l in n){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(const l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return ve(this,"shape",c),c},checks:[]});return pe(t,r)}function kr(e,t,n){const a=ge(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const r in n){if(!(r in i))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(i[r]=new e({type:"nonoptional",innerType:o[r]}))}else for(const r in o)i[r]=new e({type:"nonoptional",innerType:o[r]});return ve(this,"shape",i),i}});return pe(t,a)}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Te(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function De(e){return typeof e=="string"?e:e?.message}function ue(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const o=De(e.inst?._zod.def?.error?.(e))??De(t?.error?.(e))??De(n.customError?.(e))??De(n.localeError?.(e))??"Invalid input";a.message=o}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function it(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ne(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const an=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,tt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},on=m("$ZodError",an),rn=m("$ZodError",an,{Parent:Error});function Cr(e,t=n=>n.message){const n={},a=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):a.push(t(o));return{formErrors:a,fieldErrors:n}}function Er(e,t=n=>n.message){const n={_errors:[]},a=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(r=>a({issues:r}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let r=n,s=0;for(;s<i.path.length;){const c=i.path[s];s===i.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(i))):r[c]=r[c]||{_errors:[]},r=r[c],s++}}};return a(e),n}const rt=e=>(t,n,a,o)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new Ce;if(r.issues.length){const s=new(o?.Err??e)(r.issues.map(c=>ue(c,i,de())));throw tn(s,o?.callee),s}return r.value},st=e=>async(t,n,a,o)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise&&(r=await r),r.issues.length){const s=new(o?.Err??e)(r.issues.map(c=>ue(c,i,de())));throw tn(s,o?.callee),s}return r.value},Be=e=>(t,n,a)=>{const o=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ce;return i.issues.length?{success:!1,error:new(e??on)(i.issues.map(r=>ue(r,o,de())))}:{success:!0,data:i.value}},Sr=Be(rn),Re=e=>async(t,n,a)=>{const o=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(r=>ue(r,o,de())))}:{success:!0,data:i.value}},Tr=Re(rn),Ir=e=>(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return rt(e)(t,n,o)},zr=e=>(t,n,a)=>rt(e)(t,n,a),Ar=e=>async(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return st(e)(t,n,o)},Nr=e=>async(t,n,a)=>st(e)(t,n,a),Pr=e=>(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Be(e)(t,n,o)},Lr=e=>(t,n,a)=>Be(e)(t,n,a),Mr=e=>async(t,n,a)=>{const o=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Re(e)(t,n,o)},$r=e=>async(t,n,a)=>Re(e)(t,n,a),Or=/^[cC][^\s-]{8,}$/,Dr=/^[0-9a-z]+$/,Br=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Rr=/^[0-9a-vA-V]{20}$/,Zr=/^[A-Za-z0-9]{27}$/,Ur=/^[a-zA-Z0-9_-]{21}$/,jr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,sn=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Hr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vr(){return new RegExp(Hr,"u")}const Gr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Kr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Jr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,cn=/^[A-Za-z0-9_-]*$/,Xr=/^\+[1-9]\d{6,14}$/,ln="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Qr=new RegExp(`^${ln}$`);function dn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function es(e){return new RegExp(`^${dn(e)}$`)}function ts(e){const t=dn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${ln}T(?:${a})$`)}const ns=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},as=/^-?\d+$/,gn=/^-?\d+(?:\.\d+)?$/,os=/^(?:true|false)$/i,is=/^[^A-Z]*$/,rs=/^[^a-z]*$/,K=m("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),pn={number:"number",bigint:"bigint",object:"date"},un=m("$ZodCheckLessThan",(e,t)=>{K.init(e,t);const n=pn[typeof t.value];e._zod.onattach.push(a=>{const o=a._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hn=m("$ZodCheckGreaterThan",(e,t)=>{K.init(e,t);const n=pn[typeof t.value];e._zod.onattach.push(a=>{const o=a._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ss=m("$ZodCheckMultipleOf",(e,t)=>{K.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):gr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cs=m("$ZodCheckNumberFormat",(e,t)=>{K.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[o,i]=mr[t.format];e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,n&&(s.pattern=as)}),e._zod.check=r=>{const s=r.value;if(n){if(!Number.isInteger(s)){r.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?r.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):r.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<o&&r.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&r.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ls=m("$ZodCheckMaxLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const o=a.value;if(o.length<=t.maximum)return;const r=it(o);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ds=m("$ZodCheckMinLength",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const o=a.value;if(o.length>=t.minimum)return;const r=it(o);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gs=m("$ZodCheckLengthEquals",(e,t)=>{var n;K.init(e,t),(n=e._zod.def).when??(n.when=a=>{const o=a.value;return!at(o)&&o.length!==void 0}),e._zod.onattach.push(a=>{const o=a._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=a=>{const o=a.value,i=o.length;if(i===t.length)return;const r=it(o),s=i>t.length;a.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Ze=m("$ZodCheckStringFormat",(e,t)=>{var n,a;K.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),ps=m("$ZodCheckRegex",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),us=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=is),Ze.init(e,t)}),hs=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rs),Ze.init(e,t)}),fs=m("$ZodCheckIncludes",(e,t)=>{K.init(e,t);const n=Oe(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),ms=m("$ZodCheckStartsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),bs=m("$ZodCheckEndsWith",(e,t)=>{K.init(e,t);const n=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),_s=m("$ZodCheckOverwrite",(e,t)=>{K.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vs{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
59
59
  `).filter(r=>r),o=Math.min(...a.map(r=>r.length-r.trimStart().length)),i=a.map(r=>r.slice(o)).map(r=>" ".repeat(this.indent*2)+r);for(const r of i)this.content.push(r)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
60
- `))}}const ys={major:4,minor:3,patch:6},Z=b("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ys;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const o of a)for(const i of o._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(r,s,c)=>{let l=Se(r),d;for(const p of s){if(p._zod.def.when){if(!p._zod.def.when(r))continue}else if(l)continue;const u=r.issues.length,g=p._zod.check(r);if(g instanceof Promise&&c?.async===!1)throw new Ce;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,r.issues.length!==u&&(l||(l=Se(r,u)))});else{if(r.issues.length===u)continue;l||(l=Se(r,u))}}return d?d.then(()=>r):r},i=(r,s,c)=>{if(Se(r))return r.aborted=!0,r;const l=o(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new Ce;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(r,s)=>{if(s.skipChecks)return e._zod.parse(r,s);if(s.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,r,s)):i(l,r,s)}const c=e._zod.parse(r,s);if(c instanceof Promise){if(s.async===!1)throw new Ce;return c.then(l=>o(l,a,s))}return o(c,a,s)}}M(e,"~standard",()=>({validate:o=>{try{const i=Sr(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Tr(e,o).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),ct=b("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ns(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),D=b("$ZodStringFormat",(e,t)=>{Ze.init(e,t),ct.init(e,t)}),ws=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fr),D.init(e,t)}),xs=b("$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=rn(a))}else t.pattern??(t.pattern=rn());D.init(e,t)}),ks=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=qr),D.init(e,t)}),Cs=b("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),o=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Es=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Vr()),D.init(e,t)}),Ss=b("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ur),D.init(e,t)}),Ts=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Or),D.init(e,t)}),Is=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dr),D.init(e,t)}),zs=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Br),D.init(e,t)}),As=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rr),D.init(e,t)}),Ns=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Zr),D.init(e,t)}),Ps=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ts(t)),D.init(e,t)}),Ls=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qr),D.init(e,t)}),Ms=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=es(t)),D.init(e,t)}),$s=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jr),D.init(e,t)}),Os=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gr),D.init(e,t),e._zod.bag.format="ipv4"}),Ds=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wr),D.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Bs=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Kr),D.init(e,t)}),Rs=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Jr),D.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[o,i]=a;if(!i)throw new Error;const r=Number(i);if(`${r}`!==i)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function hn(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Zs=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yr),D.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{hn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Us(e){if(!sn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return hn(n)}const js=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=sn),D.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Us(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Fs=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xr),D.init(e,t)});function qs(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const o=JSON.parse(atob(a));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Hs=b("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=n=>{qs(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),fn=b("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??dn,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Vs=b("$ZodNumberFormat",(e,t)=>{cs.init(e,t),fn.init(e,t)}),Gs=b("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=os,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ws=b("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),Ks=b("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function mn(e,t,n){e.issues.length&&t.issues.push(...Te(n,e.issues)),t.value[n]=e.value}const Js=b("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let r=0;r<o.length;r++){const s=o[r],c=t.element._zod.run({value:s,issues:[]},a);c instanceof Promise?i.push(c.then(l=>mn(l,n,r))):mn(c,n,r)}return i.length?Promise.all(i).then(()=>n):n}});function Ue(e,t,n,a,o){if(e.issues.length){if(o&&!(n in a))return;t.issues.push(...Te(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function bn(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=fr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function _n(e,t,n,a,o,i){const r=[],s=o.keySet,c=o.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const p in t){if(s.has(p))continue;if(l==="never"){r.push(p);continue}const u=c.run({value:t[p],issues:[]},a);u instanceof Promise?e.push(u.then(g=>Ue(g,n,p,t,d))):Ue(u,n,p,t,d)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Ys=b("$ZodObject",(e,t)=>{if(Z.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}const a=nt(()=>bn(t));M(e._zod,"propValues",()=>{const s=t.shape,c={};for(const l in s){const d=s[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const p of d.values)c[l].add(p)}}return c});const o=$e,i=t.catchall;let r;e._zod.parse=(s,c)=>{r??(r=a.value);const l=s.value;if(!o(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};const d=[],p=r.shape;for(const u of r.keys){const g=p[u],m=g._zod.optout==="optional",_=g._zod.run({value:l[u],issues:[]},c);_ instanceof Promise?d.push(_.then(y=>Ue(y,s,u,l,m))):Ue(_,s,u,l,m)}return i?_n(d,l,s,c,a.value,e):d.length?Promise.all(d).then(()=>s):s}}),Xs=b("$ZodObjectJIT",(e,t)=>{Ys.init(e,t);const n=e._zod.parse,a=nt(()=>bn(t)),o=u=>{const g=new vs(["shape","payload","ctx"]),m=a.value,_=h=>{const x=Qt(h);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};g.write("const input = payload.value;");const y=Object.create(null);let z=0;for(const h of m.keys)y[h]=`key_${z++}`;g.write("const newResult = {};");for(const h of m.keys){const x=y[h],k=Qt(h),L=u[h]?._zod?.optout==="optional";g.write(`const ${x} = ${_(h)};`),L?g.write(`
61
- if (${x}.issues.length) {
62
- if (${k} in input) {
63
- payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
60
+ `))}}const ys={major:4,minor:3,patch:6},Z=m("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ys;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const o of a)for(const i of o._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(r,s,c)=>{let l=Se(r),d;for(const g of s){if(g._zod.def.when){if(!g._zod.def.when(r))continue}else if(l)continue;const u=r.issues.length,p=g._zod.check(r);if(p instanceof Promise&&c?.async===!1)throw new Ce;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,r.issues.length!==u&&(l||(l=Se(r,u)))});else{if(r.issues.length===u)continue;l||(l=Se(r,u))}}return d?d.then(()=>r):r},i=(r,s,c)=>{if(Se(r))return r.aborted=!0,r;const l=o(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new Ce;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(r,s)=>{if(s.skipChecks)return e._zod.parse(r,s);if(s.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,r,s)):i(l,r,s)}const c=e._zod.parse(r,s);if(c instanceof Promise){if(s.async===!1)throw new Ce;return c.then(l=>o(l,a,s))}return o(c,a,s)}}M(e,"~standard",()=>({validate:o=>{try{const i=Sr(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Tr(e,o).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),ct=m("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ns(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),D=m("$ZodStringFormat",(e,t)=>{Ze.init(e,t),ct.init(e,t)}),ws=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fr),D.init(e,t)}),xs=m("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=sn(a))}else t.pattern??(t.pattern=sn());D.init(e,t)}),ks=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=qr),D.init(e,t)}),Cs=m("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),o=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Es=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Vr()),D.init(e,t)}),Ss=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ur),D.init(e,t)}),Ts=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Or),D.init(e,t)}),Is=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dr),D.init(e,t)}),zs=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Br),D.init(e,t)}),As=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rr),D.init(e,t)}),Ns=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Zr),D.init(e,t)}),Ps=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ts(t)),D.init(e,t)}),Ls=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qr),D.init(e,t)}),Ms=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=es(t)),D.init(e,t)}),$s=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jr),D.init(e,t)}),Os=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gr),D.init(e,t),e._zod.bag.format="ipv4"}),Ds=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wr),D.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Bs=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Kr),D.init(e,t)}),Rs=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Jr),D.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[o,i]=a;if(!i)throw new Error;const r=Number(i);if(`${r}`!==i)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function fn(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Zs=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yr),D.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{fn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Us(e){if(!cn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return fn(n)}const js=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=cn),D.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Us(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Fs=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xr),D.init(e,t)});function qs(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const o=JSON.parse(atob(a));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Hs=m("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=n=>{qs(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),mn=m("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??gn,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Vs=m("$ZodNumberFormat",(e,t)=>{cs.init(e,t),mn.init(e,t)}),Gs=m("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=os,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ws=m("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),Ks=m("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function bn(e,t,n){e.issues.length&&t.issues.push(...Te(n,e.issues)),t.value[n]=e.value}const Js=m("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let r=0;r<o.length;r++){const s=o[r],c=t.element._zod.run({value:s,issues:[]},a);c instanceof Promise?i.push(c.then(l=>bn(l,n,r))):bn(c,n,r)}return i.length?Promise.all(i).then(()=>n):n}});function Ue(e,t,n,a,o){if(e.issues.length){if(o&&!(n in a))return;t.issues.push(...Te(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function _n(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=fr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function vn(e,t,n,a,o,i){const r=[],s=o.keySet,c=o.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const g in t){if(s.has(g))continue;if(l==="never"){r.push(g);continue}const u=c.run({value:t[g],issues:[]},a);u instanceof Promise?e.push(u.then(p=>Ue(p,n,g,t,d))):Ue(u,n,g,t,d)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Ys=m("$ZodObject",(e,t)=>{if(Z.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}const a=nt(()=>_n(t));M(e._zod,"propValues",()=>{const s=t.shape,c={};for(const l in s){const d=s[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const g of d.values)c[l].add(g)}}return c});const o=$e,i=t.catchall;let r;e._zod.parse=(s,c)=>{r??(r=a.value);const l=s.value;if(!o(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};const d=[],g=r.shape;for(const u of r.keys){const p=g[u],f=p._zod.optout==="optional",v=p._zod.run({value:l[u],issues:[]},c);v instanceof Promise?d.push(v.then(y=>Ue(y,s,u,l,f))):Ue(v,s,u,l,f)}return i?vn(d,l,s,c,a.value,e):d.length?Promise.all(d).then(()=>s):s}}),Xs=m("$ZodObjectJIT",(e,t)=>{Ys.init(e,t);const n=e._zod.parse,a=nt(()=>_n(t)),o=u=>{const p=new vs(["shape","payload","ctx"]),f=a.value,v=b=>{const _=en(b);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};p.write("const input = payload.value;");const y=Object.create(null);let I=0;for(const b of f.keys)y[b]=`key_${I++}`;p.write("const newResult = {};");for(const b of f.keys){const _=y[b],w=en(b),P=u[b]?._zod?.optout==="optional";p.write(`const ${_} = ${v(b)};`),P?p.write(`
61
+ if (${_}.issues.length) {
62
+ if (${w} in input) {
63
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
64
64
  ...iss,
65
- path: iss.path ? [${k}, ...iss.path] : [${k}]
65
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
66
66
  })));
67
67
  }
68
68
  }
69
69
 
70
- if (${x}.value === undefined) {
71
- if (${k} in input) {
72
- newResult[${k}] = undefined;
70
+ if (${_}.value === undefined) {
71
+ if (${w} in input) {
72
+ newResult[${w}] = undefined;
73
73
  }
74
74
  } else {
75
- newResult[${k}] = ${x}.value;
75
+ newResult[${w}] = ${_}.value;
76
76
  }
77
77
 
78
- `):g.write(`
79
- if (${x}.issues.length) {
80
- payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
78
+ `):p.write(`
79
+ if (${_}.issues.length) {
80
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
81
81
  ...iss,
82
- path: iss.path ? [${k}, ...iss.path] : [${k}]
82
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
83
83
  })));
84
84
  }
85
85
 
86
- if (${x}.value === undefined) {
87
- if (${k} in input) {
88
- newResult[${k}] = undefined;
86
+ if (${_}.value === undefined) {
87
+ if (${w} in input) {
88
+ newResult[${w}] = undefined;
89
89
  }
90
90
  } else {
91
- newResult[${k}] = ${x}.value;
91
+ newResult[${w}] = ${_}.value;
92
92
  }
93
93
 
94
- `)}g.write("payload.value = newResult;"),g.write("return payload;");const I=g.compile();return(h,x)=>I(u,h,x)};let i;const r=$e,s=!Jt.jitless,l=s&&ur.value,d=t.catchall;let p;e._zod.parse=(u,g)=>{p??(p=a.value);const m=u.value;return r(m)?s&&l&&g?.async===!1&&g.jitless!==!0?(i||(i=o(t.shape)),u=i(u,g),d?_n([],m,u,g,p,e):u):n(u,g):(u.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),u)}});function vn(e,t,n,a){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Se(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(r=>ue(r,a,de())))}),t)}const Qs=b("$ZodUnion",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),M(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),M(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),M(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ot(i.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return a(o,i);let r=!1;const s=[];for(const c of t.options){const l=c._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)s.push(l),r=!0;else{if(l.issues.length===0)return l;s.push(l)}}return r?Promise.all(s).then(c=>vn(c,o,e,i)):vn(s,o,e,i)}}),ec=b("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},a),r=t.right._zod.run({value:o,issues:[]},a);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([c,l])=>yn(n,c,l)):yn(n,i,r)}});function lt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ee(e)&&Ee(t)){const n=Object.keys(t),a=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of a){const r=lt(e[i],t[i]);if(!r.valid)return{valid:!1,mergeErrorPath:[i,...r.mergeErrorPath]};o[i]=r.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let a=0;a<e.length;a++){const o=e[a],i=t[a],r=lt(o,i);if(!r.valid)return{valid:!1,mergeErrorPath:[a,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function yn(e,t,n){const a=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).r=!0;else e.issues.push(s);const i=[...a].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),Se(e))return e;const r=lt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const tc=b("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value;if(!Ee(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],r=t.keyType._zod.values;if(r){n.value={};const s=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:o[l],issues:[]},a);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...Te(l,p.issues)),n.value[l]=p.value})):(d.issues.length&&n.issues.push(...Te(l,d.issues)),n.value[l]=d.value)}let c;for(const l in o)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},a);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&dn.test(s)&&c.issues.length){const p=t.keyType._zod.run({value:Number(s),issues:[]},a);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>ue(p,a,de())),input:s,path:[s],inst:e});continue}const d=t.valueType._zod.run({value:o[s],issues:[]},a);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&n.issues.push(...Te(s,p.issues)),n.value[c.value]=p.value})):(d.issues.length&&n.issues.push(...Te(s,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),nc=b("$ZodEnum",(e,t)=>{Z.init(e,t);const n=Yt(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(o=>hr.has(typeof o)).map(o=>typeof o=="string"?Oe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return a.has(r)||o.issues.push({code:"invalid_value",values:n,input:r,inst:e}),o}}),ac=b("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Kt(e.constructor.name);const o=t.transform(n.value,n);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(r=>(n.value=r,n));if(o instanceof Promise)throw new Ce;return n.value=o,n}});function wn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const xn=b("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",M(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),M(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ot(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>wn(i,n.value)):wn(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),oc=b("$ZodExactOptional",(e,t)=>{xn.init(e,t),M(e._zod,"values",()=>t.innerType._zod.values),M(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),ic=b("$ZodNullable",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.innerType._zod.optin),M(e._zod,"optout",()=>t.innerType._zod.optout),M(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ot(n.source)}|null)$`):void 0}),M(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),rc=b("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>kn(i,t)):kn(o,t)}});function kn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const sc=b("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),cc=b("$ZodNonOptional",(e,t)=>{Z.init(e,t),M(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>Cn(i,e)):Cn(o,e)}});function Cn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const lc=b("$ZodCatch",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.innerType._zod.optin),M(e._zod,"optout",()=>t.innerType._zod.optout),M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(r=>ue(r,a,de()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>ue(i,a,de()))},input:n.value}),n.issues=[]),n)}}),dc=b("$ZodPipe",(e,t)=>{Z.init(e,t),M(e._zod,"values",()=>t.in._zod.values),M(e._zod,"optin",()=>t.in._zod.optin),M(e._zod,"optout",()=>t.out._zod.optout),M(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const i=t.out._zod.run(n,a);return i instanceof Promise?i.then(r=>je(r,t.in,a)):je(i,t.in,a)}const o=t.in._zod.run(n,a);return o instanceof Promise?o.then(i=>je(i,t.out,a)):je(o,t.out,a)}});function je(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const gc=b("$ZodReadonly",(e,t)=>{Z.init(e,t),M(e._zod,"propValues",()=>t.innerType._zod.propValues),M(e._zod,"values",()=>t.innerType._zod.values),M(e._zod,"optin",()=>t.innerType?._zod?.optin),M(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(En):En(o)}});function En(e){return e.value=Object.freeze(e.value),e}const pc=b("$ZodCustom",(e,t)=>{K.init(e,t),Z.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,o=t.fn(a);if(o instanceof Promise)return o.then(i=>Sn(i,n,a,e));Sn(o,n,a,e)}});function Sn(e,t,n,a){if(!e){const o={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(o.params=a._zod.def.params),t.issues.push(Ne(o))}}var Tn;class uc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const o={...a,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function hc(){return new uc}(Tn=globalThis).__zod_globalRegistry??(Tn.__zod_globalRegistry=hc());const Pe=globalThis.__zod_globalRegistry;function fc(e,t){return new e({type:"string",...C(t)})}function mc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...C(t)})}function In(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...C(t)})}function bc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...C(t)})}function _c(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...C(t)})}function vc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...C(t)})}function yc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...C(t)})}function wc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...C(t)})}function xc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...C(t)})}function kc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...C(t)})}function Cc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...C(t)})}function Ec(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...C(t)})}function Sc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...C(t)})}function Tc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...C(t)})}function Ic(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...C(t)})}function zc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...C(t)})}function Ac(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...C(t)})}function Nc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...C(t)})}function Pc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...C(t)})}function Lc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...C(t)})}function Mc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...C(t)})}function $c(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...C(t)})}function Oc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...C(t)})}function Dc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...C(t)})}function Bc(e,t){return new e({type:"string",format:"date",check:"string_format",...C(t)})}function Rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...C(t)})}function Zc(e,t){return new e({type:"string",format:"duration",check:"string_format",...C(t)})}function Uc(e,t){return new e({type:"number",checks:[],...C(t)})}function jc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...C(t)})}function Fc(e,t){return new e({type:"boolean",...C(t)})}function qc(e){return new e({type:"unknown"})}function Hc(e,t){return new e({type:"never",...C(t)})}function zn(e,t){return new pn({check:"less_than",...C(t),value:e,inclusive:!1})}function dt(e,t){return new pn({check:"less_than",...C(t),value:e,inclusive:!0})}function An(e,t){return new un({check:"greater_than",...C(t),value:e,inclusive:!1})}function gt(e,t){return new un({check:"greater_than",...C(t),value:e,inclusive:!0})}function Nn(e,t){return new ss({check:"multiple_of",...C(t),value:e})}function Pn(e,t){return new ls({check:"max_length",...C(t),maximum:e})}function Fe(e,t){return new ds({check:"min_length",...C(t),minimum:e})}function Ln(e,t){return new gs({check:"length_equals",...C(t),length:e})}function Vc(e,t){return new ps({check:"string_format",format:"regex",...C(t),pattern:e})}function Gc(e){return new us({check:"string_format",format:"lowercase",...C(e)})}function Wc(e){return new hs({check:"string_format",format:"uppercase",...C(e)})}function Kc(e,t){return new fs({check:"string_format",format:"includes",...C(t),includes:e})}function Jc(e,t){return new ms({check:"string_format",format:"starts_with",...C(t),prefix:e})}function Yc(e,t){return new bs({check:"string_format",format:"ends_with",...C(t),suffix:e})}function Ie(e){return new _s({check:"overwrite",tx:e})}function Xc(e){return Ie(t=>t.normalize(e))}function Qc(){return Ie(e=>e.trim())}function el(){return Ie(e=>e.toLowerCase())}function tl(){return Ie(e=>e.toUpperCase())}function nl(){return Ie(e=>pr(e))}function al(e,t,n){return new e({type:"array",element:t,...C(n)})}function ol(e,t,n){return new e({type:"custom",check:"custom",fn:t,...C(n)})}function il(e){const t=rl(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ne(a,n.value,t._zod.def));else{const o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Ne(o))}},e(n.value,n)));return t}function rl(e,t){const n=new K({check:"custom",...C(t)});return n._zod.check=e,n}function Mn(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Pe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function F(e,t,n={path:[],schemaPath:[]}){var a;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const s=e._zod.toJSONSchema?.();if(s)r.schema=s;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const u=r.schema,g=t.processors[o.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,t,u,d)}const p=e._zod.parent;p&&(r.ref||(r.ref=p),F(p,t,d),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&G(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((a=r.schema).default??(a.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function $n(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const r of e.seen.entries()){const s=e.metadataRegistry.get(r[0])?.id;if(s){const c=a.get(s);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,r[0])}}const o=r=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(r[0])?.id,u=e.external.uri??(m=>m);if(p)return{ref:u(p)};const g=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=g,{defId:g,ref:`${u("__shared")}#/${s}/${g}`}}if(r[1]===n)return{ref:"#"};const l=`#/${s}/`,d=r[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},i=r=>{if(r[1].schema.$ref)return;const s=r[1],{ref:c,defId:l}=o(r);s.def={...s.schema},l&&(s.defId=l);const d=s.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const s=r[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
94
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const z=p.compile();return(b,_)=>z(u,b,_)};let i;const r=$e,s=!Yt.jitless,l=s&&ur.value,d=t.catchall;let g;e._zod.parse=(u,p)=>{g??(g=a.value);const f=u.value;return r(f)?s&&l&&p?.async===!1&&p.jitless!==!0?(i||(i=o(t.shape)),u=i(u,p),d?vn([],f,u,p,g,e):u):n(u,p):(u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u)}});function yn(e,t,n,a){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Se(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(r=>ue(r,a,de())))}),t)}const Qs=m("$ZodUnion",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),M(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),M(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),M(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ot(i.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return a(o,i);let r=!1;const s=[];for(const c of t.options){const l=c._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)s.push(l),r=!0;else{if(l.issues.length===0)return l;s.push(l)}}return r?Promise.all(s).then(c=>yn(c,o,e,i)):yn(s,o,e,i)}}),ec=m("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},a),r=t.right._zod.run({value:o,issues:[]},a);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([c,l])=>wn(n,c,l)):wn(n,i,r)}});function lt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ee(e)&&Ee(t)){const n=Object.keys(t),a=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of a){const r=lt(e[i],t[i]);if(!r.valid)return{valid:!1,mergeErrorPath:[i,...r.mergeErrorPath]};o[i]=r.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let a=0;a<e.length;a++){const o=e[a],i=t[a],r=lt(o,i);if(!r.valid)return{valid:!1,mergeErrorPath:[a,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function wn(e,t,n){const a=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).r=!0;else e.issues.push(s);const i=[...a].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),Se(e))return e;const r=lt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const tc=m("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{const o=n.value;if(!Ee(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],r=t.keyType._zod.values;if(r){n.value={};const s=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:o[l],issues:[]},a);d instanceof Promise?i.push(d.then(g=>{g.issues.length&&n.issues.push(...Te(l,g.issues)),n.value[l]=g.value})):(d.issues.length&&n.issues.push(...Te(l,d.issues)),n.value[l]=d.value)}let c;for(const l in o)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},a);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&gn.test(s)&&c.issues.length){const g=t.keyType._zod.run({value:Number(s),issues:[]},a);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){t.mode==="loose"?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>ue(g,a,de())),input:s,path:[s],inst:e});continue}const d=t.valueType._zod.run({value:o[s],issues:[]},a);d instanceof Promise?i.push(d.then(g=>{g.issues.length&&n.issues.push(...Te(s,g.issues)),n.value[c.value]=g.value})):(d.issues.length&&n.issues.push(...Te(s,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),nc=m("$ZodEnum",(e,t)=>{Z.init(e,t);const n=Xt(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(o=>hr.has(typeof o)).map(o=>typeof o=="string"?Oe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return a.has(r)||o.issues.push({code:"invalid_value",values:n,input:r,inst:e}),o}}),ac=m("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Jt(e.constructor.name);const o=t.transform(n.value,n);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(r=>(n.value=r,n));if(o instanceof Promise)throw new Ce;return n.value=o,n}});function xn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const kn=m("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",M(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),M(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ot(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>xn(i,n.value)):xn(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),oc=m("$ZodExactOptional",(e,t)=>{kn.init(e,t),M(e._zod,"values",()=>t.innerType._zod.values),M(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),ic=m("$ZodNullable",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.innerType._zod.optin),M(e._zod,"optout",()=>t.innerType._zod.optout),M(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ot(n.source)}|null)$`):void 0}),M(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),rc=m("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>Cn(i,t)):Cn(o,t)}});function Cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const sc=m("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),cc=m("$ZodNonOptional",(e,t)=>{Z.init(e,t),M(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>En(i,e)):En(o,e)}});function En(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const lc=m("$ZodCatch",(e,t)=>{Z.init(e,t),M(e._zod,"optin",()=>t.innerType._zod.optin),M(e._zod,"optout",()=>t.innerType._zod.optout),M(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(r=>ue(r,a,de()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>ue(i,a,de()))},input:n.value}),n.issues=[]),n)}}),dc=m("$ZodPipe",(e,t)=>{Z.init(e,t),M(e._zod,"values",()=>t.in._zod.values),M(e._zod,"optin",()=>t.in._zod.optin),M(e._zod,"optout",()=>t.out._zod.optout),M(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const i=t.out._zod.run(n,a);return i instanceof Promise?i.then(r=>je(r,t.in,a)):je(i,t.in,a)}const o=t.in._zod.run(n,a);return o instanceof Promise?o.then(i=>je(i,t.out,a)):je(o,t.out,a)}});function je(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const gc=m("$ZodReadonly",(e,t)=>{Z.init(e,t),M(e._zod,"propValues",()=>t.innerType._zod.propValues),M(e._zod,"values",()=>t.innerType._zod.values),M(e._zod,"optin",()=>t.innerType?._zod?.optin),M(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const o=t.innerType._zod.run(n,a);return o instanceof Promise?o.then(Sn):Sn(o)}});function Sn(e){return e.value=Object.freeze(e.value),e}const pc=m("$ZodCustom",(e,t)=>{K.init(e,t),Z.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,o=t.fn(a);if(o instanceof Promise)return o.then(i=>Tn(i,n,a,e));Tn(o,n,a,e)}});function Tn(e,t,n,a){if(!e){const o={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(o.params=a._zod.def.params),t.issues.push(Ne(o))}}var In;class uc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const o={...a,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function hc(){return new uc}(In=globalThis).__zod_globalRegistry??(In.__zod_globalRegistry=hc());const Pe=globalThis.__zod_globalRegistry;function fc(e,t){return new e({type:"string",...S(t)})}function mc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function zn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function bc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function _c(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function vc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function yc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function wc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function xc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function kc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function Cc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function Ec(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function Sc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function Tc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function Ic(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function zc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function Ac(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function Nc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function Pc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function Lc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function Mc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function $c(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function Oc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function Dc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function Bc(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function Rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function Zc(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function Uc(e,t){return new e({type:"number",checks:[],...S(t)})}function jc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function Fc(e,t){return new e({type:"boolean",...S(t)})}function qc(e){return new e({type:"unknown"})}function Hc(e,t){return new e({type:"never",...S(t)})}function An(e,t){return new un({check:"less_than",...S(t),value:e,inclusive:!1})}function dt(e,t){return new un({check:"less_than",...S(t),value:e,inclusive:!0})}function Nn(e,t){return new hn({check:"greater_than",...S(t),value:e,inclusive:!1})}function gt(e,t){return new hn({check:"greater_than",...S(t),value:e,inclusive:!0})}function Pn(e,t){return new ss({check:"multiple_of",...S(t),value:e})}function Ln(e,t){return new ls({check:"max_length",...S(t),maximum:e})}function Fe(e,t){return new ds({check:"min_length",...S(t),minimum:e})}function Mn(e,t){return new gs({check:"length_equals",...S(t),length:e})}function Vc(e,t){return new ps({check:"string_format",format:"regex",...S(t),pattern:e})}function Gc(e){return new us({check:"string_format",format:"lowercase",...S(e)})}function Wc(e){return new hs({check:"string_format",format:"uppercase",...S(e)})}function Kc(e,t){return new fs({check:"string_format",format:"includes",...S(t),includes:e})}function Jc(e,t){return new ms({check:"string_format",format:"starts_with",...S(t),prefix:e})}function Yc(e,t){return new bs({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Ie(e){return new _s({check:"overwrite",tx:e})}function Xc(e){return Ie(t=>t.normalize(e))}function Qc(){return Ie(e=>e.trim())}function el(){return Ie(e=>e.toLowerCase())}function tl(){return Ie(e=>e.toUpperCase())}function nl(){return Ie(e=>pr(e))}function al(e,t,n){return new e({type:"array",element:t,...S(n)})}function ol(e,t,n){return new e({type:"custom",check:"custom",fn:t,...S(n)})}function il(e){const t=rl(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ne(a,n.value,t._zod.def));else{const o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Ne(o))}},e(n.value,n)));return t}function rl(e,t){const n=new K({check:"custom",...S(t)});return n._zod.check=e,n}function $n(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Pe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function F(e,t,n={path:[],schemaPath:[]}){var a;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const s=e._zod.toJSONSchema?.();if(s)r.schema=s;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const u=r.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,u,d)}const g=e._zod.parent;g&&(r.ref||(r.ref=g),F(g,t,d),t.seen.get(g).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&G(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((a=r.schema).default??(a.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function On(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const r of e.seen.entries()){const s=e.metadataRegistry.get(r[0])?.id;if(s){const c=a.get(s);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,r[0])}}const o=r=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=e.external.registry.get(r[0])?.id,u=e.external.uri??(f=>f);if(g)return{ref:u(g)};const p=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=p,{defId:p,ref:`${u("__shared")}#/${s}/${p}`}}if(r[1]===n)return{ref:"#"};const l=`#/${s}/`,d=r[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},i=r=>{if(r[1].schema.$ref)return;const s=r[1],{ref:c,defId:l}=o(r);s.def={...s.schema},l&&(s.defId=l);const d=s.schema;for(const g in d)delete d[g];d.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const s=r[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
95
95
 
96
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const s=r[1];if(t===r[0]){i(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){i(r);continue}}if(e.metadataRegistry.get(r[0])?.id){i(r);continue}if(s.cycle){i(r);continue}if(s.count>1&&e.reused==="ref"){i(r);continue}}}function On(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=r=>{const s=e.seen.get(r);if(s.ref===null)return;const c=s.def??s.schema,l={...c},d=s.ref;if(s.ref=null,d){a(d);const u=e.seen.get(d),g=u.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(g)):Object.assign(c,g),Object.assign(c,l),r._zod.parent===d)for(const _ in c)_==="$ref"||_==="allOf"||_ in l||delete c[_];if(g.$ref&&u.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in u.def&&JSON.stringify(c[_])===JSON.stringify(u.def[_])&&delete c[_]}const p=r._zod.parent;if(p&&p!==d){a(p);const u=e.seen.get(p);if(u?.schema.$ref&&(c.$ref=u.schema.$ref,u.def))for(const g in c)g==="$ref"||g==="allOf"||g in u.def&&JSON.stringify(c[g])===JSON.stringify(u.def[g])&&delete c[g]}e.override({zodSchema:r,jsonSchema:c,path:s.path??[]})};for(const r of[...e.seen.entries()].reverse())a(r[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(r)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const r of e.seen.entries()){const s=r[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const r=JSON.parse(JSON.stringify(o));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:qe(t,"input",e.processors),output:qe(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function G(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return G(a.element,n);if(a.type==="set")return G(a.valueType,n);if(a.type==="lazy")return G(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return G(a.innerType,n);if(a.type==="intersection")return G(a.left,n)||G(a.right,n);if(a.type==="record"||a.type==="map")return G(a.keyType,n)||G(a.valueType,n);if(a.type==="pipe")return G(a.in,n)||G(a.out,n);if(a.type==="object"){for(const o in a.shape)if(G(a.shape[o],n))return!0;return!1}if(a.type==="union"){for(const o of a.options)if(G(o,n))return!0;return!1}if(a.type==="tuple"){for(const o of a.items)if(G(o,n))return!0;return!!(a.rest&&G(a.rest,n))}return!1}const sl=(e,t={})=>n=>{const a=Mn({...n,processors:t});return F(e,a),$n(a,e),On(a,e)},qe=(e,t,n={})=>a=>{const{libraryOptions:o,target:i}=a??{},r=Mn({...o??{},target:i,io:t,processors:n});return F(e,r),$n(r,e),On(r,e)},cl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ll=(e,t,n,a)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof r=="number"&&(o.maxLength=r),s&&(o.format=cl[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},dl=(e,t,n,a)=>{const o=n,{minimum:i,maximum:r,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l),typeof r=="number"&&(o.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},gl=(e,t,n,a)=>{n.type="boolean"},pl=(e,t,n,a)=>{n.not={}},ul=(e,t,n,a)=>{},hl=(e,t,n,a)=>{const o=e._zod.def,i=Yt(o.entries);i.every(r=>typeof r=="number")&&(n.type="number"),i.every(r=>typeof r=="string")&&(n.type="string"),n.enum=i},fl=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ml=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bl=(e,t,n,a)=>{const o=n,i=e._zod.def,{minimum:r,maximum:s}=e._zod.bag;typeof r=="number"&&(o.minItems=r),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=F(i.element,t,{...a,path:[...a.path,"items"]})},_l=(e,t,n,a)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const r=i.shape;for(const l in r)o.properties[l]=F(r[l],t,{...a,path:[...a.path,"properties",l]});const s=new Set(Object.keys(r)),c=new Set([...s].filter(l=>{const d=i.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=F(i.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},vl=(e,t,n,a)=>{const o=e._zod.def,i=o.inclusive===!1,r=o.options.map((s,c)=>F(s,t,{...a,path:[...a.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=r:n.anyOf=r},yl=(e,t,n,a)=>{const o=e._zod.def,i=F(o.left,t,{...a,path:[...a.path,"allOf",0]}),r=F(o.right,t,{...a,path:[...a.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(i)?i.allOf:[i],...s(r)?r.allOf:[r]];n.allOf=c},wl=(e,t,n,a)=>{const o=n,i=e._zod.def;o.type="object";const r=i.keyType,c=r._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=F(i.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});o.patternProperties={};for(const p of c)o.patternProperties[p.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=F(i.keyType,t,{...a,path:[...a.path,"propertyNames"]})),o.additionalProperties=F(i.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const l=r._zod.values;if(l){const d=[...l].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(o.required=d)}},xl=(e,t,n,a)=>{const o=e._zod.def,i=F(o.innerType,t,a),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},kl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType},Cl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},El=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Sl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType;let r;try{r=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Tl=(e,t,n,a)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;F(i,t,a);const r=t.seen.get(e);r.ref=i},Il=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Dn=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType},zl=b("ZodISODateTime",(e,t)=>{Ps.init(e,t),R.init(e,t)});function Al(e){return Dc(zl,e)}const Nl=b("ZodISODate",(e,t)=>{Ls.init(e,t),R.init(e,t)});function Pl(e){return Bc(Nl,e)}const Ll=b("ZodISOTime",(e,t)=>{Ms.init(e,t),R.init(e,t)});function Ml(e){return Rc(Ll,e)}const $l=b("ZodISODuration",(e,t)=>{$s.init(e,t),R.init(e,t)});function Ol(e){return Zc($l,e)}const Y=b("ZodError",(e,t)=>{an.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Er(e,n)},flatten:{value:n=>Cr(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,tt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,tt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Dl=rt(Y),Bl=st(Y),Rl=Be(Y),Zl=Re(Y),Ul=Ir(Y),jl=zr(Y),Fl=Ar(Y),ql=Nr(Y),Hl=Pr(Y),Vl=Lr(Y),Gl=Mr(Y),Wl=$r(Y),U=b("ZodType",(e,t)=>(Z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:qe(e,"input"),output:qe(e,"output")}}),e.toJSONSchema=sl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ge(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>pe(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Dl(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>Rl(e,n,a),e.parseAsync=async(n,a)=>Bl(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>Zl(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Ul(e,n,a),e.decode=(n,a)=>jl(e,n,a),e.encodeAsync=async(n,a)=>Fl(e,n,a),e.decodeAsync=async(n,a)=>ql(e,n,a),e.safeEncode=(n,a)=>Hl(e,n,a),e.safeDecode=(n,a)=>Vl(e,n,a),e.safeEncodeAsync=async(n,a)=>Gl(e,n,a),e.safeDecodeAsync=async(n,a)=>Wl(e,n,a),e.refine=(n,a)=>e.check(Zd(n,a)),e.superRefine=n=>e.check(Ud(n)),e.overwrite=n=>e.check(Ie(n)),e.optional=()=>Fn(e),e.exactOptional=()=>Td(e),e.nullable=()=>qn(e),e.nullish=()=>Fn(qn(e)),e.nonoptional=n=>Ld(e,n),e.array=()=>B(e),e.or=n=>Ve([e,n]),e.and=n=>xd(e,n),e.transform=n=>Vn(e,Ed(n)),e.default=n=>Ad(e,n),e.prefault=n=>Pd(e,n),e.catch=n=>$d(e,n),e.pipe=n=>Vn(e,n),e.readonly=()=>Bd(e),e.describe=n=>{const a=e.clone();return Pe.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Pe.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Pe.get(e);const a=e.clone();return Pe.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Bn=b("_ZodString",(e,t)=>{ct.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>ll(e,a,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(Vc(...a)),e.includes=(...a)=>e.check(Kc(...a)),e.startsWith=(...a)=>e.check(Jc(...a)),e.endsWith=(...a)=>e.check(Yc(...a)),e.min=(...a)=>e.check(Fe(...a)),e.max=(...a)=>e.check(Pn(...a)),e.length=(...a)=>e.check(Ln(...a)),e.nonempty=(...a)=>e.check(Fe(1,...a)),e.lowercase=a=>e.check(Gc(a)),e.uppercase=a=>e.check(Wc(a)),e.trim=()=>e.check(Qc()),e.normalize=(...a)=>e.check(Xc(...a)),e.toLowerCase=()=>e.check(el()),e.toUpperCase=()=>e.check(tl()),e.slugify=()=>e.check(nl())}),Kl=b("ZodString",(e,t)=>{ct.init(e,t),Bn.init(e,t),e.email=n=>e.check(mc(Jl,n)),e.url=n=>e.check(wc(Yl,n)),e.jwt=n=>e.check(Oc(pd,n)),e.emoji=n=>e.check(xc(Xl,n)),e.guid=n=>e.check(In(Rn,n)),e.uuid=n=>e.check(bc(He,n)),e.uuidv4=n=>e.check(_c(He,n)),e.uuidv6=n=>e.check(vc(He,n)),e.uuidv7=n=>e.check(yc(He,n)),e.nanoid=n=>e.check(kc(Ql,n)),e.guid=n=>e.check(In(Rn,n)),e.cuid=n=>e.check(Cc(ed,n)),e.cuid2=n=>e.check(Ec(td,n)),e.ulid=n=>e.check(Sc(nd,n)),e.base64=n=>e.check(Lc(ld,n)),e.base64url=n=>e.check(Mc(dd,n)),e.xid=n=>e.check(Tc(ad,n)),e.ksuid=n=>e.check(Ic(od,n)),e.ipv4=n=>e.check(zc(id,n)),e.ipv6=n=>e.check(Ac(rd,n)),e.cidrv4=n=>e.check(Nc(sd,n)),e.cidrv6=n=>e.check(Pc(cd,n)),e.e164=n=>e.check($c(gd,n)),e.datetime=n=>e.check(Al(n)),e.date=n=>e.check(Pl(n)),e.time=n=>e.check(Ml(n)),e.duration=n=>e.check(Ol(n))});function w(e){return fc(Kl,e)}const R=b("ZodStringFormat",(e,t)=>{D.init(e,t),Bn.init(e,t)}),Jl=b("ZodEmail",(e,t)=>{ks.init(e,t),R.init(e,t)}),Rn=b("ZodGUID",(e,t)=>{ws.init(e,t),R.init(e,t)}),He=b("ZodUUID",(e,t)=>{xs.init(e,t),R.init(e,t)}),Yl=b("ZodURL",(e,t)=>{Cs.init(e,t),R.init(e,t)}),Xl=b("ZodEmoji",(e,t)=>{Es.init(e,t),R.init(e,t)}),Ql=b("ZodNanoID",(e,t)=>{Ss.init(e,t),R.init(e,t)}),ed=b("ZodCUID",(e,t)=>{Ts.init(e,t),R.init(e,t)}),td=b("ZodCUID2",(e,t)=>{Is.init(e,t),R.init(e,t)}),nd=b("ZodULID",(e,t)=>{zs.init(e,t),R.init(e,t)}),ad=b("ZodXID",(e,t)=>{As.init(e,t),R.init(e,t)}),od=b("ZodKSUID",(e,t)=>{Ns.init(e,t),R.init(e,t)}),id=b("ZodIPv4",(e,t)=>{Os.init(e,t),R.init(e,t)}),rd=b("ZodIPv6",(e,t)=>{Ds.init(e,t),R.init(e,t)}),sd=b("ZodCIDRv4",(e,t)=>{Bs.init(e,t),R.init(e,t)}),cd=b("ZodCIDRv6",(e,t)=>{Rs.init(e,t),R.init(e,t)}),ld=b("ZodBase64",(e,t)=>{Zs.init(e,t),R.init(e,t)}),dd=b("ZodBase64URL",(e,t)=>{js.init(e,t),R.init(e,t)}),gd=b("ZodE164",(e,t)=>{Fs.init(e,t),R.init(e,t)}),pd=b("ZodJWT",(e,t)=>{Hs.init(e,t),R.init(e,t)}),Zn=b("ZodNumber",(e,t)=>{fn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>dl(e,a,o),e.gt=(a,o)=>e.check(An(a,o)),e.gte=(a,o)=>e.check(gt(a,o)),e.min=(a,o)=>e.check(gt(a,o)),e.lt=(a,o)=>e.check(zn(a,o)),e.lte=(a,o)=>e.check(dt(a,o)),e.max=(a,o)=>e.check(dt(a,o)),e.int=a=>e.check(Un(a)),e.safe=a=>e.check(Un(a)),e.positive=a=>e.check(An(0,a)),e.nonnegative=a=>e.check(gt(0,a)),e.negative=a=>e.check(zn(0,a)),e.nonpositive=a=>e.check(dt(0,a)),e.multipleOf=(a,o)=>e.check(Nn(a,o)),e.step=(a,o)=>e.check(Nn(a,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function he(e){return Uc(Zn,e)}const ud=b("ZodNumberFormat",(e,t)=>{Vs.init(e,t),Zn.init(e,t)});function Un(e){return jc(ud,e)}const hd=b("ZodBoolean",(e,t)=>{Gs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>gl(e,n,a)});function pt(e){return Fc(hd,e)}const fd=b("ZodUnknown",(e,t)=>{Ws.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>ul()});function ae(){return qc(fd)}const md=b("ZodNever",(e,t)=>{Ks.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>pl(e,n,a)});function bd(e){return Hc(md,e)}const _d=b("ZodArray",(e,t)=>{Js.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>bl(e,n,a,o),e.element=t.element,e.min=(n,a)=>e.check(Fe(n,a)),e.nonempty=n=>e.check(Fe(1,n)),e.max=(n,a)=>e.check(Pn(n,a)),e.length=(n,a)=>e.check(Ln(n,a)),e.unwrap=()=>e.element});function B(e,t){return al(_d,e,t)}const vd=b("ZodObject",(e,t)=>{Xs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>_l(e,n,a,o),M(e,"shape",()=>t.shape),e.keyof=()=>ht(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ae()}),e.loose=()=>e.clone({...e._zod.def,catchall:ae()}),e.strict=()=>e.clone({...e._zod.def,catchall:bd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>vr(e,n),e.safeExtend=n=>yr(e,n),e.merge=n=>wr(e,n),e.pick=n=>br(e,n),e.omit=n=>_r(e,n),e.partial=(...n)=>xr(jn,e,n[0]),e.required=(...n)=>kr(Hn,e,n[0])});function P(e,t){const n={type:"object",shape:e??{},...C(t)};return new vd(n)}const yd=b("ZodUnion",(e,t)=>{Qs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>vl(e,n,a,o),e.options=t.options});function Ve(e,t){return new yd({type:"union",options:e,...C(t)})}const wd=b("ZodIntersection",(e,t)=>{ec.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>yl(e,n,a,o)});function xd(e,t){return new wd({type:"intersection",left:e,right:t})}const kd=b("ZodRecord",(e,t)=>{tc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>wl(e,n,a,o),e.keyType=t.keyType,e.valueType=t.valueType});function Le(e,t,n){return new kd({type:"record",keyType:e,valueType:t,...C(n)})}const ut=b("ZodEnum",(e,t)=>{nc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>hl(e,a,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,o)=>{const i={};for(const r of a)if(n.has(r))i[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...C(o),entries:i})},e.exclude=(a,o)=>{const i={...t.entries};for(const r of a)if(n.has(r))delete i[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...C(o),entries:i})}});function ht(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new ut({type:"enum",entries:n,...C(t)})}const Cd=b("ZodTransform",(e,t)=>{ac.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>ml(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Kt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ne(i,n.value,t));else{const r=i;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(Ne(r))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Ed(e){return new Cd({type:"transform",transform:e})}const jn=b("ZodOptional",(e,t)=>{xn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Dn(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Fn(e){return new jn({type:"optional",innerType:e})}const Sd=b("ZodExactOptional",(e,t)=>{oc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Dn(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Td(e){return new Sd({type:"optional",innerType:e})}const Id=b("ZodNullable",(e,t)=>{ic.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>xl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function qn(e){return new Id({type:"nullable",innerType:e})}const zd=b("ZodDefault",(e,t)=>{rc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Cl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ad(e,t){return new zd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tn(t)}})}const Nd=b("ZodPrefault",(e,t)=>{sc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>El(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Pd(e,t){return new Nd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tn(t)}})}const Hn=b("ZodNonOptional",(e,t)=>{cc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>kl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e,t){return new Hn({type:"nonoptional",innerType:e,...C(t)})}const Md=b("ZodCatch",(e,t)=>{lc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Sl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $d(e,t){return new Md({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Od=b("ZodPipe",(e,t)=>{dc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Tl(e,n,a,o),e.in=t.in,e.out=t.out});function Vn(e,t){return new Od({type:"pipe",in:e,out:t})}const Dd=b("ZodReadonly",(e,t)=>{gc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Il(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Bd(e){return new Dd({type:"readonly",innerType:e})}const Rd=b("ZodCustom",(e,t)=>{pc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>fl(e,n)});function Zd(e,t={}){return ol(Rd,e,t)}function Ud(e){return il(e)}const jd=P({role:ht(["user","assistant"]),content:w(),timestamp:he().optional()}),Fd=P({sku:w(),name:w(),imageUrl:w().url().optional(),price:w().optional(),originalPrice:w().optional(),url:w().url(),ctaLabel:w().optional()}),qd=P({buttons:B(P({label:w(),action:P({title:w(),type:w(),payload:ae().optional()})}))}),Hd=P({}),Vd=P({label:w().optional()}),Gn=P({sku:w(),name:w(),price:w(),imageUrl:w().optional(),rating:he().optional(),reviewCount:he().optional()}),Gd=P({recommended:Gn,products:B(Gn),attributes:B(P({label:w(),values:B(w())})),highlights:B(w()),specialCases:B(w()).optional(),recommendedText:w().optional(),winnerHits:Le(w(),P({positive:B(w()).optional(),negative:B(w()).optional()})).optional(),productActions:Le(w(),P({title:w(),type:w(),payload:ae().optional()})).optional()}),Wd=P({label:w(),sentiment:ht(["positive","negative","neutral"]).optional()}),Kd=P({product:Le(w(),ae()),role:w().optional(),reason:w().optional(),labels:B(Wd).optional(),expertQualityScore:he().optional(),reviewHighlight:w().optional(),action:P({title:w(),type:w(),payload:ae().optional()}).optional()}),Jd=P({suggestions:B(Kd)}),Yd=P({title:w().optional(),text:w().optional(),reviewCount:w().optional(),action:P({title:w(),type:w(),payload:ae().optional()})}),Xd=P({entries:B(P({name:w(),image:w().optional(),description:w().optional(),action:P({title:w(),type:w(),payload:ae().optional()})}))}),Qd=P({entries:B(P({shortName:w(),detailedMessage:w().optional(),whyDifferent:w().optional(),image:w().optional(),action:P({title:w(),type:w(),payload:ae().optional()})}))}),Wn=P({title:w(),type:w(),payload:ae().optional()}),eg=P({name:w().optional(),variant_name:w().optional(),sku:w().optional(),price:Ve([he(),w()]).optional()}),tg=P({product:P({sku:w().optional(),name:w().optional(),images:B(w()).optional(),imageUrl:w().optional(),rating:he().optional(),reviewCount:he().optional(),price:w().optional(),originalPrice:w().optional(),price_async:pt().optional(),inStock:pt().optional(),promotions:B(w()).optional(),variants:B(eg).optional(),url:w().optional(),cartCode:w().optional(),description:w().optional(),specifications:Ve([Le(w(),w()),B(P({key:w(),value:w()}))]).optional()}).optional(),action:Wn.optional()}),ng=P({endOfList:pt().optional()}),ag=P({review_class:w().optional(),review_text:w().optional(),review_rating:Ve([w(),he()]).optional(),review_tag:w().optional()}),og=P({reviews:B(ag).optional()}),ig=P({productName:w().optional(),pros:B(w()).optional(),cons:B(w()).optional()}),rg=P({groups:B(P({groupName:w(),products:B(Le(w(),ae())).optional()})).optional(),filterTags:B(P({title:w(),action:Wn.optional()})).optional()}),sg=P({summary:w().optional(),products_discussed:B(w()).optional(),user_sentiment:w().optional()}),cg={components:{MessageBubble:{schema:jd,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:Fd,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:qd,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:Hd,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:Vd,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:Gd,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:Jd,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:Yd,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:Xd,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:Qd,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:tg,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:ng,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:og,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:ig,description:"A pros and cons list for a product."},CategoriesContainer:{schema:rg,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:sg,description:"A notice shown when the conversation is escalated to a human agent."}}};function lg(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function Me(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}class Kn extends ka{constructor(){super(...arguments),this._shadow=null,this._rootEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._activityTracker=null,this._heartbeat=null,this._proactiveShown=!1,this._drawerVisible=!1,this._messages=[],this._currentMessageId=0,this._abortControllers=new Set,this._currentThreadId=null,this._lastThreadId=null,this._chatCreatedAt="",this._lastBackendContext=null,this._productSort={type:"related"},this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._pdpLaunched=!1,this._i18n=Je,this._extendedModeManager=null,this._activeTypewriter=null,this._activeTtsHandle=null,this._activeRequestThreadId=null,this._skuToProductItem={},this._conversationMode=null,this._initComplete=!1,this._pendingActions=[],this._bridgeContext=null,this._cartQuantity=null,this._threadsWithFirstBot=new Set,this._panel=null,this._session=null,this._eventCallbacks=new Map}async onInit(t){this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),this._shadow=this.root.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Gi,this._shadow.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-root",this._rootEl=a,this._shadow.appendChild(a);const o=t.variant??"floating";if(o==="floating"){const d={onClick:()=>this.open(),ariaLabel:this._i18n.openButton};t.launcherSvg!==void 0&&(d.svgMarkup=t.launcherSvg),t.hideMobileLauncher!==void 0&&(d.hideMobile=t.hideMobileLauncher),t.mobileBreakpoint!==void 0&&(d.mobileBreakpoint=t.mobileBreakpoint),t.launcherTooltip!==void 0&&(d.tooltip=t.launcherTooltip),this._launcher=Fo(d),a.appendChild(this._launcher.container)}o==="overlay"&&a.classList.add("gengage-chat--overlay");const i=document.createElement("div");a.appendChild(i),this._drawer=new Uo(i,{i18n:this._i18n,onSend:(d,p)=>this._sendMessage(d,p),onClose:()=>this.close(),onAttachment:d=>this._handleAttachment(d),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onRollback:d=>this._handleRollback(d),onPanelBack:()=>this._panel?.navigateBack(),onPanelForward:()=>this._panel?.navigateForward(),headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,headerFavoritesToggle:t.headerFavoritesToggle,onFavoritesClick:()=>{or(),t.onFavoritesClick?.()},onThumbnailClick:d=>this._rollbackToThread(d),onLinkClick:d=>{this._saveSessionAndOpenURL(d)},voiceEnabled:t.voiceEnabled,voiceLang:t.locale?`${t.locale.split("-")[0]??"tr"}-${(t.locale.split("-")[1]??t.locale.split("-")[0]??"TR").toUpperCase()}`:void 0}),this._extendedModeManager=new Bi({onChange:d=>this._panel?.notifyExtension(d),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new Ri({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:d=>this._rollbackToThread(d)}),o!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"),this._drawer.restorePanelState(t.accountId),(t.panelMode??"auto")==="collapsed"?this._drawer.setPanelCollapsed(!0):this._drawer.setForceExpanded();const s=sessionStorage.getItem("gengage_restore_session_id"),c=sessionStorage.getItem("gengage_restore_sku");s&&c&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const d=new Oi;await d.open(),this._session=new Ht(d),await this._restoreFromIndexedDB()}catch{this._session=new Ht(null)}this._registerPublicAPI(),t.mobileInitialState!==void 0&&(this._openState=t.mobileInitialState),this._mobileBreakpoint=t.mobileBreakpoint??768,this._syncViewportState();const l=()=>this._syncViewportState();if(window.addEventListener("resize",l,{passive:!0}),this.addCleanup(()=>window.removeEventListener("resize",l)),window.visualViewport){const d=()=>{if(!this._drawerVisible||!this._isMobileViewport)return;const p=this._drawer?.getElement();if(!p)return;const u=window.innerHeight-(window.visualViewport?.height??window.innerHeight);p.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,u)}px`)};window.visualViewport.addEventListener("resize",d),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",d))}o==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses()),this._bridge=new Sa({namespace:"chat",onMessage:d=>this._handleBridgeMessage(d)}),this._activityTracker=new Ho({idleThresholdMs:t.proactiveDelayMs??3e4,onActivity:d=>{if(d.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 Wo({middlewareUrl:t.middlewareUrl,accountId:t.accountId,sessionId:t.session?.sessionId??"",locale:t.locale??"tr",intervalMs:t.heartbeatIntervalMs??3e4,getPageType:()=>this.config.pageContext?.pageType??"other",getCurrentSku:()=>this.config.pageContext?.sku??"",onMessage:d=>{if(!this._proactiveShown&&!this._drawerVisible&&d.message){const p=[];if(d.suggested_actions&&Array.isArray(d.suggested_actions))for(const u of d.suggested_actions)u.title&&Me(u.requestDetails)&&p.push({title:u.title,onSelect:()=>{this.openWithAction(u.requestDetails)}});this._showProactivePopup(d.message,p.length>0?p:void 0)}}}),this._heartbeat.start(),this.addCleanup(()=>this._heartbeat?.destroy())),this._initComplete=!0;for(const d of this._pendingActions)this._sendAction(d.action,d.options);this._pendingActions=[],ee("gengage:chat:ready",{}),Ki("chat"),t.onReady?.()}onUpdate(t){}onShow(){this._showDrawer(),this.emit("open"),ee("gengage:chat:open",{state:this._openState}),Ji("chat"),this.config.onOpen?.(),!this._pdpLaunched&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku}},{silent:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),ee("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._bridge?.destroy(),this._bridge=null,this._extendedModeManager=null,this._panel?.destroy(),this._panel=null,this._session?.close(),this._session=null,window.gengage&&delete window.gengage.chat,this._shadow&&(this._shadow.innerHTML="",this._shadow=null),this._rootEl=null}open(t){t?.state!==void 0&&(this._openState=t.state,this._drawerVisible&&this._applyOpenStateClasses()),this.show(),t?.initialMessage!==void 0&&this._sendMessage(t.initialMessage)}openWithAction(t,n){n?.sku!==void 0&&this.update({sku:n.sku}),this._pdpLaunched=!0,n?.state!==void 0?this._openState=n.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,n){this._sendAction(t,n)}close(){this.hide()}saveSession(t,n){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",n)}get isOpen(){return this._drawerVisible}addCallback(t,n){let a=this._eventCallbacks.get(t);return a||(a=new Set,this._eventCallbacks.set(t,a)),a.add(n),()=>{a.delete(n),a.size===0&&this._eventCallbacks.delete(t)}}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const n=t.payload,a=n?.action,o=Me(a)?a:Me(n)?n:null;o&&this._sendAction(o,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const n=t.payload;if(n&&typeof n=="object"){this._bridgeContext=n;const a=n.sku;if(a&&this.update({sku:a}),Me(n.action)){this._pdpLaunched=!0,this.open(),this._sendAction(n.action);break}}this.open();break}case"launcherAction":{const a=t.payload?.action;a&&typeof a=="object"&&"type"in a&&this._sendAction(a);break}case"scrollToBottom":this._drawer?.scrollToBottomIfNeeded();break;case"addToCardHandler":{this._bridge?.send("addToCardResult",t.payload);break}case"cartQuantityHandler":{const n=t.payload;n&&"quantity"in n&&typeof n.quantity=="number"&&(this._cartQuantity=n.quantity);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&lg(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,n)=>this.openWithAction(t,n),sendMessage:t=>this.sendMessage(t),sendAction:(t,n)=>this.sendAction(t,n),close:()=>this.close(),saveSession:(t,n)=>this.saveSession(t,n),get isOpen(){return!1},on:(t,n)=>this.on(t,n),trackCheckout:(t,n)=>this.trackCheckout(t,n),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,n)=>this.addCallback(t,n)},Object.defineProperty(window.gengage.chat,"isOpen",{get:()=>this._drawerVisible})}_showDrawer(){if(this._drawerVisible)return;this._drawerVisible=!0;const t=this._drawer?.getElement();t&&t.classList.remove("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._isMobileViewport&&this._openState==="half"||this._drawer?.focusInput(),this._extendedModeManager?.setChatShown(!0)}_showProactivePopup(t,n){if(this._proactiveShown||!this._rootEl)return;this._proactiveShown=!0;try{sessionStorage.setItem("gengage_proactive_shown","1")}catch{}this._setProactiveCooldown();const a={message:t,onAccept:()=>this.open(),onDismiss:()=>{},...n&&n.length>0&&{actionButtons:n}};this.config.proactiveAcceptLabel!==void 0&&(a.acceptLabel=this.config.proactiveAcceptLabel);const o=qo(a);this._rootEl.appendChild(o)}async _fetchAndShowProactive(){if(!this._proactiveShown)try{const t={middlewareUrl:this.config.middlewareUrl,accountId:this.config.accountId,backendType:this.config.backendType??"v1"},n=this.config.pageContext?.sku,a=this.config.pageContext?.pageType,o=this.config.locale,i=await Ao({account_id:this.config.accountId,...n&&{sku:n},...a&&{page_type:a},...o&&{output_language:o}},t);if(!i)return;const r=i.question??i.title??"";if(!r)return;const s=[];if(i.actions&&Array.isArray(i.actions))for(const c of i.actions){const l=c,d=l.title;if(d&&Me(l.requestDetails)){const p=l.requestDetails;s.push({title:d,onSelect:()=>{this.openWithAction(p)}})}}this._showProactivePopup(r,s)}catch{}}_proactiveCooldownKey(){return`gengage_proactive_time_${this.config.accountId}`}_isProactiveCooldownActive(){try{const t=localStorage.getItem(this._proactiveCooldownKey());if(t){const n=Date.now()-parseInt(t,10),a=this.config.proactiveCooldownMs??36e5;return n<a}}catch{}return!1}_setProactiveCooldown(){try{localStorage.setItem(this._proactiveCooldownKey(),String(Date.now()))}catch{}}_hideDrawer(){if(!this._drawerVisible)return;this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawerVisible=!1,this._openState="full",this._drawer?.clearPanel();const t=this._drawer?.getElement();t&&t.classList.add("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._extendedModeManager?.setChatShown(!1)}_syncViewportState(){if(this._rootEl){if(this._isMobileViewport=window.innerWidth<=this._mobileBreakpoint,this._rootEl.classList.toggle("gengage-chat-root--mobile",this._isMobileViewport),this._launcher){const t=this._isMobileViewport&&this.config.hideMobileLauncher===!0;this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile",t)}this._applyOpenStateClasses()}}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",n=this._drawerVisible&&this._isMobileViewport&&this._openState==="full";this._rootEl.classList.toggle("gengage-chat-root--open",this._drawerVisible),this._rootEl.classList.toggle("gengage-chat-root--mobile-half",t),this._rootEl.classList.toggle("gengage-chat-root--mobile-full",n)}_handleAttachment(t){const n=Da(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;ee("gengage:global:error",{message:a,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,n){cr(),this._messages.some(i=>i.role==="user")||lr();const o={title:t,type:"user_message",payload:t};n!==void 0?this._sendAction(o,{attachment:n}):this._sendAction(o)}_sendAction(t,n){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:n});return}if(this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const h=this._currentThreadId,x=this._messages.filter(E=>E.threadId!==void 0&&E.threadId>h);this._messages=this._messages.filter(E=>!E.threadId||E.threadId<=h);for(const E of x)this._shadow?.querySelector(`[data-message-id="${CSS.escape(E.id)}"]`)?.remove(),this._panel.snapshots.delete(E.id),this._panel.snapshotTypes.delete(E.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(E=>{E instanceof HTMLElement&&E.dataset.threadId&&E.dataset.threadId>h&&E.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=Ea();this._currentThreadId=a,this._lastThreadId=a;const o=n?.preservePanel===!0;if(o||(this._activeRequestThreadId=a),!n?.silent){const h=this._createMessage("user",typeof t.payload=="string"?t.payload:t.title);h.threadId=a,n?.attachment!==void 0&&(h.attachment=n.attachment),this._drawer?.addMessage(h),this._messages.push(h)}n?.preservePanel||(this._drawer?.hasPanelContent()?this._drawer.showPanelLoading():this._drawer?.clearPanel()),this._drawer?.showTypingIndicator();let i="";const r=this._createMessage("assistant","");r.threadId=a,r.status="streaming",this._messages.push(r),n?.preservePanel||(this._abortControllers.forEach(h=>h.abort()),this._abortControllers.clear());const s={middlewareUrl:this.config.middlewareUrl,...this.config.backendType?{backendType:this.config.backendType}:{},...this.config.accountId?{accountId:this.config.accountId}:{}};n?.attachment!==void 0&&(s.attachment=n.attachment);const l=this._getVisibleMessages().filter(h=>h.content).slice(-50).map(h=>({role:h.role==="user"?"user":"model",content:h.content??""})),d={outputLanguage:Vi(this.config.locale),parentUrl:window.location.href,windowWidth:String(window.innerWidth),windowHeight:String(window.innerHeight),selfUrl:"",id:this.config.session?.sessionId??"",userId:this.config.session?.userId??"",appId:this.config.accountId,threads:[],createdAt:this._chatCreatedAt,kvkkApproved:Gt(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:a,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this.config.session?.viewId!==void 0&&(d.viewId=this.config.session.viewId);const p=Eo(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),u={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:p.type,locale:this.config.locale??"tr",meta:d,context:{...this._lastBackendContext??{},messages:l,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(u.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(u.view_id=this.config.session.viewId),p.payload!==void 0&&(u.payload=p.payload),this.config.pageContext?.sku!==void 0&&(u.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(u.page_type=this.config.pageContext.pageType);const g=crypto.randomUUID(),m=Date.now();let _=0,y=!1,z=!1;this.track(Qn(this.analyticsContext(),{endpoint:"process_action",request_id:g,widget:"chat"}));let I=null;I=zo(u,{onTextChunk:(h,x,k)=>{if(!o&&a!==this._activeRequestThreadId||(i+=h,this._drawer?.removeTypingIndicator(),k?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...k.skuToProductItem}),k?.conversationMode&&(this._conversationMode=k.conversationMode),this.track(ea(this.analyticsContext(),{request_id:g,chunk_index:_++,widget:"chat"})),!this._drawer))return;let E=i;if(x&&et(E)){const f=this.config.accountId;if(!Gt(f)){const v=qi(E);v&&this._drawer?.showKvkkBanner(v,()=>{this._drawer?.hideKvkkBanner()}),ji(f)}E=Fi(E)}const L=this._shadow?.querySelector(`[data-message-id="${r.id}"] .gengage-chat-bubble-text`);if(L?L.innerHTML=we(E):(r.content=E,r.role==="assistant"&&r.threadId&&!this._threadsWithFirstBot.has(r.threadId)&&(this._threadsWithFirstBot.add(r.threadId),this._drawer.markFirstBotMessage(r.id)),this._drawer.addMessage(r)),x){r.content=E,r.status="done",Wt();const f=this._shadow?.querySelector(`[data-message-id="${r.id}"] .gengage-chat-bubble-text`);if(f){this._activeTypewriter?.cancel();const v=k?.productMentions;this._activeTypewriter=Ti({container:f,html:we(E),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,v&&v.length>0&&f&&Ii({container:f,mentions:v,onProductClick:S=>{this._sendAction({title:v.find(A=>A.sku===S)?.short_name??S,type:"launchSingleProduct",payload:{sku:S}})}})}})}}},onUISpec:(h,x,k)=>{if(!o&&a!==this._activeRequestThreadId||x!=="chat")return;const E=h.elements[h.root],L=E?.type??"unknown";this.track(ta(this.analyticsContext(),{request_id:g,chunk_index:_,component_type:L,widget:"chat"}));const f=this._buildRenderContext();if(L==="ComparisonTable"){const A=E?.props?.products;nr(Array.isArray(A)?A.length:0)}if(L==="ProductGrid"){const A=E?.children?.length??0;ir(void 0,A)}const v=k==="panel"&&this._panel?this._panel.toPanelSpec(h):h,S=!r.silent&&(k!=="panel"||L==="ProductCard")&&L!=="ActionButtons";if(k==="panel"&&this._panel){z=!0,E?.props?.similarsAppend===!0&&this._panel.currentType==="ProductDetailsPanel"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._appendSimilarsToPanel(v,f):L==="ProductGrid"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._drawer.appendPanelContent(this._renderUISpec(v,f)):(this._drawer?.setPanelContent(this._renderUISpec(v,f)),this._panel.currentType=L),r.threadId&&!this._panel.threads.includes(r.threadId)&&this._panel.threads.push(r.threadId);const A=this._panel.currentType??L;this._panel.updateTopBar(A),this._panel.updateExtendedMode(L)}if(L==="ProductDetailsPanel"&&!r.silent&&k==="panel"){const A=E?.props?.product;if(A){const $={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:A}}}},N=this._shadow?.querySelector(".gengage-chat-messages");if(N){const T=this._renderUISpec($,f);r.threadId&&(T.dataset.threadId=r.threadId),N.appendChild(T),T.scrollIntoView({behavior:"auto",block:"end"})}}}if(S){const A=this._shadow?.querySelector(".gengage-chat-messages");if(A){const $=this._renderUISpec(h,f);r.threadId&&($.dataset.threadId=r.threadId),A.appendChild($),$.scrollIntoView({behavior:"auto",block:"end"})}}if((L==="ProductGrid"||L==="ProductCard")&&r.threadId){const A=E?.children??[],$=L==="ProductGrid"?A.map(N=>h.elements[N]?.props?.product).filter(Boolean):[E?.props?.product].filter(Boolean);for(const N of $){const T=N.sku,j=N.imageUrl;T&&j&&this._thumbnailEntries.push({sku:T,imageUrl:j,threadId:r.threadId})}this._drawer?.setThumbnails(this._thumbnailEntries)}if(L==="ProductGrid"||L==="ProductDetailsPanel"){const $=(L==="ProductGrid"?(E?.children??[]).map(N=>h.elements[N]?.props?.product).filter(Boolean):[E?.props?.product??E?.props].filter(Boolean)).map(N=>N.imageUrl).filter(N=>typeof N=="string").slice(0,5);$.length>0&&this._bridge?.send("previewImages",{images:$})}if(L==="ProductGrid"&&k==="panel"&&!this._comparisonSelectMode&&!Li()&&(this._choicePrompterEl?.remove(),this._choicePrompterEl=Pi({heading:this._i18n.choicePrompterHeading,suggestion:this._i18n.choicePrompterSuggestion,ctaLabel:this._i18n.choicePrompterCta,onCtaClick:()=>{this._comparisonSelectMode=!0,this._choicePrompterEl=null},onDismiss:()=>{this._choicePrompterEl=null}}),this._shadow?.querySelector(".gengage-chat-panel")?.appendChild(this._choicePrompterEl)),L==="ActionButtons"){const A=E?.props?.buttons;if(A&&A.length>0){const $=[],N=[];for(const T of A)if(Ni(T)){const j={label:T.label,action:T.action};T.icon&&(j.icon=T.icon),$.push(j)}else N.push(T);$.length>0&&this._drawer?.setInputAreaChips($.map(T=>({label:T.label,onAction:()=>this._sendAction(T.action),...T.icon?{icon:T.icon}:{}}))),N.length>0&&this._drawer?.setPills(N.map(T=>{const j={label:T.label,onAction:()=>this._sendAction(T.action)};return T.icon&&(j.icon=T.icon),T.image&&(j.image=T.image),T.description&&(j.description=T.description),j}))}}r.uiSpec=h},onAction:h=>{if(!(!o&&a!==this._activeRequestThreadId)&&h.type==="action"){const x={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(x.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(x.allowScriptCall=this.config.actionHandling.allowScriptCall),za(h,{openChat:()=>this.open(),navigate:k=>{this._bridge?.send("navigate",k),k.newTab?window.open(k.url,"_blank","noopener,noreferrer"):window.location.href=k.url},saveSession:k=>this.saveSession(k.sessionId,k.sku),addToCart:k=>{ee("gengage:similar:add-to-cart",k)},scriptCall:k=>{ee("gengage:chat:script-call",k),this.config.onScriptCall?.(k)}},x)}},onMetadata:h=>{if(!(!o&&a!==this._activeRequestThreadId)&&h.type==="metadata"&&h.meta){if((h.meta.panel!==void 0||h.meta.messages!==void 0||h.meta.message_id!==void 0)&&(this._lastBackendContext=h.meta),h.meta.panelLoading){y=!0,z=!1;const k=typeof h.meta.panelPendingType=="string"?h.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(k),k&&this._panel?.updateTopBarForLoading(k)}if(h.meta.voice){const k=new CustomEvent("gengage:chat:voice",{detail:{payload:h.meta.voice},bubbles:!1,cancelable:!0}),E=window.dispatchEvent(k);if(dr(),E){const L=h.meta.voice;L.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=Go(L.audio_base64,L.content_type??"audio/ogg"))}}(h.meta.redirectTarget||h.meta.redirect)&&ee("gengage:chat:redirect",{target:h.meta.redirectTarget??null,payload:h.meta.redirect??null}),h.meta.analyzeAnimation&&(y=!0,z=!1,this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),h.meta.loading&&typeof h.meta.loadingText=="string"&&(this._drawer?.addThinkingStep(h.meta.loadingText),this._bridge?.send("loadingMessage",{text:h.meta.loadingText})),h.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",h.meta.visitorDataResponse),h.meta.formType&&this._bridge?.send("glovOtokoc",{type:h.meta.formType,data:h.meta.formPayload}),h.meta.launcherContent&&this._bridge?.send("launcherContent",h.meta.launcherContent),ee("gengage:chat:metadata",{payload:h.meta});const x=h.meta;typeof x.prompt_tokens=="number"&&typeof x.completion_tokens=="number"&&this.track(oa(this.analyticsContext(),{model:h.model??"unknown",prompt_tokens:x.prompt_tokens,completion_tokens:x.completion_tokens,total_tokens:x.total_tokens??x.prompt_tokens+x.completion_tokens}))}},onError:h=>{I&&this._abortControllers.delete(I),!(!o&&a!==this._activeRequestThreadId)&&(this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),y&&!z&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),y=!1,z=!1,ee("gengage:global:error",{source:"chat",code:"STREAM_ERROR",message:this._i18n.errorMessage}),this.emit("error",h),this._drawer?.showError(h.message),r.status==="streaming"&&(r.status="error"),this.track(aa(this.analyticsContext(),{request_id:g,error_code:"STREAM_ERROR",error_message:h.message,widget:"chat"})))},onDone:()=>{I&&this._abortControllers.delete(I),!(!o&&a!==this._activeRequestThreadId)&&(this._activeRequestThreadId=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),y&&!z&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),y=!1,z=!1,r.status==="streaming"&&(r.status="done",Wt()),this.emit("message",r),this._panel?.snapshotForMessage(r.id),this._panel?.attachClickHandler(r.id),this.track(na(this.analyticsContext(),{request_id:g,latency_ms:Date.now()-m,chunk_count:_,widget:"chat"})),this.track(ia(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(sa(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{}))}},s),this._abortControllers.add(I)}_getVisibleMessages(){const t=this._messages.filter(a=>!a.silent);if(!this._currentThreadId)return t;const n=this._currentThreadId;return t.filter(a=>!a.threadId||a.threadId<=n)}_appendSimilarsToPanel(t,n){if(!this._drawer)return;const a=this._drawer.getPanelContentElement();if(!a)return;const o=document.createElement("h3");o.className="gengage-chat-product-details-similars-heading",o.textContent=this._i18n.similarProductsLabel??"Benzer Ürünler",a.appendChild(o);const i=this._renderUISpec(t,n);i.classList.add("gengage-chat-product-details-similars"),a.appendChild(i)}_handleRollback(t){const n=this._messages.find(a=>a.id===t);n?.threadId&&this._rollbackToThread(n.threadId)}_rollbackToThread(t){this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1);for(const i of this._messages){const r=this._shadow?.querySelector(`[data-message-id="${CSS.escape(i.id)}"]`);r&&(i.threadId&&i.threadId>t?r.classList.add("gengage-chat-bubble--hidden"):r.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(i=>{i instanceof HTMLElement&&i.dataset.threadId&&i.dataset.threadId>t?i.classList.add("gengage-chat-bubble--hidden"):i instanceof HTMLElement&&i.classList.remove("gengage-chat-bubble--hidden")});const n=this._messages.find(i=>i.role==="assistant"&&i.threadId===t);n&&this._panel?.restoreForMessage(n.id)||this._drawer?.clearPanel();const o=this._panel.currentType??"";this._panel?.updateTopBar(o),this._drawer?.setPills([]),this._session?.db&&this.config.session?.sessionId&&this._session?.db.loadContext(this.config.session.sessionId,t).then(i=>{i&&(this._lastBackendContext=i.context)}).catch(()=>{}),this._session?.db&&this.config.session?.sessionId&&this._session?.db.deleteContextsAfterThread(this.config.session.sessionId,t).catch(()=>{})}async _persistToIndexedDB(){!this._session||!this.config.session?.sessionId||await this._session.persist({userId:this.config.session.userId??"",appId:this.config.accountId,sessionId:this.config.session.sessionId,messages:this._messages,currentThreadId:this._currentThreadId,lastThreadId:this._lastThreadId,chatCreatedAt:this._chatCreatedAt,panelSnapshots:this._panel?.snapshots??new Map,panelThreads:this._panel?.threads??[],thumbnailEntries:this._thumbnailEntries,lastBackendContext:this._lastBackendContext})}_isSameOriginUrl(t){try{return new URL(t,window.location.href).origin===window.location.origin}catch{return!1}}async _saveSessionAndOpenURL(t){this._session&&await this._session.saveAndOpenURL(t,()=>this._persistToIndexedDB(),this._bridge)}async _loadPayload(t,n){return this._session?this._session.loadPayload(t,n):null}async _restoreFromIndexedDB(){if(!this._session?.db)return;const t=this.config.session?.sessionId;if(!t)return;const n=this.config.session?.userId??"",a=this.config.accountId;await this._session.loadFavorites(n,a);const o=await this._session.db?.loadSession(n,a,t);if(!o||o.messages.length===0)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=o.currentThreadId,this._lastThreadId=o.lastThreadId,this._chatCreatedAt=o.createdAt,o.panelThreads&&(this._panel.threads=o.panelThreads),o.thumbnailEntries&&(this._thumbnailEntries=o.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),o.panelSnapshotHtml)for(const[r,s]of Object.entries(o.panelSnapshotHtml)){const c=document.createElement("div");c.innerHTML=we(s),this._panel.snapshots.set(r,c)}let i=0;for(const r of o.messages){const s={id:r.id,role:r.role,timestamp:r.timestamp,status:r.status};if(r.threadId!==void 0&&(s.threadId=r.threadId),r.content!==void 0&&(s.content=r.content),r.silent&&(s.silent=!0),this._messages.push(s),s.silent)continue;s.role==="assistant"&&s.threadId&&!this._threadsWithFirstBot.has(s.threadId)&&(this._threadsWithFirstBot.add(s.threadId),this._drawer?.markFirstBotMessage(s.id)),this._drawer?.addMessage(s);const c=parseInt(r.id.replace("msg-",""),10);if(!isNaN(c)&&c>i&&(i=c),s.role==="assistant"&&s.threadId){const l=await this._loadPayload(s.threadId,s.id);l&&(s.uiSpec=l,this._restoreInlineUISpec(s),this._panel?.attachClickHandler(s.id),delete s.uiSpec)}}if(i>this._currentMessageId&&(this._currentMessageId=i),this._currentThreadId){let r=await this._session.db?.loadContext(t,this._currentThreadId);r||(r=await this._session.db?.loadLatestContext(t)),r&&(this._lastBackendContext=r.context)}if(this._currentThreadId){const r=[...this._messages].reverse().find(s=>s.role==="assistant"&&s.threadId===this._currentThreadId&&!s.silent);r&&this._panel.snapshots.has(r.id)&&this._panel?.restoreForMessage(r.id)}if(this._currentThreadId){const r=this._currentThreadId;for(const s of this._messages)s.threadId&&s.threadId>r&&this._shadow?.querySelector(`[data-message-id="${CSS.escape(s.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");this._shadow?.querySelectorAll("[data-thread-id]").forEach(s=>{s instanceof HTMLElement&&s.dataset.threadId&&s.dataset.threadId>r&&s.classList.add("gengage-chat-bubble--hidden")})}if(this._panel.threads.length>0&&this._currentThreadId){const r=this._panel.threads[this._panel.threads.length-1];if(r){const s=[...this._messages].reverse().find(c=>c.role==="assistant"&&c.threadId===r);if(s?.threadId){const c=await this._loadPayload(s.threadId,s.id);if(c){const l=c.elements[c.root];l&&this._panel?.updateTopBar(l.type)}}}}setTimeout(()=>{this._drawer?.scrollToLastThread()},550)}_buildRenderContext(){const t={onAction:n=>{if(Yi(n.title,n.type),n.type==="findSimilar"){const o=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";Xi(o)}n.type==="getComparisonTable"&&er(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{rr(n.sku),ee("gengage:similar:product-click",{sku:n.sku,url:n.url,sessionId:this.config.session?.sessionId??null}),this.config.isDemoWebsite===!0||!this._isSameOriginUrl(n.url)?this._sendAction({title:n.sku,type:"launchSingleProduct",payload:{sku:n.sku}}):this._saveSessionAndOpenURL(n.url)},onAddToCart:n=>{sr(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};ee("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",n),this._runEventCallbacks("gengage-cart-add",a),this._sendAction({title:"Sepete Ekle",type:"addToCart",payload:{sku:n.sku,cart_code:n.cartCode,quantity:n.quantity}},{preservePanel:!0})},onProductSelect:n=>{const a={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:n}}}};this._drawer?.setPanelContent(this._renderUISpec(a,t))},i18n:this._i18n,pricing:this.config.pricing,productSort:this._productSort,onSortChange:n=>{this._productSort=n},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,onToggleComparisonSku:n=>{n===""?(this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectMode||(this._comparisonSelectedSkus=[],tr())):this._comparisonSelectedSkus.indexOf(n)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(o=>o!==n):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,n],Qi(n))},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(n,a)=>{ar(n),this._toggleFavorite(n,a);const o=a.name??n;this._sendAction({title:o,type:"like",payload:{sku:n}},{preservePanel:!0})}};return t}async _toggleFavorite(t,n){if(!this._session)return;const a=this.config.session?.userId??"",o=this.config.accountId;await this._session.toggleFavorite(a,o,t,n)}async _runEventCallbacks(t,n){const a=this._eventCallbacks.get(t);if(!(!a||a.size===0))for(const o of a)try{const i=o(n);if((i instanceof Promise?await i:i)===!1){this._handleCallbackFailure(t,n);return}}catch{this._handleCallbackFailure(t,n);return}}_handleCallbackFailure(t,n){if(t==="gengage-cart-add"){const o=this._createMessage("assistant","Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.");this._currentThreadId&&(o.threadId=this._currentThreadId),this._messages.push(o),this._drawer?.addMessage(o)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const n=t.uiSpec,a=n.elements[n.root];if(!a)return;const o=a.type;if(o==="ActionButtons"||o==="ComparisonTable"||o==="ProductGrid"&&a.props?.similarsAppend===!0)return;const i=this._buildRenderContext(),r=this._shadow?.querySelector(".gengage-chat-messages");if(!r)return;if(o==="ProductDetailsPanel"){const c=a.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},d=this._renderUISpec(l,i);t.threadId&&(d.dataset.threadId=t.threadId),r.appendChild(d);return}const s=this._renderUISpec(n,i);t.threadId&&(s.dataset.threadId=t.threadId),r.appendChild(s)}_createMessage(t,n){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:n,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...Lo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Zt();return Xn(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??Qe,i=(c,l)=>Ut(c,l,a,o),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:o,defaultRender:i}):i(t,n)}}function dg(){return new Kn}fe.GengageChat=Kn,fe.chatCatalog=cg,fe.createChatWidget=dg,fe.createDefaultChatUISpecRegistry=Zt,fe.defaultChatUnknownUISpecRenderer=Qe,fe.renderUISpec=Ut,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
96
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const s=r[1];if(t===r[0]){i(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){i(r);continue}}if(e.metadataRegistry.get(r[0])?.id){i(r);continue}if(s.cycle){i(r);continue}if(s.count>1&&e.reused==="ref"){i(r);continue}}}function Dn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=r=>{const s=e.seen.get(r);if(s.ref===null)return;const c=s.def??s.schema,l={...c},d=s.ref;if(s.ref=null,d){a(d);const u=e.seen.get(d),p=u.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):Object.assign(c,p),Object.assign(c,l),r._zod.parent===d)for(const v in c)v==="$ref"||v==="allOf"||v in l||delete c[v];if(p.$ref&&u.def)for(const v in c)v==="$ref"||v==="allOf"||v in u.def&&JSON.stringify(c[v])===JSON.stringify(u.def[v])&&delete c[v]}const g=r._zod.parent;if(g&&g!==d){a(g);const u=e.seen.get(g);if(u?.schema.$ref&&(c.$ref=u.schema.$ref,u.def))for(const p in c)p==="$ref"||p==="allOf"||p in u.def&&JSON.stringify(c[p])===JSON.stringify(u.def[p])&&delete c[p]}e.override({zodSchema:r,jsonSchema:c,path:s.path??[]})};for(const r of[...e.seen.entries()].reverse())a(r[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(r)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const r of e.seen.entries()){const s=r[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const r=JSON.parse(JSON.stringify(o));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:qe(t,"input",e.processors),output:qe(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function G(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return G(a.element,n);if(a.type==="set")return G(a.valueType,n);if(a.type==="lazy")return G(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return G(a.innerType,n);if(a.type==="intersection")return G(a.left,n)||G(a.right,n);if(a.type==="record"||a.type==="map")return G(a.keyType,n)||G(a.valueType,n);if(a.type==="pipe")return G(a.in,n)||G(a.out,n);if(a.type==="object"){for(const o in a.shape)if(G(a.shape[o],n))return!0;return!1}if(a.type==="union"){for(const o of a.options)if(G(o,n))return!0;return!1}if(a.type==="tuple"){for(const o of a.items)if(G(o,n))return!0;return!!(a.rest&&G(a.rest,n))}return!1}const sl=(e,t={})=>n=>{const a=$n({...n,processors:t});return F(e,a),On(a,e),Dn(a,e)},qe=(e,t,n={})=>a=>{const{libraryOptions:o,target:i}=a??{},r=$n({...o??{},target:i,io:t,processors:n});return F(e,r),On(r,e),Dn(r,e)},cl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ll=(e,t,n,a)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof r=="number"&&(o.maxLength=r),s&&(o.format=cl[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},dl=(e,t,n,a)=>{const o=n,{minimum:i,maximum:r,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l),typeof r=="number"&&(o.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},gl=(e,t,n,a)=>{n.type="boolean"},pl=(e,t,n,a)=>{n.not={}},ul=(e,t,n,a)=>{},hl=(e,t,n,a)=>{const o=e._zod.def,i=Xt(o.entries);i.every(r=>typeof r=="number")&&(n.type="number"),i.every(r=>typeof r=="string")&&(n.type="string"),n.enum=i},fl=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ml=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bl=(e,t,n,a)=>{const o=n,i=e._zod.def,{minimum:r,maximum:s}=e._zod.bag;typeof r=="number"&&(o.minItems=r),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=F(i.element,t,{...a,path:[...a.path,"items"]})},_l=(e,t,n,a)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const r=i.shape;for(const l in r)o.properties[l]=F(r[l],t,{...a,path:[...a.path,"properties",l]});const s=new Set(Object.keys(r)),c=new Set([...s].filter(l=>{const d=i.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=F(i.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},vl=(e,t,n,a)=>{const o=e._zod.def,i=o.inclusive===!1,r=o.options.map((s,c)=>F(s,t,{...a,path:[...a.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=r:n.anyOf=r},yl=(e,t,n,a)=>{const o=e._zod.def,i=F(o.left,t,{...a,path:[...a.path,"allOf",0]}),r=F(o.right,t,{...a,path:[...a.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(i)?i.allOf:[i],...s(r)?r.allOf:[r]];n.allOf=c},wl=(e,t,n,a)=>{const o=n,i=e._zod.def;o.type="object";const r=i.keyType,c=r._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=F(i.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});o.patternProperties={};for(const g of c)o.patternProperties[g.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=F(i.keyType,t,{...a,path:[...a.path,"propertyNames"]})),o.additionalProperties=F(i.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const l=r._zod.values;if(l){const d=[...l].filter(g=>typeof g=="string"||typeof g=="number");d.length>0&&(o.required=d)}},xl=(e,t,n,a)=>{const o=e._zod.def,i=F(o.innerType,t,a),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},kl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType},Cl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},El=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Sl=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType;let r;try{r=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Tl=(e,t,n,a)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;F(i,t,a);const r=t.seen.get(e);r.ref=i},Il=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Bn=(e,t,n,a)=>{const o=e._zod.def;F(o.innerType,t,a);const i=t.seen.get(e);i.ref=o.innerType},zl=m("ZodISODateTime",(e,t)=>{Ps.init(e,t),R.init(e,t)});function Al(e){return Dc(zl,e)}const Nl=m("ZodISODate",(e,t)=>{Ls.init(e,t),R.init(e,t)});function Pl(e){return Bc(Nl,e)}const Ll=m("ZodISOTime",(e,t)=>{Ms.init(e,t),R.init(e,t)});function Ml(e){return Rc(Ll,e)}const $l=m("ZodISODuration",(e,t)=>{$s.init(e,t),R.init(e,t)});function Ol(e){return Zc($l,e)}const Y=m("ZodError",(e,t)=>{on.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Er(e,n)},flatten:{value:n=>Cr(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,tt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,tt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Dl=rt(Y),Bl=st(Y),Rl=Be(Y),Zl=Re(Y),Ul=Ir(Y),jl=zr(Y),Fl=Ar(Y),ql=Nr(Y),Hl=Pr(Y),Vl=Lr(Y),Gl=Mr(Y),Wl=$r(Y),U=m("ZodType",(e,t)=>(Z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:qe(e,"input"),output:qe(e,"output")}}),e.toJSONSchema=sl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ge(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>pe(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Dl(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>Rl(e,n,a),e.parseAsync=async(n,a)=>Bl(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>Zl(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Ul(e,n,a),e.decode=(n,a)=>jl(e,n,a),e.encodeAsync=async(n,a)=>Fl(e,n,a),e.decodeAsync=async(n,a)=>ql(e,n,a),e.safeEncode=(n,a)=>Hl(e,n,a),e.safeDecode=(n,a)=>Vl(e,n,a),e.safeEncodeAsync=async(n,a)=>Gl(e,n,a),e.safeDecodeAsync=async(n,a)=>Wl(e,n,a),e.refine=(n,a)=>e.check(Zd(n,a)),e.superRefine=n=>e.check(Ud(n)),e.overwrite=n=>e.check(Ie(n)),e.optional=()=>qn(e),e.exactOptional=()=>Td(e),e.nullable=()=>Hn(e),e.nullish=()=>qn(Hn(e)),e.nonoptional=n=>Ld(e,n),e.array=()=>B(e),e.or=n=>Ve([e,n]),e.and=n=>xd(e,n),e.transform=n=>Gn(e,Ed(n)),e.default=n=>Ad(e,n),e.prefault=n=>Pd(e,n),e.catch=n=>$d(e,n),e.pipe=n=>Gn(e,n),e.readonly=()=>Bd(e),e.describe=n=>{const a=e.clone();return Pe.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Pe.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Pe.get(e);const a=e.clone();return Pe.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Rn=m("_ZodString",(e,t)=>{ct.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>ll(e,a,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(Vc(...a)),e.includes=(...a)=>e.check(Kc(...a)),e.startsWith=(...a)=>e.check(Jc(...a)),e.endsWith=(...a)=>e.check(Yc(...a)),e.min=(...a)=>e.check(Fe(...a)),e.max=(...a)=>e.check(Ln(...a)),e.length=(...a)=>e.check(Mn(...a)),e.nonempty=(...a)=>e.check(Fe(1,...a)),e.lowercase=a=>e.check(Gc(a)),e.uppercase=a=>e.check(Wc(a)),e.trim=()=>e.check(Qc()),e.normalize=(...a)=>e.check(Xc(...a)),e.toLowerCase=()=>e.check(el()),e.toUpperCase=()=>e.check(tl()),e.slugify=()=>e.check(nl())}),Kl=m("ZodString",(e,t)=>{ct.init(e,t),Rn.init(e,t),e.email=n=>e.check(mc(Jl,n)),e.url=n=>e.check(wc(Yl,n)),e.jwt=n=>e.check(Oc(pd,n)),e.emoji=n=>e.check(xc(Xl,n)),e.guid=n=>e.check(zn(Zn,n)),e.uuid=n=>e.check(bc(He,n)),e.uuidv4=n=>e.check(_c(He,n)),e.uuidv6=n=>e.check(vc(He,n)),e.uuidv7=n=>e.check(yc(He,n)),e.nanoid=n=>e.check(kc(Ql,n)),e.guid=n=>e.check(zn(Zn,n)),e.cuid=n=>e.check(Cc(ed,n)),e.cuid2=n=>e.check(Ec(td,n)),e.ulid=n=>e.check(Sc(nd,n)),e.base64=n=>e.check(Lc(ld,n)),e.base64url=n=>e.check(Mc(dd,n)),e.xid=n=>e.check(Tc(ad,n)),e.ksuid=n=>e.check(Ic(od,n)),e.ipv4=n=>e.check(zc(id,n)),e.ipv6=n=>e.check(Ac(rd,n)),e.cidrv4=n=>e.check(Nc(sd,n)),e.cidrv6=n=>e.check(Pc(cd,n)),e.e164=n=>e.check($c(gd,n)),e.datetime=n=>e.check(Al(n)),e.date=n=>e.check(Pl(n)),e.time=n=>e.check(Ml(n)),e.duration=n=>e.check(Ol(n))});function x(e){return fc(Kl,e)}const R=m("ZodStringFormat",(e,t)=>{D.init(e,t),Rn.init(e,t)}),Jl=m("ZodEmail",(e,t)=>{ks.init(e,t),R.init(e,t)}),Zn=m("ZodGUID",(e,t)=>{ws.init(e,t),R.init(e,t)}),He=m("ZodUUID",(e,t)=>{xs.init(e,t),R.init(e,t)}),Yl=m("ZodURL",(e,t)=>{Cs.init(e,t),R.init(e,t)}),Xl=m("ZodEmoji",(e,t)=>{Es.init(e,t),R.init(e,t)}),Ql=m("ZodNanoID",(e,t)=>{Ss.init(e,t),R.init(e,t)}),ed=m("ZodCUID",(e,t)=>{Ts.init(e,t),R.init(e,t)}),td=m("ZodCUID2",(e,t)=>{Is.init(e,t),R.init(e,t)}),nd=m("ZodULID",(e,t)=>{zs.init(e,t),R.init(e,t)}),ad=m("ZodXID",(e,t)=>{As.init(e,t),R.init(e,t)}),od=m("ZodKSUID",(e,t)=>{Ns.init(e,t),R.init(e,t)}),id=m("ZodIPv4",(e,t)=>{Os.init(e,t),R.init(e,t)}),rd=m("ZodIPv6",(e,t)=>{Ds.init(e,t),R.init(e,t)}),sd=m("ZodCIDRv4",(e,t)=>{Bs.init(e,t),R.init(e,t)}),cd=m("ZodCIDRv6",(e,t)=>{Rs.init(e,t),R.init(e,t)}),ld=m("ZodBase64",(e,t)=>{Zs.init(e,t),R.init(e,t)}),dd=m("ZodBase64URL",(e,t)=>{js.init(e,t),R.init(e,t)}),gd=m("ZodE164",(e,t)=>{Fs.init(e,t),R.init(e,t)}),pd=m("ZodJWT",(e,t)=>{Hs.init(e,t),R.init(e,t)}),Un=m("ZodNumber",(e,t)=>{mn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>dl(e,a,o),e.gt=(a,o)=>e.check(Nn(a,o)),e.gte=(a,o)=>e.check(gt(a,o)),e.min=(a,o)=>e.check(gt(a,o)),e.lt=(a,o)=>e.check(An(a,o)),e.lte=(a,o)=>e.check(dt(a,o)),e.max=(a,o)=>e.check(dt(a,o)),e.int=a=>e.check(jn(a)),e.safe=a=>e.check(jn(a)),e.positive=a=>e.check(Nn(0,a)),e.nonnegative=a=>e.check(gt(0,a)),e.negative=a=>e.check(An(0,a)),e.nonpositive=a=>e.check(dt(0,a)),e.multipleOf=(a,o)=>e.check(Pn(a,o)),e.step=(a,o)=>e.check(Pn(a,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function he(e){return Uc(Un,e)}const ud=m("ZodNumberFormat",(e,t)=>{Vs.init(e,t),Un.init(e,t)});function jn(e){return jc(ud,e)}const hd=m("ZodBoolean",(e,t)=>{Gs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>gl(e,n,a)});function pt(e){return Fc(hd,e)}const fd=m("ZodUnknown",(e,t)=>{Ws.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>ul()});function ae(){return qc(fd)}const md=m("ZodNever",(e,t)=>{Ks.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>pl(e,n,a)});function bd(e){return Hc(md,e)}const _d=m("ZodArray",(e,t)=>{Js.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>bl(e,n,a,o),e.element=t.element,e.min=(n,a)=>e.check(Fe(n,a)),e.nonempty=n=>e.check(Fe(1,n)),e.max=(n,a)=>e.check(Ln(n,a)),e.length=(n,a)=>e.check(Mn(n,a)),e.unwrap=()=>e.element});function B(e,t){return al(_d,e,t)}const vd=m("ZodObject",(e,t)=>{Xs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>_l(e,n,a,o),M(e,"shape",()=>t.shape),e.keyof=()=>ht(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ae()}),e.loose=()=>e.clone({...e._zod.def,catchall:ae()}),e.strict=()=>e.clone({...e._zod.def,catchall:bd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>vr(e,n),e.safeExtend=n=>yr(e,n),e.merge=n=>wr(e,n),e.pick=n=>br(e,n),e.omit=n=>_r(e,n),e.partial=(...n)=>xr(Fn,e,n[0]),e.required=(...n)=>kr(Vn,e,n[0])});function L(e,t){const n={type:"object",shape:e??{},...S(t)};return new vd(n)}const yd=m("ZodUnion",(e,t)=>{Qs.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>vl(e,n,a,o),e.options=t.options});function Ve(e,t){return new yd({type:"union",options:e,...S(t)})}const wd=m("ZodIntersection",(e,t)=>{ec.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>yl(e,n,a,o)});function xd(e,t){return new wd({type:"intersection",left:e,right:t})}const kd=m("ZodRecord",(e,t)=>{tc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>wl(e,n,a,o),e.keyType=t.keyType,e.valueType=t.valueType});function Le(e,t,n){return new kd({type:"record",keyType:e,valueType:t,...S(n)})}const ut=m("ZodEnum",(e,t)=>{nc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(a,o,i)=>hl(e,a,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,o)=>{const i={};for(const r of a)if(n.has(r))i[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...S(o),entries:i})},e.exclude=(a,o)=>{const i={...t.entries};for(const r of a)if(n.has(r))delete i[r];else throw new Error(`Key ${r} not found in enum`);return new ut({...t,checks:[],...S(o),entries:i})}});function ht(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new ut({type:"enum",entries:n,...S(t)})}const Cd=m("ZodTransform",(e,t)=>{ac.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>ml(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Jt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ne(i,n.value,t));else{const r=i;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(Ne(r))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Ed(e){return new Cd({type:"transform",transform:e})}const Fn=m("ZodOptional",(e,t)=>{kn.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Bn(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function qn(e){return new Fn({type:"optional",innerType:e})}const Sd=m("ZodExactOptional",(e,t)=>{oc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Bn(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Td(e){return new Sd({type:"optional",innerType:e})}const Id=m("ZodNullable",(e,t)=>{ic.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>xl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Hn(e){return new Id({type:"nullable",innerType:e})}const zd=m("ZodDefault",(e,t)=>{rc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Cl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ad(e,t){return new zd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():nn(t)}})}const Nd=m("ZodPrefault",(e,t)=>{sc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>El(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Pd(e,t){return new Nd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():nn(t)}})}const Vn=m("ZodNonOptional",(e,t)=>{cc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>kl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e,t){return new Vn({type:"nonoptional",innerType:e,...S(t)})}const Md=m("ZodCatch",(e,t)=>{lc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Sl(e,n,a,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $d(e,t){return new Md({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Od=m("ZodPipe",(e,t)=>{dc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Tl(e,n,a,o),e.in=t.in,e.out=t.out});function Gn(e,t){return new Od({type:"pipe",in:e,out:t})}const Dd=m("ZodReadonly",(e,t)=>{gc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>Il(e,n,a,o),e.unwrap=()=>e._zod.def.innerType});function Bd(e){return new Dd({type:"readonly",innerType:e})}const Rd=m("ZodCustom",(e,t)=>{pc.init(e,t),U.init(e,t),e._zod.processJSONSchema=(n,a,o)=>fl(e,n)});function Zd(e,t={}){return ol(Rd,e,t)}function Ud(e){return il(e)}const jd=L({role:ht(["user","assistant"]),content:x(),timestamp:he().optional()}),Fd=L({sku:x(),name:x(),imageUrl:x().url().optional(),price:x().optional(),originalPrice:x().optional(),url:x().url(),ctaLabel:x().optional()}),qd=L({buttons:B(L({label:x(),action:L({title:x(),type:x(),payload:ae().optional()})}))}),Hd=L({}),Vd=L({label:x().optional()}),Wn=L({sku:x(),name:x(),price:x(),imageUrl:x().optional(),rating:he().optional(),reviewCount:he().optional()}),Gd=L({recommended:Wn,products:B(Wn),attributes:B(L({label:x(),values:B(x())})),highlights:B(x()),specialCases:B(x()).optional(),recommendedText:x().optional(),winnerHits:Le(x(),L({positive:B(x()).optional(),negative:B(x()).optional()})).optional(),productActions:Le(x(),L({title:x(),type:x(),payload:ae().optional()})).optional()}),Wd=L({label:x(),sentiment:ht(["positive","negative","neutral"]).optional()}),Kd=L({product:Le(x(),ae()),role:x().optional(),reason:x().optional(),labels:B(Wd).optional(),expertQualityScore:he().optional(),reviewHighlight:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()}).optional()}),Jd=L({suggestions:B(Kd)}),Yd=L({title:x().optional(),text:x().optional(),reviewCount:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()})}),Xd=L({entries:B(L({name:x(),image:x().optional(),description:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()})}))}),Qd=L({entries:B(L({shortName:x(),detailedMessage:x().optional(),whyDifferent:x().optional(),image:x().optional(),action:L({title:x(),type:x(),payload:ae().optional()})}))}),Kn=L({title:x(),type:x(),payload:ae().optional()}),eg=L({name:x().optional(),variant_name:x().optional(),sku:x().optional(),price:Ve([he(),x()]).optional()}),tg=L({product:L({sku:x().optional(),name:x().optional(),images:B(x()).optional(),imageUrl:x().optional(),rating:he().optional(),reviewCount:he().optional(),price:x().optional(),originalPrice:x().optional(),price_async:pt().optional(),inStock:pt().optional(),promotions:B(x()).optional(),variants:B(eg).optional(),url:x().optional(),cartCode:x().optional(),description:x().optional(),specifications:Ve([Le(x(),x()),B(L({key:x(),value:x()}))]).optional()}).optional(),action:Kn.optional()}),ng=L({endOfList:pt().optional()}),ag=L({review_class:x().optional(),review_text:x().optional(),review_rating:Ve([x(),he()]).optional(),review_tag:x().optional()}),og=L({reviews:B(ag).optional()}),ig=L({productName:x().optional(),pros:B(x()).optional(),cons:B(x()).optional()}),rg=L({groups:B(L({groupName:x(),products:B(Le(x(),ae())).optional()})).optional(),filterTags:B(L({title:x(),action:Kn.optional()})).optional()}),sg=L({summary:x().optional(),products_discussed:B(x()).optional(),user_sentiment:x().optional()}),cg={components:{MessageBubble:{schema:jd,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:Fd,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:qd,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:Hd,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:Vd,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:Gd,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:Jd,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:Yd,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:Xd,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:Qd,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:tg,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:ng,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:og,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:ig,description:"A pros and cons list for a product."},CategoriesContainer:{schema:rg,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:sg,description:"A notice shown when the conversation is escalated to a human agent."}}};function lg(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function Me(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}class Jn extends Ca{constructor(){super(...arguments),this._shadow=null,this._rootEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._activityTracker=null,this._heartbeat=null,this._proactiveShown=!1,this._drawerVisible=!1,this._messages=[],this._currentMessageId=0,this._abortControllers=new Set,this._currentThreadId=null,this._lastThreadId=null,this._chatCreatedAt="",this._lastBackendContext=null,this._productSort={type:"related"},this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._pdpLaunched=!1,this._i18n=Je,this._extendedModeManager=null,this._activeTypewriter=null,this._activeTtsHandle=null,this._activeRequestThreadId=null,this._skuToProductItem={},this._conversationMode=null,this._initComplete=!1,this._pendingActions=[],this._bridgeContext=null,this._cartQuantity=null,this._threadsWithFirstBot=new Set,this._panel=null,this._session=null,this._eventCallbacks=new Map}async onInit(t){this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),this._shadow=this.root.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Wi,this._shadow.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-root",this._rootEl=a,this._shadow.appendChild(a);const o=t.variant??"floating";if(o==="floating"){const d={onClick:()=>this.open(),ariaLabel:this._i18n.openButton};t.launcherSvg!==void 0&&(d.svgMarkup=t.launcherSvg),t.hideMobileLauncher!==void 0&&(d.hideMobile=t.hideMobileLauncher),t.mobileBreakpoint!==void 0&&(d.mobileBreakpoint=t.mobileBreakpoint),t.launcherTooltip!==void 0&&(d.tooltip=t.launcherTooltip),this._launcher=qo(d),a.appendChild(this._launcher.container)}o==="overlay"&&a.classList.add("gengage-chat--overlay");const i=document.createElement("div");a.appendChild(i),this._drawer=new jo(i,{i18n:this._i18n,onSend:(d,g)=>this._sendMessage(d,g),onClose:()=>this.close(),onAttachment:d=>this._handleAttachment(d),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onRollback:d=>this._handleRollback(d),onPanelBack:()=>this._panel?.navigateBack(),onPanelForward:()=>this._panel?.navigateForward(),headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,headerFavoritesToggle:t.headerFavoritesToggle,onFavoritesClick:()=>{or(),t.onFavoritesClick?.()},onThumbnailClick:d=>this._rollbackToThread(d),onLinkClick:d=>{this._saveSessionAndOpenURL(d)},voiceEnabled:t.voiceEnabled,voiceLang:t.locale?`${t.locale.split("-")[0]??"tr"}-${(t.locale.split("-")[1]??t.locale.split("-")[0]??"TR").toUpperCase()}`:void 0}),this._extendedModeManager=new Ri({onChange:d=>this._panel?.notifyExtension(d),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new Zi({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:d=>this._rollbackToThread(d)}),o!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"),this._drawer.restorePanelState(t.accountId),(t.panelMode??"auto")==="collapsed"?this._drawer.setPanelCollapsed(!0):this._drawer.setForceExpanded();const s=sessionStorage.getItem("gengage_restore_session_id"),c=sessionStorage.getItem("gengage_restore_sku");s&&c&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const d=new Di;await d.open(),this._session=new Ht(d),await this._restoreFromIndexedDB()}catch{this._session=new Ht(null)}this._registerPublicAPI(),t.mobileInitialState!==void 0&&(this._openState=t.mobileInitialState),this._mobileBreakpoint=t.mobileBreakpoint??768,this._syncViewportState();const l=()=>this._syncViewportState();if(window.addEventListener("resize",l,{passive:!0}),this.addCleanup(()=>window.removeEventListener("resize",l)),window.visualViewport){const d=()=>{if(!this._drawerVisible||!this._isMobileViewport)return;const g=this._drawer?.getElement();if(!g)return;const u=window.innerHeight-(window.visualViewport?.height??window.innerHeight);g.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,u)}px`)};window.visualViewport.addEventListener("resize",d),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",d))}o==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses()),this._bridge=new Ta({namespace:"chat",onMessage:d=>this._handleBridgeMessage(d)}),this._activityTracker=new Vo({idleThresholdMs:t.proactiveDelayMs??3e4,onActivity:d=>{if(d.type==="idle"&&!this._proactiveShown&&!this._drawerVisible){const g=t.proactiveMinScrollDepth??0;if(g>0&&(this._activityTracker?.maxScrollDepth??0)<g*100)return;try{if(sessionStorage.getItem("gengage_proactive_shown"))return}catch{}if(this._isProactiveCooldownActive())return;t.proactiveFetchActions?this._fetchAndShowProactive():t.proactiveMessage&&this._showProactivePopup(t.proactiveMessage)}}}),this.addCleanup(()=>this._activityTracker?.destroy()),t.enableHeartbeat&&(this._heartbeat=new Ko({middlewareUrl:t.middlewareUrl,accountId:t.accountId,sessionId:t.session?.sessionId??"",locale:t.locale??"tr",intervalMs:t.heartbeatIntervalMs??3e4,getPageType:()=>this.config.pageContext?.pageType??"other",getCurrentSku:()=>this.config.pageContext?.sku??"",onMessage:d=>{if(!this._proactiveShown&&!this._drawerVisible&&d.message){const g=[];if(d.suggested_actions&&Array.isArray(d.suggested_actions))for(const u of d.suggested_actions)u.title&&Me(u.requestDetails)&&g.push({title:u.title,onSelect:()=>{this.openWithAction(u.requestDetails)}});this._showProactivePopup(d.message,g.length>0?g:void 0)}}}),this._heartbeat.start(),this.addCleanup(()=>this._heartbeat?.destroy())),this._initComplete=!0;for(const d of this._pendingActions)this._sendAction(d.action,d.options);this._pendingActions=[],ee("gengage:chat:ready",{}),Ji("chat"),t.onReady?.()}onUpdate(t){}onShow(){this._showDrawer(),this.emit("open"),ee("gengage:chat:open",{state:this._openState}),Yi("chat"),this.config.onOpen?.(),!this._pdpLaunched&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku}},{silent:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),ee("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._bridge?.destroy(),this._bridge=null,this._extendedModeManager=null,this._panel?.destroy(),this._panel=null,this._session?.close(),this._session=null,window.gengage&&delete window.gengage.chat,this._shadow&&(this._shadow.innerHTML="",this._shadow=null),this._rootEl=null}open(t){t?.state!==void 0&&(this._openState=t.state,this._drawerVisible&&this._applyOpenStateClasses()),this.show(),t?.initialMessage!==void 0&&this._sendMessage(t.initialMessage)}openWithAction(t,n){n?.sku!==void 0&&this.update({sku:n.sku}),this._pdpLaunched=!0,n?.state!==void 0?this._openState=n.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,n){this._sendAction(t,n)}close(){this.hide()}saveSession(t,n){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",n)}get isOpen(){return this._drawerVisible}addCallback(t,n){let a=this._eventCallbacks.get(t);return a||(a=new Set,this._eventCallbacks.set(t,a)),a.add(n),()=>{a.delete(n),a.size===0&&this._eventCallbacks.delete(t)}}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const n=t.payload,a=n?.action,o=Me(a)?a:Me(n)?n:null;o&&this._sendAction(o,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const n=t.payload;if(n&&typeof n=="object"){this._bridgeContext=n;const a=n.sku;if(a&&this.update({sku:a}),Me(n.action)){this._pdpLaunched=!0,this.open(),this._sendAction(n.action);break}}this.open();break}case"launcherAction":{const a=t.payload?.action;a&&typeof a=="object"&&"type"in a&&this._sendAction(a);break}case"scrollToBottom":this._drawer?.scrollToBottomIfNeeded();break;case"addToCardHandler":{this._bridge?.send("addToCardResult",t.payload);break}case"cartQuantityHandler":{const n=t.payload;n&&"quantity"in n&&typeof n.quantity=="number"&&(this._cartQuantity=n.quantity);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&lg(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,n)=>this.openWithAction(t,n),sendMessage:t=>this.sendMessage(t),sendAction:(t,n)=>this.sendAction(t,n),close:()=>this.close(),saveSession:(t,n)=>this.saveSession(t,n),get isOpen(){return!1},on:(t,n)=>this.on(t,n),trackCheckout:(t,n)=>this.trackCheckout(t,n),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,n)=>this.addCallback(t,n)},Object.defineProperty(window.gengage.chat,"isOpen",{get:()=>this._drawerVisible})}_showDrawer(){if(this._drawerVisible)return;this._drawerVisible=!0;const t=this._drawer?.getElement();t&&t.classList.remove("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._isMobileViewport&&this._openState==="half"||this._drawer?.focusInput(),this._extendedModeManager?.setChatShown(!0)}_showProactivePopup(t,n){if(this._proactiveShown||!this._rootEl)return;this._proactiveShown=!0;try{sessionStorage.setItem("gengage_proactive_shown","1")}catch{}this._setProactiveCooldown();const a={message:t,onAccept:()=>this.open(),onDismiss:()=>{},...n&&n.length>0&&{actionButtons:n}};this.config.proactiveAcceptLabel!==void 0&&(a.acceptLabel=this.config.proactiveAcceptLabel);const o=Ho(a);this._rootEl.appendChild(o)}async _fetchAndShowProactive(){if(!this._proactiveShown)try{const t={middlewareUrl:this.config.middlewareUrl,accountId:this.config.accountId,backendType:this.config.backendType??"v1"},n=this.config.pageContext?.sku,a=this.config.pageContext?.pageType,o=this.config.locale,i=await No({account_id:this.config.accountId,...n&&{sku:n},...a&&{page_type:a},...o&&{output_language:o}},t);if(!i)return;const r=i.question??i.title??"";if(!r)return;const s=[];if(i.actions&&Array.isArray(i.actions))for(const c of i.actions){const l=c,d=l.title;if(d&&Me(l.requestDetails)){const g=l.requestDetails;s.push({title:d,onSelect:()=>{this.openWithAction(g)}})}}this._showProactivePopup(r,s)}catch{}}_proactiveCooldownKey(){return`gengage_proactive_time_${this.config.accountId}`}_isProactiveCooldownActive(){try{const t=localStorage.getItem(this._proactiveCooldownKey());if(t){const n=Date.now()-parseInt(t,10),a=this.config.proactiveCooldownMs??36e5;return n<a}}catch{}return!1}_setProactiveCooldown(){try{localStorage.setItem(this._proactiveCooldownKey(),String(Date.now()))}catch{}}_hideDrawer(){if(!this._drawerVisible)return;this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawerVisible=!1,this._openState="full",this._drawer?.clearPanel();const t=this._drawer?.getElement();t&&t.classList.add("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._extendedModeManager?.setChatShown(!1)}_syncViewportState(){if(this._rootEl){if(this._isMobileViewport=window.innerWidth<=this._mobileBreakpoint,this._rootEl.classList.toggle("gengage-chat-root--mobile",this._isMobileViewport),this._launcher){const t=this._isMobileViewport&&this.config.hideMobileLauncher===!0;this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile",t)}this._applyOpenStateClasses()}}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",n=this._drawerVisible&&this._isMobileViewport&&this._openState==="full";this._rootEl.classList.toggle("gengage-chat-root--open",this._drawerVisible),this._rootEl.classList.toggle("gengage-chat-root--mobile-half",t),this._rootEl.classList.toggle("gengage-chat-root--mobile-full",n)}_handleAttachment(t){const n=Ba(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;ee("gengage:global:error",{message:a,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,n){cr(),this._messages.some(i=>i.role==="user")||lr();const o={title:t,type:"user_message",payload:t};n!==void 0?this._sendAction(o,{attachment:n}):this._sendAction(o)}_sendAction(t,n){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:n});return}if(this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const b=this._currentThreadId,_=this._messages.filter(E=>E.threadId!==void 0&&E.threadId>b);this._messages=this._messages.filter(E=>!E.threadId||E.threadId<=b);for(const E of _)this._shadow?.querySelector(`[data-message-id="${CSS.escape(E.id)}"]`)?.remove(),this._panel.snapshots.delete(E.id),this._panel.snapshotTypes.delete(E.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(E=>{E instanceof HTMLElement&&E.dataset.threadId&&E.dataset.threadId>b&&E.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=Sa();this._currentThreadId=a,this._lastThreadId=a;const o=n?.preservePanel===!0;if(o||(this._activeRequestThreadId=a),!n?.silent){const b=this._createMessage("user",typeof t.payload=="string"?t.payload:t.title);b.threadId=a,n?.attachment!==void 0&&(b.attachment=n.attachment),this._drawer?.addMessage(b),this._messages.push(b)}n?.preservePanel||(this._drawer?.hasPanelContent()?this._drawer.showPanelLoading():this._drawer?.clearPanel()),this._drawer?.showTypingIndicator();let i="";const r=this._createMessage("assistant","");r.threadId=a,r.status="streaming",this._messages.push(r),n?.preservePanel||(this._abortControllers.forEach(b=>b.abort()),this._abortControllers.clear());const s={middlewareUrl:this.config.middlewareUrl,...this.config.backendType?{backendType:this.config.backendType}:{},...this.config.accountId?{accountId:this.config.accountId}:{}};n?.attachment!==void 0&&(s.attachment=n.attachment);const l=this._getVisibleMessages().filter(b=>b.content).slice(-50).map(b=>({role:b.role==="user"?"user":"model",content:b.content??""})),d={outputLanguage:Gi(this.config.locale),parentUrl:window.location.href,windowWidth:String(window.innerWidth),windowHeight:String(window.innerHeight),selfUrl:"",id:this.config.session?.sessionId??"",userId:this.config.session?.userId??"",appId:this.config.accountId,threads:[],createdAt:this._chatCreatedAt,kvkkApproved:Gt(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:a,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this.config.session?.viewId!==void 0&&(d.viewId=this.config.session.viewId);const g=So(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),u={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:g.type,locale:this.config.locale??"tr",meta:d,context:{...this._lastBackendContext??{},messages:l,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(u.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(u.view_id=this.config.session.viewId),g.payload!==void 0&&(u.payload=g.payload),this.config.pageContext?.sku!==void 0&&(u.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(u.page_type=this.config.pageContext.pageType);const p=crypto.randomUUID(),f=Date.now();let v=0,y=!1,I=!1;this.track(ea(this.analyticsContext(),{endpoint:"process_action",request_id:p,widget:"chat"}));let z=null;z=Ao(u,{onTextChunk:(b,_,w)=>{if(!o&&a!==this._activeRequestThreadId||(i+=b,this._drawer?.removeTypingIndicator(),w?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...w.skuToProductItem}),w?.conversationMode&&(this._conversationMode=w.conversationMode),this.track(ta(this.analyticsContext(),{request_id:p,chunk_index:v++,widget:"chat"})),!this._drawer))return;let E=i;if(_&&et(E)){const h=this.config.accountId;if(!Gt(h)){const k=Hi(E);k&&this._drawer?.showKvkkBanner(k,()=>{this._drawer?.hideKvkkBanner()}),Fi(h)}E=qi(E)}const P=this._shadow?.querySelector(`[data-message-id="${r.id}"] .gengage-chat-bubble-text`);if(P?P.innerHTML=we(E):(r.content=E,r.role==="assistant"&&r.threadId&&!this._threadsWithFirstBot.has(r.threadId)&&(this._threadsWithFirstBot.add(r.threadId),this._drawer.markFirstBotMessage(r.id)),this._drawer.addMessage(r)),_){r.content=E,r.status="done",Kt();const h=this._shadow?.querySelector(`[data-message-id="${r.id}"] .gengage-chat-bubble-text`);if(h){this._activeTypewriter?.cancel();const k=w?.productMentions;this._activeTypewriter=Ii({container:h,html:we(E),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,k&&k.length>0&&h&&zi({container:h,mentions:k,onProductClick:C=>{this._sendAction({title:k.find(A=>A.sku===C)?.short_name??C,type:"launchSingleProduct",payload:{sku:C}})}})}})}}},onUISpec:(b,_,w)=>{if(!o&&a!==this._activeRequestThreadId||_!=="chat")return;const E=b.elements[b.root],P=E?.type??"unknown";this.track(na(this.analyticsContext(),{request_id:p,chunk_index:v,component_type:P,widget:"chat"}));const h=this._buildRenderContext();if(P==="ComparisonTable"){const A=E?.props?.products;nr(Array.isArray(A)?A.length:0)}if(P==="ProductGrid"){const A=E?.children?.length??0;ir(void 0,A)}const k=w==="panel"&&this._panel?this._panel.toPanelSpec(b):b,C=!r.silent&&(w!=="panel"||P==="ProductCard")&&P!=="ActionButtons";if(w==="panel"&&this._panel){I=!0,E?.props?.similarsAppend===!0&&this._panel.currentType==="ProductDetailsPanel"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._appendSimilarsToPanel(k,h):P==="ProductGrid"&&this._drawer?.hasPanelContent()&&!this._drawer.isPanelLoading()?this._drawer.appendPanelContent(this._renderUISpec(k,h)):(this._drawer?.setPanelContent(this._renderUISpec(k,h)),this._panel.currentType=P),r.threadId&&!this._panel.threads.includes(r.threadId)&&this._panel.threads.push(r.threadId);const A=this._panel.currentType??P;this._panel.updateTopBar(A),this._panel.updateExtendedMode(P)}if(P==="ProductDetailsPanel"&&!r.silent&&w==="panel"){const A=E?.props?.product;if(A){const $={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:A}}}},N=this._shadow?.querySelector(".gengage-chat-messages");if(N){const T=this._renderUISpec($,h);r.threadId&&(T.dataset.threadId=r.threadId),N.appendChild(T),T.scrollIntoView({behavior:"auto",block:"end"})}}}if(C){const A=this._shadow?.querySelector(".gengage-chat-messages");if(A){const $=this._renderUISpec(b,h);r.threadId&&($.dataset.threadId=r.threadId),A.appendChild($),$.scrollIntoView({behavior:"auto",block:"end"})}}if((P==="ProductGrid"||P==="ProductCard")&&r.threadId){const A=E?.children??[],$=P==="ProductGrid"?A.map(N=>b.elements[N]?.props?.product).filter(Boolean):[E?.props?.product].filter(Boolean);for(const N of $){const T=N.sku,j=N.imageUrl;T&&j&&this._thumbnailEntries.push({sku:T,imageUrl:j,threadId:r.threadId})}this._drawer?.setThumbnails(this._thumbnailEntries)}if(P==="ProductGrid"||P==="ProductDetailsPanel"){const $=(P==="ProductGrid"?(E?.children??[]).map(N=>b.elements[N]?.props?.product).filter(Boolean):[E?.props?.product??E?.props].filter(Boolean)).map(N=>N.imageUrl).filter(N=>typeof N=="string").slice(0,5);$.length>0&&this._bridge?.send("previewImages",{images:$})}if(P==="ProductGrid"&&w==="panel"&&!this._comparisonSelectMode&&!Mi()&&(this._choicePrompterEl?.remove(),this._choicePrompterEl=Li({heading:this._i18n.choicePrompterHeading,suggestion:this._i18n.choicePrompterSuggestion,ctaLabel:this._i18n.choicePrompterCta,onCtaClick:()=>{this._comparisonSelectMode=!0,this._choicePrompterEl=null,this._refreshComparisonUI()},onDismiss:()=>{this._choicePrompterEl=null}}),this._shadow?.querySelector(".gengage-chat-panel")?.appendChild(this._choicePrompterEl)),P==="ActionButtons"){const A=E?.props?.buttons;if(A&&A.length>0){const $=[],N=[];for(const T of A)if(Pi(T)){const j={label:T.label,action:T.action};T.icon&&(j.icon=T.icon),$.push(j)}else N.push(T);$.length>0&&this._drawer?.setInputAreaChips($.map(T=>({label:T.label,onAction:()=>this._sendAction(T.action),...T.icon?{icon:T.icon}:{}}))),N.length>0&&this._drawer?.setPills(N.map(T=>{const j={label:T.label,onAction:()=>this._sendAction(T.action)};return T.icon&&(j.icon=T.icon),T.image&&(j.image=T.image),T.description&&(j.description=T.description),j}))}}r.uiSpec=b},onAction:b=>{if(!(!o&&a!==this._activeRequestThreadId)&&b.type==="action"){const _={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(_.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(_.allowScriptCall=this.config.actionHandling.allowScriptCall),Aa(b,{openChat:()=>this.open(),navigate:w=>{this._bridge?.send("navigate",w),w.newTab?window.open(w.url,"_blank","noopener,noreferrer"):window.location.href=w.url},saveSession:w=>this.saveSession(w.sessionId,w.sku),addToCart:w=>{ee("gengage:similar:add-to-cart",w)},scriptCall:w=>{ee("gengage:chat:script-call",w),this.config.onScriptCall?.(w)}},_)}},onMetadata:b=>{if(!(!o&&a!==this._activeRequestThreadId)&&b.type==="metadata"&&b.meta){if((b.meta.panel!==void 0||b.meta.messages!==void 0||b.meta.message_id!==void 0)&&(this._lastBackendContext=b.meta),b.meta.panelLoading){y=!0,I=!1;const w=typeof b.meta.panelPendingType=="string"?b.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(w),w&&this._panel?.updateTopBarForLoading(w)}if(b.meta.voice){const w=new CustomEvent("gengage:chat:voice",{detail:{payload:b.meta.voice},bubbles:!1,cancelable:!0}),E=window.dispatchEvent(w);if(dr(),E){const P=b.meta.voice;P.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=Wo(P.audio_base64,P.content_type??"audio/ogg"))}}(b.meta.redirectTarget||b.meta.redirect)&&ee("gengage:chat:redirect",{target:b.meta.redirectTarget??null,payload:b.meta.redirect??null}),b.meta.analyzeAnimation&&(y=!0,I=!1,this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),b.meta.loading&&typeof b.meta.loadingText=="string"&&(this._drawer?.addThinkingStep(b.meta.loadingText),this._bridge?.send("loadingMessage",{text:b.meta.loadingText})),b.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",b.meta.visitorDataResponse),b.meta.formType&&this._bridge?.send("glovOtokoc",{type:b.meta.formType,data:b.meta.formPayload}),b.meta.launcherContent&&this._bridge?.send("launcherContent",b.meta.launcherContent),ee("gengage:chat:metadata",{payload:b.meta});const _=b.meta;typeof _.prompt_tokens=="number"&&typeof _.completion_tokens=="number"&&this.track(ia(this.analyticsContext(),{model:b.model??"unknown",prompt_tokens:_.prompt_tokens,completion_tokens:_.completion_tokens,total_tokens:_.total_tokens??_.prompt_tokens+_.completion_tokens}))}},onError:b=>{z&&this._abortControllers.delete(z),!(!o&&a!==this._activeRequestThreadId)&&(this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),y&&!I&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),y=!1,I=!1,ee("gengage:global:error",{source:"chat",code:"STREAM_ERROR",message:this._i18n.errorMessage}),this.emit("error",b),this._drawer?.showError(b.message),r.status==="streaming"&&(r.status="error"),this.track(oa(this.analyticsContext(),{request_id:p,error_code:"STREAM_ERROR",error_message:b.message,widget:"chat"})))},onDone:()=>{z&&this._abortControllers.delete(z),!(!o&&a!==this._activeRequestThreadId)&&(this._activeRequestThreadId=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),y&&!I&&this._drawer?.isPanelLoading()&&this._drawer.clearPanel(),y=!1,I=!1,r.status==="streaming"&&(r.status="done",Kt()),this.emit("message",r),this._panel?.snapshotForMessage(r.id),this._panel?.attachClickHandler(r.id),this.track(aa(this.analyticsContext(),{request_id:p,latency_ms:Date.now()-f,chunk_count:v,widget:"chat"})),this.track(ra(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(ca(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{}))}},s),this._abortControllers.add(z)}_getVisibleMessages(){const t=this._messages.filter(a=>!a.silent);if(!this._currentThreadId)return t;const n=this._currentThreadId;return t.filter(a=>!a.threadId||a.threadId<=n)}_appendSimilarsToPanel(t,n){if(!this._drawer)return;const a=this._drawer.getPanelContentElement();if(!a)return;const o=document.createElement("h3");o.className="gengage-chat-product-details-similars-heading",o.textContent=this._i18n.similarProductsLabel??"Benzer Ürünler",a.appendChild(o);const i=this._renderUISpec(t,n);i.classList.add("gengage-chat-product-details-similars"),a.appendChild(i)}_handleRollback(t){const n=this._messages.find(a=>a.id===t);n?.threadId&&this._rollbackToThread(n.threadId)}_rollbackToThread(t){this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1);for(const i of this._messages){const r=this._shadow?.querySelector(`[data-message-id="${CSS.escape(i.id)}"]`);r&&(i.threadId&&i.threadId>t?r.classList.add("gengage-chat-bubble--hidden"):r.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(i=>{i instanceof HTMLElement&&i.dataset.threadId&&i.dataset.threadId>t?i.classList.add("gengage-chat-bubble--hidden"):i instanceof HTMLElement&&i.classList.remove("gengage-chat-bubble--hidden")});const n=this._messages.find(i=>i.role==="assistant"&&i.threadId===t);n&&this._panel?.restoreForMessage(n.id)||this._drawer?.clearPanel();const o=this._panel.currentType??"";this._panel?.updateTopBar(o),this._drawer?.setPills([]),this._session?.db&&this.config.session?.sessionId&&this._session?.db.loadContext(this.config.session.sessionId,t).then(i=>{i&&(this._lastBackendContext=i.context)}).catch(()=>{}),this._session?.db&&this.config.session?.sessionId&&this._session?.db.deleteContextsAfterThread(this.config.session.sessionId,t).catch(()=>{})}async _persistToIndexedDB(){!this._session||!this.config.session?.sessionId||await this._session.persist({userId:this.config.session.userId??"",appId:this.config.accountId,sessionId:this.config.session.sessionId,messages:this._messages,currentThreadId:this._currentThreadId,lastThreadId:this._lastThreadId,chatCreatedAt:this._chatCreatedAt,panelSnapshots:this._panel?.snapshots??new Map,panelThreads:this._panel?.threads??[],thumbnailEntries:this._thumbnailEntries,lastBackendContext:this._lastBackendContext})}_isSameOriginUrl(t){try{return new URL(t,window.location.href).origin===window.location.origin}catch{return!1}}async _saveSessionAndOpenURL(t){this._session&&await this._session.saveAndOpenURL(t,()=>this._persistToIndexedDB(),this._bridge)}async _loadPayload(t,n){return this._session?this._session.loadPayload(t,n):null}async _restoreFromIndexedDB(){if(!this._session?.db)return;const t=this.config.session?.sessionId;if(!t)return;const n=this.config.session?.userId??"",a=this.config.accountId;await this._session.loadFavorites(n,a);const o=await this._session.db?.loadSession(n,a,t);if(!o||o.messages.length===0)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=o.currentThreadId,this._lastThreadId=o.lastThreadId,this._chatCreatedAt=o.createdAt,o.panelThreads&&(this._panel.threads=o.panelThreads),o.thumbnailEntries&&(this._thumbnailEntries=o.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),o.panelSnapshotHtml)for(const[r,s]of Object.entries(o.panelSnapshotHtml)){const c=document.createElement("div");c.innerHTML=we(s),this._panel.snapshots.set(r,c)}let i=0;for(const r of o.messages){const s={id:r.id,role:r.role,timestamp:r.timestamp,status:r.status};if(r.threadId!==void 0&&(s.threadId=r.threadId),r.content!==void 0&&(s.content=r.content),r.silent&&(s.silent=!0),this._messages.push(s),s.silent)continue;s.role==="assistant"&&s.threadId&&!this._threadsWithFirstBot.has(s.threadId)&&(this._threadsWithFirstBot.add(s.threadId),this._drawer?.markFirstBotMessage(s.id)),this._drawer?.addMessage(s);const c=parseInt(r.id.replace("msg-",""),10);if(!isNaN(c)&&c>i&&(i=c),s.role==="assistant"&&s.threadId){const l=await this._loadPayload(s.threadId,s.id);l&&(s.uiSpec=l,this._restoreInlineUISpec(s),this._panel?.attachClickHandler(s.id),delete s.uiSpec)}}if(i>this._currentMessageId&&(this._currentMessageId=i),this._currentThreadId){let r=await this._session.db?.loadContext(t,this._currentThreadId);r||(r=await this._session.db?.loadLatestContext(t)),r&&(this._lastBackendContext=r.context)}if(this._currentThreadId){const r=[...this._messages].reverse().find(s=>s.role==="assistant"&&s.threadId===this._currentThreadId&&!s.silent);r&&this._panel.snapshots.has(r.id)&&this._panel?.restoreForMessage(r.id)}if(this._currentThreadId){const r=this._currentThreadId;for(const s of this._messages)s.threadId&&s.threadId>r&&this._shadow?.querySelector(`[data-message-id="${CSS.escape(s.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");this._shadow?.querySelectorAll("[data-thread-id]").forEach(s=>{s instanceof HTMLElement&&s.dataset.threadId&&s.dataset.threadId>r&&s.classList.add("gengage-chat-bubble--hidden")})}if(this._panel.threads.length>0&&this._currentThreadId){const r=this._panel.threads[this._panel.threads.length-1];if(r){const s=[...this._messages].reverse().find(c=>c.role==="assistant"&&c.threadId===r);if(s?.threadId){const c=await this._loadPayload(s.threadId,s.id);if(c){const l=c.elements[c.root];l&&this._panel?.updateTopBar(l.type)}}}}setTimeout(()=>{this._drawer?.scrollToLastThread()},550)}_toggleComparisonSku(t){t===""?(this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectMode||(this._comparisonSelectedSkus=[],tr())):this._comparisonSelectedSkus.indexOf(t)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],er(t)),this._refreshComparisonUI()}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t)return;const n=t.querySelector(".gengage-chat-product-grid-wrapper");if(!n)return;const a=n.querySelector(".gengage-chat-product-grid");if(!a)return;const o=n.querySelector(".gengage-chat-comparison-toggle-btn");if(o&&o.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const r=a.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const s of r){if(s.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const g=s.parentElement.querySelector(".gengage-chat-comparison-checkbox");g&&(g.checked=this._comparisonSelectedSkus.includes(s.dataset.sku));continue}const c=s.dataset.sku,l=document.createElement("div");l.className="gengage-chat-comparison-select-wrapper";const d=document.createElement("input");d.type="checkbox",d.className="gengage-chat-comparison-checkbox",d.checked=this._comparisonSelectedSkus.includes(c),d.addEventListener("change",()=>{this._toggleComparisonSku(c)}),s.parentNode.insertBefore(l,s),l.appendChild(d),l.appendChild(s)}}else{const r=a.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const s of r){const c=s.querySelector(".gengage-chat-product-card");c&&s.parentNode&&(s.parentNode.insertBefore(c,s),s.remove())}}const i=n.querySelector(".gengage-chat-comparison-floating-btn");if(this._comparisonSelectMode&&this._comparisonSelectedSkus.length>=2){const r=this._i18n.compareSelected??"Karşılaştır",s=`${r} (${this._comparisonSelectedSkus.length})`;if(i)i.textContent=s;else{const c=document.createElement("button");c.className="gengage-chat-comparison-floating-btn",c.type="button",c.textContent=s,c.addEventListener("click",()=>{Wt(this._comparisonSelectedSkus),this._sendAction({title:r,type:"getComparisonTable",payload:{sku_list:[...this._comparisonSelectedSkus]}})}),n.appendChild(c)}}else i?.remove()}_buildRenderContext(){const t={onAction:n=>{if(Xi(n.title,n.type),n.type==="findSimilar"){const o=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";Qi(o)}n.type==="getComparisonTable"&&Wt(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{rr(n.sku),ee("gengage:similar:product-click",{sku:n.sku,url:n.url,sessionId:this.config.session?.sessionId??null}),this.config.isDemoWebsite===!0||!this._isSameOriginUrl(n.url)?this._sendAction({title:n.sku,type:"launchSingleProduct",payload:{sku:n.sku}}):this._saveSessionAndOpenURL(n.url)},onAddToCart:n=>{sr(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};ee("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",n),this._runEventCallbacks("gengage-cart-add",a),this._sendAction({title:"Sepete Ekle",type:"addToCart",payload:{sku:n.sku,cart_code:n.cartCode,quantity:n.quantity}},{preservePanel:!0})},onProductSelect:n=>{const a={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:n}}}};this._drawer?.setPanelContent(this._renderUISpec(a,t))},i18n:this._i18n,pricing:this.config.pricing,productSort:this._productSort,onSortChange:n=>{this._productSort=n},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,onToggleComparisonSku:n=>{this._toggleComparisonSku(n)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(n,a)=>{ar(n),this._toggleFavorite(n,a);const o=a.name??n;this._sendAction({title:o,type:"like",payload:{sku:n}},{preservePanel:!0})}};return t}async _toggleFavorite(t,n){if(!this._session)return;const a=this.config.session?.userId??"",o=this.config.accountId;await this._session.toggleFavorite(a,o,t,n)}async _runEventCallbacks(t,n){const a=this._eventCallbacks.get(t);if(!(!a||a.size===0))for(const o of a)try{const i=o(n);if((i instanceof Promise?await i:i)===!1){this._handleCallbackFailure(t,n);return}}catch{this._handleCallbackFailure(t,n);return}}_handleCallbackFailure(t,n){if(t==="gengage-cart-add"){const o=this._createMessage("assistant","Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.");this._currentThreadId&&(o.threadId=this._currentThreadId),this._messages.push(o),this._drawer?.addMessage(o)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const n=t.uiSpec,a=n.elements[n.root];if(!a)return;const o=a.type;if(o==="ActionButtons"||o==="ComparisonTable"||o==="ProductGrid"&&a.props?.similarsAppend===!0)return;const i=this._buildRenderContext(),r=this._shadow?.querySelector(".gengage-chat-messages");if(!r)return;if(o==="ProductDetailsPanel"){const c=a.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},d=this._renderUISpec(l,i);t.threadId&&(d.dataset.threadId=t.threadId),r.appendChild(d);return}const s=this._renderUISpec(n,i);t.threadId&&(s.dataset.threadId=t.threadId),r.appendChild(s)}_createMessage(t,n){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:n,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...Mo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=Zt();return Qn(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??Qe,i=(c,l)=>Ut(c,l,a,o),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:o,defaultRender:i}):i(t,n)}}function dg(){return new Jn}fe.GengageChat=Jn,fe.chatCatalog=cg,fe.createChatWidget=dg,fe.createDefaultChatUISpecRegistry=Zt,fe.defaultChatUnknownUISpecRenderer=Qe,fe.renderUISpec=Ut,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
97
97
  //# sourceMappingURL=chat.iife.js.map