@gengage/assistant-fe 0.1.0 → 0.1.2
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 +2 -2
- package/README.md +2 -2
- package/dist/assistant-fe.css +1 -1
- package/dist/chat/api.d.ts +12 -2
- package/dist/chat/api.d.ts.map +1 -1
- package/dist/chat/catalog.d.ts +246 -896
- package/dist/chat/catalog.d.ts.map +1 -1
- package/dist/chat/components/AIGroupingCards.d.ts.map +1 -1
- package/dist/chat/components/AISuggestedSearchCards.d.ts.map +1 -1
- package/dist/chat/components/AITopPicks.d.ts.map +1 -1
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +16 -3
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
- package/dist/chat/components/ComparisonTable.d.ts +9 -0
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
- package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -1
- package/dist/chat/components/HandoffNotice.d.ts +5 -0
- package/dist/chat/components/HandoffNotice.d.ts.map +1 -0
- package/dist/chat/components/KvkkBanner.d.ts +1 -0
- package/dist/chat/components/KvkkBanner.d.ts.map +1 -1
- package/dist/chat/components/ProactivePopup.d.ts +9 -0
- package/dist/chat/components/ProactivePopup.d.ts.map +1 -1
- package/dist/chat/components/ProductSummaryCard.d.ts +4 -0
- package/dist/chat/components/ProductSummaryCard.d.ts.map +1 -0
- package/dist/chat/components/ReviewHighlights.d.ts +3 -1
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -1
- package/dist/chat/components/ThumbnailsColumn.d.ts.map +1 -1
- package/dist/chat/components/renderUISpec.d.ts +4 -3
- package/dist/chat/components/renderUISpec.d.ts.map +1 -1
- package/dist/chat/heartbeat.d.ts +71 -0
- package/dist/chat/heartbeat.d.ts.map +1 -0
- package/dist/chat/index.d.ts +39 -78
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/kvkk.d.ts +21 -0
- package/dist/chat/kvkk.d.ts.map +1 -0
- package/dist/chat/locales/en.d.ts.map +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/panel-manager.d.ts +81 -0
- package/dist/chat/panel-manager.d.ts.map +1 -0
- package/dist/chat/session-persistence.d.ts +56 -0
- package/dist/chat/session-persistence.d.ts.map +1 -0
- package/dist/chat/types.d.ts +39 -1
- package/dist/chat/types.d.ts.map +1 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +48 -10
- package/dist/chat.iife.js.map +1 -1
- package/dist/chat.js +9 -8
- package/dist/chat.js.map +1 -1
- package/dist/common/analytics-events.d.ts +2 -0
- package/dist/common/analytics-events.d.ts.map +1 -1
- package/dist/common/analytics.d.ts.map +1 -1
- package/dist/common/api-paths.d.ts +5 -0
- package/dist/common/api-paths.d.ts.map +1 -1
- package/dist/common/client.d.ts +4 -1
- package/dist/common/client.d.ts.map +1 -1
- package/dist/common/communication-bridge.d.ts.map +1 -1
- package/dist/common/config-schema.d.ts +33 -195
- package/dist/common/config-schema.d.ts.map +1 -1
- package/dist/common/ga-datalayer.d.ts +62 -0
- package/dist/common/ga-datalayer.d.ts.map +1 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/indexed-db.d.ts +1 -1
- package/dist/common/indexed-db.d.ts.map +1 -1
- package/dist/common/merchant-configs.d.ts +22 -0
- package/dist/common/merchant-configs.d.ts.map +1 -0
- package/dist/common/overlay.d.ts +5 -0
- package/dist/common/overlay.d.ts.map +1 -1
- package/dist/common/page-detect.d.ts +31 -0
- package/dist/common/page-detect.d.ts.map +1 -0
- package/dist/common/preflight.d.ts +3 -1
- package/dist/common/preflight.d.ts.map +1 -1
- package/dist/common/price-formatter.d.ts +33 -0
- package/dist/common/price-formatter.d.ts.map +1 -0
- package/dist/common/product-utils.d.ts +26 -0
- package/dist/common/product-utils.d.ts.map +1 -0
- package/dist/common/quantity-stepper.d.ts +22 -0
- package/dist/common/quantity-stepper.d.ts.map +1 -0
- package/dist/common/safe-html.d.ts +10 -6
- package/dist/common/safe-html.d.ts.map +1 -1
- package/dist/common/streaming.d.ts +6 -0
- package/dist/common/streaming.d.ts.map +1 -1
- package/dist/common/tts-player.d.ts +12 -0
- package/dist/common/tts-player.d.ts.map +1 -0
- package/dist/common/types.d.ts +51 -0
- package/dist/common/types.d.ts.map +1 -1
- package/dist/common/v1-protocol-adapter.d.ts +9 -0
- package/dist/common/v1-protocol-adapter.d.ts.map +1 -1
- package/dist/common/voice-input.d.ts +74 -0
- package/dist/common/voice-input.d.ts.map +1 -0
- package/dist/common/widget-base.d.ts +18 -1
- package/dist/common/widget-base.d.ts.map +1 -1
- package/dist/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/common.js +564 -244
- package/dist/common.js.map +1 -1
- package/dist/index-CXbH-cw8.js +4337 -0
- package/dist/index-CXbH-cw8.js.map +1 -0
- package/dist/index-DHfTHscz.cjs +13 -0
- package/dist/index-DHfTHscz.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -53
- package/dist/qna/catalog.d.ts +30 -96
- package/dist/qna/catalog.d.ts.map +1 -1
- package/dist/qna/components/TextInput.d.ts.map +1 -1
- package/dist/qna/components/renderUISpec.d.ts.map +1 -1
- package/dist/qna/index.d.ts +2 -0
- package/dist/qna/index.d.ts.map +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.cjs.map +1 -1
- package/dist/qna.iife.js +46 -8
- package/dist/qna.iife.js.map +1 -1
- package/dist/qna.js +94 -86
- package/dist/qna.js.map +1 -1
- package/dist/quantity-stepper-B8kX8GbN.js +209 -0
- package/dist/quantity-stepper-B8kX8GbN.js.map +1 -0
- package/dist/quantity-stepper-UbAp53Ow.cjs +2 -0
- package/dist/quantity-stepper-UbAp53Ow.cjs.map +1 -0
- package/dist/schemas-CPkzbgia.js +4572 -0
- package/dist/schemas-CPkzbgia.js.map +1 -0
- package/dist/schemas-tCxs1sED.cjs +86 -0
- package/dist/schemas-tCxs1sED.cjs.map +1 -0
- package/dist/simrel/api.d.ts.map +1 -1
- package/dist/simrel/catalog.d.ts +32 -240
- package/dist/simrel/catalog.d.ts.map +1 -1
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -1
- package/dist/simrel/components/ProductCard.d.ts +2 -0
- package/dist/simrel/components/ProductCard.d.ts.map +1 -1
- package/dist/simrel/components/renderUISpec.d.ts.map +1 -1
- package/dist/simrel/index.d.ts.map +1 -1
- package/dist/simrel/types.d.ts +5 -0
- package/dist/simrel/types.d.ts.map +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.cjs.map +1 -1
- package/dist/simrel.css +1 -1
- package/dist/simrel.iife.js +46 -8
- package/dist/simrel.iife.js.map +1 -1
- package/dist/simrel.js +319 -279
- package/dist/simrel.js.map +1 -1
- package/package.json +28 -8
- package/dist/index-CFA70IGF.js +0 -3626
- package/dist/index-CFA70IGF.js.map +0 -1
- package/dist/index-Dfl89zpe.cjs +0 -13
- package/dist/index-Dfl89zpe.cjs.map +0 -1
- package/dist/types-CeON7iBO.cjs +0 -48
- package/dist/types-CeON7iBO.cjs.map +0 -1
- package/dist/types-yxW8WA7u.js +0 -4132
- package/dist/types-yxW8WA7u.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index-DHfTHscz.cjs"),a=require("./qna.cjs"),i=require("./simrel.cjs"),t=require("./schemas-tCxs1sED.cjs"),e=require("./common.cjs");exports.GengageChat=n.GengageChat;exports.VoiceInput=n.VoiceInput;exports.createChatWidget=n.createChatWidget;exports.createDefaultChatUISpecRegistry=n.createDefaultChatUISpecRegistry;exports.defaultChatUnknownUISpecRenderer=n.defaultChatUnknownUISpecRenderer;exports.isVoiceInputSupported=n.isVoiceInputSupported;exports.renderChatUISpec=n.renderUISpec;exports.routeStreamAction=n.routeStreamAction;exports.GengageQNA=a.GengageQNA;exports.createDefaultQnaUISpecRegistry=a.createDefaultQnaUISpecRegistry;exports.createQNAWidget=a.createQNAWidget;exports.defaultQnaUnknownUISpecRenderer=a.defaultQnaUnknownUISpecRenderer;exports.renderQnaUISpec=a.renderQnaUISpec;exports.GengageSimRel=i.GengageSimRel;exports.createDefaultSimRelUISpecRegistry=i.createDefaultSimRelUISpecRegistry;exports.createSimRelWidget=i.createSimRelWidget;exports.defaultSimRelUnknownUISpecRenderer=i.defaultSimRelUnknownUISpecRenderer;exports.renderSimRelUISpec=i.renderSimRelUISpec;exports.DEFAULT_WIDGET_THEME_TOKENS=t.DEFAULT_WIDGET_THEME_TOKENS;exports.bootstrapSession=t.bootstrapSession;exports.buildChatEndpointUrl=t.buildChatEndpointUrl;exports.consumeStream=t.consumeStream;exports.defaultUnknownUISpecRenderer=t.defaultUnknownUISpecRenderer;exports.dispatch=t.dispatch;exports.listen=t.listen;exports.normalizeMiddlewareUrl=t.normalizeMiddlewareUrl;exports.renderUISpecWithRegistry=t.renderUISpecWithRegistry;exports.streamPost=t.streamPost;exports.updatePageContext=t.updatePageContext;exports.wireGADataLayer=t.wireGADataLayer;exports.wireQNAToChat=t.wireQNAToChat;exports.wireSimilarToChat=t.wireSimilarToChat;exports.withDefaultWidgetTheme=t.withDefaultWidgetTheme;exports.AccountRuntimeConfigSchema=e.AccountRuntimeConfigSchema;exports.AnalyticsAuthModeSchema=e.AnalyticsAuthModeSchema;exports.BASE_WIDGET_THEME=e.BASE_WIDGET_THEME;exports.DEFAULT_CUSTOMIZATION_LOCALE=e.DEFAULT_CUSTOMIZATION_LOCALE;exports.UnknownActionPolicySchema=e.UnknownActionPolicySchema;exports.autoDetectPageContext=e.autoDetectPageContext;exports.buildOverlayIdempotencyKey=e.buildOverlayIdempotencyKey;exports.createAccountIdentity=e.createAccountIdentity;exports.createAnalyticsClient=e.createAnalyticsClient;exports.createDefaultAccountRuntimeConfig=e.createDefaultAccountRuntimeConfig;exports.createDefaultAnalyticsConfig=e.createDefaultAnalyticsConfig;exports.createFloatingChatConfig=e.createFloatingChatConfig;exports.createPdpQnaConfig=e.createPdpQnaConfig;exports.createPdpSimRelConfig=e.createPdpSimRelConfig;exports.destroyOverlayWidgets=e.destroyOverlayWidgets;exports.detectPageType=e.detectPageType;exports.extractSkuFromUrl=e.extractSkuFromUrl;exports.getMerchantConfig=e.getMerchantConfig;exports.getMerchantIds=e.getMerchantIds;exports.getOverlayWidgets=e.getOverlayWidgets;exports.initGengageClient=e.initGengageClient;exports.initOverlayWidgets=e.initOverlayWidgets;exports.parseAccountRuntimeConfig=e.parseAccountRuntimeConfig;exports.preflightDiagnostics=e.preflightDiagnostics;exports.safeParseAccountRuntimeConfig=e.safeParseAccountRuntimeConfig;exports.withBaseTheme=e.withBaseTheme;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export { GengageSimRel, createSimRelWidget } from './simrel/index.js';
|
|
|
15
15
|
export { renderUISpec as renderChatUISpec, createDefaultChatUISpecRegistry, defaultChatUnknownUISpecRenderer, } from './chat/index.js';
|
|
16
16
|
export { renderQnaUISpec, createDefaultQnaUISpecRegistry, defaultQnaUnknownUISpecRenderer } from './qna/index.js';
|
|
17
17
|
export { renderSimRelUISpec, createDefaultSimRelUISpecRegistry, defaultSimRelUnknownUISpecRenderer, } from './simrel/index.js';
|
|
18
|
-
export { bootstrapSession, updatePageContext, initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey, wireQNAToChat, wireSimilarToChat, dispatch, listen, consumeStream, streamPost, buildChatEndpointUrl, normalizeMiddlewareUrl, routeStreamAction, createAnalyticsClient, renderUISpecWithRegistry, defaultUnknownUISpecRenderer, BASE_WIDGET_THEME, withBaseTheme, DEFAULT_WIDGET_THEME_TOKENS, withDefaultWidgetTheme, DEFAULT_CUSTOMIZATION_LOCALE, createAccountIdentity, createFloatingChatConfig, createPdpQnaConfig, createPdpSimRelConfig, createDefaultAnalyticsConfig, parseAccountRuntimeConfig, safeParseAccountRuntimeConfig, createDefaultAccountRuntimeConfig, AccountRuntimeConfigSchema, AnalyticsAuthModeSchema, UnknownActionPolicySchema, initGengageClient, preflightDiagnostics, } from './common/index.js';
|
|
19
|
-
export type { PageContext, SessionContext, BaseWidgetConfig, GengageWidget, StreamEvent, UISpec, UIElement, ActionPayload, GengageEventName, ChatPublicAPI, ChatTransportConfig, ChatEndpointName, AccountRuntimeConfig, AnalyticsAuthMode, UnknownActionPolicy, HostActionHandlers, ActionRouterOptions, AnalyticsEnvelope, AnalyticsInput, AnalyticsAuthConfig, AnalyticsClientConfig, UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, AccountIdentityConfig, AccountIdentity, GengageClientOptions, HostActions, PreflightResult, PreflightWarning, WireQNAToChatOptions, } from './common/index.js';
|
|
18
|
+
export { bootstrapSession, updatePageContext, initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey, wireQNAToChat, wireSimilarToChat, dispatch, listen, consumeStream, streamPost, buildChatEndpointUrl, normalizeMiddlewareUrl, routeStreamAction, createAnalyticsClient, renderUISpecWithRegistry, defaultUnknownUISpecRenderer, BASE_WIDGET_THEME, withBaseTheme, DEFAULT_WIDGET_THEME_TOKENS, withDefaultWidgetTheme, DEFAULT_CUSTOMIZATION_LOCALE, createAccountIdentity, createFloatingChatConfig, createPdpQnaConfig, createPdpSimRelConfig, createDefaultAnalyticsConfig, parseAccountRuntimeConfig, safeParseAccountRuntimeConfig, createDefaultAccountRuntimeConfig, AccountRuntimeConfigSchema, AnalyticsAuthModeSchema, UnknownActionPolicySchema, initGengageClient, preflightDiagnostics, wireGADataLayer, isVoiceInputSupported, VoiceInput, detectPageType, extractSkuFromUrl, autoDetectPageContext, getMerchantConfig, getMerchantIds, } from './common/index.js';
|
|
19
|
+
export type { PageContext, SessionContext, BaseWidgetConfig, GengageWidget, StreamEvent, UISpec, UIElement, ActionPayload, GengageEventName, ChatPublicAPI, ChatTransportConfig, ChatEndpointName, AccountRuntimeConfig, AnalyticsAuthMode, UnknownActionPolicy, HostActionHandlers, ActionRouterOptions, AnalyticsEnvelope, AnalyticsInput, AnalyticsAuthConfig, AnalyticsClientConfig, UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, AccountIdentityConfig, AccountIdentity, GengageClientOptions, HostActions, PreflightResult, PreflightWarning, WireQNAToChatOptions, VoiceInputState, VoiceInputErrorCode, VoiceInputCallbacks, VoiceInputOptions, DetectablePageType, PageDetectionRule, MerchantConfig, } from './common/index.js';
|
|
20
20
|
export type { ChatWidgetConfig, ChatMessage, ChatSession, ChatI18n, ChatRendererConfig } from './chat/index.js';
|
|
21
21
|
export type { ChatUISpecRegistry, UISpecRenderContext as ChatUISpecRenderContext } from './chat/index.js';
|
|
22
22
|
export type { QNAWidgetConfig, QNAI18n, QNAUISpecRenderContext, QNAUISpecRegistry, QNARendererConfig, } from './qna/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAClH,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,aAAa,EACb,2BAA2B,EAC3B,sBAAsB,EACtB,4BAA4B,EAC5B,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAClH,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,aAAa,EACb,2BAA2B,EAC3B,sBAAsB,EACtB,4BAA4B,EAC5B,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,MAAM,EACN,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,8BAA8B,EAC9B,0BAA0B,EAC1B,iBAAiB,EACjB,8BAA8B,EAC9B,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChH,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1G,YAAY,EACV,eAAe,EACf,OAAO,EACP,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,59 +1,67 @@
|
|
|
1
|
-
import { G as a,
|
|
2
|
-
import { GengageQNA as
|
|
3
|
-
import { GengageSimRel as
|
|
4
|
-
import {
|
|
5
|
-
import { AccountRuntimeConfigSchema as
|
|
1
|
+
import { G as a, V as n, c as r, a as i, d as c, i as o, b as s, r as g } from "./index-CXbH-cw8.js";
|
|
2
|
+
import { GengageQNA as d, createDefaultQnaUISpecRegistry as p, createQNAWidget as u, defaultQnaUnknownUISpecRenderer as S, renderQnaUISpec as m } from "./qna.js";
|
|
3
|
+
import { GengageSimRel as C, createDefaultSimRelUISpecRegistry as h, createSimRelWidget as U, defaultSimRelUnknownUISpecRenderer as A, renderSimRelUISpec as I } from "./simrel.js";
|
|
4
|
+
import { X as R, Y as T, b as D, c as E, a0 as w, j as W, a3 as x, A as G, r as O, a8 as P, a9 as M, aa as Q, W as _, ab as b, ac as k } from "./schemas-CPkzbgia.js";
|
|
5
|
+
import { AccountRuntimeConfigSchema as N, AnalyticsAuthModeSchema as v, BASE_WIDGET_THEME as F, DEFAULT_CUSTOMIZATION_LOCALE as V, UnknownActionPolicySchema as B, autoDetectPageContext as H, buildOverlayIdempotencyKey as K, createAccountIdentity as j, createAnalyticsClient as z, createDefaultAccountRuntimeConfig as X, createDefaultAnalyticsConfig as Y, createFloatingChatConfig as Z, createPdpQnaConfig as q, createPdpSimRelConfig as J, destroyOverlayWidgets as $, detectPageType as ee, extractSkuFromUrl as te, getMerchantConfig as ae, getMerchantIds as ne, getOverlayWidgets as re, initGengageClient as ie, initOverlayWidgets as ce, parseAccountRuntimeConfig as oe, preflightDiagnostics as se, safeParseAccountRuntimeConfig as ge, withBaseTheme as le } from "./common.js";
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
N as AccountRuntimeConfigSchema,
|
|
8
|
+
v as AnalyticsAuthModeSchema,
|
|
9
|
+
F as BASE_WIDGET_THEME,
|
|
10
|
+
V as DEFAULT_CUSTOMIZATION_LOCALE,
|
|
11
|
+
R as DEFAULT_WIDGET_THEME_TOKENS,
|
|
12
12
|
a as GengageChat,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Z as
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
13
|
+
d as GengageQNA,
|
|
14
|
+
C as GengageSimRel,
|
|
15
|
+
B as UnknownActionPolicySchema,
|
|
16
|
+
n as VoiceInput,
|
|
17
|
+
H as autoDetectPageContext,
|
|
18
|
+
T as bootstrapSession,
|
|
19
|
+
D as buildChatEndpointUrl,
|
|
20
|
+
K as buildOverlayIdempotencyKey,
|
|
21
|
+
E as consumeStream,
|
|
22
|
+
j as createAccountIdentity,
|
|
23
|
+
z as createAnalyticsClient,
|
|
24
|
+
r as createChatWidget,
|
|
25
|
+
X as createDefaultAccountRuntimeConfig,
|
|
26
|
+
Y as createDefaultAnalyticsConfig,
|
|
27
|
+
i as createDefaultChatUISpecRegistry,
|
|
28
|
+
p as createDefaultQnaUISpecRegistry,
|
|
29
|
+
h as createDefaultSimRelUISpecRegistry,
|
|
30
|
+
Z as createFloatingChatConfig,
|
|
31
|
+
q as createPdpQnaConfig,
|
|
32
|
+
J as createPdpSimRelConfig,
|
|
33
|
+
u as createQNAWidget,
|
|
34
|
+
U as createSimRelWidget,
|
|
35
|
+
c as defaultChatUnknownUISpecRenderer,
|
|
36
|
+
S as defaultQnaUnknownUISpecRenderer,
|
|
37
|
+
A as defaultSimRelUnknownUISpecRenderer,
|
|
38
|
+
w as defaultUnknownUISpecRenderer,
|
|
39
|
+
$ as destroyOverlayWidgets,
|
|
40
|
+
ee as detectPageType,
|
|
41
|
+
W as dispatch,
|
|
42
|
+
te as extractSkuFromUrl,
|
|
43
|
+
ae as getMerchantConfig,
|
|
44
|
+
ne as getMerchantIds,
|
|
45
|
+
re as getOverlayWidgets,
|
|
46
|
+
ie as initGengageClient,
|
|
47
|
+
ce as initOverlayWidgets,
|
|
48
|
+
o as isVoiceInputSupported,
|
|
49
|
+
x as listen,
|
|
50
|
+
G as normalizeMiddlewareUrl,
|
|
51
|
+
oe as parseAccountRuntimeConfig,
|
|
52
|
+
se as preflightDiagnostics,
|
|
53
|
+
s as renderChatUISpec,
|
|
54
|
+
m as renderQnaUISpec,
|
|
55
|
+
I as renderSimRelUISpec,
|
|
49
56
|
O as renderUISpecWithRegistry,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
g as routeStreamAction,
|
|
58
|
+
ge as safeParseAccountRuntimeConfig,
|
|
59
|
+
P as streamPost,
|
|
60
|
+
M as updatePageContext,
|
|
61
|
+
Q as wireGADataLayer,
|
|
54
62
|
_ as wireQNAToChat,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
b as wireSimilarToChat,
|
|
64
|
+
le as withBaseTheme,
|
|
65
|
+
k as withDefaultWidgetTheme
|
|
58
66
|
};
|
|
59
67
|
//# sourceMappingURL=index.js.map
|
package/dist/qna/catalog.d.ts
CHANGED
|
@@ -5,60 +5,27 @@ export declare const ActionButtonSchema: z.ZodObject<{
|
|
|
5
5
|
title: z.ZodString;
|
|
6
6
|
type: z.ZodString;
|
|
7
7
|
payload: z.ZodOptional<z.ZodUnknown>;
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
payload?: unknown;
|
|
16
|
-
}>;
|
|
17
|
-
variant: z.ZodOptional<z.ZodEnum<["primary", "outline", "ghost"]>>;
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
label: string;
|
|
20
|
-
action: {
|
|
21
|
-
type: string;
|
|
22
|
-
title: string;
|
|
23
|
-
payload?: unknown;
|
|
24
|
-
};
|
|
25
|
-
variant?: "primary" | "outline" | "ghost" | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
label: string;
|
|
28
|
-
action: {
|
|
29
|
-
type: string;
|
|
30
|
-
title: string;
|
|
31
|
-
payload?: unknown;
|
|
32
|
-
};
|
|
33
|
-
variant?: "primary" | "outline" | "ghost" | undefined;
|
|
34
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
primary: "primary";
|
|
11
|
+
outline: "outline";
|
|
12
|
+
ghost: "ghost";
|
|
13
|
+
}>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
35
15
|
export declare const ButtonRowSchema: z.ZodObject<{
|
|
36
|
-
orientation: z.ZodOptional<z.ZodEnum<
|
|
16
|
+
orientation: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
horizontal: "horizontal";
|
|
18
|
+
vertical: "vertical";
|
|
19
|
+
}>>;
|
|
37
20
|
wrap: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
-
},
|
|
39
|
-
orientation?: "horizontal" | "vertical" | undefined;
|
|
40
|
-
wrap?: boolean | undefined;
|
|
41
|
-
}, {
|
|
42
|
-
orientation?: "horizontal" | "vertical" | undefined;
|
|
43
|
-
wrap?: boolean | undefined;
|
|
44
|
-
}>;
|
|
21
|
+
}, z.core.$strip>;
|
|
45
22
|
export declare const TextInputSchema: z.ZodObject<{
|
|
46
|
-
placeholder: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
23
|
+
placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
47
24
|
ctaLabel: z.ZodOptional<z.ZodString>;
|
|
48
|
-
},
|
|
49
|
-
placeholder?: string | string[] | undefined;
|
|
50
|
-
ctaLabel?: string | undefined;
|
|
51
|
-
}, {
|
|
52
|
-
placeholder?: string | string[] | undefined;
|
|
53
|
-
ctaLabel?: string | undefined;
|
|
54
|
-
}>;
|
|
25
|
+
}, z.core.$strip>;
|
|
55
26
|
export declare const QuestionHeadingSchema: z.ZodObject<{
|
|
56
27
|
text: z.ZodString;
|
|
57
|
-
},
|
|
58
|
-
text: string;
|
|
59
|
-
}, {
|
|
60
|
-
text: string;
|
|
61
|
-
}>;
|
|
28
|
+
}, z.core.$strip>;
|
|
62
29
|
export declare const qnaCatalog: {
|
|
63
30
|
readonly components: {
|
|
64
31
|
readonly ActionButton: {
|
|
@@ -68,69 +35,36 @@ export declare const qnaCatalog: {
|
|
|
68
35
|
title: z.ZodString;
|
|
69
36
|
type: z.ZodString;
|
|
70
37
|
payload: z.ZodOptional<z.ZodUnknown>;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
payload?: unknown;
|
|
79
|
-
}>;
|
|
80
|
-
variant: z.ZodOptional<z.ZodEnum<["primary", "outline", "ghost"]>>;
|
|
81
|
-
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
label: string;
|
|
83
|
-
action: {
|
|
84
|
-
type: string;
|
|
85
|
-
title: string;
|
|
86
|
-
payload?: unknown;
|
|
87
|
-
};
|
|
88
|
-
variant?: "primary" | "outline" | "ghost" | undefined;
|
|
89
|
-
}, {
|
|
90
|
-
label: string;
|
|
91
|
-
action: {
|
|
92
|
-
type: string;
|
|
93
|
-
title: string;
|
|
94
|
-
payload?: unknown;
|
|
95
|
-
};
|
|
96
|
-
variant?: "primary" | "outline" | "ghost" | undefined;
|
|
97
|
-
}>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
primary: "primary";
|
|
41
|
+
outline: "outline";
|
|
42
|
+
ghost: "ghost";
|
|
43
|
+
}>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
98
45
|
readonly description: "A single clickable QNA action button.";
|
|
99
46
|
};
|
|
100
47
|
readonly ButtonRow: {
|
|
101
48
|
readonly schema: z.ZodObject<{
|
|
102
|
-
orientation: z.ZodOptional<z.ZodEnum<
|
|
49
|
+
orientation: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
horizontal: "horizontal";
|
|
51
|
+
vertical: "vertical";
|
|
52
|
+
}>>;
|
|
103
53
|
wrap: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
-
},
|
|
105
|
-
orientation?: "horizontal" | "vertical" | undefined;
|
|
106
|
-
wrap?: boolean | undefined;
|
|
107
|
-
}, {
|
|
108
|
-
orientation?: "horizontal" | "vertical" | undefined;
|
|
109
|
-
wrap?: boolean | undefined;
|
|
110
|
-
}>;
|
|
54
|
+
}, z.core.$strip>;
|
|
111
55
|
readonly description: "Container for a group of QNA action buttons.";
|
|
112
56
|
};
|
|
113
57
|
readonly TextInput: {
|
|
114
58
|
readonly schema: z.ZodObject<{
|
|
115
|
-
placeholder: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
59
|
+
placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
116
60
|
ctaLabel: z.ZodOptional<z.ZodString>;
|
|
117
|
-
},
|
|
118
|
-
placeholder?: string | string[] | undefined;
|
|
119
|
-
ctaLabel?: string | undefined;
|
|
120
|
-
}, {
|
|
121
|
-
placeholder?: string | string[] | undefined;
|
|
122
|
-
ctaLabel?: string | undefined;
|
|
123
|
-
}>;
|
|
61
|
+
}, z.core.$strip>;
|
|
124
62
|
readonly description: "Free-text input with rotating placeholder and CTA button.";
|
|
125
63
|
};
|
|
126
64
|
readonly QuestionHeading: {
|
|
127
65
|
readonly schema: z.ZodObject<{
|
|
128
66
|
text: z.ZodString;
|
|
129
|
-
},
|
|
130
|
-
text: string;
|
|
131
|
-
}, {
|
|
132
|
-
text: string;
|
|
133
|
-
}>;
|
|
67
|
+
}, z.core.$strip>;
|
|
134
68
|
readonly description: "A heading displayed above the QNA button group.";
|
|
135
69
|
};
|
|
136
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/qna/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/qna/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;iBAG1B,CAAC;AAEH,eAAO,MAAM,eAAe;;;iBAG1B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;iBAEhC,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBb,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../src/qna/components/TextInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../src/qna/components/TextInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW,CAmEtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderUISpec.d.ts","sourceRoot":"","sources":["../../../src/qna/components/renderUISpec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,KAAK,EAAE,MAAM,EAA4B,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"renderUISpec.d.ts","sourceRoot":"","sources":["../../../src/qna/components/renderUISpec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,KAAK,EAAE,MAAM,EAA4B,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;AAqJ1E,eAAO,MAAM,+BAA+B,EAAE,wBAAwB,CAAC,sBAAsB,CAgB5F,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,iBAAiB,CAElE;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,oBAA+B,EACvC,eAAe,GAAE,wBAAwB,CAAC,sBAAsB,CAAmC,GAClG,WAAW,CAQb"}
|
package/dist/qna/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare class GengageQNA extends BaseWidget<QNAWidgetConfig> {
|
|
|
13
13
|
protected onHide(): void;
|
|
14
14
|
protected onDestroy(): void;
|
|
15
15
|
private _abort;
|
|
16
|
+
/** Clean up TextInput placeholder rotation timers to prevent interval leaks. */
|
|
17
|
+
private _cleanupTextInputTimers;
|
|
16
18
|
private _fetchAndRender;
|
|
17
19
|
private _createLoadingIndicator;
|
|
18
20
|
private _resolveI18n;
|
package/dist/qna/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/qna/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAIxF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/qna/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAIxF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAgBtD,OAAO,KAAK,EAAE,eAAe,EAAmC,MAAM,YAAY,CAAC;AAInF,OAAO,sBAAsB,CAAC;AAE9B,qBAAa,UAAW,SAAQ,UAAU,CAAC,eAAe,CAAC;IACzD,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,KAAK,CAAwB;cAErB,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAavD,SAAS,CAAC,MAAM,IAAI,IAAI;IAUxB,SAAS,CAAC,MAAM,IAAI,IAAI;IAIxB,SAAS,CAAC,SAAS,IAAI,IAAI;IAiB3B,OAAO,CAAC,MAAM;IAKd,gFAAgF;IAChF,OAAO,CAAC,uBAAuB;YAQjB,eAAe;IAmJ7B,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,yBAAyB;IAiCjC,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,eAAe;IAKvB,cAAc,WAXgB,aAAa,KAAG,IAAI,CAWH;IAC/C,gBAAgB,QANW,IAAI,CAMoB;CACpD;AAED,wBAAgB,eAAe,IAAI,UAAU,CAE5C;AAED,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACvH,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,+BAA+B,GAChC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/qna.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./types-CeON7iBO.cjs");async function q(n,e,t){const i=s.buildChatEndpointUrl("launcher_action",e),o={uiSpecs:[],actions:[]},r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)};t!==void 0&&(r.signal=t);const a=await fetch(i,r);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const c={onEvent:l=>{const u=s.adaptV1Event(l);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const p of Object.values(u.spec.elements))if(p.type==="ActionButton"&&p.props?.action){const h=p.props.action;o.actions.push(h)}}}};return t!==void 0&&(c.signal=t),await s.consumeStream(a,c),o}function _(n){const e=document.createElement("div");e.className="gengage-qna-buttons",e.setAttribute("role","group"),e.setAttribute("aria-label",n.quickQuestionsAriaLabel??"Quick questions"),n.orientation==="vertical"&&(e.style.flexDirection="column");for(const t of n.actions){const i=document.createElement("button");i.className="gengage-qna-button",i.textContent=t.title,i.type="button",i.addEventListener("click",()=>{const o={title:t.title,type:t.type};t.payload!==void 0&&(o.payload=t.payload),n.onAction(o)}),e.appendChild(i)}if(n.ctaText||n.onOpenChat){const t=document.createElement("button");t.className="gengage-qna-cta",t.textContent=n.ctaText??n.defaultCtaText??"Başka bir şey sor",t.type="button",t.addEventListener("click",()=>{n.onOpenChat?.()}),e.appendChild(t)}return e}function w(n){const e=document.createElement("div");e.className="gengage-qna-input-wrapper";const t=document.createElement("input");t.type="text",t.className="gengage-qna-input",t.setAttribute("aria-label",n.askQuestionAriaLabel??"Ask a question");const i=Array.isArray(n.placeholders)?n.placeholders:n.placeholders?[n.placeholders]:[n.defaultInputPlaceholder??"Bir soru sorun..."];let o=0;t.placeholder=i[0]??"";let r=null;i.length>1&&(r=setInterval(()=>{t.classList.add("gengage-qna-input--fade"),setTimeout(()=>{o=(o+1)%i.length,t.placeholder=i[o]??"",t.classList.remove("gengage-qna-input--fade")},180)},3e3));const a=document.createElement("button");a.className="gengage-qna-send",a.type="button",a.textContent=n.ctaLabel??n.sendButtonText??"Sor",a.setAttribute("aria-label",n.sendQuestionAriaLabel??"Send question");const c=()=>{const l=t.value.trim();l&&(n.onSubmit({title:l,type:"user_message",payload:l}),t.value="")};return a.addEventListener("click",c),t.addEventListener("keydown",l=>{l.key==="Enter"&&(l.preventDefault(),c())}),e.appendChild(t),e.appendChild(a),e._cleanup=()=>{r&&clearInterval(r)},e}function f(n,e){if(!n||typeof n!="object")return null;const t=n,i=t.type;if(typeof i!="string"||i.length===0)return null;const o=t.title,r=t.payload,a=typeof o=="string"&&o.length>0?o:e;if(!a)return null;const c={title:a,type:i};return r!==void 0&&(c.payload=r),c}function A(n){const e={title:n.title,type:n.type};return n.payload!==void 0&&(e.payload=n.payload),e}function T(n,e){const t=[],i=n.props?.actions;if(Array.isArray(i))for(const a of i){const c=f(a);c&&t.push(c)}const o=n.props?.buttons;if(Array.isArray(o))for(const a of o){if(!a||typeof a!="object")continue;const c=a,l=typeof c.label=="string"?c.label:void 0,u=f(c.action,l);u&&t.push(u)}if(n.children)for(const a of n.children){const c=e.elements[a];if(!c||c.type!=="ActionButton")continue;const l=typeof c.props?.label=="string"?c.props.label:void 0,u=f(c.props?.action,l);u&&t.push(u)}const r=new Set;return t.filter(a=>r.has(a.title)?!1:(r.add(a.title),!0))}const C={ButtonRow:({element:n,spec:e,context:t})=>{const i=T(n,e).map(A),o=n.props?.orientation,r={actions:i,onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(r.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(r.ctaText=t.ctaText),(o==="horizontal"||o==="vertical")&&(r.orientation=o),_(r)},ActionButtons:({element:n,spec:e,context:t})=>{const o={actions:T(n,e).map(A),onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(o.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(o.ctaText=t.ctaText),_(o)},ActionButton:({element:n,context:e})=>{const t=document.createElement("button");t.className="gengage-qna-button",t.type="button";const i=n.props?.label;typeof i=="string"?t.textContent=i:t.textContent=e.i18n.defaultCtaText;const o=f(n.props?.action,typeof i=="string"?i:void 0);return o&&t.addEventListener("click",()=>e.onAction(o)),t},TextInput:({element:n,context:e})=>{const t=n.props?.placeholder,i=typeof t=="string"||Array.isArray(t)?t:e.inputPlaceholder,o=typeof n.props?.ctaLabel=="string"?n.props.ctaLabel:e.ctaText,r={onSubmit:e.onAction,askQuestionAriaLabel:e.i18n.askQuestionAriaLabel,defaultInputPlaceholder:e.i18n.defaultInputPlaceholder,sendButtonText:e.i18n.sendButton,sendQuestionAriaLabel:e.i18n.sendQuestionAriaLabel};return i!==void 0&&(r.placeholders=i),o!==void 0&&(r.ctaLabel=o),w(r)},QuestionHeading:({element:n})=>{const e=document.createElement("h3");e.className="gengage-qna-heading";const t=n.props?.text;return e.textContent=typeof t=="string"?t:"",e}},b=({element:n,renderElement:e})=>{if(!n.children||n.children.length===0)return null;const t=document.createElement("div");for(const i of n.children){const o=e(i);o&&t.appendChild(o)}return t};function E(){return{...C}}function v(n,e,t=C,i=b){return s.renderUISpecWithRegistry({spec:n,context:e,registry:t,containerClassName:"gengage-qna-uispec",unknownRenderer:i})}const S={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},Q={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function L(n){return n?n.toLowerCase().split("-")[0]??"tr":"tr"}function R(n){return L(n)==="en"?Q:S}const x=s.objectType({title:s.stringType(),type:s.stringType(),payload:s.unknownType().optional()}),N=s.objectType({label:s.stringType(),action:x,variant:s.enumType(["primary","outline","ghost"]).optional()}),B=s.objectType({orientation:s.enumType(["horizontal","vertical"]).optional(),wrap:s.booleanType().optional()}),U=s.objectType({placeholder:s.unionType([s.stringType(),s.arrayType(s.stringType())]).optional(),ctaLabel:s.stringType().optional()}),O=s.objectType({text:s.stringType()}),P={components:{ActionButton:{schema:N,description:"A single clickable QNA action button."},ButtonRow:{schema:B,description:"Container for a group of QNA action buttons."},TextInput:{schema:U,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:O,description:"A heading displayed above the QNA button group."}}};class I extends s.BaseWidget{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=S,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 t=e.pageContext?.sku;t&&(this._lastSku=t,await this._fetchAndRender(t)),this.isVisible=!0}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._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 t=this._createLoadingIndicator();this._contentEl.appendChild(t);const i={middlewareUrl:this.config.middlewareUrl},o=crypto.randomUUID(),r=Date.now();this.track(s.streamStartEvent(this.analyticsContext(),{endpoint:"launcher_action",request_id:o,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"},c=this.config.pageContext?.pageType;c!==void 0&&(a.page_type=c);const l=await q(a,i,this._abortController.signal);if(this.track(s.streamDoneEvent(this.analyticsContext(),{request_id:o,latency_ms:Date.now()-r,chunk_count:l.actions.length,widget:"qna"})),this.track(s.widgetHistorySnapshotEvent(this.analyticsContext(),{message_count:l.actions.length,history_ref:o,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(l.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const d=document.createElement("h3");d.className="gengage-qna-heading",d.textContent=this.config.staticQuestionText,this._contentEl.appendChild(d)}const p=this.config.inputPlaceholder,h=l.actions.length>0&&p===!0?l.actions.map(d=>d.title):p===!0?this._i18n.defaultInputPlaceholder:p,g={onAction:this._actionHandler,i18n:this._i18n};p===void 0&&(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),h!==void 0&&(g.inputPlaceholder=h);const k=this._buildFallbackActionsSpec(l.actions),m=(l.uiSpecs.length>0?l.uiSpecs:[k]).filter(d=>Object.keys(d.elements).length>0);for(const d of m){const y=this._renderUISpec(d,g);this._contentEl.appendChild(y)}if(p!==void 0&&!this._specIncludesType(m,"TextInput")){const d={root:"root",elements:{root:{type:"TextInput",props:{placeholder:h,ctaLabel:this.config.ctaText}}}},y=this._renderUISpec(d,g);this._contentEl.appendChild(y)}}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return;s.dispatch("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:s.getGlobalErrorMessage(this.config.locale)}),this.track(s.streamErrorEvent(this.analyticsContext(),{request_id:o,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 t=0;t<3;t++){const i=document.createElement("div");i.className="gengage-qna-loading-dot",e.appendChild(i)}return e}_resolveI18n(e){return{...R(e.locale),...e.i18n}}_resolveUISpecRegistry(){const e=E();return s.mergeUISpecRegistry(e,this.config.renderer?.registry)}_renderUISpec(e,t){const i=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??b,r=(l,u)=>v(l,u,i,o),a=this.config.renderer?.renderUISpec;return a?a(e,t,{registry:i,unknownRenderer:o,defaultRender:r}):r(e,t)}_specIncludesType(e,t){for(const i of e)for(const o of Object.values(i.elements))if(o.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},i=[];for(let o=0;o<e.length;o++){const r=e[o],a=`action-${o}`;i.push(a),t[a]={type:"ActionButton",props:{label:r.title,action:{title:r.title,type:r.type,payload:r.payload}}}}return t.root={type:"ButtonRow",children:i},{root:"root",elements:t}}_handleAction(e){this.config.onActionSelected?.(e),s.dispatch("gengage:qna:action",e)}_handleOpenChat(){this.config.onOpenChat?.(),s.dispatch("gengage:qna:open-chat",{})}}function H(){return new I}exports.GengageQNA=I;exports.createDefaultQnaUISpecRegistry=E;exports.createQNAWidget=H;exports.defaultQnaUnknownUISpecRenderer=b;exports.qnaCatalog=P;exports.renderQnaUISpec=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./schemas-tCxs1sED.cjs");async function q(n,e,t){const i=s.buildChatEndpointUrl("launcher_action",e),o={uiSpecs:[],actions:[]},r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)};t!==void 0&&(r.signal=t);const a=await fetch(i,r);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const c={onEvent:u=>{const l=s.adaptV1Event(u);if(l&&(l.type==="ui_spec"&&o.uiSpecs.push(l.spec),l.type==="ui_spec"&&l.spec.elements)){for(const p of Object.values(l.spec.elements))if(p.type==="ActionButton"&&p.props?.action){const h=p.props.action;o.actions.push(h)}}}};return t!==void 0&&(c.signal=t),await s.consumeStream(a,c),o}function _(n){const e=document.createElement("div");e.className="gengage-qna-buttons",e.setAttribute("role","group"),e.setAttribute("aria-label",n.quickQuestionsAriaLabel??"Quick questions"),n.orientation==="vertical"&&(e.style.flexDirection="column");for(const t of n.actions){const i=document.createElement("button");i.className="gengage-qna-button",i.textContent=t.title,i.type="button",i.addEventListener("click",()=>{const o={title:t.title,type:t.type};t.payload!==void 0&&(o.payload=t.payload),n.onAction(o)}),e.appendChild(i)}if(n.ctaText||n.onOpenChat){const t=document.createElement("button");t.className="gengage-qna-cta",t.textContent=n.ctaText??n.defaultCtaText??"Başka bir şey sor",t.type="button",t.addEventListener("click",()=>{n.onOpenChat?.()}),e.appendChild(t)}return e}function w(n){const e=document.createElement("div");e.className="gengage-qna-input-wrapper";const t=document.createElement("input");t.type="text",t.className="gengage-qna-input",t.setAttribute("aria-label",n.askQuestionAriaLabel??"Ask a question");const i=Array.isArray(n.placeholders)?n.placeholders:n.placeholders?[n.placeholders]:[n.defaultInputPlaceholder??"Bir soru sorun..."];let o=0;t.placeholder=i[0]??"";let r=null,a=null;i.length>1&&(r=setInterval(()=>{t.classList.add("gengage-qna-input--fade"),a=setTimeout(()=>{o=(o+1)%i.length,t.placeholder=i[o]??"",t.classList.remove("gengage-qna-input--fade")},180)},3e3));const c=document.createElement("button");c.className="gengage-qna-send",c.type="button",c.textContent=n.ctaLabel??n.sendButtonText??"Sor",c.setAttribute("aria-label",n.sendQuestionAriaLabel??"Send question");const u=()=>{const l=t.value.trim();l&&(n.onSubmit({title:l,type:"user_message",payload:{text:l}}),t.value="")};return c.addEventListener("click",u),t.addEventListener("keydown",l=>{l.key==="Enter"&&(l.preventDefault(),u())}),e.appendChild(t),e.appendChild(c),e._cleanup=()=>{r&&clearInterval(r),a&&clearTimeout(a)},e}function f(n,e){if(!n||typeof n!="object")return null;const t=n,i=t.type;if(typeof i!="string"||i.length===0)return null;const o=t.title,r=t.payload,a=typeof o=="string"&&o.length>0?o:e;if(!a)return null;const c={title:a,type:i};return r!==void 0&&(c.payload=r),c}function A(n){const e={title:n.title,type:n.type};return n.payload!==void 0&&(e.payload=n.payload),e}function T(n,e){const t=[],i=n.props?.actions;if(Array.isArray(i))for(const a of i){const c=f(a);c&&t.push(c)}const o=n.props?.buttons;if(Array.isArray(o))for(const a of o){if(!a||typeof a!="object")continue;const c=a,u=typeof c.label=="string"?c.label:void 0,l=f(c.action,u);l&&t.push(l)}if(n.children)for(const a of n.children){const c=e.elements[a];if(!c||c.type!=="ActionButton")continue;const u=typeof c.props?.label=="string"?c.props.label:void 0,l=f(c.props?.action,u);l&&t.push(l)}const r=new Set;return t.filter(a=>r.has(a.title)?!1:(r.add(a.title),!0))}const C={ButtonRow:({element:n,spec:e,context:t})=>{const i=T(n,e).map(A),o=n.props?.orientation,r={actions:i,onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(r.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(r.ctaText=t.ctaText),(o==="horizontal"||o==="vertical")&&(r.orientation=o),_(r)},ActionButtons:({element:n,spec:e,context:t})=>{const o={actions:T(n,e).map(A),onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(o.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(o.ctaText=t.ctaText),_(o)},ActionButton:({element:n,context:e})=>{const t=document.createElement("button");t.className="gengage-qna-button",t.type="button";const i=n.props?.label;typeof i=="string"?t.textContent=i:t.textContent=e.i18n.defaultCtaText;const o=f(n.props?.action,typeof i=="string"?i:void 0);return o&&t.addEventListener("click",()=>e.onAction(o)),t},TextInput:({element:n,context:e})=>{const t=n.props?.placeholder,i=typeof t=="string"||Array.isArray(t)?t:e.inputPlaceholder,o=typeof n.props?.ctaLabel=="string"?n.props.ctaLabel:e.ctaText,r={onSubmit:e.onAction,askQuestionAriaLabel:e.i18n.askQuestionAriaLabel,defaultInputPlaceholder:e.i18n.defaultInputPlaceholder,sendButtonText:e.i18n.sendButton,sendQuestionAriaLabel:e.i18n.sendQuestionAriaLabel};return i!==void 0&&(r.placeholders=i),o!==void 0&&(r.ctaLabel=o),w(r)},QuestionHeading:({element:n})=>{const e=document.createElement("h3");e.className="gengage-qna-heading";const t=n.props?.text;return e.textContent=typeof t=="string"?t:"",e},ProductCard:()=>null},m=({element:n,renderElement:e})=>{if(!n.children||n.children.length===0)return null;const t=document.createElement("div");for(const i of n.children){const o=e(i);o&&t.appendChild(o)}return t};function E(){return{...C}}function S(n,e,t=C,i=m){return s.renderUISpecWithRegistry({spec:n,context:e,registry:t,containerClassName:"gengage-qna-uispec",unknownRenderer:i})}const v={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},Q={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function L(n){return n?n.toLowerCase().split("-")[0]??"tr":"tr"}function x(n){return L(n)==="en"?Q:v}const R=s.object({title:s.string(),type:s.string(),payload:s.unknown().optional()}),N=s.object({label:s.string(),action:R,variant:s._enum(["primary","outline","ghost"]).optional()}),B=s.object({orientation:s._enum(["horizontal","vertical"]).optional(),wrap:s.boolean().optional()}),U=s.object({placeholder:s.union([s.string(),s.array(s.string())]).optional(),ctaLabel:s.string().optional()}),O=s.object({text:s.string()}),P={components:{ActionButton:{schema:N,description:"A single clickable QNA action button."},ButtonRow:{schema:B,description:"Container for a group of QNA action buttons."},TextInput:{schema:U,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:O,description:"A heading displayed above the QNA button group."}}};class I extends s.BaseWidget{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=v,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 t=e.pageContext?.sku;t&&(this._lastSku=t,await this._fetchAndRender(t)),this.isVisible=!0,s.trackInit("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const i={middlewareUrl:this.config.middlewareUrl},o=crypto.randomUUID(),r=Date.now();this.track(s.streamStartEvent(this.analyticsContext(),{endpoint:"launcher_action",request_id:o,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"},c=this.config.pageContext?.pageType;c!==void 0&&(a.page_type=c);const u=await q(a,i,this._abortController.signal);if(this.track(s.streamDoneEvent(this.analyticsContext(),{request_id:o,latency_ms:Date.now()-r,chunk_count:u.actions.length,widget:"qna"})),this.track(s.widgetHistorySnapshotEvent(this.analyticsContext(),{message_count:u.actions.length,history_ref:o,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(u.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const d=document.createElement("h3");d.className="gengage-qna-heading",d.textContent=this.config.staticQuestionText,this._contentEl.appendChild(d)}const p=this.config.inputPlaceholder,h=u.actions.length>0&&p===!0?u.actions.map(d=>d.title):p===!0?this._i18n.defaultInputPlaceholder:p,g={onAction:this._actionHandler,i18n:this._i18n};p===void 0&&(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),h!==void 0&&(g.inputPlaceholder=h);const k=this._buildFallbackActionsSpec(u.actions),b=(u.uiSpecs.length>0?u.uiSpecs:[k]).filter(d=>Object.keys(d.elements).length>0);for(const d of b){const y=this._renderUISpec(d,g);this._contentEl.appendChild(y)}if(b.length>0&&s.trackShow("qna"),p!==void 0&&!this._specIncludesType(b,"TextInput")){const d={root:"root",elements:{root:{type:"TextInput",props:{placeholder:h,ctaLabel:this.config.ctaText}}}},y=this._renderUISpec(d,g);this._contentEl.appendChild(y)}}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return;s.dispatch("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:s.getGlobalErrorMessage(this.config.locale)}),this.track(s.streamErrorEvent(this.analyticsContext(),{request_id:o,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 t=0;t<3;t++){const i=document.createElement("div");i.className="gengage-qna-loading-dot",e.appendChild(i)}return e}_resolveI18n(e){return{...x(e.locale),...e.i18n}}_resolveUISpecRegistry(){const e=E();return s.mergeUISpecRegistry(e,this.config.renderer?.registry)}_renderUISpec(e,t){const i=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??m,r=(u,l)=>S(u,l,i,o),a=this.config.renderer?.renderUISpec;return a?a(e,t,{registry:i,unknownRenderer:o,defaultRender:r}):r(e,t)}_specIncludesType(e,t){for(const i of e)for(const o of Object.values(i.elements))if(o.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},i=[];for(let o=0;o<e.length;o++){const r=e[o],a=`action-${o}`;i.push(a),t[a]={type:"ActionButton",props:{label:r.title,action:{title:r.title,type:r.type,payload:r.payload}}}}return t.root={type:"ButtonRow",children:i},{root:"root",elements:t}}_handleAction(e){s.trackSuggestedQuestion(e.title,e.type),this.config.onActionSelected?.(e),s.dispatch("gengage:qna:action",e)}_handleOpenChat(){this.config.onOpenChat?.(),s.dispatch("gengage:qna:open-chat",{})}}function H(){return new I}exports.GengageQNA=I;exports.createDefaultQnaUISpecRegistry=E;exports.createQNAWidget=H;exports.defaultQnaUnknownUISpecRenderer=m;exports.qnaCatalog=P;exports.renderQnaUISpec=S;
|
|
2
2
|
//# sourceMappingURL=qna.cjs.map
|