@gengage/assistant-fe 0.3.23 → 0.3.25

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.
@@ -1,40 +0,0 @@
1
- const Ut=require("./ga-datalayer-BVppFxqk.cjs");var We=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const r=document.createElement("div");for(const n of e.children){const o=t(n);o&&r.appendChild(o)}return r};function Lt(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const r=e.unknownRenderer??We,n=i=>{const a=e.spec.elements[i];if(!a)return null;const s=e.registry[a.type];return s?s({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:n}):r({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:n})},o=n(e.spec.root);return o&&t.appendChild(o),t}function Ft(e,t){if(!t)return e;const r={...e};for(const[n,o]of Object.entries(t))o&&(r[n]=o);return r}function ze(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Mt(e){const t=[];let r=0,n=!1,o=!1,i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o){o=!1;continue}if(s==="\\"&&n){o=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&r++,s==="}"&&(r--,r===0&&(t.push(e.slice(i,a+1)),i=a+1)))}return t.length>0?t:[e]}function $e(e,t){const r=e.trim();if(!r||r.startsWith(":"))return!1;const n=r.startsWith("data: ")?r.slice(6):r;if(n==="[DONE]")return t.onDone?.(),!0;try{const o=JSON.parse(n);return ze(o)?(Ut.debugLog("stream",`event: ${o.type}`,o),t.onEvent(o),o.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const o=Mt(n);if(o.length>1){for(const i of o)try{const a=JSON.parse(i);if(!ze(a))continue;if(t.onEvent(a),a.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Be(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const r=e.body.getReader(),n=new TextDecoder("utf-8");let o="";const i=t.idleTimeoutMs??6e4,a=Symbol("idle-timeout");let s=!1;try{for(;;){const c=r.read();let u;const d=await(i>0?Promise.race([c.then(g=>(clearTimeout(u),g)),new Promise(g=>{u=setTimeout(()=>g(a),i)})]):c);if(d===a){s=!0,await r.cancel();break}const{done:p,value:f}=d;if(p)break;o+=n.decode(f,{stream:!0});const m=o.split(`
2
- `);o=m.pop()??"";for(const g of m)if($e(g,t))return}if(o.trim()&&$e(o,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||r.releaseLock()}t.onDone?.()}function Jt(e,t,r){const n=new AbortController,o=r.signal?Vt([r.signal,n.signal]):n.signal;return fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...r.headers},body:JSON.stringify(t),signal:o}).then(i=>Be(i,{...r,signal:o})).catch(i=>{i instanceof DOMException&&i.name==="AbortError"||r.onError?.(i instanceof Error?i:new Error(String(i)))}),n}function Vt(e){const t=new AbortController,r=[];for(const n of e){if(n.aborted)return t.abort(n.reason),t.signal;const o=()=>t.abort(n.reason);n.addEventListener("abort",o,{once:!0}),r.push(()=>n.removeEventListener("abort",o))}return t.signal.addEventListener("abort",()=>{for(const n of r)n()},{once:!0}),t.signal}var Se=3,qt=(e,t)=>{const r=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!r)return"";const n=t?.stripLeadingStopWords?r.replace(/^(?:daha|için)\s+/i,"").trim():r;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},ae=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(r=>qt(r,t)).filter(Boolean):[];function Ke(e){const t=(e.display_keywords??[]).flatMap(o=>ae(o,{stripLeadingStopWords:!0})),r=t.filter((o,i)=>t.indexOf(o)===i);if(r.length>0)return r.slice(0,Se);const n=[...ae(e.chosen_attribute,{stripLeadingStopWords:!0}),...ae(e.short_name)];return n.filter((o,i)=>n.indexOf(o)===i).slice(0,Se)}function He(e){return Ke(e).join(" • ")}var Gt=["beauty_consulting","watch_expert"];function Ye(e){return typeof e=="string"&&Gt.includes(e)}function Wt(e){if(typeof e.type!="string")return null;if(Bt(e))return e;const t=e;switch(t.type){case"outputText":return Kt(t);case"suggestedActions":return Ht(t);case"productList":return Yt(t);case"productDetails":return Xt(t);case"productDetailsSimilars":return Qt(t);case"comparisonTable":return er(t);case"context":return or(t);case"chatStreamEnd":return ir();case"loading":return ar(t);case"panelLoading":return sr(t);case"similarLoading":return cr(t);case"redirect":return ur(t);case"error":return lr(t);case"dummy":return dr(t);case"launcherAction":return pr(t);case"text":return me(t);case"productItem":return fr(t);case"text_image":return Xe(t);case"quick_qna":return Qe(t);case"reviewHighlights":return mr(t);case"aiProductSuggestions":return _r(t);case"aiProductGroupings":return vr(t);case"aiSuggestedSearches":return yr(t);case"prosAndCons":return hr(t);case"getGroundingReview":return br(t);case"voice":return kr(t);case"visitorDataResponse":return gr(t);case"productListPreview":return wr();case"groupList":return zr(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return $r(t);case"launcherContent":return Zr(t);case"handoff":return Sr(t);case"uiSpec":return Cr(t);default:return null}}function Bt(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const r=e.widget;if(r!=="chat"&&r!=="qna"&&r!=="simrel")return!1;const n=I(e.spec);return n?typeof n.root=="string"&&I(n.elements)!==null:!1}case"action":{const r=I(e.action);return r!==null&&typeof r.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Kt(e){const t=_(e.payload.text,e.payload.plain_text)??"",r=_(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:r||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},o=e.payload.product_mentions;Array.isArray(o)&&o.length>0&&(n.productMentions=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const a=e.payload.conversation_mode;typeof a=="string"&&a&&(n.conversationMode=a);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function Ht(e){return et((e.payload.actions??[]).map(t=>{const r=_(t.title)??"",n=j(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(he),"chat")}function Yt(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(a=>{const s=_(a.style_label),c=_(a.style_mood),u=_(a.image_url??void 0),d=(Array.isArray(a.product_list)?a.product_list:[]).map(f=>{const m=I(f);return m?rt(I(m.product_detail)??I(m.product)??m):null}).filter(he),p=Array.isArray(a.recommendation_groups)?a.recommendation_groups.map(f=>({label:_(f.label)??"",reason:_(f.reason)??"",skus:Array.isArray(f.skus)?f.skus.filter(m=>typeof m=="string"&&m.trim().length>0):[]})):[];return{style_label:s??"",style_mood:c??"",...u?{image_url:u}:{},product_list:d,recommendation_groups:p}}).filter(a=>a.product_list.length>0),r=e.payload.product_list??[],n=Ye(e.payload.source)&&t.length>0?t[0].product_list:null,o=n?Or(n,"chat"):tt(r,"chat");o.panelHint="panel";const i=o.spec.elements[o.spec.root];if(i){const a={};typeof e.payload.offset=="number"&&(a.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(a.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(a.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(a.source=e.payload.source),t.length>0&&(a.styleVariations=t),Object.keys(a).length>0&&(i.props={...i.props,...a})}return o}function Xt(e){const t=e.payload.productDetails;if(!t)return Er("chat");const r=R(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...r}}}}},panelHint:"panel"}}function Qt(e){const t=tt(e.payload.similarProducts??[],"chat"),r=t.spec.elements[t.spec.root];return r&&(r.props={...r.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function er(e){const t=e.payload.multiple_product_details??[],r=e.payload,n={key_differences:r.key_differences,recommended_choice:r.recommended_choice,recommended_choice_sku:r.recommended_choice_sku,special_considerations:r.special_considerations,criteria_view:r.criteria_view,criteria_view_short:r.criteria_view_short,compared_field_names:r.compared_field_names,winner_product:r.winner_product,winner_hits:r.winner_hits,...e.payload.product_comparison_framework??{}},o=e.payload.table,i=e.payload.features_list,a=[];for(const $ of t){const Z=R($);a.push(Z)}const s=tr(o,a,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const u=c?a.find($=>$.sku===c)??a[0]:a[0],d=[];if(Array.isArray(n?.key_differences))for(const $ of n.key_differences)typeof $=="string"&&d.push($);const p=Ar(n?.special_considerations),f=n?.recommended_choice,m=n?.winner_hits,g={};for(const $ of a){const Z=$.sku;Z&&(g[Z]={title:$.name??Z,type:"launchSingleProduct",payload:{sku:Z}})}const y={products:a,attributes:s,highlights:d,productActions:g};return u&&(y.recommended=u),p.length>0&&(y.specialCases=p),f&&(y.recommendedText=f),m&&(y.winnerHits=m),typeof n?.key_differences=="string"&&(y.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(y.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:y}}},panelHint:"panel"}}function tr(e,t,r,n){if(!e)return[];const o=Object.entries(e);if(o.length===0)return[];const i=o[0]?.[1];if(Array.isArray(i)){const p=r.criteria_view??r.criteria_view_short??{},f=r.compared_field_names??Object.keys(e),m=[];for(const g of f){const y=e[g];if(!y||!Array.isArray(y))continue;const $=p[g]??g;m.push({label:$,values:y.map(Z=>typeof Z=="string"?Z:String(Z??""))})}return m}const a=e,s=t.map(p=>String(p.sku??"")).filter(p=>p.length>0),c=r.criteria_view??r.criteria_view_short??{},u=(n&&n.length>0?n:r.compared_field_names&&r.compared_field_names.length>0?r.compared_field_names:rr(a)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),d=[];for(const p of u){const f=s.map(g=>{const y=a[g];if(!y||typeof y!="object")return"";const $=y[`${p}_short`],Z=y[p];return nr($??Z)});if(f.every(g=>g.length===0))continue;const m=c[p]??p;d.push({label:m,values:f})}return d}function rr(e){const t=[],r=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function nr(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function or(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function ir(){return{type:"done"}}function ar(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 sr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function cr(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function ur(e){const t=_(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:_(e.payload.to)}}}function lr(e){return{type:"error",code:"BACKEND_ERROR",message:_(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function dr(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,a=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.type=i),a!==void 0&&(o.theme=a),Qe({type:"quick_qna",payload:o})}const r=I(t.action);if(r){const o={action:r},i=typeof t.text=="string"?t.text:void 0,a=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(o.text=i),a!==void 0&&(o.image_url=a),s!==void 0&&(o.theme=s),Xe({type:"text_image",payload:o})}const n=typeof t.text=="string"?t.text:"";if(n){const o={text:n},i=typeof t.type=="string"?t.type:void 0,a=typeof t.theme=="string"?t.theme:void 0,s=I(t.payload)??void 0;return i!==void 0&&(o.type=i),s!==void 0&&(o.payload=s),a!==void 0&&(o.theme=a),me({type:"text",payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function me(e){const t={text:_(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 fr(e){return Pr(e.payload,"qna")}function Xe(e){const t=_(e.payload.text)??"",r=j(e.payload.action,t);if(r){const o={label:t||r.title,action:r};return typeof e.payload.image_url=="string"&&(o.image=e.payload.image_url),typeof e.payload.theme=="string"&&(o.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:o}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),me({type:"text",payload:n})}function Qe(e){return et((e.payload.action_list??[]).map(t=>{const r=_(t.title)??"",n=j(t.requestDetails,r),o=n?{label:r,action:n}:null;return o?(typeof t.icon=="string"&&(o.icon=t.icon),typeof t.image=="string"&&(o.image=t.image),o):null}).filter(he),"qna")}function mr(e){const t={reviews:(e.payload.reviews??[]).map(r=>{const n={};return typeof r.review_class=="string"&&(n.review_class=r.review_class),typeof r.review_text=="string"&&(n.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(n.review_rating=r.review_rating),typeof r.review_tag=="string"&&(n.review_tag=r.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function hr(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 gr(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function _r(e){const t=e.payload.product_suggestions??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=Ir(o);if(!i)continue;const a={product:i},s=j(o.requestDetails,i.name);s&&(a.action=s),typeof o.role=="string"&&(a.role=o.role),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.review_highlight=="string"&&(a.reviewHighlight=o.review_highlight),Array.isArray(o.labels)&&(a.labels=o.labels),typeof o.expert_quality_score=="number"&&(a.expertQualityScore=o.expert_quality_score),r.push(a)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:r}}}}}}function vr(e){const t=e.payload.product_groupings??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=_(o.name)??"",a=o.sku&&o.sku.length>0?{type:"findSimilar",payload:{sku:o.sku}}:void 0,s=j(o.requestDetails??a,i);if(!s)continue;const c={name:i,action:s};if(Array.isArray(o.labels)){const u=o.labels.filter(d=>typeof d=="string");u.length>0&&(c.labels=u)}typeof o.image=="string"&&(c.image=o.image),r.push(c)}return 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 yr(e){const t=e.payload.suggested_searches??[],r=[];for(let n=0;n<t.length;n++){const o=t[n];if(!o)continue;const i=_(o.short_name,o.chosen_attribute,o.detailed_user_message)??`Search ${n+1}`,a={},s=_(o.detailed_user_message);s&&(a.text=s);const c=I(I(o.requestDetails)?.payload),u=c?.group_skus;o.group_skus&&Array.isArray(o.group_skus)?a.group_skus=o.group_skus:Array.isArray(u)&&(a.group_skus=u.filter(Z=>typeof Z=="string"));const d=_(o.sku,o.representative_product_sku,c?.sku);d&&(a.sku=d),a.is_suggested_text=1;const p={type:"inputText",payload:a},f=j(o.requestDetails,i),m=f?.type==="findSimilar"&&typeof a.text=="string"?j(p,i):f??j(p,i);if(!m)continue;const g={shortName:i,action:m},y=_(o.detailed_user_message);y&&y!==i&&(g.detailedMessage=y);const $=He(o);$&&$!==i&&$!==(y??"")&&(g.whyDifferent=$),typeof o.image=="string"&&(g.image=o.image),r.push(g)}return r.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:r}}}}}}function br(e){const t=e.payload,r=j(t.requestDetails??t.request_details,_(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!r)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:r};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function wr(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function kr(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function zr(e){const t=e.payload.group_list??[],r=[];for(const o of t){const i=o.group_name??"",a=(o.product_list??[]).map(R);r.push({groupName:i,products:a})}const n=[];for(const o of e.payload.filter_tags??[]){const i=o.title??"";if(!i)continue;const a=j(o.requestDetails,i),s={title:i};a&&(s.action=a),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:r,filterTags:n}}}},panelHint:"panel"}}function $r(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Sr(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 Zr(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function et(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`action-${o}`;n.push(a);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),r[a]={type:"ActionButton",props:s}}return r.root={type:"ActionButtons",props:{buttons:e.map(o=>{const i={label:o.label,action:o.action};return o.image!==void 0&&(i.image=o.image),o.description!==void 0&&(i.description=o.description),o.icon!==void 0&&(i.icon=o.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function tt(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=R(i),s=`product-${o}`;n.push(s);const c={product:a,index:o};a.sku&&(c.action={title:a.name,type:"launchSingleProduct",payload:{sku:a.sku}}),r[s]={type:"ProductCard",props:c}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function Or(e,t){const r={},n=[];for(let o=0;o<e.length;o++){const i=e[o];if(!i)continue;const a=`product-${o}`;n.push(a);const s={product:i,index:o},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),r[a]={type:"ProductCard",props:s}}return r.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:r}}}function Pr(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:R(e),index:0}}}}}}function Er(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Ir(e){const t=_(e.sku),r=_(e.short_name),n={...I(e.product_item)??e},o=_(e.discount_reason,e.discountReason);return o&&!_(n.discount_reason,n.discountReason)&&(n.discount_reason=o),rt(n,t,r)}function rt(e,t,r){const n=_(e.sku,t),o=_(e.name,r);if(!n||!o)return null;const i={sku:n,name:o},a=_(e.brand);a&&(i.brand=a);const s=_(e.url);s&&(i.url=s);const c=Tr(e.images);if(c.length>0)i.images=c;else{const y=_(e.image,e.image_url,e.imageUrl);y&&(i.images=[y])}const u=W(e.price_discounted);u!==void 0&&(i.price_discounted=u);const d=W(e.price);d!==void 0&&(i.price=d);const p=W(e.rating);p!==void 0&&(i.rating=p);const f=W(e.review_count)??W(e.reviewCount);f!==void 0&&(i.review_count=f);const m=_(e.cart_code,e.cartCode);m&&(i.cart_code=m),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const g=_(e.discount_reason,e.discountReason);return g&&(i.discount_reason=g),R(i)}function j(e,t){const r=I(e);if(!r)return null;const n=r.type;if(typeof n!="string"||n.length===0)return null;const o={title:t||n,type:n};return r.payload!==void 0&&(o.payload=r.payload),o}function I(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function _(...e){for(const t of e)if(typeof t=="string"){const r=t.trim();if(r.length>0)return r}}function Tr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Ar(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 W(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const r=Number(t);if(Number.isFinite(r))return r}}function he(e){return e!=null}var Nr=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 R(e){const t=e.price_discounted!=null&&e.price_discounted>0,r=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let o;n!=null&&r!=null&&n>0?o=Math.round((n-r)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(o=e.price_discount_rate);const i=_(e.brand),a=_(e.name)??e.sku,s=i&&!a.toLowerCase().startsWith(i.toLowerCase())?`${i} ${a}`:a,c={sku:e.sku,name:s,url:_(e.url)??""},u=e.images?.[0];u&&(c.imageUrl=u),e.images&&e.images.length>1&&(c.images=e.images),r!=null&&(c.price=String(r)),n!=null&&(c.originalPrice=String(n)),o!==void 0&&(c.discountPercent=o),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.short_name!==void 0&&(c.shortName=e.short_name);const d=e,p={};let f=!1;for(const m of Object.keys(d))Nr.has(m)||(p[m]=d[m],f=!0);return f&&(c.extras=p),c}function jr(e){return e.results.map(R)}function Rr(e){return e.product_groupings.map(t=>{const r={name:t.name,products:(t.group_products??[]).map(R)};return t.highlight!==void 0&&(r.highlight=t.highlight),r})}function Cr(e){const t=e.payload.type,{type:r,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}var xr={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function nt(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 Dr(e,t){return`${nt(t?.middlewareUrl)}/chat${xr[e]}`}var Os=Object.freeze({status:"aborted"});function l(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const u=a.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const f=d[p];f in s||(s[f]=u[f].bind(s))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;const u=r?.Parent?new i:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var J=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ot=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},ue={};function C(e){return e&&Object.assign(ue,e),ue}function it(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function le(e,t){return typeof t=="bigint"?t.toString():t}function ge(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function _e(e){return e==null}function ve(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ur(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const a=n.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const i=r>o?r:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}var Ze=Symbol("evaluating");function v(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ze)return n===void 0&&(n=Ze,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function L(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function D(...e){const t={};for(const r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function Oe(e){return JSON.stringify(e)}function Lr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var at="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Fr=ge(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function V(e){if(Q(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Q(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function st(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}var Mr=new Set(["string","number","symbol"]);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function h(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 Jr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Vr={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 qr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return U(e,D(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=r.shape[i])}return L(this,"shape",o),o},checks:[]}))}function Gr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return U(e,D(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return L(this,"shape",o),o},checks:[]}))}function Wr(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const n=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return U(e,D(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return L(this,"shape",n),n}}))}function Br(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");return U(e,D(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return L(this,"shape",r),r}}))}function Kr(e,t){return U(e,D(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return L(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]}))}function Hr(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return U(t,D(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:o[a]}):o[a])}else for(const a in o)i[a]=e?new e({type:"optional",innerType:o[a]}):o[a];return L(this,"shape",i),i},checks:[]}))}function Yr(e,t,r){return U(t,D(t._zod.def,{get shape(){const n=t._zod.def.shape,o={...n};if(r)for(const i in r){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(o[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(const i in n)o[i]=new e({type:"nonoptional",innerType:n[i]});return L(this,"shape",o),o}}))}function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function M(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function H(e){return typeof e=="string"?e:e?.message}function x(e,t,r){const n={...e,path:e.path??[]};return e.message||(n.message=H(e.inst?._zod.def?.error?.(e))??H(t?.error?.(e))??H(r.customError?.(e))??H(r.localeError?.(e))??"Invalid input"),delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function ye(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function K(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var ct=(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,le,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ut=l("$ZodError",ct),lt=l("$ZodError",ct,{Parent:Error});function Xr(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Qr(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){const c=i.path[s];s!==i.path.length-1?a[c]=a[c]||{_errors:[]}:(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))),a=a[c],s++}}};return n(e),r}var be=e=>(t,r,n,o)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new J;if(a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>x(c,i,C())));throw at(s,o?.callee),s}return a.value};var we=e=>async(t,r,n,o)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(o?.Err??e)(a.issues.map(c=>x(c,i,C())));throw at(s,o?.callee),s}return a.value};var ne=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new J;return i.issues.length?{success:!1,error:new(e??ut)(i.issues.map(a=>x(a,o,C())))}:{success:!0,data:i.value}},en=ne(lt),oe=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>x(a,o,C())))}:{success:!0,data:i.value}},tn=oe(lt),rn=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return be(e)(t,r,o)};var nn=e=>(t,r,n)=>be(e)(t,r,n);var on=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return we(e)(t,r,o)};var an=e=>async(t,r,n)=>we(e)(t,r,n);var sn=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ne(e)(t,r,o)};var cn=e=>(t,r,n)=>ne(e)(t,r,n);var un=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return oe(e)(t,r,o)};var ln=e=>async(t,r,n)=>oe(e)(t,r,n);var dn=/^[cC][^\s-]{8,}$/,pn=/^[0-9a-z]+$/,fn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mn=/^[0-9a-vA-V]{20}$/,hn=/^[A-Za-z0-9]{27}$/,gn=/^[a-zA-Z0-9_-]{21}$/,_n=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vn=/^([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})$/,Pe=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)$/,yn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function wn(){return new RegExp(bn,"u")}var kn=/^(?:(?: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])$/,zn=/^(([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}|:))$/,$n=/^((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])$/,Sn=/^(([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])$/,Zn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dt=/^[A-Za-z0-9_-]*$/,On=/^\+[1-9]\d{6,14}$/,pt="(?:(?:\\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])))",Pn=new RegExp(`^${pt}$`);function ft(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 En(e){return new RegExp(`^${ft(e)}$`)}function In(e){const t=ft({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${pt}T(?:${n})$`)}var Tn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},An=/^-?\d+$/,mt=/^-?\d+(?:\.\d+)?$/,Nn=/^(?:true|false)$/i,jn=/^[^A-Z]*$/,Rn=/^[^a-z]*$/,E=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),ht={number:"number",bigint:"bigint",object:"date"},gt=l("$ZodCheckLessThan",(e,t)=>{E.init(e,t);const r=ht[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_t=l("$ZodCheckGreaterThan",(e,t)=>{E.init(e,t);const r=ht[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cn=l("$ZodCheckMultipleOf",(e,t)=>{E.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Ur(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),xn=l("$ZodCheckNumberFormat",(e,t)=>{E.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Vr[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,r&&(s.pattern=An)}),e._zod.check=a=>{const s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Dn=l("$ZodCheckMaxLength",(e,t)=>{var r;E.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!_e(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=ye(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Un=l("$ZodCheckMinLength",(e,t)=>{var r;E.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!_e(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=ye(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ln=l("$ZodCheckLengthEquals",(e,t)=>{var r;E.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!_e(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const a=ye(o),s=i>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ie=l("$ZodCheckStringFormat",(e,t)=>{var r,n;E.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Fn=l("$ZodCheckRegex",(e,t)=>{ie.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Mn=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jn),ie.init(e,t)}),Jn=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rn),ie.init(e,t)}),Vn=l("$ZodCheckIncludes",(e,t)=>{E.init(e,t);const r=q(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),qn=l("$ZodCheckStartsWith",(e,t)=>{E.init(e,t);const r=new RegExp(`^${q(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Gn=l("$ZodCheckEndsWith",(e,t)=>{E.init(e,t);const r=new RegExp(`.*${q(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Wn=l("$ZodCheckOverwrite",(e,t)=>{E.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}}),Bn=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(`
3
- `).filter(o=>o),r=Math.min(...t.map(o=>o.length-o.trimStart().length)),n=t.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of n)this.content.push(o)}compile(){const e=Function,t=this?.args,r=[...(this?.content??[""]).map(n=>` ${n}`)];return new e(...t,r.join(`
4
- `))}},Kn={major:4,minor:3,patch:6},w=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Kn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,s,c)=>{let u=F(a),d;for(const p of s){if(p._zod.def.when){if(!p._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,m=p._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new J;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==f&&(u||(u=F(a,f)))});else{if(a.issues.length===f)continue;u||(u=F(a,f))}}return d?d.then(()=>a):a},i=(a,s,c)=>{if(F(a))return a.aborted=!0,a;const u=o(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new J;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,a,s)):i(u,a,s)}const c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new J;return c.then(u=>o(u,n,s))}return o(c,n,s)}}v(e,"~standard",()=>({validate:o=>{try{const i=en(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return tn(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),ke=l("$ZodString",(e,t)=>{w.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Tn(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),b=l("$ZodStringFormat",(e,t)=>{ie.init(e,t),ke.init(e,t)}),Hn=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=vn),b.init(e,t)}),Yn=l("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Pe(r))}else t.pattern??(t.pattern=Pe());b.init(e,t)}),Xn=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=yn),b.init(e,t)}),Qn=l("$ZodURL",(e,t)=>{b.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),eo=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wn()),b.init(e,t)}),to=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=gn),b.init(e,t)}),ro=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=dn),b.init(e,t)}),no=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=pn),b.init(e,t)}),oo=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=fn),b.init(e,t)}),io=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=mn),b.init(e,t)}),ao=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hn),b.init(e,t)}),so=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=In(t)),b.init(e,t)}),co=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Pn),b.init(e,t)}),uo=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=En(t)),b.init(e,t)}),lo=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_n),b.init(e,t)}),po=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=kn),b.init(e,t),e._zod.bag.format="ipv4"}),fo=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=zn),b.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),mo=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=$n),b.init(e,t)}),ho=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sn),b.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,i]=n;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function vt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var go=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Zn),b.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{vt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function _o(e){if(!dt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/");return vt(t.padEnd(Math.ceil(t.length/4)*4,"="))}var vo=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=dt),b.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{_o(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),yo=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=On),b.init(e,t)});function bo(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var wo=l("$ZodJWT",(e,t)=>{b.init(e,t),e._zod.check=r=>{bo(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),yt=l("$ZodNumber",(e,t)=>{w.init(e,t),e._zod.pattern=e._zod.bag.pattern??mt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),ko=l("$ZodNumberFormat",(e,t)=>{xn.init(e,t),yt.init(e,t)}),zo=l("$ZodBoolean",(e,t)=>{w.init(e,t),e._zod.pattern=Nn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),$o=l("$ZodUnknown",(e,t)=>{w.init(e,t),e._zod.parse=r=>r}),So=l("$ZodNever",(e,t)=>{w.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ee(e,t,r){e.issues.length&&t.issues.push(...M(r,e.issues)),t.value[r]=e.value}var Zo=l("$ZodArray",(e,t)=>{w.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const s=o[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(u=>Ee(u,r,a))):Ee(c,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function ee(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...M(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function bt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Jr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function wt(e,t,r,n,o,i){const a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const p in t){if(s.has(p))continue;if(u==="never"){a.push(p);continue}const f=c.run({value:t[p],issues:[]},n);f instanceof Promise?e.push(f.then(m=>ee(m,r,p,t,d))):ee(f,r,p,t,d)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var Oo=l("$ZodObject",(e,t)=>{if(w.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const s={...a};return Object.defineProperty(t,"shape",{value:s}),s}})}const r=ge(()=>bt(t));v(e._zod,"propValues",()=>{const a=t.shape,s={};for(const c in a){const u=a[c]._zod;if(u.values){s[c]??(s[c]=new Set);for(const d of u.values)s[c].add(d)}}return s});const n=Q,o=t.catchall;let i;e._zod.parse=(a,s)=>{i??(i=r.value);const c=a.value;if(!n(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};const u=[],d=i.shape;for(const p of i.keys){const f=d[p],m=f._zod.optout==="optional",g=f._zod.run({value:c[p],issues:[]},s);g instanceof Promise?u.push(g.then(y=>ee(y,a,p,c,m))):ee(g,a,p,c,m)}return o?wt(u,c,a,s,r.value,e):u.length?Promise.all(u).then(()=>a):a}}),Po=l("$ZodObjectJIT",(e,t)=>{Oo.init(e,t);const r=e._zod.parse,n=ge(()=>bt(t)),o=f=>{const m=new Bn(["shape","payload","ctx"]),g=n.value,y=N=>{const P=Oe(N);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};m.write("const input = payload.value;");const $=Object.create(null);let Z=0;for(const N of g.keys)$[N]=`key_${Z++}`;m.write("const newResult = {};");for(const N of g.keys){const P=$[N],A=Oe(N),Dt=f[N]?._zod?.optout==="optional";m.write(`const ${P} = ${y(N)};`),Dt?m.write(`
5
- if (${P}.issues.length) {
6
- if (${A} in input) {
7
- payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
8
- ...iss,
9
- path: iss.path ? [${A}, ...iss.path] : [${A}]
10
- })));
11
- }
12
- }
13
-
14
- if (${P}.value === undefined) {
15
- if (${A} in input) {
16
- newResult[${A}] = undefined;
17
- }
18
- } else {
19
- newResult[${A}] = ${P}.value;
20
- }
21
-
22
- `):m.write(`
23
- if (${P}.issues.length) {
24
- payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
25
- ...iss,
26
- path: iss.path ? [${A}, ...iss.path] : [${A}]
27
- })));
28
- }
29
-
30
- if (${P}.value === undefined) {
31
- if (${A} in input) {
32
- newResult[${A}] = undefined;
33
- }
34
- } else {
35
- newResult[${A}] = ${P}.value;
36
- }
37
-
38
- `)}m.write("payload.value = newResult;"),m.write("return payload;");const xt=m.compile();return(N,P)=>xt(f,N,P)};let i;const a=Q,s=!ue.jitless,u=s&&Fr.value,d=t.catchall;let p;e._zod.parse=(f,m)=>{p??(p=n.value);const g=f.value;return a(g)?s&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),f=i(f,m),d?wt([],g,f,m,p,e):f):r(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Ie(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!F(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>x(a,n,C())))}),t)}var Eo=l("$ZodUnion",(e,t)=>{w.init(e,t),v(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),v(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),v(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),v(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ve(i.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1;const s=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>Ie(c,o,e,i)):Ie(s,o,e,i)}}),Io=l("$ZodIntersection",(e,t)=>{w.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([s,c])=>Te(r,s,c)):Te(r,i,a)}});function de(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(V(e)&&V(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const a=de(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],a=de(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Te(e,t,r){const n=new Map;let o;for(const s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(const c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(const s of r.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);const i=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),F(e))return e;const a=de(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var To=l("$ZodRecord",(e,t)=>{w.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!V(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a){r.value={};const s=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);const d=t.valueType._zod.run({value:o[u],issues:[]},n);d instanceof Promise?i.push(d.then(p=>{p.issues.length&&r.issues.push(...M(u,p.issues)),r.value[u]=p.value})):(d.issues.length&&r.issues.push(...M(u,d.issues)),r.value[u]=d.value)}let c;for(const u in o)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(const s of Reflect.ownKeys(o)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&mt.test(s)&&c.issues.length){const d=t.keyType._zod.run({value:Number(s),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=o[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>x(d,n,C())),input:s,path:[s],inst:e});continue}const u=t.valueType._zod.run({value:o[s],issues:[]},n);u instanceof Promise?i.push(u.then(d=>{d.issues.length&&r.issues.push(...M(s,d.issues)),r.value[c.value]=d.value})):(u.issues.length&&r.issues.push(...M(s,u.issues)),r.value[c.value]=u.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Ao=l("$ZodEnum",(e,t)=>{w.init(e,t);const r=it(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Mr.has(typeof o)).map(o=>typeof o=="string"?q(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),No=l("$ZodLiteral",(e,t)=>{if(w.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?q(n):n?q(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),jo=l("$ZodTransform",(e,t)=>{w.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ot(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new J;return r.value=o,r}});function Ae(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var kt=l("$ZodOptional",(e,t)=>{w.init(e,t),e._zod.optin="optional",e._zod.optout="optional",v(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),v(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ve(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Ae(i,r.value)):Ae(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Ro=l("$ZodExactOptional",(e,t)=>{kt.init(e,t),v(e._zod,"values",()=>t.innerType._zod.values),v(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Co=l("$ZodNullable",(e,t)=>{w.init(e,t),v(e._zod,"optin",()=>t.innerType._zod.optin),v(e._zod,"optout",()=>t.innerType._zod.optout),v(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${ve(r.source)}|null)$`):void 0}),v(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),xo=l("$ZodDefault",(e,t)=>{w.init(e,t),e._zod.optin="optional",v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Ne(i,t)):Ne(o,t)}});function Ne(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Do=l("$ZodPrefault",(e,t)=>{w.init(e,t),e._zod.optin="optional",v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Uo=l("$ZodNonOptional",(e,t)=>{w.init(e,t),v(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>je(i,e)):je(o,e)}});function je(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 Lo=l("$ZodCatch",(e,t)=>{w.init(e,t),v(e._zod,"optin",()=>t.innerType._zod.optin),v(e._zod,"optout",()=>t.innerType._zod.optout),v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>x(a,n,C()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>x(i,n,C()))},input:r.value}),r.issues=[]),r)}}),Fo=l("$ZodPipe",(e,t)=>{w.init(e,t),v(e._zod,"values",()=>t.in._zod.values),v(e._zod,"optin",()=>t.in._zod.optin),v(e._zod,"optout",()=>t.out._zod.optout),v(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>Y(a,t.in,n)):Y(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>Y(i,t.out,n)):Y(o,t.out,n)}});function Y(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Mo=l("$ZodReadonly",(e,t)=>{w.init(e,t),v(e._zod,"propValues",()=>t.innerType._zod.propValues),v(e._zod,"values",()=>t.innerType._zod.values),v(e._zod,"optin",()=>t.innerType?._zod?.optin),v(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Re):Re(o)}});function Re(e){return e.value=Object.freeze(e.value),e}var Jo=l("$ZodCustom",(e,t)=>{E.init(e,t),w.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>Ce(i,r,n,e));Ce(o,r,n,e)}});function Ce(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(K(o))}}var xe,Vo=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function qo(){return new Vo}(xe=globalThis).__zod_globalRegistry??(xe.__zod_globalRegistry=qo());var B=globalThis.__zod_globalRegistry;function Go(e,t){return new e({type:"string",...h(t)})}function Wo(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...h(t)})}function De(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...h(t)})}function Bo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...h(t)})}function Ko(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...h(t)})}function Ho(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...h(t)})}function Yo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...h(t)})}function Xo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...h(t)})}function Qo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...h(t)})}function ei(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...h(t)})}function ti(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...h(t)})}function ri(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...h(t)})}function ni(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...h(t)})}function oi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...h(t)})}function ii(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...h(t)})}function ai(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...h(t)})}function si(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...h(t)})}function ci(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...h(t)})}function ui(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...h(t)})}function li(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...h(t)})}function di(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...h(t)})}function pi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...h(t)})}function fi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...h(t)})}function mi(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...h(t)})}function hi(e,t){return new e({type:"string",format:"date",check:"string_format",...h(t)})}function gi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...h(t)})}function _i(e,t){return new e({type:"string",format:"duration",check:"string_format",...h(t)})}function vi(e,t){return new e({type:"number",checks:[],...h(t)})}function yi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...h(t)})}function bi(e,t){return new e({type:"boolean",...h(t)})}function wi(e){return new e({type:"unknown"})}function ki(e,t){return new e({type:"never",...h(t)})}function Ue(e,t){return new gt({check:"less_than",...h(t),value:e,inclusive:!1})}function se(e,t){return new gt({check:"less_than",...h(t),value:e,inclusive:!0})}function Le(e,t){return new _t({check:"greater_than",...h(t),value:e,inclusive:!1})}function ce(e,t){return new _t({check:"greater_than",...h(t),value:e,inclusive:!0})}function Fe(e,t){return new Cn({check:"multiple_of",...h(t),value:e})}function zt(e,t){return new Dn({check:"max_length",...h(t),maximum:e})}function te(e,t){return new Un({check:"min_length",...h(t),minimum:e})}function $t(e,t){return new Ln({check:"length_equals",...h(t),length:e})}function zi(e,t){return new Fn({check:"string_format",format:"regex",...h(t),pattern:e})}function $i(e){return new Mn({check:"string_format",format:"lowercase",...h(e)})}function Si(e){return new Jn({check:"string_format",format:"uppercase",...h(e)})}function Zi(e,t){return new Vn({check:"string_format",format:"includes",...h(t),includes:e})}function Oi(e,t){return new qn({check:"string_format",format:"starts_with",...h(t),prefix:e})}function Pi(e,t){return new Gn({check:"string_format",format:"ends_with",...h(t),suffix:e})}function G(e){return new Wn({check:"overwrite",tx:e})}function Ei(e){return G(t=>t.normalize(e))}function Ii(){return G(e=>e.trim())}function Ti(){return G(e=>e.toLowerCase())}function Ai(){return G(e=>e.toUpperCase())}function Ni(){return G(e=>Lr(e))}function ji(e,t,r){return new e({type:"array",element:t,...h(r)})}function Ri(e,t,r){return new e({type:"custom",check:"custom",fn:t,...h(r)})}function Ci(e){const t=xi(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(K(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(K(o))}},e(r.value,r)));return t}function xi(e,t){const r=new E({check:"custom",...h(t)});return r._zod.check=e,r}function St(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??B,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 S(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{const p=a.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,u)}const d=e._zod.parent;d&&(a.ref||(a.ref=d),S(d,t,u),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&O(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Zt(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const a of e.seen.entries()){const s=e.metadataRegistry.get(a[0])?.id;if(s){const c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}const o=a=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(a[0])?.id,p=e.external.uri??(m=>m);if(d)return{ref:p(d)};const f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${p("__shared")}#/${s}/${f}`}}if(a[1]===r)return{ref:"#"};const c=`#/${s}/`,u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},i=a=>{if(a[1].schema.$ref)return;const s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);const d=s.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const a of e.seen.entries()){const s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
39
-
40
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const s=a[1];if(t===a[0]){i(a);continue}if(e.external){const c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function Ot(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const s=e.seen.get(a);if(s.ref===null)return;const c=s.def??s.schema,u={...c},d=s.ref;if(s.ref=null,d){n(d);const f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,u),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(m.$ref&&f.def)for(const g in c)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(c[g])===JSON.stringify(f.def[g])&&delete c[g]}const p=a._zod.parent;if(p&&p!==d){n(p);const f=e.seen.get(p);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(const m in c)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(c[m])===JSON.stringify(f.def[m])&&delete c[m]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())n(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:re(t,"input",e.processors),output:re(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function O(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return O(n.element,r);if(n.type==="set")return O(n.valueType,r);if(n.type==="lazy")return O(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return O(n.innerType,r);if(n.type==="intersection")return O(n.left,r)||O(n.right,r);if(n.type==="record"||n.type==="map")return O(n.keyType,r)||O(n.valueType,r);if(n.type==="pipe")return O(n.in,r)||O(n.out,r);if(n.type==="object"){for(const o in n.shape)if(O(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(O(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(O(o,r))return!0;return!!(n.rest&&O(n.rest,r))}return!1}var Di=(e,t={})=>r=>{const n=St({...r,processors:t});return S(e,n),Zt(n,e),Ot(n,e)},re=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},a=St({...o??{},target:i,io:t,processors:r});return S(e,a),Zt(a,e),Ot(a,e)},Ui={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Li=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=Ui[s]??s,o.format===""&&delete o.format,s==="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(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Fi=(e,t,r,n)=>{const o=r,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},Mi=(e,t,r,n)=>{r.type="boolean"},Ji=(e,t,r,n)=>{r.not={}},Vi=(e,t,r,n)=>{},qi=(e,t,r,n)=>{const o=e._zod.def,i=it(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Gi=(e,t,r,n)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Wi=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Bi=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ki=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=S(i.element,t,{...n,path:[...n.path,"items"]})},Hi=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=S(a[u],t,{...n,path:[...n.path,"properties",u]});const s=new Set(Object.keys(a)),c=new Set([...s].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=S(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Yi=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>S(s,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=a:r.anyOf=a},Xi=(e,t,r,n)=>{const o=e._zod.def,i=S(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=S(o.right,t,{...n,path:[...n.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1;r.allOf=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]]},Qi=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object";const a=i.keyType,s=a._zod.bag?.patterns;if(i.mode==="loose"&&s&&s.size>0){const u=S(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(const d of s)o.patternProperties[d.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=S(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=S(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const c=a._zod.values;if(c){const u=[...c].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(o.required=u)}},ea=(e,t,r,n)=>{const o=e._zod.def,i=S(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},ta=(e,t,r,n)=>{const o=e._zod.def;S(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},ra=(e,t,r,n)=>{const o=e._zod.def;S(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},na=(e,t,r,n)=>{const o=e._zod.def;S(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},oa=(e,t,r,n)=>{const o=e._zod.def;S(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},ia=(e,t,r,n)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;S(i,t,n);const a=t.seen.get(e);a.ref=i},aa=(e,t,r,n)=>{const o=e._zod.def;S(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},Pt=(e,t,r,n)=>{const o=e._zod.def;S(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},sa=l("ZodISODateTime",(e,t)=>{so.init(e,t),z.init(e,t)});function ca(e){return mi(sa,e)}var ua=l("ZodISODate",(e,t)=>{co.init(e,t),z.init(e,t)});function la(e){return hi(ua,e)}var da=l("ZodISOTime",(e,t)=>{uo.init(e,t),z.init(e,t)});function pa(e){return gi(da,e)}var fa=l("ZodISODuration",(e,t)=>{lo.init(e,t),z.init(e,t)});function ma(e){return _i(fa,e)}var Et=(e,t)=>{ut.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Qr(e,r)},flatten:{value:r=>Xr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,le,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,le,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ps=l("ZodError",Et),T=l("ZodError",Et,{Parent:Error}),ha=be(T),ga=we(T),_a=ne(T),va=oe(T),ya=rn(T),ba=nn(T),wa=on(T),ka=an(T),za=sn(T),$a=cn(T),Sa=un(T),Za=ln(T),k=l("ZodType",(e,t)=>(w.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:re(e,"input"),output:re(e,"output")}}),e.toJSONSchema=Di(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(D(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>U(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>ha(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>_a(e,r,n),e.parseAsync=async(r,n)=>ga(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>va(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>ya(e,r,n),e.decode=(r,n)=>ba(e,r,n),e.encodeAsync=async(r,n)=>wa(e,r,n),e.decodeAsync=async(r,n)=>ka(e,r,n),e.safeEncode=(r,n)=>za(e,r,n),e.safeDecode=(r,n)=>$a(e,r,n),e.safeEncodeAsync=async(r,n)=>Sa(e,r,n),e.safeDecodeAsync=async(r,n)=>Za(e,r,n),e.refine=(r,n)=>e.check(Ss(r,n)),e.superRefine=r=>e.check(Zs(r)),e.overwrite=r=>e.check(G(r)),e.optional=()=>Ve(e),e.exactOptional=()=>ps(e),e.nullable=()=>qe(e),e.nullish=()=>Ve(qe(e)),e.nonoptional=r=>vs(e,r),e.array=()=>At(e),e.or=r=>Nt([e,r]),e.and=r=>os(e,r),e.transform=r=>Ge(e,ls(r)),e.default=r=>hs(e,r),e.prefault=r=>_s(e,r),e.catch=r=>bs(e,r),e.pipe=r=>Ge(e,r),e.readonly=()=>zs(e),e.describe=r=>{const n=e.clone();return B.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return B.get(e);const n=e.clone();return B.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),It=l("_ZodString",(e,t)=>{ke.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Li(e,n,o,i);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(zi(...n)),e.includes=(...n)=>e.check(Zi(...n)),e.startsWith=(...n)=>e.check(Oi(...n)),e.endsWith=(...n)=>e.check(Pi(...n)),e.min=(...n)=>e.check(te(...n)),e.max=(...n)=>e.check(zt(...n)),e.length=(...n)=>e.check($t(...n)),e.nonempty=(...n)=>e.check(te(1,...n)),e.lowercase=n=>e.check($i(n)),e.uppercase=n=>e.check(Si(n)),e.trim=()=>e.check(Ii()),e.normalize=(...n)=>e.check(Ei(...n)),e.toLowerCase=()=>e.check(Ti()),e.toUpperCase=()=>e.check(Ai()),e.slugify=()=>e.check(Ni())}),Oa=l("ZodString",(e,t)=>{ke.init(e,t),It.init(e,t),e.email=r=>e.check(Wo(Ea,r)),e.url=r=>e.check(Xo(Ia,r)),e.jwt=r=>e.check(fi(qa,r)),e.emoji=r=>e.check(Qo(Ta,r)),e.guid=r=>e.check(De(Me,r)),e.uuid=r=>e.check(Bo(X,r)),e.uuidv4=r=>e.check(Ko(X,r)),e.uuidv6=r=>e.check(Ho(X,r)),e.uuidv7=r=>e.check(Yo(X,r)),e.nanoid=r=>e.check(ei(Aa,r)),e.guid=r=>e.check(De(Me,r)),e.cuid=r=>e.check(ti(Na,r)),e.cuid2=r=>e.check(ri(ja,r)),e.ulid=r=>e.check(ni(Ra,r)),e.base64=r=>e.check(li(Ma,r)),e.base64url=r=>e.check(di(Ja,r)),e.xid=r=>e.check(oi(Ca,r)),e.ksuid=r=>e.check(ii(xa,r)),e.ipv4=r=>e.check(ai(Da,r)),e.ipv6=r=>e.check(si(Ua,r)),e.cidrv4=r=>e.check(ci(La,r)),e.cidrv6=r=>e.check(ui(Fa,r)),e.e164=r=>e.check(pi(Va,r)),e.datetime=r=>e.check(ca(r)),e.date=r=>e.check(la(r)),e.time=r=>e.check(pa(r)),e.duration=r=>e.check(ma(r))});function Pa(e){return Go(Oa,e)}var z=l("ZodStringFormat",(e,t)=>{b.init(e,t),It.init(e,t)}),Ea=l("ZodEmail",(e,t)=>{Xn.init(e,t),z.init(e,t)}),Me=l("ZodGUID",(e,t)=>{Hn.init(e,t),z.init(e,t)}),X=l("ZodUUID",(e,t)=>{Yn.init(e,t),z.init(e,t)}),Ia=l("ZodURL",(e,t)=>{Qn.init(e,t),z.init(e,t)}),Ta=l("ZodEmoji",(e,t)=>{eo.init(e,t),z.init(e,t)}),Aa=l("ZodNanoID",(e,t)=>{to.init(e,t),z.init(e,t)}),Na=l("ZodCUID",(e,t)=>{ro.init(e,t),z.init(e,t)}),ja=l("ZodCUID2",(e,t)=>{no.init(e,t),z.init(e,t)}),Ra=l("ZodULID",(e,t)=>{oo.init(e,t),z.init(e,t)}),Ca=l("ZodXID",(e,t)=>{io.init(e,t),z.init(e,t)}),xa=l("ZodKSUID",(e,t)=>{ao.init(e,t),z.init(e,t)}),Da=l("ZodIPv4",(e,t)=>{po.init(e,t),z.init(e,t)}),Ua=l("ZodIPv6",(e,t)=>{fo.init(e,t),z.init(e,t)}),La=l("ZodCIDRv4",(e,t)=>{mo.init(e,t),z.init(e,t)}),Fa=l("ZodCIDRv6",(e,t)=>{ho.init(e,t),z.init(e,t)}),Ma=l("ZodBase64",(e,t)=>{go.init(e,t),z.init(e,t)}),Ja=l("ZodBase64URL",(e,t)=>{vo.init(e,t),z.init(e,t)}),Va=l("ZodE164",(e,t)=>{yo.init(e,t),z.init(e,t)}),qa=l("ZodJWT",(e,t)=>{wo.init(e,t),z.init(e,t)}),Tt=l("ZodNumber",(e,t)=>{yt.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Fi(e,n,o,i),e.gt=(n,o)=>e.check(Le(n,o)),e.gte=(n,o)=>e.check(ce(n,o)),e.min=(n,o)=>e.check(ce(n,o)),e.lt=(n,o)=>e.check(Ue(n,o)),e.lte=(n,o)=>e.check(se(n,o)),e.max=(n,o)=>e.check(se(n,o)),e.int=n=>e.check(Je(n)),e.safe=n=>e.check(Je(n)),e.positive=n=>e.check(Le(0,n)),e.nonnegative=n=>e.check(ce(0,n)),e.negative=n=>e.check(Ue(0,n)),e.nonpositive=n=>e.check(se(0,n)),e.multipleOf=(n,o)=>e.check(Fe(n,o)),e.step=(n,o)=>e.check(Fe(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Ga(e){return vi(Tt,e)}var Wa=l("ZodNumberFormat",(e,t)=>{ko.init(e,t),Tt.init(e,t)});function Je(e){return yi(Wa,e)}var Ba=l("ZodBoolean",(e,t)=>{zo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mi(e,r,n,o)});function Ka(e){return bi(Ba,e)}var Ha=l("ZodUnknown",(e,t)=>{$o.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vi(e,r,n,o)});function pe(){return wi(Ha)}var Ya=l("ZodNever",(e,t)=>{So.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ji(e,r,n,o)});function Xa(e){return ki(Ya,e)}var Qa=l("ZodArray",(e,t)=>{Zo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ki(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(te(r,n)),e.nonempty=r=>e.check(te(1,r)),e.max=(r,n)=>e.check(zt(r,n)),e.length=(r,n)=>e.check($t(r,n)),e.unwrap=()=>e.element});function At(e,t){return ji(Qa,e,t)}var es=l("ZodObject",(e,t)=>{Po.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hi(e,r,n,o),v(e,"shape",()=>t.shape),e.keyof=()=>jt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:pe()}),e.loose=()=>e.clone({...e._zod.def,catchall:pe()}),e.strict=()=>e.clone({...e._zod.def,catchall:Xa()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Wr(e,r),e.safeExtend=r=>Br(e,r),e.merge=r=>Kr(e,r),e.pick=r=>qr(e,r),e.omit=r=>Gr(e,r),e.partial=(...r)=>Hr(Rt,e,r[0]),e.required=(...r)=>Yr(Ct,e,r[0])});function ts(e,t){return new es({type:"object",shape:e??{},...h(t)})}var rs=l("ZodUnion",(e,t)=>{Eo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yi(e,r,n,o),e.options=t.options});function Nt(e,t){return new rs({type:"union",options:e,...h(t)})}var ns=l("ZodIntersection",(e,t)=>{Io.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xi(e,r,n,o)});function os(e,t){return new ns({type:"intersection",left:e,right:t})}var is=l("ZodRecord",(e,t)=>{To.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qi(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function as(e,t,r){return new is({type:"record",keyType:e,valueType:t,...h(r)})}var fe=l("ZodEnum",(e,t)=>{Ao.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,i)=>qi(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new fe({...t,checks:[],...h(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new fe({...t,checks:[],...h(o),entries:i})}});function jt(e,t){return new fe({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e,...h(t)})}var ss=l("ZodLiteral",(e,t)=>{No.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gi(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function cs(e,t){return new ss({type:"literal",values:Array.isArray(e)?e:[e],...h(t)})}var us=l("ZodTransform",(e,t)=>{jo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bi(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ot(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(K(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(K(a))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function ls(e){return new us({type:"transform",transform:e})}var Rt=l("ZodOptional",(e,t)=>{kt.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ve(e){return new Rt({type:"optional",innerType:e})}var ds=l("ZodExactOptional",(e,t)=>{Ro.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ps(e){return new ds({type:"optional",innerType:e})}var fs=l("ZodNullable",(e,t)=>{Co.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ea(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function qe(e){return new fs({type:"nullable",innerType:e})}var ms=l("ZodDefault",(e,t)=>{xo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ra(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function hs(e,t){return new ms({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():st(t)}})}var gs=l("ZodPrefault",(e,t)=>{Do.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>na(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function _s(e,t){return new gs({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():st(t)}})}var Ct=l("ZodNonOptional",(e,t)=>{Uo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ta(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function vs(e,t){return new Ct({type:"nonoptional",innerType:e,...h(t)})}var ys=l("ZodCatch",(e,t)=>{Lo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bs(e,t){return new ys({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ws=l("ZodPipe",(e,t)=>{Fo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ia(e,r,n,o),e.in=t.in,e.out=t.out});function Ge(e,t){return new ws({type:"pipe",in:e,out:t})}var ks=l("ZodReadonly",(e,t)=>{Mo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>aa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function zs(e){return new ks({type:"readonly",innerType:e})}var $s=l("ZodCustom",(e,t)=>{Jo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wi(e,r,n,o)});function Ss(e,t={}){return Ri($s,e,t)}function Zs(e){return Ci(e)}Object.defineProperty(exports,"_enum",{enumerable:!0,get:function(){return jt}});Object.defineProperty(exports,"adaptBackendEvent",{enumerable:!0,get:function(){return Wt}});Object.defineProperty(exports,"array",{enumerable:!0,get:function(){return At}});Object.defineProperty(exports,"boolean",{enumerable:!0,get:function(){return Ka}});Object.defineProperty(exports,"buildChatEndpointUrl",{enumerable:!0,get:function(){return Dr}});Object.defineProperty(exports,"consumeStream",{enumerable:!0,get:function(){return Be}});Object.defineProperty(exports,"defaultUnknownUISpecRenderer",{enumerable:!0,get:function(){return We}});Object.defineProperty(exports,"getSuggestedSearchKeywords",{enumerable:!0,get:function(){return Ke}});Object.defineProperty(exports,"getSuggestedSearchKeywordsText",{enumerable:!0,get:function(){return He}});Object.defineProperty(exports,"isConsultingSource",{enumerable:!0,get:function(){return Ye}});Object.defineProperty(exports,"literal",{enumerable:!0,get:function(){return cs}});Object.defineProperty(exports,"mergeUISpecRegistry",{enumerable:!0,get:function(){return Ft}});Object.defineProperty(exports,"normalizeMiddlewareUrl",{enumerable:!0,get:function(){return nt}});Object.defineProperty(exports,"normalizeProductGroupingsResponse",{enumerable:!0,get:function(){return Rr}});Object.defineProperty(exports,"normalizeSimilarProductsResponse",{enumerable:!0,get:function(){return jr}});Object.defineProperty(exports,"number",{enumerable:!0,get:function(){return Ga}});Object.defineProperty(exports,"object",{enumerable:!0,get:function(){return ts}});Object.defineProperty(exports,"productToNormalized",{enumerable:!0,get:function(){return R}});Object.defineProperty(exports,"record",{enumerable:!0,get:function(){return as}});Object.defineProperty(exports,"renderUISpecWithRegistry",{enumerable:!0,get:function(){return Lt}});Object.defineProperty(exports,"streamPost",{enumerable:!0,get:function(){return Jt}});Object.defineProperty(exports,"string",{enumerable:!0,get:function(){return Pa}});Object.defineProperty(exports,"union",{enumerable:!0,get:function(){return Nt}});Object.defineProperty(exports,"unknown",{enumerable:!0,get:function(){return pe}});
@@ -1 +0,0 @@
1
- const n=require("./ga-datalayer-BVppFxqk.cjs");var h={findSimilarLabel:"Benzerlerini Bul"},f={findSimilarLabel:"Find Similar"};function b(t,i){return i?.findSimilarLabel?i.findSimilarLabel:(t??"tr").toLowerCase().startsWith("en")?f.findSimilarLabel:h.findSimilarLabel}function o(t){const i=typeof t.sku=="string"&&t.sku.length>0?t.sku:void 0,r=typeof t.pageContext?.sku=="string"&&t.pageContext.sku.length>0?t.pageContext.sku:void 0;return i??r}var u=class extends n.BaseWidget{constructor(...t){super(...t),this._button=null,this._label=h.findSimilarLabel}async onInit(t){this._label=b(t.locale,t.i18n),this.root.classList.add("gengage-simbut-root"),window.getComputedStyle(this.root).position==="static"&&(this.root.style.position="relative");const i=document.createElement("button");i.type="button",i.className="gengage-chat-find-similar-pill",i.textContent=this._label,this._button=i;const r=()=>{i.disabled=!(o(this.config)&&(this.config.onFindSimilar||this.config.chat))};i.addEventListener("click",c=>{c.stopPropagation();const e=o(this.config);if(!e)return;const a=this.config.imageUrl,s=typeof a=="string"&&n.isSafeUrl(a)?a:void 0;if(n.trackSuggestedQuestion(this._label,"findSimilar"),n.trackFindSimilars(e),this.config.onFindSimilar){this.config.onFindSimilar(s?{sku:e,imageUrl:s}:{sku:e});return}const l=this.config.chat;if(!l)return;const d={title:this._label,type:"findSimilar",payload:s?{sku:e,image_url:s}:{sku:e}};l.openWithAction(d,{sku:e})}),this.root.appendChild(i),r(),n.trackInit("simbut")}onUpdate(t){if(!this._button)return;const i=!!o(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!i}hide(){this.isVisible&&(this.isVisible=!1,this._button&&(this._button.style.display="none"),this.onHide(),this.emit("hide"))}show(){this.isVisible||(this.isVisible=!0,this._button&&(this._button.style.display=""),this.onShow(),this.emit("show"))}_cleanupRoot(){}onShow(){}onHide(){}onDestroy(){this._button?.remove(),this._button=null}setChat(t){if(this.config.chat=t,this._button){const i=!!o(this.config)&&(!!this.config.onFindSimilar||!!this.config.chat);this._button.disabled=!i}}};function g(){return new u}Object.defineProperty(exports,"GengageSimBut",{enumerable:!0,get:function(){return u}});Object.defineProperty(exports,"createSimButWidget",{enumerable:!0,get:function(){return g}});
package/dist/simbut.cjs DELETED
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./simbut-D_ycY_MQ.cjs");exports.GengageSimBut=e.GengageSimBut;exports.createSimButWidget=e.createSimButWidget;
@@ -1 +0,0 @@
1
- const c=require("./schemas-B7jnyzQI.cjs"),b=require("./ga-datalayer-BVppFxqk.cjs"),S=require("./product-utils-DLXQQJbh.cjs"),G=require("./connection-warning-YQiIRXrz.cjs");function R(e){const t=[];for(const n of Object.values(e))if(n.type==="ProductCard"&&n.props){const r=n.props.product??n.props;typeof r.sku=="string"&&typeof r.name=="string"&&t.push(r)}return t}function L(e){const t=e.headers.get("Content-Type")??"";return t.includes("application/x-ndjson")||t.includes("text/event-stream")}async function M(e,t){const n=[],r={onEvent:o=>{const a=c.adaptBackendEvent(o);!a||a.type!=="ui_spec"||n.push(...R(a.spec.elements))}};return t!==void 0&&(r.signal=t),await c.consumeStream(e,r),n}async function B(e,t,n){const r=c.buildChatEndpointUrl("similar_products",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(o.signal=n);const a=await fetch(r,o);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);if(L(a))return M(a,n);const s=await a.text();if(!s)throw new Error("Empty response body from similar_products endpoint");try{return c.normalizeSimilarProductsResponse(JSON.parse(s))}catch{throw new Error("Invalid JSON from similar_products endpoint")}}async function q(e,t){const n=[];let r=null;const o={onEvent:a=>{const s=c.adaptBackendEvent(a);if(s){if(s.type==="metadata"&&s.meta){const l=s.meta.group_name;if(typeof l=="string"){r={name:l,products:[]};const u=s.meta.highlight;typeof u=="string"&&(r.highlight=u),n.push(r)}}s.type==="ui_spec"&&r&&r.products.push(...R(s.spec.elements))}}};return t!==void 0&&(o.signal=t),await c.consumeStream(e,o),n}async function D(e,t,n){const r=c.buildChatEndpointUrl("product_groupings",t),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)};n!==void 0&&(o.signal=n);const a=await fetch(r,o);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);if(L(a))return q(a,n);const s=await a.text();if(!s)return[];try{return c.normalizeProductGroupingsResponse(JSON.parse(s))}catch{throw new Error("Invalid JSON from product_groupings endpoint")}}function N(e){const{product:t,index:n,discountType:r,onClick:o,onAddToCart:a,renderCard:s}=e,l=e.i18n,u=e.pricing;if(e.renderCardElement){const i=e.renderCardElement(t,n);if(i)return i}if(s){const i=document.createElement("div");return i.className="gengage-simrel-card gengage-simrel-card--custom gds-card gds-product-card gds-card-interactive",i.dataset.gengagePart="simrel-product-card",i.innerHTML=b.sanitizeHtml(s(t,n)),i.addEventListener("click",p=>{p.target.closest(".gengage-simrel-atc")||p.target.closest(".gengage-chat-product-card-atc")||o(t)}),i}const d=document.createElement("article");d.className="gengage-simrel-card gengage-chat-product-card gds-card gds-product-card gds-card-interactive",d.dataset.gengagePart="simrel-product-card",t.inStock===!1&&d.classList.add("gengage-simrel-card--out-of-stock"),d.setAttribute("role","listitem"),d.dataset.sku=t.sku;const g=document.createElement("div");if(g.className="gengage-simrel-card-image gengage-chat-product-card-img-wrapper",g.dataset.gengagePart="simrel-product-card-image",t.imageUrl&&b.isSafeImageUrl(t.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.src=t.imageUrl,i.alt=t.name,i.loading="lazy",S.addImageErrorHandler(i),g.appendChild(i)}if(r==="badge"&&t.discountPercent&&t.discountPercent>0){const i=document.createElement("span");i.className="gengage-simrel-badge gengage-chat-product-card-discount-badge",i.textContent=`%${S.clampDiscount(t.discountPercent)}`,g.appendChild(i)}d.appendChild(g);const f=document.createElement("div");if(f.className="gengage-simrel-card-info gengage-chat-product-card-body",f.dataset.gengagePart="simrel-product-card-body",t.brand){const i=document.createElement("div");i.className="gengage-simrel-card-brand gengage-chat-product-card-brand",i.textContent=t.brand,f.appendChild(i)}const h=document.createElement("div");if(h.className="gengage-simrel-card-name gengage-chat-product-card-name",h.textContent=t.name,h.title=t.name,f.appendChild(h),t.rating!=null&&t.rating>0){const i=document.createElement("div");if(i.className="gengage-simrel-card-rating gengage-chat-product-card-rating",i.appendChild(S.createStarRatingElement(t.rating)),t.reviewCount!=null){const p=document.createElement("span");p.className="gengage-simrel-card-review-count gengage-chat-product-card-review-count",p.textContent=` (${t.reviewCount})`,i.appendChild(p)}f.appendChild(i)}const v=document.createElement("div");if(v.className="gengage-simrel-card-price gengage-chat-product-card-price",t.originalPrice&&t.originalPrice!==t.price&&(r==="strike-through"||!r)){const i=document.createElement("span");i.className="gengage-simrel-card-price-original gengage-chat-product-card-original-price",i.textContent=S.formatPrice(t.originalPrice,u),v.appendChild(i)}if(t.price&&parseFloat(t.price)>0){const i=document.createElement("span");i.className="gengage-simrel-card-price-current gengage-chat-product-card-price-current",i.textContent=S.formatPrice(t.price,u),v.appendChild(i)}f.appendChild(v),d.appendChild(f);const y=document.createElement("button");if(y.className="gengage-simrel-card-cta gengage-chat-product-card-cta gds-btn gds-btn-secondary",y.type="button",y.dataset.gengagePart="simrel-product-card-cta",y.textContent=l?.ctaLabel??"View",y.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),o(t)}),d.appendChild(y),t.inStock===!1){const i=document.createElement("div");i.className="gengage-simrel-card-oos",i.textContent=l?.outOfStockLabel??"Out of Stock",d.appendChild(i)}else if(t.cartCode){const i=document.createElement("button");i.className="gengage-simrel-atc gengage-simrel-atc-button gds-btn gds-btn-secondary",i.type="button",i.textContent=l?.addToCartButton??"Add to Cart",i.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),a({sku:t.sku,quantity:1,cartCode:t.cartCode})}),d.appendChild(i)}return d.addEventListener("click",i=>{i.target.closest(".gengage-simrel-atc")||i.target.closest(".gengage-chat-product-card-atc")||i.target.closest(".gengage-chat-product-card-cta")||o(t)}),d}function P(e){const t=document.createElement("div");t.className="gengage-simrel-grid",t.setAttribute("role","list"),t.setAttribute("aria-label",e.i18n?.similarProductsAriaLabel??"Similar products"),e.columns&&t.style.setProperty("--gengage-simrel-columns",String(e.columns));for(let n=0;n<e.products.length;n++){const r={product:e.products[n],index:n,onClick:e.onClick,onAddToCart:e.onAddToCart};e.i18n!==void 0&&(r.i18n=e.i18n),e.discountType!==void 0&&(r.discountType=e.discountType),e.renderCard!==void 0&&(r.renderCard=e.renderCard),e.renderCardElement!==void 0&&(r.renderCardElement=e.renderCardElement);const o=N(r);t.appendChild(o)}return e.products.length===0&&(t.style.display="none",t.dataset.empty="true"),t}var H=0;function F(e){const t=H++,n=document.createElement("div");if(n.className="gengage-simrel-groups",n.dataset.gengagePart="simrel-groups",e.groups.length===0)return n.style.display="none",n.dataset.empty="true",n;const r=document.createElement("div");r.className="gengage-simrel-tabs gds-toolbar",r.dataset.gengagePart="simrel-tab-bar",r.setAttribute("role","tablist");const o=[],a=[],s=i=>{const p={products:i.products,onClick:e.onClick,onAddToCart:e.onAddToCart};return e.i18n!==void 0&&(p.i18n=e.i18n),e.discountType!==void 0&&(p.discountType=e.discountType),e.renderCard!==void 0&&(p.renderCard=e.renderCard),e.renderCardElement!==void 0&&(p.renderCardElement=e.renderCardElement),e.columns!==void 0&&(p.columns=e.columns),p},l=i=>{for(let m=0;m<o.length;m++){const C=m===i;o[m].classList.toggle("gengage-simrel-tab--active",C),o[m].setAttribute("aria-selected",String(C)),o[m].tabIndex=C?0:-1}const p=e.groups[i],E=a[i];E.innerHTML="";const w=P(s(p));E.appendChild(w);for(let m=0;m<a.length;m++){const C=m===i;a[m].style.display=C?"":"none",a[m].tabIndex=C?0:-1}};for(let i=0;i<e.groups.length;i++){const p=e.groups[i],E=`gengage-simrel-tab-${t}-${i}`,w=`gengage-simrel-panel-${t}-${i}`,m=document.createElement("button");m.className="gengage-simrel-tab gds-tab",m.type="button",m.dataset.gengagePart="simrel-tab",m.id=E,m.textContent=p.name,m.setAttribute("role","tab"),m.setAttribute("aria-controls",w),m.setAttribute("aria-selected",String(i===0)),m.tabIndex=i===0?0:-1,i===0&&m.classList.add("gengage-simrel-tab--active"),m.addEventListener("click",()=>l(i)),m.addEventListener("keydown",_=>{let k=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?k=(i+1)%e.groups.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?k=(i-1+e.groups.length)%e.groups.length:_.key==="Home"?k=0:_.key==="End"&&(k=e.groups.length-1),k>=0&&(_.preventDefault(),l(k),o[k].focus())}),o.push(m),r.appendChild(m);const C=document.createElement("div");C.className="gengage-simrel-tab-panel",C.dataset.gengagePart="simrel-tab-panel",C.id=w,C.setAttribute("role","tabpanel"),C.setAttribute("aria-labelledby",E),C.tabIndex=i===0?0:-1,i!==0&&(C.style.display="none"),a.push(C)}const u=document.createElement("button");u.type="button",u.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--left",u.setAttribute("aria-label",e.i18n?.scrollTabsLeft??"Scroll tabs left"),u.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>';const d=document.createElement("button");d.type="button",d.className="gengage-simrel-tabs-arrow gengage-simrel-tabs-arrow--right",d.setAttribute("aria-label",e.i18n?.scrollTabsRight??"Scroll tabs right"),d.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';const g=200;u.addEventListener("click",()=>{r.scrollBy({left:-g,behavior:"smooth"})}),d.addEventListener("click",()=>{r.scrollBy({left:g,behavior:"smooth"})});const f=()=>{const i=r.scrollLeft<=4,p=r.scrollLeft+r.clientWidth>=r.scrollWidth-4;u.style.display=i?"none":"",d.style.display=p?"none":"",r.classList.toggle("gengage-simrel-tabs--peek-right",!p),r.classList.toggle("gengage-simrel-tabs--peek-left",!i)};r.addEventListener("scroll",f,{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(f).observe(r),u.style.display="none",d.style.display="none",requestAnimationFrame(f);const h=document.createElement("div");h.className="gengage-simrel-tabs-wrapper",h.appendChild(u),h.appendChild(r),h.appendChild(d),n.appendChild(h);const v=a[0],y=P(s(e.groups[0]));v.appendChild(y);for(const i of a)n.appendChild(i);return n}function A(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.sku!="string"||typeof t.name!="string"||typeof t.url!="string")return null;const n={sku:t.sku,name:t.name,url:t.url},r=t.imageUrl;typeof r=="string"&&(n.imageUrl=r);const o=t.price;typeof o=="string"&&(n.price=o);const a=t.originalPrice;typeof a=="string"&&(n.originalPrice=a);const s=t.discountPercent;typeof s=="number"&&(n.discountPercent=s);const l=t.brand;typeof l=="string"&&(n.brand=l);const u=t.rating;typeof u=="number"&&(n.rating=u);const d=t.reviewCount;typeof d=="number"&&(n.reviewCount=d);const g=t.cartCode;typeof g=="string"&&(n.cartCode=g);const f=t.inStock;typeof f=="boolean"&&(n.inStock=f);const h=t.extras;return h!=null&&typeof h=="object"&&(n.extras=h),n}function z(e){if(!e||typeof e!="object")return null;const t=e,n=t.title,r=t.type;if(typeof n!="string"||typeof r!="string")return null;const o={title:n,type:r};return t.payload!==void 0&&(o.payload=t.payload),o}var I={ProductGrid:({element:e,renderElement:t,context:n})=>{const r=document.createElement("div");r.className="gengage-simrel-grid",r.setAttribute("role","list");const o=e.props?.columns;let a;typeof o=="number"&&Number.isFinite(o)&&o>0?a=Math.floor(o):typeof n.gridColumns=="number"&&Number.isFinite(n.gridColumns)&&n.gridColumns>0&&(a=Math.floor(n.gridColumns)),a!==void 0&&r.style.setProperty("--gengage-simrel-columns",String(a));for(const s of e.children??[]){const l=t(s);l&&r.appendChild(l)}if(r.children.length===0){const s=document.createElement("div");s.className="gengage-simrel-empty",s.textContent=n.i18n.emptyStateMessage,r.appendChild(s)}return r},ProductCard:({element:e,context:t})=>{const n=A(e.props?.product??e.props);if(!n)return null;const r=e.props?.index,o=typeof r=="number"&&Number.isFinite(r)?r:0,a=e.props?.discountType,s=a==="strike-through"||a==="badge"?a:t.discountType,l={product:n,index:o,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n};return s!==void 0&&(l.discountType=s),t.renderCard!==void 0&&(l.renderCard=t.renderCard),t.renderCardElement!==void 0&&(l.renderCardElement=t.renderCardElement),t.pricing!==void 0&&(l.pricing=t.pricing),N(l)},GroupTabs:({element:e,context:t})=>{const n=e.props?.groups;if(!Array.isArray(n))return null;const r=[];for(const s of n){if(!s||typeof s!="object")continue;const l=s;if(typeof l.name!="string")continue;const u=[];if(Array.isArray(l.products))for(const g of l.products){const f=A(g);f&&u.push(f)}const d={name:l.name,products:u};typeof l.highlight=="string"&&(d.highlight=l.highlight),r.push(d)}const o={groups:r,onClick:t.onClick,onAddToCart:t.onAddToCart,i18n:t.i18n},a=e.props?.columns;return typeof a=="number"&&Number.isFinite(a)&&a>0?o.columns=Math.floor(a):typeof t.gridColumns=="number"&&Number.isFinite(t.gridColumns)&&t.gridColumns>0&&(o.columns=Math.floor(t.gridColumns)),t.discountType!==void 0&&(o.discountType=t.discountType),t.renderCard!==void 0&&(o.renderCard=t.renderCard),t.renderCardElement!==void 0&&(o.renderCardElement=t.renderCardElement),F(o)},EmptyState:({element:e,context:t})=>{const n=document.createElement("div");n.className="gengage-simrel-empty";const r=e.props?.message;return n.textContent=typeof r=="string"?r:t.i18n.emptyStateMessage,n},AddToCartButton:({element:e,context:t})=>{const n=e.props?.sku,r=e.props?.cartCode;if(typeof n!="string"||typeof r!="string")return null;const o=document.createElement("button");o.className="gengage-simrel-atc gengage-chat-product-card-cta",o.type="button";const a=e.props?.label;return o.textContent=typeof a=="string"?a:t.i18n.addToCartButton,o.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),t.onAddToCart({sku:n,quantity:1,cartCode:r})}),o},QuickActions:({element:e,context:t})=>{const n=document.createElement("div");n.className="gengage-simrel-quick-actions";const r=e.props?.actions;if(!Array.isArray(r)||!t.onAction)return n;for(const o of r){if(!o||typeof o!="object")continue;const a=o,s=a.label,l=z(a.action);if(typeof s!="string"||!l)continue;const u=document.createElement("button");u.className="gengage-simrel-quick-action",u.type="button",u.textContent=s,u.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),t.onAction?.(l)}),n.appendChild(u)}return n}},T=({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 U(){return{...I}}function O(e,t,n=I,r=T){return c.renderUISpecWithRegistry({spec:e,context:t,registry:n,containerClassName:"gengage-simrel-uispec",unknownRenderer:r})}var x={similarProductsAriaLabel:"Benzer ürünler",emptyStateMessage:"Benzer ürün bulunamadı.",addToCartButton:"Sepete Ekle",ctaLabel:"İncele",outOfStockLabel:"Stokta Yok",decreaseLabel:"Azalt",increaseLabel:"Artır",errorLoadingMessage:"Benzer ürünler yüklenemedi.",retryButtonText:"Tekrar dene",priceSuffix:" TL",scrollTabsLeft:"Sola kaydır",scrollTabsRight:"Sağa kaydır"},$={similarProductsAriaLabel:"Similar products",emptyStateMessage:"No similar products found.",addToCartButton:"Add to cart",ctaLabel:"View",outOfStockLabel:"Out of Stock",decreaseLabel:"Decrease",increaseLabel:"Increase",errorLoadingMessage:"Could not load similar products.",retryButtonText:"Try again",priceSuffix:"",scrollTabsLeft:"Scroll tabs left",scrollTabsRight:"Scroll tabs right"};function W(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function J(e){return W(e)==="en"?$:x}var Q=c.object({sku:c.string(),name:c.string(),imageUrl:c.string().url().optional(),price:c.string().optional(),originalPrice:c.string().optional(),discountPercent:c.number().optional(),url:c.string().url(),brand:c.string().optional(),rating:c.number().min(0).max(5).optional(),reviewCount:c.number().int().nonnegative().optional()}),Y=c.object({layout:c._enum(["grid","carousel"]).optional(),columns:c.number().int().positive().optional()}),V=c.object({product:Q,index:c.number().int().nonnegative(),discountType:c._enum(["strike-through","badge"]).optional()}),K=c.object({sku:c.string(),label:c.string().optional(),cartCode:c.string()}),X=c.object({actions:c.array(c.object({label:c.string(),action:c.object({title:c.string(),type:c.string(),payload:c.unknown().optional()})}))}),Z=c.object({message:c.string().optional()}),ee={components:{ProductGrid:{schema:Y,description:"Outer grid or carousel container for similar products."},ProductCard:{schema:V,description:"A single product card with image, title, price, and actions."},AddToCartButton:{schema:K,description:"Add-to-cart CTA rendered inside or below a product card."},QuickActions:{schema:X,description:"A row of quick-action buttons below product info."},EmptyState:{schema:Z,description:"Empty state shown when no similar products are available."}}},j=class extends b.BaseWidget{constructor(...e){super(...e),this._abortController=null,this._contentEl=null,this._lastResultCount=-1,this._i18n=x}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-simrel-container",this._contentEl.dataset.gengagePart="simrel-container";const t=this._clampGridColumns(e.gridColumns);t!==void 0&&this._contentEl.style.setProperty("--gengage-simrel-columns",String(t)),this.root.appendChild(this._contentEl),this._lastSku=e.sku,await this._fetchAndRender(e.sku),b.trackInit("simrel")}onUpdate(e){const t=e.sku;!t||t===this._lastSku&&this._lastResultCount!==0||(this._lastSku=t,this._fetchAndRender(t))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.3s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._contentEl&&(this._contentEl.remove(),this._contentEl=null)}_handleProductClick(e){const t={sku:e.sku,name:e.name,url:e.url};if(e.imageUrl!==void 0&&(t.imageUrl=e.imageUrl),e.price!==void 0&&(t.price=e.price),e.originalPrice!==void 0&&(t.originalPrice=e.originalPrice),e.discountPercent!==void 0&&(t.discountPercent=e.discountPercent),e.brand!==void 0&&(t.brand=e.brand),e.rating!==void 0&&(t.rating=e.rating),e.reviewCount!==void 0&&(t.reviewCount=e.reviewCount),e.cartCode!==void 0&&(t.cartCode=e.cartCode),e.inStock!==void 0&&(t.inStock=e.inStock),this.config.onProductClick?.(t)===!1)return;b.trackProductDetail(e.sku,e.name);const n=this.config.session?.sessionId??null;b.dispatch("gengage:similar:product-click",{sku:e.sku,url:e.url,sessionId:n}),this.config.onProductNavigate?.(e.url,e.sku,n)}_handleAddToCart(e){b.trackCartAdd(e.sku,e.quantity),this.config.onAddToCart?.(e),b.dispatch("gengage:similar:add-to-cart",e),this.track(b.basketAddEvent(this.analyticsContext(),{attribution_source:"simrel",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:e.quantity,sku:e.sku}))}_abort(){this._abortController?.abort(),this._abortController=null}_isSuperseded(e){return this._abortController?.signal!==e}async _fetchAndRender(e){this._abort(),this._abortController=new AbortController;const t=this._abortController.signal,n=setTimeout(()=>this._abortController?.abort(),1e4);if(t.addEventListener("abort",()=>clearTimeout(n)),!this._contentEl)return;this._contentEl.innerHTML="",this._contentEl.style.display="";const r=document.createElement("div");r.className="gengage-simrel-loading",r.dataset.gengagePart="simrel-loading";const o=document.createElement("div");o.className="gengage-simrel-spinner",o.dataset.gengagePart="simrel-loading-spinner",r.appendChild(o),this._contentEl.appendChild(r);const a={middlewareUrl:this.config.middlewareUrl},s=crypto.randomUUID(),l=Date.now(),u=G.trackConnectionWarningRequest({source:"simrel",locale:this.config.locale});this.track(b.streamStartEvent(this.analyticsContext(),{endpoint:"similar_products",request_id:s,widget:"simrel"}));try{const d={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e};this.config.domain!==void 0&&(d.domain=this.config.domain);const g=await B(d,a,t);if(this._lastResultCount=g.length,!this._contentEl)return;if(this._contentEl.innerHTML="",g.length>0)try{const f=g.map(y=>y.sku),h=new Map(g.map(y=>[y.sku,y])),v=(await D({account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",skus:f},a,t)).map(y=>({...y,products:y.products.map(i=>({...h.get(i.sku),...i})).filter(i=>typeof i.sku=="string"&&typeof i.name=="string"&&typeof i.url=="string")})).filter(y=>y.products.length>0);if(v.length>0&&this._contentEl){const y=this._buildGroupsSpec(v),i=this._renderUISpec(y);this._contentEl.appendChild(i),b.trackShow("simrel"),this.track(b.streamDoneEvent(this.analyticsContext(),{request_id:s,latency_ms:Date.now()-l,chunk_count:v.reduce((p,E)=>p+E.products.length,0),widget:"simrel"})),this.track(b.widgetHistorySnapshotEvent(this.analyticsContext(),{message_count:v.reduce((p,E)=>p+E.products.length,0),history_ref:s,redaction_level:"none",widget:"simrel"}));return}}catch{}if(this._isSuperseded(t))return;if(this._contentEl){const f=this._buildProductsSpec(g),h=this._renderUISpec(f);this._contentEl.appendChild(h)}g.length>0&&b.trackShow("simrel"),this.track(b.streamDoneEvent(this.analyticsContext(),{request_id:s,latency_ms:Date.now()-l,chunk_count:g.length,widget:"simrel"})),this.track(b.widgetHistorySnapshotEvent(this.analyticsContext(),{message_count:g.length,history_ref:s,redaction_level:"none",widget:"simrel"}))}catch(d){if(d instanceof DOMException&&d.name==="AbortError"&&this._isSuperseded(t))return;if(b.dispatch("gengage:global:error",{source:"simrel",code:"FETCH_ERROR",message:b.getGlobalErrorMessage(this.config.locale,d)}),this.track(b.streamErrorEvent(this.analyticsContext(),{request_id:s,error_code:"FETCH_ERROR",error_message:d instanceof Error?d.message:String(d),widget:"simrel"})),this._contentEl){this._contentEl.innerHTML="";const g=document.createElement("div");g.className="gengage-simrel-error";const f=document.createElement("span");f.textContent=this._i18n.errorLoadingMessage,g.appendChild(f);const h=document.createElement("button");h.className="gengage-simrel-retry",h.textContent=this._i18n.retryButtonText,h.addEventListener("click",()=>{this._fetchAndRender(this.config.sku)}),g.appendChild(h),this._contentEl.appendChild(g)}}finally{u()}}_clampGridColumns(e){if(!(e===void 0||typeof e!="number"||!Number.isFinite(e)))return Math.max(1,Math.min(12,Math.floor(e)))}_resolveI18n(e){return{...J(e.locale),...e.i18n}}_resolveUISpecRegistry(){return c.mergeUISpecRegistry(U(),this.config.renderer?.registry)}_buildRenderContext(){const e=this.config.renderCard,t={onClick:r=>this._handleProductClick(r),onAddToCart:r=>this._handleAddToCart(r),i18n:this._i18n};this.config.discountType!==void 0&&(t.discountType=this.config.discountType),e!==void 0&&(t.renderCard=e),this.config.renderCardElement!==void 0&&(t.renderCardElement=this.config.renderCardElement),this.config.pricing!==void 0&&(t.pricing=this.config.pricing);const n=this._clampGridColumns(this.config.gridColumns);return n!==void 0&&(t.gridColumns=n),t}_renderUISpec(e){const t=this._resolveUISpecRegistry(),n=this._buildRenderContext(),r=this.config.renderer?.unknownRenderer??T,o=(s,l)=>O(s,l,t,r),a=this.config.renderer?.renderUISpec;return a?a(e,n,{registry:t,unknownRenderer:r,defaultRender:o}):o(e,n)}_buildProductsSpec(e){const t={},n=[];for(let a=0;a<e.length;a++){const s=e[a],l=`product-${a}`;n.push(l),t[l]={type:"ProductCard",props:{product:s,index:a,discountType:this.config.discountType}}}const r={layout:"grid"},o=this._clampGridColumns(this.config.gridColumns);return o!==void 0&&(r.columns=o),t.root={type:"ProductGrid",props:r,children:n},{root:"root",elements:t}}_buildGroupsSpec(e){return{root:"root",elements:{root:{type:"GroupTabs",props:{groups:e}}}}}};function te(){return new j}Object.defineProperty(exports,"GengageSimRel",{enumerable:!0,get:function(){return j}});Object.defineProperty(exports,"createDefaultSimRelUISpecRegistry",{enumerable:!0,get:function(){return U}});Object.defineProperty(exports,"createSimRelWidget",{enumerable:!0,get:function(){return te}});Object.defineProperty(exports,"defaultSimRelUnknownUISpecRenderer",{enumerable:!0,get:function(){return T}});Object.defineProperty(exports,"renderSimRelUISpec",{enumerable:!0,get:function(){return O}});Object.defineProperty(exports,"simRelCatalog",{enumerable:!0,get:function(){return ee}});
package/dist/simrel.cjs DELETED
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./simrel-DdP4lur9.cjs");exports.GengageSimRel=e.GengageSimRel;exports.createDefaultSimRelUISpecRegistry=e.createDefaultSimRelUISpecRegistry;exports.createSimRelWidget=e.createSimRelWidget;exports.defaultSimRelUnknownUISpecRenderer=e.defaultSimRelUnknownUISpecRenderer;exports.renderSimRelUISpec=e.renderSimRelUISpec;exports.simRelCatalog=e.simRelCatalog;