@gengage/assistant-fe 0.6.45 → 0.6.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/types.d.ts +6 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +2 -2
- package/dist/chat.js +1 -1
- package/dist/{common-BqApfsJV.js → common-BYaIofv0.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-B829KlSR.js → connection-warning-BWCgMHwN.js} +1 -1
- package/dist/{fastIntent-DtopsdAD.js → fastIntent-BfYLNhFF.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +2 -2
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{request-response-cache-DIu22gmN.js → request-response-cache-DxtNGhlh.js} +1 -1
- package/dist/{runtime-Dly7YrGI.js → runtime-B9k46n2p.js} +3 -3
- package/dist/{runtime-5Iu4s-BA.js → runtime-DBmJg9TG.js} +6 -4
- package/dist/{runtime-BmIfwBR6.js → runtime-IlZ-GH68.js} +3 -3
- package/dist/{simbut-DN8UCH7t.js → simbut-CobYs9jE.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-DGfunNnJ.js → simrel-BEyFl3Ec.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-DH9dsYIO.js → widget-base-BsHKmSMq.js} +1 -1
- package/package.json +1 -1
package/dist/native.iife.js
CHANGED
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,document.head.appendChild(t)}var He,xa,Bt,$n,Vn,Gn,Wn,_a,je,Kn,it=P((()=>{Ke(),Bs(),He="gengage-global-toast-root",xa="gengage-global-toast-style",Bt="gengage-global-toast-root--visible",$n=4200,Vn=1500,Gn=15e3,Wn=["--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"],_a=!1,je=null,Kn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i]}));function qs(){if(rt!==null)return rt;try{rt=localStorage.getItem("gengage:debug")==="1"}catch{rt=!1}return rt}function Re(t,e,a){if(!qs())return;const n=[`[gengage:${t}]`,e];a!==void 0&&n.push(a),console.debug(...n)}var rt,ot=P((()=>{rt=null}));function Os(){if(typeof window>"u")return;const t=window;t.__gengageSdkRuntimeInfoLogged||(t.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${Yn} (${Qn})`))}var Yn,Qn,js=P((()=>{Yn=("0.6.
|
|
48
|
-
`);i=f.pop()??"";for(const b of f)if(ii(b,e))return}if(i.trim()&&ii(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 wa=P((()=>{ot()}));function nc(t){const e=(t.display_keywords??[]).flatMap(i=>Ft(i,{stripLeadingStopWords:!0})),a=e.filter((i,r)=>e.indexOf(i)===r);if(a.length>0)return a.slice(0,ka);const n=[...Ft(t.chosen_attribute,{stripLeadingStopWords:!0}),...Ft(t.short_name)];return n.filter((i,r)=>n.indexOf(i)===r).slice(0,ka)}function ic(t){return nc(t).join(" • ")}var ka,ri,Ft,rc=P((()=>{ka=3,ri=(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():""},Ft=(t,e)=>t?t.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>ri(a,e)).filter(Boolean):[]}));function oi(t){return t==="beauty_consulting"||t==="account_expert"}var si=P((()=>{}));function ft(...t){for(const e of t){if(typeof e!="string")continue;const a=e.trim();if(a.length>0)return a}}function bt(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim()):[]}function ct(t){const e={...t},a=ft(e.sku),n=bt(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=ft(e.image_url);i?e.image_url=i:delete e.image_url}return e}var Ca=P((()=>{}));function Dt(t){if(typeof t.type!="string")return null;if(oc(t))return t;const e=t;switch(e.type){case"outputText":return sc(e);case"suggestedActions":return cc(e);case"productList":return lc(e);case"productDetails":return gc(e);case"productDetailsSimilars":return dc(e);case"comparisonTable":return pc(e);case"context":return fc(e);case"chatStreamEnd":return bc();case"loading":return vc(e);case"panelLoading":return yc(e);case"similarLoading":return xc(e);case"redirect":return _c(e);case"error":return wc(e);case"dummy":return kc(e);case"launcherAction":return Cc(e);case"text":return Sa(e);case"productItem":return Sc(e);case"text_image":return ci(e);case"quick_qna":return li(e);case"reviewHighlights":return Ec(e);case"aiProductSuggestions":return Ac(e);case"aiProductGroupings":return Lc(e);case"aiSuggestedSearches":return Mc(e);case"prosAndCons":return Tc(e);case"getGroundingReview":return Bc(e);case"voice":return zc(e);case"visitorDataResponse":return Pc(e);case"productListPreview":return Rc();case"groupList":return Hc(e);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Fc(e);case"launcherContent":return Uc(e);case"handoff":return Dc(e);case"uiSpec":return Yc(e);default:return null}}function oc(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=_e(t.spec);return n?typeof n.root=="string"&&_e(n.elements)!==null:!1}case"action":{const a=_e(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 sc(t){const e=te(t.payload.text,t.payload.plain_text)??"",a=te(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.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const r=t.payload.product_mentions;Array.isArray(r)&&r.length>0&&(n.productMentions=r.map(c=>{if(typeof c!="object"||c===null||typeof c.sku!="string")return null;const l=typeof c.short_name=="string"?c.short_name:"";if(!l)return null;const g=(typeof c.url=="string"&&c.url.trim()?c.url.trim():void 0)??(()=>{const d=n.skuToProductItem?.[c.sku];return typeof d?.url=="string"&&d.url.trim()?d.url.trim():void 0})();return g?{sku:c.sku,short_name:l,url:g}:{sku:c.sku,short_name:l}}).filter(c=>c!==null));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 cc(t){return gi((t.payload.actions??[]).map(e=>{const a=te(e.title)??"",n=Te(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(yt),"chat")}function lc(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=te(s.style_label);if(!c)return null;const l=te(s.style_mood),g=te(s.image_url??void 0),d=(Array.isArray(s.product_list)?s.product_list:[]).map(f=>{const b=_e(f);return b?Pa(_e(b.product_detail)??_e(b.product)??b):null}).filter(yt),h=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(f=>({label:te(f.label)??"",reason:te(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??"",...g?{image_url:g}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:d,recommendation_groups:h}}).filter(yt),n=t.payload.product_list??[],i=oi(t.payload.source)&&a.length>0?a[0].product_list:null,r=i?Oc(i,"chat"):e.length>0?qc(e,n,"chat")??Ta(n,"chat"):Ta(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 gc(t){const e=t.payload.productDetails;if(!e)return $c("chat");const a=De(e);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...e,...a}}}}},panelHint:"panel"}}function dc(t){const e=Ta(t.payload.similarProducts??[],"chat"),a=e.spec.elements[e.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...e,panelHint:"panel"}}function pc(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 p=De(u);o.push(p)}const s=hc(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],g=[];if(Array.isArray(n?.key_differences))for(const u of n.key_differences)typeof u=="string"&&g.push(u);const d=di(n?.special_considerations),h=n?.recommended_choice,f=n?.winner_hits,b={};for(const u of o){const p=u.sku;p&&(b[p]={title:u.name??p,type:"launchSingleProduct",payload:{sku:p}})}const m={products:o,attributes:s,highlights:g,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 hc(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(p=>typeof p=="string"?p:String(p??""))})}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:uc(o)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),g=[];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`],p=m[d];return mc(u??p)});if(h.every(b=>b.length===0))continue;const f=c[d]??d;g.push({label:f,values:h})}return g}function uc(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 mc(t){return typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):""}function fc(t){return{type:"metadata",sessionId:"",model:"",meta:{panel:t.payload.panel,messages:t.payload.messages,message_id:t.payload.message_id}}}function bc(){return{type:"done"}}function vc(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 yc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function xc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function _c(t){const e=te(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:te(t.payload.to)}}}function wc(t){return{type:"error",code:"BACKEND_ERROR",message:te(t.payload?.text,t.payload?.message,t.payload?.error)??"Backend returned an error"}}function kc(t){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Cc(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),li({type:"quick_qna",payload:i})}const a=_e(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),ci({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=_e(e.payload)??void 0;return r!==void 0&&(i.type=r),s!==void 0&&(i.payload=s),o!==void 0&&(i.theme=o),Sa({type:"text",payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:e}}}function Sa(t){const e={text:te(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 Sc(t){return jc(t.payload,"qna")}function ci(t){const e=te(t.payload.text)??"",a=Te(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),Sa({type:"text",payload:n})}function li(t){return gi((t.payload.action_list??[]).map(e=>{const a=te(e.title)??"",n=Te(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(yt),"qna")}function Ec(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 Tc(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 Pc(t){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:t.payload}}}function Ac(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=Vc(i);if(!r)continue;const o={product:r},s=Te(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 Lc(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=te(r.name)??"",s=te(r.description),c=te(r.highlight),l=Array.isArray(r.labels)?di(r.labels):[],g=te(r.sku,r.repr_sku),d=te(r.image,r.repr_image),h=Ic(r,o,g),f=(Array.isArray(r.group_products)?r.group_products:[]).map(u=>{const p=_e(u);return p?Pa(p):null}).filter(yt),b=d??te(...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 Ic(t,e,a){const n=_e(t.requestDetails);if(n){if(n.type!=="findSimilar")return Te(n,e);const o={..._e(n.payload)??{}};a&&!ft(o.sku)&&(o.sku=a);const s=bt(t.group_skus);return s.length>0&&(o.group_skus=s),Te({...n,payload:ct(o)},e)}const i={};a&&(i.sku=a);const r=bt(t.group_skus);return r.length>0&&(i.group_skus=r),Object.keys(i).length===0?null:Te({type:"findSimilar",payload:ct(i)},e)}function Nc(t,e){const a=_e(t.requestDetails),n=_e(a?.payload),i=te(t.detailed_user_message),r=t.group_skus&&Array.isArray(t.group_skus)?bt(t.group_skus):bt(n?.group_skus),o=te(t.sku,t.representative_product_sku,n?.sku);if(a?.type==="findSimilar"){const c={...n??{}};return o&&(c.sku=o),r.length>0&&(c.group_skus=r),i&&(c.input=i,ft(c.text)||(c.text=i)),c.is_search_suggestion=1,Te({...a,payload:ct(c)},e)}if(o){const c={sku:o,is_search_suggestion:1};return r.length>0&&(c.group_skus=r),i&&(c.input=i,c.text=i),Te({type:"findSimilar",payload:ct(c)},e)}const s={...n??{},is_suggested_text:1,is_search_suggestion:1};return i&&!ft(s.text)&&(s.text=i),r.length>0&&(s.group_skus=r),Te(a?.type==="inputText"?{...a,payload:s}:{type:"inputText",payload:s},e)}function Mc(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=te(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Search ${n+1}`,o=Nc(i,r);if(!o)continue;const s={shortName:r,action:o},c=te(i.detailed_user_message);c&&c!==r&&(s.detailedMessage=c);const l=ic(i);l&&l!==r&&l!==(c??"")&&(s.whyDifferent=l),typeof i.image=="string"&&(s.image=i.image),a.push(s)}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 Bc(t){const e=t.payload,a=Te(e.requestDetails??e.request_details,te(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 Rc(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function zc(t){return{type:"metadata",sessionId:"",model:"",meta:{voice:t.payload}}}function Hc(t){const e=t.payload.group_list??[],a=[];for(const i of e){const r=i.group_name??"",o=(i.product_list??[]).map(De);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=Te(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 Fc(t){return{type:"metadata",sessionId:"",model:"",meta:{formType:t.type,formPayload:t.payload??{}}}}function Dc(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 Uc(t){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:t.payload??{}}}}function Ea(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 gi(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 Ta(t,e){const a={},n=[];for(let i=0;i<t.length;i++){const r=t[i];if(!r)continue;const o=De(r),s=`product-${i}`;n.push(s),a[s]=Ea(o,i)}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function qc(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 g=t[l],d=te(g?.title)??"",h=Array.isArray(g?.skus)?g.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 p=`product-${l}-${b}`,y=De(u);o.push(p),f.push(p),r[p]=Ea(y,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 Oc(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]=Ea(r,i)}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function jc(t,e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:De(t),index:0}}}}}}function $c(t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Vc(t){const e=te(t.sku),a=te(t.short_name),n={..._e(t.product_item)??t},i=te(t.discount_reason,t.discountReason);return i&&!te(n.discount_reason,n.discountReason)&&(n.discount_reason=i),Pa(n,e,a)}function Pa(t,e,a){const n=te(t.sku,e),i=te(t.name,a);if(!n||!i)return null;const r={sku:n,name:i},o=te(t.brand);o&&(r.brand=o);const s=te(t.url);s&&(r.url=s);const c=Gc(t.images);if(c.length>0)r.images=c;else{const m=te(t.image,t.image_url,t.imageUrl);m&&(r.images=[m])}const l=vt(t.price_discounted);l!==void 0&&(r.price_discounted=l);const g=vt(t.price);g!==void 0&&(r.price=g);const d=vt(t.rating);d!==void 0&&(r.rating=d);const h=vt(t.review_count)??vt(t.reviewCount);h!==void 0&&(r.review_count=h);const f=te(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=te(t.discount_reason,t.discountReason);return b&&(r.discount_reason=b),De(r)}function Te(t,e){const a=_e(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 _e(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function te(...t){for(const e of t)if(typeof e=="string"){const a=e.trim();if(a.length>0)return a}}function Gc(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):[]}function di(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 vt(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 yt(t){return t!=null}function De(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=te(t.brand),o=te(t.name)??t.sku,s=r&&!o.toLowerCase().startsWith(r.toLowerCase())?`${r} ${o}`:o,c={sku:t.sku,name:s,url:te(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 g=t,d={};let h=!1;for(const f of Object.keys(g))pi.has(f)||(d[f]=g[f],h=!0);return h&&(c.extras=d),c}function Wc(t){return t.results.map(De)}function Kc(t){return t.product_groupings.map(e=>{const a={name:e.name,products:(e.group_products??[]).map(De)};return e.highlight!==void 0&&(a.highlight=e.highlight),a})}function Yc(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 pi,Aa=P((()=>{rc(),si(),Ca(),pi=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 Qc(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 Ut(t,e){return`${Qc(e?.middlewareUrl)}/chat${hi[t]}`}var hi,La=P((()=>{hi={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"}}));function Zc(t){if(!(typeof window>"u"||!t))try{const e=window.GengageAssistantInjector?.[t]?.streamTransport;return typeof e=="function"?e:void 0}catch{return}}var Xc=P((()=>{}));async function qt(t,e={},a={}){const n=Jc(t,e);if(!n)return fetch(t,e);const i=Date.now(),r=await nl(n,i);if(r)return ol(r);const o=await fetch(t,e);return o.ok&&il(n,o.clone(),i,{ttlMs:a.ttlMs??vi,maxEntries:a.maxEntries??Ma,maxBodyBytes:a.maxBodyBytes??yi}),o}function Jc(t,e={}){if(typeof Request<"u"&&t instanceof Request)return null;const a=String(e.method||"GET").toUpperCase();if(a!=="POST"||typeof e.body!="string")return null;const n=el(e.body);if(tl(n))return null;const i=al(n);if(i){const r=xt(n?.action);return`rr:${bi(fi({url:String(t),method:a,headers:ui(e.headers),type:n?.type??r?.type??"",account_id:n?.account_id??n?.accountId??"",locale:n?.locale??"",outputLanguage:xt(n?.meta)?.outputLanguage??"",cache_key:i}))}`}return`rr:${bi(fi({url:String(t),method:a,headers:ui(e.headers),body:e.body}))}`}function el(t){try{const e=JSON.parse(t);return!e||typeof e!="object"||Array.isArray(e)?null:e}catch{return null}}function tl(t){const e=t?.type;return typeof e=="string"&&wi.has(e)}function al(t){const e=(xt(t?.payload)??xt(xt(t?.action)?.payload))?.cache_key;return typeof e=="string"&&e.trim().length>0?e.trim():null}async function nl(t,e){const a=Ne.get(t);if(a)if(a.expiresAt<=e)Ne.delete(t);else return a.lastAccessedAt=e,Ne.delete(t),Ne.set(t,a),Ia(a),a;const n=await cl(t);return n?n.expiresAt<=e?(Ne.delete(t),ll(t),null):(n.lastAccessedAt=e,Ne.set(t,n),Ia(n),mi(Ma),n):null}async function il(t,e,a,n){try{const i=await e.text();if(dl(i)>n.maxBodyBytes||rl(i))return;const r={key:t,status:e.status,statusText:e.statusText,headers:sl(e.headers),body:i,createdAt:a,expiresAt:a+n.ttlMs,lastAccessedAt:a};Ne.set(t,r),mi(n.maxEntries),await Ia(r),await gl(n.maxEntries,a)}catch{}}function rl(t){return/"_error"\s*:/u.test(t)||/"type"\s*:\s*"error"/u.test(t)}function ol(t){return new Response(t.body,{status:t.status,statusText:t.statusText,headers:new Headers(t.headers)})}function ui(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 sl(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 mi(t){for(;Ne.size>t;){const e=[...Ne.values()].sort((a,n)=>a.lastAccessedAt-n.lastAccessedAt)[0];if(!e)break;Ne.delete(e.key)}}async function Ot(){return typeof indexedDB>"u"?null:(Ba??=new Promise(t=>{const e=indexedDB.open(xi,_i);e.onupgradeneeded=()=>{const a=e.result;a.objectStoreNames.contains(Ie)||a.createObjectStore(Ie,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},e.onsuccess=()=>t(e.result),e.onerror=()=>t(null),e.onblocked=()=>t(null)}),Ba)}async function cl(t){const e=await Ot();return e?new Promise(a=>{const n=e.transaction(Ie,"readonly"),i=n.objectStore(Ie).get(t);i.onsuccess=()=>a(i.result??null),i.onerror=()=>a(null),n.onerror=()=>a(null)}):null}async function Ia(t){const e=await Ot();e&&await new Promise(a=>{const n=e.transaction(Ie,"readwrite");n.objectStore(Ie).put(t),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function ll(t){const e=await Ot();e&&await new Promise(a=>{const n=e.transaction(Ie,"readwrite");n.objectStore(Ie).delete(t),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function gl(t,e){const a=await Ot();a&&await new Promise(n=>{const i=a.transaction(Ie,"readwrite"),r=i.objectStore(Ie),o=[],s=r.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const l=o.filter(d=>d.expiresAt<=e),g=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,...g])r.delete(d.key);return}o.push(c.value),c.continue()},s.onerror=()=>n(),i.oncomplete=()=>n(),i.onerror=()=>n(),i.onabort=()=>n()})}function fi(t){return JSON.stringify(Na(t))}function xt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Na(t){return Array.isArray(t)?t.map(Na):!t||typeof t!="object"?t:Object.fromEntries(Object.entries(t).sort(([e],[a])=>e.localeCompare(a)).map(([e,a])=>[e,Na(a)]))}function bi(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 dl(t){return typeof TextEncoder<"u"?new TextEncoder().encode(t).byteLength:t.length}var vi,Ma,yi,xi,_i,Ie,wi,Ne,Ba,Ra=P((()=>{vi=7200*1e3,Ma=200,yi=5*1024*1024,xi="gengage_request_response_cache",_i=1,Ie="responses",wi=new Set(["addToCart","like"]),Ne=new Map,Ba=null}));function pl(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=e.genericNonPdpLaunch===!0&&e.pageContext?.pageType!=="pdp"&&(o.is_entry_question===1||o.is_entry_question===!0),c=o.is_search_suggestion===1||o.is_search_suggestion===!0,l={is_launcher:0};if(!s&&e.pageContext?.extra&&(l.page_details=e.pageContext.extra),!s&&!c&&!r&&!("sku_list"in o)){const d=e.pageContext?.skuList&&e.pageContext.skuList.length>0?e.pageContext.skuList:e.pageContext?.sku?[e.pageContext.sku]:void 0;d&&d.length>0&&(l.sku_list=d)}"is_suggested_text"in o||(l.is_suggested_text=0);const g={...o};for(const[d,h]of Object.entries(l))d in g||(g[d]=h);return{...t,payload:g}}case"findSimilar":{const r={is_launcher:0};return t.title&&(r.text=t.title,r.input=t.title),{...t,payload:ct(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 ki(t){const{action:e,type:a,payload:n,...i}=t,r=a??e?.type??"inputText",o=n??e?.payload,s=Si[r]??r,c={...i,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function hl(t){return JSON.parse(ki(t))}function ul(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Ci(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 ml(t,e,a){const n=new AbortController,i=a.injectorAdapter??Zc(a.accountId);return i?((async()=>{const o=Ci(e,n.signal);try{if(await Promise.resolve(),n.signal.aborted)return;const s=i(hl(t),o.callbacks,n.signal,a.attachment);ul(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=Ut("process_action",a),s=ki(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 g=c?await fetch(o,l):await qt(o,l);if(!g.ok){let h=g.statusText;try{const f=await g.json(),b=f.detail??f.message??f.error;typeof b=="string"&&(h=b)}catch{}e.onError(new Error(`HTTP ${g.status}: ${h}`));return}const d=Ci(e);await Ht(g,{onEvent:h=>{const f=Dt(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 Si,fl=P((()=>{wa(),Aa(),La(),Xc(),Ca(),Ra(),Si={user_message:"inputText"}}));function bl(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search);if(Ei.some(e=>t.get(e)==="1"))return!0;try{return Ti.some(e=>window.localStorage.getItem(e)==="1")}catch{return!1}}function vl(t,e,a){if(!bl())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 Ei,Ti,yl=P((()=>{Ei=["chat_debug","presentation_debug"],Ti=["gengage_chat_debug","gengage_presentation_debug"]}));function Pi(t){Ye=t}function xl(){if(Ye&&Ye.isConnected)return Ye;Ye=null;const t=document.getElementById(_t);return t||(vl("chat-scroll","failed to resolve scroll container (not registered)",{id:_t}),null)}function Ai(){Ye=null}var _t,Ye,Li=P((()=>{yl(),_t="gengage-chat-scroll",Ye=null})),Qe,_l=P((()=>{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",addingToCartToast:"Sepete ekleniyor...",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"}})),Ii,wl=P((()=>{Ii={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",addingToCartToast:"Adding 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 kl(t){return t?t.toLowerCase().split("-")[0]??"tr":"tr"}function Cl(t){return kl(t)==="en"?Ii:Qe}var wt=P((()=>{_l(),wl()}));function Sl(){return Ni()!==null}function Ni(){const t=globalThis;return t.SpeechRecognition??t.webkitSpeechRecognition??null}function El(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 Mi,Tl=P((()=>{Mi=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=Ni();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=El(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 Pl(t){const e=document.createElement("div");e.className="gengage-chat-kvkk-banner",e.dataset.gengagePart="kvkk-banner",e.setAttribute("role","note");const a=document.createElement("div");return a.className="gengage-chat-kvkk-content",a.dataset.gengagePart="kvkk-content",a.innerHTML=xe(t.htmlContent),e.appendChild(a),e}var Al=P((()=>{pe()})),Bi,Ll=P((()=>{Bi=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 Il(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 Ri(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 g=document.createElement("p");g.className="gengage-chat-beauty-photo-step-desc",g.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(g),c.appendChild(d),o.appendChild(s),o.appendChild(c),o}var za=P((()=>{wt()}));function Nl(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 Ml(t,e,a,n,i){if(!a.visible)return t&&(t.hidden=!0,t.innerHTML=""),t;const r=Nl(t,e);r.hidden=!1,r.innerHTML="";const o=Ri({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 Bl=P((()=>{za()}));function zi(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 Hi(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 Fi(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=Hi(t.strengths,e.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=Hi(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 g=document.createElement("p");if(g.className="gengage-chat-photo-analysis-celeb-name",g.textContent=e.celebStyle,c.appendChild(l),c.appendChild(g),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 Rl(t){const e={...Qe,...t?.i18n??{}};return{badge:e.photoAnalysisBadge,strengths:e.photoAnalysisStrengthsLabel,focus:e.photoAnalysisFocusLabel,celebStyle:e.photoAnalysisCelebStyleLabel}}function zl(t,e){const a=zi(t.props??{})??{summary:""};return Fi(Rl(e),a)}function Hl(t,e,a){t.innerHTML="",a&&t.appendChild(Fi(e,a))}var Ha=P((()=>{wt()}));async function Fl(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(qi)?.[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 Dl(t){try{const e=t??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return e?Fl(await e):null}catch{}return null}var Fa,Da,Di,Ui,Ua,qi,Oi,Ul=P((()=>{Li(),pe(),Ke(),wt(),Tl(),zt(),Al(),Ll(),Bl(),Ha(),Fa='<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>',Da={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>'},Di=Qe,Ui=1400,Ua=1500,qi=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi,Oi=class{_renderPhotoAnalysisCard(t,e){Hl(t,{badge:this.i18n.photoAnalysisBadge,strengths:this.i18n.photoAnalysisStrengthsLabel,focus:this.i18n.photoAnalysisFocusLabel,celebStyle:this.i18n.photoAnalysisCelebStyleLabel},e)}_createLegacyHeaderPoweredBy(){const t=typeof this.i18n.poweredBy=="string"?this.i18n.poweredBy.trim():"";if(!t)return null;const e=document.createElement("a");return e.className="gengage-chat-header-powered",e.dataset.gengagePart="chat-header-powered-by",e.href="https://gengage.ai/",e.target="_blank",e.rel="noopener noreferrer",e.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>${t}`,e}_createFooterAttribution(){const t=document.createElement("div");t.className="gengage-chat-footer",t.dataset.gengagePart="chat-footer";const e=this._options.footerAttribution,a=typeof e?.label=="string"?e.label.trim():"",n=typeof e?.href=="string"?e.href.trim():"",i=typeof this.i18n.poweredBy=="string"?this.i18n.poweredBy.trim():"",r=a||i;if(!r)return null;if(n&&de(n)){const o=document.createElement("a");return o.className="gengage-chat-footer-link",o.dataset.gengagePart="chat-footer-link",o.href=n,o.target=e?.target||"_blank",o.rel=e?.rel||"noopener noreferrer",o.textContent=r,typeof e?.ariaLabel=="string"&&e.ariaLabel.trim()&&o.setAttribute("aria-label",e.ariaLabel.trim()),t.appendChild(o),t}return t.textContent=r,t}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._cartToastEl=null,this._cartToastTimerId=null,this._options=e,this.i18n={...Di,...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 C=document.createElement("div");C.className="gengage-chat-drawer-handle",C.dataset.gengagePart="chat-drawer-handle",C.setAttribute("aria-hidden","true"),C.style.pointerEvents="none",i=C}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 C=document.createElement("img");C.className="gengage-chat-header-avatar",c&&C.classList.add("gengage-chat-header-avatar--logo"),C.dataset.gengagePart="chat-header-avatar",C.src=s,C.alt=e.headerTitle??"Assistant",o.appendChild(C)}const l=document.createElement("div");l.className="gengage-chat-header-info",l.dataset.gengagePart="chat-header-info";const g=document.createElement("div");g.className="gengage-chat-header-title-row",g.dataset.gengagePart="chat-header-title-row";const d=document.createElement("span");if(d.className="gengage-chat-header-title",d.dataset.gengagePart="chat-header-title",d.textContent=e.headerTitle??this.i18n.headerTitle??"Product Expert",g.appendChild(d),e.headerBadge){const C=document.createElement("span");C.className="gengage-chat-header-badge gds-badge gds-badge-brand",C.dataset.gengagePart="chat-header-badge",C.textContent=e.headerBadge,g.appendChild(C)}if(l.appendChild(g),e.footerAttribution===void 0){const C=this._createLegacyHeaderPoweredBy();C&&l.appendChild(C)}o.appendChild(l),r.appendChild(o);const h=document.createElement("div");h.className="gengage-chat-header-right",h.dataset.gengagePart="chat-header-actions";{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-reopen-panel",C.setAttribute("aria-label",this.i18n.showPanelAriaLabel),C.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>',C.addEventListener("click",()=>this._showMobilePanelFromBtn()),h.appendChild(C),this._reopenPanelBtn=C}if(e.headerCartUrl||e.onCartClick){const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--cart gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-cart",C.setAttribute("aria-label",this.i18n.cartAriaLabel),C.title=this.i18n.cartAriaLabel,C.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>',C.addEventListener("click",()=>e.onCartClick?.()),h.appendChild(C),this._cartBtn=C}if(e.onHistoryClick){const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--history gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-history",C.setAttribute("aria-label",this.i18n.historyAriaLabel),C.title=this.i18n.historyAriaLabel,C.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>',C.addEventListener("click",()=>e.onHistoryClick?.()),h.appendChild(C)}if(e.onNewChat){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-new-chat gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-new-chat",C.type="button",C.setAttribute("aria-label",this.i18n.newChatButton),C.title=this.i18n.newChatButton,C.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>',C.addEventListener("click",()=>e.onNewChat?.()),h.appendChild(C)}const f=document.createElement("button");if(f.className="gengage-chat-close gds-btn gds-btn-ghost gds-icon-btn",f.dataset.gengagePart="chat-header-close",f.type="button",f.setAttribute("aria-label",this.i18n.closeButton),f.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>',f.addEventListener("click",e.onClose),e.showHeaderFavorites){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-header-btn--fav gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-favorites",C.type="button",C.setAttribute("aria-label",this.i18n.favoritesAriaLabel),C.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 W=document.createElement("span");W.className="gengage-chat-header-fav-badge",W.dataset.gengagePart="chat-header-favorites-badge",W.setAttribute("aria-hidden","true"),W.style.display="none",C.appendChild(W),this._favBadgeEl=W,C.addEventListener("click",()=>{e.onFavoritesClick?.()}),h.appendChild(C)}h.appendChild(f),i&&r.insertBefore(i,r.firstChild),r.appendChild(h);{let W=0,ge=0,ce=!1;const N=V=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||V.target.closest('button, a, input, [role="button"]'))return;const G=V.changedTouches?.[0];G&&(W=G.clientY,ge=0,ce=!0,this.root.style.transition="none")},U=V=>{if(!ce)return;const G=V.changedTouches?.[0];if(!G)return;ge=G.clientY-W;const J=(e.getMobileState?.()??"full")==="full"?Math.max(0,ge):ge;V.preventDefault(),this.root.style.transform=`translateY(${J}px)`},ne=()=>{if(!ce)return;ce=!1;const V=e.getMobileState?.()??"full";let G;ge>72?G=V==="full"?"half":"close":ge<-72&&V==="half"?G="full":G=V,this.root.style.transition="",G==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",e.onMobileSnap?.("close")},280)):(this.root.style.transform="",e.onMobileSnap?.(G)),ge=0},ve=()=>{ce&&(ce=!1,ge=0,this.root.style.transition="",this.root.style.transform="")};r.addEventListener("touchstart",N,{passive:!0}),r.addEventListener("touchmove",U,{passive:!1}),r.addEventListener("touchend",ne,{passive:!0}),r.addEventListener("touchcancel",ve,{passive:!0}),this._cleanups.push(()=>{r.removeEventListener("touchstart",N),r.removeEventListener("touchmove",U),r.removeEventListener("touchend",ne),r.removeEventListener("touchcancel",ve)})}const b=document.createElement("div");b.className="gengage-chat-body",b.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 Bi({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 m=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",m,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",m)),b.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.dataset.gengagePart="chat-panel-divider",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel);const u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",u.dataset.gengagePart="chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),u.setAttribute("title",this.i18n.togglePanelAriaLabel),u.textContent="»",u.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let p=null,y=null;const _=24,v=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const W=C.changedTouches?.[0];W&&(p=W.clientX,y=W.clientY)},w=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||p===null||y===null)return;const W=C.changedTouches?.[0];if(!W)return;const ge=W.clientX-p,ce=W.clientY-y;if(p=null,y=null,Math.abs(ce)<_||Math.abs(ce)<Math.abs(ge))return;const N=ce<0;N!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(N),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",v,{passive:!0}),this._dividerEl.addEventListener("touchend",w,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",v),this._dividerEl.removeEventListener("touchend",w)}),this._dividerEl.appendChild(u),b.appendChild(this._dividerEl);const E=document.createElement("div");E.className="gengage-chat-conversation",E.dataset.gengagePart="chat-conversation",this._conversationEl=E,E.appendChild(r);const k=document.createElement("div");k.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",k.dataset.gengagePart="chat-offline-bar",k.setAttribute("role","status"),k.setAttribute("aria-live","polite"),k.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&k.classList.add("gengage-chat-offline-bar--visible"),E.appendChild(k);const T=()=>k.classList.add("gengage-chat-offline-bar--visible"),z=()=>k.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",T),window.addEventListener("online",z),this._cleanups.push(()=>{window.removeEventListener("offline",T),window.removeEventListener("online",z)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",E.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=_t,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),Pi(this.messagesEl);const O=document.createElement("button");O.type="button",O.className="gengage-chat-former-messages-btn gds-chip",O.dataset.gengagePart="chat-former-messages-button",O.textContent=this.i18n.showFormerMessagesButton,O.setAttribute("aria-label",this.i18n.showFormerMessagesButton),O.style.display="none",O.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(O),this._formerMessagesBtn=O;const Z=()=>{this._userInteractionUntil=Date.now()+2e3};let le=!1;const se=()=>this._options.presentation,A=()=>{le||(le=!0,requestAnimationFrame(()=>{le=!1;const{scrollTop:C,scrollHeight:W,clientHeight:ge}=this.messagesEl,ce=W-C-ge;this._userScrolledUp=ce>10;const N=this._presentationPinned?ce<96:ce<32,U=Date.now(),ne=U<this._programmaticScrollUntil,ve=!N&&U<this._userInteractionUntil,V=ne?!1:ve;N!==this._presentationPinned&&(this._presentationPinned=N,se()?.onPinnedToBottomChange?.(N)),V!==this._presentationUserInteracting&&(this._presentationUserInteracting=V,se()?.onUserInteractingChange?.(V))}))};this.messagesEl.addEventListener("scroll",A,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",A)});const F=C=>{Z(),C.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",F,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",F));const S=C=>{Z(),this._touchStartY=C.touches[0]?.clientY??null},M=C=>{Z();const W=C.touches[0]?.clientY,ge=this._touchStartY;typeof W=="number"&&typeof ge=="number"&&W-ge>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",S,{passive:!0}),this.messagesEl.addEventListener("touchmove",M,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",S),this.messagesEl.removeEventListener("touchmove",M)}),E.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 B=document.createElement("div");B.className="gengage-chat-pills-scroll",B.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(B);const D=document.createElement("button");D.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",D.dataset.gengagePart="chat-suggestion-pills-more",D.type="button",D.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),D.textContent="›",D.addEventListener("click",()=>{B.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(D);let H=!1;const ie=()=>{H||(H=!0,requestAnimationFrame(()=>{H=!1;const C=B.scrollLeft+B.clientWidth>=B.scrollWidth-4;D.style.display=C?"none":""}))};B.addEventListener("scroll",ie,{passive:!0}),this._cleanups.push(()=>{B.removeEventListener("scroll",ie)}),E.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",E.appendChild(this._inputChipsEl);const X=document.createElement("div");X.className="gengage-chat-input-area",X.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",C=>{C.key==="Enter"&&!C.isComposing&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!C.shiftKey)&&(C.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",C=>{const W=C.clipboardData;if(!W)return;let ge=null;const ce=W.files?.[0];if(ce&&ce.type.startsWith("image/"))ge=ce;else if(W.items?.length)for(let N=0;N<W.items.length;N++){const U=W.items[N];if(U?.kind==="file"&&U.type.startsWith("image/")){const ne=U.getAsFile();if(ne){ge=ne;break}}}ge&&(C.preventDefault(),this._routeAttachmentFile(ge))}),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 C=this._fileInput.files?.[0];C&&this._routeAttachmentFile(C),this._fileInput.value=""});const K=document.createElement("div");K.className="gengage-chat-attach-wrap",K.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=K;const x=document.createElement("button");this._attachBtn=x,x.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",x.dataset.gengagePart="chat-attach-button",x.type="button",x.setAttribute("aria-label",this.i18n.attachImageButton),x.setAttribute("aria-haspopup","menu"),x.setAttribute("aria-expanded","false"),x.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>',x.addEventListener("click",C=>{C.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 L=document.createElement("button");L.type="button",L.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",L.dataset.gengagePart="chat-attach-menu-select-photo",L.setAttribute("role","menuitem"),L.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>`,L.addEventListener("click",C=>{C.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const R=document.createElement("div");R.className="gengage-chat-attach-menu-sep",R.dataset.gengagePart="chat-attach-menu-separator",R.setAttribute("aria-hidden","true");const q=document.createElement("button");q.type="button",q.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",q.dataset.gengagePart="chat-attach-menu-paste",q.setAttribute("role","menuitem"),q.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>`,q.addEventListener("click",C=>{C.stopPropagation();const W=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(W)}),I.appendChild(L),I.appendChild(R),I.appendChild(q),K.appendChild(x),K.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 j=document.createElement("img");j.className="gengage-chat-attachment-preview-thumb",j.dataset.gengagePart="chat-attachment-preview-thumb",j.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const $=document.createElement("button");$.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",$.dataset.gengagePart="chat-attachment-preview-remove",$.type="button",$.setAttribute("aria-label",this.i18n.removeAttachmentButton),$.textContent="×",$.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(j),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild($),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 C=this._sendStopHandler;this.hideStopButton(),C();return}this._submit()}),X.addEventListener("dragover",C=>{C.preventDefault(),X.classList.add("gengage-chat-input-area--dragover")}),X.addEventListener("dragleave",()=>{X.classList.remove("gengage-chat-input-area--dragover")}),X.addEventListener("drop",C=>{C.preventDefault(),X.classList.remove("gengage-chat-input-area--dragover");const W=C.dataTransfer?.files[0];W&&this._routeAttachmentFile(W)});const ee=document.createElement("div");ee.className="gengage-chat-input-pill gds-input-shell",ee.dataset.gengagePart="chat-input-shell",ee.appendChild(K),ee.appendChild(this.inputEl),this._voiceEnabled&&Sl()&&(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()),ee.appendChild(this._micBtn),this._voiceInput=new Mi({onInterim:C=>{this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.inputEl.value=C,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:C=>{this.inputEl.value=C},onAutoSubmit:C=>{this.inputEl.value=C,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:C=>{C==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(C,W)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),ee.appendChild(this.sendBtn),X.appendChild(this._previewStrip),X.appendChild(this._fileInput),X.appendChild(ee),E.appendChild(X),b.appendChild(E),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",b.appendChild(this._comparisonDockSlotEl),this.root.appendChild(b),this._setupHorizontalSwipe(E);const Q=this._createFooterAttribution();Q&&this.root.appendChild(Q);const re=C=>{C.key==="Escape"&&e.onClose()};this.root.addEventListener("keydown",re),this._cleanups.push(()=>this.root.removeEventListener("keydown",re)),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=xe(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="${ye(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=Da[n.icon]??Fa,s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,i.appendChild(s)}if(n.image&&ke(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){this._kvkkSlot.innerHTML="";const e=Pl({htmlContent:t});this._kvkkSlot.appendChild(e)}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=Ml(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 Dl(t);if(e){this._routeAttachmentFile(e),this._closeAttachMenu();return}be("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 g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";for(let k=0;k<2;k++){const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",k===1&&T.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),g.appendChild(T)}const d=document.createElement("div");d.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",g.appendChild(d),c.appendChild(l),c.appendChild(g),o.appendChild(c);const 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 k=0;k<3;k++){const T=document.createElement("li"),z=document.createElement("div");z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",k===1&&z.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),k===2&&z.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),T.appendChild(z),b.appendChild(T)}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 p=document.createElement("div");p.className="gengage-chat-comparison-key-differences-content";for(let k=0;k<4;k++){const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",p.appendChild(T)}m.appendChild(p),r.appendChild(m);const y=document.createElement("div");y.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",y.appendChild(_),r.appendChild(y);const v=document.createElement("div");v.className="gengage-chat-comparison-skeleton-table-wrap";const w=document.createElement("div");w.className="gengage-chat-comparison-skeleton-table-head";const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-corner",w.appendChild(E);for(let k=0;k<3;k++){const T=document.createElement("div");T.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 O=document.createElement("div");O.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const Z=document.createElement("div");Z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",T.appendChild(z),T.appendChild(O),T.appendChild(Z),w.appendChild(T)}v.appendChild(w);for(let k=0;k<3;k++){const T=document.createElement("div");T.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",T.appendChild(z);for(let O=0;O<3;O++){const Z=document.createElement("div");Z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",T.appendChild(Z)}v.appendChild(T)}r.appendChild(v),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)},Ui))}_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="${ye(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=xe(e)),this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const e=this.messagesEl.querySelector(`[data-message-id="${ye(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="${ye(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="${ye(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+Ua,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,o+Ua),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=Da[e.icon]??Fa,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 g=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||g.display==="none"||g.visibility==="hidden"?!1:l.getClientRects().length>0});if(a.length===0)return;const n=a[0],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}))}hideCartToast(){this._cartToastTimerId!==null&&(window.clearTimeout(this._cartToastTimerId),this._cartToastTimerId=null);const t=this._cartToastEl;t&&(this._cartToastEl=null,t.classList.remove("gengage-chat-cart-toast--visible"),window.setTimeout(()=>{t.remove()},300))}showCartToast(t,e){const a=e?.tone??"success",n=e?.autoHideMs??2500;let i=this._cartToastEl;(!i||!i.isConnected)&&(i=document.createElement("div"),i.className="gengage-chat-cart-toast",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),this.root.appendChild(i),this._cartToastEl=i),this._cartToastTimerId!==null&&(window.clearTimeout(this._cartToastTimerId),this._cartToastTimerId=null),i.classList.toggle("gengage-chat-cart-toast--neutral",a==="neutral"),i.textContent=t,i.classList.remove("gengage-chat-cart-toast--visible"),i.offsetWidth,i.classList.add("gengage-chat-cart-toast--visible"),n!==null&&(this._cartToastTimerId=window.setTimeout(()=>{this.hideCartToast()},n))}destroy(){Pi(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.hideCartToast(),this._closeAttachMenu();for(const t of this._cleanups)t();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}}}));function ji(t){return t==="watch_expert"?"account_expert":$i.includes(t)?t:null}function ql(t){return typeof t=="string"?ji(t):null}function Ce(t){return t==null||typeof t!="object"||Array.isArray(t)?null:t}function Ol(...t){for(const e of t)if(typeof e=="string"){const a=e.trim();if(a.length>0)return a}}function jl(t){const e=Ce(t);if(!e)return null;const a=Ol(e.assistant_mode,e.assistantMode);if(!a)return null;const n=ji(a);return!n||n==="shopping"?null:n}function $l(t){return t==="beauty_consulting"?"user_message":"findSimilar"}var $i,Vi=P((()=>{$i=["shopping","beauty_consulting","account_expert"]})),Gi,Vl=P((()=>{Vi(),ot(),Gi=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){Re("mode","redirect metadata received",t);const e=jl(t);return e?(this.switchMode(e),!0):!1}switchMode(t){const e=this._mode;this._mode=t,Re("mode","assistant mode switched",{from:e,to:t})}updateFromContext(t){const e=t.assistant_mode;if(typeof e=="string"&&e){const a=ql(e);a?this._mode=a:Re("mode","ignoring unrecognised assistant_mode from context",e)}else e===null&&(this._mode="shopping");this._uiHints=Ce(t.ui_hints)??null}reset(){const t=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,t}resolveAttachmentActionType(){return $l(this._mode)}shouldCondenseThinking(){return this._mode!=="shopping"}}}));function Gl(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function Wl(t,e,a,n,i){if(t==="PhotoAnalysisCard"){const r=zi(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):(Re("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",e),!1)}if(t==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const r=Il(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 Kl(t){return t.renderHint==="photo_analysis"}function Yl(t,e){t.streamIncludedBeautyPhotoStep||e.drawer?.setBeautyPhotoStepCard({visible:!1}),t.pendingPhotoStepSkip&&(t.pendingPhotoStepSkip=!1,e.sendSkipMessage())}function Ql(t,e){t.pendingPhotoStepSkip&&(t.pendingPhotoStepSkip=!1,e.sendSkipMessage())}var Zl=P((()=>{Ha(),za(),ot()}));function qa(t){return Number.isFinite(t)?Math.max(0,Math.min(5,t)):0}function Oa(t){return Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t))):0}function ja(t){const e=qa(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 Se(t){t.addEventListener("error",()=>{t.style.display="none"},{once:!0})}var $e=P((()=>{}));function ae(t,e){const a=Number(t);if(!Number.isFinite(a)||a<0)return t;const n={...Wi,...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 g;return c!==void 0?g=`${l}${n.decimalSeparator}${c}`:g=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${g}`:`${g} ${n.currencySymbol}`:g}var Wi,lt=P((()=>{Wi={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1}}));function Xl(t,e,a){return e?.[t]??Qi[t]??t.replace(/_/g," ").replace(/^./u,n=>Jl(n,a))}function Jl(t,e){try{return t.toLocaleUpperCase(Fe(e))}catch{return t.toLocaleUpperCase("tr")}}function Ki(t){if(typeof t!="string")return!1;const e=Number(t);return Number.isFinite(e)&&e>0}function eg(t){const e=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;return Number.isFinite(e)&&e>0}function tg(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 ag(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 g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(g);const d=document.createElement("div");d.className="gengage-chat-comparison-recommended-body",d.classList.add("gds-clickable"),d.tabIndex=0,d.setAttribute("role","button"),d.setAttribute("aria-label",e.name);const h=document.createElement("div");if(h.className="gengage-chat-comparison-recommended-media",e.imageUrl&&ke(e.imageUrl)){const p=document.createElement("img");p.src=e.imageUrl,p.alt=e.name,p.loading="lazy",p.addEventListener("error",()=>{p.style.display="none"},{once:!0}),h.appendChild(p)}else{const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-placeholder",p.setAttribute("aria-hidden","true"),h.appendChild(p)}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",eg(e.rating)&&m.appendChild(tg(e.rating)),Ki(e.price)){const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-price",p.textContent=ae(e.price,t.pricing),m.appendChild(p)}if(m.childElementCount>0&&f.appendChild(m),t.recommendedText){const p=document.createElement("p");p.className="gengage-chat-comparison-recommended-text",p.innerHTML=xe(t.recommendedText),f.appendChild(p)}d.appendChild(f);const u=()=>{o({sku:e.sku,name:e.name})};if(d.addEventListener("click",u),d.addEventListener("keydown",p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),u())}),l.appendChild(d),i.length>0){const p=document.createElement("div");p.className="gengage-chat-comparison-highlights",p.dataset.gengagePart="comparison-highlights";const y=document.createElement("div");y.className="gengage-chat-comparison-highlights-label",y.textContent=s?.highlightsLabel??"Key Highlights",p.appendChild(y);const _=document.createElement("ul");for(const v of i){const w=document.createElement("li");w.textContent=v,_.appendChild(w)}p.appendChild(_),l.appendChild(p)}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 g=document.createElement("summary");g.className="gengage-chat-comparison-key-differences-summary";const d=document.createElement("span");d.className="gengage-chat-comparison-key-differences-summary-label",d.textContent=s?.keyDifferencesLabel??"Key Differences";const h=document.createElement("span");h.className="gengage-chat-comparison-key-differences-summary-meta",h.textContent=s?.viewMoreLabel??"Show More",g.appendChild(d),g.appendChild(h),l.appendChild(g);const f=document.createElement("div");f.className="gengage-chat-comparison-key-differences-content",f.innerHTML=xe(ng(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 g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(g);const d=document.createElement("ul");for(const h of r)ig(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 g=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 p=document.createElement("div");p.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",p.tabIndex=0,p.setAttribute("role","button"),p.setAttribute("aria-label",m.name),p.title=m.name;const y=()=>{o({sku:m.sku,name:m.name})};if(p.addEventListener("click",y),p.addEventListener("keydown",v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),y())}),m.imageUrl&&ke(m.imageUrl)){const v=document.createElement("img");v.src=m.imageUrl,v.alt=m.name,v.loading="lazy",v.addEventListener("error",()=>{v.style.display="none"},{once:!0}),p.appendChild(v)}else{const v=document.createElement("div");v.className="gengage-chat-comparison-table-header-img-placeholder",v.setAttribute("aria-hidden","true"),p.appendChild(v)}const _=document.createElement("div");if(_.className="gengage-chat-comparison-table-product-name",_.textContent=m.name,p.appendChild(_),Ki(m.price)){const v=document.createElement("div");v.className="gengage-chat-comparison-table-price",v.textContent=ae(m.price,t.pricing),p.appendChild(v)}u.appendChild(p),d.appendChild(u)}g.appendChild(d),l.appendChild(g);const f=document.createElement("tbody");for(const m of n){const u=document.createElement("tr"),p=document.createElement("td");p.className="gengage-chat-comparison-label",p.textContent=Xl(m.label,s?.criteriaLabels,t.locale),u.appendChild(p);for(let y=0;y<m.values.length;y++){const _=document.createElement("td");a[y]?.sku===e?.sku&&(_.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const v=m.values[y]??"";Yi(v)?_.innerHTML=xe(v):_.textContent=v,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 g=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const d=g[0],h=g[g.length-1];l.shiftKey&&document.activeElement===d?(l.preventDefault(),h.focus()):!l.shiftKey&&document.activeElement===h&&(l.preventDefault(),d.focus())}),c}function ng(t){if(/<[uo]l[\s>]/i.test(t)||/<li[\s>]/i.test(t))return t;const e=t.split(`
|
|
47
|
+
`,document.head.appendChild(t)}var He,xa,Bt,$n,Vn,Gn,Wn,_a,je,Kn,it=P((()=>{Ke(),Bs(),He="gengage-global-toast-root",xa="gengage-global-toast-style",Bt="gengage-global-toast-root--visible",$n=4200,Vn=1500,Gn=15e3,Wn=["--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"],_a=!1,je=null,Kn=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i]}));function qs(){if(rt!==null)return rt;try{rt=localStorage.getItem("gengage:debug")==="1"}catch{rt=!1}return rt}function Re(t,e,a){if(!qs())return;const n=[`[gengage:${t}]`,e];a!==void 0&&n.push(a),console.debug(...n)}var rt,ot=P((()=>{rt=null}));function Os(){if(typeof window>"u")return;const t=window;t.__gengageSdkRuntimeInfoLogged||(t.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${Yn} (${Qn})`))}var Yn,Qn,js=P((()=>{Yn=("0.6.46".trim(),"0.6.46".trim()),Qn=("iife-build".trim(),"iife-build".trim())}));function $s(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}var ut,Rt=P((()=>{Ke(),In(),Ms(),it(),ot(),js(),ut=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=Ns(t.theme);Os(),this.config={...t,theme:e,session:Ln(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(e),Rs();const a=Mt("gengage:context:update",n=>this.update(n));this._cleanups.push(a),Re("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,Re("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-${$s(e)}`;this.root.style.setProperty(n,a)}}}}}));function Zn(){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 Vs=P((()=>{}));function Gs(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.gengage=="string"&&typeof e.type=="string"}function Ws(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}var Xn,Ks=P((()=>{Xn=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("*")&&Ws()&&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(!Gs(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 Jn(t,e){if(typeof window>"u"||!de(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 ei=P((()=>{pe()}));function Ys(t,e,a={}){const n=t.action,i=a.logger??ti;switch(Re("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(!de(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??Qs)(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=Zs(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 Qs(t,e){if(!(typeof window>"u")){if(!de(t)){console.warn("[gengage] Blocked navigation to unsafe URL:",t);return}Jn(t,e)}}function Zs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ti,Xs=P((()=>{pe(),ot(),ei(),ti=console}));function Fe(t){const e=t?.trim();return e||"tr"}var mt=P((()=>{}));function ye(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 zt=P((()=>{}));function Js(t){return ai.includes(t.type)?t.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}var ai,ec,tc=P((()=>{ai=["image/jpeg","image/png","image/webp"],ec=5*1024*1024}));function ni(t){return typeof t=="object"&&t!==null&&typeof t.type=="string"}function ac(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 ii(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 ni(i)?(Re("stream",`event: ${i.type}`,i),e.onEvent(i),i.type==="done"?(e.onDone?.(),!0):!1):!1}catch{const i=ac(n);if(i.length>1){for(const r of i)try{const o=JSON.parse(r);if(!ni(o))continue;if(e.onEvent(o),o.type==="done")return e.onDone?.(),!0}catch{}return!1}return!1}}async function Ht(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 g=await(r>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(o),r)})]):c);if(g===o){s=!0,await a.cancel();break}const{done:d,value:h}=g;if(d)break;i+=n.decode(h,{stream:!0});const f=i.split(`
|
|
48
|
+
`);i=f.pop()??"";for(const b of f)if(ii(b,e))return}if(i.trim()&&ii(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 wa=P((()=>{ot()}));function nc(t){const e=(t.display_keywords??[]).flatMap(i=>Ft(i,{stripLeadingStopWords:!0})),a=e.filter((i,r)=>e.indexOf(i)===r);if(a.length>0)return a.slice(0,ka);const n=[...Ft(t.chosen_attribute,{stripLeadingStopWords:!0}),...Ft(t.short_name)];return n.filter((i,r)=>n.indexOf(i)===r).slice(0,ka)}function ic(t){return nc(t).join(" • ")}var ka,ri,Ft,rc=P((()=>{ka=3,ri=(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():""},Ft=(t,e)=>t?t.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>ri(a,e)).filter(Boolean):[]}));function oi(t){return t==="beauty_consulting"||t==="account_expert"}var si=P((()=>{}));function ft(...t){for(const e of t){if(typeof e!="string")continue;const a=e.trim();if(a.length>0)return a}}function bt(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim()):[]}function ct(t){const e={...t},a=ft(e.sku),n=bt(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=ft(e.image_url);i?e.image_url=i:delete e.image_url}return e}var Ca=P((()=>{}));function Dt(t){if(typeof t.type!="string")return null;if(oc(t))return t;const e=t;switch(e.type){case"outputText":return sc(e);case"suggestedActions":return cc(e);case"productList":return lc(e);case"productDetails":return gc(e);case"productDetailsSimilars":return dc(e);case"comparisonTable":return pc(e);case"context":return fc(e);case"chatStreamEnd":return bc();case"loading":return vc(e);case"panelLoading":return yc(e);case"similarLoading":return xc(e);case"redirect":return _c(e);case"error":return wc(e);case"dummy":return kc(e);case"launcherAction":return Cc(e);case"text":return Sa(e);case"productItem":return Sc(e);case"text_image":return ci(e);case"quick_qna":return li(e);case"reviewHighlights":return Ec(e);case"aiProductSuggestions":return Ac(e);case"aiProductGroupings":return Lc(e);case"aiSuggestedSearches":return Mc(e);case"prosAndCons":return Tc(e);case"getGroundingReview":return Bc(e);case"voice":return zc(e);case"visitorDataResponse":return Pc(e);case"productListPreview":return Rc();case"groupList":return Hc(e);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Fc(e);case"launcherContent":return Uc(e);case"handoff":return Dc(e);case"uiSpec":return Yc(e);default:return null}}function oc(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=_e(t.spec);return n?typeof n.root=="string"&&_e(n.elements)!==null:!1}case"action":{const a=_e(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 sc(t){const e=te(t.payload.text,t.payload.plain_text)??"",a=te(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.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const r=t.payload.product_mentions;Array.isArray(r)&&r.length>0&&(n.productMentions=r.map(c=>{if(typeof c!="object"||c===null||typeof c.sku!="string")return null;const l=typeof c.short_name=="string"?c.short_name:"";if(!l)return null;const g=(typeof c.url=="string"&&c.url.trim()?c.url.trim():void 0)??(()=>{const d=n.skuToProductItem?.[c.sku];return typeof d?.url=="string"&&d.url.trim()?d.url.trim():void 0})();return g?{sku:c.sku,short_name:l,url:g}:{sku:c.sku,short_name:l}}).filter(c=>c!==null));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 cc(t){return gi((t.payload.actions??[]).map(e=>{const a=te(e.title)??"",n=Te(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(yt),"chat")}function lc(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=te(s.style_label);if(!c)return null;const l=te(s.style_mood),g=te(s.image_url??void 0),d=(Array.isArray(s.product_list)?s.product_list:[]).map(f=>{const b=_e(f);return b?Pa(_e(b.product_detail)??_e(b.product)??b):null}).filter(yt),h=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(f=>({label:te(f.label)??"",reason:te(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??"",...g?{image_url:g}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:d,recommendation_groups:h}}).filter(yt),n=t.payload.product_list??[],i=oi(t.payload.source)&&a.length>0?a[0].product_list:null,r=i?Oc(i,"chat"):e.length>0?qc(e,n,"chat")??Ta(n,"chat"):Ta(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 gc(t){const e=t.payload.productDetails;if(!e)return $c("chat");const a=De(e);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...e,...a}}}}},panelHint:"panel"}}function dc(t){const e=Ta(t.payload.similarProducts??[],"chat"),a=e.spec.elements[e.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...e,panelHint:"panel"}}function pc(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 p=De(u);o.push(p)}const s=hc(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],g=[];if(Array.isArray(n?.key_differences))for(const u of n.key_differences)typeof u=="string"&&g.push(u);const d=di(n?.special_considerations),h=n?.recommended_choice,f=n?.winner_hits,b={};for(const u of o){const p=u.sku;p&&(b[p]={title:u.name??p,type:"launchSingleProduct",payload:{sku:p}})}const m={products:o,attributes:s,highlights:g,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 hc(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(p=>typeof p=="string"?p:String(p??""))})}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:uc(o)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),g=[];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`],p=m[d];return mc(u??p)});if(h.every(b=>b.length===0))continue;const f=c[d]??d;g.push({label:f,values:h})}return g}function uc(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 mc(t){return typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):""}function fc(t){return{type:"metadata",sessionId:"",model:"",meta:{panel:t.payload.panel,messages:t.payload.messages,message_id:t.payload.message_id}}}function bc(){return{type:"done"}}function vc(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 yc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function xc(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function _c(t){const e=te(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:te(t.payload.to)}}}function wc(t){return{type:"error",code:"BACKEND_ERROR",message:te(t.payload?.text,t.payload?.message,t.payload?.error)??"Backend returned an error"}}function kc(t){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Cc(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),li({type:"quick_qna",payload:i})}const a=_e(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),ci({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=_e(e.payload)??void 0;return r!==void 0&&(i.type=r),s!==void 0&&(i.payload=s),o!==void 0&&(i.theme=o),Sa({type:"text",payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:e}}}function Sa(t){const e={text:te(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 Sc(t){return jc(t.payload,"qna")}function ci(t){const e=te(t.payload.text)??"",a=Te(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),Sa({type:"text",payload:n})}function li(t){return gi((t.payload.action_list??[]).map(e=>{const a=te(e.title)??"",n=Te(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(yt),"qna")}function Ec(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 Tc(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 Pc(t){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:t.payload}}}function Ac(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=Vc(i);if(!r)continue;const o={product:r},s=Te(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 Lc(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=te(r.name)??"",s=te(r.description),c=te(r.highlight),l=Array.isArray(r.labels)?di(r.labels):[],g=te(r.sku,r.repr_sku),d=te(r.image,r.repr_image),h=Ic(r,o,g),f=(Array.isArray(r.group_products)?r.group_products:[]).map(u=>{const p=_e(u);return p?Pa(p):null}).filter(yt),b=d??te(...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 Ic(t,e,a){const n=_e(t.requestDetails);if(n){if(n.type!=="findSimilar")return Te(n,e);const o={..._e(n.payload)??{}};a&&!ft(o.sku)&&(o.sku=a);const s=bt(t.group_skus);return s.length>0&&(o.group_skus=s),Te({...n,payload:ct(o)},e)}const i={};a&&(i.sku=a);const r=bt(t.group_skus);return r.length>0&&(i.group_skus=r),Object.keys(i).length===0?null:Te({type:"findSimilar",payload:ct(i)},e)}function Nc(t,e){const a=_e(t.requestDetails),n=_e(a?.payload),i=te(t.detailed_user_message),r=t.group_skus&&Array.isArray(t.group_skus)?bt(t.group_skus):bt(n?.group_skus),o=te(t.sku,t.representative_product_sku,n?.sku);if(a?.type==="findSimilar"){const c={...n??{}};return o&&(c.sku=o),r.length>0&&(c.group_skus=r),i&&(c.input=i,ft(c.text)||(c.text=i)),c.is_search_suggestion=1,Te({...a,payload:ct(c)},e)}if(o){const c={sku:o,is_search_suggestion:1};return r.length>0&&(c.group_skus=r),i&&(c.input=i,c.text=i),Te({type:"findSimilar",payload:ct(c)},e)}const s={...n??{},is_suggested_text:1,is_search_suggestion:1};return i&&!ft(s.text)&&(s.text=i),r.length>0&&(s.group_skus=r),Te(a?.type==="inputText"?{...a,payload:s}:{type:"inputText",payload:s},e)}function Mc(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=te(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Search ${n+1}`,o=Nc(i,r);if(!o)continue;const s={shortName:r,action:o},c=te(i.detailed_user_message);c&&c!==r&&(s.detailedMessage=c);const l=ic(i);l&&l!==r&&l!==(c??"")&&(s.whyDifferent=l),typeof i.image=="string"&&(s.image=i.image),a.push(s)}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 Bc(t){const e=t.payload,a=Te(e.requestDetails??e.request_details,te(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 Rc(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function zc(t){return{type:"metadata",sessionId:"",model:"",meta:{voice:t.payload}}}function Hc(t){const e=t.payload.group_list??[],a=[];for(const i of e){const r=i.group_name??"",o=(i.product_list??[]).map(De);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=Te(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 Fc(t){return{type:"metadata",sessionId:"",model:"",meta:{formType:t.type,formPayload:t.payload??{}}}}function Dc(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 Uc(t){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:t.payload??{}}}}function Ea(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 gi(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 Ta(t,e){const a={},n=[];for(let i=0;i<t.length;i++){const r=t[i];if(!r)continue;const o=De(r),s=`product-${i}`;n.push(s),a[s]=Ea(o,i)}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function qc(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 g=t[l],d=te(g?.title)??"",h=Array.isArray(g?.skus)?g.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 p=`product-${l}-${b}`,y=De(u);o.push(p),f.push(p),r[p]=Ea(y,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 Oc(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]=Ea(r,i)}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:e,spec:{root:"root",elements:a}}}function jc(t,e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:De(t),index:0}}}}}}function $c(t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Vc(t){const e=te(t.sku),a=te(t.short_name),n={..._e(t.product_item)??t},i=te(t.discount_reason,t.discountReason);return i&&!te(n.discount_reason,n.discountReason)&&(n.discount_reason=i),Pa(n,e,a)}function Pa(t,e,a){const n=te(t.sku,e),i=te(t.name,a);if(!n||!i)return null;const r={sku:n,name:i},o=te(t.brand);o&&(r.brand=o);const s=te(t.url);s&&(r.url=s);const c=Gc(t.images);if(c.length>0)r.images=c;else{const m=te(t.image,t.image_url,t.imageUrl);m&&(r.images=[m])}const l=vt(t.price_discounted);l!==void 0&&(r.price_discounted=l);const g=vt(t.price);g!==void 0&&(r.price=g);const d=vt(t.rating);d!==void 0&&(r.rating=d);const h=vt(t.review_count)??vt(t.reviewCount);h!==void 0&&(r.review_count=h);const f=te(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=te(t.discount_reason,t.discountReason);return b&&(r.discount_reason=b),De(r)}function Te(t,e){const a=_e(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 _e(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function te(...t){for(const e of t)if(typeof e=="string"){const a=e.trim();if(a.length>0)return a}}function Gc(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):[]}function di(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 vt(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 yt(t){return t!=null}function De(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=te(t.brand),o=te(t.name)??t.sku,s=r&&!o.toLowerCase().startsWith(r.toLowerCase())?`${r} ${o}`:o,c={sku:t.sku,name:s,url:te(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 g=t,d={};let h=!1;for(const f of Object.keys(g))pi.has(f)||(d[f]=g[f],h=!0);return h&&(c.extras=d),c}function Wc(t){return t.results.map(De)}function Kc(t){return t.product_groupings.map(e=>{const a={name:e.name,products:(e.group_products??[]).map(De)};return e.highlight!==void 0&&(a.highlight=e.highlight),a})}function Yc(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 pi,Aa=P((()=>{rc(),si(),Ca(),pi=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 Qc(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 Ut(t,e){return`${Qc(e?.middlewareUrl)}/chat${hi[t]}`}var hi,La=P((()=>{hi={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"}}));function Zc(t){if(!(typeof window>"u"||!t))try{const e=window.GengageAssistantInjector?.[t]?.streamTransport;return typeof e=="function"?e:void 0}catch{return}}var Xc=P((()=>{}));async function qt(t,e={},a={}){const n=Jc(t,e);if(!n)return fetch(t,e);const i=Date.now(),r=await nl(n,i);if(r)return ol(r);const o=await fetch(t,e);return o.ok&&il(n,o.clone(),i,{ttlMs:a.ttlMs??vi,maxEntries:a.maxEntries??Ma,maxBodyBytes:a.maxBodyBytes??yi}),o}function Jc(t,e={}){if(typeof Request<"u"&&t instanceof Request)return null;const a=String(e.method||"GET").toUpperCase();if(a!=="POST"||typeof e.body!="string")return null;const n=el(e.body);if(tl(n))return null;const i=al(n);if(i){const r=xt(n?.action);return`rr:${bi(fi({url:String(t),method:a,headers:ui(e.headers),type:n?.type??r?.type??"",account_id:n?.account_id??n?.accountId??"",locale:n?.locale??"",outputLanguage:xt(n?.meta)?.outputLanguage??"",cache_key:i}))}`}return`rr:${bi(fi({url:String(t),method:a,headers:ui(e.headers),body:e.body}))}`}function el(t){try{const e=JSON.parse(t);return!e||typeof e!="object"||Array.isArray(e)?null:e}catch{return null}}function tl(t){const e=t?.type;return typeof e=="string"&&wi.has(e)}function al(t){const e=(xt(t?.payload)??xt(xt(t?.action)?.payload))?.cache_key;return typeof e=="string"&&e.trim().length>0?e.trim():null}async function nl(t,e){const a=Ne.get(t);if(a)if(a.expiresAt<=e)Ne.delete(t);else return a.lastAccessedAt=e,Ne.delete(t),Ne.set(t,a),Ia(a),a;const n=await cl(t);return n?n.expiresAt<=e?(Ne.delete(t),ll(t),null):(n.lastAccessedAt=e,Ne.set(t,n),Ia(n),mi(Ma),n):null}async function il(t,e,a,n){try{const i=await e.text();if(dl(i)>n.maxBodyBytes||rl(i))return;const r={key:t,status:e.status,statusText:e.statusText,headers:sl(e.headers),body:i,createdAt:a,expiresAt:a+n.ttlMs,lastAccessedAt:a};Ne.set(t,r),mi(n.maxEntries),await Ia(r),await gl(n.maxEntries,a)}catch{}}function rl(t){return/"_error"\s*:/u.test(t)||/"type"\s*:\s*"error"/u.test(t)}function ol(t){return new Response(t.body,{status:t.status,statusText:t.statusText,headers:new Headers(t.headers)})}function ui(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 sl(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 mi(t){for(;Ne.size>t;){const e=[...Ne.values()].sort((a,n)=>a.lastAccessedAt-n.lastAccessedAt)[0];if(!e)break;Ne.delete(e.key)}}async function Ot(){return typeof indexedDB>"u"?null:(Ba??=new Promise(t=>{const e=indexedDB.open(xi,_i);e.onupgradeneeded=()=>{const a=e.result;a.objectStoreNames.contains(Ie)||a.createObjectStore(Ie,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},e.onsuccess=()=>t(e.result),e.onerror=()=>t(null),e.onblocked=()=>t(null)}),Ba)}async function cl(t){const e=await Ot();return e?new Promise(a=>{const n=e.transaction(Ie,"readonly"),i=n.objectStore(Ie).get(t);i.onsuccess=()=>a(i.result??null),i.onerror=()=>a(null),n.onerror=()=>a(null)}):null}async function Ia(t){const e=await Ot();e&&await new Promise(a=>{const n=e.transaction(Ie,"readwrite");n.objectStore(Ie).put(t),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function ll(t){const e=await Ot();e&&await new Promise(a=>{const n=e.transaction(Ie,"readwrite");n.objectStore(Ie).delete(t),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function gl(t,e){const a=await Ot();a&&await new Promise(n=>{const i=a.transaction(Ie,"readwrite"),r=i.objectStore(Ie),o=[],s=r.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const l=o.filter(d=>d.expiresAt<=e),g=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,...g])r.delete(d.key);return}o.push(c.value),c.continue()},s.onerror=()=>n(),i.oncomplete=()=>n(),i.onerror=()=>n(),i.onabort=()=>n()})}function fi(t){return JSON.stringify(Na(t))}function xt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Na(t){return Array.isArray(t)?t.map(Na):!t||typeof t!="object"?t:Object.fromEntries(Object.entries(t).sort(([e],[a])=>e.localeCompare(a)).map(([e,a])=>[e,Na(a)]))}function bi(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 dl(t){return typeof TextEncoder<"u"?new TextEncoder().encode(t).byteLength:t.length}var vi,Ma,yi,xi,_i,Ie,wi,Ne,Ba,Ra=P((()=>{vi=7200*1e3,Ma=200,yi=5*1024*1024,xi="gengage_request_response_cache",_i=1,Ie="responses",wi=new Set(["addToCart","like"]),Ne=new Map,Ba=null}));function pl(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=e.genericNonPdpLaunch===!0&&e.pageContext?.pageType!=="pdp"&&(o.is_entry_question===1||o.is_entry_question===!0),c=o.is_search_suggestion===1||o.is_search_suggestion===!0,l={is_launcher:0};if(!s&&e.pageContext?.extra&&(l.page_details=e.pageContext.extra),!s&&!c&&!r&&!("sku_list"in o)){const d=e.pageContext?.skuList&&e.pageContext.skuList.length>0?e.pageContext.skuList:e.pageContext?.sku?[e.pageContext.sku]:void 0;d&&d.length>0&&(l.sku_list=d)}"is_suggested_text"in o||(l.is_suggested_text=0);const g={...o};for(const[d,h]of Object.entries(l))d in g||(g[d]=h);return{...t,payload:g}}case"findSimilar":{const r={is_launcher:0};return t.title&&(r.text=t.title,r.input=t.title),{...t,payload:ct(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 ki(t){const{action:e,type:a,payload:n,...i}=t,r=a??e?.type??"inputText",o=n??e?.payload,s=Si[r]??r,c={...i,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function hl(t){return JSON.parse(ki(t))}function ul(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Ci(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 ml(t,e,a){const n=new AbortController,i=a.injectorAdapter??Zc(a.accountId);return i?((async()=>{const o=Ci(e,n.signal);try{if(await Promise.resolve(),n.signal.aborted)return;const s=i(hl(t),o.callbacks,n.signal,a.attachment);ul(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=Ut("process_action",a),s=ki(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 g=c?await fetch(o,l):await qt(o,l);if(!g.ok){let h=g.statusText;try{const f=await g.json(),b=f.detail??f.message??f.error;typeof b=="string"&&(h=b)}catch{}e.onError(new Error(`HTTP ${g.status}: ${h}`));return}const d=Ci(e);await Ht(g,{onEvent:h=>{const f=Dt(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 Si,fl=P((()=>{wa(),Aa(),La(),Xc(),Ca(),Ra(),Si={user_message:"inputText"}}));function bl(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search);if(Ei.some(e=>t.get(e)==="1"))return!0;try{return Ti.some(e=>window.localStorage.getItem(e)==="1")}catch{return!1}}function vl(t,e,a){if(!bl())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 Ei,Ti,yl=P((()=>{Ei=["chat_debug","presentation_debug"],Ti=["gengage_chat_debug","gengage_presentation_debug"]}));function Pi(t){Ye=t}function xl(){if(Ye&&Ye.isConnected)return Ye;Ye=null;const t=document.getElementById(_t);return t||(vl("chat-scroll","failed to resolve scroll container (not registered)",{id:_t}),null)}function Ai(){Ye=null}var _t,Ye,Li=P((()=>{yl(),_t="gengage-chat-scroll",Ye=null})),Qe,_l=P((()=>{Qe={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",inputAriaLabel:"Mesajınızı yazın",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",addingToCartToast:"Sepete ekleniyor...",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"}})),Ii,wl=P((()=>{Ii={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",inputAriaLabel:"Type your message",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",addingToCartToast:"Adding 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 kl(t){return t?t.toLowerCase().split("-")[0]??"tr":"tr"}function Cl(t){return kl(t)==="en"?Ii:Qe}var wt=P((()=>{_l(),wl()}));function Sl(){return Ni()!==null}function Ni(){const t=globalThis;return t.SpeechRecognition??t.webkitSpeechRecognition??null}function El(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 Mi,Tl=P((()=>{Mi=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=Ni();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=El(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 Pl(t){const e=document.createElement("div");e.className="gengage-chat-kvkk-banner",e.dataset.gengagePart="kvkk-banner",e.setAttribute("role","note");const a=document.createElement("div");return a.className="gengage-chat-kvkk-content",a.dataset.gengagePart="kvkk-content",a.innerHTML=xe(t.htmlContent),e.appendChild(a),e}var Al=P((()=>{pe()})),Bi,Ll=P((()=>{Bi=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 Il(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 Ri(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 g=document.createElement("p");g.className="gengage-chat-beauty-photo-step-desc",g.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(g),c.appendChild(d),o.appendChild(s),o.appendChild(c),o}var za=P((()=>{wt()}));function Nl(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 Ml(t,e,a,n,i){if(!a.visible)return t&&(t.hidden=!0,t.innerHTML=""),t;const r=Nl(t,e);r.hidden=!1,r.innerHTML="";const o=Ri({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 Bl=P((()=>{za()}));function zi(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 Hi(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 Fi(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=Hi(t.strengths,e.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=Hi(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 g=document.createElement("p");if(g.className="gengage-chat-photo-analysis-celeb-name",g.textContent=e.celebStyle,c.appendChild(l),c.appendChild(g),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 Rl(t){const e={...Qe,...t?.i18n??{}};return{badge:e.photoAnalysisBadge,strengths:e.photoAnalysisStrengthsLabel,focus:e.photoAnalysisFocusLabel,celebStyle:e.photoAnalysisCelebStyleLabel}}function zl(t,e){const a=zi(t.props??{})??{summary:""};return Fi(Rl(e),a)}function Hl(t,e,a){t.innerHTML="",a&&t.appendChild(Fi(e,a))}var Ha=P((()=>{wt()}));async function Fl(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(qi)?.[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 Dl(t){try{const e=t??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return e?Fl(await e):null}catch{}return null}var Fa,Da,Di,Ui,Ua,qi,Oi,Ul=P((()=>{Li(),pe(),Ke(),wt(),Tl(),zt(),Al(),Ll(),Bl(),Ha(),Fa='<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>',Da={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>'},Di=Qe,Ui=1400,Ua=1500,qi=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi,Oi=class{_renderPhotoAnalysisCard(t,e){Hl(t,{badge:this.i18n.photoAnalysisBadge,strengths:this.i18n.photoAnalysisStrengthsLabel,focus:this.i18n.photoAnalysisFocusLabel,celebStyle:this.i18n.photoAnalysisCelebStyleLabel},e)}_createLegacyHeaderPoweredBy(){const t=typeof this.i18n.poweredBy=="string"?this.i18n.poweredBy.trim():"";if(!t)return null;const e=document.createElement("a");return e.className="gengage-chat-header-powered",e.dataset.gengagePart="chat-header-powered-by",e.href="https://gengage.ai/",e.target="_blank",e.rel="noopener noreferrer",e.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>${t}`,e}_createFooterAttribution(){const t=document.createElement("div");t.className="gengage-chat-footer",t.dataset.gengagePart="chat-footer";const e=this._options.footerAttribution,a=typeof e?.label=="string"?e.label.trim():"",n=typeof e?.href=="string"?e.href.trim():"",i=typeof this.i18n.poweredBy=="string"?this.i18n.poweredBy.trim():"",r=a||i;if(!r)return null;if(n&&de(n)){const o=document.createElement("a");return o.className="gengage-chat-footer-link",o.dataset.gengagePart="chat-footer-link",o.href=n,o.target=e?.target||"_blank",o.rel=e?.rel||"noopener noreferrer",o.textContent=r,typeof e?.ariaLabel=="string"&&e.ariaLabel.trim()&&o.setAttribute("aria-label",e.ariaLabel.trim()),t.appendChild(o),t}return t.textContent=r,t}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._cartToastEl=null,this._cartToastTimerId=null,this._options=e,this.i18n={...Di,...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 C=document.createElement("div");C.className="gengage-chat-drawer-handle",C.dataset.gengagePart="chat-drawer-handle",C.setAttribute("aria-hidden","true"),C.style.pointerEvents="none",i=C}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 C=document.createElement("img");C.className="gengage-chat-header-avatar",c&&C.classList.add("gengage-chat-header-avatar--logo"),C.dataset.gengagePart="chat-header-avatar",C.src=s,C.alt=e.headerTitle??"Assistant",o.appendChild(C)}const l=document.createElement("div");l.className="gengage-chat-header-info",l.dataset.gengagePart="chat-header-info";const g=document.createElement("div");g.className="gengage-chat-header-title-row",g.dataset.gengagePart="chat-header-title-row";const d=document.createElement("span");if(d.className="gengage-chat-header-title",d.dataset.gengagePart="chat-header-title",d.textContent=e.headerTitle??this.i18n.headerTitle??"Product Expert",g.appendChild(d),e.headerBadge){const C=document.createElement("span");C.className="gengage-chat-header-badge gds-badge gds-badge-brand",C.dataset.gengagePart="chat-header-badge",C.textContent=e.headerBadge,g.appendChild(C)}if(l.appendChild(g),e.footerAttribution===void 0){const C=this._createLegacyHeaderPoweredBy();C&&l.appendChild(C)}o.appendChild(l),r.appendChild(o);const h=document.createElement("div");h.className="gengage-chat-header-right",h.dataset.gengagePart="chat-header-actions";{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-reopen-panel",C.setAttribute("aria-label",this.i18n.showPanelAriaLabel),C.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>',C.addEventListener("click",()=>this._showMobilePanelFromBtn()),h.appendChild(C),this._reopenPanelBtn=C}if(e.headerCartUrl||e.onCartClick){const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--cart gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-cart",C.setAttribute("aria-label",this.i18n.cartAriaLabel),C.title=this.i18n.cartAriaLabel,C.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>',C.addEventListener("click",()=>e.onCartClick?.()),h.appendChild(C),this._cartBtn=C}if(e.onHistoryClick){const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--history gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-history",C.setAttribute("aria-label",this.i18n.historyAriaLabel),C.title=this.i18n.historyAriaLabel,C.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>',C.addEventListener("click",()=>e.onHistoryClick?.()),h.appendChild(C)}if(e.onNewChat){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-new-chat gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-new-chat",C.type="button",C.setAttribute("aria-label",this.i18n.newChatButton),C.title=this.i18n.newChatButton,C.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>',C.addEventListener("click",()=>e.onNewChat?.()),h.appendChild(C)}const f=document.createElement("button");if(f.className="gengage-chat-close gds-btn gds-btn-ghost gds-icon-btn",f.dataset.gengagePart="chat-header-close",f.type="button",f.setAttribute("aria-label",this.i18n.closeButton),f.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>',f.addEventListener("click",e.onClose),e.showHeaderFavorites){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-header-btn--fav gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-favorites",C.type="button",C.setAttribute("aria-label",this.i18n.favoritesAriaLabel),C.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 W=document.createElement("span");W.className="gengage-chat-header-fav-badge",W.dataset.gengagePart="chat-header-favorites-badge",W.setAttribute("aria-hidden","true"),W.style.display="none",C.appendChild(W),this._favBadgeEl=W,C.addEventListener("click",()=>{e.onFavoritesClick?.()}),h.appendChild(C)}h.appendChild(f),i&&r.insertBefore(i,r.firstChild),r.appendChild(h);{let W=0,ge=0,ce=!1;const N=V=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||V.target.closest('button, a, input, [role="button"]'))return;const G=V.changedTouches?.[0];G&&(W=G.clientY,ge=0,ce=!0,this.root.style.transition="none")},U=V=>{if(!ce)return;const G=V.changedTouches?.[0];if(!G)return;ge=G.clientY-W;const J=(e.getMobileState?.()??"full")==="full"?Math.max(0,ge):ge;V.preventDefault(),this.root.style.transform=`translateY(${J}px)`},ne=()=>{if(!ce)return;ce=!1;const V=e.getMobileState?.()??"full";let G;ge>72?G=V==="full"?"half":"close":ge<-72&&V==="half"?G="full":G=V,this.root.style.transition="",G==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",e.onMobileSnap?.("close")},280)):(this.root.style.transform="",e.onMobileSnap?.(G)),ge=0},ve=()=>{ce&&(ce=!1,ge=0,this.root.style.transition="",this.root.style.transform="")};r.addEventListener("touchstart",N,{passive:!0}),r.addEventListener("touchmove",U,{passive:!1}),r.addEventListener("touchend",ne,{passive:!0}),r.addEventListener("touchcancel",ve,{passive:!0}),this._cleanups.push(()=>{r.removeEventListener("touchstart",N),r.removeEventListener("touchmove",U),r.removeEventListener("touchend",ne),r.removeEventListener("touchcancel",ve)})}const b=document.createElement("div");b.className="gengage-chat-body",b.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 Bi({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 m=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",m,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",m)),b.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.dataset.gengagePart="chat-panel-divider",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel);const u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",u.dataset.gengagePart="chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),u.setAttribute("title",this.i18n.togglePanelAriaLabel),u.textContent="»",u.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let p=null,y=null;const _=24,v=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const W=C.changedTouches?.[0];W&&(p=W.clientX,y=W.clientY)},w=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||p===null||y===null)return;const W=C.changedTouches?.[0];if(!W)return;const ge=W.clientX-p,ce=W.clientY-y;if(p=null,y=null,Math.abs(ce)<_||Math.abs(ce)<Math.abs(ge))return;const N=ce<0;N!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(N),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",v,{passive:!0}),this._dividerEl.addEventListener("touchend",w,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",v),this._dividerEl.removeEventListener("touchend",w)}),this._dividerEl.appendChild(u),b.appendChild(this._dividerEl);const E=document.createElement("div");E.className="gengage-chat-conversation",E.dataset.gengagePart="chat-conversation",this._conversationEl=E,E.appendChild(r);const k=document.createElement("div");k.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",k.dataset.gengagePart="chat-offline-bar",k.setAttribute("role","status"),k.setAttribute("aria-live","polite"),k.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&k.classList.add("gengage-chat-offline-bar--visible"),E.appendChild(k);const T=()=>k.classList.add("gengage-chat-offline-bar--visible"),z=()=>k.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",T),window.addEventListener("online",z),this._cleanups.push(()=>{window.removeEventListener("offline",T),window.removeEventListener("online",z)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",E.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=_t,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),Pi(this.messagesEl);const O=document.createElement("button");O.type="button",O.className="gengage-chat-former-messages-btn gds-chip",O.dataset.gengagePart="chat-former-messages-button",O.textContent=this.i18n.showFormerMessagesButton,O.setAttribute("aria-label",this.i18n.showFormerMessagesButton),O.style.display="none",O.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(O),this._formerMessagesBtn=O;const Z=()=>{this._userInteractionUntil=Date.now()+2e3};let le=!1;const se=()=>this._options.presentation,A=()=>{le||(le=!0,requestAnimationFrame(()=>{le=!1;const{scrollTop:C,scrollHeight:W,clientHeight:ge}=this.messagesEl,ce=W-C-ge;this._userScrolledUp=ce>10;const N=this._presentationPinned?ce<96:ce<32,U=Date.now(),ne=U<this._programmaticScrollUntil,ve=!N&&U<this._userInteractionUntil,V=ne?!1:ve;N!==this._presentationPinned&&(this._presentationPinned=N,se()?.onPinnedToBottomChange?.(N)),V!==this._presentationUserInteracting&&(this._presentationUserInteracting=V,se()?.onUserInteractingChange?.(V))}))};this.messagesEl.addEventListener("scroll",A,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",A)});const F=C=>{Z(),C.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",F,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",F));const S=C=>{Z(),this._touchStartY=C.touches[0]?.clientY??null},M=C=>{Z();const W=C.touches[0]?.clientY,ge=this._touchStartY;typeof W=="number"&&typeof ge=="number"&&W-ge>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",S,{passive:!0}),this.messagesEl.addEventListener("touchmove",M,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",S),this.messagesEl.removeEventListener("touchmove",M)}),E.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 B=document.createElement("div");B.className="gengage-chat-pills-scroll",B.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(B);const D=document.createElement("button");D.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",D.dataset.gengagePart="chat-suggestion-pills-more",D.type="button",D.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),D.textContent="›",D.addEventListener("click",()=>{B.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(D);let H=!1;const ie=()=>{H||(H=!0,requestAnimationFrame(()=>{H=!1;const C=B.scrollLeft+B.clientWidth>=B.scrollWidth-4;D.style.display=C?"none":""}))};B.addEventListener("scroll",ie,{passive:!0}),this._cleanups.push(()=>{B.removeEventListener("scroll",ie)}),E.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",E.appendChild(this._inputChipsEl);const X=document.createElement("div");X.className="gengage-chat-input-area",X.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.setAttribute("aria-label",this.i18n.inputAriaLabel??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",C=>{C.key==="Enter"&&!C.isComposing&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!C.shiftKey)&&(C.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",C=>{const W=C.clipboardData;if(!W)return;let ge=null;const ce=W.files?.[0];if(ce&&ce.type.startsWith("image/"))ge=ce;else if(W.items?.length)for(let N=0;N<W.items.length;N++){const U=W.items[N];if(U?.kind==="file"&&U.type.startsWith("image/")){const ne=U.getAsFile();if(ne){ge=ne;break}}}ge&&(C.preventDefault(),this._routeAttachmentFile(ge))}),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 C=this._fileInput.files?.[0];C&&this._routeAttachmentFile(C),this._fileInput.value=""});const K=document.createElement("div");K.className="gengage-chat-attach-wrap",K.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=K;const x=document.createElement("button");this._attachBtn=x,x.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",x.dataset.gengagePart="chat-attach-button",x.type="button",x.setAttribute("aria-label",this.i18n.attachImageButton),x.setAttribute("aria-haspopup","menu"),x.setAttribute("aria-expanded","false"),x.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>',x.addEventListener("click",C=>{C.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 L=document.createElement("button");L.type="button",L.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",L.dataset.gengagePart="chat-attach-menu-select-photo",L.setAttribute("role","menuitem"),L.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>`,L.addEventListener("click",C=>{C.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const R=document.createElement("div");R.className="gengage-chat-attach-menu-sep",R.dataset.gengagePart="chat-attach-menu-separator",R.setAttribute("aria-hidden","true");const q=document.createElement("button");q.type="button",q.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",q.dataset.gengagePart="chat-attach-menu-paste",q.setAttribute("role","menuitem"),q.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>`,q.addEventListener("click",C=>{C.stopPropagation();const W=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(W)}),I.appendChild(L),I.appendChild(R),I.appendChild(q),K.appendChild(x),K.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 j=document.createElement("img");j.className="gengage-chat-attachment-preview-thumb",j.dataset.gengagePart="chat-attachment-preview-thumb",j.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const $=document.createElement("button");$.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",$.dataset.gengagePart="chat-attachment-preview-remove",$.type="button",$.setAttribute("aria-label",this.i18n.removeAttachmentButton),$.textContent="×",$.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(j),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild($),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 C=this._sendStopHandler;this.hideStopButton(),C();return}this._submit()}),X.addEventListener("dragover",C=>{C.preventDefault(),X.classList.add("gengage-chat-input-area--dragover")}),X.addEventListener("dragleave",()=>{X.classList.remove("gengage-chat-input-area--dragover")}),X.addEventListener("drop",C=>{C.preventDefault(),X.classList.remove("gengage-chat-input-area--dragover");const W=C.dataTransfer?.files[0];W&&this._routeAttachmentFile(W)});const ee=document.createElement("div");ee.className="gengage-chat-input-pill gds-input-shell",ee.dataset.gengagePart="chat-input-shell",ee.appendChild(K),ee.appendChild(this.inputEl),this._voiceEnabled&&Sl()&&(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()),ee.appendChild(this._micBtn),this._voiceInput=new Mi({onInterim:C=>{this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.inputEl.value=C,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:C=>{this.inputEl.value=C},onAutoSubmit:C=>{this.inputEl.value=C,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:C=>{C==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(C,W)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),ee.appendChild(this.sendBtn),X.appendChild(this._previewStrip),X.appendChild(this._fileInput),X.appendChild(ee),E.appendChild(X),b.appendChild(E),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",b.appendChild(this._comparisonDockSlotEl),this.root.appendChild(b),this._setupHorizontalSwipe(E);const Q=this._createFooterAttribution();Q&&this.root.appendChild(Q);const re=C=>{C.key==="Escape"&&e.onClose()};this.root.addEventListener("keydown",re),this._cleanups.push(()=>this.root.removeEventListener("keydown",re)),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=xe(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="${ye(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=Da[n.icon]??Fa,s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,i.appendChild(s)}if(n.image&&ke(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){this._kvkkSlot.innerHTML="";const e=Pl({htmlContent:t});this._kvkkSlot.appendChild(e)}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=Ml(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 Dl(t);if(e){this._routeAttachmentFile(e),this._closeAttachMenu();return}be("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 g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";for(let k=0;k<2;k++){const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",k===1&&T.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),g.appendChild(T)}const d=document.createElement("div");d.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",g.appendChild(d),c.appendChild(l),c.appendChild(g),o.appendChild(c);const 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 k=0;k<3;k++){const T=document.createElement("li"),z=document.createElement("div");z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",k===1&&z.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),k===2&&z.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),T.appendChild(z),b.appendChild(T)}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 p=document.createElement("div");p.className="gengage-chat-comparison-key-differences-content";for(let k=0;k<4;k++){const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",p.appendChild(T)}m.appendChild(p),r.appendChild(m);const y=document.createElement("div");y.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",y.appendChild(_),r.appendChild(y);const v=document.createElement("div");v.className="gengage-chat-comparison-skeleton-table-wrap";const w=document.createElement("div");w.className="gengage-chat-comparison-skeleton-table-head";const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-corner",w.appendChild(E);for(let k=0;k<3;k++){const T=document.createElement("div");T.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 O=document.createElement("div");O.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const Z=document.createElement("div");Z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",T.appendChild(z),T.appendChild(O),T.appendChild(Z),w.appendChild(T)}v.appendChild(w);for(let k=0;k<3;k++){const T=document.createElement("div");T.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",T.appendChild(z);for(let O=0;O<3;O++){const Z=document.createElement("div");Z.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",T.appendChild(Z)}v.appendChild(T)}r.appendChild(v),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)},Ui))}_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="${ye(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=xe(e)),this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const e=this.messagesEl.querySelector(`[data-message-id="${ye(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="${ye(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="${ye(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+Ua,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,o+Ua),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=Da[e.icon]??Fa,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 g=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||g.display==="none"||g.visibility==="hidden"?!1:l.getClientRects().length>0});if(a.length===0)return;const n=a[0],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}))}hideCartToast(){this._cartToastTimerId!==null&&(window.clearTimeout(this._cartToastTimerId),this._cartToastTimerId=null);const t=this._cartToastEl;t&&(this._cartToastEl=null,t.classList.remove("gengage-chat-cart-toast--visible"),window.setTimeout(()=>{t.remove()},300))}showCartToast(t,e){const a=e?.tone??"success",n=e?.autoHideMs??2500;let i=this._cartToastEl;(!i||!i.isConnected)&&(i=document.createElement("div"),i.className="gengage-chat-cart-toast",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),this.root.appendChild(i),this._cartToastEl=i),this._cartToastTimerId!==null&&(window.clearTimeout(this._cartToastTimerId),this._cartToastTimerId=null),i.classList.toggle("gengage-chat-cart-toast--neutral",a==="neutral"),i.textContent=t,i.classList.remove("gengage-chat-cart-toast--visible"),i.offsetWidth,i.classList.add("gengage-chat-cart-toast--visible"),n!==null&&(this._cartToastTimerId=window.setTimeout(()=>{this.hideCartToast()},n))}destroy(){Pi(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.hideCartToast(),this._closeAttachMenu();for(const t of this._cleanups)t();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}}}));function ji(t){return t==="watch_expert"?"account_expert":$i.includes(t)?t:null}function ql(t){return typeof t=="string"?ji(t):null}function Ce(t){return t==null||typeof t!="object"||Array.isArray(t)?null:t}function Ol(...t){for(const e of t)if(typeof e=="string"){const a=e.trim();if(a.length>0)return a}}function jl(t){const e=Ce(t);if(!e)return null;const a=Ol(e.assistant_mode,e.assistantMode);if(!a)return null;const n=ji(a);return!n||n==="shopping"?null:n}function $l(t){return t==="beauty_consulting"?"user_message":"findSimilar"}var $i,Vi=P((()=>{$i=["shopping","beauty_consulting","account_expert"]})),Gi,Vl=P((()=>{Vi(),ot(),Gi=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){Re("mode","redirect metadata received",t);const e=jl(t);return e?(this.switchMode(e),!0):!1}switchMode(t){const e=this._mode;this._mode=t,Re("mode","assistant mode switched",{from:e,to:t})}updateFromContext(t){const e=t.assistant_mode;if(typeof e=="string"&&e){const a=ql(e);a?this._mode=a:Re("mode","ignoring unrecognised assistant_mode from context",e)}else e===null&&(this._mode="shopping");this._uiHints=Ce(t.ui_hints)??null}reset(){const t=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,t}resolveAttachmentActionType(){return $l(this._mode)}shouldCondenseThinking(){return this._mode!=="shopping"}}}));function Gl(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function Wl(t,e,a,n,i){if(t==="PhotoAnalysisCard"){const r=zi(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):(Re("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",e),!1)}if(t==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const r=Il(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 Kl(t){return t.renderHint==="photo_analysis"}function Yl(t,e){t.streamIncludedBeautyPhotoStep||e.drawer?.setBeautyPhotoStepCard({visible:!1}),t.pendingPhotoStepSkip&&(t.pendingPhotoStepSkip=!1,e.sendSkipMessage())}function Ql(t,e){t.pendingPhotoStepSkip&&(t.pendingPhotoStepSkip=!1,e.sendSkipMessage())}var Zl=P((()=>{Ha(),za(),ot()}));function qa(t){return Number.isFinite(t)?Math.max(0,Math.min(5,t)):0}function Oa(t){return Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t))):0}function ja(t){const e=qa(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 Se(t){t.addEventListener("error",()=>{t.style.display="none"},{once:!0})}var $e=P((()=>{}));function ae(t,e){const a=Number(t);if(!Number.isFinite(a)||a<0)return t;const n={...Wi,...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 g;return c!==void 0?g=`${l}${n.decimalSeparator}${c}`:g=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${g}`:`${g} ${n.currencySymbol}`:g}var Wi,lt=P((()=>{Wi={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1}}));function Xl(t,e,a){return e?.[t]??Qi[t]??t.replace(/_/g," ").replace(/^./u,n=>Jl(n,a))}function Jl(t,e){try{return t.toLocaleUpperCase(Fe(e))}catch{return t.toLocaleUpperCase("tr")}}function Ki(t){if(typeof t!="string")return!1;const e=Number(t);return Number.isFinite(e)&&e>0}function eg(t){const e=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;return Number.isFinite(e)&&e>0}function tg(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 ag(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 g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(g);const d=document.createElement("div");d.className="gengage-chat-comparison-recommended-body",d.classList.add("gds-clickable"),d.tabIndex=0,d.setAttribute("role","button"),d.setAttribute("aria-label",e.name);const h=document.createElement("div");if(h.className="gengage-chat-comparison-recommended-media",e.imageUrl&&ke(e.imageUrl)){const p=document.createElement("img");p.src=e.imageUrl,p.alt=e.name,p.loading="lazy",p.addEventListener("error",()=>{p.style.display="none"},{once:!0}),h.appendChild(p)}else{const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-placeholder",p.setAttribute("aria-hidden","true"),h.appendChild(p)}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",eg(e.rating)&&m.appendChild(tg(e.rating)),Ki(e.price)){const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-price",p.textContent=ae(e.price,t.pricing),m.appendChild(p)}if(m.childElementCount>0&&f.appendChild(m),t.recommendedText){const p=document.createElement("p");p.className="gengage-chat-comparison-recommended-text",p.innerHTML=xe(t.recommendedText),f.appendChild(p)}d.appendChild(f);const u=()=>{o({sku:e.sku,name:e.name})};if(d.addEventListener("click",u),d.addEventListener("keydown",p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),u())}),l.appendChild(d),i.length>0){const p=document.createElement("div");p.className="gengage-chat-comparison-highlights",p.dataset.gengagePart="comparison-highlights";const y=document.createElement("div");y.className="gengage-chat-comparison-highlights-label",y.textContent=s?.highlightsLabel??"Key Highlights",p.appendChild(y);const _=document.createElement("ul");for(const v of i){const w=document.createElement("li");w.textContent=v,_.appendChild(w)}p.appendChild(_),l.appendChild(p)}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 g=document.createElement("summary");g.className="gengage-chat-comparison-key-differences-summary";const d=document.createElement("span");d.className="gengage-chat-comparison-key-differences-summary-label",d.textContent=s?.keyDifferencesLabel??"Key Differences";const h=document.createElement("span");h.className="gengage-chat-comparison-key-differences-summary-meta",h.textContent=s?.viewMoreLabel??"Show More",g.appendChild(d),g.appendChild(h),l.appendChild(g);const f=document.createElement("div");f.className="gengage-chat-comparison-key-differences-content",f.innerHTML=xe(ng(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 g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(g);const d=document.createElement("ul");for(const h of r)ig(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 g=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 p=document.createElement("div");p.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",p.tabIndex=0,p.setAttribute("role","button"),p.setAttribute("aria-label",m.name),p.title=m.name;const y=()=>{o({sku:m.sku,name:m.name})};if(p.addEventListener("click",y),p.addEventListener("keydown",v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),y())}),m.imageUrl&&ke(m.imageUrl)){const v=document.createElement("img");v.src=m.imageUrl,v.alt=m.name,v.loading="lazy",v.addEventListener("error",()=>{v.style.display="none"},{once:!0}),p.appendChild(v)}else{const v=document.createElement("div");v.className="gengage-chat-comparison-table-header-img-placeholder",v.setAttribute("aria-hidden","true"),p.appendChild(v)}const _=document.createElement("div");if(_.className="gengage-chat-comparison-table-product-name",_.textContent=m.name,p.appendChild(_),Ki(m.price)){const v=document.createElement("div");v.className="gengage-chat-comparison-table-price",v.textContent=ae(m.price,t.pricing),p.appendChild(v)}u.appendChild(p),d.appendChild(u)}g.appendChild(d),l.appendChild(g);const f=document.createElement("tbody");for(const m of n){const u=document.createElement("tr"),p=document.createElement("td");p.className="gengage-chat-comparison-label",p.textContent=Xl(m.label,s?.criteriaLabels,t.locale),u.appendChild(p);for(let y=0;y<m.values.length;y++){const _=document.createElement("td");a[y]?.sku===e?.sku&&(_.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const v=m.values[y]??"";Yi(v)?_.innerHTML=xe(v):_.textContent=v,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 g=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const d=g[0],h=g[g.length-1];l.shiftKey&&document.activeElement===d?(l.preventDefault(),h.focus()):!l.shiftKey&&document.activeElement===h&&(l.preventDefault(),d.focus())}),c}function ng(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 ig(t,e){const a=xe(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=xe(o.innerHTML),t.appendChild(s)}return}const r=document.createElement("li");Yi(e)?r.innerHTML=a:r.textContent=e,t.appendChild(r)}function Yi(t){return/<\/?[a-z][\s\S]*>/i.test(t)}var Qi,rg=P((()=>{pe(),lt(),mt(),Qi={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 kt(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 Zi=P((()=>{}));function og(t){if(typeof t!="string")return[jt];const e=t.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return e.length===0?[jt]:Array.from(new Set(e.map(a=>a.toLocaleLowerCase()))).map(a=>e.find(n=>n.toLocaleLowerCase()===a)??jt)}function sg(t){return t==="positive"||t==="negative"||t==="neutral"?t:"neutral"}function cg(t){if(typeof t!="string")return"";const e=t.trim().replace(/\s+/g," ");return e.length<=$a?e:`${e.slice(0,$a-3).trimEnd()}...`}function lg(t){return t.positive>t.negative?"positive":t.negative>t.positive?"negative":"neutral"}function gg(t){return kt(t==="positive"?["M7 17 17 7","M7 7h10v10"]:t==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function dg(t,e="1 customer mentions",a="customers mention"){return t===1?e:`${t} ${a}`}function pg(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=sg(m.review_class),p=cg(m.review_text),y=og(m.review_tag);for(const _ of y){const v=_.toLocaleLowerCase();let w=r.get(v);if(w||(w={key:v,label:_,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},r.set(v,w)),w.mentions+=1,u==="positive"?w.positive+=1:u==="negative"?w.negative+=1:w.neutral+=1,p.length>0&&w.snippets.length<Xi&&!w.snippets.some(E=>E.text===p)){const E={text:p,tone:u};m.review_rating!==void 0&&String(m.review_rating).length>0&&(E.rating=m.review_rating),w.snippets.push(E)}}}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 g=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(!g)return;const m=o.find(_=>_.key===g);if(!m)return;const u=document.createElement("div");u.className="gengage-chat-review-detail-meta";const p=document.createElement("span");if(p.className="gengage-chat-review-detail-mentions",p.textContent=`${dg(m.mentions,e?.reviewCustomersMentionSingular,e?.reviewCustomersMentionPlural)} "${m.label}"`,u.appendChild(p),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 y=document.createElement("div");y.className="gengage-chat-review-snippets";for(const _ of m.snippets){const v=document.createElement("article");v.className="gengage-chat-review-snippet",v.dataset.tone=_.tone;const w=document.createElement("div");if(w.className="gengage-chat-review-snippet-text",w.textContent=`"${_.text}"`,v.appendChild(w),_.rating!==void 0&&String(_.rating).length>0){const E=document.createElement("div");E.className="gengage-chat-review-snippet-rating",E.textContent=`★ ${String(_.rating)}`,v.appendChild(E)}y.appendChild(v)}h.appendChild(y)},b=()=>{for(const m of d.querySelectorAll(".gengage-chat-review-subject")){const u=m.dataset.subjectKey===g;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=lg(m),p=document.createElement("button");p.type="button",p.className="gengage-chat-review-subject gds-chip",p.dataset.subjectKey=m.key,p.dataset.tone=u;const y=document.createElement("span");y.className="gengage-chat-review-subject-icon",y.appendChild(gg(u)),p.appendChild(y);const _=document.createElement("span");_.className="gengage-chat-review-subject-label",_.textContent=m.label,p.appendChild(_);const v=document.createElement("span");v.className="gengage-chat-review-subject-count",v.textContent=`(${m.mentions})`,p.appendChild(v),p.addEventListener("click",()=>{g=m.key,b(),f()}),d.appendChild(p)}return a.appendChild(d),b(),f(),a.appendChild(h),a}var jt,$a,Xi,hg=P((()=>{Zi(),jt="General",$a=220,Xi=6}));function ug(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 gt(t,e){if(t.productPriceUi?.showCampaignReason===!0)return ug(e)}function Ct(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 $t(t){const e=document.createElement("div");return e.className="gengage-chat-campaign-reason",e.textContent=t,e}function Vt(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(ke(r))return r}}const a=t.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(ke(n))return n}}function Gt(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,Se(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 Va=P((()=>{pe(),$e()}));function mg(){try{return globalThis.GENGAGE_TOPPICKS_MOBILE_LAYOUT==="uniform"}catch{return!1}}function Ji(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 er(t,e){if(!t||!e)return null;const a=ar[t];return a?e[a]??t:t}function fg(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 bg(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&&ke(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",fe(l,"src",s),l.loading="lazy",l.alt=e,Se(l),r.appendChild(l)}const c=Ji(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 g=n.i18n?.findSimilarLabel??"Find Similar",d=document.createElement("button");d.className="gengage-chat-find-similar-pill",d.type="button",d.setAttribute("aria-label",g),d.dataset.tooltip=g,d.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const h=document.createElement("span");h.className="gengage-chat-find-similar-pill-text",h.textContent=g,d.appendChild(h),d.addEventListener("click",f=>{f.stopPropagation(),n.onAction({title:g,type:"findSimilar",payload:{sku:c}})}),l.appendChild(d),r.appendChild(l)}a.appendChild(r)}function vg(t,e,a){const n=t.price,i=t.originalPrice;if(!n)return;const r=gt(a,t),o=Ct(a,t),s=!!(i&&i!==n),c=!!(r&&s),l=Vt(a,t),g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",g.dataset.gengagePart="ai-top-pick-price",c){const d=Gt({reasonText:r,salePriceFormatted:ae(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline"),g.appendChild(d);const 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=ae(i,a.pricing),g.appendChild(h),g.appendChild(f)}else{const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=ae(i,a.pricing),g.appendChild(h),g.appendChild(document.createTextNode(" ")),g.appendChild(d)}e.appendChild(g);return}if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=ae(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=ae(i,a.pricing),g.appendChild(d),g.appendChild(h),g.appendChild(f)}else if(s){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=ae(i,a.pricing),g.appendChild(d),g.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-current",h.textContent=ae(n,a.pricing),g.appendChild(h)}else{const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=ae(n,a.pricing),g.appendChild(d)}if(r){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price-stack",d.appendChild($t(r)),d.appendChild(g),e.appendChild(d)}else e.appendChild(g)}function yg(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 tr(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=Ji(t),c=o.url??"",l=o.cartCode,g=o.inStock,d=!!(s&&l&&g!==!1),h=t.action;s&&e.onProductClick?(i.classList.add("gds-clickable"),i.addEventListener("click",k=>{if(k.target.closest(".gengage-chat-ai-toppick-cta")||k.target.closest(".gengage-chat-favorite-btn")||k.target.closest(".gengage-chat-find-similar-pill"))return;const T=o.name;e.onProductClick?.({sku:s,url:c,...T?{name:T}:{}})})):h&&(i.classList.add("gds-clickable"),i.addEventListener("click",k=>{k.target.closest(".gengage-chat-ai-toppick-cta")||k.target.closest(".gengage-chat-favorite-btn")||k.target.closest(".gengage-chat-find-similar-pill")||e.onAction(h)}));const f=o.name||"Product image",b=!a&&e.isMobile===!0&&!r,m=a?er(t.role,e.i18n)??e.i18n?.roleWinner??"TOP MATCH":er(t.role,e.i18n);if(m&&!b){const k=document.createElement("span");k.className="gengage-chat-ai-toppick-badge gds-badge",k.dataset.gengagePart="ai-top-pick-role-badge",k.textContent=m,i.appendChild(k)}const u=document.createElement("div");u.className="gengage-chat-ai-toppick-top-row",u.dataset.gengagePart="ai-top-pick-top-row",bg(t,f,u,e,{skipOverlayActions:b});const p=document.createElement("div");if(p.className="gengage-chat-ai-toppick-body",p.dataset.gengagePart="ai-top-pick-body",m&&b){const k=document.createElement("div");k.className="gengage-chat-ai-toppick-role-line",k.dataset.gengagePart="ai-top-pick-role-line",k.textContent=m,p.appendChild(k)}const y=o.name;if(y){const k=document.createElement("div");k.className="gengage-chat-ai-toppick-name",k.dataset.gengagePart="ai-top-pick-name",k.textContent=y,p.appendChild(k)}const _=fg(o);_&&p.appendChild(_),vg(o,p,e),t.labels&&t.labels.length>0&&p.appendChild(_g(t.labels)),u.appendChild(p),i.appendChild(u);const v=document.createElement("div");if(v.className="gengage-chat-ai-toppick-detail",v.dataset.gengagePart="ai-top-pick-detail",a)yg(t,v,e);else{const k=typeof t.reason=="string"?t.reason.trim():"";if(k){const T=document.createElement("p");T.className="gengage-chat-ai-toppick-snippet",T.dataset.gengagePart="ai-top-pick-snippet",T.textContent=k,v.appendChild(T)}}v.childNodes.length>0&&i.appendChild(v);const w=!!(s&&e.topPicksLoadingSku===s),E=(d||h)&&!b;if(w||d||h){const k=document.createElement("div");if(k.className="gengage-chat-ai-toppick-spinner",k.dataset.gengagePart="ai-top-pick-spinner",k.style.display=w?"":"none",i.appendChild(k),E){const T=document.createElement("button");T.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",T.dataset.gengagePart="ai-top-pick-cta",T.type="button",T.textContent=d?e.i18n?.addToCartButton??"Add to Cart":e.i18n?.viewDetails??"View Details",T.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 O=o.name;e.onProductClick({sku:s,url:c,...O?{name:O}:{}});return}e.onAction(h)}}),i.appendChild(T)}}return i}function xg(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&&mg(),o=n[0];if(i.appendChild(tr(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],g=l.role==="winner";s.appendChild(tr(l,e,g,{uniformMobileLayout:r}))}i.appendChild(s)}return a.appendChild(i),a}function _g(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 ar,wg=P((()=>{lt(),pe(),$e(),Va(),ar={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"}}));function kg(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(kt(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z","M8 9h8","M8 13h6"])),a.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body",l.dataset.gengagePart="grounding-review-body";const g=document.createElement("div");if(g.className="gengage-chat-grounding-review-title",g.dataset.gengagePart="grounding-review-title",g.textContent=i??e.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(g),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(kt(["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 Cg=P((()=>{Zi()}));function Sg(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:ct(i)}}function Eg(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(Sg(s))),s.image&&ke(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 g=document.createElement("span");if(g.className="gengage-chat-grouping-card-name",g.dataset.gengagePart="ai-grouping-card-name",g.textContent=s.name,l.appendChild(g),s.labels&&s.labels.length>0){const 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 Tg=P((()=>{pe(),Ca()}));function Pg(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&&ke(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 Ag=P((()=>{pe()}));function Lg(t,e){const a=document.createElement("div");a.className="gengage-chat-inline-question-buttons",a.dataset.gengagePart="inline-question-buttons";const n=t.props?.buttons??[];for(const i of n){if(typeof i?.label!="string"||!i.label.trim())continue;const r=document.createElement("button");r.className="gengage-chat-inline-question-btn gds-chip",r.dataset.gengagePart="inline-question-button",r.type="button";const o=document.createElement("span");o.className="gengage-chat-inline-question-icon",o.setAttribute("aria-hidden","true"),o.textContent="✦";const s=document.createElement("span");s.className="gengage-chat-inline-question-label",s.textContent=i.label,r.append(o,s),r.addEventListener("click",()=>e.onAction(i.action)),a.appendChild(r)}return a}var Ig=P((()=>{}));function nr(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 g=document.createElement("button");if(g.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",g.type="button",g.textContent=n,g.disabled=!a,a||g.classList.add("gengage-chat-comparison-floating-action--disabled"),g.addEventListener("click",()=>{a&&e.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...t],gengage_analytics_source:"floating_compare_dock"}})}),r.appendChild(g),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 ir=P((()=>{}));function Ng(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 Mg=P((()=>{}));function Bg(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,rr)}function Rg(t){const e=Bg(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(zg(t)),e.length>0&&n.appendChild(Hg(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 zg(t){const e=document.createElement("div");if(e.className="gengage-chat-categories-group-selection",e.dataset.gengagePart="categories-group-selection",t.image&&ke(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",Se(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 Hg(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 Fg(t,e){const a=t.props?.groups??[],n=t.props?.filterTags??[],i=`gengage-cat-${or++}`,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=g=>{for(let d=0;d<s.length;d++){const h=d===g;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 g=0;g<a.length;g++){const d=a[g],h=`${i}-tab-${g}`,f=`${i}-panel-${g}`,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(g===0)),b.tabIndex=g===0?0:-1,g===0&&b.classList.add("gengage-chat-categories-tab--active","is-active"),d.image&&ke(d.image)){const _=document.createElement("img");_.className="gengage-chat-categories-tab-image",_.draggable=!1,_.src=d.image,_.alt=d.groupName,_.loading="lazy",Se(_),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(g)),b.addEventListener("keydown",_=>{let v=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?v=(g+1)%a.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?v=(g-1+a.length)%a.length:_.key==="Home"?v=0:_.key==="End"&&(v=a.length-1),v>=0&&(_.preventDefault(),l(v),s[v].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),g!==0&&(u.style.display="none");const p=Rg(d);p&&u.appendChild(p);const y=document.createElement("div");y.className="gengage-chat-categories-grid",y.dataset.gengagePart="categories-grid";for(const _ of d.products){const v=Dg(_,e);y.appendChild(v)}u.appendChild(y),c.push(u)}r.appendChild(o);for(const g of c)r.appendChild(g);if(n.length>0){const g=document.createElement("div");g.className="gengage-chat-categories-filter-tags gds-toolbar",g.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)}),g.appendChild(h)}r.appendChild(g)}return r}function Dg(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&&ke(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",Se(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=ae(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 rr,or,Ug=P((()=>{pe(),lt(),$e(),rr=4,or=0}));function qg(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 Og=P((()=>{}));function Ve(t){return typeof t=="string"?t:""}function jg(t){return Array.isArray(t)?t.map(e=>{if(!e||typeof e!="object")return null;const a=e;return{imageUrl:Ve(a.imageUrl)||void 0,name:Ve(a.name)||void 0}}).filter(e=>e!==null):[]}function $g(t,e){const a=t.props??{},n=Ve(a.eyebrow),i=Ve(a.title),r=a.showTitle!==!1,o=Ve(a.ctaLabel)||e.i18n?.showPanelAriaLabel||"Show Results",s=Ve(a.panelMessageId),c=Ve(a.highlightMessageId),l=Ve(a.threadId),g=jg(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:sr,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(g.length>0){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__previews";for(const u of g){const p=document.createElement("div");p.className="gengage-chat-panel-restore-card__thumb";const y=u.imageUrl;if(y&&de(y)){const _=document.createElement("img");_.loading="lazy",_.alt=u.name||i,fe(_,"src",y),Se(_),p.appendChild(_)}m.appendChild(p)}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 sr,cr=P((()=>{pe(),$e(),sr="frontend_restore_panel_message"}));function Vg(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",p=>{p.target.closest("a")||e.onProductSelect?.(a)});const i=a.imageUrl;if(i&&de(i)){const p=document.createElement("div");p.className="gengage-chat-product-summary__image",p.dataset.gengagePart="product-summary-image";const y=document.createElement("img");y.loading="lazy",fe(y,"src",i),y.alt=a.name||"Product image",Se(y),p.appendChild(y),n.appendChild(p)}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 p=document.createElement("div");p.className="gengage-chat-product-summary__name",p.dataset.gengagePart="product-summary-name";const y=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;p.textContent=y,p.title=y,r.appendChild(p)}const c=a.rating,l=a.reviewCount;if(e.hideUserReviews!==!0&&typeof c=="number"&&Number.isFinite(c)&&c>0){const p=document.createElement("div");if(p.className="gengage-chat-product-summary__rating",p.dataset.gengagePart="product-summary-rating",p.appendChild(ja(c)),typeof l=="number"&&Number.isFinite(l)){const y=document.createElement("span");y.className="gengage-chat-product-summary__review-count",y.textContent=` (${l})`,p.appendChild(y)}r.appendChild(p)}const g=a.price,d=a.originalPrice;if(g){const p=gt(e,a),y=Ct(e,a),_=!!(d&&d!==g),v=document.createElement("div");v.className="gengage-chat-product-summary__price",v.dataset.gengagePart="product-summary-price";const w=!!(p&&_),E=Vt(e,a);if(w){const k=Gt({reasonText:p,salePriceFormatted:ae(g,e.pricing),...E!==void 0?{logoUrl:E}:{}});if(_&&y==="inline"){v.classList.add("gengage-chat-product-summary__price--inline"),v.appendChild(k);const T=document.createElement("span");T.className="gengage-chat-product-summary__price-sep",T.setAttribute("aria-hidden","true");const z=document.createElement("span");z.className="gengage-chat-product-summary__price-original",z.textContent=ae(d,e.pricing),v.appendChild(T),v.appendChild(z)}else{const T=document.createElement("span");T.className="gengage-chat-product-summary__price-original",T.textContent=ae(d,e.pricing),v.appendChild(T),v.appendChild(document.createTextNode(" ")),v.appendChild(k)}r.appendChild(v)}else{if(_&&y==="inline"){v.classList.add("gengage-chat-product-summary__price--inline");const k=document.createElement("span");k.className="gengage-chat-product-summary__price-current",k.textContent=ae(g,e.pricing);const T=document.createElement("span");T.className="gengage-chat-product-summary__price-sep",T.setAttribute("aria-hidden","true");const z=document.createElement("span");z.className="gengage-chat-product-summary__price-original",z.textContent=ae(d,e.pricing),v.appendChild(k),v.appendChild(T),v.appendChild(z)}else if(_){const k=document.createElement("span");k.className="gengage-chat-product-summary__price-original",k.textContent=ae(d,e.pricing),v.appendChild(k),v.appendChild(document.createTextNode(" "));const T=document.createElement("span");T.className="gengage-chat-product-summary__price-current",T.textContent=ae(g,e.pricing),v.appendChild(T)}else{const k=document.createElement("span");k.className="gengage-chat-product-summary__price-current",k.textContent=ae(g,e.pricing),v.appendChild(k)}if(p){const k=document.createElement("div");k.className="gengage-chat-product-summary__price-stack",k.appendChild($t(p)),k.appendChild(v),r.appendChild(k)}else r.appendChild(v)}}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 p=document.createElement("button");p.type="button",p.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",p.dataset.gengagePart="product-summary-cta",p.textContent=e.i18n?.addToCartButton??"Add to Cart",p.addEventListener("click",y=>{y.stopPropagation(),e.onAction({title:e.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:f,cartCode:m,quantity:1}})}),n.appendChild(p)}else if(h&&de(h)){const p=document.createElement("a");p.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",p.dataset.gengagePart="product-summary-cta",fe(p,"href",h),fe(p,"target","_blank"),fe(p,"rel","noopener noreferrer"),p.textContent=e.i18n?.productCtaLabel??"View",n.appendChild(p)}return n}var Gg=P((()=>{lt(),pe(),$e(),Va()})),lr,Wg=P((()=>{Ha(),za(),lr={PhotoAnalysisCard:({element:t,context:e})=>zl(t,e),BeautyPhotoStep:({element:t,context:e})=>Ri(t,e)}}));function Wt(){return window.innerWidth<768}function gr(){return{...Ka}}function dr(t,e,a=Ka,n=Zt){return ma({spec:t,context:e,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function Kg(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 Yg(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 pr(t,e,a,n,i){t.replaceChildren();const r=Ct(e,a),o=!!(i&&n&&i!==n),s=gt(e,a),c=!!(s&&o),l=Vt(e,a);if(!n||parseFloat(n)<=0)return;if(c){const d=Gt({reasonText:s,salePriceFormatted:ae(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=ae(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=ae(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=ae(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=ae(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 g=document.createElement("span");if(g.className="gengage-chat-product-card-current-price",g.textContent=ae(n,e.pricing),t.appendChild(g),o){t.appendChild(document.createTextNode(" "));const d=document.createElement("span");d.className="gengage-chat-product-card-original-price",d.textContent=ae(i,e.pricing),t.appendChild(d)}}function hr(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=gt(e,a),c=!!(s&&o),l=Vt(e,a);if(c){const d=Gt({reasonText:s,salePriceFormatted:ae(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=ae(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=ae(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=ae(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=ae(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=ae(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=ae(n,e.pricing),t.appendChild(d)}const g=Kt(a,"discountPercent","price_discount_rate");if(!e.hideProductDiscountBadge&&typeof g=="number"&&g>0){const d=document.createElement("span");d.className="gengage-chat-product-details-discount-badge",d.textContent=`%${Oa(g)}`,t.appendChild(d)}}function Ga(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&&de(s)?s:void 0,g=()=>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",S=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!S.target.closest(".gengage-chat-product-card-atc")&&!S.target.closest(".gengage-chat-product-card-cta")){if(r){g()||e.onAction(r);return}e.onProductSelect?.(n)}}));const d=n.imageUrl;if(d&&de(d)){const S=document.createElement("div");S.className="gengage-chat-product-card-img-wrapper";const M=document.createElement("img");M.className="gengage-chat-product-card-img",M.loading="lazy",fe(M,"src",d);const B=n.name;B&&(M.alt=B),Se(M),S.appendChild(M);const D=n.discountPercent;if(!e.hideProductDiscountBadge&&typeof D=="number"&&D>0){const x=document.createElement("span");x.className="gengage-chat-product-card-discount-badge",x.textContent=`%${Oa(D)}`,S.appendChild(x)}const H=document.createElement("div");H.className="gengage-chat-product-card-img-actions";const ie=n.sku;if(ie&&e.onFavoriteToggle){const x=document.createElement("button");x.className="gengage-chat-favorite-btn",x.type="button",x.dataset.gengageFavoriteSku=ie,x.setAttribute("aria-label",e.i18n?.addToFavoritesLabel??"Add to favorites");const I=e.favoritedSkus?.has(ie)??!1;I&&x.classList.add("gengage-chat-favorite-btn--active"),x.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${I?"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",L=>{L.stopPropagation(),x.classList.toggle("gengage-chat-favorite-btn--active");const R=x.querySelector("svg");R&&R.setAttribute("fill",x.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),e.onFavoriteToggle(ie,n)}),H.appendChild(x)}const X=n.sku,K=e.i18n?.findSimilarLabel??"Find Similar";if(X){const x=document.createElement("button");x.className="gengage-chat-find-similar-pill",x.type="button",x.setAttribute("aria-label",K),x.dataset.tooltip=K,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 I=document.createElement("span");I.className="gengage-chat-find-similar-pill-text",I.textContent=K,x.appendChild(I),x.addEventListener("click",L=>{L.stopPropagation(),e.onAction({title:K,type:"findSimilar",payload:{sku:X}})}),H.appendChild(x)}H.childElementCount>0&&S.appendChild(H),a.appendChild(S)}const h=document.createElement("div");h.className="gengage-chat-product-card-body";const f=n.brand;if(f){const S=document.createElement("div");S.className="gengage-chat-product-card-brand",S.textContent=f,h.appendChild(S)}const b=n.rating,m=n.reviewCount,u=n.price,p=n.originalPrice,y=n.price_async,_=gt(e,n),v=Ct(e,n),w=!!(p&&u&&p!==u&&parseFloat(u)>0),E=!!(_&&w),k=!!(_&&!E||w&&v==="inline"),T=typeof b=="number"&&Number.isFinite(b)&&b>0,z=document.createElement("div");z.className="gengage-chat-product-card-meta-row";const O=document.createElement("div");O.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const Z=k?(()=>{const S=document.createElement("div");return S.className="gengage-chat-product-card-price-stack",_&&!E&&S.appendChild($t(_)),S.appendChild(O),S})():O;if(y===!0){const S=document.createElement("span");S.className="gengage-chat-price-skeleton",O.appendChild(S),setTimeout(()=>{S.parentElement&&(u&&parseFloat(u)>0?pr(O,e,n,u,n.originalPrice):S.remove())},300)}else u&&parseFloat(u)>0&&pr(O,e,n,u,p);if((O.childElementCount>0||y===!0)&&z.appendChild(Z),T){const S=document.createElement("div");S.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const M=qa(b),B=[`${M.toFixed(1)}`,"out of 5 stars"];typeof m=="number"&&Number.isFinite(m)&&B.push(`(${m} reviews)`),S.setAttribute("aria-label",B.join(" "));const D=document.createElement("span");D.className="gengage-chat-product-card-rating-compact-star",D.setAttribute("aria-hidden","true"),D.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 H=document.createElement("span");H.className="gengage-chat-product-card-rating-compact-value",H.textContent=M.toFixed(1),S.appendChild(D),S.appendChild(H),z.appendChild(S)}if(z.childElementCount===0&&(z.classList.add("gengage-chat-product-card-meta-row--empty"),z.setAttribute("aria-hidden","true")),h.appendChild(z),o){const S=document.createElement("div");S.className="gengage-chat-product-card-name",S.textContent=o,S.title=o,h.appendChild(S)}const le=n.inStock;if(e.hideStockStatus!==!0&&typeof le=="boolean"){const S=document.createElement("div");S.className=`gengage-chat-product-card-stock ${le?"is-in-stock":"is-out-of-stock"}`,S.textContent=le?e.i18n?.inStockLabel??"In Stock":e.i18n?.outOfStockLabel??"Out of Stock",h.appendChild(S)}a.appendChild(h);const se=n.cartCode,A=!!(se&&c&&le!==!1),F=e.i18n?.productCtaLabel??"View";if(A){const S=document.createElement("div");S.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=F,M.addEventListener("click",B=>{B.stopPropagation(),e.onAction({title:e.i18n?.addToCartButton??F,type:"addToCart",payload:{sku:c,cartCode:se,quantity:1}})}),S.appendChild(M),a.appendChild(S)}else if(r){const S=document.createElement("button");S.className="gengage-chat-product-card-cta",S.type="button",S.textContent=r.type==="launchSingleProduct"?F:r.title||F,S.addEventListener("click",M=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){M.stopPropagation();return}g()||e.onAction(r)}),a.appendChild(S)}else if(l){const S=document.createElement("a");S.className="gengage-chat-product-card-cta",fe(S,"href",l),fe(S,"target","_blank"),fe(S,"rel","noopener noreferrer"),S.textContent=F,S.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(S)}if(e.comparisonSelectMode&&c&&e.onToggleComparisonSku){const S=document.createElement("div");S.className="gengage-chat-comparison-select-wrapper";const M=e.comparisonSelectedSkus?.includes(c)??!1;M&&S.classList.add("gengage-chat-comparison-select-wrapper--selected");const B=n.name??c,D=e.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";S.setAttribute("role","group"),S.setAttribute("aria-label",`${String(B)}. ${D}`);const H=document.createElement("button");H.type="button",H.className="gengage-chat-comparison-checkbox",H.dataset.selected=M?"true":"false",H.setAttribute("aria-pressed",M?"true":"false");const ie=document.createElement("span");ie.className="gengage-chat-comparison-checkbox-icon",ie.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 X=document.createElement("span");X.className="gengage-chat-comparison-checkbox-label",X.textContent=M?e.i18n?.comparisonSelectedLabel??"Selected":e.i18n?.comparisonSelectLabel??"Select to compare",H.appendChild(ie),H.appendChild(X),H.addEventListener("click",x=>{x.stopPropagation(),e.onToggleComparisonSku?.(c)});const K=document.createElement("div");return K.className="gengage-chat-comparison-card-hint",K.setAttribute("aria-hidden","true"),K.textContent=D,S.addEventListener("click",x=>{x.target.closest(".gengage-chat-comparison-checkbox")||(x.stopPropagation(),e.onToggleComparisonSku?.(c))}),S.appendChild(H),S.appendChild(K),S.appendChild(a),S}return a}function Ee(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 Kt(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 Yt(t,...e){for(const a of e){const n=t[a];if(typeof n=="boolean")return n}}function Qg(t,...e){for(const a of e){const n=t[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function Zg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.trim().length>0):[]}function Xg(t){const e=[...Zg(t.images),Ee(t,"imageUrl","image_url","image")].filter(a=>!!a&&de(a));return Array.from(new Set(e))}function Jg(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 ed(t){const e=Ee(t,"description_html","descriptionHtml");if(e){const n=Jg(e);if(n)return{text:n,html:e}}const a=Ee(t,"description");return a?{text:a}:void 0}function Qt(t){return Array.isArray(t)?t.map(e=>{if(!e||typeof e!="object")return null;const a=e,n=Ee(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 ur(t){const e=Qt(t.features);return e.length>0?e:Qt(t.specifications)}function td(t){const e=t.specifications,a=Qt(e);if(a.length>0)return Array.isArray(e)?a:Object.fromEntries(a.map(i=>[i.key,i.value]));const n=Qt(t.features);return n.length>0?n:void 0}function Ue(t,...e){return Ee(t,...e)}function mr(t,...e){return Kt(t,...e)}function fr(t){return Ue(t,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function br(t){const e=Ue(t,"type","attribute","option_name","attribute_name");return e||(Ue(t,"value")?Ue(t,"name","variant_name"):void 0)}function ad(t){const e=br(t)?.toLowerCase();return!!(Ee(t,"color","colour","color_hex","hex","swatch","swatchColor")||e&&Ya.has(e))}function vr(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 nd(t){const e=vr(Ue(t,"swatchColor","swatch","color_hex","hex","color","colour"));if(e)return e;if(ad(t))return vr(fr(t))}function id(t){return Ue(t,"image","imageUrl","image_url","swatchImage","swatch_image")}function rd(t){return mr(t,"price_discounted","priceDiscounted")??Ue(t,"price_discounted","priceDiscounted")??mr(t,"price")??Ue(t,"price")}function od(t){const e=t.trim().toLowerCase();return Ya.has(e)||wr.has(e)||kr.has(e)}function sd(t){const e=t.trim().toLowerCase();return e==="renk kodu"?"Renk":e==="color code"?"Color":t.trim()}function cd(t){for(const e of Cr){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 ld(t){const e=cd(t);if(e)return e;const a=Ee(t,"sku"),n=Yt(t,"inStock","in_stock"),i=[],r=new Set,o=(c,l)=>{if(!od(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const g=String(l).trim();if(!g)return;const d=sd(c),h=`${d.toLowerCase()}:${g.toLowerCase()}`;r.has(h)||(r.add(h),i.push({name:d,value:g,sku:a,inStock:n}))},s=Qg(t,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of ur(t))o(c.key,c.value);return i}function gd(t,e){const a=Array.from(new Set(t.map(br).filter(n=>!!n)));return a.length===1?`${t.length} ${a[0]}`:e.i18n?.variantsLabel??"Variants"}function dd(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=Ee(n,"name"),r=Ee(n,"brand"),o=Ee(n,"sku"),s=Ee(n,"cartCode","cart_code"),c=Ee(n,"price"),l=Ee(n,"originalPrice","price_original"),g=Yt(n,"price_async"),d=gt(e,n),h=Ct(e,n),f=!!(l&&c&&l!==c),b=Yt(n,"inStock","in_stock"),m=Kt(n,"reviewCount","review_count"),u=Kt(n,"rating"),p=Xg(n),y=ur(n).slice(0,4);if(p.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 F=document.createElement("img");F.className="gengage-chat-product-details-img",fe(F,"src",p[0]),F.alt=i??"Product image",Se(F),A.appendChild(F);const S=document.createElement("div");S.className="gengage-chat-product-gallery-thumbs";const M=6;let B=null,D=0;const H=e.i18n,ie=H?.galleryPrevAriaLabel??"Previous image",X=H?.galleryNextAriaLabel??"Next image",K=$=>$==="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",ie),x.innerHTML=K("prev");const I=document.createElement("button");I.type="button",I.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn",I.setAttribute("aria-label",X),I.innerHTML=K("next");const L=()=>{x.disabled=D<=0,I.disabled=D>=p.length-1},R=$=>{if($<0||$>=p.length||$===D)return;const ee=p[$];if(!ee)return;fe(F,"src",ee);const Q=S.querySelectorAll(".gengage-chat-product-gallery-thumb");B&&B.classList.remove("gengage-chat-product-gallery-thumb--active"),$<M&&Q[$]?(Q[$].classList.add("gengage-chat-product-gallery-thumb--active"),B=Q[$]):B=null,D=$,L()};for(let $=0;$<p.length;$++){const ee=p[$];if($>=M)break;const Q=document.createElement("img");Q.className="gengage-chat-product-gallery-thumb",$===0&&(Q.classList.add("gengage-chat-product-gallery-thumb--active"),B=Q),fe(Q,"src",ee),Q.alt=`${i??"Product"} ${$+1}`,Q.width=48,Q.height=48,Se(Q),Q.addEventListener("click",()=>{R($)}),S.appendChild(Q)}if(p.length>M){const $=document.createElement("span");$.className="gengage-chat-product-gallery-thumb-more",$.textContent=`+${p.length-M}`,S.appendChild($)}x.addEventListener("click",$=>{$.stopPropagation(),R(D-1)}),I.addEventListener("click",$=>{$.stopPropagation(),R(D+1)}),L();let q=0;const j=50;F.addEventListener("touchstart",$=>{q=$.changedTouches[0].clientX},{passive:!0}),F.addEventListener("touchend",$=>{const ee=$.changedTouches[0].clientX,Q=q-ee;Math.abs(Q)<j||R(Q>0?Math.min(D+1,p.length-1):Math.max(D-1,0))}),A.appendChild(x),A.appendChild(I),A.appendChild(S),a.appendChild(A)}else if(p.length===1){const A=document.createElement("div");A.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const F=document.createElement("img");F.className="gengage-chat-product-details-img",F.loading="lazy",fe(F,"src",p[0]),Se(F),F.alt=i??"Product image",A.appendChild(F),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(ja(u));const F=document.createElement("span");if(F.className="gengage-chat-product-details-rating-value",F.textContent=qa(u).toFixed(1),A.appendChild(F),typeof m=="number"&&Number.isFinite(m)){const S=document.createElement("span");S.className="gengage-chat-product-details-review-count",S.textContent=` (${m})`,A.appendChild(S)}_.appendChild(A)}{const A=!!(d&&f);let F=_;if(d&&!A){const M=document.createElement("div");M.className="gengage-chat-product-details-price-stack",M.appendChild($t(d)),_.appendChild(M),F=M}const S=document.createElement("div");if(S.className="gengage-chat-product-details-price",g===!0){const M=document.createElement("span");M.className="gengage-chat-price-skeleton",S.appendChild(M),F.appendChild(S),setTimeout(()=>{if(M.parentElement)if(c&&parseFloat(c)>0)hr(S,e,n,c,l,h,f);else{const B=S.parentElement;S.remove(),B?.classList.contains("gengage-chat-product-details-price-stack")&&B.remove()}},300)}else if(c&&parseFloat(c)>0)hr(S,e,n,c,l,h,f),F.appendChild(S);else if(d){const M=F;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 v=n.promotions;if(v&&v.length>0){const A=document.createElement("div");A.className="gengage-chat-product-details-promos";for(const F of v.slice(0,3)){if(!F||/%(0(\.0+)?)\s/.test(F))continue;const S=document.createElement("span");S.className="gengage-chat-product-details-promo-badge",S.textContent=F,S.title=F,A.appendChild(S)}A.childElementCount>0&&_.appendChild(A)}if(y.length>0){const A=document.createElement("dl");A.className="gengage-chat-product-details-facts";for(const F of y){const S=document.createElement("div");S.className="gengage-chat-product-details-fact";const M=document.createElement("dt");M.textContent=F.key;const B=document.createElement("dd");B.textContent=F.value,S.appendChild(M),S.appendChild(B),A.appendChild(S)}_.appendChild(A)}const w=ld(n);if(w.length>0){const A=document.createElement("div");A.className="gengage-chat-product-variants";const F=document.createElement("div");F.className="gengage-chat-product-variants-label",F.textContent=gd(w,e),A.appendChild(F);const S=document.createElement("div");S.className="gengage-chat-product-variants-list";for(const M of w){const B=fr(M),D=Ue(M,"sku");if(!B&&!D)continue;const H=document.createElement("button");H.className="gengage-chat-product-variant-btn gds-chip",H.type="button";const ie=B??D??"";H.title=ie;const X=Yt(M,"in_stock","inStock");D&&o&&D===o?(H.classList.add("gengage-chat-product-variant-btn--active"),H.setAttribute("aria-pressed","true")):H.setAttribute("aria-pressed","false"),X===!1&&(H.classList.add("gengage-chat-product-variant-btn--out"),H.disabled=!0);const K=id(M),x=nd(M);if(K&&de(K)){const R=document.createElement("img");R.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",fe(R,"src",K),R.alt="",R.setAttribute("aria-hidden","true"),Se(R),H.appendChild(R)}else if(x){const R=document.createElement("span");R.className="gengage-chat-product-variant-swatch",R.setAttribute("aria-hidden","true"),R.style.backgroundColor=x,H.appendChild(R)}const I=document.createElement("span");I.className="gengage-chat-product-variant-label",I.textContent=ie,H.appendChild(I);const L=rd(M);if(L&&String(L)!==String(c)){const R=document.createElement("span");R.className="gengage-chat-product-variant-price",R.textContent=ae(String(L),e.pricing),H.appendChild(R)}if(D&&D!==o){const R=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=R.length>0?q.length>0&&q!==R?`${R} (${q})`:R:ie;H.addEventListener("click",()=>{e.onAction({title:j,type:"launchVariant",payload:{sku:D}})})}S.appendChild(H)}S.childElementCount>0&&(A.appendChild(S),_.appendChild(A))}const E=document.createElement("div");E.className="gengage-chat-product-details-actions";const k=t.props?.action;if(k){const A=document.createElement("button");A.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",A.type="button",A.textContent=k.title||e.i18n?.productCtaLabel||"View",A.addEventListener("click",()=>e.onAction(k)),E.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}})}),E.appendChild(A)}const T=Ee(n,"url");if(!k&&T&&de(T)){const A=document.createElement("a");A.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",fe(A,"href",T),fe(A,"target","_blank"),fe(A,"rel","noopener noreferrer"),A.textContent=e.i18n?.viewOnSiteLabel??e.i18n?.productCtaLabel??"View on Site",A.addEventListener("click",F=>{e.onProductClick&&o&&(F.preventDefault(),e.onProductClick({sku:o,url:T,...i?{name:i}:{}}))}),E.appendChild(A)}const z=T;if(z&&de(z)){let B=function(H,ie){const X=document.createElementNS(S,"circle");X.setAttribute("cx",H),X.setAttribute("cy",ie),X.setAttribute("r","3"),M.appendChild(X)},D=function(H,ie,X,K){const x=document.createElementNS(S,"line");x.setAttribute("x1",H),x.setAttribute("y1",ie),x.setAttribute("x2",X),x.setAttribute("y2",K),M.appendChild(x)};var le=B,se=D;const A=document.createElement("button");A.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",A.type="button";const F=e.i18n?.shareButton??"Share";A.title=F,A.setAttribute("aria-label",F);const S="http://www.w3.org/2000/svg",M=document.createElementNS(S,"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"),B("18","5"),B("6","12"),B("18","19"),D("8.59","13.51","15.42","17.49"),D("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{}}),E.appendChild(A)}E.childElementCount>0&&_.appendChild(E),a.appendChild(_);const O=ed(n),Z=td(n);return(O||Z)&&a.appendChild(ud(O,Z,e)),a}function Wa(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(Er.has(a))return null;if(!Sr.has(a)){const i=document.createDocumentFragment();for(const r of Array.from(e.childNodes)){const o=Wa(r);o&&i.appendChild(o)}return i}const n=document.createElement(a.toLowerCase());for(const i of Array.from(e.childNodes)){const r=Wa(i);r&&n.appendChild(r)}return n}function pd(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 hd(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=>Wa(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}}pd(t,e.text)}function ud(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",hd(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 g=Array.isArray(e)?e:Object.entries(e).map(([d,h])=>({key:d,value:h}));for(const d of g){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,g)=>{l.style.display=g===c?"":"none"})})}),n.appendChild(i);for(const s of r)n.appendChild(s);return n}function yr(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 md(){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 fd(){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 bd(){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 xr(t,e){return t.type===e.type&&t.direction===e.direction}function _r(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 vd(t,e,a,n){const i=_r(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 yd(t,e,a,n){const i=document.createElement("div");i.className="gengage-chat-product-grid-wrapper";const r=Ja(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(p=>({title:typeof p.title=="string"?p.title:"",children:Array.isArray(p.children)?p.children.filter(y=>typeof y=="string"&&!!e.elements[y]):[]})).filter(p=>p.children.length>0):[],g=l.length>1,d=!g&&l.length===1&&l[0]?.title?l[0].title:"",h=n?.panelProductListHeading??(d||void 0),f=!o&&!g&&s.length>1&&n?.onSortChange,b=p=>{if(!n?.onToggleComparisonSku)return;const y=document.createElement("button");y.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",y.type="button",n.comparisonSelectMode&&y.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&y.classList.add("gengage-chat-comparison-toggle-btn--hidden");const _=document.createElement("span");_.className="gengage-chat-comparison-toggle-icon",_.innerHTML=bd();const v=document.createElement("span");v.className="gengage-chat-comparison-toggle-label";const w=n.i18n?.compareSelected??"Compare";v.textContent=w,y.setAttribute("aria-label",w),y.title=w,y.appendChild(_),y.appendChild(v),y.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),p.appendChild(y)},m=(p,y=s.length)=>{const _=t.props?.endOfList;if(o||!(g?_===!1:_!==!0)||y===0)return;const v=n?.i18n?.viewMoreLabel??"Show More",w=document.createElement("button");w.className="gengage-chat-product-grid-view-more",w.type="button",w.textContent=v,w.addEventListener("click",()=>{n?.onAction({title:v,type:"moreProductList",payload:{}})}),p.appendChild(w)},u=()=>{const p=n?.isMobile??Wt();n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!p&&i.appendChild(nr(n.comparisonSelectedSkus,n))};if(f){const p=document.createElement("div");p.className="gengage-chat-product-sort-toolbar",p.setAttribute("role","toolbar"),p.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let y=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"}],v=document.createElement("div");v.className="gengage-chat-product-sort-dropdown";const w=document.createElement("button");w.type="button",w.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",w.setAttribute("aria-haspopup","listbox"),w.setAttribute("aria-expanded","false");const E=n.i18n?.sortToolbarAriaLabel??"Sort products",k=document.createElement("span");k.className="gengage-chat-product-sort-trigger-icon";const T=document.createElement("span");T.className="gengage-chat-product-sort-trigger-label";const z=B=>{const D=_.find(H=>xr(H.sortState,B))??_[0];T.textContent=D.label,k.innerHTML=yr(D.icon),v.dataset.sortIcon=D.icon,w.setAttribute("aria-label",`${E}: ${D.label}`),w.title=D.label};z(y);const O=document.createElement("span");O.className="gengage-chat-product-sort-trigger-chevron",O.innerHTML=md(),w.appendChild(k),w.appendChild(T),w.appendChild(O);const Z=document.createElement("div");Z.className="gengage-chat-product-sort-menu gds-menu",Z.hidden=!0,Z.setAttribute("role","listbox"),Z.setAttribute("aria-label",E);const le=p.ownerDocument;let se=null;const A=()=>{Z.hidden=!0,v.classList.remove("gengage-chat-product-sort-dropdown--open"),w.setAttribute("aria-expanded","false"),se?.abort(),se=null},F=B=>{v.classList.contains("gengage-chat-product-sort-dropdown--open")&&(v.contains(B.target)||A())},S=B=>{B.key==="Escape"&&(B.preventDefault(),A())},M=()=>{Z.hidden=!1,v.classList.add("gengage-chat-product-sort-dropdown--open"),w.setAttribute("aria-expanded","true"),se=new AbortController;const{signal:B}=se;le.addEventListener("click",F,{signal:B}),le.addEventListener("keydown",S,{capture:!0,signal:B})};w.addEventListener("click",B=>{B.stopPropagation(),v.classList.contains("gengage-chat-product-sort-dropdown--open")?A():M()});for(const B of _){const D=document.createElement("button");D.type="button",D.className="gengage-chat-product-sort-option gds-menu-option",D.setAttribute("role","option");const H=xr(y,B.sortState);D.setAttribute("aria-selected",H?"true":"false"),H&&D.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const ie=B.sortState.type==="related"?"related":`price-${B.sortState.direction??""}`;D.dataset.sortKey=ie;const X=document.createElement("span");X.className="gengage-chat-product-sort-option-icon",X.innerHTML=yr(B.icon);const K=document.createElement("span");K.className="gengage-chat-product-sort-option-label",K.textContent=B.label;const x=document.createElement("span");x.className="gengage-chat-product-sort-option-check",x.innerHTML=fd(),x.setAttribute("aria-hidden","true"),H||x.classList.add("gengage-chat-product-sort-option-check--hidden"),D.appendChild(X),D.appendChild(K),D.appendChild(x),D.addEventListener("click",()=>{y=B.sortState,n.onSortChange?.(B.sortState),vd(c,s,e,B.sortState),Z.querySelectorAll(".gengage-chat-product-sort-option").forEach(I=>{const L=I,R=L.dataset.sortKey===ie;L.classList.toggle("gengage-chat-product-sort-option--active",R),L.classList.toggle("gds-menu-option-active",R),L.setAttribute("aria-selected",R?"true":"false"),L.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!R)}),z(B.sortState),A()}),Z.appendChild(D)}if(v.appendChild(w),v.appendChild(Z),p.appendChild(v),b(p),h){p.classList.add("gengage-chat-product-sort-toolbar--inline");const B=document.createElement("div");B.className="gengage-chat-product-grid-head";const D=document.createElement("span");D.className="gengage-chat-product-grid-head-title",D.textContent=h,B.appendChild(D);const H=document.createElement("div");H.className="gengage-chat-product-grid-head-actions",H.appendChild(p),B.appendChild(H),i.appendChild(B)}else i.appendChild(p)}else if(h){const p=document.createElement("div");p.className="gengage-chat-product-grid-head";const y=document.createElement("span");y.className="gengage-chat-product-grid-head-title",y.textContent=h,p.appendChild(y),i.appendChild(p)}if(g&&!o){if(i.classList.add("gengage-chat-product-grid-wrapper--grouped"),n?.onToggleComparisonSku){const v=document.createElement("div");v.className="gengage-chat-product-sort-toolbar gengage-chat-product-sort-toolbar--compare-only",v.setAttribute("role","toolbar"),v.setAttribute("aria-label",n.i18n?.compareSelected??"Compare"),b(v),i.appendChild(v)}const p=document.createElement("div");p.className="gengage-chat-product-grid-sections",p.setAttribute("role","list");const y=t.props?.rankingState;let _=0;for(const v of l){_+=v.children.length;const w=xd(v.children.length,n),E=document.createElement("section");E.className="gengage-chat-product-grid-section",E.setAttribute("role","listitem");const k=document.createElement("div");if(k.className="gengage-chat-product-grid-section-head",v.title){const O=document.createElement("h3");O.className="gengage-chat-product-grid-section-title",O.textContent=v.title,k.appendChild(O)}const T=document.createElement("span");T.className="gengage-chat-product-grid-section-count",T.textContent=w,k.appendChild(T),E.appendChild(k);const z=document.createElement("div");z.className="gengage-chat-product-grid gengage-chat-product-grid--section";for(const O of v.children){const Z=a(O);Z&&(Z.dataset.elementId=O,z.appendChild(Z))}(n?.isMobile??Wt())&&z.classList.add("gengage-chat-product-grid--mobile"),y==="pending"&&(z.classList.add("gengage-chat-product-grid--pending"),z.inert=!0,z.setAttribute("aria-busy","true")),E.appendChild(z),p.appendChild(E)}return i.appendChild(p),m(i,_),u(),i}if(o)Ad(i,c,r,n);else{const p=_r(s,e,n?.productSort);for(const y of p){if(!e.elements[y])continue;const _=a(y);_&&(_.dataset.elementId=y,c.appendChild(_))}}return(n?.isMobile??Wt())&&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 xd(t,e){return(e?.i18n?.productGridSectionCountLabel??"{count} product(s)").replace(/\{count\}/g,String(t))}function _d(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 wd(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,g=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=_d(b,i,r);e.onProductClick?.({sku:b,url:u,...m!==void 0&&m!==""?{name:m}:{}})},pricing:e.pricing};l!==void 0&&(h.recommendedText=l),g!==void 0&&(h.winnerHits=g),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=ag(h);return(e.isMobile??Wt())&&f.classList.add("gengage-chat-comparison--mobile"),f}function kd(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 Ka,Zt,Ya,wr,kr,Cr,Sr,Er,Tr=P((()=>{nt(),lt(),rg(),hg(),wg(),Cg(),Tg(),Ag(),Ig(),ir(),Mg(),Ug(),Og(),cr(),Gg(),Wg(),Nr(),pe(),$e(),Va(),Ka={ActionButtons:({element:t,context:e})=>Kg(t,e),ActionButton:({element:t,context:e})=>Yg(t,e),InlineQuestionButtons:({element:t,context:e})=>Lg(t,e),ProductCard:({element:t,context:e})=>Ga(t,e),ProductDetailsPanel:({element:t,context:e})=>dd(t,e),ProductGrid:({element:t,spec:e,renderElement:a,context:n})=>yd(t,e,a,n),ReviewHighlights:({element:t,context:e})=>e.hideUserReviews===!0?null:pg(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})=>wd(t,e),AITopPicks:({element:t,context:e})=>xg(t,e),GroundingReviewCard:({element:t,context:e})=>e.hideUserReviews===!0?null:kg(t,e),AIGroupingCards:({element:t,context:e})=>Eg(t,e),AISuggestedSearchCards:({element:t,context:e})=>Pg(t,e),ProsAndCons:({element:t})=>Ng(t),CategoriesContainer:({element:t,context:e})=>Fg(t,e),HandoffNotice:({element:t,context:e})=>qg(t,e),PanelRestoreCard:({element:t,context:e})=>$g(t,e),ProductSummaryCard:({element:t,context:e})=>Vg(t,e),Divider:({element:t})=>kd(t),...lr},Zt=({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},Ya=new Set(["color","colour","renk","renk kodu","color code"]),wr=new Set(["size","beden","boyut"]),kr=new Set(["finish","bitiş","bitişi"]),Cr=["variants","variantOptions","variant_options","productVariants","product_variants","options"],Sr=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),Er=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"])}));function Pr(t){return{...Qe,...t?.i18n??{}}}function Ar(t){return t.watchStylesPreparedTitle??t.beautyStylesPreparedTitle}function Xt(t){return typeof t.status=="string"?t.status:"ready"}function Qa(t){const e=t.findIndex(a=>Xt(a)!=="loading");return e<0?0:e}function Cd(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 Lr(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=Jt(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 g=0;g<3;g+=1){const d=document.createElement("div");d.className="gengage-chat-consulting-loading-card",l.appendChild(d)}o.appendChild(l)}i.appendChild(o)}function Jt(t,e,a){const n=i=>a.consultingFallbackStyleLabel.replace("{index}",String(i));return t.style_label??n(e)}function Za(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=Xt(a),s=e+1;if(o==="loading"){Lr(t,a,"loading",s);return}if(o!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){Lr(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 g=new Map;for(const u of c){const p=typeof u?.sku=="string"?u.sku:void 0;p&&g.set(p,u)}const d=(u,p,y,_)=>{if(p.length===0)return;const v=document.createElement("section");v.className="gengage-chat-consulting-group";const w=document.createElement("div");w.className="gengage-chat-consulting-group-header";const E=document.createElement("h4");if(E.className="gengage-chat-consulting-group-label",E.textContent=`${u} (${p.length})`,w.appendChild(E),typeof _=="string"&&_.trim().length>0){const T=document.createElement("p");T.className="gengage-chat-consulting-group-reason",T.textContent=_,w.appendChild(T)}v.appendChild(w);const k=document.createElement("div");k.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",y&&k.classList.add("gengage-chat-consulting-group-grid--single-group"),k.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,p.length))));for(const T of p){const z=Ga({type:"ProductCard",props:{product:T}},i??{onAction:()=>{}});k.appendChild(z)}v.appendChild(k),n.appendChild(v)},h=new Set,f=[];for(const u of l){const p=(Array.isArray(u.skus)?u.skus.filter(v=>typeof v=="string"&&v.trim().length>0):[]).map(v=>(h.add(v),g.get(v))).filter(v=>!!v);if(p.length===0)continue;const y=typeof u.label=="string"&&u.label.trim().length>0?u.label:r.consultingFallbackGroupLabel,_=typeof u.reason=="string"?u.reason:void 0;f.push({labelText:y,products:p,..._!==void 0?{reasonText:_}:{}})}const b=c.filter(u=>{const p=typeof u?.sku=="string"?u.sku:"";return p.length>0&&!h.has(p)});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 g of c){const d=Ga({type:"ProductCard",props:{product:g}},i??{onAction:()=>{}});n.appendChild(d)}}function Xa(t,e,a,n){const i=Xt(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",Jt(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=Cd(e.image_url);if(c&&de(c)){const g=document.createElement("img");g.className="gengage-chat-consulting-style-image",g.draggable=!1,fe(g,"src",c),g.alt=Jt(e,a+1,n),g.loading="lazy",Se(g),s.appendChild(g)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=Jt(e,a+1,n),s.appendChild(l),i==="loading"||i!=="ready"){const g=document.createElement("span");g.className="gengage-chat-consulting-style-status",g.textContent=i==="loading"?r:o,s.appendChild(g)}}function Ir(t,e,a,n){t.addEventListener("click",()=>{const i=St.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)}),Za(i,n))})}function Sd(t,e,a,n){const i=Pr(n),r=Qa(a),o=document.createElement("div");o.className="gengage-chat-consulting-style-picker";const s={grid:e,ctx:n,variations:a,i18n:i,selectedIndex:r};St.set(o,s);const c=document.createElement("div");c.className="gengage-chat-consulting-style-picker-title",c.textContent=Ar(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((g,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"),Xa(h,g,d,i),Ir(h,o,l,d),l.appendChild(h)}),t.appendChild(o),Za(s,r)}function Ed(t,e,a){const n=t.querySelector(".gengage-chat-consulting-style-picker"),i=Td(t);if(!n||!i)return!1;const r=n.querySelector(".gengage-chat-consulting-style-grid");if(!r)return!1;const o=Pr(a);let s=St.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:Qa(e)};St.set(n,h),s=h}const c=n.querySelector(".gengage-chat-consulting-style-picker-title");c&&(c.textContent=Ar(o).replace("{count}",String(e.length)));const l=s;let g=l.selectedIndex;g>=e.length&&(g=Math.max(0,e.length-1)),g<0&&(g=0),e.length>0&&Xt(e[g]??{})==="loading"&&(g=Qa(e)),l.selectedIndex=g;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?Xa(b,f,h,o):(b=document.createElement("button"),b.type="button",b.className="gengage-chat-consulting-style-btn gds-card",Xa(b,f,h,o),Ir(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)}),Za(l,l.selectedIndex),!0}function Td(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 St,Pd=P((()=>{pe(),$e(),wt(),Tr(),St=new WeakMap}));function Ja(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:oi(e)&&a.length>0,source:e,styleVariations:a}}function Ad(t,e,a,n){Sd(t,e,a.styleVariations,n)}function Ld(t){return!t.isConsulting||t.styleVariations.length===0?!0:t.styleVariations.some(e=>(typeof e.status=="string"?e.status:"ready")!=="loading")}function Id(t,e,a){return!e.isConsulting||!e.source?!1:Ed(t,e.styleVariations,a)}var Nr=P((()=>{Pd(),si()}));function Nd(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??Mr;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 Mr,Md=P((()=>{Mr=`<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"/>
|
|
51
51
|
<rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
|