@telia-ace/knowledge-data-client-flamingo 1.1.110-rc.2 → 1.1.110
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/index.js +1 -1
- package/index.mjs +175 -175
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=(i,e,t,...n)=>{const s=`[${i.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(s,...n);break;case"warning":console.warn(s,...n);break;case"error":console.error(s,...n);break}},ie=i=>{const e=i.container||i;return{info:(t,...n)=>j(e,"info",t,...n),warn:(t,...n)=>j(e,"warning",t,...n),error:(t,...n)=>j(e,"error",t,...n)}};var T=(i=>(i.Implementation="implementation",i.Widget="widget",i))(T||{}),k=(i=>(i.Pre="pre",i.Post="post",i))(k||{});const se=(i,e,t,n)=>{try{const s=new e(t,n);return{name:i,invoke:(o,a)=>{let r;return s[o]&&(r=s[o].call(s,a)),Promise.resolve(r)},getInstance:()=>s}}catch(s){if(s.message&&s.message.indexOf("is not a constructor")>=0)return{name:i,invoke:o=>{let a;return o==="initialize"&&(a=e(t,n)),Promise.resolve(a)},getInstance:()=>e};throw s}};function W(i,e){return typeof i>"u"?e:i}class ne{constructor(e={}){this.part=e}createCommand(e,t,n){let s;typeof t=="function"?s={scope:T.Widget,stage:k.Post,defaultArgs:void 0,handlerResolver:t}:s={scope:W(t.scope,T.Widget),stage:W(t.stage,k.Post),defaultArgs:t.defaultArgs,handlerResolver:n};let o=this.part;const a=e.split(".");return a.forEach((r,c)=>{c===a.length-1?o[r]||(o[r]=()=>s):o=this.part[r]=this.part[r]||{}}),this}get(){return this.part}}const z=i=>{const e=new ne({});return i(e),e.get()};z(i=>{i.createCommand("types.register",{scope:T.Implementation,stage:k.Pre},e=>(t,n)=>{e.container.get("$types")[t]=n}).createCommand("type",{stage:k.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:k.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:k.Pre},e=>(t,n,s)=>{const{container:o}=e;let a=null,r=t,c=n;typeof t=="string"&&(a=t,r=n,c=s);const d=u=>{const{transformPluginSettings:f}=e.container.get("$environmentOptions"),h=f?f(c||{},a,e.container,r):n;try{const p=se(a,r,o,h);o.get("$plugins").push(p),u&&p.invoke("initialize",null)}catch(p){ie(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?d(!0):e.events.subscribeOnce("widget:instance-created",()=>d(!1))}).createCommand("container.register",e=>(t,n)=>{e.container.register(t,n)}).createCommand("container.registerAsync",e=>(t,n)=>{e.container.registerAsync(t,n)}).createCommand("container.registerFactory",e=>(t,n)=>{e.container.registerFactory(t,n)}).createCommand("container.touch",e=>(t,n)=>{e.container.touch(t,n)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})});const G=(i,e,...t)=>typeof e=="string"?i(`[humany] ${e}`,...t):i(e,...t),M=class{constructor(){this.keys=[],this.log=(i,...e)=>this.lookup(i,()=>M.log(...e)),this.warn=(i,...e)=>this.lookup(i,()=>M.warn(...e)),this.error=(i,...e)=>this.lookup(i,()=>M.error(...e)),this.info=(i,...e)=>this.lookup(i,()=>M.info(...e))}lookup(i,e){this.keys.indexOf(i)===-1&&(this.keys.push(i),e())}};let S=M;S.log=(...i)=>G(console.log,...i);S.warn=(...i)=>G(console.warn,...i);S.error=(...i)=>G(console.error,...i);S.info=(...i)=>G(console.info,...i);const V=i=>{let e={},t,n;if(typeof i!="object"||i===null)return i;e=Array.isArray(i)?[]:{};for(n in i)t=i[n],e[n]=typeof t=="object"&&t!==null?V(t):t;return e};class oe{constructor(e,t){this.lockWarningTime=e,this.lockErrorTime=t,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,n,s){this.tasks.push({task:e,resolve:t,reject:n,done:s}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){let t;const n=setTimeout(()=>{process.env.NODE_ENV!=="production"&&S.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,e),t=setTimeout(()=>{e.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),s=Promise.resolve(e.task()).then(o=>(clearTimeout(n),clearTimeout(t),o));return Promise.resolve(s).then(this.next).then(()=>s.then(o=>{e.done(),e.resolve(o)})).catch(o=>(e.done(),e.reject(o),this.next()))}return Promise.resolve()})}}const P=new WeakMap;function re(i,e=5e3,t=1e3){return P.has(i)||P.set(i,new oe(e,t)),n=>new Promise((s,o)=>{const a=P.get(i);a.add(n,s,o,()=>{a.tasks.length||P.delete(i)})})}const ae=(i={})=>(Object.keys(i).forEach(e=>{(i[e]===null||typeof i[e]>"u")&&delete i[e]}),i),R=(i,e)=>{let t=!0;return Object.keys(i).length!==Object.keys(e).length||Object.keys(i).some(n=>!Object.keys(e).some(s=>n===s))?!1:(Object.keys(i).forEach(n=>{if(t){const s=typeof i[n]>"u"?"":i[n],o=typeof e[n]>"u"?"":e[n];t=s.toString()===o.toString()}}),t)};z(i=>{i.createCommand("components",e=>t=>{e.events.subscribeOnce("components:platform-created",(n,{platform:s})=>{t.handlers&&t.handlers.forEach(([o,a])=>{s.addComponentHandler(o,a)})})})});var q=(i=>(i.open="open",i.closed="closed",i.hidden="hidden",i))(q||{});const K=i=>Promise.resolve().then(()=>require("./index-B9t-W0wz.js")).then(({ServiceClient:e,ServiceProxy:t})=>i.get("settings").then(n=>{const{name:s,events:o}=i.get("$widget"),{data:{projection:a="",site:r="current",forceHttps:c=!1}}=n,d=new t(a,{credentials:"same-origin"}),u=new e(d,{funnel:s.replace("_contact-method","").replace("_contact",""),site:ce(r,c)},null,i);return o.subscribe("widget:settings-updated",(f,{data:h})=>{h&&h.projection!==a&&u.proxy.setBaseUrl(h.projection)}),u})),ce=(i,e)=>()=>{const t=s=>{const o=document.createElement("a");return o.href=s,o};let n=window.location;return i==="referrer"&&document.referrer&&(n=t(document.referrer)),[e?"https:":"","//",n.host,n.pathname].join("")},N=i=>{if(i){const{Type:e,Content:t}=i;if(e&&t)return{type:e,content:t}}},U=i=>i.map(e=>{const t={id:e.Id.toString(),title:e.Name,symbol:N(e.DefaultIcon),activeSymbol:e.ActiveIcon&&N(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(t.items=U(e.Children)),t}),v=(i,e)=>i.filter(({Type:t})=>t===e).map(({Id:t,Title:n,Body:s})=>({id:t.toString(),title:n,body:s})),D=i=>i.map(({Id:e,Title:t,DefaultIcon:n,ListNotices:s,Notices:o})=>({id:e.toString(),title:t,symbol:N(n),defaultHeaderOptions:{visible:!!s.length},notifications:(s||[]).concat(o||[]).map(({Id:a,Title:r,Body:c,Type:d,Modified:u})=>({id:a.toString(),title:r,body:c,modified:u,expandable:d==="listNotice"}))})),B=({Id:i,Title:e,DefaultIcon:t,Exits:[n],ExitType:s,ConfirmationText:o,Description:a},r)=>{const{Adapter:c}=n||{Adapter:{}},{ClientName:d="",Settings:u={},CustomClientName:f=""}=c,h={id:i.toString(),title:e,description:a,symbol:N(t),clientName:d==="custom.adapter"?f:d,expanded:!0,inline:!0,body:{}};if(d.indexOf("phone")>-1||d.indexOf("freetext")>-1){const{displayTextBeforeClick:p,textBeforeClick:w}=u;p==="true"&&(h.expanded=!1,h.title=w),d.indexOf("phone.text")>-1?h.body.phoneNumber=u.phoneNumber:h.body.freetext=u.freetext}return(d.indexOf("chat.popup")>-1||d.indexOf("link")>-1||d==="custom.adapter"&&s==="custom")&&(h.body=u,h.body.confirmationFallback=o),d.indexOf("ace")>-1&&(h.body=u),h},E=(i=[])=>i.map(({Id:e,Title:t,TotalMatches:n,Symbol:s,DefaultIcon:o,ActiveIcon:a})=>({id:e.toString(),title:t,matches:n,symbol:N(o||s),defaultIcon:N(o),activeIcon:N(a)})),$=i=>i.map(({Id:e,Title:t,Tags:n,FirstPublishedDate:s,Modified:o})=>({id:e.toString(),title:t,tags:E(n),published:s,modified:o})),Y=(i,e)=>{switch(i){case m.MatchByCategory:case m.Match:{const t={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:n,TotalMatches:s,Notices:o,NoticeLists:a,Tags:r,ByCategory:c}=e;return t.guides=$(n),t.matches=s,t.byCategory=(c||[]).map(({Id:d,Matches:u,TotalMatches:f})=>({id:d,guides:$(u),matches:f})),t.tags=E(r),t.notificationLists=D(a||[]),t.topNotifications=v(o||[],"noticeRowTop"),t.middleNotifications=v(o||[],"noticeRowMiddle"),t.bottomNotifications=v(o||[],"footerNotice"),t}case m.Categories:{const{Children:t,GuidesCountTotal:n}=e;return{categories:U(t||[]),matches:n}}case m.Guide:{const{Id:t,Title:n,Body:s,Related:o,Options:a,ConnectionId:r,ContactMethods:c,EnableFeedback:d,HandoverExists:u,FirstPublishedDate:f,Modified:h,ModifiedByDisplayName:p,FirstPublishedByDisplayName:w,Categories:y,Tags:l,SeoMetaDescription:g,SeoAllowIndex:L,Perspectives:x,PerspectiveKey:F,Translations:H}=e,ee=F||Object.values(x).find(b=>b===r)||x.Default||null,Q={guide:{id:t.toString(),title:n,body:s,modified:h,published:f,modifiedBy:p,publishedBy:w,connection:r,categories:y,hasHandover:u,allowFeedback:d,seoMetaDescription:g,seoAllowIndex:L,perspectives:x,perspective:ee,translations:Object.keys(H||{}).reduce((b,O)=>(b[O]=H[O].toString(),b),{})},related:$(o||[]),dialog:[],contactMethods:(c||[]).map(b=>B(b)),tags:E(l)};return(a||[]).forEach(({CanAccess:b,Description:O,ConnectionId:te,Properties:C})=>{if(!b)return;const A={id:t.toString(),title:O,connection:te,connectionKey:C.ConnectionKey,type:"default",parent:{id:t.toString(),title:n,tags:E(l)}};if(C.Type==="Guide"||C.Type==="Link")switch(C.Id&&(A.id=C.Id.toString()),C.Uri&&(A.href=C.Uri),C.Target&&(A.target=C.Target),C.Type){case"Guide":A.type="guide";break;case"Link":A.type="link";break}Q.dialog.push(A)}),Q}case m.Contacts:{const{Children:t,Matches:n,Notices:s,NoticeLists:o}=e;return{contactMethods:(n||[]).map(r=>B(r)),categories:U(t||[]),topNotifications:v(s||[],"noticeRowTop"),middleNotifications:v(s||[],"noticeRowMiddle"),bottomNotifications:v(s||[],"footerNotice"),notificationLists:D(o||[])}}case m.ContactMethod:{const{ContactMethod:t}=e;return B(t||{})}case m.Tags:case m.TagsOnGuides:return E(e||[]);case m.Notifications:{const{Notices:t,NoticeLists:n}=e;return{topNotifications:v(t||[],"noticeRowTop"),middleNotifications:v(t||[],"noticeRowMiddle"),bottomNotifications:v(t||[],"footerNotice"),notificationLists:D(n||[])}}default:return{}}};var J=(i=>(i.Guide="guide",i.Guides="guides",i.GuidesByCategory="guides-by-category",i.RowNotifications="row-notices",i.NotificationLists="notification-lists",i.GuideCategories="guide-categories",i.ContactMethodCategories="contact-method-categories",i.ContactMethod="contact-method",i.ContactMethods="contact-methods",i.Tags="tags",i.TagsOnGuides="tagsonguides",i))(J||{}),m=(i=>(i.Match="match",i.Categories="categories",i.Guide="guide",i.Contacts="contacts",i.ContactMethod="contact-method",i.MatchByCategory="match-by-category",i.Tags="tags",i.TagsOnGuides="tagsonguides",i.Notifications="notifications",i))(m||{}),X=(i=>(i.Positive="Positive",i.Negative="Negative",i))(X||{}),Z=(i=>(i.POPULARITY_DESCENDING="popularity-descending",i.ALPHABETIC_ASCENDING="alphabetic-ascending",i.ALPHABETIC_DESCENDING="alphabetic-descending",i.MODIFIED_ASCENDING="modified-ascending",i.MODIFIED_DESCENDING="modified-descending",i.PUBLISHED_ASCENDING="published-ascending",i.PUBLISHED_DESCENDING="published-descending",i))(Z||{});const _=i=>{switch(i){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"}},de=async i=>{const{invoke:e}=i.get("$widget");return await e("renderState")===q.hidden};class I{constructor(e,t){this.container=e,this.matchingClient=t,this.queries=new Map,this.getUnresolvedQueries=()=>{let n=0;return this.queries.forEach((s,o)=>{s.some(r=>!r.resolved)&&(n=1)}),n},this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(n,{next:s,previous:o})=>{o===q.hidden&&s===q.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,t="dataClient"){return re(this)(()=>e.getAsync(t).then(async n=>{let s=await e.getAsync("matchingClient");s||(s=await K(e),e.registerAsync("matchingClient",()=>s));let o=n;return o||(o=new I(e,s),e.registerAsync(t,()=>o)),o}))}fetch(e,t,n){return new Promise((s,o)=>{t.take,ae(t);const a=_(e);let r=this.queries.get(a)||[],c=r.find(d=>R(d.params,t))||null;if(c&&(n!=null&&n.noCache)){const d=r.findIndex(u=>R(u.params,t));r=[...r.slice(0,d),...r.slice(d+1)],c=null}if(c){const d=r.indexOf(c);if(c.resolved?(this.events.dispatch("data-client:fetched",{params:t,type:a,response:c.data,unresolvedQueries:this.getUnresolvedQueries()}),this.track(c.data,a,c.error),c.data&&c.error?o({error:c.error}):s(c.data)):c.resolvers.push({resolve:s,reject:o}),r.splice(d,1),r.push(c),this.queries.set(a,r),!c.loading&&!c.resolved)return this.runQuery(a,t)}else return r.push({params:t,resolved:!1,loading:!0,data:{},resolvers:[{resolve:s,reject:o}]}),this.queries.set(a,r),this.runQuery(a,t)}).then(s=>V(s))}read(e,t){const{select:n}=t,s=_(e);return(this.queries.get(s)||[]).reduce((r,c)=>{if(typeof n=="function"){const d=n(c.data);d&&r.push(d)}else r.push(c.data);return r},[])}feedback(e,t,n){return this.matchingClient.giveFeedback(e,t,n)}setLoadingStatus(e,t,n){const s=this.queries.get(e)||[],o=s.find(a=>R(a.params,t));o&&(o.loading=n),this.queries.set(e,s)}async runQuery(e,t){const{searchPhrase:n="",categories:s="0",contactMethodCategoryId:o="0",contactMethodId:a="0",tagId:r=void 0,take:c=5,connection:d="",guideId:u,expandCategories:f="descendants",currentCategory:h,sorting:p="popularity-descending",guideIds:w=[]}=t,y=n.toString().trim();if(await de(this.container))return Promise.resolve();switch(e){case"match":{const l=g=>{const[L,x]=g.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(L),direction:x}};return w.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:w,take:+c}}).then(g=>g&&this.handleResponse(g,e,t)):this.matchingClient.match(y,{categories:s==="0"?[]:Array.isArray(s)?s:[+s],take:+c,tags:r,sorting:l(p),ids:w}).then(g=>g&&this.handleResponse(g,e,t))}case"match-by-category":return this.matchingClient.match(y,{groupByCategory:!0,categories:s==="0"?[]:Array.isArray(s)?s:[+s],take:+c,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"guide":return this.matchingClient.getGuide(u,{connectionId:d}).then(l=>{l&&this.handleResponse(l,e,t)}).catch(l=>{const g={message:"Something went wrong.",status:l.status||400};g.status===404&&(g.message="The guide could not be found."),this.handleResponse({},e,t,g)});case"categories":return this.matchingClient.getCategories({phrase:y,expand:f,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"contacts":return u?this.matchingClient.contactMethods(+u,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t)):this.matchingClient.contacts(+o,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t));case"contact-method":return this.matchingClient.getContactMethod(+a,{guideId:u,currentCategory:h}).then(l=>l&&this.handleResponse(l,e,t));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:y,categories:s==="0"?[]:Array.isArray(s)?s:[+s]}}).then(l=>l&&this.handleResponse(l,e,t));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:y,categories:s==="0"?[]:Array.isArray(s)?s:[+s],tags:r}}).then(l=>l&&this.handleResponse(l,e,t));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:y,categories:s==="0"?[]:Array.isArray(s)?s:[+s]}}).then(l=>l&&this.handleResponse(l,e,t))}}handleResponse(e={},t,n,s){const o=this.queries.get(t)||[],a=o.find(r=>R(r.params,n));if(a){const r=s||Y(t,e);this.track(r,t,s),a.resolvers.forEach(d=>{s?d.reject({error:r}):d.resolve(r)});const c=o.indexOf(a);c>-1&&o.splice(c,1),o.push({...a,error:s,resolvers:[],data:r,resolved:!0}),this.setLoadingStatus(t,n,!1),this.queries.set(t,o),s||this.events.dispatch("data-client:fetched",{type:t,params:n,response:r,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,t]of this.queries)t.filter(n=>!n.resolved).forEach(n=>{this.runQuery(e,n.params)})}track(e={},t,n){const s=this.container.get("$widget");s&&!n?s.events.dispatch("tracking:service-client-response",{type:t,data:e}):s&&s.events.dispatch("tracking:service-client-error",{type:t,error:n})}static create(e){return e.getAsync("matchingClient").then(async t=>{if(t)return new I(e,t);const n=await K(e);return e.registerAsync("matchingClient",()=>n),new I(e,n)})}getClient(){return this.matchingClient}}const le=async i=>{i.registerAsync("dataClient",()=>I.create(i))};exports.DataClient=I;exports.DataType=J;exports.FeedbackType=X;exports.KnowledgeDataClientPlugin=le;exports.ServiceClientQueryType=m;exports.SortingType=Z;exports.determineServiceClientQueryType=_;exports.formatLegacyData=Y;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=(s,e,t,...n)=>{const i=`[${s.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(i,...n);break;case"warning":console.warn(i,...n);break;case"error":console.error(i,...n);break}},se=s=>{const e=s.container||s;return{info:(t,...n)=>j(e,"info",t,...n),warn:(t,...n)=>j(e,"warning",t,...n),error:(t,...n)=>j(e,"error",t,...n)}};var T=(s=>(s.Implementation="implementation",s.Widget="widget",s))(T||{}),k=(s=>(s.Pre="pre",s.Post="post",s))(k||{});const ie=(s,e,t,n)=>{try{const i=new e(t,n);return{name:s,invoke:(o,a)=>{let r;return i[o]&&(r=i[o].call(i,a)),Promise.resolve(r)},getInstance:()=>i}}catch(i){if(i.message&&i.message.indexOf("is not a constructor")>=0)return{name:s,invoke:o=>{let a;return o==="initialize"&&(a=e(t,n)),Promise.resolve(a)},getInstance:()=>e};throw i}};function W(s,e){return typeof s>"u"?e:s}class ne{constructor(e={}){this.part=e}createCommand(e,t,n){let i;typeof t=="function"?i={scope:T.Widget,stage:k.Post,defaultArgs:void 0,handlerResolver:t}:i={scope:W(t.scope,T.Widget),stage:W(t.stage,k.Post),defaultArgs:t.defaultArgs,handlerResolver:n};let o=this.part;const a=e.split(".");return a.forEach((r,c)=>{c===a.length-1?o[r]||(o[r]=()=>i):o=this.part[r]=this.part[r]||{}}),this}get(){return this.part}}const z=s=>{const e=new ne({});return s(e),e.get()};z(s=>{s.createCommand("types.register",{scope:T.Implementation,stage:k.Pre},e=>(t,n)=>{e.container.get("$types")[t]=n}).createCommand("type",{stage:k.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:k.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:k.Pre},e=>(t,n,i)=>{const{container:o}=e;let a=null,r=t,c=n;typeof t=="string"&&(a=t,r=n,c=i);const d=u=>{const{transformPluginSettings:f}=e.container.get("$environmentOptions"),h=f?f(c||{},a,e.container,r):n;try{const p=ie(a,r,o,h);o.get("$plugins").push(p),u&&p.invoke("initialize",null)}catch(p){se(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?d(!0):e.events.subscribeOnce("widget:instance-created",()=>d(!1))}).createCommand("container.register",e=>(t,n)=>{e.container.register(t,n)}).createCommand("container.registerAsync",e=>(t,n)=>{e.container.registerAsync(t,n)}).createCommand("container.registerFactory",e=>(t,n)=>{e.container.registerFactory(t,n)}).createCommand("container.touch",e=>(t,n)=>{e.container.touch(t,n)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})});const G=(s,e,...t)=>typeof e=="string"?s(`[humany] ${e}`,...t):s(e,...t),M=class{constructor(){this.keys=[],this.log=(s,...e)=>this.lookup(s,()=>M.log(...e)),this.warn=(s,...e)=>this.lookup(s,()=>M.warn(...e)),this.error=(s,...e)=>this.lookup(s,()=>M.error(...e)),this.info=(s,...e)=>this.lookup(s,()=>M.info(...e))}lookup(s,e){this.keys.indexOf(s)===-1&&(this.keys.push(s),e())}};let S=M;S.log=(...s)=>G(console.log,...s);S.warn=(...s)=>G(console.warn,...s);S.error=(...s)=>G(console.error,...s);S.info=(...s)=>G(console.info,...s);const V=s=>{let e={},t,n;if(typeof s!="object"||s===null)return s;e=Array.isArray(s)?[]:{};for(n in s)t=s[n],e[n]=typeof t=="object"&&t!==null?V(t):t;return e};class oe{constructor(e,t){this.lockWarningTime=e,this.lockErrorTime=t,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,n,i){this.tasks.push({task:e,resolve:t,reject:n,done:i}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){let t;const n=setTimeout(()=>{process.env.NODE_ENV!=="production"&&S.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,e),t=setTimeout(()=>{e.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),i=Promise.resolve(e.task()).then(o=>(clearTimeout(n),clearTimeout(t),o));return Promise.resolve(i).then(this.next).then(()=>i.then(o=>{e.done(),e.resolve(o)})).catch(o=>(e.done(),e.reject(o),this.next()))}return Promise.resolve()})}}const P=new WeakMap;function re(s,e=5e3,t=1e3){return P.has(s)||P.set(s,new oe(e,t)),n=>new Promise((i,o)=>{const a=P.get(s);a.add(n,i,o,()=>{a.tasks.length||P.delete(s)})})}const ae=(s={})=>(Object.keys(s).forEach(e=>{(s[e]===null||typeof s[e]>"u")&&delete s[e]}),s),R=(s,e)=>{let t=!0;return Object.keys(s).length!==Object.keys(e).length||Object.keys(s).some(n=>!Object.keys(e).some(i=>n===i))?!1:(Object.keys(s).forEach(n=>{if(t){const i=typeof s[n]>"u"?"":s[n],o=typeof e[n]>"u"?"":e[n];t=i.toString()===o.toString()}}),t)};z(s=>{s.createCommand("components",e=>t=>{e.events.subscribeOnce("components:platform-created",(n,{platform:i})=>{t.handlers&&t.handlers.forEach(([o,a])=>{i.addComponentHandler(o,a)})})})});var q=(s=>(s.open="open",s.closed="closed",s.hidden="hidden",s))(q||{});const K=s=>Promise.resolve().then(()=>require("./index-B9t-W0wz.js")).then(({ServiceClient:e,ServiceProxy:t})=>s.get("settings").then(n=>{const{name:i,events:o}=s.get("$widget"),{data:{projection:a="",site:r="current",forceHttps:c=!1}}=n,d=new t(a,{credentials:"same-origin"}),u=new e(d,{funnel:i.replace("_contact-method","").replace("_contact",""),site:ce(r,c)},null,s);return o.subscribe("widget:settings-updated",(f,{data:h})=>{h&&h.projection!==a&&u.proxy.setBaseUrl(h.projection)}),u})),ce=(s,e)=>()=>{const t=i=>{const o=document.createElement("a");return o.href=i,o};let n=window.location;return s==="referrer"&&document.referrer&&(n=t(document.referrer)),[e?"https:":"","//",n.host,n.pathname].join("")},N=s=>{if(s){const{Type:e,Content:t}=s;if(e&&t)return{type:e,content:t}}},U=s=>s.map(e=>{const t={id:e.Id.toString(),title:e.Name,symbol:N(e.DefaultIcon),activeSymbol:e.ActiveIcon&&N(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(t.items=U(e.Children)),t}),b=(s,e)=>s.filter(({Type:t})=>t===e).map(({Id:t,Title:n,Body:i})=>({id:t.toString(),title:n,body:i})),D=s=>s.map(({Id:e,Title:t,DefaultIcon:n,ListNotices:i,Notices:o})=>({id:e.toString(),title:t,symbol:N(n),defaultHeaderOptions:{visible:!!i.length},notifications:(i||[]).concat(o||[]).map(({Id:a,Title:r,Body:c,Type:d,Modified:u})=>({id:a.toString(),title:r,body:c,modified:u,expandable:d==="listNotice"}))})),B=({Id:s,Title:e,DefaultIcon:t,Exits:[n],ExitType:i,ConfirmationText:o,Description:a},r)=>{const{Adapter:c}=n||{Adapter:{}},{ClientName:d="",Settings:u={},CustomClientName:f=""}=c,h={id:s.toString(),title:e,description:a,symbol:N(t),clientName:d==="custom.adapter"?f:d,expanded:!0,inline:!0,body:{}};if(d.indexOf("phone")>-1||d.indexOf("freetext")>-1){const{displayTextBeforeClick:p,textBeforeClick:w}=u;p==="true"&&(h.expanded=!1,h.title=w),d.indexOf("phone.text")>-1?h.body.phoneNumber=u.phoneNumber:h.body.freetext=u.freetext}return(d.indexOf("chat.popup")>-1||d.indexOf("link")>-1||d==="custom.adapter"&&i==="custom")&&(h.body=u,h.body.confirmationFallback=o),d.indexOf("ace")>-1&&(h.body=u),h},E=(s=[])=>s.map(({Id:e,Title:t,TotalMatches:n,Symbol:i,DefaultIcon:o,ActiveIcon:a})=>({id:e.toString(),title:t,matches:n,symbol:N(o||i),defaultIcon:N(o),activeIcon:N(a)})),$=s=>s.map(({Id:e,Title:t,Tags:n,FirstPublishedDate:i,Modified:o})=>({id:e.toString(),title:t,tags:E(n),published:i,modified:o})),Y=(s,e)=>{switch(s){case m.MatchByCategory:case m.Match:{const t={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:n,TotalMatches:i,Notices:o,NoticeLists:a,Tags:r,ByCategory:c}=e;return t.guides=$(n),t.matches=i,t.byCategory=(c||[]).map(({Id:d,Matches:u,TotalMatches:f})=>({id:d,guides:$(u),matches:f})),t.tags=E(r),t.notificationLists=D(a||[]),t.topNotifications=b(o||[],"noticeRowTop"),t.middleNotifications=b(o||[],"noticeRowMiddle"),t.bottomNotifications=b(o||[],"footerNotice"),t}case m.Categories:{const{Children:t,GuidesCountTotal:n}=e;return{categories:U(t||[]),matches:n}}case m.Guide:{const{Id:t,Title:n,Body:i,Related:o,Options:a,ConnectionId:r,ContactMethods:c,EnableFeedback:d,HandoverExists:u,FirstPublishedDate:f,Modified:h,ModifiedByDisplayName:p,FirstPublishedByDisplayName:w,Categories:y,Tags:l,SeoMetaDescription:g,SeoAllowIndex:L,Perspectives:x,PerspectiveKey:F,Translations:H}=e,ee=F||Object.values(x).find(v=>v===r)||x.Default||null,Q={guide:{id:t.toString(),title:n,body:i,modified:h,published:f,modifiedBy:p,publishedBy:w,connection:r,categories:y,hasHandover:u,allowFeedback:d,seoMetaDescription:g,seoAllowIndex:L,perspectives:x,perspective:ee,translations:Object.keys(H||{}).reduce((v,O)=>(v[O]=H[O].toString(),v),{})},related:$(o||[]),dialog:[],contactMethods:(c||[]).map(v=>B(v)),tags:E(l)};return(a||[]).forEach(({CanAccess:v,Description:O,ConnectionId:te,Properties:C})=>{if(!v)return;const A={id:t.toString(),title:O,connection:te,connectionKey:C.ConnectionKey,type:"default",parent:{id:t.toString(),title:n,tags:E(l)}};if(C.Type==="Guide"||C.Type==="Link")switch(C.Id&&(A.id=C.Id.toString()),C.Uri&&(A.href=C.Uri),C.Target&&(A.target=C.Target),C.Type){case"Guide":A.type="guide";break;case"Link":A.type="link";break}Q.dialog.push(A)}),Q}case m.Contacts:{const{Children:t,Matches:n,Notices:i,NoticeLists:o}=e;return{contactMethods:(n||[]).map(r=>B(r)),categories:U(t||[]),topNotifications:b(i||[],"noticeRowTop"),middleNotifications:b(i||[],"noticeRowMiddle"),bottomNotifications:b(i||[],"footerNotice"),notificationLists:D(o||[])}}case m.ContactMethod:{const{ContactMethod:t}=e;return B(t||{})}case m.Tags:case m.TagsOnGuides:return E(e||[]);case m.Notifications:{const{Notices:t,NoticeLists:n}=e;return{topNotifications:b(t||[],"noticeRowTop"),middleNotifications:b(t||[],"noticeRowMiddle"),bottomNotifications:b(t||[],"footerNotice"),notificationLists:D(n||[])}}default:return{}}};var J=(s=>(s.Guide="guide",s.Guides="guides",s.GuidesByCategory="guides-by-category",s.RowNotifications="row-notices",s.NotificationLists="notification-lists",s.GuideCategories="guide-categories",s.ContactMethodCategories="contact-method-categories",s.ContactMethod="contact-method",s.ContactMethods="contact-methods",s.Tags="tags",s.TagsOnGuides="tagsonguides",s))(J||{}),m=(s=>(s.Match="match",s.Categories="categories",s.Guide="guide",s.Contacts="contacts",s.ContactMethod="contact-method",s.MatchByCategory="match-by-category",s.Tags="tags",s.TagsOnGuides="tagsonguides",s.Notifications="notifications",s))(m||{}),X=(s=>(s.Positive="Positive",s.Negative="Negative",s))(X||{}),Z=(s=>(s.POPULARITY_DESCENDING="popularity-descending",s.ALPHABETIC_ASCENDING="alphabetic-ascending",s.ALPHABETIC_DESCENDING="alphabetic-descending",s.MODIFIED_ASCENDING="modified-ascending",s.MODIFIED_DESCENDING="modified-descending",s.PUBLISHED_ASCENDING="published-ascending",s.PUBLISHED_DESCENDING="published-descending",s))(Z||{});const _=s=>{switch(s){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"}},de=async s=>{const{invoke:e}=s.get("$widget");return await e("renderState")===q.hidden};class I{constructor(e,t){this.container=e,this.matchingClient=t,this.queries=new Map,this.getUnresolvedQueries=()=>{let n=0;return this.queries.forEach((i,o)=>{i.some(r=>!r.resolved)&&(n=1)}),n},this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(n,{next:i,previous:o})=>{o===q.hidden&&i===q.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,t="dataClient"){return re(this)(()=>e.getAsync(t).then(async n=>{let i=await e.getAsync("matchingClient");i||(i=await K(e),e.registerAsync("matchingClient",()=>i));let o=n;return o||(o=new I(e,i),e.registerAsync(t,()=>o)),o}))}fetch(e,t,n){return new Promise((i,o)=>{t.take,ae(t);const a=_(e);let r=this.queries.get(a)||[],c=r.find(d=>R(d.params,t))||null;if(c&&(n!=null&&n.noCache)){const d=r.findIndex(u=>R(u.params,t));r=[...r.slice(0,d),...r.slice(d+1)],c=null}if(c){const d=r.indexOf(c);if(c.resolved?(this.events.dispatch("data-client:fetched",{params:t,type:a,response:c.data,unresolvedQueries:this.getUnresolvedQueries()}),this.track(c.data,a,c.error),c.data&&c.error?o({error:c.error}):i(c.data)):c.resolvers.push({resolve:i,reject:o}),r.splice(d,1),r.push(c),this.queries.set(a,r),!c.loading&&!c.resolved)return this.runQuery(a,t)}else return r.push({params:t,resolved:!1,loading:!0,data:{},resolvers:[{resolve:i,reject:o}]}),this.queries.set(a,r),this.runQuery(a,t)}).then(i=>V(i))}read(e,t){const{select:n}=t,i=_(e);return(this.queries.get(i)||[]).reduce((r,c)=>{if(typeof n=="function"){const d=n(c.data);d&&r.push(d)}else r.push(c.data);return r},[])}feedback(e,t,n){return this.matchingClient.giveFeedback(e,t,n)}setLoadingStatus(e,t,n){const i=this.queries.get(e)||[],o=i.find(a=>R(a.params,t));o&&(o.loading=n),this.queries.set(e,i)}async runQuery(e,t){const{searchPhrase:n="",categories:i="0",contactMethodCategoryId:o="0",contactMethodId:a="0",tagId:r=void 0,take:c=5,connection:d="",guideId:u,expandCategories:f="descendants",currentCategory:h,sorting:p="popularity-descending",guideIds:w=[]}=t,y=n.toString().trim();if(await de(this.container))return Promise.resolve();switch(e){case"match":{const l=g=>{const[L,x]=g.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(L),direction:x}};return w.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:w,take:+c}}).then(g=>g&&this.handleResponse(g,e,t)):this.matchingClient.match(y,{categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+c,tags:r,sorting:l(p),ids:w}).then(g=>g&&this.handleResponse(g,e,t))}case"match-by-category":return this.matchingClient.match(y,{groupByCategory:!0,categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+c,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"guide":return this.matchingClient.getGuide(u,{connectionId:d}).then(l=>{l&&this.handleResponse(l,e,t)}).catch(l=>{const g={message:"Something went wrong.",status:l.status||400};g.status===404&&(g.message="The guide could not be found."),this.handleResponse({},e,t,g)});case"categories":return this.matchingClient.getCategories({phrase:y,expand:f,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"contacts":return u?this.matchingClient.contactMethods(+u,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t)):this.matchingClient.contacts(+o,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t));case"contact-method":return this.matchingClient.getContactMethod(+a,{guideId:u,currentCategory:h}).then(l=>l&&this.handleResponse(l,e,t));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(l=>l&&this.handleResponse(l,e,t));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i],tags:r}}).then(l=>l&&this.handleResponse(l,e,t));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(l=>l&&this.handleResponse(l,e,t))}}handleResponse(e={},t,n,i){const o=this.queries.get(t)||[],a=o.find(r=>R(r.params,n));if(a){const r=i||Y(t,e);this.track(r,t,i),a.resolvers.forEach(d=>{i?d.reject({error:r}):d.resolve(r)});const c=o.indexOf(a);c>-1&&o.splice(c,1),o.push({...a,error:i,resolvers:[],data:r,resolved:!0}),this.setLoadingStatus(t,n,!1),this.queries.set(t,o),i||this.events.dispatch("data-client:fetched",{type:t,params:n,response:r,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,t]of this.queries)t.filter(n=>!n.resolved).forEach(n=>{this.runQuery(e,n.params)})}track(e={},t,n){const i=this.container.get("$widget");i&&!n?i.events.dispatch("tracking:service-client-response",{type:t,data:e}):i&&i.events.dispatch("tracking:service-client-error",{type:t,error:n})}static create(e){return e.getAsync("matchingClient").then(async t=>{if(t)return new I(e,t);const n=await K(e);return e.registerAsync("matchingClient",()=>n),new I(e,n)})}getClient(){return this.matchingClient}}const le=async s=>{s.registerAsync("dataClient",()=>I.create(s))};exports.DataClient=I;exports.DataType=J;exports.FeedbackType=X;exports.KnowledgeDataClientPlugin=le;exports.ServiceClientQueryType=m;exports.SortingType=Z;exports.determineServiceClientQueryType=_;exports.formatLegacyData=Y;
|
package/index.mjs
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
const j = (s, e, t, ...
|
|
2
|
-
const
|
|
1
|
+
const j = (s, e, t, ...i) => {
|
|
2
|
+
const n = `[${s.get("$environment").name || "webprovisions"}] ${t}`;
|
|
3
3
|
switch (e) {
|
|
4
4
|
case "info":
|
|
5
|
-
console.info(
|
|
5
|
+
console.info(n, ...i);
|
|
6
6
|
break;
|
|
7
7
|
case "warning":
|
|
8
|
-
console.warn(
|
|
8
|
+
console.warn(n, ...i);
|
|
9
9
|
break;
|
|
10
10
|
case "error":
|
|
11
|
-
console.error(
|
|
11
|
+
console.error(n, ...i);
|
|
12
12
|
break;
|
|
13
13
|
}
|
|
14
14
|
}, X = (s) => {
|
|
15
15
|
const e = s.container || s;
|
|
16
16
|
return {
|
|
17
|
-
info: (t, ...
|
|
18
|
-
warn: (t, ...
|
|
19
|
-
error: (t, ...
|
|
17
|
+
info: (t, ...i) => j(e, "info", t, ...i),
|
|
18
|
+
warn: (t, ...i) => j(e, "warning", t, ...i),
|
|
19
|
+
error: (t, ...i) => j(e, "error", t, ...i)
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
var G = /* @__PURE__ */ ((s) => (s.Implementation = "implementation", s.Widget = "widget", s))(G || {}), k = /* @__PURE__ */ ((s) => (s.Pre = "pre", s.Post = "post", s))(k || {});
|
|
23
|
-
const Z = (s, e, t,
|
|
23
|
+
const Z = (s, e, t, i) => {
|
|
24
24
|
try {
|
|
25
|
-
const
|
|
25
|
+
const n = new e(t, i);
|
|
26
26
|
return {
|
|
27
27
|
name: s,
|
|
28
28
|
invoke: (o, c) => {
|
|
29
29
|
let r;
|
|
30
|
-
return
|
|
30
|
+
return n[o] && (r = n[o].call(n, c)), Promise.resolve(r);
|
|
31
31
|
},
|
|
32
|
-
getInstance: () =>
|
|
32
|
+
getInstance: () => n
|
|
33
33
|
};
|
|
34
|
-
} catch (
|
|
35
|
-
if (
|
|
34
|
+
} catch (n) {
|
|
35
|
+
if (n.message && n.message.indexOf("is not a constructor") >= 0)
|
|
36
36
|
return {
|
|
37
37
|
name: s,
|
|
38
38
|
invoke: (o) => {
|
|
39
39
|
let c;
|
|
40
|
-
return o === "initialize" && (c = e(t,
|
|
40
|
+
return o === "initialize" && (c = e(t, i)), Promise.resolve(c);
|
|
41
41
|
},
|
|
42
42
|
getInstance: () => e
|
|
43
43
|
};
|
|
44
|
-
throw
|
|
44
|
+
throw n;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
function W(s, e) {
|
|
@@ -51,23 +51,23 @@ class ee {
|
|
|
51
51
|
constructor(e = {}) {
|
|
52
52
|
this.part = e;
|
|
53
53
|
}
|
|
54
|
-
createCommand(e, t,
|
|
55
|
-
let
|
|
56
|
-
typeof t == "function" ?
|
|
54
|
+
createCommand(e, t, i) {
|
|
55
|
+
let n;
|
|
56
|
+
typeof t == "function" ? n = {
|
|
57
57
|
scope: G.Widget,
|
|
58
58
|
stage: k.Post,
|
|
59
59
|
defaultArgs: void 0,
|
|
60
60
|
handlerResolver: t
|
|
61
|
-
} :
|
|
61
|
+
} : n = {
|
|
62
62
|
scope: W(t.scope, G.Widget),
|
|
63
63
|
stage: W(t.stage, k.Post),
|
|
64
64
|
defaultArgs: t.defaultArgs,
|
|
65
|
-
handlerResolver:
|
|
65
|
+
handlerResolver: i
|
|
66
66
|
};
|
|
67
67
|
let o = this.part;
|
|
68
68
|
const c = e.split(".");
|
|
69
69
|
return c.forEach((r, a) => {
|
|
70
|
-
a === c.length - 1 ? o[r] || (o[r] = () =>
|
|
70
|
+
a === c.length - 1 ? o[r] || (o[r] = () => n) : o = this.part[r] = this.part[r] || {};
|
|
71
71
|
}), this;
|
|
72
72
|
}
|
|
73
73
|
get() {
|
|
@@ -82,8 +82,8 @@ z((s) => {
|
|
|
82
82
|
s.createCommand(
|
|
83
83
|
"types.register",
|
|
84
84
|
{ scope: G.Implementation, stage: k.Pre },
|
|
85
|
-
(e) => (t,
|
|
86
|
-
e.container.get("$types")[t] =
|
|
85
|
+
(e) => (t, i) => {
|
|
86
|
+
e.container.get("$types")[t] = i;
|
|
87
87
|
}
|
|
88
88
|
).createCommand(
|
|
89
89
|
"type",
|
|
@@ -104,25 +104,25 @@ z((s) => {
|
|
|
104
104
|
).createCommand(
|
|
105
105
|
"plugin",
|
|
106
106
|
{ stage: k.Pre },
|
|
107
|
-
(e) => (t,
|
|
107
|
+
(e) => (t, i, n) => {
|
|
108
108
|
const { container: o } = e;
|
|
109
|
-
let c = null, r = t, a =
|
|
110
|
-
typeof t == "string" && (c = t, r =
|
|
111
|
-
const d = (
|
|
112
|
-
const { transformPluginSettings: f } = e.container.get("$environmentOptions"),
|
|
109
|
+
let c = null, r = t, a = i;
|
|
110
|
+
typeof t == "string" && (c = t, r = i, a = n);
|
|
111
|
+
const d = (u) => {
|
|
112
|
+
const { transformPluginSettings: f } = e.container.get("$environmentOptions"), h = f ? f(
|
|
113
113
|
a || {},
|
|
114
114
|
c,
|
|
115
115
|
e.container,
|
|
116
116
|
r
|
|
117
|
-
) :
|
|
117
|
+
) : i;
|
|
118
118
|
try {
|
|
119
119
|
const m = Z(
|
|
120
120
|
c,
|
|
121
121
|
r,
|
|
122
122
|
o,
|
|
123
|
-
|
|
123
|
+
h
|
|
124
124
|
);
|
|
125
|
-
o.get("$plugins").push(m),
|
|
125
|
+
o.get("$plugins").push(m), u && m.invoke("initialize", null);
|
|
126
126
|
} catch (m) {
|
|
127
127
|
X(e).warn("Error when initializing plugin", m);
|
|
128
128
|
}
|
|
@@ -131,23 +131,23 @@ z((s) => {
|
|
|
131
131
|
}
|
|
132
132
|
).createCommand(
|
|
133
133
|
"container.register",
|
|
134
|
-
(e) => (t,
|
|
135
|
-
e.container.register(t,
|
|
134
|
+
(e) => (t, i) => {
|
|
135
|
+
e.container.register(t, i);
|
|
136
136
|
}
|
|
137
137
|
).createCommand(
|
|
138
138
|
"container.registerAsync",
|
|
139
|
-
(e) => (t,
|
|
140
|
-
e.container.registerAsync(t,
|
|
139
|
+
(e) => (t, i) => {
|
|
140
|
+
e.container.registerAsync(t, i);
|
|
141
141
|
}
|
|
142
142
|
).createCommand(
|
|
143
143
|
"container.registerFactory",
|
|
144
|
-
(e) => (t,
|
|
145
|
-
e.container.registerFactory(t,
|
|
144
|
+
(e) => (t, i) => {
|
|
145
|
+
e.container.registerFactory(t, i);
|
|
146
146
|
}
|
|
147
147
|
).createCommand(
|
|
148
148
|
"container.touch",
|
|
149
|
-
(e) => (t,
|
|
150
|
-
e.container.touch(t,
|
|
149
|
+
(e) => (t, i) => {
|
|
150
|
+
e.container.touch(t, i);
|
|
151
151
|
}
|
|
152
152
|
).createCommand(
|
|
153
153
|
"csp",
|
|
@@ -171,36 +171,36 @@ O.warn = (...s) => T(console.warn, ...s);
|
|
|
171
171
|
O.error = (...s) => T(console.error, ...s);
|
|
172
172
|
O.info = (...s) => T(console.info, ...s);
|
|
173
173
|
const V = (s) => {
|
|
174
|
-
let e = {}, t,
|
|
174
|
+
let e = {}, t, i;
|
|
175
175
|
if (typeof s != "object" || s === null)
|
|
176
176
|
return s;
|
|
177
177
|
e = Array.isArray(s) ? [] : {};
|
|
178
|
-
for (
|
|
179
|
-
t = s[
|
|
178
|
+
for (i in s)
|
|
179
|
+
t = s[i], e[i] = typeof t == "object" && t !== null ? V(t) : t;
|
|
180
180
|
return e;
|
|
181
181
|
};
|
|
182
182
|
class te {
|
|
183
183
|
constructor(e, t) {
|
|
184
184
|
this.lockWarningTime = e, this.lockErrorTime = t, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
|
|
185
185
|
}
|
|
186
|
-
add(e, t,
|
|
187
|
-
this.tasks.push({ task: e, resolve: t, reject:
|
|
186
|
+
add(e, t, i, n) {
|
|
187
|
+
this.tasks.push({ task: e, resolve: t, reject: i, done: n }), this.next();
|
|
188
188
|
}
|
|
189
189
|
next() {
|
|
190
190
|
this.current = this.current.then(() => {
|
|
191
191
|
const e = this.tasks.shift();
|
|
192
192
|
if (e) {
|
|
193
193
|
let t;
|
|
194
|
-
const
|
|
194
|
+
const i = setTimeout(() => {
|
|
195
195
|
process.env.NODE_ENV !== "production" && O.warn(
|
|
196
196
|
`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
|
|
197
197
|
e
|
|
198
198
|
), t = setTimeout(() => {
|
|
199
199
|
e.reject("lock timeout exceeded");
|
|
200
200
|
}, this.lockErrorTime);
|
|
201
|
-
}, this.lockWarningTime),
|
|
202
|
-
return Promise.resolve(
|
|
203
|
-
() =>
|
|
201
|
+
}, this.lockWarningTime), n = Promise.resolve(e.task()).then((o) => (clearTimeout(i), clearTimeout(t), o));
|
|
202
|
+
return Promise.resolve(n).then(this.next).then(
|
|
203
|
+
() => n.then((o) => {
|
|
204
204
|
e.done(), e.resolve(o);
|
|
205
205
|
})
|
|
206
206
|
).catch((o) => (e.done(), e.reject(o), this.next()));
|
|
@@ -211,21 +211,21 @@ class te {
|
|
|
211
211
|
}
|
|
212
212
|
const S = /* @__PURE__ */ new WeakMap();
|
|
213
213
|
function se(s, e = 5e3, t = 1e3) {
|
|
214
|
-
return S.has(s) || S.set(s, new te(e, t)), (
|
|
214
|
+
return S.has(s) || S.set(s, new te(e, t)), (i) => new Promise((n, o) => {
|
|
215
215
|
const c = S.get(s);
|
|
216
|
-
c.add(
|
|
216
|
+
c.add(i, n, o, () => {
|
|
217
217
|
c.tasks.length || S.delete(s);
|
|
218
218
|
});
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const ne = (s = {}) => (Object.keys(s).forEach((e) => {
|
|
222
222
|
(s[e] === null || typeof s[e] > "u") && delete s[e];
|
|
223
223
|
}), s), P = (s, e) => {
|
|
224
224
|
let t = !0;
|
|
225
|
-
return Object.keys(s).length !== Object.keys(e).length || Object.keys(s).some((
|
|
225
|
+
return Object.keys(s).length !== Object.keys(e).length || Object.keys(s).some((i) => !Object.keys(e).some((n) => i === n)) ? !1 : (Object.keys(s).forEach((i) => {
|
|
226
226
|
if (t) {
|
|
227
|
-
const
|
|
228
|
-
t =
|
|
227
|
+
const n = typeof s[i] > "u" ? "" : s[i], o = typeof e[i] > "u" ? "" : e[i];
|
|
228
|
+
t = n.toString() === o.toString();
|
|
229
229
|
}
|
|
230
230
|
}), t);
|
|
231
231
|
};
|
|
@@ -233,9 +233,9 @@ z((s) => {
|
|
|
233
233
|
s.createCommand("components", (e) => (t) => {
|
|
234
234
|
e.events.subscribeOnce(
|
|
235
235
|
"components:platform-created",
|
|
236
|
-
(
|
|
236
|
+
(i, { platform: n }) => {
|
|
237
237
|
t.handlers && t.handlers.forEach(([o, c]) => {
|
|
238
|
-
|
|
238
|
+
n.addComponentHandler(o, c);
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
);
|
|
@@ -243,35 +243,35 @@ z((s) => {
|
|
|
243
243
|
});
|
|
244
244
|
var q = /* @__PURE__ */ ((s) => (s.open = "open", s.closed = "closed", s.hidden = "hidden", s))(q || {});
|
|
245
245
|
const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
246
|
-
({ ServiceClient: e, ServiceProxy: t }) => s.get("settings").then((
|
|
247
|
-
const { name:
|
|
246
|
+
({ ServiceClient: e, ServiceProxy: t }) => s.get("settings").then((i) => {
|
|
247
|
+
const { name: n, events: o } = s.get("$widget"), {
|
|
248
248
|
data: { projection: c = "", site: r = "current", forceHttps: a = !1 }
|
|
249
|
-
} =
|
|
249
|
+
} = i, d = new t(c, {
|
|
250
250
|
credentials: "same-origin"
|
|
251
|
-
}),
|
|
251
|
+
}), u = new e(
|
|
252
252
|
d,
|
|
253
253
|
{
|
|
254
|
-
funnel:
|
|
255
|
-
site:
|
|
254
|
+
funnel: n.replace("_contact-method", "").replace("_contact", ""),
|
|
255
|
+
site: ie(r, a)
|
|
256
256
|
},
|
|
257
257
|
null,
|
|
258
258
|
s
|
|
259
259
|
);
|
|
260
|
-
return o.subscribe("widget:settings-updated", (f, { data:
|
|
261
|
-
|
|
262
|
-
}),
|
|
260
|
+
return o.subscribe("widget:settings-updated", (f, { data: h }) => {
|
|
261
|
+
h && h.projection !== c && u.proxy.setBaseUrl(h.projection);
|
|
262
|
+
}), u;
|
|
263
263
|
})
|
|
264
|
-
),
|
|
265
|
-
const t = (
|
|
264
|
+
), ie = (s, e) => () => {
|
|
265
|
+
const t = (n) => {
|
|
266
266
|
const o = document.createElement("a");
|
|
267
|
-
return o.href =
|
|
267
|
+
return o.href = n, o;
|
|
268
268
|
};
|
|
269
|
-
let
|
|
270
|
-
return s === "referrer" && document.referrer && (
|
|
269
|
+
let i = window.location;
|
|
270
|
+
return s === "referrer" && document.referrer && (i = t(document.referrer)), [
|
|
271
271
|
e ? "https:" : "",
|
|
272
272
|
"//",
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
i.host,
|
|
274
|
+
i.pathname
|
|
275
275
|
].join("");
|
|
276
276
|
}, N = (s) => {
|
|
277
277
|
if (s) {
|
|
@@ -289,34 +289,34 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
289
289
|
matches: e.GuidesCount
|
|
290
290
|
};
|
|
291
291
|
return e.Children && e.Children.length && (t.items = U(e.Children)), t;
|
|
292
|
-
}), b = (s, e) => s.filter(({ Type: t }) => t === e).map(({ Id: t, Title:
|
|
292
|
+
}), b = (s, e) => s.filter(({ Type: t }) => t === e).map(({ Id: t, Title: i, Body: n }) => ({
|
|
293
293
|
id: t.toString(),
|
|
294
|
-
title:
|
|
295
|
-
body:
|
|
296
|
-
})), B = (s) => s.map(({ Id: e, Title: t, DefaultIcon:
|
|
294
|
+
title: i,
|
|
295
|
+
body: n
|
|
296
|
+
})), B = (s) => s.map(({ Id: e, Title: t, DefaultIcon: i, ListNotices: n, Notices: o }) => ({
|
|
297
297
|
id: e.toString(),
|
|
298
298
|
title: t,
|
|
299
|
-
symbol: N(
|
|
299
|
+
symbol: N(i),
|
|
300
300
|
defaultHeaderOptions: {
|
|
301
|
-
visible: !!
|
|
301
|
+
visible: !!n.length
|
|
302
302
|
},
|
|
303
|
-
notifications: (
|
|
303
|
+
notifications: (n || []).concat(o || []).map(({ Id: c, Title: r, Body: a, Type: d, Modified: u }) => ({
|
|
304
304
|
id: c.toString(),
|
|
305
305
|
title: r,
|
|
306
306
|
body: a,
|
|
307
|
-
modified:
|
|
307
|
+
modified: u,
|
|
308
308
|
expandable: d === "listNotice"
|
|
309
309
|
}))
|
|
310
310
|
})), $ = ({
|
|
311
311
|
Id: s,
|
|
312
312
|
Title: e,
|
|
313
313
|
DefaultIcon: t,
|
|
314
|
-
Exits: [
|
|
315
|
-
ExitType:
|
|
314
|
+
Exits: [i],
|
|
315
|
+
ExitType: n,
|
|
316
316
|
ConfirmationText: o,
|
|
317
317
|
Description: c
|
|
318
318
|
}, r) => {
|
|
319
|
-
const { Adapter: a } =
|
|
319
|
+
const { Adapter: a } = i || { Adapter: {} }, { ClientName: d = "", Settings: u = {}, CustomClientName: f = "" } = a, h = {
|
|
320
320
|
id: s.toString(),
|
|
321
321
|
title: e,
|
|
322
322
|
description: c,
|
|
@@ -327,24 +327,24 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
327
327
|
body: {}
|
|
328
328
|
};
|
|
329
329
|
if (d.indexOf("phone") > -1 || d.indexOf("freetext") > -1) {
|
|
330
|
-
const { displayTextBeforeClick: m, textBeforeClick: w } =
|
|
331
|
-
m === "true" && (
|
|
330
|
+
const { displayTextBeforeClick: m, textBeforeClick: w } = u;
|
|
331
|
+
m === "true" && (h.expanded = !1, h.title = w), d.indexOf("phone.text") > -1 ? h.body.phoneNumber = u.phoneNumber : h.body.freetext = u.freetext;
|
|
332
332
|
}
|
|
333
|
-
return (d.indexOf("chat.popup") > -1 || d.indexOf("link") > -1 || d === "custom.adapter" &&
|
|
333
|
+
return (d.indexOf("chat.popup") > -1 || d.indexOf("link") > -1 || d === "custom.adapter" && n === "custom") && (h.body = u, h.body.confirmationFallback = o), d.indexOf("ace") > -1 && (h.body = u), h;
|
|
334
334
|
}, M = (s = []) => s.map(
|
|
335
|
-
({ Id: e, Title: t, TotalMatches:
|
|
335
|
+
({ Id: e, Title: t, TotalMatches: i, Symbol: n, DefaultIcon: o, ActiveIcon: c }) => ({
|
|
336
336
|
id: e.toString(),
|
|
337
337
|
title: t,
|
|
338
|
-
matches:
|
|
339
|
-
symbol: N(o ||
|
|
338
|
+
matches: i,
|
|
339
|
+
symbol: N(o || n),
|
|
340
340
|
defaultIcon: N(o),
|
|
341
341
|
activeIcon: N(c)
|
|
342
342
|
})
|
|
343
|
-
), D = (s) => s.map(({ Id: e, Title: t, Tags:
|
|
343
|
+
), D = (s) => s.map(({ Id: e, Title: t, Tags: i, FirstPublishedDate: n, Modified: o }) => ({
|
|
344
344
|
id: e.toString(),
|
|
345
345
|
title: t,
|
|
346
|
-
tags: M(
|
|
347
|
-
published:
|
|
346
|
+
tags: M(i),
|
|
347
|
+
published: n,
|
|
348
348
|
modified: o
|
|
349
349
|
})), oe = (s, e) => {
|
|
350
350
|
switch (s) {
|
|
@@ -360,41 +360,41 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
360
360
|
tags: [],
|
|
361
361
|
byCategory: []
|
|
362
362
|
}, {
|
|
363
|
-
Matches:
|
|
364
|
-
TotalMatches:
|
|
363
|
+
Matches: i,
|
|
364
|
+
TotalMatches: n,
|
|
365
365
|
Notices: o,
|
|
366
366
|
NoticeLists: c,
|
|
367
367
|
Tags: r,
|
|
368
368
|
ByCategory: a
|
|
369
369
|
} = e;
|
|
370
|
-
return t.guides = D(
|
|
371
|
-
({ Id: d, Matches:
|
|
370
|
+
return t.guides = D(i), t.matches = n, t.byCategory = (a || []).map(
|
|
371
|
+
({ Id: d, Matches: u, TotalMatches: f }) => ({
|
|
372
372
|
id: d,
|
|
373
|
-
guides: D(
|
|
373
|
+
guides: D(u),
|
|
374
374
|
matches: f
|
|
375
375
|
})
|
|
376
376
|
), t.tags = M(r), t.notificationLists = B(c || []), t.topNotifications = b(o || [], "noticeRowTop"), t.middleNotifications = b(o || [], "noticeRowMiddle"), t.bottomNotifications = b(o || [], "footerNotice"), t;
|
|
377
377
|
}
|
|
378
378
|
case C.Categories: {
|
|
379
|
-
const { Children: t, GuidesCountTotal:
|
|
379
|
+
const { Children: t, GuidesCountTotal: i } = e;
|
|
380
380
|
return {
|
|
381
381
|
categories: U(t || []),
|
|
382
|
-
matches:
|
|
382
|
+
matches: i
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
case C.Guide: {
|
|
386
386
|
const {
|
|
387
387
|
Id: t,
|
|
388
|
-
Title:
|
|
389
|
-
Body:
|
|
388
|
+
Title: i,
|
|
389
|
+
Body: n,
|
|
390
390
|
Related: o,
|
|
391
391
|
Options: c,
|
|
392
392
|
ConnectionId: r,
|
|
393
393
|
ContactMethods: a,
|
|
394
394
|
EnableFeedback: d,
|
|
395
|
-
HandoverExists:
|
|
395
|
+
HandoverExists: u,
|
|
396
396
|
FirstPublishedDate: f,
|
|
397
|
-
Modified:
|
|
397
|
+
Modified: h,
|
|
398
398
|
ModifiedByDisplayName: m,
|
|
399
399
|
FirstPublishedByDisplayName: w,
|
|
400
400
|
Categories: p,
|
|
@@ -409,15 +409,15 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
409
409
|
) || I.Default || null, F = {
|
|
410
410
|
guide: {
|
|
411
411
|
id: t.toString(),
|
|
412
|
-
title:
|
|
413
|
-
body:
|
|
414
|
-
modified:
|
|
412
|
+
title: i,
|
|
413
|
+
body: n,
|
|
414
|
+
modified: h,
|
|
415
415
|
published: f,
|
|
416
416
|
modifiedBy: m,
|
|
417
417
|
publishedBy: w,
|
|
418
418
|
connection: r,
|
|
419
419
|
categories: p,
|
|
420
|
-
hasHandover:
|
|
420
|
+
hasHandover: u,
|
|
421
421
|
allowFeedback: d,
|
|
422
422
|
seoMetaDescription: g,
|
|
423
423
|
seoAllowIndex: L,
|
|
@@ -444,7 +444,7 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
444
444
|
type: "default",
|
|
445
445
|
parent: {
|
|
446
446
|
id: t.toString(),
|
|
447
|
-
title:
|
|
447
|
+
title: i,
|
|
448
448
|
tags: M(l)
|
|
449
449
|
}
|
|
450
450
|
};
|
|
@@ -464,18 +464,18 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
464
464
|
case C.Contacts: {
|
|
465
465
|
const {
|
|
466
466
|
Children: t,
|
|
467
|
-
Matches:
|
|
468
|
-
Notices:
|
|
467
|
+
Matches: i,
|
|
468
|
+
Notices: n,
|
|
469
469
|
NoticeLists: o
|
|
470
470
|
} = e;
|
|
471
471
|
return {
|
|
472
|
-
contactMethods: (
|
|
472
|
+
contactMethods: (i || []).map(
|
|
473
473
|
(r) => $(r)
|
|
474
474
|
),
|
|
475
475
|
categories: U(t || []),
|
|
476
|
-
topNotifications: b(
|
|
477
|
-
middleNotifications: b(
|
|
478
|
-
bottomNotifications: b(
|
|
476
|
+
topNotifications: b(n || [], "noticeRowTop"),
|
|
477
|
+
middleNotifications: b(n || [], "noticeRowMiddle"),
|
|
478
|
+
bottomNotifications: b(n || [], "footerNotice"),
|
|
479
479
|
notificationLists: B(o || [])
|
|
480
480
|
};
|
|
481
481
|
}
|
|
@@ -487,12 +487,12 @@ const Q = (s) => import("./index-BpmTFodb.mjs").then(
|
|
|
487
487
|
case C.TagsOnGuides:
|
|
488
488
|
return M(e || []);
|
|
489
489
|
case C.Notifications: {
|
|
490
|
-
const { Notices: t, NoticeLists:
|
|
490
|
+
const { Notices: t, NoticeLists: i } = e;
|
|
491
491
|
return {
|
|
492
492
|
topNotifications: b(t || [], "noticeRowTop"),
|
|
493
493
|
middleNotifications: b(t || [], "noticeRowMiddle"),
|
|
494
494
|
bottomNotifications: b(t || [], "footerNotice"),
|
|
495
|
-
notificationLists: B(
|
|
495
|
+
notificationLists: B(i || [])
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
498
|
default:
|
|
@@ -532,36 +532,36 @@ const K = (s) => {
|
|
|
532
532
|
class E {
|
|
533
533
|
constructor(e, t) {
|
|
534
534
|
this.container = e, this.matchingClient = t, this.queries = /* @__PURE__ */ new Map(), this.getUnresolvedQueries = () => {
|
|
535
|
-
let
|
|
536
|
-
return this.queries.forEach((
|
|
537
|
-
|
|
538
|
-
}),
|
|
535
|
+
let i = 0;
|
|
536
|
+
return this.queries.forEach((n, o) => {
|
|
537
|
+
n.some((r) => !r.resolved) && (i = 1);
|
|
538
|
+
}), i;
|
|
539
539
|
}, this.events = e.get("$widget").events, this.events.subscribe(
|
|
540
540
|
"widget:settings-updated",
|
|
541
541
|
() => this.queries = /* @__PURE__ */ new Map()
|
|
542
542
|
), this.events.subscribe(
|
|
543
543
|
"widget:render-state-changed",
|
|
544
|
-
(
|
|
545
|
-
o === q.hidden &&
|
|
544
|
+
(i, { next: n, previous: o }) => {
|
|
545
|
+
o === q.hidden && n === q.open && this.fetchAllUnresolvedQueries();
|
|
546
546
|
}
|
|
547
547
|
);
|
|
548
548
|
}
|
|
549
549
|
static getInstance(e, t = "dataClient") {
|
|
550
|
-
return se(this)(() => e.getAsync(t).then(async (
|
|
551
|
-
let
|
|
552
|
-
|
|
553
|
-
let o =
|
|
554
|
-
return o || (o = new E(e,
|
|
550
|
+
return se(this)(() => e.getAsync(t).then(async (i) => {
|
|
551
|
+
let n = await e.getAsync("matchingClient");
|
|
552
|
+
n || (n = await Q(e), e.registerAsync("matchingClient", () => n));
|
|
553
|
+
let o = i;
|
|
554
|
+
return o || (o = new E(e, n), e.registerAsync(t, () => o)), o;
|
|
555
555
|
}));
|
|
556
556
|
}
|
|
557
|
-
fetch(e, t,
|
|
558
|
-
return new Promise((
|
|
559
|
-
t.take,
|
|
557
|
+
fetch(e, t, i) {
|
|
558
|
+
return new Promise((n, o) => {
|
|
559
|
+
t.take, ne(t);
|
|
560
560
|
const c = K(e);
|
|
561
561
|
let r = this.queries.get(c) || [], a = r.find((d) => P(d.params, t)) || null;
|
|
562
|
-
if (a && (
|
|
562
|
+
if (a && (i != null && i.noCache)) {
|
|
563
563
|
const d = r.findIndex(
|
|
564
|
-
(
|
|
564
|
+
(u) => P(u.params, t)
|
|
565
565
|
);
|
|
566
566
|
r = [...r.slice(0, d), ...r.slice(d + 1)], a = null;
|
|
567
567
|
}
|
|
@@ -572,7 +572,7 @@ class E {
|
|
|
572
572
|
type: c,
|
|
573
573
|
response: a.data,
|
|
574
574
|
unresolvedQueries: this.getUnresolvedQueries()
|
|
575
|
-
}), this.track(a.data, c, a.error), a.data && a.error ? o({ error: a.error }) :
|
|
575
|
+
}), this.track(a.data, c, a.error), a.data && a.error ? o({ error: a.error }) : n(a.data)) : a.resolvers.push({ resolve: n, reject: o }), r.splice(d, 1), r.push(a), this.queries.set(c, r), !a.loading && !a.resolved)
|
|
576
576
|
return this.runQuery(c, t);
|
|
577
577
|
} else
|
|
578
578
|
return r.push({
|
|
@@ -580,44 +580,44 @@ class E {
|
|
|
580
580
|
resolved: !1,
|
|
581
581
|
loading: !0,
|
|
582
582
|
data: {},
|
|
583
|
-
resolvers: [{ resolve:
|
|
583
|
+
resolvers: [{ resolve: n, reject: o }]
|
|
584
584
|
}), this.queries.set(c, r), this.runQuery(c, t);
|
|
585
|
-
}).then((
|
|
585
|
+
}).then((n) => V(n));
|
|
586
586
|
}
|
|
587
587
|
// query the cached data
|
|
588
588
|
read(e, t) {
|
|
589
|
-
const { select:
|
|
590
|
-
return (this.queries.get(
|
|
591
|
-
if (typeof
|
|
592
|
-
const d =
|
|
589
|
+
const { select: i } = t, n = K(e);
|
|
590
|
+
return (this.queries.get(n) || []).reduce((r, a) => {
|
|
591
|
+
if (typeof i == "function") {
|
|
592
|
+
const d = i(a.data);
|
|
593
593
|
d && r.push(d);
|
|
594
594
|
} else
|
|
595
595
|
r.push(a.data);
|
|
596
596
|
return r;
|
|
597
597
|
}, []);
|
|
598
598
|
}
|
|
599
|
-
feedback(e, t,
|
|
600
|
-
return this.matchingClient.giveFeedback(e, t,
|
|
599
|
+
feedback(e, t, i) {
|
|
600
|
+
return this.matchingClient.giveFeedback(e, t, i);
|
|
601
601
|
}
|
|
602
|
-
setLoadingStatus(e, t,
|
|
603
|
-
const
|
|
604
|
-
o && (o.loading =
|
|
602
|
+
setLoadingStatus(e, t, i) {
|
|
603
|
+
const n = this.queries.get(e) || [], o = n.find((c) => P(c.params, t));
|
|
604
|
+
o && (o.loading = i), this.queries.set(e, n);
|
|
605
605
|
}
|
|
606
606
|
async runQuery(e, t) {
|
|
607
607
|
const {
|
|
608
|
-
searchPhrase:
|
|
609
|
-
categories:
|
|
608
|
+
searchPhrase: i = "",
|
|
609
|
+
categories: n = "0",
|
|
610
610
|
contactMethodCategoryId: o = "0",
|
|
611
611
|
contactMethodId: c = "0",
|
|
612
612
|
tagId: r = void 0,
|
|
613
613
|
take: a = 5,
|
|
614
614
|
connection: d = "",
|
|
615
|
-
guideId:
|
|
615
|
+
guideId: u,
|
|
616
616
|
expandCategories: f = "descendants",
|
|
617
|
-
currentCategory:
|
|
617
|
+
currentCategory: h,
|
|
618
618
|
sorting: m = "popularity-descending",
|
|
619
619
|
guideIds: w = []
|
|
620
|
-
} = t, p =
|
|
620
|
+
} = t, p = i.toString().trim();
|
|
621
621
|
if (await de(this.container))
|
|
622
622
|
return Promise.resolve();
|
|
623
623
|
switch (e) {
|
|
@@ -639,7 +639,7 @@ class E {
|
|
|
639
639
|
}).then(
|
|
640
640
|
(g) => g && this.handleResponse(g, e, t)
|
|
641
641
|
) : this.matchingClient.match(p, {
|
|
642
|
-
categories:
|
|
642
|
+
categories: n === "0" ? [] : Array.isArray(n) ? n : [+n],
|
|
643
643
|
take: +a,
|
|
644
644
|
tags: r,
|
|
645
645
|
sorting: l(m),
|
|
@@ -651,14 +651,14 @@ class E {
|
|
|
651
651
|
case "match-by-category":
|
|
652
652
|
return this.matchingClient.match(p, {
|
|
653
653
|
groupByCategory: !0,
|
|
654
|
-
categories:
|
|
654
|
+
categories: n === "0" ? [] : Array.isArray(n) ? n : [+n],
|
|
655
655
|
take: +a,
|
|
656
656
|
tags: r
|
|
657
657
|
}).then(
|
|
658
658
|
(l) => l && this.handleResponse(l, e, t)
|
|
659
659
|
);
|
|
660
660
|
case "guide":
|
|
661
|
-
return this.matchingClient.getGuide(
|
|
661
|
+
return this.matchingClient.getGuide(u, { connectionId: d }).then((l) => {
|
|
662
662
|
l && this.handleResponse(l, e, t);
|
|
663
663
|
}).catch((l) => {
|
|
664
664
|
const g = {
|
|
@@ -676,13 +676,13 @@ class E {
|
|
|
676
676
|
(l) => l && this.handleResponse(l, e, t)
|
|
677
677
|
);
|
|
678
678
|
case "contacts":
|
|
679
|
-
return
|
|
679
|
+
return u ? this.matchingClient.contactMethods(+u, { phrase: p }).then(
|
|
680
680
|
(l) => l && this.handleResponse(l, e, t)
|
|
681
681
|
) : this.matchingClient.contacts(+o, { phrase: p }).then(
|
|
682
682
|
(l) => l && this.handleResponse(l, e, t)
|
|
683
683
|
);
|
|
684
684
|
case "contact-method":
|
|
685
|
-
return this.matchingClient.getContactMethod(+c, { guideId:
|
|
685
|
+
return this.matchingClient.getContactMethod(+c, { guideId: u, currentCategory: h }).then(
|
|
686
686
|
(l) => l && this.handleResponse(l, e, t)
|
|
687
687
|
);
|
|
688
688
|
case "tags":
|
|
@@ -690,7 +690,7 @@ class E {
|
|
|
690
690
|
configuration: {
|
|
691
691
|
take: 999999,
|
|
692
692
|
phrase: p,
|
|
693
|
-
categories:
|
|
693
|
+
categories: n === "0" ? [] : Array.isArray(n) ? n : [+n]
|
|
694
694
|
}
|
|
695
695
|
}).then(
|
|
696
696
|
(l) => l && this.handleResponse(l, e, t)
|
|
@@ -700,7 +700,7 @@ class E {
|
|
|
700
700
|
configuration: {
|
|
701
701
|
take: 999999,
|
|
702
702
|
phrase: p,
|
|
703
|
-
categories:
|
|
703
|
+
categories: n === "0" ? [] : Array.isArray(n) ? n : [+n],
|
|
704
704
|
tags: r
|
|
705
705
|
}
|
|
706
706
|
}).then(
|
|
@@ -710,30 +710,30 @@ class E {
|
|
|
710
710
|
return this.matchingClient.customRequest("notices", "GET", {
|
|
711
711
|
configuration: {
|
|
712
712
|
phrase: p,
|
|
713
|
-
categories:
|
|
713
|
+
categories: n === "0" ? [] : Array.isArray(n) ? n : [+n]
|
|
714
714
|
}
|
|
715
715
|
}).then(
|
|
716
716
|
(l) => l && this.handleResponse(l, e, t)
|
|
717
717
|
);
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
-
handleResponse(e = {}, t,
|
|
721
|
-
const o = this.queries.get(t) || [], c = o.find((r) => P(r.params,
|
|
720
|
+
handleResponse(e = {}, t, i, n) {
|
|
721
|
+
const o = this.queries.get(t) || [], c = o.find((r) => P(r.params, i));
|
|
722
722
|
if (c) {
|
|
723
|
-
const r =
|
|
724
|
-
this.track(r, t,
|
|
725
|
-
|
|
723
|
+
const r = n || oe(t, e);
|
|
724
|
+
this.track(r, t, n), c.resolvers.forEach((d) => {
|
|
725
|
+
n ? d.reject({ error: r }) : d.resolve(r);
|
|
726
726
|
});
|
|
727
727
|
const a = o.indexOf(c);
|
|
728
728
|
a > -1 && o.splice(a, 1), o.push({
|
|
729
729
|
...c,
|
|
730
|
-
error:
|
|
730
|
+
error: n,
|
|
731
731
|
resolvers: [],
|
|
732
732
|
data: r,
|
|
733
733
|
resolved: !0
|
|
734
|
-
}), this.setLoadingStatus(t,
|
|
734
|
+
}), this.setLoadingStatus(t, i, !1), this.queries.set(t, o), n || this.events.dispatch("data-client:fetched", {
|
|
735
735
|
type: t,
|
|
736
|
-
params:
|
|
736
|
+
params: i,
|
|
737
737
|
response: r,
|
|
738
738
|
unresolvedQueries: this.getUnresolvedQueries()
|
|
739
739
|
});
|
|
@@ -741,26 +741,26 @@ class E {
|
|
|
741
741
|
}
|
|
742
742
|
fetchAllUnresolvedQueries() {
|
|
743
743
|
for (const [e, t] of this.queries)
|
|
744
|
-
t.filter((
|
|
745
|
-
this.runQuery(e,
|
|
744
|
+
t.filter((i) => !i.resolved).forEach((i) => {
|
|
745
|
+
this.runQuery(e, i.params);
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
|
-
track(e = {}, t,
|
|
749
|
-
const
|
|
750
|
-
|
|
748
|
+
track(e = {}, t, i) {
|
|
749
|
+
const n = this.container.get("$widget");
|
|
750
|
+
n && !i ? n.events.dispatch("tracking:service-client-response", {
|
|
751
751
|
type: t,
|
|
752
752
|
data: e
|
|
753
|
-
}) :
|
|
753
|
+
}) : n && n.events.dispatch("tracking:service-client-error", {
|
|
754
754
|
type: t,
|
|
755
|
-
error:
|
|
755
|
+
error: i
|
|
756
756
|
});
|
|
757
757
|
}
|
|
758
758
|
static create(e) {
|
|
759
759
|
return e.getAsync("matchingClient").then(async (t) => {
|
|
760
760
|
if (t)
|
|
761
761
|
return new E(e, t);
|
|
762
|
-
const
|
|
763
|
-
return e.registerAsync("matchingClient", () =>
|
|
762
|
+
const i = await Q(e);
|
|
763
|
+
return e.registerAsync("matchingClient", () => i), new E(e, i);
|
|
764
764
|
});
|
|
765
765
|
}
|
|
766
766
|
getClient() {
|