@telia-ace/widget-utilities 0.0.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.
@@ -0,0 +1,6 @@
1
+ type ArgumentHandler = string | [boolean, string | string[]] | undefined;
2
+ export declare function uniqueClassArray(classNames: string[]): string[];
3
+ export declare function append(className1?: string, className2?: string): string;
4
+ export declare function handleFunctionArgument(expression: boolean, classes: string | string[]): string | undefined;
5
+ export default function appendClassNames(...args: ArgumentHandler[]): string;
6
+ export {};
package/batch.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export type BatchFunction<T> = (acc: T) => T;
2
+ export type Batch<T> = (fn: BatchFunction<T>) => Promise<T>;
3
+ declare const createBatch: <T>(delay: number, createFallback: () => T) => Batch<T>;
4
+ export default createBatch;
package/camilize.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function camilize(obj: any): any;
@@ -0,0 +1,15 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ type Item = {
4
+ id: string;
5
+ items?: Item[];
6
+ title: string;
7
+ symbol?: any;
8
+ };
9
+ type ChildParentStructure = {
10
+ [key: number]: string;
11
+ };
12
+ export declare function categoryTrail(id: string, items: Item[], ids?: string[], structure?: ChildParentStructure): string[];
13
+ export declare const getCategoryTrailAsObjects: (trail: string[], categories: Item[]) => Map<string, Item>;
14
+ export declare const buildCategoryTrail: (routeName: string, categoryIds: string | string[], container: Container, dataType?: 'guide-categories' | 'contact-method-categories') => Promise<any[]>;
15
+ export {};
@@ -0,0 +1,21 @@
1
+ export type Input = {
2
+ phrase?: string;
3
+ category?: ParamValue;
4
+ guideCategory?: ParamValue;
5
+ contactCategory?: ParamValue;
6
+ take?: number;
7
+ connectionKey?: string;
8
+ id?: string;
9
+ uriName?: string;
10
+ sorting?: string;
11
+ tag?: string | string[];
12
+ tagId?: string | number;
13
+ tagTitle?: string;
14
+ } & {
15
+ [key: string]: ParamValue;
16
+ };
17
+ export type ParamValue = string | number | any;
18
+ export type Params = {
19
+ [key: string]: ParamValue;
20
+ };
21
+ export default function createParams(args?: Input): Params;
@@ -0,0 +1,2 @@
1
+ declare const dataURItoBlob: (dataURI: string) => Blob;
2
+ export default dataURItoBlob;
package/debug.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Checks if process.env.NODE_ENV === 'production'
3
+ * and passes arguments to console.warn().
4
+ */
5
+ export declare function debugLog(...args: any[]): false | void;
6
+ /**
7
+ * Simple internal log-handler
8
+ */
9
+ export declare class Logger {
10
+ private keys;
11
+ private lookup;
12
+ /**
13
+ * Passes args to console.log
14
+ */
15
+ static log: (...args: any[]) => void;
16
+ /**
17
+ * Passes args to console.warn
18
+ */
19
+ static warn: (...args: any[]) => void;
20
+ /**
21
+ * Passes args to console.error
22
+ */
23
+ static error: (...args: any[]) => void;
24
+ /**
25
+ * Passes args to console.info
26
+ */
27
+ static info: (...args: any[]) => void;
28
+ /**
29
+ * Checks if key already has been logged.
30
+ * If not, passes following args to console.log
31
+ * and stores key in logged messages.
32
+ */
33
+ log: (key: string, ...args: any[]) => void;
34
+ /**
35
+ * Checks if key already has been logged.
36
+ * If not, passes following args to console.warn
37
+ * and stores key in logged messages.
38
+ */
39
+ warn: (key: string, ...args: any[]) => void;
40
+ /**
41
+ * Checks if key already has been logged.
42
+ * If not, passes following args to console.error
43
+ * and stores key in logged messages.
44
+ */
45
+ error: (key: string, ...args: any[]) => void;
46
+ /**
47
+ * Checks if key already has been logged.
48
+ * If not, passes following args to console.info
49
+ * and stores key in logged messages.
50
+ */
51
+ info: (key: string, ...args: any[]) => void;
52
+ }
@@ -0,0 +1,2 @@
1
+ declare const deepClone: <Type>(data: Type) => Type;
2
+ export default deepClone;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Looks for stored widgets on the implementation in localStorage
3
+ * and adds a trigger link to the DOM.
4
+ *
5
+ * TODO: A more robust version have been discussed, where the storageService is added to the
6
+ * implementation instead of the widget.
7
+ */
8
+ declare const _default: (implementation: any) => null | undefined;
9
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Find a category by it's ID
3
+ * @param id Id of category to find
4
+ */
5
+ declare const findCategoryById: (id: string, categories: any) => any;
6
+ export default findCategoryById;
@@ -0,0 +1,2 @@
1
+ declare const _default: (date: any, includeTime?: boolean) => string;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const formatUrl: (url: string) => string;
2
+ export default formatUrl;
@@ -0,0 +1 @@
1
+ export default function getCookie(cookieName: string): string | null;
package/hash.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (s: string): string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Checks whether or not the passed child is a descendant
3
+ * of the passed parent.
4
+ * Will return true if falsey parent or child.
5
+ */
6
+ declare const _default: (parent: HTMLElement | Window, child: Element | null) => boolean;
7
+ export default _default;
package/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ export { default as appendClassNames } from './append-class-names';
2
+ export { default as createBatch } from './batch';
3
+ export type { Batch, BatchFunction } from './batch';
4
+ export { default as camilize } from './camilize';
5
+ export { buildCategoryTrail, categoryTrail, getCategoryTrailAsObjects, } from './category-trail';
6
+ export { default as createParams } from './create-params';
7
+ export type { Params, ParamValue } from './create-params';
8
+ export { default as dataURItoBlob } from './data-uri-to-blob';
9
+ export { debugLog, Logger } from './debug';
10
+ export { default as deepClone } from './deep-clone';
11
+ export { default as findAndActivateStoredWidgets } from './find-and-activate-stored-widgets';
12
+ export { default as findCategoryById } from './find-category-by-id';
13
+ export { default as formatDate } from './format-date';
14
+ export { default as formatUrl } from './format-url';
15
+ export { default as getCookie } from './get-cookie';
16
+ export { default as hash } from './hash';
17
+ export { default as htmlParentContains } from './html-parent-contains';
18
+ export { default as kebabCase } from './kebab-case';
19
+ export { default as lock } from './lock';
20
+ export { default as mergeDeep } from './merge-deep';
21
+ export { default as notifyDataLoaded } from './notify-data-loaded';
22
+ export { default as removeNullAndUndefinedValues } from './remove-null-and-undefined-values';
23
+ export { default as setCookie } from './set-cookie';
24
+ export { default as shallowCompare } from './shallow-compare';
25
+ export { default as uuid } from './uuid';
26
+ export { default as WaitFor } from './wait-for';
27
+ export type { WaitForOptions } from './wait-for';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function W(o){const t=[];return o.forEach(e=>{t.indexOf(e)===-1&&t.push(e)}),t}function w(o="",t=""){const e=o.split(" ").concat(t.split(" "));return W(e).join(" ").trim()}function z(o,t){if(o){if(typeof t=="string")return t;if(Array.isArray(t)){let e="";return t.forEach(r=>e=w(e,r)),e}}}function I(...o){let t="";return o.length&&o.forEach(e=>{typeof e=="string"?t=w(t,e):Array.isArray(e)?t=w(t,z(...e)):typeof e<"u"&&e!==null&&process.env.NODE_ENV!=="production"&&x.warn("appendClassNames: arguments either haveto be a string or [boolean, ...string[]]. Passed args:",...o)}),t}const B=(o,t)=>{let e,r=[];return i=>(clearTimeout(e),new Promise((n,a)=>{r.push([i,n,a]),e=setTimeout(()=>{let f=t();r.forEach(([c,g,m])=>{f=c(f)}),r=[],n(f)},o)}))};function T(o){const t={};if(typeof o=="number"||typeof o=="string")return o;for(const e in o)if(o.hasOwnProperty(e)){const r=o[e],i=e.substring(0,1).toLowerCase()+e.substring(1);if(Object.prototype.toString.call(r)==="[object Array]"){t[i]=[];for(let n=0,a=r.length;n<a;n++)t[i].push(T(r[n]))}else r!==null&&typeof r=="object"?t[i]=T(r):t[i]=r}return t}function O(o={}){const{phrase:t="",category:e,guideCategory:r,contactCategory:i,take:n,connectionKey:a,accordion:f,id:c,uriName:g,sorting:m,tag:u,tagId:l,tagTitle:h,...D}=o,s={};return Object.keys(D).forEach(v=>{typeof o[v]=="string"&&(s[v]=o[v])}),typeof t=="string"&&t.length&&(s.phrase=t),t===null&&(s.phrase=t),typeof r=="string"&&r!=="0"&&(s.guideCategory=r),typeof r=="number"&&r!==0&&(s.guideCategory=r),typeof r=="object"&&r!==null&&(typeof r.id=="string"&&r.id!=="0"&&(s.guideCategory=r.id),typeof r.id=="number"&&r.id!==0&&(s.guideCategory=r.id)),typeof i=="string"&&i!=="0"&&(s.contactCategory=i),typeof i=="number"&&i!==0&&(s.contactCategory=i),typeof i=="object"&&i!==null&&(typeof i.id=="string"&&i.id!=="0"&&(s.contactCategory=i.id),typeof i.id=="number"&&i.id!==0&&(s.contactCategory=i.id)),typeof e=="string"&&e!=="0"&&(s.category=e),typeof e=="number"&&e!==0&&(s.category=e),typeof e=="object"&&e!==null&&(typeof e.id=="string"&&e.id!=="0"&&(s.category=e.id),typeof e.id=="number"&&e.id!==0&&(s.category=e.id)),c&&(s.id=c),g&&(+s.category||+s.guideCategory||+s.guide||+s.contactCategory||+s.contactMethod)&&(s.uriName=g),a&&(s.connectionKey=a),n&&(s.take=n),m&&(s.sorting=m),typeof f=="string"&&f.length>0&&(s.accordion=f),typeof u=="string"&&u!=="0"&&(s.tag=u),typeof u=="number"&&u!==0&&(s.tag=u),Array.isArray(u)&&u.length&&(s.tag=u),(typeof l=="string"||typeof l=="number")&&(s.tagId=l),typeof h=="string"&&(s.tagTitle=h),typeof s.tag=="string"&&(s.tag=s.tag.split(",")),s}function*N(o){if(o)for(let t=0;t<o.length;t++){const e=o[t];yield e,e.items&&(yield*N(e.items))}}const E=(o,t)=>{const e=N(t);let r=e.next(),i=null;for(;!r.done;)r.value.id===o&&(i=r.value),r=e.next();return i},$=o=>{if(!o)return"";const t=[{from:/[äæǽ]+/gi,to:"ae"},{from:/[öœ]+/gi,to:"oe"},{from:/[ü]+/gi,to:"ue"},{from:/[Ä]+/gi,to:"Ae"},{from:/[Ü]+/gi,to:"Ue"},{from:/[Ö]+/gi,to:"Oe"},{from:/[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi,to:"A"},{from:/[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi,to:"a"},{from:/[Б]+/gi,to:"B"},{from:/[б]+/gi,to:"b"},{from:/[ÇĆĈĊČ]+/gi,to:"C"},{from:/[çćĉċč]+/gi,to:"c"},{from:/[Д]+/gi,to:"D"},{from:/[д]+/gi,to:"d"},{from:/[ÐĎĐΔ]+/gi,to:"Dj"},{from:/[ðďđδ]+/gi,to:"dj"},{from:/[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi,to:"E"},{from:/[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi,to:"e"},{from:/[Ф]+/gi,to:"F"},{from:/[ф]+/gi,to:"f"},{from:/[ĜĞĠĢΓГҐ]+/gi,to:"G"},{from:/[ĝğġģγгґ]+/gi,to:"g"},{from:/[ĤĦ]+/gi,to:"H"},{from:/[ĥħ]+/gi,to:"h"},{from:/[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi,to:"I"},{from:/[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi,to:"i"},{from:/[Ĵ]+/gi,to:"J"},{from:/[ĵ]+/gi,to:"j"},{from:/[ĶΚК]+/gi,to:"K"},{from:/[ķκк]+/gi,to:"k"},{from:/[ĹĻĽĿŁΛЛ]+/gi,to:"L"},{from:/[ĺļľŀłλл]+/gi,to:"l"},{from:/[М]+/gi,to:"M"},{from:/[м]+/gi,to:"m"},{from:/[ÑŃŅŇΝН]+/gi,to:"N"},{from:/[ñńņňʼnνн]+/gi,to:"n"},{from:/[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi,to:"O"},{from:/[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi,to:"o"},{from:/[П]+/gi,to:"P"},{from:/[п]+/gi,to:"p"},{from:/[ŔŖŘΡР]+/gi,to:"R"},{from:/[ŕŗřρр]+/gi,to:"r"},{from:/[ŚŜŞȘŠΣС]+/gi,to:"S"},{from:/[śŝşșšſσςс]+/gi,to:"s"},{from:/[ȚŢŤŦτТ]+/gi,to:"T"},{from:/[țţťŧт]+/gi,to:"t"},{from:/[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi,to:"U"},{from:/[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi,to:"u"},{from:/[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi,to:"Y"},{from:/[ýÿŷỳỹỷỵй]+/gi,to:"y"},{from:/[В]+/gi,to:"V"},{from:/[в]+/gi,to:"v"},{from:/[Ŵ]+/gi,to:"W"},{from:/[ŵ]+/gi,to:"w"},{from:/[ŹŻŽΖЗ]+/gi,to:"Z"},{from:/[źżžζз]+/gi,to:"z"},{from:/[ÆǼ]+/gi,to:"AE"},{from:/[ß]+/gi,to:"ss"},{from:/[IJ]+/gi,to:"IJ"},{from:/[ij]+/gi,to:"ij"},{from:/[Œ]+/gi,to:"OE"},{from:/[ƒ]+/gi,to:"f"},{from:/[ξ]+/gi,to:"ks"},{from:/[π]+/gi,to:"p"},{from:/[β]+/gi,to:"v"},{from:/[μ]+/gi,to:"m"},{from:/[ψ]+/gi,to:"ps"},{from:/[Ё]+/gi,to:"Yo"},{from:/[ё]+/gi,to:"yo"},{from:/[Є]+/gi,to:"Ye"},{from:/[є]+/gi,to:"ye"},{from:/[Ї]+/gi,to:"Yi"},{from:/[Ж]+/gi,to:"Zh"},{from:/[ж]+/gi,to:"zh"},{from:/[Х]+/gi,to:"Kh"},{from:/[х]+/gi,to:"kh"},{from:/[Ц]+/gi,to:"Ts"},{from:/[ц]+/gi,to:"ts"},{from:/[Ч]+/gi,to:"Ch"},{from:/[ч]+/gi,to:"ch"},{from:/[Ш]+/gi,to:"Sh"},{from:/[ш]+/gi,to:"sh"},{from:/[Щ]+/gi,to:"Shch"},{from:/[щ]+/gi,to:"shch"},{from:/[ЪъЬь]+/gi,to:""},{from:/[Ю]+/gi,to:"Yu"},{from:/[ю]+/gi,to:"yu"},{from:/[Я]+/gi,to:"Ya"},{from:/[я]+/gi,to:"ya"}],e=/[^a-zA-Z0-9]+/g,r=/[-]$/;let i=o;for(const n in t)t.hasOwnProperty(n)&&t[n].from.test(o)&&(i=i.replace(t[n].from,t[n].to));return i=i.replace(e,"-"),i=i.replace(r,""),i=i.toLowerCase(),i||"humany"};function S(o,t={},e){return o.forEach(r=>{e&&(t[+r.id]=e),r.items&&S(r.items,t,r.id)}),t}function q(o,t,e=[o],r=S(t)){const i=a=>{const f=r[+a];f&&(e.unshift(f),i(f))},n=r[+o];return n&&(e.unshift(n),i(n)),e}const P=(o,t)=>typeof o>"u"||typeof t>"u"?new Map:new Map(o.map(e=>{const r=E(e,t);return[e,r]})),M=(o,t,e,r="guide-categories")=>e.getAsync("dataClient").then(i=>i.fetch(r,{expandCategories:"descendants"}).then(({categories:n})=>{const a=f=>{const c=q(f,n),g=P(c,n),m=[];return c.forEach(u=>{const l=g.get(u);l&&m.push({routeName:o,title:l.title,symbol:l.symbol,id:l.id,routeParams:O(r==="contact-method-categories"?{contactCategory:l.id,uriName:$(l.title)}:{guideCategory:l.id,uriName:$(l.title)})})}),m};return Array.isArray(t)?t.reduce((f,c)=>{const g=a(c);return g.length>0&&f.push(g),f},[]):a(t)})),U=o=>{let t;o.split(",")[0].indexOf("base64")!==-1?t=atob(o.split(",")[1]):t=decodeURI(o.split(",")[1]);const e=o.split(",")[0].split(":")[1].split(";")[0],r=[];for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new Blob([new Uint8Array(r)],{type:e})};function V(...o){return process.env.NODE_ENV!=="production"&&console&&console.warn(...o)}const A=(o,t,...e)=>typeof t=="string"?o(`[humany] ${t}`,...e):o(t,...e),y=class p{constructor(){this.keys=[],this.log=(t,...e)=>this.lookup(t,()=>p.log(...e)),this.warn=(t,...e)=>this.lookup(t,()=>p.warn(...e)),this.error=(t,...e)=>this.lookup(t,()=>p.error(...e)),this.info=(t,...e)=>this.lookup(t,()=>p.info(...e))}lookup(t,e){this.keys.indexOf(t)===-1&&(this.keys.push(t),e())}};y.log=(...o)=>A(console.log,...o);y.warn=(...o)=>A(console.warn,...o);y.error=(...o)=>A(console.error,...o);y.info=(...o)=>A(console.info,...o);let x=y;const C=o=>{let t={},e,r;if(typeof o!="object"||o===null)return o;t=Array.isArray(o)?[]:{};for(r in o)e=o[r],t[r]=typeof e=="object"&&e!==null?C(e):e;return t},F=o=>{var e;if(!o)return null;const t=localStorage.getItem(`humany_${L(o.tenant+o.name)}`);if(t){const{activeStickyWidget:r}=JSON.parse(t);if(r&&r.value){const i=o.widgets.get(r.value);if(i)if(r.value.endsWith("_contact-method")){const n=o.widgets.get(r.value.slice(0,-7));(e=n==null?void 0:n.events)==null||e.subscribe("widget:attached",()=>{i.activate(),i.invoke("attach"),i.invoke("open")})}else{const n=document.createElement("a");n.setAttribute("href",`//${o.bindings[0]}/${r.value}`),document.body.appendChild(n)}}}},Y=(o,t=!1)=>{const e=new Date(o);let r=`${e.getMonth()+1}`,i=`${e.getDate()}`;const n=e.getFullYear();if(r.length<2&&(r=`0${r}`),i.length<2&&(i=`0${i}`),t){let a=`${e.getHours()}`,f=`${e.getMinutes()}`;return a.length<2&&(a=`0${a}`),f.length<2&&(f=`0${f}`),`${[n,r,i].join("-")} ${[a,f].join(":")}`}return[n,r,i].join("-")};function K(o){const t=document.cookie;if(t.length>0){let e=t.indexOf(`${o}=`);if(e!==-1){e=e+o.length+1;let r=t.indexOf(";",e);return r===-1&&(r=t.length),unescape(t.substring(e,r))}}return null}function L(o){let t=0;if(o.length===0)return t.toString();for(let e=0;e<o.length;e++){const r=o.charCodeAt(e);t=(t<<5)-t+r,t=t&t}return t.toString()}const Z=(o,t)=>{if(!o||!t)return!0;let e=t.parentNode,r=!1;for(;e!==null;)e===o&&(r=!0),e=e.parentNode;return r};function _(o){return o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase()}class J{constructor(t,e){this.lockWarningTime=t,this.lockErrorTime=e,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(t,e,r,i){this.tasks.push({task:t,resolve:e,reject:r,done:i}),this.next()}next(){this.current=this.current.then(()=>{const t=this.tasks.shift();if(t){let e;const r=setTimeout(()=>{process.env.NODE_ENV!=="production"&&x.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,t),e=setTimeout(()=>{t.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),i=Promise.resolve(t.task()).then(n=>(clearTimeout(r),clearTimeout(e),n));return Promise.resolve(i).then(this.next).then(()=>i.then(n=>{t.done(),t.resolve(n)})).catch(n=>(t.done(),t.reject(n),this.next()))}return Promise.resolve()})}}const b=new WeakMap;function Q(o,t=5e3,e=1e3){return b.has(o)||b.set(o,new J(t,e)),r=>new Promise((i,n)=>{const a=b.get(o);a.add(r,i,n,()=>{a.tasks.length||b.delete(o)})})}const k=o=>!!o&&typeof o=="object"&&!Array.isArray(o),H=(o,...t)=>{const e=C(o),r=C(t);return j(e,...r)},j=(o,...t)=>{if(!t.length)return o;const e=t.shift();if(k(o)&&k(e))for(const r in e)k(e[r])?(o[r]||Object.assign(o,{[r]:{}}),j(o[r],e[r])):Object.assign(o,{[r]:e[r]});return j(o,...t)},R=(o,t)=>{const e=()=>t.querySelectorAll("[data-loading=true]").length>0,i=(()=>{let a=!1;return()=>{if(a)return;o.get("$widget").events.dispatch("widget:data-loaded",{element:t}),a=!0}})();if(!e())return i();new MutationObserver((a,f)=>{a.find(g=>g.type==="attributes"&&g.attributeName==="data-loading")&&!e()&&(f.disconnect(),i())}).observe(t,{attributes:!0,childList:!0,subtree:!0})},G=(o,t)=>{o.get("$widget").container.getAsync("components").then(r=>{r.events.subscribeOnce("components:component-model-initialized",()=>{let i=r.nodes.visible.reduce((f,c)=>(!c.name||!c.type||c.type==="view"||c.type==="root"||c.attributes.layout.size==="none"||t.querySelector(`[data-name="${c.name}"]`)||f.push(c.name),f),[]),n=!1;new MutationObserver((f,c)=>{f.forEach(g=>{if(g.addedNodes){const m=Array.from(g.addedNodes).reduce((u,l)=>{const h=l.getAttribute&&l.getAttribute("data-name");return h&&i.indexOf(h)>-1&&u.push(h),u},[]);i=i.filter(u=>m.indexOf(u)===-1),!n&&i.length===0&&(n=!0,R(o,t),c.disconnect())}})}).observe(t,{attributes:!1,characterData:!1,childList:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1})})})},X=(o={})=>(Object.keys(o).forEach(t=>{(o[t]===null||typeof o[t]>"u")&&delete o[t]}),o);function tt(o,t,e){let r="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),r=`; expires=${i.toUTCString()}`}document.cookie=`${o}=${t}${r}; path=/`}const et=(o,t)=>{let e=!0;return Object.keys(o).length!==Object.keys(t).length||Object.keys(o).some(i=>!Object.keys(t).some(a=>i===a))?!1:(Object.keys(o).forEach(i=>{if(e){const n=typeof o[i]>"u"?"":o[i],a=typeof t[i]>"u"?"":t[i];e=n.toString()===a.toString()}}),e)},d=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);function ot(){return d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()}class rt{constructor(t){this.queue=[],this.queueAttemptCalls=0,this.callCount=5,this.add=e=>{this.queue.push(e),this.queueAttempt=setInterval(this.processQueue,1e3)},this.processQueue=()=>{if(this.queue.length>0){const e=[];this.queue.forEach((r,i)=>{const n=r();typeof n=="function"&&(n(),e.push(i))}),this.queue=this.queue.filter((r,i)=>!(e.indexOf(i)>-1)),this.queueAttempt&&clearInterval(this.queueAttempt)}this.queueAttemptCalls>this.callCount&&(clearInterval(this.queueAttempt),this.queueAttemptCalls=0),this.queueAttemptCalls=this.queueAttemptCalls+1},t&&t.callCount&&(this.callCount=t.callCount)}}exports.Logger=x;exports.WaitFor=rt;exports.appendClassNames=I;exports.buildCategoryTrail=M;exports.camilize=T;exports.categoryTrail=q;exports.createBatch=B;exports.createParams=O;exports.dataURItoBlob=U;exports.debugLog=V;exports.deepClone=C;exports.findAndActivateStoredWidgets=F;exports.findCategoryById=E;exports.formatDate=Y;exports.formatUrl=$;exports.getCategoryTrailAsObjects=P;exports.getCookie=K;exports.hash=L;exports.htmlParentContains=Z;exports.kebabCase=_;exports.lock=Q;exports.mergeDeep=H;exports.notifyDataLoaded=G;exports.removeNullAndUndefinedValues=X;exports.setCookie=tt;exports.shallowCompare=et;exports.uuid=ot;
package/index.mjs ADDED
@@ -0,0 +1,505 @@
1
+ function S(o) {
2
+ const t = [];
3
+ return o.forEach((e) => {
4
+ t.indexOf(e) === -1 && t.push(e);
5
+ }), t;
6
+ }
7
+ function k(o = "", t = "") {
8
+ const e = o.split(" ").concat(t.split(" "));
9
+ return S(e).join(" ").trim();
10
+ }
11
+ function P(o, t) {
12
+ if (o) {
13
+ if (typeof t == "string")
14
+ return t;
15
+ if (Array.isArray(t)) {
16
+ let e = "";
17
+ return t.forEach((r) => e = k(e, r)), e;
18
+ }
19
+ }
20
+ }
21
+ function V(...o) {
22
+ let t = "";
23
+ return o.length && o.forEach((e) => {
24
+ typeof e == "string" ? t = k(t, e) : Array.isArray(e) ? t = k(t, P(...e)) : typeof e < "u" && e !== null && process.env.NODE_ENV !== "production" && N.warn(
25
+ "appendClassNames: arguments either haveto be a string or [boolean, ...string[]]. Passed args:",
26
+ ...o
27
+ );
28
+ }), t;
29
+ }
30
+ const Y = (o, t) => {
31
+ let e, r = [];
32
+ return (i) => (clearTimeout(e), new Promise((n, c) => {
33
+ r.push([i, n, c]), e = setTimeout(() => {
34
+ let f = t();
35
+ r.forEach(([a, g, m]) => {
36
+ f = a(f);
37
+ }), r = [], n(f);
38
+ }, o);
39
+ }));
40
+ };
41
+ function $(o) {
42
+ const t = {};
43
+ if (typeof o == "number" || typeof o == "string")
44
+ return o;
45
+ for (const e in o)
46
+ if (o.hasOwnProperty(e)) {
47
+ const r = o[e], i = e.substring(0, 1).toLowerCase() + e.substring(1);
48
+ if (Object.prototype.toString.call(r) === "[object Array]") {
49
+ t[i] = [];
50
+ for (let n = 0, c = r.length; n < c; n++)
51
+ t[i].push($(r[n]));
52
+ } else
53
+ r !== null && typeof r == "object" ? t[i] = $(r) : t[i] = r;
54
+ }
55
+ return t;
56
+ }
57
+ function x(o = {}) {
58
+ const {
59
+ phrase: t = "",
60
+ category: e,
61
+ guideCategory: r,
62
+ contactCategory: i,
63
+ take: n,
64
+ connectionKey: c,
65
+ accordion: f,
66
+ id: a,
67
+ uriName: g,
68
+ sorting: m,
69
+ tag: u,
70
+ tagId: l,
71
+ tagTitle: d,
72
+ ...q
73
+ } = o, s = {};
74
+ return Object.keys(q).forEach((A) => {
75
+ typeof o[A] == "string" && (s[A] = o[A]);
76
+ }), typeof t == "string" && t.length && (s.phrase = t), t === null && (s.phrase = t), typeof r == "string" && r !== "0" && (s.guideCategory = r), typeof r == "number" && r !== 0 && (s.guideCategory = r), typeof r == "object" && r !== null && (typeof r.id == "string" && r.id !== "0" && (s.guideCategory = r.id), typeof r.id == "number" && r.id !== 0 && (s.guideCategory = r.id)), typeof i == "string" && i !== "0" && (s.contactCategory = i), typeof i == "number" && i !== 0 && (s.contactCategory = i), typeof i == "object" && i !== null && (typeof i.id == "string" && i.id !== "0" && (s.contactCategory = i.id), typeof i.id == "number" && i.id !== 0 && (s.contactCategory = i.id)), typeof e == "string" && e !== "0" && (s.category = e), typeof e == "number" && e !== 0 && (s.category = e), typeof e == "object" && e !== null && (typeof e.id == "string" && e.id !== "0" && (s.category = e.id), typeof e.id == "number" && e.id !== 0 && (s.category = e.id)), a && (s.id = a), g && (+s.category || +s.guideCategory || +s.guide || +s.contactCategory || +s.contactMethod) && (s.uriName = g), c && (s.connectionKey = c), n && (s.take = n), m && (s.sorting = m), typeof f == "string" && f.length > 0 && (s.accordion = f), typeof u == "string" && u !== "0" && (s.tag = u), typeof u == "number" && u !== 0 && (s.tag = u), Array.isArray(u) && u.length && (s.tag = u), (typeof l == "string" || typeof l == "number") && (s.tagId = l), typeof d == "string" && (s.tagTitle = d), typeof s.tag == "string" && (s.tag = s.tag.split(",")), s;
77
+ }
78
+ function* E(o) {
79
+ if (o)
80
+ for (let t = 0; t < o.length; t++) {
81
+ const e = o[t];
82
+ yield e, e.items && (yield* E(e.items));
83
+ }
84
+ }
85
+ const L = (o, t) => {
86
+ const e = E(t);
87
+ let r = e.next(), i = null;
88
+ for (; !r.done; )
89
+ r.value.id === o && (i = r.value), r = e.next();
90
+ return i;
91
+ }, T = (o) => {
92
+ if (!o)
93
+ return "";
94
+ const t = [
95
+ { from: /[äæǽ]+/gi, to: "ae" },
96
+ { from: /[öœ]+/gi, to: "oe" },
97
+ { from: /[ü]+/gi, to: "ue" },
98
+ { from: /[Ä]+/gi, to: "Ae" },
99
+ { from: /[Ü]+/gi, to: "Ue" },
100
+ { from: /[Ö]+/gi, to: "Oe" },
101
+ { from: /[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi, to: "A" },
102
+ { from: /[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi, to: "a" },
103
+ { from: /[Б]+/gi, to: "B" },
104
+ { from: /[б]+/gi, to: "b" },
105
+ { from: /[ÇĆĈĊČ]+/gi, to: "C" },
106
+ { from: /[çćĉċč]+/gi, to: "c" },
107
+ { from: /[Д]+/gi, to: "D" },
108
+ { from: /[д]+/gi, to: "d" },
109
+ { from: /[ÐĎĐΔ]+/gi, to: "Dj" },
110
+ { from: /[ðďđδ]+/gi, to: "dj" },
111
+ { from: /[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi, to: "E" },
112
+ { from: /[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi, to: "e" },
113
+ { from: /[Ф]+/gi, to: "F" },
114
+ { from: /[ф]+/gi, to: "f" },
115
+ { from: /[ĜĞĠĢΓГҐ]+/gi, to: "G" },
116
+ { from: /[ĝğġģγгґ]+/gi, to: "g" },
117
+ { from: /[ĤĦ]+/gi, to: "H" },
118
+ { from: /[ĥħ]+/gi, to: "h" },
119
+ { from: /[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi, to: "I" },
120
+ { from: /[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi, to: "i" },
121
+ { from: /[Ĵ]+/gi, to: "J" },
122
+ { from: /[ĵ]+/gi, to: "j" },
123
+ { from: /[ĶΚК]+/gi, to: "K" },
124
+ { from: /[ķκк]+/gi, to: "k" },
125
+ { from: /[ĹĻĽĿŁΛЛ]+/gi, to: "L" },
126
+ { from: /[ĺļľŀłλл]+/gi, to: "l" },
127
+ { from: /[М]+/gi, to: "M" },
128
+ { from: /[м]+/gi, to: "m" },
129
+ { from: /[ÑŃŅŇΝН]+/gi, to: "N" },
130
+ { from: /[ñńņňʼnνн]+/gi, to: "n" },
131
+ { from: /[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi, to: "O" },
132
+ { from: /[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi, to: "o" },
133
+ { from: /[П]+/gi, to: "P" },
134
+ { from: /[п]+/gi, to: "p" },
135
+ { from: /[ŔŖŘΡР]+/gi, to: "R" },
136
+ { from: /[ŕŗřρр]+/gi, to: "r" },
137
+ { from: /[ŚŜŞȘŠΣС]+/gi, to: "S" },
138
+ { from: /[śŝşșšſσςс]+/gi, to: "s" },
139
+ { from: /[ȚŢŤŦτТ]+/gi, to: "T" },
140
+ { from: /[țţťŧт]+/gi, to: "t" },
141
+ { from: /[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi, to: "U" },
142
+ { from: /[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi, to: "u" },
143
+ { from: /[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi, to: "Y" },
144
+ { from: /[ýÿŷỳỹỷỵй]+/gi, to: "y" },
145
+ { from: /[В]+/gi, to: "V" },
146
+ { from: /[в]+/gi, to: "v" },
147
+ { from: /[Ŵ]+/gi, to: "W" },
148
+ { from: /[ŵ]+/gi, to: "w" },
149
+ { from: /[ŹŻŽΖЗ]+/gi, to: "Z" },
150
+ { from: /[źżžζз]+/gi, to: "z" },
151
+ { from: /[ÆǼ]+/gi, to: "AE" },
152
+ { from: /[ß]+/gi, to: "ss" },
153
+ { from: /[IJ]+/gi, to: "IJ" },
154
+ { from: /[ij]+/gi, to: "ij" },
155
+ { from: /[Œ]+/gi, to: "OE" },
156
+ { from: /[ƒ]+/gi, to: "f" },
157
+ { from: /[ξ]+/gi, to: "ks" },
158
+ { from: /[π]+/gi, to: "p" },
159
+ { from: /[β]+/gi, to: "v" },
160
+ { from: /[μ]+/gi, to: "m" },
161
+ { from: /[ψ]+/gi, to: "ps" },
162
+ { from: /[Ё]+/gi, to: "Yo" },
163
+ { from: /[ё]+/gi, to: "yo" },
164
+ { from: /[Є]+/gi, to: "Ye" },
165
+ { from: /[є]+/gi, to: "ye" },
166
+ { from: /[Ї]+/gi, to: "Yi" },
167
+ { from: /[Ж]+/gi, to: "Zh" },
168
+ { from: /[ж]+/gi, to: "zh" },
169
+ { from: /[Х]+/gi, to: "Kh" },
170
+ { from: /[х]+/gi, to: "kh" },
171
+ { from: /[Ц]+/gi, to: "Ts" },
172
+ { from: /[ц]+/gi, to: "ts" },
173
+ { from: /[Ч]+/gi, to: "Ch" },
174
+ { from: /[ч]+/gi, to: "ch" },
175
+ { from: /[Ш]+/gi, to: "Sh" },
176
+ { from: /[ш]+/gi, to: "sh" },
177
+ { from: /[Щ]+/gi, to: "Shch" },
178
+ { from: /[щ]+/gi, to: "shch" },
179
+ { from: /[ЪъЬь]+/gi, to: "" },
180
+ { from: /[Ю]+/gi, to: "Yu" },
181
+ { from: /[ю]+/gi, to: "yu" },
182
+ { from: /[Я]+/gi, to: "Ya" },
183
+ { from: /[я]+/gi, to: "ya" }
184
+ ], e = /[^a-zA-Z0-9]+/g, r = /[-]$/;
185
+ let i = o;
186
+ for (const n in t)
187
+ t.hasOwnProperty(n) && t[n].from.test(o) && (i = i.replace(t[n].from, t[n].to));
188
+ return i = i.replace(e, "-"), i = i.replace(r, ""), i = i.toLowerCase(), i || "humany";
189
+ };
190
+ function j(o, t = {}, e) {
191
+ return o.forEach((r) => {
192
+ e && (t[+r.id] = e), r.items && j(r.items, t, r.id);
193
+ }), t;
194
+ }
195
+ function D(o, t, e = [o], r = j(t)) {
196
+ const i = (c) => {
197
+ const f = r[+c];
198
+ f && (e.unshift(f), i(f));
199
+ }, n = r[+o];
200
+ return n && (e.unshift(n), i(n)), e;
201
+ }
202
+ const z = (o, t) => typeof o > "u" || typeof t > "u" ? /* @__PURE__ */ new Map() : new Map(
203
+ o.map((e) => {
204
+ const r = L(e, t);
205
+ return [e, r];
206
+ })
207
+ ), F = (o, t, e, r = "guide-categories") => e.getAsync("dataClient").then((i) => i.fetch(r, { expandCategories: "descendants" }).then(({ categories: n }) => {
208
+ const c = (f) => {
209
+ const a = D(f, n), g = z(a, n), m = [];
210
+ return a.forEach((u) => {
211
+ const l = g.get(u);
212
+ l && m.push({
213
+ routeName: o,
214
+ title: l.title,
215
+ symbol: l.symbol,
216
+ id: l.id,
217
+ routeParams: x(r === "contact-method-categories" ? {
218
+ contactCategory: l.id,
219
+ uriName: T(l.title)
220
+ } : {
221
+ guideCategory: l.id,
222
+ uriName: T(l.title)
223
+ })
224
+ });
225
+ }), m;
226
+ };
227
+ return Array.isArray(t) ? t.reduce((f, a) => {
228
+ const g = c(a);
229
+ return g.length > 0 && f.push(g), f;
230
+ }, []) : c(t);
231
+ })), K = (o) => {
232
+ let t;
233
+ o.split(",")[0].indexOf("base64") !== -1 ? t = atob(o.split(",")[1]) : t = decodeURI(o.split(",")[1]);
234
+ const e = o.split(",")[0].split(":")[1].split(";")[0], r = [];
235
+ for (let i = 0; i < t.length; i++)
236
+ r[i] = t.charCodeAt(i);
237
+ return new Blob([new Uint8Array(r)], { type: e });
238
+ };
239
+ function B(...o) {
240
+ return process.env.NODE_ENV !== "production" && console && console.warn(...o);
241
+ }
242
+ const C = (o, t, ...e) => typeof t == "string" ? o(`[humany] ${t}`, ...e) : o(t, ...e), y = class p {
243
+ constructor() {
244
+ this.keys = [], this.log = (t, ...e) => this.lookup(t, () => p.log(...e)), this.warn = (t, ...e) => this.lookup(t, () => p.warn(...e)), this.error = (t, ...e) => this.lookup(t, () => p.error(...e)), this.info = (t, ...e) => this.lookup(t, () => p.info(...e));
245
+ }
246
+ lookup(t, e) {
247
+ this.keys.indexOf(t) === -1 && (this.keys.push(t), e());
248
+ }
249
+ };
250
+ y.log = (...o) => C(console.log, ...o);
251
+ y.warn = (...o) => C(console.warn, ...o);
252
+ y.error = (...o) => C(console.error, ...o);
253
+ y.info = (...o) => C(console.info, ...o);
254
+ let N = y;
255
+ const w = (o) => {
256
+ let t = {}, e, r;
257
+ if (typeof o != "object" || o === null)
258
+ return o;
259
+ t = Array.isArray(o) ? [] : {};
260
+ for (r in o)
261
+ e = o[r], t[r] = typeof e == "object" && e !== null ? w(e) : e;
262
+ return t;
263
+ }, U = (o) => {
264
+ var e;
265
+ if (!o)
266
+ return null;
267
+ const t = localStorage.getItem(
268
+ `humany_${W(o.tenant + o.name)}`
269
+ );
270
+ if (t) {
271
+ const { activeStickyWidget: r } = JSON.parse(t);
272
+ if (r && r.value) {
273
+ const i = o.widgets.get(r.value);
274
+ if (i)
275
+ if (r.value.endsWith("_contact-method")) {
276
+ const n = o.widgets.get(
277
+ r.value.slice(0, -7)
278
+ );
279
+ (e = n == null ? void 0 : n.events) == null || e.subscribe("widget:attached", () => {
280
+ i.activate(), i.invoke("attach"), i.invoke("open");
281
+ });
282
+ } else {
283
+ const n = document.createElement("a");
284
+ n.setAttribute(
285
+ "href",
286
+ `//${o.bindings[0]}/${r.value}`
287
+ ), document.body.appendChild(n);
288
+ }
289
+ }
290
+ }
291
+ }, Z = (o, t = !1) => {
292
+ const e = new Date(o);
293
+ let r = `${e.getMonth() + 1}`, i = `${e.getDate()}`;
294
+ const n = e.getFullYear();
295
+ if (r.length < 2 && (r = `0${r}`), i.length < 2 && (i = `0${i}`), t) {
296
+ let c = `${e.getHours()}`, f = `${e.getMinutes()}`;
297
+ return c.length < 2 && (c = `0${c}`), f.length < 2 && (f = `0${f}`), `${[n, r, i].join("-")} ${[c, f].join(":")}`;
298
+ }
299
+ return [n, r, i].join("-");
300
+ };
301
+ function _(o) {
302
+ const t = document.cookie;
303
+ if (t.length > 0) {
304
+ let e = t.indexOf(`${o}=`);
305
+ if (e !== -1) {
306
+ e = e + o.length + 1;
307
+ let r = t.indexOf(";", e);
308
+ return r === -1 && (r = t.length), unescape(t.substring(e, r));
309
+ }
310
+ }
311
+ return null;
312
+ }
313
+ function W(o) {
314
+ let t = 0;
315
+ if (o.length === 0)
316
+ return t.toString();
317
+ for (let e = 0; e < o.length; e++) {
318
+ const r = o.charCodeAt(e);
319
+ t = (t << 5) - t + r, t = t & t;
320
+ }
321
+ return t.toString();
322
+ }
323
+ const J = (o, t) => {
324
+ if (!o || !t)
325
+ return !0;
326
+ let e = t.parentNode, r = !1;
327
+ for (; e !== null; )
328
+ e === o && (r = !0), e = e.parentNode;
329
+ return r;
330
+ };
331
+ function Q(o) {
332
+ return o.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\s+/g, "-").toLowerCase();
333
+ }
334
+ class I {
335
+ constructor(t, e) {
336
+ this.lockWarningTime = t, this.lockErrorTime = e, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
337
+ }
338
+ add(t, e, r, i) {
339
+ this.tasks.push({ task: t, resolve: e, reject: r, done: i }), this.next();
340
+ }
341
+ next() {
342
+ this.current = this.current.then(() => {
343
+ const t = this.tasks.shift();
344
+ if (t) {
345
+ let e;
346
+ const r = setTimeout(() => {
347
+ process.env.NODE_ENV !== "production" && N.warn(
348
+ `A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
349
+ t
350
+ ), e = setTimeout(() => {
351
+ t.reject("lock timeout exceeded");
352
+ }, this.lockErrorTime);
353
+ }, this.lockWarningTime), i = Promise.resolve(t.task()).then((n) => (clearTimeout(r), clearTimeout(e), n));
354
+ return Promise.resolve(i).then(this.next).then(
355
+ () => i.then((n) => {
356
+ t.done(), t.resolve(n);
357
+ })
358
+ ).catch((n) => (t.done(), t.reject(n), this.next()));
359
+ }
360
+ return Promise.resolve();
361
+ });
362
+ }
363
+ }
364
+ const b = /* @__PURE__ */ new WeakMap();
365
+ function H(o, t = 5e3, e = 1e3) {
366
+ return b.has(o) || b.set(o, new I(t, e)), (r) => new Promise((i, n) => {
367
+ const c = b.get(o);
368
+ c.add(r, i, n, () => {
369
+ c.tasks.length || b.delete(o);
370
+ });
371
+ });
372
+ }
373
+ const v = (o) => !!o && typeof o == "object" && !Array.isArray(o), G = (o, ...t) => {
374
+ const e = w(o), r = w(t);
375
+ return O(e, ...r);
376
+ }, O = (o, ...t) => {
377
+ if (!t.length)
378
+ return o;
379
+ const e = t.shift();
380
+ if (v(o) && v(e))
381
+ for (const r in e)
382
+ v(e[r]) ? (o[r] || Object.assign(o, { [r]: {} }), O(o[r], e[r])) : Object.assign(o, { [r]: e[r] });
383
+ return O(o, ...t);
384
+ }, M = (o, t) => {
385
+ const e = () => t.querySelectorAll("[data-loading=true]").length > 0, i = (() => {
386
+ let c = !1;
387
+ return () => {
388
+ if (c)
389
+ return;
390
+ o.get("$widget").events.dispatch("widget:data-loaded", {
391
+ element: t
392
+ }), c = !0;
393
+ };
394
+ })();
395
+ if (!e())
396
+ return i();
397
+ new MutationObserver((c, f) => {
398
+ c.find(
399
+ (g) => g.type === "attributes" && g.attributeName === "data-loading"
400
+ ) && !e() && (f.disconnect(), i());
401
+ }).observe(t, {
402
+ attributes: !0,
403
+ childList: !0,
404
+ subtree: !0
405
+ });
406
+ }, R = (o, t) => {
407
+ o.get("$widget").container.getAsync("components").then((r) => {
408
+ r.events.subscribeOnce(
409
+ "components:component-model-initialized",
410
+ () => {
411
+ let i = r.nodes.visible.reduce(
412
+ (f, a) => (!a.name || !a.type || a.type === "view" || a.type === "root" || a.attributes.layout.size === "none" || t.querySelector(`[data-name="${a.name}"]`) || f.push(a.name), f),
413
+ []
414
+ ), n = !1;
415
+ new MutationObserver((f, a) => {
416
+ f.forEach((g) => {
417
+ if (g.addedNodes) {
418
+ const m = Array.from(
419
+ g.addedNodes
420
+ ).reduce((u, l) => {
421
+ const d = l.getAttribute && l.getAttribute("data-name");
422
+ return d && i.indexOf(d) > -1 && u.push(d), u;
423
+ }, []);
424
+ i = i.filter((u) => m.indexOf(u) === -1), !n && i.length === 0 && (n = !0, M(o, t), a.disconnect());
425
+ }
426
+ });
427
+ }).observe(t, {
428
+ attributes: !1,
429
+ characterData: !1,
430
+ childList: !0,
431
+ subtree: !0,
432
+ attributeOldValue: !1,
433
+ characterDataOldValue: !1
434
+ });
435
+ }
436
+ );
437
+ });
438
+ }, X = (o = {}) => (Object.keys(o).forEach((t) => {
439
+ (o[t] === null || typeof o[t] > "u") && delete o[t];
440
+ }), o);
441
+ function tt(o, t, e) {
442
+ let r = "";
443
+ if (e) {
444
+ const i = /* @__PURE__ */ new Date();
445
+ i.setTime(i.getTime() + e * 24 * 60 * 60 * 1e3), r = `; expires=${i.toUTCString()}`;
446
+ }
447
+ document.cookie = `${o}=${t}${r}; path=/`;
448
+ }
449
+ const et = (o, t) => {
450
+ let e = !0;
451
+ return Object.keys(o).length !== Object.keys(t).length || Object.keys(o).some((i) => !Object.keys(t).some((c) => i === c)) ? !1 : (Object.keys(o).forEach((i) => {
452
+ if (e) {
453
+ const n = typeof o[i] > "u" ? "" : o[i], c = typeof t[i] > "u" ? "" : t[i];
454
+ e = n.toString() === c.toString();
455
+ }
456
+ }), e);
457
+ }, h = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
458
+ function ot() {
459
+ return h() + h() + "-" + h() + "-" + h() + "-" + h() + "-" + h() + h() + h();
460
+ }
461
+ class rt {
462
+ constructor(t) {
463
+ this.queue = [], this.queueAttemptCalls = 0, this.callCount = 5, this.add = (e) => {
464
+ this.queue.push(e), this.queueAttempt = setInterval(this.processQueue, 1e3);
465
+ }, this.processQueue = () => {
466
+ if (this.queue.length > 0) {
467
+ const e = [];
468
+ this.queue.forEach((r, i) => {
469
+ const n = r();
470
+ typeof n == "function" && (n(), e.push(i));
471
+ }), this.queue = this.queue.filter((r, i) => !(e.indexOf(i) > -1)), this.queueAttempt && clearInterval(this.queueAttempt);
472
+ }
473
+ this.queueAttemptCalls > this.callCount && (clearInterval(this.queueAttempt), this.queueAttemptCalls = 0), this.queueAttemptCalls = this.queueAttemptCalls + 1;
474
+ }, t && t.callCount && (this.callCount = t.callCount);
475
+ }
476
+ }
477
+ export {
478
+ N as Logger,
479
+ rt as WaitFor,
480
+ V as appendClassNames,
481
+ F as buildCategoryTrail,
482
+ $ as camilize,
483
+ D as categoryTrail,
484
+ Y as createBatch,
485
+ x as createParams,
486
+ K as dataURItoBlob,
487
+ B as debugLog,
488
+ w as deepClone,
489
+ U as findAndActivateStoredWidgets,
490
+ L as findCategoryById,
491
+ Z as formatDate,
492
+ T as formatUrl,
493
+ z as getCategoryTrailAsObjects,
494
+ _ as getCookie,
495
+ W as hash,
496
+ J as htmlParentContains,
497
+ Q as kebabCase,
498
+ H as lock,
499
+ G as mergeDeep,
500
+ R as notifyDataLoaded,
501
+ X as removeNullAndUndefinedValues,
502
+ tt as setCookie,
503
+ et as shallowCompare,
504
+ ot as uuid
505
+ };
@@ -0,0 +1 @@
1
+ export default function kebabCase(string: string): string;
package/lock.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ type Task = () => Promise<any> | any;
2
+ export type AddTask = (task: Task) => Promise<any>;
3
+ /**
4
+ * Creates a lock for the specified owner that allows only one executing
5
+ * task simultaneously.
6
+ * @param key Lock owner.
7
+ */
8
+ export default function lock(key: object, lockWarningTime?: number, lockErrorTime?: number): AddTask;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param target Target to merge into
3
+ * @param sources Source to merge into target
4
+ * @returns Clone (new reference) with merged sources
5
+ */
6
+ declare const mergeDeep: <Target, Source>(target: Target, ...sources: Source[]) => Target & Source;
7
+ export default mergeDeep;
@@ -0,0 +1,7 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ /**
4
+ * Wait for all visible components to render
5
+ */
6
+ declare const notifyDataLoaded: (viewOutletContainer: Container, widgetDOMElement: HTMLElement) => void;
7
+ export default notifyDataLoaded;
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@telia-ace/widget-utilities",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@webprovisions/platform": "^1.1.4"
6
+ },
7
+ "main": "./index.js",
8
+ "module": "./index.mjs",
9
+ "typings": "./index.d.ts"
10
+ }
@@ -0,0 +1,6 @@
1
+ declare const removeNullAndUndefinedValues: (object?: {
2
+ [key: string]: any;
3
+ }) => {
4
+ [key: string]: any;
5
+ };
6
+ export default removeNullAndUndefinedValues;
@@ -0,0 +1 @@
1
+ export default function setCookie(cookieName: string, value: any, days: number): void;
@@ -0,0 +1,6 @@
1
+ declare const _default: (a: {
2
+ [key: string]: any;
3
+ }, b: {
4
+ [key: string]: any;
5
+ }) => boolean;
6
+ export default _default;
package/uuid.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function uuid(): string;
package/wait-for.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ type Action = (...args: any[]) => Function | false;
2
+ export type WaitForOptions = {
3
+ callCount?: number;
4
+ };
5
+ export default class WaitFor {
6
+ private queue;
7
+ private queueAttempt;
8
+ private queueAttemptCalls;
9
+ private callCount;
10
+ constructor(options?: WaitForOptions);
11
+ /**
12
+ * Add action to the queue
13
+ */
14
+ add: (action: Action) => void;
15
+ /**
16
+ * Go through queue and attempt to call each action
17
+ */
18
+ processQueue: () => void;
19
+ }
20
+ export {};