@gengage/assistant-fe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +61 -0
- package/README.md +232 -0
- package/dist/assistant-fe.css +1 -0
- package/dist/chat/api.d.ts +87 -0
- package/dist/chat/api.d.ts.map +1 -0
- package/dist/chat/attachment-utils.d.ts +10 -0
- package/dist/chat/attachment-utils.d.ts.map +1 -0
- package/dist/chat/catalog.d.ts +1114 -0
- package/dist/chat/catalog.d.ts.map +1 -0
- package/dist/chat/components/AIGroupingCards.d.ts +4 -0
- package/dist/chat/components/AIGroupingCards.d.ts.map +1 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts +4 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts.map +1 -0
- package/dist/chat/components/AITopPicks.d.ts +4 -0
- package/dist/chat/components/AITopPicks.d.ts.map +1 -0
- package/dist/chat/components/CategoriesContainer.d.ts +4 -0
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -0
- package/dist/chat/components/ChatDrawer.d.ts +140 -0
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -0
- package/dist/chat/components/ChoicePrompter.d.ts +16 -0
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -0
- package/dist/chat/components/ComparisonTable.d.ts +47 -0
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts +11 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts.map +1 -0
- package/dist/chat/components/GroundingReviewCard.d.ts +4 -0
- package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -0
- package/dist/chat/components/KvkkBanner.d.ts +6 -0
- package/dist/chat/components/KvkkBanner.d.ts.map +1 -0
- package/dist/chat/components/Launcher.d.ts +25 -0
- package/dist/chat/components/Launcher.d.ts.map +1 -0
- package/dist/chat/components/PanelTopBar.d.ts +20 -0
- package/dist/chat/components/PanelTopBar.d.ts.map +1 -0
- package/dist/chat/components/ProactivePopup.d.ts +11 -0
- package/dist/chat/components/ProactivePopup.d.ts.map +1 -0
- package/dist/chat/components/ProsAndCons.d.ts +9 -0
- package/dist/chat/components/ProsAndCons.d.ts.map +1 -0
- package/dist/chat/components/ReviewHighlights.d.ts +3 -0
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -0
- package/dist/chat/components/ThumbnailsColumn.d.ts +23 -0
- package/dist/chat/components/ThumbnailsColumn.d.ts.map +1 -0
- package/dist/chat/components/actionClassifier.d.ts +13 -0
- package/dist/chat/components/actionClassifier.d.ts.map +1 -0
- package/dist/chat/components/productMentionLinker.d.ts +26 -0
- package/dist/chat/components/productMentionLinker.d.ts.map +1 -0
- package/dist/chat/components/renderUISpec.d.ts +15 -0
- package/dist/chat/components/renderUISpec.d.ts.map +1 -0
- package/dist/chat/components/typewriter.d.ts +25 -0
- package/dist/chat/components/typewriter.d.ts.map +1 -0
- package/dist/chat/extendedModeManager.d.ts +33 -0
- package/dist/chat/extendedModeManager.d.ts.map +1 -0
- package/dist/chat/index.d.ts +192 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/locales/en.d.ts +3 -0
- package/dist/chat/locales/en.d.ts.map +1 -0
- package/dist/chat/locales/index.d.ts +6 -0
- package/dist/chat/locales/index.d.ts.map +1 -0
- package/dist/chat/locales/tr.d.ts +3 -0
- package/dist/chat/locales/tr.d.ts.map +1 -0
- package/dist/chat/types.d.ts +212 -0
- package/dist/chat/types.d.ts.map +1 -0
- package/dist/chat.cjs +2 -0
- package/dist/chat.cjs.map +1 -0
- package/dist/chat.iife.js +59 -0
- package/dist/chat.iife.js.map +1 -0
- package/dist/chat.js +11 -0
- package/dist/chat.js.map +1 -0
- package/dist/common/action-router.d.ts +30 -0
- package/dist/common/action-router.d.ts.map +1 -0
- package/dist/common/activity-tracker.d.ts +38 -0
- package/dist/common/activity-tracker.d.ts.map +1 -0
- package/dist/common/analytics-events.d.ts +90 -0
- package/dist/common/analytics-events.d.ts.map +1 -0
- package/dist/common/analytics.d.ts +58 -0
- package/dist/common/analytics.d.ts.map +1 -0
- package/dist/common/api-paths.d.ts +14 -0
- package/dist/common/api-paths.d.ts.map +1 -0
- package/dist/common/client.d.ts +20 -0
- package/dist/common/client.d.ts.map +1 -0
- package/dist/common/communication-bridge.d.ts +51 -0
- package/dist/common/communication-bridge.d.ts.map +1 -0
- package/dist/common/config-schema.d.ts +241 -0
- package/dist/common/config-schema.d.ts.map +1 -0
- package/dist/common/context.d.ts +28 -0
- package/dist/common/context.d.ts.map +1 -0
- package/dist/common/customization-factories.d.ts +63 -0
- package/dist/common/customization-factories.d.ts.map +1 -0
- package/dist/common/events.d.ts +47 -0
- package/dist/common/events.d.ts.map +1 -0
- package/dist/common/global-error-toast.d.ts +6 -0
- package/dist/common/global-error-toast.d.ts.map +1 -0
- package/dist/common/index.d.ts +36 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/indexed-db.d.ts +74 -0
- package/dist/common/indexed-db.d.ts.map +1 -0
- package/dist/common/overlay.d.ts +64 -0
- package/dist/common/overlay.d.ts.map +1 -0
- package/dist/common/preflight.d.ts +12 -0
- package/dist/common/preflight.d.ts.map +1 -0
- package/dist/common/renderer/dom.d.ts +4 -0
- package/dist/common/renderer/dom.d.ts.map +1 -0
- package/dist/common/renderer/index.d.ts +5 -0
- package/dist/common/renderer/index.d.ts.map +1 -0
- package/dist/common/renderer/overrides.d.ts +24 -0
- package/dist/common/renderer/overrides.d.ts.map +1 -0
- package/dist/common/renderer/registry.d.ts +3 -0
- package/dist/common/renderer/registry.d.ts.map +1 -0
- package/dist/common/renderer/types.d.ts +20 -0
- package/dist/common/renderer/types.d.ts.map +1 -0
- package/dist/common/safe-html.d.ts +19 -0
- package/dist/common/safe-html.d.ts.map +1 -0
- package/dist/common/streaming.d.ts +32 -0
- package/dist/common/streaming.d.ts.map +1 -0
- package/dist/common/theme-utils.d.ts +16 -0
- package/dist/common/theme-utils.d.ts.map +1 -0
- package/dist/common/types.d.ts +298 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/ui-theme.d.ts +10 -0
- package/dist/common/ui-theme.d.ts.map +1 -0
- package/dist/common/uuidv7.d.ts +8 -0
- package/dist/common/uuidv7.d.ts.map +1 -0
- package/dist/common/v1-protocol-adapter.d.ts +66 -0
- package/dist/common/v1-protocol-adapter.d.ts.map +1 -0
- package/dist/common/widget-base.d.ts +75 -0
- package/dist/common/widget-base.d.ts.map +1 -0
- package/dist/common.cjs +2 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.js +584 -0
- package/dist/common.js.map +1 -0
- package/dist/index-CFA70IGF.js +3626 -0
- package/dist/index-CFA70IGF.js.map +1 -0
- package/dist/index-Dfl89zpe.cjs +13 -0
- package/dist/index-Dfl89zpe.cjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/qna/api.d.ts +22 -0
- package/dist/qna/api.d.ts.map +1 -0
- package/dist/qna/catalog.d.ts +140 -0
- package/dist/qna/catalog.d.ts.map +1 -0
- package/dist/qna/components/ButtonRow.d.ts +16 -0
- package/dist/qna/components/ButtonRow.d.ts.map +1 -0
- package/dist/qna/components/TextInput.d.ts +12 -0
- package/dist/qna/components/TextInput.d.ts.map +1 -0
- package/dist/qna/components/renderUISpec.d.ts +8 -0
- package/dist/qna/components/renderUISpec.d.ts.map +1 -0
- package/dist/qna/index.d.ts +34 -0
- package/dist/qna/index.d.ts.map +1 -0
- package/dist/qna/locales/en.d.ts +3 -0
- package/dist/qna/locales/en.d.ts.map +1 -0
- package/dist/qna/locales/index.d.ts +6 -0
- package/dist/qna/locales/index.d.ts.map +1 -0
- package/dist/qna/locales/tr.d.ts +3 -0
- package/dist/qna/locales/tr.d.ts.map +1 -0
- package/dist/qna/types.d.ts +62 -0
- package/dist/qna/types.d.ts.map +1 -0
- package/dist/qna.cjs +2 -0
- package/dist/qna.cjs.map +1 -0
- package/dist/qna.css +1 -0
- package/dist/qna.iife.js +48 -0
- package/dist/qna.iife.js.map +1 -0
- package/dist/qna.js +435 -0
- package/dist/qna.js.map +1 -0
- package/dist/simrel/api.d.ts +26 -0
- package/dist/simrel/api.d.ts.map +1 -0
- package/dist/simrel/catalog.d.ts +319 -0
- package/dist/simrel/catalog.d.ts.map +1 -0
- package/dist/simrel/components/GroupTabs.d.ts +17 -0
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -0
- package/dist/simrel/components/ProductCard.d.ts +17 -0
- package/dist/simrel/components/ProductCard.d.ts.map +1 -0
- package/dist/simrel/components/ProductGrid.d.ts +17 -0
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -0
- package/dist/simrel/components/renderUISpec.d.ts +8 -0
- package/dist/simrel/components/renderUISpec.d.ts.map +1 -0
- package/dist/simrel/index.d.ts +36 -0
- package/dist/simrel/index.d.ts.map +1 -0
- package/dist/simrel/locales/en.d.ts +3 -0
- package/dist/simrel/locales/en.d.ts.map +1 -0
- package/dist/simrel/locales/index.d.ts +6 -0
- package/dist/simrel/locales/index.d.ts.map +1 -0
- package/dist/simrel/locales/tr.d.ts +3 -0
- package/dist/simrel/locales/tr.d.ts.map +1 -0
- package/dist/simrel/types.d.ts +111 -0
- package/dist/simrel/types.d.ts.map +1 -0
- package/dist/simrel.cjs +2 -0
- package/dist/simrel.cjs.map +1 -0
- package/dist/simrel.css +1 -0
- package/dist/simrel.iife.js +48 -0
- package/dist/simrel.iife.js.map +1 -0
- package/dist/simrel.js +620 -0
- package/dist/simrel.js.map +1 -0
- package/dist/types-CeON7iBO.cjs +48 -0
- package/dist/types-CeON7iBO.cjs.map +1 -0
- package/dist/types-yxW8WA7u.js +4132 -0
- package/dist/types-yxW8WA7u.js.map +1 -0
- package/package.json +100 -0
package/dist/qna.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gengage-qna-container{font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px);color:var(--gengage-foreground-color, #333)}.gengage-qna-uispec>*{animation:gengage-qna-enter .15s cubic-bezier(.2,.72,.2,1) both}@keyframes gengage-qna-enter{0%{opacity:0;transform:translateY(4px) scale(.995)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-qna-buttons{display:flex;flex-wrap:wrap;gap:8px;padding:8px 0 12px}.gengage-qna-button{display:inline-flex;align-items:center;justify-content:center;padding:8px 14px;border:none;border-radius:var(--gengage-qna-pill-radius, 999px);background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;transition:filter .14s ease,transform .12s ease;text-align:left;line-height:1.25}.gengage-qna-button:hover{filter:brightness(1.06);transform:translateY(-1px)}.gengage-qna-button:active{transform:translateY(1px) scale(.988)}.gengage-qna-button:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}.gengage-qna-cta{display:inline-flex;align-items:center;padding:8px 14px;border:1px dashed color-mix(in srgb,var(--gengage-primary-color, #3b82f6) 65%,#cbd5e1 35%);border-radius:var(--gengage-qna-pill-radius, 999px);background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;opacity:.92;transition:opacity .12s ease,transform .12s ease;white-space:nowrap}.gengage-qna-cta:hover{opacity:1;transform:translateY(-1px)}.gengage-qna-input-wrapper{display:flex;gap:8px;padding:6px 0 2px;align-items:center}.gengage-qna-input{flex:1;min-width:0;height:48px;padding:0 14px 0 40px;border:1px solid #d5dbe7;border-radius:var(--gengage-qna-input-radius, 14px);font-size:15px;font-family:inherit;outline:none;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 14px center no-repeat;transition:border-color .14s ease,box-shadow .14s ease}.gengage-qna-input::placeholder{transition:opacity .18s ease}.gengage-qna-input--fade::placeholder{opacity:0}.gengage-qna-input:focus{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 3px color-mix(in srgb,var(--gengage-primary-color, #3b82f6) 18%,transparent)}.gengage-qna-send{min-width:60px;height:48px;padding:0 16px;border:1px dashed color-mix(in srgb,var(--gengage-primary-color, #3b82f6) 65%,#cbd5e1 35%);border-radius:var(--gengage-qna-pill-radius, 999px);background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;opacity:.92;transition:opacity .12s ease,transform .12s ease;white-space:nowrap}.gengage-qna-send:hover{opacity:1;transform:translateY(-1px)}.gengage-qna-send:active{transform:translateY(1px)}.gengage-qna-heading{font-size:1.04em;font-weight:700;margin:0 0 6px;color:var(--gengage-foreground-color, #333)}.gengage-qna-loading{display:flex;gap:4px;padding:12px 0}.gengage-qna-loading-dot{width:7px;height:7px;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);opacity:.4;animation:gengage-qna-pulse 1.4s infinite ease-in-out both}.gengage-qna-loading-dot:nth-child(1){animation-delay:0s}.gengage-qna-loading-dot:nth-child(2){animation-delay:.16s}.gengage-qna-loading-dot:nth-child(3){animation-delay:.32s}@keyframes gengage-qna-pulse{0%,80%,to{opacity:.4;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}@media(max-width:768px){.gengage-qna-input-wrapper{flex-direction:column}.gengage-qna-send{width:100%}}@media(prefers-reduced-motion:reduce){.gengage-qna-uispec>*,.gengage-qna-button,.gengage-qna-cta,.gengage-qna-send{animation:none!important;transition:none!important;transform:none!important}}
|
package/dist/qna.iife.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(function(D){"use strict";const at=({element:t,renderElement:e})=>{if(!t.children||t.children.length===0)return null;const n=document.createElement("div");for(const r of t.children){const s=e(r);s&&n.appendChild(s)}return n};function ot(t){const e=document.createElement("div");if(e.className=t.containerClassName,!t.spec.elements[t.spec.root])return e;const r=t.unknownRenderer??at,s=a=>{const o=t.spec.elements[a];if(!o)return null;const c=t.registry[o.type];return c?c({elementId:a,element:o,spec:t.spec,context:t.context,renderElement:s}):r({elementId:a,element:o,spec:t.spec,context:t.context,renderElement:s})},i=s(t.spec.root);return i&&e.appendChild(i),e}function ct(t,e){if(!e)return t;const n={...t};for(const[r,s]of Object.entries(e))s&&(n[r]=s);return n}function dt(t,e){const n={event_name:"stream.start",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,payload:{endpoint:e.endpoint,request_id:e.request_id}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),e.widget!==void 0&&(n.widget=e.widget),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function ut(t,e){const n={event_name:"stream.done",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,payload:{request_id:e.request_id,latency_ms:e.latency_ms,chunk_count:e.chunk_count}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),e.widget!==void 0&&(n.widget=e.widget),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function lt(t,e){const n={event_name:"stream.error",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,payload:{request_id:e.request_id,error_code:e.error_code,error_message:e.error_message}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),e.widget!==void 0&&(n.widget=e.widget),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function ft(t,e){const n={event_name:"metering.summary",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,payload:{meter_key:e.meter_key,quantity:e.quantity,unit:e.unit}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function pt(t,e){const n={event_name:"widget.history.snapshot",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,widget:e.widget,payload:{message_count:e.message_count,history_ref:e.history_ref,redaction_level:e.redaction_level}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function ht(t,e){const n={event_name:"checkout.start",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,widget:e.attribution_source,payload:{attribution_source:e.attribution_source,attribution_action_id:e.attribution_action_id,cart_value:e.cart_value,currency:e.currency,line_items:e.line_items}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function mt(t,e){const n={event_name:"checkout.complete",account_id:t.account_id,session_id:t.session_id,correlation_id:t.correlation_id,widget:e.attribution_source,payload:{attribution_source:e.attribution_source,attribution_action_id:e.attribution_action_id,cart_value:e.cart_value,currency:e.currency,line_items:e.line_items}};return t.view_id!==void 0&&(n.view_id=t.view_id),t.user_id!==void 0&&(n.user_id=t.user_id),t.page_type!==void 0&&(n.page_type=t.page_type),t.sku!==void 0&&(n.sku=t.sku),n}function ue(t,e){window.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!1}))}function Te(t,e){const n=r=>{e(r.detail)};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}function gt(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function _t(t){return{sessionId:t?.sessionId??gt(),...t}}const Ce={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"14px","--gengage-simrel-card-radius":"14px"};function yt(t){return t?{...Ce,...t}:{...Ce}}const O="gengage-global-toast-root",Ae="gengage-global-toast-style",le="gengage-global-toast-root--visible",vt=4200,bt=1500,kt=15e3;let Se=!1,M=null;function xt(t){return typeof t=="string"&&t.toLowerCase().startsWith("tr")?"Baglanti sorunu olustu. Lutfen tekrar deneyin.":"Connection issue. Please try again."}function wt(){Se||typeof window>"u"||typeof document>"u"||(Se=!0,Te("gengage:global:error",t=>{Tt(t)}))}function Tt(t){if(typeof document>"u")return;const e=t.message.trim();if(!e)return;Et();const n=St();n.innerHTML="";const r=document.createElement("section");r.className="gengage-global-toast gengage-global-toast--error",r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const s=document.createElement("div");s.className="gengage-global-toast-title",s.textContent=At(t.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=e,r.appendChild(s),r.appendChild(i),n.appendChild(r),n.classList.add(le),M&&(clearTimeout(M),M=null),M=setTimeout(()=>{Ct()},It(t.durationMs))}function Ct(){if(typeof document>"u")return;const t=document.getElementById(O);t&&(t.classList.remove(le),t.innerHTML="",M&&(clearTimeout(M),M=null))}function At(t){switch(t){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function St(){const t=document.getElementById(O);if(t instanceof HTMLElement)return t;const e=document.createElement("div");return e.id=O,e.className="gengage-global-toast-root",document.body.appendChild(e),e}function It(t){return typeof t!="number"||!Number.isFinite(t)?vt:Math.min(kt,Math.max(bt,Math.round(t)))}function Et(){if(document.getElementById(Ae))return;const t=document.createElement("style");t.id=Ae,t.textContent=`
|
|
2
|
+
#${O} {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 16px;
|
|
5
|
+
right: 16px;
|
|
6
|
+
z-index: 2147483646;
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
}
|
|
9
|
+
#${O}.${le} {
|
|
10
|
+
pointer-events: auto;
|
|
11
|
+
}
|
|
12
|
+
#${O} .gengage-global-toast {
|
|
13
|
+
min-width: 260px;
|
|
14
|
+
max-width: min(92vw, 420px);
|
|
15
|
+
border-radius: 12px;
|
|
16
|
+
border: 1px solid #f5c2c7;
|
|
17
|
+
border-left: 4px solid #d93025;
|
|
18
|
+
background: #fff9f9;
|
|
19
|
+
color: #4a1f21;
|
|
20
|
+
box-shadow: 0 10px 30px rgba(38, 18, 18, 0.18);
|
|
21
|
+
padding: 10px 12px;
|
|
22
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
23
|
+
font-size: 13px;
|
|
24
|
+
line-height: 1.4;
|
|
25
|
+
animation: gengage-global-toast-in 180ms ease-out forwards;
|
|
26
|
+
}
|
|
27
|
+
#${O} .gengage-global-toast-title {
|
|
28
|
+
margin: 0 0 4px;
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
font-weight: 700;
|
|
31
|
+
}
|
|
32
|
+
#${O} .gengage-global-toast-message {
|
|
33
|
+
margin: 0;
|
|
34
|
+
font-weight: 500;
|
|
35
|
+
}
|
|
36
|
+
@keyframes gengage-global-toast-in {
|
|
37
|
+
from {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: translateY(-8px);
|
|
40
|
+
}
|
|
41
|
+
to {
|
|
42
|
+
opacity: 1;
|
|
43
|
+
transform: translateY(0);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`,document.head.appendChild(t)}class Nt{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=yt(e.theme);this.config={...e,theme:n,session:_t(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(n),wt();const r=Te("gengage:context:update",s=>this.update(s));this._cleanups.push(r),await this.onInit(this.config),this.isInitialised=!0,this.emit("ready")}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:this.config={...this.config,pageContext:e},this.onUpdate(e))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1}on(e,n){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(n),()=>this._handlers.get(e)?.delete(n)}trackCheckout(e,n){const r=e==="start"?ht:mt;this.track(r(this.analyticsContext(),n))}flushMeteringSummary(e){this.track(ft(this.analyticsContext(),e))}emit(e,...n){this._handlers.get(e)?.forEach(r=>r(...n))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){const e={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(e.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(e.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(e.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(e.sku=this.config.pageContext.sku),e}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`[gengage] Mount target not found: "${e}"`);return r}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(e){if(e){for(const[n,r]of Object.entries(e))if(r!==void 0){const s=n.startsWith("--")?n:`--gengage-${Rt(n)}`;this.root.style.setProperty(s,r)}}}}function Rt(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ot(t){const e=[];let n=0,r=!1,s=!1,i=0;for(let a=0;a<t.length;a++){const o=t[a];if(s){s=!1;continue}if(o==="\\"&&r){s=!0;continue}if(o==='"'){r=!r;continue}r||(o==="{"&&n++,o==="}"&&(n--,n===0&&(e.push(t.slice(i,a+1)),i=a+1)))}return e.length>0?e:[t]}function Ie(t,e){const n=t.trim();if(!n||n.startsWith(":"))return!1;const r=n.startsWith("data: ")?n.slice(6):n;if(r==="[DONE]")return!0;try{const s=JSON.parse(r);return e.onEvent(s),s.type==="done"?(e.onDone?.(),!0):!1}catch{const s=Ot(r);if(s.length>1){for(const i of s)try{const a=JSON.parse(i);if(e.onEvent(a),a.type==="done")return e.onDone?.(),!0}catch{}return!1}return!1}}async function Lt(t,e){if(!t.ok){e.onError?.(new Error(`HTTP ${t.status}: ${t.statusText}`));return}if(!t.body){e.onError?.(new Error("Response body is null — streaming not supported"));return}const n=t.body.getReader(),r=new TextDecoder("utf-8");let s="";try{for(;;){const{done:i,value:a}=await n.read();if(i)break;s+=r.decode(a,{stream:!0});const o=s.split(`
|
|
47
|
+
`);s=o.pop()??"";for(const c of o)if(Ie(c,e))return}s.trim()&&Ie(s,e)}catch(i){if(i instanceof DOMException&&i.name==="AbortError")return;e.onError?.(i instanceof Error?i:new Error(String(i)))}finally{n.releaseLock()}e.onDone?.()}const Pt={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings",proactive_action:"/proactive_action"};function Zt(t){if(t===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const e=t.trim();return e===""?"":e.replace(/\/+$/,"")}function jt(t,e){return`${Zt(e?.middlewareUrl)}/chat${Pt[t]}`}function qt(t){if(typeof t.type!="string")return null;if($t(t))return t;const n=t;switch(n.type){case"outputText":return Dt(n);case"suggestedActions":return Mt(n);case"productList":return Ut(n);case"productDetails":return Bt(n);case"productDetailsSimilars":return Vt(n);case"comparisonTable":return zt(n);case"context":return Qt(n);case"chatStreamEnd":return Ht();case"loading":return Ft(n);case"panelLoading":return Wt(n);case"similarLoading":return Gt(n);case"redirect":return Jt(n);case"error":return Yt(n);case"dummy":return Xt();case"launcherAction":return Kt(n);case"text":return fe(n);case"productItem":return en(n);case"text_image":return Ee(n);case"quick_qna":return Ne(n);case"reviewHighlights":return tn(n);case"aiProductSuggestions":return rn(n);case"aiProductGroupings":return an(n);case"aiSuggestedSearches":return on(n);case"prosAndCons":return nn(n);case"getGroundingReview":return cn(n);case"voice":return un(n);case"visitorDataResponse":return sn(n);case"productListPreview":return dn();case"groupList":return ln(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return fn(n);case"launcherContent":return pn(n);default:return null}}function $t(t){const e=t.type;if(typeof e!="string")return!1;switch(e){case"metadata":return typeof t.sessionId=="string"&&typeof t.model=="string";case"text_chunk":return typeof t.content=="string";case"ui_spec":{const n=t.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const r=U(t.spec);return r?typeof r.root=="string"&&U(r.elements)!==null:!1}case"action":{const n=U(t.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof t.code=="string"&&typeof t.message=="string";case"done":return!0;default:return!1}}function Dt(t){const e=b(t.payload.text,t.payload.plain_text)??"",n=b(t.payload.plain_text,t.payload.text)??e;if(t.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const r={type:"text_chunk",content:e,final:!0},s=t.payload.product_mentions;Array.isArray(s)&&s.length>0&&(r.productMentions=s.filter(o=>typeof o=="object"&&o!==null&&typeof o.sku=="string"&&typeof o.short_name=="string"));const i=t.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(r.skuToProductItem=i);const a=t.payload.conversation_mode;return typeof a=="string"&&a&&(r.conversationMode=a),r}function Mt(t){const e=(t.payload.actions??[]).map(n=>{const r=b(n.title)??"",s=L(n.requestDetails,r),i=s?{label:r,action:s}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Re(e.filter(Le),"chat")}function Ut(t){const e=Oe(t.payload.product_list??[],"chat");e.panelHint="panel";const n=e.spec.elements[e.spec.root];return n&&(typeof t.payload.offset=="number"&&(n.props={...n.props,offset:t.payload.offset}),typeof t.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:t.payload.end_of_list})),e}function Bt(t){const e=t.payload.productDetails;return e?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:z(e)}}}},panelHint:"panel"}:mn("chat")}function Vt(t){const e=Oe(t.payload.similarProducts??[],"chat"),n=e.spec.elements[e.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...e,panelHint:"panel"}}function zt(t){const e=t.payload.multiple_product_details??[],n=t.payload.product_comparison_framework,r=t.payload.table,s=[];for(const w of e){const E=z(w);s.push(E)}const i=[];if(r){const w=n?.criteria_view??n?.criteria_view_short??{},E=n?.compared_field_names??Object.keys(r);for(const de of E){const A=r[de];if(!A||!Array.isArray(A))continue;const ne=w[de]??de;i.push({label:ne,values:A.map(we=>typeof we=="string"?we:String(we??""))})}}let a;n?.recommended_choice_sku?a=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(a=n.winner_product[0]?.sku);const o=a?s.find(w=>w.sku===a)??s[0]:s[0],c=[];if(n?.key_differences)for(const w of n.key_differences)typeof w=="string"&&c.push(w);const u=[];if(n?.special_considerations)for(const w of n.special_considerations)typeof w=="string"&&u.push(w);const h=n?.recommended_choice,k=n?.winner_hits,T={};for(const w of s){const E=w.sku;E&&(T[E]={title:w.name??E,type:"launchSingleProduct",payload:{sku:E}})}const C={products:s,attributes:i,highlights:c,productActions:T};return o&&(C.recommended=o),u.length>0&&(C.specialCases=u),h&&(C.recommendedText=h),k&&(C.winnerHits=k),typeof n?.key_differences=="string"&&(C.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(C.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:C}}},panelHint:"panel"}}function Qt(t){return{type:"metadata",sessionId:"",model:"",meta:{panel:t.payload.panel,messages:t.payload.messages,message_id:t.payload.message_id}}}function Ht(){return{type:"done"}}function Ft(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:t.payload.text,thinkingMessages:t.payload.thinking_messages,dynamicLoading:t.payload.is_dynamic===!0}}}function Wt(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function Gt(t){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:t.payload?.pending_type,loadingText:t.payload?.text}}}function Jt(t){const e=b(t.payload.url);return e?{type:"action",action:{kind:"navigate",url:e,newTab:t.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:t.payload,redirectTarget:b(t.payload.to)}}}function Yt(t){return{type:"error",code:"BACKEND_ERROR",message:b(t.payload?.text,t.payload?.message,t.payload?.error)??"Backend returned an error"}}function Xt(t){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Kt(t){const e=t.payload??{};if(Array.isArray(e.action_list)){const i={action_list:e.action_list},a=typeof e.type=="string"?e.type:void 0,o=typeof e.theme=="string"?e.theme:void 0;return a!==void 0&&(i.type=a),o!==void 0&&(i.theme=o),Ne({payload:i})}const r=U(e.action);if(r){const i={action:r},a=typeof e.text=="string"?e.text:void 0,o=typeof e.image_url=="string"?e.image_url:void 0,c=typeof e.theme=="string"?e.theme:void 0;return a!==void 0&&(i.text=a),o!==void 0&&(i.image_url=o),c!==void 0&&(i.theme=c),Ee({payload:i})}const s=typeof e.text=="string"?e.text:"";if(s){const i={text:s},a=typeof e.type=="string"?e.type:void 0,o=typeof e.theme=="string"?e.theme:void 0,c=U(e.payload)??void 0;return a!==void 0&&(i.type=a),c!==void 0&&(i.payload=c),o!==void 0&&(i.theme=o),fe({payload:i})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:e}}}function fe(t){const e={text:b(t.payload.text)??""};return typeof t.payload.theme=="string"&&(e.theme=t.payload.theme),t.payload.payload!==void 0&&(e.payload=t.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:e}}}}}function en(t){return hn(t.payload,"qna")}function Ee(t){const e=b(t.payload.text)??"",n=L(t.payload.action,e);if(n){const s={label:e||n.title,action:n};return typeof t.payload.image_url=="string"&&(s.image=t.payload.image_url),typeof t.payload.theme=="string"&&(s.theme=t.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:s}}}}}const r={text:e};return typeof t.payload.theme=="string"&&(r.theme=t.payload.theme),fe({payload:r})}function Ne(t){const e=(t.payload.action_list??[]).map(n=>{const r=b(n.title)??"",s=L(n.requestDetails,r),i=s?{label:r,action:s}:null;return i?(typeof n.icon=="string"&&(i.icon=n.icon),typeof n.image=="string"&&(i.image=n.image),i):null});return Re(e.filter(Le),"qna")}function tn(t){const n={reviews:(t.payload.reviews??[]).map(r=>{const s={};return typeof r.review_class=="string"&&(s.review_class=r.review_class),typeof r.review_text=="string"&&(s.review_text=r.review_text),(typeof r.review_rating=="string"||typeof r.review_rating=="number")&&(s.review_rating=r.review_rating),typeof r.review_tag=="string"&&(s.review_tag=r.review_tag),s})};return typeof t.payload.sku=="string"&&(n.sku=t.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function nn(t){const e={};return Array.isArray(t.payload.pros)&&(e.pros=t.payload.pros),Array.isArray(t.payload.cons)&&(e.cons=t.payload.cons),typeof t.payload.product_name=="string"&&(e.productName=t.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:e}}}}}function sn(t){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:t.payload}}}function rn(t){const e=t.payload.product_suggestions??[],n=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=gn(s);if(!i)continue;const a={product:i},o=L(s.requestDetails,i.name);o&&(a.action=o),typeof s.role=="string"&&(a.role=s.role),typeof s.reason=="string"&&(a.reason=s.reason),typeof s.review_highlight=="string"&&(a.reviewHighlight=s.review_highlight),Array.isArray(s.labels)&&(a.labels=s.labels),typeof s.expert_quality_score=="number"&&(a.expertQualityScore=s.expert_quality_score),n.push(a)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:t.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:n}}}}}}function an(t){const e=t.payload.product_groupings??[],n=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=b(s.name)??"",a=s.sku&&s.sku.length>0?{type:"findSimilar",payload:{sku:s.sku}}:void 0,o=L(s.requestDetails??a,i);if(!o)continue;const c={name:i,action:o};if(Array.isArray(s.labels)){const u=s.labels.filter(h=>typeof h=="string");u.length>0&&(c.labels=u)}typeof s.image=="string"&&(c.image=s.image),n.push(c)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:t.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function on(t){const e=t.payload.suggested_searches??[],n=[];for(let r=0;r<e.length;r++){const s=e[r];if(!s)continue;const i=b(s.short_name,s.chosen_attribute,s.detailed_user_message)??`Arama ${r+1}`,a={},o=b(s.detailed_user_message);o&&(a.text=o),s.group_skus&&Array.isArray(s.group_skus)&&(a.group_skus=s.group_skus);const c=b(s.sku,s.representative_product_sku);c&&(a.sku=c),a.is_suggested_text=1;const u={type:"inputText",payload:a},h=L(s.requestDetails??u,i);if(!h)continue;const k={shortName:i,action:h},T=b(s.detailed_user_message);T&&T!==i&&(k.detailedMessage=T);const C=b(s.why_different);C&&(k.whyDifferent=C),typeof s.image=="string"&&(k.image=s.image),n.push(k)}return n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:t.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:n}}}}}}function cn(t){const e=L(t.payload.requestDetails,b(t.payload.review_count,t.payload.text,t.payload.title)??"Urun yorumlarini goster");if(!e)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t.payload}};const n={action:e};return t.payload.title&&(n.title=t.payload.title),t.payload.text&&(n.text=t.payload.text),t.payload.review_count&&(n.reviewCount=t.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function dn(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function un(t){return{type:"metadata",sessionId:"",model:"",meta:{voice:t.payload}}}function ln(t){const e=t.payload.group_list??[],n=[];for(const s of e){const i=s.group_name??"",a=(s.product_list??[]).map(z);n.push({groupName:i,products:a})}const r=[];for(const s of t.payload.filter_tags??[]){const i=s.title??"";if(!i)continue;const a=L(s.requestDetails,i),o={title:i};a&&(o.action=a),r.push(o)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:r}}}},panelHint:"panel"}}function fn(t){return{type:"metadata",sessionId:"",model:"",meta:{formType:t.type,formPayload:t.payload??{}}}}function pn(t){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:t.payload??{}}}}function Re(t,e){const n={},r=[];for(let s=0;s<t.length;s++){const i=t[s];if(!i)continue;const a=`action-${s}`;r.push(a);const o={label:i.label,action:i.action};i.icon!==void 0&&(o.icon=i.icon),i.image!==void 0&&(o.image=i.image),i.description!==void 0&&(o.description=i.description),n[a]={type:"ActionButton",props:o}}return n.root={type:"ActionButtons",props:{buttons:t.map(s=>{const i={label:s.label,action:s.action};return s.image!==void 0&&(i.image=s.image),s.description!==void 0&&(i.description=s.description),s.icon!==void 0&&(i.icon=s.icon),i})},children:r},{type:"ui_spec",widget:e,spec:{root:"root",elements:n}}}function Oe(t,e){const n={},r=[];for(let s=0;s<t.length;s++){const i=t[s];if(!i)continue;const a=`product-${s}`;r.push(a),n[a]={type:"ProductCard",props:{product:z(i),index:s}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:r},{type:"ui_spec",widget:e,spec:{root:"root",elements:n}}}function hn(t,e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:z(t),index:0}}}}}}function mn(t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function gn(t){const e=b(t.sku),n=b(t.short_name),r=U(t.product_item)??t;return _n(r,e,n)}function _n(t,e,n){const r=b(t.sku,e),s=b(t.name,n);if(!r||!s)return null;const i={sku:r,name:s},a=b(t.brand);a&&(i.brand=a);const o=b(t.url);o&&(i.url=o);const c=yn(t.images);if(c.length>0)i.images=c;else{const w=b(t.image,t.image_url,t.imageUrl);w&&(i.images=[w])}const u=J(t.price_discounted);u!==void 0&&(i.price_discounted=u);const h=J(t.price);h!==void 0&&(i.price=h);const k=J(t.rating);k!==void 0&&(i.rating=k);const T=J(t.review_count)??J(t.reviewCount);T!==void 0&&(i.review_count=T);const C=b(t.cart_code,t.cartCode);return C&&(i.cart_code=C),typeof t.in_stock=="boolean"&&(i.in_stock=t.in_stock),typeof t.inStock=="boolean"&&(i.in_stock=t.inStock),z(i)}function L(t,e){const n=U(t);if(!n)return null;const r=n.type;if(typeof r!="string"||r.length===0)return null;const s={title:e||r,type:r};return n.payload!==void 0&&(s.payload=n.payload),s}function U(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function b(...t){for(const e of t)if(typeof e=="string"){const n=e.trim();if(n.length>0)return n}}function yn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):[]}function J(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const e=t.replace(",","."),n=Number(e);if(Number.isFinite(n))return n}}function Le(t){return t!=null}function z(t){const e=t.price_discounted!=null&&t.price_discounted>0?t.price_discounted:t.price,n=t.price_discounted!=null&&t.price_discounted>0&&t.price!=null?t.price:void 0;let r;n!=null&&e!=null&&n>0&&(r=Math.round((n-e)/n*100));const s=b(t.brand),i=b(t.name)??t.sku,a=s&&!i.startsWith(s)?`${s} ${i}`:i,o={sku:t.sku,name:a,url:b(t.url)??""},c=t.images?.[0];return c&&(o.imageUrl=c),t.images&&t.images.length>1&&(o.images=t.images),e!=null&&(o.price=String(e)),n!=null&&(o.originalPrice=String(n)),r!==void 0&&(o.discountPercent=r),s!==void 0&&(o.brand=s),t.rating!==void 0&&(o.rating=t.rating),t.review_count!==void 0&&(o.reviewCount=t.review_count),t.cart_code!==void 0&&(o.cartCode=t.cart_code),t.in_stock!==void 0&&(o.inStock=t.in_stock),t.variants&&t.variants.length>0&&(o.variants=t.variants),t.discount_reason!==void 0&&(o.discountReason=t.discount_reason),t.promotions&&t.promotions.length>0&&(o.promotions=t.promotions),o}async function vn(t,e,n){const r=jt("launcher_action",e),s={uiSpecs:[],actions:[]},i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};n!==void 0&&(i.signal=n);const a=await fetch(r,i);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const o={onEvent:c=>{const u=qt(c);if(u&&(u.type==="ui_spec"&&s.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const h of Object.values(u.spec.elements))if(h.type==="ActionButton"&&h.props?.action){const k=h.props.action;s.actions.push(k)}}}};return n!==void 0&&(o.signal=n),await Lt(a,o),s}function Pe(t){const e=document.createElement("div");e.className="gengage-qna-buttons",e.setAttribute("role","group"),e.setAttribute("aria-label",t.quickQuestionsAriaLabel??"Quick questions"),t.orientation==="vertical"&&(e.style.flexDirection="column");for(const n of t.actions){const r=document.createElement("button");r.className="gengage-qna-button",r.textContent=n.title,r.type="button",r.addEventListener("click",()=>{const s={title:n.title,type:n.type};n.payload!==void 0&&(s.payload=n.payload),t.onAction(s)}),e.appendChild(r)}if(t.ctaText||t.onOpenChat){const n=document.createElement("button");n.className="gengage-qna-cta",n.textContent=t.ctaText??t.defaultCtaText??"Başka bir şey sor",n.type="button",n.addEventListener("click",()=>{t.onOpenChat?.()}),e.appendChild(n)}return e}function bn(t){const e=document.createElement("div");e.className="gengage-qna-input-wrapper";const n=document.createElement("input");n.type="text",n.className="gengage-qna-input",n.setAttribute("aria-label",t.askQuestionAriaLabel??"Ask a question");const r=Array.isArray(t.placeholders)?t.placeholders:t.placeholders?[t.placeholders]:[t.defaultInputPlaceholder??"Bir soru sorun..."];let s=0;n.placeholder=r[0]??"";let i=null;r.length>1&&(i=setInterval(()=>{n.classList.add("gengage-qna-input--fade"),setTimeout(()=>{s=(s+1)%r.length,n.placeholder=r[s]??"",n.classList.remove("gengage-qna-input--fade")},180)},3e3));const a=document.createElement("button");a.className="gengage-qna-send",a.type="button",a.textContent=t.ctaLabel??t.sendButtonText??"Sor",a.setAttribute("aria-label",t.sendQuestionAriaLabel??"Send question");const o=()=>{const c=n.value.trim();c&&(t.onSubmit({title:c,type:"user_message",payload:c}),n.value="")};return a.addEventListener("click",o),n.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),o())}),e.appendChild(n),e.appendChild(a),e._cleanup=()=>{i&&clearInterval(i)},e}function se(t,e){if(!t||typeof t!="object")return null;const n=t,r=n.type;if(typeof r!="string"||r.length===0)return null;const s=n.title,i=n.payload,a=typeof s=="string"&&s.length>0?s:e;if(!a)return null;const o={title:a,type:r};return i!==void 0&&(o.payload=i),o}function Ze(t){const e={title:t.title,type:t.type};return t.payload!==void 0&&(e.payload=t.payload),e}function je(t,e){const n=[],r=t.props?.actions;if(Array.isArray(r))for(const a of r){const o=se(a);o&&n.push(o)}const s=t.props?.buttons;if(Array.isArray(s))for(const a of s){if(!a||typeof a!="object")continue;const o=a,c=typeof o.label=="string"?o.label:void 0,u=se(o.action,c);u&&n.push(u)}if(t.children)for(const a of t.children){const o=e.elements[a];if(!o||o.type!=="ActionButton")continue;const c=typeof o.props?.label=="string"?o.props.label:void 0,u=se(o.props?.action,c);u&&n.push(u)}const i=new Set;return n.filter(a=>i.has(a.title)?!1:(i.add(a.title),!0))}const qe={ButtonRow:({element:t,spec:e,context:n})=>{const r=je(t,e).map(Ze),s=t.props?.orientation,i={actions:r,onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(i.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(i.ctaText=n.ctaText),(s==="horizontal"||s==="vertical")&&(i.orientation=s),Pe(i)},ActionButtons:({element:t,spec:e,context:n})=>{const s={actions:je(t,e).map(Ze),onAction:n.onAction,defaultCtaText:n.i18n.defaultCtaText,quickQuestionsAriaLabel:n.i18n.quickQuestionsAriaLabel};return n.onOpenChat!==void 0&&(s.onOpenChat=n.onOpenChat),n.ctaText!==void 0&&(s.ctaText=n.ctaText),Pe(s)},ActionButton:({element:t,context:e})=>{const n=document.createElement("button");n.className="gengage-qna-button",n.type="button";const r=t.props?.label;typeof r=="string"?n.textContent=r:n.textContent=e.i18n.defaultCtaText;const s=se(t.props?.action,typeof r=="string"?r:void 0);return s&&n.addEventListener("click",()=>e.onAction(s)),n},TextInput:({element:t,context:e})=>{const n=t.props?.placeholder,r=typeof n=="string"||Array.isArray(n)?n:e.inputPlaceholder,s=typeof t.props?.ctaLabel=="string"?t.props.ctaLabel:e.ctaText,i={onSubmit:e.onAction,askQuestionAriaLabel:e.i18n.askQuestionAriaLabel,defaultInputPlaceholder:e.i18n.defaultInputPlaceholder,sendButtonText:e.i18n.sendButton,sendQuestionAriaLabel:e.i18n.sendQuestionAriaLabel};return r!==void 0&&(i.placeholders=r),s!==void 0&&(i.ctaLabel=s),bn(i)},QuestionHeading:({element:t})=>{const e=document.createElement("h3");e.className="gengage-qna-heading";const n=t.props?.text;return e.textContent=typeof n=="string"?n:"",e}},pe=({element:t,renderElement:e})=>{if(!t.children||t.children.length===0)return null;const n=document.createElement("div");for(const r of t.children){const s=e(r);s&&n.appendChild(s)}return n};function $e(){return{...qe}}function De(t,e,n=qe,r=pe){return ot({spec:t,context:e,registry:n,containerClassName:"gengage-qna-uispec",unknownRenderer:r})}const Me={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},kn={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function xn(t){return t?t.toLowerCase().split("-")[0]??"tr":"tr"}function wn(t){return xn(t)==="en"?kn:Me}var v;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(const a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(v||(v={}));var Ue;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ue||(Ue={}));const f=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},d=v.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class R extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof R))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}R.create=t=>new R(t);const he=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===f.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,v.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${v.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${v.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${v.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:v.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,v.assertNever(t)}return{message:n}};let Tn=he;function Cn(){return Tn}const An=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}};function l(t,e){const n=Cn(),r=An({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===he?void 0:he].filter(s=>!!s)});t.common.issues.push(r)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return m;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return S.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return m;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}}const m=Object.freeze({status:"aborted"}),Y=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),Be=t=>t.status==="aborted",Ve=t=>t.status==="dirty",Q=t=>t.status==="valid",re=t=>typeof Promise<"u"&&t instanceof Promise;var p;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));class Z{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ze=(t,e)=>{if(Q(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new R(t.common.issues);return this._error=n,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{const{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:s}}class y{get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(re(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ze(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Q(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Q(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(re(s)?s:Promise.resolve(s));return ze(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:d.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new W({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return $.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return ce.create(this,this._def)}or(e){return ae.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new W({..._(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ve({..._(this._def),innerType:this,defaultValue:n,typeName:g.ZodDefault})}brand(){return new Gn({typeName:g.ZodBranded,type:this,..._(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new be({..._(this._def),innerType:this,catchValue:n,typeName:g.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ke.create(this,e)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sn=/^c[^\s-]{8,}$/i,In=/^[0-9a-z]+$/,En=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Nn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Rn=/^[a-z0-9_-]{21}$/i,On=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ln=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Pn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let me;const jn=/^(?:(?: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])$/,qn=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$n=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Dn=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Un=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qe="((\\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])))",Bn=new RegExp(`^${Qe}$`);function He(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Vn(t){return new RegExp(`^${He(t)}$`)}function zn(t){let e=`${Qe}T${He(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Qn(t,e){return!!((e==="v4"||!e)&&jn.test(t)||(e==="v6"||!e)&&$n.test(t))}function Hn(t,e){if(!On.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Fn(t,e){return!!((e==="v4"||!e)&&qn.test(t)||(e==="v6"||!e)&&Dn.test(t))}class j extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_type,expected:f.string,received:i.parsedType}),m}const r=new S;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?l(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&l(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Pn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")me||(me=new RegExp(Zn,"u")),me.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Sn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")In.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")En.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:d.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:d.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?zn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Vn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Qn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Hn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"jwt",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Fn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cidr",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Un.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64url",code:d.invalid_string,message:i.message}),r.dirty()):v.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:d.invalid_string,...p.errToObj(r)})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...p.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...p.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...p.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...p.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...p.errToObj(n)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}j.create=t=>new j({checks:[],typeName:g.ZodString,coerce:t?.coerce??!1,..._(t)});function Wn(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}class X extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_type,expected:f.number,received:i.parsedType}),m}let r;const s=new S;for(const i of this._def.checks)i.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Wn(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_finite,message:i.message}),s.dirty()):v.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,r,s){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:p.toString(s)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}X.create=t=>new X({checks:[],typeName:g.ZodNumber,coerce:t?.coerce||!1,..._(t)});class K extends y{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let r;const s=new S;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):v.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:f.bigint,received:n.parsedType}),m}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,r,s){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:p.toString(s)}]})}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}K.create=t=>new K({checks:[],typeName:g.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class ge extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.boolean,received:r.parsedType}),m}return I(e.data)}}ge.create=t=>new ge({typeName:g.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class ie extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_type,expected:f.date,received:i.parsedType}),m}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return l(i,{code:d.invalid_date}),m}const r=new S;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):v.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ie({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ie.create=t=>new ie({checks:[],coerce:t?.coerce||!1,typeName:g.ZodDate,..._(t)});class Fe extends y{_parse(e){if(this._getType(e)!==f.symbol){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.symbol,received:r.parsedType}),m}return I(e.data)}}Fe.create=t=>new Fe({typeName:g.ZodSymbol,..._(t)});class We extends y{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.undefined,received:r.parsedType}),m}return I(e.data)}}We.create=t=>new We({typeName:g.ZodUndefined,..._(t)});class Ge extends y{_parse(e){if(this._getType(e)!==f.null){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.null,received:r.parsedType}),m}return I(e.data)}}Ge.create=t=>new Ge({typeName:g.ZodNull,..._(t)});class Je extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}}Je.create=t=>new Je({typeName:g.ZodAny,..._(t)});class _e extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}}_e.create=t=>new _e({typeName:g.ZodUnknown,..._(t)});class q extends y{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:f.never,received:n.parsedType}),m}}q.create=t=>new q({typeName:g.ZodNever,..._(t)});class Ye extends y{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.void,received:r.parsedType}),m}return I(e.data)}}Ye.create=t=>new Ye({typeName:g.ZodVoid,..._(t)});class N extends y{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==f.array)return l(n,{code:d.invalid_type,expected:f.array,received:n.parsedType}),m;if(s.exactLength!==null){const a=n.data.length>s.exactLength.value,o=n.data.length<s.exactLength.value;(a||o)&&(l(n,{code:a?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(l(n,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(l(n,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>s.type._parseAsync(new Z(n,a,n.path,o)))).then(a=>S.mergeArray(r,a));const i=[...n.data].map((a,o)=>s.type._parseSync(new Z(n,a,n.path,o)));return S.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new N({...this._def,minLength:{value:e,message:p.toString(n)}})}max(e,n){return new N({...this._def,maxLength:{value:e,message:p.toString(n)}})}length(e,n){return new N({...this._def,exactLength:{value:e,message:p.toString(n)}})}nonempty(e){return this.min(1,e)}}N.create=(t,e)=>new N({type:t,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,..._(e)});function H(t){if(t instanceof x){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=$.create(H(r))}return new x({...t._def,shape:()=>e})}else return t instanceof N?new N({...t._def,type:H(t.element)}):t instanceof $?$.create(H(t.unwrap())):t instanceof G?G.create(H(t.unwrap())):t instanceof B?B.create(t.items.map(e=>H(e))):t}class x extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=v.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),m}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof q&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const h=i[u],k=s.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new Z(s,k,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof q){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(u==="strict")o.length>0&&(l(s,{code:d.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of o){const k=s.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new Z(s,k,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const h of c){const k=await h.key,T=await h.value;u.push({key:k,value:T,alwaysSet:h.alwaysSet})}return u}).then(u=>S.mergeObjectSync(r,u)):S.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new x({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:p.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new x({...this._def,unknownKeys:"strip"})}passthrough(){return new x({...this._def,unknownKeys:"passthrough"})}extend(e){return new x({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new x({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new x({...this._def,catchall:e})}pick(e){const n={};for(const r of v.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new x({...this._def,shape:()=>n})}omit(e){const n={};for(const r of v.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new x({...this._def,shape:()=>n})}deepPartial(){return H(this)}partial(e){const n={};for(const r of v.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new x({...this._def,shape:()=>n})}required(e){const n={};for(const r of v.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof $;)i=i._def.innerType;n[r]=i}return new x({...this._def,shape:()=>n})}keyof(){return tt(v.objectKeys(this.shape))}}x.create=(t,e)=>new x({shape:()=>t,unknownKeys:"strip",catchall:q.create(),typeName:g.ZodObject,..._(e)}),x.strictCreate=(t,e)=>new x({shape:()=>t,unknownKeys:"strict",catchall:q.create(),typeName:g.ZodObject,..._(e)}),x.lazycreate=(t,e)=>new x({shape:t,unknownKeys:"strip",catchall:q.create(),typeName:g.ZodObject,..._(e)});class ae extends y{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new R(o.ctx.common.issues));return l(n,{code:d.invalid_union,unionErrors:a}),m}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new R(c));return l(n,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ae.create=(t,e)=>new ae({options:t,typeName:g.ZodUnion,..._(e)});function ye(t,e){const n=P(t),r=P(e);if(t===e)return{valid:!0,data:t};if(n===f.object&&r===f.object){const s=v.objectKeys(e),i=v.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(const o of i){const c=ye(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(n===f.array&&r===f.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const a=t[i],o=e[i],c=ye(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===f.date&&r===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class oe extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(Be(i)||Be(a))return m;const o=ye(i.value,a.value);return o.valid?((Ve(i)||Ve(a))&&n.dirty(),{status:n.value,value:o.data}):(l(r,{code:d.invalid_intersection_types}),m)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}oe.create=(t,e,n)=>new oe({left:t,right:e,typeName:g.ZodIntersection,..._(n)});class B extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return l(r,{code:d.invalid_type,expected:f.array,received:r.parsedType}),m;if(r.data.length<this._def.items.length)return l(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&r.data.length>this._def.items.length&&(l(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Z(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>S.mergeArray(n,a)):S.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new B({...this._def,rest:e})}}B.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new B({items:t,typeName:g.ZodTuple,rest:null,..._(e)})};class Xe extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return l(r,{code:d.invalid_type,expected:f.map,received:r.parsedType}),m;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([o,c],u)=>({key:s._parse(new Z(r,o,r.path,[u,"key"])),value:i._parse(new Z(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,h=await c.value;if(u.status==="aborted"||h.status==="aborted")return m;(u.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(u.value,h.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return m;(u.status==="dirty"||h.status==="dirty")&&n.dirty(),o.set(u.value,h.value)}return{status:n.value,value:o}}}}Xe.create=(t,e,n)=>new Xe({valueType:e,keyType:t,typeName:g.ZodMap,..._(n)});class ee extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return l(r,{code:d.invalid_type,expected:f.set,received:r.parsedType}),m;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(l(r,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(l(r,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const h of c){if(h.status==="aborted")return m;h.status==="dirty"&&n.dirty(),u.add(h.value)}return{status:n.value,value:u}}const o=[...r.data.values()].map((c,u)=>i._parse(new Z(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,n){return new ee({...this._def,minSize:{value:e,message:p.toString(n)}})}max(e,n){return new ee({...this._def,maxSize:{value:e,message:p.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ee.create=(t,e)=>new ee({valueType:t,minSize:null,maxSize:null,typeName:g.ZodSet,..._(e)});class Ke extends y{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Ke.create=(t,e)=>new Ke({getter:t,typeName:g.ZodLazy,..._(e)});class et extends y{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}et.create=(t,e)=>new et({value:t,typeName:g.ZodLiteral,..._(e)});function tt(t,e){return new F({values:t,typeName:g.ZodEnum,..._(e)})}class F extends y{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return l(n,{expected:v.joinValues(r),received:n.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return l(n,{received:n.data,code:d.invalid_enum_value,options:r}),m}return I(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return F.create(e,{...this._def,...n})}exclude(e,n=this._def){return F.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}F.create=tt;class nt extends y{_parse(e){const n=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){const s=v.objectValues(n);return l(r,{expected:v.joinValues(s),received:r.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=v.objectValues(n);return l(r,{received:r.data,code:d.invalid_enum_value,options:s}),m}return I(e.data)}get enum(){return this._def.values}}nt.create=(t,e)=>new nt({values:t,typeName:g.ZodNativeEnum,..._(e)});class ce extends y{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==f.promise&&n.common.async===!1)return l(n,{code:d.invalid_type,expected:f.promise,received:n.parsedType}),m;const r=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return I(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ce.create=(t,e)=>new ce({type:t,typeName:g.ZodPromise,..._(e)});class W extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{l(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async o=>{if(n.value==="aborted")return m;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?m:c.status==="dirty"||n.value==="dirty"?Y(c.value):c});{if(n.value==="aborted")return m;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?m:o.status==="dirty"||n.value==="dirty"?Y(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Q(a))return m;const o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Q(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:n.value,value:o})):m);v.assertNever(s)}}W.create=(t,e,n)=>new W({schema:t,typeName:g.ZodEffects,effect:e,..._(n)}),W.createWithPreprocess=(t,e,n)=>new W({schema:e,effect:{type:"preprocess",transform:t},typeName:g.ZodEffects,..._(n)});class $ extends y{_parse(e){return this._getType(e)===f.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$.create=(t,e)=>new $({innerType:t,typeName:g.ZodOptional,..._(e)});class G extends y{_parse(e){return this._getType(e)===f.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:g.ZodNullable,..._(e)});class ve extends y{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===f.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ve.create=(t,e)=>new ve({innerType:t,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class be extends y{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return re(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new R(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new R(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}be.create=(t,e)=>new be({innerType:t,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class st extends y{_parse(e){if(this._getType(e)!==f.nan){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:f.nan,received:r.parsedType}),m}return{status:"valid",value:e.data}}}st.create=t=>new st({typeName:g.ZodNaN,..._(t)});class Gn extends y{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class ke extends y{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?m:i.status==="dirty"?(n.dirty(),Y(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?m:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new ke({in:e,out:n,typeName:g.ZodPipeline})}}class xe extends y{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Q(s)&&(s.value=Object.freeze(s.value)),s);return re(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}xe.create=(t,e)=>new xe({innerType:t,typeName:g.ZodReadonly,..._(e)});var g;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(g||(g={}));const V=j.create,Jn=ge.create,Yn=_e.create;q.create;const Xn=N.create,te=x.create,Kn=ae.create;oe.create,B.create;const rt=F.create;ce.create,$.create,G.create;const es=te({title:V(),type:V(),payload:Yn().optional()}),ts=te({label:V(),action:es,variant:rt(["primary","outline","ghost"]).optional()}),ns=te({orientation:rt(["horizontal","vertical"]).optional(),wrap:Jn().optional()}),ss=te({placeholder:Kn([V(),Xn(V())]).optional(),ctaLabel:V().optional()}),rs=te({text:V()}),is={components:{ActionButton:{schema:ts,description:"A single clickable QNA action button."},ButtonRow:{schema:ns,description:"Container for a group of QNA action buttons."},TextInput:{schema:ss,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:rs,description:"A heading displayed above the QNA button group."}}};class it extends Nt{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=Me,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const n=e.pageContext?.sku;n&&(this._lastSku=n,await this._fetchAndRender(n)),this.isVisible=!0}onUpdate(e){const n=e.sku;!n||n===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=n,this._fetchAndRender(n)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._contentEl.querySelector(".gengage-qna-input-wrapper")?._cleanup?.(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._contentEl.innerHTML="";const n=this._createLoadingIndicator();this._contentEl.appendChild(n);const r={middlewareUrl:this.config.middlewareUrl},s=crypto.randomUUID(),i=Date.now();this.track(dt(this.analyticsContext(),{endpoint:"launcher_action",request_id:s,widget:"qna"}));try{const a={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e,locale:this.config.locale??"tr"},o=this.config.pageContext?.pageType;o!==void 0&&(a.page_type=o);const c=await vn(a,r,this._abortController.signal);if(this.track(ut(this.analyticsContext(),{request_id:s,latency_ms:Date.now()-i,chunk_count:c.actions.length,widget:"qna"})),this.track(pt(this.analyticsContext(),{message_count:c.actions.length,history_ref:s,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(c.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const A=document.createElement("h3");A.className="gengage-qna-heading",A.textContent=this.config.staticQuestionText,this._contentEl.appendChild(A)}const h=this.config.inputPlaceholder,k=c.actions.length>0&&h===!0?c.actions.map(A=>A.title):h===!0?this._i18n.defaultInputPlaceholder:h,T={onAction:this._actionHandler,i18n:this._i18n};h===void 0&&(T.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(T.ctaText=this.config.ctaText)),k!==void 0&&(T.inputPlaceholder=k);const C=this._buildFallbackActionsSpec(c.actions),E=(c.uiSpecs.length>0?c.uiSpecs:[C]).filter(A=>Object.keys(A.elements).length>0);for(const A of E){const ne=this._renderUISpec(A,T);this._contentEl.appendChild(ne)}if(h!==void 0&&!this._specIncludesType(E,"TextInput")){const A={root:"root",elements:{root:{type:"TextInput",props:{placeholder:k,ctaLabel:this.config.ctaText}}}},ne=this._renderUISpec(A,T);this._contentEl.appendChild(ne)}}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return;ue("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:xt(this.config.locale)}),this.track(lt(this.analyticsContext(),{request_id:s,error_code:"FETCH_ERROR",error_message:a instanceof Error?a.message:String(a),widget:"qna"}))}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let n=0;n<3;n++){const r=document.createElement("div");r.className="gengage-qna-loading-dot",e.appendChild(r)}return e}_resolveI18n(e){return{...wn(e.locale),...e.i18n}}_resolveUISpecRegistry(){const e=$e();return ct(e,this.config.renderer?.registry)}_renderUISpec(e,n){const r=this._resolveUISpecRegistry(),s=this.config.renderer?.unknownRenderer??pe,i=(c,u)=>De(c,u,r,s),a=this.config.renderer?.renderUISpec;return a?a(e,n,{registry:r,unknownRenderer:s,defaultRender:i}):i(e,n)}_specIncludesType(e,n){for(const r of e)for(const s of Object.values(r.elements))if(s.type===n)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const n={},r=[];for(let s=0;s<e.length;s++){const i=e[s],a=`action-${s}`;r.push(a),n[a]={type:"ActionButton",props:{label:i.title,action:{title:i.title,type:i.type,payload:i.payload}}}}return n.root={type:"ButtonRow",children:r},{root:"root",elements:n}}_handleAction(e){this.config.onActionSelected?.(e),ue("gengage:qna:action",e)}_handleOpenChat(){this.config.onOpenChat?.(),ue("gengage:qna:open-chat",{})}}function as(){return new it}D.GengageQNA=it,D.createDefaultQnaUISpecRegistry=$e,D.createQNAWidget=as,D.defaultQnaUnknownUISpecRenderer=pe,D.qnaCatalog=is,D.renderQnaUISpec=De,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
|
|
48
|
+
//# sourceMappingURL=qna.iife.js.map
|