@gengage/assistant-fe 0.6.30 → 0.6.32
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/{agent-ui-steps-WKbTVOS4.js → agent-ui-steps-DIWmTMuV.js} +297 -295
- package/dist/agentic/index.js +547 -447
- package/dist/agentic/types.d.ts +2 -0
- package/dist/agentic/worker/be-client.d.ts +1 -0
- package/dist/agentic/worker.js +108 -106
- package/dist/agentic.iife.js +146 -61
- package/dist/{api-paths-Bu9ctkKv.js → api-paths-BQM6ulFP.js} +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +1 -1
- package/dist/chat.js +1 -1
- package/dist/{common-Cz-AVJ2C.js → common-Co_8C5Ir.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-ByISkfmd.js → connection-warning-9lEST376.js} +1 -1
- package/dist/{fastIntent-CVFoeCkX.js → fastIntent-yOfaIrPb.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +1 -1
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-B3wxv8V8.js → runtime-CwGrFmYS.js} +3 -3
- package/dist/{runtime-C_igcdtR.js → runtime-D3-L3wDc.js} +3 -3
- package/dist/{runtime-fbyf-Q1_.js → runtime-DJ3kOIL6.js} +3 -3
- package/dist/{simbut-CfqbQIVL.js → simbut-BJjl8BHs.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-vCmhTjw0.js → simrel-DLNifT30.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-DgQV6knT.js → widget-base-CYbh5dI9.js} +1 -1
- package/package.json +1 -1
package/dist/native.iife.js
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(t)}var ze,fa,At,jn,$n,Vn,Gn,ba,qe,Wn,it=L((()=>{Ke(),Ls(),ze="gengage-global-toast-root",fa="gengage-global-toast-style",At="gengage-global-toast-root--visible",jn=4200,$n=1500,Vn=15e3,Gn=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],ba=!1,qe=null,Wn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i]}));function Hs(){if(rt!==null)return rt;try{rt=localStorage.getItem("gengage:debug")==="1"}catch{rt=!1}return rt}function Be(t,e,a){if(!Hs())return;const n=[`[gengage:${t}]`,e];a!==void 0&&n.push(a),console.debug(...n)}var rt,ot=L((()=>{rt=null}));function Fs(){if(typeof window>"u")return;const t=window;t.__gengageSdkRuntimeInfoLogged||(t.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${Kn} (${Yn})`))}var Kn,Yn,Ds=L((()=>{Kn=("0.6.
|
|
47
|
+
`,document.head.appendChild(t)}var ze,fa,At,jn,$n,Vn,Gn,ba,qe,Wn,it=L((()=>{Ke(),Ls(),ze="gengage-global-toast-root",fa="gengage-global-toast-style",At="gengage-global-toast-root--visible",jn=4200,$n=1500,Vn=15e3,Gn=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],ba=!1,qe=null,Wn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i]}));function Hs(){if(rt!==null)return rt;try{rt=localStorage.getItem("gengage:debug")==="1"}catch{rt=!1}return rt}function Be(t,e,a){if(!Hs())return;const n=[`[gengage:${t}]`,e];a!==void 0&&n.push(a),console.debug(...n)}var rt,ot=L((()=>{rt=null}));function Fs(){if(typeof window>"u")return;const t=window;t.__gengageSdkRuntimeInfoLogged||(t.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${Kn} (${Yn})`))}var Kn,Yn,Ds=L((()=>{Kn=("0.6.32".trim(),"0.6.32".trim()),Yn=("iife-build".trim(),"iife-build".trim())}));function Us(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}var pt,Lt=L((()=>{Ke(),Ln(),As(),it(),ot(),Ds(),pt=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const e=Ts(t.theme);Fs(),this.config={...t,theme:e,session:An(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(e),Is();const a=Tt("gengage:context:update",n=>this.update(n));this._cleanups.push(a),Be("lifecycle",`${this.constructor.name}.init`,{accountId:t.accountId,sku:t.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Be("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(t,e){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(e),()=>this._handlers.get(t)?.delete(e)}emit(t,...e){this._handlers.get(t)?.forEach(a=>a(...e))}addCleanup(t){this._cleanups.push(t)}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const e=document.createElement("div");return e.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(e,document.body.firstChild),this._ownsRoot=!0,e}_applyTheme(t){if(t){for(const[e,a]of Object.entries(t))if(a!==void 0){const n=e.startsWith("--")?e:`--gengage-${Us(e)}`;this.root.style.setProperty(n,a)}}}}}));function Qn(){const t=Date.now(),e=new Uint8Array(16);crypto.getRandomValues(e),e[0]=t/2**40&255,e[1]=t/2**32&255,e[2]=t/2**24&255,e[3]=t/2**16&255,e[4]=t/2**8&255,e[5]=t&255,e[6]=e[6]&15|112,e[8]=e[8]&63|128;const a=Array.from(e,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 Os=L((()=>{}));function qs(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.gengage=="string"&&typeof e.type=="string"}function js(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}var Zn,$s=L((()=>{Zn=class{constructor(t){this._handlers=new Map,this._destroyed=!1,this._namespace=t.namespace,this._allowedOrigins=t.allowedOrigins??[location.origin],this._onMessage=t.onMessage,this._allowedOrigins.includes("*")&&js()&&console.warn("[gengage] postMessage bridge using wildcard origin. Set allowedOrigins for production security."),this._messageListener=e=>this._handlePostMessage(e),window.addEventListener("message",this._messageListener)}send(t,e){if(this._destroyed)return;const a={namespace:this._namespace,type:t};e!==void 0&&(a.payload=e),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(t,e){this._handlers.has(t)||this._handlers.set(t,new Set);const a=this._handlers.get(t);return a.add(e),()=>{a.delete(e),a.size===0&&this._handlers.delete(t)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(t){if(this._destroyed||!this._isOriginAllowed(t.origin))return;const e=t.data;if(!qs(e)||e.gengage!==this._namespace)return;const a={type:e.type};e.payload!==void 0&&(a.payload=e.payload),this._onMessage?.(a);const n=this._handlers.get(a.type);if(n)for(const i of n)i(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}}));function Xn(t,e){if(typeof window>"u"||!pe(t))return!1;const a=new CustomEvent("gengage:navigate",{detail:e===void 0?{url:t}:{url:t,newTab:e},cancelable:!0});return window.dispatchEvent(a)?(e?window.open(t,"_blank","noopener,noreferrer"):window.location.href=t,!0):!1}var Jn=L((()=>{ge()}));function Vs(t,e,a={}){const n=t.action,i=a.logger??ei;switch(Be("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":e.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){st(n,e,a,i);return}if(!pe(n.url)){i.warn("[gengage] Blocked navigation to unsafe URL:",n.url);return}const r=typeof n.newTab=="boolean"?n.newTab:void 0;if(e.navigate){e.navigate({url:n.url,...r!==void 0&&{newTab:r}});return}(a.defaultNavigate??Gs)(n.url,r);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){st(n,e,a,i);return}e.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"){st(n,e,a,i);return}e.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){st(n,e,a,i);return}if(typeof n.name!="string"){st(n,e,a,i);return}const r=Ws(n.payload)?n.payload:void 0;e.scriptCall?.({name:n.name,...r!==void 0&&{payload:r}});return}default:st(n,e,a,i)}}function st(t,e,a,n){const i=a.unknownActionPolicy??"log-and-ignore";if(i==="delegate"){e.unknown?.(t),e.unknown||n.warn("[gengage] Unknown action received without delegate handler",t);return}if(i==="throw")throw new Error(`[gengage] Unknown action kind: ${t.kind}`);n.warn("[gengage] Unknown action ignored",t)}function Gs(t,e){if(!(typeof window>"u")){if(!pe(t)){console.warn("[gengage] Blocked navigation to unsafe URL:",t);return}Xn(t,e)}}function Ws(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ei,Ks=L((()=>{ge(),ot(),Jn(),ei=console}));function He(t){const e=t?.trim();return e||"tr"}var ht=L((()=>{}));function ve(t){const e=globalThis.CSS?.escape;if(typeof e=="function")return e(t);const a=Array.from(t);return a.map((n,i)=>{const r=n.codePointAt(0);return r===void 0?"":r===0?"�":r>=1&&r<=31||r===127||i===0&&r>=48&&r<=57||i===1&&a[0]==="-"&&r>=48&&r<=57?`\\${r.toString(16)} `:i===0&&n==="-"&&a.length===1?"\\-":r>=128||/[A-Za-z0-9_-]/.test(n)?n:`\\${n}`}).join("")}var It=L((()=>{}));function Ys(t){return ti.includes(t.type)?t.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}var ti,Qs,Zs=L((()=>{ti=["image/jpeg","image/png","image/webp"],Qs=5*1024*1024}));function ai(t){return typeof t=="object"&&t!==null&&typeof t.type=="string"}function Xs(t){const e=[];let a=0,n=!1,i=!1,r=0;for(let o=0;o<t.length;o++){const s=t[o];if(i){i=!1;continue}if(s==="\\"&&n){i=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&a++,s==="}"&&(a--,a===0&&(e.push(t.slice(r,o+1)),r=o+1)))}return e.length>0?e:[t]}function ni(t,e){const a=t.trim();if(!a||a.startsWith(":"))return!1;const n=a.startsWith("data: ")?a.slice(6):a;if(n==="[DONE]")return e.onDone?.(),!0;try{const i=JSON.parse(n);return ai(i)?(Be("stream",`event: ${i.type}`,i),e.onEvent(i),i.type==="done"?(e.onDone?.(),!0):!1):!1}catch{const i=Xs(n);if(i.length>1){for(const r of i)try{const o=JSON.parse(r);if(!ai(o))continue;if(e.onEvent(o),o.type==="done")return e.onDone?.(),!0}catch{}return!1}return!1}}async function Nt(t,e){if(!t.ok){e.onError?.(new Error(`HTTP ${t.status}: ${t.statusText}`));return}if(!t.body){e.onError?.(new Error("Response body is null — streaming not supported"));return}const a=t.body.getReader(),n=new TextDecoder("utf-8");let i="";const r=e.idleTimeoutMs??6e4,o=Symbol("idle-timeout");let s=!1;try{for(;;){const c=a.read();let l;const p=await(r>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(o),r)})]):c);if(p===o){s=!0,await a.cancel();break}const{done:d,value:h}=p;if(d)break;i+=n.decode(h,{stream:!0});const f=i.split(`
|
|
48
48
|
`);i=f.pop()??"";for(const b of f)if(ni(b,e))return}if(i.trim()&&ni(i,e))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;e.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||a.releaseLock()}e.onDone?.()}var va=L((()=>{ot()}));function Js(t){const e=(t.display_keywords??[]).flatMap(i=>Mt(i,{stripLeadingStopWords:!0})),a=e.filter((i,r)=>e.indexOf(i)===r);if(a.length>0)return a.slice(0,ya);const n=[...Mt(t.chosen_attribute,{stripLeadingStopWords:!0}),...Mt(t.short_name)];return n.filter((i,r)=>n.indexOf(i)===r).slice(0,ya)}function ec(t){return Js(t).join(" • ")}var ya,ii,Mt,tc=L((()=>{ya=3,ii=(t,e)=>{const a=t.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!a)return"";const n=e?.stripLeadingStopWords?a.replace(/^(?:daha|için)\s+/i,"").trim():a;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},Mt=(t,e)=>t?t.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>ii(a,e)).filter(Boolean):[]}));function ri(t){return t==="beauty_consulting"||t==="account_expert"}var oi=L((()=>{}));function xa(...t){for(const e of t){if(typeof e!="string")continue;const a=e.trim();if(a.length>0)return a}}function _a(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim()):[]}function Bt(t){const e={...t},a=xa(e.sku),n=_a(e.group_skus);if(a?e.sku=a:delete e.sku,n.length>0?e.group_skus=n:delete e.group_skus,a||n.length>0)delete e.image_url;else{const i=xa(e.image_url);i?e.image_url=i:delete e.image_url}return e}var wa=L((()=>{}));function Rt(t){if(typeof t.type!="string")return null;if(ac(t))return t;const e=t;switch(e.type){case"outputText":return nc(e);case"suggestedActions":return ic(e);case"productList":return rc(e);case"productDetails":return oc(e);case"productDetailsSimilars":return sc(e);case"comparisonTable":return cc(e);case"context":return pc(e);case"chatStreamEnd":return hc();case"loading":return uc(e);case"panelLoading":return mc(e);case"similarLoading":return fc(e);case"redirect":return bc(e);case"error":return vc(e);case"dummy":return yc(e);case"launcherAction":return xc(e);case"text":return ka(e);case"productItem":return _c(e);case"text_image":return si(e);case"quick_qna":return ci(e);case"reviewHighlights":return wc(e);case"aiProductSuggestions":return Sc(e);case"aiProductGroupings":return Ec(e);case"aiSuggestedSearches":return Tc(e);case"prosAndCons":return kc(e);case"getGroundingReview":return Ac(e);case"voice":return Ic(e);case"visitorDataResponse":return Cc(e);case"productListPreview":return Lc();case"groupList":return Nc(e);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Mc(e);case"launcherContent":return Rc(e);case"handoff":return Bc(e);case"uiSpec":return $c(e);default:return null}}function ac(t){const e=t.type;if(typeof e!="string")return!1;switch(e){case"metadata":return typeof t.sessionId=="string"&&typeof t.model=="string";case"text_chunk":return typeof t.content=="string";case"ui_spec":{const a=t.widget;if(a!=="chat"&&a!=="qna"&&a!=="simrel")return!1;const n=xe(t.spec);return n?typeof n.root=="string"&&xe(n.elements)!==null:!1}case"action":{const a=xe(t.action);return a!==null&&typeof a.kind=="string"}case"error":return typeof t.code=="string"&&typeof t.message=="string";case"done":return!0;default:return!1}}function nc(t){const e=ee(t.payload.text,t.payload.plain_text)??"",a=ee(t.payload.plain_text,t.payload.text)??e;if(t.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:a||"Backend returned an error"};const n={type:"text_chunk",content:e,final:!0},i=t.payload.product_mentions;Array.isArray(i)&&i.length>0&&(n.productMentions=i.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const r=t.payload.sku_to_product_item;r&&typeof r=="object"&&!Array.isArray(r)&&(n.skuToProductItem=r);const o=t.payload.conversation_mode;typeof o=="string"&&o&&(n.conversationMode=o);const s=t.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),t.payload.kvkk===!0&&(n.kvkk=!0),n}function ic(t){return li((t.payload.actions??[]).map(e=>{const a=ee(e.title)??"",n=Ee(e.requestDetails,a),i=n?{label:a,action:n}:null;return i?(typeof e.icon=="string"&&(i.icon=e.icon),typeof e.image=="string"&&(i.image=e.image),i):null}).filter(mt),"chat")}function rc(t){const e=Array.isArray(t.payload.grouped_assignment)?t.payload.grouped_assignment:[],a=(Array.isArray(t.payload.style_variations)?t.payload.style_variations:[]).map(s=>{const c=ee(s.style_label);if(!c)return null;const l=ee(s.style_mood),p=ee(s.image_url??void 0),d=(Array.isArray(s.product_list)?s.product_list:[]).map(f=>{const b=xe(f);return b?Ea(xe(b.product_detail)??xe(b.product)??b):null}).filter(mt),h=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(f=>({label:ee(f.label)??"",reason:ee(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(b=>typeof b=="string"&&b.trim().length>0):[]})):[];return{style_label:c,style_mood:l??"",...p?{image_url:p}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:d,recommendation_groups:h}}).filter(mt),n=t.payload.product_list??[],i=ri(t.payload.source)&&a.length>0?a[0].product_list:null,r=i?Hc(i,"chat"):e.length>0?zc(e,n,"chat")??Sa(n,"chat"):Sa(n,"chat");r.panelHint="panel";const o=r.spec.elements[r.spec.root];if(o){const s={};typeof t.payload.offset=="number"&&(s.offset=t.payload.offset),typeof t.payload.end_of_list=="boolean"&&(s.endOfList=t.payload.end_of_list),typeof t.payload.title=="string"&&(s.panelTitle=t.payload.title),typeof t.payload.source=="string"&&(s.source=t.payload.source),a.length>0&&(s.styleVariations=a),t.payload.replace_panel===!0&&(s.replacePanel=!0),(t.payload.ranking_state==="pending"||t.payload.ranking_state==="final")&&(s.rankingState=t.payload.ranking_state);const c=t.payload.sequence_id??t.payload.search_id;typeof c=="string"&&c.length>0&&(s.sequenceId=c),Object.keys(s).length>0&&(o.props={...o.props,...s})}return r}function oc(t){const e=t.payload.productDetails;if(!e)return Dc("chat");const a=Fe(e);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...e,...a}}}}},panelHint:"panel"}}function sc(t){const e=Sa(t.payload.similarProducts??[],"chat"),a=e.spec.elements[e.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...e,panelHint:"panel"}}function cc(t){const e=t.payload.multiple_product_details??[],a=t.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,...t.payload.product_comparison_framework??{}},i=t.payload.table,r=t.payload.features_list,o=[];for(const u of e){const g=Fe(u);o.push(g)}const s=lc(i,o,n,r);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(u=>u.sku===c)??o[0]:o[0],p=[];if(Array.isArray(n?.key_differences))for(const u of n.key_differences)typeof u=="string"&&p.push(u);const d=gi(n?.special_considerations),h=n?.recommended_choice,f=n?.winner_hits,b={};for(const u of o){const g=u.sku;g&&(b[g]={title:u.name??g,type:"launchSingleProduct",payload:{sku:g}})}const m={products:o,attributes:s,highlights:p,productActions:b};return l&&(m.recommended=l),d.length>0&&(m.specialCases=d),h&&(m.recommendedText=h),f&&(m.winnerHits=f),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 lc(t,e,a,n){if(!t)return[];const i=Object.entries(t);if(i.length===0)return[];const r=i[0]?.[1];if(Array.isArray(r)){const d=a.criteria_view??a.criteria_view_short??{},h=a.compared_field_names??Object.keys(t),f=[];for(const b of h){const m=t[b];if(!m||!Array.isArray(m))continue;const u=d[b]??b;f.push({label:u,values:m.map(g=>typeof g=="string"?g:String(g??""))})}return f}const o=t,s=e.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:gc(o)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),p=[];for(const d of l){const h=s.map(b=>{const m=o[b];if(!m||typeof m!="object")return"";const u=m[`${d}_short`],g=m[d];return dc(u??g)});if(h.every(b=>b.length===0))continue;const f=c[d]??d;p.push({label:f,values:h})}return p}function gc(t){const e=[],a=new Set;for(const n of Object.values(t))if(!(!n||typeof n!="object"))for(const i of Object.keys(n))a.has(i)||(a.add(i),e.push(i));return e}function dc(t){return typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):""}function pc(t){return{type:"metadata",sessionId:"",model:"",meta:{panel:t.payload.panel,messages:t.payload.messages,message_id:t.payload.message_id}}}function hc(){return{type:"done"}}function uc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:t.payload.text,thinkingMessages:t.payload.thinking_messages,dynamicLoading:t.payload.is_dynamic===!0}}}function mc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function fc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function bc(t){const e=ee(t.payload.url);return e?{type:"action",action:{kind:"navigate",url:e,newTab:t.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:t.payload,redirectTarget:ee(t.payload.to)}}}function vc(t){return{type:"error",code:"BACKEND_ERROR",message:ee(t.payload?.text,t.payload?.message,t.payload?.error)??"Backend returned an error"}}function yc(t){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function xc(t){const e=t.payload??{};if(Array.isArray(e.action_list)){const i={action_list:e.action_list},r=typeof e.type=="string"?e.type:void 0,o=typeof e.theme=="string"?e.theme:void 0;return r!==void 0&&(i.type=r),o!==void 0&&(i.theme=o),ci({type:"quick_qna",payload:i})}const a=xe(e.action);if(a){const i={action:a},r=typeof e.text=="string"?e.text:void 0,o=typeof e.image_url=="string"?e.image_url:void 0,s=typeof e.theme=="string"?e.theme:void 0;return r!==void 0&&(i.text=r),o!==void 0&&(i.image_url=o),s!==void 0&&(i.theme=s),si({type:"text_image",payload:i})}const n=typeof e.text=="string"?e.text:"";if(n){const i={text:n},r=typeof e.type=="string"?e.type:void 0,o=typeof e.theme=="string"?e.theme:void 0,s=xe(e.payload)??void 0;return r!==void 0&&(i.type=r),s!==void 0&&(i.payload=s),o!==void 0&&(i.theme=o),ka({type:"text",payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:e}}}function ka(t){const e={text:ee(t.payload.text)??""};return typeof t.payload.theme=="string"&&(e.theme=t.payload.theme),t.payload.payload!==void 0&&(e.payload=t.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:e}}}}}function _c(t){return Fc(t.payload,"qna")}function si(t){const e=ee(t.payload.text)??"",a=Ee(t.payload.action,e);if(a){const i={label:e||a.title,action:a};return typeof t.payload.image_url=="string"&&(i.image=t.payload.image_url),typeof t.payload.theme=="string"&&(i.theme=t.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:i}}}}}const n={text:e};return typeof t.payload.theme=="string"&&(n.theme=t.payload.theme),ka({type:"text",payload:n})}function ci(t){return li((t.payload.action_list??[]).map(e=>{const a=ee(e.title)??"",n=Ee(e.requestDetails,a),i=n?{label:a,action:n}:null;return i?(typeof e.icon=="string"&&(i.icon=e.icon),typeof e.image=="string"&&(i.image=e.image),i):null}).filter(mt),"qna")}function wc(t){const e={reviews:(t.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 t.payload.sku=="string"&&(e.sku=t.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:e}}}}}function kc(t){const e={};return Array.isArray(t.payload.pros)&&(e.pros=t.payload.pros),Array.isArray(t.payload.cons)&&(e.cons=t.payload.cons),typeof t.payload.product_name=="string"&&(e.productName=t.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:e}}}}}function Cc(t){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:t.payload}}}function Sc(t){const e=t.payload.product_suggestions??[],a=[];for(let n=0;n<e.length;n++){const i=e[n];if(!i)continue;const r=Uc(i);if(!r)continue;const o={product:r},s=Ee(i.requestDetails,r.name);s&&(o.action=s),typeof i.role=="string"&&(o.role=i.role),typeof i.reason=="string"&&(o.reason=i.reason),typeof i.review_highlight=="string"&&(o.reviewHighlight=i.review_highlight),Array.isArray(i.labels)&&(o.labels=i.labels),typeof i.expert_quality_score=="number"&&(o.expertQualityScore=i.expert_quality_score),a.push(o)}return a.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:t.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:a}}}}}}function Ec(t){const e=t.payload.product_groupings??[],a=[],n=[];for(let i=0;i<e.length;i++){const r=e[i];if(!r)continue;const o=ee(r.name)??"",s=ee(r.description),c=ee(r.highlight),l=Array.isArray(r.labels)?gi(r.labels):[],p=ee(r.sku,r.repr_sku),d=ee(r.image,r.repr_image),h=Pc(r,o,p),f=(Array.isArray(r.group_products)?r.group_products:[]).map(u=>{const g=xe(u);return g?Ea(g):null}).filter(mt),b=d??ee(...f.map(u=>u.imageUrl));if(o&&f.length>0){const u={groupName:o,products:f};b&&(u.image=b),s&&(u.description=s),c&&(u.highlight=c),l.length>0&&(u.labels=l),a.push(u)}if(!h)continue;const m={name:o,action:h};l.length>0&&(m.labels=l),d!==void 0&&(m.image=d),n.push(m)}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:t.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function Pc(t,e,a){const n=xe(t.requestDetails);if(n){if(n.type!=="findSimilar")return Ee(n,e);const o={...xe(n.payload)??{}};a&&!xa(o.sku)&&(o.sku=a);const s=_a(t.group_skus);return s.length>0&&(o.group_skus=s),Ee({...n,payload:Bt(o)},e)}const i={};a&&(i.sku=a);const r=_a(t.group_skus);return r.length>0&&(i.group_skus=r),Object.keys(i).length===0?null:Ee({type:"findSimilar",payload:Bt(i)},e)}function Tc(t){const e=t.payload.suggested_searches??[],a=[];for(let n=0;n<e.length;n++){const i=e[n];if(!i)continue;const r=ee(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Search ${n+1}`,o={},s=ee(i.detailed_user_message);s&&(o.text=s);const c=xe(xe(i.requestDetails)?.payload),l=c?.group_skus;i.group_skus&&Array.isArray(i.group_skus)?o.group_skus=i.group_skus:Array.isArray(l)&&(o.group_skus=l.filter(g=>typeof g=="string"));const p=ee(i.sku,i.representative_product_sku,c?.sku);p&&(o.sku=p),o.is_suggested_text=1;const d={type:"inputText",payload:o},h=Ee(i.requestDetails,r),f=h?.type==="findSimilar"&&typeof o.text=="string"?Ee(d,r):h??Ee(d,r);if(!f)continue;const b={shortName:r,action:f},m=ee(i.detailed_user_message);m&&m!==r&&(b.detailedMessage=m);const u=ec(i);u&&u!==r&&u!==(m??"")&&(b.whyDifferent=u),typeof i.image=="string"&&(b.image=i.image),a.push(b)}return a.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:t.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:a}}}}}}function Ac(t){const e=t.payload,a=Ee(e.requestDetails??e.request_details,ee(e.review_count,e.reviewCount,e.text,e.title)??"Show product reviews");if(!a)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e}};const n={action:a};return e.title&&(n.title=e.title),e.text&&(n.text=e.text),e.review_count?n.reviewCount=e.review_count:typeof e.reviewCount=="string"&&e.reviewCount.trim()&&(n.reviewCount=e.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function Lc(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Ic(t){return{type:"metadata",sessionId:"",model:"",meta:{voice:t.payload}}}function Nc(t){const e=t.payload.group_list??[],a=[];for(const i of e){const r=i.group_name??"",o=(i.product_list??[]).map(Fe);a.push({groupName:r,products:o})}const n=[];for(const i of t.payload.filter_tags??[]){const r=i.title??"";if(!r)continue;const o=Ee(i.requestDetails,r),s={title:r};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 Mc(t){return{type:"metadata",sessionId:"",model:"",meta:{formType:t.type,formPayload:t.payload??{}}}}function Bc(t){const e={};return typeof t.payload?.summary=="string"&&(e.summary=t.payload.summary),Array.isArray(t.payload?.products_discussed)&&(e.products_discussed=t.payload.products_discussed),typeof t.payload?.user_sentiment=="string"&&(e.user_sentiment=t.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:e}}}}}function Rc(t){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:t.payload??{}}}}function Ca(t,e){const a={product:t,index:e},n=t,i=typeof n.sku=="string"?n.sku:void 0;return i&&(a.action={title:typeof n.name=="string"?n.name:"",type:"launchSingleProduct",payload:{sku:i}}),{type:"ProductCard",props:a}}function li(t,e){const a={},n=[];for(let i=0;i<t.length;i++){const r=t[i];if(!r)continue;const o=`action-${i}`;n.push(o);const s={label:r.label,action:r.action};r.icon!==void 0&&(s.icon=r.icon),r.image!==void 0&&(s.image=r.image),r.description!==void 0&&(s.description=r.description),a[o]={type:"ActionButton",props:s}}return a.root={type:"ActionButtons",props:{buttons:t.map(i=>{const r={label:i.label,action:i.action};return i.image!==void 0&&(r.image=i.image),i.description!==void 0&&(r.description=i.description),i.icon!==void 0&&(r.icon=i.icon),r})},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function Sa(t,e){const a={},n=[];for(let i=0;i<t.length;i++){const r=t[i];if(!r)continue;const o=Fe(r),s=`product-${i}`;n.push(s),a[s]=Ca(o,i)}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function zc(t,e,a){const n=new Map;for(const l of e)l?.sku&&n.set(l.sku,l);if(n.size===0)return null;const i=new Set,r={},o=[],s=[];let c=0;for(let l=0;l<t.length;l++){const p=t[l],d=ee(p?.title)??"",h=Array.isArray(p?.skus)?p.skus:[],f=[];for(let b=0;b<h.length;b++){const m=typeof h[b]=="string"?h[b].trim():"";if(!m||i.has(m))continue;const u=n.get(m);if(!u)continue;i.add(m);const g=`product-${l}-${b}`,v=Fe(u);o.push(g),f.push(g),r[g]=Ca(v,c),c+=1}f.length>0&&s.push({title:d,children:f})}return s.length===0||i.size<n.size?null:(r.root={type:"ProductGrid",props:{layout:"grouped",productSections:s},children:o},{type:"ui_spec",widget:a,spec:{root:"root",elements:r}})}function Hc(t,e){const a={},n=[];for(let i=0;i<t.length;i++){const r=t[i];if(!r)continue;const o=`product-${i}`;n.push(o),a[o]=Ca(r,i)}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function Fc(t,e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:Fe(t),index:0}}}}}}function Dc(t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Uc(t){const e=ee(t.sku),a=ee(t.short_name),n={...xe(t.product_item)??t},i=ee(t.discount_reason,t.discountReason);return i&&!ee(n.discount_reason,n.discountReason)&&(n.discount_reason=i),Ea(n,e,a)}function Ea(t,e,a){const n=ee(t.sku,e),i=ee(t.name,a);if(!n||!i)return null;const r={sku:n,name:i},o=ee(t.brand);o&&(r.brand=o);const s=ee(t.url);s&&(r.url=s);const c=Oc(t.images);if(c.length>0)r.images=c;else{const m=ee(t.image,t.image_url,t.imageUrl);m&&(r.images=[m])}const l=ut(t.price_discounted);l!==void 0&&(r.price_discounted=l);const p=ut(t.price);p!==void 0&&(r.price=p);const d=ut(t.rating);d!==void 0&&(r.rating=d);const h=ut(t.review_count)??ut(t.reviewCount);h!==void 0&&(r.review_count=h);const f=ee(t.cart_code,t.cartCode);f&&(r.cart_code=f),typeof t.in_stock=="boolean"&&(r.in_stock=t.in_stock),typeof t.inStock=="boolean"&&(r.in_stock=t.inStock);const b=ee(t.discount_reason,t.discountReason);return b&&(r.discount_reason=b),Fe(r)}function Ee(t,e){const a=xe(t);if(!a)return null;const n=a.type;if(typeof n!="string"||n.length===0)return null;const i={title:e||n,type:n};return a.payload!==void 0&&(i.payload=a.payload),i}function xe(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function ee(...t){for(const e of t)if(typeof e=="string"){const a=e.trim();if(a.length>0)return a}}function Oc(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):[]}function gi(t){if(typeof t=="string"){const e=t.trim();return e?[e]:[]}return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(e=>e.length>0):[]}function ut(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){let e;t.includes(".")&&t.includes(",")?e=t.replace(/\./g,"").replace(",","."):e=t.replace(",",".");const a=Number(e);if(Number.isFinite(a))return a}}function mt(t){return t!=null}function Fe(t){const e=t.price_discounted!=null&&t.price_discounted>0,a=e?t.price_discounted:t.price,n=e&&t.price!=null?t.price:void 0;let i;n!=null&&a!=null&&n>0?i=Math.round((n-a)/n*100):t.price_discount_rate!=null&&t.price_discount_rate>0&&(i=t.price_discount_rate);const r=ee(t.brand),o=ee(t.name)??t.sku,s=r&&!o.toLowerCase().startsWith(r.toLowerCase())?`${r} ${o}`:o,c={sku:t.sku,name:s,url:ee(t.url)??""},l=t.images?.[0];l&&(c.imageUrl=l),t.images&&t.images.length>1&&(c.images=t.images),a!=null&&a>0&&(c.price=String(a)),n!=null&&n>0&&(c.originalPrice=String(n)),i!==void 0&&(c.discountPercent=i),r!==void 0&&(c.brand=r),t.rating!==void 0&&(c.rating=t.rating),t.review_count!==void 0&&(c.reviewCount=t.review_count),t.cart_code!==void 0&&(c.cartCode=t.cart_code),t.in_stock!==void 0&&(c.inStock=t.in_stock),t.variants&&t.variants.length>0&&(c.variants=t.variants),t.discount_reason!==void 0&&(c.discountReason=t.discount_reason),t.promotions&&t.promotions.length>0&&(c.promotions=t.promotions),t.description!==void 0&&(c.description=t.description),t.description_html!==void 0&&(c.descriptionHtml=t.description_html),t.features&&t.features.length>0&&(c.features=t.features),t.specifications!==void 0&&(c.specifications=t.specifications),t.facet_hits&&(c.facetHits=t.facet_hits),t.category_names&&t.category_names.length>0&&(c.categoryNames=t.category_names),t.short_name!==void 0&&(c.shortName=t.short_name);const p=t,d={};let h=!1;for(const f of Object.keys(p))di.has(f)||(d[f]=p[f],h=!0);return h&&(c.extras=d),c}function qc(t){return t.results.map(Fe)}function jc(t){return t.product_groupings.map(e=>{const a={name:e.name,products:(e.group_products??[]).map(Fe)};return e.highlight!==void 0&&(a.highlight=e.highlight),a})}function $c(t){const e=t.payload.type,{type:a,...n}=t.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:e,props:n}}}}}var di,Pa=L((()=>{tc(),oi(),wa(),di=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 Vc(t){if(t===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const e=t.trim();return e===""?"":e.replace(/\/+$/,"")}function zt(t,e){return`${Vc(e?.middlewareUrl)}/chat${pi[t]}`}var pi,Ta=L((()=>{pi={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"}}));function Gc(t){if(!(typeof window>"u"||!t))try{const e=window.GengageAssistantInjector?.[t]?.streamTransport;return typeof e=="function"?e:void 0}catch{return}}var Wc=L((()=>{}));async function Ht(t,e={},a={}){const n=Kc(t,e);if(!n)return fetch(t,e);const i=Date.now(),r=await Qc(n,i);if(r)return Jc(r);const o=await fetch(t,e);return o.ok&&Zc(n,o.clone(),i,{ttlMs:a.ttlMs??ui,maxEntries:a.maxEntries??Ia,maxBodyBytes:a.maxBodyBytes??mi}),o}function Kc(t,e={}){if(typeof Request<"u"&&t instanceof Request)return null;const a=String(e.method||"GET").toUpperCase();return a!=="POST"||typeof e.body!="string"||Yc(e.body)?null:`rr:${ol(rl({url:String(t),method:a,headers:el(e.headers),body:e.body}))}`}function Yc(t){try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e))return!1;const a=e.type;return typeof a=="string"&&vi.has(a)}catch{return!1}}async function Qc(t,e){const a=Ie.get(t);if(a)if(a.expiresAt<=e)Ie.delete(t);else return a.lastAccessedAt=e,Ie.delete(t),Ie.set(t,a),Aa(a),a;const n=await al(t);return n?n.expiresAt<=e?(Ie.delete(t),nl(t),null):(n.lastAccessedAt=e,Ie.set(t,n),Aa(n),hi(Ia),n):null}async function Zc(t,e,a,n){try{const i=await e.text();if(sl(i)>n.maxBodyBytes||Xc(i))return;const r={key:t,status:e.status,statusText:e.statusText,headers:tl(e.headers),body:i,createdAt:a,expiresAt:a+n.ttlMs,lastAccessedAt:a};Ie.set(t,r),hi(n.maxEntries),await Aa(r),await il(n.maxEntries,a)}catch{}}function Xc(t){return/"_error"\s*:/u.test(t)||/"type"\s*:\s*"error"/u.test(t)}function Jc(t){return new Response(t.body,{status:t.status,statusText:t.statusText,headers:new Headers(t.headers)})}function el(t){const e=new Headers(t),a=[];return e.forEach((n,i)=>{const r=i.toLowerCase();r!=="authorization"&&r!=="cookie"&&a.push([r,n])}),a.sort(([n],[i])=>n.localeCompare(i))}function tl(t){const e=[];return t.forEach((a,n)=>{const i=n.toLowerCase();i!=="set-cookie"&&e.push([i,a])}),e.sort(([a],[n])=>a.localeCompare(n))}function hi(t){for(;Ie.size>t;){const e=[...Ie.values()].sort((a,n)=>a.lastAccessedAt-n.lastAccessedAt)[0];if(!e)break;Ie.delete(e.key)}}async function Ft(){return typeof indexedDB>"u"?null:(Na??=new Promise(t=>{const e=indexedDB.open(fi,bi);e.onupgradeneeded=()=>{const a=e.result;a.objectStoreNames.contains(Le)||a.createObjectStore(Le,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},e.onsuccess=()=>t(e.result),e.onerror=()=>t(null),e.onblocked=()=>t(null)}),Na)}async function al(t){const e=await Ft();return e?new Promise(a=>{const n=e.transaction(Le,"readonly"),i=n.objectStore(Le).get(t);i.onsuccess=()=>a(i.result??null),i.onerror=()=>a(null),n.onerror=()=>a(null)}):null}async function Aa(t){const e=await Ft();e&&await new Promise(a=>{const n=e.transaction(Le,"readwrite");n.objectStore(Le).put(t),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function nl(t){const e=await Ft();e&&await new Promise(a=>{const n=e.transaction(Le,"readwrite");n.objectStore(Le).delete(t),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function il(t,e){const a=await Ft();a&&await new Promise(n=>{const i=a.transaction(Le,"readwrite"),r=i.objectStore(Le),o=[],s=r.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const l=o.filter(d=>d.expiresAt<=e),p=o.filter(d=>d.expiresAt>e).sort((d,h)=>d.lastAccessedAt-h.lastAccessedAt).slice(0,Math.max(0,o.length-l.length-t));for(const d of[...l,...p])r.delete(d.key);return}o.push(c.value),c.continue()},s.onerror=()=>n(),i.oncomplete=()=>n(),i.onerror=()=>n(),i.onabort=()=>n()})}function rl(t){return JSON.stringify(La(t))}function La(t){return Array.isArray(t)?t.map(La):!t||typeof t!="object"?t:Object.fromEntries(Object.entries(t).sort(([e],[a])=>e.localeCompare(a)).map(([e,a])=>[e,La(a)]))}function ol(t){let e=14695981039346656037n;const a=1099511628211n;for(let n=0;n<t.length;n+=1)e^=BigInt(t.charCodeAt(n)),e=BigInt.asUintN(64,e*a);return e.toString(16).padStart(16,"0")}function sl(t){return typeof TextEncoder<"u"?new TextEncoder().encode(t).byteLength:t.length}var ui,Ia,mi,fi,bi,Le,vi,Ie,Na,Ma=L((()=>{ui=7200*1e3,Ia=200,mi=5*1024*1024,fi="gengage_request_response_cache",bi=1,Le="responses",vi=new Set(["addToCart","like"]),Ie=new Map,Na=null}));function cl(t,e){const a=t.type,n=t.payload!=null&&typeof t.payload=="object"&&!Array.isArray(t.payload)?t.payload:{},i=r=>{const o={...n};for(const[s,c]of Object.entries(r))s in o||(o[s]=c);return o};switch(a){case"user_message":case"inputText":{const r=typeof t.payload=="string",o=r?{text:t.payload}:t.payload!=null&&typeof t.payload=="object"&&!Array.isArray(t.payload)?t.payload:n,s={is_launcher:0};if(e.pageContext?.extra&&(s.page_details=e.pageContext.extra),!r&&!("sku_list"in o)){const l=e.pageContext?.skuList&&e.pageContext.skuList.length>0?e.pageContext.skuList:e.pageContext?.sku?[e.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,p]of Object.entries(s))l in c||(c[l]=p);return{...t,payload:c}}case"findSimilar":{const r={is_launcher:0};return t.title&&(r.text=t.title,r.input=t.title),{...t,payload:Bt(i(r))}}case"getComparisonTable":{const r=t.payload;if(r&&typeof r=="object"&&!Array.isArray(r)&&"gengage_analytics_source"in r){const o={...r};return delete o.gengage_analytics_source,{...t,payload:o}}return t}case"launchProductList":return t;case"launchHomepage":return t;case"addToCart":{const r={};return"error_message"in n||(r.error_message=""),{...t,payload:i(r)}}case"reviewSummary":{const r={};return e.pageContext?.sku&&!("sku"in n)&&(r.sku=e.pageContext.sku),Object.keys(r).length===0?t:{...t,payload:i(r)}}default:return t}}function yi(t){const{action:e,type:a,payload:n,...i}=t,r=a??e?.type??"inputText",o=n??e?.payload,s=_i[r]??r,c={...i,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function ll(t){return JSON.parse(yi(t))}function gl(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function xi(t,e){let a=!1;const n=()=>e?.aborted===!0,i=()=>a||n(),r=()=>{i()||(a=!0,t.onDone())};return{fireDone:r,callbacks:{onTextChunk:(...o)=>{i()||t.onTextChunk(...o)},onUISpec:(...o)=>{i()||t.onUISpec(...o)},onAction:o=>{i()||t.onAction(o)},onMetadata:o=>{i()||t.onMetadata(o)},onError:o=>{n()||t.onError(o)},onDone:r}}}function dl(t,e,a){const n=new AbortController,i=a.injectorAdapter??Gc(a.accountId);return i?((async()=>{const o=xi(e,n.signal);try{if(await Promise.resolve(),n.signal.aborted)return;const s=i(ll(t),o.callbacks,n.signal,a.attachment);gl(s)&&(await s,o.fireDone())}catch(s){if(n.signal.aborted||s instanceof DOMException&&s.name==="AbortError")return;o.callbacks.onError(s instanceof Error?s:new Error(String(s)))}})(),n):((async()=>{try{const o=zt("process_action",a),s=yi(t),c=a.attachment!==void 0;let l;if(c){const h=new FormData;h.append("request",s),a.attachment!==void 0&&h.append("attachment",a.attachment),l={method:"POST",body:h,signal:n.signal}}else l={method:"POST",headers:{"Content-Type":"application/json"},body:s,signal:n.signal};const p=c?await fetch(o,l):await Ht(o,l);if(!p.ok){let h=p.statusText;try{const f=await p.json(),b=f.detail??f.message??f.error;typeof b=="string"&&(h=b)}catch{}e.onError(new Error(`HTTP ${p.status}: ${h}`));return}const d=xi(e);await Nt(p,{onEvent:h=>{const f=Rt(h);if(f)switch(f.type){case"text_chunk":d.callbacks.onTextChunk(f.content,f.final===!0,{productMentions:f.productMentions,skuToProductItem:f.skuToProductItem,conversationMode:f.conversationMode,renderHint:f.renderHint,kvkk:f.kvkk});break;case"ui_spec":d.callbacks.onUISpec(f.spec,f.widget,f.panelHint,f.clearPanel===!0);break;case"action":d.callbacks.onAction(f);break;case"metadata":d.callbacks.onMetadata(f);break;case"error":d.callbacks.onError(new Error(f.message));break;case"done":d.fireDone();break}},onError:e.onError,signal:n.signal}),d.fireDone()}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;e.onError(o instanceof Error?o:new Error(String(o)))}})(),n)}var _i,pl=L((()=>{va(),Pa(),Ta(),Wc(),wa(),Ma(),_i={user_message:"inputText"}}));function hl(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search);if(wi.some(e=>t.get(e)==="1"))return!0;try{return ki.some(e=>window.localStorage.getItem(e)==="1")}catch{return!1}}function ul(t,e,a){if(!hl())return;const n=(window.__gengageChatPresentationDebugSeq??0)+1;window.__gengageChatPresentationDebugSeq=n;const i={seq:n,time:new Date().toISOString(),scope:t,message:e,payload:a};window.__gengageChatPresentationDebugLog||(window.__gengageChatPresentationDebugLog=[]),window.__gengageChatPresentationDebugLog.push(i),window.__gengageChatPresentationDebugLog.length>400&&window.__gengageChatPresentationDebugLog.shift();const r=`[gengage-chat-debug #${n}][${t}] ${e}`;a===void 0?console.debug(r):console.debug(r,a)}var wi,ki,ml=L((()=>{wi=["chat_debug","presentation_debug"],ki=["gengage_chat_debug","gengage_presentation_debug"]}));function Ci(t){Ye=t}function fl(){if(Ye&&Ye.isConnected)return Ye;Ye=null;const t=document.getElementById(ft);return t||(ul("chat-scroll","failed to resolve scroll container (not registered)",{id:ft}),null)}function Si(){Ye=null}var ft,Ye,Ei=L((()=>{ml(),ft="gengage-chat-scroll",Ye=null})),Qe,bl=L((()=>{Qe={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",productGridSectionCountLabel:"{count} ürün",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ı öneri 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",historyImageAttachmentLabel:"Görsel eklendi",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"}})),Pi,vl=L((()=>{Pi={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",productGridSectionCountLabel:"{count} product(s)",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} recommendation 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",historyImageAttachmentLabel:"Image attachment",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 yl(t){return t?t.toLowerCase().split("-")[0]??"tr":"tr"}function xl(t){return yl(t)==="en"?Pi:Qe}var bt=L((()=>{bl(),vl()}));function _l(){return Ti()!==null}function Ti(){const t=globalThis;return t.SpeechRecognition??t.webkitSpeechRecognition??null}function wl(t){switch(t){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"}}var Ai,kl=L((()=>{Ai=class{constructor(t,e){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this._lastRestartAt=0,this.callbacks=t,this.lang=e?.lang??"tr-TR",this.silenceTimeoutMs=e?.silenceTimeoutMs??1500,this.autoSubmit=e?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=Ti();if(!t){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const e=new t;e.continuous=!0,e.interimResults=!0,e.lang=this.lang,e.maxAlternatives=1,e.onstart=()=>{this.setState("listening")},e.onresult=a=>{this.clearSilenceTimer();let n="",i="";for(let r=a.resultIndex;r<a.results.length;r++){const o=a.results[r];if(!o)continue;const s=o[0];s&&(o.isFinal?i+=s.transcript:n+=s.transcript)}i&&(this.accumulatedTranscript+=i,this.callbacks.onFinal?.(this.accumulatedTranscript)),n&&this.callbacks.onInterim?.(this.accumulatedTranscript+n),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},e.onerror=a=>{const n=wl(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(n,a.message||a.error))},e.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{e.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=e;try{e.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}}));function Cl(t){const e=document.createElement("div");e.className="gengage-chat-kvkk-banner gds-evidence-card gds-evidence-card-warning",e.dataset.gengagePart="kvkk-banner",e.setAttribute("role","alert");const a=document.createElement("div");a.className="gengage-chat-kvkk-content",a.dataset.gengagePart="kvkk-content",a.innerHTML=ye(t.htmlContent),e.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",t.closeAriaLabel??"Close privacy notice"),n.textContent="×",n.addEventListener("click",t.onDismiss),e.appendChild(n),e}var Sl=L((()=>{ge()})),Li,El=L((()=>{Li=class{constructor(t){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",t.backAriaLabel??"Back"),this._backBtn.title=t.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",()=>t.onBack());const e=document.createElement("div");e.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",e.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",t.forwardAriaLabel??"Forward"),this._forwardBtn.title=t.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",()=>t.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",t.closePanelAriaLabel??"Close panel"),this._closeBtn.title=t.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",()=>t.onClose?.()),this._el.appendChild(this._backBtn),this._el.appendChild(e),this._el.appendChild(this._actionsEl),this._el.appendChild(this._forwardBtn),this._el.appendChild(this._closeBtn)}update(t,e,a){this._backBtn.disabled=!t,this._forwardBtn.disabled=!e,this._backBtn.hidden=!t,this._forwardBtn.hidden=!e,this._titleEl.textContent=a,this._titleEl.title=a}getElement(){return this._el}setTitle(t){this._titleEl.textContent=t}setActions(t){this._actionsEl.replaceChildren(),t&&this._actionsEl.appendChild(t)}getTitle(){return this._titleEl.textContent??""}}}));function Pl(t){return{processing:t.processing===!0,title:typeof t.title=="string"?t.title:void 0,description:typeof t.description=="string"?t.description:void 0,uploadLabel:typeof t.upload_label=="string"?t.upload_label:void 0,skipLabel:typeof t.skip_label=="string"?t.skip_label:void 0}}function Ii(t,e,a){const n=t.props??{},i=n.processing===!0,r={...Qe,...e.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)??r.beautyPhotoStepTitle;const p=document.createElement("p");p.className="gengage-chat-beauty-photo-step-desc",p.textContent=(typeof n.description=="string"?n.description:void 0)??r.beautyPhotoStepDescription;const d=document.createElement("div");d.className="gengage-chat-beauty-photo-step-actions";const h=document.createElement("button");h.type="button",h.className="gengage-chat-beauty-photo-step-upload gds-btn gds-btn-primary",h.textContent=i?r.beautyPhotoStepProcessing:(typeof n.upload_label=="string"?n.upload_label:void 0)??r.beautyPhotoStepUpload,h.disabled=i,a?.onUpload&&h.addEventListener("click",()=>a.onUpload());const f=document.createElement("button");return f.type="button",f.className="gengage-chat-beauty-photo-step-skip gds-btn gds-btn-ghost",f.textContent=(typeof n.skip_label=="string"?n.skip_label:void 0)??r.beautyPhotoStepSkip,a?.onSkip&&f.addEventListener("click",()=>a.onSkip()),d.appendChild(h),d.appendChild(f),c.appendChild(l),c.appendChild(p),c.appendChild(d),o.appendChild(s),o.appendChild(c),o}var Ba=L((()=>{bt()}));function Tl(t,e){if(t)return t;const a=document.createElement("section");a.className="gengage-chat-beauty-photo-step",a.dataset.gengagePart="chat-beauty-photo-step",a.hidden=!0;const n=e?.querySelector(".gengage-chat-input-area");return n?n.parentElement?.insertBefore(a,n):e?.appendChild(a),a}function Al(t,e,a,n,i){if(!a.visible)return t&&(t.hidden=!0,t.innerHTML=""),t;const r=Tl(t,e);r.hidden=!1,r.innerHTML="";const o=Ii({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:i,onSkip:a.onSkip});return r.appendChild(o),r}var Ll=L((()=>{Ba()}));function Ni(t){const e=typeof t.summary=="string"?t.summary:"",a=Array.isArray(t.strengths)?t.strengths.filter(c=>typeof c=="string"):[],n=Array.isArray(t.focus_points)?t.focus_points.filter(c=>typeof c=="string"):[];if(!e&&a.length===0&&n.length===0)return null;const i={summary:e},r=typeof t.celeb_style=="string"?t.celeb_style:void 0,o=typeof t.celeb_style_reason=="string"?t.celeb_style_reason:void 0,s=typeof t.next_question=="string"?t.next_question:void 0;return a.length>0&&(i.strengths=a),n.length>0&&(i.focusPoints=n),r&&(i.celebStyle=r),o&&(i.celebStyleReason=o),s&&(i.nextQuestion=s),i}function Mi(t,e,a){if(e.length===0)return null;const n=document.createElement("section");n.className=`gengage-chat-photo-analysis-section ${a}`;const i=document.createElement("h4");i.className="gengage-chat-photo-analysis-section-title",i.textContent=t;const r=document.createElement("ul");r.className="gengage-chat-photo-analysis-section-list";for(const o of e){const s=document.createElement("li");s.className="gengage-chat-photo-analysis-section-item",s.textContent=o,r.appendChild(s)}return n.appendChild(i),n.appendChild(r),n}function Bi(t,e){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=t.badge;const i=document.createElement("div");if(i.className="gengage-chat-photo-analysis-body",e.summary){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-summary",c.textContent=e.summary,i.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-photo-analysis-highlights";const o=Mi(t.strengths,e.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=Mi(t.focus,e.focusPoints??[],"gengage-chat-photo-analysis-section--focus");if(o&&r.appendChild(o),s&&r.appendChild(s),r.childElementCount>0&&i.appendChild(r),e.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=t.celebStyle;const p=document.createElement("p");if(p.className="gengage-chat-photo-analysis-celeb-name",p.textContent=e.celebStyle,c.appendChild(l),c.appendChild(p),e.celebStyleReason){const d=document.createElement("p");d.className="gengage-chat-photo-analysis-celeb-reason",d.textContent=e.celebStyleReason,c.appendChild(d)}i.appendChild(c)}if(e.nextQuestion){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-next",c.textContent=e.nextQuestion,i.appendChild(c)}return a.appendChild(n),a.appendChild(i),a}function Il(t){const e={...Qe,...t?.i18n??{}};return{badge:e.photoAnalysisBadge,strengths:e.photoAnalysisStrengthsLabel,focus:e.photoAnalysisFocusLabel,celebStyle:e.photoAnalysisCelebStyleLabel}}function Nl(t,e){const a=Ni(t.props??{})??{summary:""};return Bi(Il(e),a)}function Ml(t,e,a){t.innerHTML="",a&&t.appendChild(Bi(e,a))}var Ra=L((()=>{bt()}));async function Bl(t){for(const e of t)for(const a of e.types)if(a.startsWith("image/"))try{const n=await e.getType(a);if(!n||n.size===0)continue;const i=a||n.type||"image/png",r=i==="image/png"?"png":i==="image/webp"?"webp":"jpg",o=`paste-${Date.now()}.${r}`;return new File([n],o,{type:i})}catch{continue}for(const e of t)if(e.types.includes("text/html"))try{const a=(await(await e.getType("text/html")).text()).match(Hi)?.[0];if(!a||a.length>5e6)continue;const n=await(await fetch(a)).blob();if(!n||n.size===0)continue;const i=n.type||"image/png";if(!["image/jpeg","image/png","image/webp"].includes(i))continue;const r=i==="image/png"?"png":i==="image/webp"?"webp":"jpg";return new File([n],`paste-${Date.now()}.${r}`,{type:i})}catch{continue}return null}async function Rl(t){try{const e=t??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return e?Bl(await e):null}catch{}return null}var za,Ha,Ri,zi,Fa,Hi,Fi,zl=L((()=>{Ei(),ge(),Ke(),bt(),kl(),It(),Sl(),El(),Ll(),Ra(),za='<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>',Ha={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>'},Ri=Qe,zi=1400,Fa=1500,Hi=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi,Fi=class{_renderPhotoAnalysisCard(t,e){Ml(t,{badge:this.i18n.photoAnalysisBadge,strengths:this.i18n.photoAnalysisStrengthsLabel,focus:this.i18n.photoAnalysisFocusLabel,celebStyle:this.i18n.photoAnalysisCelebStyleLabel},e)}constructor(t,e){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=e,this.i18n={...Ri,...e.i18n},this.onSend=e.onSend,e.onPanelToggle!==void 0&&(this._onPanelToggle=e.onPanelToggle),e.onHostShellSync!==void 0&&(this._onHostShellSync=e.onHostShellSync),e.onAttachment!==void 0&&(this._onAttachment=e.onAttachment),e.onRollback!==void 0&&(this._onRollback=e.onRollback),e.onLinkClick!==void 0&&(this._onLinkClick=e.onLinkClick),e.voiceEnabled&&(this._voiceEnabled=!0),e.voiceLang!==void 0&&(this._voiceLang=e.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 i=null;{const S=document.createElement("div");S.className="gengage-chat-drawer-handle",S.dataset.gengagePart="chat-drawer-handle",S.setAttribute("aria-hidden","true"),S.style.pointerEvents="none",i=S}const r=document.createElement("div");r.className="gengage-chat-header gds-shell-header",r.dataset.gengagePart="chat-header";const o=document.createElement("div");o.className="gengage-chat-header-left",o.dataset.gengagePart="chat-header-left";const s=e.headerAvatarUrl??e.launcherImageUrl,c=typeof e.headerAvatarUrl=="string"&&e.headerAvatarUrl.length>0&&e.headerAvatarUrl!==e.launcherImageUrl;if(s){const S=document.createElement("img");S.className="gengage-chat-header-avatar",c&&S.classList.add("gengage-chat-header-avatar--logo"),S.dataset.gengagePart="chat-header-avatar",S.src=s,S.alt=e.headerTitle??"Assistant",o.appendChild(S)}const l=document.createElement("div");l.className="gengage-chat-header-info",l.dataset.gengagePart="chat-header-info";const p=document.createElement("div");p.className="gengage-chat-header-title-row",p.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=e.headerTitle??this.i18n.headerTitle??"Product Expert",p.appendChild(d),e.headerBadge){const S=document.createElement("span");S.className="gengage-chat-header-badge gds-badge gds-badge-brand",S.dataset.gengagePart="chat-header-badge",S.textContent=e.headerBadge,p.appendChild(S)}l.appendChild(p);const h=document.createElement("a");h.className="gengage-chat-header-powered",h.dataset.gengagePart="chat-header-powered-by",h.href="https://gengage.ai/",h.target="_blank",h.rel="noopener noreferrer",h.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(h),o.appendChild(l),r.appendChild(o);const f=document.createElement("div");f.className="gengage-chat-header-right",f.dataset.gengagePart="chat-header-actions";{const S=document.createElement("button");S.type="button",S.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel gds-btn gds-btn-ghost gds-icon-btn",S.dataset.gengagePart="chat-header-reopen-panel",S.setAttribute("aria-label",this.i18n.showPanelAriaLabel),S.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>',S.addEventListener("click",()=>this._showMobilePanelFromBtn()),f.appendChild(S),this._reopenPanelBtn=S}if(e.headerCartUrl||e.onCartClick){const S=document.createElement("button");S.type="button",S.className="gengage-chat-header-btn gengage-chat-header-btn--cart gds-btn gds-btn-ghost gds-icon-btn",S.dataset.gengagePart="chat-header-cart",S.setAttribute("aria-label",this.i18n.cartAriaLabel),S.title=this.i18n.cartAriaLabel,S.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>',S.addEventListener("click",()=>e.onCartClick?.()),f.appendChild(S),this._cartBtn=S}if(e.onHistoryClick){const S=document.createElement("button");S.type="button",S.className="gengage-chat-header-btn gengage-chat-header-btn--history gds-btn gds-btn-ghost gds-icon-btn",S.dataset.gengagePart="chat-header-history",S.setAttribute("aria-label",this.i18n.historyAriaLabel),S.title=this.i18n.historyAriaLabel,S.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>',S.addEventListener("click",()=>e.onHistoryClick?.()),f.appendChild(S)}if(e.onNewChat){const S=document.createElement("button");S.className="gengage-chat-header-btn gengage-chat-new-chat gds-btn gds-btn-ghost gds-icon-btn",S.dataset.gengagePart="chat-header-new-chat",S.type="button",S.setAttribute("aria-label",this.i18n.newChatButton),S.title=this.i18n.newChatButton,S.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>',S.addEventListener("click",()=>e.onNewChat?.()),f.appendChild(S)}const b=document.createElement("button");if(b.className="gengage-chat-close gds-btn gds-btn-ghost gds-icon-btn",b.dataset.gengagePart="chat-header-close",b.type="button",b.setAttribute("aria-label",this.i18n.closeButton),b.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>',b.addEventListener("click",e.onClose),e.showHeaderFavorites){const S=document.createElement("button");S.className="gengage-chat-header-btn gengage-chat-header-btn--fav gds-btn gds-btn-ghost gds-icon-btn",S.dataset.gengagePart="chat-header-favorites",S.type="button",S.setAttribute("aria-label",this.i18n.favoritesAriaLabel),S.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 T=document.createElement("span");T.className="gengage-chat-header-fav-badge",T.dataset.gengagePart="chat-header-favorites-badge",T.setAttribute("aria-hidden","true"),T.style.display="none",S.appendChild(T),this._favBadgeEl=T,S.addEventListener("click",()=>{e.onFavoritesClick?.()}),f.appendChild(S)}f.appendChild(b),i&&r.insertBefore(i,r.firstChild),r.appendChild(f);{let T=0,H=0,Z=!1;const re=K=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||K.target.closest('button, a, input, [role="button"]'))return;const Q=K.changedTouches?.[0];Q&&(T=Q.clientY,H=0,Z=!0,this.root.style.transition="none")},ce=K=>{if(!Z)return;const Q=K.changedTouches?.[0];if(!Q)return;H=Q.clientY-T;const X=(e.getMobileState?.()??"full")==="full"?Math.max(0,H):H;K.preventDefault(),this.root.style.transform=`translateY(${X}px)`},fe=()=>{if(!Z)return;Z=!1;const K=e.getMobileState?.()??"full";let Q;H>72?Q=K==="full"?"half":"close":H<-72&&K==="half"?Q="full":Q=K,this.root.style.transition="",Q==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",e.onMobileSnap?.("close")},280)):(this.root.style.transform="",e.onMobileSnap?.(Q)),H=0},F=()=>{Z&&(Z=!1,H=0,this.root.style.transition="",this.root.style.transform="")};r.addEventListener("touchstart",re,{passive:!0}),r.addEventListener("touchmove",ce,{passive:!1}),r.addEventListener("touchend",fe,{passive:!0}),r.addEventListener("touchcancel",F,{passive:!0}),this._cleanups.push(()=>{r.removeEventListener("touchstart",re),r.removeEventListener("touchmove",ce),r.removeEventListener("touchend",fe),r.removeEventListener("touchcancel",F)})}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 Li({onBack:()=>e.onPanelBack?.(),onForward:()=>e.onPanelForward?.(),onClose:()=>{e.getMobileViewport?.()??!1?this.hideMobilePanel():this.clearPanel(),e.onPanelClose?.()},backAriaLabel:this.i18n.backAriaLabel,forwardAriaLabel:this.i18n.forwardAriaLabel,closePanelAriaLabel:this.i18n.closePanelAriaLabel}),this._panelEl.appendChild(this._panelTopBar.getElement());const u=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",u,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",u)),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 g=document.createElement("button");g.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",g.dataset.gengagePart="chat-panel-divider-toggle",g.type="button",g.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),g.setAttribute("title",this.i18n.togglePanelAriaLabel),g.textContent="»",g.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let v=null,_=null;const y=24,k=S=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const T=S.changedTouches?.[0];T&&(v=T.clientX,_=T.clientY)},P=S=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||v===null||_===null)return;const T=S.changedTouches?.[0];if(!T)return;const H=T.clientX-v,Z=T.clientY-_;if(v=null,_=null,Math.abs(Z)<y||Math.abs(Z)<Math.abs(H))return;const re=Z<0;re!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(re),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",k,{passive:!0}),this._dividerEl.addEventListener("touchend",P,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",k),this._dividerEl.removeEventListener("touchend",P)}),this._dividerEl.appendChild(g),m.appendChild(this._dividerEl);const w=document.createElement("div");w.className="gengage-chat-conversation",w.dataset.gengagePart="chat-conversation",this._conversationEl=w,w.appendChild(r);const E=document.createElement("div");E.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",E.dataset.gengagePart="chat-offline-bar",E.setAttribute("role","status"),E.setAttribute("aria-live","polite"),E.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&E.classList.add("gengage-chat-offline-bar--visible"),w.appendChild(E);const z=()=>E.classList.add("gengage-chat-offline-bar--visible"),V=()=>E.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",z),window.addEventListener("online",V),this._cleanups.push(()=>{window.removeEventListener("offline",z),window.removeEventListener("online",V)}),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=ft,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),Ci(this.messagesEl);const W=document.createElement("button");W.type="button",W.className="gengage-chat-former-messages-btn gds-chip",W.dataset.gengagePart="chat-former-messages-button",W.textContent=this.i18n.showFormerMessagesButton,W.setAttribute("aria-label",this.i18n.showFormerMessagesButton),W.style.display="none",W.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(W),this._formerMessagesBtn=W;const oe=()=>{this._userInteractionUntil=Date.now()+2e3};let ie=!1;const A=()=>this._options.presentation,D=()=>{ie||(ie=!0,requestAnimationFrame(()=>{ie=!1;const{scrollTop:S,scrollHeight:T,clientHeight:H}=this.messagesEl,Z=T-S-H;this._userScrolledUp=Z>10;const re=this._presentationPinned?Z<96:Z<32,ce=Date.now(),fe=ce<this._programmaticScrollUntil,F=!re&&ce<this._userInteractionUntil,K=fe?!1:F;re!==this._presentationPinned&&(this._presentationPinned=re,A()?.onPinnedToBottomChange?.(re)),K!==this._presentationUserInteracting&&(this._presentationUserInteracting=K,A()?.onUserInteractingChange?.(K))}))};this.messagesEl.addEventListener("scroll",D,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",D)});const C=S=>{oe(),S.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",C,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",C));const M=S=>{oe(),this._touchStartY=S.touches[0]?.clientY??null},O=S=>{oe();const T=S.touches[0]?.clientY,H=this._touchStartY;typeof T=="number"&&typeof H=="number"&&T-H>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",M,{passive:!0}),this.messagesEl.addEventListener("touchmove",O,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",M),this.messagesEl.removeEventListener("touchmove",O)}),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 U=document.createElement("div");U.className="gengage-chat-pills-scroll",U.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(U);const R=document.createElement("button");R.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",R.dataset.gengagePart="chat-suggestion-pills-more",R.type="button",R.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),R.textContent="›",R.addEventListener("click",()=>{U.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(R);let ne=!1;const ae=()=>{ne||(ne=!0,requestAnimationFrame(()=>{ne=!1;const S=U.scrollLeft+U.clientWidth>=U.scrollWidth-4;R.style.display=S?"none":""}))};U.addEventListener("scroll",ae,{passive:!0}),this._cleanups.push(()=>{U.removeEventListener("scroll",ae)}),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 G=document.createElement("div");G.className="gengage-chat-input-area",G.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",S=>{S.key==="Enter"&&!S.isComposing&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!S.shiftKey)&&(S.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",S=>{const T=S.clipboardData;if(!T)return;let H=null;const Z=T.files?.[0];if(Z&&Z.type.startsWith("image/"))H=Z;else if(T.items?.length)for(let re=0;re<T.items.length;re++){const ce=T.items[re];if(ce?.kind==="file"&&ce.type.startsWith("image/")){const fe=ce.getAsFile();if(fe){H=fe;break}}}H&&(S.preventDefault(),this._routeAttachmentFile(H))}),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 S=this._fileInput.files?.[0];S&&this._routeAttachmentFile(S),this._fileInput.value=""});const x=document.createElement("div");x.className="gengage-chat-attach-wrap",x.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=x;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",S=>{S.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 B=document.createElement("button");B.type="button",B.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",B.dataset.gengagePart="chat-attach-menu-select-photo",B.setAttribute("role","menuitem"),B.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>`,B.addEventListener("click",S=>{S.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const q=document.createElement("div");q.className="gengage-chat-attach-menu-sep",q.dataset.gengagePart="chat-attach-menu-separator",q.setAttribute("aria-hidden","true");const j=document.createElement("button");j.type="button",j.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",j.dataset.gengagePart="chat-attach-menu-paste",j.setAttribute("role","menuitem"),j.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>`,j.addEventListener("click",S=>{S.stopPropagation();const T=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(T)}),I.appendChild(B),I.appendChild(q),I.appendChild(j),x.appendChild(N),x.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 $=document.createElement("img");$.className="gengage-chat-attachment-preview-thumb",$.dataset.gengagePart="chat-attachment-preview-thumb",$.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const J=document.createElement("button");J.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",J.dataset.gengagePart="chat-attachment-preview-remove",J.type="button",J.setAttribute("aria-label",this.i18n.removeAttachmentButton),J.textContent="×",J.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild($),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(J),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 S=this._sendStopHandler;this.hideStopButton(),S();return}this._submit()}),G.addEventListener("dragover",S=>{S.preventDefault(),G.classList.add("gengage-chat-input-area--dragover")}),G.addEventListener("dragleave",()=>{G.classList.remove("gengage-chat-input-area--dragover")}),G.addEventListener("drop",S=>{S.preventDefault(),G.classList.remove("gengage-chat-input-area--dragover");const T=S.dataTransfer?.files[0];T&&this._routeAttachmentFile(T)});const Y=document.createElement("div");Y.className="gengage-chat-input-pill gds-input-shell",Y.dataset.gengagePart="chat-input-shell",Y.appendChild(x),Y.appendChild(this.inputEl),this._voiceEnabled&&_l()&&(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()),Y.appendChild(this._micBtn),this._voiceInput=new Ai({onInterim:S=>{this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.inputEl.value=S,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:S=>{this.inputEl.value=S},onAutoSubmit:S=>{this.inputEl.value=S,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:S=>{S==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(S,T)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),Y.appendChild(this.sendBtn),G.appendChild(this._previewStrip),G.appendChild(this._fileInput),G.appendChild(Y),w.appendChild(G),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 se=document.createElement("div");se.className="gengage-chat-footer",se.dataset.gengagePart="chat-footer",se.textContent=this.i18n.poweredBy,this.root.appendChild(se);const me=S=>{S.key==="Escape"&&e.onClose()};this.root.addEventListener("keydown",me),this._cleanups.push(()=>this.root.removeEventListener("keydown",me)),t.appendChild(this.root)}addMessage(t){const e=this._options.renderMessageUISpec?.(t)??null;if(!(t.content||t.attachment||e||t.role==="user"&&this._onRollback))return;const a=document.createElement("div");if(a.className=`gengage-chat-bubble gds-message ${t.role==="assistant"?"gds-message-assistant":"gds-message-user"} gengage-chat-bubble--${t.role}`,a.dataset.gengagePart=t.role==="assistant"?"chat-message-assistant":"chat-message-user",a.setAttribute("role","listitem"),a.dataset.messageId=t.id,t.threadId&&(a.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&a.classList.add("gengage-chat-bubble--first"),t.attachment){const n=document.createElement("img");n.className="gengage-chat-attachment-thumb";const i=URL.createObjectURL(t.attachment);n.src=i,n.alt=t.attachment.name,n.addEventListener("load",()=>URL.revokeObjectURL(i),{once:!0}),n.addEventListener("error",()=>URL.revokeObjectURL(i),{once:!0}),a.insertBefore(n,a.firstChild)}if(t.content){const n=document.createElement("div");if(n.className="gengage-chat-bubble-text",n.dataset.gengagePart="chat-message-text",t.role==="assistant"){if(t.renderHint==="photo_analysis"?(a.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(n,t.photoAnalysis)):n.innerHTML=ye(t.content),this._onLinkClick){const i=n.querySelectorAll("a[href]");for(const r of i)r.addEventListener("click",o=>{o.preventDefault();const s=r.getAttribute("href");s&&this._onLinkClick?.(s)})}}else n.textContent=t.content;a.appendChild(n)}if(e&&(a.classList.add("gengage-chat-bubble--ui-spec"),t.content||a.classList.add("gengage-chat-bubble--ui-spec-only"),e.classList.add("gengage-chat-bubble-ui-spec"),(e.classList.contains("gengage-chat-panel-restore-card")||e.querySelector(".gengage-chat-panel-restore-card")!==null)&&a.classList.add("gengage-chat-bubble--panel-restore"),a.appendChild(e)),t.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",i=>{i.stopPropagation(),this._onRollback?.(t.id)}),a.appendChild(n)}this.messagesEl.appendChild(a),this._presentationFocusThreadId&&this._applyPresentationCollapsed(),this._scrollToBottom(t.role==="user")}removeMessageBubble(t){this._firstBotMessageIds.delete(t),this.messagesEl.querySelector(`[data-message-id="${ve(t)}"]`)?.remove(),this._presentationFocusThreadId&&this._applyPresentationCollapsed()}showTypingIndicator(t,e="auto"){this.removeTypingIndicator();const a=this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):t?[t]:this.i18n.loadingSequenceGeneric,{root:n,binding:i}=this._createLoadingSequence("chat",a,"chat-typing-indicator","gengage-chat-typing");n.dataset.typing="true",this._typingLoadingBinding=i,this.messagesEl.appendChild(n),this.setTypingIndicatorMode(e),this._scrollToBottom(!0)}addThinkingStep(t){const e=t.trim();e&&this._thinkingSteps[this._thinkingSteps.length-1]!==e&&(this._thinkingSteps.push(e),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(t){const e=t.map(a=>a.trim()).filter(Boolean).slice(-3);e.length!==0&&(this._thinkingSteps=e,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()}setTypingIndicatorMode(t){const e=this.messagesEl.querySelector(".gengage-chat-typing"),a=this._typingLoadingBinding;if(!e||!a)return;const n=t==="auto"?this._panelOwnsProgressSurface()?"presence":"full":t;e.dataset.progressMode!==n&&(e.classList.toggle("gengage-chat-typing--presence",n==="presence"),e.dataset.progressMode=n,n==="presence"?(a.labelEl.setAttribute("aria-hidden","true"),a.labelEl.classList.add("gengage-sr-only"),e.setAttribute("aria-label",this.i18n.loadingMessage)):(a.labelEl.removeAttribute("aria-hidden"),a.labelEl.classList.remove("gengage-sr-only"),e.removeAttribute("aria-label")))}_panelOwnsProgressSurface(){return(this._options.getMobileViewport?.()??window.innerWidth<=768)||!this._panelVisible||this._panelCollapsed?!1:this._panelLoadingBinding!==null||this._panelAiZoneLoadingBinding!==null}showStopButton(t){this._sendStopHandler=t,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(t,e){const a=document.createElement("div");a.className="gengage-chat-error",a.setAttribute("role","alert");const n=document.createElement("span");if(n.textContent=t??this.i18n.errorMessage,a.appendChild(n),e){const i=document.createElement("button");i.className="gengage-chat-error-retry",i.textContent=this.i18n.retryButton??"Retry",i.addEventListener("click",()=>{a.remove(),e()}),a.appendChild(i)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}showErrorWithRecovery(t,e){this.showError(t),this.setRecoveryPills(e)}showRecoveryPillsOnly(t){this.setRecoveryPills(t)}setRecoveryPills(t){this.setPills([{label:this.i18n.tryAgainButton,onAction:t.onRetry},{label:this.i18n.askSomethingElseButton,onAction:t.onNewQuestion}])}clearMessages(){const t=this._formerMessagesBtn;for(const e of[...this.messagesEl.children])e!==t&&e.remove()}setPills(t){const e=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!e)return;for(;e.firstChild;)e.removeChild(e.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const n of t){const i=document.createElement("button");if(i.className=n.image?"gengage-chat-pill gds-chip gds-chip-active gengage-chat-pill--rich":"gengage-chat-pill gds-chip gds-chip-active",i.type="button",n.icon){const o=Ha[n.icon]??za,s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,i.appendChild(s)}if(n.image&&we(n.image)){const o=document.createElement("img");o.className="gengage-chat-pill-img",o.src=n.image,o.alt="",i.appendChild(o)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=n.label,i.appendChild(r),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,i.appendChild(o),i.setAttribute("aria-describedby",s)}i.addEventListener("click",()=>n.onAction()),e.appendChild(i)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=e.scrollWidth>e.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,e){this._kvkkSlot.innerHTML="";const a=Cl({htmlContent:t,onDismiss:e,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(t){this._attachWrapEl&&(this._attachWrapEl.style.display=t?"":"none",t||this._closeAttachMenu())}setBeautyPhotoStepCard(t){this._beautyPhotoStepEl=Al(this._beautyPhotoStepEl,this._conversationEl??null,t,this.i18n,()=>this.openAttachmentPicker())}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const e=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");e&&(e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),e.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}_routeAttachmentFile(t){if(this._onAttachment)try{this._onAttachment(t)}catch(e){console.error("[gengage:chat] Attachment callback error:",e)}else this.stageAttachment(t)}_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 t=a=>{this._attachWrapEl?.contains(a.target)||this._closeAttachMenu()},e=a=>{a.key==="Escape"&&(a.stopPropagation(),this._closeAttachMenu())};this._attachMenuClickTimerId=window.setTimeout(()=>{this._attachMenuClickTimerId=null,document.addEventListener("click",t,!0)},0),document.addEventListener("keydown",e,!0),this._attachMenuCleanup=()=>{document.removeEventListener("click",t,!0),document.removeEventListener("keydown",e,!0)}}_toggleAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.hasAttribute("hidden")?this._openAttachMenu():this._closeAttachMenu())}async _pasteImageFromClipboardMenu(t){const e=await Rl(t);if(e){this._routeAttachmentFile(e),this._closeAttachMenu();return}ue("gengage:global:error",{message:this.i18n.clipboardNoImageMessage,source:"chat"}),this._closeAttachMenu()}getPendingAttachment(){return this._pendingAttachment}setPanelAiZoneState(t,e){if(this._panelAiZoneEl.isConnected&&(this._clearPanelAiZoneState(),t!=="hidden")){if(this._panelAiZoneEl.removeAttribute("hidden"),t==="analyzing"){this._panelAiZoneEl.innerHTML="";const a=[e?.analyzingLabel??this.i18n.aiAnalysisAnalyzingLabel,...this.i18n.loadingSequencePanel],{root:n,binding:i}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-ai-zone-loading","gengage-chat-panel-ai-zone-inner");this._panelAiZoneLoadingBinding=i,this._panelAiZoneEl.appendChild(n)}else t==="results"&&e?.resultEl&&(this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.appendChild(e.resultEl));this.setTypingIndicatorMode("auto")}}_clearPanelAiZoneState(){this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden",""),this.setTypingIndicatorMode("auto")}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}_emitHostShellSync(){this.setTypingIndicatorMode("auto"),this._onHostShellSync?.()}_applyPanelCollapsedState(){this._panelEl.classList.toggle("gengage-chat-panel--collapsed",this._panelCollapsed);const t=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");t&&(t.textContent=this._panelCollapsed?"«":"»")}_syncPanelTopBarFromContent(t){const e=t.querySelector(".gengage-chat-product-grid-head");if(e){const a=e.querySelector(".gengage-chat-product-grid-head-title"),n=e.querySelector(".gengage-chat-product-grid-head-actions");if(a?.textContent?.trim()){const i=a.textContent.trim();t.dataset.gengagePanelDerivedTitle=i,this._panelTopBar.setTitle(i)}n?(n.classList.add("gengage-chat-panel-topbar-toolbar-host"),this._panelTopBar.setActions(n)):this._panelTopBar.setActions(null),e.remove();return}this._syncPanelTopBarTitleFromContent(t)}_syncPanelTopBarTitleFromContent(t){const e=t.dataset.gengagePanelDerivedTitle;if(e?.trim()){this._panelTopBar.setTitle(e.trim());return}const a=t.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(t,e){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,e?.preserveAiZone!==!0&&this._clearPanelAiZoneState(),this._panelVisible?this._swapPanelContent(t):(this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelTopBar.setActions(null),this._panelEl.appendChild(t),this._panelEl.appendChild(this._panelFloatingEl)),this._syncPanelTopBarFromContent(t),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(t){this._panelTopBar.setActions(null);const e=this._panelEl.querySelector(".gengage-chat-panel-skeleton");if(e){e.replaceWith(t);return}const a=this.getPanelContentElement();if(a){a.replaceWith(t);return}this._panelEl.insertBefore(t,this._panelFloatingEl)}appendPanelContent(t){this._panelEl.insertBefore(t,this._panelFloatingEl),this._syncPanelTopBarFromContent(this.getPanelContentElement()??t),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 t=this._panelEl.children;for(let e=0;e<t.length;e++){const a=t[e];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 t=this.getPanelContentElement();t&&this._syncPanelTopBarFromContent(t)}isPanelVisible(){return this._panelVisible}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){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 e=document.createElement("div");e.className="gengage-chat-panel-skeleton";const a=t==="comparisonTable"?this.i18n.loadingSequenceComparison:this.i18n.loadingSequencePanel,{root:n,binding:i}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-loading-status","gengage-chat-panel-loading-status");switch(this._panelLoadingBinding=i,t){case"productDetails":{e.appendChild(n);const r=document.createElement("div");r.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",e.appendChild(r);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",e.appendChild(s)}break}case"productList":case"groupList":{e.appendChild(n);const r=document.createElement("div");r.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",r.appendChild(s)}e.appendChild(r);break}case"comparisonTable":{e.classList.add("gengage-chat-panel-skeleton--comparison"),e.appendChild(n);const r=document.createElement("div");r.className="gengage-chat-comparison gengage-chat-comparison--skeleton",r.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 p=document.createElement("div");p.className="gengage-chat-comparison-recommended-info";for(let w=0;w<2;w++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",w===1&&E.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),p.appendChild(E)}const d=document.createElement("div");d.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",p.appendChild(d),c.appendChild(l),c.appendChild(p),o.appendChild(c);const h=document.createElement("div");h.className="gengage-chat-comparison-highlights";const f=document.createElement("div");f.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-label",h.appendChild(f);const b=document.createElement("ul");b.className="gengage-chat-comparison-skeleton-hl-list";for(let w=0;w<3;w++){const E=document.createElement("li"),z=document.createElement("div");z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",w===1&&z.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),w===2&&z.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),E.appendChild(z),b.appendChild(E)}h.appendChild(b),o.appendChild(h),r.appendChild(o);const m=document.createElement("div");m.className="gengage-chat-comparison-key-differences";const u=document.createElement("div");u.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-heading",m.appendChild(u);const g=document.createElement("div");g.className="gengage-chat-comparison-key-differences-content";for(let w=0;w<4;w++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",g.appendChild(E)}m.appendChild(g),r.appendChild(m);const v=document.createElement("div");v.className="gengage-chat-comparison-special gengage-chat-comparison-special--skeleton";const _=document.createElement("div");_.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-special-line",v.appendChild(_),r.appendChild(v);const y=document.createElement("div");y.className="gengage-chat-comparison-skeleton-table-wrap";const k=document.createElement("div");k.className="gengage-chat-comparison-skeleton-table-head";const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-table-corner",k.appendChild(P);for(let w=0;w<3;w++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-col";const z=document.createElement("div");z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";const V=document.createElement("div");V.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const W=document.createElement("div");W.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",E.appendChild(z),E.appendChild(V),E.appendChild(W),k.appendChild(E)}y.appendChild(k);for(let w=0;w<3;w++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-row";const z=document.createElement("div");z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label",E.appendChild(z);for(let V=0;V<3;V++){const W=document.createElement("div");W.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",E.appendChild(W)}y.appendChild(E)}r.appendChild(y),e.appendChild(r);break}default:e.appendChild(n);for(let r=0;r<3;r++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",e.appendChild(o)}break}this._panelEl.appendChild(e),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._applyPanelCollapsedState(),this._syncComparisonDockVisibility(),this._emitHostShellSync()}updatePanelTopBar(t,e,a){const n=this._options.getMobileViewport?.()??!1;this._panelTopBar.update(n?!0:t,e,a);const i=this.getPanelContentElement();i&&this._syncPanelTopBarTitleFromContent(i)}getPanelTopBarTitle(){return this._panelTopBar.getTitle()}updateFavoritesBadge(t){this._favBadgeEl&&(t>0?(this._favBadgeEl.textContent=t>99?"99+":String(t),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 t=this._panelVisible&&this._comparisonDockSlotEl.children.length>0;this._comparisonDockSlotEl.classList.toggle("gengage-chat-comparison-dock-slot--panel-visible",t),this._comparisonDockSlotEl.style.display=t?"":"none",this._comparisonDockSlotEl.setAttribute("aria-hidden",t?"false":"true")}setComparisonDockContent(t){this._comparisonDockSlotEl.replaceChildren(),t&&this._comparisonDockSlotEl.appendChild(t),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 t=this._panelEl.querySelector(".gengage-chat-product-grid--mobile .gengage-chat-product-card, .gengage-chat-product-grid .gengage-chat-product-card"),e=this._panelEl.querySelector(".gengage-chat-product-card"),a=t??e;if(!a)return 88;const n=Math.round(a.getBoundingClientRect().height);return!Number.isFinite(n)||n<=0?88:n}_updateScrollAffordance(){const t=this._panelEl,e=t.scrollTop+t.clientHeight>=t.scrollHeight-10,a=this._getChoicePrompterRevealScrollThreshold();t.classList.toggle("gengage-chat-panel--has-scroll",!e&&t.scrollHeight>t.clientHeight),t.classList.toggle("gengage-chat-panel--scrolled",t.scrollTop>a)}_setupHorizontalSwipe(t){let e=0,a=0;const n=r=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=r.touches[0];o&&(e=o.clientX,a=o.clientY)},i=r=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=r.changedTouches[0];if(!o)return;const s=o.clientX-e,c=o.clientY-a;Math.abs(s)>50&&Math.abs(s)>Math.abs(c)*2&&(this.togglePanel(),this._onPanelToggle?.())};t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchend",i,{passive:!0}),this._cleanups.push(()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchend",i)})}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){this._panelCollapsed=t,this._applyPanelCollapsedState(),this._emitHostShellSync()}persistPanelState(t){try{const e=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(e,"collapsed"):sessionStorage.removeItem(e)}catch{}}restorePanelState(t){try{const e=`gengage:panel:${t}`;if(sessionStorage.getItem(e)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_createLoadingSequence(t,e,a,n){const i=document.createElement("div");i.className=`${n} gds-progress-loader ${t==="chat"?"gds-progress-loader-chat":"gds-progress-loader-panel"}`,i.dataset.gengagePart=a,i.setAttribute("role","status"),i.setAttribute("aria-live","polite");const r=document.createElement("span");r.className=t==="chat"?"gengage-chat-typing-text gds-progress-label":"gengage-chat-panel-loading-label gds-progress-label",i.appendChild(r);const o=document.createElement("span");o.className=t==="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)}i.appendChild(o);const s={labelEl:r,steps:[],index:0,intervalId:null};return this._applyLoadingSteps(s,e),{root:i,binding:s}}_applyLoadingSteps(t,e,a=!1){const n=e.map(r=>r.trim()).filter(Boolean).slice(-3),i=[this.i18n.loadingMessage];t.steps=n.length>0?n:i,this._clearLoadingBindingInterval(t),t.index=a?t.steps.length-1:0,t.labelEl.textContent=t.steps[t.index],!a&&t.steps.length>1&&(t.intervalId=setInterval(()=>{if(t.index>=t.steps.length-1){this._clearLoadingBindingInterval(t);return}t.index+=1,t.labelEl.textContent=t.steps[t.index],t.index>=t.steps.length-1&&this._clearLoadingBindingInterval(t)},zi))}_clearLoadingBindingInterval(t){t?.intervalId&&(clearInterval(t.intervalId),t.intervalId=null)}_destroyLoadingBinding(t){this._clearLoadingBindingInterval(t)}_updateSendEnabled(){if(this._sendStopHandler){this.sendBtn.disabled=!1;return}const t=this.inputEl.value.trim().length>0||this._pendingAttachment!==null;this.sendBtn.disabled=!t}_renderSendButtonIcon(t){this.sendBtn.innerHTML=t==="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 t=this.inputEl.value.trim(),e=this._pendingAttachment;if(this._sendStopHandler){const a=this._sendStopHandler;if(this.hideStopButton(),a(),!t&&!e)return}else if(!t&&!e)return;this.onSend(t,e??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment(),this._updateSendEnabled()}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&this._options.presentation?.shouldBlockSoftAutoScroll?.()||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(t,e,a,n){const i=this.messagesEl.querySelector(`[data-message-id="${ve(t)}"]`);if(!i)return;let r=i.querySelector(".gengage-chat-bubble-text");r||(r=document.createElement("div"),r.className="gengage-chat-bubble-text",i.appendChild(r)),a==="photo_analysis"?(i.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(r,n)):(i.classList.remove("gengage-chat-bubble--photo-analysis"),r.innerHTML=ye(e)),this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const e=this.messagesEl.querySelector(`[data-message-id="${ve(t)}"]`);e&&e.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const e=t[t.length-1].getAttribute("data-thread-id");if(!e){this._scrollToBottom(!0);return}this._programmaticScrollUntil=Date.now()+700;const a=this.messagesEl.querySelector(`[data-thread-id="${ve(e)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}scrollThreadIntoView(t,e="smooth"){const a=this.messagesEl.querySelectorAll(`[data-thread-id="${ve(t)}"]`),n=this.messagesEl.ownerDocument.defaultView?.HTMLElement;if(!n)return!1;let i=null,r=null;for(let c=0;c<a.length;c++){const l=a[c];if(l instanceof n&&(r||(r=l),!l.classList.contains("gengage-chat-bubble--presentation-collapsed")&&!l.classList.contains("gengage-chat-bubble--hidden")&&l.offsetHeight!==0&&!(l.classList.contains("gengage-chat-bubble--assistant")&&(l.textContent?.trim().length??0)===0))){i=l;break}}if(i||(i=r),!i)return!1;const o=Date.now();this._programmaticScrollUntil=o+Fa,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,o+Fa),this._userScrolledUp=!0;const s=()=>{this._scrollMessagesTo(Math.max(i.offsetTop-20,0),e)};return s(),requestAnimationFrame(s),!0}scrollToBottomPresentation(t="smooth"){this._programmaticScrollUntil=Date.now()+700,requestAnimationFrame(()=>{this._scrollMessagesTo(this.messagesEl.scrollHeight,t),this._userScrolledUp=!1})}_scrollMessagesTo(t,e){if(typeof this.messagesEl.scrollTo=="function"){this.messagesEl.scrollTo({top:t,behavior:e});return}this.messagesEl.scrollTop=t}setPresentationFocus(t){this._presentationFocusThreadId=t,this._applyPresentationCollapsed()}setFormerMessagesButtonVisible(t){this._formerMessagesBtn&&(this._formerMessagesBtn.style.display=t?"":"none")}setInputPlaceholder(t){this.inputEl.placeholder=t}_applyPresentationCollapsed(){const t=this._presentationFocusThreadId;this.messagesEl.querySelectorAll("[data-thread-id]").forEach(e=>{const a=e.dataset.threadId;a&&(t&&a!==t?e.classList.add("gengage-chat-bubble--presentation-collapsed"):e.classList.remove("gengage-chat-bubble--presentation-collapsed"))})}refreshPresentationCollapsed(){this._presentationFocusThreadId&&this._applyPresentationCollapsed()}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const e of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip gds-chip",a.type="button",e.icon){const i=Ha[e.icon]??za,r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=i,a.appendChild(r)}const n=document.createElement("span");n.textContent=e.label,a.appendChild(n),a.addEventListener("click",()=>e.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}trapFocus(){this._previouslyFocusedElement=document.activeElement,this.releaseFocus();const t=e=>{if(e.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 p=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||p.display==="none"||p.visibility==="hidden"?!1:l.getClientRects().length>0});if(a.length===0)return;const n=a[0],i=a[a.length-1],r=e.composedPath().find(l=>l instanceof HTMLElement&&this.root.contains(l))??null,o=this.root.getRootNode(),s=r??(o instanceof ShadowRoot&&o.activeElement instanceof HTMLElement?o.activeElement:document.activeElement instanceof HTMLElement?document.activeElement:null),c=s&&this.root.contains(s)?s:null;e.shiftKey?(c===n||!this.root.contains(c))&&(e.preventDefault(),i.focus()):(c===i||!this.root.contains(c))&&(e.preventDefault(),n.focus())};this._focusTrapHandler=t,this.root.addEventListener("keydown",t)}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(t){this.root.querySelector(".gengage-chat-cart-toast")?.remove();const e=document.createElement("div");e.className="gengage-chat-cart-toast",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.textContent=t,this.root.appendChild(e),e.offsetWidth,e.classList.add("gengage-chat-cart-toast--visible"),setTimeout(()=>{e.classList.remove("gengage-chat-cart-toast--visible"),setTimeout(()=>e.remove(),300)},2500)}destroy(){Ci(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 t of this._cleanups)t();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}}}));function Di(t){return t==="watch_expert"?"account_expert":Ui.includes(t)?t:null}function Hl(t){return typeof t=="string"?Di(t):null}function ke(t){return t==null||typeof t!="object"||Array.isArray(t)?null:t}function Fl(...t){for(const e of t)if(typeof e=="string"){const a=e.trim();if(a.length>0)return a}}function Dl(t){const e=ke(t);if(!e)return null;const a=Fl(e.assistant_mode,e.assistantMode);if(!a)return null;const n=Di(a);return!n||n==="shopping"?null:n}function Ul(t){return t==="beauty_consulting"?"user_message":"findSimilar"}var Ui,Oi=L((()=>{Ui=["shopping","beauty_consulting","account_expert"]})),qi,Ol=L((()=>{Oi(),ot(),qi=class{constructor(){this._mode="shopping",this._uiHints=null}get mode(){return this._mode}set mode(t){this._mode=t}get uiHints(){return this._uiHints}set uiHints(t){this._uiHints=t}get isShopping(){return this._mode==="shopping"}get isBeautyConsulting(){return this._mode==="beauty_consulting"}get isChoicePrompterHidden(){return this._uiHints?.hide_choice_prompter===!0}applyUiHints(t,e,a){const n=r=>this._uiHints?.[r]===!0;t?.setAttachmentControlsVisible(!n("hide_attachment_controls")),n("hide_choice_prompter")&&a?.();const i=typeof this._uiHints?.input_placeholder=="string"?this._uiHints.input_placeholder:void 0;i?t?.setInputPlaceholder(i):t?.setInputPlaceholder(e)}handleRedirect(t){Be("mode","redirect metadata received",t);const e=Dl(t);return e?(this.switchMode(e),!0):!1}switchMode(t){const e=this._mode;this._mode=t,Be("mode","assistant mode switched",{from:e,to:t})}updateFromContext(t){const e=t.assistant_mode;if(typeof e=="string"&&e){const a=Hl(e);a?this._mode=a:Be("mode","ignoring unrecognised assistant_mode from context",e)}else e===null&&(this._mode="shopping");this._uiHints=ke(t.ui_hints)??null}reset(){const t=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,t}resolveAttachmentActionType(){return Ul(this._mode)}shouldCondenseThinking(){return this._mode!=="shopping"}}}));function ql(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function jl(t,e,a,n,i){if(t==="PhotoAnalysisCard"){const r=Ni(e);return r?(i.photoAnalysis=r,i.renderHint="photo_analysis",n.ensureRendered(),n.cancelTypewriter(),n.drawer?.updateBotMessage(i.id,i.content??"","photo_analysis",i.photoAnalysis),!0):(Be("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",e),!1)}if(t==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const r=Pl(e);return n.drawer?.setBeautyPhotoStepCard({visible:!0,...r,onSkip:()=>{n.drawer?.setBeautyPhotoStepCard({visible:!1}),n.streamDone?n.sendSkipMessage():a.pendingPhotoStepSkip=!0}}),!0}return!1}function $l(t){return t.renderHint==="photo_analysis"}function Vl(t,e){t.streamIncludedBeautyPhotoStep||e.drawer?.setBeautyPhotoStepCard({visible:!1}),t.pendingPhotoStepSkip&&(t.pendingPhotoStepSkip=!1,e.sendSkipMessage())}function Gl(t,e){t.pendingPhotoStepSkip&&(t.pendingPhotoStepSkip=!1,e.sendSkipMessage())}var Wl=L((()=>{Ra(),Ba(),ot()}));function Da(t){return Number.isFinite(t)?Math.max(0,Math.min(5,t)):0}function Ua(t){return Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t))):0}function Oa(t){const e=Da(t),a=Math.floor(e),n=e-a>=.5,i=5-a-(n?1:0),r=document.createElement("span");if(r.className="gengage-star-rating",r.setAttribute("role","img"),r.setAttribute("aria-label",`${e.toFixed(1)} out of 5 stars`),a>0&&r.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),r.appendChild(o)}return i>0&&r.appendChild(document.createTextNode("☆".repeat(i))),r}function Ce(t){t.addEventListener("error",()=>{t.style.display="none"},{once:!0})}var je=L((()=>{}));function te(t,e){const a=Number(t);if(!Number.isFinite(a)||a<0)return t;const n={...ji,...e},i=Math.abs(a%1)<Number.EPSILON,r=n.alwaysShowDecimals||!i?a.toFixed(2):a.toFixed(0),o=r.indexOf("."),s=o===-1?r:r.slice(0,o),c=o===-1?void 0:r.slice(o+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let p;return c!==void 0?p=`${l}${n.decimalSeparator}${c}`:p=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${p}`:`${p} ${n.currencySymbol}`:p}var ji,ct=L((()=>{ji={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1}}));function Kl(t,e,a){return e?.[t]??Gi[t]??t.replace(/_/g," ").replace(/^./u,n=>Yl(n,a))}function Yl(t,e){try{return t.toLocaleUpperCase(He(e))}catch{return t.toLocaleUpperCase("tr")}}function $i(t){if(typeof t!="string")return!1;const e=Number(t);return Number.isFinite(e)&&e>0}function Ql(t){const e=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;return Number.isFinite(e)&&e>0}function Zl(t){const e=typeof t=="number"?t:Number(t),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=e.toFixed(1),a.appendChild(n),a}function Xl(t){const{recommended:e,products:a,attributes:n,highlights:i,specialCases:r,onProductClick:o,i18n:s}=t,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"),e){const l=document.createElement("article");l.className="gengage-chat-comparison-recommended gds-card",l.dataset.gengagePart="comparison-recommended-card";const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-label",p.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(p);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",e.name);const h=document.createElement("div");if(h.className="gengage-chat-comparison-recommended-media",e.imageUrl&&we(e.imageUrl)){const g=document.createElement("img");g.src=e.imageUrl,g.alt=e.name,g.loading="lazy",g.addEventListener("error",()=>{g.style.display="none"},{once:!0}),h.appendChild(g)}else{const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-placeholder",g.setAttribute("aria-hidden","true"),h.appendChild(g)}d.appendChild(h);const f=document.createElement("div");f.className="gengage-chat-comparison-recommended-info";const b=document.createElement("div");b.className="gengage-chat-comparison-recommended-title",b.textContent=e.name,f.appendChild(b);const m=document.createElement("div");if(m.className="gengage-chat-comparison-recommended-meta",Ql(e.rating)&&m.appendChild(Zl(e.rating)),$i(e.price)){const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-price",g.textContent=te(e.price,t.pricing),m.appendChild(g)}if(m.childElementCount>0&&f.appendChild(m),t.recommendedText){const g=document.createElement("p");g.className="gengage-chat-comparison-recommended-text",g.innerHTML=ye(t.recommendedText),f.appendChild(g)}d.appendChild(f);const u=()=>{o({sku:e.sku,name:e.name})};if(d.addEventListener("click",u),d.addEventListener("keydown",g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),u())}),l.appendChild(d),i.length>0){const g=document.createElement("div");g.className="gengage-chat-comparison-highlights",g.dataset.gengagePart="comparison-highlights";const v=document.createElement("div");v.className="gengage-chat-comparison-highlights-label",v.textContent=s?.highlightsLabel??"Key Highlights",g.appendChild(v);const _=document.createElement("ul");for(const y of i){const k=document.createElement("li");k.textContent=y,_.appendChild(k)}g.appendChild(_),l.appendChild(g)}c.appendChild(l)}if(t.keyDifferencesHtml){const l=document.createElement("details");l.className="gengage-chat-comparison-key-differences",l.dataset.gengagePart="comparison-key-differences";const p=document.createElement("summary");p.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 h=document.createElement("span");h.className="gengage-chat-comparison-key-differences-summary-meta",h.textContent=s?.viewMoreLabel??"Show More",p.appendChild(d),p.appendChild(h),l.appendChild(p);const f=document.createElement("div");f.className="gengage-chat-comparison-key-differences-content",f.innerHTML=ye(Jl(t.keyDifferencesHtml)),l.appendChild(f),c.appendChild(l)}if(r&&r.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 p=document.createElement("summary");p.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(p);const d=document.createElement("ul");for(const h of r)eg(d,h);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 p=document.createElement("thead"),d=document.createElement("tr"),h=document.createElement("th");d.appendChild(h);for(const m of a){const u=document.createElement("th");m.sku===e?.sku&&(u.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const g=document.createElement("div");g.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",g.tabIndex=0,g.setAttribute("role","button"),g.setAttribute("aria-label",m.name),g.title=m.name;const v=()=>{o({sku:m.sku,name:m.name})};if(g.addEventListener("click",v),g.addEventListener("keydown",y=>{y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),v())}),m.imageUrl&&we(m.imageUrl)){const y=document.createElement("img");y.src=m.imageUrl,y.alt=m.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),g.appendChild(y)}else{const y=document.createElement("div");y.className="gengage-chat-comparison-table-header-img-placeholder",y.setAttribute("aria-hidden","true"),g.appendChild(y)}const _=document.createElement("div");if(_.className="gengage-chat-comparison-table-product-name",_.textContent=m.name,g.appendChild(_),$i(m.price)){const y=document.createElement("div");y.className="gengage-chat-comparison-table-price",y.textContent=te(m.price,t.pricing),g.appendChild(y)}u.appendChild(g),d.appendChild(u)}p.appendChild(d),l.appendChild(p);const f=document.createElement("tbody");for(const m of n){const u=document.createElement("tr"),g=document.createElement("td");g.className="gengage-chat-comparison-label",g.textContent=Kl(m.label,s?.criteriaLabels,t.locale),u.appendChild(g);for(let v=0;v<m.values.length;v++){const _=document.createElement("td");a[v]?.sku===e?.sku&&(_.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const y=m.values[v]??"";Vi(y)?_.innerHTML=ye(y):_.textContent=y,u.appendChild(_)}f.appendChild(u)}l.appendChild(f);const b=document.createElement("div");b.className="gengage-chat-comparison-table-wrapper",b.dataset.gengagePart="comparison-table-wrapper",b.appendChild(l),c.appendChild(b)}return c.addEventListener("keydown",l=>{if(l.key!=="Tab")return;const p=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(p.length===0)return;const d=p[0],h=p[p.length-1];l.shiftKey&&document.activeElement===d?(l.preventDefault(),h.focus()):!l.shiftKey&&document.activeElement===h&&(l.preventDefault(),d.focus())}),c}function Jl(t){if(/<[uo]l[\s>]/i.test(t)||/<li[\s>]/i.test(t))return t;const e=t.split(`
|
|
49
49
|
`).filter(a=>a.trim());return e.length<=1?t:"<ul>"+e.map(a=>`<li>${a.trim()}</li>`).join("")+"</ul>"}function eg(t,e){const a=ye(e);if(!a)return;const n=document.createElement("template");n.innerHTML=a;const i=Array.from(n.content.querySelectorAll("li"));if(i.length>0){for(const o of i){const s=document.createElement("li");s.innerHTML=ye(o.innerHTML),t.appendChild(s)}return}const r=document.createElement("li");Vi(e)?r.innerHTML=a:r.textContent=e,t.appendChild(r)}function Vi(t){return/<\/?[a-z][\s\S]*>/i.test(t)}var Gi,tg=L((()=>{ge(),ct(),ht(),Gi={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 vt(t,e=18){const a="http://www.w3.org/2000/svg",n=document.createElementNS(a,"svg");n.setAttribute("width",String(e)),n.setAttribute("height",String(e)),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 i of t){const r=document.createElementNS(a,"path");r.setAttribute("d",i),n.appendChild(r)}return n}var Wi=L((()=>{}));function ag(t){if(typeof t!="string")return[Dt];const e=t.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return e.length===0?[Dt]:Array.from(new Set(e.map(a=>a.toLocaleLowerCase()))).map(a=>e.find(n=>n.toLocaleLowerCase()===a)??Dt)}function ng(t){return t==="positive"||t==="negative"||t==="neutral"?t:"neutral"}function ig(t){if(typeof t!="string")return"";const e=t.trim().replace(/\s+/g," ");return e.length<=qa?e:`${e.slice(0,qa-3).trimEnd()}...`}function rg(t){return t.positive>t.negative?"positive":t.negative>t.positive?"negative":"neutral"}function og(t){return vt(t==="positive"?["M7 17 17 7","M7 7h10v10"]:t==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function sg(t,e="1 customer mentions",a="customers mention"){return t===1?e:`${t} ${a}`}function cg(t,e){const a=document.createElement("div");a.className="gengage-chat-review-highlights";const n=t.props?.reviews;if(!Array.isArray(n)||n.length===0){const m=document.createElement("div");return m.className="gengage-chat-review-empty",m.textContent=e?.emptyReviewsMessage??"No review summary found.",a.appendChild(m),a}const i=n.filter(m=>m!==null&&typeof m=="object"),r=new Map;for(const m of i){const u=ng(m.review_class),g=ig(m.review_text),v=ag(m.review_tag);for(const _ of v){const y=_.toLocaleLowerCase();let k=r.get(y);if(k||(k={key:y,label:_,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},r.set(y,k)),k.mentions+=1,u==="positive"?k.positive+=1:u==="negative"?k.negative+=1:k.neutral+=1,g.length>0&&k.snippets.length<Ki&&!k.snippets.some(P=>P.text===g)){const P={text:g,tone:u};m.review_rating!==void 0&&String(m.review_rating).length>0&&(P.rating=m.review_rating),k.snippets.push(P)}}}const o=Array.from(r.values()).sort((m,u)=>u.mentions!==m.mentions?u.mentions-m.mentions:m.label.localeCompare(u.label));if(o.length===0){const m=document.createElement("div");return m.className="gengage-chat-review-empty",m.textContent=e?.emptyReviewsMessage??"No review summary found.",a.appendChild(m),a}const s=(e?.reviewFilterPositive??"positive").toLowerCase(),c=(e?.reviewFilterNegative??"negative").toLowerCase(),l=document.createElement("div");l.className="gengage-chat-review-subjects-heading",l.textContent=e?.reviewSubjectsHeading??"Select to learn more",a.appendChild(l);let p=o[0]?.key??null;const d=document.createElement("div");d.className="gengage-chat-review-subjects gds-toolbar gds-toolbar-compact";const h=document.createElement("section");h.className="gengage-chat-review-detail gds-evidence-card";const f=()=>{for(;h.firstChild;)h.removeChild(h.firstChild);if(!p)return;const m=o.find(_=>_.key===p);if(!m)return;const u=document.createElement("div");u.className="gengage-chat-review-detail-meta";const g=document.createElement("span");if(g.className="gengage-chat-review-detail-mentions",g.textContent=`${sg(m.mentions,e?.reviewCustomersMentionSingular,e?.reviewCustomersMentionPlural)} "${m.label}"`,u.appendChild(g),m.positive>0){const _=document.createElement("span");_.className="gengage-chat-review-detail-positive",_.textContent=`${m.positive} ${s}`,u.appendChild(_)}if(m.negative>0){const _=document.createElement("span");_.className="gengage-chat-review-detail-negative",_.textContent=`${m.negative} ${c}`,u.appendChild(_)}h.appendChild(u);const v=document.createElement("div");v.className="gengage-chat-review-snippets";for(const _ of m.snippets){const y=document.createElement("article");y.className="gengage-chat-review-snippet",y.dataset.tone=_.tone;const k=document.createElement("div");if(k.className="gengage-chat-review-snippet-text",k.textContent=`"${_.text}"`,y.appendChild(k),_.rating!==void 0&&String(_.rating).length>0){const P=document.createElement("div");P.className="gengage-chat-review-snippet-rating",P.textContent=`★ ${String(_.rating)}`,y.appendChild(P)}v.appendChild(y)}h.appendChild(v)},b=()=>{for(const m of d.querySelectorAll(".gengage-chat-review-subject")){const u=m.dataset.subjectKey===p;m.classList.toggle("gengage-chat-review-subject--active",u),m.classList.toggle("gds-chip-active",u),m.setAttribute("aria-pressed",String(u))}};for(const m of o){const u=rg(m),g=document.createElement("button");g.type="button",g.className="gengage-chat-review-subject gds-chip",g.dataset.subjectKey=m.key,g.dataset.tone=u;const v=document.createElement("span");v.className="gengage-chat-review-subject-icon",v.appendChild(og(u)),g.appendChild(v);const _=document.createElement("span");_.className="gengage-chat-review-subject-label",_.textContent=m.label,g.appendChild(_);const y=document.createElement("span");y.className="gengage-chat-review-subject-count",y.textContent=`(${m.mentions})`,g.appendChild(y),g.addEventListener("click",()=>{p=m.key,b(),f()}),d.appendChild(g)}return a.appendChild(d),b(),f(),a.appendChild(h),a}var Dt,qa,Ki,lg=L((()=>{Wi(),Dt="General",qa=220,Ki=6}));function gg(t){if(!t)return;const e=t.discountReason??t.discount_reason??t.campaignReason??t.campaign_reason;if(typeof e!="string")return;const a=e.trim();return a.length>0?a:void 0}function lt(t,e){if(t.productPriceUi?.showCampaignReason===!0)return gg(e)}function yt(t,e){const a=e?.originalPriceStyle??e?.price_original_style;if(a==="inline"||a==="strikethrough")return a;const n=t.productPriceUi?.originalPriceStyle;return n==="inline"||n==="strikethrough"?n:"strikethrough"}function Ut(t){const e=document.createElement("div");return e.className="gengage-chat-campaign-reason",e.textContent=t,e}function Ot(t,e){for(const n of["campaignReasonLogoUrl","campaign_reason_logo_url","discountBadgeLogoUrl","discount_badge_logo_url"]){const i=e?.[n];if(typeof i=="string"&&i.trim()){const r=i.trim();if(we(r))return r}}const a=t.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(we(n))return n}}function qt(t){const e=document.createElement("div");if(e.className="gengage-chat-campaign-price-badge",e.dataset.gengagePart="campaign-price-badge",t.logoUrl){const r=document.createElement("div");r.className="gengage-chat-campaign-price-badge__logo";const o=document.createElement("img");o.alt="",o.loading="lazy",o.src=t.logoUrl,Ce(o),r.appendChild(o),e.appendChild(r)}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=t.reasonText;const i=document.createElement("span");return i.className="gengage-chat-campaign-price-badge__sale",i.textContent=t.salePriceFormatted,a.appendChild(n),a.appendChild(i),e.appendChild(a),e}var ja=L((()=>{ge(),je()}));function dg(){try{return globalThis.GENGAGE_TOPPICKS_MOBILE_LAYOUT==="uniform"}catch{return!1}}function Yi(t){const e=t.product.sku;if(typeof e=="string"&&e.length>0)return e;const a=t.action?.payload;return a&&typeof a=="object"&&"sku"in a&&typeof a.sku=="string"?a.sku:null}function Qi(t,e){if(!t||!e)return null;const a=Xi[t];return a?e[a]??t:t}function pg(t){const e=t.rating,a=typeof e=="number"?e:typeof e=="string"?parseFloat(e):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 i=document.createElement("span");i.className="gengage-chat-ai-toppick-rating-icon",i.setAttribute("aria-hidden","true"),i.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 r=document.createElement("span");return r.className="gengage-chat-ai-toppick-rating-value",r.textContent=a.toFixed(1),n.appendChild(i),n.appendChild(r),n}function hg(t,e,a,n,i){const r=document.createElement("div");r.className="gengage-chat-ai-toppick-media",r.dataset.gengagePart="ai-top-pick-media";const o=t.product,s=o.imageUrl;if(s&&we(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",he(l,"src",s),l.loading="lazy",l.alt=e,Ce(l),r.appendChild(l)}const c=Yi(t);if(c&&!i?.skipOverlayActions){const l=document.createElement("div");if(l.className="gengage-chat-product-card-img-actions",n.onFavoriteToggle){const f=document.createElement("button");f.className="gengage-chat-favorite-btn",f.type="button",f.dataset.gengageFavoriteSku=c,f.setAttribute("aria-label",n.i18n?.addToFavoritesLabel??"Add to favorites");const b=n.favoritedSkus?.has(c)??!1;b&&f.classList.add("gengage-chat-favorite-btn--active"),f.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${b?"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>`,f.addEventListener("click",m=>{m.stopPropagation(),f.classList.toggle("gengage-chat-favorite-btn--active"),f.querySelector("svg")?.setAttribute("fill",f.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),n.onFavoriteToggle?.(c,o)}),l.appendChild(f)}const p=n.i18n?.findSimilarLabel??"Find Similar",d=document.createElement("button");d.className="gengage-chat-find-similar-pill",d.type="button",d.setAttribute("aria-label",p),d.dataset.tooltip=p,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 h=document.createElement("span");h.className="gengage-chat-find-similar-pill-text",h.textContent=p,d.appendChild(h),d.addEventListener("click",f=>{f.stopPropagation(),n.onAction({title:p,type:"findSimilar",payload:{sku:c}})}),l.appendChild(d),r.appendChild(l)}a.appendChild(r)}function ug(t,e,a){const n=t.price,i=t.originalPrice;if(!n)return;const r=lt(a,t),o=yt(a,t),s=!!(i&&i!==n),c=!!(r&&s),l=Ot(a,t),p=document.createElement("div");if(p.className="gengage-chat-ai-toppick-price",p.dataset.gengagePart="ai-top-pick-price",c){const d=qt({reasonText:r,salePriceFormatted:te(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){p.classList.add("gengage-chat-ai-toppick-price--inline"),p.appendChild(d);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const f=document.createElement("span");f.className="gengage-chat-ai-toppick-original-price",f.textContent=te(i,a.pricing),p.appendChild(h),p.appendChild(f)}else{const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=te(i,a.pricing),p.appendChild(h),p.appendChild(document.createTextNode(" ")),p.appendChild(d)}e.appendChild(p);return}if(s&&o==="inline"){p.classList.add("gengage-chat-ai-toppick-price--inline");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=te(n,a.pricing);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const f=document.createElement("span");f.className="gengage-chat-ai-toppick-original-price",f.textContent=te(i,a.pricing),p.appendChild(d),p.appendChild(h),p.appendChild(f)}else if(s){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=te(i,a.pricing),p.appendChild(d),p.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-current",h.textContent=te(n,a.pricing),p.appendChild(h)}else{const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=te(n,a.pricing),p.appendChild(d)}if(r){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price-stack",d.appendChild(Ut(r)),d.appendChild(p),e.appendChild(d)}else e.appendChild(p)}function mg(t,e,a){const n=typeof t.reason=="string"?t.reason.trim():"",i=a.hideUserReviews!==!0&&typeof t.reviewHighlight=="string"?t.reviewHighlight.trim():"";if(!(!n&&!i)){if(n){const r=document.createElement("p");r.className="gengage-chat-ai-toppick-reason",r.dataset.gengagePart="ai-top-pick-reason",r.textContent=n,e.appendChild(r)}if(i){const r=document.createElement("div");r.className="gengage-chat-ai-toppick-review",r.dataset.gengagePart="ai-top-pick-review",r.textContent=i,e.appendChild(r)}}}function Zi(t,e,a,n){const i=document.createElement("div");i.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 r=n?.uniformMobileLayout===!0;!a&&r&&i.classList.add("gengage-chat-ai-toppick-card--mobile-uniform"),i.dataset.gengagePart=a?"ai-top-pick-card-winner":"ai-top-pick-card";const o=t.product,s=Yi(t),c=o.url??"",l=o.cartCode,p=o.inStock,d=!!(s&&l&&p!==!1),h=t.action;s&&e.onProductClick?(i.classList.add("gds-clickable"),i.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 E=o.name;e.onProductClick?.({sku:s,url:c,...E?{name:E}:{}})})):h&&(i.classList.add("gds-clickable"),i.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")||e.onAction(h)}));const f=o.name||"Product image",b=!a&&e.isMobile===!0&&!r,m=a?Qi(t.role,e.i18n)??e.i18n?.roleWinner??"TOP MATCH":Qi(t.role,e.i18n);if(m&&!b){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,i.appendChild(w)}const u=document.createElement("div");u.className="gengage-chat-ai-toppick-top-row",u.dataset.gengagePart="ai-top-pick-top-row",hg(t,f,u,e,{skipOverlayActions:b});const g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-body",g.dataset.gengagePart="ai-top-pick-body",m&&b){const w=document.createElement("div");w.className="gengage-chat-ai-toppick-role-line",w.dataset.gengagePart="ai-top-pick-role-line",w.textContent=m,g.appendChild(w)}const v=o.name;if(v){const w=document.createElement("div");w.className="gengage-chat-ai-toppick-name",w.dataset.gengagePart="ai-top-pick-name",w.textContent=v,g.appendChild(w)}const _=pg(o);_&&g.appendChild(_),ug(o,g,e),t.labels&&t.labels.length>0&&g.appendChild(bg(t.labels)),u.appendChild(g),i.appendChild(u);const y=document.createElement("div");if(y.className="gengage-chat-ai-toppick-detail",y.dataset.gengagePart="ai-top-pick-detail",a)mg(t,y,e);else{const w=typeof t.reason=="string"?t.reason.trim():"";if(w){const E=document.createElement("p");E.className="gengage-chat-ai-toppick-snippet",E.dataset.gengagePart="ai-top-pick-snippet",E.textContent=w,y.appendChild(E)}}y.childNodes.length>0&&i.appendChild(y);const k=!!(s&&e.topPicksLoadingSku===s),P=(d||h)&&!b;if(k||d||h){const w=document.createElement("div");if(w.className="gengage-chat-ai-toppick-spinner",w.dataset.gengagePart="ai-top-pick-spinner",w.style.display=k?"":"none",i.appendChild(w),P){const E=document.createElement("button");E.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",E.dataset.gengagePart="ai-top-pick-cta",E.type="button",E.textContent=d?e.i18n?.addToCartButton??"Add to Cart":e.i18n?.viewDetails??"View Details",E.addEventListener("click",z=>{if(z.stopPropagation(),d){e.onAction({title:e.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:s,cartCode:l,quantity:1}});return}if(h){if(h.type==="findSimilar"&&s&&e.onProductClick){const V=o.name;e.onProductClick({sku:s,url:c,...V?{name:V}:{}});return}e.onAction(h)}}),i.appendChild(E)}}return i}function fg(t,e){const a=document.createElement("div");a.className="gengage-chat-ai-top-picks",a.dataset.gengagePart="ai-top-picks";const n=t.props?.suggestions??[];if(n.length===0)return a;const i=document.createElement("div");i.className="gengage-chat-ai-top-picks-scroll",i.dataset.gengagePart="ai-top-picks-scroll";const r=e.isMobile===!0&&dg(),o=n[0];if(i.appendChild(Zi(o,e,!0,{uniformMobileLayout:r})),n.length>1){const s=document.createElement("div");s.className="gengage-chat-ai-top-picks-rest",r&&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],p=l.role==="winner";s.appendChild(Zi(l,e,p,{uniformMobileLayout:r}))}i.appendChild(s)}return a.appendChild(i),a}function bg(t){const e=document.createElement("div");e.className="gengage-chat-ai-toppick-labels",e.dataset.gengagePart="ai-top-pick-labels";for(const a of t){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,e.appendChild(n)}return e}var Xi,vg=L((()=>{ct(),ge(),je(),ja(),Xi={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"}}));function yg(t,e){const a=document.createElement("div");a.className="gengage-chat-grounding-review gds-evidence-card",a.dataset.gengagePart="grounding-review-card";const n=t.props??{},i=n.title,r=n.reviewCount,o=n.action,s=e.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.appendChild(vt(["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 p=document.createElement("div");if(p.className="gengage-chat-grounding-review-title",p.dataset.gengagePart="grounding-review-title",p.textContent=i??e.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(p),r){const b=document.createElement("div");b.className="gengage-chat-grounding-review-subtitle",b.dataset.gengagePart="grounding-review-subtitle",b.textContent=(e.i18n?.groundingReviewSubtitle??"{count} yorum mevcut").replace("{count}",r),l.appendChild(b)}a.appendChild(l);const d=document.createElement("span");d.className="gengage-chat-grounding-review-cta",d.dataset.gengagePart="grounding-review-cta";const h=document.createElement("span");h.textContent=s,d.appendChild(h);const f=document.createElement("span");return f.className="gengage-chat-grounding-review-cta-icon",f.appendChild(vt(["M5 12h14","M15 8l4 4-4 4"],14)),d.appendChild(f),a.appendChild(d),o&&(a.classList.add("gds-clickable"),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.addEventListener("click",()=>e.onAction(o)),a.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),e.onAction(o))})),a}var xg=L((()=>{Wi()}));function _g(t){const e=t.action.type;if(e!=="findSimilar")return t.action;const a=t.action.payload&&typeof t.action.payload=="object"?t.action.payload:null,n=typeof a?.input=="string"&&a.input.trim()||typeof a?.text=="string"&&a.text.trim()||t.name.trim();if(!n)return t.action;const i={...a??{},text:n,is_suggested_text:1};return typeof a?.input=="string"&&a.input.trim()?i.input=a.input:delete i.input,{title:t.action.title,type:e,payload:Bt(i)}}function wg(t,e){const a=document.createElement("div");a.className="gengage-chat-grouping-cards",a.dataset.gengagePart="ai-grouping-cards";const n=t.props?.entries??[];if(n.length===0)return a;const i=t.props?.sectionTitle,r=typeof i=="string"&&i.trim().length>0?i.trim():e.i18n?.aiBrowseCategoriesTitle;if(r){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=r,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",()=>e.onAction(_g(s))),s.image&&we(s.image)){const h=document.createElement("img");h.className="gengage-chat-grouping-card-img",h.dataset.gengagePart="ai-grouping-card-image",h.draggable=!1,h.src=s.image,h.alt=s.name,h.width=64,h.height=64,c.appendChild(h)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body",l.dataset.gengagePart="ai-grouping-card-body";const p=document.createElement("span");if(p.className="gengage-chat-grouping-card-name",p.dataset.gengagePart="ai-grouping-card-name",p.textContent=s.name,l.appendChild(p),s.labels&&s.labels.length>0){const h=document.createElement("div");h.className="gengage-chat-grouping-card-labels",h.dataset.gengagePart="ai-grouping-card-labels";for(const f of s.labels.slice(0,2)){const b=document.createElement("span");b.className="gengage-chat-grouping-card-label gds-chip",b.textContent=f,h.appendChild(b)}l.appendChild(h)}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}var kg=L((()=>{ge(),wa()}));function Cg(t,e){const a=document.createElement("div");a.className="gengage-chat-suggested-search-cards",a.dataset.gengagePart="ai-suggested-search-cards";const n=t.props?.entries??[];if(n.length===0)return a;for(const i of n){const r=document.createElement("div");if(r.className="gengage-chat-suggested-search-card gds-card",r.dataset.gengagePart="ai-suggested-search-card",r.classList.add("gds-clickable"),r.addEventListener("click",()=>e.onAction(i.action)),i.image&&we(i.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.dataset.gengagePart="ai-suggested-search-card-image",c.src=i.image,c.alt=i.shortName,c.width=64,c.height=64,r.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=i.shortName,o.appendChild(s),r.appendChild(o),a.appendChild(r)}return a}var Sg=L((()=>{ge()}));function Ji(t,e){const a=t.length>=2,n=e.i18n?.compareSelected??"Compare",i=e.comparisonSelectionWarning,r=document.createElement("div");r.className="gengage-chat-comparison-floating-btn",r.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(t.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} (${t.length})`:e.i18n?.compareMinHint??"Select at least 2 products",c.appendChild(l),i){const d=document.createElement("div");d.className="gengage-chat-comparison-floating-warning",d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.textContent=i,c.appendChild(d)}o.appendChild(c),r.appendChild(o);const p=document.createElement("button");if(p.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",p.type="button",p.textContent=n,p.disabled=!a,a||p.classList.add("gengage-chat-comparison-floating-action--disabled"),p.addEventListener("click",()=>{a&&e.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...t],gengage_analytics_source:"floating_compare_dock"}})}),r.appendChild(p),e.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",e.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",h=>{h.preventDefault(),h.stopPropagation(),e.onToggleComparisonSku?.("")}),r.appendChild(d)}return r}var er=L((()=>{}));function Eg(t){const e=document.createElement("div");e.className="gengage-chat-pros-cons gds-card-soft",e.dataset.gengagePart="pros-cons";const a=t.props?.productName;if(a){const r=document.createElement("h4");r.className="gengage-chat-pros-cons-heading",r.textContent=a,e.appendChild(r)}const n=t.props?.pros,i=t.props?.cons;if(n&&n.length>0){const r=document.createElement("ul");r.className="gengage-chat-pros-cons-list",r.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),r.appendChild(s)}e.appendChild(r)}if(i&&i.length>0){const r=document.createElement("ul");r.className="gengage-chat-pros-cons-list",r.dataset.gengagePart="cons-list";for(const o of i){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),r.appendChild(s)}e.appendChild(r)}return e}var Pg=L((()=>{}));function Tg(t){const e=[],a=new Set,n=(i,r)=>{if(typeof i!="string")return;const o=i.trim();if(!o)return;const s=o.toLowerCase();a.has(s)||(a.add(s),e.push({text:o,accent:r}))};n(t.highlight,!0);for(const i of t.labels??[])n(i,!1);return e.slice(0,tr)}function Ag(t){const e=Tg(t),a=typeof t.description=="string"?t.description.trim():"";if(!a&&e.length===0)return null;const n=document.createElement("div");if(n.className="gengage-chat-categories-group-summary",n.dataset.gengagePart="categories-group-summary",n.appendChild(Lg(t)),e.length>0&&n.appendChild(Ig(e)),a){const i=document.createElement("p");i.className="gengage-chat-categories-group-reason",i.dataset.gengagePart="categories-group-reason",i.textContent=a,n.appendChild(i)}return n}function Lg(t){const e=document.createElement("div");if(e.className="gengage-chat-categories-group-selection",e.dataset.gengagePart="categories-group-selection",t.image&&we(t.image)){const n=document.createElement("img");n.className="gengage-chat-categories-group-selection-image",n.draggable=!1,n.src=t.image,n.alt=t.groupName,n.loading="lazy",Ce(n),e.appendChild(n)}const a=document.createElement("div");return a.className="gengage-chat-categories-group-selection-title",a.textContent=t.groupName,e.appendChild(a),e}function Ig(t){const e=document.createElement("div");e.className="gengage-chat-categories-group-chips",e.dataset.gengagePart="categories-group-chips";for(const a of t){const n=document.createElement("span");n.className=a.accent?"gengage-chat-categories-group-chip gengage-chat-categories-group-chip--accent gds-chip gds-chip-active":"gengage-chat-categories-group-chip gds-chip",n.textContent=a.text,e.appendChild(n)}return e}function Ng(t,e){const a=t.props?.groups??[],n=t.props?.filterTags??[],i=`gengage-cat-${ar++}`,r=document.createElement("div");if(r.className="gengage-chat-categories",r.dataset.gengagePart="categories-container",a.length===0)return r;const o=document.createElement("div");o.className="gengage-chat-categories-tabs gds-toolbar",o.dataset.gengagePart="categories-tab-bar",o.setAttribute("role","tablist");const s=[],c=[],l=p=>{for(let d=0;d<s.length;d++){const h=d===p;s[d].classList.toggle("gengage-chat-categories-tab--active",h),s[d].classList.toggle("is-active",h),s[d].setAttribute("aria-selected",String(h)),s[d].tabIndex=h?0:-1,c[d].style.display=h?"":"none"}};for(let p=0;p<a.length;p++){const d=a[p],h=`${i}-tab-${p}`,f=`${i}-panel-${p}`,b=document.createElement("button");if(b.className="gengage-chat-categories-tab gds-tab",b.type="button",b.dataset.gengagePart="categories-tab",b.id=h,b.setAttribute("role","tab"),b.setAttribute("aria-controls",f),b.setAttribute("aria-selected",String(p===0)),b.tabIndex=p===0?0:-1,p===0&&b.classList.add("gengage-chat-categories-tab--active","is-active"),d.image&&we(d.image)){const _=document.createElement("img");_.className="gengage-chat-categories-tab-image",_.draggable=!1,_.src=d.image,_.alt=d.groupName,_.loading="lazy",Ce(_),b.appendChild(_)}const m=document.createElement("span");m.className="gengage-chat-categories-tab-text",m.textContent=d.groupName,b.appendChild(m),b.addEventListener("click",()=>l(p)),b.addEventListener("keydown",_=>{let y=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?y=(p+1)%a.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?y=(p-1+a.length)%a.length:_.key==="Home"?y=0:_.key==="End"&&(y=a.length-1),y>=0&&(_.preventDefault(),l(y),s[y].focus())}),s.push(b),o.appendChild(b);const u=document.createElement("div");u.className="gengage-chat-categories-panel",u.dataset.gengagePart="categories-panel",u.id=f,u.setAttribute("role","tabpanel"),u.setAttribute("aria-labelledby",h),p!==0&&(u.style.display="none");const g=Ag(d);g&&u.appendChild(g);const v=document.createElement("div");v.className="gengage-chat-categories-grid",v.dataset.gengagePart="categories-grid";for(const _ of d.products){const y=Mg(_,e);v.appendChild(y)}u.appendChild(v),c.push(u)}r.appendChild(o);for(const p of c)r.appendChild(p);if(n.length>0){const p=document.createElement("div");p.className="gengage-chat-categories-filter-tags gds-toolbar",p.dataset.gengagePart="categories-filter-tags";for(const d of n){const h=document.createElement("button");h.className="gengage-chat-categories-filter-tag gds-chip",h.type="button",h.dataset.gengagePart="categories-filter-tag",h.textContent=d.title,d.action&&h.addEventListener("click",()=>{e.onAction(d.action)}),p.appendChild(h)}r.appendChild(p)}return r}function Mg(t,e){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",t.imageUrl&&we(t.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-product-card-img",r.draggable=!1,r.src=t.imageUrl,r.alt=t.name,r.loading="lazy",Ce(r),a.appendChild(r)}const n=document.createElement("div");n.className="gengage-chat-product-card-body";const i=document.createElement("div");if(i.className="gengage-chat-product-card-name",i.textContent=t.name,n.appendChild(i),t.price){const r=document.createElement("div");r.className="gengage-chat-product-card-price",r.textContent=te(t.price,e.pricing),n.appendChild(r)}return a.appendChild(n),(e.onProductSelect||e.onAction)&&(a.classList.add("gds-clickable"),a.addEventListener("click",()=>{if(t.sku){e.onAction({title:t.name,type:"launchSingleProduct",payload:{sku:t.sku}});return}e.onProductSelect?.(t)})),a}var tr,ar,Bg=L((()=>{ge(),ct(),je(),tr=4,ar=0}));function Rg(t,e){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 i=document.createElement("h4");i.className="gengage-chat-handoff-notice-heading",i.textContent=e.i18n?.handoffHeading??"Transferring to a support agent",a.appendChild(i);const r=t.props?.summary;if(r){const o=document.createElement("p");o.className="gengage-chat-handoff-notice-summary",o.textContent=r,a.appendChild(o)}return a}var zg=L((()=>{}));function $e(t){return typeof t=="string"?t:""}function Hg(t){return Array.isArray(t)?t.map(e=>{if(!e||typeof e!="object")return null;const a=e;return{imageUrl:$e(a.imageUrl)||void 0,name:$e(a.name)||void 0}}).filter(e=>e!==null):[]}function Fg(t,e){const a=t.props??{},n=$e(a.eyebrow),i=$e(a.title),r=a.showTitle!==!1,o=$e(a.ctaLabel)||e.i18n?.showPanelAriaLabel||"Show Results",s=$e(a.panelMessageId),c=$e(a.highlightMessageId),l=$e(a.threadId),p=Hg(a.products).slice(0,3),d=document.createElement("button");d.type="button",d.className="gengage-chat-panel-restore-card gds-card",!n&&!r&&d.classList.add("gengage-chat-panel-restore-card--minimal"),d.dataset.gengagePart="panel-restore-card";const h=i||n||o;d.setAttribute("aria-label",i?`${h} - ${o}`:h);const f={title:i,type:nr,payload:{panelMessageId:s,highlightMessageId:c,threadId:l}};if(d.addEventListener("click",()=>e.onAction(f)),n){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__eyebrow",m.textContent=n,d.appendChild(m)}if(p.length>0){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__previews";for(const u of p){const g=document.createElement("div");g.className="gengage-chat-panel-restore-card__thumb";const v=u.imageUrl;if(v&&pe(v)){const _=document.createElement("img");_.loading="lazy",_.alt=u.name||i,he(_,"src",v),Ce(_),g.appendChild(_)}m.appendChild(g)}d.appendChild(m)}if(r&&i){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__title",m.textContent=i,m.title=i,d.appendChild(m)}const b=document.createElement("div");return b.className="gengage-chat-panel-restore-card__cta",b.textContent=o,d.appendChild(b),d}var nr,ir=L((()=>{ge(),je(),nr="frontend_restore_panel_message"}));function Dg(t,e){const a=t.props?.product??t.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",g=>{g.target.closest("a")||e.onProductSelect?.(a)});const i=a.imageUrl;if(i&&pe(i)){const g=document.createElement("div");g.className="gengage-chat-product-summary__image",g.dataset.gengagePart="product-summary-image";const v=document.createElement("img");v.loading="lazy",he(v,"src",i),v.alt=a.name||"Product image",Ce(v),g.appendChild(v),n.appendChild(g)}const r=document.createElement("div");r.className="gengage-chat-product-summary__content",r.dataset.gengagePart="product-summary-content";const o=a.brand,s=a.name;if(s){const g=document.createElement("div");g.className="gengage-chat-product-summary__name",g.dataset.gengagePart="product-summary-name";const v=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;g.textContent=v,g.title=v,r.appendChild(g)}const c=a.rating,l=a.reviewCount;if(e.hideUserReviews!==!0&&typeof c=="number"&&Number.isFinite(c)&&c>0){const g=document.createElement("div");if(g.className="gengage-chat-product-summary__rating",g.dataset.gengagePart="product-summary-rating",g.appendChild(Oa(c)),typeof l=="number"&&Number.isFinite(l)){const v=document.createElement("span");v.className="gengage-chat-product-summary__review-count",v.textContent=` (${l})`,g.appendChild(v)}r.appendChild(g)}const p=a.price,d=a.originalPrice;if(p){const g=lt(e,a),v=yt(e,a),_=!!(d&&d!==p),y=document.createElement("div");y.className="gengage-chat-product-summary__price",y.dataset.gengagePart="product-summary-price";const k=!!(g&&_),P=Ot(e,a);if(k){const w=qt({reasonText:g,salePriceFormatted:te(p,e.pricing),...P!==void 0?{logoUrl:P}:{}});if(_&&v==="inline"){y.classList.add("gengage-chat-product-summary__price--inline"),y.appendChild(w);const E=document.createElement("span");E.className="gengage-chat-product-summary__price-sep",E.setAttribute("aria-hidden","true");const z=document.createElement("span");z.className="gengage-chat-product-summary__price-original",z.textContent=te(d,e.pricing),y.appendChild(E),y.appendChild(z)}else{const E=document.createElement("span");E.className="gengage-chat-product-summary__price-original",E.textContent=te(d,e.pricing),y.appendChild(E),y.appendChild(document.createTextNode(" ")),y.appendChild(w)}r.appendChild(y)}else{if(_&&v==="inline"){y.classList.add("gengage-chat-product-summary__price--inline");const w=document.createElement("span");w.className="gengage-chat-product-summary__price-current",w.textContent=te(p,e.pricing);const E=document.createElement("span");E.className="gengage-chat-product-summary__price-sep",E.setAttribute("aria-hidden","true");const z=document.createElement("span");z.className="gengage-chat-product-summary__price-original",z.textContent=te(d,e.pricing),y.appendChild(w),y.appendChild(E),y.appendChild(z)}else if(_){const w=document.createElement("span");w.className="gengage-chat-product-summary__price-original",w.textContent=te(d,e.pricing),y.appendChild(w),y.appendChild(document.createTextNode(" "));const E=document.createElement("span");E.className="gengage-chat-product-summary__price-current",E.textContent=te(p,e.pricing),y.appendChild(E)}else{const w=document.createElement("span");w.className="gengage-chat-product-summary__price-current",w.textContent=te(p,e.pricing),y.appendChild(w)}if(g){const w=document.createElement("div");w.className="gengage-chat-product-summary__price-stack",w.appendChild(Ut(g)),w.appendChild(y),r.appendChild(w)}else r.appendChild(y)}}n.appendChild(r);const h=a.url,f=a.sku,b=a.cartCode??a.cart_code,m=typeof b=="string"&&b.trim()?b.trim():void 0,u=a.inStock;if(f&&m&&u!==!1){const g=document.createElement("button");g.type="button",g.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",g.dataset.gengagePart="product-summary-cta",g.textContent=e.i18n?.addToCartButton??"Add to Cart",g.addEventListener("click",v=>{v.stopPropagation(),e.onAction({title:e.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:f,cartCode:m,quantity:1}})}),n.appendChild(g)}else if(h&&pe(h)){const g=document.createElement("a");g.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",g.dataset.gengagePart="product-summary-cta",he(g,"href",h),he(g,"target","_blank"),he(g,"rel","noopener noreferrer"),g.textContent=e.i18n?.productCtaLabel??"View",n.appendChild(g)}return n}var Ug=L((()=>{ct(),ge(),je(),ja()})),rr,Og=L((()=>{Ra(),Ba(),rr={PhotoAnalysisCard:({element:t,context:e})=>Nl(t,e),BeautyPhotoStep:({element:t,context:e})=>Ii(t,e)}}));function jt(){return window.innerWidth<768}function or(){return{...Ga}}function sr(t,e,a=Ga,n=Wt){return da({spec:t,context:e,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function qg(t,e){const a=document.createElement("div");a.className="gengage-chat-action-buttons";const n=t.props?.buttons;if(n)for(const i of n){const r=document.createElement("button");r.className="gengage-chat-action-btn",r.textContent=i.label,r.addEventListener("click",()=>e.onAction(i.action)),a.appendChild(r)}return a}function jg(t,e){const a=document.createElement("button");a.className="gengage-chat-action-btn";const n=t.props?.label;typeof n=="string"&&(a.textContent=n);const i=t.props?.action;return i&&a.addEventListener("click",()=>e.onAction(i)),a}function cr(t,e,a,n,i){t.replaceChildren();const r=yt(e,a),o=!!(i&&n&&i!==n),s=lt(e,a),c=!!(s&&o),l=Ot(e,a);if(!n||parseFloat(n)<=0)return;if(c){const d=qt({reasonText:s,salePriceFormatted:te(n,e.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&r==="inline"){t.classList.add("gengage-chat-product-card-price-block--inline");const h=document.createElement("div");h.className="gengage-chat-product-card-price-row",h.appendChild(d);const f=document.createElement("span");f.className="gengage-chat-product-card-price-sep",f.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=te(i,e.pricing),h.appendChild(f),h.appendChild(b),t.appendChild(h);return}if(t.classList.remove("gengage-chat-product-card-price-block--inline"),t.appendChild(d),o){t.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-product-card-original-price",h.textContent=te(i,e.pricing),t.appendChild(h)}return}if(o&&r==="inline"){t.classList.add("gengage-chat-product-card-price-block--inline");const d=document.createElement("div");d.className="gengage-chat-product-card-price-row";const h=document.createElement("span");h.className="gengage-chat-product-card-current-price",h.textContent=te(n,e.pricing);const f=document.createElement("span");f.className="gengage-chat-product-card-price-sep",f.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=te(i,e.pricing),d.appendChild(h),d.appendChild(f),d.appendChild(b),t.appendChild(d);return}t.classList.remove("gengage-chat-product-card-price-block--inline");const p=document.createElement("span");if(p.className="gengage-chat-product-card-current-price",p.textContent=te(n,e.pricing),t.appendChild(p),o){t.appendChild(document.createTextNode(" "));const d=document.createElement("span");d.className="gengage-chat-product-card-original-price",d.textContent=te(i,e.pricing),t.appendChild(d)}}function lr(t,e,a,n,i,r,o){t.classList.remove("gengage-chat-product-details-price--inline"),t.replaceChildren(),t.className="gengage-chat-product-details-price";const s=lt(e,a),c=!!(s&&o),l=Ot(e,a);if(c){const d=qt({reasonText:s,salePriceFormatted:te(n,e.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&r==="inline"){t.classList.add("gengage-chat-product-details-price--inline"),t.appendChild(d);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const f=document.createElement("span");f.className="gengage-chat-product-details-original-price",f.textContent=te(i,e.pricing),t.appendChild(h),t.appendChild(f)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=te(i,e.pricing),t.appendChild(h),t.appendChild(document.createTextNode(" "))}t.appendChild(d)}}else if(o&&r==="inline"){t.classList.add("gengage-chat-product-details-price--inline");const d=document.createElement("span");d.className="gengage-chat-product-details-current-price",d.textContent=te(n,e.pricing);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const f=document.createElement("span");f.className="gengage-chat-product-details-original-price",f.textContent=te(i,e.pricing),t.appendChild(d),t.appendChild(h),t.appendChild(f)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=te(i,e.pricing),t.appendChild(h),t.appendChild(document.createTextNode(" "))}const d=document.createElement("span");d.className="gengage-chat-product-details-current-price",d.textContent=te(n,e.pricing),t.appendChild(d)}const p=$t(a,"discountPercent","price_discount_rate");if(!e.hideProductDiscountBadge&&typeof p=="number"&&p>0){const d=document.createElement("span");d.className="gengage-chat-product-details-discount-badge",d.textContent=`%${Ua(p)}`,t.appendChild(d)}}function $a(t,e){const a=document.createElement("div");a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive";const n=t.props?.product??t.props;if(!n)return a;const i=n.sku;i&&(a.dataset.sku=i);const r=t.props?.action,o=n.name,s=n.url,c=n.sku,l=s&&pe(s)?s:void 0,p=()=>r?.type!=="launchSingleProduct"||l===void 0||c===void 0||e.onProductClick===void 0?!1:(e.onProductClick({sku:c,url:l,...typeof o=="string"?{name:o}:{}}),!0);(e.onProductSelect||r)&&(a.classList.add("gds-clickable"),a.addEventListener("click",C=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!C.target.closest(".gengage-chat-product-card-atc")&&!C.target.closest(".gengage-chat-product-card-cta")){if(r){p()||e.onAction(r);return}e.onProductSelect?.(n)}}));const d=n.imageUrl;if(d&&pe(d)){const C=document.createElement("div");C.className="gengage-chat-product-card-img-wrapper";const M=document.createElement("img");M.className="gengage-chat-product-card-img",M.loading="lazy",he(M,"src",d);const O=n.name;O&&(M.alt=O),Ce(M),C.appendChild(M);const U=n.discountPercent;if(!e.hideProductDiscountBadge&&typeof U=="number"&&U>0){const x=document.createElement("span");x.className="gengage-chat-product-card-discount-badge",x.textContent=`%${Ua(U)}`,C.appendChild(x)}const R=document.createElement("div");R.className="gengage-chat-product-card-img-actions";const ne=n.sku;if(ne&&e.onFavoriteToggle){const x=document.createElement("button");x.className="gengage-chat-favorite-btn",x.type="button",x.dataset.gengageFavoriteSku=ne,x.setAttribute("aria-label",e.i18n?.addToFavoritesLabel??"Add to favorites");const N=e.favoritedSkus?.has(ne)??!1;N&&x.classList.add("gengage-chat-favorite-btn--active"),x.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${N?"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>`,x.addEventListener("click",I=>{I.stopPropagation(),x.classList.toggle("gengage-chat-favorite-btn--active");const B=x.querySelector("svg");B&&B.setAttribute("fill",x.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),e.onFavoriteToggle(ne,n)}),R.appendChild(x)}const ae=n.sku,G=e.i18n?.findSimilarLabel??"Find Similar";if(ae){const x=document.createElement("button");x.className="gengage-chat-find-similar-pill",x.type="button",x.setAttribute("aria-label",G),x.dataset.tooltip=G,x.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 N=document.createElement("span");N.className="gengage-chat-find-similar-pill-text",N.textContent=G,x.appendChild(N),x.addEventListener("click",I=>{I.stopPropagation(),e.onAction({title:G,type:"findSimilar",payload:{sku:ae}})}),R.appendChild(x)}R.childElementCount>0&&C.appendChild(R),a.appendChild(C)}const h=document.createElement("div");h.className="gengage-chat-product-card-body";const f=n.brand;if(f){const C=document.createElement("div");C.className="gengage-chat-product-card-brand",C.textContent=f,h.appendChild(C)}const b=n.rating,m=n.reviewCount,u=n.price,g=n.originalPrice,v=n.price_async,_=lt(e,n),y=yt(e,n),k=!!(g&&u&&g!==u&&parseFloat(u)>0),P=!!(_&&k),w=!!(_&&!P||k&&y==="inline"),E=typeof b=="number"&&Number.isFinite(b)&&b>0,z=document.createElement("div");z.className="gengage-chat-product-card-meta-row";const V=document.createElement("div");V.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const W=w?(()=>{const C=document.createElement("div");return C.className="gengage-chat-product-card-price-stack",_&&!P&&C.appendChild(Ut(_)),C.appendChild(V),C})():V;if(v===!0){const C=document.createElement("span");C.className="gengage-chat-price-skeleton",V.appendChild(C),setTimeout(()=>{C.parentElement&&(u&&parseFloat(u)>0?cr(V,e,n,u,n.originalPrice):C.remove())},300)}else u&&parseFloat(u)>0&&cr(V,e,n,u,g);if((V.childElementCount>0||v===!0)&&z.appendChild(W),E){const C=document.createElement("div");C.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const M=Da(b),O=[`${M.toFixed(1)}`,"out of 5 stars"];typeof m=="number"&&Number.isFinite(m)&&O.push(`(${m} reviews)`),C.setAttribute("aria-label",O.join(" "));const U=document.createElement("span");U.className="gengage-chat-product-card-rating-compact-star",U.setAttribute("aria-hidden","true"),U.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 R=document.createElement("span");R.className="gengage-chat-product-card-rating-compact-value",R.textContent=M.toFixed(1),C.appendChild(U),C.appendChild(R),z.appendChild(C)}if(z.childElementCount===0&&(z.classList.add("gengage-chat-product-card-meta-row--empty"),z.setAttribute("aria-hidden","true")),h.appendChild(z),o){const C=document.createElement("div");C.className="gengage-chat-product-card-name",C.textContent=o,C.title=o,h.appendChild(C)}const oe=n.inStock;if(e.hideStockStatus!==!0&&typeof oe=="boolean"){const C=document.createElement("div");C.className=`gengage-chat-product-card-stock ${oe?"is-in-stock":"is-out-of-stock"}`,C.textContent=oe?e.i18n?.inStockLabel??"In Stock":e.i18n?.outOfStockLabel??"Out of Stock",h.appendChild(C)}a.appendChild(h);const ie=n.cartCode,A=!!(ie&&c&&oe!==!1),D=e.i18n?.productCtaLabel??"View";if(A){const C=document.createElement("div");C.className="gengage-chat-product-card-buy-footer";const M=document.createElement("button");M.type="button",M.className="gengage-chat-product-card-buy-trigger",M.textContent=D,M.addEventListener("click",O=>{O.stopPropagation(),e.onAction({title:e.i18n?.addToCartButton??D,type:"addToCart",payload:{sku:c,cartCode:ie,quantity:1}})}),C.appendChild(M),a.appendChild(C)}else if(r){const C=document.createElement("button");C.className="gengage-chat-product-card-cta",C.type="button",C.textContent=r.type==="launchSingleProduct"?D:r.title||D,C.addEventListener("click",M=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){M.stopPropagation();return}p()||e.onAction(r)}),a.appendChild(C)}else if(l){const C=document.createElement("a");C.className="gengage-chat-product-card-cta",he(C,"href",l),he(C,"target","_blank"),he(C,"rel","noopener noreferrer"),C.textContent=D,C.addEventListener("click",M=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){M.preventDefault(),M.stopPropagation();return}e.onProductClick&&c&&(M.preventDefault(),e.onProductClick({sku:c,url:l,...o?{name:o}:{}}))}),a.appendChild(C)}if(e.comparisonSelectMode&&c&&e.onToggleComparisonSku){const C=document.createElement("div");C.className="gengage-chat-comparison-select-wrapper";const M=e.comparisonSelectedSkus?.includes(c)??!1;M&&C.classList.add("gengage-chat-comparison-select-wrapper--selected");const O=n.name??c,U=e.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";C.setAttribute("role","group"),C.setAttribute("aria-label",`${String(O)}. ${U}`);const R=document.createElement("button");R.type="button",R.className="gengage-chat-comparison-checkbox",R.dataset.selected=M?"true":"false",R.setAttribute("aria-pressed",M?"true":"false");const ne=document.createElement("span");ne.className="gengage-chat-comparison-checkbox-icon",ne.innerHTML=M?'<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 ae=document.createElement("span");ae.className="gengage-chat-comparison-checkbox-label",ae.textContent=M?e.i18n?.comparisonSelectedLabel??"Selected":e.i18n?.comparisonSelectLabel??"Select to compare",R.appendChild(ne),R.appendChild(ae),R.addEventListener("click",x=>{x.stopPropagation(),e.onToggleComparisonSku?.(c)});const G=document.createElement("div");return G.className="gengage-chat-comparison-card-hint",G.setAttribute("aria-hidden","true"),G.textContent=U,C.addEventListener("click",x=>{x.target.closest(".gengage-chat-comparison-checkbox")||(x.stopPropagation(),e.onToggleComparisonSku?.(c))}),C.appendChild(R),C.appendChild(G),C.appendChild(a),C}return a}function Se(t,...e){for(const a of e){const n=t[a];if(typeof n=="string"){const i=n.trim();if(i.length>0)return i}}}function $t(t,...e){for(const a of e){const n=t[a];if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const i=Number(n.replace(",","."));if(Number.isFinite(i))return i}}}function Vt(t,...e){for(const a of e){const n=t[a];if(typeof n=="boolean")return n}}function $g(t,...e){for(const a of e){const n=t[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function Vg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.trim().length>0):[]}function Gg(t){const e=[...Vg(t.images),Se(t,"imageUrl","image_url","image")].filter(a=>!!a&&pe(a));return Array.from(new Set(e))}function Wg(t){return typeof DOMParser<"u"?(new DOMParser().parseFromString(t,"text/html").body.textContent??"").replace(/\s+/g," ").trim():t.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function Kg(t){const e=Se(t,"description_html","descriptionHtml");if(e){const n=Wg(e);if(n)return{text:n,html:e}}const a=Se(t,"description");return a?{text:a}:void 0}function Gt(t){return Array.isArray(t)?t.map(e=>{if(!e||typeof e!="object")return null;const a=e,n=Se(a,"key","name","label","title"),i=a.value,r=typeof i=="string"||typeof i=="number"||typeof i=="boolean"?String(i).trim():void 0;return!n||!r?null:{key:n,value:r}}).filter(e=>e!==null):t&&typeof t=="object"?Object.entries(t).map(([e,a])=>{const n=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a).trim():void 0;return!e||!n?null:{key:e,value:n}}).filter(e=>e!==null):[]}function gr(t){const e=Gt(t.features);return e.length>0?e:Gt(t.specifications)}function Yg(t){const e=t.specifications,a=Gt(e);if(a.length>0)return Array.isArray(e)?a:Object.fromEntries(a.map(i=>[i.key,i.value]));const n=Gt(t.features);return n.length>0?n:void 0}function De(t,...e){return Se(t,...e)}function dr(t,...e){return $t(t,...e)}function pr(t){return De(t,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function hr(t){const e=De(t,"type","attribute","option_name","attribute_name");return e||(De(t,"value")?De(t,"name","variant_name"):void 0)}function Qg(t){const e=hr(t)?.toLowerCase();return!!(Se(t,"color","colour","color_hex","hex","swatch","swatchColor")||e&&Wa.has(e))}function ur(t){if(!t)return;const e=t.trim();if(!(!e||e.includes(";"))&&(typeof CSS<"u"&&CSS.supports?.("color",e)||/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)))return e}function Zg(t){const e=ur(De(t,"swatchColor","swatch","color_hex","hex","color","colour"));if(e)return e;if(Qg(t))return ur(pr(t))}function Xg(t){return De(t,"image","imageUrl","image_url","swatchImage","swatch_image")}function Jg(t){return dr(t,"price_discounted","priceDiscounted")??De(t,"price_discounted","priceDiscounted")??dr(t,"price")??De(t,"price")}function ed(t){const e=t.trim().toLowerCase();return Wa.has(e)||vr.has(e)||yr.has(e)}function td(t){const e=t.trim().toLowerCase();return e==="renk kodu"?"Renk":e==="color code"?"Color":t.trim()}function ad(t){for(const e of xr){const a=t[e];if(!Array.isArray(a))continue;const n=a.filter(i=>!!i&&typeof i=="object"&&!Array.isArray(i));if(n.length>0)return n}}function nd(t){const e=ad(t);if(e)return e;const a=Se(t,"sku"),n=Vt(t,"inStock","in_stock"),i=[],r=new Set,o=(c,l)=>{if(!ed(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const p=String(l).trim();if(!p)return;const d=td(c),h=`${d.toLowerCase()}:${p.toLowerCase()}`;r.has(h)||(r.add(h),i.push({name:d,value:p,sku:a,inStock:n}))},s=$g(t,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of gr(t))o(c.key,c.value);return i}function id(t,e){const a=Array.from(new Set(t.map(hr).filter(n=>!!n)));return a.length===1?`${t.length} ${a[0]}`:e.i18n?.variantsLabel??"Variants"}function rd(t,e){const a=document.createElement("article");a.className="gengage-chat-product-details-panel";const n=t.props?.product??t.props;if(!n)return a;const i=Se(n,"name"),r=Se(n,"brand"),o=Se(n,"sku"),s=Se(n,"cartCode","cart_code"),c=Se(n,"price"),l=Se(n,"originalPrice","price_original"),p=Vt(n,"price_async"),d=lt(e,n),h=yt(e,n),f=!!(l&&c&&l!==c),b=Vt(n,"inStock","in_stock"),m=$t(n,"reviewCount","review_count"),u=$t(n,"rating"),g=Gg(n),v=gr(n).slice(0,4);if(g.length>1){const A=document.createElement("div");A.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const D=document.createElement("img");D.className="gengage-chat-product-details-img",he(D,"src",g[0]),D.alt=i??"Product image",Ce(D),A.appendChild(D);const C=document.createElement("div");C.className="gengage-chat-product-gallery-thumbs";const M=6;let O=null,U=0;const R=e.i18n,ne=R?.galleryPrevAriaLabel??"Previous image",ae=R?.galleryNextAriaLabel??"Next image",G=$=>$==="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>',x=document.createElement("button");x.type="button",x.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn",x.setAttribute("aria-label",ne),x.innerHTML=G("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",ae),N.innerHTML=G("next");const I=()=>{x.disabled=U<=0,N.disabled=U>=g.length-1},B=$=>{if($<0||$>=g.length||$===U)return;const J=g[$];if(!J)return;he(D,"src",J);const Y=C.querySelectorAll(".gengage-chat-product-gallery-thumb");O&&O.classList.remove("gengage-chat-product-gallery-thumb--active"),$<M&&Y[$]?(Y[$].classList.add("gengage-chat-product-gallery-thumb--active"),O=Y[$]):O=null,U=$,I()};for(let $=0;$<g.length;$++){const J=g[$];if($>=M)break;const Y=document.createElement("img");Y.className="gengage-chat-product-gallery-thumb",$===0&&(Y.classList.add("gengage-chat-product-gallery-thumb--active"),O=Y),he(Y,"src",J),Y.alt=`${i??"Product"} ${$+1}`,Y.width=48,Y.height=48,Ce(Y),Y.addEventListener("click",()=>{B($)}),C.appendChild(Y)}if(g.length>M){const $=document.createElement("span");$.className="gengage-chat-product-gallery-thumb-more",$.textContent=`+${g.length-M}`,C.appendChild($)}x.addEventListener("click",$=>{$.stopPropagation(),B(U-1)}),N.addEventListener("click",$=>{$.stopPropagation(),B(U+1)}),I();let q=0;const j=50;D.addEventListener("touchstart",$=>{q=$.changedTouches[0].clientX},{passive:!0}),D.addEventListener("touchend",$=>{const J=$.changedTouches[0].clientX,Y=q-J;Math.abs(Y)<j||B(Y>0?Math.min(U+1,g.length-1):Math.max(U-1,0))}),A.appendChild(x),A.appendChild(N),A.appendChild(C),a.appendChild(A)}else if(g.length===1){const A=document.createElement("div");A.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const D=document.createElement("img");D.className="gengage-chat-product-details-img",D.loading="lazy",he(D,"src",g[0]),Ce(D),D.alt=i??"Product image",A.appendChild(D),a.appendChild(A)}const _=document.createElement("div");if(_.className="gengage-chat-product-details-content",r&&(!i||!i.toLowerCase().startsWith(r.toLowerCase()))){const A=document.createElement("div");A.className="gengage-chat-product-details-brand",A.textContent=r,_.appendChild(A)}if(i){const A=document.createElement("h3");A.className="gengage-chat-product-details-title",A.textContent=i,A.title=i,_.appendChild(A)}if(e.hideUserReviews!==!0&&typeof u=="number"&&Number.isFinite(u)&&u>0){const A=document.createElement(o?"button":"div");A.className="gengage-chat-product-details-rating",o&&(A.type="button",A.classList.add("gengage-chat-product-details-rating--clickable"),A.setAttribute("aria-label",e.i18n?.groundingReviewCta??"Read Reviews"),A.addEventListener("click",()=>{e.onAction({title:e.i18n?.customerReviewsTitle??"Customer Reviews",type:"reviewSummary",payload:{sku:o}})})),A.appendChild(Oa(u));const D=document.createElement("span");if(D.className="gengage-chat-product-details-rating-value",D.textContent=Da(u).toFixed(1),A.appendChild(D),typeof m=="number"&&Number.isFinite(m)){const C=document.createElement("span");C.className="gengage-chat-product-details-review-count",C.textContent=` (${m})`,A.appendChild(C)}_.appendChild(A)}{const A=!!(d&&f);let D=_;if(d&&!A){const M=document.createElement("div");M.className="gengage-chat-product-details-price-stack",M.appendChild(Ut(d)),_.appendChild(M),D=M}const C=document.createElement("div");if(C.className="gengage-chat-product-details-price",p===!0){const M=document.createElement("span");M.className="gengage-chat-price-skeleton",C.appendChild(M),D.appendChild(C),setTimeout(()=>{if(M.parentElement)if(c&&parseFloat(c)>0)lr(C,e,n,c,l,h,f);else{const O=C.parentElement;C.remove(),O?.classList.contains("gengage-chat-product-details-price-stack")&&O.remove()}},300)}else if(c&&parseFloat(c)>0)lr(C,e,n,c,l,h,f),D.appendChild(C);else if(d){const M=D;M.classList.contains("gengage-chat-product-details-price-stack")&&M.remove()}}if(e.hideStockStatus!==!0&&typeof b=="boolean"){const A=document.createElement("div");A.className=`gengage-chat-product-details-stock ${b?"is-in-stock":"is-out-of-stock"}`,A.textContent=b?e.i18n?.inStockLabel??"In Stock":e.i18n?.outOfStockLabel??"Out of Stock",_.appendChild(A)}const y=n.promotions;if(y&&y.length>0){const A=document.createElement("div");A.className="gengage-chat-product-details-promos";for(const D of y.slice(0,3)){if(!D||/%(0(\.0+)?)\s/.test(D))continue;const C=document.createElement("span");C.className="gengage-chat-product-details-promo-badge",C.textContent=D,C.title=D,A.appendChild(C)}A.childElementCount>0&&_.appendChild(A)}if(v.length>0){const A=document.createElement("dl");A.className="gengage-chat-product-details-facts";for(const D of v){const C=document.createElement("div");C.className="gengage-chat-product-details-fact";const M=document.createElement("dt");M.textContent=D.key;const O=document.createElement("dd");O.textContent=D.value,C.appendChild(M),C.appendChild(O),A.appendChild(C)}_.appendChild(A)}const k=nd(n);if(k.length>0){const A=document.createElement("div");A.className="gengage-chat-product-variants";const D=document.createElement("div");D.className="gengage-chat-product-variants-label",D.textContent=id(k,e),A.appendChild(D);const C=document.createElement("div");C.className="gengage-chat-product-variants-list";for(const M of k){const O=pr(M),U=De(M,"sku");if(!O&&!U)continue;const R=document.createElement("button");R.className="gengage-chat-product-variant-btn gds-chip",R.type="button";const ne=O??U??"";R.title=ne;const ae=Vt(M,"in_stock","inStock");U&&o&&U===o?(R.classList.add("gengage-chat-product-variant-btn--active"),R.setAttribute("aria-pressed","true")):R.setAttribute("aria-pressed","false"),ae===!1&&(R.classList.add("gengage-chat-product-variant-btn--out"),R.disabled=!0);const G=Xg(M),x=Zg(M);if(G&&pe(G)){const B=document.createElement("img");B.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",he(B,"src",G),B.alt="",B.setAttribute("aria-hidden","true"),Ce(B),R.appendChild(B)}else if(x){const B=document.createElement("span");B.className="gengage-chat-product-variant-swatch",B.setAttribute("aria-hidden","true"),B.style.backgroundColor=x,R.appendChild(B)}const N=document.createElement("span");N.className="gengage-chat-product-variant-label",N.textContent=ne,R.appendChild(N);const I=Jg(M);if(I&&String(I)!==String(c)){const B=document.createElement("span");B.className="gengage-chat-product-variant-price",B.textContent=te(String(I),e.pricing),R.appendChild(B)}if(U&&U!==o){const B=i??"",q=(typeof M.value=="string"?M.value.trim():"")||(typeof M.name=="string"?M.name.trim():"")||(typeof M.variant_name=="string"?M.variant_name.trim():"")||"",j=B.length>0?q.length>0&&q!==B?`${B} (${q})`:B:ne;R.addEventListener("click",()=>{e.onAction({title:j,type:"launchVariant",payload:{sku:U}})})}C.appendChild(R)}C.childElementCount>0&&(A.appendChild(C),_.appendChild(A))}const P=document.createElement("div");P.className="gengage-chat-product-details-actions";const w=t.props?.action;if(w){const A=document.createElement("button");A.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",A.type="button",A.textContent=w.title||e.i18n?.productCtaLabel||"View",A.addEventListener("click",()=>e.onAction(w)),P.appendChild(A)}if(s&&o&&b!==!1){const A=document.createElement("button");A.className="gengage-chat-product-details-atc gds-btn gds-btn-primary",A.type="button",A.textContent=e.i18n?.addToCartButton??"Add to Cart",A.addEventListener("click",()=>{e.onAction({title:e.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:o,cartCode:s,quantity:1}})}),P.appendChild(A)}const E=Se(n,"url");if(!w&&E&&pe(E)){const A=document.createElement("a");A.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",he(A,"href",E),he(A,"target","_blank"),he(A,"rel","noopener noreferrer"),A.textContent=e.i18n?.viewOnSiteLabel??e.i18n?.productCtaLabel??"View on Site",A.addEventListener("click",D=>{e.onProductClick&&o&&(D.preventDefault(),e.onProductClick({sku:o,url:E,...i?{name:i}:{}}))}),P.appendChild(A)}const z=E;if(z&&pe(z)){let O=function(R,ne){const ae=document.createElementNS(C,"circle");ae.setAttribute("cx",R),ae.setAttribute("cy",ne),ae.setAttribute("r","3"),M.appendChild(ae)},U=function(R,ne,ae,G){const x=document.createElementNS(C,"line");x.setAttribute("x1",R),x.setAttribute("y1",ne),x.setAttribute("x2",ae),x.setAttribute("y2",G),M.appendChild(x)};var oe=O,ie=U;const A=document.createElement("button");A.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",A.type="button";const D=e.i18n?.shareButton??"Share";A.title=D,A.setAttribute("aria-label",D);const C="http://www.w3.org/2000/svg",M=document.createElementNS(C,"svg");M.setAttribute("width","18"),M.setAttribute("height","18"),M.setAttribute("viewBox","0 0 24 24"),M.setAttribute("fill","none"),M.setAttribute("stroke","currentColor"),M.setAttribute("stroke-width","2"),M.setAttribute("stroke-linecap","round"),M.setAttribute("stroke-linejoin","round"),O("18","5"),O("6","12"),O("18","19"),U("8.59","13.51","15.42","17.49"),U("15.41","6.51","8.59","10.49"),A.appendChild(M),A.addEventListener("click",async()=>{try{navigator.share?await navigator.share({title:i??"",url:z}):navigator.clipboard&&(await navigator.clipboard.writeText(z),A.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>A.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),P.appendChild(A)}P.childElementCount>0&&_.appendChild(P),a.appendChild(_);const V=Kg(n),W=Yg(n);return(V||W)&&a.appendChild(cd(V,W,e)),a}function Va(t){if(t.nodeType===Node.TEXT_NODE)return document.createTextNode(t.textContent??"");if(t.nodeType!==Node.ELEMENT_NODE)return null;const e=t,a=e.tagName.toUpperCase();if(wr.has(a))return null;if(!_r.has(a)){const i=document.createDocumentFragment();for(const r of Array.from(e.childNodes)){const o=Va(r);o&&i.appendChild(o)}return i}const n=document.createElement(a.toLowerCase());for(const i of Array.from(e.childNodes)){const r=Va(i);r&&n.appendChild(r)}return n}function od(t,e){const a=e.split(/\n{2,}/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean);if(a.length!==0)for(const n of a){const i=document.createElement("p");i.textContent=n,t.appendChild(i)}}function sd(t,e){if(t.classList.add("gengage-chat-product-description"),e.html&&typeof DOMParser<"u"){const a=new DOMParser().parseFromString(e.html,"text/html"),n=Array.from(a.body.childNodes).map(i=>Va(i)).filter(i=>!!i&&(i.nodeType===Node.ELEMENT_NODE||!!i.textContent?.trim()));if(n.length>0){for(const i of n)t.appendChild(i);return}}od(t,e.text)}function cd(t,e,a){const n=document.createElement("div");n.className="gengage-chat-product-detail-tabs";const i=document.createElement("div");i.className="gengage-chat-product-detail-tab-bar gds-toolbar";const r=[];if(t){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",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",sd(c,t),r.push(c)}if(e){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab gds-tab${t?"":" gengage-chat-product-detail-tab--active is-active"}`,s.type="button",s.setAttribute("aria-selected",t?"false":"true"),s.textContent=a.i18n?.specificationsTab??"Specifications",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",t&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const p=Array.isArray(e)?e:Object.entries(e).map(([d,h])=>({key:d,value:h}));for(const d of p){const h=document.createElement("tr"),f=document.createElement("td");f.className="gengage-chat-product-specs-key",f.textContent=d.key;const b=document.createElement("td");b.className="gengage-chat-product-specs-value",b.textContent=d.value,h.appendChild(f),h.appendChild(b),l.appendChild(h)}c.appendChild(l),r.push(c)}const o=i.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"),r.forEach((l,p)=>{l.style.display=p===c?"":"none"})})}),n.appendChild(i);for(const s of r)n.appendChild(s);return n}function mr(t){const e='width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';switch(t){case"related":return`<svg ${e} aria-hidden="true"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`;case"priceAsc":return`<svg ${e} 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 ${e} 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 ld(){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 gd(){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 dd(){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 fr(t,e){return t.type===e.type&&t.direction===e.direction}function br(t,e,a){if(!a||a.type==="related")return t;const n=t.map(i=>{const r=e.elements[i]?.props?.product,o=r?Number(r.price):NaN;return{id:i,price:Number.isFinite(o)?o:1/0}});return n.sort((i,r)=>i.price===1/0&&r.price===1/0?0:i.price===1/0?1:r.price===1/0?-1:a.direction==="desc"?r.price-i.price:i.price-r.price),n.map(i=>i.id)}function pd(t,e,a,n){const i=br(e,a,n),r=new Map;for(const o of Array.from(t.children)){const s=o.dataset.elementId;s&&r.set(s,o)}for(const o of i){const s=r.get(o);s&&t.appendChild(s)}}function hd(t,e,a,n){const i=document.createElement("div");i.className="gengage-chat-product-grid-wrapper";const r=Za(t),o=r.isConsulting,s=t.children??[],c=document.createElement("div");c.className="gengage-chat-product-grid";const l=Array.isArray(t.props?.productSections)?t.props.productSections.map(g=>({title:typeof g.title=="string"?g.title:"",children:Array.isArray(g.children)?g.children.filter(v=>typeof v=="string"&&!!e.elements[v]):[]})).filter(g=>g.children.length>0):[],p=l.length>1,d=!p&&l.length===1&&l[0]?.title?l[0].title:"",h=n?.panelProductListHeading??(d||void 0),f=!o&&!p&&s.length>1&&n?.onSortChange,b=g=>{if(!n?.onToggleComparisonSku)return;const v=document.createElement("button");v.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",v.type="button",n.comparisonSelectMode&&v.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&v.classList.add("gengage-chat-comparison-toggle-btn--hidden");const _=document.createElement("span");_.className="gengage-chat-comparison-toggle-icon",_.innerHTML=dd();const y=document.createElement("span");y.className="gengage-chat-comparison-toggle-label";const k=n.i18n?.compareSelected??"Compare";y.textContent=k,v.setAttribute("aria-label",k),v.title=k,v.appendChild(_),v.appendChild(y),v.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),g.appendChild(v)},m=(g,v=s.length)=>{const _=t.props?.endOfList;if(o||!(p?_===!1:_!==!0)||v===0)return;const y=n?.i18n?.viewMoreLabel??"Show More",k=document.createElement("button");k.className="gengage-chat-product-grid-view-more",k.type="button",k.textContent=y,k.addEventListener("click",()=>{n?.onAction({title:y,type:"moreProductList",payload:{}})}),g.appendChild(k)},u=()=>{const g=n?.isMobile??jt();n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!g&&i.appendChild(Ji(n.comparisonSelectedSkus,n))};if(f){const g=document.createElement("div");g.className="gengage-chat-product-sort-toolbar",g.setAttribute("role","toolbar"),g.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let v=n.productSort??{type:"related"};const _=[{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"}],y=document.createElement("div");y.className="gengage-chat-product-sort-dropdown";const k=document.createElement("button");k.type="button",k.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",k.setAttribute("aria-haspopup","listbox"),k.setAttribute("aria-expanded","false");const P=n.i18n?.sortToolbarAriaLabel??"Sort products",w=document.createElement("span");w.className="gengage-chat-product-sort-trigger-icon";const E=document.createElement("span");E.className="gengage-chat-product-sort-trigger-label";const z=O=>{const U=_.find(R=>fr(R.sortState,O))??_[0];E.textContent=U.label,w.innerHTML=mr(U.icon),y.dataset.sortIcon=U.icon,k.setAttribute("aria-label",`${P}: ${U.label}`),k.title=U.label};z(v);const V=document.createElement("span");V.className="gengage-chat-product-sort-trigger-chevron",V.innerHTML=ld(),k.appendChild(w),k.appendChild(E),k.appendChild(V);const W=document.createElement("div");W.className="gengage-chat-product-sort-menu gds-menu",W.hidden=!0,W.setAttribute("role","listbox"),W.setAttribute("aria-label",P);const oe=g.ownerDocument;let ie=null;const A=()=>{W.hidden=!0,y.classList.remove("gengage-chat-product-sort-dropdown--open"),k.setAttribute("aria-expanded","false"),ie?.abort(),ie=null},D=O=>{y.classList.contains("gengage-chat-product-sort-dropdown--open")&&(y.contains(O.target)||A())},C=O=>{O.key==="Escape"&&(O.preventDefault(),A())},M=()=>{W.hidden=!1,y.classList.add("gengage-chat-product-sort-dropdown--open"),k.setAttribute("aria-expanded","true"),ie=new AbortController;const{signal:O}=ie;oe.addEventListener("click",D,{signal:O}),oe.addEventListener("keydown",C,{capture:!0,signal:O})};k.addEventListener("click",O=>{O.stopPropagation(),y.classList.contains("gengage-chat-product-sort-dropdown--open")?A():M()});for(const O of _){const U=document.createElement("button");U.type="button",U.className="gengage-chat-product-sort-option gds-menu-option",U.setAttribute("role","option");const R=fr(v,O.sortState);U.setAttribute("aria-selected",R?"true":"false"),R&&U.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const ne=O.sortState.type==="related"?"related":`price-${O.sortState.direction??""}`;U.dataset.sortKey=ne;const ae=document.createElement("span");ae.className="gengage-chat-product-sort-option-icon",ae.innerHTML=mr(O.icon);const G=document.createElement("span");G.className="gengage-chat-product-sort-option-label",G.textContent=O.label;const x=document.createElement("span");x.className="gengage-chat-product-sort-option-check",x.innerHTML=gd(),x.setAttribute("aria-hidden","true"),R||x.classList.add("gengage-chat-product-sort-option-check--hidden"),U.appendChild(ae),U.appendChild(G),U.appendChild(x),U.addEventListener("click",()=>{v=O.sortState,n.onSortChange?.(O.sortState),pd(c,s,e,O.sortState),W.querySelectorAll(".gengage-chat-product-sort-option").forEach(N=>{const I=N,B=I.dataset.sortKey===ne;I.classList.toggle("gengage-chat-product-sort-option--active",B),I.classList.toggle("gds-menu-option-active",B),I.setAttribute("aria-selected",B?"true":"false"),I.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!B)}),z(O.sortState),A()}),W.appendChild(U)}if(y.appendChild(k),y.appendChild(W),g.appendChild(y),b(g),h){g.classList.add("gengage-chat-product-sort-toolbar--inline");const O=document.createElement("div");O.className="gengage-chat-product-grid-head";const U=document.createElement("span");U.className="gengage-chat-product-grid-head-title",U.textContent=h,O.appendChild(U);const R=document.createElement("div");R.className="gengage-chat-product-grid-head-actions",R.appendChild(g),O.appendChild(R),i.appendChild(O)}else i.appendChild(g)}else if(h){const g=document.createElement("div");g.className="gengage-chat-product-grid-head";const v=document.createElement("span");v.className="gengage-chat-product-grid-head-title",v.textContent=h,g.appendChild(v),i.appendChild(g)}if(p&&!o){if(i.classList.add("gengage-chat-product-grid-wrapper--grouped"),n?.onToggleComparisonSku){const y=document.createElement("div");y.className="gengage-chat-product-sort-toolbar gengage-chat-product-sort-toolbar--compare-only",y.setAttribute("role","toolbar"),y.setAttribute("aria-label",n.i18n?.compareSelected??"Compare"),b(y),i.appendChild(y)}const g=document.createElement("div");g.className="gengage-chat-product-grid-sections",g.setAttribute("role","list");const v=t.props?.rankingState;let _=0;for(const y of l){_+=y.children.length;const k=ud(y.children.length,n),P=document.createElement("section");P.className="gengage-chat-product-grid-section",P.setAttribute("role","listitem");const w=document.createElement("div");if(w.className="gengage-chat-product-grid-section-head",y.title){const V=document.createElement("h3");V.className="gengage-chat-product-grid-section-title",V.textContent=y.title,w.appendChild(V)}const E=document.createElement("span");E.className="gengage-chat-product-grid-section-count",E.textContent=k,w.appendChild(E),P.appendChild(w);const z=document.createElement("div");z.className="gengage-chat-product-grid gengage-chat-product-grid--section";for(const V of y.children){const W=a(V);W&&(W.dataset.elementId=V,z.appendChild(W))}(n?.isMobile??jt())&&z.classList.add("gengage-chat-product-grid--mobile"),v==="pending"&&(z.classList.add("gengage-chat-product-grid--pending"),z.inert=!0,z.setAttribute("aria-busy","true")),P.appendChild(z),g.appendChild(P)}return i.appendChild(g),m(i,_),u(),i}if(o)kd(i,c,r,n);else{const g=br(s,e,n?.productSort);for(const v of g){if(!e.elements[v])continue;const _=a(v);_&&(_.dataset.elementId=v,c.appendChild(_))}}return(n?.isMobile??jt())&&c.classList.add("gengage-chat-product-grid--mobile"),t.props?.rankingState==="pending"&&(c.classList.add("gengage-chat-product-grid--pending"),c.inert=!0,c.setAttribute("aria-busy","true")),i.appendChild(c),m(i),u(),i}function ud(t,e){return(e?.i18n?.productGridSectionCountLabel??"{count} product(s)").replace(/\{count\}/g,String(t))}function md(t,e,a){const n=i=>{const r=i?.url;return typeof r=="string"?r.trim():""};if(e.sku===t){const i=n(e);if(i.length>0)return i}return n(a.find(i=>i.sku===t))}function fd(t,e){const a=t.props??{},n=a.keyDifferencesHtml,i=a.recommended,r=a.products??[],o=a.attributes??[],s=a.highlights??[],c=a.specialCases,l=a.recommendedText,p=a.winnerHits,d=a.productActions;if(!i)return document.createElement("div");const h={recommended:i,products:r,attributes:o,highlights:s,specialCases:c,locale:e.locale,onProductClick:({sku:b,name:m})=>{const u=md(b,i,r);e.onProductClick?.({sku:b,url:u,...m!==void 0&&m!==""?{name:m}:{}})},pricing:e.pricing};l!==void 0&&(h.recommendedText=l),p!==void 0&&(h.winnerHits=p),d!==void 0&&(h.productActions=d),n!==void 0&&(h.keyDifferencesHtml=n),e.i18n&&(h.i18n={comparisonHeading:e.i18n.panelTitleComparisonResults,recommendedChoiceLabel:e.i18n.recommendedChoiceLabel,highlightsLabel:e.i18n.highlightsLabel,keyDifferencesLabel:e.i18n.keyDifferencesLabel,viewMoreLabel:e.i18n.viewMoreLabel,specialCasesLabel:e.i18n.specialCasesLabel,addToCartButton:e.i18n.addToCartButton});const f=Xl(h);return(e.isMobile??jt())&&f.classList.add("gengage-chat-comparison--mobile"),f}function bd(t){const e=document.createElement("hr");e.className="gengage-chat-divider";const a=t.props?.label;if(a){const n=document.createElement("div");n.className="gengage-chat-divider-wrapper";const i=document.createElement("span");i.className="gengage-chat-divider-label",i.textContent=a,n.appendChild(e),n.appendChild(i);const r=document.createElement("hr");return r.className="gengage-chat-divider",n.appendChild(r),n}return e}var Ga,Wt,Wa,vr,yr,xr,_r,wr,kr=L((()=>{nt(),ct(),tg(),lg(),vg(),xg(),kg(),Sg(),er(),Pg(),Bg(),zg(),ir(),Ug(),Og(),Tr(),ge(),je(),ja(),Ga={ActionButtons:({element:t,context:e})=>qg(t,e),ActionButton:({element:t,context:e})=>jg(t,e),ProductCard:({element:t,context:e})=>$a(t,e),ProductDetailsPanel:({element:t,context:e})=>rd(t,e),ProductGrid:({element:t,spec:e,renderElement:a,context:n})=>hd(t,e,a,n),ReviewHighlights:({element:t,context:e})=>e.hideUserReviews===!0?null:cg(t,{emptyReviewsMessage:e.i18n?.emptyReviewsMessage,reviewFilterPositive:e.i18n?.reviewFilterPositive,reviewFilterNegative:e.i18n?.reviewFilterNegative,reviewCustomersMentionSingular:e.i18n?.reviewCustomersMentionSingular,reviewCustomersMentionPlural:e.i18n?.reviewCustomersMentionPlural,reviewSubjectsHeading:e.i18n?.reviewSubjectsHeading}),ComparisonTable:({element:t,context:e})=>fd(t,e),AITopPicks:({element:t,context:e})=>fg(t,e),GroundingReviewCard:({element:t,context:e})=>e.hideUserReviews===!0?null:yg(t,e),AIGroupingCards:({element:t,context:e})=>wg(t,e),AISuggestedSearchCards:({element:t,context:e})=>Cg(t,e),ProsAndCons:({element:t})=>Eg(t),CategoriesContainer:({element:t,context:e})=>Ng(t,e),HandoffNotice:({element:t,context:e})=>Rg(t,e),PanelRestoreCard:({element:t,context:e})=>Fg(t,e),ProductSummaryCard:({element:t,context:e})=>Dg(t,e),Divider:({element:t})=>bd(t),...rr},Wt=({element:t,renderElement:e})=>{if(!t.children||t.children.length===0)return null;const a=document.createElement("div");for(const n of t.children){const i=e(n);i&&a.appendChild(i)}return a},Wa=new Set(["color","colour","renk","renk kodu","color code"]),vr=new Set(["size","beden","boyut"]),yr=new Set(["finish","bitiş","bitişi"]),xr=["variants","variantOptions","variant_options","productVariants","product_variants","options"],_r=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),wr=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"])}));function Cr(t){return{...Qe,...t?.i18n??{}}}function Sr(t){return t.watchStylesPreparedTitle??t.beautyStylesPreparedTitle}function Kt(t){return typeof t.status=="string"?t.status:"ready"}function Ka(t){const e=t.findIndex(a=>Kt(a)!=="loading");return e<0?0:e}function vd(t){if(typeof t!="string")return;const e=t.trim();if(!e)return;if(/^https?:\/\//i.test(e))return e;let a=e.split(/[?#]/)[0];if(a&&(a=a.replace(/^\/+/,""),a.startsWith("remoteConfig/")&&(a=a.slice(13)),!!a))return`https://configs.gengage.ai/assets/${a}`}function Er(t,e,a,n){const{grid:i,i18n:r}=t;i.innerHTML="",i.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=Yt(e,n,r),o.appendChild(s);const c=document.createElement("p");if(c.className="gengage-chat-consulting-loading-panel-copy",c.textContent=a==="loading"?r.consultingStyleLoadingDescription:r.consultingStyleUnavailableDescription,o.appendChild(c),a==="loading"){const l=document.createElement("div");l.className="gengage-chat-consulting-loading-grid";for(let p=0;p<3;p+=1){const d=document.createElement("div");d.className="gengage-chat-consulting-loading-card",l.appendChild(d)}o.appendChild(l)}i.appendChild(o)}function Yt(t,e,a){const n=i=>a.consultingFallbackStyleLabel.replace("{index}",String(i));return t.style_label??n(e)}function Ya(t,e){const a=t.variations[e];if(!a)return;const{grid:n,ctx:i,i18n:r}=t;n.innerHTML="",n.classList.remove("gengage-chat-product-grid--consulting-groups");const o=Kt(a),s=e+1;if(o==="loading"){Er(t,a,"loading",s);return}if(o!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){Er(t,a,"unavailable",s);return}const c=Array.isArray(a.product_list)?a.product_list:[],l=Array.isArray(a.recommendation_groups)?a.recommendation_groups:[];if(l.length>0){n.classList.add("gengage-chat-product-grid--consulting-groups");const p=new Map;for(const u of c){const g=typeof u?.sku=="string"?u.sku:void 0;g&&p.set(g,u)}const d=(u,g,v,_)=>{if(g.length===0)return;const y=document.createElement("section");y.className="gengage-chat-consulting-group";const k=document.createElement("div");k.className="gengage-chat-consulting-group-header";const P=document.createElement("h4");if(P.className="gengage-chat-consulting-group-label",P.textContent=`${u} (${g.length})`,k.appendChild(P),typeof _=="string"&&_.trim().length>0){const E=document.createElement("p");E.className="gengage-chat-consulting-group-reason",E.textContent=_,k.appendChild(E)}y.appendChild(k);const w=document.createElement("div");w.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",v&&w.classList.add("gengage-chat-consulting-group-grid--single-group"),w.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,g.length))));for(const E of g){const z=$a({type:"ProductCard",props:{product:E}},i??{onAction:()=>{}});w.appendChild(z)}y.appendChild(w),n.appendChild(y)},h=new Set,f=[];for(const u of l){const g=(Array.isArray(u.skus)?u.skus.filter(y=>typeof y=="string"&&y.trim().length>0):[]).map(y=>(h.add(y),p.get(y))).filter(y=>!!y);if(g.length===0)continue;const v=typeof u.label=="string"&&u.label.trim().length>0?u.label:r.consultingFallbackGroupLabel,_=typeof u.reason=="string"?u.reason:void 0;f.push({labelText:v,products:g,..._!==void 0?{reasonText:_}:{}})}const b=c.filter(u=>{const g=typeof u?.sku=="string"?u.sku:"";return g.length>0&&!h.has(g)});b.length>0&&f.push({labelText:r.consultingOtherCompatibleProductsLabel,products:b});const m=f.length===1;for(const u of f)d(u.labelText,u.products,m,u.reasonText);return}for(const p of c){const d=$a({type:"ProductCard",props:{product:p}},i??{onAction:()=>{}});n.appendChild(d)}}function Qa(t,e,a,n){const i=Kt(e),r=n.consultingStyleLoadingBadge,o=n.consultingStyleUnavailableBadge;t.classList.remove("gengage-chat-consulting-style-btn--loading","gengage-chat-consulting-style-btn--muted"),i==="loading"?t.classList.add("gengage-chat-consulting-style-btn--loading"):i!=="ready"&&t.classList.add("gengage-chat-consulting-style-btn--muted"),t.setAttribute("aria-label",Yt(e,a+1,n));let s=t.querySelector(".gengage-chat-consulting-style-media");s?s.innerHTML="":(s=document.createElement("div"),s.className="gengage-chat-consulting-style-media",t.appendChild(s));const c=vd(e.image_url);if(c&&pe(c)){const p=document.createElement("img");p.className="gengage-chat-consulting-style-image",p.draggable=!1,he(p,"src",c),p.alt=Yt(e,a+1,n),p.loading="lazy",Ce(p),s.appendChild(p)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=Yt(e,a+1,n),s.appendChild(l),i==="loading"||i!=="ready"){const p=document.createElement("span");p.className="gengage-chat-consulting-style-status",p.textContent=i==="loading"?r:o,s.appendChild(p)}}function Pr(t,e,a,n){t.addEventListener("click",()=>{const i=xt.get(e);i&&i.selectedIndex!==n&&(i.selectedIndex=n,a.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((r,o)=>{r.classList.toggle("gengage-chat-consulting-style-btn--active",o===n)}),Ya(i,n))})}function yd(t,e,a,n){const i=Cr(n),r=Ka(a),o=document.createElement("div");o.className="gengage-chat-consulting-style-picker";const s={grid:e,ctx:n,variations:a,i18n:i,selectedIndex:r};xt.set(o,s);const c=document.createElement("div");c.className="gengage-chat-consulting-style-picker-title",c.textContent=Sr(i).replace("{count}",String(a.length)),o.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-consulting-style-grid",o.appendChild(l),a.forEach((p,d)=>{const h=document.createElement("button");h.type="button",h.className="gengage-chat-consulting-style-btn gds-card",d===r&&h.classList.add("gengage-chat-consulting-style-btn--active"),Qa(h,p,d,i),Pr(h,o,l,d),l.appendChild(h)}),t.appendChild(o),Ya(s,r)}function xd(t,e,a){const n=t.querySelector(".gengage-chat-consulting-style-picker"),i=_d(t);if(!n||!i)return!1;const r=n.querySelector(".gengage-chat-consulting-style-grid");if(!r)return!1;const o=Cr(a);let s=xt.get(n);if(s)s.grid=i,s.ctx=a,s.variations=e,s.i18n=o;else{const h={grid:i,ctx:a,variations:e,i18n:o,selectedIndex:Ka(e)};xt.set(n,h),s=h}const c=n.querySelector(".gengage-chat-consulting-style-picker-title");c&&(c.textContent=Sr(o).replace("{count}",String(e.length)));const l=s;let p=l.selectedIndex;p>=e.length&&(p=Math.max(0,e.length-1)),p<0&&(p=0),e.length>0&&Kt(e[p]??{})==="loading"&&(p=Ka(e)),l.selectedIndex=p;const d=[...r.querySelectorAll(".gengage-chat-consulting-style-btn")];if(d.length===0)return!1;for(let h=0;h<e.length;h+=1){const f=e[h];let b=d[h];b?Qa(b,f,h,o):(b=document.createElement("button"),b.type="button",b.className="gengage-chat-consulting-style-btn gds-card",Qa(b,f,h,o),Pr(b,n,r,h),r.appendChild(b),d[h]=b)}for(;r.querySelectorAll(".gengage-chat-consulting-style-btn").length>e.length;)r.lastElementChild?.remove();return r.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((h,f)=>{h.classList.toggle("gengage-chat-consulting-style-btn--active",f===l.selectedIndex)}),Ya(l,l.selectedIndex),!0}function _d(t){const e=[...t.children];for(let a=e.length-1;a>=0;a-=1){const n=e[a];if(n.classList.contains("gengage-chat-product-grid"))return n}return t.querySelector(":scope > .gengage-chat-product-grid")}var xt,wd=L((()=>{ge(),je(),bt(),kr(),xt=new WeakMap}));function Za(t){const e=typeof t.props?.source=="string"?t.props.source:void 0,a=(Array.isArray(t.props?.styleVariations)?t.props.styleVariations:[]).filter(n=>typeof n.style_label=="string"&&n.style_label.trim().length>0);return{isConsulting:ri(e)&&a.length>0,source:e,styleVariations:a}}function kd(t,e,a,n){yd(t,e,a.styleVariations,n)}function Cd(t){return!t.isConsulting||t.styleVariations.length===0?!0:t.styleVariations.some(e=>(typeof e.status=="string"?e.status:"ready")!=="loading")}function Sd(t,e,a){return!e.isConsulting||!e.source?!1:xd(t,e.styleVariations,a)}var Tr=L((()=>{wd(),oi()}));function Ed(t){const e=document.createElement("div");e.className="gengage-chat-launcher-container",e.dataset.gengagePart="chat-launcher-container";const a=document.createElement("div");a.className="gengage-chat-launcher-content-area",a.dataset.gengagePart="chat-launcher-content-primary",e.appendChild(a);const n=document.createElement("button");if(n.type="button",n.setAttribute("aria-label",t.ariaLabel??"Open chat"),t.imageUrl){n.className="gengage-chat-launcher gengage-chat-launcher--image-mode";const r=document.createElement("img");if(r.src=t.imageUrl,r.alt="",r.draggable=!1,t.mobileImageUrl){r.className="gengage-chat-launcher-img--desktop";const o=document.createElement("img");o.src=t.mobileImageUrl,o.alt="",o.draggable=!1,o.className="gengage-chat-launcher-img--mobile",n.appendChild(r),n.appendChild(o)}else n.appendChild(r)}else n.className="gengage-chat-launcher",n.innerHTML=t.svgMarkup??Ar;if(n.dataset.gengagePart="chat-launcher-button",t.tooltip!==void 0){const r=document.createElement("span");r.className="gengage-chat-launcher-tooltip",r.dataset.gengagePart="chat-launcher-tooltip",r.textContent=t.tooltip,n.appendChild(r)}t.hideMobile&&(e.dataset.hideMobile="1"),t.mobileBreakpoint!==void 0&&(e.dataset.mobileBreakpoint=String(t.mobileBreakpoint)),n.addEventListener("click",t.onClick),e.appendChild(n);const i=document.createElement("div");return i.className="gengage-chat-launcher-content-area-bottom",i.dataset.gengagePart="chat-launcher-content-secondary",e.appendChild(i),{container:e,button:n,contentArea:a,contentAreaBottom:i}}var Ar,Pd=L((()=>{Ar=`<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"/>
|