@froomle/frontend-sdk 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # Froomle Frontend SDK (JavaScript)
2
+
3
+ This is the JavaScript/TypeScript client for the Froomle Frontend SDK.
4
+
5
+ ## Documentation
6
+
7
+ Documentation for this SDK is available at:
8
+ [https://docs.froomle.ai/froomle-doc-main/js_lib/jslib.html](https://docs.froomle.ai/froomle-doc-main/js_lib/jslib.html)
@@ -0,0 +1,5 @@
1
+ "use strict";var FroomleFrontendSdk=(()=>{var we=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var st=(u,e)=>{for(var t in e)we(u,t,{get:e[t],enumerable:!0})},nt=(u,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!rt.call(u,n)&&n!==t&&we(u,n,{get:()=>e[n],enumerable:!(r=et(e,n))||r.enumerable});return u};var it=u=>nt(we({},"__esModule",{value:!0}),u);var ut={};st(ut,{RecommendationItem:()=>G,RecommendationList:()=>W,Recommendations:()=>Q,setConsent:()=>at,setDeviceId:()=>Qe,setEnvironment:()=>ze,setPageVisit:()=>Ke,setRequestDomain:()=>We,setUserId:()=>Xe});var s=class u{static global(e){return u.globals[e]?u.globals[e]:u.globals[e]={}}static createStatic(e,t,r){let n=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return r!=null&&(n=r(),r=null),n},set:function(i){r!=null&&(n=r(),r=null),n=i}})}static iterator(e){if(Array.isArray(e)){let t=e;return function(){return u.mkIter(t)}}else return typeof e.iterator=="function"?e.iterator.bind(e):e.iterator}static getIterator(e){return Array.isArray(e)?u.mkIter(e):e.iterator()}static mkIter(e){return new xe(e)}static extend(e){function t(){this[u.new].apply(this,arguments)}return Object.setPrototypeOf(t.prototype,e.prototype),t}static inherits(e,t){t==null&&(t=!1);function r(){t&&e&&r[u.init]&&r[u.init](),this[u.new].apply(this,arguments)}return t?r[u.init]=()=>{let n=e();n[u.init]&&n[u.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[u.init]=void 0}:e&&e[u.init]?(t=!0,r[u.init]=()=>{e[u.init]&&e[u.init](),Object.setPrototypeOf(r.prototype,e.prototype),r[u.init]=void 0}):e&&Object.setPrototypeOf(r.prototype,e.prototype),r}static bind(e,t){if(t==null)return null;t.__id__==null&&(t.__id__=u.fid++);let r=null;return e.hx__closures__==null?e.hx__closures__={}:r=e.hx__closures__[t.__id__],r==null&&(r=t.bind(e),e.hx__closures__[t.__id__]=r),r}static get __name__(){return"genes.Register"}get __class__(){return u}};s.$global=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:void 0;s.globals={};s.new=Symbol();s.init=Symbol();s.fid=0;var xe=s.global("$hxClasses")["genes._Register.ArrayIterator"]=class Pe extends s.inherits(){[s.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return"genes._Register.ArrayIterator"}get __class__(){return Pe}};xe.prototype.array=null;xe.prototype.current=null;var mt=s.$global,Q=function(){};Q.__isInterface__=!0;var W=function(){};W.__isInterface__=!0;var G=function(){};G.__isInterface__=!0;var ft=s.$global,me=s.global("$hxClasses")["haxe.ValueException"]=class Ce extends s.inherits(()=>S,!0){[s.new](e,t,r){super[s.new](String(e),t,r),this.value=e}unwrap(){return this.value}static get __name__(){return"haxe.ValueException"}static get __super__(){return S}get __class__(){return Ce}};me.prototype.value=null;var xt=s.$global,S=s.global("$hxClasses")["haxe.Exception"]=class ie extends s.inherits(()=>Error,!0){[s.new](e,t,r){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=r!=null?r:this}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof ie?e:e instanceof Error?new ie(e.message,null,e):new me(e,null,e)}static thrown(e){return e instanceof ie?e.get_native():e instanceof Error?e:new me(e)}static get __name__(){return"haxe.Exception"}static get __super__(){return Error}get __class__(){return ie}};S.prototype.native=null;S.prototype.__skipStack=null;S.prototype.__nativeException=null;S.prototype.__previousException=null;var Et=s.$global,ve=s.global("$hxClasses")["js.Browser"]=class qe{static get supported(){return this.get_supported()}static get_supported(){return typeof window!="undefined"&&typeof window.location!="undefined"?typeof window.location.protocol=="string":!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")return new"ActiveXObject"("Microsoft.XMLHTTP");throw S.thrown("Unable to create XMLHttpRequest object.")}static get __name__(){return"js.Browser"}get __class__(){return qe}};var kt=s.$global,F=s.global("$hxEnums")["haxe.io.Error"]={__ename__:"haxe.io.Error",Blocked:{_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error"},Overflow:{_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error"},OutsideBounds:{_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error"},Custom:Object.assign(u=>({_hx_index:3,__enum__:"haxe.io.Error",e:u}),{_hx_name:"Custom",__params__:["e"]})};F.__constructs__=[F.Blocked,F.Overflow,F.OutsideBounds,F.Custom];F.__empty_constructs__=[F.Blocked,F.Overflow,F.OutsideBounds];var Ct=s.$global,L=s.global("$hxEnums")["haxe.io.Encoding"]={__ename__:"haxe.io.Encoding",UTF8:{_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding"},RawNative:{_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding"}};L.__constructs__=[L.UTF8,L.RawNative];L.__empty_constructs__=[L.UTF8,L.RawNative];var Ft=s.$global,Y=s.global("$hxClasses")["haxe.io.Bytes"]=class Re extends s.inherits(){[s.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,r){if(e<0||t<0||e+t>this.length)throw S.thrown(F.OutsideBounds);r==null&&(r=L.UTF8);let n="",i=this.b,a=e,o=e+t;switch(r._hx_index){case 0:let f=e>0;for(;a<o;){let h=i[a++];if(h<128){if(h==0)break;n+=String.fromCodePoint(h)}else if(h<224){let g=(h&63)<<6|i[a++]&127;n+=String.fromCodePoint(g)}else if(h<240){let g=i[a++],c=(h&31)<<12|(g&127)<<6|i[a++]&127;n+=String.fromCodePoint(c)}else{let g=i[a++],c=i[a++],p=(h&15)<<18|(g&127)<<12|(c&127)<<6|i[a++]&127;n+=String.fromCodePoint(p)}}break;case 1:for(;a<o;){let h=i[a++]|i[a++]<<8;n+=String.fromCodePoint(h)}break}return n}static ofData(e){let t=e.hxBytes;return t!=null?t:new Re(e)}static get __name__(){return"haxe.io.Bytes"}get __class__(){return Re}};Y.prototype.length=null;Y.prototype.b=null;var Ut=s.$global,T=s.global("$hxClasses")["haxe.http.HttpBase"]=class Be extends s.inherits(){[s.new](e){this.url=e,this.headers=[],this.params=[],this.emptyOnData=s.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let r=0,n=this.headers.length;for(;r<n;){let i=r++;if(this.headers[i].name==e){this.headers[i]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return s.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,L.UTF8)),this.responseAsString}static get __name__(){return"haxe.http.HttpBase"}get __class__(){return Be}};T.prototype.url=null;T.prototype.responseBytes=null;T.prototype.responseAsString=null;T.prototype.postData=null;T.prototype.postBytes=null;T.prototype.headers=null;T.prototype.params=null;T.prototype.emptyOnData=null;var Nt=s.$global,pe=s.global("$hxClasses")["haxe.iterators.MapKeyValueIterator"]=class Ve extends s.inherits(){[s.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return"haxe.iterators.MapKeyValueIterator"}get __class__(){return Ve}};pe.prototype.map=null;pe.prototype.keys=null;var Kt=s.$global,Ie=function(){};Ie.__isInterface__=!0;var Wt=s.$global,Ee=s.global("$hxClasses")["js.Boot"]=class le{static __string_rec(e,t){if(e==null)return"null";if(t.length>=5)return"<...>";let r=typeof e;switch(r=="function"&&(e.__name__||e.__ename__)&&(r="object"),r){case"function":return"<function>";case"object":if(e.__enum__){let h=s.global("$hxEnums")[e.__enum__].__constructs__[e._hx_index],g=h._hx_name;return h.__params__?(t=t+" ",g+"("+(function(c){var p;let $=[];{let _=0,m=h.__params__;for(;_<m.length;){let v=m[_];_=_+1,$.push(le.__string_rec(e[v],t))}}return p=$,p})(this).join(",")+")"):g}if(e instanceof Array){let f="[";t+=" ";let h=0,g=e.length;for(;h<g;){let c=h++;f+=(c>0?",":"")+le.__string_rec(e[c],t)}return f+="]",f}let n;try{n=e.toString}catch{return"???"}if(n!=null&&n!=Object.toString&&typeof n=="function"){let f=e.toString();if(f!="[object Object]")return f}let i=`{
2
+ `;t+=" ";let a=e.hasOwnProperty!=null,o=null;for(o in e)a&&!e.hasOwnProperty(o)||o=="prototype"||o=="__class__"||o=="__super__"||o=="__interfaces__"||o=="__properties__"||(i.length!=2&&(i+=`,
3
+ `),i+=t+o+" : "+le.__string_rec(e[o],t));return t=t.substring(1),i+=`
4
+ `+t+"}",i;break;case"string":return e;default:return String(e)}}static get __name__(){return"js.Boot"}get __class__(){return le}};Ee.__toStr={}.toString;var er=s.$global,b=s.global("$hxClasses").Std=class Ae{static string(e){return Ee.__string_rec(e,"")}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static get __name__(){return"Std"}get __class__(){return Ae}};String.__name__=!0,Array.__name__=!0;var nr=s.$global,he=s.global("$hxClasses")["genes.util.EsMap"]=class oe extends s.inherits(){[s.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return oe.adaptIterator(this.inst.keys())}iterator(){return oe.adaptIterator(this.inst.values())}toString(){let e=[],t=oe.adaptIterator(this.inst.keys());for(;t.hasNext();){let r=t.next();e.push(""+b.string(r)+" => "+b.string(this.inst.get(r)))}return"{"+e.join(", ")+"}"}clear(){this.inst.clear()}static adaptIterator(e){let t,r,n=function(){let i=e.next();t=i.value,r=i.done};return{hasNext:function(){return r==null&&n(),!r},next:function(){r==null&&n();let i=t;return n(),i}}}static get __name__(){return"genes.util.EsMap"}get __class__(){return oe}};he.prototype.inst=null;var cr=s.$global,Oe=s.global("$hxClasses")["haxe.ds.StringMap"]=class $e extends s.inherits(he){[s.new](){super[s.new]()}copy(){let e=new $e;return e.inst=new Map(this.inst),e}keyValueIterator(){return new pe(this)}static get __name__(){return"haxe.ds.StringMap"}static get __interfaces__(){return[Ie]}static get __super__(){return he}get __class__(){return $e}};var mr=s.$global,B=s.global("$hxClasses").HxOverrides=class Fe{static cca(e,t){let r=e.charCodeAt(t);if(r==r)return r}static substr(e,t,r){if(r==null)r=e.length;else if(r<0)if(t==0)r=e.length+r;else return"";return e.substr(t,r)}static now(){return Date.now()}static get __name__(){return"HxOverrides"}get __class__(){return Fe}};typeof performance!="undefined"&&typeof performance.now=="function"&&(B.now=performance.now.bind(performance));var fr=s.$global,J=s.global("$hxClasses").StringTools=class de{static isSpace(e,t){let r=B.cca(e,t);return r>8&&r<14?!0:r==32}static ltrim(e){let t=e.length,r=0;for(;r<t&&de.isSpace(e,r);)++r;return r>0?B.substr(e,r,t-r):e}static rtrim(e){let t=e.length,r=0;for(;r<t&&de.isSpace(e,t-r-1);)++r;return r>0?B.substr(e,0,t-r):e}static replace(e,t,r){return e.split(t).join(r)}static get __name__(){return"StringTools"}get __class__(){return de}};var wr=s.$global,Te=s.global("$hxClasses").Lambda=class He{static exists(e,t){let r=s.getIterator(e);for(;r.hasNext();){let n=r.next();if(t(n))return!0}return!1}static get __name__(){return"Lambda"}get __class__(){return He}};var $r=s.$global,ae=s.global("$hxClasses").EReg=class Le extends s.inherits(){[s.new](e,t){this.r=new RegExp(e,t.split("u").join(""))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw S.thrown("EReg::matched")}matchedPos(){if(this.r.m==null)throw S.thrown("No string matched");return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,r){if(r==null&&(r=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(r<0?e:B.substr(e,0,t+r));let n=this.r.m!=null;return n&&(this.r.s=e),n}else{let n=this.match(r<0?B.substr(e,t,null):B.substr(e,t,r));return n&&(this.r.s=e,this.r.m.index+=t),n}}map(e,t){let r=0,n="";do{if(r>=e.length)break;if(!this.matchSub(e,r)){n+=b.string(B.substr(e,r,null));break}let i=this.matchedPos();n+=b.string(B.substr(e,r,i.pos-r)),n+=b.string(t(this)),i.len==0?(n+=b.string(B.substr(e,i.pos,1)),r=i.pos+1):r=i.pos+i.len}while(this.r.global);return!this.r.global&&r>0&&r<e.length&&(n+=b.string(B.substr(e,r,null))),n}static get __name__(){return"EReg"}get __class__(){return Le}};ae.prototype.r=null;var Tr=s.$global,Z=s.global("$hxClasses")["haxe.http.HttpJs"]=class Ue extends s.inherits(T){[s.new](e){this.async=!0,this.withCredentials=!1,super[s.new](e)}request(e){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let t=this.req=ve.createXMLHttpRequest(),r=this,n=function(g){if(t.readyState!=4)return;let c;try{c=t.status}catch{c=null}if(c==0&&ve.get_supported()&&s.$global.location!=null){let p=s.$global.location.protocol.toLowerCase();new ae("^(?:about|app|app-storage|.+-extension|file|res|widget):$","").match(p)&&(c=t.response!=null?200:404)}if(c==null&&(c=null),c!=null&&r.onStatus(c),c!=null&&c>=200&&c<400){r.req=null;let p=t.getAllResponseHeaders().split(`\r
5
+ `),$=[],_=0,m=p;for(;_<m.length;){let R=m[_];++_,R!=""&&$.push(R)}p=$;let v=new Oe;r.responseHeaders=v;let w=0;for(;w<p.length;){let R=p[w];++w;let C=R.split(": "),O=C.shift(),x=C.length==1?C[0]:C.join(": ");x=J.ltrim(J.rtrim(x)),r.responseHeaders.inst.set(O,x)}r.success(Y.ofData(t.response))}else if(c==null||c==0&&t.response==null)r.req=null,r.onError("Failed to connect or resolve host");else if(c==null){r.req=null;let p=t.response!=null?Y.ofData(t.response):null;r.responseBytes=p,r.onError("Http Error #"+t.status)}else switch(c){case 12007:r.req=null,r.onError("Unknown host");break;case 12029:r.req=null,r.onError("Failed to connect to host");break;default:r.req=null;let p=t.response!=null?Y.ofData(t.response):null;r.responseBytes=p,r.onError("Http Error #"+t.status)}};this.async&&(t.onreadystatechange=n);let i,a=this.postData,o=this.postBytes;if(a==null)if(o==null)i=null;else{let g=o;i=new Blob([g.b.bufferValue])}else o==null?i=a:i=null;if(i!=null)e=!0;else{let g=0,c=this.params;for(;g<c.length;){let p=c[g];++g,i==null?i="":i=(i==null?"null":b.string(i))+"&";let $=p.name,_=(i==null?"null":b.string(i))+encodeURIComponent($)+"=",m=p.value;i=_+encodeURIComponent(m)}}try{if(e)t.open("POST",this.url,this.async);else if(i!=null){let g=this.url.split("?").length<=1;t.open("GET",this.url+(g?"?":"&")+(i==null?"null":b.string(i)),this.async),i=null}else t.open("GET",this.url,this.async);t.responseType="arraybuffer"}catch(g){let c=S.caught(g).unwrap();this.req=null,this.onError(c.toString());return}t.withCredentials=this.withCredentials,!Te.exists(this.headers,function(g){return g.name=="Content-Type"})&&e&&this.postData==null&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded");let f=0,h=this.headers;for(;f<h.length;){let g=h[f];++f,t.setRequestHeader(g.name,g.value)}t.send(i),this.async||n(null)}static get __name__(){return"haxe.http.HttpJs"}static get __super__(){return T}get __class__(){return Ue}};Z.prototype.async=null;Z.prototype.withCredentials=null;Z.prototype.responseHeaders=null;Z.prototype.req=null;var Ur=s.$global,M=s.global("$hxClasses").SimpleFuture=class je extends s.inherits(){[s.new](){this._isFinished=!1}trigger(e){this._result=e,this._isFinished=!0,this._callback!=null&&this._callback(this._result)}then(e){this._callback=e,this._isFinished&&e(this._result)}static get __name__(){return"SimpleFuture"}get __class__(){return je}};M.prototype._callback=null;M.prototype._result=null;M.prototype._isFinished=null;var Nr=s.$global,E=s.global("$hxClasses").Reflect=class Me{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let r;if(e==null)return null;{let n;return e.__properties__?(r=e.__properties__["get_"+t],n=r):n=!1,n?e[r]():e[t]}}static setProperty(e,t,r){let n,i;e.__properties__?(n=e.__properties__["set_"+t],i=n):i=!1,i?e[n](r):e[t]=r}static fields(e){let t=[];if(e!=null){let n=Object.prototype.hasOwnProperty;for(var r in e)r!="__id__"&&r!="hx__closures__"&&n.call(e,r)&&t.push(r)}return t}static get __name__(){return"Reflect"}get __class__(){return Me}};var Zr=s.$global,l=s.global("$hxClasses")["internal.RecoBackendV2"]=class y extends s.inherits(){[s.new](){}static _requestUri(){return"https://"+y._req_domain+"/api/"+y._environment+"/recommendations/requests"}static noConsentBody(){return{device_id:"no-consent",user_group:"no-consent",version:"no-consent"}}static buildRequestBody(e){let t={lists:e,page_type:y._page_visit!=null?y._page_visit:y._page_view,channel:"www-desktop"};if(y._consent==0){let r=y.noConsentBody(),n=0,i=E.fields(r);for(;n<i.length;){let a=i[n];++n,t[a]=E.field(r,a)}}else y._user_id!=null?t.user_id=y._user_id:t.device_id=y._device_id;return t}static _requestRecos(e){let t=new M,r=null;s.$global.console.log(y._requestUri());let n=new Z(y._requestUri());n.setHeader("Content-Type","application/json"),n.setPostData(JSON.stringify(y.buildRequestBody(e))),n.onError=function(o){throw S.thrown("HTTP Request Error: "+o)},n.onStatus=function(o){if(o<200||o>=300)throw S.thrown("HTTP Status Error: "+o)};try{n.request(!1)}catch(o){let f=S.caught(o).unwrap();throw S.thrown("Failed to execute synchronous request: "+b.string(f))}let i=function(o){let f=JSON.parse(o);s.$global.console.log(b.string(f));let h=ee.fromRequestData(f);s.$global.console.log("got recommendations parsed"),t.trigger(h)},a=n.get_responseData();return a!=null?i(a):n.onData=i,t}static getRawRecommendations(e){return y._requestRecos(e)}static setConsent(e){e>2&&(e=2),y._consent=e}static setPageVisit(e){y._page_visit=e}static setEnvironment(e){y._environment=e}static setDeviceId(e){y._device_id=e}static setUserId(e){y._user_id=e}static setRequestDomain(e){y._req_domain=e}static setPageView(e){y._page_view=e}static getRequestDomain(){return y._req_domain}static getEnvironment(){return y._environment}static getPageVisit(){return y._page_visit}static getUserId(){return y._user_id}static getDeviceId(){return y._device_id}static getPageView(){return y._page_view}static get __name__(){return"internal.RecoBackendV2"}get __class__(){return y}};l._environment=null;l._device_id=null;l._user_id=null;l._consent=0;l._req_domain="europe-west1.froomle.com";l._page_visit=null;l._page_view=null;var lt=function(){};lt.__isInterface__=!0;var ot=function(){};ot.__isInterface__=!0;var ee=s.global("$hxClasses")["internal._RecommendationsInternal"]=class De extends s.inherits(){[s.new](e,t,r,n,i){this.request_id=t,this.user_group=r,this.device_id=e,this.user_id=n,this._lists=i}items(){let e=[],t=0,r=this._lists;for(;t<r.length;){let n=r[t];++t;let i=0,a=n.items;for(;i<a.length;){let o=a[i];++i,e.push(o)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,r=this._lists;for(;t<r.length;){let n=r[t];if(++t,n.list_name==e)return n}return null}static fromRequestData(e){let t=E.getProperty(e,"lists");s.$global.console.log("lists: "+b.string(t)),s.$global.console.log("data: "+b.string(e));let r=[],n=0;for(;n<t.length;){let i=t[n];++n;let a=E.getProperty(i,"items"),o=[],f=0;for(;f<a.length;){let g=a[f];++f,o.push(new ue(g))}let h=new te({limit:E.getProperty(i,"limit"),list_key:E.getProperty(i,"list_key"),list_name:E.getProperty(i,"list_name"),list_size:E.getProperty(i,"list_size"),items:o});r.push(h)}return new De(E.getProperty(e,"device_id"),E.getProperty(e,"request_id"),E.getProperty(e,"user_group"),E.getProperty(e,"user_id"),r)}static get __name__(){return"internal._RecommendationsInternal"}static get __interfaces__(){return[Q]}get __class__(){return De}};ee.prototype.request_id=null;ee.prototype.user_group=null;ee.prototype.user_id=null;ee.prototype.device_id=null;ee.prototype._lists=null;var te=s.global("$hxClasses")["internal._RecommendationsListInternal"]=class Ne extends s.inherits(){[s.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size}static get __name__(){return"internal._RecommendationsListInternal"}static get __interfaces__(){return[W]}get __class__(){return Ne}};te.prototype.limit=null;te.prototype.list_key=null;te.prototype.list_name=null;te.prototype.list_size=null;te.prototype.items=null;var ue=s.global("$hxClasses")["internal._RecommendationItemInternal"]=class Je extends s.inherits(){[s.new](e){this._data={},this.Id=E.getProperty(e,"item_id"),this.RequestId=E.getProperty(e,"request_id"),this.UserGroup=E.getProperty(e,"user_group");let t=0,r=E.fields(e);for(;t<r.length;){let n=r[t];++t,this._data[n]=E.field(e,n)}}get(e){return this._data[e]}static get __name__(){return"internal._RecommendationItemInternal"}static get __interfaces__(){return[G]}get __class__(){return Je}};ue.prototype.Id=null;ue.prototype.RequestId=null;ue.prototype.UserGroup=null;ue.prototype._data=null;var q=s.global("$hxClasses")["internal._RecoBackendV2.RecoBackendV2_Fields_"]=class ke{static getRawRecommendations(e){return l.getRawRecommendations(e)}static setConsent(e){l.setConsent(e)}static setPageVisit(e){l.setPageVisit(e)}static setEnvironment(e){l.setEnvironment(e)}static setDeviceId(e){l.setDeviceId(e)}static setUserId(e){l.setUserId(e)}static setRequestDomain(e){l.setRequestDomain(e)}static setPageView(e){l.setPageView(e)}static getConsent(){ke.getConsent()}static getPageVisit(){l.getPageVisit()}static getEnvironment(){l.getEnvironment()}static getDeviceId(){l.getDeviceId()}static getUserId(){l.getUserId()}static getPageView(){l.getPageView()}static get __name__(){return"internal._RecoBackendV2.RecoBackendV2_Fields_"}get __class__(){return ke}},es=q.getRawRecommendations,ts=q.setConsent,rs=q.setPageVisit,ss=q.setEnvironment,ns=q.setDeviceId,is=q.setUserId,ls=q.setRequestDomain,os=q.setPageView,as=q.getConsent,us=q.getPageVisit,cs=q.getEnvironment,gs=q.getDeviceId,_s=q.getUserId,ms=q.getPageView;var fs=s.$global,A=s.global("$hxClasses").FroomleSdk=class V{static register(){V.registered||V._env_set&&(!V._page_visit_set&&!V._page_view_set||(V.registered=!0))}static setEnvironment(e){l.setEnvironment(e),V._env_set=!0,V.register()}static setDeviceId(e){l.setDeviceId(e)}static setUserId(e){l.setUserId(e)}static setConsent(e){l.setConsent(e)}static setPageView(e){l.setPageView(e),V._page_view_set=!0,V.register()}static setPageVisit(e){l.setPageVisit(e),V._page_visit_set=!0,V.register()}static setRequestDomain(e){l.setRequestDomain(e)}static getRawRecommendations(e){return l.getRawRecommendations(e)}static getVersion(){return"0.0.1"}static get __name__(){return"FroomleSdk"}get __class__(){return V}};A._env_set=!1;A._page_visit_set=!1;A._page_view_set=!1;A.registered=!1;var ws=s.$global,re=s.global("$hxClasses")["internal.domHandler.FroomleDomTree"]=class fe extends s.inherits(){[s.new](){}createElement(e){return window.document.createElement(e)}querySelectorAll(e){let t=this.root,r=[],n=t.querySelectorAll(e),i=0,a=n.length;for(;i<a;){let o=i++;r.push(n.item(o))}return r}getRoot(){return this.root}toString(){return this.root.outerHTML}static run(){}static fromHtml(e){return new fe}static fromDocument(){let e=new fe;return e.root=window.document,e}static get __name__(){return"internal.domHandler.FroomleDomTree"}get __class__(){return fe}};re.prototype.root=null;var Rs=s.$global,U=s.global("$hxClasses")["internal._ADomNode.ADomNode"]=class Se{static _new(e){return e}static fromElement(e){return e}static create(e,t){return window.document.createElement(t)}static replaceChild(e,t,r){e.replaceChild(t,r)}static get attributes(){return this.get_attributes()}static get_attributes(e){let t=e,r=[],n=0,i=t.attributes.length;for(;n<i;){let a=n++,o=t.attributes.item(a);r.push({name:o.name,value:o.value})}return r}static addChild(e,t){e.appendChild(t)}static removeChild(e,t){e.removeChild(t)}static getAttribute(e,t){return e.getAttribute(t)}static setAttribute(e,t,r){e.setAttribute(t,r)}static getText(e){return e.textContent}static setText(e,t){e.textContent=t}static get children(){return this.get_children()}static get_children(e){let t=[],n=e.children,i=0,a=n.length;for(;i<a;){let o=i++;t.push(n[o])}return t}static querySelectorAll(e,t){let r=e,n=[],i=r.querySelectorAll(t),a=0,o=i.length;for(;a<o;){let f=a++;n.push(i.item(f))}return n}static getFilterKeyValue(e){let t=0,r=Se.get_attributes(e);for(;t<r.length;){let n=r[t];if(++t,n.name.startsWith("data-froomle-reco-filter-"))return{key:n.name.substring(25),value:n.value}}return{key:null,value:null}}static get __name__(){return"internal._ADomNode.ADomNode_Impl_"}get __class__(){return Se}};var As=s.$global,ce=s.global("$hxClasses")["internal.domHandler.DomDomDom"]=class z extends s.inherits(){[s.new](){}static _fillRecoTargets(e){let t=new M;if(e==null)return t.trigger(!1),t;s.$global.console.log("filling recos");let r=[],n=e,i=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let d=o++;i.push(a.item(d))}let h=i;s.$global.console.log(h.length+" amount of elements");let g=0;for(;g<h.length;){let d=h[g];++g;let k=0,I=U.get_attributes(d);for(;k<I.length;){let N=I[k];++k,N.name=="data-froomle-reco"&&r.push(d)}}s.$global.console.log("amount of targets: "+(r.length==null?"null":""+r.length));let c=[],p=0;for(;p<r.length;){let d=r[p];++p,d.getAttribute("data-froomle-request-id")==null&&(d.getAttribute("data-froomle-id")==null||d.getAttribute("data-froomle-id")=="")&&c.push(d)}if(s.$global.console.log("filtered: "+b.string(c)),s.$global.console.log("filtered targets length "+c.length),c.length<1)return new M;let $=[],_=[],m="",v="",w="",R=[],C=function(){let d={list_name:m,list_size:R.length,limit:R.length};v!=null&&E.setProperty(d,v,w),$.push(d),_.push(R),s.$global.console.log("pushed a list with name:"+m+"filter_key: "+(v==null?"null":""+v)+" and value "+(w==null?"null":""+w)),s.$global.console.log("had length "+d.list_size)},O=function(d,k,I,N){m=d,v=k,w=I,R=[N]},x=0;for(;x<c.length;){let d=c[x];++x;let k=d.getAttribute("data-froomle-reco"),I=U.getFilterKeyValue(d);if(m==""){O(k,I.key,I.value,d);continue}else if(k==m&&I.key==v&&I.value==w){R.push(d);continue}else{C(),O(k,I.key,I.value,d);continue}}m!=""&&C();let D=q.getRawRecommendations($);return s.$global.console.log("should have recos"),D.then(function(d){let k=0,I=d.lists();for(;k<I.length;){let N=I[k],H=k++,j=N,X=j.items.length!=_[H].length,ne=0,be=j.items;for(;ne<be.length;){let ye=be[ne],Ye=ne++,Ze=ye;z._fillParameters(_[H][Ye],Ze,d.request_id)}}t.trigger(!0)}),t}static _fillParameters(e,t,r){let n=function(p,$,_,m){m==null&&(m="");let v=function(w,R,C){C==null&&(C="fgh");try{R=new ae("\\\\[(\\\\w+)\\\\]","g").map(R,function(I){return"."+I.matched(1)}),R=J.replace(R,"[","."),R=J.replace(R,"]",""),B.cca(R,0)==46&&(R=B.substr(R,1,null));let x=R.split("."),D=w.get(x[0]),d=1,k=x.length;for(;d<k;){let I=d++;if(D==null)return null;D instanceof Array&&b.parseInt(x[I])!=null?D=D[b.parseInt(x[I])]:D=E.field(D,x[I])}return D}catch{return C}};try{let w=v(t,_,m);$=="inner"?p.textContent=w:p.setAttribute($,w)}catch{}};e.setAttribute("data-froomle-id",t.Id),e.setAttribute("data-froomle-request-id",r);let i=e,a=[],o=i.querySelectorAll("*"),f=0,h=o.length;for(;f<h;){let p=f++;a.push(o.item(p))}let g=a,c=0;for(;c<g.length;){let p=g[c];++c;let $=0,_=U.get_attributes(p);for(;$<_.length;){let m=_[$];if(++$,m.name.startsWith("data-froomle-param-")){let v=J.replace(m.name,"data-froomle-param-",""),w=m.value;n(p,v,w)}}}}static _orderElements(e){let t=function(_,m,v){let w=[],R=U.get_children(_),C=0;for(;C<R.length;){let D=R[C];if(++C,D.getAttribute("data-froomle-ordervalue")!=null){w.push(D);let k=U.create(e,"span");k.setAttribute("data-froomle-tmp-node",""),U.replaceChild(_,k,D)}}let O=[],x=0;for(;x<w.length;){let D=w[x];++x,O.push(D.getAttribute("data-froomle-ordervalue"))}return{el:_,key:m,values:O,orderChildren:w,list_name:v}},r=new M,n=e.getRoot(),i=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let _=o++;i.push(a.item(_))}let h=i,g=[],c=0;for(;c<h.length;){let _=h[c];++c;let m=0,v=U.get_attributes(_);for(;m<v.length;){let w=v[m];++m,w.name.startsWith("data-froomle-order-")&&g.push(t(_,w.name.substring(19),w.value))}}if(g.length<1)return r.trigger(!1),r;let p=[],$=0;for(;$<g.length;){let _=g[$];++$;let m={list_name:_.list_name,limit:_.values.length,list_size:_.values.length},v={};E.setProperty(v,_.key,_.values),E.setProperty(m,"order",v),p.push(m)}return q.getRawRecommendations(p).then(function(_){s.$global.console.log("got order recos"),s.$global.console.log(b.string(_));let m=0,v=_.lists();for(;m<v.length;){let w=v[m],C=m++,O=w,x=g[C];x.el.setAttribute("data-froomle-request-id",_.request_id),s.$global.console.log("children "+b.string(x.orderChildren));let D=[],d=0,k=O.items;for(;d<k.length;){let K=k[d];++d;let H=K.get(x.key);s.$global.console.log("looking for value "+H+" for key "+x.key),s.$global.console.log("item was "+b.string(K));let j=0,X=x.values;for(;j<X.length;){let ne=X[j],ye=j++;if(H==ne){s.$global.console.log("found matching value "+H),D.push(x.orderChildren[ye]);break}}}s.$global.console.log("sorted items "+b.string(D));let I=0,N=D.length;for(;I<N;){let K=I++;s.$global.console.log("replacing in section "+b.string(x.el.innerHTML)+" the item "+b.string(D[K]));let H=0,j=U.get_children(x.el);for(;H<j.length;){let X=j[H];if(++H,X.getAttribute("data-froomle-tmp-node")==""){U.replaceChild(x.el,D[K],X);break}}}s.$global.console.log("done replacing for section "+b.string(x.el.innerHTML)),s.$global.console.log("sorted items "+b.string(D))}r.trigger(!0)}),r}static domInit(e){z._orderElements(e).then(function(t){z._fillRecoTargets(e.getRoot())})}static fillElementRecos(e){z._fillRecoTargets(e)}static runFromHtml(e){let t=re.fromHtml(e);return z.domInit(t),t.toString()}static get __name__(){return"internal.domHandler.DomDomDom"}get __class__(){return z}};var Ts=s.$global;var P=class P{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e=[];for(let t of P.impressionQueue){let r={event_type:"impression",page_type:l.getPageVisit(),action_item:t.getAttribute("data-froomle-id"),action_item_type:"article",channel:"www-desktop"};l.getUserId()?r.user_id=l.getUserId():r.device_id=l.getDeviceId();let n=t.getAttribute("data-froomle-reco");if(n){r.list_name=n;let i=t.getAttribute("data-froomle-request-id");if(!i)throw console.error("element need reco but doesnt have request id registered yet"),new Error("element need reco but doesnt have request id registered");r.request_id=i}}return P.impressionQueue=[],JSON.stringify({events:e})}static sendImpressions(){P.impressionQueue.length!==0&&fetch(P.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:P.generateBody()})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(e){let t=e.getBoundingClientRect(),r=P.getViewPortRect();return t.right>r.left&&t.left<r.right&&t.bottom>r.top&&t.top<r.bottom}static addIntersectionImpressionListener(e){P.observer.observe(e)}static processDocument(){if(l.getDeviceId()!="no-consent"){for(let e of document.querySelectorAll("[data-froomle-id]"))P.intersectsWithViewPortRect(e)?P.impressionQueue.push(e):P.addIntersectionImpressionListener(e);P.sendImpressions()}}};P.impressionQueue=[],P.observer=new IntersectionObserver((e,t)=>{e.forEach(r=>{r.isIntersecting&&(P.impressionQueue.push(r.target),P.observer.unobserve(r.target))}),P.impressionQueue.length>0&&P.sendImpressions()});var se=P;var ge=class u{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e={event_type:"page_visit",page_type:l.getPageVisit(),channel:"www-desktop"};return l.getUserId()?e.user_id=l.getUserId():e.device_id=l.getDeviceId(),JSON.stringify(e)}static sendPageVisit(){l.getPageVisit()&&l.getDeviceId()!="no-consent"&&fetch(u.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:u.generateBody()})}};var _e=class u{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e={event_type:"detail_pageview",page_type:"article_detail",action_item:l.getPageView(),action_item_type:"article",channel:"www-desktop"};return l.getUserId()?e.user_id=l.getUserId():e.device_id=l.getDeviceId(),JSON.stringify(e)}static sendPageView(){l.getPageView()&&l.getDeviceId()!="no-consent"&&fetch(u.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:u.generateBody()})}};var ze=A.setEnvironment,Ke=A.setPageVisit,at=A.setConsent,Xe=A.setUserId,Qe=A.setDeviceId,We=A.setRequestDomain;if(typeof document!="undefined"){let u=document.currentScript;if(console.log("dom loaded"),console.log(u),u){console.log("loaded script");let e=u.getAttribute("data-froomle-device-id"),t=u.getAttribute("data-froomle-user-id"),r=u.getAttribute("data-froomle-env"),n=u.getAttribute("data-froomle-page-visit"),i=u.getAttribute("data-froomle-request-domain");ze(r),Ke(n),e&&Qe(e),t&&Xe(t),i&&We(i)}else console.error("Froomle SDK: could not find the script tag where the sdk is included.");document.addEventListener("DOMContentLoaded",()=>{ce.domInit(re.fromDocument()),se.processDocument(),ge.sendPageVisit(),_e.sendPageView(),new MutationObserver(t=>{for(let r of t)if(r.type==="childList"&&se.processElement(r.target),r.type==="attributes")if(r.attributeName==="data-froomle-reco"){let n=r.target.getAttribute("data-froomle-request-id");(!n||n==="")&&ce.fillElementRecos(r.target)}else r.attributeName==="data-froomle-request-id"&&ce.fillElementRecos(r.target)}).observe(document,{childList:!0,subtree:!0})})}return it(ut);})();
package/dist/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var we=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var st=(u,e)=>{for(var t in e)we(u,t,{get:e[t],enumerable:!0})},nt=(u,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!rt.call(u,n)&&n!==t&&we(u,n,{get:()=>e[n],enumerable:!(r=et(e,n))||r.enumerable});return u};var it=u=>nt(we({},"__esModule",{value:!0}),u);var ut={};st(ut,{RecommendationItem:()=>G,RecommendationList:()=>W,Recommendations:()=>Q,setConsent:()=>at,setDeviceId:()=>Qe,setEnvironment:()=>ze,setPageVisit:()=>Ke,setRequestDomain:()=>We,setUserId:()=>Xe});module.exports=it(ut);var s=class u{static global(e){return u.globals[e]?u.globals[e]:u.globals[e]={}}static createStatic(e,t,r){let n=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return r!=null&&(n=r(),r=null),n},set:function(i){r!=null&&(n=r(),r=null),n=i}})}static iterator(e){if(Array.isArray(e)){let t=e;return function(){return u.mkIter(t)}}else return typeof e.iterator=="function"?e.iterator.bind(e):e.iterator}static getIterator(e){return Array.isArray(e)?u.mkIter(e):e.iterator()}static mkIter(e){return new xe(e)}static extend(e){function t(){this[u.new].apply(this,arguments)}return Object.setPrototypeOf(t.prototype,e.prototype),t}static inherits(e,t){t==null&&(t=!1);function r(){t&&e&&r[u.init]&&r[u.init](),this[u.new].apply(this,arguments)}return t?r[u.init]=()=>{let n=e();n[u.init]&&n[u.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[u.init]=void 0}:e&&e[u.init]?(t=!0,r[u.init]=()=>{e[u.init]&&e[u.init](),Object.setPrototypeOf(r.prototype,e.prototype),r[u.init]=void 0}):e&&Object.setPrototypeOf(r.prototype,e.prototype),r}static bind(e,t){if(t==null)return null;t.__id__==null&&(t.__id__=u.fid++);let r=null;return e.hx__closures__==null?e.hx__closures__={}:r=e.hx__closures__[t.__id__],r==null&&(r=t.bind(e),e.hx__closures__[t.__id__]=r),r}static get __name__(){return"genes.Register"}get __class__(){return u}};s.$global=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:void 0;s.globals={};s.new=Symbol();s.init=Symbol();s.fid=0;var xe=s.global("$hxClasses")["genes._Register.ArrayIterator"]=class Pe extends s.inherits(){[s.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return"genes._Register.ArrayIterator"}get __class__(){return Pe}};xe.prototype.array=null;xe.prototype.current=null;var mt=s.$global,Q=function(){};Q.__isInterface__=!0;var W=function(){};W.__isInterface__=!0;var G=function(){};G.__isInterface__=!0;var ft=s.$global,me=s.global("$hxClasses")["haxe.ValueException"]=class Ce extends s.inherits(()=>S,!0){[s.new](e,t,r){super[s.new](String(e),t,r),this.value=e}unwrap(){return this.value}static get __name__(){return"haxe.ValueException"}static get __super__(){return S}get __class__(){return Ce}};me.prototype.value=null;var xt=s.$global,S=s.global("$hxClasses")["haxe.Exception"]=class ie extends s.inherits(()=>Error,!0){[s.new](e,t,r){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=r!=null?r:this}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof ie?e:e instanceof Error?new ie(e.message,null,e):new me(e,null,e)}static thrown(e){return e instanceof ie?e.get_native():e instanceof Error?e:new me(e)}static get __name__(){return"haxe.Exception"}static get __super__(){return Error}get __class__(){return ie}};S.prototype.native=null;S.prototype.__skipStack=null;S.prototype.__nativeException=null;S.prototype.__previousException=null;var Et=s.$global,ve=s.global("$hxClasses")["js.Browser"]=class qe{static get supported(){return this.get_supported()}static get_supported(){return typeof window!="undefined"&&typeof window.location!="undefined"?typeof window.location.protocol=="string":!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")return new"ActiveXObject"("Microsoft.XMLHTTP");throw S.thrown("Unable to create XMLHttpRequest object.")}static get __name__(){return"js.Browser"}get __class__(){return qe}};var kt=s.$global,F=s.global("$hxEnums")["haxe.io.Error"]={__ename__:"haxe.io.Error",Blocked:{_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error"},Overflow:{_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error"},OutsideBounds:{_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error"},Custom:Object.assign(u=>({_hx_index:3,__enum__:"haxe.io.Error",e:u}),{_hx_name:"Custom",__params__:["e"]})};F.__constructs__=[F.Blocked,F.Overflow,F.OutsideBounds,F.Custom];F.__empty_constructs__=[F.Blocked,F.Overflow,F.OutsideBounds];var Ct=s.$global,L=s.global("$hxEnums")["haxe.io.Encoding"]={__ename__:"haxe.io.Encoding",UTF8:{_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding"},RawNative:{_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding"}};L.__constructs__=[L.UTF8,L.RawNative];L.__empty_constructs__=[L.UTF8,L.RawNative];var Ft=s.$global,Y=s.global("$hxClasses")["haxe.io.Bytes"]=class Re extends s.inherits(){[s.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,r){if(e<0||t<0||e+t>this.length)throw S.thrown(F.OutsideBounds);r==null&&(r=L.UTF8);let n="",i=this.b,a=e,o=e+t;switch(r._hx_index){case 0:let f=e>0;for(;a<o;){let h=i[a++];if(h<128){if(h==0)break;n+=String.fromCodePoint(h)}else if(h<224){let g=(h&63)<<6|i[a++]&127;n+=String.fromCodePoint(g)}else if(h<240){let g=i[a++],c=(h&31)<<12|(g&127)<<6|i[a++]&127;n+=String.fromCodePoint(c)}else{let g=i[a++],c=i[a++],p=(h&15)<<18|(g&127)<<12|(c&127)<<6|i[a++]&127;n+=String.fromCodePoint(p)}}break;case 1:for(;a<o;){let h=i[a++]|i[a++]<<8;n+=String.fromCodePoint(h)}break}return n}static ofData(e){let t=e.hxBytes;return t!=null?t:new Re(e)}static get __name__(){return"haxe.io.Bytes"}get __class__(){return Re}};Y.prototype.length=null;Y.prototype.b=null;var Ut=s.$global,T=s.global("$hxClasses")["haxe.http.HttpBase"]=class Be extends s.inherits(){[s.new](e){this.url=e,this.headers=[],this.params=[],this.emptyOnData=s.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let r=0,n=this.headers.length;for(;r<n;){let i=r++;if(this.headers[i].name==e){this.headers[i]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return s.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,L.UTF8)),this.responseAsString}static get __name__(){return"haxe.http.HttpBase"}get __class__(){return Be}};T.prototype.url=null;T.prototype.responseBytes=null;T.prototype.responseAsString=null;T.prototype.postData=null;T.prototype.postBytes=null;T.prototype.headers=null;T.prototype.params=null;T.prototype.emptyOnData=null;var Nt=s.$global,pe=s.global("$hxClasses")["haxe.iterators.MapKeyValueIterator"]=class Ve extends s.inherits(){[s.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return"haxe.iterators.MapKeyValueIterator"}get __class__(){return Ve}};pe.prototype.map=null;pe.prototype.keys=null;var Kt=s.$global,Ie=function(){};Ie.__isInterface__=!0;var Wt=s.$global,Ee=s.global("$hxClasses")["js.Boot"]=class le{static __string_rec(e,t){if(e==null)return"null";if(t.length>=5)return"<...>";let r=typeof e;switch(r=="function"&&(e.__name__||e.__ename__)&&(r="object"),r){case"function":return"<function>";case"object":if(e.__enum__){let h=s.global("$hxEnums")[e.__enum__].__constructs__[e._hx_index],g=h._hx_name;return h.__params__?(t=t+" ",g+"("+(function(c){var p;let $=[];{let _=0,m=h.__params__;for(;_<m.length;){let v=m[_];_=_+1,$.push(le.__string_rec(e[v],t))}}return p=$,p})(this).join(",")+")"):g}if(e instanceof Array){let f="[";t+=" ";let h=0,g=e.length;for(;h<g;){let c=h++;f+=(c>0?",":"")+le.__string_rec(e[c],t)}return f+="]",f}let n;try{n=e.toString}catch{return"???"}if(n!=null&&n!=Object.toString&&typeof n=="function"){let f=e.toString();if(f!="[object Object]")return f}let i=`{
2
+ `;t+=" ";let a=e.hasOwnProperty!=null,o=null;for(o in e)a&&!e.hasOwnProperty(o)||o=="prototype"||o=="__class__"||o=="__super__"||o=="__interfaces__"||o=="__properties__"||(i.length!=2&&(i+=`,
3
+ `),i+=t+o+" : "+le.__string_rec(e[o],t));return t=t.substring(1),i+=`
4
+ `+t+"}",i;break;case"string":return e;default:return String(e)}}static get __name__(){return"js.Boot"}get __class__(){return le}};Ee.__toStr={}.toString;var er=s.$global,b=s.global("$hxClasses").Std=class Ae{static string(e){return Ee.__string_rec(e,"")}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static get __name__(){return"Std"}get __class__(){return Ae}};String.__name__=!0,Array.__name__=!0;var nr=s.$global,he=s.global("$hxClasses")["genes.util.EsMap"]=class oe extends s.inherits(){[s.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return oe.adaptIterator(this.inst.keys())}iterator(){return oe.adaptIterator(this.inst.values())}toString(){let e=[],t=oe.adaptIterator(this.inst.keys());for(;t.hasNext();){let r=t.next();e.push(""+b.string(r)+" => "+b.string(this.inst.get(r)))}return"{"+e.join(", ")+"}"}clear(){this.inst.clear()}static adaptIterator(e){let t,r,n=function(){let i=e.next();t=i.value,r=i.done};return{hasNext:function(){return r==null&&n(),!r},next:function(){r==null&&n();let i=t;return n(),i}}}static get __name__(){return"genes.util.EsMap"}get __class__(){return oe}};he.prototype.inst=null;var cr=s.$global,Oe=s.global("$hxClasses")["haxe.ds.StringMap"]=class $e extends s.inherits(he){[s.new](){super[s.new]()}copy(){let e=new $e;return e.inst=new Map(this.inst),e}keyValueIterator(){return new pe(this)}static get __name__(){return"haxe.ds.StringMap"}static get __interfaces__(){return[Ie]}static get __super__(){return he}get __class__(){return $e}};var mr=s.$global,B=s.global("$hxClasses").HxOverrides=class Fe{static cca(e,t){let r=e.charCodeAt(t);if(r==r)return r}static substr(e,t,r){if(r==null)r=e.length;else if(r<0)if(t==0)r=e.length+r;else return"";return e.substr(t,r)}static now(){return Date.now()}static get __name__(){return"HxOverrides"}get __class__(){return Fe}};typeof performance!="undefined"&&typeof performance.now=="function"&&(B.now=performance.now.bind(performance));var fr=s.$global,J=s.global("$hxClasses").StringTools=class de{static isSpace(e,t){let r=B.cca(e,t);return r>8&&r<14?!0:r==32}static ltrim(e){let t=e.length,r=0;for(;r<t&&de.isSpace(e,r);)++r;return r>0?B.substr(e,r,t-r):e}static rtrim(e){let t=e.length,r=0;for(;r<t&&de.isSpace(e,t-r-1);)++r;return r>0?B.substr(e,0,t-r):e}static replace(e,t,r){return e.split(t).join(r)}static get __name__(){return"StringTools"}get __class__(){return de}};var wr=s.$global,Te=s.global("$hxClasses").Lambda=class He{static exists(e,t){let r=s.getIterator(e);for(;r.hasNext();){let n=r.next();if(t(n))return!0}return!1}static get __name__(){return"Lambda"}get __class__(){return He}};var $r=s.$global,ae=s.global("$hxClasses").EReg=class Le extends s.inherits(){[s.new](e,t){this.r=new RegExp(e,t.split("u").join(""))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw S.thrown("EReg::matched")}matchedPos(){if(this.r.m==null)throw S.thrown("No string matched");return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,r){if(r==null&&(r=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(r<0?e:B.substr(e,0,t+r));let n=this.r.m!=null;return n&&(this.r.s=e),n}else{let n=this.match(r<0?B.substr(e,t,null):B.substr(e,t,r));return n&&(this.r.s=e,this.r.m.index+=t),n}}map(e,t){let r=0,n="";do{if(r>=e.length)break;if(!this.matchSub(e,r)){n+=b.string(B.substr(e,r,null));break}let i=this.matchedPos();n+=b.string(B.substr(e,r,i.pos-r)),n+=b.string(t(this)),i.len==0?(n+=b.string(B.substr(e,i.pos,1)),r=i.pos+1):r=i.pos+i.len}while(this.r.global);return!this.r.global&&r>0&&r<e.length&&(n+=b.string(B.substr(e,r,null))),n}static get __name__(){return"EReg"}get __class__(){return Le}};ae.prototype.r=null;var Tr=s.$global,Z=s.global("$hxClasses")["haxe.http.HttpJs"]=class Ue extends s.inherits(T){[s.new](e){this.async=!0,this.withCredentials=!1,super[s.new](e)}request(e){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let t=this.req=ve.createXMLHttpRequest(),r=this,n=function(g){if(t.readyState!=4)return;let c;try{c=t.status}catch{c=null}if(c==0&&ve.get_supported()&&s.$global.location!=null){let p=s.$global.location.protocol.toLowerCase();new ae("^(?:about|app|app-storage|.+-extension|file|res|widget):$","").match(p)&&(c=t.response!=null?200:404)}if(c==null&&(c=null),c!=null&&r.onStatus(c),c!=null&&c>=200&&c<400){r.req=null;let p=t.getAllResponseHeaders().split(`\r
5
+ `),$=[],_=0,m=p;for(;_<m.length;){let R=m[_];++_,R!=""&&$.push(R)}p=$;let v=new Oe;r.responseHeaders=v;let w=0;for(;w<p.length;){let R=p[w];++w;let C=R.split(": "),O=C.shift(),x=C.length==1?C[0]:C.join(": ");x=J.ltrim(J.rtrim(x)),r.responseHeaders.inst.set(O,x)}r.success(Y.ofData(t.response))}else if(c==null||c==0&&t.response==null)r.req=null,r.onError("Failed to connect or resolve host");else if(c==null){r.req=null;let p=t.response!=null?Y.ofData(t.response):null;r.responseBytes=p,r.onError("Http Error #"+t.status)}else switch(c){case 12007:r.req=null,r.onError("Unknown host");break;case 12029:r.req=null,r.onError("Failed to connect to host");break;default:r.req=null;let p=t.response!=null?Y.ofData(t.response):null;r.responseBytes=p,r.onError("Http Error #"+t.status)}};this.async&&(t.onreadystatechange=n);let i,a=this.postData,o=this.postBytes;if(a==null)if(o==null)i=null;else{let g=o;i=new Blob([g.b.bufferValue])}else o==null?i=a:i=null;if(i!=null)e=!0;else{let g=0,c=this.params;for(;g<c.length;){let p=c[g];++g,i==null?i="":i=(i==null?"null":b.string(i))+"&";let $=p.name,_=(i==null?"null":b.string(i))+encodeURIComponent($)+"=",m=p.value;i=_+encodeURIComponent(m)}}try{if(e)t.open("POST",this.url,this.async);else if(i!=null){let g=this.url.split("?").length<=1;t.open("GET",this.url+(g?"?":"&")+(i==null?"null":b.string(i)),this.async),i=null}else t.open("GET",this.url,this.async);t.responseType="arraybuffer"}catch(g){let c=S.caught(g).unwrap();this.req=null,this.onError(c.toString());return}t.withCredentials=this.withCredentials,!Te.exists(this.headers,function(g){return g.name=="Content-Type"})&&e&&this.postData==null&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded");let f=0,h=this.headers;for(;f<h.length;){let g=h[f];++f,t.setRequestHeader(g.name,g.value)}t.send(i),this.async||n(null)}static get __name__(){return"haxe.http.HttpJs"}static get __super__(){return T}get __class__(){return Ue}};Z.prototype.async=null;Z.prototype.withCredentials=null;Z.prototype.responseHeaders=null;Z.prototype.req=null;var Ur=s.$global,M=s.global("$hxClasses").SimpleFuture=class je extends s.inherits(){[s.new](){this._isFinished=!1}trigger(e){this._result=e,this._isFinished=!0,this._callback!=null&&this._callback(this._result)}then(e){this._callback=e,this._isFinished&&e(this._result)}static get __name__(){return"SimpleFuture"}get __class__(){return je}};M.prototype._callback=null;M.prototype._result=null;M.prototype._isFinished=null;var Nr=s.$global,E=s.global("$hxClasses").Reflect=class Me{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let r;if(e==null)return null;{let n;return e.__properties__?(r=e.__properties__["get_"+t],n=r):n=!1,n?e[r]():e[t]}}static setProperty(e,t,r){let n,i;e.__properties__?(n=e.__properties__["set_"+t],i=n):i=!1,i?e[n](r):e[t]=r}static fields(e){let t=[];if(e!=null){let n=Object.prototype.hasOwnProperty;for(var r in e)r!="__id__"&&r!="hx__closures__"&&n.call(e,r)&&t.push(r)}return t}static get __name__(){return"Reflect"}get __class__(){return Me}};var Zr=s.$global,l=s.global("$hxClasses")["internal.RecoBackendV2"]=class y extends s.inherits(){[s.new](){}static _requestUri(){return"https://"+y._req_domain+"/api/"+y._environment+"/recommendations/requests"}static noConsentBody(){return{device_id:"no-consent",user_group:"no-consent",version:"no-consent"}}static buildRequestBody(e){let t={lists:e,page_type:y._page_visit!=null?y._page_visit:y._page_view,channel:"www-desktop"};if(y._consent==0){let r=y.noConsentBody(),n=0,i=E.fields(r);for(;n<i.length;){let a=i[n];++n,t[a]=E.field(r,a)}}else y._user_id!=null?t.user_id=y._user_id:t.device_id=y._device_id;return t}static _requestRecos(e){let t=new M,r=null;s.$global.console.log(y._requestUri());let n=new Z(y._requestUri());n.setHeader("Content-Type","application/json"),n.setPostData(JSON.stringify(y.buildRequestBody(e))),n.onError=function(o){throw S.thrown("HTTP Request Error: "+o)},n.onStatus=function(o){if(o<200||o>=300)throw S.thrown("HTTP Status Error: "+o)};try{n.request(!1)}catch(o){let f=S.caught(o).unwrap();throw S.thrown("Failed to execute synchronous request: "+b.string(f))}let i=function(o){let f=JSON.parse(o);s.$global.console.log(b.string(f));let h=ee.fromRequestData(f);s.$global.console.log("got recommendations parsed"),t.trigger(h)},a=n.get_responseData();return a!=null?i(a):n.onData=i,t}static getRawRecommendations(e){return y._requestRecos(e)}static setConsent(e){e>2&&(e=2),y._consent=e}static setPageVisit(e){y._page_visit=e}static setEnvironment(e){y._environment=e}static setDeviceId(e){y._device_id=e}static setUserId(e){y._user_id=e}static setRequestDomain(e){y._req_domain=e}static setPageView(e){y._page_view=e}static getRequestDomain(){return y._req_domain}static getEnvironment(){return y._environment}static getPageVisit(){return y._page_visit}static getUserId(){return y._user_id}static getDeviceId(){return y._device_id}static getPageView(){return y._page_view}static get __name__(){return"internal.RecoBackendV2"}get __class__(){return y}};l._environment=null;l._device_id=null;l._user_id=null;l._consent=0;l._req_domain="europe-west1.froomle.com";l._page_visit=null;l._page_view=null;var lt=function(){};lt.__isInterface__=!0;var ot=function(){};ot.__isInterface__=!0;var ee=s.global("$hxClasses")["internal._RecommendationsInternal"]=class De extends s.inherits(){[s.new](e,t,r,n,i){this.request_id=t,this.user_group=r,this.device_id=e,this.user_id=n,this._lists=i}items(){let e=[],t=0,r=this._lists;for(;t<r.length;){let n=r[t];++t;let i=0,a=n.items;for(;i<a.length;){let o=a[i];++i,e.push(o)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,r=this._lists;for(;t<r.length;){let n=r[t];if(++t,n.list_name==e)return n}return null}static fromRequestData(e){let t=E.getProperty(e,"lists");s.$global.console.log("lists: "+b.string(t)),s.$global.console.log("data: "+b.string(e));let r=[],n=0;for(;n<t.length;){let i=t[n];++n;let a=E.getProperty(i,"items"),o=[],f=0;for(;f<a.length;){let g=a[f];++f,o.push(new ue(g))}let h=new te({limit:E.getProperty(i,"limit"),list_key:E.getProperty(i,"list_key"),list_name:E.getProperty(i,"list_name"),list_size:E.getProperty(i,"list_size"),items:o});r.push(h)}return new De(E.getProperty(e,"device_id"),E.getProperty(e,"request_id"),E.getProperty(e,"user_group"),E.getProperty(e,"user_id"),r)}static get __name__(){return"internal._RecommendationsInternal"}static get __interfaces__(){return[Q]}get __class__(){return De}};ee.prototype.request_id=null;ee.prototype.user_group=null;ee.prototype.user_id=null;ee.prototype.device_id=null;ee.prototype._lists=null;var te=s.global("$hxClasses")["internal._RecommendationsListInternal"]=class Ne extends s.inherits(){[s.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size}static get __name__(){return"internal._RecommendationsListInternal"}static get __interfaces__(){return[W]}get __class__(){return Ne}};te.prototype.limit=null;te.prototype.list_key=null;te.prototype.list_name=null;te.prototype.list_size=null;te.prototype.items=null;var ue=s.global("$hxClasses")["internal._RecommendationItemInternal"]=class Je extends s.inherits(){[s.new](e){this._data={},this.Id=E.getProperty(e,"item_id"),this.RequestId=E.getProperty(e,"request_id"),this.UserGroup=E.getProperty(e,"user_group");let t=0,r=E.fields(e);for(;t<r.length;){let n=r[t];++t,this._data[n]=E.field(e,n)}}get(e){return this._data[e]}static get __name__(){return"internal._RecommendationItemInternal"}static get __interfaces__(){return[G]}get __class__(){return Je}};ue.prototype.Id=null;ue.prototype.RequestId=null;ue.prototype.UserGroup=null;ue.prototype._data=null;var q=s.global("$hxClasses")["internal._RecoBackendV2.RecoBackendV2_Fields_"]=class ke{static getRawRecommendations(e){return l.getRawRecommendations(e)}static setConsent(e){l.setConsent(e)}static setPageVisit(e){l.setPageVisit(e)}static setEnvironment(e){l.setEnvironment(e)}static setDeviceId(e){l.setDeviceId(e)}static setUserId(e){l.setUserId(e)}static setRequestDomain(e){l.setRequestDomain(e)}static setPageView(e){l.setPageView(e)}static getConsent(){ke.getConsent()}static getPageVisit(){l.getPageVisit()}static getEnvironment(){l.getEnvironment()}static getDeviceId(){l.getDeviceId()}static getUserId(){l.getUserId()}static getPageView(){l.getPageView()}static get __name__(){return"internal._RecoBackendV2.RecoBackendV2_Fields_"}get __class__(){return ke}},es=q.getRawRecommendations,ts=q.setConsent,rs=q.setPageVisit,ss=q.setEnvironment,ns=q.setDeviceId,is=q.setUserId,ls=q.setRequestDomain,os=q.setPageView,as=q.getConsent,us=q.getPageVisit,cs=q.getEnvironment,gs=q.getDeviceId,_s=q.getUserId,ms=q.getPageView;var fs=s.$global,A=s.global("$hxClasses").FroomleSdk=class V{static register(){V.registered||V._env_set&&(!V._page_visit_set&&!V._page_view_set||(V.registered=!0))}static setEnvironment(e){l.setEnvironment(e),V._env_set=!0,V.register()}static setDeviceId(e){l.setDeviceId(e)}static setUserId(e){l.setUserId(e)}static setConsent(e){l.setConsent(e)}static setPageView(e){l.setPageView(e),V._page_view_set=!0,V.register()}static setPageVisit(e){l.setPageVisit(e),V._page_visit_set=!0,V.register()}static setRequestDomain(e){l.setRequestDomain(e)}static getRawRecommendations(e){return l.getRawRecommendations(e)}static getVersion(){return"0.0.1"}static get __name__(){return"FroomleSdk"}get __class__(){return V}};A._env_set=!1;A._page_visit_set=!1;A._page_view_set=!1;A.registered=!1;var ws=s.$global,re=s.global("$hxClasses")["internal.domHandler.FroomleDomTree"]=class fe extends s.inherits(){[s.new](){}createElement(e){return window.document.createElement(e)}querySelectorAll(e){let t=this.root,r=[],n=t.querySelectorAll(e),i=0,a=n.length;for(;i<a;){let o=i++;r.push(n.item(o))}return r}getRoot(){return this.root}toString(){return this.root.outerHTML}static run(){}static fromHtml(e){return new fe}static fromDocument(){let e=new fe;return e.root=window.document,e}static get __name__(){return"internal.domHandler.FroomleDomTree"}get __class__(){return fe}};re.prototype.root=null;var Rs=s.$global,U=s.global("$hxClasses")["internal._ADomNode.ADomNode"]=class Se{static _new(e){return e}static fromElement(e){return e}static create(e,t){return window.document.createElement(t)}static replaceChild(e,t,r){e.replaceChild(t,r)}static get attributes(){return this.get_attributes()}static get_attributes(e){let t=e,r=[],n=0,i=t.attributes.length;for(;n<i;){let a=n++,o=t.attributes.item(a);r.push({name:o.name,value:o.value})}return r}static addChild(e,t){e.appendChild(t)}static removeChild(e,t){e.removeChild(t)}static getAttribute(e,t){return e.getAttribute(t)}static setAttribute(e,t,r){e.setAttribute(t,r)}static getText(e){return e.textContent}static setText(e,t){e.textContent=t}static get children(){return this.get_children()}static get_children(e){let t=[],n=e.children,i=0,a=n.length;for(;i<a;){let o=i++;t.push(n[o])}return t}static querySelectorAll(e,t){let r=e,n=[],i=r.querySelectorAll(t),a=0,o=i.length;for(;a<o;){let f=a++;n.push(i.item(f))}return n}static getFilterKeyValue(e){let t=0,r=Se.get_attributes(e);for(;t<r.length;){let n=r[t];if(++t,n.name.startsWith("data-froomle-reco-filter-"))return{key:n.name.substring(25),value:n.value}}return{key:null,value:null}}static get __name__(){return"internal._ADomNode.ADomNode_Impl_"}get __class__(){return Se}};var As=s.$global,ce=s.global("$hxClasses")["internal.domHandler.DomDomDom"]=class z extends s.inherits(){[s.new](){}static _fillRecoTargets(e){let t=new M;if(e==null)return t.trigger(!1),t;s.$global.console.log("filling recos");let r=[],n=e,i=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let d=o++;i.push(a.item(d))}let h=i;s.$global.console.log(h.length+" amount of elements");let g=0;for(;g<h.length;){let d=h[g];++g;let k=0,I=U.get_attributes(d);for(;k<I.length;){let N=I[k];++k,N.name=="data-froomle-reco"&&r.push(d)}}s.$global.console.log("amount of targets: "+(r.length==null?"null":""+r.length));let c=[],p=0;for(;p<r.length;){let d=r[p];++p,d.getAttribute("data-froomle-request-id")==null&&(d.getAttribute("data-froomle-id")==null||d.getAttribute("data-froomle-id")=="")&&c.push(d)}if(s.$global.console.log("filtered: "+b.string(c)),s.$global.console.log("filtered targets length "+c.length),c.length<1)return new M;let $=[],_=[],m="",v="",w="",R=[],C=function(){let d={list_name:m,list_size:R.length,limit:R.length};v!=null&&E.setProperty(d,v,w),$.push(d),_.push(R),s.$global.console.log("pushed a list with name:"+m+"filter_key: "+(v==null?"null":""+v)+" and value "+(w==null?"null":""+w)),s.$global.console.log("had length "+d.list_size)},O=function(d,k,I,N){m=d,v=k,w=I,R=[N]},x=0;for(;x<c.length;){let d=c[x];++x;let k=d.getAttribute("data-froomle-reco"),I=U.getFilterKeyValue(d);if(m==""){O(k,I.key,I.value,d);continue}else if(k==m&&I.key==v&&I.value==w){R.push(d);continue}else{C(),O(k,I.key,I.value,d);continue}}m!=""&&C();let D=q.getRawRecommendations($);return s.$global.console.log("should have recos"),D.then(function(d){let k=0,I=d.lists();for(;k<I.length;){let N=I[k],H=k++,j=N,X=j.items.length!=_[H].length,ne=0,be=j.items;for(;ne<be.length;){let ye=be[ne],Ye=ne++,Ze=ye;z._fillParameters(_[H][Ye],Ze,d.request_id)}}t.trigger(!0)}),t}static _fillParameters(e,t,r){let n=function(p,$,_,m){m==null&&(m="");let v=function(w,R,C){C==null&&(C="fgh");try{R=new ae("\\\\[(\\\\w+)\\\\]","g").map(R,function(I){return"."+I.matched(1)}),R=J.replace(R,"[","."),R=J.replace(R,"]",""),B.cca(R,0)==46&&(R=B.substr(R,1,null));let x=R.split("."),D=w.get(x[0]),d=1,k=x.length;for(;d<k;){let I=d++;if(D==null)return null;D instanceof Array&&b.parseInt(x[I])!=null?D=D[b.parseInt(x[I])]:D=E.field(D,x[I])}return D}catch{return C}};try{let w=v(t,_,m);$=="inner"?p.textContent=w:p.setAttribute($,w)}catch{}};e.setAttribute("data-froomle-id",t.Id),e.setAttribute("data-froomle-request-id",r);let i=e,a=[],o=i.querySelectorAll("*"),f=0,h=o.length;for(;f<h;){let p=f++;a.push(o.item(p))}let g=a,c=0;for(;c<g.length;){let p=g[c];++c;let $=0,_=U.get_attributes(p);for(;$<_.length;){let m=_[$];if(++$,m.name.startsWith("data-froomle-param-")){let v=J.replace(m.name,"data-froomle-param-",""),w=m.value;n(p,v,w)}}}}static _orderElements(e){let t=function(_,m,v){let w=[],R=U.get_children(_),C=0;for(;C<R.length;){let D=R[C];if(++C,D.getAttribute("data-froomle-ordervalue")!=null){w.push(D);let k=U.create(e,"span");k.setAttribute("data-froomle-tmp-node",""),U.replaceChild(_,k,D)}}let O=[],x=0;for(;x<w.length;){let D=w[x];++x,O.push(D.getAttribute("data-froomle-ordervalue"))}return{el:_,key:m,values:O,orderChildren:w,list_name:v}},r=new M,n=e.getRoot(),i=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let _=o++;i.push(a.item(_))}let h=i,g=[],c=0;for(;c<h.length;){let _=h[c];++c;let m=0,v=U.get_attributes(_);for(;m<v.length;){let w=v[m];++m,w.name.startsWith("data-froomle-order-")&&g.push(t(_,w.name.substring(19),w.value))}}if(g.length<1)return r.trigger(!1),r;let p=[],$=0;for(;$<g.length;){let _=g[$];++$;let m={list_name:_.list_name,limit:_.values.length,list_size:_.values.length},v={};E.setProperty(v,_.key,_.values),E.setProperty(m,"order",v),p.push(m)}return q.getRawRecommendations(p).then(function(_){s.$global.console.log("got order recos"),s.$global.console.log(b.string(_));let m=0,v=_.lists();for(;m<v.length;){let w=v[m],C=m++,O=w,x=g[C];x.el.setAttribute("data-froomle-request-id",_.request_id),s.$global.console.log("children "+b.string(x.orderChildren));let D=[],d=0,k=O.items;for(;d<k.length;){let K=k[d];++d;let H=K.get(x.key);s.$global.console.log("looking for value "+H+" for key "+x.key),s.$global.console.log("item was "+b.string(K));let j=0,X=x.values;for(;j<X.length;){let ne=X[j],ye=j++;if(H==ne){s.$global.console.log("found matching value "+H),D.push(x.orderChildren[ye]);break}}}s.$global.console.log("sorted items "+b.string(D));let I=0,N=D.length;for(;I<N;){let K=I++;s.$global.console.log("replacing in section "+b.string(x.el.innerHTML)+" the item "+b.string(D[K]));let H=0,j=U.get_children(x.el);for(;H<j.length;){let X=j[H];if(++H,X.getAttribute("data-froomle-tmp-node")==""){U.replaceChild(x.el,D[K],X);break}}}s.$global.console.log("done replacing for section "+b.string(x.el.innerHTML)),s.$global.console.log("sorted items "+b.string(D))}r.trigger(!0)}),r}static domInit(e){z._orderElements(e).then(function(t){z._fillRecoTargets(e.getRoot())})}static fillElementRecos(e){z._fillRecoTargets(e)}static runFromHtml(e){let t=re.fromHtml(e);return z.domInit(t),t.toString()}static get __name__(){return"internal.domHandler.DomDomDom"}get __class__(){return z}};var Ts=s.$global;var P=class P{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e=[];for(let t of P.impressionQueue){let r={event_type:"impression",page_type:l.getPageVisit(),action_item:t.getAttribute("data-froomle-id"),action_item_type:"article",channel:"www-desktop"};l.getUserId()?r.user_id=l.getUserId():r.device_id=l.getDeviceId();let n=t.getAttribute("data-froomle-reco");if(n){r.list_name=n;let i=t.getAttribute("data-froomle-request-id");if(!i)throw console.error("element need reco but doesnt have request id registered yet"),new Error("element need reco but doesnt have request id registered");r.request_id=i}}return P.impressionQueue=[],JSON.stringify({events:e})}static sendImpressions(){P.impressionQueue.length!==0&&fetch(P.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:P.generateBody()})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(e){let t=e.getBoundingClientRect(),r=P.getViewPortRect();return t.right>r.left&&t.left<r.right&&t.bottom>r.top&&t.top<r.bottom}static addIntersectionImpressionListener(e){P.observer.observe(e)}static processDocument(){if(l.getDeviceId()!="no-consent"){for(let e of document.querySelectorAll("[data-froomle-id]"))P.intersectsWithViewPortRect(e)?P.impressionQueue.push(e):P.addIntersectionImpressionListener(e);P.sendImpressions()}}};P.impressionQueue=[],P.observer=new IntersectionObserver((e,t)=>{e.forEach(r=>{r.isIntersecting&&(P.impressionQueue.push(r.target),P.observer.unobserve(r.target))}),P.impressionQueue.length>0&&P.sendImpressions()});var se=P;var ge=class u{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e={event_type:"page_visit",page_type:l.getPageVisit(),channel:"www-desktop"};return l.getUserId()?e.user_id=l.getUserId():e.device_id=l.getDeviceId(),JSON.stringify(e)}static sendPageVisit(){l.getPageVisit()&&l.getDeviceId()!="no-consent"&&fetch(u.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:u.generateBody()})}};var _e=class u{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e={event_type:"detail_pageview",page_type:"article_detail",action_item:l.getPageView(),action_item_type:"article",channel:"www-desktop"};return l.getUserId()?e.user_id=l.getUserId():e.device_id=l.getDeviceId(),JSON.stringify(e)}static sendPageView(){l.getPageView()&&l.getDeviceId()!="no-consent"&&fetch(u.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:u.generateBody()})}};var ze=A.setEnvironment,Ke=A.setPageVisit,at=A.setConsent,Xe=A.setUserId,Qe=A.setDeviceId,We=A.setRequestDomain;if(typeof document!="undefined"){let u=document.currentScript;if(console.log("dom loaded"),console.log(u),u){console.log("loaded script");let e=u.getAttribute("data-froomle-device-id"),t=u.getAttribute("data-froomle-user-id"),r=u.getAttribute("data-froomle-env"),n=u.getAttribute("data-froomle-page-visit"),i=u.getAttribute("data-froomle-request-domain");ze(r),Ke(n),e&&Qe(e),t&&Xe(t),i&&We(i)}else console.error("Froomle SDK: could not find the script tag where the sdk is included.");document.addEventListener("DOMContentLoaded",()=>{ce.domInit(re.fromDocument()),se.processDocument(),ge.sendPageVisit(),_e.sendPageView(),new MutationObserver(t=>{for(let r of t)if(r.type==="childList"&&se.processElement(r.target),r.type==="attributes")if(r.attributeName==="data-froomle-reco"){let n=r.target.getAttribute("data-froomle-request-id");(!n||n==="")&&ce.fillElementRecos(r.target)}else r.attributeName==="data-froomle-request-id"&&ce.fillElementRecos(r.target)}).observe(document,{childList:!0,subtree:!0})})}
@@ -0,0 +1,61 @@
1
+ declare interface Recommendations {
2
+ request_id: string
3
+ user_group: string
4
+ user_id: string
5
+ device_id: string
6
+ lists(): RecommendationList[]
7
+ }
8
+
9
+ declare interface RecommendationList {
10
+ limit: number
11
+ list_key: string
12
+ list_name: string
13
+ list_size: number
14
+ items: RecommendationItem[]
15
+ }
16
+
17
+ declare interface RecommendationItem {
18
+ get(key: string): any
19
+ Id: string
20
+ RequestId: string
21
+ UserGroup: string
22
+ }
23
+
24
+ declare class SimpleFuture<T> {
25
+ constructor()
26
+ protected _callback: (arg0: T) => void
27
+ protected _result: null | T
28
+ protected _isFinished: boolean
29
+ trigger(data: T): void
30
+ then(callback: ((arg0: T) => void)): void
31
+ }
32
+
33
+ declare class FroomleSdk {
34
+ protected static _env_set: boolean
35
+ protected static _page_visit_set: boolean
36
+ protected static _page_view_set: boolean
37
+ protected static registered: boolean
38
+ protected static register(): void
39
+ static setEnvironment(env: string): void
40
+ static setDeviceId(id: string): void
41
+ static setUserId(id: string): void
42
+ static setConsent(consent: number): void
43
+ static setPageView(page: string): void
44
+ static setPageVisit(page: string): void
45
+ static setRequestDomain(domain: string): void
46
+ static getRawRecommendations(lists: {
47
+ limit: number,
48
+ list_name: string,
49
+ list_size: number
50
+ }[]): SimpleFuture<Recommendations>
51
+ static getVersion(): string
52
+ }
53
+
54
+ declare const setPageVisit: typeof FroomleSdk.setPageVisit;
55
+ declare const setEnvironment: typeof FroomleSdk.setEnvironment;
56
+ declare const setConsent: typeof FroomleSdk.setConsent;
57
+ declare const setUserId: typeof FroomleSdk.setUserId;
58
+ declare const setDeviceId: typeof FroomleSdk.setDeviceId;
59
+ declare const setRequestDomain: typeof FroomleSdk.setRequestDomain;
60
+
61
+ export { type RecommendationItem, type RecommendationList, type Recommendations, setConsent, setDeviceId, setEnvironment, setPageVisit, setRequestDomain, setUserId };
@@ -0,0 +1,61 @@
1
+ declare interface Recommendations {
2
+ request_id: string
3
+ user_group: string
4
+ user_id: string
5
+ device_id: string
6
+ lists(): RecommendationList[]
7
+ }
8
+
9
+ declare interface RecommendationList {
10
+ limit: number
11
+ list_key: string
12
+ list_name: string
13
+ list_size: number
14
+ items: RecommendationItem[]
15
+ }
16
+
17
+ declare interface RecommendationItem {
18
+ get(key: string): any
19
+ Id: string
20
+ RequestId: string
21
+ UserGroup: string
22
+ }
23
+
24
+ declare class SimpleFuture<T> {
25
+ constructor()
26
+ protected _callback: (arg0: T) => void
27
+ protected _result: null | T
28
+ protected _isFinished: boolean
29
+ trigger(data: T): void
30
+ then(callback: ((arg0: T) => void)): void
31
+ }
32
+
33
+ declare class FroomleSdk {
34
+ protected static _env_set: boolean
35
+ protected static _page_visit_set: boolean
36
+ protected static _page_view_set: boolean
37
+ protected static registered: boolean
38
+ protected static register(): void
39
+ static setEnvironment(env: string): void
40
+ static setDeviceId(id: string): void
41
+ static setUserId(id: string): void
42
+ static setConsent(consent: number): void
43
+ static setPageView(page: string): void
44
+ static setPageVisit(page: string): void
45
+ static setRequestDomain(domain: string): void
46
+ static getRawRecommendations(lists: {
47
+ limit: number,
48
+ list_name: string,
49
+ list_size: number
50
+ }[]): SimpleFuture<Recommendations>
51
+ static getVersion(): string
52
+ }
53
+
54
+ declare const setPageVisit: typeof FroomleSdk.setPageVisit;
55
+ declare const setEnvironment: typeof FroomleSdk.setEnvironment;
56
+ declare const setConsent: typeof FroomleSdk.setConsent;
57
+ declare const setUserId: typeof FroomleSdk.setUserId;
58
+ declare const setDeviceId: typeof FroomleSdk.setDeviceId;
59
+ declare const setRequestDomain: typeof FroomleSdk.setRequestDomain;
60
+
61
+ export { type RecommendationItem, type RecommendationList, type Recommendations, setConsent, setDeviceId, setEnvironment, setPageVisit, setRequestDomain, setUserId };
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ var s=class _{static global(e){return _.globals[e]?_.globals[e]:_.globals[e]={}}static createStatic(e,t,r){let n=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return r!=null&&(n=r(),r=null),n},set:function(i){r!=null&&(n=r(),r=null),n=i}})}static iterator(e){if(Array.isArray(e)){let t=e;return function(){return _.mkIter(t)}}else return typeof e.iterator=="function"?e.iterator.bind(e):e.iterator}static getIterator(e){return Array.isArray(e)?_.mkIter(e):e.iterator()}static mkIter(e){return new we(e)}static extend(e){function t(){this[_.new].apply(this,arguments)}return Object.setPrototypeOf(t.prototype,e.prototype),t}static inherits(e,t){t==null&&(t=!1);function r(){t&&e&&r[_.init]&&r[_.init](),this[_.new].apply(this,arguments)}return t?r[_.init]=()=>{let n=e();n[_.init]&&n[_.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[_.init]=void 0}:e&&e[_.init]?(t=!0,r[_.init]=()=>{e[_.init]&&e[_.init](),Object.setPrototypeOf(r.prototype,e.prototype),r[_.init]=void 0}):e&&Object.setPrototypeOf(r.prototype,e.prototype),r}static bind(e,t){if(t==null)return null;t.__id__==null&&(t.__id__=_.fid++);let r=null;return e.hx__closures__==null?e.hx__closures__={}:r=e.hx__closures__[t.__id__],r==null&&(r=t.bind(e),e.hx__closures__[t.__id__]=r),r}static get __name__(){return"genes.Register"}get __class__(){return _}};s.$global=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:void 0;s.globals={};s.new=Symbol();s.init=Symbol();s.fid=0;var we=s.global("$hxClasses")["genes._Register.ArrayIterator"]=class Se extends s.inherits(){[s.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return"genes._Register.ArrayIterator"}get __class__(){return Se}};we.prototype.array=null;we.prototype.current=null;var st=s.$global,re=function(){};re.__isInterface__=!0;var se=function(){};se.__isInterface__=!0;var ne=function(){};ne.__isInterface__=!0;var ot=s.$global,me=s.global("$hxClasses")["haxe.ValueException"]=class Pe extends s.inherits(()=>S,!0){[s.new](e,t,r){super[s.new](String(e),t,r),this.value=e}unwrap(){return this.value}static get __name__(){return"haxe.ValueException"}static get __super__(){return S}get __class__(){return Pe}};me.prototype.value=null;var gt=s.$global,S=s.global("$hxClasses")["haxe.Exception"]=class ie extends s.inherits(()=>Error,!0){[s.new](e,t,r){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=r!=null?r:this}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof ie?e:e instanceof Error?new ie(e.message,null,e):new me(e,null,e)}static thrown(e){return e instanceof ie?e.get_native():e instanceof Error?e:new me(e)}static get __name__(){return"haxe.Exception"}static get __super__(){return Error}get __class__(){return ie}};S.prototype.native=null;S.prototype.__skipStack=null;S.prototype.__nativeException=null;S.prototype.__previousException=null;var ht=s.$global,xe=s.global("$hxClasses")["js.Browser"]=class Ce{static get supported(){return this.get_supported()}static get_supported(){return typeof window!="undefined"&&typeof window.location!="undefined"?typeof window.location.protocol=="string":!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")return new"ActiveXObject"("Microsoft.XMLHTTP");throw S.thrown("Unable to create XMLHttpRequest object.")}static get __name__(){return"js.Browser"}get __class__(){return Ce}};var bt=s.$global,F=s.global("$hxEnums")["haxe.io.Error"]={__ename__:"haxe.io.Error",Blocked:{_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error"},Overflow:{_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error"},OutsideBounds:{_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error"},Custom:Object.assign(_=>({_hx_index:3,__enum__:"haxe.io.Error",e:_}),{_hx_name:"Custom",__params__:["e"]})};F.__constructs__=[F.Blocked,F.Overflow,F.OutsideBounds,F.Custom];F.__empty_constructs__=[F.Blocked,F.Overflow,F.OutsideBounds];var xt=s.$global,L=s.global("$hxEnums")["haxe.io.Encoding"]={__ename__:"haxe.io.Encoding",UTF8:{_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding"},RawNative:{_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding"}};L.__constructs__=[L.UTF8,L.RawNative];L.__empty_constructs__=[L.UTF8,L.RawNative];var Dt=s.$global,Q=s.global("$hxClasses")["haxe.io.Bytes"]=class ve extends s.inherits(){[s.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,r){if(e<0||t<0||e+t>this.length)throw S.thrown(F.OutsideBounds);r==null&&(r=L.UTF8);let n="",i=this.b,a=e,o=e+t;switch(r._hx_index){case 0:let f=e>0;for(;a<o;){let h=i[a++];if(h<128){if(h==0)break;n+=String.fromCodePoint(h)}else if(h<224){let c=(h&63)<<6|i[a++]&127;n+=String.fromCodePoint(c)}else if(h<240){let c=i[a++],u=(h&31)<<12|(c&127)<<6|i[a++]&127;n+=String.fromCodePoint(u)}else{let c=i[a++],u=i[a++],p=(h&15)<<18|(c&127)<<12|(u&127)<<6|i[a++]&127;n+=String.fromCodePoint(p)}}break;case 1:for(;a<o;){let h=i[a++]|i[a++]<<8;n+=String.fromCodePoint(h)}break}return n}static ofData(e){let t=e.hxBytes;return t!=null?t:new ve(e)}static get __name__(){return"haxe.io.Bytes"}get __class__(){return ve}};Q.prototype.length=null;Q.prototype.b=null;var Ct=s.$global,T=s.global("$hxClasses")["haxe.http.HttpBase"]=class qe extends s.inherits(){[s.new](e){this.url=e,this.headers=[],this.params=[],this.emptyOnData=s.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let r=0,n=this.headers.length;for(;r<n;){let i=r++;if(this.headers[i].name==e){this.headers[i]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return s.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,L.UTF8)),this.responseAsString}static get __name__(){return"haxe.http.HttpBase"}get __class__(){return qe}};T.prototype.url=null;T.prototype.responseBytes=null;T.prototype.responseAsString=null;T.prototype.postData=null;T.prototype.postBytes=null;T.prototype.headers=null;T.prototype.params=null;T.prototype.emptyOnData=null;var Vt=s.$global,pe=s.global("$hxClasses")["haxe.iterators.MapKeyValueIterator"]=class Be extends s.inherits(){[s.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return"haxe.iterators.MapKeyValueIterator"}get __class__(){return Be}};pe.prototype.map=null;pe.prototype.keys=null;var Ft=s.$global,Re=function(){};Re.__isInterface__=!0;var Lt=s.$global,Ie=s.global("$hxClasses")["js.Boot"]=class le{static __string_rec(e,t){if(e==null)return"null";if(t.length>=5)return"<...>";let r=typeof e;switch(r=="function"&&(e.__name__||e.__ename__)&&(r="object"),r){case"function":return"<function>";case"object":if(e.__enum__){let h=s.global("$hxEnums")[e.__enum__].__constructs__[e._hx_index],c=h._hx_name;return h.__params__?(t=t+" ",c+"("+(function(u){var p;let $=[];{let g=0,m=h.__params__;for(;g<m.length;){let v=m[g];g=g+1,$.push(le.__string_rec(e[v],t))}}return p=$,p})(this).join(",")+")"):c}if(e instanceof Array){let f="[";t+=" ";let h=0,c=e.length;for(;h<c;){let u=h++;f+=(u>0?",":"")+le.__string_rec(e[u],t)}return f+="]",f}let n;try{n=e.toString}catch{return"???"}if(n!=null&&n!=Object.toString&&typeof n=="function"){let f=e.toString();if(f!="[object Object]")return f}let i=`{
2
+ `;t+=" ";let a=e.hasOwnProperty!=null,o=null;for(o in e)a&&!e.hasOwnProperty(o)||o=="prototype"||o=="__class__"||o=="__super__"||o=="__interfaces__"||o=="__properties__"||(i.length!=2&&(i+=`,
3
+ `),i+=t+o+" : "+le.__string_rec(e[o],t));return t=t.substring(1),i+=`
4
+ `+t+"}",i;break;case"string":return e;default:return String(e)}}static get __name__(){return"js.Boot"}get __class__(){return le}};Ie.__toStr={}.toString;var Nt=s.$global,b=s.global("$hxClasses").Std=class Ve{static string(e){return Ie.__string_rec(e,"")}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static get __name__(){return"Std"}get __class__(){return Ve}};String.__name__=!0,Array.__name__=!0;var Xt=s.$global,he=s.global("$hxClasses")["genes.util.EsMap"]=class oe extends s.inherits(){[s.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return oe.adaptIterator(this.inst.keys())}iterator(){return oe.adaptIterator(this.inst.values())}toString(){let e=[],t=oe.adaptIterator(this.inst.keys());for(;t.hasNext();){let r=t.next();e.push(""+b.string(r)+" => "+b.string(this.inst.get(r)))}return"{"+e.join(", ")+"}"}clear(){this.inst.clear()}static adaptIterator(e){let t,r,n=function(){let i=e.next();t=i.value,r=i.done};return{hasNext:function(){return r==null&&n(),!r},next:function(){r==null&&n();let i=t;return n(),i}}}static get __name__(){return"genes.util.EsMap"}get __class__(){return oe}};he.prototype.inst=null;var er=s.$global,Ae=s.global("$hxClasses")["haxe.ds.StringMap"]=class Ee extends s.inherits(he){[s.new](){super[s.new]()}copy(){let e=new Ee;return e.inst=new Map(this.inst),e}keyValueIterator(){return new pe(this)}static get __name__(){return"haxe.ds.StringMap"}static get __interfaces__(){return[Re]}static get __super__(){return he}get __class__(){return Ee}};var sr=s.$global,B=s.global("$hxClasses").HxOverrides=class Oe{static cca(e,t){let r=e.charCodeAt(t);if(r==r)return r}static substr(e,t,r){if(r==null)r=e.length;else if(r<0)if(t==0)r=e.length+r;else return"";return e.substr(t,r)}static now(){return Date.now()}static get __name__(){return"HxOverrides"}get __class__(){return Oe}};typeof performance!="undefined"&&typeof performance.now=="function"&&(B.now=performance.now.bind(performance));var or=s.$global,J=s.global("$hxClasses").StringTools=class de{static isSpace(e,t){let r=B.cca(e,t);return r>8&&r<14?!0:r==32}static ltrim(e){let t=e.length,r=0;for(;r<t&&de.isSpace(e,r);)++r;return r>0?B.substr(e,r,t-r):e}static rtrim(e){let t=e.length,r=0;for(;r<t&&de.isSpace(e,t-r-1);)++r;return r>0?B.substr(e,0,t-r):e}static replace(e,t,r){return e.split(t).join(r)}static get __name__(){return"StringTools"}get __class__(){return de}};var cr=s.$global,Fe=s.global("$hxClasses").Lambda=class Te{static exists(e,t){let r=s.getIterator(e);for(;r.hasNext();){let n=r.next();if(t(n))return!0}return!1}static get __name__(){return"Lambda"}get __class__(){return Te}};var dr=s.$global,ae=s.global("$hxClasses").EReg=class He extends s.inherits(){[s.new](e,t){this.r=new RegExp(e,t.split("u").join(""))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw S.thrown("EReg::matched")}matchedPos(){if(this.r.m==null)throw S.thrown("No string matched");return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,r){if(r==null&&(r=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(r<0?e:B.substr(e,0,t+r));let n=this.r.m!=null;return n&&(this.r.s=e),n}else{let n=this.match(r<0?B.substr(e,t,null):B.substr(e,t,r));return n&&(this.r.s=e,this.r.m.index+=t),n}}map(e,t){let r=0,n="";do{if(r>=e.length)break;if(!this.matchSub(e,r)){n+=b.string(B.substr(e,r,null));break}let i=this.matchedPos();n+=b.string(B.substr(e,r,i.pos-r)),n+=b.string(t(this)),i.len==0?(n+=b.string(B.substr(e,i.pos,1)),r=i.pos+1):r=i.pos+i.len}while(this.r.global);return!this.r.global&&r>0&&r<e.length&&(n+=b.string(B.substr(e,r,null))),n}static get __name__(){return"EReg"}get __class__(){return He}};ae.prototype.r=null;var kr=s.$global,W=s.global("$hxClasses")["haxe.http.HttpJs"]=class Le extends s.inherits(T){[s.new](e){this.async=!0,this.withCredentials=!1,super[s.new](e)}request(e){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let t=this.req=xe.createXMLHttpRequest(),r=this,n=function(c){if(t.readyState!=4)return;let u;try{u=t.status}catch{u=null}if(u==0&&xe.get_supported()&&s.$global.location!=null){let p=s.$global.location.protocol.toLowerCase();new ae("^(?:about|app|app-storage|.+-extension|file|res|widget):$","").match(p)&&(u=t.response!=null?200:404)}if(u==null&&(u=null),u!=null&&r.onStatus(u),u!=null&&u>=200&&u<400){r.req=null;let p=t.getAllResponseHeaders().split(`\r
5
+ `),$=[],g=0,m=p;for(;g<m.length;){let R=m[g];++g,R!=""&&$.push(R)}p=$;let v=new Ae;r.responseHeaders=v;let w=0;for(;w<p.length;){let R=p[w];++w;let C=R.split(": "),O=C.shift(),x=C.length==1?C[0]:C.join(": ");x=J.ltrim(J.rtrim(x)),r.responseHeaders.inst.set(O,x)}r.success(Q.ofData(t.response))}else if(u==null||u==0&&t.response==null)r.req=null,r.onError("Failed to connect or resolve host");else if(u==null){r.req=null;let p=t.response!=null?Q.ofData(t.response):null;r.responseBytes=p,r.onError("Http Error #"+t.status)}else switch(u){case 12007:r.req=null,r.onError("Unknown host");break;case 12029:r.req=null,r.onError("Failed to connect to host");break;default:r.req=null;let p=t.response!=null?Q.ofData(t.response):null;r.responseBytes=p,r.onError("Http Error #"+t.status)}};this.async&&(t.onreadystatechange=n);let i,a=this.postData,o=this.postBytes;if(a==null)if(o==null)i=null;else{let c=o;i=new Blob([c.b.bufferValue])}else o==null?i=a:i=null;if(i!=null)e=!0;else{let c=0,u=this.params;for(;c<u.length;){let p=u[c];++c,i==null?i="":i=(i==null?"null":b.string(i))+"&";let $=p.name,g=(i==null?"null":b.string(i))+encodeURIComponent($)+"=",m=p.value;i=g+encodeURIComponent(m)}}try{if(e)t.open("POST",this.url,this.async);else if(i!=null){let c=this.url.split("?").length<=1;t.open("GET",this.url+(c?"?":"&")+(i==null?"null":b.string(i)),this.async),i=null}else t.open("GET",this.url,this.async);t.responseType="arraybuffer"}catch(c){let u=S.caught(c).unwrap();this.req=null,this.onError(u.toString());return}t.withCredentials=this.withCredentials,!Fe.exists(this.headers,function(c){return c.name=="Content-Type"})&&e&&this.postData==null&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded");let f=0,h=this.headers;for(;f<h.length;){let c=h[f];++f,t.setRequestHeader(c.name,c.value)}t.send(i),this.async||n(null)}static get __name__(){return"haxe.http.HttpJs"}static get __super__(){return T}get __class__(){return Le}};W.prototype.async=null;W.prototype.withCredentials=null;W.prototype.responseHeaders=null;W.prototype.req=null;var Cr=s.$global,M=s.global("$hxClasses").SimpleFuture=class Ue extends s.inherits(){[s.new](){this._isFinished=!1}trigger(e){this._result=e,this._isFinished=!0,this._callback!=null&&this._callback(this._result)}then(e){this._callback=e,this._isFinished&&e(this._result)}static get __name__(){return"SimpleFuture"}get __class__(){return Ue}};M.prototype._callback=null;M.prototype._result=null;M.prototype._isFinished=null;var Vr=s.$global,E=s.global("$hxClasses").Reflect=class je{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let r;if(e==null)return null;{let n;return e.__properties__?(r=e.__properties__["get_"+t],n=r):n=!1,n?e[r]():e[t]}}static setProperty(e,t,r){let n,i;e.__properties__?(n=e.__properties__["set_"+t],i=n):i=!1,i?e[n](r):e[t]=r}static fields(e){let t=[];if(e!=null){let n=Object.prototype.hasOwnProperty;for(var r in e)r!="__id__"&&r!="hx__closures__"&&n.call(e,r)&&t.push(r)}return t}static get __name__(){return"Reflect"}get __class__(){return je}};var Mr=s.$global,l=s.global("$hxClasses")["internal.RecoBackendV2"]=class y extends s.inherits(){[s.new](){}static _requestUri(){return"https://"+y._req_domain+"/api/"+y._environment+"/recommendations/requests"}static noConsentBody(){return{device_id:"no-consent",user_group:"no-consent",version:"no-consent"}}static buildRequestBody(e){let t={lists:e,page_type:y._page_visit!=null?y._page_visit:y._page_view,channel:"www-desktop"};if(y._consent==0){let r=y.noConsentBody(),n=0,i=E.fields(r);for(;n<i.length;){let a=i[n];++n,t[a]=E.field(r,a)}}else y._user_id!=null?t.user_id=y._user_id:t.device_id=y._device_id;return t}static _requestRecos(e){let t=new M,r=null;s.$global.console.log(y._requestUri());let n=new W(y._requestUri());n.setHeader("Content-Type","application/json"),n.setPostData(JSON.stringify(y.buildRequestBody(e))),n.onError=function(o){throw S.thrown("HTTP Request Error: "+o)},n.onStatus=function(o){if(o<200||o>=300)throw S.thrown("HTTP Status Error: "+o)};try{n.request(!1)}catch(o){let f=S.caught(o).unwrap();throw S.thrown("Failed to execute synchronous request: "+b.string(f))}let i=function(o){let f=JSON.parse(o);s.$global.console.log(b.string(f));let h=G.fromRequestData(f);s.$global.console.log("got recommendations parsed"),t.trigger(h)},a=n.get_responseData();return a!=null?i(a):n.onData=i,t}static getRawRecommendations(e){return y._requestRecos(e)}static setConsent(e){e>2&&(e=2),y._consent=e}static setPageVisit(e){y._page_visit=e}static setEnvironment(e){y._environment=e}static setDeviceId(e){y._device_id=e}static setUserId(e){y._user_id=e}static setRequestDomain(e){y._req_domain=e}static setPageView(e){y._page_view=e}static getRequestDomain(){return y._req_domain}static getEnvironment(){return y._environment}static getPageVisit(){return y._page_visit}static getUserId(){return y._user_id}static getDeviceId(){return y._device_id}static getPageView(){return y._page_view}static get __name__(){return"internal.RecoBackendV2"}get __class__(){return y}};l._environment=null;l._device_id=null;l._user_id=null;l._consent=0;l._req_domain="europe-west1.froomle.com";l._page_visit=null;l._page_view=null;var Xe=function(){};Xe.__isInterface__=!0;var Qe=function(){};Qe.__isInterface__=!0;var G=s.global("$hxClasses")["internal._RecommendationsInternal"]=class $e extends s.inherits(){[s.new](e,t,r,n,i){this.request_id=t,this.user_group=r,this.device_id=e,this.user_id=n,this._lists=i}items(){let e=[],t=0,r=this._lists;for(;t<r.length;){let n=r[t];++t;let i=0,a=n.items;for(;i<a.length;){let o=a[i];++i,e.push(o)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,r=this._lists;for(;t<r.length;){let n=r[t];if(++t,n.list_name==e)return n}return null}static fromRequestData(e){let t=E.getProperty(e,"lists");s.$global.console.log("lists: "+b.string(t)),s.$global.console.log("data: "+b.string(e));let r=[],n=0;for(;n<t.length;){let i=t[n];++n;let a=E.getProperty(i,"items"),o=[],f=0;for(;f<a.length;){let c=a[f];++f,o.push(new ue(c))}let h=new Y({limit:E.getProperty(i,"limit"),list_key:E.getProperty(i,"list_key"),list_name:E.getProperty(i,"list_name"),list_size:E.getProperty(i,"list_size"),items:o});r.push(h)}return new $e(E.getProperty(e,"device_id"),E.getProperty(e,"request_id"),E.getProperty(e,"user_group"),E.getProperty(e,"user_id"),r)}static get __name__(){return"internal._RecommendationsInternal"}static get __interfaces__(){return[re]}get __class__(){return $e}};G.prototype.request_id=null;G.prototype.user_group=null;G.prototype.user_id=null;G.prototype.device_id=null;G.prototype._lists=null;var Y=s.global("$hxClasses")["internal._RecommendationsListInternal"]=class Me extends s.inherits(){[s.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size}static get __name__(){return"internal._RecommendationsListInternal"}static get __interfaces__(){return[se]}get __class__(){return Me}};Y.prototype.limit=null;Y.prototype.list_key=null;Y.prototype.list_name=null;Y.prototype.list_size=null;Y.prototype.items=null;var ue=s.global("$hxClasses")["internal._RecommendationItemInternal"]=class Ne extends s.inherits(){[s.new](e){this._data={},this.Id=E.getProperty(e,"item_id"),this.RequestId=E.getProperty(e,"request_id"),this.UserGroup=E.getProperty(e,"user_group");let t=0,r=E.fields(e);for(;t<r.length;){let n=r[t];++t,this._data[n]=E.field(e,n)}}get(e){return this._data[e]}static get __name__(){return"internal._RecommendationItemInternal"}static get __interfaces__(){return[ne]}get __class__(){return Ne}};ue.prototype.Id=null;ue.prototype.RequestId=null;ue.prototype.UserGroup=null;ue.prototype._data=null;var q=s.global("$hxClasses")["internal._RecoBackendV2.RecoBackendV2_Fields_"]=class De{static getRawRecommendations(e){return l.getRawRecommendations(e)}static setConsent(e){l.setConsent(e)}static setPageVisit(e){l.setPageVisit(e)}static setEnvironment(e){l.setEnvironment(e)}static setDeviceId(e){l.setDeviceId(e)}static setUserId(e){l.setUserId(e)}static setRequestDomain(e){l.setRequestDomain(e)}static setPageView(e){l.setPageView(e)}static getConsent(){De.getConsent()}static getPageVisit(){l.getPageVisit()}static getEnvironment(){l.getEnvironment()}static getDeviceId(){l.getDeviceId()}static getUserId(){l.getUserId()}static getPageView(){l.getPageView()}static get __name__(){return"internal._RecoBackendV2.RecoBackendV2_Fields_"}get __class__(){return De}},Nr=q.getRawRecommendations,Jr=q.setConsent,zr=q.setPageVisit,Kr=q.setEnvironment,Xr=q.setDeviceId,Qr=q.setUserId,Wr=q.setRequestDomain,Gr=q.setPageView,Yr=q.getConsent,Zr=q.getPageVisit,es=q.getEnvironment,ts=q.getDeviceId,rs=q.getUserId,ss=q.getPageView;var os=s.$global,A=s.global("$hxClasses").FroomleSdk=class V{static register(){V.registered||V._env_set&&(!V._page_visit_set&&!V._page_view_set||(V.registered=!0))}static setEnvironment(e){l.setEnvironment(e),V._env_set=!0,V.register()}static setDeviceId(e){l.setDeviceId(e)}static setUserId(e){l.setUserId(e)}static setConsent(e){l.setConsent(e)}static setPageView(e){l.setPageView(e),V._page_view_set=!0,V.register()}static setPageVisit(e){l.setPageVisit(e),V._page_visit_set=!0,V.register()}static setRequestDomain(e){l.setRequestDomain(e)}static getRawRecommendations(e){return l.getRawRecommendations(e)}static getVersion(){return"0.0.1"}static get __name__(){return"FroomleSdk"}get __class__(){return V}};A._env_set=!1;A._page_visit_set=!1;A._page_view_set=!1;A.registered=!1;var cs=s.$global,Z=s.global("$hxClasses")["internal.domHandler.FroomleDomTree"]=class fe extends s.inherits(){[s.new](){}createElement(e){return window.document.createElement(e)}querySelectorAll(e){let t=this.root,r=[],n=t.querySelectorAll(e),i=0,a=n.length;for(;i<a;){let o=i++;r.push(n.item(o))}return r}getRoot(){return this.root}toString(){return this.root.outerHTML}static run(){}static fromHtml(e){return new fe}static fromDocument(){let e=new fe;return e.root=window.document,e}static get __name__(){return"internal.domHandler.FroomleDomTree"}get __class__(){return fe}};Z.prototype.root=null;var ms=s.$global,U=s.global("$hxClasses")["internal._ADomNode.ADomNode"]=class ke{static _new(e){return e}static fromElement(e){return e}static create(e,t){return window.document.createElement(t)}static replaceChild(e,t,r){e.replaceChild(t,r)}static get attributes(){return this.get_attributes()}static get_attributes(e){let t=e,r=[],n=0,i=t.attributes.length;for(;n<i;){let a=n++,o=t.attributes.item(a);r.push({name:o.name,value:o.value})}return r}static addChild(e,t){e.appendChild(t)}static removeChild(e,t){e.removeChild(t)}static getAttribute(e,t){return e.getAttribute(t)}static setAttribute(e,t,r){e.setAttribute(t,r)}static getText(e){return e.textContent}static setText(e,t){e.textContent=t}static get children(){return this.get_children()}static get_children(e){let t=[],n=e.children,i=0,a=n.length;for(;i<a;){let o=i++;t.push(n[o])}return t}static querySelectorAll(e,t){let r=e,n=[],i=r.querySelectorAll(t),a=0,o=i.length;for(;a<o;){let f=a++;n.push(i.item(f))}return n}static getFilterKeyValue(e){let t=0,r=ke.get_attributes(e);for(;t<r.length;){let n=r[t];if(++t,n.name.startsWith("data-froomle-reco-filter-"))return{key:n.name.substring(25),value:n.value}}return{key:null,value:null}}static get __name__(){return"internal._ADomNode.ADomNode_Impl_"}get __class__(){return ke}};var Es=s.$global,ce=s.global("$hxClasses")["internal.domHandler.DomDomDom"]=class z extends s.inherits(){[s.new](){}static _fillRecoTargets(e){let t=new M;if(e==null)return t.trigger(!1),t;s.$global.console.log("filling recos");let r=[],n=e,i=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let d=o++;i.push(a.item(d))}let h=i;s.$global.console.log(h.length+" amount of elements");let c=0;for(;c<h.length;){let d=h[c];++c;let k=0,I=U.get_attributes(d);for(;k<I.length;){let N=I[k];++k,N.name=="data-froomle-reco"&&r.push(d)}}s.$global.console.log("amount of targets: "+(r.length==null?"null":""+r.length));let u=[],p=0;for(;p<r.length;){let d=r[p];++p,d.getAttribute("data-froomle-request-id")==null&&(d.getAttribute("data-froomle-id")==null||d.getAttribute("data-froomle-id")=="")&&u.push(d)}if(s.$global.console.log("filtered: "+b.string(u)),s.$global.console.log("filtered targets length "+u.length),u.length<1)return new M;let $=[],g=[],m="",v="",w="",R=[],C=function(){let d={list_name:m,list_size:R.length,limit:R.length};v!=null&&E.setProperty(d,v,w),$.push(d),g.push(R),s.$global.console.log("pushed a list with name:"+m+"filter_key: "+(v==null?"null":""+v)+" and value "+(w==null?"null":""+w)),s.$global.console.log("had length "+d.list_size)},O=function(d,k,I,N){m=d,v=k,w=I,R=[N]},x=0;for(;x<u.length;){let d=u[x];++x;let k=d.getAttribute("data-froomle-reco"),I=U.getFilterKeyValue(d);if(m==""){O(k,I.key,I.value,d);continue}else if(k==m&&I.key==v&&I.value==w){R.push(d);continue}else{C(),O(k,I.key,I.value,d);continue}}m!=""&&C();let D=q.getRawRecommendations($);return s.$global.console.log("should have recos"),D.then(function(d){let k=0,I=d.lists();for(;k<I.length;){let N=I[k],H=k++,j=N,X=j.items.length!=g[H].length,te=0,be=j.items;for(;te<be.length;){let ye=be[te],ze=te++,Ke=ye;z._fillParameters(g[H][ze],Ke,d.request_id)}}t.trigger(!0)}),t}static _fillParameters(e,t,r){let n=function(p,$,g,m){m==null&&(m="");let v=function(w,R,C){C==null&&(C="fgh");try{R=new ae("\\\\[(\\\\w+)\\\\]","g").map(R,function(I){return"."+I.matched(1)}),R=J.replace(R,"[","."),R=J.replace(R,"]",""),B.cca(R,0)==46&&(R=B.substr(R,1,null));let x=R.split("."),D=w.get(x[0]),d=1,k=x.length;for(;d<k;){let I=d++;if(D==null)return null;D instanceof Array&&b.parseInt(x[I])!=null?D=D[b.parseInt(x[I])]:D=E.field(D,x[I])}return D}catch{return C}};try{let w=v(t,g,m);$=="inner"?p.textContent=w:p.setAttribute($,w)}catch{}};e.setAttribute("data-froomle-id",t.Id),e.setAttribute("data-froomle-request-id",r);let i=e,a=[],o=i.querySelectorAll("*"),f=0,h=o.length;for(;f<h;){let p=f++;a.push(o.item(p))}let c=a,u=0;for(;u<c.length;){let p=c[u];++u;let $=0,g=U.get_attributes(p);for(;$<g.length;){let m=g[$];if(++$,m.name.startsWith("data-froomle-param-")){let v=J.replace(m.name,"data-froomle-param-",""),w=m.value;n(p,v,w)}}}}static _orderElements(e){let t=function(g,m,v){let w=[],R=U.get_children(g),C=0;for(;C<R.length;){let D=R[C];if(++C,D.getAttribute("data-froomle-ordervalue")!=null){w.push(D);let k=U.create(e,"span");k.setAttribute("data-froomle-tmp-node",""),U.replaceChild(g,k,D)}}let O=[],x=0;for(;x<w.length;){let D=w[x];++x,O.push(D.getAttribute("data-froomle-ordervalue"))}return{el:g,key:m,values:O,orderChildren:w,list_name:v}},r=new M,n=e.getRoot(),i=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let g=o++;i.push(a.item(g))}let h=i,c=[],u=0;for(;u<h.length;){let g=h[u];++u;let m=0,v=U.get_attributes(g);for(;m<v.length;){let w=v[m];++m,w.name.startsWith("data-froomle-order-")&&c.push(t(g,w.name.substring(19),w.value))}}if(c.length<1)return r.trigger(!1),r;let p=[],$=0;for(;$<c.length;){let g=c[$];++$;let m={list_name:g.list_name,limit:g.values.length,list_size:g.values.length},v={};E.setProperty(v,g.key,g.values),E.setProperty(m,"order",v),p.push(m)}return q.getRawRecommendations(p).then(function(g){s.$global.console.log("got order recos"),s.$global.console.log(b.string(g));let m=0,v=g.lists();for(;m<v.length;){let w=v[m],C=m++,O=w,x=c[C];x.el.setAttribute("data-froomle-request-id",g.request_id),s.$global.console.log("children "+b.string(x.orderChildren));let D=[],d=0,k=O.items;for(;d<k.length;){let K=k[d];++d;let H=K.get(x.key);s.$global.console.log("looking for value "+H+" for key "+x.key),s.$global.console.log("item was "+b.string(K));let j=0,X=x.values;for(;j<X.length;){let te=X[j],ye=j++;if(H==te){s.$global.console.log("found matching value "+H),D.push(x.orderChildren[ye]);break}}}s.$global.console.log("sorted items "+b.string(D));let I=0,N=D.length;for(;I<N;){let K=I++;s.$global.console.log("replacing in section "+b.string(x.el.innerHTML)+" the item "+b.string(D[K]));let H=0,j=U.get_children(x.el);for(;H<j.length;){let X=j[H];if(++H,X.getAttribute("data-froomle-tmp-node")==""){U.replaceChild(x.el,D[K],X);break}}}s.$global.console.log("done replacing for section "+b.string(x.el.innerHTML)),s.$global.console.log("sorted items "+b.string(D))}r.trigger(!0)}),r}static domInit(e){z._orderElements(e).then(function(t){z._fillRecoTargets(e.getRoot())})}static fillElementRecos(e){z._fillRecoTargets(e)}static runFromHtml(e){let t=Z.fromHtml(e);return z.domInit(t),t.toString()}static get __name__(){return"internal.domHandler.DomDomDom"}get __class__(){return z}};var ks=s.$global;var P=class P{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e=[];for(let t of P.impressionQueue){let r={event_type:"impression",page_type:l.getPageVisit(),action_item:t.getAttribute("data-froomle-id"),action_item_type:"article",channel:"www-desktop"};l.getUserId()?r.user_id=l.getUserId():r.device_id=l.getDeviceId();let n=t.getAttribute("data-froomle-reco");if(n){r.list_name=n;let i=t.getAttribute("data-froomle-request-id");if(!i)throw console.error("element need reco but doesnt have request id registered yet"),new Error("element need reco but doesnt have request id registered");r.request_id=i}}return P.impressionQueue=[],JSON.stringify({events:e})}static sendImpressions(){P.impressionQueue.length!==0&&fetch(P.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:P.generateBody()})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(e){let t=e.getBoundingClientRect(),r=P.getViewPortRect();return t.right>r.left&&t.left<r.right&&t.bottom>r.top&&t.top<r.bottom}static addIntersectionImpressionListener(e){P.observer.observe(e)}static processDocument(){if(l.getDeviceId()!="no-consent"){for(let e of document.querySelectorAll("[data-froomle-id]"))P.intersectsWithViewPortRect(e)?P.impressionQueue.push(e):P.addIntersectionImpressionListener(e);P.sendImpressions()}}};P.impressionQueue=[],P.observer=new IntersectionObserver((e,t)=>{e.forEach(r=>{r.isIntersecting&&(P.impressionQueue.push(r.target),P.observer.unobserve(r.target))}),P.impressionQueue.length>0&&P.sendImpressions()});var ee=P;var ge=class _{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e={event_type:"page_visit",page_type:l.getPageVisit(),channel:"www-desktop"};return l.getUserId()?e.user_id=l.getUserId():e.device_id=l.getDeviceId(),JSON.stringify(e)}static sendPageVisit(){l.getPageVisit()&&l.getDeviceId()!="no-consent"&&fetch(_.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:_.generateBody()})}};var _e=class _{static uri(){return"https://"+l.getRequestDomain()+"/api/"+l.getEnvironment()+"/events"}static generateBody(){let e={event_type:"detail_pageview",page_type:"article_detail",action_item:l.getPageView(),action_item_type:"article",channel:"www-desktop"};return l.getUserId()?e.user_id=l.getUserId():e.device_id=l.getDeviceId(),JSON.stringify(e)}static sendPageView(){l.getPageView()&&l.getDeviceId()!="no-consent"&&fetch(_.uri(),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:_.generateBody()})}};var We=A.setEnvironment,Ge=A.setPageVisit,Qs=A.setConsent,Ye=A.setUserId,Ze=A.setDeviceId,et=A.setRequestDomain;if(typeof document!="undefined"){let _=document.currentScript;if(console.log("dom loaded"),console.log(_),_){console.log("loaded script");let e=_.getAttribute("data-froomle-device-id"),t=_.getAttribute("data-froomle-user-id"),r=_.getAttribute("data-froomle-env"),n=_.getAttribute("data-froomle-page-visit"),i=_.getAttribute("data-froomle-request-domain");We(r),Ge(n),e&&Ze(e),t&&Ye(t),i&&et(i)}else console.error("Froomle SDK: could not find the script tag where the sdk is included.");document.addEventListener("DOMContentLoaded",()=>{ce.domInit(Z.fromDocument()),ee.processDocument(),ge.sendPageVisit(),_e.sendPageView(),new MutationObserver(t=>{for(let r of t)if(r.type==="childList"&&ee.processElement(r.target),r.type==="attributes")if(r.attributeName==="data-froomle-reco"){let n=r.target.getAttribute("data-froomle-request-id");(!n||n==="")&&ce.fillElementRecos(r.target)}else r.attributeName==="data-froomle-request-id"&&ce.fillElementRecos(r.target)}).observe(document,{childList:!0,subtree:!0})})}export{ne as RecommendationItem,se as RecommendationList,re as Recommendations,Qs as setConsent,Ze as setDeviceId,We as setEnvironment,Ge as setPageVisit,et as setRequestDomain,Ye as setUserId};