@gengage/assistant-fe 0.5.0 → 0.5.1

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
@@ -44,7 +44,7 @@
44
44
  transform: translateY(0);
45
45
  }
46
46
  }
47
- `,document.head.appendChild(e)}var kt=null;function Qi(){if(kt!==null)return kt;try{kt=localStorage.getItem("gengage:debug")==="1"}catch{kt=!1}return kt}function Ze(e,t,a){if(!Qi())return;const n=[`[gengage:${e}]`,t];a!==void 0&&n.push(a),console.debug(...n)}var eo=("0.5.0".trim(),"0.5.0".trim()),to=("iife-build".trim(),"iife-build".trim());function ao(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${eo} (${to})`))}var no=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=Fi(e.theme);ao(),this.config={...e,theme:t,session:Di(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Vi();const a=Ga("gengage:context:update",n=>this.update(n));this._cleanups.push(a),Ze("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Ze("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),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(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(a=>a(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const a=document.querySelector(e);if(!a)throw new Error(`[gengage] Mount target not found: "${e}"`);return a}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,a]of Object.entries(e))if(a!==void 0){const n=t.startsWith("--")?t:`--gengage-${ro(t)}`;this.root.style.setProperty(n,a)}}}};function ro(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Xa(){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 a=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}var io=class{constructor(e){this._handlers=new Map,this._destroyed=!1,this._namespace=e.namespace,this._allowedOrigins=e.allowedOrigins??[location.origin],this._onMessage=e.onMessage,this._allowedOrigins.includes("*")&&so()&&console.warn("[gengage] postMessage bridge using wildcard origin. Set allowedOrigins for production security."),this._messageListener=t=>this._handlePostMessage(t),window.addEventListener("message",this._messageListener)}send(e,t){if(this._destroyed)return;const a={namespace:this._namespace,type:e};t!==void 0&&(a.payload=t),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(e,t){this._handlers.has(e)||this._handlers.set(e,new Set);const a=this._handlers.get(e);return a.add(t),()=>{a.delete(t),a.size===0&&this._handlers.delete(e)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(e){if(this._destroyed||!this._isOriginAllowed(e.origin))return;const t=e.data;if(!oo(t)||t.gengage!==this._namespace)return;const a={type:t.type};t.payload!==void 0&&(a.payload=t.payload),this._onMessage?.(a);const n=this._handlers.get(a.type);if(n)for(const r of n)r(a.payload)}_isOriginAllowed(e){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(e)}};function oo(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}function so(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}function Qa(e,t){if(typeof window>"u"||!we(e))return!1;const a=new CustomEvent("gengage:navigate",{detail:t===void 0?{url:e}:{url:e,newTab:t},cancelable:!0});return window.dispatchEvent(a)?(t?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e,!0):!1}var co=console;function lo(e,t,a={}){const n=e.action,r=a.logger??co;switch(Ze("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":t.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){gt(n,t,a,r);return}if(!we(n.url)){r.warn("[gengage] Blocked navigation to unsafe URL:",n.url);return}const i=typeof n.newTab=="boolean"?n.newTab:void 0;if(t.navigate){t.navigate({url:n.url,...i!==void 0&&{newTab:i}});return}(a.defaultNavigate??go)(n.url,i);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){gt(n,t,a,r);return}t.saveSession?.({sessionId:n.sessionId,sku:n.sku});return;case"add_to_cart":if(typeof n.sku!="string"||typeof n.quantity!="number"||typeof n.cartCode!="string"){gt(n,t,a,r);return}t.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){gt(n,t,a,r);return}if(typeof n.name!="string"){gt(n,t,a,r);return}const i=po(n.payload)?n.payload:void 0;t.scriptCall?.({name:n.name,...i!==void 0&&{payload:i}});return}default:gt(n,t,a,r)}}function gt(e,t,a,n){const r=a.unknownActionPolicy??"log-and-ignore";if(r==="delegate"){t.unknown?.(e),t.unknown||n.warn("[gengage] Unknown action received without delegate handler",e);return}if(r==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);n.warn("[gengage] Unknown action ignored",e)}function go(e,t){if(!(typeof window>"u")){if(!we(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}Qa(e,t)}}function po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ct(e){const t=e?.trim();return t||"tr"}function ke(e){const t=globalThis.CSS?.escape;if(typeof t=="function")return t(e);const a=Array.from(e);return a.map((n,r)=>{const i=n.codePointAt(0);return i===void 0?"":i===0?"�":i>=1&&i<=31||i===127||r===0&&i>=48&&i<=57||r===1&&a[0]==="-"&&i>=48&&i<=57?`\\${i.toString(16)} `:r===0&&n==="-"&&a.length===1?"\\-":i>=128||/[A-Za-z0-9_-]/.test(n)?n:`\\${n}`}).join("")}var ho=["image/jpeg","image/png","image/webp"],Fm=5*1024*1024;function uo(e){return ho.includes(e.type)?e.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function en(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function mo(e){const t=[];let a=0,n=!1,r=!1,i=0;for(let o=0;o<e.length;o++){const s=e[o];if(r){r=!1;continue}if(s==="\\"&&n){r=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&a++,s==="}"&&(a--,a===0&&(t.push(e.slice(i,o+1)),i=o+1)))}return t.length>0?t:[e]}function tn(e,t){const a=e.trim();if(!a||a.startsWith(":"))return!1;const n=a.startsWith("data: ")?a.slice(6):a;if(n==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(n);return en(r)?(Ze("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=mo(n);if(r.length>1){for(const i of r)try{const o=JSON.parse(i);if(!en(o))continue;if(t.onEvent(o),o.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function fo(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 a=e.body.getReader(),n=new TextDecoder("utf-8");let r="";const i=t.idleTimeoutMs??6e4,o=Symbol("idle-timeout");let s=!1;try{for(;;){const c=a.read();let l;const g=await(i>0?Promise.race([c.then(v=>(clearTimeout(l),v)),new Promise(v=>{l=setTimeout(()=>v(o),i)})]):c);if(g===o){s=!0,await a.cancel();break}const{done:d,value:p}=g;if(d)break;r+=n.decode(p,{stream:!0});const h=r.split(`
47
+ `,document.head.appendChild(e)}var kt=null;function Qi(){if(kt!==null)return kt;try{kt=localStorage.getItem("gengage:debug")==="1"}catch{kt=!1}return kt}function Ze(e,t,a){if(!Qi())return;const n=[`[gengage:${e}]`,t];a!==void 0&&n.push(a),console.debug(...n)}var eo=("0.5.1".trim(),"0.5.1".trim()),to=("iife-build".trim(),"iife-build".trim());function ao(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${eo} (${to})`))}var no=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=Fi(e.theme);ao(),this.config={...e,theme:t,session:Di(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Vi();const a=Ga("gengage:context:update",n=>this.update(n));this._cleanups.push(a),Ze("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Ze("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),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(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(a=>a(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const a=document.querySelector(e);if(!a)throw new Error(`[gengage] Mount target not found: "${e}"`);return a}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,a]of Object.entries(e))if(a!==void 0){const n=t.startsWith("--")?t:`--gengage-${ro(t)}`;this.root.style.setProperty(n,a)}}}};function ro(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Xa(){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 a=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}var io=class{constructor(e){this._handlers=new Map,this._destroyed=!1,this._namespace=e.namespace,this._allowedOrigins=e.allowedOrigins??[location.origin],this._onMessage=e.onMessage,this._allowedOrigins.includes("*")&&so()&&console.warn("[gengage] postMessage bridge using wildcard origin. Set allowedOrigins for production security."),this._messageListener=t=>this._handlePostMessage(t),window.addEventListener("message",this._messageListener)}send(e,t){if(this._destroyed)return;const a={namespace:this._namespace,type:e};t!==void 0&&(a.payload=t),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(e,t){this._handlers.has(e)||this._handlers.set(e,new Set);const a=this._handlers.get(e);return a.add(t),()=>{a.delete(t),a.size===0&&this._handlers.delete(e)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(e){if(this._destroyed||!this._isOriginAllowed(e.origin))return;const t=e.data;if(!oo(t)||t.gengage!==this._namespace)return;const a={type:t.type};t.payload!==void 0&&(a.payload=t.payload),this._onMessage?.(a);const n=this._handlers.get(a.type);if(n)for(const r of n)r(a.payload)}_isOriginAllowed(e){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(e)}};function oo(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}function so(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}function Qa(e,t){if(typeof window>"u"||!we(e))return!1;const a=new CustomEvent("gengage:navigate",{detail:t===void 0?{url:e}:{url:e,newTab:t},cancelable:!0});return window.dispatchEvent(a)?(t?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e,!0):!1}var co=console;function lo(e,t,a={}){const n=e.action,r=a.logger??co;switch(Ze("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":t.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){gt(n,t,a,r);return}if(!we(n.url)){r.warn("[gengage] Blocked navigation to unsafe URL:",n.url);return}const i=typeof n.newTab=="boolean"?n.newTab:void 0;if(t.navigate){t.navigate({url:n.url,...i!==void 0&&{newTab:i}});return}(a.defaultNavigate??go)(n.url,i);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){gt(n,t,a,r);return}t.saveSession?.({sessionId:n.sessionId,sku:n.sku});return;case"add_to_cart":if(typeof n.sku!="string"||typeof n.quantity!="number"||typeof n.cartCode!="string"){gt(n,t,a,r);return}t.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){gt(n,t,a,r);return}if(typeof n.name!="string"){gt(n,t,a,r);return}const i=po(n.payload)?n.payload:void 0;t.scriptCall?.({name:n.name,...i!==void 0&&{payload:i}});return}default:gt(n,t,a,r)}}function gt(e,t,a,n){const r=a.unknownActionPolicy??"log-and-ignore";if(r==="delegate"){t.unknown?.(e),t.unknown||n.warn("[gengage] Unknown action received without delegate handler",e);return}if(r==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);n.warn("[gengage] Unknown action ignored",e)}function go(e,t){if(!(typeof window>"u")){if(!we(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}Qa(e,t)}}function po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ct(e){const t=e?.trim();return t||"tr"}function ke(e){const t=globalThis.CSS?.escape;if(typeof t=="function")return t(e);const a=Array.from(e);return a.map((n,r)=>{const i=n.codePointAt(0);return i===void 0?"":i===0?"�":i>=1&&i<=31||i===127||r===0&&i>=48&&i<=57||r===1&&a[0]==="-"&&i>=48&&i<=57?`\\${i.toString(16)} `:r===0&&n==="-"&&a.length===1?"\\-":i>=128||/[A-Za-z0-9_-]/.test(n)?n:`\\${n}`}).join("")}var ho=["image/jpeg","image/png","image/webp"],Fm=5*1024*1024;function uo(e){return ho.includes(e.type)?e.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function en(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function mo(e){const t=[];let a=0,n=!1,r=!1,i=0;for(let o=0;o<e.length;o++){const s=e[o];if(r){r=!1;continue}if(s==="\\"&&n){r=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&a++,s==="}"&&(a--,a===0&&(t.push(e.slice(i,o+1)),i=o+1)))}return t.length>0?t:[e]}function tn(e,t){const a=e.trim();if(!a||a.startsWith(":"))return!1;const n=a.startsWith("data: ")?a.slice(6):a;if(n==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(n);return en(r)?(Ze("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=mo(n);if(r.length>1){for(const i of r)try{const o=JSON.parse(i);if(!en(o))continue;if(t.onEvent(o),o.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function fo(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 a=e.body.getReader(),n=new TextDecoder("utf-8");let r="";const i=t.idleTimeoutMs??6e4,o=Symbol("idle-timeout");let s=!1;try{for(;;){const c=a.read();let l;const g=await(i>0?Promise.race([c.then(v=>(clearTimeout(l),v)),new Promise(v=>{l=setTimeout(()=>v(o),i)})]):c);if(g===o){s=!0,await a.cancel();break}const{done:d,value:p}=g;if(d)break;r+=n.decode(p,{stream:!0});const h=r.split(`
48
48
  `);r=h.pop()??"";for(const v of h)if(tn(v,t))return}if(r.trim()&&tn(r,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||a.releaseLock()}t.onDone?.()}var an=3,bo=(e,t)=>{const a=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!a)return"";const n=t?.stripLeadingStopWords?a.replace(/^(?:daha|için)\s+/i,"").trim():a;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},la=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>bo(a,t)).filter(Boolean):[];function vo(e){const t=(e.display_keywords??[]).flatMap(r=>la(r,{stripLeadingStopWords:!0})),a=t.filter((r,i)=>t.indexOf(r)===i);if(a.length>0)return a.slice(0,an);const n=[...la(e.chosen_attribute,{stripLeadingStopWords:!0}),...la(e.short_name)];return n.filter((r,i)=>n.indexOf(r)===i).slice(0,an)}function yo(e){return vo(e).join(" • ")}var xo=["beauty_consulting","watch_expert"];function nn(e){return typeof e=="string"&&xo.includes(e)}function ga(...e){for(const t of e){if(typeof t!="string")continue;const a=t.trim();if(a.length>0)return a}}function da(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function Rt(e){const t={...e},a=ga(t.sku),n=da(t.group_skus);if(a?t.sku=a:delete t.sku,n.length>0?t.group_skus=n:delete t.group_skus,a||n.length>0)delete t.image_url;else{const r=ga(t.image_url);r?t.image_url=r:delete t.image_url}return t}function _o(e){if(typeof e.type!="string")return null;if(wo(e))return e;const t=e;switch(t.type){case"outputText":return ko(t);case"suggestedActions":return Co(t);case"productList":return So(t);case"productDetails":return Eo(t);case"productDetailsSimilars":return Po(t);case"comparisonTable":return To(t);case"context":return No(t);case"chatStreamEnd":return zo();case"loading":return Mo(t);case"panelLoading":return Bo(t);case"similarLoading":return Ro(t);case"redirect":return Oo(t);case"error":return Do(t);case"dummy":return Fo(t);case"launcherAction":return Ho(t);case"text":return pa(t);case"productItem":return $o(t);case"text_image":return rn(t);case"quick_qna":return on(t);case"reviewHighlights":return Uo(t);case"aiProductSuggestions":return Vo(t);case"aiProductGroupings":return qo(t);case"aiSuggestedSearches":return Wo(t);case"prosAndCons":return jo(t);case"getGroundingReview":return Ko(t);case"voice":return Jo(t);case"visitorDataResponse":return Zo(t);case"productListPreview":return Yo();case"groupList":return Xo(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Qo(t);case"launcherContent":return ts(t);case"handoff":return es(t);case"uiSpec":return ls(t);default:return null}}function wo(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 a=e.widget;if(a!=="chat"&&a!=="qna"&&a!=="simrel")return!1;const n=Ce(e.spec);return n?typeof n.root=="string"&&Ce(n.elements)!==null:!1}case"action":{const a=Ce(e.action);return a!==null&&typeof a.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function ko(e){const t=ae(e.payload.text,e.payload.plain_text)??"",a=ae(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:a||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},r=e.payload.product_mentions;Array.isArray(r)&&r.length>0&&(n.productMentions=r.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const o=e.payload.conversation_mode;typeof o=="string"&&o&&(n.conversationMode=o);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function Co(e){return sn((e.payload.actions??[]).map(t=>{const a=ae(t.title)??"",n=Me(t.requestDetails,a),r=n?{label:a,action:n}:null;return r?(typeof t.icon=="string"&&(r.icon=t.icon),typeof t.image=="string"&&(r.image=t.image),r):null}).filter(Et),"chat")}function So(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(o=>{const s=ae(o.style_label);if(!s)return null;const c=ae(o.style_mood),l=ae(o.image_url??void 0),g=(Array.isArray(o.product_list)?o.product_list:[]).map(p=>{const h=Ce(p);return h?ha(Ce(h.product_detail)??Ce(h.product)??h):null}).filter(Et),d=Array.isArray(o.recommendation_groups)?o.recommendation_groups.map(p=>({label:ae(p.label)??"",reason:ae(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(h=>typeof h=="string"&&h.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...l?{image_url:l}:{},...typeof o.status=="string"?{status:o.status}:{},product_list:g,recommendation_groups:d}}).filter(Et),a=e.payload.product_list??[],n=nn(e.payload.source)&&t.length>0?t[0].product_list:null,r=n?as(n,"chat"):cn(a,"chat");r.panelHint="panel";const i=r.spec.elements[r.spec.root];if(i){const o={};typeof e.payload.offset=="number"&&(o.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(o.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(o.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(o.source=e.payload.source),t.length>0&&(o.styleVariations=t),e.payload.replace_panel===!0&&(o.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(o.rankingState=e.payload.ranking_state);const s=e.payload.sequence_id??e.payload.search_id;typeof s=="string"&&s.length>0&&(o.sequenceId=s),Object.keys(o).length>0&&(i.props={...i.props,...o})}return r}function Eo(e){const t=e.payload.productDetails;if(!t)return rs("chat");const a=dt(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...a}}}}},panelHint:"panel"}}function Po(e){const t=cn(e.payload.similarProducts??[],"chat"),a=t.spec.elements[t.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function To(e){const t=e.payload.multiple_product_details??[],a=e.payload,n={key_differences:a.key_differences,recommended_choice:a.recommended_choice,recommended_choice_sku:a.recommended_choice_sku,special_considerations:a.special_considerations,criteria_view:a.criteria_view,criteria_view_short:a.criteria_view_short,compared_field_names:a.compared_field_names,winner_product:a.winner_product,winner_hits:a.winner_hits,...e.payload.product_comparison_framework??{}},r=e.payload.table,i=e.payload.features_list,o=[];for(const f of t){const u=dt(f);o.push(u)}const s=Ao(r,o,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const l=c?o.find(f=>f.sku===c)??o[0]:o[0],g=[];if(Array.isArray(n?.key_differences))for(const f of n.key_differences)typeof f=="string"&&g.push(f);const d=ss(n?.special_considerations),p=n?.recommended_choice,h=n?.winner_hits,v={};for(const f of o){const u=f.sku;u&&(v[u]={title:f.name??u,type:"launchSingleProduct",payload:{sku:u}})}const m={products:o,attributes:s,highlights:g,productActions:v};return l&&(m.recommended=l),d.length>0&&(m.specialCases=d),p&&(m.recommendedText=p),h&&(m.winnerHits=h),typeof n?.key_differences=="string"&&(m.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(m.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function Ao(e,t,a,n){if(!e)return[];const r=Object.entries(e);if(r.length===0)return[];const i=r[0]?.[1];if(Array.isArray(i)){const d=a.criteria_view??a.criteria_view_short??{},p=a.compared_field_names??Object.keys(e),h=[];for(const v of p){const m=e[v];if(!m||!Array.isArray(m))continue;const f=d[v]??v;h.push({label:f,values:m.map(u=>typeof u=="string"?u:String(u??""))})}return h}const o=e,s=t.map(d=>String(d.sku??"")).filter(d=>d.length>0),c=a.criteria_view??a.criteria_view_short??{},l=(n&&n.length>0?n:a.compared_field_names&&a.compared_field_names.length>0?a.compared_field_names:Lo(o)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),g=[];for(const d of l){const p=s.map(v=>{const m=o[v];if(!m||typeof m!="object")return"";const f=m[`${d}_short`],u=m[d];return Io(f??u)});if(p.every(v=>v.length===0))continue;const h=c[d]??d;g.push({label:h,values:p})}return g}function Lo(e){const t=[],a=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const r of Object.keys(n))a.has(r)||(a.add(r),t.push(r));return t}function Io(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function No(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function zo(){return{type:"done"}}function Mo(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 Bo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Ro(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Oo(e){const t=ae(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:ae(e.payload.to)}}}function Do(e){return{type:"error",code:"BACKEND_ERROR",message:ae(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Fo(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Ho(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const r={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,o=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(r.type=i),o!==void 0&&(r.theme=o),on({type:"quick_qna",payload:r})}const a=Ce(t.action);if(a){const r={action:a},i=typeof t.text=="string"?t.text:void 0,o=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(r.text=i),o!==void 0&&(r.image_url=o),s!==void 0&&(r.theme=s),rn({type:"text_image",payload:r})}const n=typeof t.text=="string"?t.text:"";if(n){const r={text:n},i=typeof t.type=="string"?t.type:void 0,o=typeof t.theme=="string"?t.theme:void 0,s=Ce(t.payload)??void 0;return i!==void 0&&(r.type=i),s!==void 0&&(r.payload=s),o!==void 0&&(r.theme=o),pa({type:"text",payload:r})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function pa(e){const t={text:ae(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 $o(e){return ns(e.payload,"qna")}function rn(e){const t=ae(e.payload.text)??"",a=Me(e.payload.action,t);if(a){const r={label:t||a.title,action:a};return typeof e.payload.image_url=="string"&&(r.image=e.payload.image_url),typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:r}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),pa({type:"text",payload:n})}function on(e){return sn((e.payload.action_list??[]).map(t=>{const a=ae(t.title)??"",n=Me(t.requestDetails,a),r=n?{label:a,action:n}:null;return r?(typeof t.icon=="string"&&(r.icon=t.icon),typeof t.image=="string"&&(r.image=t.image),r):null}).filter(Et),"qna")}function Uo(e){const t={reviews:(e.payload.reviews??[]).map(a=>{const n={};return typeof a.review_class=="string"&&(n.review_class=a.review_class),typeof a.review_text=="string"&&(n.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(n.review_rating=a.review_rating),typeof a.review_tag=="string"&&(n.review_tag=a.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function jo(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 Zo(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Vo(e){const t=e.payload.product_suggestions??[],a=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r)continue;const i=is(r);if(!i)continue;const o={product:i},s=Me(r.requestDetails,i.name);s&&(o.action=s),typeof r.role=="string"&&(o.role=r.role),typeof r.reason=="string"&&(o.reason=r.reason),typeof r.review_highlight=="string"&&(o.reviewHighlight=r.review_highlight),Array.isArray(r.labels)&&(o.labels=r.labels),typeof r.expert_quality_score=="number"&&(o.expertQualityScore=r.expert_quality_score),a.push(o)}return a.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:a}}}}}}function qo(e){const t=e.payload.product_groupings??[],a=[],n=[];for(let r=0;r<t.length;r++){const i=t[r];if(!i)continue;const o=ae(i.name)??"",s=ae(i.sku,i.repr_sku),c=ae(i.image,i.repr_image),l=Go(i,o,s),g=(Array.isArray(i.group_products)?i.group_products:[]).map(h=>{const v=Ce(h);return v?ha(v):null}).filter(Et),d=c??ae(...g.map(h=>h.imageUrl));if(o&&g.length>0){const h={groupName:o,products:g};d&&(h.image=d),a.push(h)}if(!l)continue;const p={name:o,action:l};if(Array.isArray(i.labels)){const h=i.labels.filter(v=>typeof v=="string");h.length>0&&(p.labels=h)}c!==void 0&&(p.image=c),n.push(p)}return a.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:a}}}},panelHint:"panel"}: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,t,a){const n=Ce(e.requestDetails);if(n){if(n.type!=="findSimilar")return Me(n,t);const o={...Ce(n.payload)??{}};a&&!ga(o.sku)&&(o.sku=a);const s=da(e.group_skus);return s.length>0&&(o.group_skus=s),Me({...n,payload:Rt(o)},t)}const r={};a&&(r.sku=a);const i=da(e.group_skus);return i.length>0&&(r.group_skus=i),Object.keys(r).length===0?null:Me({type:"findSimilar",payload:Rt(r)},t)}function Wo(e){const t=e.payload.suggested_searches??[],a=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r)continue;const i=ae(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${n+1}`,o={},s=ae(r.detailed_user_message);s&&(o.text=s);const c=Ce(Ce(r.requestDetails)?.payload),l=c?.group_skus;r.group_skus&&Array.isArray(r.group_skus)?o.group_skus=r.group_skus:Array.isArray(l)&&(o.group_skus=l.filter(u=>typeof u=="string"));const g=ae(r.sku,r.representative_product_sku,c?.sku);g&&(o.sku=g),o.is_suggested_text=1;const d={type:"inputText",payload:o},p=Me(r.requestDetails,i),h=p?.type==="findSimilar"&&typeof o.text=="string"?Me(d,i):p??Me(d,i);if(!h)continue;const v={shortName:i,action:h},m=ae(r.detailed_user_message);m&&m!==i&&(v.detailedMessage=m);const f=yo(r);f&&f!==i&&f!==(m??"")&&(v.whyDifferent=f),typeof r.image=="string"&&(v.image=r.image),a.push(v)}return a.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:a}}}}}}function Ko(e){const t=e.payload,a=Me(t.requestDetails??t.request_details,ae(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!a)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:a};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function Yo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Jo(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Xo(e){const t=e.payload.group_list??[],a=[];for(const r of t){const i=r.group_name??"",o=(r.product_list??[]).map(dt);a.push({groupName:i,products:o})}const n=[];for(const r of e.payload.filter_tags??[]){const i=r.title??"";if(!i)continue;const o=Me(r.requestDetails,i),s={title:i};o&&(s.action=o),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:a,filterTags:n}}}},panelHint:"panel"}}function Qo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function es(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 ts(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function sn(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=`action-${r}`;n.push(o);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),a[o]={type:"ActionButton",props:s}}return a.root={type:"ActionButtons",props:{buttons:e.map(r=>{const i={label:r.label,action:r.action};return r.image!==void 0&&(i.image=r.image),r.description!==void 0&&(i.description=r.description),r.icon!==void 0&&(i.icon=r.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function cn(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=dt(i),s=`product-${r}`;n.push(s);const c={product:o,index:r};o.sku&&(c.action={title:o.name,type:"launchSingleProduct",payload:{sku:o.sku}}),a[s]={type:"ProductCard",props:c}}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function as(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=`product-${r}`;n.push(o);const s={product:i,index:r},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),a[o]={type:"ProductCard",props:s}}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function ns(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:dt(e),index:0}}}}}}function rs(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function is(e){const t=ae(e.sku),a=ae(e.short_name),n={...Ce(e.product_item)??e},r=ae(e.discount_reason,e.discountReason);return r&&!ae(n.discount_reason,n.discountReason)&&(n.discount_reason=r),ha(n,t,a)}function ha(e,t,a){const n=ae(e.sku,t),r=ae(e.name,a);if(!n||!r)return null;const i={sku:n,name:r},o=ae(e.brand);o&&(i.brand=o);const s=ae(e.url);s&&(i.url=s);const c=os(e.images);if(c.length>0)i.images=c;else{const m=ae(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const l=St(e.price_discounted);l!==void 0&&(i.price_discounted=l);const g=St(e.price);g!==void 0&&(i.price=g);const d=St(e.rating);d!==void 0&&(i.rating=d);const p=St(e.review_count)??St(e.reviewCount);p!==void 0&&(i.review_count=p);const h=ae(e.cart_code,e.cartCode);h&&(i.cart_code=h),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const v=ae(e.discount_reason,e.discountReason);return v&&(i.discount_reason=v),dt(i)}function Me(e,t){const a=Ce(e);if(!a)return null;const n=a.type;if(typeof n!="string"||n.length===0)return null;const r={title:t||n,type:n};return a.payload!==void 0&&(r.payload=a.payload),r}function Ce(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function ae(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function os(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ss(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function St(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 a=Number(t);if(Number.isFinite(a))return a}}function Et(e){return e!=null}var cs=new Set(["sku","name","brand","images","price","price_discounted","price_discount_rate","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","description","description_html","features","specifications","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function dt(e){const t=e.price_discounted!=null&&e.price_discounted>0,a=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let r;n!=null&&a!=null&&n>0?r=Math.round((n-a)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(r=e.price_discount_rate);const i=ae(e.brand),o=ae(e.name)??e.sku,s=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,c={sku:e.sku,name:s,url:ae(e.url)??""},l=e.images?.[0];l&&(c.imageUrl=l),e.images&&e.images.length>1&&(c.images=e.images),a!=null&&a>0&&(c.price=String(a)),n!=null&&n>0&&(c.originalPrice=String(n)),r!==void 0&&(c.discountPercent=r),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.category_names&&e.category_names.length>0&&(c.categoryNames=e.category_names),e.short_name!==void 0&&(c.shortName=e.short_name);const g=e,d={};let p=!1;for(const h of Object.keys(g))cs.has(h)||(d[h]=g[h],p=!0);return p&&(c.extras=d),c}function ls(e){const t=e.payload.type,{type:a,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}var gs={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function ds(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 ps(e,t){return`${ds(t?.middlewareUrl)}/chat${gs[e]}`}function hs(e,t){const a=e.type,n=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},r=i=>{const o={...n};for(const[s,c]of Object.entries(i))s in o||(o[s]=c);return o};switch(a){case"user_message":case"inputText":{const i=typeof e.payload=="string",o=i?{text:e.payload}:e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:n,s={is_launcher:0};if(t.pageContext?.extra&&(s.page_details=t.pageContext.extra),!i&&!("sku_list"in o)){const l=t.pageContext?.skuList&&t.pageContext.skuList.length>0?t.pageContext.skuList:t.pageContext?.sku?[t.pageContext.sku]:void 0;l&&l.length>0&&(s.sku_list=l)}"is_suggested_text"in o||(s.is_suggested_text=0);const c={...o};for(const[l,g]of Object.entries(s))l in c||(c[l]=g);return{...e,payload:c}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title,i.input=e.title),{...e,payload:Rt(r(i))}}case"getComparisonTable":{const i=e.payload;if(i&&typeof i=="object"&&!Array.isArray(i)&&"gengage_analytics_source"in i){const o={...i};return delete o.gengage_analytics_source,{...e,payload:o}}return e}case"launchProductList":return e;case"launchHomepage":return e;case"addToCart":{const i={};return"error_message"in n||(i.error_message=""),{...e,payload:r(i)}}case"reviewSummary":{const i={};return t.pageContext?.sku&&!("sku"in n)&&(i.sku=t.pageContext.sku),Object.keys(i).length===0?e:{...e,payload:r(i)}}default:return e}}var us={user_message:"inputText"};function ms(e){const{action:t,type:a,payload:n,...r}=e,i=a??t?.type??"inputText",o=n??t?.payload,s=us[i]??i,c={...r,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function fs(e,t,a){const n=ps("process_action",a),r=new AbortController;return(async()=>{try{const o=ms(e),s=a.attachment!==void 0;let c;if(s){const p=new FormData;p.append("request",o),a.attachment!==void 0&&p.append("attachment",a.attachment),c={method:"POST",body:p,signal:r.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:o,signal:r.signal};const l=await fetch(n,c);if(!l.ok){let p=l.statusText;try{const h=await l.json(),v=h.detail??h.message??h.error;typeof v=="string"&&(p=v)}catch{}t.onError(new Error(`HTTP ${l.status}: ${p}`));return}let g=!1;const d=()=>{g||(g=!0,t.onDone())};await fo(l,{onEvent:p=>{const h=_o(p);if(h&&!(g&&h.type!=="error"))switch(h.type){case"text_chunk":t.onTextChunk(h.content,h.final===!0,{productMentions:h.productMentions,skuToProductItem:h.skuToProductItem,conversationMode:h.conversationMode,renderHint:h.renderHint,kvkk:h.kvkk});break;case"ui_spec":t.onUISpec(h.spec,h.widget,h.panelHint,h.clearPanel===!0);break;case"action":t.onAction(h);break;case"metadata":t.onMetadata(h);break;case"error":t.onError(new Error(h.message));break;case"done":d();break}},onError:t.onError,signal:r.signal}),d()}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;t.onError(o instanceof Error?o:new Error(String(o)))}})(),r}var bs=["chat_debug","presentation_debug"],vs=["gengage_chat_debug","gengage_presentation_debug"];function ys(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(bs.some(t=>e.get(t)==="1"))return!0;try{return vs.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function xs(e,t,a){if(!ys())return;const n=(window.__gengageChatPresentationDebugSeq??0)+1;window.__gengageChatPresentationDebugSeq=n;const r={seq:n,time:new Date().toISOString(),scope:e,message:t,payload:a};window.__gengageChatPresentationDebugLog||(window.__gengageChatPresentationDebugLog=[]),window.__gengageChatPresentationDebugLog.push(r),window.__gengageChatPresentationDebugLog.length>400&&window.__gengageChatPresentationDebugLog.shift();const i=`[gengage-chat-debug #${n}][${e}] ${t}`;a===void 0?console.debug(i):console.debug(i,a)}var Ot="gengage-chat-scroll",pt=null;function ln(e){pt=e}function _s(){if(pt&&pt.isConnected)return pt;pt=null;const e=document.getElementById(Ot);return e||(xs("chat-scroll","failed to resolve scroll container (not registered)",{id:Ot}),null)}function gn(){pt=null}var ht={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Gengage ile",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"İsteğinizi inceliyorum...",loadingSequenceGeneric:["İsteğinizi inceliyorum...","Ürün ve yorumlara bakıyorum...","Detayları inceliyorum..."],loadingSequencePanel:["En ilgili detayları inceliyorum","En güçlü sinyalleri kontrol ediyorum","Bu görünümü sizin için hazırlıyorum"],loadingSequenceComparison:["Ürün farklarını inceliyorum","En güçlü farkları ve ödünleşimleri kontrol ediyorum","Karşılaştırmayı sizin için hazırlıyorum"],productCtaLabel:"Satın Al",viewOnSiteLabel:"Sitede Gör",attachImageButton:"Resim ekle",attachMenuSelectPhoto:"Fotoğraf Seç",attachMenuPaste:"Yapıştır",clipboardNoImageMessage:"Panoda görsel bulunamadı. Önce bir görsel kopyalayın veya dosya seçin.",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:"Size Özel Seçimim",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 düşükten yükseğe",sortPriceDesc:"Fiyat yüksekten düşüğe",sortToolbarAriaLabel:"Ürünleri sırala",compareSelected:"Karşılaştır",compareMinHint:"En az 2 ürün seçin",compareMaxHint:"En fazla 5 ürün seçebilirsiniz",comparisonSelectLabel:"Karşılaştırmak için seç",comparisonSelectedLabel:"Seçildi",comparisonSelectCardHint:"Karşılaştırmaya eklemek veya çıkarmak için kartın herhangi bir yerine dokunun.",comparisonPreparingLabel:"Karşılaştırma tablosu hazırlanıyor…",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",panelTitleSearchResults:"Arama Sonuçları",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",galleryPrevAriaLabel:"Önceki görsel",galleryNextAriaLabel:"Sonraki görsel",beautyStylesPreparedTitle:"Sizin için {count} farklı stil hazırladım",watchStylesPreparedTitle:"Sizin için {count} farklı stil yönü hazırladım",consultingOtherCompatibleProductsLabel:"Diğer Uyumlu Ürünler",consultingFallbackGroupLabel:"Öneri",consultingFallbackStyleLabel:"Stil {index}",consultingStyleLoadingDescription:"Bu stil için ürünleri toplamaya devam ediyorum. Panel kısa süre içinde yenilenir.",consultingStyleUnavailableDescription:"Bu stil için şu anda yeterli ürün eşleşmesi çıkaramadım. Diğer stilleri inceleyebilirsiniz.",consultingStyleLoadingBadge:"Yükleniyor",consultingStyleUnavailableBadge:"Hazır değil",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",addedToCartToast:"Sepete eklendi",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor",productNotFoundMessage:"Bu ürün bilgisi şu an kullanılamıyor. Başka bir konuda yardımcı olabilirim.",stopGenerating:"Yanıtı Durdur",offlineMessage:"Çevrimdışısınız — bağlantı kurulduğunda mesajlar gönderilecek.",cartAriaLabel:"Sepetim",favoritesAriaLabel:"Favorilerim",historyAriaLabel:"Sohbet geçmişi",historyPageTitle:"Sohbet Geçmişi",emptyHistoryMessage:"Henüz kaydedilmiş sohbet yok.",historyDeleteLabel:"Sohbeti sil",historyDeleteConfirmMessage:"Bu sohbet geçmişten silinsin mi? Bu işlem geri alınamaz.",showPanelAriaLabel:"Sonuçları Göster",addToFavoritesLabel:"Favorilere ekle",customerReviewsTitle:"Müşteri Yorumları",togglePanelAriaLabel:"Paneli aç/kapat",chatMessagesAriaLabel:"Sohbet mesajları",suggestionsAriaLabel:"Öneriler",moreSuggestionsAriaLabel:"Daha fazla öneri",rollbackAriaLabel:"Bu mesaja geri dön",backAriaLabel:"Geri",forwardAriaLabel:"İleri",closePanelAriaLabel:"Paneli kapat",dismissAriaLabel:"Kapat",cartAddErrorMessage:"Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.",favoriteToggleErrorMessage:"Favoriler güncellenemedi. Lütfen tekrar deneyin.",reviewFilterPositive:"Olumlu",reviewFilterNegative:"Olumsuz",decreaseLabel:"Azalt",increaseLabel:"Artır",reviewCustomersMentionSingular:"1 müşteri bahsediyor",reviewCustomersMentionPlural:"müşteri bahsediyor",reviewSubjectsHeading:"İncelemek için seçin",tryAgainButton:"Tekrar dene",askSomethingElseButton:"Başka bir şey sor",accountInactiveMessage:"Bu hesap şu an aktif değil. Lütfen daha sonra tekrar deneyin.",favoritesPageTitle:"Favorilerim",emptyFavoritesMessage:"Henüz favori ürün yok. Bir ürünü kalp ikonuna tıklayarak favorilere ekleyebilirsin.",showFormerMessagesButton:"↑ Önceki mesajları göster",aiAnalysisAnalyzingLabel:"Ürünler analiz ediliyor...",aiBrowseCategoriesTitle:"Kategorilere Göz At",photoAnalysisBadge:"Cilt Analizi",photoAnalysisStrengthsLabel:"Öne Çıkanlar",photoAnalysisFocusLabel:"Odak Noktaları",photoAnalysisCelebStyleLabel:"Celeb Vibe Eşleşmesi",beautyPhotoStepTitle:"Selfie ile kişiselleştir",beautyPhotoStepDescription:"İstersen net bir profil fotoğrafı yükle, sana özel önerilerde bulunayım.",beautyPhotoStepUpload:"Fotoğraf Yükle",beautyPhotoStepProcessing:"Fotoğraf işleniyor...",beautyPhotoStepSkip:"Geç",beautyPhotoStepSkipMessage:"Fotoğraf adımını geçiyorum"},ws={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:"Reviewing your request...",loadingSequenceGeneric:["Reviewing your request...","Looking through products and reviews...","Reviewing the details..."],loadingSequencePanel:["Reviewing the most relevant details","Checking the strongest signals","Preparing this view for you"],loadingSequenceComparison:["Reviewing the product differences","Checking the strongest tradeoffs","Preparing your comparison"],productCtaLabel:"Buy",viewOnSiteLabel:"View on Site",attachImageButton:"Attach image",attachMenuSelectPhoto:"Choose photo",attachMenuPaste:"Paste",clipboardNoImageMessage:"No image found in clipboard. Copy an image first or choose a file.",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:"Recommended",sortPriceAsc:"Price low to high",sortPriceDesc:"Price high to low",sortToolbarAriaLabel:"Sort products",compareSelected:"Compare",compareMinHint:"Select at least 2 products",compareMaxHint:"You can select up to 5 products",comparisonSelectLabel:"Select to compare",comparisonSelectedLabel:"Selected",comparisonSelectCardHint:"Tap anywhere on the card to add or remove it from comparison.",comparisonPreparingLabel:"Preparing your comparison…",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",panelTitleSearchResults:"Search Results",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",galleryPrevAriaLabel:"Previous image",galleryNextAriaLabel:"Next image",beautyStylesPreparedTitle:"Prepared {count} beauty styles for you",watchStylesPreparedTitle:"Prepared {count} style directions for you",consultingOtherCompatibleProductsLabel:"Other compatible products",consultingFallbackGroupLabel:"Recommendation",consultingFallbackStyleLabel:"Style {index}",consultingStyleLoadingDescription:"I am still collecting products for this style. The panel will refresh shortly.",consultingStyleUnavailableDescription:"I could not find enough product matches for this style yet. You can review the other styles.",consultingStyleLoadingBadge:"Loading",consultingStyleUnavailableBadge:"Not ready",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",addedToCartToast:"Added to cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent",productNotFoundMessage:"Product information is currently unavailable. I can help with something else.",stopGenerating:"Stop generating",offlineMessage:"You're offline — messages will send when you reconnect.",cartAriaLabel:"My cart",favoritesAriaLabel:"My favorites",historyAriaLabel:"Chat history",historyPageTitle:"Chat History",emptyHistoryMessage:"You don't have any saved chats yet.",historyDeleteLabel:"Delete chat",historyDeleteConfirmMessage:"Delete this chat from history? This cannot be undone.",showPanelAriaLabel:"Show Results",addToFavoritesLabel:"Add to favorites",customerReviewsTitle:"Customer Reviews",togglePanelAriaLabel:"Toggle panel",chatMessagesAriaLabel:"Chat messages",suggestionsAriaLabel:"Suggestions",moreSuggestionsAriaLabel:"More suggestions",rollbackAriaLabel:"Rollback to this message",backAriaLabel:"Back",forwardAriaLabel:"Forward",closePanelAriaLabel:"Close panel",dismissAriaLabel:"Dismiss",cartAddErrorMessage:"Sorry, I couldn't add that to your cart. Something went wrong.",favoriteToggleErrorMessage:"We couldn't update favorites. Please try again.",reviewFilterPositive:"Positive",reviewFilterNegative:"Negative",decreaseLabel:"Decrease",increaseLabel:"Increase",reviewCustomersMentionSingular:"1 customer mentions",reviewCustomersMentionPlural:"customers mention",reviewSubjectsHeading:"Select to learn more",tryAgainButton:"Try again",askSomethingElseButton:"Ask something else",accountInactiveMessage:"This account is currently inactive. Please try again later.",favoritesPageTitle:"My Favorites",emptyFavoritesMessage:"No favorites yet. Heart a product to save it here.",showFormerMessagesButton:"↑ Show earlier messages",aiAnalysisAnalyzingLabel:"Analyzing products...",aiBrowseCategoriesTitle:"Browse categories",photoAnalysisBadge:"Skin Analysis",photoAnalysisStrengthsLabel:"Your strengths",photoAnalysisFocusLabel:"Focus points",photoAnalysisCelebStyleLabel:"Celeb style match",beautyPhotoStepTitle:"Personalize with a selfie",beautyPhotoStepDescription:"Upload a clear profile photo so I can give you personalized recommendations.",beautyPhotoStepUpload:"Upload Photo",beautyPhotoStepProcessing:"Processing photo...",beautyPhotoStepSkip:"Skip",beautyPhotoStepSkipMessage:"Skip the photo step"};function ks(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Cs(e){return ks(e)==="en"?ws:ht}function Ss(){return dn()!==null}function dn(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var Es=class{constructor(e,t){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this._lastRestartAt=0,this.callbacks=e,this.lang=t?.lang??"tr-TR",this.silenceTimeoutMs=t?.silenceTimeoutMs??1500,this.autoSubmit=t?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const e=dn();if(!e){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 t=new e;t.continuous=!0,t.interimResults=!0,t.lang=this.lang,t.maxAlternatives=1,t.onstart=()=>{this.setState("listening")},t.onresult=a=>{this.clearSilenceTimer();let n="",r="";for(let i=a.resultIndex;i<a.results.length;i++){const o=a.results[i];if(!o)continue;const s=o[0];s&&(o.isFinal?r+=s.transcript:n+=s.transcript)}r&&(this.accumulatedTranscript+=r,this.callbacks.onFinal?.(this.accumulatedTranscript)),n&&this.callbacks.onInterim?.(this.accumulatedTranscript+n),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},t.onerror=a=>{const n=Ps(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(n,a.message||a.error))},t.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){const a=Date.now();if(a-this._lastRestartAt<500){this.setState("idle");return}this._lastRestartAt=a;try{t.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=t;try{t.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(e){this._state!==e&&(this._state=e,this.callbacks.onStateChange?.(e))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const e=this.stop();e.trim()&&this.callbacks.onAutoSubmit?.(e.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}};function Ps(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 Ts(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner gds-evidence-card gds-evidence-card-warning",t.dataset.gengagePart="kvkk-banner",t.setAttribute("role","alert");const a=document.createElement("div");a.className="gengage-chat-kvkk-content",a.dataset.gengagePart="kvkk-content",a.innerHTML=Ee(e.htmlContent),t.appendChild(a);const n=document.createElement("button");return n.className="gengage-chat-kvkk-dismiss",n.dataset.gengagePart="kvkk-dismiss",n.type="button",n.setAttribute("aria-label",e.closeAriaLabel??"Close privacy notice"),n.textContent="×",n.addEventListener("click",e.onDismiss),t.appendChild(n),t}var As=class{constructor(e){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar gds-toolbar",this._el.dataset.gengagePart="panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back gds-btn gds-btn-ghost gds-icon-btn",this._backBtn.dataset.gengagePart="panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label",e.backAriaLabel??"Back"),this._backBtn.title=e.backAriaLabel??"Back",this._backBtn.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/><path d="M21 12H9"/></svg>',this._backBtn.addEventListener("click",()=>e.onBack());const t=document.createElement("div");t.className="gengage-chat-panel-topbar-title-wrap",this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._titleEl.dataset.gengagePart="panel-topbar-title",t.appendChild(this._titleEl),this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward gds-btn gds-btn-ghost gds-icon-btn",this._forwardBtn.dataset.gengagePart="panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label",e.forwardAriaLabel??"Forward"),this._forwardBtn.title=e.forwardAriaLabel??"Forward",this._forwardBtn.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/><path d="M3 12h12"/></svg>',this._forwardBtn.addEventListener("click",()=>e.onForward()),this._actionsEl=document.createElement("div"),this._actionsEl.className="gengage-chat-panel-topbar-actions",this._actionsEl.dataset.gengagePart="panel-topbar-actions",this._closeBtn=document.createElement("button"),this._closeBtn.className="gengage-chat-panel-topbar-close gds-btn gds-btn-ghost gds-icon-btn",this._closeBtn.dataset.gengagePart="panel-topbar-close",this._closeBtn.type="button",this._closeBtn.setAttribute("aria-label",e.closePanelAriaLabel??"Close panel"),this._closeBtn.title=e.closePanelAriaLabel??"Close panel",this._closeBtn.innerHTML='<svg width="14" height="14" 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>',this._closeBtn.addEventListener("click",()=>e.onClose?.()),this._el.appendChild(this._backBtn),this._el.appendChild(t),this._el.appendChild(this._actionsEl),this._el.appendChild(this._forwardBtn),this._el.appendChild(this._closeBtn)}update(e,t,a){this._backBtn.disabled=!e,this._forwardBtn.disabled=!t,this._backBtn.hidden=!e,this._forwardBtn.hidden=!t,this._titleEl.textContent=a,this._titleEl.title=a}getElement(){return this._el}setTitle(e){this._titleEl.textContent=e}setActions(e){this._actionsEl.replaceChildren(),e&&this._actionsEl.appendChild(e)}getTitle(){return this._titleEl.textContent??""}};function Ls(e){return{processing:e.processing===!0,title:typeof e.title=="string"?e.title:void 0,description:typeof e.description=="string"?e.description:void 0,uploadLabel:typeof e.upload_label=="string"?e.upload_label:void 0,skipLabel:typeof e.skip_label=="string"?e.skip_label:void 0}}function pn(e,t,a){const n=e.props??{},r=n.processing===!0,i={...ht,...t.i18n??{}},o=document.createElement("div");o.className="gengage-chat-beauty-photo-step-card";const s=document.createElement("span");s.className="gengage-chat-beauty-photo-step-icon",s.setAttribute("aria-hidden","true"),s.textContent="✦";const c=document.createElement("div");c.className="gengage-chat-beauty-photo-step-content";const l=document.createElement("div");l.className="gengage-chat-beauty-photo-step-title",l.textContent=(typeof n.title=="string"?n.title:void 0)??i.beautyPhotoStepTitle;const g=document.createElement("p");g.className="gengage-chat-beauty-photo-step-desc",g.textContent=(typeof n.description=="string"?n.description:void 0)??i.beautyPhotoStepDescription;const d=document.createElement("div");d.className="gengage-chat-beauty-photo-step-actions";const p=document.createElement("button");p.type="button",p.className="gengage-chat-beauty-photo-step-upload gds-btn gds-btn-primary",p.textContent=r?i.beautyPhotoStepProcessing:(typeof n.upload_label=="string"?n.upload_label:void 0)??i.beautyPhotoStepUpload,p.disabled=r,a?.onUpload&&p.addEventListener("click",()=>a.onUpload());const h=document.createElement("button");return h.type="button",h.className="gengage-chat-beauty-photo-step-skip gds-btn gds-btn-ghost",h.textContent=(typeof n.skip_label=="string"?n.skip_label:void 0)??i.beautyPhotoStepSkip,a?.onSkip&&h.addEventListener("click",()=>a.onSkip()),d.appendChild(p),d.appendChild(h),c.appendChild(l),c.appendChild(g),c.appendChild(d),o.appendChild(s),o.appendChild(c),o}function Is(e,t){if(e)return e;const a=document.createElement("section");a.className="gengage-chat-beauty-photo-step",a.dataset.gengagePart="chat-beauty-photo-step",a.hidden=!0;const n=t?.querySelector(".gengage-chat-input-area");return n?n.parentElement?.insertBefore(a,n):t?.appendChild(a),a}function Ns(e,t,a,n,r){if(!a.visible)return e&&(e.hidden=!0,e.innerHTML=""),e;const i=Is(e,t);i.hidden=!1,i.innerHTML="";const o=pn({type:"BeautyPhotoStep",props:{processing:a.processing??!1,title:a.title,description:a.description,upload_label:a.uploadLabel,skip_label:a.skipLabel}},{i18n:n,onAction:()=>{}},{onUpload:r,onSkip:a.onSkip});return i.appendChild(o),i}function hn(e){const t=typeof e.summary=="string"?e.summary:"",a=Array.isArray(e.strengths)?e.strengths.filter(c=>typeof c=="string"):[],n=Array.isArray(e.focus_points)?e.focus_points.filter(c=>typeof c=="string"):[];if(!t&&a.length===0&&n.length===0)return null;const r={summary:t},i=typeof e.celeb_style=="string"?e.celeb_style:void 0,o=typeof e.celeb_style_reason=="string"?e.celeb_style_reason:void 0,s=typeof e.next_question=="string"?e.next_question:void 0;return a.length>0&&(r.strengths=a),n.length>0&&(r.focusPoints=n),i&&(r.celebStyle=i),o&&(r.celebStyleReason=o),s&&(r.nextQuestion=s),r}function un(e,t,a){if(t.length===0)return null;const n=document.createElement("section");n.className=`gengage-chat-photo-analysis-section ${a}`;const r=document.createElement("h4");r.className="gengage-chat-photo-analysis-section-title",r.textContent=e;const i=document.createElement("ul");i.className="gengage-chat-photo-analysis-section-list";for(const o of t){const s=document.createElement("li");s.className="gengage-chat-photo-analysis-section-item",s.textContent=o,i.appendChild(s)}return n.appendChild(r),n.appendChild(i),n}function mn(e,t){const a=document.createElement("div");a.className="gengage-chat-photo-analysis-card";const n=document.createElement("div");n.className="gengage-chat-photo-analysis-badge",n.textContent=e.badge;const r=document.createElement("div");if(r.className="gengage-chat-photo-analysis-body",t.summary){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-summary",c.textContent=t.summary,r.appendChild(c)}const i=document.createElement("div");i.className="gengage-chat-photo-analysis-highlights";const o=un(e.strengths,t.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=un(e.focus,t.focusPoints??[],"gengage-chat-photo-analysis-section--focus");if(o&&i.appendChild(o),s&&i.appendChild(s),i.childElementCount>0&&r.appendChild(i),t.celebStyle){const c=document.createElement("section");c.className="gengage-chat-photo-analysis-section gengage-chat-photo-analysis-section--celeb";const l=document.createElement("h4");l.className="gengage-chat-photo-analysis-section-title",l.textContent=e.celebStyle;const g=document.createElement("p");if(g.className="gengage-chat-photo-analysis-celeb-name",g.textContent=t.celebStyle,c.appendChild(l),c.appendChild(g),t.celebStyleReason){const d=document.createElement("p");d.className="gengage-chat-photo-analysis-celeb-reason",d.textContent=t.celebStyleReason,c.appendChild(d)}r.appendChild(c)}if(t.nextQuestion){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-next",c.textContent=t.nextQuestion,r.appendChild(c)}return a.appendChild(n),a.appendChild(r),a}function zs(e){const t={...ht,...e?.i18n??{}};return{badge:t.photoAnalysisBadge,strengths:t.photoAnalysisStrengthsLabel,focus:t.photoAnalysisFocusLabel,celebStyle:t.photoAnalysisCelebStyleLabel}}function Ms(e,t){const a=hn(e.props??{})??{summary:""};return mn(zs(t),a)}function Bs(e,t,a){e.innerHTML="",a&&e.appendChild(mn(t,a))}var fn='<svg viewBox="0 0 16 16" class="gengage-chat-icon"><path d="M3 8h10M9 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',bn={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>'},Rs=ht,Os=1400,vn=1500,Ds=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi;async function Fs(e){for(const t of e)for(const a of t.types)if(a.startsWith("image/"))try{const n=await t.getType(a);if(!n||n.size===0)continue;const r=a||n.type||"image/png",i=r==="image/png"?"png":r==="image/webp"?"webp":"jpg",o=`paste-${Date.now()}.${i}`;return new File([n],o,{type:r})}catch{continue}for(const t of e)if(t.types.includes("text/html"))try{const a=(await(await t.getType("text/html")).text()).match(Ds)?.[0];if(!a||a.length>5e6)continue;const n=await(await fetch(a)).blob();if(!n||n.size===0)continue;const r=n.type||"image/png";if(!["image/jpeg","image/png","image/webp"].includes(r))continue;const i=r==="image/png"?"png":r==="image/webp"?"webp":"jpg";return new File([n],`paste-${Date.now()}.${i}`,{type:r})}catch{continue}return null}async function Hs(e){try{const t=e??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return t?Fs(await t):null}catch{}return null}var $s=class{_renderPhotoAnalysisCard(e,t){Bs(e,{badge:this.i18n.photoAnalysisBadge,strengths:this.i18n.photoAnalysisStrengthsLabel,focus:this.i18n.photoAnalysisFocusLabel,celebStyle:this.i18n.photoAnalysisCelebStyleLabel},t)}constructor(e,t){this._sendStopHandler=null,this._panelVisible=!1,this._panelCollapsed=!1,this._onPanelToggle=void 0,this._onHostShellSync=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._favBadgeEl=null,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this._ignoreNextDividerClick=!1,this._cleanups=[],this._focusTrapHandler=null,this._previouslyFocusedElement=null,this._conversationEl=null,this._reopenPanelBtn=null,this._presentationFocusThreadId=null,this._formerMessagesBtn=null,this._programmaticScrollUntil=0,this._userInteractionUntil=0,this._touchStartY=null,this._presentationPinned=!0,this._presentationUserInteracting=!1,this._resizeRafId=null,this._cartBtn=null,this._attachWrapEl=null,this._attachMenuEl=null,this._attachBtn=null,this._attachMenuCleanup=null,this._attachMenuClickTimerId=null,this._typingLoadingBinding=null,this._panelLoadingBinding=null,this._panelAiZoneLoadingBinding=null,this._beautyPhotoStepEl=null,this._options=t,this.i18n={...Rs,...t.i18n},this.onSend=t.onSend,t.onPanelToggle!==void 0&&(this._onPanelToggle=t.onPanelToggle),t.onHostShellSync!==void 0&&(this._onHostShellSync=t.onHostShellSync),t.onAttachment!==void 0&&(this._onAttachment=t.onAttachment),t.onRollback!==void 0&&(this._onRollback=t.onRollback),t.onLinkClick!==void 0&&(this._onLinkClick=t.onLinkClick),t.voiceEnabled&&(this._voiceEnabled=!0),t.voiceLang!==void 0&&(this._voiceLang=t.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer gds-panel",this.root.dataset.gengagePart="chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a="gengage-chat-dialog-desc",n=document.createElement("span");n.id=a,n.className="gengage-sr-only",n.textContent=this.i18n.headerTitle??"AI shopping assistant",this.root.appendChild(n),this.root.setAttribute("aria-describedby",a);let r=null;{const k=document.createElement("div");k.className="gengage-chat-drawer-handle",k.dataset.gengagePart="chat-drawer-handle",k.setAttribute("aria-hidden","true"),k.style.pointerEvents="none",r=k}const i=document.createElement("div");i.className="gengage-chat-header gds-shell-header",i.dataset.gengagePart="chat-header";const o=document.createElement("div");o.className="gengage-chat-header-left",o.dataset.gengagePart="chat-header-left";const s=t.headerAvatarUrl??t.launcherImageUrl,c=typeof t.headerAvatarUrl=="string"&&t.headerAvatarUrl.length>0&&t.headerAvatarUrl!==t.launcherImageUrl;if(s){const k=document.createElement("img");k.className="gengage-chat-header-avatar",c&&k.classList.add("gengage-chat-header-avatar--logo"),k.dataset.gengagePart="chat-header-avatar",k.src=s,k.alt=t.headerTitle??"Assistant",o.appendChild(k)}const l=document.createElement("div");l.className="gengage-chat-header-info",l.dataset.gengagePart="chat-header-info";const g=document.createElement("div");g.className="gengage-chat-header-title-row",g.dataset.gengagePart="chat-header-title-row";const d=document.createElement("span");if(d.className="gengage-chat-header-title",d.dataset.gengagePart="chat-header-title",d.textContent=t.headerTitle??this.i18n.headerTitle??"Product Expert",g.appendChild(d),t.headerBadge){const k=document.createElement("span");k.className="gengage-chat-header-badge gds-badge gds-badge-brand",k.dataset.gengagePart="chat-header-badge",k.textContent=t.headerBadge,g.appendChild(k)}l.appendChild(g);const p=document.createElement("a");p.className="gengage-chat-header-powered",p.dataset.gengagePart="chat-header-powered-by",p.href="https://gengage.ai/",p.target="_blank",p.rel="noopener noreferrer",p.innerHTML=`<svg viewBox="0 0 15 15" fill="none" aria-hidden="true"><path d="M15 5.88941C12.2201 5.88941 9.72762 7.14107 8.05571 9.11059H0C2.77991 9.11059 5.27238 7.85893 6.94429 5.88941H15Z" fill="currentColor"/><path d="M9.10964 0C9.10964 2.24394 8.29524 4.30038 6.94429 5.88941C5.27238 7.85962 2.77922 9.11059 0 9.11059V5.88941C3.24802 5.88941 5.89036 3.2465 5.89036 0H9.10964Z" fill="currentColor" fill-opacity="0.68"/><path d="M15 5.88941V9.11059C11.752 9.11059 9.10964 11.7535 9.10964 15H5.89036C5.89036 12.7561 6.70476 10.6996 8.05571 9.11059C9.72762 7.14038 12.2208 5.88941 15 5.88941Z" fill="currentColor" fill-opacity="0.68"/></svg>${this.i18n.poweredBy}`,l.appendChild(p),o.appendChild(l),i.appendChild(o);const h=document.createElement("div");h.className="gengage-chat-header-right",h.dataset.gengagePart="chat-header-actions";{const k=document.createElement("button");k.type="button",k.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel gds-btn gds-btn-ghost gds-icon-btn",k.dataset.gengagePart="chat-header-reopen-panel",k.setAttribute("aria-label",this.i18n.showPanelAriaLabel),k.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="9" y1="3" x2="9" y2="21"/></svg>',k.addEventListener("click",()=>this._showMobilePanelFromBtn()),h.appendChild(k),this._reopenPanelBtn=k}if(t.headerCartUrl||t.onCartClick){const k=document.createElement("button");k.type="button",k.className="gengage-chat-header-btn gengage-chat-header-btn--cart gds-btn gds-btn-ghost gds-icon-btn",k.dataset.gengagePart="chat-header-cart",k.setAttribute("aria-label",this.i18n.cartAriaLabel),k.title=this.i18n.cartAriaLabel,k.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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>',k.addEventListener("click",()=>t.onCartClick?.()),h.appendChild(k),this._cartBtn=k}if(t.onHistoryClick){const k=document.createElement("button");k.type="button",k.className="gengage-chat-header-btn gengage-chat-header-btn--history gds-btn gds-btn-ghost gds-icon-btn",k.dataset.gengagePart="chat-header-history",k.setAttribute("aria-label",this.i18n.historyAriaLabel),k.title=this.i18n.historyAriaLabel,k.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 8v5l3 2"/><path d="M3.05 11A9 9 0 1 1 5 17.5"/><path d="M3 8v4h4"/></svg>',k.addEventListener("click",()=>t.onHistoryClick?.()),h.appendChild(k)}if(t.onNewChat){const k=document.createElement("button");k.className="gengage-chat-header-btn gengage-chat-new-chat gds-btn gds-btn-ghost gds-icon-btn",k.dataset.gengagePart="chat-header-new-chat",k.type="button",k.setAttribute("aria-label",this.i18n.newChatButton),k.title=this.i18n.newChatButton,k.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="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',k.addEventListener("click",()=>t.onNewChat?.()),h.appendChild(k)}const v=document.createElement("button");if(v.className="gengage-chat-close gds-btn gds-btn-ghost gds-icon-btn",v.dataset.gengagePart="chat-header-close",v.type="button",v.setAttribute("aria-label",this.i18n.closeButton),v.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>',v.addEventListener("click",t.onClose),t.showHeaderFavorites){const k=document.createElement("button");k.className="gengage-chat-header-btn gengage-chat-header-btn--fav gds-btn gds-btn-ghost gds-icon-btn",k.dataset.gengagePart="chat-header-favorites",k.type="button",k.setAttribute("aria-label",this.i18n.favoritesAriaLabel),k.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>';const J=document.createElement("span");J.className="gengage-chat-header-fav-badge",J.dataset.gengagePart="chat-header-favorites-badge",J.setAttribute("aria-hidden","true"),J.style.display="none",k.appendChild(J),this._favBadgeEl=J,k.addEventListener("click",()=>{t.onFavoritesClick?.()}),h.appendChild(k)}h.appendChild(v),r&&i.insertBefore(r,i.firstChild),i.appendChild(h);{let J=0,ce=0,pe=!1;const me=Q=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||Q.target.closest('button, a, input, [role="button"]'))return;const te=Q.changedTouches?.[0];te&&(J=te.clientY,ce=0,pe=!0,this.root.style.transition="none")},Ne=Q=>{if(!pe)return;const te=Q.changedTouches?.[0];if(!te)return;ce=te.clientY-J;const X=(t.getMobileState?.()??"full")==="full"?Math.max(0,ce):ce;Q.preventDefault(),this.root.style.transform=`translateY(${X}px)`},$e=()=>{if(!pe)return;pe=!1;const Q=t.getMobileState?.()??"full";let te;ce>72?te=Q==="full"?"half":"close":ce<-72&&Q==="half"?te="full":te=Q,this.root.style.transition="",te==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",t.onMobileSnap?.("close")},280)):(this.root.style.transform="",t.onMobileSnap?.(te)),ce=0},O=()=>{pe&&(pe=!1,ce=0,this.root.style.transition="",this.root.style.transform="")};i.addEventListener("touchstart",me,{passive:!0}),i.addEventListener("touchmove",Ne,{passive:!1}),i.addEventListener("touchend",$e,{passive:!0}),i.addEventListener("touchcancel",O,{passive:!0}),this._cleanups.push(()=>{i.removeEventListener("touchstart",me),i.removeEventListener("touchmove",Ne),i.removeEventListener("touchend",$e),i.removeEventListener("touchcancel",O)})}const m=document.createElement("div");m.className="gengage-chat-body",m.dataset.gengagePart="chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel gds-panel",this._panelEl.dataset.gengagePart="chat-panel",this._panelTopBar=new As({onBack:()=>t.onPanelBack?.(),onForward:()=>t.onPanelForward?.(),onClose:()=>{t.getMobileViewport?.()??!1?this.hideMobilePanel():this.clearPanel(),t.onPanelClose?.()},backAriaLabel:this.i18n.backAriaLabel,forwardAriaLabel:this.i18n.forwardAriaLabel,closePanelAriaLabel:this.i18n.closePanelAriaLabel}),this._panelEl.appendChild(this._panelTopBar.getElement());const f=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",f,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",f)),m.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.dataset.gengagePart="chat-panel-divider",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel);const u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",u.dataset.gengagePart="chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),u.setAttribute("title",this.i18n.togglePanelAriaLabel),u.textContent="»",u.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let A=null,P=null;const x=24,E=k=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const J=k.changedTouches?.[0];J&&(A=J.clientX,P=J.clientY)},T=k=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||A===null||P===null)return;const J=k.changedTouches?.[0];if(!J)return;const ce=J.clientX-A,pe=J.clientY-P;if(A=null,P=null,Math.abs(pe)<x||Math.abs(pe)<Math.abs(ce))return;const me=pe<0;me!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(me),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",E,{passive:!0}),this._dividerEl.addEventListener("touchend",T,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",E),this._dividerEl.removeEventListener("touchend",T)}),this._dividerEl.appendChild(u),m.appendChild(this._dividerEl);const w=document.createElement("div");w.className="gengage-chat-conversation",w.dataset.gengagePart="chat-conversation",this._conversationEl=w,w.appendChild(i);const C=document.createElement("div");C.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",C.dataset.gengagePart="chat-offline-bar",C.setAttribute("role","status"),C.setAttribute("aria-live","polite"),C.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&C.classList.add("gengage-chat-offline-bar--visible"),w.appendChild(C);const B=()=>C.classList.add("gengage-chat-offline-bar--visible"),W=()=>C.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",B),window.addEventListener("online",W),this._cleanups.push(()=>{window.removeEventListener("offline",B),window.removeEventListener("online",W)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",w.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=Ot,this.messagesEl.className="gengage-chat-messages",this.messagesEl.dataset.gengagePart="chat-messages",this.messagesEl.setAttribute("role","log"),this.messagesEl.setAttribute("aria-live","polite"),this.messagesEl.setAttribute("aria-atomic","false"),this.messagesEl.setAttribute("aria-label",this.i18n.chatMessagesAriaLabel),ln(this.messagesEl);const ee=document.createElement("button");ee.type="button",ee.className="gengage-chat-former-messages-btn gds-chip",ee.dataset.gengagePart="chat-former-messages-button",ee.textContent=this.i18n.showFormerMessagesButton,ee.setAttribute("aria-label",this.i18n.showFormerMessagesButton),ee.style.display="none",ee.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(ee),this._formerMessagesBtn=ee;const fe=()=>{this._userInteractionUntil=Date.now()+2e3};let D=!1;const b=()=>this._options.presentation,L=()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const{scrollTop:k,scrollHeight:J,clientHeight:ce}=this.messagesEl,pe=J-k-ce;this._userScrolledUp=pe>10;const me=this._presentationPinned?pe<96:pe<32,Ne=Date.now(),$e=Ne<this._programmaticScrollUntil,O=!me&&Ne<this._userInteractionUntil,Q=$e?!1:O;me!==this._presentationPinned&&(this._presentationPinned=me,b()?.onPinnedToBottomChange?.(me)),Q!==this._presentationUserInteracting&&(this._presentationUserInteracting=Q,b()?.onUserInteractingChange?.(Q))}))};this.messagesEl.addEventListener("scroll",L,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",L)});const M=k=>{fe(),k.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",M,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",M));const R=k=>{fe(),this._touchStartY=k.touches[0]?.clientY??null},j=k=>{fe();const J=k.touches[0]?.clientY,ce=this._touchStartY;typeof J=="number"&&typeof ce=="number"&&J-ce>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",R,{passive:!0}),this.messagesEl.addEventListener("touchmove",j,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",R),this.messagesEl.removeEventListener("touchmove",j)}),w.appendChild(this.messagesEl),this._panelFloatingEl=document.createElement("div"),this._panelFloatingEl.className="gengage-chat-panel-float",this._panelFloatingEl.dataset.gengagePart="chat-panel-floating-layer",this._panelEl.appendChild(this._panelFloatingEl),this._resetPanelAiZoneElement(),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.dataset.gengagePart="chat-suggestion-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label",this.i18n.suggestionsAriaLabel),this._pillsEl.style.display="none";const q=document.createElement("div");q.className="gengage-chat-pills-scroll",q.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(q);const F=document.createElement("button");F.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",F.dataset.gengagePart="chat-suggestion-pills-more",F.type="button",F.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),F.textContent="›",F.addEventListener("click",()=>{q.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(F);let ne=!1;const H=()=>{ne||(ne=!0,requestAnimationFrame(()=>{ne=!1;const k=q.scrollLeft+q.clientWidth>=q.scrollWidth-4;F.style.display=k?"none":""}))};q.addEventListener("scroll",H,{passive:!0}),this._cleanups.push(()=>{q.removeEventListener("scroll",H)}),w.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.dataset.gengagePart="chat-input-chips",this._inputChipsEl.style.display="none",w.appendChild(this._inputChipsEl);const K=document.createElement("div");K.className="gengage-chat-input-area",K.dataset.gengagePart="chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.dataset.gengagePart="chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{this._resizeRafId!==null&&cancelAnimationFrame(this._resizeRafId),this._resizeRafId=requestAnimationFrame(()=>{this._resizeRafId=null,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`}),this._updateSendEnabled()}),this.inputEl.addEventListener("keydown",k=>{k.key==="Enter"&&!k.isComposing&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!k.shiftKey)&&(k.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",k=>{const J=k.clipboardData;if(!J)return;let ce=null;const pe=J.files?.[0];if(pe&&pe.type.startsWith("image/"))ce=pe;else if(J.items?.length)for(let me=0;me<J.items.length;me++){const Ne=J.items[me];if(Ne?.kind==="file"&&Ne.type.startsWith("image/")){const $e=Ne.getAsFile();if($e){ce=$e;break}}}ce&&(k.preventDefault(),this._routeAttachmentFile(ce))}),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 k=this._fileInput.files?.[0];k&&this._routeAttachmentFile(k),this._fileInput.value=""});const y=document.createElement("div");y.className="gengage-chat-attach-wrap",y.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=y;const N=document.createElement("button");this._attachBtn=N,N.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",N.dataset.gengagePart="chat-attach-button",N.type="button",N.setAttribute("aria-label",this.i18n.attachImageButton),N.setAttribute("aria-haspopup","menu"),N.setAttribute("aria-expanded","false"),N.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>',N.addEventListener("click",k=>{k.stopPropagation(),this._toggleAttachMenu()});const I=document.createElement("div");this._attachMenuEl=I,I.className="gengage-chat-attach-menu gds-menu",I.dataset.gengagePart="chat-attach-menu",I.setAttribute("role","menu"),I.setAttribute("hidden","");const z=document.createElement("button");z.type="button",z.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",z.dataset.gengagePart="chat-attach-menu-select-photo",z.setAttribute("role","menuitem"),z.innerHTML=`<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><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></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuSelectPhoto}</span>`,z.addEventListener("click",k=>{k.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const V=document.createElement("div");V.className="gengage-chat-attach-menu-sep",V.dataset.gengagePart="chat-attach-menu-separator",V.setAttribute("aria-hidden","true");const $=document.createElement("button");$.type="button",$.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",$.dataset.gengagePart="chat-attach-menu-paste",$.setAttribute("role","menuitem"),$.innerHTML=`<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><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="M15 2H9a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1Z"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/><path d="M16 4h2a2 2 0 0 1 2 2v4"/><path d="M21 14H11"/><path d="m15 10-4 4 4 4"/></svg></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuPaste}</span>`,$.addEventListener("click",k=>{k.stopPropagation();const J=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(J)}),I.appendChild(z),I.appendChild(V),I.appendChild($),y.appendChild(N),y.appendChild(I),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden gds-card-soft",this._previewStrip.dataset.gengagePart="chat-attachment-preview";const U=document.createElement("img");U.className="gengage-chat-attachment-preview-thumb",U.dataset.gengagePart="chat-attachment-preview-thumb",U.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const re=document.createElement("button");re.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",re.dataset.gengagePart="chat-attachment-preview-remove",re.type="button",re.setAttribute("aria-label",this.i18n.removeAttachmentButton),re.textContent="×",re.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(U),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(re),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send gds-btn gds-btn-primary",this.sendBtn.dataset.gengagePart="chat-send",this.sendBtn.type="button",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.dataset.tooltip=this.i18n.sendButton,this._renderSendButtonIcon("send"),this.sendBtn.addEventListener("click",()=>{if(this._sendStopHandler){const k=this._sendStopHandler;this.hideStopButton(),k();return}this._submit()}),K.addEventListener("dragover",k=>{k.preventDefault(),K.classList.add("gengage-chat-input-area--dragover")}),K.addEventListener("dragleave",()=>{K.classList.remove("gengage-chat-input-area--dragover")}),K.addEventListener("drop",k=>{k.preventDefault(),K.classList.remove("gengage-chat-input-area--dragover");const J=k.dataTransfer?.files[0];J&&this._routeAttachmentFile(J)});const G=document.createElement("div");G.className="gengage-chat-input-pill gds-input-shell",G.dataset.gengagePart="chat-input-shell",G.appendChild(y),G.appendChild(this.inputEl),this._voiceEnabled&&Ss()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn gds-btn gds-btn-ghost",this._micBtn.dataset.gengagePart="chat-mic-button",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()),G.appendChild(this._micBtn),this._voiceInput=new Es({onInterim:k=>{this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.inputEl.value=k,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:k=>{this.inputEl.value=k},onAutoSubmit:k=>{this.inputEl.value=k,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:k=>{k==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(k,J)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),G.appendChild(this.sendBtn),K.appendChild(this._previewStrip),K.appendChild(this._fileInput),K.appendChild(G),w.appendChild(K),m.appendChild(w),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",m.appendChild(this._comparisonDockSlotEl),this.root.appendChild(m),this._setupHorizontalSwipe(w);const de=document.createElement("div");de.className="gengage-chat-footer",de.dataset.gengagePart="chat-footer",de.textContent=this.i18n.poweredBy,this.root.appendChild(de);const xe=k=>{k.key==="Escape"&&t.onClose()};this.root.addEventListener("keydown",xe),this._cleanups.push(()=>this.root.removeEventListener("keydown",xe)),e.appendChild(this.root)}addMessage(e){const t=this._options.renderMessageUISpec?.(e)??null;if(!(e.content||e.attachment||t||e.role==="user"&&this._onRollback))return;const a=document.createElement("div");if(a.className=`gengage-chat-bubble gds-message ${e.role==="assistant"?"gds-message-assistant":"gds-message-user"} gengage-chat-bubble--${e.role}`,a.dataset.gengagePart=e.role==="assistant"?"chat-message-assistant":"chat-message-user",a.setAttribute("role","listitem"),a.dataset.messageId=e.id,e.threadId&&(a.dataset.threadId=e.threadId),this._firstBotMessageIds.has(e.id)&&a.classList.add("gengage-chat-bubble--first"),e.attachment){const n=document.createElement("img");n.className="gengage-chat-attachment-thumb";const r=URL.createObjectURL(e.attachment);n.src=r,n.alt=e.attachment.name,n.addEventListener("load",()=>URL.revokeObjectURL(r),{once:!0}),n.addEventListener("error",()=>URL.revokeObjectURL(r),{once:!0}),a.insertBefore(n,a.firstChild)}if(e.content){const n=document.createElement("div");if(n.className="gengage-chat-bubble-text",n.dataset.gengagePart="chat-message-text",e.role==="assistant"){if(e.renderHint==="photo_analysis"?(a.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(n,e.photoAnalysis)):n.innerHTML=Ee(e.content),this._onLinkClick){const r=n.querySelectorAll("a[href]");for(const i of r)i.addEventListener("click",o=>{o.preventDefault();const s=i.getAttribute("href");s&&this._onLinkClick?.(s)})}}else n.textContent=e.content;a.appendChild(n)}if(t&&(a.classList.add("gengage-chat-bubble--ui-spec"),e.content||a.classList.add("gengage-chat-bubble--ui-spec-only"),t.classList.add("gengage-chat-bubble-ui-spec"),a.appendChild(t)),e.role==="user"&&this._onRollback){const n=document.createElement("button");n.className="gengage-chat-rollback-btn gds-btn gds-btn-ghost",n.dataset.gengagePart="chat-message-rollback",n.type="button",n.setAttribute("aria-label",this.i18n.rollbackAriaLabel),n.title=this.i18n.rollbackAriaLabel,n.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>',n.addEventListener("click",r=>{r.stopPropagation(),this._onRollback?.(e.id)}),a.appendChild(n)}this.messagesEl.appendChild(a),this._presentationFocusThreadId&&this._applyPresentationCollapsed(),this._scrollToBottom(e.role==="user")}removeMessageBubble(e){this._firstBotMessageIds.delete(e),this.messagesEl.querySelector(`[data-message-id="${ke(e)}"]`)?.remove(),this._presentationFocusThreadId&&this._applyPresentationCollapsed()}showTypingIndicator(e){this.removeTypingIndicator();const t=this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):e?[e]:this.i18n.loadingSequenceGeneric,{root:a,binding:n}=this._createLoadingSequence("chat",t,"chat-typing-indicator","gengage-chat-typing");a.dataset.typing="true",this._typingLoadingBinding=n,this.messagesEl.appendChild(a),this._scrollToBottom(!0)}addThinkingStep(e){const t=e.trim();t&&this._thinkingSteps[this._thinkingSteps.length-1]!==t&&(this._thinkingSteps.push(t),this._thinkingSteps=this._thinkingSteps.slice(-3),this._typingLoadingBinding&&this._applyLoadingSteps(this._typingLoadingBinding,this._thinkingSteps,!0),this._panelLoadingBinding&&this._applyLoadingSteps(this._panelLoadingBinding,this._thinkingSteps,!0),this._panelAiZoneLoadingBinding&&this._applyLoadingSteps(this._panelAiZoneLoadingBinding,this._thinkingSteps,!0))}setThinkingSteps(e){const t=e.map(a=>a.trim()).filter(Boolean).slice(-3);t.length!==0&&(this._thinkingSteps=t,this._typingLoadingBinding&&this._applyLoadingSteps(this._typingLoadingBinding,this._thinkingSteps,!0),this._panelLoadingBinding&&this._applyLoadingSteps(this._panelLoadingBinding,this._thinkingSteps,!0),this._panelAiZoneLoadingBinding&&this._applyLoadingSteps(this._panelAiZoneLoadingBinding,this._thinkingSteps,!0))}removeTypingIndicator(){this._destroyLoadingBinding(this._typingLoadingBinding),this._typingLoadingBinding=null,this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[],this.hideStopButton()}showStopButton(e){this._sendStopHandler=e,this.sendBtn.disabled=!1,this.sendBtn.classList.add("gengage-chat-send--stop","gds-btn-secondary"),this.sendBtn.classList.remove("gds-btn-primary"),this.sendBtn.setAttribute("aria-label",this.i18n.stopGenerating),this.sendBtn.dataset.tooltip=this.i18n.stopGenerating,this._renderSendButtonIcon("stop")}hideStopButton(){this._sendStopHandler=null,this.sendBtn.classList.remove("gengage-chat-send--stop","gds-btn-secondary"),this.sendBtn.classList.add("gds-btn-primary"),this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.dataset.tooltip=this.i18n.sendButton,this._renderSendButtonIcon("send"),this._updateSendEnabled()}showError(e,t){const a=document.createElement("div");a.className="gengage-chat-error",a.setAttribute("role","alert");const n=document.createElement("span");if(n.textContent=e??this.i18n.errorMessage,a.appendChild(n),t){const r=document.createElement("button");r.className="gengage-chat-error-retry",r.textContent=this.i18n.retryButton??"Retry",r.addEventListener("click",()=>{a.remove(),t()}),a.appendChild(r)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}showErrorWithRecovery(e,t){this.showError(e),this.setRecoveryPills(t)}showRecoveryPillsOnly(e){this.setRecoveryPills(e)}setRecoveryPills(e){this.setPills([{label:this.i18n.tryAgainButton,onAction:e.onRetry},{label:this.i18n.askSomethingElseButton,onAction:e.onNewQuestion}])}clearMessages(){const e=this._formerMessagesBtn;for(const t of[...this.messagesEl.children])t!==e&&t.remove()}setPills(e){const t=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!t)return;for(;t.firstChild;)t.removeChild(t.firstChild);if(e.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const n of e){const r=document.createElement("button");if(r.className=n.image?"gengage-chat-pill gds-chip gds-chip-active gengage-chat-pill--rich":"gengage-chat-pill gds-chip gds-chip-active",r.type="button",n.icon){const o=bn[n.icon]??fn,s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,r.appendChild(s)}if(n.image&&Ue(n.image)){const o=document.createElement("img");o.className="gengage-chat-pill-img",o.src=n.image,o.alt="",r.appendChild(o)}const i=document.createElement("span");if(i.className="gengage-chat-pill-text",i.textContent=n.label,r.appendChild(i),n.description){const o=document.createElement("span");o.className="gengage-chat-pill-desc";const s=`pill-desc-${Math.random().toString(36).slice(2,9)}`;o.id=s,o.textContent=n.description,r.appendChild(o),r.setAttribute("aria-describedby",s)}r.addEventListener("click",()=>n.onAction()),t.appendChild(r)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=t.scrollWidth>t.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(e,t){this._kvkkSlot.innerHTML="";const a=Ts({htmlContent:e,onDismiss:t,closeAriaLabel:this.i18n.closeAriaLabel});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}isKvkkBannerVisible(){return this._kvkkSlot.childNodes.length>0}getElement(){return this.root}openAttachmentPicker(){this._fileInput.click()}setAttachmentControlsVisible(e){this._attachWrapEl&&(this._attachWrapEl.style.display=e?"":"none",e||this._closeAttachMenu())}setBeautyPhotoStepCard(e){this._beautyPhotoStepEl=Ns(this._beautyPhotoStepEl,this._conversationEl??null,e,this.i18n,()=>this.openAttachmentPicker())}stageAttachment(e){this._pendingAttachment=e,this._previewName.textContent=e.name;const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t&&(t.src&&t.src.startsWith("blob:")&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}clearAttachment(){const e=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");e?.src&&(URL.revokeObjectURL(e.src),e.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}_routeAttachmentFile(e){if(this._onAttachment)try{this._onAttachment(e)}catch(t){console.error("[gengage:chat] Attachment callback error:",t)}else this.stageAttachment(e)}_closeAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.setAttribute("hidden",""),this._attachBtn?.setAttribute("aria-expanded","false"),this._attachMenuClickTimerId!==null&&(clearTimeout(this._attachMenuClickTimerId),this._attachMenuClickTimerId=null),this._attachMenuCleanup&&(this._attachMenuCleanup(),this._attachMenuCleanup=null))}_openAttachMenu(){if(!this._attachMenuEl)return;this._attachMenuEl.removeAttribute("hidden"),this._attachBtn?.setAttribute("aria-expanded","true");const e=a=>{this._attachWrapEl?.contains(a.target)||this._closeAttachMenu()},t=a=>{a.key==="Escape"&&(a.stopPropagation(),this._closeAttachMenu())};this._attachMenuClickTimerId=window.setTimeout(()=>{this._attachMenuClickTimerId=null,document.addEventListener("click",e,!0)},0),document.addEventListener("keydown",t,!0),this._attachMenuCleanup=()=>{document.removeEventListener("click",e,!0),document.removeEventListener("keydown",t,!0)}}_toggleAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.hasAttribute("hidden")?this._openAttachMenu():this._closeAttachMenu())}async _pasteImageFromClipboardMenu(e){const t=await Hs(e);if(t){this._routeAttachmentFile(t),this._closeAttachMenu();return}ze("gengage:global:error",{message:this.i18n.clipboardNoImageMessage,source:"chat"}),this._closeAttachMenu()}getPendingAttachment(){return this._pendingAttachment}setPanelAiZoneState(e,t){if(this._panelAiZoneEl.isConnected&&(this._clearPanelAiZoneState(),e!=="hidden"))if(this._panelAiZoneEl.removeAttribute("hidden"),e==="analyzing"){this._panelAiZoneEl.innerHTML="";const a=[t?.analyzingLabel??this.i18n.aiAnalysisAnalyzingLabel,...this.i18n.loadingSequencePanel],{root:n,binding:r}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-ai-zone-loading","gengage-chat-panel-ai-zone-inner");this._panelAiZoneLoadingBinding=r,this._panelAiZoneEl.appendChild(n)}else e==="results"&&t?.resultEl&&(this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.appendChild(t.resultEl))}_clearPanelAiZoneState(){this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden","")}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}_emitHostShellSync(){this._onHostShellSync?.()}_syncPanelTopBarFromContent(e){const t=e.querySelector(".gengage-chat-product-grid-head");if(t){const a=t.querySelector(".gengage-chat-product-grid-head-title"),n=t.querySelector(".gengage-chat-product-grid-head-actions");if(a?.textContent?.trim()){const r=a.textContent.trim();e.dataset.gengagePanelDerivedTitle=r,this._panelTopBar.setTitle(r)}n?(n.classList.add("gengage-chat-panel-topbar-toolbar-host"),this._panelTopBar.setActions(n)):this._panelTopBar.setActions(null),t.remove();return}this._syncPanelTopBarTitleFromContent(e)}_syncPanelTopBarTitleFromContent(e){const t=e.dataset.gengagePanelDerivedTitle;if(t?.trim()){this._panelTopBar.setTitle(t.trim());return}const a=e.querySelector(".gengage-chat-product-details-title, .gengage-chat-product-details-similars-heading, .gengage-chat-ai-top-picks-title")?.textContent?.trim();a&&this._panelTopBar.setTitle(a)}setPanelContent(e,t){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,t?.preserveAiZone!==!0&&this._clearPanelAiZoneState(),this._panelVisible?this._swapPanelContent(e):(this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelTopBar.setActions(null),this._panelEl.appendChild(e),this._panelEl.appendChild(this._panelFloatingEl)),this._syncPanelTopBarFromContent(e),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._panelCollapsed&&this.setPanelCollapsed(!1),this._syncComparisonDockVisibility(),requestAnimationFrame(()=>{this._updateScrollAffordance(),this._smoothScrollPanelListToTop()}),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this._emitHostShellSync()}_swapPanelContent(e){this._panelTopBar.setActions(null);const t=this._panelEl.querySelector(".gengage-chat-panel-skeleton");if(t){t.replaceWith(e);return}const a=this.getPanelContentElement();if(a){a.replaceWith(e);return}this._panelEl.insertBefore(e,this._panelFloatingEl)}appendPanelContent(e){this._panelEl.insertBefore(e,this._panelFloatingEl),this._syncPanelTopBarFromContent(this.getPanelContentElement()??e),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this.setPanelCollapsed(this._panelCollapsed),this._syncComparisonDockVisibility(),this._emitHostShellSync()}getPanelContentElement(){const e=this._panelEl.children;for(let t=0;t<e.length;t++){const a=e[t];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-panel-ai-zone")||a.classList.contains("gengage-chat-panel-float")))return a}return null}resyncPanelTopBarFromCurrentContent(){const e=this.getPanelContentElement();e&&this._syncPanelTopBarFromContent(e)}isPanelVisible(){return this._panelVisible}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(e){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl);const t=document.createElement("div");t.className="gengage-chat-panel-skeleton";const a=e==="comparisonTable"?this.i18n.loadingSequenceComparison:this.i18n.loadingSequencePanel,{root:n,binding:r}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-loading-status","gengage-chat-panel-loading-status");switch(this._panelLoadingBinding=r,e){case"productDetails":{t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",t.appendChild(i);for(let o=0;o<3;o++){const s=document.createElement("div");s.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",t.appendChild(s)}break}case"productList":case"groupList":{t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-grid";for(let o=0;o<6;o++){const s=document.createElement("div");s.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",i.appendChild(s)}t.appendChild(i);break}case"comparisonTable":{t.classList.add("gengage-chat-panel-skeleton--comparison"),t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-comparison gengage-chat-comparison--skeleton",i.setAttribute("aria-busy","true");const o=document.createElement("div");o.className="gengage-chat-comparison-recommended";const s=document.createElement("div");s.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-label",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-recommended-body";const l=document.createElement("div");l.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-img",l.setAttribute("aria-hidden","true");const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";for(let w=0;w<2;w++){const C=document.createElement("div");C.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",w===1&&C.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),g.appendChild(C)}const d=document.createElement("div");d.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",g.appendChild(d),c.appendChild(l),c.appendChild(g),o.appendChild(c);const p=document.createElement("div");p.className="gengage-chat-comparison-highlights";const h=document.createElement("div");h.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-label",p.appendChild(h);const v=document.createElement("ul");v.className="gengage-chat-comparison-skeleton-hl-list";for(let w=0;w<3;w++){const C=document.createElement("li"),B=document.createElement("div");B.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",w===1&&B.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),w===2&&B.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),C.appendChild(B),v.appendChild(C)}p.appendChild(v),o.appendChild(p),i.appendChild(o);const m=document.createElement("div");m.className="gengage-chat-comparison-key-differences";const f=document.createElement("div");f.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-heading",m.appendChild(f);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content";for(let w=0;w<4;w++){const C=document.createElement("div");C.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",u.appendChild(C)}m.appendChild(u),i.appendChild(m);const A=document.createElement("div");A.className="gengage-chat-comparison-special gengage-chat-comparison-special--skeleton";const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-special-line",A.appendChild(P),i.appendChild(A);const x=document.createElement("div");x.className="gengage-chat-comparison-skeleton-table-wrap";const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-head";const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-table-corner",E.appendChild(T);for(let w=0;w<3;w++){const C=document.createElement("div");C.className="gengage-chat-comparison-skeleton-table-col";const B=document.createElement("div");B.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";const W=document.createElement("div");W.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const ee=document.createElement("div");ee.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",C.appendChild(B),C.appendChild(W),C.appendChild(ee),E.appendChild(C)}x.appendChild(E);for(let w=0;w<3;w++){const C=document.createElement("div");C.className="gengage-chat-comparison-skeleton-table-row";const B=document.createElement("div");B.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label",C.appendChild(B);for(let W=0;W<3;W++){const ee=document.createElement("div");ee.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",C.appendChild(ee)}x.appendChild(C)}i.appendChild(x),t.appendChild(i);break}default:t.appendChild(n);for(let i=0;i<3;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",t.appendChild(o)}break}this._panelEl.appendChild(t),this._panelEl.appendChild(this._panelFloatingEl),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._syncComparisonDockVisibility(),this._emitHostShellSync()}updatePanelTopBar(e,t,a){const n=this._options.getMobileViewport?.()??!1;this._panelTopBar.update(n?!0:e,t,a);const r=this.getPanelContentElement();r&&this._syncPanelTopBarTitleFromContent(r)}getPanelTopBarTitle(){return this._panelTopBar.getTitle()}updateFavoritesBadge(e){this._favBadgeEl&&(e>0?(this._favBadgeEl.textContent=e>99?"99+":String(e),this._favBadgeEl.style.display=""):this._favBadgeEl.style.display="none")}clearPanel(){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(this._panelFloatingEl),this._panelTopBar.setActions(null),this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this.setComparisonDockContent(null),this._emitHostShellSync()}_syncComparisonDockVisibility(){const e=this._panelVisible&&this._comparisonDockSlotEl.children.length>0;this._comparisonDockSlotEl.classList.toggle("gengage-chat-comparison-dock-slot--panel-visible",e),this._comparisonDockSlotEl.style.display=e?"":"none",this._comparisonDockSlotEl.setAttribute("aria-hidden",e?"false":"true")}setComparisonDockContent(e){this._comparisonDockSlotEl.replaceChildren(),e&&this._comparisonDockSlotEl.appendChild(e),this._syncComparisonDockVisibility()}hideMobilePanel(){this._panelVisible&&(this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="flex"),this._syncComparisonDockVisibility(),this._emitHostShellSync())}_showMobilePanelFromBtn(){this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this._syncComparisonDockVisibility(),this._emitHostShellSync())}showMobilePanel(){this._showMobilePanelFromBtn()}expandPanel(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._syncComparisonDockVisibility(),this._emitHostShellSync()}setForceExpanded(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._syncComparisonDockVisibility(),this._emitHostShellSync()}_smoothScrollPanelListToTop(){this._panelEl.scrollTop=0}_getChoicePrompterRevealScrollThreshold(){if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return 88;const e=this._panelEl.querySelector(".gengage-chat-product-grid--mobile .gengage-chat-product-card, .gengage-chat-product-grid .gengage-chat-product-card"),t=this._panelEl.querySelector(".gengage-chat-product-card"),a=e??t;if(!a)return 88;const n=Math.round(a.getBoundingClientRect().height);return!Number.isFinite(n)||n<=0?88:n}_updateScrollAffordance(){const e=this._panelEl,t=e.scrollTop+e.clientHeight>=e.scrollHeight-10,a=this._getChoicePrompterRevealScrollThreshold();e.classList.toggle("gengage-chat-panel--has-scroll",!t&&e.scrollHeight>e.clientHeight),e.classList.toggle("gengage-chat-panel--scrolled",e.scrollTop>a)}_setupHorizontalSwipe(e){let t=0,a=0;const n=i=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=i.touches[0];o&&(t=o.clientX,a=o.clientY)},r=i=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=i.changedTouches[0];if(!o)return;const s=o.clientX-t,c=o.clientY-a;Math.abs(s)>50&&Math.abs(s)>Math.abs(c)*2&&(this.togglePanel(),this._onPanelToggle?.())};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",r,{passive:!0}),this._cleanups.push(()=>{e.removeEventListener("touchstart",n),e.removeEventListener("touchend",r)})}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(e){this._panelCollapsed=e,e?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const t=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");t&&(t.textContent=e?"«":"»"),this._emitHostShellSync()}persistPanelState(e){try{const t=`gengage:panel:${e}`;this._panelCollapsed?sessionStorage.setItem(t,"collapsed"):sessionStorage.removeItem(t)}catch{}}restorePanelState(e){try{const t=`gengage:panel:${e}`;if(sessionStorage.getItem(t)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_createLoadingSequence(e,t,a,n){const r=document.createElement("div");r.className=`${n} gds-progress-loader ${e==="chat"?"gds-progress-loader-chat":"gds-progress-loader-panel"}`,r.dataset.gengagePart=a,r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const i=document.createElement("span");i.className=e==="chat"?"gengage-chat-typing-text gds-progress-label":"gengage-chat-panel-loading-label gds-progress-label",r.appendChild(i);const o=document.createElement("span");o.className=e==="chat"?"gengage-chat-typing-dots gds-progress-dots":"gds-progress-dots",o.setAttribute("aria-hidden","true");for(let c=0;c<3;c++){const l=document.createElement("span");l.className="gds-progress-dot",o.appendChild(l)}r.appendChild(o);const s={labelEl:i,steps:[],index:0,intervalId:null};return this._applyLoadingSteps(s,t),{root:r,binding:s}}_applyLoadingSteps(e,t,a=!1){const n=t.map(i=>i.trim()).filter(Boolean).slice(-3),r=[this.i18n.loadingMessage];e.steps=n.length>0?n:r,this._clearLoadingBindingInterval(e),e.index=a?e.steps.length-1:0,e.labelEl.textContent=e.steps[e.index],!a&&e.steps.length>1&&(e.intervalId=setInterval(()=>{if(e.index>=e.steps.length-1){this._clearLoadingBindingInterval(e);return}e.index+=1,e.labelEl.textContent=e.steps[e.index],e.index>=e.steps.length-1&&this._clearLoadingBindingInterval(e)},Os))}_clearLoadingBindingInterval(e){e?.intervalId&&(clearInterval(e.intervalId),e.intervalId=null)}_destroyLoadingBinding(e){this._clearLoadingBindingInterval(e)}_updateSendEnabled(){if(this._sendStopHandler){this.sendBtn.disabled=!1;return}const e=this.inputEl.value.trim().length>0||this._pendingAttachment!==null;this.sendBtn.disabled=!e}_renderSendButtonIcon(e){this.sendBtn.innerHTML=e==="stop"?'<span class="gengage-chat-send-stop-icon" aria-hidden="true"></span>':'<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>'}_submit(){const e=this.inputEl.value.trim(),t=this._pendingAttachment;if(this._sendStopHandler){const a=this._sendStopHandler;if(this.hideStopButton(),a(),!e&&!t)return}else if(!e&&!t)return;this.onSend(e,t??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment(),this._updateSendEnabled()}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const e=this._voiceInput.stop();e.trim()&&(this.inputEl.value=e,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(e=!1){!e&&this._userScrolledUp||!e&&this._options.presentation?.shouldBlockSoftAutoScroll?.()||!e&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(e,t,a,n){const r=this.messagesEl.querySelector(`[data-message-id="${ke(e)}"]`);if(!r)return;let i=r.querySelector(".gengage-chat-bubble-text");i||(i=document.createElement("div"),i.className="gengage-chat-bubble-text",r.appendChild(i)),a==="photo_analysis"?(r.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(i,n)):(r.classList.remove("gengage-chat-bubble--photo-analysis"),i.innerHTML=Ee(t)),this._scrollToBottom(!1)}markFirstBotMessage(e){this._firstBotMessageIds.add(e);const t=this.messagesEl.querySelector(`[data-message-id="${ke(e)}"]`);t&&t.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const e=this.messagesEl.querySelectorAll("[data-thread-id]");if(e.length===0){this._scrollToBottom(!0);return}const t=e[e.length-1].getAttribute("data-thread-id");if(!t){this._scrollToBottom(!0);return}this._programmaticScrollUntil=Date.now()+700;const a=this.messagesEl.querySelector(`[data-thread-id="${ke(t)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}scrollThreadIntoView(e,t="smooth"){const a=this.messagesEl.querySelectorAll(`[data-thread-id="${ke(e)}"]`);let n=null,r=null;for(let s=0;s<a.length;s++){const c=a[s];if(c instanceof HTMLElement&&(r||(r=c),!c.classList.contains("gengage-chat-bubble--presentation-collapsed")&&!c.classList.contains("gengage-chat-bubble--hidden")&&c.offsetHeight!==0&&!(c.classList.contains("gengage-chat-bubble--assistant")&&(c.textContent?.trim().length??0)===0))){n=c;break}}if(n||(n=r),!n)return!1;const i=Date.now();this._programmaticScrollUntil=i+vn,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,i+vn),this._userScrolledUp=!0;const o=()=>{this._scrollMessagesTo(Math.max(n.offsetTop-20,0),t)};return o(),requestAnimationFrame(o),!0}scrollToBottomPresentation(e="smooth"){this._programmaticScrollUntil=Date.now()+700,requestAnimationFrame(()=>{this._scrollMessagesTo(this.messagesEl.scrollHeight,e),this._userScrolledUp=!1})}_scrollMessagesTo(e,t){if(typeof this.messagesEl.scrollTo=="function"){this.messagesEl.scrollTo({top:e,behavior:t});return}this.messagesEl.scrollTop=e}setPresentationFocus(e){this._presentationFocusThreadId=e,this._applyPresentationCollapsed()}setFormerMessagesButtonVisible(e){this._formerMessagesBtn&&(this._formerMessagesBtn.style.display=e?"":"none")}setInputPlaceholder(e){this.inputEl.placeholder=e}_applyPresentationCollapsed(){const e=this._presentationFocusThreadId;this.messagesEl.querySelectorAll("[data-thread-id]").forEach(t=>{const a=t.dataset.threadId;a&&(e&&a!==e?t.classList.add("gengage-chat-bubble--presentation-collapsed"):t.classList.remove("gengage-chat-bubble--presentation-collapsed"))})}refreshPresentationCollapsed(){this._presentationFocusThreadId&&this._applyPresentationCollapsed()}setInputAreaChips(e){if(this._inputChipsEl.innerHTML="",e.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const t of e){const a=document.createElement("button");if(a.className="gengage-chat-input-chip gds-chip",a.type="button",t.icon){const r=bn[t.icon]??fn,i=document.createElement("span");i.className="gengage-chat-input-chip-icon",i.innerHTML=r,a.appendChild(i)}const n=document.createElement("span");n.textContent=t.label,a.appendChild(n),a.addEventListener("click",()=>t.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}trapFocus(){this._previouslyFocusedElement=document.activeElement,this.releaseFocus();const e=t=>{if(t.key!=="Tab")return;const a=Array.from(this.root.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(l=>{const g=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||g.display==="none"||g.visibility==="hidden"?!1:l.getClientRects().length>0});if(a.length===0)return;const n=a[0],r=a[a.length-1],i=t.composedPath().find(l=>l instanceof HTMLElement&&this.root.contains(l))??null,o=this.root.getRootNode(),s=i??(o instanceof ShadowRoot&&o.activeElement instanceof HTMLElement?o.activeElement:document.activeElement instanceof HTMLElement?document.activeElement:null),c=s&&this.root.contains(s)?s:null;t.shiftKey?(c===n||!this.root.contains(c))&&(t.preventDefault(),r.focus()):(c===r||!this.root.contains(c))&&(t.preventDefault(),n.focus())};this._focusTrapHandler=e,this.root.addEventListener("keydown",e)}releaseFocus(){if(this._focusTrapHandler&&(this.root.removeEventListener("keydown",this._focusTrapHandler),this._focusTrapHandler=null),this._previouslyFocusedElement){try{this._previouslyFocusedElement.focus()}catch{}this._previouslyFocusedElement=null}}flashCartBadge(){this._cartBtn&&(this._cartBtn.classList.remove("gengage-chat-header-btn--cart-flash"),this._cartBtn.offsetWidth,this._cartBtn.classList.add("gengage-chat-header-btn--cart-flash"),this._cartBtn.addEventListener("animationend",()=>{this._cartBtn?.classList.remove("gengage-chat-header-btn--cart-flash")},{once:!0}))}showCartToast(e){this.root.querySelector(".gengage-chat-cart-toast")?.remove();const t=document.createElement("div");t.className="gengage-chat-cart-toast",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.textContent=e,this.root.appendChild(t),t.offsetWidth,t.classList.add("gengage-chat-cart-toast--visible"),setTimeout(()=>{t.classList.remove("gengage-chat-cart-toast--visible"),setTimeout(()=>t.remove(),300)},2500)}destroy(){ln(null),this.releaseFocus(),this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._destroyLoadingBinding(this._typingLoadingBinding),this._typingLoadingBinding=null,this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._closeAttachMenu();for(const e of this._cleanups)e();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}},yn=["beauty_consulting","watch_expert","booking"],Us=["shopping",...yn];function js(e){return typeof e=="string"&&Us.includes(e)?e:null}function Pe(e){return e==null||typeof e!="object"||Array.isArray(e)?null:e}function Zs(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Vs(e){const t=Pe(e);if(!t)return null;const a=Zs(t.assistant_mode,t.assistantMode);return!a||!yn.includes(a)?null:a}var qs=class{constructor(){this._mode="shopping",this._uiHints=null}get mode(){return this._mode}set mode(e){this._mode=e}get uiHints(){return this._uiHints}set uiHints(e){this._uiHints=e}get isShopping(){return this._mode==="shopping"}get isBeautyConsulting(){return this._mode==="beauty_consulting"}get isChoicePrompterHidden(){return this._uiHints?.hide_choice_prompter===!0}applyUiHints(e,t,a){const n=i=>this._uiHints?.[i]===!0;e?.setAttachmentControlsVisible(!n("hide_attachment_controls")),n("hide_choice_prompter")&&a?.();const r=typeof this._uiHints?.input_placeholder=="string"?this._uiHints.input_placeholder:void 0;r?e?.setInputPlaceholder(r):e?.setInputPlaceholder(t)}handleRedirect(e){Ze("mode","redirect metadata received",e);const t=Vs(e);return t?(this.switchMode(t),!0):!1}switchMode(e){const t=this._mode;this._mode=e,Ze("mode","assistant mode switched",{from:t,to:e})}updateFromContext(e){const t=e.assistant_mode;if(typeof t=="string"&&t){const a=js(t);a?this._mode=a:Ze("mode","ignoring unrecognised assistant_mode from context",t)}else t===null&&(this._mode="shopping");this._uiHints=Pe(e.ui_hints)??null}reset(){const e=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,e}resolveAttachmentActionType(){return this._mode==="beauty_consulting"?"user_message":"findSimilar"}shouldCondenseThinking(){return this._mode!=="shopping"}};function Gs(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function Ws(e,t,a,n,r){if(e==="PhotoAnalysisCard"){const i=hn(t);return i?(r.photoAnalysis=i,r.renderHint="photo_analysis",n.ensureRendered(),n.cancelTypewriter(),n.drawer?.updateBotMessage(r.id,r.content??"","photo_analysis",r.photoAnalysis),!0):(Ze("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",t),!1)}if(e==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const i=Ls(t);return n.drawer?.setBeautyPhotoStepCard({visible:!0,...i,onSkip:()=>{n.drawer?.setBeautyPhotoStepCard({visible:!1}),n.streamDone?n.sendSkipMessage():a.pendingPhotoStepSkip=!0}}),!0}return!1}function Ks(e){return e.renderHint==="photo_analysis"}function Ys(e,t){e.streamIncludedBeautyPhotoStep||t.drawer?.setBeautyPhotoStepCard({visible:!1}),e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function Js(e,t){e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function ua(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function xn(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function _n(e){const t=ua(e),a=Math.floor(t),n=t-a>=.5,r=5-a-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),a>0&&i.appendChild(document.createTextNode("★".repeat(a))),n){const o=document.createElement("span");o.className="gengage-star-half",o.textContent="☆";const s=document.createElement("span");s.textContent="★",o.appendChild(s),i.appendChild(o)}return r>0&&i.appendChild(document.createTextNode("☆".repeat(r))),i}function Be(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}var Xs={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function ie(e,t){const a=Number(e);if(!Number.isFinite(a)||a<0)return e;const n={...Xs,...t},r=Math.abs(a%1)<Number.EPSILON,i=n.alwaysShowDecimals||!r?a.toFixed(2):a.toFixed(0),o=i.indexOf("."),s=o===-1?i:i.slice(0,o),c=o===-1?void 0:i.slice(o+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let g;return c!==void 0?g=`${l}${n.decimalSeparator}${c}`:g=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${g}`:`${g} ${n.currencySymbol}`:g}var Qs={screen_size:"Screen Size",weight:"Weight",battery_capacity:"Battery Capacity",battery_life:"Battery Life",storage:"Storage",memory:"Memory",ram:"RAM",processor:"Processor",camera:"Camera",resolution:"Resolution",display_type:"Display Type",refresh_rate:"Refresh Rate",color:"Color",material:"Material",dimensions:"Dimensions",warranty:"Warranty",connectivity:"Connectivity",water_resistance:"Water Resistance",operating_system:"Operating System",brand:"Brand",model:"Model",price:"Price",energy_class:"Energy Class",noise_level:"Noise Level",capacity:"Capacity",power:"Power",voltage:"Voltage",width:"Width",height:"Height",depth:"Depth"};function ec(e,t,a){return t?.[e]??Qs[e]??e.replace(/_/g," ").replace(/^./u,n=>tc(n,a))}function tc(e,t){try{return e.toLocaleUpperCase(Ct(t))}catch{return e.toLocaleUpperCase("tr")}}function wn(e){if(typeof e!="string")return!1;const t=Number(e);return Number.isFinite(t)&&t>0}function ac(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)&&t>0}function nc(e){const t=typeof e=="number"?e:Number(e),a=document.createElement("div");a.className="gengage-chat-comparison-recommended-rating",a.innerHTML='<span class="gengage-chat-comparison-recommended-rating-icon" aria-hidden="true"><svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg></span>';const n=document.createElement("span");return n.className="gengage-chat-comparison-recommended-rating-value",n.textContent=t.toFixed(1),a.appendChild(n),a}function rc(e){const{recommended:t,products:a,attributes:n,highlights:r,specialCases:i,onProductClick:o,i18n:s}=e,c=document.createElement("div");if(c.className="gengage-chat-comparison",c.dataset.gengagePart="comparison-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-label",s?.comparisonHeading??"Comparison Results"),t){const l=document.createElement("article");l.className="gengage-chat-comparison-recommended gds-card",l.dataset.gengagePart="comparison-recommended-card";const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(g);const d=document.createElement("div");d.className="gengage-chat-comparison-recommended-body",d.classList.add("gds-clickable"),d.tabIndex=0,d.setAttribute("role","button"),d.setAttribute("aria-label",t.name);const p=document.createElement("div");if(p.className="gengage-chat-comparison-recommended-media",t.imageUrl&&Ue(t.imageUrl)){const u=document.createElement("img");u.src=t.imageUrl,u.alt=t.name,u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),p.appendChild(u)}else{const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-placeholder",u.setAttribute("aria-hidden","true"),p.appendChild(u)}d.appendChild(p);const h=document.createElement("div");h.className="gengage-chat-comparison-recommended-info";const v=document.createElement("div");v.className="gengage-chat-comparison-recommended-title",v.textContent=t.name,h.appendChild(v);const m=document.createElement("div");if(m.className="gengage-chat-comparison-recommended-meta",ac(t.rating)&&m.appendChild(nc(t.rating)),wn(t.price)){const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-price",u.textContent=ie(t.price,e.pricing),m.appendChild(u)}if(m.childElementCount>0&&h.appendChild(m),e.recommendedText){const u=document.createElement("p");u.className="gengage-chat-comparison-recommended-text",u.innerHTML=Ee(e.recommendedText),h.appendChild(u)}d.appendChild(h);const f=()=>{o({sku:t.sku,name:t.name})};if(d.addEventListener("click",f),d.addEventListener("keydown",u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),f())}),l.appendChild(d),r.length>0){const u=document.createElement("div");u.className="gengage-chat-comparison-highlights",u.dataset.gengagePart="comparison-highlights";const A=document.createElement("div");A.className="gengage-chat-comparison-highlights-label",A.textContent=s?.highlightsLabel??"Key Highlights",u.appendChild(A);const P=document.createElement("ul");for(const x of r){const E=document.createElement("li");E.textContent=x,P.appendChild(E)}u.appendChild(P),l.appendChild(u)}c.appendChild(l)}if(e.keyDifferencesHtml){const l=document.createElement("details");l.className="gengage-chat-comparison-key-differences",l.dataset.gengagePart="comparison-key-differences";const g=document.createElement("summary");g.className="gengage-chat-comparison-key-differences-summary";const d=document.createElement("span");d.className="gengage-chat-comparison-key-differences-summary-label",d.textContent=s?.keyDifferencesLabel??"Key Differences";const p=document.createElement("span");p.className="gengage-chat-comparison-key-differences-summary-meta",p.textContent=s?.viewMoreLabel??"Show More",g.appendChild(d),g.appendChild(p),l.appendChild(g);const h=document.createElement("div");h.className="gengage-chat-comparison-key-differences-content",h.innerHTML=Ee(ic(e.keyDifferencesHtml)),l.appendChild(h),c.appendChild(l)}if(i&&i.length>0){const l=document.createElement("details");l.className="gengage-chat-comparison-special gds-evidence-card gds-evidence-card-warning",l.dataset.gengagePart="comparison-special-cases";const g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(g);const d=document.createElement("ul");for(const p of i)oc(d,p);d.childElementCount>0&&l.appendChild(d),c.appendChild(l)}if(a.length>0&&n.length>0){const l=document.createElement("table");l.className="gengage-chat-comparison-table gds-comparison-table";const g=document.createElement("thead"),d=document.createElement("tr"),p=document.createElement("th");d.appendChild(p);for(const m of a){const f=document.createElement("th");m.sku===t?.sku&&(f.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const u=document.createElement("div");u.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",u.tabIndex=0,u.setAttribute("role","button"),u.setAttribute("aria-label",m.name),u.title=m.name;const A=()=>{o({sku:m.sku,name:m.name})};if(u.addEventListener("click",A),u.addEventListener("keydown",x=>{x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),A())}),m.imageUrl&&Ue(m.imageUrl)){const x=document.createElement("img");x.src=m.imageUrl,x.alt=m.name,x.loading="lazy",x.addEventListener("error",()=>{x.style.display="none"},{once:!0}),u.appendChild(x)}else{const x=document.createElement("div");x.className="gengage-chat-comparison-table-header-img-placeholder",x.setAttribute("aria-hidden","true"),u.appendChild(x)}const P=document.createElement("div");if(P.className="gengage-chat-comparison-table-product-name",P.textContent=m.name,u.appendChild(P),wn(m.price)){const x=document.createElement("div");x.className="gengage-chat-comparison-table-price",x.textContent=ie(m.price,e.pricing),u.appendChild(x)}f.appendChild(u),d.appendChild(f)}g.appendChild(d),l.appendChild(g);const h=document.createElement("tbody");for(const m of n){const f=document.createElement("tr"),u=document.createElement("td");u.className="gengage-chat-comparison-label",u.textContent=ec(m.label,s?.criteriaLabels,e.locale),f.appendChild(u);for(let A=0;A<m.values.length;A++){const P=document.createElement("td");a[A]?.sku===t?.sku&&(P.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const x=m.values[A]??"";kn(x)?P.innerHTML=Ee(x):P.textContent=x,f.appendChild(P)}h.appendChild(f)}l.appendChild(h);const v=document.createElement("div");v.className="gengage-chat-comparison-table-wrapper",v.dataset.gengagePart="comparison-table-wrapper",v.appendChild(l),c.appendChild(v)}return c.addEventListener("keydown",l=>{if(l.key!=="Tab")return;const g=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const d=g[0],p=g[g.length-1];l.shiftKey&&document.activeElement===d?(l.preventDefault(),p.focus()):!l.shiftKey&&document.activeElement===p&&(l.preventDefault(),d.focus())}),c}function ic(e){if(/<[uo]l[\s>]/i.test(e)||/<li[\s>]/i.test(e))return e;const t=e.split(`
49
49
  `).filter(a=>a.trim());return t.length<=1?e:"<ul>"+t.map(a=>`<li>${a.trim()}</li>`).join("")+"</ul>"}function oc(e,t){const a=Ee(t);if(!a)return;const n=document.createElement("template");n.innerHTML=a;const r=Array.from(n.content.querySelectorAll("li"));if(r.length>0){for(const o of r){const s=document.createElement("li");s.innerHTML=Ee(o.innerHTML),e.appendChild(s)}return}const i=document.createElement("li");kn(t)?i.innerHTML=a:i.textContent=t,e.appendChild(i)}function kn(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function Pt(e,t=18){const a="http://www.w3.org/2000/svg",n=document.createElementNS(a,"svg");n.setAttribute("width",String(t)),n.setAttribute("height",String(t)),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"),n.setAttribute("aria-hidden","true");for(const r of e){const i=document.createElementNS(a,"path");i.setAttribute("d",r),n.appendChild(i)}return n}var ma="General",Cn=220,sc=6;function cc(e){if(typeof e!="string")return[ma];const t=e.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return t.length===0?[ma]:Array.from(new Set(t.map(a=>a.toLocaleLowerCase()))).map(a=>t.find(n=>n.toLocaleLowerCase()===a)??ma)}function lc(e){return e==="positive"||e==="negative"||e==="neutral"?e:"neutral"}function gc(e){if(typeof e!="string")return"";const t=e.trim().replace(/\s+/g," ");return t.length<=Cn?t:`${t.slice(0,Cn-3).trimEnd()}...`}function dc(e){return e.positive>e.negative?"positive":e.negative>e.positive?"negative":"neutral"}function pc(e){return Pt(e==="positive"?["M7 17 17 7","M7 7h10v10"]:e==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function hc(e,t="1 customer mentions",a="customers mention"){return e===1?t:`${e} ${a}`}function uc(e,t){const a=document.createElement("div");a.className="gengage-chat-review-highlights";const n=e.props?.reviews;if(!Array.isArray(n)||n.length===0){const m=document.createElement("div");return m.className="gengage-chat-review-empty",m.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(m),a}const r=n.filter(m=>m!==null&&typeof m=="object"),i=new Map;for(const m of r){const f=lc(m.review_class),u=gc(m.review_text),A=cc(m.review_tag);for(const P of A){const x=P.toLocaleLowerCase();let E=i.get(x);if(E||(E={key:x,label:P,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},i.set(x,E)),E.mentions+=1,f==="positive"?E.positive+=1:f==="negative"?E.negative+=1:E.neutral+=1,u.length>0&&E.snippets.length<sc&&!E.snippets.some(T=>T.text===u)){const T={text:u,tone:f};m.review_rating!==void 0&&String(m.review_rating).length>0&&(T.rating=m.review_rating),E.snippets.push(T)}}}const o=Array.from(i.values()).sort((m,f)=>f.mentions!==m.mentions?f.mentions-m.mentions:m.label.localeCompare(f.label));if(o.length===0){const m=document.createElement("div");return m.className="gengage-chat-review-empty",m.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(m),a}const s=(t?.reviewFilterPositive??"positive").toLowerCase(),c=(t?.reviewFilterNegative??"negative").toLowerCase(),l=document.createElement("div");l.className="gengage-chat-review-subjects-heading",l.textContent=t?.reviewSubjectsHeading??"Select to learn more",a.appendChild(l);let g=o[0]?.key??null;const d=document.createElement("div");d.className="gengage-chat-review-subjects gds-toolbar gds-toolbar-compact";const p=document.createElement("section");p.className="gengage-chat-review-detail gds-evidence-card";const h=()=>{for(;p.firstChild;)p.removeChild(p.firstChild);if(!g)return;const m=o.find(P=>P.key===g);if(!m)return;const f=document.createElement("div");f.className="gengage-chat-review-detail-meta";const u=document.createElement("span");if(u.className="gengage-chat-review-detail-mentions",u.textContent=`${hc(m.mentions,t?.reviewCustomersMentionSingular,t?.reviewCustomersMentionPlural)} "${m.label}"`,f.appendChild(u),m.positive>0){const P=document.createElement("span");P.className="gengage-chat-review-detail-positive",P.textContent=`${m.positive} ${s}`,f.appendChild(P)}if(m.negative>0){const P=document.createElement("span");P.className="gengage-chat-review-detail-negative",P.textContent=`${m.negative} ${c}`,f.appendChild(P)}p.appendChild(f);const A=document.createElement("div");A.className="gengage-chat-review-snippets";for(const P of m.snippets){const x=document.createElement("article");x.className="gengage-chat-review-snippet",x.dataset.tone=P.tone;const E=document.createElement("div");if(E.className="gengage-chat-review-snippet-text",E.textContent=`"${P.text}"`,x.appendChild(E),P.rating!==void 0&&String(P.rating).length>0){const T=document.createElement("div");T.className="gengage-chat-review-snippet-rating",T.textContent=`★ ${String(P.rating)}`,x.appendChild(T)}A.appendChild(x)}p.appendChild(A)},v=()=>{for(const m of d.querySelectorAll(".gengage-chat-review-subject")){const f=m.dataset.subjectKey===g;m.classList.toggle("gengage-chat-review-subject--active",f),m.classList.toggle("gds-chip-active",f),m.setAttribute("aria-pressed",String(f))}};for(const m of o){const f=dc(m),u=document.createElement("button");u.type="button",u.className="gengage-chat-review-subject gds-chip",u.dataset.subjectKey=m.key,u.dataset.tone=f;const A=document.createElement("span");A.className="gengage-chat-review-subject-icon",A.appendChild(pc(f)),u.appendChild(A);const P=document.createElement("span");P.className="gengage-chat-review-subject-label",P.textContent=m.label,u.appendChild(P);const x=document.createElement("span");x.className="gengage-chat-review-subject-count",x.textContent=`(${m.mentions})`,u.appendChild(x),u.addEventListener("click",()=>{g=m.key,v(),h()}),d.appendChild(u)}return a.appendChild(d),v(),h(),a.appendChild(p),a}function mc(e){if(!e)return;const t=e.discountReason??e.discount_reason??e.campaignReason??e.campaign_reason;if(typeof t!="string")return;const a=t.trim();return a.length>0?a:void 0}function ut(e,t){if(e.productPriceUi?.showCampaignReason===!0)return mc(t)}function Tt(e,t){const a=t?.originalPriceStyle??t?.price_original_style;if(a==="inline"||a==="strikethrough")return a;const n=e.productPriceUi?.originalPriceStyle;return n==="inline"||n==="strikethrough"?n:"strikethrough"}function Dt(e){const t=document.createElement("div");return t.className="gengage-chat-campaign-reason",t.textContent=e,t}function Ft(e,t){for(const n of["campaignReasonLogoUrl","campaign_reason_logo_url","discountBadgeLogoUrl","discount_badge_logo_url"]){const r=t?.[n];if(typeof r=="string"&&r.trim()){const i=r.trim();if(Ue(i))return i}}const a=e.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(Ue(n))return n}}function Ht(e){const t=document.createElement("div");if(t.className="gengage-chat-campaign-price-badge",t.dataset.gengagePart="campaign-price-badge",e.logoUrl){const i=document.createElement("div");i.className="gengage-chat-campaign-price-badge__logo";const o=document.createElement("img");o.alt="",o.loading="lazy",o.src=e.logoUrl,Be(o),i.appendChild(o),t.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-campaign-price-badge__body";const n=document.createElement("div");n.className="gengage-chat-campaign-price-badge__reason",n.textContent=e.reasonText;const r=document.createElement("span");return r.className="gengage-chat-campaign-price-badge__sale",r.textContent=e.salePriceFormatted,a.appendChild(n),a.appendChild(r),t.appendChild(a),t}function fc(){try{return globalThis.GENGAGE_TOPPICKS_MOBILE_LAYOUT==="uniform"}catch{return!1}}function Sn(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const a=e.action?.payload;return a&&typeof a=="object"&&"sku"in a&&typeof a.sku=="string"?a.sku:null}var bc={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function En(e,t){if(!e||!t)return null;const a=bc[e];return a?t[a]??e:e}function vc(e){const t=e.rating,a=typeof t=="number"?t:typeof t=="string"?parseFloat(t):NaN;if(Number.isNaN(a)||a<=0)return null;const n=document.createElement("div");n.className="gengage-chat-ai-toppick-rating",n.dataset.gengagePart="ai-top-pick-rating";const r=document.createElement("span");r.className="gengage-chat-ai-toppick-rating-icon",r.setAttribute("aria-hidden","true"),r.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const i=document.createElement("span");return i.className="gengage-chat-ai-toppick-rating-value",i.textContent=a.toFixed(1),n.appendChild(r),n.appendChild(i),n}function yc(e,t,a,n,r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-media",i.dataset.gengagePart="ai-top-pick-media";const o=e.product,s=o.imageUrl;if(s&&Ue(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",ve(l,"src",s),l.loading="lazy",l.alt=t,Be(l),i.appendChild(l)}const c=Sn(e);if(c&&!r?.skipOverlayActions){const l=document.createElement("div");if(l.className="gengage-chat-product-card-img-actions",n.onFavoriteToggle){const h=document.createElement("button");h.className="gengage-chat-favorite-btn",h.type="button",h.dataset.gengageFavoriteSku=c,h.setAttribute("aria-label",n.i18n?.addToFavoritesLabel??"Add to favorites");const v=n.favoritedSkus?.has(c)??!1;v&&h.classList.add("gengage-chat-favorite-btn--active"),h.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${v?"currentColor":"none"}" 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>`,h.addEventListener("click",m=>{m.stopPropagation(),h.classList.toggle("gengage-chat-favorite-btn--active"),h.querySelector("svg")?.setAttribute("fill",h.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),n.onFavoriteToggle?.(c,o)}),l.appendChild(h)}const g=n.i18n?.findSimilarLabel??"Find Similar",d=document.createElement("button");d.className="gengage-chat-find-similar-pill",d.type="button",d.setAttribute("aria-label",g),d.dataset.tooltip=g,d.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const p=document.createElement("span");p.className="gengage-chat-find-similar-pill-text",p.textContent=g,d.appendChild(p),d.addEventListener("click",h=>{h.stopPropagation(),n.onAction({title:g,type:"findSimilar",payload:{sku:c}})}),l.appendChild(d),i.appendChild(l)}a.appendChild(i)}function xc(e,t,a){const n=e.price,r=e.originalPrice;if(!n)return;const i=ut(a,e),o=Tt(a,e),s=!!(r&&r!==n),c=!!(i&&s),l=Ft(a,e),g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",g.dataset.gengagePart="ai-top-pick-price",c){const d=Ht({reasonText:i,salePriceFormatted:ie(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline"),g.appendChild(d);const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-sep",p.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=ie(r,a.pricing),g.appendChild(p),g.appendChild(h)}else{const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=ie(r,a.pricing),g.appendChild(p),g.appendChild(document.createTextNode(" ")),g.appendChild(d)}t.appendChild(g);return}if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=ie(n,a.pricing);const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-sep",p.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=ie(r,a.pricing),g.appendChild(d),g.appendChild(p),g.appendChild(h)}else if(s){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=ie(r,a.pricing),g.appendChild(d),g.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=ie(n,a.pricing),g.appendChild(p)}else{const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=ie(n,a.pricing),g.appendChild(d)}if(i){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price-stack",d.appendChild(Dt(i)),d.appendChild(g),t.appendChild(d)}else t.appendChild(g)}function _c(e,t,a){const n=typeof e.reason=="string"?e.reason.trim():"",r=a.hideUserReviews!==!0&&typeof e.reviewHighlight=="string"?e.reviewHighlight.trim():"";if(!(!n&&!r)){if(n){const i=document.createElement("p");i.className="gengage-chat-ai-toppick-reason",i.dataset.gengagePart="ai-top-pick-reason",i.textContent=n,t.appendChild(i)}if(r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-review",i.dataset.gengagePart="ai-top-pick-review",i.textContent=r,t.appendChild(i)}}}function Pn(e,t,a,n){const r=document.createElement("div");r.className=a?"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner gds-card":"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact gds-card";const i=n?.uniformMobileLayout===!0;!a&&i&&r.classList.add("gengage-chat-ai-toppick-card--mobile-uniform"),r.dataset.gengagePart=a?"ai-top-pick-card-winner":"ai-top-pick-card";const o=e.product,s=Sn(e),c=o.url??"",l=o.cartCode,g=o.inStock,d=!!(s&&l&&g!==!1),p=e.action;s&&t.onProductClick?(r.classList.add("gds-clickable"),r.addEventListener("click",w=>{if(w.target.closest(".gengage-chat-ai-toppick-cta")||w.target.closest(".gengage-chat-favorite-btn")||w.target.closest(".gengage-chat-find-similar-pill"))return;const C=o.name;t.onProductClick?.({sku:s,url:c,...C?{name:C}:{}})})):p&&(r.classList.add("gds-clickable"),r.addEventListener("click",w=>{w.target.closest(".gengage-chat-ai-toppick-cta")||w.target.closest(".gengage-chat-favorite-btn")||w.target.closest(".gengage-chat-find-similar-pill")||t.onAction(p)}));const h=o.name||"Product image",v=!a&&t.isMobile===!0&&!i,m=a?En(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":En(e.role,t.i18n);if(m&&!v){const w=document.createElement("span");w.className="gengage-chat-ai-toppick-badge gds-badge",w.dataset.gengagePart="ai-top-pick-role-badge",w.textContent=m,r.appendChild(w)}const f=document.createElement("div");f.className="gengage-chat-ai-toppick-top-row",f.dataset.gengagePart="ai-top-pick-top-row",yc(e,h,f,t,{skipOverlayActions:v});const u=document.createElement("div");if(u.className="gengage-chat-ai-toppick-body",u.dataset.gengagePart="ai-top-pick-body",m&&v){const w=document.createElement("div");w.className="gengage-chat-ai-toppick-role-line",w.dataset.gengagePart="ai-top-pick-role-line",w.textContent=m,u.appendChild(w)}const A=o.name;if(A){const w=document.createElement("div");w.className="gengage-chat-ai-toppick-name",w.dataset.gengagePart="ai-top-pick-name",w.textContent=A,u.appendChild(w)}const P=vc(o);P&&u.appendChild(P),xc(o,u,t),e.labels&&e.labels.length>0&&u.appendChild(kc(e.labels)),f.appendChild(u),r.appendChild(f);const x=document.createElement("div");if(x.className="gengage-chat-ai-toppick-detail",x.dataset.gengagePart="ai-top-pick-detail",a)_c(e,x,t);else{const w=typeof e.reason=="string"?e.reason.trim():"";if(w){const C=document.createElement("p");C.className="gengage-chat-ai-toppick-snippet",C.dataset.gengagePart="ai-top-pick-snippet",C.textContent=w,x.appendChild(C)}}x.childNodes.length>0&&r.appendChild(x);const E=!!(s&&t.topPicksLoadingSku===s),T=(d||p)&&!v;if(E||d||p){const w=document.createElement("div");if(w.className="gengage-chat-ai-toppick-spinner",w.dataset.gengagePart="ai-top-pick-spinner",w.style.display=E?"":"none",r.appendChild(w),T){const C=document.createElement("button");C.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",C.dataset.gengagePart="ai-top-pick-cta",C.type="button",C.textContent=d?t.i18n?.addToCartButton??"Add to Cart":t.i18n?.viewDetails??"View Details",C.addEventListener("click",B=>{if(B.stopPropagation(),d){t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:s,cartCode:l,quantity:1}});return}if(p){if(p.type==="findSimilar"&&s&&t.onProductClick){const W=o.name;t.onProductClick({sku:s,url:c,...W?{name:W}:{}});return}t.onAction(p)}}),r.appendChild(C)}}return r}function wc(e,t){const a=document.createElement("div");a.className="gengage-chat-ai-top-picks",a.dataset.gengagePart="ai-top-picks";const n=e.props?.suggestions??[];if(n.length===0)return a;const r=document.createElement("div");r.className="gengage-chat-ai-top-picks-scroll",r.dataset.gengagePart="ai-top-picks-scroll";const i=t.isMobile===!0&&fc(),o=n[0];if(r.appendChild(Pn(o,t,!0,{uniformMobileLayout:i})),n.length>1){const s=document.createElement("div");s.className="gengage-chat-ai-top-picks-rest",i&&s.classList.add("gengage-chat-ai-top-picks-rest--uniform-mobile"),s.dataset.gengagePart="ai-top-picks-rest";for(let c=1;c<n.length;c++){const l=n[c],g=l.role==="winner";s.appendChild(Pn(l,t,g,{uniformMobileLayout:i}))}r.appendChild(s)}return a.appendChild(r),a}function kc(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels",t.dataset.gengagePart="ai-top-pick-labels";for(const a of e){const n=document.createElement("span");n.className="gengage-chat-ai-toppick-label gds-chip",n.dataset.gengagePart="ai-top-pick-label",n.dataset.sentiment=a.sentiment??"neutral",n.textContent=a.label,t.appendChild(n)}return t}function Cc(e,t){const a=document.createElement("div");a.className="gengage-chat-grounding-review gds-evidence-card",a.dataset.gengagePart="grounding-review-card";const n=e.props??{},r=n.title,i=n.reviewCount,o=n.action,s=t.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.appendChild(Pt(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z","M8 9h8","M8 13h6"])),a.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body",l.dataset.gengagePart="grounding-review-body";const g=document.createElement("div");if(g.className="gengage-chat-grounding-review-title",g.dataset.gengagePart="grounding-review-title",g.textContent=r??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(g),i){const v=document.createElement("div");v.className="gengage-chat-grounding-review-subtitle",v.dataset.gengagePart="grounding-review-subtitle",v.textContent=(t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut").replace("{count}",i),l.appendChild(v)}a.appendChild(l);const d=document.createElement("span");d.className="gengage-chat-grounding-review-cta",d.dataset.gengagePart="grounding-review-cta";const p=document.createElement("span");p.textContent=s,d.appendChild(p);const h=document.createElement("span");return h.className="gengage-chat-grounding-review-cta-icon",h.appendChild(Pt(["M5 12h14","M15 8l4 4-4 4"],14)),d.appendChild(h),a.appendChild(d),o&&(a.classList.add("gds-clickable"),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.addEventListener("click",()=>t.onAction(o)),a.addEventListener("keydown",v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),t.onAction(o))})),a}function Sc(e){const t=e.action.type;if(t!=="findSimilar")return e.action;const a=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,n=typeof a?.input=="string"&&a.input.trim()||typeof a?.text=="string"&&a.text.trim()||e.name.trim();if(!n)return e.action;const r={...a??{},text:n,is_suggested_text:1};return typeof a?.input=="string"&&a.input.trim()?r.input=a.input:delete r.input,{title:e.action.title,type:t,payload:Rt(r)}}function Ec(e,t){const a=document.createElement("div");a.className="gengage-chat-grouping-cards",a.dataset.gengagePart="ai-grouping-cards";const n=e.props?.entries??[];if(n.length===0)return a;const r=e.props?.sectionTitle,i=typeof r=="string"&&r.trim().length>0?r.trim():t.i18n?.aiBrowseCategoriesTitle;if(i){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=i,a.appendChild(s)}const o=document.createElement("div");o.className="gengage-chat-grouping-cards-scroll",o.dataset.gengagePart="ai-grouping-cards-scroll";for(const s of n){const c=document.createElement("div");if(c.className="gengage-chat-grouping-card gds-card",c.dataset.gengagePart="ai-grouping-card",c.classList.add("gds-clickable"),c.addEventListener("click",()=>t.onAction(Sc(s))),s.image&&Ue(s.image)){const p=document.createElement("img");p.className="gengage-chat-grouping-card-img",p.dataset.gengagePart="ai-grouping-card-image",p.draggable=!1,p.src=s.image,p.alt=s.name,p.width=64,p.height=64,c.appendChild(p)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body",l.dataset.gengagePart="ai-grouping-card-body";const g=document.createElement("span");if(g.className="gengage-chat-grouping-card-name",g.dataset.gengagePart="ai-grouping-card-name",g.textContent=s.name,l.appendChild(g),s.labels&&s.labels.length>0){const p=document.createElement("div");p.className="gengage-chat-grouping-card-labels",p.dataset.gengagePart="ai-grouping-card-labels";for(const h of s.labels.slice(0,2)){const v=document.createElement("span");v.className="gengage-chat-grouping-card-label gds-chip",v.textContent=h,p.appendChild(v)}l.appendChild(p)}c.appendChild(l);const d=document.createElement("span");d.className="gengage-chat-grouping-card-arrow",d.textContent="↳",c.insertBefore(d,c.firstChild),o.appendChild(c)}return a.appendChild(o),a}function Pc(e,t){const a=document.createElement("div");a.className="gengage-chat-suggested-search-cards",a.dataset.gengagePart="ai-suggested-search-cards";const n=e.props?.entries??[];if(n.length===0)return a;for(const r of n){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card gds-card",i.dataset.gengagePart="ai-suggested-search-card",i.classList.add("gds-clickable"),i.addEventListener("click",()=>t.onAction(r.action)),r.image&&Ue(r.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.dataset.gengagePart="ai-suggested-search-card-image",c.src=r.image,c.alt=r.shortName,c.width=64,c.height=64,i.appendChild(c)}const o=document.createElement("div");o.className="gengage-chat-suggested-search-card-body",o.dataset.gengagePart="ai-suggested-search-card-body";const s=document.createElement("div");s.className="gengage-chat-suggested-search-card-name",s.dataset.gengagePart="ai-suggested-search-card-name",s.textContent=r.shortName,o.appendChild(s),i.appendChild(o),a.appendChild(i)}return a}function Tn(e,t){const a=e.length>=2,n=t.i18n?.compareSelected??"Compare",r=t.comparisonSelectionWarning,i=document.createElement("div");i.className="gengage-chat-comparison-floating-btn",i.dataset.gengagePart="comparison-dock";const o=document.createElement("div");o.className="gengage-chat-comparison-floating-summary";const s=document.createElement("span");s.className="gengage-chat-comparison-floating-count",s.textContent=String(e.length),o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-floating-copy";const l=document.createElement("div");if(l.className="gengage-chat-comparison-floating-title",l.textContent=a?`${n} (${e.length})`:t.i18n?.compareMinHint??"Select at least 2 products",c.appendChild(l),r){const d=document.createElement("div");d.className="gengage-chat-comparison-floating-warning",d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.textContent=r,c.appendChild(d)}o.appendChild(c),i.appendChild(o);const g=document.createElement("button");if(g.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",g.type="button",g.textContent=n,g.disabled=!a,a||g.classList.add("gengage-chat-comparison-floating-action--disabled"),g.addEventListener("click",()=>{a&&t.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...e],gengage_analytics_source:"floating_compare_dock"}})}),i.appendChild(g),t.onToggleComparisonSku){const d=document.createElement("button");d.className="gengage-chat-comparison-floating-close gds-btn gds-btn-ghost gds-icon-btn",d.dataset.gengagePart="comparison-dock-close",d.type="button",d.setAttribute("aria-label",t.i18n?.closeAriaLabel??"Close"),d.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',d.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),t.onToggleComparisonSku?.("")}),i.appendChild(d)}return i}function Tc(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons gds-card-soft",t.dataset.gengagePart="pros-cons";const a=e.props?.productName;if(a){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=a,t.appendChild(i)}const n=e.props?.pros,r=e.props?.cons;if(n&&n.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="pros-list";for(const o of n){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="pros-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=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(r&&r.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="cons-list";for(const o of r){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="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=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}function Ac(e,t){const a=e.props?.groups??[],n=e.props?.filterTags??[],r=document.createElement("div");if(r.className="gengage-chat-categories",r.dataset.gengagePart="categories-container",a.length===0)return r;const i=document.createElement("div");i.className="gengage-chat-categories-tabs gds-toolbar",i.dataset.gengagePart="categories-tab-bar",i.setAttribute("role","tablist");const o=[],s=[],c=l=>{for(let g=0;g<o.length;g++){const d=g===l;o[g].classList.toggle("gengage-chat-categories-tab--active",d),o[g].classList.toggle("is-active",d),o[g].setAttribute("aria-selected",String(d)),o[g].tabIndex=d?0:-1,s[g].style.display=d?"":"none"}};for(let l=0;l<a.length;l++){const g=a[l],d=`gengage-cat-tab-${l}`,p=`gengage-cat-panel-${l}`,h=document.createElement("button");if(h.className="gengage-chat-categories-tab gds-tab",h.type="button",h.dataset.gengagePart="categories-tab",h.id=d,h.setAttribute("role","tab"),h.setAttribute("aria-controls",p),h.setAttribute("aria-selected",String(l===0)),h.tabIndex=l===0?0:-1,l===0&&h.classList.add("gengage-chat-categories-tab--active","is-active"),g.image&&Ue(g.image)){const f=document.createElement("img");f.className="gengage-chat-categories-tab-image",f.draggable=!1,f.src=g.image,f.alt=g.groupName,f.loading="lazy",Be(f),h.appendChild(f)}const v=document.createElement("span");v.className="gengage-chat-categories-tab-text",v.textContent=g.groupName,h.appendChild(v),h.addEventListener("click",()=>c(l)),h.addEventListener("keydown",f=>{let u=-1;f.key==="ArrowRight"||f.key==="ArrowDown"?u=(l+1)%a.length:f.key==="ArrowLeft"||f.key==="ArrowUp"?u=(l-1+a.length)%a.length:f.key==="Home"?u=0:f.key==="End"&&(u=a.length-1),u>=0&&(f.preventDefault(),c(u),o[u].focus())}),o.push(h),i.appendChild(h);const m=document.createElement("div");m.className="gengage-chat-categories-grid",m.dataset.gengagePart="categories-panel",m.id=p,m.setAttribute("role","tabpanel"),m.setAttribute("aria-labelledby",d),l!==0&&(m.style.display="none");for(const f of g.products){const u=Lc(f,t);m.appendChild(u)}s.push(m)}r.appendChild(i);for(const l of s)r.appendChild(l);if(n.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags gds-toolbar",l.dataset.gengagePart="categories-filter-tags";for(const g of n){const d=document.createElement("button");d.className="gengage-chat-categories-filter-tag gds-chip",d.type="button",d.dataset.gengagePart="categories-filter-tag",d.textContent=g.title,g.action&&d.addEventListener("click",()=>{t.onAction(g.action)}),l.appendChild(d)}r.appendChild(l)}return r}function Lc(e,t){const a=document.createElement("div");if(a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive",a.dataset.gengagePart="categories-product-card",e.imageUrl&&Ue(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.draggable=!1,i.src=e.imageUrl,i.alt=e.name,i.loading="lazy",Be(i),a.appendChild(i)}const n=document.createElement("div");n.className="gengage-chat-product-card-body";const r=document.createElement("div");if(r.className="gengage-chat-product-card-name",r.textContent=e.name,n.appendChild(r),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=ie(e.price,t.pricing),n.appendChild(i)}return a.appendChild(n),(t.onProductSelect||t.onAction)&&(a.classList.add("gds-clickable"),a.addEventListener("click",()=>{if(e.sku){t.onAction({title:e.name,type:"launchSingleProduct",payload:{sku:e.sku}});return}t.onProductSelect?.(e)})),a}function Ic(e,t){const a=document.createElement("div");a.className="gengage-chat-handoff-notice gds-evidence-card gds-evidence-card-warning",a.dataset.gengagePart="handoff-notice",a.setAttribute("role","alert");const n=document.createElement("span");n.className="gengage-chat-handoff-notice-icon",n.textContent="👤",n.setAttribute("aria-hidden","true"),a.appendChild(n);const r=document.createElement("h4");r.className="gengage-chat-handoff-notice-heading",r.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",a.appendChild(r);const i=e.props?.summary;if(i){const o=document.createElement("p");o.className="gengage-chat-handoff-notice-summary",o.textContent=i,a.appendChild(o)}return a}var Nc="frontend_restore_panel_message";function Je(e){return typeof e=="string"?e:""}function zc(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t;return{imageUrl:Je(a.imageUrl)||void 0,name:Je(a.name)||void 0}}).filter(t=>t!==null):[]}function Mc(e,t){const a=e.props??{},n=Je(a.eyebrow),r=Je(a.title),i=a.showTitle!==!1,o=Je(a.ctaLabel)||t.i18n?.showPanelAriaLabel||"Show Results",s=Je(a.panelMessageId),c=Je(a.highlightMessageId),l=Je(a.threadId),g=zc(a.products).slice(0,3),d=document.createElement("button");d.type="button",d.className="gengage-chat-panel-restore-card gds-card",!n&&!i&&d.classList.add("gengage-chat-panel-restore-card--minimal"),d.dataset.gengagePart="panel-restore-card";const p=r||n||o;d.setAttribute("aria-label",r?`${p} - ${o}`:p);const h={title:r,type:Nc,payload:{panelMessageId:s,highlightMessageId:c,threadId:l}};if(d.addEventListener("click",()=>t.onAction(h)),n){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__eyebrow",m.textContent=n,d.appendChild(m)}if(g.length>0){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__previews";for(const f of g){const u=document.createElement("div");u.className="gengage-chat-panel-restore-card__thumb";const A=f.imageUrl;if(A&&we(A)){const P=document.createElement("img");P.loading="lazy",P.alt=f.name||r,ve(P,"src",A),Be(P),u.appendChild(P)}m.appendChild(u)}d.appendChild(m)}if(i&&r){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__title",m.textContent=r,m.title=r,d.appendChild(m)}const v=document.createElement("div");return v.className="gengage-chat-panel-restore-card__cta",v.textContent=o,d.appendChild(v),d}function Bc(e,t){const a=e.props?.product??e.props,n=document.createElement("div");if(n.className="gengage-chat-product-summary gds-card",n.dataset.gengagePart="product-summary-card",!a)return n;n.classList.add("gds-clickable"),n.addEventListener("click",u=>{u.target.closest("a")||t.onProductSelect?.(a)});const r=a.imageUrl;if(r&&we(r)){const u=document.createElement("div");u.className="gengage-chat-product-summary__image",u.dataset.gengagePart="product-summary-image";const A=document.createElement("img");A.loading="lazy",ve(A,"src",r),A.alt=a.name||"Product image",Be(A),u.appendChild(A),n.appendChild(u)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content",i.dataset.gengagePart="product-summary-content";const o=a.brand,s=a.name;if(s){const u=document.createElement("div");u.className="gengage-chat-product-summary__name",u.dataset.gengagePart="product-summary-name";const A=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;u.textContent=A,u.title=A,i.appendChild(u)}const c=a.rating,l=a.reviewCount;if(t.hideUserReviews!==!0&&typeof c=="number"&&Number.isFinite(c)&&c>0){const u=document.createElement("div");if(u.className="gengage-chat-product-summary__rating",u.dataset.gengagePart="product-summary-rating",u.appendChild(_n(c)),typeof l=="number"&&Number.isFinite(l)){const A=document.createElement("span");A.className="gengage-chat-product-summary__review-count",A.textContent=` (${l})`,u.appendChild(A)}i.appendChild(u)}const g=a.price,d=a.originalPrice;if(g){const u=ut(t,a),A=Tt(t,a),P=!!(d&&d!==g),x=document.createElement("div");x.className="gengage-chat-product-summary__price",x.dataset.gengagePart="product-summary-price";const E=!!(u&&P),T=Ft(t,a);if(E){const w=Ht({reasonText:u,salePriceFormatted:ie(g,t.pricing),...T!==void 0?{logoUrl:T}:{}});if(P&&A==="inline"){x.classList.add("gengage-chat-product-summary__price--inline"),x.appendChild(w);const C=document.createElement("span");C.className="gengage-chat-product-summary__price-sep",C.setAttribute("aria-hidden","true");const B=document.createElement("span");B.className="gengage-chat-product-summary__price-original",B.textContent=ie(d,t.pricing),x.appendChild(C),x.appendChild(B)}else{const C=document.createElement("span");C.className="gengage-chat-product-summary__price-original",C.textContent=ie(d,t.pricing),x.appendChild(C),x.appendChild(document.createTextNode(" ")),x.appendChild(w)}i.appendChild(x)}else{if(P&&A==="inline"){x.classList.add("gengage-chat-product-summary__price--inline");const w=document.createElement("span");w.className="gengage-chat-product-summary__price-current",w.textContent=ie(g,t.pricing);const C=document.createElement("span");C.className="gengage-chat-product-summary__price-sep",C.setAttribute("aria-hidden","true");const B=document.createElement("span");B.className="gengage-chat-product-summary__price-original",B.textContent=ie(d,t.pricing),x.appendChild(w),x.appendChild(C),x.appendChild(B)}else if(P){const w=document.createElement("span");w.className="gengage-chat-product-summary__price-original",w.textContent=ie(d,t.pricing),x.appendChild(w),x.appendChild(document.createTextNode(" "));const C=document.createElement("span");C.className="gengage-chat-product-summary__price-current",C.textContent=ie(g,t.pricing),x.appendChild(C)}else{const w=document.createElement("span");w.className="gengage-chat-product-summary__price-current",w.textContent=ie(g,t.pricing),x.appendChild(w)}if(u){const w=document.createElement("div");w.className="gengage-chat-product-summary__price-stack",w.appendChild(Dt(u)),w.appendChild(x),i.appendChild(w)}else i.appendChild(x)}}n.appendChild(i);const p=a.url,h=a.sku,v=a.cartCode??a.cart_code,m=typeof v=="string"&&v.trim()?v.trim():void 0,f=a.inStock;if(h&&m&&f!==!1){const u=document.createElement("button");u.type="button",u.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",u.dataset.gengagePart="product-summary-cta",u.textContent=t.i18n?.addToCartButton??"Add to Cart",u.addEventListener("click",A=>{A.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:h,cartCode:m,quantity:1}})}),n.appendChild(u)}else if(p&&we(p)){const u=document.createElement("a");u.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",u.dataset.gengagePart="product-summary-cta",ve(u,"href",p),ve(u,"target","_blank"),ve(u,"rel","noopener noreferrer"),u.textContent=t.i18n?.productCtaLabel??"View",n.appendChild(u)}return n}var Rc={PhotoAnalysisCard:({element:e,context:t})=>Ms(e,t),BeautyPhotoStep:({element:e,context:t})=>pn(e,t)};function fa(){return window.innerWidth<768}var An={ActionButtons:({element:e,context:t})=>Oc(e,t),ActionButton:({element:e,context:t})=>Dc(e,t),ProductCard:({element:e,context:t})=>va(e,t),ProductDetailsPanel:({element:e,context:t})=>il(e,t),ProductGrid:({element:e,spec:t,renderElement:a,context:n})=>hl(e,t,a,n),ReviewHighlights:({element:e,context:t})=>t.hideUserReviews===!0?null:uc(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage,reviewFilterPositive:t.i18n?.reviewFilterPositive,reviewFilterNegative:t.i18n?.reviewFilterNegative,reviewCustomersMentionSingular:t.i18n?.reviewCustomersMentionSingular,reviewCustomersMentionPlural:t.i18n?.reviewCustomersMentionPlural,reviewSubjectsHeading:t.i18n?.reviewSubjectsHeading}),ComparisonTable:({element:e,context:t})=>ul(e,t),AITopPicks:({element:e,context:t})=>wc(e,t),GroundingReviewCard:({element:e,context:t})=>t.hideUserReviews===!0?null:Cc(e,t),AIGroupingCards:({element:e,context:t})=>Ec(e,t),AISuggestedSearchCards:({element:e,context:t})=>Pc(e,t),ProsAndCons:({element:e})=>Tc(e),CategoriesContainer:({element:e,context:t})=>Ac(e,t),HandoffNotice:({element:e,context:t})=>Ic(e,t),PanelRestoreCard:({element:e,context:t})=>Mc(e,t),ProductSummaryCard:({element:e,context:t})=>Bc(e,t),Divider:({element:e})=>ml(e),...Rc},ba=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const a=document.createElement("div");for(const n of e.children){const r=t(n);r&&a.appendChild(r)}return a};function Ln(){return{...An}}function In(e,t,a=An,n=ba){return di({spec:e,context:t,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function Oc(e,t){const a=document.createElement("div");a.className="gengage-chat-action-buttons";const n=e.props?.buttons;if(n)for(const r of n){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=r.label,i.addEventListener("click",()=>t.onAction(r.action)),a.appendChild(i)}return a}function Dc(e,t){const a=document.createElement("button");a.className="gengage-chat-action-btn";const n=e.props?.label;typeof n=="string"&&(a.textContent=n);const r=e.props?.action;return r&&a.addEventListener("click",()=>t.onAction(r)),a}function Nn(e,t,a,n,r){e.replaceChildren();const i=Tt(t,a),o=!!(r&&n&&r!==n),s=ut(t,a),c=!!(s&&o),l=Ft(t,a);if(!n||parseFloat(n)<=0)return;if(c){const d=Ht({reasonText:s,salePriceFormatted:ie(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const p=document.createElement("div");p.className="gengage-chat-product-card-price-row",p.appendChild(d);const h=document.createElement("span");h.className="gengage-chat-product-card-price-sep",h.setAttribute("aria-hidden","true");const v=document.createElement("span");v.className="gengage-chat-product-card-original-price",v.textContent=ie(r,t.pricing),p.appendChild(h),p.appendChild(v),e.appendChild(p);return}if(e.classList.remove("gengage-chat-product-card-price-block--inline"),e.appendChild(d),o){e.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-product-card-original-price",p.textContent=ie(r,t.pricing),e.appendChild(p)}return}if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const d=document.createElement("div");d.className="gengage-chat-product-card-price-row";const p=document.createElement("span");p.className="gengage-chat-product-card-current-price",p.textContent=ie(n,t.pricing);const h=document.createElement("span");h.className="gengage-chat-product-card-price-sep",h.setAttribute("aria-hidden","true");const v=document.createElement("span");v.className="gengage-chat-product-card-original-price",v.textContent=ie(r,t.pricing),d.appendChild(p),d.appendChild(h),d.appendChild(v),e.appendChild(d);return}e.classList.remove("gengage-chat-product-card-price-block--inline");const g=document.createElement("span");if(g.className="gengage-chat-product-card-current-price",g.textContent=ie(n,t.pricing),e.appendChild(g),o){e.appendChild(document.createTextNode(" "));const d=document.createElement("span");d.className="gengage-chat-product-card-original-price",d.textContent=ie(r,t.pricing),e.appendChild(d)}}function zn(e,t,a,n,r,i,o){e.classList.remove("gengage-chat-product-details-price--inline"),e.replaceChildren(),e.className="gengage-chat-product-details-price";const s=ut(t,a),c=!!(s&&o),l=Ft(t,a);if(c){const d=Ht({reasonText:s,salePriceFormatted:ie(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline"),e.appendChild(d);const p=document.createElement("span");p.className="gengage-chat-product-details-price-sep",p.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=ie(r,t.pricing),e.appendChild(p),e.appendChild(h)}else{if(o){const p=document.createElement("span");p.className="gengage-chat-product-details-original-price",p.textContent=ie(r,t.pricing),e.appendChild(p),e.appendChild(document.createTextNode(" "))}e.appendChild(d)}}else if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline");const d=document.createElement("span");d.className="gengage-chat-product-details-current-price",d.textContent=ie(n,t.pricing);const p=document.createElement("span");p.className="gengage-chat-product-details-price-sep",p.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=ie(r,t.pricing),e.appendChild(d),e.appendChild(p),e.appendChild(h)}else{if(o){const p=document.createElement("span");p.className="gengage-chat-product-details-original-price",p.textContent=ie(r,t.pricing),e.appendChild(p),e.appendChild(document.createTextNode(" "))}const d=document.createElement("span");d.className="gengage-chat-product-details-current-price",d.textContent=ie(n,t.pricing),e.appendChild(d)}const g=$t(a,"discountPercent","price_discount_rate");if(!t.hideProductDiscountBadge&&typeof g=="number"&&g>0){const d=document.createElement("span");d.className="gengage-chat-product-details-discount-badge",d.textContent=`%${xn(g)}`,e.appendChild(d)}}function va(e,t){const a=document.createElement("div");a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive";const n=e.props?.product??e.props;if(!n)return a;const r=n.sku;r&&(a.dataset.sku=r);const i=e.props?.action;(t.onProductSelect||i)&&(a.classList.add("gds-clickable"),a.addEventListener("click",b=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!b.target.closest(".gengage-chat-product-card-atc")&&!b.target.closest(".gengage-chat-product-card-cta")){if(i){t.onAction(i);return}t.onProductSelect?.(n)}}));const o=n.imageUrl;if(o&&we(o)){const b=document.createElement("div");b.className="gengage-chat-product-card-img-wrapper";const L=document.createElement("img");L.className="gengage-chat-product-card-img",L.loading="lazy",ve(L,"src",o);const M=n.name;M&&(L.alt=M),Be(L),b.appendChild(L);const R=n.discountPercent;if(!t.hideProductDiscountBadge&&typeof R=="number"&&R>0){const H=document.createElement("span");H.className="gengage-chat-product-card-discount-badge",H.textContent=`%${xn(R)}`,b.appendChild(H)}const j=document.createElement("div");j.className="gengage-chat-product-card-img-actions";const q=n.sku;if(q&&t.onFavoriteToggle){const H=document.createElement("button");H.className="gengage-chat-favorite-btn",H.type="button",H.dataset.gengageFavoriteSku=q,H.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const K=t.favoritedSkus?.has(q)??!1;K&&H.classList.add("gengage-chat-favorite-btn--active"),H.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${K?"currentColor":"none"}" 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>`,H.addEventListener("click",y=>{y.stopPropagation(),H.classList.toggle("gengage-chat-favorite-btn--active");const N=H.querySelector("svg");N&&N.setAttribute("fill",H.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(q,n)}),j.appendChild(H)}const F=n.sku,ne=t.i18n?.findSimilarLabel??"Find Similar";if(F){const H=document.createElement("button");H.className="gengage-chat-find-similar-pill",H.type="button",H.setAttribute("aria-label",ne),H.dataset.tooltip=ne,H.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const K=document.createElement("span");K.className="gengage-chat-find-similar-pill-text",K.textContent=ne,H.appendChild(K),H.addEventListener("click",y=>{y.stopPropagation(),t.onAction({title:ne,type:"findSimilar",payload:{sku:F}})}),j.appendChild(H)}j.childElementCount>0&&b.appendChild(j),a.appendChild(b)}const s=document.createElement("div");s.className="gengage-chat-product-card-body";const c=n.brand;if(c){const b=document.createElement("div");b.className="gengage-chat-product-card-brand",b.textContent=c,s.appendChild(b)}const l=n.rating,g=n.reviewCount,d=n.price,p=n.originalPrice,h=n.price_async,v=ut(t,n),m=Tt(t,n),f=!!(p&&d&&p!==d&&parseFloat(d)>0),u=!!(v&&f),A=!!(v&&!u||f&&m==="inline"),P=typeof l=="number"&&Number.isFinite(l)&&l>0,x=document.createElement("div");x.className="gengage-chat-product-card-meta-row";const E=document.createElement("div");E.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const T=A?(()=>{const b=document.createElement("div");return b.className="gengage-chat-product-card-price-stack",v&&!u&&b.appendChild(Dt(v)),b.appendChild(E),b})():E;if(h===!0){const b=document.createElement("span");b.className="gengage-chat-price-skeleton",E.appendChild(b),setTimeout(()=>{b.parentElement&&(d&&parseFloat(d)>0?Nn(E,t,n,d,n.originalPrice):b.remove())},300)}else d&&parseFloat(d)>0&&Nn(E,t,n,d,p);if((E.childElementCount>0||h===!0)&&x.appendChild(T),P){const b=document.createElement("div");b.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const L=ua(l),M=[`${L.toFixed(1)}`,"out of 5 stars"];typeof g=="number"&&Number.isFinite(g)&&M.push(`(${g} reviews)`),b.setAttribute("aria-label",M.join(" "));const R=document.createElement("span");R.className="gengage-chat-product-card-rating-compact-star",R.setAttribute("aria-hidden","true"),R.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const j=document.createElement("span");j.className="gengage-chat-product-card-rating-compact-value",j.textContent=L.toFixed(1),b.appendChild(R),b.appendChild(j),x.appendChild(b)}x.childElementCount===0&&(x.classList.add("gengage-chat-product-card-meta-row--empty"),x.setAttribute("aria-hidden","true")),s.appendChild(x);const w=n.name;if(w){const b=document.createElement("div");b.className="gengage-chat-product-card-name",b.textContent=w,b.title=w,s.appendChild(b)}const C=n.inStock;if(t.hideStockStatus!==!0&&typeof C=="boolean"){const b=document.createElement("div");b.className=`gengage-chat-product-card-stock ${C?"is-in-stock":"is-out-of-stock"}`,b.textContent=C?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",s.appendChild(b)}a.appendChild(s);const B=n.url,W=n.sku,ee=n.cartCode,fe=!!(ee&&W&&C!==!1),D=t.i18n?.productCtaLabel??"View";if(fe){const b=document.createElement("div");b.className="gengage-chat-product-card-buy-footer";const L=document.createElement("button");L.type="button",L.className="gengage-chat-product-card-buy-trigger",L.textContent=D,L.addEventListener("click",M=>{M.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??D,type:"addToCart",payload:{sku:W,cartCode:ee,quantity:1}})}),b.appendChild(L),a.appendChild(b)}else if(i){const b=document.createElement("button");b.className="gengage-chat-product-card-cta",b.type="button",b.textContent=i.type==="launchSingleProduct"?D:i.title||D,b.addEventListener("click",L=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){L.stopPropagation();return}t.onAction(i)}),a.appendChild(b)}else if(B&&we(B)){const b=document.createElement("a");b.className="gengage-chat-product-card-cta",ve(b,"href",B),ve(b,"target","_blank"),ve(b,"rel","noopener noreferrer"),b.textContent=D,b.addEventListener("click",L=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){L.preventDefault(),L.stopPropagation();return}t.onProductClick&&W&&(L.preventDefault(),t.onProductClick({sku:W,url:B,...w?{name:w}:{}}))}),a.appendChild(b)}if(t.comparisonSelectMode&&W&&t.onToggleComparisonSku){const b=document.createElement("div");b.className="gengage-chat-comparison-select-wrapper";const L=t.comparisonSelectedSkus?.includes(W)??!1;L&&b.classList.add("gengage-chat-comparison-select-wrapper--selected");const M=n.name??W,R=t.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";b.setAttribute("role","group"),b.setAttribute("aria-label",`${String(M)}. ${R}`);const j=document.createElement("button");j.type="button",j.className="gengage-chat-comparison-checkbox",j.dataset.selected=L?"true":"false",j.setAttribute("aria-pressed",L?"true":"false");const q=document.createElement("span");q.className="gengage-chat-comparison-checkbox-icon",q.innerHTML=L?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>';const F=document.createElement("span");F.className="gengage-chat-comparison-checkbox-label",F.textContent=L?t.i18n?.comparisonSelectedLabel??"Selected":t.i18n?.comparisonSelectLabel??"Select to compare",j.appendChild(q),j.appendChild(F),j.addEventListener("click",H=>{H.stopPropagation(),t.onToggleComparisonSku?.(W)});const ne=document.createElement("div");return ne.className="gengage-chat-comparison-card-hint",ne.setAttribute("aria-hidden","true"),ne.textContent=R,b.addEventListener("click",H=>{H.target.closest(".gengage-chat-comparison-checkbox")||(H.stopPropagation(),t.onToggleComparisonSku?.(W))}),b.appendChild(j),b.appendChild(ne),b.appendChild(a),b}return a}var Mn=new Set(["color","colour","renk","renk kodu","color code"]),Fc=new Set(["size","beden","boyut"]),Hc=new Set(["finish","bitiş","bitişi"]),$c=["variants","variantOptions","variant_options","productVariants","product_variants","options"],Uc=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),jc=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function Te(e,...t){for(const a of t){const n=e[a];if(typeof n=="string"){const r=n.trim();if(r.length>0)return r}}}function $t(e,...t){for(const a of t){const n=e[a];if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const r=Number(n.replace(",","."));if(Number.isFinite(r))return r}}}function Ut(e,...t){for(const a of t){const n=e[a];if(typeof n=="boolean")return n}}function Zc(e,...t){for(const a of t){const n=e[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function Vc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function qc(e){const t=[...Vc(e.images),Te(e,"imageUrl","image_url","image")].filter(a=>!!a&&we(a));return Array.from(new Set(t))}function Gc(e){return typeof DOMParser<"u"?(new DOMParser().parseFromString(e,"text/html").body.textContent??"").replace(/\s+/g," ").trim():e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function Wc(e){const t=Te(e,"description_html","descriptionHtml");if(t){const n=Gc(t);if(n)return{text:n,html:t}}const a=Te(e,"description");return a?{text:a}:void 0}function jt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t,n=Te(a,"key","name","label","title"),r=a.value,i=typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r).trim():void 0;return!n||!i?null:{key:n,value:i}}).filter(t=>t!==null):e&&typeof e=="object"?Object.entries(e).map(([t,a])=>{const n=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a).trim():void 0;return!t||!n?null:{key:t,value:n}}).filter(t=>t!==null):[]}function Bn(e){const t=jt(e.features);return t.length>0?t:jt(e.specifications)}function Kc(e){const t=e.specifications,a=jt(t);if(a.length>0)return Array.isArray(t)?a:Object.fromEntries(a.map(r=>[r.key,r.value]));const n=jt(e.features);return n.length>0?n:void 0}function qe(e,...t){return Te(e,...t)}function Rn(e,...t){return $t(e,...t)}function On(e){return qe(e,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function Dn(e){const t=qe(e,"type","attribute","option_name","attribute_name");return t||(qe(e,"value")?qe(e,"name","variant_name"):void 0)}function Yc(e){const t=Dn(e)?.toLowerCase();return!!(Te(e,"color","colour","color_hex","hex","swatch","swatchColor")||t&&Mn.has(t))}function Fn(e){if(!e)return;const t=e.trim();if(!(!t||t.includes(";"))&&(typeof CSS<"u"&&CSS.supports?.("color",t)||/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)))return t}function Jc(e){const t=Fn(qe(e,"swatchColor","swatch","color_hex","hex","color","colour"));if(t)return t;if(Yc(e))return Fn(On(e))}function Xc(e){return qe(e,"image","imageUrl","image_url","swatchImage","swatch_image")}function Qc(e){return Rn(e,"price_discounted","priceDiscounted")??qe(e,"price_discounted","priceDiscounted")??Rn(e,"price")??qe(e,"price")}function el(e){const t=e.trim().toLowerCase();return Mn.has(t)||Fc.has(t)||Hc.has(t)}function tl(e){const t=e.trim().toLowerCase();return t==="renk kodu"?"Renk":t==="color code"?"Color":e.trim()}function al(e){for(const t of $c){const a=e[t];if(!Array.isArray(a))continue;const n=a.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r));if(n.length>0)return n}}function nl(e){const t=al(e);if(t)return t;const a=Te(e,"sku"),n=Ut(e,"inStock","in_stock"),r=[],i=new Set,o=(c,l)=>{if(!el(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const g=String(l).trim();if(!g)return;const d=tl(c),p=`${d.toLowerCase()}:${g.toLowerCase()}`;i.has(p)||(i.add(p),r.push({name:d,value:g,sku:a,inStock:n}))},s=Zc(e,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of Bn(e))o(c.key,c.value);return r}function rl(e,t){const a=Array.from(new Set(e.map(Dn).filter(n=>!!n)));return a.length===1?`${e.length} ${a[0]}`:t.i18n?.variantsLabel??"Variants"}function il(e,t){const a=document.createElement("article");a.className="gengage-chat-product-details-panel";const n=e.props?.product??e.props;if(!n)return a;const r=Te(n,"name"),i=Te(n,"brand"),o=Te(n,"sku"),s=Te(n,"cartCode","cart_code"),c=Te(n,"price"),l=Te(n,"originalPrice","price_original"),g=Ut(n,"price_async"),d=ut(t,n),p=Tt(t,n),h=!!(l&&c&&l!==c),v=Ut(n,"inStock","in_stock"),m=$t(n,"reviewCount","review_count"),f=$t(n,"rating"),u=qc(n),A=Bn(n).slice(0,4);if(u.length>1){const b=document.createElement("div");b.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const L=document.createElement("img");L.className="gengage-chat-product-details-img",ve(L,"src",u[0]),L.alt=r??"Product image",Be(L),b.appendChild(L);const M=document.createElement("div");M.className="gengage-chat-product-gallery-thumbs";const R=6;let j=null,q=0;const F=t.i18n,ne=F?.galleryPrevAriaLabel??"Previous image",H=F?.galleryNextAriaLabel??"Next image",K=U=>U==="prev"?'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>':'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg>',y=document.createElement("button");y.type="button",y.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn",y.setAttribute("aria-label",ne),y.innerHTML=K("prev");const N=document.createElement("button");N.type="button",N.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn",N.setAttribute("aria-label",H),N.innerHTML=K("next");const I=()=>{y.disabled=q<=0,N.disabled=q>=u.length-1},z=U=>{if(U<0||U>=u.length||U===q)return;const re=u[U];if(!re)return;ve(L,"src",re);const G=M.querySelectorAll(".gengage-chat-product-gallery-thumb");j&&j.classList.remove("gengage-chat-product-gallery-thumb--active"),U<R&&G[U]?(G[U].classList.add("gengage-chat-product-gallery-thumb--active"),j=G[U]):j=null,q=U,I()};for(let U=0;U<u.length;U++){const re=u[U];if(U>=R)break;const G=document.createElement("img");G.className="gengage-chat-product-gallery-thumb",U===0&&(G.classList.add("gengage-chat-product-gallery-thumb--active"),j=G),ve(G,"src",re),G.alt=`${r??"Product"} ${U+1}`,G.width=48,G.height=48,Be(G),G.addEventListener("click",()=>{z(U)}),M.appendChild(G)}if(u.length>R){const U=document.createElement("span");U.className="gengage-chat-product-gallery-thumb-more",U.textContent=`+${u.length-R}`,M.appendChild(U)}y.addEventListener("click",U=>{U.stopPropagation(),z(q-1)}),N.addEventListener("click",U=>{U.stopPropagation(),z(q+1)}),I();let V=0;const $=50;L.addEventListener("touchstart",U=>{V=U.changedTouches[0].clientX},{passive:!0}),L.addEventListener("touchend",U=>{const re=U.changedTouches[0].clientX,G=V-re;Math.abs(G)<$||z(G>0?Math.min(q+1,u.length-1):Math.max(q-1,0))}),b.appendChild(y),b.appendChild(N),b.appendChild(M),a.appendChild(b)}else if(u.length===1){const b=document.createElement("div");b.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const L=document.createElement("img");L.className="gengage-chat-product-details-img",L.loading="lazy",ve(L,"src",u[0]),Be(L),L.alt=r??"Product image",b.appendChild(L),a.appendChild(b)}const P=document.createElement("div");if(P.className="gengage-chat-product-details-content",i&&(!r||!r.toLowerCase().startsWith(i.toLowerCase()))){const b=document.createElement("div");b.className="gengage-chat-product-details-brand",b.textContent=i,P.appendChild(b)}if(r){const b=document.createElement("h3");b.className="gengage-chat-product-details-title",b.textContent=r,b.title=r,P.appendChild(b)}if(t.hideUserReviews!==!0&&typeof f=="number"&&Number.isFinite(f)&&f>0){const b=document.createElement(o?"button":"div");b.className="gengage-chat-product-details-rating",o&&(b.type="button",b.classList.add("gengage-chat-product-details-rating--clickable"),b.setAttribute("aria-label",t.i18n?.groundingReviewCta??"Read Reviews"),b.addEventListener("click",()=>{t.onAction({title:t.i18n?.customerReviewsTitle??"Customer Reviews",type:"reviewSummary",payload:{sku:o}})})),b.appendChild(_n(f));const L=document.createElement("span");if(L.className="gengage-chat-product-details-rating-value",L.textContent=ua(f).toFixed(1),b.appendChild(L),typeof m=="number"&&Number.isFinite(m)){const M=document.createElement("span");M.className="gengage-chat-product-details-review-count",M.textContent=` (${m})`,b.appendChild(M)}P.appendChild(b)}{const b=!!(d&&h);let L=P;if(d&&!b){const R=document.createElement("div");R.className="gengage-chat-product-details-price-stack",R.appendChild(Dt(d)),P.appendChild(R),L=R}const M=document.createElement("div");if(M.className="gengage-chat-product-details-price",g===!0){const R=document.createElement("span");R.className="gengage-chat-price-skeleton",M.appendChild(R),L.appendChild(M),setTimeout(()=>{if(R.parentElement)if(c&&parseFloat(c)>0)zn(M,t,n,c,l,p,h);else{const j=M.parentElement;M.remove(),j?.classList.contains("gengage-chat-product-details-price-stack")&&j.remove()}},300)}else if(c&&parseFloat(c)>0)zn(M,t,n,c,l,p,h),L.appendChild(M);else if(d){const R=L;R.classList.contains("gengage-chat-product-details-price-stack")&&R.remove()}}if(t.hideStockStatus!==!0&&typeof v=="boolean"){const b=document.createElement("div");b.className=`gengage-chat-product-details-stock ${v?"is-in-stock":"is-out-of-stock"}`,b.textContent=v?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",P.appendChild(b)}const x=n.promotions;if(x&&x.length>0){const b=document.createElement("div");b.className="gengage-chat-product-details-promos";for(const L of x.slice(0,3)){if(!L||/%(0(\.0+)?)\s/.test(L))continue;const M=document.createElement("span");M.className="gengage-chat-product-details-promo-badge",M.textContent=L,M.title=L,b.appendChild(M)}b.childElementCount>0&&P.appendChild(b)}if(A.length>0){const b=document.createElement("dl");b.className="gengage-chat-product-details-facts";for(const L of A){const M=document.createElement("div");M.className="gengage-chat-product-details-fact";const R=document.createElement("dt");R.textContent=L.key;const j=document.createElement("dd");j.textContent=L.value,M.appendChild(R),M.appendChild(j),b.appendChild(M)}P.appendChild(b)}const E=nl(n);if(E.length>0){const b=document.createElement("div");b.className="gengage-chat-product-variants";const L=document.createElement("div");L.className="gengage-chat-product-variants-label",L.textContent=rl(E,t),b.appendChild(L);const M=document.createElement("div");M.className="gengage-chat-product-variants-list";for(const R of E){const j=On(R),q=qe(R,"sku");if(!j&&!q)continue;const F=document.createElement("button");F.className="gengage-chat-product-variant-btn gds-chip",F.type="button";const ne=j??q??"";F.title=ne;const H=Ut(R,"in_stock","inStock");q&&o&&q===o?(F.classList.add("gengage-chat-product-variant-btn--active"),F.setAttribute("aria-pressed","true")):F.setAttribute("aria-pressed","false"),H===!1&&(F.classList.add("gengage-chat-product-variant-btn--out"),F.disabled=!0);const K=Xc(R),y=Jc(R);if(K&&we(K)){const z=document.createElement("img");z.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",ve(z,"src",K),z.alt="",z.setAttribute("aria-hidden","true"),Be(z),F.appendChild(z)}else if(y){const z=document.createElement("span");z.className="gengage-chat-product-variant-swatch",z.setAttribute("aria-hidden","true"),z.style.backgroundColor=y,F.appendChild(z)}const N=document.createElement("span");N.className="gengage-chat-product-variant-label",N.textContent=ne,F.appendChild(N);const I=Qc(R);if(I&&String(I)!==String(c)){const z=document.createElement("span");z.className="gengage-chat-product-variant-price",z.textContent=ie(String(I),t.pricing),F.appendChild(z)}if(q&&q!==o){const z=r??"",V=(typeof R.value=="string"?R.value.trim():"")||(typeof R.name=="string"?R.name.trim():"")||(typeof R.variant_name=="string"?R.variant_name.trim():"")||"",$=z.length>0?V.length>0&&V!==z?`${z} (${V})`:z:ne;F.addEventListener("click",()=>{t.onAction({title:$,type:"launchVariant",payload:{sku:q}})})}M.appendChild(F)}M.childElementCount>0&&(b.appendChild(M),P.appendChild(b))}const T=document.createElement("div");T.className="gengage-chat-product-details-actions";const w=e.props?.action;if(w){const b=document.createElement("button");b.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",b.type="button",b.textContent=w.title||t.i18n?.productCtaLabel||"View",b.addEventListener("click",()=>t.onAction(w)),T.appendChild(b)}if(s&&o&&v!==!1){const b=document.createElement("button");b.className="gengage-chat-product-details-atc gds-btn gds-btn-primary",b.type="button",b.textContent=t.i18n?.addToCartButton??"Add to Cart",b.addEventListener("click",()=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:o,cartCode:s,quantity:1}})}),T.appendChild(b)}const C=Te(n,"url");if(!w&&C&&we(C)){const b=document.createElement("a");b.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",ve(b,"href",C),ve(b,"target","_blank"),ve(b,"rel","noopener noreferrer"),b.textContent=t.i18n?.viewOnSiteLabel??t.i18n?.productCtaLabel??"View on Site",b.addEventListener("click",L=>{t.onProductClick&&o&&(L.preventDefault(),t.onProductClick({sku:o,url:C,...r?{name:r}:{}}))}),T.appendChild(b)}const B=C;if(B&&we(B)){let j=function(F,ne){const H=document.createElementNS(M,"circle");H.setAttribute("cx",F),H.setAttribute("cy",ne),H.setAttribute("r","3"),R.appendChild(H)},q=function(F,ne,H,K){const y=document.createElementNS(M,"line");y.setAttribute("x1",F),y.setAttribute("y1",ne),y.setAttribute("x2",H),y.setAttribute("y2",K),R.appendChild(y)};var fe=j,D=q;const b=document.createElement("button");b.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",b.type="button";const L=t.i18n?.shareButton??"Share";b.title=L,b.setAttribute("aria-label",L);const M="http://www.w3.org/2000/svg",R=document.createElementNS(M,"svg");R.setAttribute("width","18"),R.setAttribute("height","18"),R.setAttribute("viewBox","0 0 24 24"),R.setAttribute("fill","none"),R.setAttribute("stroke","currentColor"),R.setAttribute("stroke-width","2"),R.setAttribute("stroke-linecap","round"),R.setAttribute("stroke-linejoin","round"),j("18","5"),j("6","12"),j("18","19"),q("8.59","13.51","15.42","17.49"),q("15.41","6.51","8.59","10.49"),b.appendChild(R),b.addEventListener("click",async()=>{try{navigator.share?await navigator.share({title:r??"",url:B}):navigator.clipboard&&(await navigator.clipboard.writeText(B),b.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>b.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),T.appendChild(b)}T.childElementCount>0&&P.appendChild(T),a.appendChild(P);const W=Wc(n),ee=Kc(n);return(W||ee)&&a.appendChild(cl(W,ee,t)),a}function ya(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent??"");if(e.nodeType!==Node.ELEMENT_NODE)return null;const t=e,a=t.tagName.toUpperCase();if(jc.has(a))return null;if(!Uc.has(a)){const r=document.createDocumentFragment();for(const i of Array.from(t.childNodes)){const o=ya(i);o&&r.appendChild(o)}return r}const n=document.createElement(a.toLowerCase());for(const r of Array.from(t.childNodes)){const i=ya(r);i&&n.appendChild(i)}return n}function ol(e,t){const a=t.split(/\n{2,}/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean);if(a.length!==0)for(const n of a){const r=document.createElement("p");r.textContent=n,e.appendChild(r)}}function sl(e,t){if(e.classList.add("gengage-chat-product-description"),t.html&&typeof DOMParser<"u"){const a=new DOMParser().parseFromString(t.html,"text/html"),n=Array.from(a.body.childNodes).map(r=>ya(r)).filter(r=>!!r&&(r.nodeType===Node.ELEMENT_NODE||!!r.textContent?.trim()));if(n.length>0){for(const r of n)e.appendChild(r);return}}ol(e,t.text)}function cl(e,t,a){const n=document.createElement("div");n.className="gengage-chat-product-detail-tabs";const r=document.createElement("div");r.className="gengage-chat-product-detail-tab-bar gds-toolbar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gds-tab gengage-chat-product-detail-tab--active is-active",s.type="button",s.setAttribute("aria-selected","true"),s.textContent=a.i18n?.productInfoTab??"Product Info",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",sl(c,e),i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab gds-tab${e?"":" gengage-chat-product-detail-tab--active is-active"}`,s.type="button",s.setAttribute("aria-selected",e?"false":"true"),s.textContent=a.i18n?.specificationsTab??"Specifications",r.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 g=Array.isArray(t)?t:Object.entries(t).map(([d,p])=>({key:d,value:p}));for(const d of g){const p=document.createElement("tr"),h=document.createElement("td");h.className="gengage-chat-product-specs-key",h.textContent=d.key;const v=document.createElement("td");v.className="gengage-chat-product-specs-value",v.textContent=d.value,p.appendChild(h),p.appendChild(v),l.appendChild(p)}c.appendChild(l),i.push(c)}const o=r.querySelectorAll(".gengage-chat-product-detail-tab");o.forEach((s,c)=>{s.addEventListener("click",()=>{o.forEach(l=>{l.classList.remove("gengage-chat-product-detail-tab--active","is-active"),l.setAttribute("aria-selected","false")}),s.classList.add("gengage-chat-product-detail-tab--active","is-active"),s.setAttribute("aria-selected","true"),i.forEach((l,g)=>{l.style.display=g===c?"":"none"})})}),n.appendChild(r);for(const s of i)n.appendChild(s);return n}function Hn(e){const t='width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';switch(e){case"related":return`<svg ${t} aria-hidden="true"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`;case"priceAsc":return`<svg ${t} aria-hidden="true"><polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/></svg>`;case"priceDesc":return`<svg ${t} aria-hidden="true"><polyline points="22 17 13.5 8.5 8.5 13.5 2 7"/><polyline points="16 17 22 17 22 11"/></svg>`;default:return""}}function ll(){return'<svg class="gengage-chat-product-sort-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>'}function gl(){return'<svg class="gengage-chat-product-sort-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>'}function dl(){return'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3 4 7l4 4"/><path d="M16 21l4-4-4-4"/><path d="M4 7h16"/><path d="M20 17H4"/></svg>'}function $n(e,t){return e.type===t.type&&e.direction===t.direction}function Un(e,t,a){if(!a||a.type==="related")return e;const n=e.map(r=>{const i=t.elements[r]?.props?.product,o=i?Number(i.price):NaN;return{id:r,price:Number.isFinite(o)?o:1/0}});return n.sort((r,i)=>r.price===1/0&&i.price===1/0?0:r.price===1/0?1:i.price===1/0?-1:a.direction==="desc"?i.price-r.price:r.price-i.price),n.map(r=>r.id)}function pl(e,t,a,n){const r=Un(t,a,n),i=new Map;for(const o of Array.from(e.children)){const s=o.dataset.elementId;s&&i.set(s,o)}for(const o of r){const s=i.get(o);s&&e.appendChild(s)}}function hl(e,t,a,n){const r=document.createElement("div");r.className="gengage-chat-product-grid-wrapper";const i=ka(e),o=i.isConsulting,s=e.children??[],c=document.createElement("div");c.className="gengage-chat-product-grid";const l=n?.panelProductListHeading;if(!o&&s.length>1&&n?.onSortChange){const p=document.createElement("div");p.className="gengage-chat-product-sort-toolbar",p.setAttribute("role","toolbar"),p.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let h=n.productSort??{type:"related"};const v=[{label:n.i18n?.sortRelated??"Related",sortState:{type:"related"},icon:"related"},{label:n.i18n?.sortPriceAsc??"Price ↑",sortState:{type:"price",direction:"asc"},icon:"priceAsc"},{label:n.i18n?.sortPriceDesc??"Price ↓",sortState:{type:"price",direction:"desc"},icon:"priceDesc"}],m=document.createElement("div");m.className="gengage-chat-product-sort-dropdown";const f=document.createElement("button");f.type="button",f.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",f.setAttribute("aria-haspopup","listbox"),f.setAttribute("aria-expanded","false");const u=n.i18n?.sortToolbarAriaLabel??"Sort products",A=document.createElement("span");A.className="gengage-chat-product-sort-trigger-icon";const P=document.createElement("span");P.className="gengage-chat-product-sort-trigger-label";const x=D=>{const b=v.find(L=>$n(L.sortState,D))??v[0];P.textContent=b.label,A.innerHTML=Hn(b.icon),m.dataset.sortIcon=b.icon,f.setAttribute("aria-label",`${u}: ${b.label}`),f.title=b.label};x(h);const E=document.createElement("span");E.className="gengage-chat-product-sort-trigger-chevron",E.innerHTML=ll(),f.appendChild(A),f.appendChild(P),f.appendChild(E);const T=document.createElement("div");T.className="gengage-chat-product-sort-menu gds-menu",T.hidden=!0,T.setAttribute("role","listbox"),T.setAttribute("aria-label",u);const w=p.ownerDocument;let C=null;const B=()=>{T.hidden=!0,m.classList.remove("gengage-chat-product-sort-dropdown--open"),f.setAttribute("aria-expanded","false"),C?.abort(),C=null},W=D=>{m.classList.contains("gengage-chat-product-sort-dropdown--open")&&(m.contains(D.target)||B())},ee=D=>{D.key==="Escape"&&(D.preventDefault(),B())},fe=()=>{T.hidden=!1,m.classList.add("gengage-chat-product-sort-dropdown--open"),f.setAttribute("aria-expanded","true"),C=new AbortController;const{signal:D}=C;w.addEventListener("click",W,{signal:D}),w.addEventListener("keydown",ee,{capture:!0,signal:D})};f.addEventListener("click",D=>{D.stopPropagation(),m.classList.contains("gengage-chat-product-sort-dropdown--open")?B():fe()});for(const D of v){const b=document.createElement("button");b.type="button",b.className="gengage-chat-product-sort-option gds-menu-option",b.setAttribute("role","option");const L=$n(h,D.sortState);b.setAttribute("aria-selected",L?"true":"false"),L&&b.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const M=D.sortState.type==="related"?"related":`price-${D.sortState.direction??""}`;b.dataset.sortKey=M;const R=document.createElement("span");R.className="gengage-chat-product-sort-option-icon",R.innerHTML=Hn(D.icon);const j=document.createElement("span");j.className="gengage-chat-product-sort-option-label",j.textContent=D.label;const q=document.createElement("span");q.className="gengage-chat-product-sort-option-check",q.innerHTML=gl(),q.setAttribute("aria-hidden","true"),L||q.classList.add("gengage-chat-product-sort-option-check--hidden"),b.appendChild(R),b.appendChild(j),b.appendChild(q),b.addEventListener("click",()=>{h=D.sortState,n.onSortChange?.(D.sortState),pl(c,s,t,D.sortState),T.querySelectorAll(".gengage-chat-product-sort-option").forEach(F=>{const ne=F,H=ne.dataset.sortKey===M;ne.classList.toggle("gengage-chat-product-sort-option--active",H),ne.classList.toggle("gds-menu-option-active",H),ne.setAttribute("aria-selected",H?"true":"false"),ne.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!H)}),x(D.sortState),B()}),T.appendChild(b)}if(m.appendChild(f),m.appendChild(T),p.appendChild(m),n.onToggleComparisonSku){const D=document.createElement("button");D.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",D.type="button",n.comparisonSelectMode&&D.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&D.classList.add("gengage-chat-comparison-toggle-btn--hidden");const b=document.createElement("span");b.className="gengage-chat-comparison-toggle-icon",b.innerHTML=dl();const L=document.createElement("span");L.className="gengage-chat-comparison-toggle-label";const M=n.i18n?.compareSelected??"Compare";L.textContent=M,D.setAttribute("aria-label",M),D.title=M,D.appendChild(b),D.appendChild(L),D.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),p.appendChild(D)}if(l){p.classList.add("gengage-chat-product-sort-toolbar--inline");const D=document.createElement("div");D.className="gengage-chat-product-grid-head";const b=document.createElement("span");b.className="gengage-chat-product-grid-head-title",b.textContent=l,D.appendChild(b);const L=document.createElement("div");L.className="gengage-chat-product-grid-head-actions",L.appendChild(p),D.appendChild(L),r.appendChild(D)}else r.appendChild(p)}else if(l){const p=document.createElement("div");p.className="gengage-chat-product-grid-head";const h=document.createElement("span");h.className="gengage-chat-product-grid-head-title",h.textContent=l,p.appendChild(h),r.appendChild(p)}if(o)xl(r,c,i,n);else{const p=Un(s,t,n?.productSort);for(const h of p){if(!t.elements[h])continue;const v=a(h);v&&(v.dataset.elementId=h,c.appendChild(v))}}(n?.isMobile??fa())&&c.classList.add("gengage-chat-product-grid--mobile"),e.props?.rankingState==="pending"&&(c.classList.add("gengage-chat-product-grid--pending"),c.inert=!0,c.setAttribute("aria-busy","true")),r.appendChild(c);const g=e.props?.endOfList;if(!o&&g!==!0&&s.length>0){const p=n?.i18n?.viewMoreLabel??"Show More",h=document.createElement("button");h.className="gengage-chat-product-grid-view-more",h.type="button",h.textContent=p,h.addEventListener("click",()=>{n?.onAction({title:p,type:"moreProductList",payload:{}})}),r.appendChild(h)}const d=n?.isMobile??fa();if(n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!d){const p=Tn(n.comparisonSelectedSkus,n);r.appendChild(p)}return r}function ul(e,t){const a=e.props??{},n=a.keyDifferencesHtml,r=a.recommended,i=a.products??[],o=a.attributes??[],s=a.highlights??[],c=a.specialCases,l=a.recommendedText,g=a.winnerHits,d=a.productActions;if(!r)return document.createElement("div");const p={recommended:r,products:i,attributes:o,highlights:s,specialCases:c,locale:t.locale,onProductClick:({sku:v,name:m})=>{t.onProductClick?.({sku:v,url:"",name:m})},pricing:t.pricing};l!==void 0&&(p.recommendedText=l),g!==void 0&&(p.winnerHits=g),d!==void 0&&(p.productActions=d),n!==void 0&&(p.keyDifferencesHtml=n),t.i18n&&(p.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,viewMoreLabel:t.i18n.viewMoreLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const h=rc(p);return(t.isMobile??fa())&&h.classList.add("gengage-chat-comparison--mobile"),h}function ml(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const a=e.props?.label;if(a){const n=document.createElement("div");n.className="gengage-chat-divider-wrapper";const r=document.createElement("span");r.className="gengage-chat-divider-label",r.textContent=a,n.appendChild(t),n.appendChild(r);const i=document.createElement("hr");return i.className="gengage-chat-divider",n.appendChild(i),n}return t}var Zt=new WeakMap;function jn(e){return{...ht,...e?.i18n??{}}}function Vt(e){return typeof e.status=="string"?e.status:"ready"}function xa(e){const t=e.findIndex(a=>Vt(a)!=="loading");return t<0?0:t}function fl(e){if(typeof e!="string")return;const t=e.trim();if(!t)return;if(/^https?:\/\//i.test(t))return t;let a=t.split(/[?#]/)[0];if(a&&(a=a.replace(/^\/+/,""),a.startsWith("remoteConfig/")&&(a=a.slice(13)),!!a))return`https://configs.gengage.ai/assets/${a}`}function Zn(e,t,a,n){const{grid:r,i18n:i}=e;r.innerHTML="",r.classList.remove("gengage-chat-product-grid--consulting-groups");const o=document.createElement("section");o.className="gengage-chat-consulting-loading-panel";const s=document.createElement("h4");s.className="gengage-chat-consulting-loading-panel-title",s.textContent=qt(t,n,i),o.appendChild(s);const c=document.createElement("p");if(c.className="gengage-chat-consulting-loading-panel-copy",c.textContent=a==="loading"?i.consultingStyleLoadingDescription:i.consultingStyleUnavailableDescription,o.appendChild(c),a==="loading"){const l=document.createElement("div");l.className="gengage-chat-consulting-loading-grid";for(let g=0;g<3;g+=1){const d=document.createElement("div");d.className="gengage-chat-consulting-loading-card",l.appendChild(d)}o.appendChild(l)}r.appendChild(o)}function qt(e,t,a){const n=r=>a.consultingFallbackStyleLabel.replace("{index}",String(r));return e.style_label??n(t)}function _a(e,t){const a=e.variations[t];if(!a)return;const{grid:n,source:r,ctx:i,i18n:o}=e;n.innerHTML="",n.classList.remove("gengage-chat-product-grid--consulting-groups");const s=Vt(a),c=t+1;if(s==="loading"){Zn(e,a,"loading",c);return}if(s!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){Zn(e,a,"unavailable",c);return}const l=Array.isArray(a.product_list)?a.product_list:[],g=r==="watch_expert"?[]:Array.isArray(a.recommendation_groups)?a.recommendation_groups:[];if(g.length>0){n.classList.add("gengage-chat-product-grid--consulting-groups");const d=new Map;for(const u of l){const A=typeof u?.sku=="string"?u.sku:void 0;A&&d.set(A,u)}const p=(u,A,P,x)=>{if(A.length===0)return;const E=document.createElement("section");E.className="gengage-chat-consulting-group";const T=document.createElement("div");T.className="gengage-chat-consulting-group-header";const w=document.createElement("h4");if(w.className="gengage-chat-consulting-group-label",w.textContent=`${u} (${A.length})`,T.appendChild(w),typeof x=="string"&&x.trim().length>0){const B=document.createElement("p");B.className="gengage-chat-consulting-group-reason",B.textContent=x,T.appendChild(B)}E.appendChild(T);const C=document.createElement("div");C.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",P&&C.classList.add("gengage-chat-consulting-group-grid--single-group"),C.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,A.length))));for(const B of A){const W=va({type:"ProductCard",props:{product:B}},i??{onAction:()=>{}});C.appendChild(W)}E.appendChild(C),n.appendChild(E)},h=new Set,v=[];for(const u of g){const A=(Array.isArray(u.skus)?u.skus.filter(E=>typeof E=="string"&&E.trim().length>0):[]).map(E=>(h.add(E),d.get(E))).filter(E=>!!E);if(A.length===0)continue;const P=typeof u.label=="string"&&u.label.trim().length>0?u.label:o.consultingFallbackGroupLabel,x=typeof u.reason=="string"?u.reason:void 0;v.push({labelText:P,products:A,...x!==void 0?{reasonText:x}:{}})}const m=l.filter(u=>{const A=typeof u?.sku=="string"?u.sku:"";return A.length>0&&!h.has(A)});m.length>0&&v.push({labelText:o.consultingOtherCompatibleProductsLabel,products:m});const f=v.length===1;for(const u of v)p(u.labelText,u.products,f,u.reasonText);return}for(const d of l){const p=va({type:"ProductCard",props:{product:d}},i??{onAction:()=>{}});n.appendChild(p)}}function wa(e,t,a,n){const r=Vt(t),i=n.consultingStyleLoadingBadge,o=n.consultingStyleUnavailableBadge;e.classList.remove("gengage-chat-consulting-style-btn--loading","gengage-chat-consulting-style-btn--muted"),r==="loading"?e.classList.add("gengage-chat-consulting-style-btn--loading"):r!=="ready"&&e.classList.add("gengage-chat-consulting-style-btn--muted"),e.setAttribute("aria-label",qt(t,a+1,n));let s=e.querySelector(".gengage-chat-consulting-style-media");s?s.innerHTML="":(s=document.createElement("div"),s.className="gengage-chat-consulting-style-media",e.appendChild(s));const c=fl(t.image_url);if(c&&we(c)){const g=document.createElement("img");g.className="gengage-chat-consulting-style-image",g.draggable=!1,ve(g,"src",c),g.alt=qt(t,a+1,n),g.loading="lazy",Be(g),s.appendChild(g)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=qt(t,a+1,n),s.appendChild(l),r==="loading"||r!=="ready"){const g=document.createElement("span");g.className="gengage-chat-consulting-style-status",g.textContent=r==="loading"?i:o,s.appendChild(g)}}function Vn(e,t,a,n){e.addEventListener("click",()=>{const r=Zt.get(t);r&&r.selectedIndex!==n&&(r.selectedIndex=n,a.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((i,o)=>{i.classList.toggle("gengage-chat-consulting-style-btn--active",o===n)}),_a(r,n))})}function bl(e,t,a,n,r){const i=jn(r),o=xa(n),s=document.createElement("div");s.className="gengage-chat-consulting-style-picker";const c={grid:t,source:a,ctx:r,variations:n,i18n:i,selectedIndex:o};Zt.set(s,c);const l=document.createElement("div");l.className="gengage-chat-consulting-style-picker-title",l.textContent=(a==="watch_expert"?i.watchStylesPreparedTitle:i.beautyStylesPreparedTitle).replace("{count}",String(n.length)),s.appendChild(l);const g=document.createElement("div");g.className="gengage-chat-consulting-style-grid",s.appendChild(g),n.forEach((d,p)=>{const h=document.createElement("button");h.type="button",h.className="gengage-chat-consulting-style-btn gds-card",p===o&&h.classList.add("gengage-chat-consulting-style-btn--active"),wa(h,d,p,i),Vn(h,s,g,p),g.appendChild(h)}),e.appendChild(s),_a(c,o)}function vl(e,t,a,n){const r=e.querySelector(".gengage-chat-consulting-style-picker"),i=yl(e);if(!r||!i)return!1;const o=r.querySelector(".gengage-chat-consulting-style-grid");if(!o)return!1;const s=jn(n);let c=Zt.get(r);if(c)c.grid=i,c.source=t,c.ctx=n,c.variations=a,c.i18n=s;else{const h={grid:i,source:t,ctx:n,variations:a,i18n:s,selectedIndex:xa(a)};Zt.set(r,h),c=h}const l=r.querySelector(".gengage-chat-consulting-style-picker-title");l&&(l.textContent=(t==="watch_expert"?s.watchStylesPreparedTitle:s.beautyStylesPreparedTitle).replace("{count}",String(a.length)));const g=c;let d=g.selectedIndex;d>=a.length&&(d=Math.max(0,a.length-1)),d<0&&(d=0),a.length>0&&Vt(a[d]??{})==="loading"&&(d=xa(a)),g.selectedIndex=d;const p=[...o.querySelectorAll(".gengage-chat-consulting-style-btn")];if(p.length===0)return!1;for(let h=0;h<a.length;h+=1){const v=a[h];let m=p[h];m?wa(m,v,h,s):(m=document.createElement("button"),m.type="button",m.className="gengage-chat-consulting-style-btn gds-card",wa(m,v,h,s),Vn(m,r,o,h),o.appendChild(m),p[h]=m)}for(;o.querySelectorAll(".gengage-chat-consulting-style-btn").length>a.length;)o.lastElementChild?.remove();return o.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((h,v)=>{h.classList.toggle("gengage-chat-consulting-style-btn--active",v===g.selectedIndex)}),_a(g,g.selectedIndex),!0}function yl(e){const t=[...e.children];for(let a=t.length-1;a>=0;a-=1){const n=t[a];if(n.classList.contains("gengage-chat-product-grid"))return n}return e.querySelector(":scope > .gengage-chat-product-grid")}function ka(e){const t=typeof e.props?.source=="string"?e.props.source:void 0,a=(Array.isArray(e.props?.styleVariations)?e.props.styleVariations:[]).filter(n=>typeof n.style_label=="string"&&n.style_label.trim().length>0);return{isConsulting:nn(t)&&a.length>0,source:t,styleVariations:a}}function xl(e,t,a,n){bl(e,t,a.source,a.styleVariations,n)}function _l(e){return!e.isConsulting||e.styleVariations.length===0?!0:e.styleVariations.some(t=>(typeof t.status=="string"?t.status:"ready")!=="loading")}function wl(e,t,a){return!t.isConsulting||!t.source?!1:vl(e,t.source,t.styleVariations,a)}var kl=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
50
50
  <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>