"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),l=require("react"),i=require("./provider.js"),p=require("./useStreamLayerApp2.js"),S=()=>i.Tt,f=i.styled_default(S())({name:"QuestionWrap",class:"q10hhsxv",propsAsIs:!0}),g=({gamification:e,sdk:o,persistent:n,skipAutoClose:a,hideHeader:d,insightId:t})=>{const s=l.useRef(""),h=i.useStore(e.openedQuestion.$store);return l.useEffect(()=>t?(!n||e.isOpenedQuestion(t)||(s.current=t,e.getFeedItem(t).then(r=>{var c;s.current===t&&((c=r==null?void 0:r.attributes)==null?void 0:c.attributes.case)==="insight"&&e.openQuestion(t,r)})),()=>{s.current=""}):(e.activeQuestionId.subscribe(({data:r})=>{var c;r&&((c=r.feedItem)==null?void 0:c.type)==="insight"&&(!n||e.isOpenedQuestion(r.feedItem.id)||(s.current=r.feedItem.id,e.openQuestion(r.feedItem.id,r.feedItem))),!r&&s.current&&(e.closeQuestion(s.current),s.current="")}),()=>{}),[e,n,t]),h?u.jsx(f,{sdk:o,skipAutoClose:a,hideHeader:d,gamification:e,hideSponsor:!0}):null},m=({sdk:e,persistent:o,skipAutoClose:n,insightId:a,hideHeader:d})=>{if(!i.useStore(e.featuresList.getStore()))return null;const t=e.getFeature(p.SdkOverlayType.GAMES);return t?u.jsx(g,{insightId:a,sdk:e,persistent:o,hideHeader:d,gamification:t,skipAutoClose:n}):null},I=({event:e,theme:o,hideHeader:n,skipAutoClose:a,persistent:d})=>{const t=i.useStreamLayer(),s=i.useStreamLayerTheme();return t?u.jsxs("div",{className:"StreamLayerSDK",children:[u.jsx(i.h,{customTheme:o??s.theme,themeMode:s.themeMode,children:u.jsx(m,{skipAutoClose:a,sdk:t,hideHeader:n,persistent:d})}),e!==void 0&&u.jsx(i.StreamLayerSDKEvent,{event:e})]}):null};exports.StreamLayerSDKInsight=I;exports.StreamLayerSDKInsightUI=m;
