@gengage/assistant-fe 0.4.4 → 0.4.6
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/README.md +1 -1
- package/dist/api-paths-C4GDpeTf.js +1214 -0
- package/dist/chat/index.d.ts +1 -374
- package/dist/chat/runtime.d.ts +374 -0
- package/dist/chat/types.d.ts +1 -1
- package/dist/chat-BRKK63lt.js +303 -0
- package/dist/chat-runtime.js +13 -0
- package/dist/chat.iife.js +7 -7
- package/dist/chat.js +11 -10
- package/dist/common/config-constants.d.ts +1 -0
- package/dist/common/config-schema.d.ts +0 -1
- package/dist/common/overlay.d.ts +4 -4
- package/dist/common-CEN5OW7E.js +491 -0
- package/dist/common.js +78 -76
- package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
- package/dist/context-VIG4SVcS.js +529 -0
- package/dist/index.js +70 -67
- package/dist/locale-CfqNifrU.js +7 -0
- package/dist/native-webview-DudQ7nHe.js +273 -0
- package/dist/native.iife.js +28 -91
- package/dist/native.js +1 -1
- package/dist/overlay-1EO41ZC7.js +212 -0
- package/dist/overlay.d.ts +4 -0
- package/dist/overlay.js +10 -0
- package/dist/pill-launcher-57nrdLRr.js +364 -0
- package/dist/qna/index.d.ts +1 -61
- package/dist/qna/runtime.d.ts +61 -0
- package/dist/qna-BNvttR6s.js +40 -0
- package/dist/qna-runtime.js +8 -0
- package/dist/qna.iife.js +4 -4
- package/dist/qna.js +6 -5
- package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
- package/dist/{chat-DI7Vm0gh.js → runtime-C0qZk0y7.js} +1644 -2298
- package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
- package/dist/schemas-CLo8wCjs.js +3207 -0
- package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
- package/dist/simbut.js +1 -1
- package/dist/simrel/index.d.ts +1 -59
- package/dist/simrel/runtime.d.ts +59 -0
- package/dist/simrel-ohfkluhp.js +55 -0
- package/dist/simrel-runtime.js +8 -0
- package/dist/simrel.iife.js +4 -4
- package/dist/simrel.js +7 -6
- package/dist/widget-base-TgwiA8cD.js +578 -0
- package/package.json +17 -1
- package/dist/common-BxSi3UWt.js +0 -387
- package/dist/locale-MM0U5eeR.js +0 -1109
- package/dist/native-webview-DFqnyus6.js +0 -586
- package/dist/schemas-JpRGzRQT.js +0 -4419
- /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
package/dist/simrel.iife.js
CHANGED
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`,document.head.appendChild(e)}var ne=null;function gn(){if(ne!==null)return ne;try{ne=localStorage.getItem("gengage:debug")==="1"}catch{ne=!1}return ne}function Ae(e,t,r){if(!gn())return;const n=[`[gengage:${e}]`,t];r!==void 0&&n.push(r),console.debug(...n)}var mn=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=Xr(e.theme);this.config={...e,theme:t,session:Qr(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),cn();const r=et("gengage:context:update",n=>this.update(n));this._cleanups.push(r),Ae("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Ae("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}trackCheckout(e,t){const r=e==="start"?Lr:Dr;this.track(r(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(Rr(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(r=>r(...t))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){const e={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(e.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(e.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(e.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(e.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(e.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(e.ab_test_experiment_id=this.config.session.abTestExperimentId),e}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`[gengage] Mount target not found: "${e}"`);return r}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,r]of Object.entries(e))if(r!==void 0){const n=t.startsWith("--")?t:`--gengage-${hn(t)}`;this.root.style.setProperty(n,r)}}}};function hn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function _n(e){const t=e?.trim();return t||"tr"}var yn=8e3,vn=5e3,bn="https://www.google.com/favicon.ico",U=new Map,st=!1,Q=null,oe=null,W=!1;function wn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function at(e){return wn(e)?"İnternet bağlantısında sorun var gibi görünüyor. İstek sürerken yeniden deneyeceğiz.":"Your internet connection looks unstable. We'll keep retrying while this request is active."}function ct(){let e;for(const t of U.values())e=t;return e}function Pe(){Q&&(clearTimeout(Q),Q=null)}function kn(){oe&&(clearInterval(oe),oe=null)}async function ut(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const r=window.location.hostname;if(r==="localhost"||r==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(bn,{method:"HEAD",mode:"no-cors",cache:"no-cache",signal:e.signal}),!0}catch{return navigator.onLine}finally{clearTimeout(t)}}catch{return typeof navigator>"u"?!0:navigator.onLine}}function fe(){W=!1,kn(),it()}function pe(){Q||W||U.size===0||(Q=setTimeout(async()=>{Q=null,!(W||U.size===0)&&!await ut()&&U.size>0&&(W=!0,Ie({source:"sdk",message:at(ct()),sticky:!0}),oe||(oe=setInterval(async()=>{if(U.size===0){fe();return}await ut()&&(fe(),pe())},vn)))},yn))}function Sn(){st||typeof window>"u"||(st=!0,window.addEventListener("online",()=>{fe(),pe()}),window.addEventListener("offline",()=>{U.size===0||W||(W=!0,Pe(),Ie({source:"sdk",message:at(ct()),sticky:!0}))}))}function En(e){Sn();const t=Symbol(e.source);U.set(t,e.locale),pe();let r=!1;return()=>{if(!r){if(r=!0,U.delete(t),U.size===0){Pe(),fe();return}W||(Pe(),pe())}}}var Cn={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function zn(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function dt(e,t){return`${zn(t?.middlewareUrl)}/chat${Cn[e]}`}function lt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Tn(e){const t=[];let r=0,n=!1,o=!1,i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o){o=!1;continue}if(a==="\\"&&n){o=!0;continue}if(a==='"'){n=!n;continue}n||(a==="{"&&r++,a==="}"&&(r--,r===0&&(t.push(e.slice(i,s+1)),i=s+1)))}return t.length>0?t:[e]}function ft(e,t){const r=e.trim();if(!r||r.startsWith(":"))return!1;const n=r.startsWith("data: ")?r.slice(6):r;if(n==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(n);return lt(o)?(Ae("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Tn(n);if(o.length>1){for(const i of o)try{const s=JSON.parse(i);if(!lt(s))continue;if(t.onEvent(s),s.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function pt(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const r=e.body.getReader(),n=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,s=Symbol("idle-timeout");let a=!1;try{for(;;){const c=r.read();let u;const f=await(i>0?Promise.race([c.then(_=>(clearTimeout(u),_)),new Promise(_=>{u=setTimeout(()=>_(s),i)})]):c);if(f===s){a=!0,await r.cancel();break}const{done:g,value:p}=f;if(g)break;o+=n.decode(p,{stream:!0});const m=o.split(`
|
|
48
|
-
`);o=m.pop()??"";for(const _ of m)if(ft(_,t))return}if(o.trim()&&ft(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{a||r.releaseLock()}t.onDone?.()}var gt=3,$n=(e,t)=>{const r=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!r)return"";const n=t?.stripLeadingStopWords?r.replace(/^(?:daha|için)\s+/i,"").trim():r;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},Ne=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(r=>$n(r,t)).filter(Boolean):[];function In(e){const t=(e.display_keywords??[]).flatMap(o=>Ne(o,{stripLeadingStopWords:!0})),r=t.filter((o,i)=>t.indexOf(o)===i);if(r.length>0)return r.slice(0,gt);const n=[...Ne(e.chosen_attribute,{stripLeadingStopWords:!0}),...Ne(e.short_name)];return n.filter((o,i)=>n.indexOf(o)===i).slice(0,gt)}function An(e){return In(e).join(" • ")}var Pn=["beauty_consulting","watch_expert"];function Nn(e){return typeof e=="string"&&Pn.includes(e)}function mt(e){if(typeof e.type!="string")return null;if(On(e))return e;const t=e;switch(t.type){case"outputText":return Zn(t);case"suggestedActions":return Rn(t);case"productList":return xn(t);case"productDetails":return Ln(t);case"productDetailsSimilars":return Dn(t);case"comparisonTable":return jn(t);case"context":return qn(t);case"chatStreamEnd":return Gn();case"loading":return Jn(t);case"panelLoading":return Vn(t);case"similarLoading":return Bn(t);case"redirect":return Wn(t);case"error":return Hn(t);case"dummy":return Kn(t);case"launcherAction":return Yn(t);case"text":return Oe(t);case"productItem":return Qn(t);case"text_image":return ht(t);case"quick_qna":return _t(t);case"reviewHighlights":return Xn(t);case"aiProductSuggestions":return ro(t);case"aiProductGroupings":return no(t);case"aiSuggestedSearches":return oo(t);case"prosAndCons":return eo(t);case"getGroundingReview":return io(t);case"voice":return ao(t);case"visitorDataResponse":return to(t);case"productListPreview":return so();case"groupList":return co(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return uo(t);case"launcherContent":return fo(t);case"handoff":return lo(t);case"uiSpec":return ko(t);default:return null}}function On(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const r=e.widget;if(r!=="chat"&&r!=="qna"&&r!=="simrel")return!1;const n=Z(e.spec);return n?typeof n.root=="string"&&Z(n.elements)!==null:!1}case"action":{const r=Z(e.action);return r!==null&&typeof r.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Zn(e){const t=k(e.payload.text,e.payload.plain_text)??"",r=k(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:r||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(n.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const s=e.payload.conversation_mode;typeof s=="string"&&s&&(n.conversationMode=s);const a=e.payload.render_hint;return typeof a=="string"&&a&&(n.renderHint=a),e.payload.kvkk===!0&&(n.kvkk=!0),n}function Rn(e){return yt((e.payload.actions??[]).map(t=>{const r=k(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(se),"chat")}function xn(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(s=>{const a=k(s.style_label);if(!a)return null;const c=k(s.style_mood),u=k(s.image_url??void 0),f=(Array.isArray(s.product_list)?s.product_list:[]).map(p=>{const m=Z(p);return m?Ze(Z(m.product_detail)??Z(m.product)??m):null}).filter(se),g=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(p=>({label:k(p.label)??"",reason:k(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(m=>typeof m=="string"&&m.trim().length>0):[]})):[];return{style_label:a,style_mood:c??"",...u?{image_url:u}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:f,recommendation_groups:g}}).filter(se),r=e.payload.product_list??[],n=Nn(e.payload.source)&&t.length>0?t[0].product_list:null,o=n?po(n,"chat"):vt(r,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){const s={};typeof e.payload.offset=="number"&&(s.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(s.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(s.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(s.source=e.payload.source),t.length>0&&(s.styleVariations=t),e.payload.replace_panel===!0&&(s.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(s.rankingState=e.payload.ranking_state);const a=e.payload.sequence_id??e.payload.search_id;typeof a=="string"&&a.length>0&&(s.sequenceId=a),Object.keys(s).length>0&&(i.props={...i.props,...s})}return o}function Ln(e){const t=e.payload.productDetails;if(!t)return mo("chat");const r=F(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...r}}}}},panelHint:"panel"}}function Dn(e){const t=vt(e.payload.similarProducts??[],"chat"),r=t.spec.elements[t.spec.root];return r&&(r.props={...r.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function jn(e){const t=e.payload.multiple_product_details??[],r=e.payload,n={key_differences:r.key_differences,recommended_choice:r.recommended_choice,recommended_choice_sku:r.recommended_choice_sku,special_considerations:r.special_considerations,criteria_view:r.criteria_view,criteria_view_short:r.criteria_view_short,compared_field_names:r.compared_field_names,winner_product:r.winner_product,winner_hits:r.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const h of t){const v=F(h);s.push(v)}const a=Un(o,s,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const u=c?s.find(h=>h.sku===c)??s[0]:s[0],f=[];if(Array.isArray(n?.key_differences))for(const h of n.key_differences)typeof h=="string"&&f.push(h);const g=yo(n?.special_considerations),p=n?.recommended_choice,m=n?.winner_hits,_={};for(const h of s){const v=h.sku;v&&(_[v]={title:h.name??v,type:"launchSingleProduct",payload:{sku:v}})}const d={products:s,attributes:a,highlights:f,productActions:_};return u&&(d.recommended=u),g.length>0&&(d.specialCases=g),p&&(d.recommendedText=p),m&&(d.winnerHits=m),typeof n?.key_differences=="string"&&(d.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(d.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:d}}},panelHint:"panel"}}function Un(e,t,r,n){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const g=r.criteria_view??r.criteria_view_short??{},p=r.compared_field_names??Object.keys(e),m=[];for(const _ of p){const d=e[_];if(!d||!Array.isArray(d))continue;const h=g[_]??_;m.push({label:h,values:d.map(v=>typeof v=="string"?v:String(v??""))})}return m}const s=e,a=t.map(g=>String(g.sku??"")).filter(g=>g.length>0),c=r.criteria_view??r.criteria_view_short??{},u=(n&&n.length>0?n:r.compared_field_names&&r.compared_field_names.length>0?r.compared_field_names:Mn(s)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),f=[];for(const g of u){const p=a.map(_=>{const d=s[_];if(!d||typeof d!="object")return"";const h=d[`${g}_short`],v=d[g];return Fn(h??v)});if(p.every(_=>_.length===0))continue;const m=c[g]??g;f.push({label:m,values:p})}return f}function Mn(e){const t=[],r=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function Fn(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function qn(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Gn(){return{type:"done"}}function Jn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function Vn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Bn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Wn(e){const t=k(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:k(e.payload.to)}}}function Hn(e){return{type:"error",code:"BACKEND_ERROR",message:k(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Kn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Yn(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.theme=s),_t({type:"quick_qna",payload:o})}const r=Z(t.action);if(r){const o={action:r},i=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),s!==void 0&&(o.image_url=s),a!==void 0&&(o.theme=a),ht({type:"text_image",payload:o})}const n=typeof t.text=="string"?t.text:"";if(n){const o={text:n},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,a=Z(t.payload)??void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.payload=a),s!==void 0&&(o.theme=s),Oe({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Oe(e){const t={text:k(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function Qn(e){return go(e.payload,"qna")}function ht(e){const t=k(e.payload.text)??"",r=D(e.payload.action,t);if(r){const o={label:t||r.title,action:r};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),Oe({type:"text",payload:n})}function _t(e){return yt((e.payload.action_list??[]).map(t=>{const r=k(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(se),"qna")}function Xn(e){const t={reviews:(e.payload.reviews??[]).map(r=>{const n={};return typeof r.review_class=="string"&&(n.review_class=r.review_class),typeof r.review_text=="string"&&(n.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(n.review_rating=r.review_rating),typeof r.review_tag=="string"&&(n.review_tag=r.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function eo(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function to(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function ro(e){const t=e.payload.product_suggestions??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=ho(o);if(!i)continue;const s={product:i},a=D(o.requestDetails,i.name);a&&(s.action=a),typeof o.role=="string"&&(s.role=o.role),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.review_highlight=="string"&&(s.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(s.labels=o.labels),typeof o.expert_quality_score=="number"&&(s.expertQualityScore=o.expert_quality_score),r.push(s)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:r}}}}}}function no(e){const t=e.payload.product_groupings??[],r=[],n=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const s=k(i.name)??"",a=k(i.sku,i.repr_sku),c=k(i.image,i.repr_image),u=a!==void 0?{type:"findSimilar",payload:{sku:a}}:void 0,f=D(i.requestDetails??u,s),g=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const d=Z(_);return d?Ze(d):null}).filter(se),p=c??k(...g.map(_=>_.imageUrl));if(s&&g.length>0){const _={groupName:s,products:g};p&&(_.image=p),r.push(_)}if(!f)continue;const m={name:s,action:f};if(Array.isArray(i.labels)){const _=i.labels.filter(d=>typeof d=="string");_.length>0&&(m.labels=_)}c!==void 0&&(m.image=c),n.push(m)}return r.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function oo(e){const t=e.payload.suggested_searches??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=k(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${n+1}`,s={},a=k(o.detailed_user_message);a&&(s.text=a);const c=Z(Z(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?s.group_skus=o.group_skus:Array.isArray(u)&&(s.group_skus=u.filter(v=>typeof v=="string"));const f=k(o.sku,o.representative_product_sku,c?.sku);f&&(s.sku=f),s.is_suggested_text=1;const g={type:"inputText",payload:s},p=D(o.requestDetails,i),m=p?.type==="findSimilar"&&typeof s.text=="string"?D(g,i):p??D(g,i);if(!m)continue;const _={shortName:i,action:m},d=k(o.detailed_user_message);d&&d!==i&&(_.detailedMessage=d);const h=An(o);h&&h!==i&&h!==(d??"")&&(_.whyDifferent=h),typeof o.image=="string"&&(_.image=o.image),r.push(_)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:r}}}}}}function io(e){const t=e.payload,r=D(t.requestDetails??t.request_details,k(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!r)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:r};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function so(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function ao(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function co(e){const t=e.payload.group_list??[],r=[];for(const o of t){const i=o.group_name??"",s=(o.product_list??[]).map(F);r.push({groupName:i,products:s})}const n=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const s=D(o.requestDetails,i),a={title:i};s&&(a.action=s),n.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r,filterTags:n}}}},panelHint:"panel"}}function uo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function lo(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function fo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function yt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;n.push(s);const a={label:i.label,action:i.action};i.icon!==void 0&&(a.icon=i.icon),i.image!==void 0&&(a.image=i.image),i.description!==void 0&&(a.description=i.description),r[s]={type:"ActionButton",props:a}}return r.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function vt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=F(i),a=`product-${o}`;n.push(a);const c={product:s,index:o};s.sku&&(c.action={title:s.name,type:"launchSingleProduct",payload:{sku:s.sku}}),r[a]={type:"ProductCard",props:c}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function po(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;n.push(s);const a={product:i,index:o},c=i.sku;c&&(a.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),r[s]={type:"ProductCard",props:a}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function go(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:F(e),index:0}}}}}}function mo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function ho(e){const t=k(e.sku),r=k(e.short_name),n={...Z(e.product_item)??e},o=k(e.discount_reason,e.discountReason);return o&&!k(n.discount_reason,n.discountReason)&&(n.discount_reason=o),Ze(n,t,r)}function Ze(e,t,r){const n=k(e.sku,t),o=k(e.name,r);if(!n||!o)return null;const i={sku:n,name:o},s=k(e.brand);s&&(i.brand=s);const a=k(e.url);a&&(i.url=a);const c=_o(e.images);if(c.length>0)i.images=c;else{const d=k(e.image,e.image_url,e.imageUrl);d&&(i.images=[d])}const u=ie(e.price_discounted);u!==void 0&&(i.price_discounted=u);const f=ie(e.price);f!==void 0&&(i.price=f);const g=ie(e.rating);g!==void 0&&(i.rating=g);const p=ie(e.review_count)??ie(e.reviewCount);p!==void 0&&(i.review_count=p);const m=k(e.cart_code,e.cartCode);m&&(i.cart_code=m),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const _=k(e.discount_reason,e.discountReason);return _&&(i.discount_reason=_),F(i)}function D(e,t){const r=Z(e);if(!r)return null;const n=r.type;if(typeof n!="string"||n.length===0)return null;const o={title:t||n,type:n};return r.payload!==void 0&&(o.payload=r.payload),o}function Z(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function k(...e){for(const t of e)if(typeof t=="string"){const r=t.trim();if(r.length>0)return r}}function _o(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function yo(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function ie(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const r=Number(t);if(Number.isFinite(r))return r}}function se(e){return e!=null}var vo=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","facet_tags","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function F(e){const t=e.price_discounted!=null&&e.price_discounted>0,r=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let o;n!=null&&r!=null&&n>0?o=Math.round((n-r)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=k(e.brand),s=k(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:k(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),r!=null&&r>0&&(c.price=String(r)),n!=null&&n>0&&(c.originalPrice=String(n)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.short_name!==void 0&&(c.shortName=e.short_name);const f=e,g={};let p=!1;for(const m of Object.keys(f))vo.has(m)||(g[m]=f[m],p=!0);return p&&(c.extras=g),c}function bo(e){return e.results.map(F)}function wo(e){return e.product_groupings.map(t=>{const r={name:t.name,products:(t.group_products??[]).map(F)};return t.highlight!==void 0&&(r.highlight=t.highlight),r})}function ko(e){const t=e.payload.type,{type:r,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}function bt(e){const t=[];for(const r of Object.values(e))if(r.type==="ProductCard"&&r.props){const n=r.props.product??r.props;typeof n.sku=="string"&&typeof n.name=="string"&&t.push(n)}return t}function wt(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function So(e,t){const r=[],n={onEvent:o=>{const i=mt(o);!i||i.type!=="ui_spec"||r.push(...bt(i.spec.elements))}};return t!==void 0&&(n.signal=t),await pt(e,n),r}async function Eo(e,t,r){const n=dt("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(wt(i))return So(i,r);const s=await i.text();if(!s)throw new Error("Empty response body from similar_products endpoint");try{return bo(JSON.parse(s))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function Co(e,t){const r=[];let n=null;const o={onEvent:i=>{const s=mt(i);if(s){if(s.type==="metadata"&&s.meta){const a=s.meta.group_name;if(typeof a=="string"){n={name:a,products:[]};const c=s.meta.highlight;typeof c=="string"&&(n.highlight=c),r.push(n)}}s.type==="ui_spec"&&n&&n.products.push(...bt(s.spec.elements))}}};return t!==void 0&&(o.signal=t),await pt(e,o),r}async function zo(e,t,r){const n=dt("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(wt(i))return Co(i,r);const s=await i.text();if(!s)return[];try{return wo(JSON.parse(s))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}var To={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function kt(e,t){const r=Number(e);if(!Number.isFinite(r)||r<0)return e;const n={...To,...t},o=Math.abs(r%1)<Number.EPSILON,i=n.alwaysShowDecimals||!o?r.toFixed(2):r.toFixed(0),s=i.indexOf("."),a=s===-1?i:i.slice(0,s),c=s===-1?void 0:i.slice(s+1),u=a.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let f;return c!==void 0?f=`${u}${n.decimalSeparator}${c}`:f=u,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${f}`:`${f} ${n.currencySymbol}`:f}function $o(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Io(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ao(e){const t=$o(e),r=Math.floor(t),n=t-r>=.5,o=5-r-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),r>0&&i.appendChild(document.createTextNode("★".repeat(r))),n){const s=document.createElement("span");s.className="gengage-star-half",s.textContent="☆";const a=document.createElement("span");a.textContent="★",s.appendChild(a),i.appendChild(s)}return o>0&&i.appendChild(document.createTextNode("☆".repeat(o))),i}function Po(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function St(e){const{product:t,index:r,discountType:n,onClick:o,onAddToCart:i,renderCard:s}=e,a=e.i18n,c=e.pricing;if(e.renderCardElement){const d=e.renderCardElement(t,r);if(d)return d}if(s){const d=document.createElement("div");return d.className="gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive",d.dataset.gengagePart="simrel-product-card",d.innerHTML=Br(s(t,r)),d.addEventListener("click",h=>{h.target.closest(".gengage-simrel-atc")||h.target.closest(".gengage-chat-product-card-atc")||o(t)}),d}const u=document.createElement("article");u.className="gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive",u.dataset.gengagePart="simrel-product-card",t.inStock===!1&&u.classList.add("gengage-simrel-card--out-of-stock"),u.setAttribute("role","listitem"),u.dataset.sku=t.sku;const f=document.createElement("div");if(f.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",f.dataset.gengagePart="simrel-product-card-image",t.imageUrl&&Vr(t.imageUrl)){const d=document.createElement("img");d.className="gengage-chat-product-card-img",d.src=t.imageUrl,d.alt=t.name,d.loading="lazy",Po(d),f.appendChild(d)}if(n==="badge"&&t.discountPercent&&t.discountPercent>0){const d=document.createElement("span");d.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",d.textContent=`%${Io(t.discountPercent)}`,f.appendChild(d)}u.appendChild(f);const g=document.createElement("div");if(g.className="gengage-simrel-card-info gengage-chat-product-card-body",g.dataset.gengagePart="simrel-product-card-body",t.brand){const d=document.createElement("div");d.className="gengage-simrel-card-brand gengage-chat-product-card-brand",d.textContent=t.brand,g.appendChild(d)}const p=document.createElement("div");if(p.className="gengage-simrel-card-name gengage-chat-product-card-name",p.textContent=t.name,p.title=t.name,g.appendChild(p),t.rating!=null&&t.rating>0){const d=document.createElement("div");if(d.className="gengage-simrel-card-rating gengage-chat-product-card-rating",d.appendChild(Ao(t.rating)),t.reviewCount!=null){const h=document.createElement("span");h.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",h.textContent=` (${t.reviewCount})`,d.appendChild(h)}g.appendChild(d)}const m=document.createElement("div");if(m.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(n==="strike-through"||!n)){const d=document.createElement("span");d.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",d.textContent=kt(t.originalPrice,c),m.appendChild(d)}if(t.price&&parseFloat(t.price)>0){const d=document.createElement("span");d.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",d.textContent=kt(t.price,c),m.appendChild(d)}g.appendChild(m),u.appendChild(g);const _=document.createElement("button");if(_.className="gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary",_.type="button",_.dataset.gengagePart="simrel-product-card-cta",_.textContent=a?.ctaLabel??"View",_.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),o(t)}),u.appendChild(_),t.inStock===!1){const d=document.createElement("div");d.className="gengage-simrel-card-oos",d.textContent=a?.outOfStockLabel??"Out of Stock",u.appendChild(d)}else if(t.cartCode){const d=document.createElement("button");d.className="gengage-simrel-atc gengage-simrel-atc-button gds-btn gds-btn-secondary",d.type="button",d.textContent=a?.addToCartButton??"Add to Cart",d.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),i({sku:t.sku,quantity:1,cartCode:t.cartCode})}),u.appendChild(d)}return u.addEventListener("click",d=>{d.target.closest(".gengage-simrel-atc")||d.target.closest(".gengage-chat-product-card-atc")||d.target.closest(".gengage-chat-product-card-cta")||o(t)}),u}function Et(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let r=0;r<e.products.length;r++){const n={product:e.products[r],index:r,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(n.i18n=e.i18n),e.discountType!==void 0&&(n.discountType=e.discountType),e.renderCard!==void 0&&(n.renderCard=e.renderCard),e.renderCardElement!==void 0&&(n.renderCardElement=e.renderCardElement);const o=St(n);t.appendChild(o)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}var No=0;function Oo(e){const t=No++,r=document.createElement("div");if(r.className="gengage-simrel-groups",r.dataset.gengagePart="simrel-groups",e.groups.length===0)return r.style.display="none",r.dataset.empty="true",r;const n=document.createElement("div");n.className="gengage-simrel-tabs gds-toolbar",n.dataset.gengagePart="simrel-tab-bar",n.setAttribute("role","tablist");const o=[],i=[];let s=0;const a=h=>{const v={products:h.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(v.i18n=e.i18n),e.discountType!==void 0&&(v.discountType=e.discountType),e.renderCard!==void 0&&(v.renderCard=e.renderCard),e.renderCardElement!==void 0&&(v.renderCardElement=e.renderCardElement),e.columns!==void 0&&(v.columns=e.columns),v},c=(h,v=!1)=>{if(v&&h!==s&&e.onGroupingActivate){const b=e.groups[h];e.onGroupingActivate({grouping_label:b.name,grouping_index:h})}s=h;for(let b=0;b<o.length;b++){const A=b===h;o[b].classList.toggle("gengage-simrel-tab--active",A),o[b].setAttribute("aria-selected",String(A)),o[b].tabIndex=A?0:-1}const x=e.groups[h],z=i[h];z.innerHTML="";const w=Et(a(x));z.appendChild(w);for(let b=0;b<i.length;b++){const A=b===h;i[b].style.display=A?"":"none",i[b].tabIndex=A?0:-1}};for(let h=0;h<e.groups.length;h++){const v=e.groups[h],x=`gengage-simrel-tab-${t}-${h}`,z=`gengage-simrel-panel-${t}-${h}`,w=document.createElement("button");w.className="gengage-simrel-tab gds-tab",w.type="button",w.dataset.gengagePart="simrel-tab",w.id=x,w.textContent=v.name,w.setAttribute("role","tab"),w.setAttribute("aria-controls",z),w.setAttribute("aria-selected",String(h===0)),w.tabIndex=h===0?0:-1,h===0&&w.classList.add("gengage-simrel-tab--active"),w.addEventListener("click",()=>c(h,!0)),w.addEventListener("keydown",A=>{let j=-1;A.key==="ArrowRight"||A.key==="ArrowDown"?j=(h+1)%e.groups.length:A.key==="ArrowLeft"||A.key==="ArrowUp"?j=(h-1+e.groups.length)%e.groups.length:A.key==="Home"?j=0:A.key==="End"&&(j=e.groups.length-1),j>=0&&(A.preventDefault(),c(j,!0),o[j].focus())}),o.push(w),n.appendChild(w);const b=document.createElement("div");b.className="gengage-simrel-tab-panel",b.dataset.gengagePart="simrel-tab-panel",b.id=z,b.setAttribute("role","tabpanel"),b.setAttribute("aria-labelledby",x),b.tabIndex=h===0?0:-1,h!==0&&(b.style.display="none"),i.push(b)}const u=document.createElement("button");u.type="button",u.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left",u.setAttribute("aria-label",e.i18n?.scrollTabsLeft??"Scroll tabs left"),u.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';const f=document.createElement("button");f.type="button",f.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right",f.setAttribute("aria-label",e.i18n?.scrollTabsRight??"Scroll tabs right"),f.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';const g=200;u.addEventListener("click",()=>{n.scrollBy({left:-g,behavior:"smooth"})}),f.addEventListener("click",()=>{n.scrollBy({left:g,behavior:"smooth"})});const p=()=>{const h=n.scrollLeft<=4,v=n.scrollLeft+n.clientWidth>=n.scrollWidth-4;u.style.display=h?"none":"",f.style.display=v?"none":"",n.classList.toggle("gengage-simrel-tabs--peek-right",!v),n.classList.toggle("gengage-simrel-tabs--peek-left",!h)};n.addEventListener("scroll",p,{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(p).observe(n),u.style.display="none",f.style.display="none",requestAnimationFrame(p);const m=document.createElement("div");m.className="gengage-simrel-tabs-wrapper",m.appendChild(u),m.appendChild(n),m.appendChild(f),r.appendChild(m);const _=i[0],d=Et(a(e.groups[0]));_.appendChild(d);for(const h of i)r.appendChild(h);return r}function Ct(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const r={sku:t.sku,name:t.name,url:t.url},n=t.imageUrl;typeof n=="string"&&(r.imageUrl=n);const o=t.price;typeof o=="string"&&(r.price=o);const i=t.originalPrice;typeof i=="string"&&(r.originalPrice=i);const s=t.discountPercent;typeof s=="number"&&(r.discountPercent=s);const a=t.brand;typeof a=="string"&&(r.brand=a);const c=t.rating;typeof c=="number"&&(r.rating=c);const u=t.reviewCount;typeof u=="number"&&(r.reviewCount=u);const f=t.cartCode;typeof f=="string"&&(r.cartCode=f);const g=t.inStock;typeof g=="boolean"&&(r.inStock=g);const p=t.extras;return p!=null&&typeof p=="object"&&(r.extras=p),r}function Zo(e){if(!e||typeof e!="object")return null;const t=e,r=t.title,n=t.type;if(typeof r!="string"||typeof n!="string")return null;const o={title:r,type:n};return t.payload!==void 0&&(o.payload=t.payload),o}var zt={ProductGrid:({element:e,renderElement:t,context:r})=>{const n=document.createElement("div");n.className="gengage-simrel-grid",n.setAttribute("role","list");const o=e.props?.columns;let i;typeof o=="number"&&Number.isFinite(o)&&o>0?i=Math.floor(o):typeof r.gridColumns=="number"&&Number.isFinite(r.gridColumns)&&r.gridColumns>0&&(i=Math.floor(r.gridColumns)),i!==void 0&&n.style.setProperty("--gengage-simrel-columns",String(i));for(const s of e.children??[]){const a=t(s);a&&n.appendChild(a)}if(n.children.length===0){const s=document.createElement("div");s.className="gengage-simrel-empty",s.textContent=r.i18n.emptyStateMessage,n.appendChild(s)}return n},ProductCard:({element:e,context:t})=>{const r=Ct(e.props?.product??e.props);if(!r)return null;const n=e.props?.index,o=typeof n=="number"&&Number.isFinite(n)?n:0,i=e.props?.discountType,s=i==="strike-through"||i==="badge"?i:t.discountType,a={product:r,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return s!==void 0&&(a.discountType=s),t.renderCard!==void 0&&(a.renderCard=t.renderCard),t.renderCardElement!==void 0&&(a.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(a.pricing=t.pricing),St(a)},GroupTabs:({element:e,context:t})=>{const r=e.props?.groups;if(!Array.isArray(r))return null;const n=[];for(const s of r){if(!s||typeof s!="object")continue;const a=s;if(typeof a.name!="string")continue;const c=[];if(Array.isArray(a.products))for(const f of a.products){const g=Ct(f);g&&c.push(g)}const u={name:a.name,products:c};typeof a.highlight=="string"&&(u.highlight=a.highlight),n.push(u)}const o={groups:n,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n},i=e.props?.columns;return typeof i=="number"&&Number.isFinite(i)&&i>0?o.columns=Math.floor(i):typeof t.gridColumns=="number"&&Number.isFinite(t.gridColumns)&&t.gridColumns>0&&(o.columns=Math.floor(t.gridColumns)),t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),t.onGroupingActivate!==void 0&&(o.onGroupingActivate=t.onGroupingActivate),Oo(o)},EmptyState:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-empty";const n=e.props?.message;return r.textContent=typeof n=="string"?n:t.i18n.emptyStateMessage,r},AddToCartButton:({element:e,context:t})=>{const r=e.props?.sku,n=e.props?.cartCode;if(typeof r!="string"||typeof n!="string")return null;const o=document.createElement("button");o.className="gengage-simrel-atc gengage-chat-product-card-cta",o.type="button";const i=e.props?.label;return o.textContent=typeof i=="string"?i:t.i18n.addToCartButton,o.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),t.onAddToCart({sku:r,quantity:1,cartCode:n})}),o},QuickActions:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-quick-actions";const n=e.props?.actions;if(!Array.isArray(n)||!t.onAction)return r;for(const o of n){if(!o||typeof o!="object")continue;const i=o,s=i.label,a=Zo(i.action);if(typeof s!="string"||!a)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=s,c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.onAction?.(a)}),r.appendChild(c)}return r}},Re=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function Tt(){return{...zt}}function $t(e,t,r=zt,n=Re){return Pr({spec:e,context:t,registry:r,containerClassName:"gengage-simrel-uispec",unknownRenderer:n})}var It={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",ctaLabel:"İncele",outOfStockLabel:"Stokta Yok",decreaseLabel:"Azalt",increaseLabel:"Artır",errorLoadingMessage:"Benzer ürünler yüklenemedi.",retryButtonText:"Tekrar dene",priceSuffix:" TL",scrollTabsLeft:"Sola kaydır",scrollTabsRight:"Sağa kaydır"},Ro={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",ctaLabel:"View",outOfStockLabel:"Out of Stock",decreaseLabel:"Decrease",increaseLabel:"Increase",errorLoadingMessage:"Could not load similar products.",retryButtonText:"Try again",priceSuffix:"",scrollTabsLeft:"Scroll tabs left",scrollTabsRight:"Scroll tabs right"};function xo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Lo(e){return xo(e)==="en"?Ro:It}var At;function l(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,f=Object.keys(u);for(let g=0;g<f.length;g++){const p=f[g];p in a||(a[p]=u[p].bind(a))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=r?.Parent?new i:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var X=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Pt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(At=globalThis).__zod_globalConfig??(At.__zod_globalConfig={});var ge=globalThis.__zod_globalConfig;function H(e){return e&&Object.assign(ge,e),ge}function Nt(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function xe(e,t){return typeof t=="bigint"?t.toString():t}function Le(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function De(e){return e==null}function je(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Do(e,t){const r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Ot=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ot)return n===void 0&&(n=Ot,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function K(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function q(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function Zt(e){return JSON.stringify(e)}function jo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Rt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Uo=Le(()=>{if(ge.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function ae(e){if(me(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(me(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function xt(e){return ae(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Mo=new Set(["string","number","symbol"]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Fo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var qo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Go(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return G(e,q(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=r.shape[i])}return K(this,"shape",o),o},checks:[]}))}function Jo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return G(e,q(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return K(this,"shape",o),o},checks:[]}))}function Vo(e,t){if(!ae(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return G(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return K(this,"shape",n),n}}))}function Bo(e,t){if(!ae(t))throw new Error("Invalid input to safeExtend: expected a plain object");return G(e,q(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return K(this,"shape",r),r}}))}function Wo(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return G(e,q(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return K(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ho(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return G(t,q(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=e?new e({type:"optional",innerType:o[s]}):o[s])}else for(const s in o)i[s]=e?new e({type:"optional",innerType:o[s]}):o[s];return K(this,"shape",i),i},checks:[]}))}function Ko(e,t,r){return G(t,q(t._zod.def,{get shape(){const n=t._zod.def.shape,o={...n};if(r)for(const i in r){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(o[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(const i in n)o[i]=new e({type:"nonoptional",innerType:n[i]});return K(this,"shape",o),o}}))}function ee(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Yo(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Lt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function _e(e){return typeof e=="string"?e:e?.message}function Y(e,t,r){const n=e.message?e.message:_e(e.inst?._zod.def?.error?.(e))??_e(t?.error?.(e))??_e(r.customError?.(e))??_e(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function Ue(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ce(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Dt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},jt=l("$ZodError",Dt),Ut=l("$ZodError",Dt,{Parent:Error});function Qo(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Xo(e,t=r=>r.message){const r={_errors:[]},n=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;for(;u<a.length;){const f=a[u];u!==a.length-1?c[f]=c[f]||{_errors:[]}:(c[f]=c[f]||{_errors:[]},c[f]._errors.push(t(s))),c=c[f],u++}}}};return n(e),r}var Me=e=>(t,r,n,o)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new X;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>Y(c,i,H())));throw Rt(a,o?.callee),a}return s.value},Fe=e=>async(t,r,n,o)=>{const i=n?{...n,async:!0}:{async:!0};let s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>Y(c,i,H())));throw Rt(a,o?.callee),a}return s.value},ye=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new X;return i.issues.length?{success:!1,error:new(e??jt)(i.issues.map(s=>Y(s,o,H())))}:{success:!0,data:i.value}},ei=ye(Ut),ve=e=>async(t,r,n)=>{const o=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Y(s,o,H())))}:{success:!0,data:i.value}},ti=ve(Ut),ri=e=>(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return Me(e)(t,r,o)},ni=e=>(t,r,n)=>Me(e)(t,r,n),oi=e=>async(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return Fe(e)(t,r,o)},ii=e=>async(t,r,n)=>Fe(e)(t,r,n),si=e=>(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return ye(e)(t,r,o)},ai=e=>(t,r,n)=>ye(e)(t,r,n),ci=e=>async(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return ve(e)(t,r,o)},ui=e=>async(t,r,n)=>ve(e)(t,r,n),di=/^[cC][0-9a-z]{6,}$/,li=/^[0-9a-z]+$/,fi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,pi=/^[0-9a-vA-V]{20}$/,gi=/^[A-Za-z0-9]{27}$/,mi=/^[a-zA-Z0-9_-]{21}$/,hi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_i=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Mt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,yi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function bi(){return new RegExp(vi,"u")}var wi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ki=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Si=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ei=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ci=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ft=/^[A-Za-z0-9_-]*$/,zi=/^https?$/,Ti=/^\+[1-9]\d{6,14}$/,qt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",$i=new RegExp(`^${qt}$`);function Gt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ii(e){return new RegExp(`^${Gt(e)}$`)}function Ai(e){const t=Gt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${qt}T(?:${n})$`)}var Pi=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ni=/^-?\d+$/,Oi=/^-?\d+(?:\.\d+)?$/,Zi=/^[^A-Z]*$/,Ri=/^[^a-z]*$/,N=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Jt={number:"number",bigint:"bigint",object:"date"},Vt=l("$ZodCheckLessThan",(e,t)=>{N.init(e,t);const r=Jt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bt=l("$ZodCheckGreaterThan",(e,t)=>{N.init(e,t);const r=Jt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xi=l("$ZodCheckMultipleOf",(e,t)=>{N.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Do(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Li=l("$ZodCheckNumberFormat",(e,t)=>{N.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=qo[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,r&&(a.pattern=Ni)}),e._zod.check=s=>{const a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Di=l("$ZodCheckMaxLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!De(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=Ue(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ji=l("$ZodCheckMinLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!De(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=Ue(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ui=l("$ZodCheckLengthEquals",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!De(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const s=Ue(o),a=i>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),be=l("$ZodCheckStringFormat",(e,t)=>{var r,n;N.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Mi=l("$ZodCheckRegex",(e,t)=>{be.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fi=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Zi),be.init(e,t)}),qi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ri),be.init(e,t)}),Gi=l("$ZodCheckIncludes",(e,t)=>{N.init(e,t);const r=he(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`^${he(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Vi=l("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`.*${he(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Bi=l("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),Wi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
|
|
48
|
+
`);o=m.pop()??"";for(const _ of m)if(ft(_,t))return}if(o.trim()&&ft(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{a||r.releaseLock()}t.onDone?.()}var gt=3,$n=(e,t)=>{const r=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!r)return"";const n=t?.stripLeadingStopWords?r.replace(/^(?:daha|için)\s+/i,"").trim():r;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},Ne=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(r=>$n(r,t)).filter(Boolean):[];function In(e){const t=(e.display_keywords??[]).flatMap(o=>Ne(o,{stripLeadingStopWords:!0})),r=t.filter((o,i)=>t.indexOf(o)===i);if(r.length>0)return r.slice(0,gt);const n=[...Ne(e.chosen_attribute,{stripLeadingStopWords:!0}),...Ne(e.short_name)];return n.filter((o,i)=>n.indexOf(o)===i).slice(0,gt)}function An(e){return In(e).join(" • ")}var Pn=["beauty_consulting","watch_expert"];function Nn(e){return typeof e=="string"&&Pn.includes(e)}function mt(e){if(typeof e.type!="string")return null;if(On(e))return e;const t=e;switch(t.type){case"outputText":return Zn(t);case"suggestedActions":return Rn(t);case"productList":return xn(t);case"productDetails":return Ln(t);case"productDetailsSimilars":return Dn(t);case"comparisonTable":return jn(t);case"context":return qn(t);case"chatStreamEnd":return Gn();case"loading":return Jn(t);case"panelLoading":return Vn(t);case"similarLoading":return Bn(t);case"redirect":return Wn(t);case"error":return Hn(t);case"dummy":return Kn(t);case"launcherAction":return Yn(t);case"text":return Oe(t);case"productItem":return Qn(t);case"text_image":return ht(t);case"quick_qna":return _t(t);case"reviewHighlights":return Xn(t);case"aiProductSuggestions":return ro(t);case"aiProductGroupings":return no(t);case"aiSuggestedSearches":return oo(t);case"prosAndCons":return eo(t);case"getGroundingReview":return io(t);case"voice":return ao(t);case"visitorDataResponse":return to(t);case"productListPreview":return so();case"groupList":return co(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return uo(t);case"launcherContent":return fo(t);case"handoff":return lo(t);case"uiSpec":return ko(t);default:return null}}function On(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const r=e.widget;if(r!=="chat"&&r!=="qna"&&r!=="simrel")return!1;const n=Z(e.spec);return n?typeof n.root=="string"&&Z(n.elements)!==null:!1}case"action":{const r=Z(e.action);return r!==null&&typeof r.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Zn(e){const t=k(e.payload.text,e.payload.plain_text)??"",r=k(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:r||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(n.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const s=e.payload.conversation_mode;typeof s=="string"&&s&&(n.conversationMode=s);const a=e.payload.render_hint;return typeof a=="string"&&a&&(n.renderHint=a),e.payload.kvkk===!0&&(n.kvkk=!0),n}function Rn(e){return yt((e.payload.actions??[]).map(t=>{const r=k(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(se),"chat")}function xn(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(s=>{const a=k(s.style_label);if(!a)return null;const c=k(s.style_mood),u=k(s.image_url??void 0),f=(Array.isArray(s.product_list)?s.product_list:[]).map(p=>{const m=Z(p);return m?Ze(Z(m.product_detail)??Z(m.product)??m):null}).filter(se),g=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(p=>({label:k(p.label)??"",reason:k(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(m=>typeof m=="string"&&m.trim().length>0):[]})):[];return{style_label:a,style_mood:c??"",...u?{image_url:u}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:f,recommendation_groups:g}}).filter(se),r=e.payload.product_list??[],n=Nn(e.payload.source)&&t.length>0?t[0].product_list:null,o=n?po(n,"chat"):vt(r,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){const s={};typeof e.payload.offset=="number"&&(s.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(s.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(s.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(s.source=e.payload.source),t.length>0&&(s.styleVariations=t),e.payload.replace_panel===!0&&(s.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(s.rankingState=e.payload.ranking_state);const a=e.payload.sequence_id??e.payload.search_id;typeof a=="string"&&a.length>0&&(s.sequenceId=a),Object.keys(s).length>0&&(i.props={...i.props,...s})}return o}function Ln(e){const t=e.payload.productDetails;if(!t)return mo("chat");const r=F(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...r}}}}},panelHint:"panel"}}function Dn(e){const t=vt(e.payload.similarProducts??[],"chat"),r=t.spec.elements[t.spec.root];return r&&(r.props={...r.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function jn(e){const t=e.payload.multiple_product_details??[],r=e.payload,n={key_differences:r.key_differences,recommended_choice:r.recommended_choice,recommended_choice_sku:r.recommended_choice_sku,special_considerations:r.special_considerations,criteria_view:r.criteria_view,criteria_view_short:r.criteria_view_short,compared_field_names:r.compared_field_names,winner_product:r.winner_product,winner_hits:r.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const h of t){const v=F(h);s.push(v)}const a=Un(o,s,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const u=c?s.find(h=>h.sku===c)??s[0]:s[0],f=[];if(Array.isArray(n?.key_differences))for(const h of n.key_differences)typeof h=="string"&&f.push(h);const g=yo(n?.special_considerations),p=n?.recommended_choice,m=n?.winner_hits,_={};for(const h of s){const v=h.sku;v&&(_[v]={title:h.name??v,type:"launchSingleProduct",payload:{sku:v}})}const d={products:s,attributes:a,highlights:f,productActions:_};return u&&(d.recommended=u),g.length>0&&(d.specialCases=g),p&&(d.recommendedText=p),m&&(d.winnerHits=m),typeof n?.key_differences=="string"&&(d.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(d.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:d}}},panelHint:"panel"}}function Un(e,t,r,n){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const g=r.criteria_view??r.criteria_view_short??{},p=r.compared_field_names??Object.keys(e),m=[];for(const _ of p){const d=e[_];if(!d||!Array.isArray(d))continue;const h=g[_]??_;m.push({label:h,values:d.map(v=>typeof v=="string"?v:String(v??""))})}return m}const s=e,a=t.map(g=>String(g.sku??"")).filter(g=>g.length>0),c=r.criteria_view??r.criteria_view_short??{},u=(n&&n.length>0?n:r.compared_field_names&&r.compared_field_names.length>0?r.compared_field_names:Mn(s)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),f=[];for(const g of u){const p=a.map(_=>{const d=s[_];if(!d||typeof d!="object")return"";const h=d[`${g}_short`],v=d[g];return Fn(h??v)});if(p.every(_=>_.length===0))continue;const m=c[g]??g;f.push({label:m,values:p})}return f}function Mn(e){const t=[],r=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function Fn(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function qn(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Gn(){return{type:"done"}}function Jn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function Vn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Bn(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Wn(e){const t=k(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:k(e.payload.to)}}}function Hn(e){return{type:"error",code:"BACKEND_ERROR",message:k(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Kn(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Yn(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.theme=s),_t({type:"quick_qna",payload:o})}const r=Z(t.action);if(r){const o={action:r},i=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),s!==void 0&&(o.image_url=s),a!==void 0&&(o.theme=a),ht({type:"text_image",payload:o})}const n=typeof t.text=="string"?t.text:"";if(n){const o={text:n},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,a=Z(t.payload)??void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.payload=a),s!==void 0&&(o.theme=s),Oe({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Oe(e){const t={text:k(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function Qn(e){return go(e.payload,"qna")}function ht(e){const t=k(e.payload.text)??"",r=D(e.payload.action,t);if(r){const o={label:t||r.title,action:r};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),Oe({type:"text",payload:n})}function _t(e){return yt((e.payload.action_list??[]).map(t=>{const r=k(t.title)??"",n=D(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(se),"qna")}function Xn(e){const t={reviews:(e.payload.reviews??[]).map(r=>{const n={};return typeof r.review_class=="string"&&(n.review_class=r.review_class),typeof r.review_text=="string"&&(n.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(n.review_rating=r.review_rating),typeof r.review_tag=="string"&&(n.review_tag=r.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function eo(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function to(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function ro(e){const t=e.payload.product_suggestions??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=ho(o);if(!i)continue;const s={product:i},a=D(o.requestDetails,i.name);a&&(s.action=a),typeof o.role=="string"&&(s.role=o.role),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.review_highlight=="string"&&(s.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(s.labels=o.labels),typeof o.expert_quality_score=="number"&&(s.expertQualityScore=o.expert_quality_score),r.push(s)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:r}}}}}}function no(e){const t=e.payload.product_groupings??[],r=[],n=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const s=k(i.name)??"",a=k(i.sku,i.repr_sku),c=k(i.image,i.repr_image),u=a!==void 0?{type:"findSimilar",payload:{sku:a}}:void 0,f=D(i.requestDetails??u,s),g=(Array.isArray(i.group_products)?i.group_products:[]).map(_=>{const d=Z(_);return d?Ze(d):null}).filter(se),p=c??k(...g.map(_=>_.imageUrl));if(s&&g.length>0){const _={groupName:s,products:g};p&&(_.image=p),r.push(_)}if(!f)continue;const m={name:s,action:f};if(Array.isArray(i.labels)){const _=i.labels.filter(d=>typeof d=="string");_.length>0&&(m.labels=_)}c!==void 0&&(m.image=c),n.push(m)}return r.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function oo(e){const t=e.payload.suggested_searches??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=k(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${n+1}`,s={},a=k(o.detailed_user_message);a&&(s.text=a);const c=Z(Z(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?s.group_skus=o.group_skus:Array.isArray(u)&&(s.group_skus=u.filter(v=>typeof v=="string"));const f=k(o.sku,o.representative_product_sku,c?.sku);f&&(s.sku=f),s.is_suggested_text=1;const g={type:"inputText",payload:s},p=D(o.requestDetails,i),m=p?.type==="findSimilar"&&typeof s.text=="string"?D(g,i):p??D(g,i);if(!m)continue;const _={shortName:i,action:m},d=k(o.detailed_user_message);d&&d!==i&&(_.detailedMessage=d);const h=An(o);h&&h!==i&&h!==(d??"")&&(_.whyDifferent=h),typeof o.image=="string"&&(_.image=o.image),r.push(_)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:r}}}}}}function io(e){const t=e.payload,r=D(t.requestDetails??t.request_details,k(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!r)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:r};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function so(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function ao(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function co(e){const t=e.payload.group_list??[],r=[];for(const o of t){const i=o.group_name??"",s=(o.product_list??[]).map(F);r.push({groupName:i,products:s})}const n=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const s=D(o.requestDetails,i),a={title:i};s&&(a.action=s),n.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r,filterTags:n}}}},panelHint:"panel"}}function uo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function lo(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function fo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function yt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;n.push(s);const a={label:i.label,action:i.action};i.icon!==void 0&&(a.icon=i.icon),i.image!==void 0&&(a.image=i.image),i.description!==void 0&&(a.description=i.description),r[s]={type:"ActionButton",props:a}}return r.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function vt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=F(i),a=`product-${o}`;n.push(a);const c={product:s,index:o};s.sku&&(c.action={title:s.name,type:"launchSingleProduct",payload:{sku:s.sku}}),r[a]={type:"ProductCard",props:c}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function po(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;n.push(s);const a={product:i,index:o},c=i.sku;c&&(a.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),r[s]={type:"ProductCard",props:a}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function go(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:F(e),index:0}}}}}}function mo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function ho(e){const t=k(e.sku),r=k(e.short_name),n={...Z(e.product_item)??e},o=k(e.discount_reason,e.discountReason);return o&&!k(n.discount_reason,n.discountReason)&&(n.discount_reason=o),Ze(n,t,r)}function Ze(e,t,r){const n=k(e.sku,t),o=k(e.name,r);if(!n||!o)return null;const i={sku:n,name:o},s=k(e.brand);s&&(i.brand=s);const a=k(e.url);a&&(i.url=a);const c=_o(e.images);if(c.length>0)i.images=c;else{const d=k(e.image,e.image_url,e.imageUrl);d&&(i.images=[d])}const u=ie(e.price_discounted);u!==void 0&&(i.price_discounted=u);const f=ie(e.price);f!==void 0&&(i.price=f);const g=ie(e.rating);g!==void 0&&(i.rating=g);const p=ie(e.review_count)??ie(e.reviewCount);p!==void 0&&(i.review_count=p);const m=k(e.cart_code,e.cartCode);m&&(i.cart_code=m),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const _=k(e.discount_reason,e.discountReason);return _&&(i.discount_reason=_),F(i)}function D(e,t){const r=Z(e);if(!r)return null;const n=r.type;if(typeof n!="string"||n.length===0)return null;const o={title:t||n,type:n};return r.payload!==void 0&&(o.payload=r.payload),o}function Z(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function k(...e){for(const t of e)if(typeof t=="string"){const r=t.trim();if(r.length>0)return r}}function _o(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function yo(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function ie(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const r=Number(t);if(Number.isFinite(r))return r}}function se(e){return e!=null}var vo=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","facet_tags","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function F(e){const t=e.price_discounted!=null&&e.price_discounted>0,r=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let o;n!=null&&r!=null&&n>0?o=Math.round((n-r)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=k(e.brand),s=k(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:k(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),r!=null&&r>0&&(c.price=String(r)),n!=null&&n>0&&(c.originalPrice=String(n)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.short_name!==void 0&&(c.shortName=e.short_name);const f=e,g={};let p=!1;for(const m of Object.keys(f))vo.has(m)||(g[m]=f[m],p=!0);return p&&(c.extras=g),c}function bo(e){return e.results.map(F)}function wo(e){return e.product_groupings.map(t=>{const r={name:t.name,products:(t.group_products??[]).map(F)};return t.highlight!==void 0&&(r.highlight=t.highlight),r})}function ko(e){const t=e.payload.type,{type:r,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}function bt(e){const t=[];for(const r of Object.values(e))if(r.type==="ProductCard"&&r.props){const n=r.props.product??r.props;typeof n.sku=="string"&&typeof n.name=="string"&&t.push(n)}return t}function wt(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function So(e,t){const r=[],n={onEvent:o=>{const i=mt(o);!i||i.type!=="ui_spec"||r.push(...bt(i.spec.elements))}};return t!==void 0&&(n.signal=t),await pt(e,n),r}async function Eo(e,t,r){const n=dt("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(wt(i))return So(i,r);const s=await i.text();if(!s)throw new Error("Empty response body from similar_products endpoint");try{return bo(JSON.parse(s))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function Co(e,t){const r=[];let n=null;const o={onEvent:i=>{const s=mt(i);if(s){if(s.type==="metadata"&&s.meta){const a=s.meta.group_name;if(typeof a=="string"){n={name:a,products:[]};const c=s.meta.highlight;typeof c=="string"&&(n.highlight=c),r.push(n)}}s.type==="ui_spec"&&n&&n.products.push(...bt(s.spec.elements))}}};return t!==void 0&&(o.signal=t),await pt(e,o),r}async function zo(e,t,r){const n=dt("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};r!==void 0&&(o.signal=r);const i=await fetch(n,o);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);if(wt(i))return Co(i,r);const s=await i.text();if(!s)return[];try{return wo(JSON.parse(s))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}var To={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function kt(e,t){const r=Number(e);if(!Number.isFinite(r)||r<0)return e;const n={...To,...t},o=Math.abs(r%1)<Number.EPSILON,i=n.alwaysShowDecimals||!o?r.toFixed(2):r.toFixed(0),s=i.indexOf("."),a=s===-1?i:i.slice(0,s),c=s===-1?void 0:i.slice(s+1),u=a.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let f;return c!==void 0?f=`${u}${n.decimalSeparator}${c}`:f=u,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${f}`:`${f} ${n.currencySymbol}`:f}function $o(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Io(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ao(e){const t=$o(e),r=Math.floor(t),n=t-r>=.5,o=5-r-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),r>0&&i.appendChild(document.createTextNode("★".repeat(r))),n){const s=document.createElement("span");s.className="gengage-star-half",s.textContent="☆";const a=document.createElement("span");a.textContent="★",s.appendChild(a),i.appendChild(s)}return o>0&&i.appendChild(document.createTextNode("☆".repeat(o))),i}function Po(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function St(e){const{product:t,index:r,discountType:n,onClick:o,onAddToCart:i,renderCard:s}=e,a=e.i18n,c=e.pricing;if(e.renderCardElement){const d=e.renderCardElement(t,r);if(d)return d}if(s){const d=document.createElement("div");return d.className="gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive",d.dataset.gengagePart="simrel-product-card",d.innerHTML=Br(s(t,r)),d.addEventListener("click",h=>{h.target.closest(".gengage-simrel-atc")||h.target.closest(".gengage-chat-product-card-atc")||o(t)}),d}const u=document.createElement("article");u.className="gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive",u.dataset.gengagePart="simrel-product-card",t.inStock===!1&&u.classList.add("gengage-simrel-card--out-of-stock"),u.setAttribute("role","listitem"),u.dataset.sku=t.sku;const f=document.createElement("div");if(f.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",f.dataset.gengagePart="simrel-product-card-image",t.imageUrl&&Vr(t.imageUrl)){const d=document.createElement("img");d.className="gengage-chat-product-card-img",d.src=t.imageUrl,d.alt=t.name,d.loading="lazy",Po(d),f.appendChild(d)}if(n==="badge"&&t.discountPercent&&t.discountPercent>0){const d=document.createElement("span");d.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",d.textContent=`%${Io(t.discountPercent)}`,f.appendChild(d)}u.appendChild(f);const g=document.createElement("div");if(g.className="gengage-simrel-card-info gengage-chat-product-card-body",g.dataset.gengagePart="simrel-product-card-body",t.brand){const d=document.createElement("div");d.className="gengage-simrel-card-brand gengage-chat-product-card-brand",d.textContent=t.brand,g.appendChild(d)}const p=document.createElement("div");if(p.className="gengage-simrel-card-name gengage-chat-product-card-name",p.textContent=t.name,p.title=t.name,g.appendChild(p),t.rating!=null&&t.rating>0){const d=document.createElement("div");if(d.className="gengage-simrel-card-rating gengage-chat-product-card-rating",d.appendChild(Ao(t.rating)),t.reviewCount!=null){const h=document.createElement("span");h.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",h.textContent=` (${t.reviewCount})`,d.appendChild(h)}g.appendChild(d)}const m=document.createElement("div");if(m.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(n==="strike-through"||!n)){const d=document.createElement("span");d.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",d.textContent=kt(t.originalPrice,c),m.appendChild(d)}if(t.price&&parseFloat(t.price)>0){const d=document.createElement("span");d.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",d.textContent=kt(t.price,c),m.appendChild(d)}g.appendChild(m),u.appendChild(g);const _=document.createElement("button");if(_.className="gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary",_.type="button",_.dataset.gengagePart="simrel-product-card-cta",_.textContent=a?.ctaLabel??"View",_.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),o(t)}),u.appendChild(_),t.inStock===!1){const d=document.createElement("div");d.className="gengage-simrel-card-oos",d.textContent=a?.outOfStockLabel??"Out of Stock",u.appendChild(d)}else if(t.cartCode){const d=document.createElement("button");d.className="gengage-simrel-atc gengage-simrel-atc-button gds-btn gds-btn-secondary",d.type="button",d.textContent=a?.addToCartButton??"Add to Cart",d.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),i({sku:t.sku,quantity:1,cartCode:t.cartCode})}),u.appendChild(d)}return u.addEventListener("click",d=>{d.target.closest(".gengage-simrel-atc")||d.target.closest(".gengage-chat-product-card-atc")||d.target.closest(".gengage-chat-product-card-cta")||o(t)}),u}function Et(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let r=0;r<e.products.length;r++){const n={product:e.products[r],index:r,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(n.i18n=e.i18n),e.discountType!==void 0&&(n.discountType=e.discountType),e.renderCard!==void 0&&(n.renderCard=e.renderCard),e.renderCardElement!==void 0&&(n.renderCardElement=e.renderCardElement);const o=St(n);t.appendChild(o)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}var No=0;function Oo(e){const t=No++,r=document.createElement("div");if(r.className="gengage-simrel-groups",r.dataset.gengagePart="simrel-groups",e.groups.length===0)return r.style.display="none",r.dataset.empty="true",r;const n=document.createElement("div");n.className="gengage-simrel-tabs gds-toolbar",n.dataset.gengagePart="simrel-tab-bar",n.setAttribute("role","tablist");const o=[],i=[];let s=0;const a=h=>{const v={products:h.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(v.i18n=e.i18n),e.discountType!==void 0&&(v.discountType=e.discountType),e.renderCard!==void 0&&(v.renderCard=e.renderCard),e.renderCardElement!==void 0&&(v.renderCardElement=e.renderCardElement),e.columns!==void 0&&(v.columns=e.columns),v},c=(h,v=!1)=>{if(v&&h!==s&&e.onGroupingActivate){const b=e.groups[h];e.onGroupingActivate({grouping_label:b.name,grouping_index:h})}s=h;for(let b=0;b<o.length;b++){const A=b===h;o[b].classList.toggle("gengage-simrel-tab--active",A),o[b].setAttribute("aria-selected",String(A)),o[b].tabIndex=A?0:-1}const x=e.groups[h],z=i[h];z.innerHTML="";const w=Et(a(x));z.appendChild(w);for(let b=0;b<i.length;b++){const A=b===h;i[b].style.display=A?"":"none",i[b].tabIndex=A?0:-1}};for(let h=0;h<e.groups.length;h++){const v=e.groups[h],x=`gengage-simrel-tab-${t}-${h}`,z=`gengage-simrel-panel-${t}-${h}`,w=document.createElement("button");w.className="gengage-simrel-tab gds-tab",w.type="button",w.dataset.gengagePart="simrel-tab",w.id=x,w.textContent=v.name,w.setAttribute("role","tab"),w.setAttribute("aria-controls",z),w.setAttribute("aria-selected",String(h===0)),w.tabIndex=h===0?0:-1,h===0&&w.classList.add("gengage-simrel-tab--active"),w.addEventListener("click",()=>c(h,!0)),w.addEventListener("keydown",A=>{let j=-1;A.key==="ArrowRight"||A.key==="ArrowDown"?j=(h+1)%e.groups.length:A.key==="ArrowLeft"||A.key==="ArrowUp"?j=(h-1+e.groups.length)%e.groups.length:A.key==="Home"?j=0:A.key==="End"&&(j=e.groups.length-1),j>=0&&(A.preventDefault(),c(j,!0),o[j].focus())}),o.push(w),n.appendChild(w);const b=document.createElement("div");b.className="gengage-simrel-tab-panel",b.dataset.gengagePart="simrel-tab-panel",b.id=z,b.setAttribute("role","tabpanel"),b.setAttribute("aria-labelledby",x),b.tabIndex=h===0?0:-1,h!==0&&(b.style.display="none"),i.push(b)}const u=document.createElement("button");u.type="button",u.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left",u.setAttribute("aria-label",e.i18n?.scrollTabsLeft??"Scroll tabs left"),u.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';const f=document.createElement("button");f.type="button",f.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right",f.setAttribute("aria-label",e.i18n?.scrollTabsRight??"Scroll tabs right"),f.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';const g=200;u.addEventListener("click",()=>{n.scrollBy({left:-g,behavior:"smooth"})}),f.addEventListener("click",()=>{n.scrollBy({left:g,behavior:"smooth"})});const p=()=>{const h=n.scrollLeft<=4,v=n.scrollLeft+n.clientWidth>=n.scrollWidth-4;u.style.display=h?"none":"",f.style.display=v?"none":"",n.classList.toggle("gengage-simrel-tabs--peek-right",!v),n.classList.toggle("gengage-simrel-tabs--peek-left",!h)};n.addEventListener("scroll",p,{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(p).observe(n),u.style.display="none",f.style.display="none",requestAnimationFrame(p);const m=document.createElement("div");m.className="gengage-simrel-tabs-wrapper",m.appendChild(u),m.appendChild(n),m.appendChild(f),r.appendChild(m);const _=i[0],d=Et(a(e.groups[0]));_.appendChild(d);for(const h of i)r.appendChild(h);return r}function Ct(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const r={sku:t.sku,name:t.name,url:t.url},n=t.imageUrl;typeof n=="string"&&(r.imageUrl=n);const o=t.price;typeof o=="string"&&(r.price=o);const i=t.originalPrice;typeof i=="string"&&(r.originalPrice=i);const s=t.discountPercent;typeof s=="number"&&(r.discountPercent=s);const a=t.brand;typeof a=="string"&&(r.brand=a);const c=t.rating;typeof c=="number"&&(r.rating=c);const u=t.reviewCount;typeof u=="number"&&(r.reviewCount=u);const f=t.cartCode;typeof f=="string"&&(r.cartCode=f);const g=t.inStock;typeof g=="boolean"&&(r.inStock=g);const p=t.extras;return p!=null&&typeof p=="object"&&(r.extras=p),r}function Zo(e){if(!e||typeof e!="object")return null;const t=e,r=t.title,n=t.type;if(typeof r!="string"||typeof n!="string")return null;const o={title:r,type:n};return t.payload!==void 0&&(o.payload=t.payload),o}var zt={ProductGrid:({element:e,renderElement:t,context:r})=>{const n=document.createElement("div");n.className="gengage-simrel-grid",n.setAttribute("role","list");const o=e.props?.columns;let i;typeof o=="number"&&Number.isFinite(o)&&o>0?i=Math.floor(o):typeof r.gridColumns=="number"&&Number.isFinite(r.gridColumns)&&r.gridColumns>0&&(i=Math.floor(r.gridColumns)),i!==void 0&&n.style.setProperty("--gengage-simrel-columns",String(i));for(const s of e.children??[]){const a=t(s);a&&n.appendChild(a)}if(n.children.length===0){const s=document.createElement("div");s.className="gengage-simrel-empty",s.textContent=r.i18n.emptyStateMessage,n.appendChild(s)}return n},ProductCard:({element:e,context:t})=>{const r=Ct(e.props?.product??e.props);if(!r)return null;const n=e.props?.index,o=typeof n=="number"&&Number.isFinite(n)?n:0,i=e.props?.discountType,s=i==="strike-through"||i==="badge"?i:t.discountType,a={product:r,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return s!==void 0&&(a.discountType=s),t.renderCard!==void 0&&(a.renderCard=t.renderCard),t.renderCardElement!==void 0&&(a.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(a.pricing=t.pricing),St(a)},GroupTabs:({element:e,context:t})=>{const r=e.props?.groups;if(!Array.isArray(r))return null;const n=[];for(const s of r){if(!s||typeof s!="object")continue;const a=s;if(typeof a.name!="string")continue;const c=[];if(Array.isArray(a.products))for(const f of a.products){const g=Ct(f);g&&c.push(g)}const u={name:a.name,products:c};typeof a.highlight=="string"&&(u.highlight=a.highlight),n.push(u)}const o={groups:n,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n},i=e.props?.columns;return typeof i=="number"&&Number.isFinite(i)&&i>0?o.columns=Math.floor(i):typeof t.gridColumns=="number"&&Number.isFinite(t.gridColumns)&&t.gridColumns>0&&(o.columns=Math.floor(t.gridColumns)),t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),t.onGroupingActivate!==void 0&&(o.onGroupingActivate=t.onGroupingActivate),Oo(o)},EmptyState:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-empty";const n=e.props?.message;return r.textContent=typeof n=="string"?n:t.i18n.emptyStateMessage,r},AddToCartButton:({element:e,context:t})=>{const r=e.props?.sku,n=e.props?.cartCode;if(typeof r!="string"||typeof n!="string")return null;const o=document.createElement("button");o.className="gengage-simrel-atc gengage-chat-product-card-cta",o.type="button";const i=e.props?.label;return o.textContent=typeof i=="string"?i:t.i18n.addToCartButton,o.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),t.onAddToCart({sku:r,quantity:1,cartCode:n})}),o},QuickActions:({element:e,context:t})=>{const r=document.createElement("div");r.className="gengage-simrel-quick-actions";const n=e.props?.actions;if(!Array.isArray(n)||!t.onAction)return r;for(const o of n){if(!o||typeof o!="object")continue;const i=o,s=i.label,a=Zo(i.action);if(typeof s!="string"||!a)continue;const c=document.createElement("button");c.className="gengage-simrel-quick-action",c.type="button",c.textContent=s,c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.onAction?.(a)}),r.appendChild(c)}return r}},Re=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function Tt(){return{...zt}}function $t(e,t,r=zt,n=Re){return Pr({spec:e,context:t,registry:r,containerClassName:"gengage-simrel-uispec",unknownRenderer:n})}var It={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",ctaLabel:"İncele",outOfStockLabel:"Stokta Yok",decreaseLabel:"Azalt",increaseLabel:"Artır",errorLoadingMessage:"Benzer ürünler yüklenemedi.",retryButtonText:"Tekrar dene",priceSuffix:" TL",scrollTabsLeft:"Sola kaydır",scrollTabsRight:"Sağa kaydır"},Ro={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",ctaLabel:"View",outOfStockLabel:"Out of Stock",decreaseLabel:"Decrease",increaseLabel:"Increase",errorLoadingMessage:"Could not load similar products.",retryButtonText:"Try again",priceSuffix:"",scrollTabsLeft:"Scroll tabs left",scrollTabsRight:"Scroll tabs right"};function xo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Lo(e){return xo(e)==="en"?Ro:It}var Do=12e4;function jo(e){return e instanceof DOMException&&e.name==="AbortError"}var At=class extends mn{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._lastResultCount=-1,this._i18n=It}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this._contentEl.dataset.gengagePart="simrel-container",this._contentEl.lang=_n(e.locale);const t=this._clampGridColumns(e.gridColumns);t!==void 0&&this._contentEl.style.setProperty("--gengage-simrel-columns",String(t)),this.root.appendChild(this._contentEl),this._lastSku=e.sku,await this._fetchAndRender(e.sku),Hr("simrel")}onUpdate(e){const t=e.sku;!t||t===this._lastSku&&this._lastResultCount!==0||(this._lastSku=t,this._fetchAndRender(t))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(e){const t={sku:e.sku,name:e.name,url:e.url};if(e.imageUrl!==void 0&&(t.imageUrl=e.imageUrl),e.price!==void 0&&(t.price=e.price),e.originalPrice!==void 0&&(t.originalPrice=e.originalPrice),e.discountPercent!==void 0&&(t.discountPercent=e.discountPercent),e.brand!==void 0&&(t.brand=e.brand),e.rating!==void 0&&(t.rating=e.rating),e.reviewCount!==void 0&&(t.reviewCount=e.reviewCount),e.cartCode!==void 0&&(t.cartCode=e.cartCode),e.inStock!==void 0&&(t.inStock=e.inStock),this.config.onProductClick?.(t)===!1)return;const r=this.config.session?.sessionId??null;re("gengage:similar:product-click",{sku:e.sku,url:e.url,sessionId:r,productName:e.name}),this.config.onProductNavigate?.(e.url,e.sku,r)}_handleAddToCart(e){Kr(e.sku,e.quantity),this.config.onAddToCart?.(e),re("gengage:similar:add-to-cart",e),this.track(xr(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:e.quantity,sku:e.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}_isSuperseded(e){return this._abortController?.signal!==e}_emitSimilarProductsImpression(e,t){const r=this.config.session?.sessionId??null;re("gengage:similar:products-impression",{source_sku:this.config.sku,product_count:e,grouped:t,sessionId:r})}_resolveRequestTimeoutMs(){const e=this.config.requestTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Do:Math.floor(e)}async _fetchAndRender(e){this._abort();const t=new AbortController;this._abortController=t;const r=t.signal;let n=!1;const o=setTimeout(()=>{n=!0,t.abort()},this._resolveRequestTimeoutMs());if(r.addEventListener("abort",()=>clearTimeout(o),{once:!0}),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const i=document.createElement("div");i.className="gengage-simrel-loading",i.dataset.gengagePart="simrel-loading";const s=document.createElement("div");s.className="gengage-simrel-spinner",s.dataset.gengagePart="simrel-loading-spinner",i.appendChild(s),this._contentEl.appendChild(i);const a={middlewareUrl:this.config.middlewareUrl},c=crypto.randomUUID(),u=Date.now(),f=En({source:"simrel",locale:this.config.locale});this.track(Or(this.analyticsContext(),{endpoint:"similar_products",request_id:c,widget:"simrel"}));try{const g={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e};this.config.domain!==void 0&&(g.domain=this.config.domain);const p=await Eo(g,a,r);if(this._lastResultCount=p.length,!this._contentEl)return;if(this._contentEl.innerHTML="",p.length>0)try{const m=p.map(h=>h.sku),_=new Map(p.map(h=>[h.sku,h])),d=(await zo({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:m},a,r)).map(h=>({...h,products:h.products.map(v=>({..._.get(v.sku),...v})).filter(v=>typeof v.sku=="string"&&typeof v.name=="string"&&typeof v.url=="string")})).filter(h=>h.products.length>0);if(d.length>0&&this._contentEl){const h=this._buildGroupsSpec(d),v=this._renderUISpec(h);this._contentEl.appendChild(v),Xe("simrel"),this.track(Ke(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:d.reduce((x,z)=>x+z.products.length,0),widget:"simrel"})),this.track(Ye(this.analyticsContext(),{message_count:d.reduce((x,z)=>x+z.products.length,0),history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(d.reduce((x,z)=>x+z.products.length,0),!0);return}}catch{}if(this._isSuperseded(r))return;if(this._contentEl){const m=this._buildProductsSpec(p),_=this._renderUISpec(m);this._contentEl.appendChild(_)}p.length>0&&Xe("simrel"),this.track(Ke(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:p.length,widget:"simrel"})),this.track(Ye(this.analyticsContext(),{message_count:p.length,history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(p.length,!1)}catch(g){const p=jo(g);if(p&&this._isSuperseded(r))return;const m=p&&n?"REQUEST_TIMEOUT":"FETCH_ERROR",_=p&&n?"request_timeout":g instanceof Error?g.message:String(g);if(re("gengage:global:error",{source:"simrel",code:m,message:an(this.config.locale,g)}),this.track(Zr(this.analyticsContext(),{request_id:c,error_code:m,error_message:_,widget:"simrel"})),this._contentEl){this._contentEl.innerHTML="";const d=document.createElement("div");d.className="gengage-simrel-error";const h=document.createElement("span");h.textContent=this._i18n.errorLoadingMessage,d.appendChild(h);const v=document.createElement("button");v.className="gengage-simrel-retry",v.textContent=this._i18n.retryButtonText,v.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),d.appendChild(v),this._contentEl.appendChild(d)}}finally{clearTimeout(o),f()}}_clampGridColumns(e){if(!(e===void 0||typeof e!="number"||!Number.isFinite(e)))return Math.max(1,Math.min(12,Math.floor(e)))}_resolveI18n(e){return{...Lo(e.locale),...e.i18n}}_resolveUISpecRegistry(){return Nr(Tt(),this.config.renderer?.registry)}_buildRenderContext(){const e=this.config.renderCard,t={onClick:n=>this._handleProductClick(n),onAddToCart:n=>this._handleAddToCart(n),onGroupingActivate:n=>{re("gengage:similar:grouping-click",{grouping_label:n.grouping_label,grouping_index:n.grouping_index,sessionId:this.config.session?.sessionId??null})},i18n:this._i18n};this.config.discountType!==void 0&&(t.discountType=this.config.discountType),e!==void 0&&(t.renderCard=e),this.config.renderCardElement!==void 0&&(t.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(t.pricing=this.config.pricing);const r=this._clampGridColumns(this.config.gridColumns);return r!==void 0&&(t.gridColumns=r),t}_renderUISpec(e){const t=this._resolveUISpecRegistry(),r=this._buildRenderContext(),n=this.config.renderer?.unknownRenderer??Re,o=(s,a)=>$t(s,a,t,n),i=this.config.renderer?.renderUISpec;return i?i(e,r,{registry:t,unknownRenderer:n,defaultRender:o}):o(e,r)}_buildProductsSpec(e){const t={},r=[];for(let i=0;i<e.length;i++){const s=e[i],a=`product-${i}`;r.push(a),t[a]={type:"ProductCard",props:{product:s,index:i,discountType:this.config.discountType}}}const n={layout:"grid"},o=this._clampGridColumns(this.config.gridColumns);return o!==void 0&&(n.columns=o),t.root={type:"ProductGrid",props:n,children:r},{root:"root",elements:t}}_buildGroupsSpec(e){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:e}}}}}};function Uo(){return new At}var Pt;function l(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=s.prototype,f=Object.keys(u);for(let g=0;g<f.length;g++){const p=f[g];p in a||(a[p]=u[p].bind(a))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=r?.Parent?new i:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var X=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Nt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Pt=globalThis).__zod_globalConfig??(Pt.__zod_globalConfig={});var ge=globalThis.__zod_globalConfig;function H(e){return e&&Object.assign(ge,e),ge}function Ot(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function xe(e,t){return typeof t=="bigint"?t.toString():t}function Le(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function De(e){return e==null}function je(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Mo(e,t){const r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Zt=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Zt)return n===void 0&&(n=Zt,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function K(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function q(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function Rt(e){return JSON.stringify(e)}function Fo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var qo=Le(()=>{if(ge.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function ae(e){if(me(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(me(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Lt(e){return ae(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Go=new Set(["string","number","symbol"]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Jo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Vo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Bo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return G(e,q(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=r.shape[i])}return K(this,"shape",o),o},checks:[]}))}function Wo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return G(e,q(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return K(this,"shape",o),o},checks:[]}))}function Ho(e,t){if(!ae(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return G(e,q(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return K(this,"shape",n),n}}))}function Ko(e,t){if(!ae(t))throw new Error("Invalid input to safeExtend: expected a plain object");return G(e,q(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return K(this,"shape",r),r}}))}function Yo(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return G(e,q(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return K(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Qo(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return G(t,q(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=e?new e({type:"optional",innerType:o[s]}):o[s])}else for(const s in o)i[s]=e?new e({type:"optional",innerType:o[s]}):o[s];return K(this,"shape",i),i},checks:[]}))}function Xo(e,t,r){return G(t,q(t._zod.def,{get shape(){const n=t._zod.def.shape,o={...n};if(r)for(const i in r){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(o[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(const i in n)o[i]=new e({type:"nonoptional",innerType:n[i]});return K(this,"shape",o),o}}))}function ee(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ei(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Dt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function _e(e){return typeof e=="string"?e:e?.message}function Y(e,t,r){const n=e.message?e.message:_e(e.inst?._zod.def?.error?.(e))??_e(t?.error?.(e))??_e(r.customError?.(e))??_e(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function Ue(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ce(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var jt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ut=l("$ZodError",jt),Mt=l("$ZodError",jt,{Parent:Error});function ti(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function ri(e,t=r=>r.message){const r={_errors:[]},n=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;for(;u<a.length;){const f=a[u];u!==a.length-1?c[f]=c[f]||{_errors:[]}:(c[f]=c[f]||{_errors:[]},c[f]._errors.push(t(s))),c=c[f],u++}}}};return n(e),r}var Me=e=>(t,r,n,o)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new X;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>Y(c,i,H())));throw xt(a,o?.callee),a}return s.value},Fe=e=>async(t,r,n,o)=>{const i=n?{...n,async:!0}:{async:!0};let s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>Y(c,i,H())));throw xt(a,o?.callee),a}return s.value},ye=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new X;return i.issues.length?{success:!1,error:new(e??Ut)(i.issues.map(s=>Y(s,o,H())))}:{success:!0,data:i.value}},ni=ye(Mt),ve=e=>async(t,r,n)=>{const o=n?{...n,async:!0}:{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Y(s,o,H())))}:{success:!0,data:i.value}},oi=ve(Mt),ii=e=>(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return Me(e)(t,r,o)},si=e=>(t,r,n)=>Me(e)(t,r,n),ai=e=>async(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return Fe(e)(t,r,o)},ci=e=>async(t,r,n)=>Fe(e)(t,r,n),ui=e=>(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return ye(e)(t,r,o)},di=e=>(t,r,n)=>ye(e)(t,r,n),li=e=>async(t,r,n)=>{const o=n?{...n,direction:"backward"}:{direction:"backward"};return ve(e)(t,r,o)},fi=e=>async(t,r,n)=>ve(e)(t,r,n),pi=/^[cC][0-9a-z]{6,}$/,gi=/^[0-9a-z]+$/,mi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hi=/^[0-9a-vA-V]{20}$/,_i=/^[A-Za-z0-9]{27}$/,yi=/^[a-zA-Z0-9_-]{21}$/,vi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bi=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ft=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,wi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ki="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Si(){return new RegExp(ki,"u")}var Ei=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ci=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,zi=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ti=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$i=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qt=/^[A-Za-z0-9_-]*$/,Ii=/^https?$/,Ai=/^\+[1-9]\d{6,14}$/,Gt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Pi=new RegExp(`^${Gt}$`);function Jt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ni(e){return new RegExp(`^${Jt(e)}$`)}function Oi(e){const t=Jt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Gt}T(?:${n})$`)}var Zi=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ri=/^-?\d+$/,xi=/^-?\d+(?:\.\d+)?$/,Li=/^[^A-Z]*$/,Di=/^[^a-z]*$/,N=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Vt={number:"number",bigint:"bigint",object:"date"},Bt=l("$ZodCheckLessThan",(e,t)=>{N.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wt=l("$ZodCheckGreaterThan",(e,t)=>{N.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ji=l("$ZodCheckMultipleOf",(e,t)=>{N.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Mo(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ui=l("$ZodCheckNumberFormat",(e,t)=>{N.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Vo[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,r&&(a.pattern=Ri)}),e._zod.check=s=>{const a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Mi=l("$ZodCheckMaxLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!De(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=Ue(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Fi=l("$ZodCheckMinLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!De(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=Ue(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qi=l("$ZodCheckLengthEquals",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!De(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const s=Ue(o),a=i>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),be=l("$ZodCheckStringFormat",(e,t)=>{var r,n;N.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Gi=l("$ZodCheckRegex",(e,t)=>{be.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ji=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Li),be.init(e,t)}),Vi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Di),be.init(e,t)}),Bi=l("$ZodCheckIncludes",(e,t)=>{N.init(e,t);const r=he(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Wi=l("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`^${he(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Hi=l("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);const r=new RegExp(`.*${he(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ki=l("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),Yi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const t=e.split(`
|
|
49
49
|
`).filter(o=>o),r=Math.min(...t.map(o=>o.length-o.trimStart().length)),n=t.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of n)this.content.push(o)}compile(){const e=Function,t=this?.args,r=[...(this?.content??[""]).map(n=>` ${n}`)];return new e(...t,r.join(`
|
|
50
|
-
`))}},
|
|
50
|
+
`))}},Qi={major:4,minor:4,patch:3},T=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qi;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,c)=>{let u=ee(s),f;for(const g of a){if(g._zod.def.when){if(ei(s)||!g._zod.def.when(s))continue}else if(u)continue;const p=s.issues.length,m=g._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new X;if(f||m instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await m,s.issues.length!==p&&(u||(u=ee(s,p)))});else{if(s.issues.length===p)continue;u||(u=ee(s,p))}}return f?f.then(()=>s):s},i=(s,a,c)=>{if(ee(s))return s.aborted=!0,s;const u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new X;return u.then(f=>e._zod.parse(f,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(f=>i(f,s,a)):i(u,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new X;return c.then(u=>o(u,n,a))}return o(c,n,a)}}S(e,"~standard",()=>({validate:o=>{try{const i=ni(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return oi(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),qe=l("$ZodString",(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Zi(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),E=l("$ZodStringFormat",(e,t)=>{be.init(e,t),qe.init(e,t)}),Xi=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bi),E.init(e,t)}),es=l("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ft(r))}else t.pattern??(t.pattern=Ft());E.init(e,t)}),ts=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=wi),E.init(e,t)}),rs=l("$ZodURL",(e,t)=>{E.init(e,t),e._zod.check=r=>{try{const n=r.value.trim();if(!t.normalize&&t.protocol?.source===Ii.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}const o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ns=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Si()),E.init(e,t)}),os=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=yi),E.init(e,t)}),is=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=pi),E.init(e,t)}),ss=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gi),E.init(e,t)}),as=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=mi),E.init(e,t)}),cs=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=hi),E.init(e,t)}),us=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_i),E.init(e,t)}),ds=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Oi(t)),E.init(e,t)}),ls=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Pi),E.init(e,t)}),fs=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ni(t)),E.init(e,t)}),ps=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vi),E.init(e,t)}),gs=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ei),E.init(e,t),e._zod.bag.format="ipv4"}),ms=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ci),E.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),hs=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=zi),E.init(e,t)}),_s=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ti),E.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,i]=n;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Ht(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ys=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$i),E.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Ht(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function vs(e){if(!qt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return Ht(t.padEnd(Math.ceil(t.length/4)*4,"="))}var bs=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qt),E.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{vs(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ws=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ai),E.init(e,t)});function ks(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Ss=l("$ZodJWT",(e,t)=>{E.init(e,t),e._zod.check=r=>{ks(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Kt=l("$ZodNumber",(e,t)=>{T.init(e,t),e._zod.pattern=e._zod.bag.pattern??xi,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),Es=l("$ZodNumberFormat",(e,t)=>{Ui.init(e,t),Kt.init(e,t)}),Cs=l("$ZodUnknown",(e,t)=>{T.init(e,t),e._zod.parse=r=>r}),zs=l("$ZodNever",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Yt(e,t,r){e.issues.length&&t.issues.push(...Dt(r,e.issues)),t.value[r]=e.value}var Ts=l("$ZodArray",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Yt(u,r,s))):Yt(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});function we(e,t,r,n,o,i){const s=r in n;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...Dt(r,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function Qt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Jo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Xt(e,t,r,n,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,f=c.optin==="optional",g=c.optout==="optional";for(const p in t){if(p==="__proto__"||a.has(p))continue;if(u==="never"){s.push(p);continue}const m=c.run({value:t[p],issues:[]},n);m instanceof Promise?e.push(m.then(_=>we(_,r,p,t,f,g))):we(m,r,p,t,f,g)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var $s=l("$ZodObject",(e,t)=>{if(T.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...s};return Object.defineProperty(t,"shape",{value:a}),a}})}const r=Le(()=>Qt(t));S(e._zod,"propValues",()=>{const s=t.shape,a={};for(const c in s){const u=s[c]._zod;if(u.values){a[c]??(a[c]=new Set);for(const f of u.values)a[c].add(f)}}return a});const n=me,o=t.catchall;let i;e._zod.parse=(s,a)=>{i??(i=r.value);const c=s.value;if(!n(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),s;s.value={};const u=[],f=i.shape;for(const g of i.keys){const p=f[g],m=p._zod.optin==="optional",_=p._zod.optout==="optional",d=p._zod.run({value:c[g],issues:[]},a);d instanceof Promise?u.push(d.then(h=>we(h,s,g,c,m,_))):we(d,s,g,c,m,_)}return o?Xt(u,c,s,a,r.value,e):u.length?Promise.all(u).then(()=>s):s}}),Is=l("$ZodObjectJIT",(e,t)=>{$s.init(e,t);const r=e._zod.parse,n=Le(()=>Qt(t)),o=p=>{const m=new Yi(["shape","payload","ctx"]),_=n.value,d=z=>{const w=Rt(z);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};m.write("const input = payload.value;");const h=Object.create(null);let v=0;for(const z of _.keys)h[z]=`key_${v++}`;m.write("const newResult = {};");for(const z of _.keys){const w=h[z],b=Rt(z),A=p[z],j=A?._zod?.optin==="optional",ku=A?._zod?.optout==="optional";m.write(`const ${w} = ${d(z)};`),j&&ku?m.write(`
|
|
51
51
|
if (${w}.issues.length) {
|
|
52
52
|
if (${b} in input) {
|
|
53
53
|
payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
|
|
@@ -106,6 +106,6 @@
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const x=m.compile();return(z,w)=>x(p,z,w)};let i;const s=me,a=!ge.jitless,u=a&&Uo.value,f=t.catchall;let g;e._zod.parse=(p,m)=>{g??(g=n.value);const _=p.value;return s(_)?a&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),p=i(p,m),f?Qt([],_,p,m,g,e):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),p)}});function Xt(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ee(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Y(s,n,H())))}),t)}var Ts=l("$ZodUnion",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>je(o.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>Xt(a,n,e,o)):Xt(s,n,e,o)}}),$s=l("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,c])=>er(r,a,c)):er(r,i,s)}});function Ge(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ae(e)&&ae(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const s=Ge(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],s=Ge(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function er(e,t,r){const n=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(const a of r.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);const i=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),ee(e))return e;const s=Ge(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Is=l("$ZodEnum",(e,t)=>{T.init(e,t);const r=Nt(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Mo.has(typeof o)).map(o=>typeof o=="string"?he(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),As=l("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pt(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new X;return r.value=o,r.fallback=!0,r}});function tr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var rr=l("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${je(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>tr(s,o)):tr(i,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Ps=l("$ZodExactOptional",(e,t)=>{rr.init(e,t),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ns=l("$ZodNullable",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${je(r.source)}|null)$`):void 0}),S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Os=l("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>nr(i,t)):nr(o,t)}});function nr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Zs=l("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Rs=l("$ZodNonOptional",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>or(i,e)):or(o,e)}});function or(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var xs=l("$ZodCatch",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(s=>Y(s,n,H()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>Y(i,n,H()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),Ls=l("$ZodPipe",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(s=>ke(s,t.in,n)):ke(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>ke(i,t.out,n)):ke(o,t.out,n)}});function ke(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var Ds=l("$ZodReadonly",(e,t)=>{T.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(ir):ir(o)}});function ir(e){return e.value=Object.freeze(e.value),e}var js=l("$ZodCustom",(e,t)=>{N.init(e,t),T.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>sr(i,r,n,e));sr(o,r,n,e)}});function sr(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(ce(o))}}var ar,Us=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ms(){return new Us}(ar=globalThis).__zod_globalRegistry??(ar.__zod_globalRegistry=Ms());var ue=globalThis.__zod_globalRegistry;function Fs(e,t){return new e({type:"string",...y(t)})}function qs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function cr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Gs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Js(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Vs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Bs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Ws(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Hs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Ks(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ys(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Qs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Xs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function ea(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function ta(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function ra(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function na(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function oa(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function ia(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function sa(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function aa(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function ca(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function ua(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function da(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function la(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function fa(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function pa(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function ga(e,t){return new e({type:"number",checks:[],...y(t)})}function ma(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function ha(e){return new e({type:"unknown"})}function _a(e,t){return new e({type:"never",...y(t)})}function ur(e,t){return new Vt({check:"less_than",...y(t),value:e,inclusive:!1})}function Je(e,t){return new Vt({check:"less_than",...y(t),value:e,inclusive:!0})}function dr(e,t){return new Bt({check:"greater_than",...y(t),value:e,inclusive:!1})}function Ve(e,t){return new Bt({check:"greater_than",...y(t),value:e,inclusive:!0})}function lr(e,t){return new xi({check:"multiple_of",...y(t),value:e})}function fr(e,t){return new Di({check:"max_length",...y(t),maximum:e})}function Se(e,t){return new ji({check:"min_length",...y(t),minimum:e})}function pr(e,t){return new Ui({check:"length_equals",...y(t),length:e})}function ya(e,t){return new Mi({check:"string_format",format:"regex",...y(t),pattern:e})}function va(e){return new Fi({check:"string_format",format:"lowercase",...y(e)})}function ba(e){return new qi({check:"string_format",format:"uppercase",...y(e)})}function wa(e,t){return new Gi({check:"string_format",format:"includes",...y(t),includes:e})}function ka(e,t){return new Ji({check:"string_format",format:"starts_with",...y(t),prefix:e})}function Sa(e,t){return new Vi({check:"string_format",format:"ends_with",...y(t),suffix:e})}function te(e){return new Bi({check:"overwrite",tx:e})}function Ea(e){return te(t=>t.normalize(e))}function Ca(){return te(e=>e.trim())}function za(){return te(e=>e.toLowerCase())}function Ta(){return te(e=>e.toUpperCase())}function $a(){return te(e=>jo(e))}function Ia(e,t,r){return new e({type:"array",element:t,...y(r)})}function Aa(e,t,r){return new e({type:"custom",check:"custom",fn:t,...y(r)})}function Pa(e,t){const r=Na(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(ce(o,n.value,r._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(ce(i))}},e(n.value,n)),t);return r}function Na(e,t){const r=new N({check:"custom",...y(t)});return r._zod.check=e,r}function gr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ue,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function I(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const g=s.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,g,u)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),I(f,t,u),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&P(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function mr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=n.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(s[0])?.id,g=e.external.uri??(m=>m);if(f)return{ref:g(f)};const p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${g("__shared")}#/${a}/${p}`}}if(s[1]===r)return{ref:"#"};const c=`#/${a}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const g in f)delete f[g];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
109
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const x=m.compile();return(z,w)=>x(p,z,w)};let i;const s=me,a=!ge.jitless,u=a&&qo.value,f=t.catchall;let g;e._zod.parse=(p,m)=>{g??(g=n.value);const _=p.value;return s(_)?a&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),p=i(p,m),f?Xt([],_,p,m,g,e):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),p)}});function er(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ee(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Y(s,n,H())))}),t)}var As=l("$ZodUnion",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>je(o.source)).join("|")})$`)}});const r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>er(a,n,e,o)):er(s,n,e,o)}}),Ps=l("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,c])=>tr(r,a,c)):tr(r,i,s)}});function Ge(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ae(e)&&ae(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const s=Ge(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],s=Ge(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function tr(e,t,r){const n=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(const a of r.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);const i=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),ee(e))return e;const s=Ge(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Ns=l("$ZodEnum",(e,t)=>{T.init(e,t);const r=Ot(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Go.has(typeof o)).map(o=>typeof o=="string"?he(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),Os=l("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Nt(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new X;return r.value=o,r.fallback=!0,r}});function rr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var nr=l("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${je(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>rr(s,o)):rr(i,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Zs=l("$ZodExactOptional",(e,t)=>{nr.init(e,t),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Rs=l("$ZodNullable",(e,t)=>{T.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${je(r.source)}|null)$`):void 0}),S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),xs=l("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>or(i,t)):or(o,t)}});function or(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ls=l("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Ds=l("$ZodNonOptional",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>ir(i,e)):ir(o,e)}});function ir(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var js=l("$ZodCatch",(e,t)=>{T.init(e,t),e._zod.optin="optional",S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(s=>Y(s,n,H()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>Y(i,n,H()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),Us=l("$ZodPipe",(e,t)=>{T.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(s=>ke(s,t.in,n)):ke(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>ke(i,t.out,n)):ke(o,t.out,n)}});function ke(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var Ms=l("$ZodReadonly",(e,t)=>{T.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(sr):sr(o)}});function sr(e){return e.value=Object.freeze(e.value),e}var Fs=l("$ZodCustom",(e,t)=>{N.init(e,t),T.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>ar(i,r,n,e));ar(o,r,n,e)}});function ar(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(ce(o))}}var cr,qs=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Gs(){return new qs}(cr=globalThis).__zod_globalRegistry??(cr.__zod_globalRegistry=Gs());var ue=globalThis.__zod_globalRegistry;function Js(e,t){return new e({type:"string",...y(t)})}function Vs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function ur(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Bs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ws(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Hs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Ks(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Ys(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Qs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Xs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function ea(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function ta(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function ra(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function na(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function oa(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function ia(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function sa(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function aa(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function ca(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function ua(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function da(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function la(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function fa(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function pa(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function ga(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function ma(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function ha(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function _a(e,t){return new e({type:"number",checks:[],...y(t)})}function ya(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function va(e){return new e({type:"unknown"})}function ba(e,t){return new e({type:"never",...y(t)})}function dr(e,t){return new Bt({check:"less_than",...y(t),value:e,inclusive:!1})}function Je(e,t){return new Bt({check:"less_than",...y(t),value:e,inclusive:!0})}function lr(e,t){return new Wt({check:"greater_than",...y(t),value:e,inclusive:!1})}function Ve(e,t){return new Wt({check:"greater_than",...y(t),value:e,inclusive:!0})}function fr(e,t){return new ji({check:"multiple_of",...y(t),value:e})}function pr(e,t){return new Mi({check:"max_length",...y(t),maximum:e})}function Se(e,t){return new Fi({check:"min_length",...y(t),minimum:e})}function gr(e,t){return new qi({check:"length_equals",...y(t),length:e})}function wa(e,t){return new Gi({check:"string_format",format:"regex",...y(t),pattern:e})}function ka(e){return new Ji({check:"string_format",format:"lowercase",...y(e)})}function Sa(e){return new Vi({check:"string_format",format:"uppercase",...y(e)})}function Ea(e,t){return new Bi({check:"string_format",format:"includes",...y(t),includes:e})}function Ca(e,t){return new Wi({check:"string_format",format:"starts_with",...y(t),prefix:e})}function za(e,t){return new Hi({check:"string_format",format:"ends_with",...y(t),suffix:e})}function te(e){return new Ki({check:"overwrite",tx:e})}function Ta(e){return te(t=>t.normalize(e))}function $a(){return te(e=>e.trim())}function Ia(){return te(e=>e.toLowerCase())}function Aa(){return te(e=>e.toUpperCase())}function Pa(){return te(e=>Fo(e))}function Na(e,t,r){return new e({type:"array",element:t,...y(r)})}function Oa(e,t,r){return new e({type:"custom",check:"custom",fn:t,...y(r)})}function Za(e,t){const r=Ra(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(ce(o,n.value,r._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(ce(i))}},e(n.value,n)),t);return r}function Ra(e,t){const r=new N({check:"custom",...y(t)});return r._zod.check=e,r}function mr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ue,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function I(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const g=s.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,g,u)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),I(f,t,u),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&P(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function hr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=n.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(s[0])?.id,g=e.external.uri??(m=>m);if(f)return{ref:g(f)};const p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${g("__shared")}#/${a}/${p}`}}if(s[1]===r)return{ref:"#"};const c=`#/${a}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const f=a.schema;for(const g in f)delete f[g];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
110
110
|
|
|
111
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function hr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,f={...u},g=c.ref;if(c.ref=null,g){n(g);const m=e.seen.get(g),_=m.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(_)):Object.assign(u,_),Object.assign(u,f),a._zod.parent===g)for(const d in u)d==="$ref"||d==="allOf"||d in f||delete u[d];if(_.$ref&&m.def)for(const d in u)d==="$ref"||d==="allOf"||d in m.def&&JSON.stringify(u[d])===JSON.stringify(m.def[d])&&delete u[d]}const p=a._zod.parent;if(p&&p!==g){n(p);const m=e.seen.get(p);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(const _ in u)_==="$ref"||_==="allOf"||_ in m.def&&JSON.stringify(u[_])===JSON.stringify(m.def[_])&&delete u[_]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())n(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ee(t,"input",e.processors),output:Ee(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function P(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return P(n.element,r);if(n.type==="set")return P(n.valueType,r);if(n.type==="lazy")return P(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return P(n.innerType,r);if(n.type==="intersection")return P(n.left,r)||P(n.right,r);if(n.type==="record"||n.type==="map")return P(n.keyType,r)||P(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:P(n.in,r)||P(n.out,r);if(n.type==="object"){for(const o in n.shape)if(P(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(P(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(P(o,r))return!0;return!!(n.rest&&P(n.rest,r))}return!1}var Oa=(e,t={})=>r=>{const n=gr({...r,processors:t});return I(e,n),mr(n,e),hr(n,e)},Ee=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},s=gr({...o??{},target:i,io:t,processors:r});return I(e,s),mr(s,e),hr(s,e)},Za={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ra=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=Za[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},xa=(e,t,r,n)=>{const o=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";const g=typeof f=="number"&&f>=(i??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";g?m?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof i=="number"&&(o.minimum=i),p?m?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof s=="number"&&(o.maximum=s),typeof c=="number"&&(o.multipleOf=c)},La=(e,t,r,n)=>{r.not={}},Da=(e,t,r,n)=>{},ja=(e,t,r,n)=>{const o=e._zod.def,i=Nt(o.entries);i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},Ua=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ma=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Fa=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=I(i.element,t,{...n,path:[...n.path,"items"]})},qa=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=I(s[u],t,{...n,path:[...n.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const f=i.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=I(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ga=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>I(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=s:r.anyOf=s},Ja=(e,t,r,n)=>{const o=e._zod.def,i=I(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=I(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;r.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]},Va=(e,t,r,n)=>{const o=e._zod.def,i=I(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ba=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Wa=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Ha=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Ka=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Ya=(e,t,r,n)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;I(s,t,n);const a=t.seen.get(e);a.ref=s},Qa=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},_r=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Xa=l("ZodISODateTime",(e,t)=>{as.init(e,t),C.init(e,t)});function ec(e){return da(Xa,e)}var tc=l("ZodISODate",(e,t)=>{cs.init(e,t),C.init(e,t)});function rc(e){return la(tc,e)}var nc=l("ZodISOTime",(e,t)=>{us.init(e,t),C.init(e,t)});function oc(e){return fa(nc,e)}var ic=l("ZodISODuration",(e,t)=>{ds.init(e,t),C.init(e,t)});function sc(e){return pa(ic,e)}var ac=(e,t)=>{jt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Xo(e,r)},flatten:{value:r=>Qo(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,xe,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,xe,2)}},isEmpty:{get(){return e.issues.length===0}}})},R=l("ZodError",ac,{Parent:Error}),cc=Me(R),uc=Fe(R),dc=ye(R),lc=ve(R),fc=ri(R),pc=ni(R),gc=oi(R),mc=ii(R),hc=si(R),_c=ai(R),yc=ci(R),vc=ui(R),yr=new WeakMap;function de(e,t,r){const n=Object.getPrototypeOf(e);let o=yr.get(n);if(o||(o=new Set,yr.set(n,o)),!o.has(t)){o.add(t);for(const i in r){const s=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var $=l("ZodType",(e,t)=>(T.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ee(e,"input"),output:Ee(e,"output")}}),e.toJSONSchema=Oa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>cc(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>dc(e,r,n),e.parseAsync=async(r,n)=>uc(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>lc(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>fc(e,r,n),e.decode=(r,n)=>pc(e,r,n),e.encodeAsync=async(r,n)=>gc(e,r,n),e.decodeAsync=async(r,n)=>mc(e,r,n),e.safeEncode=(r,n)=>hc(e,r,n),e.safeDecode=(r,n)=>_c(e,r,n),e.safeEncodeAsync=async(r,n)=>yc(e,r,n),e.safeDecodeAsync=async(r,n)=>vc(e,r,n),de(e,"ZodType",{check(...r){const n=this.def;return this.clone(q(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return G(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(du(r,n))},superRefine(r,n){return this.check(lu(r,n))},overwrite(r){return this.check(te(r))},optional(){return Cr(this)},exactOptional(){return Yc(this)},nullable(){return zr(this)},nullish(){return Cr(zr(this))},nonoptional(r){return nu(this,r)},array(){return Sr(this)},or(r){return Jc([this,r])},and(r){return Bc(this,r)},transform(r){return $r(this,Hc(r))},default(r){return eu(this,r)},prefault(r){return ru(this,r)},catch(r){return iu(this,r)},pipe(r){return $r(this,r)},readonly(){return cu(this)},describe(r){const n=this.clone();return ue.add(n,{description:r}),n},meta(...r){if(r.length===0)return ue.get(this);const n=this.clone();return ue.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e)),vr=l("_ZodString",(e,t)=>{qe.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ra(e,n,o,i);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,de(e,"_ZodString",{regex(...n){return this.check(ya(...n))},includes(...n){return this.check(wa(...n))},startsWith(...n){return this.check(ka(...n))},endsWith(...n){return this.check(Sa(...n))},min(...n){return this.check(Se(...n))},max(...n){return this.check(fr(...n))},length(...n){return this.check(pr(...n))},nonempty(...n){return this.check(Se(1,...n))},lowercase(n){return this.check(va(n))},uppercase(n){return this.check(ba(n))},trim(){return this.check(Ca())},normalize(...n){return this.check(Ea(...n))},toLowerCase(){return this.check(za())},toUpperCase(){return this.check(Ta())},slugify(){return this.check($a())}})}),bc=l("ZodString",(e,t)=>{qe.init(e,t),vr.init(e,t),e.email=r=>e.check(qs(wc,r)),e.url=r=>e.check(Ws(kc,r)),e.jwt=r=>e.check(ua(Lc,r)),e.emoji=r=>e.check(Hs(Sc,r)),e.guid=r=>e.check(cr(br,r)),e.uuid=r=>e.check(Gs(Ce,r)),e.uuidv4=r=>e.check(Js(Ce,r)),e.uuidv6=r=>e.check(Vs(Ce,r)),e.uuidv7=r=>e.check(Bs(Ce,r)),e.nanoid=r=>e.check(Ks(Ec,r)),e.guid=r=>e.check(cr(br,r)),e.cuid=r=>e.check(Ys(Cc,r)),e.cuid2=r=>e.check(Qs(zc,r)),e.ulid=r=>e.check(Xs(Tc,r)),e.base64=r=>e.check(sa(Zc,r)),e.base64url=r=>e.check(aa(Rc,r)),e.xid=r=>e.check(ea($c,r)),e.ksuid=r=>e.check(ta(Ic,r)),e.ipv4=r=>e.check(ra(Ac,r)),e.ipv6=r=>e.check(na(Pc,r)),e.cidrv4=r=>e.check(oa(Nc,r)),e.cidrv6=r=>e.check(ia(Oc,r)),e.e164=r=>e.check(ca(xc,r)),e.datetime=r=>e.check(ec(r)),e.date=r=>e.check(rc(r)),e.time=r=>e.check(oc(r)),e.duration=r=>e.check(sc(r))});function O(e){return Fs(bc,e)}var C=l("ZodStringFormat",(e,t)=>{E.init(e,t),vr.init(e,t)}),wc=l("ZodEmail",(e,t)=>{Qi.init(e,t),C.init(e,t)}),br=l("ZodGUID",(e,t)=>{Ki.init(e,t),C.init(e,t)}),Ce=l("ZodUUID",(e,t)=>{Yi.init(e,t),C.init(e,t)}),kc=l("ZodURL",(e,t)=>{Xi.init(e,t),C.init(e,t)}),Sc=l("ZodEmoji",(e,t)=>{es.init(e,t),C.init(e,t)}),Ec=l("ZodNanoID",(e,t)=>{ts.init(e,t),C.init(e,t)}),Cc=l("ZodCUID",(e,t)=>{rs.init(e,t),C.init(e,t)}),zc=l("ZodCUID2",(e,t)=>{ns.init(e,t),C.init(e,t)}),Tc=l("ZodULID",(e,t)=>{os.init(e,t),C.init(e,t)}),$c=l("ZodXID",(e,t)=>{is.init(e,t),C.init(e,t)}),Ic=l("ZodKSUID",(e,t)=>{ss.init(e,t),C.init(e,t)}),Ac=l("ZodIPv4",(e,t)=>{ls.init(e,t),C.init(e,t)}),Pc=l("ZodIPv6",(e,t)=>{fs.init(e,t),C.init(e,t)}),Nc=l("ZodCIDRv4",(e,t)=>{ps.init(e,t),C.init(e,t)}),Oc=l("ZodCIDRv6",(e,t)=>{gs.init(e,t),C.init(e,t)}),Zc=l("ZodBase64",(e,t)=>{ms.init(e,t),C.init(e,t)}),Rc=l("ZodBase64URL",(e,t)=>{_s.init(e,t),C.init(e,t)}),xc=l("ZodE164",(e,t)=>{ys.init(e,t),C.init(e,t)}),Lc=l("ZodJWT",(e,t)=>{bs.init(e,t),C.init(e,t)}),wr=l("ZodNumber",(e,t)=>{Ht.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,i)=>xa(e,n,o,i),de(e,"ZodNumber",{gt(n,o){return this.check(dr(n,o))},gte(n,o){return this.check(Ve(n,o))},min(n,o){return this.check(Ve(n,o))},lt(n,o){return this.check(ur(n,o))},lte(n,o){return this.check(Je(n,o))},max(n,o){return this.check(Je(n,o))},int(n){return this.check(kr(n))},safe(n){return this.check(kr(n))},positive(n){return this.check(dr(0,n))},nonnegative(n){return this.check(Ve(0,n))},negative(n){return this.check(ur(0,n))},nonpositive(n){return this.check(Je(0,n))},multipleOf(n,o){return this.check(lr(n,o))},step(n,o){return this.check(lr(n,o))},finite(){return this}});const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function le(e){return ga(wr,e)}var Dc=l("ZodNumberFormat",(e,t)=>{ws.init(e,t),wr.init(e,t)});function kr(e){return ma(Dc,e)}var jc=l("ZodUnknown",(e,t)=>{ks.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Da(e,r,n,o)});function Be(){return ha(jc)}var Uc=l("ZodNever",(e,t)=>{Ss.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>La(e,r,n,o)});function Mc(e){return _a(Uc,e)}var Fc=l("ZodArray",(e,t)=>{Es.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fa(e,r,n,o),e.element=t.element,de(e,"ZodArray",{min(r,n){return this.check(Se(r,n))},nonempty(r){return this.check(Se(1,r))},max(r,n){return this.check(fr(r,n))},length(r,n){return this.check(pr(r,n))},unwrap(){return this.element}})});function Sr(e,t){return Ia(Fc,e,t)}var qc=l("ZodObject",(e,t)=>{zs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o),S(e,"shape",()=>t.shape),de(e,"ZodObject",{keyof(){return He(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Be()})},loose(){return this.clone({...this._zod.def,catchall:Be()})},strict(){return this.clone({...this._zod.def,catchall:Mc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Vo(this,r)},safeExtend(r){return Bo(this,r)},merge(r){return Wo(this,r)},pick(r){return Go(this,r)},omit(r){return Jo(this,r)},partial(...r){return Ho(Er,this,r[0])},required(...r){return Ko(Tr,this,r[0])}})});function J(e,t){return new qc({type:"object",shape:e??{},...y(t)})}var Gc=l("ZodUnion",(e,t)=>{Ts.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ga(e,r,n,o),e.options=t.options});function Jc(e,t){return new Gc({type:"union",options:e,...y(t)})}var Vc=l("ZodIntersection",(e,t)=>{$s.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ja(e,r,n,o)});function Bc(e,t){return new Vc({type:"intersection",left:e,right:t})}var We=l("ZodEnum",(e,t)=>{Is.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,i)=>ja(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const s of n)if(r.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new We({...t,checks:[],...y(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const s of n)if(r.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new We({...t,checks:[],...y(o),entries:i})}});function He(e,t){return new We({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e,...y(t)})}var Wc=l("ZodTransform",(e,t)=>{As.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ma(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pt(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(ce(i,r.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ce(s))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function Hc(e){return new Wc({type:"transform",transform:e})}var Er=l("ZodOptional",(e,t)=>{rr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_r(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Cr(e){return new Er({type:"optional",innerType:e})}var Kc=l("ZodExactOptional",(e,t)=>{Ps.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_r(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Kc({type:"optional",innerType:e})}var Qc=l("ZodNullable",(e,t)=>{Ns.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Va(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function zr(e){return new Qc({type:"nullable",innerType:e})}var Xc=l("ZodDefault",(e,t)=>{Os.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function eu(e,t){return new Xc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():xt(t)}})}var tu=l("ZodPrefault",(e,t)=>{Zs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ha(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ru(e,t){return new tu({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():xt(t)}})}var Tr=l("ZodNonOptional",(e,t)=>{Rs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ba(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nu(e,t){return new Tr({type:"nonoptional",innerType:e,...y(t)})}var ou=l("ZodCatch",(e,t)=>{xs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ka(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function iu(e,t){return new ou({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var su=l("ZodPipe",(e,t)=>{Ls.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ya(e,r,n,o),e.in=t.in,e.out=t.out});function $r(e,t){return new su({type:"pipe",in:e,out:t})}var au=l("ZodReadonly",(e,t)=>{Ds.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function cu(e){return new au({type:"readonly",innerType:e})}var uu=l("ZodCustom",(e,t)=>{js.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ua(e,r,n,o)});function du(e,t={}){return Aa(uu,e,t)}function lu(e,t){return Pa(e,t)}var fu=J({sku:O(),name:O(),imageUrl:O().url().optional(),price:O().optional(),originalPrice:O().optional(),discountPercent:le().optional(),url:O().url(),brand:O().optional(),rating:le().min(0).max(5).optional(),reviewCount:le().int().nonnegative().optional()}),pu=J({layout:He(["grid","carousel"]).optional(),columns:le().int().positive().optional()}),gu=J({product:fu,index:le().int().nonnegative(),discountType:He(["strike-through","badge"]).optional()}),mu=J({sku:O(),label:O().optional(),cartCode:O()}),hu=J({actions:Sr(J({label:O(),action:J({title:O(),type:O(),payload:Be().optional()})}))}),_u=J({message:O().optional()}),yu={components:{ProductGrid:{schema:pu,description:"Outer grid or carousel container for similar products."},ProductCard:{schema:gu,description:"A single product card with image, title, price, and actions."},AddToCartButton:{schema:mu,description:"Add-to-cart CTA rendered inside or below a product card."},QuickActions:{schema:hu,description:"A row of quick-action buttons below product info."},EmptyState:{schema:_u,description:"Empty state shown when no similar products are available."}}},vu=12e4;function bu(e){return e instanceof DOMException&&e.name==="AbortError"}var Ir=class extends mn{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._lastResultCount=-1,this._i18n=It}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this._contentEl.dataset.gengagePart="simrel-container",this._contentEl.lang=_n(e.locale);const t=this._clampGridColumns(e.gridColumns);t!==void 0&&this._contentEl.style.setProperty("--gengage-simrel-columns",String(t)),this.root.appendChild(this._contentEl),this._lastSku=e.sku,await this._fetchAndRender(e.sku),Hr("simrel")}onUpdate(e){const t=e.sku;!t||t===this._lastSku&&this._lastResultCount!==0||(this._lastSku=t,this._fetchAndRender(t))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(e){const t={sku:e.sku,name:e.name,url:e.url};if(e.imageUrl!==void 0&&(t.imageUrl=e.imageUrl),e.price!==void 0&&(t.price=e.price),e.originalPrice!==void 0&&(t.originalPrice=e.originalPrice),e.discountPercent!==void 0&&(t.discountPercent=e.discountPercent),e.brand!==void 0&&(t.brand=e.brand),e.rating!==void 0&&(t.rating=e.rating),e.reviewCount!==void 0&&(t.reviewCount=e.reviewCount),e.cartCode!==void 0&&(t.cartCode=e.cartCode),e.inStock!==void 0&&(t.inStock=e.inStock),this.config.onProductClick?.(t)===!1)return;const r=this.config.session?.sessionId??null;re("gengage:similar:product-click",{sku:e.sku,url:e.url,sessionId:r,productName:e.name}),this.config.onProductNavigate?.(e.url,e.sku,r)}_handleAddToCart(e){Kr(e.sku,e.quantity),this.config.onAddToCart?.(e),re("gengage:similar:add-to-cart",e),this.track(xr(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:e.quantity,sku:e.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}_isSuperseded(e){return this._abortController?.signal!==e}_emitSimilarProductsImpression(e,t){const r=this.config.session?.sessionId??null;re("gengage:similar:products-impression",{source_sku:this.config.sku,product_count:e,grouped:t,sessionId:r})}_resolveRequestTimeoutMs(){const e=this.config.requestTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?vu:Math.floor(e)}async _fetchAndRender(e){this._abort();const t=new AbortController;this._abortController=t;const r=t.signal;let n=!1;const o=setTimeout(()=>{n=!0,t.abort()},this._resolveRequestTimeoutMs());if(r.addEventListener("abort",()=>clearTimeout(o),{once:!0}),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const i=document.createElement("div");i.className="gengage-simrel-loading",i.dataset.gengagePart="simrel-loading";const s=document.createElement("div");s.className="gengage-simrel-spinner",s.dataset.gengagePart="simrel-loading-spinner",i.appendChild(s),this._contentEl.appendChild(i);const a={middlewareUrl:this.config.middlewareUrl},c=crypto.randomUUID(),u=Date.now(),f=En({source:"simrel",locale:this.config.locale});this.track(Or(this.analyticsContext(),{endpoint:"similar_products",request_id:c,widget:"simrel"}));try{const g={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e};this.config.domain!==void 0&&(g.domain=this.config.domain);const p=await Eo(g,a,r);if(this._lastResultCount=p.length,!this._contentEl)return;if(this._contentEl.innerHTML="",p.length>0)try{const m=p.map(h=>h.sku),_=new Map(p.map(h=>[h.sku,h])),d=(await zo({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:m},a,r)).map(h=>({...h,products:h.products.map(v=>({..._.get(v.sku),...v})).filter(v=>typeof v.sku=="string"&&typeof v.name=="string"&&typeof v.url=="string")})).filter(h=>h.products.length>0);if(d.length>0&&this._contentEl){const h=this._buildGroupsSpec(d),v=this._renderUISpec(h);this._contentEl.appendChild(v),Xe("simrel"),this.track(Ke(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:d.reduce((x,z)=>x+z.products.length,0),widget:"simrel"})),this.track(Ye(this.analyticsContext(),{message_count:d.reduce((x,z)=>x+z.products.length,0),history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(d.reduce((x,z)=>x+z.products.length,0),!0);return}}catch{}if(this._isSuperseded(r))return;if(this._contentEl){const m=this._buildProductsSpec(p),_=this._renderUISpec(m);this._contentEl.appendChild(_)}p.length>0&&Xe("simrel"),this.track(Ke(this.analyticsContext(),{request_id:c,latency_ms:Date.now()-u,chunk_count:p.length,widget:"simrel"})),this.track(Ye(this.analyticsContext(),{message_count:p.length,history_ref:c,redaction_level:"none",widget:"simrel"})),this._emitSimilarProductsImpression(p.length,!1)}catch(g){const p=bu(g);if(p&&this._isSuperseded(r))return;const m=p&&n?"REQUEST_TIMEOUT":"FETCH_ERROR",_=p&&n?"request_timeout":g instanceof Error?g.message:String(g);if(re("gengage:global:error",{source:"simrel",code:m,message:an(this.config.locale,g)}),this.track(Zr(this.analyticsContext(),{request_id:c,error_code:m,error_message:_,widget:"simrel"})),this._contentEl){this._contentEl.innerHTML="";const d=document.createElement("div");d.className="gengage-simrel-error";const h=document.createElement("span");h.textContent=this._i18n.errorLoadingMessage,d.appendChild(h);const v=document.createElement("button");v.className="gengage-simrel-retry",v.textContent=this._i18n.retryButtonText,v.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),d.appendChild(v),this._contentEl.appendChild(d)}}finally{clearTimeout(o),f()}}_clampGridColumns(e){if(!(e===void 0||typeof e!="number"||!Number.isFinite(e)))return Math.max(1,Math.min(12,Math.floor(e)))}_resolveI18n(e){return{...Lo(e.locale),...e.i18n}}_resolveUISpecRegistry(){return Nr(Tt(),this.config.renderer?.registry)}_buildRenderContext(){const e=this.config.renderCard,t={onClick:n=>this._handleProductClick(n),onAddToCart:n=>this._handleAddToCart(n),onGroupingActivate:n=>{re("gengage:similar:grouping-click",{grouping_label:n.grouping_label,grouping_index:n.grouping_index,sessionId:this.config.session?.sessionId??null})},i18n:this._i18n};this.config.discountType!==void 0&&(t.discountType=this.config.discountType),e!==void 0&&(t.renderCard=e),this.config.renderCardElement!==void 0&&(t.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(t.pricing=this.config.pricing);const r=this._clampGridColumns(this.config.gridColumns);return r!==void 0&&(t.gridColumns=r),t}_renderUISpec(e){const t=this._resolveUISpecRegistry(),r=this._buildRenderContext(),n=this.config.renderer?.unknownRenderer??Re,o=(s,a)=>$t(s,a,t,n),i=this.config.renderer?.renderUISpec;return i?i(e,r,{registry:t,unknownRenderer:n,defaultRender:o}):o(e,r)}_buildProductsSpec(e){const t={},r=[];for(let i=0;i<e.length;i++){const s=e[i],a=`product-${i}`;r.push(a),t[a]={type:"ProductCard",props:{product:s,index:i,discountType:this.config.discountType}}}const n={layout:"grid"},o=this._clampGridColumns(this.config.gridColumns);return o!==void 0&&(n.columns=o),t.root={type:"ProductGrid",props:n,children:r},{root:"root",elements:t}}_buildGroupsSpec(e){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:e}}}}}};function wu(){return new Ir}V.GengageSimRel=Ir,V.createDefaultSimRelUISpecRegistry=Tt,V.createSimRelWidget=wu,V.defaultSimRelUnknownUISpecRenderer=Re,V.renderSimRelUISpec=$t,V.simRelCatalog=yu})(this.Gengage=this.Gengage||{});
|
|
111
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function _r(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,f={...u},g=c.ref;if(c.ref=null,g){n(g);const m=e.seen.get(g),_=m.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(_)):Object.assign(u,_),Object.assign(u,f),a._zod.parent===g)for(const d in u)d==="$ref"||d==="allOf"||d in f||delete u[d];if(_.$ref&&m.def)for(const d in u)d==="$ref"||d==="allOf"||d in m.def&&JSON.stringify(u[d])===JSON.stringify(m.def[d])&&delete u[d]}const p=a._zod.parent;if(p&&p!==g){n(p);const m=e.seen.get(p);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(const _ in u)_==="$ref"||_==="allOf"||_ in m.def&&JSON.stringify(u[_])===JSON.stringify(m.def[_])&&delete u[_]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())n(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ee(t,"input",e.processors),output:Ee(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function P(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return P(n.element,r);if(n.type==="set")return P(n.valueType,r);if(n.type==="lazy")return P(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return P(n.innerType,r);if(n.type==="intersection")return P(n.left,r)||P(n.right,r);if(n.type==="record"||n.type==="map")return P(n.keyType,r)||P(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:P(n.in,r)||P(n.out,r);if(n.type==="object"){for(const o in n.shape)if(P(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(P(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(P(o,r))return!0;return!!(n.rest&&P(n.rest,r))}return!1}var xa=(e,t={})=>r=>{const n=mr({...r,processors:t});return I(e,n),hr(n,e),_r(n,e)},Ee=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},s=mr({...o??{},target:i,io:t,processors:r});return I(e,s),hr(s,e),_r(s,e)},La={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Da=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=La[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},ja=(e,t,r,n)=>{const o=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";const g=typeof f=="number"&&f>=(i??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";g?m?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof i=="number"&&(o.minimum=i),p?m?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof s=="number"&&(o.maximum=s),typeof c=="number"&&(o.multipleOf=c)},Ua=(e,t,r,n)=>{r.not={}},Ma=(e,t,r,n)=>{},Fa=(e,t,r,n)=>{const o=e._zod.def,i=Ot(o.entries);i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},qa=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ga=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ja=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=I(i.element,t,{...n,path:[...n.path,"items"]})},Va=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=I(s[u],t,{...n,path:[...n.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const f=i.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=I(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ba=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>I(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=s:r.anyOf=s},Wa=(e,t,r,n)=>{const o=e._zod.def,i=I(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=I(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;r.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]},Ha=(e,t,r,n)=>{const o=e._zod.def,i=I(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ka=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Ya=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Qa=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Xa=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},ec=(e,t,r,n)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;I(s,t,n);const a=t.seen.get(e);a.ref=s},tc=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},yr=(e,t,r,n)=>{const o=e._zod.def;I(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},rc=l("ZodISODateTime",(e,t)=>{ds.init(e,t),C.init(e,t)});function nc(e){return pa(rc,e)}var oc=l("ZodISODate",(e,t)=>{ls.init(e,t),C.init(e,t)});function ic(e){return ga(oc,e)}var sc=l("ZodISOTime",(e,t)=>{fs.init(e,t),C.init(e,t)});function ac(e){return ma(sc,e)}var cc=l("ZodISODuration",(e,t)=>{ps.init(e,t),C.init(e,t)});function uc(e){return ha(cc,e)}var dc=(e,t)=>{Ut.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>ri(e,r)},flatten:{value:r=>ti(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,xe,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,xe,2)}},isEmpty:{get(){return e.issues.length===0}}})},R=l("ZodError",dc,{Parent:Error}),lc=Me(R),fc=Fe(R),pc=ye(R),gc=ve(R),mc=ii(R),hc=si(R),_c=ai(R),yc=ci(R),vc=ui(R),bc=di(R),wc=li(R),kc=fi(R),vr=new WeakMap;function de(e,t,r){const n=Object.getPrototypeOf(e);let o=vr.get(n);if(o||(o=new Set,vr.set(n,o)),!o.has(t)){o.add(t);for(const i in r){const s=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var $=l("ZodType",(e,t)=>(T.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ee(e,"input"),output:Ee(e,"output")}}),e.toJSONSchema=xa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>lc(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>pc(e,r,n),e.parseAsync=async(r,n)=>fc(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>gc(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>mc(e,r,n),e.decode=(r,n)=>hc(e,r,n),e.encodeAsync=async(r,n)=>_c(e,r,n),e.decodeAsync=async(r,n)=>yc(e,r,n),e.safeEncode=(r,n)=>vc(e,r,n),e.safeDecode=(r,n)=>bc(e,r,n),e.safeEncodeAsync=async(r,n)=>wc(e,r,n),e.safeDecodeAsync=async(r,n)=>kc(e,r,n),de(e,"ZodType",{check(...r){const n=this.def;return this.clone(q(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return G(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(pu(r,n))},superRefine(r,n){return this.check(gu(r,n))},overwrite(r){return this.check(te(r))},optional(){return zr(this)},exactOptional(){return eu(this)},nullable(){return Tr(this)},nullish(){return zr(Tr(this))},nonoptional(r){return su(this,r)},array(){return Er(this)},or(r){return Wc([this,r])},and(r){return Kc(this,r)},transform(r){return Ir(this,Qc(r))},default(r){return nu(this,r)},prefault(r){return iu(this,r)},catch(r){return cu(this,r)},pipe(r){return Ir(this,r)},readonly(){return lu(this)},describe(r){const n=this.clone();return ue.add(n,{description:r}),n},meta(...r){if(r.length===0)return ue.get(this);const n=this.clone();return ue.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e)),br=l("_ZodString",(e,t)=>{qe.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Da(e,n,o,i);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,de(e,"_ZodString",{regex(...n){return this.check(wa(...n))},includes(...n){return this.check(Ea(...n))},startsWith(...n){return this.check(Ca(...n))},endsWith(...n){return this.check(za(...n))},min(...n){return this.check(Se(...n))},max(...n){return this.check(pr(...n))},length(...n){return this.check(gr(...n))},nonempty(...n){return this.check(Se(1,...n))},lowercase(n){return this.check(ka(n))},uppercase(n){return this.check(Sa(n))},trim(){return this.check($a())},normalize(...n){return this.check(Ta(...n))},toLowerCase(){return this.check(Ia())},toUpperCase(){return this.check(Aa())},slugify(){return this.check(Pa())}})}),Sc=l("ZodString",(e,t)=>{qe.init(e,t),br.init(e,t),e.email=r=>e.check(Vs(Ec,r)),e.url=r=>e.check(Ys(Cc,r)),e.jwt=r=>e.check(fa(Uc,r)),e.emoji=r=>e.check(Qs(zc,r)),e.guid=r=>e.check(ur(wr,r)),e.uuid=r=>e.check(Bs(Ce,r)),e.uuidv4=r=>e.check(Ws(Ce,r)),e.uuidv6=r=>e.check(Hs(Ce,r)),e.uuidv7=r=>e.check(Ks(Ce,r)),e.nanoid=r=>e.check(Xs(Tc,r)),e.guid=r=>e.check(ur(wr,r)),e.cuid=r=>e.check(ea($c,r)),e.cuid2=r=>e.check(ta(Ic,r)),e.ulid=r=>e.check(ra(Ac,r)),e.base64=r=>e.check(ua(Lc,r)),e.base64url=r=>e.check(da(Dc,r)),e.xid=r=>e.check(na(Pc,r)),e.ksuid=r=>e.check(oa(Nc,r)),e.ipv4=r=>e.check(ia(Oc,r)),e.ipv6=r=>e.check(sa(Zc,r)),e.cidrv4=r=>e.check(aa(Rc,r)),e.cidrv6=r=>e.check(ca(xc,r)),e.e164=r=>e.check(la(jc,r)),e.datetime=r=>e.check(nc(r)),e.date=r=>e.check(ic(r)),e.time=r=>e.check(ac(r)),e.duration=r=>e.check(uc(r))});function O(e){return Js(Sc,e)}var C=l("ZodStringFormat",(e,t)=>{E.init(e,t),br.init(e,t)}),Ec=l("ZodEmail",(e,t)=>{ts.init(e,t),C.init(e,t)}),wr=l("ZodGUID",(e,t)=>{Xi.init(e,t),C.init(e,t)}),Ce=l("ZodUUID",(e,t)=>{es.init(e,t),C.init(e,t)}),Cc=l("ZodURL",(e,t)=>{rs.init(e,t),C.init(e,t)}),zc=l("ZodEmoji",(e,t)=>{ns.init(e,t),C.init(e,t)}),Tc=l("ZodNanoID",(e,t)=>{os.init(e,t),C.init(e,t)}),$c=l("ZodCUID",(e,t)=>{is.init(e,t),C.init(e,t)}),Ic=l("ZodCUID2",(e,t)=>{ss.init(e,t),C.init(e,t)}),Ac=l("ZodULID",(e,t)=>{as.init(e,t),C.init(e,t)}),Pc=l("ZodXID",(e,t)=>{cs.init(e,t),C.init(e,t)}),Nc=l("ZodKSUID",(e,t)=>{us.init(e,t),C.init(e,t)}),Oc=l("ZodIPv4",(e,t)=>{gs.init(e,t),C.init(e,t)}),Zc=l("ZodIPv6",(e,t)=>{ms.init(e,t),C.init(e,t)}),Rc=l("ZodCIDRv4",(e,t)=>{hs.init(e,t),C.init(e,t)}),xc=l("ZodCIDRv6",(e,t)=>{_s.init(e,t),C.init(e,t)}),Lc=l("ZodBase64",(e,t)=>{ys.init(e,t),C.init(e,t)}),Dc=l("ZodBase64URL",(e,t)=>{bs.init(e,t),C.init(e,t)}),jc=l("ZodE164",(e,t)=>{ws.init(e,t),C.init(e,t)}),Uc=l("ZodJWT",(e,t)=>{Ss.init(e,t),C.init(e,t)}),kr=l("ZodNumber",(e,t)=>{Kt.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,i)=>ja(e,n,o,i),de(e,"ZodNumber",{gt(n,o){return this.check(lr(n,o))},gte(n,o){return this.check(Ve(n,o))},min(n,o){return this.check(Ve(n,o))},lt(n,o){return this.check(dr(n,o))},lte(n,o){return this.check(Je(n,o))},max(n,o){return this.check(Je(n,o))},int(n){return this.check(Sr(n))},safe(n){return this.check(Sr(n))},positive(n){return this.check(lr(0,n))},nonnegative(n){return this.check(Ve(0,n))},negative(n){return this.check(dr(0,n))},nonpositive(n){return this.check(Je(0,n))},multipleOf(n,o){return this.check(fr(n,o))},step(n,o){return this.check(fr(n,o))},finite(){return this}});const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function le(e){return _a(kr,e)}var Mc=l("ZodNumberFormat",(e,t)=>{Es.init(e,t),kr.init(e,t)});function Sr(e){return ya(Mc,e)}var Fc=l("ZodUnknown",(e,t)=>{Cs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ma(e,r,n,o)});function Be(){return va(Fc)}var qc=l("ZodNever",(e,t)=>{zs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ua(e,r,n,o)});function Gc(e){return ba(qc,e)}var Jc=l("ZodArray",(e,t)=>{Ts.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ja(e,r,n,o),e.element=t.element,de(e,"ZodArray",{min(r,n){return this.check(Se(r,n))},nonempty(r){return this.check(Se(1,r))},max(r,n){return this.check(pr(r,n))},length(r,n){return this.check(gr(r,n))},unwrap(){return this.element}})});function Er(e,t){return Na(Jc,e,t)}var Vc=l("ZodObject",(e,t)=>{Is.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Va(e,r,n,o),S(e,"shape",()=>t.shape),de(e,"ZodObject",{keyof(){return He(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Be()})},loose(){return this.clone({...this._zod.def,catchall:Be()})},strict(){return this.clone({...this._zod.def,catchall:Gc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Ho(this,r)},safeExtend(r){return Ko(this,r)},merge(r){return Yo(this,r)},pick(r){return Bo(this,r)},omit(r){return Wo(this,r)},partial(...r){return Qo(Cr,this,r[0])},required(...r){return Xo($r,this,r[0])}})});function J(e,t){return new Vc({type:"object",shape:e??{},...y(t)})}var Bc=l("ZodUnion",(e,t)=>{As.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ba(e,r,n,o),e.options=t.options});function Wc(e,t){return new Bc({type:"union",options:e,...y(t)})}var Hc=l("ZodIntersection",(e,t)=>{Ps.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wa(e,r,n,o)});function Kc(e,t){return new Hc({type:"intersection",left:e,right:t})}var We=l("ZodEnum",(e,t)=>{Ns.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Fa(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const s of n)if(r.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new We({...t,checks:[],...y(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const s of n)if(r.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new We({...t,checks:[],...y(o),entries:i})}});function He(e,t){return new We({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e,...y(t)})}var Yc=l("ZodTransform",(e,t)=>{Os.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ga(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Nt(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(ce(i,r.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ce(s))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function Qc(e){return new Yc({type:"transform",transform:e})}var Cr=l("ZodOptional",(e,t)=>{nr.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function zr(e){return new Cr({type:"optional",innerType:e})}var Xc=l("ZodExactOptional",(e,t)=>{Zs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function eu(e){return new Xc({type:"optional",innerType:e})}var tu=l("ZodNullable",(e,t)=>{Rs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ha(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Tr(e){return new tu({type:"nullable",innerType:e})}var ru=l("ZodDefault",(e,t)=>{xs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ya(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function nu(e,t){return new ru({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Lt(t)}})}var ou=l("ZodPrefault",(e,t)=>{Ls.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function iu(e,t){return new ou({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Lt(t)}})}var $r=l("ZodNonOptional",(e,t)=>{Ds.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ka(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function su(e,t){return new $r({type:"nonoptional",innerType:e,...y(t)})}var au=l("ZodCatch",(e,t)=>{js.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function cu(e,t){return new au({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var uu=l("ZodPipe",(e,t)=>{Us.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ec(e,r,n,o),e.in=t.in,e.out=t.out});function Ir(e,t){return new uu({type:"pipe",in:e,out:t})}var du=l("ZodReadonly",(e,t)=>{Ms.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function lu(e){return new du({type:"readonly",innerType:e})}var fu=l("ZodCustom",(e,t)=>{Fs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o)});function pu(e,t={}){return Oa(fu,e,t)}function gu(e,t){return Za(e,t)}var mu=J({sku:O(),name:O(),imageUrl:O().url().optional(),price:O().optional(),originalPrice:O().optional(),discountPercent:le().optional(),url:O().url(),brand:O().optional(),rating:le().min(0).max(5).optional(),reviewCount:le().int().nonnegative().optional()}),hu=J({layout:He(["grid","carousel"]).optional(),columns:le().int().positive().optional()}),_u=J({product:mu,index:le().int().nonnegative(),discountType:He(["strike-through","badge"]).optional()}),yu=J({sku:O(),label:O().optional(),cartCode:O()}),vu=J({actions:Er(J({label:O(),action:J({title:O(),type:O(),payload:Be().optional()})}))}),bu=J({message:O().optional()}),wu={components:{ProductGrid:{schema:hu,description:"Outer grid or carousel container for similar products."},ProductCard:{schema:_u,description:"A single product card with image, title, price, and actions."},AddToCartButton:{schema:yu,description:"Add-to-cart CTA rendered inside or below a product card."},QuickActions:{schema:vu,description:"A row of quick-action buttons below product info."},EmptyState:{schema:bu,description:"Empty state shown when no similar products are available."}}};V.GengageSimRel=At,V.createDefaultSimRelUISpecRegistry=Tt,V.createSimRelWidget=Uo,V.defaultSimRelUnknownUISpecRenderer=Re,V.renderSimRelUISpec=$t,V.simRelCatalog=wu})(this.Gengage=this.Gengage||{});
|