{"version":3,"sources":["WebChat.js","MinimizableWebChat.js","App.js","serviceWorker.js","index.js"],"names":["props","createDirectLine","memoize","token","state","styleSet","createStyleSet","backgroundColor","this","userId","onFetchToken","className","store","console","log","directLine","userID","React","Component","handleFetchToken","bind","handleMaximizeButtonClick","handleMinimizeButtonClick","handleSwitchButtonClick","createStore","dispatch","next","action","type","payload","activity","from","role","setState","newMessage","minimized","side","entityId","byTimer","setTimeout","window","botInstanceId","botConfigUri","fetch","method","res","json","ress","onClick","App","Boolean","location","hostname","match","ReactDOM","render","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister"],"mappings":"woBAOI,WAAYA,GAAQ,IAAD,8BACf,cAAMA,IAEDC,iBAAmBC,mBAAQ,SAAAC,GAAK,OAAIF,2BAAiB,CAAEE,aAG5D,EAAKC,MAAQ,CACTC,SAAUC,yBAAe,CACrBC,gBAAiB,iBARV,E,iEAcdC,KAAKR,MAAMS,SAAWD,KAAKR,MAAMG,OAASK,KAAKR,MAAMU,iB,+BAGhD,IAAD,EAIDF,KAFAR,MAASW,EAFR,EAEQA,UAAWC,EAFnB,EAEmBA,MACXP,EACTG,KADAJ,MAASC,SAHR,EAKqBG,KAAKR,MAAvBS,EALH,EAKGA,OAAQN,EALX,EAKWA,MAGhB,OAFAU,QAAQC,IAAI,eAAgBL,GAC5BI,QAAQC,IAAI,cAAeX,GAEvBA,GAASM,EACL,kBAAC,IAAD,CACIE,UAAS,UAAKA,GAAa,GAAlB,aACTI,WAAYP,KAAKP,iBAAiBE,GAClCS,MAAOA,EACPP,SAAUA,EACVW,OAAQP,IAGZ,yBAAKE,UAAS,UAAKA,GAAa,GAAlB,qBACV,yBAAKA,UAAU,WACX,yBAAKA,UAAU,QACX,0BAAMA,UAAU,4BAEpB,yE,GAzCKM,IAAMC,Y,oDCIlC,WAAYlB,GAAQ,IAAD,uBAClB,cAAMA,IACDmB,iBAAmB,EAAKA,iBAAiBC,KAAtB,gBACxB,EAAKC,0BAA4B,EAAKA,0BAA0BD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AINA,WACAE,EALM,EAKNA,KACAxB,EANM,EAMNA,MACAP,EAPM,EAONA,SACAF,EARM,EAQNA,MACAM,EATM,EASNA,OATM,EAUN6B,QAIF,OACC,yBAAK3B,UAAU,wBAEbwB,EACC,4BACCxB,UAAU,WACVqC,QAAUxC,KAAKa,2BAEf,0BAAMV,UAAYR,EAAQ,+BAAiC,6BAE1D+B,GACA,0BAAMvB,UAAU,+CAIlB,yBACCA,UAAqB,SAATyB,EAAkB,gBAAkB,kBAEhD,gCACC,yBAAKzB,UAAU,WACf,4BACCA,UAAU,SACVqC,QAAUxC,KAAKe,yBAGf,0BAAMZ,UAAU,6BAEjB,4BACCA,UAAU,WACVqC,QAAUxC,KAAKc,2BAGf,0BAAMX,UAAU,sCAGlB,kBAAC,EAAD,CACCA,UAAU,iBACVC,MAAQA,EACRP,SAAWA,EACXF,MAAQA,EACRM,OAASA,EACTC,aAAeF,KAAKW,yB,GAjKCF,IAAMC,WCOpB+B,G,+KARb,OACC,yBAAKtC,UAAU,OACd,kBAAC,EAAD,W,GAJcO,cCOEgC,QACW,cAA7BV,OAAOW,SAASC,UAEe,UAA7BZ,OAAOW,SAASC,UAEhBZ,OAAOW,SAASC,SAASC,MACvB,2DCZNC,IAASC,OAAO,kBAAC,EAAD,MAASC,SAASC,eAAe,SD2H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAMC,MAAK,SAAAC,GACjCA,EAAaC,iB","file":"static/js/main.bbde914f.chunk.js","sourcesContent":["import memoize from 'memoize-one';\r\nimport React from 'react';\r\nimport ReactWebChat, { createDirectLine, createStyleSet } from 'botframework-webchat';\r\n\r\nimport './WebChat.css';\r\n\r\nexport default class extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n\r\n this.createDirectLine = memoize(token => createDirectLine({ token }));\r\n \r\n\r\n this.state = {\r\n styleSet: createStyleSet({\r\n backgroundColor: 'Transparent'\r\n })\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n !this.props.userId && !this.props.token && this.props.onFetchToken();\r\n }\r\n\r\n render() {\r\n const {\r\n props: { className, store },\r\n state: { styleSet }\r\n } = this;\r\n const { userId, token } = this.props;\r\n console.log(\"final userid\", userId)\r\n console.log(\"final token\", token)\r\n return (\r\n token && userId ?\r\n \r\n :\r\n
\r\n
\r\n
\r\n \r\n
\r\n

Please wait while we are connecting.

\r\n
\r\n
\r\n );\r\n }\r\n}\r\n","import { createStore, createStyleSet } from 'botframework-webchat';\r\nimport React from 'react';\r\n\r\nimport './fabric-icons-inline.css';\r\nimport './MinimizableWebChat.css';\r\n\r\nimport WebChat from './WebChat';\r\n\r\nexport default class extends React.Component {\r\n\t\r\n\tconstructor(props) {\r\n\t\tsuper(props);\r\n\t\tthis.handleFetchToken = this.handleFetchToken.bind(this);\r\n\t\tthis.handleMaximizeButtonClick = this.handleMaximizeButtonClick.bind(this);\r\n\t\tthis.handleMinimizeButtonClick = this.handleMinimizeButtonClick.bind(this);\r\n\t\tthis.handleSwitchButtonClick = this.handleSwitchButtonClick.bind(this);\r\n\t\t\r\n\t\tconst store = createStore({}, ({dispatch}) => next => action => {\r\n\t\t\tif (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {\r\n\t\t\t\t/*setTimeout(() => {\r\n\t\t\t\t\tconsole.log('DIRECT_LINE/CONNECT_FULFILLED fired!');\r\n\t\t\t\t\tconsole.log('userid:' + this.state.userId);\r\n\t\t\t\t\tdispatch({\r\n\t\t\t\t\t\ttype: 'WEB_CHAT/SEND_EVENT',\r\n\t\t\t\t\t\tpayload: {\r\n\t\t\t\t\t\t\tname: 'webchat/join',\r\n\t\t\t\t\t\t\tvalue: {\r\n\t\t\t\t\t\t\t\tlanguage: window.navigator.language,\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t});\r\n\t\t\t\t}, 1000);*/\r\n\t\t\t} else if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {\r\n\t\t\t\tconsole.log('DIRECT_LINE/INCOMING_ACTIVITY fired!');\r\n\t\t\t\tif (action.payload.activity.from.role === 'bot') {\r\n\t\t\t\t\tthis.setState(() => ({newMessage: true}));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn next(action);\r\n\t\t});\r\n\t\t\r\n\t\tthis.state = {\r\n\t\t\tminimized: true,\r\n\t\t\tnewMessage: false,\r\n\t\t\tside: 'right',\r\n\t\t\tstore,\r\n\t\t\tstyleSet: createStyleSet({\r\n\t\t\t\tbackgroundColor: 'Transparent',\r\n\t\t\t}),\r\n\t\t\tentityId: 0,\r\n\t\t\tbyTimer: false,\r\n\t\t};\r\n\t\t\r\n\t\tsetTimeout(() => {\r\n\t\t\tthis.setState(() => ({\r\n\t\t\t\tminimized: false,\r\n\t\t\t\tnewMessage: false,\r\n\t\t\t\tbyTimer: true,\r\n\t\t\t}));\r\n\t\t}, 30000);\r\n\t}\r\n\t\r\n\tasync handleFetchToken() {\r\n\t\t// if (!this.state.token) {\r\n\t\t//todo: change to needed token\r\n\t\t//and pass needed groupId, inject it\r\n\t\t// const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });\r\n\t\t\r\n\t\t// const { token } = await res.json();\r\n\t\t// const { token } = \"IyyZMeznl70.dAA.RQBRADUARgBoAGQAVAB0AFQAOABuAEMAeABzAHcAUABwAGwANAAzAEIAVAAtAGEA.Jtta4v8E1QE.8qQf6jlu_5I.rqkHj0oeItP4Ymi6vhsImZhW8mgxZOcFSjh7GO9_F5A\";\r\n\t\t// console.log('http://localhost:3978/botview/GetChatConfig?groupid=5' );\r\n\t\t\r\n\t\tconsole.log('byTimer' + this.state.byTimer);\r\n\t\tconsole.log('custom var ' + window.botInstanceId);\r\n\t\tconsole.log('custom var ' + window.botConfigUri);\r\n\t\t\r\n\t\t// console.log('https://wabs-ags3-devel-botservice.azurewebsites.net/botview/GetChatConfig?groupid=');\r\n\t\tif (!this.state.token) {\r\n\t\t\tconst res = await fetch(window.botConfigUri + window.botInstanceId + '&byTimer=' + this.state.byTimer, {method: 'GET'});\r\n\t\t\t// const res = await fetch('https://tinybot.azurewebsites.net/BotView/GetChatConfig?groupid=4', { method: 'GET' });\r\n\t\t\tconst ress = await res.json();\r\n\t\t\tconst token = ress.token;\r\n\t\t\tlet userId = ress.userId;\r\n\t\t\t// let byTimer = this.state.byTimer;\r\n\t\t\t\r\n\t\t\tthis.setState({\r\n\t\t\t\ttoken: token,\r\n\t\t\t\tuserId: userId\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\t\r\n\thandleMaximizeButtonClick() {\r\n\t\tthis.setState(() => ({\r\n\t\t\tminimized: false,\r\n\t\t\tnewMessage: false,\r\n\t\t}));\r\n\t}\r\n\t\r\n\thandleMinimizeButtonClick() {\r\n\t\tthis.setState(() => ({\r\n\t\t\tminimized: true,\r\n\t\t\tnewMessage: false,\r\n\t\t}));\r\n\t}\r\n\t\r\n\thandleSwitchButtonClick() {\r\n\t\tthis.setState(({side}) => ({\r\n\t\t\tside: side === 'left' ? 'right' : 'left',\r\n\t\t}));\r\n\t}\r\n\t\r\n\trender() {\r\n\t\tconst {\r\n\t\t\tstate: {\r\n\t\t\t\tminimized,\r\n\t\t\t\tnewMessage,\r\n\t\t\t\tside,\r\n\t\t\t\tstore,\r\n\t\t\t\tstyleSet,\r\n\t\t\t\ttoken,\r\n\t\t\t\tuserId,\r\n\t\t\t\tbyTimer,\r\n\t\t\t},\r\n\t\t} = this;\r\n\t\t\r\n\t\treturn (\r\n\t\t\t
\r\n\t\t\t\t{\r\n\t\t\t\t\tminimized ?\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnewMessage &&\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t:\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t
\r\n\t\t\t\t}\r\n\t\t\t\r\n\t\t\t: \"\"\r\n\t\t);\r\n\t}\r\n}","import React, { Component } from 'react';\r\nimport MinimizableWebChat from './MinimizableWebChat';\r\n\r\nimport './App.css';\r\n\r\nclass App extends Component {\r\n\trender() {\r\n\t\treturn (\r\n\t\t\t
\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t);\r\n\t}\r\n}\r\n\r\nexport default App;\r\n","// This optional code is used to register a service worker.\r\n// register() is not called by default.\r\n\r\n// This lets the app load faster on subsequent visits in production, and gives\r\n// it offline capabilities. However, it also means that developers (and users)\r\n// will only see deployed updates on subsequent visits to a page, after all the\r\n// existing tabs open on the page have been closed, since previously cached\r\n// resources are updated in the background.\r\n\r\n// To learn more about the benefits of this model and instructions on how to\r\n// opt-in, read https://bit.ly/CRA-PWA\r\n\r\nconst isLocalhost = Boolean(\r\n window.location.hostname === 'localhost' ||\r\n // [::1] is the IPv6 localhost address.\r\n window.location.hostname === '[::1]' ||\r\n // 127.0.0.1/8 is considered localhost for IPv4.\r\n window.location.hostname.match(\r\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\r\n )\r\n);\r\n\r\nexport function register(config) {\r\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\r\n // The URL constructor is available in all browsers that support SW.\r\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\r\n if (publicUrl.origin !== window.location.origin) {\r\n // Our service worker won't work if PUBLIC_URL is on a different origin\r\n // from what our page is served on. This might happen if a CDN is used to\r\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\r\n return;\r\n }\r\n\r\n window.addEventListener('load', () => {\r\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\r\n\r\n if (isLocalhost) {\r\n // This is running on localhost. Let's check if a service worker still exists or not.\r\n checkValidServiceWorker(swUrl, config);\r\n\r\n // Add some additional logging to localhost, pointing developers to the\r\n // service worker/PWA documentation.\r\n navigator.serviceWorker.ready.then(() => {\r\n console.log(\r\n 'This web app is being served cache-first by a service ' +\r\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\r\n );\r\n });\r\n } else {\r\n // Is not localhost. Just register service worker\r\n registerValidSW(swUrl, config);\r\n }\r\n });\r\n }\r\n}\r\n\r\nfunction registerValidSW(swUrl, config) {\r\n navigator.serviceWorker\r\n .register(swUrl)\r\n .then(registration => {\r\n registration.onupdatefound = () => {\r\n const installingWorker = registration.installing;\r\n if (installingWorker == null) {\r\n return;\r\n }\r\n installingWorker.onstatechange = () => {\r\n if (installingWorker.state === 'installed') {\r\n if (navigator.serviceWorker.controller) {\r\n // At this point, the updated precached content has been fetched,\r\n // but the previous service worker will still serve the older\r\n // content until all client tabs are closed.\r\n console.log(\r\n 'New content is available and will be used when all ' +\r\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\r\n );\r\n\r\n // Execute callback\r\n if (config && config.onUpdate) {\r\n config.onUpdate(registration);\r\n }\r\n } else {\r\n // At this point, everything has been precached.\r\n // It's the perfect time to display a\r\n // \"Content is cached for offline use.\" message.\r\n console.log('Content is cached for offline use.');\r\n\r\n // Execute callback\r\n if (config && config.onSuccess) {\r\n config.onSuccess(registration);\r\n }\r\n }\r\n }\r\n };\r\n };\r\n })\r\n .catch(error => {\r\n console.error('Error during service worker registration:', error);\r\n });\r\n}\r\n\r\nfunction checkValidServiceWorker(swUrl, config) {\r\n // Check if the service worker can be found. If it can't reload the page.\r\n fetch(swUrl)\r\n .then(response => {\r\n // Ensure service worker exists, and that we really are getting a JS file.\r\n const contentType = response.headers.get('content-type');\r\n if (\r\n response.status === 404 ||\r\n (contentType != null && contentType.indexOf('javascript') === -1)\r\n ) {\r\n // No service worker found. Probably a different app. Reload the page.\r\n navigator.serviceWorker.ready.then(registration => {\r\n registration.unregister().then(() => {\r\n window.location.reload();\r\n });\r\n });\r\n } else {\r\n // Service worker found. Proceed as normal.\r\n registerValidSW(swUrl, config);\r\n }\r\n })\r\n .catch(() => {\r\n console.log(\r\n 'No internet connection found. App is running in offline mode.'\r\n );\r\n });\r\n}\r\n\r\nexport function unregister() {\r\n if ('serviceWorker' in navigator) {\r\n navigator.serviceWorker.ready.then(registration => {\r\n registration.unregister();\r\n });\r\n }\r\n}\r\n","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport App from './App';\r\nimport * as serviceWorker from './serviceWorker';\r\n\r\nReactDOM.render(, document.getElementById('root'));\r\n\r\n// If you want your app to work offline and load faster, you can change\r\n// unregister() to register() below. Note this comes with some pitfalls.\r\n// Learn more about service workers: https://bit.ly/CRA-PWA\r\nserviceWorker.unregister();\r\n"],"sourceRoot":""}