UNPKG

node-red-contrib-chatbot

Version:

REDBot a Chat bot for a full featured chat bot for Telegram, Facebook Messenger and Slack. Almost no coding skills required

25 lines 337 kB
(self.webpackChunknode_red_contrib_chatbot=self.webpackChunknode_red_contrib_chatbot||[]).push([[331],{54331:(e,t,n)=>{"use strict";n.r(t);var a=n(67294),l=n(18985),r=n(25912),o=n(46111),i=n(80091),s=n(71777),c=n(48891),u=n(77560);var m=n(84197),d=n(63792),p=n(66352),g=n(89061);function h(){return h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},h.apply(this,arguments)}const f=[{name:"authorization.notAuthorized",description:"Shown when the user is not authorized in a private chatbot"},{name:"authorization.suspended",description:"Shown when the user is suspeded in a public chatbot"},{name:"authorization.userNotFound",description:"Shown when the user is not found on the local db, something went wrong"}],{NodeRedNode:y,SlugHelp:b,TypeCommand:E}=r.AK;(0,l.plug)("user-tabs",(({formValue:e={},formError:t=null,onChange:n})=>(e=e||{},a.createElement(o.Z,{formValue:e,formError:t,onChange:n,fluid:!0,autoComplete:"off"},a.createElement(i.Z,null,a.createElement(s.Z,null,"Authorized"),a.createElement(c.Z,{onChange:t=>n({...e,authorized:t,suspended:!t&&e.suspended}),checked:e.authorized}),a.createElement(u.Z,null,"Only authorized users can access private chatbot")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Suspend"),a.createElement(c.Z,{onChange:t=>n({...e,suspended:t,authorized:!t&&e.authorized}),checked:e.suspended}),a.createElement(u.Z,null,"Suspended user cannot access a public chatbot"))))),{id:"suspend-user",label:"Access",permission:"users.authorize"}),(0,l.plug)("sidebar",null,{permission:"configure",id:"configuration",label:"Configuration",icon:"cog",options:[{id:"authorization",label:"Bot Access",url:"/authorization"}]}),(0,l.plug)("pages",(0,r.ln)("redbot-authorization",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,y]=(0,a.useState)(e),[b,E]=(0,a.useState)(null),[v,w]=(0,a.useState)("access"),Z=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(m.Z,{appearance:"tabs",activeKey:v,onSelect:w,style:{marginBottom:"25px"}},a.createElement(m.Z.Item,{eventKey:"access"},"Access"),a.createElement(m.Z.Item,{eventKey:"translations"},"Translations")),a.createElement(o.Z,{disabled:!0,formValue:l,formError:b,ref:Z,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{y(e),E(null)},onCheck:e=>{E(e)}},"translations"===v&&a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(d.Z,{name:"translations",accepter:r.Xy,schema:f,disabled:n}))),"access"===v&&a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(s.Z,null,"Private"),a.createElement(d.Z,{name:"private",accepter:(k=c.Z,({value:e,...t})=>a.createElement(k,h({checked:e},t))),disabled:n}),a.createElement(u.Z,null,"In a private chatbot, only authorized user can access"))),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{Z.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&y(e)}},"Reset")))));var k}),{Legend:()=>a.createElement("div",null,a.createElement(y,null,"Authorization"),a.createElement("p",null,"Set the chatbot private, only authorized user will be able to use the chatbot. Set the authorization in the users section."),a.createElement("p",null,"For public chatbot it's possibile to suspend a user.")),title:"Bot Access"}),{permission:"configure",url:"/authorization",title:"Welcome Message",id:"page-authorization"}),(0,l.plug)("permissions",null,{permission:"users.authorize",name:"Authorize/Suspend",description:"Authorize or suspend a user",group:"Users"});var v=n(70319),w=n(98134),Z=n(20968),k=n(19642),x=n(96486),C=n.n(x),S=n(88182);const{StringType:q,ArrayType:I,ObjectType:T,DateType:N}=S.Z.Types,P=S.Z.Model({openings:I().of(T().shape({start:N().isRequired("Specify starting hour"),end:N().isRequired("Specify ending hour"),range:q().isRequired("Select a range for opening hours")})).addRule((e=>C().isArray(e)&&0!==e.length),"Specify at least an opening hour")});var R=n(45697),O=n.n(R),A=n(57770);const z=[{key:"url",type:"string",description:"The url opened clicking on the card button",defaultValue:"http://",color:"red"},{key:"labelButton",type:"string",description:"The label of the card button",defaultValue:"Open",color:"orange"}],j=({value:e,onChange:t,disabled:n=!1})=>a.createElement("div",null,a.createElement(A.Z,{disabled:n,useSlug:!0,canCreate:!0,value:e.slug,customFieldsSchema:z,fluid:!0,onChange:n=>t({...e,slug:n})}));j.propTypes={value:O().shape({slug:O().string}),onChange:O().func,disabled:O().bool};const M=j,B=[{name:"carousel.intro",description:"Introduction text of the carousel"}];(0,l.plug)("sidebar",null,{id:"configuration",label:"Configuration",permission:"configure",icon:"cog",options:[{id:"carousel",label:"Carousel",url:"/configuration-carousel"}]}),(0,l.plug)("pages",(0,w.Z)("carousel",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,r]=(0,a.useState)(e),[c,h]=(0,a.useState)(null),[f,y]=(0,a.useState)("carousel"),b=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(m.Z,{appearance:"tabs",activeKey:f,onSelect:y,style:{marginBottom:"25px"}},a.createElement(m.Z.Item,{eventKey:"carousel"},"Carousel"),a.createElement(m.Z.Item,{eventKey:"translations"},"Translations")),a.createElement(o.Z,{model:P,disabled:!0,formValue:l,formError:c,ref:b,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{r(e),h(null)},onCheck:e=>{h(e)}},"translations"===f&&a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(d.Z,{name:"translations",accepter:k.Z,schema:B,disabled:n}))),"carousel"===f&&a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(s.Z,null,"Carousel Cards",a.createElement(u.Z,{tooltip:!0},"Select one or more content")),a.createElement(d.Z,{name:"cards",accepter:Z.Z,form:M,labelAdd:"Add card",disabled:n}))),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{b.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&r(e)}},"Reset")))))}),{Legend:()=>a.createElement("div",null,a.createElement(v.NodeRedNode,null,"Cards"),a.createElement("p",null,"Configure the carousel of cards to show in the chabot: select one or more ",a.createElement("em",null,"slugs")," from the ",a.createElement("strong",null,"Content")," section."),a.createElement(v.SlugHelp,null)),title:"Carousel"}),{permission:"configure",url:"/configuration-carousel",title:"Carousel",id:"configuration-carousel"});const{StringType:F,ArrayType:K,ObjectType:L,DateType:D}=S.Z.Types,V=S.Z.Model({commands:K().of(L().shape({command:F().isRequired("Specify the command").addRule((e=>e.startsWith("/")),'Command should start with "/"'),slug:F().isRequired("Specifig a slug (shortcut) for a content")})).addRule((e=>{const t=e.map((e=>e.command));return C().uniq(t).length===t.length}),"Some contents have the same command")});var U=n(50721),H=n(85951);const W=({value:e,onChange:t,disabled:n=!1})=>a.createElement(U.Z,{justify:"space-between"},a.createElement(U.Z.Item,{colspan:8},a.createElement(H.Z,{value:e.command,placeholder:"/command",onChange:n=>t({...e,command:n})})),a.createElement(U.Z.Item,{colspan:15},a.createElement(r.MN,{disabled:n,useSlug:!0,canCreate:!0,value:e.slug,fluid:!0,onChange:n=>t({...e,slug:n})})));W.propTypes={value:O().shape({slug:O().string,command:O().string}),onChange:O().func,disabled:O().bool};const $=W,{NodeRedNode:J,SlugHelp:Q,TypeCommand:G}=r.AK;(0,l.plug)("sidebar",null,{id:"configuration",label:"Configuration",permission:"configure",icon:"cog",options:[{id:"commands",label:"Commands",url:"/configuration-commands"}]}),(0,l.plug)("pages",(0,r.ln)("commands",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,c]=(0,a.useState)(e),[m,h]=(0,a.useState)(null),f=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(o.Z,{model:V,disabled:!0,formValue:l,formError:m,ref:f,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{c(e),h(null)},onCheck:e=>{h(e)}},a.createElement(i.Z,null,a.createElement(s.Z,null,"Content Commands",a.createElement(u.Z,{tooltip:!0},"Select one or more content to be shown after a command-line message (like ",a.createElement("em",null,"/privacy"),", etc)")),a.createElement(d.Z,{name:"commands",accepter:r.JX,form:$,labelAdd:"Add command",disabled:n,sortable:!1})),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{f.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&c(e)}},"Reset")))))}),{Legend:()=>a.createElement("div",null,a.createElement(J,null,"Commands"),a.createElement("p",null,"Use the this node to show some contents in response of some command-like messages from users, this is a perfect place to put some statics documents for pricacy or tos (for example ",a.createElement(G,null,"/privacy")," or ",a.createElement(G,null,"/terms"),")."),a.createElement(Q,null)),title:"Commands"}),{permission:"configure",url:"/configuration-commands",title:"Commands",id:"configuration-commands"});var X=n(77188),Y=n(52996);const ee=[{name:"knowledge-base.bestMatch",description:"Text shown before the list of opening hours"},{name:"knowledge-base.sorryNotFound1",description:"Answer when no support articles were found (first version)"},{name:"knowledge-base.sorryNotFound2",description:"Answer when no support articles were found (second version)"},{name:"knowledge-base.sorryNotFound3",description:"Answer when no support articles were found (third version)"},{name:"knowledge-base.askSomething1",description:"What the chatbot answer when the user requests help (first version)"},{name:"knowledge-base.askSomething2",description:"What the chatbot answer when the user requests help (second version)"},{name:"knowledge-base.askSomething3",description:"What the chatbot answer when the user requests help (third version)"},{name:"knowledge-base.no"},{name:"knowledge-base.yes"},{name:"knowledge-base.ok"},{name:"knowledge-base.wasUseful",description:"Asked if an article is useful after a search"},{name:"knowledge-base.thanksBye1",description:"Answer when the user is satisfied with the found article (first version)"},{name:"knowledge-base.thanksBye2",description:"Answer when the user is satisfied with the found article (second version)"},{name:"knowledge-base.thanksBye3",description:"Answer when the user is satisfied with the found article (third version)"},{name:"knowledge-base.selectOneOfThese",description:"Shown when the user is asked to select on of the related articles of a search"},{name:"knowledge-base.somethingWentWrong",description:"Shown when an unrecoverable error occurs"},{name:"knowledge-base.noMoreArticles",description:"Shown when user ask to more results but there aren't"}],{Contents:te,Categories:ne}=r.VY,{NodeRedNode:ae,SlugHelp:le,TypeCommand:re,ChatbotStatus:oe}=r.AK;(0,l.plug)("sidebar",null,{id:"knowledgebase",label:"Knowledge Base",url:"/knowledge-base",icon:"file-text",permission:"faq.edit",options:[{label:"Articles",url:"/knowledge-base",id:"faqs"},{label:"Categories",url:"/knowledge-base/categories",id:"faqs-categories"}]}),(0,l.plug)("sidebar",null,{id:"knowledgebase",label:"Knowledge Base",url:"/knowledge-base",icon:"file-text",permission:["faq.configure","configure"],options:[{label:"Configuration",url:"/knowledge-base/configure",id:"faqs-configure"}]}),(0,l.plug)("pages",ne,{url:"/knowledge-base/categories",title:"Categories",id:"faq-categories",permission:"faq.edit",namespace:"faq",breadcrumbs:[{title:"Knowledge Base",url:"/knowledge-base"},"Categories"]}),(0,l.plug)("pages",(0,r.ln)("knowledge-base",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,h]=(0,a.useState)(e),[f,y]=(0,a.useState)(null),[b,E]=(0,a.useState)("openings"),v=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(m.Z,{appearance:"tabs",activeKey:b,onSelect:E,style:{marginBottom:"25px"}},a.createElement(m.Z.Item,{eventKey:"openings"},"Knowledge Base"),a.createElement(m.Z.Item,{eventKey:"translations"},"Translations")),a.createElement(o.Z,{disabled:!0,formValue:l,formError:f,ref:v,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{h(e),y(null)},onCheck:e=>{y(e)}},"translations"===b&&a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(d.Z,{name:"translations",accepter:r.Xy,schema:ee,disabled:n}))),"openings"===b&&a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(s.Z,null,"Answer by Default"),a.createElement(d.Z,{name:"answerByDefault",accepter:c.Z,disabled:n}),a.createElement(u.Z,null,"With this option ",a.createElement("em",null,"enabled"),", the block execute a search for every input of the user, if ",a.createElement("em",null,"disabled")," the user has to enter in the ",a.createElement("em",null,"ask question state")," entering some sentences like ",a.createElement("em",null,'"I need help"'))),a.createElement(i.Z,null,a.createElement(s.Z,null,"Articles Sensitivity"),a.createElement(d.Z,{disabled:n,name:"threshold",accepter:r.nH}),a.createElement(u.Z,null,"The minimum score of an article to be considered relevant. Lower this value if the search doesn't return any value.")),a.createElement(i.Z,null,a.createElement(s.Z,null,"NLP Sensitivity"),a.createElement(d.Z,{disabled:n,name:"nlpThreshold",accepter:r.nH}),a.createElement(u.Z,null,"The minimum score of an intent to be considered relevant. Lower this value if the NLP doesn't catch any intent of the user input, raise this value if the NLP of this block is interfering with the NLP of other blocks.")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Suggest Articles"),a.createElement(d.Z,{disabled:n,name:"articlesToSuggest",accepter:r.zs,min:1,max:20,style:{maxWidth:"200px"},postfix:a.createElement("span",null," articles")}),a.createElement(u.Z,null,'The maximum articles to suggest if user clicks on "More articles"'))),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{v.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&h(e)}},"Reset")))))}),{Legend:()=>{const{sendMessage:e}=(0,Y.f)();return a.createElement("div",null,a.createElement(ae,null,"Knowledge Base"),a.createElement("p",null,"Configure the ",a.createElement("b",null,"Knowledge Base")," block, use the ",a.createElement("b",null,"Articles")," section to enter the knowledge base of your product or service.",a.createElement("br",null),"For articles that represent the same content but in different languages, use the same ",a.createElement("em",null,"slug"),", the block will take care of the rest."),a.createElement("p",null,"Adjust the sensitivity of the search engine, raise it when the results are not relevant to the user's question, lower it when the search is not returning anything, keep an eye on the system console to see the score of the searches.",a.createElement("br",null),"With ",a.createElement("b",null,"Answer by Default")," the block can answer automatically to any input text message or can start answering only when the chatbot in ",a.createElement(oe,null,"faq.answer")," status, which is entered when the user types senteces like ",a.createElement(re,null,"I need help"),"."),a.createElement(le,null),a.createElement("div",{style:{textAlign:"center",marginTop:"10px"}},a.createElement(g.Z,{appearance:"primary",onClick:()=>{e("faq.refresh"),X.Z.success({title:"Knowledge Base",description:"Re-index of articles started"})}},"Refresh index")))},title:"Knowledge Base"}),{url:"/knowledge-base/configure",title:"Configure",id:"faqs-configure",permission:["faq.configure","configure"]}),(0,l.plug)("pages",te,{url:"/knowledge-base",title:"Knowledge Base",id:"faqs",namespace:"faq",permission:"faq.edit",breadcrumbs:["Knowledge Base","Articles"],labels:{saveContent:"Save article",createContent:"Create article"}}),(0,l.plug)("permissions",null,{permission:"faq.edit",name:"Edit Kwnowledge base",description:"Add and edit articles of the knowledge base",group:"Knowledge Base"}),(0,l.plug)("permissions",null,{permission:"faq.configure",name:"Configure Kwnowledge base",description:"Configure Kwnowledge base",group:"Knowledge Base"});var ie=n(18499),se=n(95990),ce=n(61009),ue=n(78932);const me=se.default` query { contents(namespace: "plugins") { id, title, body, payload, fields { name, value } } } `,de=()=>{const e=(0,ie.xJ)(),{data:t}=(0,ue.Z)({namespace:"market-place"}),[n,l]=(0,a.useState)(null),{put:r}=(0,ce.default)("https://api.jsonbin.io",{headers:{"Content-Type":"application/json","secret-key":null!=t?t.jsonbin_key:null,versioning:"false"}}),o=null!=t&&!C().isEmpty(t.jsonbin_key);return a.createElement(g.Z,{disabled:null!=n||!o,appearance:"primary",onClick:async()=>{l("Loading...");const n=(await e.query({query:me,fetchPolicy:"network-only"})).data.contents.map((e=>{const t=e.fields.reduce(((e,t)=>({...e,[t.name]:t.value})),{});let n=null;return C().isEmpty(t.content_title)&&C().isEmpty(t.content_slug)&&C().isEmpty(t.content_body)||(n={title:t.content_title,slug:t.content_slug,body:t.content_body,namespace:t.content_namespace}),{id:t.id,name:e.title,description:e.body,url:t.url,flow:t.flow,version:t.version,github:t.github,keywords:t.tags,author:{name:t.author,url:t.author_url},content:n,initialConfiguration:null==e.payload||C().isEmpty(e.payload.initial_configuration)?null:e.payload.initial_configuration}}));l("Publishing..."),await r(`/b/${t.jsonbin_id}`,n),l(null),X.Z.success({title:"Published",description:"Plugin list published succesfully "})}},null!=n?n:"Publish plugins")};(0,l.plug)("sidebar",null,{id:"market-place",label:"Market Place",url:"/market-place",icon:"shopping-basket"}),(0,l.plug)("sidebar",null,{id:"configuration",label:"Configuration",permission:"configure",icon:"cog",options:[{id:"configuration-market-place",label:"Market Place",url:"/configuration-market-place"}]}),(0,l.plug)("pages",(0,r.ln)("market-place",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,r]=(0,a.useState)(e),[c,m]=(0,a.useState)(null),h=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(o.Z,{formValue:l,formError:c,ref:h,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{r(e),m(null)},onCheck:e=>{m(e)}},a.createElement(i.Z,null,a.createElement(s.Z,null,"JSONbin.io id"),a.createElement(d.Z,{name:"jsonbin_id",accepter:H.Z,disabled:n}),a.createElement(u.Z,null,"The ",a.createElement("em",null,"id")," of the ",a.createElement("strong",null,"jsonbin.io")," snippet of the plugins meta info")),a.createElement(i.Z,null,a.createElement(s.Z,null,"JSONbin.io key"),a.createElement(d.Z,{name:"jsonbin_key",accepter:H.Z,disabled:n}),a.createElement(u.Z,null,"The ",a.createElement("em",null,"secret key")," to write on ",a.createElement("strong",null,"jsonbin.io"))),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{h.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&r(e)}},"Reset")))))}),{Legend:()=>a.createElement("div",null,"Configure the id and the key to access ",a.createElement("strong",null,"jsonbing.io")," for the plugins met information.",a.createElement("br",null),"Docs about the API ",a.createElement("a",{href:"https://jsonbin.io/api-reference/bins/read",target:"blank"},"here"),"."),title:"Market Place"}),{permission:"configure",url:"/configuration-market-place",title:"Market Place",id:"configuration"}),(0,l.plug)("pages",r.VY.Contents,{url:"/market-place",title:"Market Place",id:"market-place",namespace:"plugins",breadcrumbs:["Market Place","Plugins"],labels:{saveContent:"Save plugin",createContent:"Create plugin",emptyContent:"No plugins"},custom:()=>a.createElement(de,null),customFieldsSchema:[{key:"url",type:"string",description:"URL of the compiled plugin",color:"cyan"},{key:"flow",type:"string",description:"URL of the Node-RED flow for this plugin",color:"cyan"},{key:"id",type:"string",description:"Unique id of the plugin",color:"red"},{key:"version",type:"string",description:"The version of the current (latest) plugin",color:"red"},{key:"github",type:"string",description:"The URL of the github page of the plugin",color:"red"},{key:"author",type:"string",description:"The username of the author of the plugin",color:"orange"},{key:"author_url",type:"string",description:"The home page of the username, if any",color:"orange"},{key:"tags",type:"tags",description:"List of keywords, comma separated",color:"red"},{key:"content_title",type:"string",description:"Create a content with this title",color:"violet"},{key:"content_slug",type:"string",description:"Create a content with this slug",color:"violet"},{key:"content_body",type:"string",description:"Create a content with this body",color:"violet"},{key:"content_namespace",type:"string",description:"Create a content with this namespace",color:"violet"}]}),(0,l.plug)("content-tabs",(({formValue:e={},onChange:t=(()=>{})})=>{const{initial_configuration:n}=e||{};return a.createElement("div",{style:{paddingBottom:"15px"}},a.createElement(r.Ad,{value:C().isEmpty(n)?"":n,height:"55vh",onChange:n=>{t({...e,initial_configuration:C().isEmpty(n)?null:n})}}))}),{id:"content-configuration",label:"Configuration",namespace:["plugins"]});var pe=n(91624);n(83751);const ge=e=>"location"===e?"#5E8263":e?"#D36135":e?"#595D88":"#000000";n(26926);const he=()=>a.createElement(pe.Z,{className:"map-marker",icon:"map-marker",size:"2x",style:{color:"red"}});var fe=n(73727),ye=n(87596),be=n(82122),Ee=n(69873),ve=n(40660),we=n(94184),Ze=n.n(we);function ke(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class xe extends a.Component{render(){const{thumb:e,height:t,width:n,maxWidth:l,maxHeight:r}=this.props,o=t/n;let i=Math.floor(o*l);i>r&&(i=r);const s={backgroundImage:`url(${e})`,backgroundPosition:"center",width:`${l}px`,height:`${i}px`};return a.createElement("div",{style:s})}}ke(xe,"propTypes",{thumb:O().string,height:O().number,width:O().number,maxWidth:O().number,maxHeight:O().number,onClick:O().func}),ke(xe,"defaultProps",{thumb:null,height:null,width:null,maxWidth:200,maxHeight:400,onClick:()=>{}});const Ce=xe;function Se(){return Se=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Se.apply(this,arguments)}const qe=({topic:e,ts:t,content:n,onDelete:l,onZoom:r,thumb:o,image:i,width:s,height:c,maxHeight:u,...m})=>{let d;return C().isEmpty(o)||(d=a.createElement(Ce,{thumb:o,topic:e,width:s,height:c,maxHeight:u,onClick:()=>{console.log("clicked"),r({})}})),a.createElement(Ee.Z,Se({title:e},m,{onMouseLeave:()=>{}}),a.createElement("div",{className:"popover-map-marker"},"vario"))};function Ie(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}qe.propTypes={topic:O().string,thumb:O().string,image:O().string,content:O().string,ts:O().instanceOf(Date),onDelete:O().func,width:O().number,height:O().number},qe.defaultProps={topic:null,thumb:null,image:null,content:null,ts:null,onDelete:()=>{},width:null,height:null};class Te extends a.Component{constructor(e){super(e),this.handleLoaded=this.handleLoaded.bind(this),this.handleClick=this.handleClick.bind(this);const{thumb:t}=e;this.state={needPreload:!C().isEmpty(t),preload:!1,width:null,height:null}}componentDidMount(){const{type:e,color:t}=this.props;null!=this.tooltip&&"tooltip"===e&&(this.tooltip.querySelector(".rs-tooltip-inner").style.backgroundColor=t,this.tooltip.querySelector(".rs-tooltip-arrow").style.backgroundColor=t)}handleLoaded(e){this.setState({preload:!1,width:e.target.width,height:e.target.height},(()=>this.trigger.show()))}handleClick(e){e.preventDefault(),e.stopPropagation();const{thumb:t}=this.props;C().isEmpty(t)?this.trigger.show():this.setState({preload:!0})}render(){const{children:e,point:t,text:n,type:l,popover:r,showPopover:o,thumb:i,image:s,inkColor:c,maxHeight:u,onDeletePoint:m,onShowImage:d}=this.props;let{icon:p,color:g,size:h}=this.props;const{height:f,width:y,preload:b,needPreload:E}=this.state;let v;switch(C().isEmpty(p)&&(p="map-marker"),C().isEmpty(h)&&(h="lg"),C().isEmpty(g)&&(g="#FF3300"),C().isEmpty(c)&&(g="#000000"),new Date(parseInt(t.ts,10)),l){case"icon":v=a.createElement("a",{href:"#",className:Ze()("wrapper-map-marker",{preload:b}),onClick:this.handleClick},b&&a.createElement("img",{src:i,style:{display:"none"},onLoad:this.handleLoaded,alt:""}),a.createElement(pe.Z,{className:Ze()("map-marker",{pointer:o}),icon:p,size:h,style:{color:g}}));break;case"tooltip":v=a.createElement("div",{ref:e=>this.tooltip=e,style:{height:20,backgroundColor:"#ff0000"}},a.createElement(be.Z,{visible:!0},a.createElement("span",{style:{color:c}},n)));break;default:v=null}if(o){if(E&&b)return v;const t=a.createElement(Ee.Z,{onMouseLeave:()=>{}},a.createElement("div",{className:"popover-map-marker"},e));return a.createElement(ve.Z,{trigger:"click",placement:"top",speaker:t,triggerRef:e=>this.trigger=e},v)}return v}}Ie(Te,"propTypes",{point:O().shape({topic:O().string,text:O().string,ts:O().string}).isRequired,icon:O().string,size:O().string,color:O().string,text:O().string,popover:O().string,thumb:O().string,image:O().string,showPopover:O().bool,type:O().oneOf(["icon","tooltip"]),inkColor:O().string,maxHeight:O().number}),Ie(Te,"defaultProps",{icon:"map-marker",color:"#FF3300",text:null,size:"2x",popover:null,thumb:null,image:null,type:"icon",showPopover:!1,inkColor:"#ffffff",maxHeight:480});const Ne=Te,Pe=se.default` query($where: JSON) { records(limit: 50, order: "geohash", where: $where) { id, status, title, latitude, longitude, geohash, payload } }`,{NodeRedNode:_e,SlugHelp:Re,TypeCommand:Oe}=r.AK;(0,l.plug)("sidebar",null,{id:"wiggle",label:"Panopticon",icon:"logo-survey",permission:"wiggle.view",options:[{id:"wiggle-secrets",label:"Secrets",url:"/secrets"},{id:"wiggle-secrets-map",label:"Secrets Map",url:"/secrets-map"}]}),(0,l.plug)("pages",(()=>{const[e,t]=(0,a.useState)(null),[n,l]=(0,a.useState)(!1),o=(0,ie.xJ)();let i=(e||[]).filter((e=>null!=e.latitude&&null!=e.longitude)).map((e=>a.createElement(Ne,{key:e.id,lat:e.latitude,lng:e.longitude,point:{},popover:e.title,showPopover:!0},a.createElement("div",{style:{minHeight:"120px"}},a.createElement("strong",null,e.title),null!=e.payload.secret_url&&a.createElement("div",{style:{backgroundImage:`url(${e.payload.secret_url})`,backgroundPosition:"center",minWidth:"120px",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"120px"}}),null!=e.payload.secret&&a.createElement("div",null,e.payload.secret),a.createElement(fe.rU,{to:`/record/${e.id}`},"view")))));return a.createElement(r._z,{className:"my-page"},a.createElement(r.Oo,{pages:["Secret locations"]}),a.createElement("div",{style:{width:"100%",height:"450px",position:"relative"}},n&&a.createElement("div",{style:{position:"absolute",top:"20px",left:"20px",zIndex:1e7}},a.createElement(ye.Z,{size:"md"})),a.createElement(r.oe,{defaultCenter:{lat:45.4854739,lng:9.2022176},defaultZoom:11,height:450,onChange:async({bounds:e})=>{const{se:n,nw:a}=e;l(!0);const{data:{records:r}}=await o.query({query:Pe,variables:{where:{latitude:{gte:n.lat,lte:a.lat},longitude:{gte:a.lng,lte:n.lng}}},fetchPolicy:"network-only"});t(r),l(!1)}},i)))}),{url:"/secrets-map",title:"Secrets Map",id:"secrets-maps",permission:"wiggle.view",breadcrumbs:["Secrets Map"]}),(0,l.plug)("pages",r.Op,{url:"/secrets",title:"Secrets",id:"secrets",type:"secret",permission:"wiggle.view",breadcrumbs:["Secrets"],labels:{title:"Name",record:"secret"},columns:[{id:"secret-type",label:"Type",width:120,cell:({payload:e})=>a.createElement(r.vx,{color:ge(e.secret_type)},e.secret_type)}]}),(0,l.plug)("permissions",null,{permission:"wiggle.view",name:"View Panopticon secret",description:"View secrets stored in Panopticon Bot",group:"Panopticon"}),(0,l.plug)("user-record-types",null,{type:"secret",name:"Secret",list:"Secrets",description:"List of Panopticon secrets",form:({record:e})=>{const{payload:t}=e,n=new Date(t.secret_duration),l=new Date,o=n.getTime()-l.getTime();return a.createElement("div",{className:"secret-viewer"},a.createElement(U.Z,{justify:"space-between",style:{marginTop:"30px"}},a.createElement(U.Z.Item,{colspan:7},a.createElement("div",null,a.createElement("b",null,"Secret is")," ",a.createElement(r.vx,{color:ge(t.secret_type)},t.secret_type)),("time"===t.secret_type||"location+time"===t.secret_type)&&a.createElement("div",null,a.createElement("b",null,"Revealed when"),a.createElement("br",null),a.createElement("em",null,n.toLocaleDateString(),", ",n.toLocaleTimeString()),o>0&&a.createElement("div",{className:"secret-reveal-at"},Math.round(o/1e3/60)," minutes"),o<0&&a.createElement("div",null,"Secret date is due")),null!=t.secret_bounty&&a.createElement(a.Fragment,null,a.createElement("b",null,"ICE price:")," ",t.secret_bounty," EUR",a.createElement("br",null)),null!=t.secret_payment&&a.createElement(a.Fragment,null,a.createElement("br",null),a.createElement("b",null,"User paid to reveal the secret"),a.createElement("br",null),a.createElement("b",null,"Email: ")," ",t.secret_payment.order_info.email,a.createElement("br",null),a.createElement("b",null,"Currency: ")," ",t.secret_payment.currency,a.createElement("br",null),a.createElement("b",null,"Amount: ")," ",(t.secret_payment.total_amount/100).toFixed(2),a.createElement("br",null),a.createElement("b",null,"Payment ID: ")," ",t.secret_payment.provider_payment_charge_id,a.createElement("br",null))),a.createElement(U.Z.Item,{colspan:7},null!=t.secret_url&&a.createElement("div",null,a.createElement("b",null,"Secret image"),a.createElement("img",{src:t.secret_url,width:"100%"})),null!=t.secret&&a.createElement("div",null,a.createElement("b",null,"Secret text"),a.createElement("div",{className:"display-secret"},t.secret))),a.createElement(U.Z.Item,{colspan:7},null!=e.latitude&&a.createElement("div",{className:"ui-devices-map",style:{height:"300px"}},a.createElement(r.oe,{defaultCenter:{lat:e.latitude,lng:e.longitude},defaultZoom:11},a.createElement(he,null))),null==e.latitude&&a.createElement("div",null,a.createElement("em",null,"No location for this secret")))))},status:[{value:"private",label:"Private"},{value:"public",label:"Public"},{value:"crazy",label:"Crazy"},{value:"keyholder-free",label:"Keyholder free"},{value:"keyholder-taken",label:"Keyholder taken"}]}),(0,l.plug)("sidebar",null,{id:"configuration",label:"Configuration",permission:"configure",icon:"cog",options:[{id:"panopticon",label:"Panopticon",url:"/configuration-panopticon"}]}),(0,l.plug)("pages",(0,r.ln)("panopticon",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,c]=(0,a.useState)(e),[m,h]=(0,a.useState)(null),f=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(o.Z,{disabled:!0,formValue:l,formError:m,ref:f,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{c(e),h(null)},onCheck:e=>{h(e)}},a.createElement(a.Fragment,null,a.createElement(i.Z,null,a.createElement(s.Z,null,"Content"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"content",accepter:r.MN}),a.createElement(u.Z,null,"Select a ",a.createElement("em",null,"slug")," for a multi-language content to show additional information when a user requests information about opening hours")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Sensitivity"),a.createElement(d.Z,{disabled:n,name:"threshold",accepter:r.nH}),a.createElement(u.Z,null,"The minimum score of an intent to be considered relevant. Lower this value if the NLP doesn't catch any intent of the user input, raise this value if the NLP of this block is interfering with the NLP of other blocks."))),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{f.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&c(e)}},"Reset")))))}),{Legend:()=>a.createElement("div",null,a.createElement("p",null,"Configure some ",a.createElement("i",null,"Panopticon")," parameters")),title:"Panopticon"}),{permission:"configure",url:"/configuration-panopticon",title:"Configure Panopticon",id:"configuration-panopticon"});const{NodeRedNode:Ae,SlugHelp:ze,TypeCommand:je}=r.AK;(0,l.plug)("sidebar",null,{id:"configuration",label:"Configuration",permission:"configure",icon:"cog",options:[{id:"postcard-bot",label:"PostcardBot",url:"/configuration-postcard-bot"}]}),(0,l.plug)("pages",(0,r.ln)("postcardbot",(({value:e,onSubmit:t=(()=>{}),disabled:n=!1})=>{const[l,r]=(0,a.useState)(e),[c,m]=(0,a.useState)(null),[h,f]=(0,a.useState)("openings"),y=(0,a.useRef)(null);return a.createElement("div",null,a.createElement(o.Z,{disabled:!0,formValue:l,formError:c,ref:y,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{r(e),m(null)},onCheck:e=>{m(e)}},a.createElement(i.Z,null,a.createElement(s.Z,null,"ClickSend username"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"clicksendUser",accepter:H.Z}),a.createElement(u.Z,null,"Username for ClickSend API")),a.createElement(i.Z,null,a.createElement(s.Z,null,"ClickSend API Key"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"clicksendApiKey",accepter:H.Z}),a.createElement(u.Z,null,"Secret API key for ClickSend API")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Cloudinary Username"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"cloudinaryUsername",accepter:H.Z}),a.createElement(u.Z,null,"Cloudinary username, where the images are uploaded")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Cloudinary API Key"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"cloudinaryApiKey",accepter:H.Z})),a.createElement(i.Z,null,a.createElement(s.Z,null,"Cloudinary Secret"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"cloudinarySecret",accepter:H.Z})),a.createElement(i.Z,null,a.createElement(s.Z,null,"PDF Path (production)"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"pdfPathProduction",accepter:H.Z}),a.createElement(u.Z,null,"Path to store generated PDF in production")),a.createElement(i.Z,null,a.createElement(s.Z,null,"PDF Path (development)"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"pdfPathDevelopment",accepter:H.Z}),a.createElement(u.Z,null,"Path to store generated PDF in development")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Image Path (production)"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"imagePathProduction",accepter:H.Z}),a.createElement(u.Z,null,"Path to store uploaded images in production")),a.createElement(i.Z,null,a.createElement(s.Z,null,"Image Path (development)"),a.createElement(d.Z,{useSlug:!0,readOnly:n,name:"imagePathDevelopment",accepter:H.Z}),a.createElement(u.Z,null,"Path to store uploaded images in development")),a.createElement(i.Z,{style:{marginTop:"40px"}},a.createElement(p.Z,null,a.createElement(g.Z,{disabled:n,appearance:"primary",onClick:()=>{y.current.check()&&t(l)}},"Save configuration"),a.createElement(g.Z,{disabled:n,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&r(e)}},"Reset")))))}),{Legend:()=>a.createElement("div",null,a.createElement(Ae,null,"Opening Hours node"),a.createElement("p",null,"Configure the behaviour of this node: customize the opening hours and and some additional content (for example to show extra openings, etc)."),a.createElement(ze,null)),title:"PostcardBot"}),{permission:"configure",url:"/configuration-postcard-bot",title:"PostcardBot",id:"configuration-postcard-bot"}),(0,l.plug)("sidebar",null,{id:"postcardbot",label:"PostcardBot",icon:"logo-survey",options:[{id:"postcard-invoices",label:"Invoices",url:"/invoices"}]}),(0,l.plug)("pages",r.Op,{url:"/invoices",title:"Invoices",id:"invoices",type:"invoice",breadcrumbs:["Invoices"],labels:{title:"Name",record:"invoice"},columns:[]}),(0,l.plug)("user-record-types",null,{type:"invoice",name:"Invoice",list:"Invoices",description:"List of PostcardBot invoices",form:()=>a.createElement("div",null,"ok"),status:[{value:"new",label:"New"},{value:"problem",label:"Problem"}]});var Me=n(13067);const Be=e=>C().isEmpty(e.first_name)&&C().isEmpty(e.last_name)?C().isEmpty(username)?"Anonymous (id: {id})":e.username:[e.first_name,e.last_name].filter((e=>!C().isEmpty(e))).join(" "),Fe=({value:e,validation:t,onChange:n=(()=>{}),onSubmit:l=(()=>{})})=>{const{state:{activeChatbots:c}}=(0,Me.Z)();return a.createElement("div",null,a.createElement(o.Z,{fluid:!0,formValue:e,onChange:n,formError:t},a.createElement(U.Z,{justify:"space-between"},a.createElement(U.Z.Item,{colspan:15},a.createElement(i.Z,null,a.createElement(s.Z,null,"Recipient"),a.createElement(d.Z,{name:"recipient",accepter:r.P2,cleanable:!0,onChange:t=>{if(null!=t&&_.isArray(t.chatIds)&&!_.isEmpty(t.chatIds)){const a=t.chatIds.find((e=>((e,t)=>e.some((e=>e.transport===t)))(c,e.transport)));null!=a&&n({...e,chatId:a.chatId,userId:t.userId,recipient:t,transport:a.transport,botNode:c.find((e=>e.transport===a.transport)).nodeId})}}}))),a.createElement(U.Z.Item,{colspan:8},a.createElement(i.Z,null,a.createElement(s.Z,null,"Transport",a.createElement(u.Z,{tooltip:!0},"Shows only platforms for which the selected users has a valid ",a.createElement("em",null,"chatId"))),a.createElement(d.Z,{name:"botNode",accepter:r.Tl,transports:null!=e.recipient?e.recipient.chatIds.map((e=>e.transport)):null,disabled:null==e.recipient,onChange:t=>{const a=c.find((e=>e.nodeId===t));if(null!=a&&null!=e.recipient){const l=e.recipient.chatIds.find((e=>e.transport===a.transport));null!=l&&n({...e,chatId:l.chatId,botNode:t})}},block:!0})))),a.createElement(i.Z,{style:{marginTop:"15px"}},a.createElement(s.Z,null,"Message to send"),a.createElement(d.Z,{name:"message",componentClass:"textarea",style:{height:"150px",resize:"none"},onKeyUp:e=>{e.shiftKey&&13===e.keyCode&&l()}}))))},{useModal:Ke}=r.u_,Le=e=>null!=e.recipient&&null!=e.chatId&&null!=e.botNode&&!C().isEmpty(e.message),{StringType:De,ObjectType:Ve}=S.Z.Types,Ue=(S.Z.Model({recipient:Ve().isRequired("Select recipient"),botNode:De().isRequired("Select chatbot platoform"),message:De().isRequired("Enter message for the user")}),({user:e,appearance:t="ghost",transport:n})=>{const{sendMessage:l}=(0,r.fI)(),{state:{activeChatbots:o}}=(0,Me.Z)(),{open:i,close:s,validate:c,error:u,disable:m,openWithModel:d,openWith:p}=Ke({view:Fe,title:"Send message",labelSubmit:"Send message",size:"sm"});let h,f;if(!C().isEmpty(n)&&e.chatIds.some((e=>e.transport===n))){const t=o.find((e=>e.transport===n));console.log("chatBot",t,o,n),null!=t&&(h=t.nodeId,f=e.chatIds.find((e=>e.transport===n)).chatId)}return a.createElement(g.Z,{appearance:t,onClick:async()=>{let t={recipient:e,botNode:h,chatId:f,message:""};t=await p(t,Le),t&&(l("message.send",t),X.Z.success({title:"Message sent",description:`Message sent successfully to "${Be(t.recipient)}"`}))}},"Contact User")});n(56959);const{WidgetForm:He,Content:We,Footer:$e}=r.DD;(0,l.plug)("widgets",(({stats:e})=>{const[t,n]=(0,a.useState)({message:""}),l=!_.isEmpty(t.chatId)&&!_.isEmpty(t.botNode),{sendMessage:o}=(0,Y.f)();return a.createElement(r.s_,{title:"Send Message",className:"widget-send-message"},a.createElement(He,{fluid:!0,formValue:t,onChange:e=>n(e)},a.createElement(We,null,a.createElement(Fe,{value:t,onChange:e=>n(e),onSubmit:()=>{o("message.send",t),n({...t,message:""})}})),a.createElement($e,null,a.createElement(i.Z,null,a.createElement(p.Z,null,a.createElement(g.Z,{appearance:"primary",disabled:!l,onClick:()=>{o("message.send",t),n({...t,message:""})}},"Send Message"),a.createElement("div",{className:"key-hint"},"Shift + Enter to Send"),a.createElement(g.Z,{style:{float:"right"},appearance:"default",onClick:()=>n({botNode:null,recipient:null,chatId:null,message:""})},"Cancel"))))))}),{x:0,y:0,w:2,h:6,isResizable:!1,id:1}),(0,l.plug)("user-button",Ue),(0,l.plug)("user-record-buttons",(({record:e})=>a.createElement(Ue,{transport:e.transport,appearance:"primary",user:e.user})),{type:"survey"});var Je=n(25280),Qe=n(21712);function Ge(){return Ge=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Ge.apply(this,arguments)}var Xe=n(61151);var Ye=n(14617),et=n(4664),tt=(n(44923),n(52908)),nt=n(50580),at=n(62863),lt=n(55670),rt=n(71262),ot=n(23447);const it=({params:e,onCancel:t=(()=>{}),onSubmit:n=(()=>{}),disabled:l=!1,activeChatbots:r})=>{const[c,u]=(0,a.useState)(e);return a.createElement(at.Z,{backdrop:!0,show:!0,onHide:t,keyboard:!1,className:"modal-simulator"},a.createElement(at.Z.Header,null,a.createElement(at.Z.Title,null,"Simulator Configuration")),a.createElement(at.Z.Body,null,a.createElement(o.Z,{formValue:c,onChange:e=>{const t={...e};null==e.user||null!=c.user&&c.user.id===e.user.id||!e.user.language||(t.language=e.user.language),u(t)},fluid:!0},a.createElement(i.Z,null,a.createElement(s.Z,null,"Impersonated User"),a.createElement(d.Z,{accepter:rt.Z,name:"user",placeholder:"Test User",style:{width:"100%"}})),a.createElement(U.Z,{justify:"space-between",style:{marginBottom:"20px"}},a.createElement(U.Z.Item,{colspan:11},a.createElement(i.Z,null,a.createElement(s.Z,null,"Language"),a.createElement(d.Z,{accepter:lt.Z,name:"language",block:!0}))),a.createElement(U.Z.Item,{colspan:11},a.createElement(i.Z,null,a.createElement(s.Z,null,"Transport"),a.createElement(d.Z,{accepter:ot.Z,name:"nodeId",block:!0,size:"sm",cleanable:!1})))))),a.createElement(at.Z.Footer,null,a.createElement(g.Z,{onClick:t,appearance:"subtle"},"Cancel"),a.createElement(g.Z,{appearance:"primary",disabled:l,appearance:"primary",onClick:()=>n({...c,chatBot:r.find((e=>e.nodeId===c.nodeId))})},"Save configuration")))};it.propTypes={params:O().shape({language:O().string,user:O().shape({id:O().number,userId:O().string,username:O().string,language:O().string}),nodeId:O().string}),disabled:O().bool,onCancel:O().func,onSubmit:O().func,activeChatbots:O().arrayOf(O().shape({transport:O().string,nodeId:O().string,name:O().string}))};const st=it,ct=({user:e,language:t,nodeId:n,activeChatbots:l,dispatch:r})=>{const[o,i]=(0,a.useState)(null);return a.createElement("div",{className:"simulator-transport-menu cancel-drag"},null!=o&&a.createElement(st,{activeChatbots:l,params:o,onCancel:()=>i(null),onSubmit:e=>{r({type:"params",params:e}),i(null)}}),a.createElement("div",{className:"meta"},null!=e&&a.createElement("div",{className:"user"},e.username," ",a.createElement("em",null,"(",e.userId,")")),null==e&&a.createElement("div",{className:"user"},"Test User"),a.createElement(nt.Z,null,t)),a.createElement(tt.Z,{appearance:"subtle",icon:a.createElement(pe.Z,{icon:"cog"}),onClick:()=>i({user:e,language:t,nodeId:n}),style:{marginTop:"-3px",marginRight:"1px"}}))};ct.propTypes={user:O().shape({id:O().number,userId:O().string,username:O().string,language:O().string}),language:O().string,nodeId:O().string,dispatch:O().func,activeChatbots:O().arrayOf(O().shape({transport:O().string,nodeId:O().string,name:O().string}))};const ut=ct;var mt=n(30381),dt=n.n(mt);const pt=a.createContext();var gt;(0,l.plug)("widgets",(0,Xe.Z)((gt=({activeChatbots:e,user:t})=>{const{state:{simulator:n},dispatch:l,sendMessage:r}=(({activeChatbots:e})=>{const{state:t,dispatch:n}=(e=>{const{state:t,dispatch:n}=(0,a.useContext)(Qe.Z),l=Object.keys(e);return(0,a.useEffect)((()=>{l.forEach((a=>{void 0===t[a]&&n({type:"default",key:a,value:e[a]})}))}),[]),{state:l.reduce(((n,a)=>(n[a]=void 0!==t[a]?t[a]:e[a],n)),{}),dispatch:n}})({simulator:{messages:{},transport:C().isEmpty(e)?null:e[0].transport,nodeId:C().isEmpty(e)?null:e[0].nodeId,globals:null,language:"en",user:null}}),{sendMessage:l}=(0,Y.f)({onReceive:(e,t)=>{"simulator"===e&&n({type:"message",payload:t,topic:e})}});return{state:t,dispatch:n,sendMessage:(e,{echo:n=!0}={})=>{const{transport:a,nodeId:r,language:o,user:i}=t.simulator;l("simulator",{transport:a,nodeId:r,language:o,userId:null!=i?i.userId:42,username:null!=i?i.username:"testUser",firstName:null!=i?i.first_name:null,lastName:null!=i?i.last_name:null,payload:{content:e,type:"message"},simulatorOptions:{echo:n}})}}})({activeChatbots:e}),{messages:o,transport:i,nodeId:s,language:c,user:u}=n,m=null==e,d=e=>{!C().isObject(e)||"postback"!==e.type&&"quick-reply"!==e.type||r(e.value,{echo:!1})};return a.createElement(Je.Z,{title:"Chat Simulator",className:"chat-simulator",menu:!m&&a.createElement(ut,{user:u,language:c,nodeId:s,transport:i,dispatch:l,activeChatbots:e,onChange:e=>l({type:"chatBot",chatBot:e})})},!m&&a.createElement(pt.Provider,{value:n},a.createElement(Ye.zL,null,a.createElement(Ye.Vm,null,null!=o[i]&&o[i].map((e=>C().isArray(e)?a.createElement(et.Z,{onClick:d,key:e.map((e=>e.messageId)).join(),message:e.map((e=>({...e,username:"chatbot"})))}):a.createElement(et.Z,{onClick:d,key:e.messageId,message:e.inbound?e:{...e,username:"chatbot"}})))),a.createElement(Ye.M9,{onSend:e=>r(e),onClear:()=>l({type:"clear",transport:i})}))))},e=>a.createElement(Qe.Z.Consumer,null,(({activeChatbots:t})=>a.createElement(gt,Ge({},e,{activeChatbots:t}),e.children)))),"user"),{x:0,y:0,w:2,h:8,isResizable:!0,id:"simulator-widget",permission:"simulator"}),(0,l.plug)("reducers",((e,t)=>"default"===t.type?{...e,[t.key]:t.value}:e)),(0,l.plug)("reducers",((e,t)=>{switch(t.type){case"message":const{payload:n,topic:a}=t;if("simulator"!==a)return e;const l=C().isArray(e.simulator.messages[n.transport])?e.simulator.messages[n.transport]:[];let r;r=C().isArray(n.payload)?n.payload.map((e=>({...n,...e,payload:void 0,ts:dt()()}))):{...n,ts:dt()()};const o={...e.messages,[n.transport]:[...l,r]};return{...e,simulator:{...e.simulator,messages:o}};case"clear":return{...e,simulator:{...e.simulator,messages:{...e.messages,[t.transport]:[]}}};case"globals":return{...e,simulator:{...e.simulator,globals:t.globals}};case"params":const{params:i}=t;return{...e,simulator:{...e.simulator,transport:i.chatBot.transport,nodeId:i.chatBot.nodeId,language:i.language,user:i.user}};default:return e}})),(0,l.plug)("permissions",null,{permission:"simulator",name:"Chat Simulator",description:"Access to chat simulator",group:"General"});var ht=n(30306);n(67383);const ft=({question:e})=>{switch(e.type){case"text":case"number":return a.createElement("div",{className:Ze()("answer",{[e.type]:!0})},e.answer);case"multiple":return a.createElement("div",{className:"answer multiple"},e.data.map(((t,n)=>a.createElement("div",{className:Ze()("choice",{selected:t.answer===e.answer||t.value===e.answer})},a.createElement("span",{className:"placeholder"},"ABCDEFGHILMNOPQRTSUVZ"[n])," ",t.answer))))}};ft.propTypes={question:O().shape({type:O().oneOf(["text","number","multiple","image"]),answer:O().string,data:O().oneOfType([O().string,O().shape({answer:O().string,value:O().string})])})};const yt=({record:e})=>{const{payload:t}=e;return a.createElement("div",{className:"survey-viewer"},t.map((e=>a.createElement("div",{key:e.id,className:"question"},a.createElement("h5",null,e.title),a.createElement(ft,{question:e})))))};yt.propTypes={record:O().shape({question:O().shape({type:O().oneOf(["text","number","multiple","image"]),answer:O().string,data:O().oneOfType([O().string,O().shape({answer:O().string,value:O().string})])})})};const bt=yt;var Et=n(74491);n(16573),n(37353);const vt=({icon:e,text:t,tooltip:n,color:l})=>{const r=a.createElement("div",{className:Ze()("ui-badge-icon-tooltip",{[l]:!0})},a.createElement(pe.Z,{icon:e}),null!=t&&a.createElement("span",{className:"text"},t));return null!=n?a.createElement(ve.Z,{trigger:"hover",placement:"top",speaker:a.createElement(be.Z,null,n)},r):r};vt.propTypes={color:O().oneOf(["red","orange"]),text:O().oneOfType([O().string,O().number]),icon:O().string,tooltip:O().string};const wt=vt;var Zt=n(11450);const kt=(e,t)=>e.find((e=>e.id===t.id)),xt=(e,t)=>null!=t.parent?e.find((e=>e.id===t.parent)):null,Ct=(e,t)=>e.some((e=>e.parent===t.id)),St=e=>{const t={};return e.forEach((n=>{if(null!=n.parent&&null==t[n.parent]){const a=e.find((e=>e.id===n.parent));null!=a.parent?t[n.parent]=t[a.parent]+1:t[n.parent]=1}})),t},qt=e=>{const t=St(e),n={root:0},a=t=>{if(null==t)return"";const l=null!=t.parent?e.find((e=>e.id===t.parent)):null;return`${null!=l?a(l):""}${n[null!=l?l.id:"root"]}.`},l=t=>{const l=null!=t.parent?e.find((e=>e.id===t.parent)):null;let r;return null!=l?null!=n[l.id]?(n[l.id]+=1,r=n[l.id]):(n[l.id]=1,r=1):(n.root+=1,r=n.root),`Q${a(l)}${r}`};return e.map((e=>({...e,tag:l(e),level:C().isEmpty(e.parent)?0:t[e.parent]})))},It=a.createContext({});n(14589);const Tt=({children:e,size:t="small"})=>a.createElement("div",{className:Ze()("question-tag",{[t]:!0})},e),Nt=(0,Et.JV)((()=>a.createElement("div",{className:"grippy"}))),Pt=({question:e,onSelect:t=(()=>{}),active:n=!1,level:l=null})=>{const{questions:r}=(0,a.useContext)(It),o=(_.isArray(e.data)?e.data:[]).filter((e=>null!=e.jump)).map((e=>{const t=r.find((t=>t.id===e.jump));if(null!=t)return a.createElement(wt,{key:t.tag,icon:"code-fork",text:t.tag,color:"orange",tooltip:`Jump to ${t.tag} if user selects "${e.answer}"`})}));let i;if(null!=e.parent&&((e,t)=>{const n=e.findIndex((e=>e.id===t.id));return-1!==n&&0!==n&&t.parent===e[n-1].id})(r,e)){const t=_(r).chain().filter((e=>"multiple"===e.type)).map((e=>_.isArray(e.data)?e.data:[])).flatten().some((t=>t.jump===e.id)).value();t||(i=a.createElement(wt,{icon:"exclamation-triangle",key:"jump-warni