@telia-ace/conversational-hub-bot-provider 0.0.11 → 0.0.13
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/{contact-method-c5b03dd4.js → contact-method-429ef265.js} +5 -5
- package/{contact-method-af1adf09.mjs → contact-method-ae387667.mjs} +435 -492
- package/{index-f3027d08.js → index-482ea30a.js} +1 -1
- package/{index-80e2deb5.mjs → index-93f64633.mjs} +2 -3
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ke=Object.defineProperty;var Ne=(t,e,o)=>e in t?ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var P=(t,e,o)=>(Ne(t,typeof e!="symbol"?e+"":e,o),o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("./index-f3027d08.js"),b=require("react");require("react-dom");function H(t={}){const{phrase:e="",category:o,guideCategory:s,contactCategory:i,take:r,connectionKey:c,accordion:a,id:l,uriName:d,sorting:g,tag:f,tagId:y,tagTitle:v,...p}=t,m={};return Object.keys(p).forEach(h=>{typeof t[h]=="string"&&(m[h]=t[h])}),typeof e=="string"&&e.length&&(m.phrase=e),e===null&&(m.phrase=e),typeof s=="string"&&s!=="0"&&(m.guideCategory=s),typeof s=="number"&&s!==0&&(m.guideCategory=s),typeof s=="object"&&s!==null&&(typeof s.id=="string"&&s.id!=="0"&&(m.guideCategory=s.id),typeof s.id=="number"&&s.id!==0&&(m.guideCategory=s.id)),typeof i=="string"&&i!=="0"&&(m.contactCategory=i),typeof i=="number"&&i!==0&&(m.contactCategory=i),typeof i=="object"&&i!==null&&(typeof i.id=="string"&&i.id!=="0"&&(m.contactCategory=i.id),typeof i.id=="number"&&i.id!==0&&(m.contactCategory=i.id)),typeof o=="string"&&o!=="0"&&(m.category=o),typeof o=="number"&&o!==0&&(m.category=o),typeof o=="object"&&o!==null&&(typeof o.id=="string"&&o.id!=="0"&&(m.category=o.id),typeof o.id=="number"&&o.id!==0&&(m.category=o.id)),l&&(m.id=l),d&&(+m.category||+m.guideCategory||+m.guide||+m.contactCategory||+m.contactMethod)&&(m.uriName=d),c&&(m.connectionKey=c),r&&(m.take=r),g&&(m.sorting=g),typeof a=="string"&&a.length>0&&(m.accordion=a),typeof f=="string"&&f!=="0"&&(m.tag=f),typeof f=="number"&&f!==0&&(m.tag=f),Array.isArray(f)&&f.length&&(m.tag=f),(typeof y=="string"||typeof y=="number")&&(m.tagId=y),typeof v=="string"&&(m.tagTitle=v),typeof m.tag=="string"&&(m.tag=m.tag.split(",")),m}const ee=t=>{if(!t)return"";const e=[{from:/[äæǽ]+/gi,to:"ae"},{from:/[öœ]+/gi,to:"oe"},{from:/[ü]+/gi,to:"ue"},{from:/[Ä]+/gi,to:"Ae"},{from:/[Ü]+/gi,to:"Ue"},{from:/[Ö]+/gi,to:"Oe"},{from:/[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi,to:"A"},{from:/[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi,to:"a"},{from:/[Б]+/gi,to:"B"},{from:/[б]+/gi,to:"b"},{from:/[ÇĆĈĊČ]+/gi,to:"C"},{from:/[çćĉċč]+/gi,to:"c"},{from:/[Д]+/gi,to:"D"},{from:/[д]+/gi,to:"d"},{from:/[ÐĎĐΔ]+/gi,to:"Dj"},{from:/[ðďđδ]+/gi,to:"dj"},{from:/[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi,to:"E"},{from:/[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi,to:"e"},{from:/[Ф]+/gi,to:"F"},{from:/[ф]+/gi,to:"f"},{from:/[ĜĞĠĢΓГҐ]+/gi,to:"G"},{from:/[ĝğġģγгґ]+/gi,to:"g"},{from:/[ĤĦ]+/gi,to:"H"},{from:/[ĥħ]+/gi,to:"h"},{from:/[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi,to:"I"},{from:/[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi,to:"i"},{from:/[Ĵ]+/gi,to:"J"},{from:/[ĵ]+/gi,to:"j"},{from:/[ĶΚК]+/gi,to:"K"},{from:/[ķκк]+/gi,to:"k"},{from:/[ĹĻĽĿŁΛЛ]+/gi,to:"L"},{from:/[ĺļľŀłλл]+/gi,to:"l"},{from:/[М]+/gi,to:"M"},{from:/[м]+/gi,to:"m"},{from:/[ÑŃŅŇΝН]+/gi,to:"N"},{from:/[ñńņňʼnνн]+/gi,to:"n"},{from:/[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi,to:"O"},{from:/[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi,to:"o"},{from:/[П]+/gi,to:"P"},{from:/[п]+/gi,to:"p"},{from:/[ŔŖŘΡР]+/gi,to:"R"},{from:/[ŕŗřρр]+/gi,to:"r"},{from:/[ŚŜŞȘŠΣС]+/gi,to:"S"},{from:/[śŝşșšſσςс]+/gi,to:"s"},{from:/[ȚŢŤŦτТ]+/gi,to:"T"},{from:/[țţťŧт]+/gi,to:"t"},{from:/[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi,to:"U"},{from:/[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi,to:"u"},{from:/[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi,to:"Y"},{from:/[ýÿŷỳỹỷỵй]+/gi,to:"y"},{from:/[В]+/gi,to:"V"},{from:/[в]+/gi,to:"v"},{from:/[Ŵ]+/gi,to:"W"},{from:/[ŵ]+/gi,to:"w"},{from:/[ŹŻŽΖЗ]+/gi,to:"Z"},{from:/[źżžζз]+/gi,to:"z"},{from:/[ÆǼ]+/gi,to:"AE"},{from:/[ß]+/gi,to:"ss"},{from:/[IJ]+/gi,to:"IJ"},{from:/[ij]+/gi,to:"ij"},{from:/[Œ]+/gi,to:"OE"},{from:/[ƒ]+/gi,to:"f"},{from:/[ξ]+/gi,to:"ks"},{from:/[π]+/gi,to:"p"},{from:/[β]+/gi,to:"v"},{from:/[μ]+/gi,to:"m"},{from:/[ψ]+/gi,to:"ps"},{from:/[Ё]+/gi,to:"Yo"},{from:/[ё]+/gi,to:"yo"},{from:/[Є]+/gi,to:"Ye"},{from:/[є]+/gi,to:"ye"},{from:/[Ї]+/gi,to:"Yi"},{from:/[Ж]+/gi,to:"Zh"},{from:/[ж]+/gi,to:"zh"},{from:/[Х]+/gi,to:"Kh"},{from:/[х]+/gi,to:"kh"},{from:/[Ц]+/gi,to:"Ts"},{from:/[ц]+/gi,to:"ts"},{from:/[Ч]+/gi,to:"Ch"},{from:/[ч]+/gi,to:"ch"},{from:/[Ш]+/gi,to:"Sh"},{from:/[ш]+/gi,to:"sh"},{from:/[Щ]+/gi,to:"Shch"},{from:/[щ]+/gi,to:"shch"},{from:/[ЪъЬь]+/gi,to:""},{from:/[Ю]+/gi,to:"Yu"},{from:/[ю]+/gi,to:"yu"},{from:/[Я]+/gi,to:"Ya"},{from:/[я]+/gi,to:"ya"}],o=/[^a-zA-Z0-9]+/g,s=/[-]$/;let i=t;for(const r in e)e.hasOwnProperty(r)&&e[r].from.test(t)&&(i=i.replace(e[r].from,e[r].to));return i=i.replace(o,"-"),i=i.replace(s,""),i=i.toLowerCase(),i||"humany"},je=(t,e)=>{if(!t||!e)return!0;let o=e.parentNode,s=!1;for(;o!==null;)o===t&&(s=!0),o=o.parentNode;return s},te=(t={})=>(Object.keys(t).forEach(e=>{(t[e]===null||typeof t[e]>"u")&&delete t[e]}),t),_=(t,e)=>{let o=!0;return Object.keys(t).length!==Object.keys(e).length||Object.keys(t).some(i=>!Object.keys(e).some(c=>i===c))?!1:(Object.keys(t).forEach(i=>{if(o){const r=typeof t[i]>"u"?"":t[i],c=typeof e[i]>"u"?"":e[i];o=r.toString()===c.toString()}}),o)},fe=()=>b.useContext(n.ComponentNodeContext),Me=(t,e)=>{const o=fe(),s=n.useContainer(),[i,r]=b.useState(void 0),c=n.useIsMounted(),a=t||o.type||"";return b.useEffect(()=>{if(a){let l;return(e||s).getAsync("componentResolver").then(d=>{if(c.current){const g=d.getComponent(a);r(g)}l=d.registerResolver(a,g=>{c.current&&r(g)})}),()=>{l&&l()}}},[c,a,e,s]),i},ze=()=>b.useContext(n.ConversationContext),Te=()=>{const t=n.useComponentPlatform(),e=fe(),[o,s]=b.useState([]),[i,r]=b.useState();return b.useEffect(()=>{if(t&&e){const c=new n.ComponentQuery(t).withId(e.id),a=t.actions(c,e.type||n.uuid());r(a),o!==null&&(o.forEach(l=>{a.dispatch(l.key,l.data).then(d=>l.resolve(d)).catch(d=>l.reject(d))}),s(null))}},[t,e.id]),(c,a)=>o!==null?new Promise((l,d)=>{o.push({key:c,data:a,resolve:l,reject:d})}):i.dispatch(c,a)},Re=()=>{const[t,e]=b.useState(!1);return b.useEffect(()=>{const o=()=>{e(!1)},s=i=>{i.keyCode===9&&e(!0)};return window.addEventListener("keydown",s),window.addEventListener("click",o),()=>{window.removeEventListener("keydown",s),window.removeEventListener("click",o)}},[]),t},ie=t=>{const e=n.useContainer(),o=n.useRouter(),[s,i]=b.useState({name:"",params:{}}),r=n.useIsMounted();return b.useEffect(()=>{const c=(t||e).get("$widget");if(!c)return;const{events:a}=c;return a.subscribe("router:change",(d,{next:{routeData:g}})=>{if(r.current){const{name:f,params:y}=g;te(y),i({name:f,params:y})}})},[r,t,e]),b.useEffect(()=>{if(o&&o.history&&r.current){const c=o.getRouteData(),{name:a,params:l}=c;te(l),i({name:a,params:l})}},[o,r]),s};var ue=(t=>(t.HH_MM="hh:mm",t.YYYY_MM_DD="yyyy-mm-dd",t.YYYY_MM_DD_HH_MM="yyyy-mm-dd hh:mm",t))(ue||{});const he=({className:t="",format:e="hh:mm",timestamp:o})=>u.jsx("span",{className:n.appendClassNames(t,"humany-timestamp"),children:Ie(o,e)}),se=t=>`0${t}`.slice(-2);function Ie(t,e){const o=new Date(t),s=o.toTimeString().split(" ")[0].split(":"),i=s.length>1?`${s[0]}:${s[1]}`:s[0],r=o.getFullYear(),c=o.getMonth()+1,a=o.getDate(),l=`${r}-${se(c)}-${se(a)}`;return e==="yyyy-mm-dd"?l:e==="hh:mm"?i:`${l} ${i}`}var K=(t=>(t.guide="guide",t.link="link",t.default="default",t))(K||{});const re=t=>Promise.resolve().then(()=>require("./index-373df3a5.js")).then(({ServiceClient:e,ServiceProxy:o})=>t.get("settings").then(s=>{const{name:i,events:r}=t.get("$widget"),{data:{projection:c="",site:a="current",forceHttps:l=!1}}=s,d=new o(c,{credentials:"same-origin"}),g=new e(d,{funnel:i.replace("_contact-method","").replace("_contact",""),site:Ee(a,l)},null,t);return r.subscribe("widget:settings-updated",(f,{data:y})=>{y&&y.projection!==c&&g.proxy.setBaseUrl(y.projection)}),g})),Ee=(t,e)=>()=>{const o=i=>{const r=document.createElement("a");return r.href=i,r};let s=window.location;return t==="referrer"&&document.referrer&&(s=o(document.referrer)),[e?"https:":"","//",s.host,s.pathname].join("")},B=t=>{if(t){const{Type:e,Content:o}=t;if(e&&o)return{type:e,content:o}}},oe=t=>t.map(e=>{const o={id:e.Id.toString(),title:e.Name,symbol:B(e.DefaultIcon),activeSymbol:e.ActiveIcon&&B(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(o.items=oe(e.Children)),o}),A=(t,e)=>t.filter(({Type:o})=>o===e).map(({Id:o,Title:s,Body:i})=>({id:o.toString(),title:s,body:i})),W=t=>t.map(({Id:e,Title:o,DefaultIcon:s,ListNotices:i,Notices:r})=>({id:e.toString(),title:o,symbol:B(s),defaultHeaderOptions:{visible:!!i.length},notifications:(i||[]).concat(r||[]).map(({Id:c,Title:a,Body:l,Type:d,Modified:g})=>({id:c.toString(),title:a,body:l,modified:g,expandable:d==="listNotice"}))})),Z=({Id:t,Title:e,DefaultIcon:o,Exits:[s],ExitType:i,ConfirmationText:r,ExpandFormAutomatically:c,Form:a,Description:l},d)=>{const{Adapter:g}=s||{Adapter:{}},{ClientName:f="",Settings:y={},CustomClientName:v=""}=g,p={id:t.toString(),title:e,description:l,symbol:B(o),clientName:f==="custom.adapter"?v:f,expanded:!0,inline:!0,body:{}};if(f.indexOf("phone")>-1||f.indexOf("freetext")>-1){const{displayTextBeforeClick:m,textBeforeClick:h}=y;m==="true"&&(p.expanded=!1,p.title=h),f.indexOf("phone.text")>-1?p.body.phoneNumber=y.phoneNumber:p.body.freetext=y.freetext}return(f.indexOf("chat.popup")>-1||f.indexOf("link")>-1||f==="custom.adapter"&&i==="custom")&&(p.body=y,p.body.confirmationFallback=r),f.indexOf("ace")>-1&&(p.body=y),a&&a.HasValueComponents&&(d?p.body.form=n.FormBuilder.fromLegacyForm(t.toString(),a,d).get():p.body.form=n.FormBuilder.fromLegacyForm(t.toString(),a).get(),c||(p.expanded=p.inline=!1)),p},D=(t=[])=>t.map(({Id:e,Title:o,TotalMatches:s,Symbol:i,DefaultIcon:r,ActiveIcon:c})=>({id:e.toString(),title:o,matches:s,symbol:B(r||i),defaultIcon:B(r),activeIcon:B(c)})),J=t=>t.map(({Id:e,Title:o,Tags:s,FirstPublishedDate:i,Modified:r})=>({id:e.toString(),title:o,tags:D(s),published:i,modified:r})),Ae=(t,e)=>{switch(t){case R.MatchByCategory:case R.Match:{const o={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:s,TotalMatches:i,Notices:r,NoticeLists:c,Tags:a,ByCategory:l}=e;return o.guides=J(s),o.matches=i,o.byCategory=(l||[]).map(({Id:d,Matches:g,TotalMatches:f})=>({id:d,guides:J(g),matches:f})),o.tags=D(a),o.notificationLists=W(c||[]),o.topNotifications=A(r||[],"noticeRowTop"),o.middleNotifications=A(r||[],"noticeRowMiddle"),o.bottomNotifications=A(r||[],"footerNotice"),o}case R.Categories:{const{Children:o,GuidesCountTotal:s}=e;return{categories:oe(o||[]),matches:s}}case R.Guide:{const{Id:o,Title:s,Body:i,Related:r,Options:c,ConnectionId:a,ContactMethods:l,EnableFeedback:d,HandoverExists:g,FirstPublishedDate:f,Modified:y,ModifiedByDisplayName:v,FirstPublishedByDisplayName:p,Categories:m,Tags:h,SeoMetaDescription:x,SeoAllowIndex:C,Perspectives:N,PerspectiveKey:w,Translations:j}=e,$=w||Object.values(N).find(M=>M===a)||N.Default||null,q={guide:{id:o.toString(),title:s,body:i,modified:y,published:f,modifiedBy:v,publishedBy:p,connection:a,categories:m,hasHandover:g,allowFeedback:d,seoMetaDescription:x,seoAllowIndex:C,perspectives:N,perspective:$,translations:Object.keys(j||{}).reduce((M,I)=>(M[I]=j[I].toString(),M),{})},related:J(r||[]),dialog:[],contactMethods:(l||[]).map(M=>Z(M)),tags:D(h)};return(c||[]).forEach(({CanAccess:M,Description:I,ConnectionId:L,Properties:S})=>{if(!M)return;const z={id:o.toString(),title:I,connection:L,connectionKey:S.ConnectionKey,type:K.default,parent:{id:o.toString(),title:s,tags:D(h)}};if(S.Type==="Guide"||S.Type==="Link")switch(S.Id&&(z.id=S.Id.toString()),S.Uri&&(z.href=S.Uri),S.Target&&(z.target=S.Target),S.Type){case"Guide":z.type=K.guide;break;case"Link":z.type=K.link;break}q.dialog.push(z)}),q}case R.Contacts:{const{Children:o,Matches:s,Notices:i,NoticeLists:r}=e;return{contactMethods:(s||[]).map(a=>Z(a)),categories:oe(o||[]),topNotifications:A(i||[],"noticeRowTop"),middleNotifications:A(i||[],"noticeRowMiddle"),bottomNotifications:A(i||[],"footerNotice"),notificationLists:W(r||[])}}case R.ContactMethod:{const{ContactMethod:o}=e;return Z(o||{})}case R.Tags:case R.TagsOnGuides:return D(e||[]);case R.Notifications:{const{Notices:o,NoticeLists:s}=e;return{topNotifications:A(o||[],"noticeRowTop"),middleNotifications:A(o||[],"noticeRowMiddle"),bottomNotifications:A(o||[],"footerNotice"),notificationLists:W(s||[])}}default:return{}}};var ge=(t=>(t.Guide="guide",t.Guides="guides",t.GuidesByCategory="guides-by-category",t.RowNotifications="row-notices",t.NotificationLists="notification-lists",t.GuideCategories="guide-categories",t.ContactMethodCategories="contact-method-categories",t.ContactMethod="contact-method",t.ContactMethods="contact-methods",t.Tags="tags",t.TagsOnGuides="tagsonguides",t))(ge||{}),R=(t=>(t.Match="match",t.Categories="categories",t.Guide="guide",t.Contacts="contacts",t.ContactMethod="contact-method",t.MatchByCategory="match-by-category",t.Tags="tags",t.TagsOnGuides="tagsonguides",t.Notifications="notifications",t))(R||{});const ae=t=>{switch(t){case"guides":return"match";case"guides-by-category":return"match-by-category";case"guide":return"guide";case"guide-categories":return"categories";case"contact-method-categories":case"contact-methods":return"contacts";case"contact-method":return"contact-method";case"tags":return"tags";case"tagsonguides":return"tagsonguides";case"notification-lists":case"row-notices":return"notifications";default:throw"error"}},Le=async t=>{const{invoke:e}=t.get("$widget");return await e("renderState")===n.WidgetRenderState.hidden};class G{constructor(e,o){P(this,"queries",new Map);P(this,"lastTake",0);P(this,"events");P(this,"getUnresolvedQueries",()=>{let e=0;return this.queries.forEach((o,s)=>{o.some(r=>!r.resolved)&&(e=1)}),e});this.container=e,this.matchingClient=o,this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(s,{next:i,previous:r})=>{r===n.WidgetRenderState.hidden&&i===n.WidgetRenderState.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,o="dataClient"){return n.lock(this)(()=>e.getAsync(o).then(async s=>{let i=await e.getAsync("matchingClient");i||(i=await re(e),e.registerAsync("matchingClient",()=>i));let r=s;return r||(r=new G(e,i),e.registerAsync(o,()=>r)),r}))}fetch(e,o,s){return new Promise((i,r)=>{o.take&&(this.lastTake=+(o.take||0)),te(o);const c=ae(e);let a=this.queries.get(c)||[],l=a.find(d=>_(d.params,o))||null;if(l&&(s!=null&&s.noCache)){const d=a.findIndex(g=>_(g.params,o));a=[...a.slice(0,d),...a.slice(d+1)],l=null}if(l){const d=a.indexOf(l);if(l.resolved?(this.events.dispatch("data-client:fetched",{params:o,type:c,response:l.data,unresolvedQueries:this.getUnresolvedQueries()}),this.track(l.data,c,l.error),l.data&&l.error?r({error:l.error}):i(l.data)):l.resolvers.push({resolve:i,reject:r}),a.splice(d,1),a.push(l),this.queries.set(c,a),!l.loading&&!l.resolved)return this.runQuery(c,o)}else return a.push({params:o,resolved:!1,loading:!0,data:{},resolvers:[{resolve:i,reject:r}]}),this.queries.set(c,a),this.runQuery(c,o)}).then(i=>n.deepClone(i))}read(e,o){const{select:s}=o,i=ae(e);return(this.queries.get(i)||[]).reduce((a,l)=>{if(typeof s=="function"){const d=s(l.data);d&&a.push(d)}else a.push(l.data);return a},[])}feedback(e,o,s){return this.matchingClient.giveFeedback(e,o,s)}setLoadingStatus(e,o,s){const i=this.queries.get(e)||[],r=i.find(c=>_(c.params,o));r&&(r.loading=s),this.queries.set(e,i)}async runQuery(e,o){const{searchPhrase:s="",categories:i="0",contactMethodCategoryId:r="0",contactMethodId:c="0",tagId:a=void 0,take:l=5,connection:d="",guideId:g,expandCategories:f="descendants",currentCategory:y,sorting:v="popularity-descending",guideIds:p=[]}=o,m=s.toString().trim();if(await Le(this.container))return Promise.resolve();switch(e){case"match":{const h=x=>{const[C,N]=x.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(C),direction:N}};return p.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:p,take:+l}}).then(x=>x&&this.handleResponse(x,e,o)):this.matchingClient.match(m,{categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+l,tags:a,sorting:h(v),ids:p}).then(x=>x&&this.handleResponse(x,e,o))}case"match-by-category":return this.matchingClient.match(m,{groupByCategory:!0,categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+l,tags:a}).then(h=>h&&this.handleResponse(h,e,o));case"guide":return this.matchingClient.getGuide(g,{connectionId:d}).then(h=>{h&&this.handleResponse(h,e,o)}).catch(h=>{const x={message:"Something went wrong.",status:h.status||400};x.status===404&&(x.message="The guide could not be found."),this.handleResponse({},e,o,x)});case"categories":return this.matchingClient.getCategories({phrase:m,expand:f,tags:a}).then(h=>h&&this.handleResponse(h,e,o));case"contacts":return g?this.matchingClient.contactMethods(+g,{phrase:m}).then(h=>h&&this.handleResponse(h,e,o)):this.matchingClient.contacts(+r,{phrase:m}).then(h=>h&&this.handleResponse(h,e,o));case"contact-method":return this.matchingClient.getContactMethod(+c,{guideId:g,currentCategory:y}).then(h=>h&&this.handleResponse(h,e,o));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:m,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(h=>h&&this.handleResponse(h,e,o));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:m,categories:i==="0"?[]:Array.isArray(i)?i:[+i],tags:a}}).then(h=>h&&this.handleResponse(h,e,o));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:m,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(h=>h&&this.handleResponse(h,e,o))}}handleResponse(e={},o,s,i){const r=this.queries.get(o)||[],c=r.find(a=>_(a.params,s));if(c){const a=i||Ae(o,e);this.track(a,o,i),c.resolvers.forEach(d=>{i?d.reject({error:a}):d.resolve(a)});const l=r.indexOf(c);l>-1&&r.splice(l,1),r.push({...c,error:i,resolvers:[],data:a,resolved:!0}),this.setLoadingStatus(o,s,!1),this.queries.set(o,r),i||this.events.dispatch("data-client:fetched",{type:o,params:s,response:a,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,o]of this.queries)o.filter(s=>!s.resolved).forEach(s=>{this.runQuery(e,s.params)})}track(e={},o,s){const i=this.container.get("$widget");i&&!s?i.events.dispatch("tracking:service-client-response",{type:o,data:e}):i&&i.events.dispatch("tracking:service-client-error",{type:o,error:s})}static create(e){return e.getAsync("matchingClient").then(async o=>{if(o)return new G(e,o);const s=await re(e);return e.registerAsync("matchingClient",()=>s),new G(e,s)})}getClient(){return this.matchingClient}}const Be=({title:t="",className:e,id:o,parent:s,connection:i,type:r,target:c,href:a,children:l,connectionKey:d})=>{const g={},{name:f,params:y}=ie();switch(r){case"default":case"guide":const{id:v,title:p}=s;let m=d||i;v!==o&&!d&&(m=void 0),g.routeName=f,g.params=H({...y,guide:o,connection:m,uriName:ee(o===v?p:t)});break;case"link":g.href=a,g.target=c;break}return u.jsx(n.Link,{className:n.appendClassNames(e,"humany-dialog-link"),...g,children:l||u.jsxs(u.Fragment,{children:[r==="link"&&u.jsx(n.Icon,{faIcon:"link"}),u.jsx("span",{children:t})]})})};b.forwardRef(({className:t,dialog:e,...o},s)=>e.length?u.jsx(Oe,{className:n.appendClassNames(t,"humany-dialog"),items:e,renderItem:i=>u.jsx("li",{"data-dialog":i.connection,children:u.jsx(Be,{...i})},i.connection),...o,ref:s}):null);const Oe=n.newStyled(n.List)`
|
|
1
|
+
"use strict";var ke=Object.defineProperty;var Ne=(t,e,o)=>e in t?ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var q=(t,e,o)=>(Ne(t,typeof e!="symbol"?e+"":e,o),o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("./index-482ea30a.js"),b=require("react");require("react-dom");function D(t={}){const{phrase:e="",category:o,guideCategory:s,contactCategory:i,take:r,connectionKey:c,accordion:a,id:l,uriName:d,sorting:g,tag:f,tagId:y,tagTitle:v,...p}=t,m={};return Object.keys(p).forEach(h=>{typeof t[h]=="string"&&(m[h]=t[h])}),typeof e=="string"&&e.length&&(m.phrase=e),e===null&&(m.phrase=e),typeof s=="string"&&s!=="0"&&(m.guideCategory=s),typeof s=="number"&&s!==0&&(m.guideCategory=s),typeof s=="object"&&s!==null&&(typeof s.id=="string"&&s.id!=="0"&&(m.guideCategory=s.id),typeof s.id=="number"&&s.id!==0&&(m.guideCategory=s.id)),typeof i=="string"&&i!=="0"&&(m.contactCategory=i),typeof i=="number"&&i!==0&&(m.contactCategory=i),typeof i=="object"&&i!==null&&(typeof i.id=="string"&&i.id!=="0"&&(m.contactCategory=i.id),typeof i.id=="number"&&i.id!==0&&(m.contactCategory=i.id)),typeof o=="string"&&o!=="0"&&(m.category=o),typeof o=="number"&&o!==0&&(m.category=o),typeof o=="object"&&o!==null&&(typeof o.id=="string"&&o.id!=="0"&&(m.category=o.id),typeof o.id=="number"&&o.id!==0&&(m.category=o.id)),l&&(m.id=l),d&&(+m.category||+m.guideCategory||+m.guide||+m.contactCategory||+m.contactMethod)&&(m.uriName=d),c&&(m.connectionKey=c),r&&(m.take=r),g&&(m.sorting=g),typeof a=="string"&&a.length>0&&(m.accordion=a),typeof f=="string"&&f!=="0"&&(m.tag=f),typeof f=="number"&&f!==0&&(m.tag=f),Array.isArray(f)&&f.length&&(m.tag=f),(typeof y=="string"||typeof y=="number")&&(m.tagId=y),typeof v=="string"&&(m.tagTitle=v),typeof m.tag=="string"&&(m.tag=m.tag.split(",")),m}const ee=t=>{if(!t)return"";const e=[{from:/[äæǽ]+/gi,to:"ae"},{from:/[öœ]+/gi,to:"oe"},{from:/[ü]+/gi,to:"ue"},{from:/[Ä]+/gi,to:"Ae"},{from:/[Ü]+/gi,to:"Ue"},{from:/[Ö]+/gi,to:"Oe"},{from:/[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi,to:"A"},{from:/[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi,to:"a"},{from:/[Б]+/gi,to:"B"},{from:/[б]+/gi,to:"b"},{from:/[ÇĆĈĊČ]+/gi,to:"C"},{from:/[çćĉċč]+/gi,to:"c"},{from:/[Д]+/gi,to:"D"},{from:/[д]+/gi,to:"d"},{from:/[ÐĎĐΔ]+/gi,to:"Dj"},{from:/[ðďđδ]+/gi,to:"dj"},{from:/[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi,to:"E"},{from:/[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi,to:"e"},{from:/[Ф]+/gi,to:"F"},{from:/[ф]+/gi,to:"f"},{from:/[ĜĞĠĢΓГҐ]+/gi,to:"G"},{from:/[ĝğġģγгґ]+/gi,to:"g"},{from:/[ĤĦ]+/gi,to:"H"},{from:/[ĥħ]+/gi,to:"h"},{from:/[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi,to:"I"},{from:/[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi,to:"i"},{from:/[Ĵ]+/gi,to:"J"},{from:/[ĵ]+/gi,to:"j"},{from:/[ĶΚК]+/gi,to:"K"},{from:/[ķκк]+/gi,to:"k"},{from:/[ĹĻĽĿŁΛЛ]+/gi,to:"L"},{from:/[ĺļľŀłλл]+/gi,to:"l"},{from:/[М]+/gi,to:"M"},{from:/[м]+/gi,to:"m"},{from:/[ÑŃŅŇΝН]+/gi,to:"N"},{from:/[ñńņňʼnνн]+/gi,to:"n"},{from:/[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi,to:"O"},{from:/[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi,to:"o"},{from:/[П]+/gi,to:"P"},{from:/[п]+/gi,to:"p"},{from:/[ŔŖŘΡР]+/gi,to:"R"},{from:/[ŕŗřρр]+/gi,to:"r"},{from:/[ŚŜŞȘŠΣС]+/gi,to:"S"},{from:/[śŝşșšſσςс]+/gi,to:"s"},{from:/[ȚŢŤŦτТ]+/gi,to:"T"},{from:/[țţťŧт]+/gi,to:"t"},{from:/[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi,to:"U"},{from:/[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi,to:"u"},{from:/[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi,to:"Y"},{from:/[ýÿŷỳỹỷỵй]+/gi,to:"y"},{from:/[В]+/gi,to:"V"},{from:/[в]+/gi,to:"v"},{from:/[Ŵ]+/gi,to:"W"},{from:/[ŵ]+/gi,to:"w"},{from:/[ŹŻŽΖЗ]+/gi,to:"Z"},{from:/[źżžζз]+/gi,to:"z"},{from:/[ÆǼ]+/gi,to:"AE"},{from:/[ß]+/gi,to:"ss"},{from:/[IJ]+/gi,to:"IJ"},{from:/[ij]+/gi,to:"ij"},{from:/[Œ]+/gi,to:"OE"},{from:/[ƒ]+/gi,to:"f"},{from:/[ξ]+/gi,to:"ks"},{from:/[π]+/gi,to:"p"},{from:/[β]+/gi,to:"v"},{from:/[μ]+/gi,to:"m"},{from:/[ψ]+/gi,to:"ps"},{from:/[Ё]+/gi,to:"Yo"},{from:/[ё]+/gi,to:"yo"},{from:/[Є]+/gi,to:"Ye"},{from:/[є]+/gi,to:"ye"},{from:/[Ї]+/gi,to:"Yi"},{from:/[Ж]+/gi,to:"Zh"},{from:/[ж]+/gi,to:"zh"},{from:/[Х]+/gi,to:"Kh"},{from:/[х]+/gi,to:"kh"},{from:/[Ц]+/gi,to:"Ts"},{from:/[ц]+/gi,to:"ts"},{from:/[Ч]+/gi,to:"Ch"},{from:/[ч]+/gi,to:"ch"},{from:/[Ш]+/gi,to:"Sh"},{from:/[ш]+/gi,to:"sh"},{from:/[Щ]+/gi,to:"Shch"},{from:/[щ]+/gi,to:"shch"},{from:/[ЪъЬь]+/gi,to:""},{from:/[Ю]+/gi,to:"Yu"},{from:/[ю]+/gi,to:"yu"},{from:/[Я]+/gi,to:"Ya"},{from:/[я]+/gi,to:"ya"}],o=/[^a-zA-Z0-9]+/g,s=/[-]$/;let i=t;for(const r in e)e.hasOwnProperty(r)&&e[r].from.test(t)&&(i=i.replace(e[r].from,e[r].to));return i=i.replace(o,"-"),i=i.replace(s,""),i=i.toLowerCase(),i||"humany"},je=(t,e)=>{if(!t||!e)return!0;let o=e.parentNode,s=!1;for(;o!==null;)o===t&&(s=!0),o=o.parentNode;return s},te=(t={})=>(Object.keys(t).forEach(e=>{(t[e]===null||typeof t[e]>"u")&&delete t[e]}),t),K=(t,e)=>{let o=!0;return Object.keys(t).length!==Object.keys(e).length||Object.keys(t).some(i=>!Object.keys(e).some(c=>i===c))?!1:(Object.keys(t).forEach(i=>{if(o){const r=typeof t[i]>"u"?"":t[i],c=typeof e[i]>"u"?"":e[i];o=r.toString()===c.toString()}}),o)},fe=()=>b.useContext(n.ComponentNodeContext),Me=(t,e)=>{const o=fe(),s=n.useContainer(),[i,r]=b.useState(void 0),c=n.useIsMounted(),a=t||o.type||"";return b.useEffect(()=>{if(a){let l;return(e||s).getAsync("componentResolver").then(d=>{if(c.current){const g=d.getComponent(a);r(g)}l=d.registerResolver(a,g=>{c.current&&r(g)})}),()=>{l&&l()}}},[c,a,e,s]),i},ze=()=>b.useContext(n.ConversationContext),Te=()=>{const t=n.useComponentPlatform(),e=fe(),[o,s]=b.useState([]),[i,r]=b.useState();return b.useEffect(()=>{if(t&&e){const c=new n.ComponentQuery(t).withId(e.id),a=t.actions(c,e.type||n.uuid());r(a),o!==null&&(o.forEach(l=>{a.dispatch(l.key,l.data).then(d=>l.resolve(d)).catch(d=>l.reject(d))}),s(null))}},[t,e.id]),(c,a)=>o!==null?new Promise((l,d)=>{o.push({key:c,data:a,resolve:l,reject:d})}):i.dispatch(c,a)},Re=()=>{const[t,e]=b.useState(!1);return b.useEffect(()=>{const o=()=>{e(!1)},s=i=>{i.keyCode===9&&e(!0)};return window.addEventListener("keydown",s),window.addEventListener("click",o),()=>{window.removeEventListener("keydown",s),window.removeEventListener("click",o)}},[]),t},ie=t=>{const e=n.useContainer(),o=n.useRouter(),[s,i]=b.useState({name:"",params:{}}),r=n.useIsMounted();return b.useEffect(()=>{const c=(t||e).get("$widget");if(!c)return;const{events:a}=c;return a.subscribe("router:change",(d,{next:{routeData:g}})=>{if(r.current){const{name:f,params:y}=g;te(y),i({name:f,params:y})}})},[r,t,e]),b.useEffect(()=>{if(o&&o.history&&r.current){const c=o.getRouteData(),{name:a,params:l}=c;te(l),i({name:a,params:l})}},[o,r]),s};var ue=(t=>(t.HH_MM="hh:mm",t.YYYY_MM_DD="yyyy-mm-dd",t.YYYY_MM_DD_HH_MM="yyyy-mm-dd hh:mm",t))(ue||{});const he=({className:t="",format:e="hh:mm",timestamp:o})=>u.jsx("span",{className:n.appendClassNames(t,"humany-timestamp"),children:Ie(o,e)}),se=t=>`0${t}`.slice(-2);function Ie(t,e){const o=new Date(t),s=o.toTimeString().split(" ")[0].split(":"),i=s.length>1?`${s[0]}:${s[1]}`:s[0],r=o.getFullYear(),c=o.getMonth()+1,a=o.getDate(),l=`${r}-${se(c)}-${se(a)}`;return e==="yyyy-mm-dd"?l:e==="hh:mm"?i:`${l} ${i}`}var _=(t=>(t.guide="guide",t.link="link",t.default="default",t))(_||{});const re=t=>Promise.resolve().then(()=>require("./index-373df3a5.js")).then(({ServiceClient:e,ServiceProxy:o})=>t.get("settings").then(s=>{const{name:i,events:r}=t.get("$widget"),{data:{projection:c="",site:a="current",forceHttps:l=!1}}=s,d=new o(c,{credentials:"same-origin"}),g=new e(d,{funnel:i.replace("_contact-method","").replace("_contact",""),site:Ee(a,l)},null,t);return r.subscribe("widget:settings-updated",(f,{data:y})=>{y&&y.projection!==c&&g.proxy.setBaseUrl(y.projection)}),g})),Ee=(t,e)=>()=>{const o=i=>{const r=document.createElement("a");return r.href=i,r};let s=window.location;return t==="referrer"&&document.referrer&&(s=o(document.referrer)),[e?"https:":"","//",s.host,s.pathname].join("")},E=t=>{if(t){const{Type:e,Content:o}=t;if(e&&o)return{type:e,content:o}}},oe=t=>t.map(e=>{const o={id:e.Id.toString(),title:e.Name,symbol:E(e.DefaultIcon),activeSymbol:e.ActiveIcon&&E(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(o.items=oe(e.Children)),o}),T=(t,e)=>t.filter(({Type:o})=>o===e).map(({Id:o,Title:s,Body:i})=>({id:o.toString(),title:s,body:i})),W=t=>t.map(({Id:e,Title:o,DefaultIcon:s,ListNotices:i,Notices:r})=>({id:e.toString(),title:o,symbol:E(s),defaultHeaderOptions:{visible:!!i.length},notifications:(i||[]).concat(r||[]).map(({Id:c,Title:a,Body:l,Type:d,Modified:g})=>({id:c.toString(),title:a,body:l,modified:g,expandable:d==="listNotice"}))})),Z=({Id:t,Title:e,DefaultIcon:o,Exits:[s],ExitType:i,ConfirmationText:r,ExpandFormAutomatically:c,Form:a,Description:l},d)=>{const{Adapter:g}=s||{Adapter:{}},{ClientName:f="",Settings:y={},CustomClientName:v=""}=g,p={id:t.toString(),title:e,description:l,symbol:E(o),clientName:f==="custom.adapter"?v:f,expanded:!0,inline:!0,body:{}};if(f.indexOf("phone")>-1||f.indexOf("freetext")>-1){const{displayTextBeforeClick:m,textBeforeClick:h}=y;m==="true"&&(p.expanded=!1,p.title=h),f.indexOf("phone.text")>-1?p.body.phoneNumber=y.phoneNumber:p.body.freetext=y.freetext}return(f.indexOf("chat.popup")>-1||f.indexOf("link")>-1||f==="custom.adapter"&&i==="custom")&&(p.body=y,p.body.confirmationFallback=r),f.indexOf("ace")>-1&&(p.body=y),a&&a.HasValueComponents&&(d?p.body.form=n.FormBuilder.fromLegacyForm(t.toString(),a,d).get():p.body.form=n.FormBuilder.fromLegacyForm(t.toString(),a).get(),c||(p.expanded=p.inline=!1)),p},F=(t=[])=>t.map(({Id:e,Title:o,TotalMatches:s,Symbol:i,DefaultIcon:r,ActiveIcon:c})=>({id:e.toString(),title:o,matches:s,symbol:E(r||i),defaultIcon:E(r),activeIcon:E(c)})),J=t=>t.map(({Id:e,Title:o,Tags:s,FirstPublishedDate:i,Modified:r})=>({id:e.toString(),title:o,tags:F(s),published:i,modified:r})),Le=(t,e)=>{switch(t){case M.MatchByCategory:case M.Match:{const o={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:s,TotalMatches:i,Notices:r,NoticeLists:c,Tags:a,ByCategory:l}=e;return o.guides=J(s),o.matches=i,o.byCategory=(l||[]).map(({Id:d,Matches:g,TotalMatches:f})=>({id:d,guides:J(g),matches:f})),o.tags=F(a),o.notificationLists=W(c||[]),o.topNotifications=T(r||[],"noticeRowTop"),o.middleNotifications=T(r||[],"noticeRowMiddle"),o.bottomNotifications=T(r||[],"footerNotice"),o}case M.Categories:{const{Children:o,GuidesCountTotal:s}=e;return{categories:oe(o||[]),matches:s}}case M.Guide:{const{Id:o,Title:s,Body:i,Related:r,Options:c,ConnectionId:a,ContactMethods:l,EnableFeedback:d,HandoverExists:g,FirstPublishedDate:f,Modified:y,ModifiedByDisplayName:v,FirstPublishedByDisplayName:p,Categories:m,Tags:h,SeoMetaDescription:x,SeoAllowIndex:R,Perspectives:N,PerspectiveKey:I,Translations:L}=e,C=I||Object.values(N).find(k=>k===a)||N.Default||null,G={guide:{id:o.toString(),title:s,body:i,modified:y,published:f,modifiedBy:v,publishedBy:p,connection:a,categories:m,hasHandover:g,allowFeedback:d,seoMetaDescription:x,seoAllowIndex:R,perspectives:N,perspective:C,translations:Object.keys(L||{}).reduce((k,A)=>(k[A]=L[A].toString(),k),{})},related:J(r||[]),dialog:[],contactMethods:(l||[]).map(k=>Z(k)),tags:F(h)};return(c||[]).forEach(({CanAccess:k,Description:A,ConnectionId:H,Properties:w})=>{if(!k)return;const S={id:o.toString(),title:A,connection:H,connectionKey:w.ConnectionKey,type:_.default,parent:{id:o.toString(),title:s,tags:F(h)}};if(w.Type==="Guide"||w.Type==="Link")switch(w.Id&&(S.id=w.Id.toString()),w.Uri&&(S.href=w.Uri),w.Target&&(S.target=w.Target),w.Type){case"Guide":S.type=_.guide;break;case"Link":S.type=_.link;break}G.dialog.push(S)}),G}case M.Contacts:{const{Children:o,Matches:s,Notices:i,NoticeLists:r}=e;return{contactMethods:(s||[]).map(a=>Z(a)),categories:oe(o||[]),topNotifications:T(i||[],"noticeRowTop"),middleNotifications:T(i||[],"noticeRowMiddle"),bottomNotifications:T(i||[],"footerNotice"),notificationLists:W(r||[])}}case M.ContactMethod:{const{ContactMethod:o}=e;return Z(o||{})}case M.Tags:case M.TagsOnGuides:return F(e||[]);case M.Notifications:{const{Notices:o,NoticeLists:s}=e;return{topNotifications:T(o||[],"noticeRowTop"),middleNotifications:T(o||[],"noticeRowMiddle"),bottomNotifications:T(o||[],"footerNotice"),notificationLists:W(s||[])}}default:return{}}};var ge=(t=>(t.Guide="guide",t.Guides="guides",t.GuidesByCategory="guides-by-category",t.RowNotifications="row-notices",t.NotificationLists="notification-lists",t.GuideCategories="guide-categories",t.ContactMethodCategories="contact-method-categories",t.ContactMethod="contact-method",t.ContactMethods="contact-methods",t.Tags="tags",t.TagsOnGuides="tagsonguides",t))(ge||{}),M=(t=>(t.Match="match",t.Categories="categories",t.Guide="guide",t.Contacts="contacts",t.ContactMethod="contact-method",t.MatchByCategory="match-by-category",t.Tags="tags",t.TagsOnGuides="tagsonguides",t.Notifications="notifications",t))(M||{});const ae=t=>{switch(t){case"guides":return"match";case"guides-by-category":return"match-by-category";case"guide":return"guide";case"guide-categories":return"categories";case"contact-method-categories":case"contact-methods":return"contacts";case"contact-method":return"contact-method";case"tags":return"tags";case"tagsonguides":return"tagsonguides";case"notification-lists":case"row-notices":return"notifications";default:throw"error"}},Ae=async t=>{const{invoke:e}=t.get("$widget");return await e("renderState")===n.WidgetRenderState.hidden};class P{constructor(e,o){q(this,"queries",new Map);q(this,"lastTake",0);q(this,"events");q(this,"getUnresolvedQueries",()=>{let e=0;return this.queries.forEach((o,s)=>{o.some(r=>!r.resolved)&&(e=1)}),e});this.container=e,this.matchingClient=o,this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(s,{next:i,previous:r})=>{r===n.WidgetRenderState.hidden&&i===n.WidgetRenderState.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,o="dataClient"){return n.lock(this)(()=>e.getAsync(o).then(async s=>{let i=await e.getAsync("matchingClient");i||(i=await re(e),e.registerAsync("matchingClient",()=>i));let r=s;return r||(r=new P(e,i),e.registerAsync(o,()=>r)),r}))}fetch(e,o,s){return new Promise((i,r)=>{o.take&&(this.lastTake=+(o.take||0)),te(o);const c=ae(e);let a=this.queries.get(c)||[],l=a.find(d=>K(d.params,o))||null;if(l&&(s!=null&&s.noCache)){const d=a.findIndex(g=>K(g.params,o));a=[...a.slice(0,d),...a.slice(d+1)],l=null}if(l){const d=a.indexOf(l);if(l.resolved?(this.events.dispatch("data-client:fetched",{params:o,type:c,response:l.data,unresolvedQueries:this.getUnresolvedQueries()}),this.track(l.data,c,l.error),l.data&&l.error?r({error:l.error}):i(l.data)):l.resolvers.push({resolve:i,reject:r}),a.splice(d,1),a.push(l),this.queries.set(c,a),!l.loading&&!l.resolved)return this.runQuery(c,o)}else return a.push({params:o,resolved:!1,loading:!0,data:{},resolvers:[{resolve:i,reject:r}]}),this.queries.set(c,a),this.runQuery(c,o)}).then(i=>n.deepClone(i))}read(e,o){const{select:s}=o,i=ae(e);return(this.queries.get(i)||[]).reduce((a,l)=>{if(typeof s=="function"){const d=s(l.data);d&&a.push(d)}else a.push(l.data);return a},[])}feedback(e,o,s){return this.matchingClient.giveFeedback(e,o,s)}setLoadingStatus(e,o,s){const i=this.queries.get(e)||[],r=i.find(c=>K(c.params,o));r&&(r.loading=s),this.queries.set(e,i)}async runQuery(e,o){const{searchPhrase:s="",categories:i="0",contactMethodCategoryId:r="0",contactMethodId:c="0",tagId:a=void 0,take:l=5,connection:d="",guideId:g,expandCategories:f="descendants",currentCategory:y,sorting:v="popularity-descending",guideIds:p=[]}=o,m=s.toString().trim();if(await Ae(this.container))return Promise.resolve();switch(e){case"match":{const h=x=>{const[R,N]=x.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(R),direction:N}};return p.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:p,take:+l}}).then(x=>x&&this.handleResponse(x,e,o)):this.matchingClient.match(m,{categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+l,tags:a,sorting:h(v),ids:p}).then(x=>x&&this.handleResponse(x,e,o))}case"match-by-category":return this.matchingClient.match(m,{groupByCategory:!0,categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+l,tags:a}).then(h=>h&&this.handleResponse(h,e,o));case"guide":return this.matchingClient.getGuide(g,{connectionId:d}).then(h=>{h&&this.handleResponse(h,e,o)}).catch(h=>{const x={message:"Something went wrong.",status:h.status||400};x.status===404&&(x.message="The guide could not be found."),this.handleResponse({},e,o,x)});case"categories":return this.matchingClient.getCategories({phrase:m,expand:f,tags:a}).then(h=>h&&this.handleResponse(h,e,o));case"contacts":return g?this.matchingClient.contactMethods(+g,{phrase:m}).then(h=>h&&this.handleResponse(h,e,o)):this.matchingClient.contacts(+r,{phrase:m}).then(h=>h&&this.handleResponse(h,e,o));case"contact-method":return this.matchingClient.getContactMethod(+c,{guideId:g,currentCategory:y}).then(h=>h&&this.handleResponse(h,e,o));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:m,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(h=>h&&this.handleResponse(h,e,o));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:m,categories:i==="0"?[]:Array.isArray(i)?i:[+i],tags:a}}).then(h=>h&&this.handleResponse(h,e,o));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:m,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(h=>h&&this.handleResponse(h,e,o))}}handleResponse(e={},o,s,i){const r=this.queries.get(o)||[],c=r.find(a=>K(a.params,s));if(c){const a=i||Le(o,e);this.track(a,o,i),c.resolvers.forEach(d=>{i?d.reject({error:a}):d.resolve(a)});const l=r.indexOf(c);l>-1&&r.splice(l,1),r.push({...c,error:i,resolvers:[],data:a,resolved:!0}),this.setLoadingStatus(o,s,!1),this.queries.set(o,r),i||this.events.dispatch("data-client:fetched",{type:o,params:s,response:a,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,o]of this.queries)o.filter(s=>!s.resolved).forEach(s=>{this.runQuery(e,s.params)})}track(e={},o,s){const i=this.container.get("$widget");i&&!s?i.events.dispatch("tracking:service-client-response",{type:o,data:e}):i&&i.events.dispatch("tracking:service-client-error",{type:o,error:s})}static create(e){return e.getAsync("matchingClient").then(async o=>{if(o)return new P(e,o);const s=await re(e);return e.registerAsync("matchingClient",()=>s),new P(e,s)})}getClient(){return this.matchingClient}}const Oe=({title:t="",className:e,id:o,parent:s,connection:i,type:r,target:c,href:a,children:l,connectionKey:d})=>{const g={},{name:f,params:y}=ie();switch(r){case"default":case"guide":const{id:v,title:p}=s;let m=d||i;v!==o&&!d&&(m=void 0),g.routeName=f,g.params=D({...y,guide:o,connection:m,uriName:ee(o===v?p:t)});break;case"link":g.href=a,g.target=c;break}return u.jsx(n.Link,{className:n.appendClassNames(e,"humany-dialog-link"),...g,children:l||u.jsxs(u.Fragment,{children:[r==="link"&&u.jsx(n.Icon,{faIcon:"link"}),u.jsx("span",{children:t})]})})};b.forwardRef(({className:t,dialog:e,...o},s)=>e.length?u.jsx(Be,{className:n.appendClassNames(t,"humany-dialog"),items:e,renderItem:i=>u.jsx("li",{"data-dialog":i.connection,children:u.jsx(Oe,{...i})},i.connection),...o,ref:s}):null);const Be=n.newStyled(n.List)`
|
|
2
2
|
${n.list}
|
|
3
3
|
a {
|
|
4
4
|
min-width: 150px;
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
}
|
|
244
244
|
`,X=n.newStyled(n.Text)`
|
|
245
245
|
font-style: italic;
|
|
246
|
-
`,Ue=({tags:t})=>t.filter(e=>e.symbol).length?u.jsx(Qe,{className:"humany-guide-list-tags",items:t,renderItem:({id:e,symbol:o,title:s})=>o&&u.jsx("li",{"data-tag":e,children:u.jsx(Ve,{size:18,symbol:o,title:s})},e)}):null;b.forwardRef(({title:t,id:e,route:o,symbolSize:s,collapseUri:i,children:r},c)=>{const{params:a}=ie();return u.jsxs(
|
|
246
|
+
`,Ue=({tags:t})=>t.filter(e=>e.symbol).length?u.jsx(Qe,{className:"humany-guide-list-tags",items:t,renderItem:({id:e,symbol:o,title:s})=>o&&u.jsx("li",{"data-tag":e,children:u.jsx(Ve,{size:18,symbol:o,title:s})},e)}):null;b.forwardRef(({title:t,id:e,route:o,symbolSize:s,collapseUri:i,children:r},c)=>{const{params:a}=ie();return u.jsxs(Ke,{ref:c,"data-guide":e,children:[u.jsx(n.TextLink,{title:t,"aria-label":t,routeName:o,params:D({...a,uriName:i||void 0,id:void 0,guide:void 0,accordion:void 0}),text:t,children:u.jsx(n.SymbolBadge,{size:s,symbol:{type:"Svg",content:"caret-up"}})}),r]})});const Ke=n.newStyled.li`
|
|
247
247
|
> a {
|
|
248
248
|
grid-column: 1/-1;
|
|
249
249
|
font-weight: bold;
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
> div {
|
|
254
254
|
grid-column: 1/-1;
|
|
255
255
|
}
|
|
256
|
-
`;b.forwardRef(({expandable:t=!1,routing:e={},paramMappers:o={},symbolSize:s=11,pageRole:i="link",pageCaret:r="down",showTags:c=!1,showFavoriteToggle:a=!1,localPaging:l=!1,onItemClick:d=()=>{},dispatch:g=()=>{},metadata:f={},pageLabel:y,className:v,children:p,items:m,renderItem:h,addFavoriteTooltip:x,removeFavoriteCancelLabel:
|
|
256
|
+
`;b.forwardRef(({expandable:t=!1,routing:e={},paramMappers:o={},symbolSize:s=11,pageRole:i="link",pageCaret:r="down",showTags:c=!1,showFavoriteToggle:a=!1,localPaging:l=!1,onItemClick:d=()=>{},dispatch:g=()=>{},metadata:f={},pageLabel:y,className:v,children:p,items:m,renderItem:h,addFavoriteTooltip:x,removeFavoriteCancelLabel:R,removeFavoriteConfirmLabel:N,removeFavoriteHeader:I,removeFavoriteLabel:L,removeFavoriteTooltip:C,searchResultsEmptyLabel:G,...k},A)=>{const H=Re(),w=b.useRef(),S=n.usePrevious(m),{guide:ye="guide",page:pe="index"}=e,{guide:be=({id:$})=>D({guide:$}),page:ne=()=>D()}=o,[ve,xe]=He();b.useImperativeHandle(A,()=>w.current);const Q=$=>{const{id:z,title:j,tags:O,published:Y,modified:B,publishedBy:U,modifiedBy:V}=$;return u.jsxs("li",{"data-guide":z,"has-metadata":(!!(f!=null&&f.showPublished)&&!!Y||!!(f!=null&&f.showModified)&&!!B).toString(),children:[u.jsx(n.TextLink,{className:"humany-guide-link",title:j,"aria-label":j,routeName:ye,onClick:Se=>d(Se,$),params:be($),text:j,children:u.jsx(n.SymbolBadge,{size:s,symbol:{type:"Svg",content:t?"caret-down":"caret-right"}})}),a&&u.jsx(Pe,{guideTitle:j,addFavoriteTooltip:x,removeFavoriteCancelLabel:R,removeFavoriteConfirmLabel:N,removeFavoriteHeader:I,removeFavoriteLabel:L,removeFavoriteTooltip:C,isFavorite:ve.indexOf(z)>-1,actions:xe,id:z}),c&&u.jsx(Ue,{tags:O}),u.jsx(We,{...f,indent:t?void 0:s,modified:B,published:Y,publishedBy:U,modifiedBy:V})]},z)},we=b.useCallback(($,z,j)=>h?h($,z,j,Q):Q($),[h,Q]),$e=b.useCallback($=>{l&&($.preventDefault(),g("page",ne()))},[g,l]);b.useEffect(()=>{if(S&&S.length<m.length&&w.current){const $=w.current.querySelectorAll(".humany-guide-list > ul > li"),z=$[S.length];if($.length===m.length&&S.length){const j=$[S.length];if(j){const O=j.querySelector(".humany-guide-link");O&&O.focus()}}else z&&new MutationObserver((O,Y)=>{O.forEach(B=>{if(B.addedNodes){const U=Array.from(B.addedNodes).find(V=>V.tagName==="A");U&&je(w.current,document.activeElement)&&(H&&U.focus(),Y.disconnect())}})}).observe(z,{attributes:!1,characterData:!1,childList:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1})}});const Ce=!!Object.keys(f).filter($=>typeof f[$]<"u").length;return u.jsxs(_e,{className:n.appendClassNames(v,"humany-guide-list"),"data-item-count":m.length,items:m,renderItem:we,isTabbing:H,expandable:t?"true":"false","grid-items":c||a||Ce?"true":"false",...n.convertToStringAttributes(k),ref:w,children:[y?u.jsx(n.TextLink,{text:y,title:y,"aria-label":y,routeName:pe,role:i,params:ne(),onClick:$e,children:u.jsx(n.SymbolBadge,{size:s,symbol:{type:"Svg",content:`caret-${r}`}})}):null,p,!k["data-loading"]&&m.length===0&&u.jsx("p",{children:G})]})});const _e=n.newStyled(n.ItemList)`
|
|
257
257
|
${n.itemList}
|
|
258
258
|
padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
|
|
259
259
|
overflow: auto;
|
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
a:focus-visible {
|
|
560
560
|
${n.linkTabStyle};
|
|
561
561
|
}
|
|
562
|
-
`,et=t=>{const e=Me(t.clientName),{params:{contactCategory:o,guideCategory:s,phrase:i}}=ie();if(typeof e>"u")return null;if(e===null)return process.env.NODE_ENV!=="production"?u.jsx(it,{title:`client-name: ${t.clientName}, id: ${t.id}`,className:"humany-non-resolved-contact-method",children:u.jsx(n.Typography,{variant:"h5",children:"Non resolved Contact Method type"})}):null;const r=(c={})=>{const a={...t,...c},{id:l,title:d,clientName:g,symbol:f,inline:y,onClick:v=()=>{},description:p,htmlParseInstruction:m,className:h,disabled:x,guideId:
|
|
562
|
+
`,et=t=>{const e=Me(t.clientName),{params:{contactCategory:o,guideCategory:s,phrase:i}}=ie();if(typeof e>"u")return null;if(e===null)return process.env.NODE_ENV!=="production"?u.jsx(it,{title:`client-name: ${t.clientName}, id: ${t.id}`,className:"humany-non-resolved-contact-method",children:u.jsx(n.Typography,{variant:"h5",children:"Non resolved Contact Method type"})}):null;const r=(c={})=>{const a={...t,...c},{id:l,title:d,clientName:g,symbol:f,inline:y,onClick:v=()=>{},description:p,htmlParseInstruction:m,className:h,disabled:x,guideId:R,dispatch:N=()=>{},expanded:I}=a,L=y?{onKeyDown:C=>{C.key&&C.key==="Enter"&&(v(C,a),C.defaultPrevented||!I&&N("expand",l))},onClick:C=>{v(C,a),C.defaultPrevented||!I&&N("expand",l)}}:{onClick:C=>v(C,a),routeName:"contact-method",params:D({contactCategory:o,guideId:R,guideCategory:s,phrase:i,contactMethod:l,uriName:ee(d)})};return u.jsxs(ot,{title:d,"aria-label":d,className:h,disabled:x,description:p,"data-client-name":g,...c,...L,children:[f&&u.jsx(n.SymbolBadge,{symbol:f}),p?u.jsxs("div",{className:"humany-contact-link-rich-content",children:[u.jsx(me,{children:d}),u.jsx(Xe,{html:p,htmlParseInstruction:m})]}):u.jsx(me,{children:d})]})};return t.expanded?u.jsx(b.Suspense,{fallback:null,children:u.jsx(e,{...t,renderDefault:r})}):r()},tt=t=>{var e,o,s,i,r,c,a,l;return n.css`
|
|
563
563
|
display: flex;
|
|
564
564
|
padding: ${(e=t.theme.sizes)==null?void 0:e.large};
|
|
565
565
|
${t.description?"":"align-items: center;"}
|
|
@@ -639,6 +639,6 @@
|
|
|
639
639
|
}
|
|
640
640
|
`};n.newStyled(n.ItemList)`
|
|
641
641
|
${t=>nt(t)}
|
|
642
|
-
`;const st=({contactMethodId:t,guideId:e,groupId:o,className:s})=>{var f,y,v;const[i,r]=b.useState(),c=n.useContainer(),a=Te(),l=b.useRef(!0),d=ze();b.useEffect(()=>{
|
|
642
|
+
`;const st=({contactMethodId:t,guideId:e,groupId:o,className:s})=>{var f,y,v;const[i,r]=b.useState(),c=n.useContainer(),a=Te(),l=b.useRef(!0),d=ze();b.useEffect(()=>{console.log("### ",c),console.log("### ",c.get("$widget"))},[c,i,r,d]);const g=b.useCallback(async p=>{const h=await(await P.getInstance(c)).fetch(ge.ContactMethod,{contactMethodId:p,guideId:e},{noCache:!0}),x=n.updateForm(h,{submit:"Submit",errors:{},meta:{groupId:o}});if(h.body=x,h.body.guideId=e,!l.current)return null;r(h)},[l]);return b.useEffect(()=>(g(t),()=>{l.current=!1}),[t,g]),i?u.jsx(rt,{...i,body:{...i.body,form:i.body.form?{...i.body.form,data:(f=i.body.form)==null?void 0:f.data,layout:{...i.body.form.layout},meta:(y=i.body.form)==null?void 0:y.meta,schema:(v=i.body.form)==null?void 0:v.schema}:void 0,guideId:i.body.guideId},inline:!0,expanded:!0,dispatch:a,className:n.appendClassNames("humany-bot-contact-method",s)}):null},rt=n.newStyled(et)`
|
|
643
643
|
padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}} ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
|
|
644
644
|
`;exports.default=st;
|