@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/qna.iife.js
CHANGED
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`,document.head.appendChild(e)}var X=null;function Hn(){if(X!==null)return X;try{X=localStorage.getItem("gengage:debug")==="1"}catch{X=!1}return X}function $e(e,t,n){if(!Hn())return;const r=[`[gengage:${e}]`,t];n!==void 0&&r.push(n),console.debug(...r)}var Jn=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=Cn(e.theme);this.config={...e,theme:t,session:Pn(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),jn();const n=He("gengage:context:update",r=>this.update(r));this._cleanups.push(n),$e("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(r){throw this.destroy(),r}this._destroying||(this.isInitialised=!0,$e("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 n=e==="start"?zn:Sn;this.track(n(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(wn(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(n=>n(...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 n=document.querySelector(e);if(!n)throw new Error(`[gengage] Mount target not found: "${e}"`);return n}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,n]of Object.entries(e))if(n!==void 0){const r=t.startsWith("--")?t:`--gengage-${Qn(t)}`;this.root.style.setProperty(r,n)}}}};function Qn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ke(e){const t=e?.trim();return t||"tr"}var Wn=8e3,Vn=5e3,Gn="https://www.google.com/favicon.ico",x=new Map,Ye=!1,W=null,ee=null,M=!1;function Kn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")}function Xe(e){return Kn(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 et(){let e;for(const t of x.values())e=t;return e}function Ae(){W&&(clearTimeout(W),W=null)}function Yn(){ee&&(clearInterval(ee),ee=null)}async function tt(){try{if(typeof navigator<"u"&&navigator.onLine===!1)return!1;if(typeof window<"u"){const n=window.location.hostname;if(n==="localhost"||n==="127.0.0.1")return navigator.onLine}const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);try{return await fetch(Gn,{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 ae(){M=!1,Yn(),Ge()}function ce(){W||M||x.size===0||(W=setTimeout(async()=>{W=null,!(M||x.size===0)&&!await tt()&&x.size>0&&(M=!0,Te({source:"sdk",message:Xe(et()),sticky:!0}),ee||(ee=setInterval(async()=>{if(x.size===0){ae();return}await tt()&&(ae(),ce())},Vn)))},Wn))}function Xn(){Ye||typeof window>"u"||(Ye=!0,window.addEventListener("online",()=>{ae(),ce()}),window.addEventListener("offline",()=>{x.size===0||M||(M=!0,Ae(),Te({source:"sdk",message:Xe(et()),sticky:!0}))}))}function er(e){Xn();const t=Symbol(e.source);x.set(t,e.locale),ce();let n=!1;return()=>{if(!n){if(n=!0,x.delete(t),x.size===0){Ae(),ae();return}M||(Ae(),ce())}}}function nt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function tr(e){const t=[];let n=0,r=!1,o=!1,i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o){o=!1;continue}if(a==="\\"&&r){o=!0;continue}if(a==='"'){r=!r;continue}r||(a==="{"&&n++,a==="}"&&(n--,n===0&&(t.push(e.slice(i,s+1)),i=s+1)))}return t.length>0?t:[e]}function rt(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const r=n.startsWith("data: ")?n.slice(6):n;if(r==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(r);return nt(o)?($e("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=tr(r);if(o.length>1){for(const i of o)try{const s=JSON.parse(i);if(!nt(s))continue;if(t.onEvent(s),s.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function nr(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const n=e.body.getReader(),r=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,s=Symbol("idle-timeout");let a=!1;try{for(;;){const c=n.read();let u;const d=await(i>0?Promise.race([c.then(g=>(clearTimeout(u),g)),new Promise(g=>{u=setTimeout(()=>g(s),i)})]):c);if(d===s){a=!0,await n.cancel();break}const{done:h,value:f}=d;if(h)break;o+=r.decode(f,{stream:!0});const p=o.split(`
|
|
48
|
-
`);o=p.pop()??"";for(const g of p)if(rt(g,t))return}if(o.trim()&&rt(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||n.releaseLock()}t.onDone?.()}var rr={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function or(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 ir(e,t){return`${or(t?.middlewareUrl)}/chat${rr[e]}`}var ot=3,sr=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},Ie=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>sr(n,t)).filter(Boolean):[];function ar(e){const t=(e.display_keywords??[]).flatMap(o=>Ie(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,ot);const r=[...Ie(e.chosen_attribute,{stripLeadingStopWords:!0}),...Ie(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,ot)}function cr(e){return ar(e).join(" • ")}var ur=["beauty_consulting","watch_expert"];function lr(e){return typeof e=="string"&&ur.includes(e)}function dr(e){if(typeof e.type!="string")return null;if(pr(e))return e;const t=e;switch(t.type){case"outputText":return fr(t);case"suggestedActions":return hr(t);case"productList":return gr(t);case"productDetails":return mr(t);case"productDetailsSimilars":return _r(t);case"comparisonTable":return yr(t);case"context":return kr(t);case"chatStreamEnd":return zr();case"loading":return Sr(t);case"panelLoading":return Er(t);case"similarLoading":return Tr(t);case"redirect":return $r(t);case"error":return Ar(t);case"dummy":return Ir(t);case"launcherAction":return Pr(t);case"text":return Pe(t);case"productItem":return Cr(t);case"text_image":return it(t);case"quick_qna":return st(t);case"reviewHighlights":return Or(t);case"aiProductSuggestions":return Lr(t);case"aiProductGroupings":return Nr(t);case"aiSuggestedSearches":return xr(t);case"prosAndCons":return Zr(t);case"getGroundingReview":return qr(t);case"voice":return Dr(t);case"visitorDataResponse":return Rr(t);case"productListPreview":return jr();case"groupList":return Ur(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Br(t);case"launcherContent":return Fr(t);case"handoff":return Mr(t);case"uiSpec":return Yr(t);default:return null}}function pr(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=O(e.spec);return r?typeof r.root=="string"&&O(r.elements)!==null:!1}case"action":{const n=O(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function fr(e){const t=y(e.payload.text,e.payload.plain_text)??"",n=y(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(r.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)&&(r.skuToProductItem=i);const s=e.payload.conversation_mode;typeof s=="string"&&s&&(r.conversationMode=s);const a=e.payload.render_hint;return typeof a=="string"&&a&&(r.renderHint=a),e.payload.kvkk===!0&&(r.kvkk=!0),r}function hr(e){return at((e.payload.actions??[]).map(t=>{const n=y(t.title)??"",r=L(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ne),"chat")}function gr(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(s=>{const a=y(s.style_label);if(!a)return null;const c=y(s.style_mood),u=y(s.image_url??void 0),d=(Array.isArray(s.product_list)?s.product_list:[]).map(f=>{const p=O(f);return p?Ce(O(p.product_detail)??O(p.product)??p):null}).filter(ne),h=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(f=>({label:y(f.label)??"",reason:y(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(p=>typeof p=="string"&&p.trim().length>0):[]})):[];return{style_label:a,style_mood:c??"",...u?{image_url:u}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:d,recommendation_groups:h}}).filter(ne),n=e.payload.product_list??[],r=lr(e.payload.source)&&t.length>0?t[0].product_list:null,o=r?Hr(r,"chat"):ct(n,"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 mr(e){const t=e.payload.productDetails;if(!t)return Qr("chat");const n=V(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...n}}}}},panelHint:"panel"}}function _r(e){const t=ct(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function yr(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const v of t){const S=V(v);s.push(S)}const a=vr(o,s,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?s.find(v=>v.sku===c)??s[0]:s[0],d=[];if(Array.isArray(r?.key_differences))for(const v of r.key_differences)typeof v=="string"&&d.push(v);const h=Gr(r?.special_considerations),f=r?.recommended_choice,p=r?.winner_hits,g={};for(const v of s){const S=v.sku;S&&(g[S]={title:v.name??S,type:"launchSingleProduct",payload:{sku:S}})}const m={products:s,attributes:a,highlights:d,productActions:g};return u&&(m.recommended=u),h.length>0&&(m.specialCases=h),f&&(m.recommendedText=f),p&&(m.winnerHits=p),typeof r?.key_differences=="string"&&(m.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(m.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function vr(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const h=n.criteria_view??n.criteria_view_short??{},f=n.compared_field_names??Object.keys(e),p=[];for(const g of f){const m=e[g];if(!m||!Array.isArray(m))continue;const v=h[g]??g;p.push({label:v,values:m.map(S=>typeof S=="string"?S:String(S??""))})}return p}const s=e,a=t.map(h=>String(h.sku??"")).filter(h=>h.length>0),c=n.criteria_view??n.criteria_view_short??{},u=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:br(s)).filter(h=>h!=="name"&&h!=="name_short"&&!h.endsWith("_short")),d=[];for(const h of u){const f=a.map(g=>{const m=s[g];if(!m||typeof m!="object")return"";const v=m[`${h}_short`],S=m[h];return wr(v??S)});if(f.every(g=>g.length===0))continue;const p=c[h]??h;d.push({label:p,values:f})}return d}function br(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function wr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function kr(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function zr(){return{type:"done"}}function Sr(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 Er(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Tr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function $r(e){const t=y(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:y(e.payload.to)}}}function Ar(e){return{type:"error",code:"BACKEND_ERROR",message:y(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Ir(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Pr(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),st({type:"quick_qna",payload:o})}const n=O(t.action);if(n){const o={action:n},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),it({type:"text_image",payload:o})}const r=typeof t.text=="string"?t.text:"";if(r){const o={text:r},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,a=O(t.payload)??void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.payload=a),s!==void 0&&(o.theme=s),Pe({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Pe(e){const t={text:y(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 Cr(e){return Jr(e.payload,"qna")}function it(e){const t=y(e.payload.text)??"",n=L(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),Pe({type:"text",payload:r})}function st(e){return at((e.payload.action_list??[]).map(t=>{const n=y(t.title)??"",r=L(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ne),"qna")}function Or(e){const t={reviews:(e.payload.reviews??[]).map(n=>{const r={};return typeof n.review_class=="string"&&(r.review_class=n.review_class),typeof n.review_text=="string"&&(r.review_text=n.review_text),(typeof n.review_rating=="string"||typeof n.review_rating=="number")&&(r.review_rating=n.review_rating),typeof n.review_tag=="string"&&(r.review_tag=n.review_tag),r})};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 Zr(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 Rr(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Lr(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=Wr(o);if(!i)continue;const s={product:i},a=L(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),n.push(s)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function Nr(e){const t=e.payload.product_groupings??[],n=[],r=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const s=y(i.name)??"",a=y(i.sku,i.repr_sku),c=y(i.image,i.repr_image),u=a!==void 0?{type:"findSimilar",payload:{sku:a}}:void 0,d=L(i.requestDetails??u,s),h=(Array.isArray(i.group_products)?i.group_products:[]).map(g=>{const m=O(g);return m?Ce(m):null}).filter(ne),f=c??y(...h.map(g=>g.imageUrl));if(s&&h.length>0){const g={groupName:s,products:h};f&&(g.image=f),n.push(g)}if(!d)continue;const p={name:s,action:d};if(Array.isArray(i.labels)){const g=i.labels.filter(m=>typeof m=="string");g.length>0&&(p.labels=g)}c!==void 0&&(p.image=c),r.push(p)}return n.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n}}}},panelHint:"panel"}:r.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:r}}}}}}function xr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=y(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,s={},a=y(o.detailed_user_message);a&&(s.text=a);const c=O(O(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(S=>typeof S=="string"));const d=y(o.sku,o.representative_product_sku,c?.sku);d&&(s.sku=d),s.is_suggested_text=1;const h={type:"inputText",payload:s},f=L(o.requestDetails,i),p=f?.type==="findSimilar"&&typeof s.text=="string"?L(h,i):f??L(h,i);if(!p)continue;const g={shortName:i,action:p},m=y(o.detailed_user_message);m&&m!==i&&(g.detailedMessage=m);const v=cr(o);v&&v!==i&&v!==(m??"")&&(g.whyDifferent=v),typeof o.image=="string"&&(g.image=o.image),n.push(g)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function qr(e){const t=e.payload,n=L(t.requestDetails??t.request_details,y(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!n)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const r={action:n};return t.title&&(r.title=t.title),t.text&&(r.text=t.text),t.review_count?r.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(r.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:r}}}}}function jr(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Dr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Ur(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",s=(o.product_list??[]).map(V);n.push({groupName:i,products:s})}const r=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const s=L(o.requestDetails,i),a={title:i};s&&(a.action=s),r.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function Br(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Mr(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 Fr(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function at(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;r.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),n[s]={type:"ActionButton",props:a}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function ct(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=V(i),a=`product-${o}`;r.push(a);const c={product:s,index:o};s.sku&&(c.action={title:s.name,type:"launchSingleProduct",payload:{sku:s.sku}}),n[a]={type:"ProductCard",props:c}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Hr(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;r.push(s);const a={product:i,index:o},c=i.sku;c&&(a.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),n[s]={type:"ProductCard",props:a}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Jr(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:V(e),index:0}}}}}}function Qr(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Wr(e){const t=y(e.sku),n=y(e.short_name),r={...O(e.product_item)??e},o=y(e.discount_reason,e.discountReason);return o&&!y(r.discount_reason,r.discountReason)&&(r.discount_reason=o),Ce(r,t,n)}function Ce(e,t,n){const r=y(e.sku,t),o=y(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},s=y(e.brand);s&&(i.brand=s);const a=y(e.url);a&&(i.url=a);const c=Vr(e.images);if(c.length>0)i.images=c;else{const m=y(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const u=te(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=te(e.price);d!==void 0&&(i.price=d);const h=te(e.rating);h!==void 0&&(i.rating=h);const f=te(e.review_count)??te(e.reviewCount);f!==void 0&&(i.review_count=f);const p=y(e.cart_code,e.cartCode);p&&(i.cart_code=p),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const g=y(e.discount_reason,e.discountReason);return g&&(i.discount_reason=g),V(i)}function L(e,t){const n=O(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function O(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function y(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function Vr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Gr(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 te(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function ne(e){return e!=null}var Kr=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 V(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0?o=Math.round((r-n)/r*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=y(e.brand),s=y(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:y(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&n>0&&(c.price=String(n)),r!=null&&r>0&&(c.originalPrice=String(r)),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 d=e,h={};let f=!1;for(const p of Object.keys(d))Kr.has(p)||(h[p]=d[p],f=!0);return f&&(c.extras=h),c}function Yr(e){const t=e.payload.type,{type:n,...r}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:r}}}}}async function Xr(e,t,n){const r=ir("launcher_action",t),o={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const s=await fetch(r,i);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);const a={onEvent:c=>{const u=dr(c);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const d of Object.values(u.spec.elements))if(d.type==="ActionButton"&&d.props?.action){const h=d.props.action;o.actions.push(h)}}}};return n!==void 0&&(a.signal=n),await nr(s,a),o}function ut(e){const t=document.createElement("div");t.className="gengage-qna-buttons gds-toolbar",t.dataset.gengagePart="qna-button-row",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const r=document.createElement("button");r.className="gengage-qna-button gds-chip",r.dataset.gengagePart="qna-quick-question",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const o={title:n.title,type:n.type};n.payload!==void 0&&(o.payload=n.payload),e.onAction(o)}),t.appendChild(r)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta gds-btn gds-btn-secondary",n.dataset.gengagePart="qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function eo(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper",t.dataset.gengagePart="qna-input-wrapper";const n=document.createElement("div");n.className="gengage-qna-input-combo",n.dataset.gengagePart="qna-input-combo";const r=document.createElement("input");r.type="text",r.className="gengage-qna-input",r.dataset.gengagePart="qna-input",r.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let i=0,s=o[0]??"";r.placeholder=s;let a=null,c=null,u=!1;const d=()=>{a&&clearInterval(a),a=null,c&&clearTimeout(c),c=null,r.classList.remove("gengage-qna-input--fade")},h=()=>o.length>1&&!u&&r.value.trim().length===0,f=()=>{d(),h()&&(a=setInterval(()=>{h()&&(r.classList.add("gengage-qna-input--fade"),c=setTimeout(()=>{i=(i+1)%o.length,s=o[i]??"",r.placeholder=s,r.classList.remove("gengage-qna-input--fade")},180))},3e3))},p=document.createElement("div");p.className="gengage-qna-input-actions",p.dataset.gengagePart="qna-input-actions";const g=document.createElement("button");g.className="gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden",g.type="button",g.dataset.gengagePart="qna-clear",g.setAttribute("aria-label","Clear question"),g.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';const m=document.createElement("button");m.className="gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden",m.type="button",m.dataset.gengagePart="qna-send",m.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question"),m.disabled=!0,m.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel??e.sendButtonText??"Ask"}</span>`;const v=()=>{const A=r.value.trim().length>0;g.classList.toggle("gengage-qna-icon-btn--hidden",!A),m.classList.toggle("gengage-qna-icon-btn--hidden",!A),m.classList.toggle("gengage-qna-send--active",A),m.disabled=!A},S=()=>{const A=r.value.trim();A&&(e.onSubmit({title:A,type:"user_message",payload:A}),r.value="",v(),f())};return g.addEventListener("click",()=>{r.value="",v(),r.focus({preventScroll:!0})}),m.addEventListener("click",S),r.addEventListener("focus",()=>{u=!0,d(),r.placeholder=""}),r.addEventListener("blur",()=>{u=!1,r.value.trim().length===0&&(r.placeholder=s),f()}),r.addEventListener("input",()=>{if(v(),r.value.trim().length>0){d();return}r.placeholder=u?"":s,f()}),r.addEventListener("keydown",A=>{A.key==="Enter"&&(A.preventDefault(),S()),A.key==="Escape"&&r.value.length>0&&(r.value="",v(),f())}),p.appendChild(g),p.appendChild(m),n.appendChild(r),n.appendChild(p),t.appendChild(n),v(),f(),t._cleanup=()=>{d()},t}function ue(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.type;if(typeof r!="string"||r.length===0)return null;const o=n.title,i=n.payload,s=typeof o=="string"&&o.length>0?o:t;if(!s)return null;const a={title:s,type:r};return i!==void 0&&(a.payload=i),a}function lt(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function dt(e,t){const n=[],r=e.props?.actions;if(Array.isArray(r))for(const s of r){const a=ue(s);a&&n.push(a)}const o=e.props?.buttons;if(Array.isArray(o))for(const s of o){if(!s||typeof s!="object")continue;const a=s,c=typeof a.label=="string"?a.label:void 0,u=ue(a.action,c);u&&n.push(u)}if(e.children)for(const s of e.children){const a=t.elements[s];if(!a||a.type!=="ActionButton")continue;const c=typeof a.props?.label=="string"?a.props.label:void 0,u=ue(a.props?.action,c);u&&n.push(u)}const i=new Set;return n.filter(s=>i.has(s.title)?!1:(i.add(s.title),!0))}var pt={ButtonRow:({element:e,spec:t,context:n})=>{const r=dt(e,t).map(lt),o=e.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(o==="horizontal"||o==="vertical")&&(i.orientation=o),ut(i)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:dt(e,t).map(lt),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(r.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(r.ctaText=n.ctaText),ut(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button gds-chip",n.type="button",n.dataset.gengagePart="qna-action-button";const r=e.props?.label;typeof r=="string"?n.textContent=r:n.textContent=t.i18n.defaultCtaText;const o=ue(e.props?.action,typeof r=="string"?r:void 0);return o&&n.addEventListener("click",()=>t.onAction(o)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,o=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,i={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),o!==void 0&&(i.ctaLabel=o),eo(i)},QuestionHeading:({element:e,context:t})=>{const n=document.createElement("h3");n.className="gengage-qna-heading",n.dataset.gengagePart="qna-heading";const r=e.props?.text,o=t.headingTitleOverride;return n.textContent=typeof o=="string"&&o.trim().length>0?o:typeof r=="string"?r:"",n},ProductCard:()=>null},Oe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function ft(){return{...pt}}function ht(e,t,n=pt,r=Oe){return mn({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}function to(e){if(!e)return;const t=e.extra;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.visible_skus??t.visibleSkus;if(Array.isArray(r)){const o=r.filter(i=>typeof i=="string"&&i.trim().length>0).map(i=>i.trim()).slice(0,200);if(o.length>0)return o}}const n=typeof e.sku=="string"&&e.sku.trim()?e.sku.trim():void 0;return n?[n]:void 0}function gt(e,t){if(!e)return null;const n=e.action;if(!n||typeof n!="object")return null;const r=n,o=r.type;if(typeof o!="string"||o.length===0)return null;const i=r.title,s=typeof i=="string"&&i.length>0?i:typeof t=="string"&&t.length>0?t:"";if(!s)return null;const a=r.payload,c={title:s,type:o};return a!==void 0&&(c.payload=a),c}function no(e,t){const n=e.elements[e.root];if(!n)return!1;const r=o=>{if(o.type!=="ActionButton")return!1;const i=o.props;if(!i||typeof i!="object")return!1;const s=typeof i.label=="string"?i.label:void 0;return s===t?!0:gt(i,s)?.title===t};if(n.type==="ActionButton")return r(n);if(n.children)for(const o of n.children){const i=e.elements[o];if(i&&r(i))return!0}if(n.type==="ActionButtons"&&Array.isArray(n.props?.buttons)){for(const o of n.props.buttons)if(o?.label===t||o?.action?.title===t)return!0}return!1}var mt=0;function _t(){return mt+=1,`gengage-merge-${mt}`}function ro(e,t){const n=e.elements[e.root];if(!n||n.type!=="ButtonRow")return;const r=_t();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r]}function oo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ActionButtons")return;const r=_t();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r];const o=n.props?.buttons??[],i={label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}};n.props={...n.props,buttons:[i,...o]}}function io(e){const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,...o.payload!==void 0?{payload:o.payload}:{}}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}function so(e){return e.find(t=>{const n=t.elements[t.root];return n?.type==="ActionButtons"||n?.type==="ButtonRow"})}function yt(e,t){const n=e.productContextQuickPillLabel,r={text:n};return t&&t.length>0&&(r.sku_list=t),{title:n,type:"user_message",payload:r}}function ao(e,t,n){const r=n?.skuList,o=[],i=[];for(const c of e){const u=c.elements[c.root];if(u?.type==="ActionButton"){const d=u.props;if(gt(d,typeof d?.label=="string"?d.label:void 0)?.type==="findSimilar"){o.push(yt(t,r));continue}}i.push(c)}if(o.length===0)return e;const s=yt(t,r),a=so(i);if(!a)return[...i,io([s])];if(!no(a,s.title)){const c=a.elements[a.root];c?.type==="ActionButtons"?oo(a,s):c?.type==="ButtonRow"&&ro(a,s)}return i}var vt={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor",redirectingToChat:"Sohbete yönlendiriliyor...",productContextQuickPillLabel:"Bu ürün hakkında ne bilmeliyim?"},co={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else",redirectingToChat:"Redirecting to chat...",productContextQuickPillLabel:"What should I know about this product?"};function uo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function lo(e){return uo(e)==="en"?co:vt}var bt;function l(e,t,n){function r(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,d=Object.keys(u);for(let h=0;h<d.length;h++){const f=d[h];f in a||(a[f]=u[f].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var G=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},wt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(bt=globalThis).__zod_globalConfig??(bt.__zod_globalConfig={});var le=globalThis.__zod_globalConfig;function F(e){return e&&Object.assign(le,e),le}function kt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function Ze(e,t){return typeof t=="bigint"?t.toString():t}function Re(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Le(e){return e==null}function Ne(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var zt=Symbol("evaluating");function w(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==zt)return r===void 0&&(r=zt,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function H(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function j(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function St(e){return JSON.stringify(e)}function po(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var fo=Re(()=>{if(le.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function re(e){if(de(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(de(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Tt(e){return re(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ho=new Set(["string","number","symbol"]);function pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function _(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 go(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Bc={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 mo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return D(e,j(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return H(this,"shape",o),o},checks:[]}))}function _o(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return D(e,j(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return H(this,"shape",o),o},checks:[]}))}function yo(e,t){if(!re(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return D(e,j(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return H(this,"shape",r),r}}))}function vo(e,t){if(!re(t))throw new Error("Invalid input to safeExtend: expected a plain object");return D(e,j(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return H(this,"shape",n),n}}))}function bo(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return D(e,j(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return H(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function wo(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return D(t,j(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[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 H(this,"shape",i),i},checks:[]}))}function ko(e,t,n){return D(t,j(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)o[i]=new e({type:"nonoptional",innerType:r[i]});return H(this,"shape",o),o}}))}function K(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function zo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function $t(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function fe(e){return typeof e=="string"?e:e?.message}function J(e,t,n){const r=e.message?e.message:fe(e.inst?._zod.def?.error?.(e))??fe(t?.error?.(e))??fe(n.customError?.(e))??fe(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function xe(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function oe(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}var At=(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,Ze,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},It=l("$ZodError",At),Pt=l("$ZodError",At,{Parent:Error});function So(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Eo(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<a.length;){const d=a[u];u!==a.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(s))),c=c[d],u++}}}};return r(e),n}var qe=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new G;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>J(c,i,F())));throw Et(a,o?.callee),a}return s.value},je=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>J(c,i,F())));throw Et(a,o?.callee),a}return s.value},he=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new G;return i.issues.length?{success:!1,error:new(e??It)(i.issues.map(s=>J(s,o,F())))}:{success:!0,data:i.value}},To=he(Pt),ge=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>J(s,o,F())))}:{success:!0,data:i.value}},$o=ge(Pt),Ao=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return qe(e)(t,n,o)},Io=e=>(t,n,r)=>qe(e)(t,n,r),Po=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return je(e)(t,n,o)},Co=e=>async(t,n,r)=>je(e)(t,n,r),Oo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return he(e)(t,n,o)},Zo=e=>(t,n,r)=>he(e)(t,n,r),Ro=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ge(e)(t,n,o)},Lo=e=>async(t,n,r)=>ge(e)(t,n,r),No=/^[cC][0-9a-z]{6,}$/,xo=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jo=/^[0-9a-vA-V]{20}$/,Do=/^[A-Za-z0-9]{27}$/,Uo=/^[a-zA-Z0-9_-]{21}$/,Bo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mo=/^([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})$/,Ct=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)$/,Fo=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ho="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Jo(){return new RegExp(Ho,"u")}var Qo=/^(?:(?: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])$/,Wo=/^(([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}|:))$/,Vo=/^((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])$/,Go=/^(([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])$/,Ko=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ot=/^[A-Za-z0-9_-]*$/,Yo=/^https?$/,Xo=/^\+[1-9]\d{6,14}$/,Zt="(?:(?:\\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])))",ei=new RegExp(`^${Zt}$`);function Rt(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 ti(e){return new RegExp(`^${Rt(e)}$`)}function ni(e){const t=Rt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Zt}T(?:${r})$`)}var ri=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},oi=/^(?:true|false)$/i,ii=/^[^A-Z]*$/,si=/^[^a-z]*$/,N=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ai=l("$ZodCheckMaxLength",(e,t)=>{var n;N.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=xe(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ci=l("$ZodCheckMinLength",(e,t)=>{var n;N.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=xe(o);r.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 n;N.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=xe(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),me=l("$ZodCheckStringFormat",(e,t)=>{var n,r;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?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),li=l("$ZodCheckRegex",(e,t)=>{me.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),di=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ii),me.init(e,t)}),pi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=si),me.init(e,t)}),fi=l("$ZodCheckIncludes",(e,t)=>{N.init(e,t);const n=pe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),hi=l("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);const n=new RegExp(`^${pe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),gi=l("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);const n=new RegExp(`.*${pe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),mi=l("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),_i=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=p.pop()??"";for(const g of p)if(rt(g,t))return}if(o.trim()&&rt(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||n.releaseLock()}t.onDone?.()}var rr={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function or(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 ir(e,t){return`${or(t?.middlewareUrl)}/chat${rr[e]}`}var ot=3,sr=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const r=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return r?r.split(/\s+/).slice(0,3).join(" ").trim():""},Ie=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>sr(n,t)).filter(Boolean):[];function ar(e){const t=(e.display_keywords??[]).flatMap(o=>Ie(o,{stripLeadingStopWords:!0})),n=t.filter((o,i)=>t.indexOf(o)===i);if(n.length>0)return n.slice(0,ot);const r=[...Ie(e.chosen_attribute,{stripLeadingStopWords:!0}),...Ie(e.short_name)];return r.filter((o,i)=>r.indexOf(o)===i).slice(0,ot)}function cr(e){return ar(e).join(" • ")}var ur=["beauty_consulting","watch_expert"];function lr(e){return typeof e=="string"&&ur.includes(e)}function dr(e){if(typeof e.type!="string")return null;if(pr(e))return e;const t=e;switch(t.type){case"outputText":return fr(t);case"suggestedActions":return hr(t);case"productList":return gr(t);case"productDetails":return mr(t);case"productDetailsSimilars":return _r(t);case"comparisonTable":return yr(t);case"context":return kr(t);case"chatStreamEnd":return zr();case"loading":return Sr(t);case"panelLoading":return Er(t);case"similarLoading":return Tr(t);case"redirect":return $r(t);case"error":return Ar(t);case"dummy":return Ir(t);case"launcherAction":return Pr(t);case"text":return Pe(t);case"productItem":return Cr(t);case"text_image":return it(t);case"quick_qna":return st(t);case"reviewHighlights":return Or(t);case"aiProductSuggestions":return Lr(t);case"aiProductGroupings":return Nr(t);case"aiSuggestedSearches":return xr(t);case"prosAndCons":return Zr(t);case"getGroundingReview":return qr(t);case"voice":return Dr(t);case"visitorDataResponse":return Rr(t);case"productListPreview":return jr();case"groupList":return Ur(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Br(t);case"launcherContent":return Fr(t);case"handoff":return Mr(t);case"uiSpec":return Yr(t);default:return null}}function pr(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=O(e.spec);return r?typeof r.root=="string"&&O(r.elements)!==null:!1}case"action":{const n=O(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function fr(e){const t=y(e.payload.text,e.payload.plain_text)??"",n=y(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(r.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)&&(r.skuToProductItem=i);const s=e.payload.conversation_mode;typeof s=="string"&&s&&(r.conversationMode=s);const a=e.payload.render_hint;return typeof a=="string"&&a&&(r.renderHint=a),e.payload.kvkk===!0&&(r.kvkk=!0),r}function hr(e){return at((e.payload.actions??[]).map(t=>{const n=y(t.title)??"",r=L(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ne),"chat")}function gr(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(s=>{const a=y(s.style_label);if(!a)return null;const c=y(s.style_mood),u=y(s.image_url??void 0),d=(Array.isArray(s.product_list)?s.product_list:[]).map(f=>{const p=O(f);return p?Ce(O(p.product_detail)??O(p.product)??p):null}).filter(ne),h=Array.isArray(s.recommendation_groups)?s.recommendation_groups.map(f=>({label:y(f.label)??"",reason:y(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(p=>typeof p=="string"&&p.trim().length>0):[]})):[];return{style_label:a,style_mood:c??"",...u?{image_url:u}:{},...typeof s.status=="string"?{status:s.status}:{},product_list:d,recommendation_groups:h}}).filter(ne),n=e.payload.product_list??[],r=lr(e.payload.source)&&t.length>0?t[0].product_list:null,o=r?Hr(r,"chat"):ct(n,"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 mr(e){const t=e.payload.productDetails;if(!t)return Qr("chat");const n=V(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...n}}}}},panelHint:"panel"}}function _r(e){const t=ct(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function yr(e){const t=e.payload.multiple_product_details??[],n=e.payload,r={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,s=[];for(const v of t){const S=V(v);s.push(S)}const a=vr(o,s,r,i);let c;r?.recommended_choice_sku?c=r.recommended_choice_sku:r?.winner_product&&r.winner_product.length>0&&(c=r.winner_product[0]?.product_detail?.sku??r.winner_product[0]?.sku);const u=c?s.find(v=>v.sku===c)??s[0]:s[0],d=[];if(Array.isArray(r?.key_differences))for(const v of r.key_differences)typeof v=="string"&&d.push(v);const h=Gr(r?.special_considerations),f=r?.recommended_choice,p=r?.winner_hits,g={};for(const v of s){const S=v.sku;S&&(g[S]={title:v.name??S,type:"launchSingleProduct",payload:{sku:S}})}const m={products:s,attributes:a,highlights:d,productActions:g};return u&&(m.recommended=u),h.length>0&&(m.specialCases=h),f&&(m.recommendedText=f),p&&(m.winnerHits=p),typeof r?.key_differences=="string"&&(m.keyDifferencesHtml=r.key_differences),r?.special_considerations&&(m.specialConsiderations=r.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function vr(e,t,n,r){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const h=n.criteria_view??n.criteria_view_short??{},f=n.compared_field_names??Object.keys(e),p=[];for(const g of f){const m=e[g];if(!m||!Array.isArray(m))continue;const v=h[g]??g;p.push({label:v,values:m.map(S=>typeof S=="string"?S:String(S??""))})}return p}const s=e,a=t.map(h=>String(h.sku??"")).filter(h=>h.length>0),c=n.criteria_view??n.criteria_view_short??{},u=(r&&r.length>0?r:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:br(s)).filter(h=>h!=="name"&&h!=="name_short"&&!h.endsWith("_short")),d=[];for(const h of u){const f=a.map(g=>{const m=s[g];if(!m||typeof m!="object")return"";const v=m[`${h}_short`],S=m[h];return wr(v??S)});if(f.every(g=>g.length===0))continue;const p=c[h]??h;d.push({label:p,values:f})}return d}function br(e){const t=[],n=new Set;for(const r of Object.values(e))if(!(!r||typeof r!="object"))for(const o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function wr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function kr(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function zr(){return{type:"done"}}function Sr(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 Er(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Tr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function $r(e){const t=y(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:y(e.payload.to)}}}function Ar(e){return{type:"error",code:"BACKEND_ERROR",message:y(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Ir(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Pr(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),st({type:"quick_qna",payload:o})}const n=O(t.action);if(n){const o={action:n},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),it({type:"text_image",payload:o})}const r=typeof t.text=="string"?t.text:"";if(r){const o={text:r},i=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,a=O(t.payload)??void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.payload=a),s!==void 0&&(o.theme=s),Pe({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Pe(e){const t={text:y(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 Cr(e){return Jr(e.payload,"qna")}function it(e){const t=y(e.payload.text)??"",n=L(e.payload.action,t);if(n){const o={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const r={text:t};return typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),Pe({type:"text",payload:r})}function st(e){return at((e.payload.action_list??[]).map(t=>{const n=y(t.title)??"",r=L(t.requestDetails,n),o=r?{label:n,action:r}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(ne),"qna")}function Or(e){const t={reviews:(e.payload.reviews??[]).map(n=>{const r={};return typeof n.review_class=="string"&&(r.review_class=n.review_class),typeof n.review_text=="string"&&(r.review_text=n.review_text),(typeof n.review_rating=="string"||typeof n.review_rating=="number")&&(r.review_rating=n.review_rating),typeof n.review_tag=="string"&&(r.review_tag=n.review_tag),r})};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 Zr(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 Rr(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Lr(e){const t=e.payload.product_suggestions??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=Wr(o);if(!i)continue;const s={product:i},a=L(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),n.push(s)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function Nr(e){const t=e.payload.product_groupings??[],n=[],r=[];for(let o=0;o<t.length;o++){const i=t[o];if(!i)continue;const s=y(i.name)??"",a=y(i.sku,i.repr_sku),c=y(i.image,i.repr_image),u=a!==void 0?{type:"findSimilar",payload:{sku:a}}:void 0,d=L(i.requestDetails??u,s),h=(Array.isArray(i.group_products)?i.group_products:[]).map(g=>{const m=O(g);return m?Ce(m):null}).filter(ne),f=c??y(...h.map(g=>g.imageUrl));if(s&&h.length>0){const g={groupName:s,products:h};f&&(g.image=f),n.push(g)}if(!d)continue;const p={name:s,action:d};if(Array.isArray(i.labels)){const g=i.labels.filter(m=>typeof m=="string");g.length>0&&(p.labels=g)}c!==void 0&&(p.image=c),r.push(p)}return n.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n}}}},panelHint:"panel"}:r.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:r}}}}}}function xr(e){const t=e.payload.suggested_searches??[],n=[];for(let r=0;r<t.length;r++){const o=t[r];if(!o)continue;const i=y(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${r+1}`,s={},a=y(o.detailed_user_message);a&&(s.text=a);const c=O(O(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(S=>typeof S=="string"));const d=y(o.sku,o.representative_product_sku,c?.sku);d&&(s.sku=d),s.is_suggested_text=1;const h={type:"inputText",payload:s},f=L(o.requestDetails,i),p=f?.type==="findSimilar"&&typeof s.text=="string"?L(h,i):f??L(h,i);if(!p)continue;const g={shortName:i,action:p},m=y(o.detailed_user_message);m&&m!==i&&(g.detailedMessage=m);const v=cr(o);v&&v!==i&&v!==(m??"")&&(g.whyDifferent=v),typeof o.image=="string"&&(g.image=o.image),n.push(g)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function qr(e){const t=e.payload,n=L(t.requestDetails??t.request_details,y(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!n)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const r={action:n};return t.title&&(r.title=t.title),t.text&&(r.text=t.text),t.review_count?r.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(r.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:r}}}}}function jr(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Dr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function Ur(e){const t=e.payload.group_list??[],n=[];for(const o of t){const i=o.group_name??"",s=(o.product_list??[]).map(V);n.push({groupName:i,products:s})}const r=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const s=L(o.requestDetails,i),a={title:i};s&&(a.action=s),r.push(a)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function Br(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Mr(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 Fr(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function at(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`action-${o}`;r.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),n[s]={type:"ActionButton",props:a}}return n.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function ct(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=V(i),a=`product-${o}`;r.push(a);const c={product:s,index:o};s.sku&&(c.action={title:s.name,type:"launchSingleProduct",payload:{sku:s.sku}}),n[a]={type:"ProductCard",props:c}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Hr(e,t){const n={},r=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const s=`product-${o}`;r.push(s);const a={product:i,index:o},c=i.sku;c&&(a.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),n[s]={type:"ProductCard",props:a}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function Jr(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:V(e),index:0}}}}}}function Qr(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Wr(e){const t=y(e.sku),n=y(e.short_name),r={...O(e.product_item)??e},o=y(e.discount_reason,e.discountReason);return o&&!y(r.discount_reason,r.discountReason)&&(r.discount_reason=o),Ce(r,t,n)}function Ce(e,t,n){const r=y(e.sku,t),o=y(e.name,n);if(!r||!o)return null;const i={sku:r,name:o},s=y(e.brand);s&&(i.brand=s);const a=y(e.url);a&&(i.url=a);const c=Vr(e.images);if(c.length>0)i.images=c;else{const m=y(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const u=te(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=te(e.price);d!==void 0&&(i.price=d);const h=te(e.rating);h!==void 0&&(i.rating=h);const f=te(e.review_count)??te(e.reviewCount);f!==void 0&&(i.review_count=f);const p=y(e.cart_code,e.cartCode);p&&(i.cart_code=p),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const g=y(e.discount_reason,e.discountReason);return g&&(i.discount_reason=g),V(i)}function L(e,t){const n=O(e);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const o={title:t||r,type:r};return n.payload!==void 0&&(o.payload=n.payload),o}function O(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function y(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function Vr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Gr(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 te(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const n=Number(t);if(Number.isFinite(n))return n}}function ne(e){return e!=null}var Kr=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 V(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,r=t&&e.price!=null?e.price:void 0;let o;r!=null&&n!=null&&r>0?o=Math.round((r-n)/r*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=y(e.brand),s=y(e.name)??e.sku,a=i&&!s.toLowerCase().startsWith(i.toLowerCase())?`${i} ${s}`:s,c={sku:e.sku,name:a,url:y(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&n>0&&(c.price=String(n)),r!=null&&r>0&&(c.originalPrice=String(r)),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 d=e,h={};let f=!1;for(const p of Object.keys(d))Kr.has(p)||(h[p]=d[p],f=!0);return f&&(c.extras=h),c}function Yr(e){const t=e.payload.type,{type:n,...r}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:r}}}}}async function Xr(e,t,n){const r=ir("launcher_action",t),o={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(i.signal=n);const s=await fetch(r,i);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);const a={onEvent:c=>{const u=dr(c);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const d of Object.values(u.spec.elements))if(d.type==="ActionButton"&&d.props?.action){const h=d.props.action;o.actions.push(h)}}}};return n!==void 0&&(a.signal=n),await nr(s,a),o}function ut(e){const t=document.createElement("div");t.className="gengage-qna-buttons gds-toolbar",t.dataset.gengagePart="qna-button-row",t.setAttribute("role","group"),t.setAttribute("aria-label",e.quickQuestionsAriaLabel??"Quick questions"),e.orientation==="vertical"&&(t.style.flexDirection="column");for(const n of e.actions){const r=document.createElement("button");r.className="gengage-qna-button gds-chip",r.dataset.gengagePart="qna-quick-question",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const o={title:n.title,type:n.type};n.payload!==void 0&&(o.payload=n.payload),e.onAction(o)}),t.appendChild(r)}if(e.ctaText||e.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta gds-btn gds-btn-secondary",n.dataset.gengagePart="qna-cta",n.textContent=e.ctaText??e.defaultCtaText??"Ask something else",n.type="button",n.addEventListener("click",()=>{e.onOpenChat?.()}),t.appendChild(n)}return t}function eo(e){const t=document.createElement("div");t.className="gengage-qna-input-wrapper",t.dataset.gengagePart="qna-input-wrapper";const n=document.createElement("div");n.className="gengage-qna-input-combo",n.dataset.gengagePart="qna-input-combo";const r=document.createElement("input");r.type="text",r.className="gengage-qna-input",r.dataset.gengagePart="qna-input",r.setAttribute("aria-label",e.askQuestionAriaLabel??"Ask a question");const o=Array.isArray(e.placeholders)?e.placeholders:e.placeholders?[e.placeholders]:[e.defaultInputPlaceholder??"Ask a question..."];let i=0,s=o[0]??"";r.placeholder=s;let a=null,c=null,u=!1;const d=()=>{a&&clearInterval(a),a=null,c&&clearTimeout(c),c=null,r.classList.remove("gengage-qna-input--fade")},h=()=>o.length>1&&!u&&r.value.trim().length===0,f=()=>{d(),h()&&(a=setInterval(()=>{h()&&(r.classList.add("gengage-qna-input--fade"),c=setTimeout(()=>{i=(i+1)%o.length,s=o[i]??"",r.placeholder=s,r.classList.remove("gengage-qna-input--fade")},180))},3e3))},p=document.createElement("div");p.className="gengage-qna-input-actions",p.dataset.gengagePart="qna-input-actions";const g=document.createElement("button");g.className="gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden",g.type="button",g.dataset.gengagePart="qna-clear",g.setAttribute("aria-label","Clear question"),g.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';const m=document.createElement("button");m.className="gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden",m.type="button",m.dataset.gengagePart="qna-send",m.setAttribute("aria-label",e.sendQuestionAriaLabel??"Send question"),m.disabled=!0,m.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel??e.sendButtonText??"Ask"}</span>`;const v=()=>{const A=r.value.trim().length>0;g.classList.toggle("gengage-qna-icon-btn--hidden",!A),m.classList.toggle("gengage-qna-icon-btn--hidden",!A),m.classList.toggle("gengage-qna-send--active",A),m.disabled=!A},S=()=>{const A=r.value.trim();A&&(e.onSubmit({title:A,type:"user_message",payload:A}),r.value="",v(),f())};return g.addEventListener("click",()=>{r.value="",v(),r.focus({preventScroll:!0})}),m.addEventListener("click",S),r.addEventListener("focus",()=>{u=!0,d(),r.placeholder=""}),r.addEventListener("blur",()=>{u=!1,r.value.trim().length===0&&(r.placeholder=s),f()}),r.addEventListener("input",()=>{if(v(),r.value.trim().length>0){d();return}r.placeholder=u?"":s,f()}),r.addEventListener("keydown",A=>{A.key==="Enter"&&(A.preventDefault(),S()),A.key==="Escape"&&r.value.length>0&&(r.value="",v(),f())}),p.appendChild(g),p.appendChild(m),n.appendChild(r),n.appendChild(p),t.appendChild(n),v(),f(),t._cleanup=()=>{d()},t}function ue(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.type;if(typeof r!="string"||r.length===0)return null;const o=n.title,i=n.payload,s=typeof o=="string"&&o.length>0?o:t;if(!s)return null;const a={title:s,type:r};return i!==void 0&&(a.payload=i),a}function lt(e){const t={title:e.title,type:e.type};return e.payload!==void 0&&(t.payload=e.payload),t}function dt(e,t){const n=[],r=e.props?.actions;if(Array.isArray(r))for(const s of r){const a=ue(s);a&&n.push(a)}const o=e.props?.buttons;if(Array.isArray(o))for(const s of o){if(!s||typeof s!="object")continue;const a=s,c=typeof a.label=="string"?a.label:void 0,u=ue(a.action,c);u&&n.push(u)}if(e.children)for(const s of e.children){const a=t.elements[s];if(!a||a.type!=="ActionButton")continue;const c=typeof a.props?.label=="string"?a.props.label:void 0,u=ue(a.props?.action,c);u&&n.push(u)}const i=new Set;return n.filter(s=>i.has(s.title)?!1:(i.add(s.title),!0))}var pt={ButtonRow:({element:e,spec:t,context:n})=>{const r=dt(e,t).map(lt),o=e.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(o==="horizontal"||o==="vertical")&&(i.orientation=o),ut(i)},ActionButtons:({element:e,spec:t,context:n})=>{const r={actions:dt(e,t).map(lt),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(r.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(r.ctaText=n.ctaText),ut(r)},ActionButton:({element:e,context:t})=>{const n=document.createElement("button");n.className="gengage-qna-button gds-chip",n.type="button",n.dataset.gengagePart="qna-action-button";const r=e.props?.label;typeof r=="string"?n.textContent=r:n.textContent=t.i18n.defaultCtaText;const o=ue(e.props?.action,typeof r=="string"?r:void 0);return o&&n.addEventListener("click",()=>t.onAction(o)),n},TextInput:({element:e,context:t})=>{const n=e.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:t.inputPlaceholder,o=typeof e.props?.ctaLabel=="string"?e.props.ctaLabel:void 0,i={onSubmit:t.onAction,askQuestionAriaLabel:t.i18n.askQuestionAriaLabel,defaultInputPlaceholder:t.i18n.defaultInputPlaceholder,sendButtonText:t.i18n.sendButton,sendQuestionAriaLabel:t.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),o!==void 0&&(i.ctaLabel=o),eo(i)},QuestionHeading:({element:e,context:t})=>{const n=document.createElement("h3");n.className="gengage-qna-heading",n.dataset.gengagePart="qna-heading";const r=e.props?.text,o=t.headingTitleOverride;return n.textContent=typeof o=="string"&&o.trim().length>0?o:typeof r=="string"?r:"",n},ProductCard:()=>null},Oe=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const r of e.children){const o=t(r);o&&n.appendChild(o)}return n};function ft(){return{...pt}}function ht(e,t,n=pt,r=Oe){return mn({spec:e,context:t,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}function to(e){if(!e)return;const t=e.extra;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.visible_skus??t.visibleSkus;if(Array.isArray(r)){const o=r.filter(i=>typeof i=="string"&&i.trim().length>0).map(i=>i.trim()).slice(0,200);if(o.length>0)return o}}const n=typeof e.sku=="string"&&e.sku.trim()?e.sku.trim():void 0;return n?[n]:void 0}function gt(e,t){if(!e)return null;const n=e.action;if(!n||typeof n!="object")return null;const r=n,o=r.type;if(typeof o!="string"||o.length===0)return null;const i=r.title,s=typeof i=="string"&&i.length>0?i:typeof t=="string"&&t.length>0?t:"";if(!s)return null;const a=r.payload,c={title:s,type:o};return a!==void 0&&(c.payload=a),c}function no(e,t){const n=e.elements[e.root];if(!n)return!1;const r=o=>{if(o.type!=="ActionButton")return!1;const i=o.props;if(!i||typeof i!="object")return!1;const s=typeof i.label=="string"?i.label:void 0;return s===t?!0:gt(i,s)?.title===t};if(n.type==="ActionButton")return r(n);if(n.children)for(const o of n.children){const i=e.elements[o];if(i&&r(i))return!0}if(n.type==="ActionButtons"&&Array.isArray(n.props?.buttons)){for(const o of n.props.buttons)if(o?.label===t||o?.action?.title===t)return!0}return!1}var mt=0;function _t(){return mt+=1,`gengage-merge-${mt}`}function ro(e,t){const n=e.elements[e.root];if(!n||n.type!=="ButtonRow")return;const r=_t();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r]}function oo(e,t){const n=e.elements[e.root];if(!n||n.type!=="ActionButtons")return;const r=_t();e.elements[r]={type:"ActionButton",props:{label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}}},n.children=n.children?[r,...n.children]:[r];const o=n.props?.buttons??[],i={label:t.title,action:{title:t.title,type:t.type,...t.payload!==void 0?{payload:t.payload}:{}}};n.props={...n.props,buttons:[i,...o]}}function io(e){const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,...o.payload!==void 0?{payload:o.payload}:{}}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}function so(e){return e.find(t=>{const n=t.elements[t.root];return n?.type==="ActionButtons"||n?.type==="ButtonRow"})}function yt(e,t){const n=e.productContextQuickPillLabel,r={text:n};return t&&t.length>0&&(r.sku_list=t),{title:n,type:"user_message",payload:r}}function ao(e,t,n){const r=n?.skuList,o=[],i=[];for(const c of e){const u=c.elements[c.root];if(u?.type==="ActionButton"){const d=u.props;if(gt(d,typeof d?.label=="string"?d.label:void 0)?.type==="findSimilar"){o.push(yt(t,r));continue}}i.push(c)}if(o.length===0)return e;const s=yt(t,r),a=so(i);if(!a)return[...i,io([s])];if(!no(a,s.title)){const c=a.elements[a.root];c?.type==="ActionButtons"?oo(a,s):c?.type==="ButtonRow"&&ro(a,s)}return i}var vt={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor",redirectingToChat:"Sohbete yönlendiriliyor...",productContextQuickPillLabel:"Bu ürün hakkında ne bilmeliyim?"},co={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else",redirectingToChat:"Redirecting to chat...",productContextQuickPillLabel:"What should I know about this product?"};function uo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function lo(e){return uo(e)==="en"?co:vt}var bt=class extends Jn{constructor(...e){super(...e),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=vt,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this._contentEl.dataset.gengagePart="qna-container",this._contentEl.lang=Ke(e.locale),this.root.appendChild(this._contentEl);const t=e.pageContext?.sku;t&&(this._lastSku=t,await this._fetchAndRender(t)),Tn("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_resolvedQnaHeaderTitle(){const e=this.config.headerTitle??this.config.headingTitle;if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const n={middlewareUrl:this.config.middlewareUrl},r=crypto.randomUUID(),o=Date.now(),i=er({source:"qna",locale:this.config.locale});this.track(yn(this.analyticsContext(),{endpoint:"launcher_action",request_id:r,widget:"qna"}));try{const s={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e,locale:Ke(this.config.locale)},a=this.config.pageContext?.pageType;a!==void 0&&(s.page_type=a);const c=await Xr(s,n,this._abortController.signal);if(this.track(vn(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-o,chunk_count:c.actions.length,widget:"qna"})),this.track(kn(this.analyticsContext(),{message_count:c.actions.length,history_ref:r,redaction_level:"none",widget:"qna"})),!this._contentEl)return;this._contentEl.innerHTML="";const u=document.createElement("div");u.className="gengage-qna-panel gds-panel",u.dataset.gengagePart="qna-panel",this._contentEl.appendChild(u);const d=this._specIncludesType(c.uiSpecs,"QuestionHeading"),h=this._resolvedQnaHeaderTitle()??(this.config.showStaticQuestion&&this.config.staticQuestionText?this.config.staticQuestionText:void 0);if(!d&&h){const E=document.createElement("h3");E.className="gengage-qna-heading",E.textContent=h,u.appendChild(E)}const f=this.config.inputPlaceholder;let p;if(f!==!0)p=f??this._i18n.defaultInputPlaceholder;else if(c.actions.length>0){const E=c.actions.filter(b=>b.type==="user_message"||b.title.includes("?")).map(b=>b.title);p=E.length>0?E:this._i18n.defaultInputPlaceholder}else p=this._i18n.defaultInputPlaceholder;const g={onAction:this._actionHandler,i18n:this._i18n},m=this._resolvedQnaHeaderTitle();m!==void 0&&(g.headingTitleOverride=m),this.config.hideButtonRowCta||(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),p!==void 0&&(g.inputPlaceholder=p);const v=this._buildFallbackActionsSpec(c.actions),S=to(this.config.pageContext),A=(c.uiSpecs.length>0?ao(c.uiSpecs,this._i18n,{skuList:S}):[v]).filter(E=>Object.keys(E.elements).length>0);for(const E of A){const b=this._renderUISpec(E,g);u.appendChild(b)}A.length>0&&$n("qna"),this._specIncludesType(A,"TextInput")||this._insertStandaloneInputBeforePills(u,g,p)}catch(s){if(s instanceof DOMException&&s.name==="AbortError")return;if(Se("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:qn(this.config.locale,s)}),this.track(bn(this.analyticsContext(),{request_id:r,error_code:"FETCH_ERROR",error_message:s instanceof Error?s.message:String(s),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const a=document.createElement("div");a.className="gengage-qna-panel",this._contentEl.appendChild(a);const c=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,u={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler},d=this._resolvedQnaHeaderTitle();d!==void 0&&(u.headingTitleOverride=d),this.config.ctaText!==void 0&&(u.ctaText=this.config.ctaText),this._appendStandaloneInput(u,c,a)}}finally{i()}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const n=document.createElement("div");n.className="gengage-qna-loading-dot",e.appendChild(n)}return e}_resolveI18n(e){return{...lo(e.locale),...e.i18n}}_resolveUISpecRegistry(){return _n(ft(),this.config.renderer?.registry)}_renderUISpec(e,t){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??Oe,o=(s,a)=>ht(s,a,n,r),i=this.config.renderer?.renderUISpec;return i?i(e,t,{registry:n,unknownRenderer:r,defaultRender:o}):o(e,t)}_specIncludesType(e,t){for(const n of e)for(const r of Object.values(n.elements))if(r.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}_insertStandaloneInputBeforePills(e,t,n){const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},o=this._renderUISpec(r,t),i=o.querySelector(".gengage-qna-input-wrapper");if(!i)return;const s=e.querySelector(".gengage-qna-uispec"),a=s?.querySelector(":scope > .gengage-qna-buttons");if(s&&a)s.insertBefore(i,a);else if(s){const c=s.querySelector(":scope > .gengage-qna-heading");c?c.insertAdjacentElement("afterend",i):s.prepend(i)}else{e.appendChild(o);return}o.remove()}_appendStandaloneInput(e,t,n){if(!this._contentEl)return;const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(r,e);(n??this._contentEl).appendChild(o)}_handleAction(e){this._showTransitionIndicator(),An(e.title,e.type),this.config.onActionSelected?.(e),setTimeout(()=>Se("gengage:qna:action",e),350)}_handleOpenChat(){this._showTransitionIndicator(),this.config.onOpenChat?.(),setTimeout(()=>Se("gengage:qna:open-chat",{}),350)}_showTransitionIndicator(){if(!this._contentEl)return;this._contentEl.querySelector(".gengage-qna-transition-indicator")?.remove(),this._contentEl.classList.add("gengage-qna--transitioning");const e=this._i18n.redirectingToChat??"Redirecting to chat...",t=document.createElement("div");t.className="gengage-qna-transition-indicator",t.textContent=e,(this._contentEl.querySelector(".gengage-qna-panel")??this._contentEl).appendChild(t),setTimeout(()=>{this._contentEl?.classList.remove("gengage-qna--transitioning"),t.remove()},600)}};function po(){return new bt}var wt;function l(e,t,n){function r(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,d=Object.keys(u);for(let h=0;h<d.length;h++){const f=d[h];f in a||(a[f]=u[f].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const u=n?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var G=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},kt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(wt=globalThis).__zod_globalConfig??(wt.__zod_globalConfig={});var le=globalThis.__zod_globalConfig;function F(e){return e&&Object.assign(le,e),le}function zt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function Ze(e,t){return typeof t=="bigint"?t.toString():t}function Re(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function Le(e){return e==null}function Ne(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var St=Symbol("evaluating");function w(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==St)return r===void 0&&(r=St,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function H(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function j(...e){const t={};for(const n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Et(e){return JSON.stringify(e)}function fo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Tt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ho=Re(()=>{if(le.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function re(e){if(de(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(de(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function $t(e){return re(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 pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function _(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 mo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Bc={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 _o(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return D(e,j(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return H(this,"shape",o),o},checks:[]}))}function yo(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return D(e,j(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return H(this,"shape",o),o},checks:[]}))}function vo(e,t){if(!re(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return D(e,j(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return H(this,"shape",r),r}}))}function bo(e,t){if(!re(t))throw new Error("Invalid input to safeExtend: expected a plain object");return D(e,j(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return H(this,"shape",n),n}}))}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 D(e,j(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return H(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ko(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return D(t,j(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[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 H(this,"shape",i),i},checks:[]}))}function zo(e,t,n){return D(t,j(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)o[i]=new e({type:"nonoptional",innerType:r[i]});return H(this,"shape",o),o}}))}function K(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function So(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function At(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function fe(e){return typeof e=="string"?e:e?.message}function J(e,t,n){const r=e.message?e.message:fe(e.inst?._zod.def?.error?.(e))??fe(t?.error?.(e))??fe(n.customError?.(e))??fe(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function xe(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function oe(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}var It=(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,Ze,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pt=l("$ZodError",It),Ct=l("$ZodError",It,{Parent:Error});function Eo(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function To(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<a.length;){const d=a[u];u!==a.length-1?c[d]=c[d]||{_errors:[]}:(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(s))),c=c[d],u++}}}};return r(e),n}var qe=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new G;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>J(c,i,F())));throw Tt(a,o?.callee),a}return s.value},je=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(c=>J(c,i,F())));throw Tt(a,o?.callee),a}return s.value},he=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new G;return i.issues.length?{success:!1,error:new(e??Pt)(i.issues.map(s=>J(s,o,F())))}:{success:!0,data:i.value}},$o=he(Ct),ge=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>J(s,o,F())))}:{success:!0,data:i.value}},Ao=ge(Ct),Io=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return qe(e)(t,n,o)},Po=e=>(t,n,r)=>qe(e)(t,n,r),Co=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return je(e)(t,n,o)},Oo=e=>async(t,n,r)=>je(e)(t,n,r),Zo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return he(e)(t,n,o)},Ro=e=>(t,n,r)=>he(e)(t,n,r),Lo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ge(e)(t,n,o)},No=e=>async(t,n,r)=>ge(e)(t,n,r),xo=/^[cC][0-9a-z]{6,}$/,qo=/^[0-9a-z]+$/,jo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Do=/^[0-9a-vA-V]{20}$/,Uo=/^[A-Za-z0-9]{27}$/,Bo=/^[a-zA-Z0-9_-]{21}$/,Mo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fo=/^([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})$/,Ot=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)$/,Ho=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Jo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Qo(){return new RegExp(Jo,"u")}var Wo=/^(?:(?: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])$/,Vo=/^(([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}|:))$/,Go=/^((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])$/,Ko=/^(([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])$/,Yo=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zt=/^[A-Za-z0-9_-]*$/,Xo=/^https?$/,ei=/^\+[1-9]\d{6,14}$/,Rt="(?:(?:\\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])))",ti=new RegExp(`^${Rt}$`);function Lt(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(`^${Lt(e)}$`)}function ri(e){const t=Lt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Rt}T(?:${r})$`)}var oi=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ii=/^(?:true|false)$/i,si=/^[^A-Z]*$/,ai=/^[^a-z]*$/,N=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ci=l("$ZodCheckMaxLength",(e,t)=>{var n;N.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=xe(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ui=l("$ZodCheckMinLength",(e,t)=>{var n;N.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=xe(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),li=l("$ZodCheckLengthEquals",(e,t)=>{var n;N.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Le(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=xe(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),me=l("$ZodCheckStringFormat",(e,t)=>{var n,r;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?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),di=l("$ZodCheckRegex",(e,t)=>{me.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),pi=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=si),me.init(e,t)}),fi=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ai),me.init(e,t)}),hi=l("$ZodCheckIncludes",(e,t)=>{N.init(e,t);const n=pe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),gi=l("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);const n=new RegExp(`^${pe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),mi=l("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);const n=new RegExp(`.*${pe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),_i=l("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=n=>{n.value=t.tx(n.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),n=Math.min(...t.map(o=>o.length-o.trimStart().length)),r=t.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(r=>` ${r}`)];return new e(...t,n.join(`
|
|
50
|
-
`))}},
|
|
50
|
+
`))}},vi={major:4,minor:4,patch:3},T=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=vi;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,c)=>{let u=K(s),d;for(const h of a){if(h._zod.def.when){if(So(s)||!h._zod.def.when(s))continue}else if(u)continue;const f=s.issues.length,p=h._zod.check(s);if(p instanceof Promise&&c?.async===!1)throw new G;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,s.issues.length!==f&&(u||(u=K(s,f)))});else{if(s.issues.length===f)continue;u||(u=K(s,f))}}return d?d.then(()=>s):s},i=(s,a,c)=>{if(K(s))return s.aborted=!0,s;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new G;return u.then(d=>e._zod.parse(d,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(d=>i(d,s,a)):i(u,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new G;return c.then(u=>o(u,r,a))}return o(c,r,a)}}w(e,"~standard",()=>({validate:o=>{try{const i=$o(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Ao(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),De=l("$ZodString",(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??oi(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),k=l("$ZodStringFormat",(e,t)=>{me.init(e,t),De.init(e,t)}),bi=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fo),k.init(e,t)}),wi=l("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ot(n))}else t.pattern??(t.pattern=Ot());k.init(e,t)}),ki=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ho),k.init(e,t)}),zi=l("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Xo.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Si=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Qo()),k.init(e,t)}),Ei=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Bo),k.init(e,t)}),Ti=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xo),k.init(e,t)}),$i=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=qo),k.init(e,t)}),Ai=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=jo),k.init(e,t)}),Ii=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Do),k.init(e,t)}),Pi=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Uo),k.init(e,t)}),Ci=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ri(t)),k.init(e,t)}),Oi=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ti),k.init(e,t)}),Zi=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ni(t)),k.init(e,t)}),Ri=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Mo),k.init(e,t)}),Li=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Wo),k.init(e,t),e._zod.bag.format="ipv4"}),Ni=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vo),k.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),xi=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Go),k.init(e,t)}),qi=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ko),k.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Nt(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ji=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yo),k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Nt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Di(e){if(!Zt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/");return Nt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var Ui=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zt),k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Di(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Bi=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ei),k.init(e,t)});function Mi(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Fi=l("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=n=>{Mi(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Hi=l("$ZodBoolean",(e,t)=>{T.init(e,t),e._zod.pattern=ii,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ji=l("$ZodUnknown",(e,t)=>{T.init(e,t),e._zod.parse=n=>n}),Qi=l("$ZodNever",(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function xt(e,t,n){e.issues.length&&t.issues.push(...At(n,e.issues)),t.value[n]=e.value}var Wi=l("$ZodArray",(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(u=>xt(u,n,s))):xt(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function _e(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...At(n,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}function qt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=mo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function jt(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optin==="optional",h=c.optout==="optional";for(const f in t){if(f==="__proto__"||a.has(f))continue;if(u==="never"){s.push(f);continue}const p=c.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(g=>_e(g,n,f,t,d,h))):_e(p,n,f,t,d,h)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var Vi=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 n=Re(()=>qt(t));w(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 d of u.values)a[c].add(d)}}return a});const r=de,o=t.catchall;let i;e._zod.parse=(s,a)=>{i??(i=n.value);const c=s.value;if(!r(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),s;s.value={};const u=[],d=i.shape;for(const h of i.keys){const f=d[h],p=f._zod.optin==="optional",g=f._zod.optout==="optional",m=f._zod.run({value:c[h],issues:[]},a);m instanceof Promise?u.push(m.then(v=>_e(v,s,h,c,p,g))):_e(m,s,h,c,p,g)}return o?jt(u,c,s,a,n.value,e):u.length?Promise.all(u).then(()=>s):s}}),Gi=l("$ZodObjectJIT",(e,t)=>{Vi.init(e,t);const n=e._zod.parse,r=Re(()=>qt(t)),o=f=>{const p=new yi(["shape","payload","ctx"]),g=r.value,m=E=>{const b=Et(E);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};p.write("const input = payload.value;");const v=Object.create(null);let S=0;for(const E of g.keys)v[E]=`key_${S++}`;p.write("const newResult = {};");for(const E of g.keys){const b=v[E],P=Et(E),fn=f[E],hn=fn?._zod?.optin==="optional",Uc=fn?._zod?.optout==="optional";p.write(`const ${b} = ${m(E)};`),hn&&Uc?p.write(`
|
|
51
51
|
if (${b}.issues.length) {
|
|
52
52
|
if (${P} in input) {
|
|
53
53
|
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
@@ -106,6 +106,6 @@
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
`)}p.write("payload.value = newResult;"),p.write("return payload;");const A=p.compile();return(E,b)=>A(f,E,b)};let i;const s=de,a=!le.jitless,u=a&&fo.value,d=t.catchall;let h;e._zod.parse=(f,p)=>{h??(h=r.value);const g=f.value;return s(g)?a&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=o(t.shape)),f=i(f,p),d?qt([],g,f,p,h,e):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function jt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!K(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>J(s,r,F())))}),t)}var Gi=l("$ZodUnion",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),w(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Ne(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.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=>jt(a,r,e,o)):jt(s,r,e,o)}}),Ki=l("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,c])=>Dt(n,a,c)):Dt(n,i,s)}});function Ue(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(re(e)&&re(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Ue(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 n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ue(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Dt(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),K(e))return e;const s=Ue(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Yi=l("$ZodEnum",(e,t)=>{T.init(e,t);const n=kt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>ho.has(typeof o)).map(o=>typeof o=="string"?pe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),Xi=l("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new wt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new G;return n.value=o,n.fallback=!0,n}});function Ut(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Bt=l("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ne(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Ut(s,o)):Ut(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),es=l("$ZodExactOptional",(e,t)=>{Bt.init(e,t),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ts=l("$ZodNullable",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ne(n.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),ns=l("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Mt(i,t)):Mt(o,t)}});function Mt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var rs=l("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),os=l("$ZodNonOptional",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Ft(i,e)):Ft(o,e)}});function Ft(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 is=l("$ZodCatch",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>J(s,r,F()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>J(i,r,F()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),ss=l("$ZodPipe",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>t.in._zod.values),w(e._zod,"optin",()=>t.in._zod.optin),w(e._zod,"optout",()=>t.out._zod.optout),w(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>ye(s,t.in,r)):ye(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>ye(i,t.out,r)):ye(o,t.out,r)}});function ye(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var as=l("$ZodReadonly",(e,t)=>{T.init(e,t),w(e._zod,"propValues",()=>t.innerType._zod.propValues),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"optin",()=>t.innerType?._zod?.optin),w(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Ht):Ht(o)}});function Ht(e){return e.value=Object.freeze(e.value),e}var cs=l("$ZodCustom",(e,t)=>{N.init(e,t),T.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Jt(i,n,r,e));Jt(o,n,r,e)}});function Jt(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(oe(o))}}var Qt,us=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ls(){return new us}(Qt=globalThis).__zod_globalRegistry??(Qt.__zod_globalRegistry=ls());var ie=globalThis.__zod_globalRegistry;function ds(e,t){return new e({type:"string",..._(t)})}function ps(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function Wt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function fs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function hs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function gs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function ms(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function _s(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function ys(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function vs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function bs(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function ws(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function ks(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function zs(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function Ss(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function Es(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function Ts(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function $s(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function As(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function Is(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function Ps(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function Cs(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function Os(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}function Zs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Rs(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function Ls(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function Ns(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function xs(e,t){return new e({type:"boolean",..._(t)})}function qs(e){return new e({type:"unknown"})}function js(e,t){return new e({type:"never",..._(t)})}function Vt(e,t){return new ai({check:"max_length",..._(t),maximum:e})}function ve(e,t){return new ci({check:"min_length",..._(t),minimum:e})}function Gt(e,t){return new ui({check:"length_equals",..._(t),length:e})}function Ds(e,t){return new li({check:"string_format",format:"regex",..._(t),pattern:e})}function Us(e){return new di({check:"string_format",format:"lowercase",..._(e)})}function Bs(e){return new pi({check:"string_format",format:"uppercase",..._(e)})}function Ms(e,t){return new fi({check:"string_format",format:"includes",..._(t),includes:e})}function Fs(e,t){return new hi({check:"string_format",format:"starts_with",..._(t),prefix:e})}function Hs(e,t){return new gi({check:"string_format",format:"ends_with",..._(t),suffix:e})}function Y(e){return new mi({check:"overwrite",tx:e})}function Js(e){return Y(t=>t.normalize(e))}function Qs(){return Y(e=>e.trim())}function Ws(){return Y(e=>e.toLowerCase())}function Vs(){return Y(e=>e.toUpperCase())}function Gs(){return Y(e=>po(e))}function Ks(e,t,n){return new e({type:"array",element:t,..._(n)})}function Ys(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function Xs(e,t){const n=ea(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(oe(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(oe(i))}},e(r.value,r)),t);return n}function ea(e,t){const n=new N({check:"custom",..._(t)});return n._zod.check=e,n}function Kt(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??ie,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,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const h=s.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,h,u)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),I(d,t,u),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&C(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Yt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.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.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,h=e.external.uri??(p=>p);if(d)return{ref:h(d)};const f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${f}`}}if(s[1]===n)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 d=a.schema;for(const h in d)delete d[h];d.$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
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const A=p.compile();return(E,b)=>A(f,E,b)};let i;const s=de,a=!le.jitless,u=a&&ho.value,d=t.catchall;let h;e._zod.parse=(f,p)=>{h??(h=r.value);const g=f.value;return s(g)?a&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=o(t.shape)),f=i(f,p),d?jt([],g,f,p,h,e):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Dt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!K(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>J(s,r,F())))}),t)}var Ki=l("$ZodUnion",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),w(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Ne(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.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=>Dt(a,r,e,o)):Dt(s,r,e,o)}}),Yi=l("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,c])=>Ut(n,a,c)):Ut(n,i,s)}});function Ue(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(re(e)&&re(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=Ue(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 n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ue(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ut(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),K(e))return e;const s=Ue(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Xi=l("$ZodEnum",(e,t)=>{T.init(e,t);const n=zt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>go.has(typeof o)).map(o=>typeof o=="string"?pe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),es=l("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new kt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new G;return n.value=o,n.fallback=!0,n}});function Bt(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Mt=l("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ne(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Bt(s,o)):Bt(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),ts=l("$ZodExactOptional",(e,t)=>{Mt.init(e,t),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ns=l("$ZodNullable",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ne(n.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),rs=l("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Ft(i,t)):Ft(o,t)}});function Ft(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var os=l("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),is=l("$ZodNonOptional",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Ht(i,e)):Ht(o,e)}});function Ht(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 ss=l("$ZodCatch",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>J(s,r,F()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>J(i,r,F()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),as=l("$ZodPipe",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>t.in._zod.values),w(e._zod,"optin",()=>t.in._zod.optin),w(e._zod,"optout",()=>t.out._zod.optout),w(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>ye(s,t.in,r)):ye(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>ye(i,t.out,r)):ye(o,t.out,r)}});function ye(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var cs=l("$ZodReadonly",(e,t)=>{T.init(e,t),w(e._zod,"propValues",()=>t.innerType._zod.propValues),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"optin",()=>t.innerType?._zod?.optin),w(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Jt):Jt(o)}});function Jt(e){return e.value=Object.freeze(e.value),e}var us=l("$ZodCustom",(e,t)=>{N.init(e,t),T.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Qt(i,n,r,e));Qt(o,n,r,e)}});function Qt(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(oe(o))}}var Wt,ls=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ds(){return new ls}(Wt=globalThis).__zod_globalRegistry??(Wt.__zod_globalRegistry=ds());var ie=globalThis.__zod_globalRegistry;function ps(e,t){return new e({type:"string",..._(t)})}function fs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function Vt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function hs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function gs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function ms(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function ys(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function vs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function bs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function ws(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function ks(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function zs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function Ss(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function Es(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function Ts(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function $s(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function As(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function Is(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function Ps(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function Cs(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function Os(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function Zs(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}function Rs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Ls(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function Ns(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function xs(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function qs(e,t){return new e({type:"boolean",..._(t)})}function js(e){return new e({type:"unknown"})}function Ds(e,t){return new e({type:"never",..._(t)})}function Gt(e,t){return new ci({check:"max_length",..._(t),maximum:e})}function ve(e,t){return new ui({check:"min_length",..._(t),minimum:e})}function Kt(e,t){return new li({check:"length_equals",..._(t),length:e})}function Us(e,t){return new di({check:"string_format",format:"regex",..._(t),pattern:e})}function Bs(e){return new pi({check:"string_format",format:"lowercase",..._(e)})}function Ms(e){return new fi({check:"string_format",format:"uppercase",..._(e)})}function Fs(e,t){return new hi({check:"string_format",format:"includes",..._(t),includes:e})}function Hs(e,t){return new gi({check:"string_format",format:"starts_with",..._(t),prefix:e})}function Js(e,t){return new mi({check:"string_format",format:"ends_with",..._(t),suffix:e})}function Y(e){return new _i({check:"overwrite",tx:e})}function Qs(e){return Y(t=>t.normalize(e))}function Ws(){return Y(e=>e.trim())}function Vs(){return Y(e=>e.toLowerCase())}function Gs(){return Y(e=>e.toUpperCase())}function Ks(){return Y(e=>fo(e))}function Ys(e,t,n){return new e({type:"array",element:t,..._(n)})}function Xs(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function ea(e,t){const n=ta(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(oe(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(oe(i))}},e(r.value,r)),t);return n}function ta(e,t){const n=new N({check:"custom",..._(t)});return n._zod.check=e,n}function Yt(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??ie,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,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{const h=s.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,h,u)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),I(d,t,u),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&C(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Xt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.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.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,h=e.external.uri??(p=>p);if(d)return{ref:h(d)};const f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${f}`}}if(s[1]===n)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 d=a.schema;for(const h in d)delete d[h];d.$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 Xt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,d={...u},h=c.ref;if(c.ref=null,h){r(h);const p=e.seen.get(h),g=p.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(g)):Object.assign(u,g),Object.assign(u,d),a._zod.parent===h)for(const m in u)m==="$ref"||m==="allOf"||m in d||delete u[m];if(g.$ref&&p.def)for(const m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}const f=a._zod.parent;if(f&&f!==h){r(f);const p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())r(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,n.def??n.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:be(t,"input",e.processors),output:be(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function C(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return C(r.element,n);if(r.type==="set")return C(r.valueType,n);if(r.type==="lazy")return C(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return C(r.innerType,n);if(r.type==="intersection")return C(r.left,n)||C(r.right,n);if(r.type==="record"||r.type==="map")return C(r.keyType,n)||C(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:C(r.in,n)||C(r.out,n);if(r.type==="object"){for(const o in r.shape)if(C(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(C(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(C(o,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}var ta=(e,t={})=>n=>{const r=Kt({...n,processors:t});return I(e,r),Yt(r,e),Xt(r,e)},be=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Kt({...o??{},target:i,io:t,processors:n});return I(e,s),Yt(s,e),Xt(s,e)},na={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ra=(e,t,n,r)=>{const o=n;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=na[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},oa=(e,t,n,r)=>{n.type="boolean"},ia=(e,t,n,r)=>{n.not={}},sa=(e,t,n,r)=>{},aa=(e,t,n,r)=>{const o=e._zod.def,i=kt(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},ca=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ua=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},la=(e,t,n,r)=>{const o=n,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,{...r,path:[...r.path,"items"]})},da=(e,t,n,r)=>{const o=n,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,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=I(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},pa=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>I(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},fa=(e,t,n,r)=>{const o=e._zod.def,i=I(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=I(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]},ha=(e,t,n,r)=>{const o=e._zod.def,i=I(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ga=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ma=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},_a=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},ya=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);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")}n.default=s},va=(e,t,n,r)=>{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,r);const a=t.seen.get(e);a.ref=s},ba=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},en=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},wa=l("ZodISODateTime",(e,t)=>{Pi.init(e,t),z.init(e,t)});function ka(e){return Zs(wa,e)}var za=l("ZodISODate",(e,t)=>{Ci.init(e,t),z.init(e,t)});function Sa(e){return Rs(za,e)}var Ea=l("ZodISOTime",(e,t)=>{Oi.init(e,t),z.init(e,t)});function Ta(e){return Ls(Ea,e)}var $a=l("ZodISODuration",(e,t)=>{Zi.init(e,t),z.init(e,t)});function Aa(e){return Ns($a,e)}var Ia=(e,t)=>{It.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Eo(e,n)},flatten:{value:n=>So(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ze,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ze,2)}},isEmpty:{get(){return e.issues.length===0}}})},Z=l("ZodError",Ia,{Parent:Error}),Pa=qe(Z),Ca=je(Z),Oa=he(Z),Za=ge(Z),Ra=Ao(Z),La=Io(Z),Na=Po(Z),xa=Co(Z),qa=Oo(Z),ja=Zo(Z),Da=Ro(Z),Ua=Lo(Z),tn=new WeakMap;function we(e,t,n){const r=Object.getPrototypeOf(e);let o=tn.get(r);if(o||(o=new Set,tn.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const s=n[i];Object.defineProperty(r,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:be(e,"input"),output:be(e,"output")}}),e.toJSONSchema=ta(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>Pa(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Oa(e,n,r),e.parseAsync=async(n,r)=>Ca(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Za(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Ra(e,n,r),e.decode=(n,r)=>La(e,n,r),e.encodeAsync=async(n,r)=>Na(e,n,r),e.decodeAsync=async(n,r)=>xa(e,n,r),e.safeEncode=(n,r)=>qa(e,n,r),e.safeDecode=(n,r)=>ja(e,n,r),e.safeEncodeAsync=async(n,r)=>Da(e,n,r),e.safeDecodeAsync=async(n,r)=>Ua(e,n,r),we(e,"ZodType",{check(...n){const r=this.def;return this.clone(j(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return D(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(Oc(n,r))},superRefine(n,r){return this.check(Zc(n,r))},overwrite(n){return this.check(Y(n))},optional(){return cn(this)},exactOptional(){return vc(this)},nullable(){return un(this)},nullish(){return cn(un(this))},nonoptional(n){return Ec(this,n)},array(){return on(this)},or(n){return sn([this,n])},and(n){return gc(this,n)},transform(n){return dn(this,_c(n))},default(n){return kc(this,n)},prefault(n){return Sc(this,n)},catch(n){return $c(this,n)},pipe(n){return dn(this,n)},readonly(){return Pc(this)},describe(n){const r=this.clone();return ie.add(r,{description:n}),r},meta(...n){if(n.length===0)return ie.get(this);const r=this.clone();return ie.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return ie.get(e)?.description},configurable:!0}),e)),nn=l("_ZodString",(e,t)=>{De.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ra(e,r,o,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,we(e,"_ZodString",{regex(...r){return this.check(Ds(...r))},includes(...r){return this.check(Ms(...r))},startsWith(...r){return this.check(Fs(...r))},endsWith(...r){return this.check(Hs(...r))},min(...r){return this.check(ve(...r))},max(...r){return this.check(Vt(...r))},length(...r){return this.check(Gt(...r))},nonempty(...r){return this.check(ve(1,...r))},lowercase(r){return this.check(Us(r))},uppercase(r){return this.check(Bs(r))},trim(){return this.check(Qs())},normalize(...r){return this.check(Js(...r))},toLowerCase(){return this.check(Ws())},toUpperCase(){return this.check(Vs())},slugify(){return this.check(Gs())}})}),Ba=l("ZodString",(e,t)=>{De.init(e,t),nn.init(e,t),e.email=n=>e.check(ps(Ma,n)),e.url=n=>e.check(_s(Fa,n)),e.jwt=n=>e.check(Os(ic,n)),e.emoji=n=>e.check(ys(Ha,n)),e.guid=n=>e.check(Wt(rn,n)),e.uuid=n=>e.check(fs(ke,n)),e.uuidv4=n=>e.check(hs(ke,n)),e.uuidv6=n=>e.check(gs(ke,n)),e.uuidv7=n=>e.check(ms(ke,n)),e.nanoid=n=>e.check(vs(Ja,n)),e.guid=n=>e.check(Wt(rn,n)),e.cuid=n=>e.check(bs(Qa,n)),e.cuid2=n=>e.check(ws(Wa,n)),e.ulid=n=>e.check(ks(Va,n)),e.base64=n=>e.check(Is(nc,n)),e.base64url=n=>e.check(Ps(rc,n)),e.xid=n=>e.check(zs(Ga,n)),e.ksuid=n=>e.check(Ss(Ka,n)),e.ipv4=n=>e.check(Es(Ya,n)),e.ipv6=n=>e.check(Ts(Xa,n)),e.cidrv4=n=>e.check($s(ec,n)),e.cidrv6=n=>e.check(As(tc,n)),e.e164=n=>e.check(Cs(oc,n)),e.datetime=n=>e.check(ka(n)),e.date=n=>e.check(Sa(n)),e.time=n=>e.check(Ta(n)),e.duration=n=>e.check(Aa(n))});function Q(e){return ds(Ba,e)}var z=l("ZodStringFormat",(e,t)=>{k.init(e,t),nn.init(e,t)}),Ma=l("ZodEmail",(e,t)=>{wi.init(e,t),z.init(e,t)}),rn=l("ZodGUID",(e,t)=>{vi.init(e,t),z.init(e,t)}),ke=l("ZodUUID",(e,t)=>{bi.init(e,t),z.init(e,t)}),Fa=l("ZodURL",(e,t)=>{ki.init(e,t),z.init(e,t)}),Ha=l("ZodEmoji",(e,t)=>{zi.init(e,t),z.init(e,t)}),Ja=l("ZodNanoID",(e,t)=>{Si.init(e,t),z.init(e,t)}),Qa=l("ZodCUID",(e,t)=>{Ei.init(e,t),z.init(e,t)}),Wa=l("ZodCUID2",(e,t)=>{Ti.init(e,t),z.init(e,t)}),Va=l("ZodULID",(e,t)=>{$i.init(e,t),z.init(e,t)}),Ga=l("ZodXID",(e,t)=>{Ai.init(e,t),z.init(e,t)}),Ka=l("ZodKSUID",(e,t)=>{Ii.init(e,t),z.init(e,t)}),Ya=l("ZodIPv4",(e,t)=>{Ri.init(e,t),z.init(e,t)}),Xa=l("ZodIPv6",(e,t)=>{Li.init(e,t),z.init(e,t)}),ec=l("ZodCIDRv4",(e,t)=>{Ni.init(e,t),z.init(e,t)}),tc=l("ZodCIDRv6",(e,t)=>{xi.init(e,t),z.init(e,t)}),nc=l("ZodBase64",(e,t)=>{qi.init(e,t),z.init(e,t)}),rc=l("ZodBase64URL",(e,t)=>{Di.init(e,t),z.init(e,t)}),oc=l("ZodE164",(e,t)=>{Ui.init(e,t),z.init(e,t)}),ic=l("ZodJWT",(e,t)=>{Mi.init(e,t),z.init(e,t)}),sc=l("ZodBoolean",(e,t)=>{Fi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oa(e,n,r,o)});function ac(e){return xs(sc,e)}var cc=l("ZodUnknown",(e,t)=>{Hi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sa(e,n,r,o)});function Be(){return qs(cc)}var uc=l("ZodNever",(e,t)=>{Ji.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ia(e,n,r,o)});function lc(e){return js(uc,e)}var dc=l("ZodArray",(e,t)=>{Qi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>la(e,n,r,o),e.element=t.element,we(e,"ZodArray",{min(n,r){return this.check(ve(n,r))},nonempty(n){return this.check(ve(1,n))},max(n,r){return this.check(Vt(n,r))},length(n,r){return this.check(Gt(n,r))},unwrap(){return this.element}})});function on(e,t){return Ks(dc,e,t)}var pc=l("ZodObject",(e,t)=>{Vi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>da(e,n,r,o),w(e,"shape",()=>t.shape),we(e,"ZodObject",{keyof(){return Fe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},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:lc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return yo(this,n)},safeExtend(n){return vo(this,n)},merge(n){return bo(this,n)},pick(n){return mo(this,n)},omit(n){return _o(this,n)},partial(...n){return wo(an,this,n[0])},required(...n){return ko(ln,this,n[0])}})});function se(e,t){return new pc({type:"object",shape:e??{},..._(t)})}var fc=l("ZodUnion",(e,t)=>{Gi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pa(e,n,r,o),e.options=t.options});function sn(e,t){return new fc({type:"union",options:e,..._(t)})}var hc=l("ZodIntersection",(e,t)=>{Ki.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fa(e,n,r,o)});function gc(e,t){return new hc({type:"intersection",left:e,right:t})}var Me=l("ZodEnum",(e,t)=>{Yi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,o,i)=>aa(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Me({...t,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Me({...t,checks:[],..._(o),entries:i})}});function Fe(e,t){return new Me({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e,..._(t)})}var mc=l("ZodTransform",(e,t)=>{Xi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ua(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new wt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(oe(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(oe(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function _c(e){return new mc({type:"transform",transform:e})}var an=l("ZodOptional",(e,t)=>{Bt.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>en(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function cn(e){return new an({type:"optional",innerType:e})}var yc=l("ZodExactOptional",(e,t)=>{es.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>en(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new yc({type:"optional",innerType:e})}var bc=l("ZodNullable",(e,t)=>{ts.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ha(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function un(e){return new bc({type:"nullable",innerType:e})}var wc=l("ZodDefault",(e,t)=>{ns.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ma(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kc(e,t){return new wc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Tt(t)}})}var zc=l("ZodPrefault",(e,t)=>{rs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_a(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Sc(e,t){return new zc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Tt(t)}})}var ln=l("ZodNonOptional",(e,t)=>{os.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ga(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new ln({type:"nonoptional",innerType:e,..._(t)})}var Tc=l("ZodCatch",(e,t)=>{is.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ya(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $c(e,t){return new Tc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Ac=l("ZodPipe",(e,t)=>{ss.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>va(e,n,r,o),e.in=t.in,e.out=t.out});function dn(e,t){return new Ac({type:"pipe",in:e,out:t})}var Ic=l("ZodReadonly",(e,t)=>{as.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ba(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Ic({type:"readonly",innerType:e})}var Cc=l("ZodCustom",(e,t)=>{cs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ca(e,n,r,o)});function Oc(e,t={}){return Ys(Cc,e,t)}function Zc(e,t){return Xs(e,t)}var Rc=se({title:Q(),type:Q(),payload:Be().optional()}),Lc=se({label:Q(),action:Rc,variant:Fe(["primary","outline","ghost"]).optional()}),Nc=se({orientation:Fe(["horizontal","vertical"]).optional(),wrap:ac().optional()}),xc=se({placeholder:sn([Q(),on(Q())]).optional(),ctaLabel:Q().optional()}),qc=se({text:Q()}),jc={components:{ActionButton:{schema:Lc,description:"A single clickable QNA action button."},ButtonRow:{schema:Nc,description:"Container for a group of QNA action buttons."},TextInput:{schema:xc,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:qc,description:"A heading displayed above the QNA button group."}}},pn=class extends Jn{constructor(...e){super(...e),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=vt,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this._contentEl.dataset.gengagePart="qna-container",this._contentEl.lang=Ke(e.locale),this.root.appendChild(this._contentEl);const t=e.pageContext?.sku;t&&(this._lastSku=t,await this._fetchAndRender(t)),Tn("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_resolvedQnaHeaderTitle(){const e=this.config.headerTitle??this.config.headingTitle;if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const n={middlewareUrl:this.config.middlewareUrl},r=crypto.randomUUID(),o=Date.now(),i=er({source:"qna",locale:this.config.locale});this.track(yn(this.analyticsContext(),{endpoint:"launcher_action",request_id:r,widget:"qna"}));try{const s={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e,locale:Ke(this.config.locale)},a=this.config.pageContext?.pageType;a!==void 0&&(s.page_type=a);const c=await Xr(s,n,this._abortController.signal);if(this.track(vn(this.analyticsContext(),{request_id:r,latency_ms:Date.now()-o,chunk_count:c.actions.length,widget:"qna"})),this.track(kn(this.analyticsContext(),{message_count:c.actions.length,history_ref:r,redaction_level:"none",widget:"qna"})),!this._contentEl)return;this._contentEl.innerHTML="";const u=document.createElement("div");u.className="gengage-qna-panel gds-panel",u.dataset.gengagePart="qna-panel",this._contentEl.appendChild(u);const d=this._specIncludesType(c.uiSpecs,"QuestionHeading"),h=this._resolvedQnaHeaderTitle()??(this.config.showStaticQuestion&&this.config.staticQuestionText?this.config.staticQuestionText:void 0);if(!d&&h){const E=document.createElement("h3");E.className="gengage-qna-heading",E.textContent=h,u.appendChild(E)}const f=this.config.inputPlaceholder;let p;if(f!==!0)p=f??this._i18n.defaultInputPlaceholder;else if(c.actions.length>0){const E=c.actions.filter(b=>b.type==="user_message"||b.title.includes("?")).map(b=>b.title);p=E.length>0?E:this._i18n.defaultInputPlaceholder}else p=this._i18n.defaultInputPlaceholder;const g={onAction:this._actionHandler,i18n:this._i18n},m=this._resolvedQnaHeaderTitle();m!==void 0&&(g.headingTitleOverride=m),this.config.hideButtonRowCta||(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),p!==void 0&&(g.inputPlaceholder=p);const v=this._buildFallbackActionsSpec(c.actions),S=to(this.config.pageContext),A=(c.uiSpecs.length>0?ao(c.uiSpecs,this._i18n,{skuList:S}):[v]).filter(E=>Object.keys(E.elements).length>0);for(const E of A){const b=this._renderUISpec(E,g);u.appendChild(b)}A.length>0&&$n("qna"),this._specIncludesType(A,"TextInput")||this._insertStandaloneInputBeforePills(u,g,p)}catch(s){if(s instanceof DOMException&&s.name==="AbortError")return;if(Se("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:qn(this.config.locale,s)}),this.track(bn(this.analyticsContext(),{request_id:r,error_code:"FETCH_ERROR",error_message:s instanceof Error?s.message:String(s),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const a=document.createElement("div");a.className="gengage-qna-panel",this._contentEl.appendChild(a);const c=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,u={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler},d=this._resolvedQnaHeaderTitle();d!==void 0&&(u.headingTitleOverride=d),this.config.ctaText!==void 0&&(u.ctaText=this.config.ctaText),this._appendStandaloneInput(u,c,a)}}finally{i()}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const n=document.createElement("div");n.className="gengage-qna-loading-dot",e.appendChild(n)}return e}_resolveI18n(e){return{...lo(e.locale),...e.i18n}}_resolveUISpecRegistry(){return _n(ft(),this.config.renderer?.registry)}_renderUISpec(e,t){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??Oe,o=(s,a)=>ht(s,a,n,r),i=this.config.renderer?.renderUISpec;return i?i(e,t,{registry:n,unknownRenderer:r,defaultRender:o}):o(e,t)}_specIncludesType(e,t){for(const n of e)for(const r of Object.values(n.elements))if(r.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},n=[];for(let r=0;r<e.length;r++){const o=e[r],i=`action-${r}`;n.push(i),t[i]={type:"ActionButton",props:{label:o.title,action:{title:o.title,type:o.type,payload:o.payload}}}}return t.root={type:"ButtonRow",children:n},{root:"root",elements:t}}_insertStandaloneInputBeforePills(e,t,n){const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:n}}}},o=this._renderUISpec(r,t),i=o.querySelector(".gengage-qna-input-wrapper");if(!i)return;const s=e.querySelector(".gengage-qna-uispec"),a=s?.querySelector(":scope > .gengage-qna-buttons");if(s&&a)s.insertBefore(i,a);else if(s){const c=s.querySelector(":scope > .gengage-qna-heading");c?c.insertAdjacentElement("afterend",i):s.prepend(i)}else{e.appendChild(o);return}o.remove()}_appendStandaloneInput(e,t,n){if(!this._contentEl)return;const r={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(r,e);(n??this._contentEl).appendChild(o)}_handleAction(e){this._showTransitionIndicator(),An(e.title,e.type),this.config.onActionSelected?.(e),setTimeout(()=>Se("gengage:qna:action",e),350)}_handleOpenChat(){this._showTransitionIndicator(),this.config.onOpenChat?.(),setTimeout(()=>Se("gengage:qna:open-chat",{}),350)}_showTransitionIndicator(){if(!this._contentEl)return;this._contentEl.querySelector(".gengage-qna-transition-indicator")?.remove(),this._contentEl.classList.add("gengage-qna--transitioning");const e=this._i18n.redirectingToChat??"Redirecting to chat...",t=document.createElement("div");t.className="gengage-qna-transition-indicator",t.textContent=e,(this._contentEl.querySelector(".gengage-qna-panel")??this._contentEl).appendChild(t),setTimeout(()=>{this._contentEl?.classList.remove("gengage-qna--transitioning"),t.remove()},600)}};function Dc(){return new pn}U.GengageQNA=pn,U.createDefaultQnaUISpecRegistry=ft,U.createQNAWidget=Dc,U.defaultQnaUnknownUISpecRenderer=Oe,U.qnaCatalog=jc,U.renderQnaUISpec=ht})(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 en(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,d={...u},h=c.ref;if(c.ref=null,h){r(h);const p=e.seen.get(h),g=p.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(g)):Object.assign(u,g),Object.assign(u,d),a._zod.parent===h)for(const m in u)m==="$ref"||m==="allOf"||m in d||delete u[m];if(g.$ref&&p.def)for(const m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}const f=a._zod.parent;if(f&&f!==h){r(f);const p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())r(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,n.def??n.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:be(t,"input",e.processors),output:be(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function C(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return C(r.element,n);if(r.type==="set")return C(r.valueType,n);if(r.type==="lazy")return C(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return C(r.innerType,n);if(r.type==="intersection")return C(r.left,n)||C(r.right,n);if(r.type==="record"||r.type==="map")return C(r.keyType,n)||C(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:C(r.in,n)||C(r.out,n);if(r.type==="object"){for(const o in r.shape)if(C(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(C(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(C(o,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}var na=(e,t={})=>n=>{const r=Yt({...n,processors:t});return I(e,r),Xt(r,e),en(r,e)},be=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Yt({...o??{},target:i,io:t,processors:n});return I(e,s),Xt(s,e),en(s,e)},ra={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},oa=(e,t,n,r)=>{const o=n;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=ra[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},ia=(e,t,n,r)=>{n.type="boolean"},sa=(e,t,n,r)=>{n.not={}},aa=(e,t,n,r)=>{},ca=(e,t,n,r)=>{const o=e._zod.def,i=zt(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},ua=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},la=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},da=(e,t,n,r)=>{const o=n,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,{...r,path:[...r.path,"items"]})},pa=(e,t,n,r)=>{const o=n,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,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=I(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},fa=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>I(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},ha=(e,t,n,r)=>{const o=e._zod.def,i=I(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=I(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1;n.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]},ga=(e,t,n,r)=>{const o=e._zod.def,i=I(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ma=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},_a=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ya=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},va=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);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")}n.default=s},ba=(e,t,n,r)=>{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,r);const a=t.seen.get(e);a.ref=s},wa=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},tn=(e,t,n,r)=>{const o=e._zod.def;I(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ka=l("ZodISODateTime",(e,t)=>{Ci.init(e,t),z.init(e,t)});function za(e){return Rs(ka,e)}var Sa=l("ZodISODate",(e,t)=>{Oi.init(e,t),z.init(e,t)});function Ea(e){return Ls(Sa,e)}var Ta=l("ZodISOTime",(e,t)=>{Zi.init(e,t),z.init(e,t)});function $a(e){return Ns(Ta,e)}var Aa=l("ZodISODuration",(e,t)=>{Ri.init(e,t),z.init(e,t)});function Ia(e){return xs(Aa,e)}var Pa=(e,t)=>{Pt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>To(e,n)},flatten:{value:n=>Eo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ze,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ze,2)}},isEmpty:{get(){return e.issues.length===0}}})},Z=l("ZodError",Pa,{Parent:Error}),Ca=qe(Z),Oa=je(Z),Za=he(Z),Ra=ge(Z),La=Io(Z),Na=Po(Z),xa=Co(Z),qa=Oo(Z),ja=Zo(Z),Da=Ro(Z),Ua=Lo(Z),Ba=No(Z),nn=new WeakMap;function we(e,t,n){const r=Object.getPrototypeOf(e);let o=nn.get(r);if(o||(o=new Set,nn.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const s=n[i];Object.defineProperty(r,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:be(e,"input"),output:be(e,"output")}}),e.toJSONSchema=na(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>Ca(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Za(e,n,r),e.parseAsync=async(n,r)=>Oa(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ra(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>La(e,n,r),e.decode=(n,r)=>Na(e,n,r),e.encodeAsync=async(n,r)=>xa(e,n,r),e.decodeAsync=async(n,r)=>qa(e,n,r),e.safeEncode=(n,r)=>ja(e,n,r),e.safeDecode=(n,r)=>Da(e,n,r),e.safeEncodeAsync=async(n,r)=>Ua(e,n,r),e.safeDecodeAsync=async(n,r)=>Ba(e,n,r),we(e,"ZodType",{check(...n){const r=this.def;return this.clone(j(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return D(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(Zc(n,r))},superRefine(n,r){return this.check(Rc(n,r))},overwrite(n){return this.check(Y(n))},optional(){return un(this)},exactOptional(){return bc(this)},nullable(){return ln(this)},nullish(){return un(ln(this))},nonoptional(n){return Tc(this,n)},array(){return sn(this)},or(n){return an([this,n])},and(n){return mc(this,n)},transform(n){return pn(this,yc(n))},default(n){return zc(this,n)},prefault(n){return Ec(this,n)},catch(n){return Ac(this,n)},pipe(n){return pn(this,n)},readonly(){return Cc(this)},describe(n){const r=this.clone();return ie.add(r,{description:n}),r},meta(...n){if(n.length===0)return ie.get(this);const r=this.clone();return ie.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return ie.get(e)?.description},configurable:!0}),e)),rn=l("_ZodString",(e,t)=>{De.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,o,i)=>oa(e,r,o,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,we(e,"_ZodString",{regex(...r){return this.check(Us(...r))},includes(...r){return this.check(Fs(...r))},startsWith(...r){return this.check(Hs(...r))},endsWith(...r){return this.check(Js(...r))},min(...r){return this.check(ve(...r))},max(...r){return this.check(Gt(...r))},length(...r){return this.check(Kt(...r))},nonempty(...r){return this.check(ve(1,...r))},lowercase(r){return this.check(Bs(r))},uppercase(r){return this.check(Ms(r))},trim(){return this.check(Ws())},normalize(...r){return this.check(Qs(...r))},toLowerCase(){return this.check(Vs())},toUpperCase(){return this.check(Gs())},slugify(){return this.check(Ks())}})}),Ma=l("ZodString",(e,t)=>{De.init(e,t),rn.init(e,t),e.email=n=>e.check(fs(Fa,n)),e.url=n=>e.check(ys(Ha,n)),e.jwt=n=>e.check(Zs(sc,n)),e.emoji=n=>e.check(vs(Ja,n)),e.guid=n=>e.check(Vt(on,n)),e.uuid=n=>e.check(hs(ke,n)),e.uuidv4=n=>e.check(gs(ke,n)),e.uuidv6=n=>e.check(ms(ke,n)),e.uuidv7=n=>e.check(_s(ke,n)),e.nanoid=n=>e.check(bs(Qa,n)),e.guid=n=>e.check(Vt(on,n)),e.cuid=n=>e.check(ws(Wa,n)),e.cuid2=n=>e.check(ks(Va,n)),e.ulid=n=>e.check(zs(Ga,n)),e.base64=n=>e.check(Ps(rc,n)),e.base64url=n=>e.check(Cs(oc,n)),e.xid=n=>e.check(Ss(Ka,n)),e.ksuid=n=>e.check(Es(Ya,n)),e.ipv4=n=>e.check(Ts(Xa,n)),e.ipv6=n=>e.check($s(ec,n)),e.cidrv4=n=>e.check(As(tc,n)),e.cidrv6=n=>e.check(Is(nc,n)),e.e164=n=>e.check(Os(ic,n)),e.datetime=n=>e.check(za(n)),e.date=n=>e.check(Ea(n)),e.time=n=>e.check($a(n)),e.duration=n=>e.check(Ia(n))});function Q(e){return ps(Ma,e)}var z=l("ZodStringFormat",(e,t)=>{k.init(e,t),rn.init(e,t)}),Fa=l("ZodEmail",(e,t)=>{ki.init(e,t),z.init(e,t)}),on=l("ZodGUID",(e,t)=>{bi.init(e,t),z.init(e,t)}),ke=l("ZodUUID",(e,t)=>{wi.init(e,t),z.init(e,t)}),Ha=l("ZodURL",(e,t)=>{zi.init(e,t),z.init(e,t)}),Ja=l("ZodEmoji",(e,t)=>{Si.init(e,t),z.init(e,t)}),Qa=l("ZodNanoID",(e,t)=>{Ei.init(e,t),z.init(e,t)}),Wa=l("ZodCUID",(e,t)=>{Ti.init(e,t),z.init(e,t)}),Va=l("ZodCUID2",(e,t)=>{$i.init(e,t),z.init(e,t)}),Ga=l("ZodULID",(e,t)=>{Ai.init(e,t),z.init(e,t)}),Ka=l("ZodXID",(e,t)=>{Ii.init(e,t),z.init(e,t)}),Ya=l("ZodKSUID",(e,t)=>{Pi.init(e,t),z.init(e,t)}),Xa=l("ZodIPv4",(e,t)=>{Li.init(e,t),z.init(e,t)}),ec=l("ZodIPv6",(e,t)=>{Ni.init(e,t),z.init(e,t)}),tc=l("ZodCIDRv4",(e,t)=>{xi.init(e,t),z.init(e,t)}),nc=l("ZodCIDRv6",(e,t)=>{qi.init(e,t),z.init(e,t)}),rc=l("ZodBase64",(e,t)=>{ji.init(e,t),z.init(e,t)}),oc=l("ZodBase64URL",(e,t)=>{Ui.init(e,t),z.init(e,t)}),ic=l("ZodE164",(e,t)=>{Bi.init(e,t),z.init(e,t)}),sc=l("ZodJWT",(e,t)=>{Fi.init(e,t),z.init(e,t)}),ac=l("ZodBoolean",(e,t)=>{Hi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ia(e,n,r,o)});function cc(e){return qs(ac,e)}var uc=l("ZodUnknown",(e,t)=>{Ji.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>aa(e,n,r,o)});function Be(){return js(uc)}var lc=l("ZodNever",(e,t)=>{Qi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sa(e,n,r,o)});function dc(e){return Ds(lc,e)}var pc=l("ZodArray",(e,t)=>{Wi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>da(e,n,r,o),e.element=t.element,we(e,"ZodArray",{min(n,r){return this.check(ve(n,r))},nonempty(n){return this.check(ve(1,n))},max(n,r){return this.check(Gt(n,r))},length(n,r){return this.check(Kt(n,r))},unwrap(){return this.element}})});function sn(e,t){return Ys(pc,e,t)}var fc=l("ZodObject",(e,t)=>{Gi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pa(e,n,r,o),w(e,"shape",()=>t.shape),we(e,"ZodObject",{keyof(){return Fe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},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:dc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return vo(this,n)},safeExtend(n){return bo(this,n)},merge(n){return wo(this,n)},pick(n){return _o(this,n)},omit(n){return yo(this,n)},partial(...n){return ko(cn,this,n[0])},required(...n){return zo(dn,this,n[0])}})});function se(e,t){return new fc({type:"object",shape:e??{},..._(t)})}var hc=l("ZodUnion",(e,t)=>{Ki.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fa(e,n,r,o),e.options=t.options});function an(e,t){return new hc({type:"union",options:e,..._(t)})}var gc=l("ZodIntersection",(e,t)=>{Yi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ha(e,n,r,o)});function mc(e,t){return new gc({type:"intersection",left:e,right:t})}var Me=l("ZodEnum",(e,t)=>{Xi.init(e,t),$.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ca(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Me({...t,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Me({...t,checks:[],..._(o),entries:i})}});function Fe(e,t){return new Me({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e,..._(t)})}var _c=l("ZodTransform",(e,t)=>{es.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>la(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new kt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(oe(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(oe(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function yc(e){return new _c({type:"transform",transform:e})}var cn=l("ZodOptional",(e,t)=>{Mt.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function un(e){return new cn({type:"optional",innerType:e})}var vc=l("ZodExactOptional",(e,t)=>{ts.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new vc({type:"optional",innerType:e})}var wc=l("ZodNullable",(e,t)=>{ns.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ga(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ln(e){return new wc({type:"nullable",innerType:e})}var kc=l("ZodDefault",(e,t)=>{rs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_a(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zc(e,t){return new kc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$t(t)}})}var Sc=l("ZodPrefault",(e,t)=>{os.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ya(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Sc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$t(t)}})}var dn=l("ZodNonOptional",(e,t)=>{is.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ma(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Tc(e,t){return new dn({type:"nonoptional",innerType:e,..._(t)})}var $c=l("ZodCatch",(e,t)=>{ss.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>va(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ac(e,t){return new $c({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Ic=l("ZodPipe",(e,t)=>{as.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ba(e,n,r,o),e.in=t.in,e.out=t.out});function pn(e,t){return new Ic({type:"pipe",in:e,out:t})}var Pc=l("ZodReadonly",(e,t)=>{cs.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Cc(e){return new Pc({type:"readonly",innerType:e})}var Oc=l("ZodCustom",(e,t)=>{us.init(e,t),$.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ua(e,n,r,o)});function Zc(e,t={}){return Xs(Oc,e,t)}function Rc(e,t){return ea(e,t)}var Lc=se({title:Q(),type:Q(),payload:Be().optional()}),Nc=se({label:Q(),action:Lc,variant:Fe(["primary","outline","ghost"]).optional()}),xc=se({orientation:Fe(["horizontal","vertical"]).optional(),wrap:cc().optional()}),qc=se({placeholder:an([Q(),sn(Q())]).optional(),ctaLabel:Q().optional()}),jc=se({text:Q()}),Dc={components:{ActionButton:{schema:Nc,description:"A single clickable QNA action button."},ButtonRow:{schema:xc,description:"Container for a group of QNA action buttons."},TextInput:{schema:qc,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:jc,description:"A heading displayed above the QNA button group."}}};U.GengageQNA=bt,U.createDefaultQnaUISpecRegistry=ft,U.createQNAWidget=po,U.defaultQnaUnknownUISpecRenderer=Oe,U.qnaCatalog=Dc,U.renderQnaUISpec=ht})(this.Gengage=this.Gengage||{});
|
package/dist/qna.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a, i as
|
|
1
|
+
import { a, i as r, n as t, r as n, t as o } from "./runtime-DDu8Wk0z.js";
|
|
2
|
+
import { t as p } from "./qna-BNvttR6s.js";
|
|
2
3
|
export {
|
|
3
4
|
o as GengageQNA,
|
|
4
5
|
n as createDefaultQnaUISpecRegistry,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
t as createQNAWidget,
|
|
7
|
+
r as defaultQnaUnknownUISpecRenderer,
|
|
8
|
+
p as qnaCatalog,
|
|
9
|
+
a as renderQnaUISpec
|
|
9
10
|
};
|