@telia-ace/knowledge-data-client-flamingo 1.1.121-rc.0 → 1.1.121-rc.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},b={searchParams:"URLSearchParams"in p,iterable:"Symbol"in p&&"iterator"in Symbol,blob:"FileReader"in p&&"Blob"in p&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in p,arrayBuffer:"ArrayBuffer"in p};function se(t){return t&&DataView.prototype.isPrototypeOf(t)}if(b.arrayBuffer)var oe=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ie=ArrayBuffer.isView||function(t){return t&&oe.indexOf(Object.prototype.toString.call(t))>-1};function S(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function G(t){return typeof t!="string"&&(t=String(t)),t}function V(t){var e={next:function(){var r=t.shift();return{done:r===void 0,value:r}}};return b.iterable&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach(function(e,r){this.append(r,e)},this):Array.isArray(t)?t.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}d.prototype.append=function(t,e){t=S(t),e=G(e);var r=this.map[t];this.map[t]=r?r+", "+e:e};d.prototype.delete=function(t){delete this.map[S(t)]};d.prototype.get=function(t){return t=S(t),this.has(t)?this.map[t]:null};d.prototype.has=function(t){return this.map.hasOwnProperty(S(t))};d.prototype.set=function(t,e){this.map[S(t)]=G(e)};d.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)};d.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),V(t)};d.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),V(t)};d.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),V(t)};b.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function N(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function Y(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function ae(t){var e=new FileReader,r=Y(e);return e.readAsArrayBuffer(t),r}function ce(t){var e=new FileReader,r=Y(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),o=n?n[1]:"utf-8";return e.readAsText(t,o),r}function he(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function z(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function Z(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:b.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:b.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():b.arrayBuffer&&b.blob&&se(t)?(this._bodyArrayBuffer=z(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):b.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||ie(t))?this._bodyArrayBuffer=z(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},b.blob&&(this.blob=function(){var t=N(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=N(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(b.blob)return this.blob().then(ae);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=N(this);if(t)return t;if(this._bodyBlob)return ce(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(he(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},b.formData&&(this.formData=function(){return this.text().then(le)}),this.json=function(){return this.text().then(JSON.parse)},this}var ue=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function fe(t){var e=t.toUpperCase();return ue.indexOf(e)>-1?e:t}function j(t,e){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var r=e.body;if(t instanceof j){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new d(e.headers)),this.method=fe(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in p){var s=new AbortController;return s.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var o=/\?/;this.url+=(o.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}j.prototype.clone=function(){return new j(this,{body:this._bodyInit})};function le(t){var e=new FormData;return t.trim().split("&").forEach(function(r){if(r){var n=r.split("="),o=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(s))}}),e}function de(t){var e=new d,r=t.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},b={searchParams:"URLSearchParams"in p,iterable:"Symbol"in p&&"iterator"in Symbol,blob:"FileReader"in p&&"Blob"in p&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in p,arrayBuffer:"ArrayBuffer"in p};function se(t){return t&&DataView.prototype.isPrototypeOf(t)}if(b.arrayBuffer)var oe=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ie=ArrayBuffer.isView||function(t){return t&&oe.indexOf(Object.prototype.toString.call(t))>-1};function S(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function G(t){return typeof t!="string"&&(t=String(t)),t}function V(t){var e={next:function(){var r=t.shift();return{done:r===void 0,value:r}}};return b.iterable&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach(function(e,r){this.append(r,e)},this):Array.isArray(t)?t.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}d.prototype.append=function(t,e){t=S(t),e=G(e);var r=this.map[t];this.map[t]=r?r+", "+e:e};d.prototype.delete=function(t){delete this.map[S(t)]};d.prototype.get=function(t){return t=S(t),this.has(t)?this.map[t]:null};d.prototype.has=function(t){return this.map.hasOwnProperty(S(t))};d.prototype.set=function(t,e){this.map[S(t)]=G(e)};d.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)};d.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),V(t)};d.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),V(t)};d.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),V(t)};b.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function N(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function Y(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function ae(t){var e=new FileReader,r=Y(e);return e.readAsArrayBuffer(t),r}function ce(t){var e=new FileReader,r=Y(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),o=n?n[1]:"utf-8";return e.readAsText(t,o),r}function he(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function z(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function Z(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:b.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:b.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():b.arrayBuffer&&b.blob&&se(t)?(this._bodyArrayBuffer=z(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):b.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||ie(t))?this._bodyArrayBuffer=z(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},b.blob&&(this.blob=function(){var t=N(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=N(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(b.blob)return this.blob().then(ae);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=N(this);if(t)return t;if(this._bodyBlob)return ce(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(he(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},b.formData&&(this.formData=function(){return this.text().then(le)}),this.json=function(){return this.text().then(JSON.parse)},this}var ue=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function fe(t){var e=t.toUpperCase();return ue.indexOf(e)>-1?e:t}function j(t,e){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var r=e.body;if(t instanceof j){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new d(e.headers)),this.method=fe(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||(function(){if("AbortController"in p){var s=new AbortController;return s.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var o=/\?/;this.url+=(o.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}j.prototype.clone=function(){return new j(this,{body:this._bodyInit})};function le(t){var e=new FormData;return t.trim().split("&").forEach(function(r){if(r){var n=r.split("="),o=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(s))}}),e}function de(t){var e=new d,r=t.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
2
|
`)===0?n.substr(1,n.length):n}).forEach(function(n){var o=n.split(":"),s=o.shift().trim();if(s){var a=o.join(":").trim();try{e.append(s,a)}catch(c){console.warn("Response "+c.message)}}}),e}Z.call(j.prototype);function P(t,e){if(!(this instanceof P))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}Z.call(P.prototype);P.prototype.clone=function(){return new P(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})};P.error=function(){var t=new P(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var pe=[301,302,303,307,308];P.redirect=function(t,e){if(pe.indexOf(e)===-1)throw new RangeError("Invalid status code");return new P(null,{status:e,headers:{location:t}})};var O=p.DOMException;try{new O}catch{O=function(e,r){this.message=e,this.name=r;var n=Error(e);this.stack=n.stack},O.prototype=Object.create(Error.prototype),O.prototype.constructor=O}function ee(t,e){return new Promise(function(r,n){var o=new j(t,e);if(o.signal&&o.signal.aborted)return n(new O("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var i={statusText:s.statusText,headers:de(s.getAllResponseHeaders()||"")};o.url.indexOf("file://")===0&&(s.status<200||s.status>599)?i.status=200:i.status=s.status,i.url="responseURL"in s?s.responseURL:i.headers.get("X-Request-URL");var u="response"in s?s.response:s.responseText;setTimeout(function(){r(new P(u,i))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},s.onabort=function(){setTimeout(function(){n(new O("Aborted","AbortError"))},0)};function c(i){try{return i===""&&p.location.href?p.location.href:i}catch{return i}}if(s.open(o.method,c(o.url),!0),o.credentials==="include"?s.withCredentials=!0:o.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(b.blob?s.responseType="blob":b.arrayBuffer&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof d||p.Headers&&e.headers instanceof p.Headers)){var h=[];Object.getOwnPropertyNames(e.headers).forEach(function(i){h.push(S(i)),s.setRequestHeader(i,G(e.headers[i]))}),o.headers.forEach(function(i,u){h.indexOf(u)===-1&&s.setRequestHeader(u,i)})}else o.headers.forEach(function(i,u){s.setRequestHeader(u,i)});o.signal&&(o.signal.addEventListener("abort",a),s.onreadystatechange=function(){s.readyState===4&&o.signal.removeEventListener("abort",a)}),s.send(typeof o._bodyInit>"u"?null:o._bodyInit)})}ee.polyfill=!0;p.fetch||(p.fetch=ee,p.Headers=d,p.Request=j,p.Response=P);var L,J;function ye(){return J||(J=1,L=self.fetch.bind(self)),L}ye();const M="functional",U="Humany__parameters";function be(t){const e={};return t&&Object.keys(t).forEach(r=>{const n=t[r];(B(n)==="array"?n:[n]).forEach(o=>{typeof e[r]>"u"&&(e[r]=[]),e[r].push(o)})}),e}class me{constructor(e,r){this.isLoaded=!!e,this.parameters=be(e),r&&typeof r.get=="function"&&(this.container=r)}getAll(){return this.ensureIsLoaded(),l(!0,{},this.parameters)}add(e,r){this.ensureIsLoaded(),this.parameters[e]||(this.parameters[e]=[]),this.parameters[e].push(r),this.persist()}set(e,r){this.ensureIsLoaded(),this.parameters[e]=[r],this.persist()}remove(e,r){if(this.ensureIsLoaded(),typeof r>"u")delete this.parameters[e];else{const n=this.parameters[e]||[];n.forEach((o,s)=>{o===r&&n.splice(s,1)}),this.parameters[e]=n}this.persist()}clear(){this.ensureIsLoaded(),this.parameters={},this.persist()}persist(){try{q(this.container).indexOf(M)>-1?C(U,this.parameters,1):C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when persisting parameter bag.",e)}}ensureIsLoaded(){if(!this.isLoaded){try{const e=R(U);this.parameters=e||{},q(this.container).indexOf(M)===-1&&C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when loading parameter bag.",e)}this.isLoaded=!0}}}function E(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function X(){return E()+E()+"-"+E()+"-"+E()+"-"+E()+"-"+E()+E()+E()}const te="analytical",k="Humany__clientId";let T="";function ge(t){if(q(t).indexOf(te)===-1)return C(k,"",-1),T.length||(T=X()),T;const e=R(k);return e||(T.length||(T=X()),C(k,T,1)),e||T}function we(){return"Default"}function ve(...t){const e=window.location;return[t[0]!==!1?"http:":e.protocol,"//",e.host,e.pathname].join("")}function Pe(){}const Ee={"[object Array]":"array","[object Boolean]":"boolean","[object Date]":"date","[object Function]":"function","[object Number]":"number","[object Object]":"object","[object RegExp]":"regexp","[object String]":"string"};function B(t){return t==null?t+"":typeof t=="object"||typeof t=="function"?Ee[{}.toString.call(t)]||"object":typeof t}function f(t){return B(t)==="function"}function Q(t){let e;if(!t||B(t)!=="object"||t.nodeType)return!1;try{if(t.constructor&&!Object.prototype.hasOwnProperty.call(t,"constructor")&&!Object.prototype.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch{return!1}for(e in t);return e===void 0||Object.prototype.hasOwnProperty.call(t,e)}function l(...t){let e,r,n,o,s,a,c=t[0]||{},h=1;const i=t.length;let u=!1;for(typeof c=="boolean"&&(u=c,c=t[1]||{},h=2),typeof c!="object"&&!f(c)&&(c={});h<i;h++)if((e=t[h])!=null)for(r in e)n=c[r],o=e[r],c!==o&&(u&&o&&(Q(o)||(s=B(o)==="array"))?(s?(s=!1,a=n&&B(n)==="array"?n:[]):a=n&&Q(n)?n:{},c[r]=l(u,a,o)):o!==void 0&&(c[r]=o));return c}const R=t=>{const e=new RegExp(`(?:^|;)\\s?${t}=(.*?)(?:;|$)`,"i"),r=document.cookie.match(e),n=r&&r[1];if(n){if(t==="Humany__clientId")try{return JSON.parse(n)}catch{const s=JSON.stringify(n);return JSON.parse(s)}return JSON.parse(n)}},C=(t,e,r)=>{const n=JSON.stringify(e).trim().replace(/^"+|"+$/g,""),o=`${t}=${n}`,s=`expires=${Ce(r)}`,a="path=/",c="SameSite=None",h="Secure";return document.cookie=`${o}; ${s}; ${a}; ${c}; ${h}`},q=t=>{const e=["necessary"];if(!t)return e;const r=t.get("$widget");if(!r||!r.implementation||!r.implementation.tenant)return e;const{implementation:{tenant:n}}=r,o=R(`humany_${n}`);return!o||!o.storagePolicy||!o.storagePolicy.value||!Array.isArray(o.storagePolicy.value)||!o.storagePolicy.value.length?e:o.storagePolicy.value},Ce=(t=1)=>{const e=new Date;return e.setTime(e.getTime()+t*24*60*60*1e3),e.toUTCString()},Te=(t=["necessary"])=>{t.indexOf(M)===-1&&C(U,"",-1),t.indexOf(te)===-1&&C(k,"",-1)};function $(t,e,r){if(typeof e>"u"||typeof r>"u")return t;const n=t&&t.indexOf("?")!==-1?"&":"?";return`${t}${n}${encodeURIComponent(e)}=${encodeURIComponent(r)}`}const K="p.";function re(t,e){let r=t;return Object.keys(e).forEach(n=>{const o=e[n];B(o)==="array"?o.forEach(s=>{r=$(r,`${K}${n}`,s)}):r=$(r,`${K}${n}`,o)}),r}class W{constructor(e,r){l(!0,this,e,{_client:r})}}class H{constructor(e,r){l(!0,this,e,{_client:r})}}function A(t,e,r,n){const o=[];return t[e].forEach(s=>{const a=new r(s,n),c=s[e],h=B(c);s[e]&&(h==="array"||h==="object")&&(a[e]=A(s,e,r,n)),o.push(a)}),o}class F{constructor(e,r){l(!0,this,e,{_client:r})}}function x(t,e){return f(t)?e?t.call(e):t.call(window):t}function I(t,e,r,n){let o=Promise.resolve(r);for(let s=0,a=t.length;s<a;s++){const c=t[s][e];f(c)&&(o=o.then(()=>c(r,n)))}return o}class xe{constructor(e,r={}){this.setBaseUrl(e),this.globalOptions=r,this.interceptors=r.interceptors||[]}constructUrl(e){return this.baseUrl+e}setBaseUrl(e){this.baseUrl=e+(e[e.length-1]!=="/"?"/":"")}request(e,r){const n=l(!0,{},this.globalOptions,r);let o=this.constructUrl(e);const s=this.interceptors;return n.credentials==="include"&&(o=$(o,"credentials","true")),new Promise((a,c)=>{I(s,"request",{url:o,options:n}).then(h=>fetch(h.url,h.options).then(i=>({response:i,request:h}))).then(({response:h,request:i})=>{if(h.ok){const u=h;return h.json().then(w=>{I(s,"response",{response:h,json:w,request:i}).then(()=>{n.envelope?a({json:w,response:u}):a(w),I(s,"responseEnd",{response:h,json:w,request:i})})})}else I(s,"responseError",h).then(u=>{f(n.onError)&&n.onError(u),c(u)})}).catch(h=>{I(s,"responseError",h).then(i=>{f(n.onError)&&n.onError(i),c(i)})})})}}const ne=xe;/*!
|
|
3
3
|
* Humany Service Client Library
|
|
4
4
|
* Version: 2.0
|
|
@@ -2,13 +2,13 @@ var p = typeof globalThis < "u" && globalThis || typeof self < "u" && self || //
|
|
|
2
2
|
typeof global < "u" && global || {}, b = {
|
|
3
3
|
searchParams: "URLSearchParams" in p,
|
|
4
4
|
iterable: "Symbol" in p && "iterator" in Symbol,
|
|
5
|
-
blob: "FileReader" in p && "Blob" in p && function() {
|
|
5
|
+
blob: "FileReader" in p && "Blob" in p && (function() {
|
|
6
6
|
try {
|
|
7
7
|
return new Blob(), !0;
|
|
8
8
|
} catch {
|
|
9
9
|
return !1;
|
|
10
10
|
}
|
|
11
|
-
}(),
|
|
11
|
+
})(),
|
|
12
12
|
formData: "FormData" in p,
|
|
13
13
|
arrayBuffer: "ArrayBuffer" in p
|
|
14
14
|
};
|
|
@@ -195,12 +195,12 @@ function B(t, e) {
|
|
|
195
195
|
this.url = t.url, this.credentials = t.credentials, e.headers || (this.headers = new d(t.headers)), this.method = t.method, this.mode = t.mode, this.signal = t.signal, !r && t._bodyInit != null && (r = t._bodyInit, t.bodyUsed = !0);
|
|
196
196
|
} else
|
|
197
197
|
this.url = String(t);
|
|
198
|
-
if (this.credentials = e.credentials || this.credentials || "same-origin", (e.headers || !this.headers) && (this.headers = new d(e.headers)), this.method = he(e.method || this.method || "GET"), this.mode = e.mode || this.mode || null, this.signal = e.signal || this.signal || function() {
|
|
198
|
+
if (this.credentials = e.credentials || this.credentials || "same-origin", (e.headers || !this.headers) && (this.headers = new d(e.headers)), this.method = he(e.method || this.method || "GET"), this.mode = e.mode || this.mode || null, this.signal = e.signal || this.signal || (function() {
|
|
199
199
|
if ("AbortController" in p) {
|
|
200
200
|
var s = new AbortController();
|
|
201
201
|
return s.signal;
|
|
202
202
|
}
|
|
203
|
-
}(), this.referrer = null, (this.method === "GET" || this.method === "HEAD") && r)
|
|
203
|
+
})(), this.referrer = null, (this.method === "GET" || this.method === "HEAD") && r)
|
|
204
204
|
throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
205
205
|
if (this._initBody(r), (this.method === "GET" || this.method === "HEAD") && (e.cache === "no-store" || e.cache === "no-cache")) {
|
|
206
206
|
var n = /([?&])_=[^&]*/;
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-DDuNscXE.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}),v=(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=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: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(b=>b===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((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:i,NoticeLists:o}=e;return{contactMethods:(n||[]).map(r=>B(r)),categories:U(t||[]),topNotifications:v(i||[],"noticeRowTop"),middleNotifications:v(i||[],"noticeRowMiddle"),bottomNotifications:v(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:v(t||[],"noticeRowTop"),middleNotifications:v(t||[],"noticeRowMiddle"),bottomNotifications:v(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;
|
|
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-WiNloX2z.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}),v=(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=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: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(b=>b===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((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:i,NoticeLists:o}=e;return{contactMethods:(n||[]).map(r=>B(r)),categories:U(t||[]),topNotifications:v(i||[],"noticeRowTop"),middleNotifications:v(i||[],"noticeRowMiddle"),bottomNotifications:v(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:v(t||[],"noticeRowTop"),middleNotifications:v(t||[],"noticeRowMiddle"),bottomNotifications:v(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
|
@@ -242,7 +242,7 @@ z((s) => {
|
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
var q = /* @__PURE__ */ ((s) => (s.open = "open", s.closed = "closed", s.hidden = "hidden", s))(q || {});
|
|
245
|
-
const Q = (s) => import("./index-
|
|
245
|
+
const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
246
246
|
({ ServiceClient: e, ServiceProxy: t }) => s.get("settings").then((n) => {
|
|
247
247
|
const { name: i, events: o } = s.get("$widget"), {
|
|
248
248
|
data: { projection: c = "", site: r = "current", forceHttps: a = !1 }
|