@telia-ace/knowledge-data-client-flamingo 1.1.80 → 1.1.81-rc.1
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-48f6c72c.js → index-B9t-W0wz.js} +1 -1
- package/{index-ca15ddac.mjs → index-BpmTFodb.mjs} +3 -3
- package/index.js +1 -1
- package/index.mjs +489 -1450
- package/package.json +1 -1
- package/index.d.ts +0 -4
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Humany Service Client Library
|
|
4
4
|
* Version: 2.0
|
|
5
5
|
* Copyright 2017, Telia Company AB, http://www.humany.com/
|
|
6
|
-
*/class B{constructor(...e){const r=e[1]||{};if(this.proxy=typeof e[0]=="string"?new te(e[0]):e[0],this.settings=l(!0,{},B.defaults,e[1]||{}),this.parameters=new pe(e[2],e[3]),this.current={phrase:r.phrase},this.guideCache={},this.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"},this.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"},this.subscriptions=[],e[3]&&typeof e[3].get=="function"){this.container=e[3];const n=this.container.get("$widget");n&&n.events&&this.subscriptions.push(n.events.subscribe("storage:policy-changed",(o,s)=>Pe(s)))}}getConfiguration(){return{language:x(this.settings.language,this),client:x(()=>this.settings.client(this.container),this),funnel:x(this.settings.funnel,this),site:x(this.settings.site,this),reader:x(this.settings.reader,this),perspective:x(this.settings.perspective,this)}}customRequest(e,r,n={}){const o=n.configuration||{},s=n.parameters;return e=this.constructPath(e,o,s),this.proxy.request(e,{method:r,body:n.body}).then(a=>(n.success&&n.success(a),a)).catch(a=>(n.error&&n.error(a),a))}constructPath(e,r,n=!0){let o=e;const s=l(this.getConfiguration(),r);if(Object.keys(s).filter(a=>{const c=s[a];return c!==null&&typeof c<"u"}).forEach(a=>o=$(o,a,x(s[a]))),n){const a=n===!0?this.parameters.getAll():n;o=ee(o,a)}return o}match(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1]||{},o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(y){if(f(o)){const v=this;y=this.settings.useProxyClasses&&y?(
|
|
6
|
+
*/class B{constructor(...e){const r=e[1]||{};if(this.proxy=typeof e[0]=="string"?new te(e[0]):e[0],this.settings=l(!0,{},B.defaults,e[1]||{}),this.parameters=new pe(e[2],e[3]),this.current={phrase:r.phrase},this.guideCache={},this.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"},this.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"},this.subscriptions=[],e[3]&&typeof e[3].get=="function"){this.container=e[3];const n=this.container.get("$widget");n&&n.events&&this.subscriptions.push(n.events.subscribe("storage:policy-changed",(o,s)=>Pe(s)))}}getConfiguration(){return{language:x(this.settings.language,this),client:x(()=>this.settings.client(this.container),this),funnel:x(this.settings.funnel,this),site:x(this.settings.site,this),reader:x(this.settings.reader,this),perspective:x(this.settings.perspective,this)}}customRequest(e,r,n={}){const o=n.configuration||{},s=n.parameters;return e=this.constructPath(e,o,s),this.proxy.request(e,{method:r,body:n.body}).then(a=>(n.success&&n.success(a),a)).catch(a=>(n.error&&n.error(a),a))}constructPath(e,r,n=!0){let o=e;const s=l(this.getConfiguration(),r);if(Object.keys(s).filter(a=>{const c=s[a];return c!==null&&typeof c<"u"}).forEach(a=>o=$(o,a,x(s[a]))),n){const a=n===!0?this.parameters.getAll():n;o=ee(o,a)}return o}match(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1]||{},o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(y){if(f(o)){const v=this;y=this.settings.useProxyClasses&&y?(y.Matches=A(y,"Matches",N,v),y):y,o(y)}return y}function c(y){f(s)&&s(y)}const h=l(!0,this.getConfiguration(),this.settings.paging,n),i={};let u="GET";i.categories=h.categories||h.categoryId,i.language=h.language,i.phrase=r,i.attributes=h.attributes,i.skip=h.skip,i.take=h.take,i.reader=h.reader,i.disableNotices=h.disableNotices,i.tags=h.tags,i.includeCategories=h.includeCategories,i.groupByCategory=h.groupByCategory,n.statisticsDisabled||(u="POST",i.funnel=h.funnel,i.client=h.client,i.site=h.site,this.current.phrase=r);const w="guides";n.sorting&&(i["sorting.type"]=n.sorting.type,i["sorting.direction"]=n.sorting.direction);const m=this.constructPath(w,i);return this.proxy.request(m,{method:u}).then(a.bind(this)).catch(c.bind(this))}getGuide(...e){const r=e[0];let n,o={},s,a;typeof e[1]=="function"?(s=e[1],a=e[2]):typeof e[1]=="object"?(o=e[1]||{},s=e[2],a=e[3]):typeof e[1]=="string"?(n=e[1],typeof e[2]=="function"?(s=e[2],a=e[3]):(o=e[2]||{},s=e[3],a=e[4])):!e[1]&&typeof e[2]=="function"&&(s=e[2],a=e[3]);function c(v){if(f(s)){const g=this.settings.useProxyClasses&&v?new N(v,this):v;this.guideCache[g.Id]=g,s(g)}return v}function h(v){return f(a)&&a(v),Promise.reject(v)}const i=l(!0,this.getConfiguration(),o),u={};let w="GET";u.connectionId=n||i.connectionId,u.perspective=i.perspective,u.reader=i.reader,u.phrase=this.current.phrase,this.parameters.remove("LastGuideId"),this.parameters.add("LastGuideId",r);let m=`guides/${r}`;u.connectionId&&(m+=`/${u.connectionId}`);let y="";return!o.statisticsDisabled&&!u.connectionId?(w="POST",y=this.constructPath(m,l({},this.current,o))):y=this.constructPath(m,l({},this.current,o),!1),this.proxy.request(y,{method:w}).then(c.bind(this)).catch(h.bind(this))}getCategories(...e){let r={},n,o;typeof e[0]=="object"?(r=e[0]||{},n=e[1],o=e[2]):(n=e[0],o=e[1]);function s(i){if(f(n)){const u=this;i=this.settings.useProxyClasses&&i?(i.Children=A(i,"Children",Q,u),i):i,n(i)}return i}function a(i){f(o)&&o(i)}let c="categories";r.categoryId&&(c+="/"+r.categoryId);const h=this.constructPath(c,l({},this.current,r));return this.proxy.request(h,{method:"GET"}).then(s.bind(this)).catch(a.bind(this))}answer(...e){const r=e[0],n=e[1];let o={},s,a,c;typeof e[2]=="object"?(o=e[2]||{},s=e[3],a=e[4]):(s=e[2],a=e[3]);const h=!!o.persist;function i(){!h&&c&&this.parameters.remove(c.Condition.ParameterName,c.Condition.Value)}function u(g){if(i(),f(s)){const D=this.settings.useProxyClasses&&g?new N(g,this):g;this.guideCache[D.Id]=D,s(D)}}function w(g){i(),f(a)&&a(g)}const m=this.guideCache[r];m.Options&&m.Options.forEach(g=>{this.parameters.remove(g.Condition.ParameterName,g.Condition.Value),g.ConnectionId===n&&(c=g)}),this.parameters.add(c.Condition.ParameterName,c.Condition.Value);const y=`guides/${r}/${n}`,v=this.constructPath(y,l({},this.current,o));return this.proxy.request(v,{method:"GET"}).then(u.bind(this)).catch(w.bind(this))}giveFeedback(...e){const r=e[0];let n,o,s={},a,c;typeof e[2]=="string"?(n=e[1],o=e[2],typeof e[3]=="object"?(s=e[3]||{},a=e[4],c=e[5]):(a=e[3],c=e[4])):(o=e[1],typeof e[2]=="object"&&(s=e[2]||{},a=e[3],c=e[4]));function h(m){return f(a)&&a(m),m}function i(m){return f(c)&&c(m),m}const u=`guides/${r}${n?"/"+n:""}/feedback`,w=this.constructPath(u,l({},s,{feedbackType:o}));return this.proxy.request(w,{method:"POST"}).then(h.bind(this)).catch(i.bind(this))}completeContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){f(o)&&o(u)}function c(u){f(s)&&s(u)}const h=`contactmethods/${r}/completed`,i=this.constructPath(h,n);return this.proxy.request(i,{method:"PUT"}).then(a.bind(this)).catch(c.bind(this))}getContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){if(f(o))o(u.ContactMethod);else return u}function c(u){if(f(s))s(u);else return u}const h=`contactmethods/${r}`,i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contactMethods(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],n=e[1]||{},o=e[2],s=e[3]):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(u){return f(o)&&(u=this.settings.useProxyClasses&&u?(u.Matches=A(u,"Matches",H),u):u,o(u)),u}function c(u){return f(s)&&s(u),u}const h=r?`guides/${r}/contactmethods`:"contactmethods",i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contacts(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2])):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(i){if(f(o))i&&this.settings.useProxyClasses&&(i.Children&&(i.Children=A(i,"Children",Q)),i.Matches&&(i.Matches=A(i,"Matches",H)),i.Highlighted&&(i.Highlighted=A(i,"Highlighted",H))),o(i);else return i}function c(i){if(f(s))s(i);else return i}const h=this.constructPath(`contacts/${r||""}`,l({},this.current,n));return this.proxy.request(h,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}getSettings(e){const r=this.constructPath("config",this.current);return this.proxy.request(r,{method:"GET"}).then(e)}getAuthorized(e,r){const n=this.constructPath("interfaceauthorized",this.current);return this.proxy.request(n,{method:"GET",credentials:"include"}).then(e).catch(r)}submitForm(e,r,n,o,s){let a="forms/"+e;return n&&(a+="/"+n),a=this.constructPath("config",l({},this.current,r)),this.proxy.request(a,"POST",r,o,s)}getTab(e,r,n,o){var s=arguments;typeof s[1]=="object"?(r=s[1],n=s[2],o=s[3]):(r={},n=s[1],o=s[2]);const a=`tabs/${e}`;return this.proxy.request(a,{method:"GET"}).then(n).catch(o)}dispose(){this.subscriptions.forEach(e=>e())}}B.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"};B.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"};B.defaults={client:ye,funnel:be,site:me,language:ge,paging:{skip:0,take:10},useProxyClasses:!1};B.version="1.0";const Ce=B;exports.ServiceClient=Ce;exports.ServiceProxy=te;exports.appendParameters=ee;exports.appendQueryString=$;exports.getCookie=q;exports.getStoragePolicyConsent=R;exports.setCookie=C;
|
|
@@ -640,7 +640,7 @@ class B {
|
|
|
640
640
|
function a(y) {
|
|
641
641
|
if (f(o)) {
|
|
642
642
|
const v = this;
|
|
643
|
-
y = this.settings.useProxyClasses && y ? (
|
|
643
|
+
y = this.settings.useProxyClasses && y ? (y.Matches = x(y, "Matches", L, v), y) : y, o(y);
|
|
644
644
|
}
|
|
645
645
|
return y;
|
|
646
646
|
}
|
|
@@ -687,7 +687,7 @@ class B {
|
|
|
687
687
|
function s(i) {
|
|
688
688
|
if (f(n)) {
|
|
689
689
|
const u = this;
|
|
690
|
-
i = this.settings.useProxyClasses && i ? (
|
|
690
|
+
i = this.settings.useProxyClasses && i ? (i.Children = x(i, "Children", Q, u), i) : i, n(i);
|
|
691
691
|
}
|
|
692
692
|
return i;
|
|
693
693
|
}
|
|
@@ -785,7 +785,7 @@ class B {
|
|
|
785
785
|
let r, n = {}, o, s;
|
|
786
786
|
typeof e[0] == "number" ? (r = e[0], n = e[1] || {}, o = e[2], s = e[3]) : typeof e[0] == "object" ? (n = e[0] || {}, o = e[1], s = e[2]) : (o = e[0], s = e[1]);
|
|
787
787
|
function a(u) {
|
|
788
|
-
return f(o) && (u = this.settings.useProxyClasses && u ? (
|
|
788
|
+
return f(o) && (u = this.settings.useProxyClasses && u ? (u.Matches = x(u, "Matches", D), u) : u, o(u)), u;
|
|
789
789
|
}
|
|
790
790
|
function c(u) {
|
|
791
791
|
return f(s) && s(u), u;
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=(n,e,t,...i)=>{const s=`[${n.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(s,...i);break;case"warning":console.warn(s,...i);break;case"error":console.error(s,...i);break}},je=n=>{const e=n.container||n;return{info:(t,...i)=>Y(e,"info",t,...i),warn:(t,...i)=>Y(e,"warning",t,...i),error:(t,...i)=>Y(e,"error",t,...i)}};var D=(n=>(n.Implementation="implementation",n.Widget="widget",n))(D||{}),x=(n=>(n.Pre="pre",n.Post="post",n))(x||{});const Ge=(n,e,t,i)=>{try{const s=new e(t,i);return{name:n,invoke:(r,a)=>{let o;return s[r]&&(o=s[r].call(s,a)),Promise.resolve(o)},getInstance:()=>s}}catch(s){if(s.message&&s.message.indexOf("is not a constructor")>=0)return{name:n,invoke:r=>{let a;return r==="initialize"&&(a=e(t,i)),Promise.resolve(a)},getInstance:()=>e};throw s}};function ue(n,e){return typeof n>"u"?e:n}let ze=class{constructor(e={}){this.part=e}createCommand(e,t,i){let s;typeof t=="function"?s={scope:D.Widget,stage:x.Post,defaultArgs:void 0,handlerResolver:t}:s={scope:ue(t.scope,D.Widget),stage:ue(t.stage,x.Post),defaultArgs:t.defaultArgs,handlerResolver:i};let r=this.part;const a=e.split(".");return a.forEach((o,c)=>{c===a.length-1?r[o]||(r[o]=()=>s):r=this.part[o]=this.part[o]||{}}),this}get(){return this.part}};const $e=n=>{const e=new ze({});return n(e),e.get()};$e(n=>{n.createCommand("types.register",{scope:D.Implementation,stage:x.Pre},e=>(t,i)=>{e.container.get("$types")[t]=i}).createCommand("type",{stage:x.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:x.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:x.Pre},e=>(t,i,s)=>{const{container:r}=e;let a=null,o=t,c=i;typeof t=="string"&&(a=t,o=i,c=s);const h=d=>{const{transformPluginSettings:g}=e.container.get("$environmentOptions"),u=g?g(c||{},a,e.container,o):i;try{const p=Ge(a,o,r,u);r.get("$plugins").push(p),d&&p.invoke("initialize",null)}catch(p){je(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?h(!0):e.events.subscribeOnce("widget:instance-created",()=>h(!1))}).createCommand("container.register",e=>(t,i)=>{e.container.register(t,i)}).createCommand("container.registerAsync",e=>(t,i)=>{e.container.registerAsync(t,i)}).createCommand("container.registerFactory",e=>(t,i)=>{e.container.registerFactory(t,i)}).createCommand("container.touch",e=>(t,i)=>{e.container.touch(t,i)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})});const Fe=$e(n=>{n.createCommand("ready",{scope:D.Implementation,stage:x.Pre},e=>t=>{const{container:i}=e,s=i.owner;i.get("bootstrapping").ready?t(s):s.events.subscribeOnce("bootstrap:ready",()=>{t(s)})})}),J=new WeakMap;function S(){return n=>(J.has(n)||J.set(n,{}),J.get(n))}const X=(n,e,t,...i)=>{const s=`[${n.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(s,...i);break;case"warning":console.warn(s,...i);break;case"error":console.error(s,...i);break}},v=n=>{const e=n.container||n;return{info:(t,...i)=>X(e,"info",t,...i),warn:(t,...i)=>X(e,"warning",t,...i),error:(t,...i)=>X(e,"error",t,...i)}},m=S(),re=(()=>{let n=0;return()=>++n})(),oe=(n,e,t)=>{const i=m(n).touchQueue.get(e);i&&i.forEach(s=>{s(t,n)})};class Ue{constructor(e,t,i,s){this.key=e,this.factory=t,this.parent=i,this.container=s,this.id=re(),this.resolved=!1,this.constructed=!1,this.async=!0}resolve(){if(!this.constructed){const e=this.factory(this.parent,this.container);return this.constructed=!0,this.value=Promise.resolve(e).then(t=>(this.resolved=!0,oe(this.container,this.key,t),t))}return this.value}}class We{constructor(e,t,i,s){this.key=e,this.value=t,this.parent=i,this.container=s,this.id=re(),this.async=!1,this.resolved=!1,this.constructed=!0,this.resolve=()=>(this.resolved=!0,oe(this.container,this.key,this.value),this.value)}}class Be{constructor(e,t,i,s){this.key=e,this.value=t,this.parent=i,this.container=s,this.id=re(),this.async=!1,this.resolved=!1,this.constructed=!1,this.resolve=()=>{this.resolved=!0,this.constructed=!0;const r=this.value(this.parent,this.container);return oe(this.container,this.key,this.value),r}}}let Qe=class Pe{constructor(e,t,i){this.owner=e,this.name=t,this.parent=i,m(this).resolvers=new Map,m(this).touchQueue=new Map,m(this).children=[]}delete(e){const t=m(this).resolvers,i=Array.from(t.values()).find(s=>s.id===e);return i?(m(this).touchQueue.delete(i.key),Promise.resolve(t.delete(i.key))):this.parent?this.parent.delete(e):Promise.resolve(!1)}clear(){const e=m(this).resolvers,t=Array.from(e.values());return Promise.all(t.map(i=>{if(i.constructed)return Promise.resolve(i.resolve()).then(s=>{if(s!==null&&typeof s=="object"&&typeof s.dispose=="function")return s.dispose.call(s,this,i)})})).then(()=>{t.forEach(i=>this.delete(i.id)),m(this).children.forEach(i=>i.clear())})}detach(){if(this.parent){const e=m(this.parent).children,t=e.indexOf(this);t>-1&&(e.splice(t,1),delete this.parent)}}touch(e,t){const i=m(this).resolvers.get(e);if(i&&i.constructed)Promise.resolve(i.resolve()).then(s=>{t(s,this)});else{const s=m(this).touchQueue;let r=s.get(e);r||(r=[],s.set(e,r)),r.push(t)}return this.parent&&!i?this.parent.touch(e,t):Promise.resolve()}registerAsync(e,t){const i=m(this).resolvers.get(e);i&&!i.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${e}') previously used by a non-async resolver.`);const s=new Ue(e,t,i,this);return m(this).resolvers.set(e,s),s.id}registerFactory(e,t){const i=m(this).resolvers.get(e);i&&i.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${e}') previously used by an async resolver.`);const s=new Be(e,t,i,this);return m(this).resolvers.set(e,s),s.id}register(e,t){const i=m(this).resolvers.get(e);i&&i.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${e}') previously used by an async resolver.`);const s=new We(e,t,i,this);return m(this).resolvers.set(e,s),s.id}get(e){const t=m(this).resolvers.get(e);if(t)return t.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`You are retrieving an async value (with key '${e}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`),t.resolve();if(this.parent)return this.parent.get(e)}getAsync(e){const t=m(this).resolvers.get(e);if(t){if(!t.async)throw process.env.NODE_ENV!=="production"&&v(this).warn(`You are retrieving a non-async value (with key '${e}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`),"Mismatching resolver type";return t.resolve()}return this.parent?this.parent.getAsync(e):Promise.resolve(void 0)}getMany(...e){const t={};return e.forEach(i=>t[i]=this.get(i)),t}getManyAsync(...e){const t={};return Promise.all(e.map(i=>this.getAsync(i).then(s=>t[i]=s))).then(()=>t)}createChild(e,t){const i=new Pe(e,t,this);return m(this).children.push(i),i}};class ge{constructor(e,t,i=!1,s=!1){this.type=e,this.target=t,this.cancelable=!!i,this.bubbles=!!s,this.defaultPrevented=!1}preventDefault(){this.cancelable&&(this.defaultPrevented=!0)}}const $=S(),pe=(n,e)=>[].concat($(n).listenerLookup.get(e.toLowerCase())||[],$(n).listenerLookup.get("*")||[]),me=(n,e,t,i)=>{let s,r;return e instanceof ge?(s=e,r=e.type):(s=new ge(e,n.target,!!t.cancelable,!!t.bubbles),r=e),{event:s,type:r,async:i}};class ae{constructor(e,t){this.target=e,this.parent=t,$(this).listenerLookup=new Map,$(this).children=[]}clear(){$(this).listenerLookup.clear(),$(this).children.forEach(e=>e.clear())}detach(){if(this.parent){const e=$(this.parent).children,t=e.indexOf(this);t>-1&&e.splice(t,1)}}subscribe(e,t,i){const s=$(this).listenerLookup,r=e.toLowerCase();return s.has(r)||s.set(r,[]),s.get(r).push(t),()=>this.unsubscribe(e,t)}subscribeOnce(e,t){const i=this.subscribe(e,(s,r)=>(i(),t(s,r)))}unsubscribe(e,t){const i=$(this).listenerLookup.get(e.toLowerCase());if(i){const s=i.indexOf(t);s>-1&&i.splice(s,1)}}dispatchAsync(e,t,i={}){const{event:s,type:r}=me(this,e,i,!0),a=pe(this,r);let o=0;const c=a.length;let h=Promise.resolve();for(o=0;o<c;o++)(d=>{h=h.then(g=>g?Promise.resolve(!0):Promise.resolve(d(s,t)).then(()=>s.defaultPrevented))})(a[o]);return h.then(d=>!d&&s.bubbles&&this.parent?this.parent.dispatchAsync(s,t):d)}dispatch(e,t,i={}){const{event:s,type:r}=me(this,e,i,!1),a=pe(this,r);let o=0;const c=a.length;let h=!1;for(o=0;o<c;o++)if(a[o](s,t),s.defaultPrevented){h=!0;break}return!h&&s.bubbles&&this.parent&&(h=this.parent.dispatch(s,t)),h}createChild(e){const t=new ae(e,this);return $(this).children.push(t),t}}const z=(n,e,t)=>{const i=n.get("$plugins").map(s=>{try{return s.invoke(e,t)}catch(r){v(n).error("An error occured when invoking a plugin.",s,r)}});return Promise.all(i)};class Ve{constructor(e){this.widget=e.get("$widget"),this.events=this.widget.events,this.container=this.widget.container,this.initialized=null,this.activated=null,this.initialize=this.initialize.bind(this),this.activate=this.activate.bind(this),this.deactivate=this.deactivate.bind(this),this.invoke=this.invoke.bind(this),this.createInstance()}createInstance(){if(!this.widget.container.get("$instance")){const e=this.widget.container.get("$types"),t=this.widget.container.get("$type");!t&&v(this).error("Unable to create widget. No type is specified.");const i=e[t];!i&&v(this).error(`Unable to create widget. Type '${t}' is not registered.`),this.widget.events.dispatch("widget:create-instance",{},{bubbles:!0});try{this.widget.container.register("$instance",new i(this.container))}catch(s){v(this).error("Unable to create widget type.",s)}this.widget.events.dispatch("widget:instance-created",{},{bubbles:!0})}}initialize(e){return this.initialized=this.initialized||(()=>{const t=this.container.get("$instance"),i=t.initialize||(()=>{});return this.initialized=Promise.resolve(i.call(t,e)).then(()=>z(this.container,"initialize",e)).then(()=>{})})()}activate(e){return(this.initialized||this.initialize()).then(()=>{this.activated=this.activated||(()=>z(this.container,"activate").then(()=>{const t=this.container.get("$instance");return this.activated=t.activate(e)}))()})}deactivate(){const e=this.container.get("$instance"),t=e.deactivate||(()=>{});return z(this.container,"deactivate").then(()=>Promise.resolve(t.call(e))).then(()=>{this.initialized=null,this.activated=null}).then(()=>{})}invoke(e,...t){return z(this.container,"invoke",{command:e,args:t}).then(()=>{const i=this.container.get("$instance");if(i[e])return i[e].apply(i,t);const s=i.invoke;if(s)return s.call(i,e,...t)})}}const M=(n,e)=>{if(!e)return!0;if(typeof e=="string"){const t=e.split(",");for(let i=0,s=t.length;i<s;i++){const r=t[i].trim();if(r===n||r==="*")return!0}}return e instanceof Array?e.indexOf(n)>-1:!1},He=(n,e)=>{if(typeof e=="function")return e(n);const t=typeof e=="string"?Je(e):e;return!(!M(n.implementation.tenant||"",t.tenant||"")||!M(n.implementation.name,t.implementation||"")||!M(n.name,t.widget||"")||!M(n.container.get("$type"),t.type||""))},Ke=(n,e)=>{if(typeof e=="function")return e(n);const t=typeof e=="string"?Xe(e):e;return!(!M(n.tenant||"",t.tenant||"")||!M(n.name,t.implementation||""))},Ee=n=>e=>He(e,n),Ye=n=>e=>Ke(e,n),E=n=>n instanceof Array&&n.length===1?n[0]:n,Je=n=>{const e={},t=n.split(":");return t.length===1?e.widget=E(t[0].split(",")):t.length===2?(e.implementation=E(t[0].split(",")),e.widget=E(t[1].split(","))):(e.tenant=E(t[0].split(",")),e.implementation=E(t[1].split(",")),e.widget=E(t[2].split(","))),e},Xe=n=>{const e={},t=n.split(":");return t.length===1?e.implementation=E(t[0].split(",")):(e.tenant=E(t[0].split(",")),e.implementation=E(t[1].split(","))),e},B=S(),fe=(n,e,t)=>n.filter(i=>i.stage===e&&Ee(i.selector)(t));function Ze(n){const e=n.container.get("$environment");let t=B(e).configurationCache;t&&(t=t.filter(i=>i[0]!==n),B(e).configurationCache=t)}var Q=(n=>(n.Implementation="implementation",n.Widget="widget",n))(Q||{}),A=(n=>(n.Pre="pre",n.Post="post",n))(A||{});const Ae=(n,e,t)=>(Object.keys(e).forEach(i=>{const s=e[i];if(typeof s=="function"){const r=s();typeof r.defaultArgs<"u"&&t(r,...r.defaultArgs),n[i]=(...a)=>{const o=Object.assign({},r,{handlerResolver:r.handlerResolver.bind({})});return t(o,...a),n}}else n[i]=Ae({},s,t)}),n),et=(n,e)=>{switch(e){case"implementation":return n.implementation;case"widget":return n}},ve=(n,e,t,i)=>(i.forEach(s=>{Ae(n,s,(r,...a)=>{const o={selector:e,stage:r.stage,handler:c=>{const h=et(c,r.scope),d={container:h.container,events:h.events},g=r.handlerResolver,u=g(d);let p=B(t.environment).configurationCache;return p||(p=B(t.environment).configurationCache=[]),p.find(w=>w.indexOf(h)>-1&&w.indexOf(g)>-1)?Promise.resolve():(p.push([h,g]),Promise.resolve(u(...a)))}};t.instructions.push(o)})}),n);function tt(n,e){function t(i){return ve({},i,n,e)}return ve(t,"*",n,e)}const nt=(n,e,t,i)=>{try{const s=new e(t,i);return{name:n,invoke:(r,a)=>{let o;return s[r]&&(o=s[r].call(s,a)),Promise.resolve(o)},getInstance:()=>s}}catch(s){if(s.message&&s.message.indexOf("is not a constructor")>=0)return{name:n,invoke:r=>{let a;return r==="initialize"&&(a=e(t,i)),Promise.resolve(a)},getInstance:()=>e};throw s}};function ye(n,e){return typeof n>"u"?e:n}class it{constructor(e={}){this.part=e}createCommand(e,t,i){let s;typeof t=="function"?s={scope:Q.Widget,stage:A.Post,defaultArgs:void 0,handlerResolver:t}:s={scope:ye(t.scope,Q.Widget),stage:ye(t.stage,A.Post),defaultArgs:t.defaultArgs,handlerResolver:i};let r=this.part;const a=e.split(".");return a.forEach((o,c)=>{c===a.length-1?r[o]||(r[o]=()=>s):r=this.part[o]=this.part[o]||{}}),this}get(){return this.part}}const Ne=n=>{const e=new it({});return n(e),e.get()},st=Ne(n=>{n.createCommand("types.register",{scope:Q.Implementation,stage:A.Pre},e=>(t,i)=>{e.container.get("$types")[t]=i}).createCommand("type",{stage:A.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:A.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:A.Pre},e=>(t,i,s)=>{const{container:r}=e;let a=null,o=t,c=i;typeof t=="string"&&(a=t,o=i,c=s);const h=d=>{const{transformPluginSettings:g}=e.container.get("$environmentOptions"),u=g?g(c||{},a,e.container,o):i;try{const p=nt(a,o,r,u);r.get("$plugins").push(p),d&&p.invoke("initialize",null)}catch(p){v(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?h(!0):e.events.subscribeOnce("widget:instance-created",()=>h(!1))}).createCommand("container.register",e=>(t,i)=>{e.container.register(t,i)}).createCommand("container.registerAsync",e=>(t,i)=>{e.container.registerAsync(t,i)}).createCommand("container.registerFactory",e=>(t,i)=>{e.container.registerFactory(t,i)}).createCommand("container.touch",e=>(t,i)=>{e.container.touch(t,i)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})}),rt=st;function ot(n,e,t=[]){const i=[rt].concat(t),s=tt(e,i);n(s,e)}class at{constructor(){this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,i,s){this.tasks.push({task:e,resolve:t,reject:i,done:s}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){const t=Promise.resolve(e.task());return Promise.resolve(t).then(this.next).then(()=>t.then(i=>{e.done(),e.resolve(i)})).catch(i=>(e.done(),e.reject(i),this.next()))}return Promise.resolve()})}}const F=new WeakMap;function ct(n){return F.has(n)||F.set(n,new at),e=>new Promise((t,i)=>{const s=F.get(n);s.add(e,t,i,()=>{s.tasks.length||F.delete(n)})})}const be=n=>typeof n<"u",L=(n,e)=>{n.events.dispatch("widget:state-change",{state:e},{bubbles:!0}),n.state=e,n.events.dispatch("widget:state-changed",{},{bubbles:!0})},y=S(),ht=n=>{const{container:e,events:t}=n;e.get("$controller")||(e.register("$controller",new Ve(e)),t.dispatch("widget:controller-created",{},{bubbles:!0}))};class lt{constructor(e,t,i){this.state="deactivated",this.name=e,this.implementation=t,this.container=t.container.createChild(this,e),this.events=t.events.createChild(this),y(this).subscriptions=[],i&&t.configure(s=>{const r=s(e);be(i.type)&&r.type(i.type),be(i.settings)&&r.settings(i.settings),i.plugins&&Object.keys(i.plugins).forEach(a=>{var o;const c=(o=i.plugins)==null?void 0:o[a];r.plugin(a,c)})}),this.load=this.load.bind(this),this.activate=this.activate.bind(this),this.invoke=this.invoke.bind(this),this.deactivate=this.deactivate.bind(this)}load(){return ct(this)(()=>{y(this).deactivatedPromise=null;const e=this.state==="deactivated";e&&(L(this,"activating"),this.container.register("$widget",this),this.container.register("$controller",null),this.container.register("$plugins",[]),this.container.register("$type",null),this.container.register("$instance",null)),L(this,"loading");const t=this.implementation.instructions,i=fe(t,A.Pre,this);return Promise.all(i.map(s=>s.handler(this))).then(()=>{ht(this);const s=fe(t,A.Post,this);return Promise.all(s.map(r=>r.handler(this))).then(()=>{e&&this.container.get("$controller").initialize()})}).then(()=>(L(this,"activated"),this))})}activate(e){y(this).subscriptions.push(this.implementation.events.subscribe("implementation:configured",()=>{["activated","activating","loading"].indexOf(this.state)>-1&&this.load()}));const t=y(this).activatedPromise;return t?(process.env.NODE_ENV!=="production"&&v(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`,e),t):y(this).activatedPromise=this.load().then(()=>this.container.get("$controller").activate(e))}invoke(e,...t){const i=y(this).activatedPromise,s=(r,...a)=>i.then(this.load).then(()=>this.container.get("$controller").invoke(r,...a));return i?s(e,...t):(process.env.NODE_ENV!=="production"&&v(this).warn("You are invoking a command on a deactivated widget. The invocation will be queued until the widget is activated.",this),new Promise(r=>{const a=this.events.subscribe("widget:state-changed",()=>{this.state==="activated"&&(a(),r(s(e,...t)))})}))}deactivate(){return y(this).deactivatedPromise||(this.state==="deactivated"?Promise.resolve():(L(this,"deactivating"),y(this).deactivatedPromise=this.container.get("$controller").deactivate().then(()=>(y(this).activatedPromise=null,y(this).subscriptions.forEach(t=>t()),y(this).subscriptions=[],this.container.clear().then(()=>{this.events.clear(),Ze(this),L(this,"deactivated")})))))}}const we=S();class dt{constructor(e,t,i=[]){this.instructions=[],this.widgets=new Map,this.name=e.name,this.tenant=e.tenant,this.environment=t,this.container=t.container.createChild(this,this.name),this.events=t.events.createChild(this),this.container.register("$types",{}),we(this).configurationApiExtensions=i}load(){const e=Array.from(this.widgets.values());return Promise.all(e.map(t=>t.load())).then(()=>e)}configure(e){return ot(e,this,we(this).configurationApiExtensions),this.events.dispatch("implementation:configured",{implementation:this},{bubbles:!0}),this}createWidget(e,t){const i=new lt(e,this,t);return this.widgets.set(i.name,i),i}}function ut(n,e,t){const i=new dt(n,e,t);return n.widgets&&Object.keys(n.widgets).forEach(s=>{var r;const a=(r=n.widgets)==null?void 0:r[s];i.createWidget(s,a)}),i}let ke=class xe{constructor(e,t){this.selectorFactory=t,typeof e=="function"?this.resolver=e:this.resolver=()=>e}append(e){const t=typeof e=="function"?e:()=>e;return new xe(()=>this.all().concat(t()),this.selectorFactory)}all(){return this.resolver().concat([])}query(e){return this.all().filter(this.selectorFactory(e))}find(e){const t=this.query(e);if(t.length)return t[0]}};const ce="#____version____#",Z=S(),gt=n=>n.tenant?`${n.name}:${n.tenant}`:n.name,Oe=class{constructor(n,e=[],t={}){this.widgets=new ke(()=>{let i=[];return this.implementations.all().forEach(s=>{i=i.concat(Array.from(s.widgets.values()))}),i},Ee),this.implementations=new ke([],Ye),this.name=n,this.container=new Qe(this,n),this.events=new ae(this),this.container.register("$version",ce),this.container.register("$environment",this),this.container.register("$environmentOptions",t),Z(this).configurationApiExtensions=e}createImplementation(n){const e=gt(n);let t=this.implementations.find(e);if(t)return process.env.NODE_ENV!=="production"&&v(t).warn(`Implementation "${e}" already exist on current environment.`),t;const i=Z(this).configurationApiExtensions;return t=ut(n,this,i),this.implementations=this.implementations.append([t]),this.events.dispatch("implementation:created",{implementation:t}),t}patch(n={}){const{name:e,configurationApiExtensions:t}=n;typeof e<"u"&&e!==null&&(this.name=e),t&&t.forEach(i=>{Z(this).configurationApiExtensions.push(i)})}static create(n={}){return new Oe(n.name||"",n.configurationApiExtensions,n.options)}};let Ie=Oe;Ie.version=ce;const H=(n,e,...t)=>typeof e=="string"?n(`[humany] ${e}`,...t):n(e,...t),T=class{constructor(){this.keys=[],this.log=(n,...e)=>this.lookup(n,()=>T.log(...e)),this.warn=(n,...e)=>this.lookup(n,()=>T.warn(...e)),this.error=(n,...e)=>this.lookup(n,()=>T.error(...e)),this.info=(n,...e)=>this.lookup(n,()=>T.info(...e))}lookup(n,e){this.keys.indexOf(n)===-1&&(this.keys.push(n),e())}};let j=T;j.log=(...n)=>H(console.log,...n);j.warn=(...n)=>H(console.warn,...n);j.error=(...n)=>H(console.error,...n);j.info=(...n)=>H(console.info,...n);const Me=n=>{let e={},t,i;if(typeof n!="object"||n===null)return n;e=Array.isArray(n)?[]:{};for(i in n)t=n[i],e[i]=typeof t=="object"&&t!==null?Me(t):t;return e};class pt{constructor(e,t){this.lockWarningTime=e,this.lockErrorTime=t,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,i,s){this.tasks.push({task:e,resolve:t,reject:i,done:s}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){let t;const i=setTimeout(()=>{process.env.NODE_ENV!=="production"&&j.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(r=>(clearTimeout(i),clearTimeout(t),r));return Promise.resolve(s).then(this.next).then(()=>s.then(r=>{e.done(),e.resolve(r)})).catch(r=>(e.done(),e.reject(r),this.next()))}return Promise.resolve()})}}const U=new WeakMap;function mt(n,e=5e3,t=1e3){return U.has(n)||U.set(n,new pt(e,t)),i=>new Promise((s,r)=>{const a=U.get(n);a.add(i,s,r,()=>{a.tasks.length||U.delete(n)})})}const ft=(n={})=>(Object.keys(n).forEach(e=>{(n[e]===null||typeof n[e]>"u")&&delete n[e]}),n),W=(n,e)=>{let t=!0;return Object.keys(n).length!==Object.keys(e).length||Object.keys(n).some(i=>!Object.keys(e).some(s=>i===s))?!1:(Object.keys(n).forEach(i=>{if(t){const s=typeof n[i]>"u"?"":n[i],r=typeof e[i]>"u"?"":e[i];t=s.toString()===r.toString()}}),t)};Ne(n=>{n.createCommand("components",e=>t=>{e.events.subscribeOnce("components:platform-created",(i,{platform:s})=>{t.handlers&&t.handlers.forEach(([r,a])=>{s.addComponentHandler(r,a)})})})});const vt="#____version____#",Re=class extends Ie{constructor(n,e=[]){super(n,e,{transformPluginSettings:(t,i,s)=>{const r=s.get("$settings");return{...r.plugins&&i?r.plugins[i]||{}:{},...t}}})}createImplementation(n){const e=super.createImplementation(n);return e.bindings=n.bindings,e}navigate(n,e,t){this.widgets.query(n).forEach(i=>i.invoke("navigate",{route:e,params:t}))}static create(n={}){const e=[Fe].concat(n.configurationApiExtensions||[]);return new Re("humany",e)}static createFromGlobal(n,e={}){if(this.isRuntime(n))return n.patch(e),n;const t=[],i=n&&n._c;i&&i.forEach(r=>t.push(r));const s=this.create(e);return s.container.register("$runtimecfg",t),s}static isRuntime(n){return!!(n&&typeof n=="object"&&n.container&&typeof n.container.get=="function"&&n.container.get("$environment")===n&&n.container.owner===n)}};let yt=Re;yt.version=`${vt} (${ce})`;var V=(n=>(n.open="open",n.closed="closed",n.hidden="hidden",n))(V||{});const Ce=n=>Promise.resolve().then(()=>require("./index-48f6c72c.js")).then(({ServiceClient:e,ServiceProxy:t})=>n.get("settings").then(i=>{const{name:s,events:r}=n.get("$widget"),{data:{projection:a="",site:o="current",forceHttps:c=!1}}=i,h=new t(a,{credentials:"same-origin"}),d=new e(h,{funnel:s.replace("_contact-method","").replace("_contact",""),site:bt(o,c)},null,n);return r.subscribe("widget:settings-updated",(g,{data:u})=>{u&&u.projection!==a&&d.proxy.setBaseUrl(u.projection)}),d})),bt=(n,e)=>()=>{const t=s=>{const r=document.createElement("a");return r.href=s,r};let i=window.location;return n==="referrer"&&document.referrer&&(i=t(document.referrer)),[e?"https:":"","//",i.host,i.pathname].join("")},O=n=>{if(n){const{Type:e,Content:t}=n;if(e&&t)return{type:e,content:t}}},ie=n=>n.map(e=>{const t={id:e.Id.toString(),title:e.Name,symbol:O(e.DefaultIcon),activeSymbol:e.ActiveIcon&&O(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(t.items=ie(e.Children)),t}),P=(n,e)=>n.filter(({Type:t})=>t===e).map(({Id:t,Title:i,Body:s})=>({id:t.toString(),title:i,body:s})),ee=n=>n.map(({Id:e,Title:t,DefaultIcon:i,ListNotices:s,Notices:r})=>({id:e.toString(),title:t,symbol:O(i),defaultHeaderOptions:{visible:!!s.length},notifications:(s||[]).concat(r||[]).map(({Id:a,Title:o,Body:c,Type:h,Modified:d})=>({id:a.toString(),title:o,body:c,modified:d,expandable:h==="listNotice"}))})),te=({Id:n,Title:e,DefaultIcon:t,Exits:[i],ExitType:s,ConfirmationText:r,Description:a},o)=>{const{Adapter:c}=i||{Adapter:{}},{ClientName:h="",Settings:d={},CustomClientName:g=""}=c,u={id:n.toString(),title:e,description:a,symbol:O(t),clientName:h==="custom.adapter"?g:h,expanded:!0,inline:!0,body:{}};if(h.indexOf("phone")>-1||h.indexOf("freetext")>-1){const{displayTextBeforeClick:p,textBeforeClick:w}=d;p==="true"&&(u.expanded=!1,u.title=w),h.indexOf("phone.text")>-1?u.body.phoneNumber=d.phoneNumber:u.body.freetext=d.freetext}return(h.indexOf("chat.popup")>-1||h.indexOf("link")>-1||h==="custom.adapter"&&s==="custom")&&(u.body=d,u.body.confirmationFallback=r),h.indexOf("ace")>-1&&(u.body=d),u},q=(n=[])=>n.map(({Id:e,Title:t,TotalMatches:i,Symbol:s,DefaultIcon:r,ActiveIcon:a})=>({id:e.toString(),title:t,matches:i,symbol:O(r||s),defaultIcon:O(r),activeIcon:O(a)})),ne=n=>n.map(({Id:e,Title:t,Tags:i,FirstPublishedDate:s,Modified:r})=>({id:e.toString(),title:t,tags:q(i),published:s,modified:r})),Se=(n,e)=>{switch(n){case b.MatchByCategory:case b.Match:{const t={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:i,TotalMatches:s,Notices:r,NoticeLists:a,Tags:o,ByCategory:c}=e;return t.guides=ne(i),t.matches=s,t.byCategory=(c||[]).map(({Id:h,Matches:d,TotalMatches:g})=>({id:h,guides:ne(d),matches:g})),t.tags=q(o),t.notificationLists=ee(a||[]),t.topNotifications=P(r||[],"noticeRowTop"),t.middleNotifications=P(r||[],"noticeRowMiddle"),t.bottomNotifications=P(r||[],"footerNotice"),t}case b.Categories:{const{Children:t,GuidesCountTotal:i}=e;return{categories:ie(t||[]),matches:i}}case b.Guide:{const{Id:t,Title:i,Body:s,Related:r,Options:a,ConnectionId:o,ContactMethods:c,EnableFeedback:h,HandoverExists:d,FirstPublishedDate:g,Modified:u,ModifiedByDisplayName:p,FirstPublishedByDisplayName:w,Categories:k,Tags:l,SeoMetaDescription:f,SeoAllowIndex:K,Perspectives:_,PerspectiveKey:he,Translations:le}=e,qe=he||Object.values(_).find(N=>N===o)||_.Default||null,de={guide:{id:t.toString(),title:i,body:s,modified:u,published:g,modifiedBy:p,publishedBy:w,connection:o,categories:k,hasHandover:d,allowFeedback:h,seoMetaDescription:f,seoAllowIndex:K,perspectives:_,perspective:qe,translations:Object.keys(le||{}).reduce((N,G)=>(N[G]=le[G].toString(),N),{})},related:ne(r||[]),dialog:[],contactMethods:(c||[]).map(N=>te(N)),tags:q(l)};return(a||[]).forEach(({CanAccess:N,Description:G,ConnectionId:De,Properties:C})=>{if(!N)return;const I={id:t.toString(),title:G,connection:De,connectionKey:C.ConnectionKey,type:"default",parent:{id:t.toString(),title:i,tags:q(l)}};if(C.Type==="Guide"||C.Type==="Link")switch(C.Id&&(I.id=C.Id.toString()),C.Uri&&(I.href=C.Uri),C.Target&&(I.target=C.Target),C.Type){case"Guide":I.type="guide";break;case"Link":I.type="link";break}de.dialog.push(I)}),de}case b.Contacts:{const{Children:t,Matches:i,Notices:s,NoticeLists:r}=e;return{contactMethods:(i||[]).map(o=>te(o)),categories:ie(t||[]),topNotifications:P(s||[],"noticeRowTop"),middleNotifications:P(s||[],"noticeRowMiddle"),bottomNotifications:P(s||[],"footerNotice"),notificationLists:ee(r||[])}}case b.ContactMethod:{const{ContactMethod:t}=e;return te(t||{})}case b.Tags:case b.TagsOnGuides:return q(e||[]);case b.Notifications:{const{Notices:t,NoticeLists:i}=e;return{topNotifications:P(t||[],"noticeRowTop"),middleNotifications:P(t||[],"noticeRowMiddle"),bottomNotifications:P(t||[],"footerNotice"),notificationLists:ee(i||[])}}default:return{}}};var _e=(n=>(n.Guide="guide",n.Guides="guides",n.GuidesByCategory="guides-by-category",n.RowNotifications="row-notices",n.NotificationLists="notification-lists",n.GuideCategories="guide-categories",n.ContactMethodCategories="contact-method-categories",n.ContactMethod="contact-method",n.ContactMethods="contact-methods",n.Tags="tags",n.TagsOnGuides="tagsonguides",n))(_e||{}),b=(n=>(n.Match="match",n.Categories="categories",n.Guide="guide",n.Contacts="contacts",n.ContactMethod="contact-method",n.MatchByCategory="match-by-category",n.Tags="tags",n.TagsOnGuides="tagsonguides",n.Notifications="notifications",n))(b||{}),Le=(n=>(n.Positive="Positive",n.Negative="Negative",n))(Le||{}),Te=(n=>(n.POPULARITY_DESCENDING="popularity-descending",n.ALPHABETIC_ASCENDING="alphabetic-ascending",n.ALPHABETIC_DESCENDING="alphabetic-descending",n.MODIFIED_ASCENDING="modified-ascending",n.MODIFIED_DESCENDING="modified-descending",n.PUBLISHED_ASCENDING="published-ascending",n.PUBLISHED_DESCENDING="published-descending",n))(Te||{});const se=n=>{switch(n){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"}},wt=async n=>{const{invoke:e}=n.get("$widget");return await e("renderState")===V.hidden};class R{constructor(e,t){this.container=e,this.matchingClient=t,this.queries=new Map,this.getUnresolvedQueries=()=>{let i=0;return this.queries.forEach((s,r)=>{s.some(o=>!o.resolved)&&(i=1)}),i},this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(i,{next:s,previous:r})=>{r===V.hidden&&s===V.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,t="dataClient"){return mt(this)(()=>e.getAsync(t).then(async i=>{let s=await e.getAsync("matchingClient");s||(s=await Ce(e),e.registerAsync("matchingClient",()=>s));let r=i;return r||(r=new R(e,s),e.registerAsync(t,()=>r)),r}))}fetch(e,t,i){return new Promise((s,r)=>{t.take,ft(t);const a=se(e);let o=this.queries.get(a)||[],c=o.find(h=>W(h.params,t))||null;if(c&&(i!=null&&i.noCache)){const h=o.findIndex(d=>W(d.params,t));o=[...o.slice(0,h),...o.slice(h+1)],c=null}if(c){const h=o.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?r({error:c.error}):s(c.data)):c.resolvers.push({resolve:s,reject:r}),o.splice(h,1),o.push(c),this.queries.set(a,o),!c.loading&&!c.resolved)return this.runQuery(a,t)}else return o.push({params:t,resolved:!1,loading:!0,data:{},resolvers:[{resolve:s,reject:r}]}),this.queries.set(a,o),this.runQuery(a,t)}).then(s=>Me(s))}read(e,t){const{select:i}=t,s=se(e);return(this.queries.get(s)||[]).reduce((o,c)=>{if(typeof i=="function"){const h=i(c.data);h&&o.push(h)}else o.push(c.data);return o},[])}feedback(e,t,i){return this.matchingClient.giveFeedback(e,t,i)}setLoadingStatus(e,t,i){const s=this.queries.get(e)||[],r=s.find(a=>W(a.params,t));r&&(r.loading=i),this.queries.set(e,s)}async runQuery(e,t){const{searchPhrase:i="",categories:s="0",contactMethodCategoryId:r="0",contactMethodId:a="0",tagId:o=void 0,take:c=5,connection:h="",guideId:d,expandCategories:g="descendants",currentCategory:u,sorting:p="popularity-descending",guideIds:w=[]}=t,k=i.toString().trim();if(await wt(this.container))return Promise.resolve();switch(e){case"match":{const l=f=>{const[K,_]=f.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(K),direction:_}};return w.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:w,take:+c}}).then(f=>f&&this.handleResponse(f,e,t)):this.matchingClient.match(k,{categories:s==="0"?[]:Array.isArray(s)?s:[+s],take:+c,tags:o,sorting:l(p),ids:w}).then(f=>f&&this.handleResponse(f,e,t))}case"match-by-category":return this.matchingClient.match(k,{groupByCategory:!0,categories:s==="0"?[]:Array.isArray(s)?s:[+s],take:+c,tags:o}).then(l=>l&&this.handleResponse(l,e,t));case"guide":return this.matchingClient.getGuide(d,{connectionId:h}).then(l=>{l&&this.handleResponse(l,e,t)}).catch(l=>{const f={message:"Something went wrong.",status:l.status||400};f.status===404&&(f.message="The guide could not be found."),this.handleResponse({},e,t,f)});case"categories":return this.matchingClient.getCategories({phrase:k,expand:g,tags:o}).then(l=>l&&this.handleResponse(l,e,t));case"contacts":return d?this.matchingClient.contactMethods(+d,{phrase:k}).then(l=>l&&this.handleResponse(l,e,t)):this.matchingClient.contacts(+r,{phrase:k}).then(l=>l&&this.handleResponse(l,e,t));case"contact-method":return this.matchingClient.getContactMethod(+a,{guideId:d,currentCategory:u}).then(l=>l&&this.handleResponse(l,e,t));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:k,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:k,categories:s==="0"?[]:Array.isArray(s)?s:[+s],tags:o}}).then(l=>l&&this.handleResponse(l,e,t));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:k,categories:s==="0"?[]:Array.isArray(s)?s:[+s]}}).then(l=>l&&this.handleResponse(l,e,t))}}handleResponse(e={},t,i,s){const r=this.queries.get(t)||[],a=r.find(o=>W(o.params,i));if(a){const o=s||Se(t,e);this.track(o,t,s),a.resolvers.forEach(h=>{s?h.reject({error:o}):h.resolve(o)});const c=r.indexOf(a);c>-1&&r.splice(c,1),r.push({...a,error:s,resolvers:[],data:o,resolved:!0}),this.setLoadingStatus(t,i,!1),this.queries.set(t,r),s||this.events.dispatch("data-client:fetched",{type:t,params:i,response:o,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,t]of this.queries)t.filter(i=>!i.resolved).forEach(i=>{this.runQuery(e,i.params)})}track(e={},t,i){const s=this.container.get("$widget");s&&!i?s.events.dispatch("tracking:service-client-response",{type:t,data:e}):s&&s.events.dispatch("tracking:service-client-error",{type:t,error:i})}static create(e){return e.getAsync("matchingClient").then(async t=>{if(t)return new R(e,t);const i=await Ce(e);return e.registerAsync("matchingClient",()=>i),new R(e,i)})}getClient(){return this.matchingClient}}const kt=async n=>{n.registerAsync("dataClient",()=>R.create(n))};exports.DataClient=R;exports.DataType=_e;exports.FeedbackType=Le;exports.KnowledgeDataClientPlugin=kt;exports.ServiceClientQueryType=b;exports.SortingType=Te;exports.determineServiceClientQueryType=se;exports.formatLegacyData=Se;
|
|
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;
|