New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@builder.io/sdk

Package Overview
Dependencies
Maintainers
2
Versions
701
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@builder.io/sdk - npm Package Compare versions

Comparing version

to
1.1.5-alpha.1

LICENSE

2

dist/index.browser.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("@builder.io/sdk",["exports"],t):t(e.BuilderIO={})}(this,function(exports){"use strict";var __assign=function(){return(__assign=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},isSafari="undefined"!=typeof window&&/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);function nextTick(e){if("function"==typeof setImmediate&&"undefined"==typeof window)return setImmediate(e);if(isSafari||"undefined"==typeof MutationObserver)setTimeout(e);else{var t=0,i=new MutationObserver(function(){return e()}),n=document.createTextNode("");i.observe(n,{characterData:!0}),n.data=String(t=++t)}}var QueryString=function(){function e(){}return e.parseDeep=function(e){var t=this.parse(e);return this.deepen(t)},e.stringifyDeep=function(e){var t=this.flatten(e);return this.stringify(t)},e.parse=function(e){for(var t={},i=("?"===e[0]?e.substr(1):e).split("&"),n=0;n<i.length;n++){var r=i[n].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1]||"")}return t},e.stringify=function(e){var t="";for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];t&&(t+="&"),t+=encodeURIComponent(i)+"="+encodeURIComponent(n)}return t},e.deepen=function(e){var t={};for(var i in e){for(var n=t,r=i.split("."),s=r.pop();r.length;){var o=r.shift();n=n[o]=n[o]||{}}n[s]=e[i]}return t},e.flatten=function(e,t,i){for(var n in void 0===i&&(i={}),e){var r=e[n],s=t?t+"."+n:n;r&&"object"==typeof r?this.flatten(r,s,i):i[s]=r}return i},e}(),version="1.1.3",Subscription=function(){function e(e,t){this.listeners=e,this.listener=t,this.unsubscribed=!1,this.otherSubscriptions=[]}return e.prototype.add=function(e){this.otherSubscriptions.push(e)},e.prototype.unsubscribe=function(){if(!this.unsubscribed){if(this.listener&&this.listeners){var e=this.listeners.indexOf(this.listener);e&&this.listeners.splice(e,1)}this.otherSubscriptions.forEach(function(e){return e.unsubscribe()}),this.unsubscribed=!0}},e}(),BehaviorSubject=function(){function e(e){this.value=e,this.listeners=[],this.errorListeners=[]}return e.prototype.next=function(e){this.value=e;for(var t=0,i=this.listeners;t<i.length;t++){(0,i[t])(e)}},e.prototype.map=function(t){var i=new e(t(this.value));return this.subscribe(function(e){i.next(t(e))}),this.catch(function(e){i.error(e)}),i},e.prototype.catch=function(e){return this.errorListeners.push(e),new Subscription(this.errorListeners,e)},e.prototype.error=function(e){for(var t=0,i=this.errorListeners;t<i.length;t++){(0,i[t])(e)}},e.prototype.subscribe=function(e,t){return this.listeners.push(e),t&&this.errorListeners.push(t),new Subscription(this.listeners,e)},e.prototype.toPromise=function(){var e=this;return new Promise(function(t,i){var n=e.subscribe(function(e){t(e),n.unsubscribe()},function(e){i(e),n.unsubscribe()})})},e.prototype.promise=function(){return this.toPromise()},e}(),State={Pending:"Pending",Fulfilled:"Fulfilled",Rejected:"Rejected"};function isFunction(e){return e&&"function"==typeof e}function isObject(e){return e&&"object"==typeof e}var TinyPromise=function(){function e(e){this._state=State.Pending,this._handlers=[],this._value=null,e(this._resolve.bind(this),this._reject.bind(this))}return e.prototype._resolve=function(t){var i=this;if(t instanceof e)t.then(this._resolve.bind(this),this._reject.bind(this));else if(isObject(t)||isFunction(t)){var n=!1;try{var r=t.then;isFunction(r)?r.call(t,function(e){n||i._resolve(e),n=!0},function(e){n||i._reject(e),n=!0}):this._fulfill(t)}catch(e){n||this._reject(e)}}else this._fulfill(t)},e.prototype._fulfill=function(e){var t=this;this._state=State.Fulfilled,this._value=e,this._handlers.forEach(function(e){return t._callHandler(e)})},e.prototype._reject=function(e){var t=this;this._state=State.Rejected,this._value=e,this._handlers.forEach(function(e){return t._callHandler(e)})},e.prototype._isPending=function(){return this._state===State.Pending},e.prototype._isFulfilled=function(){return this._state===State.Fulfilled},e.prototype._isRejected=function(){return this._state===State.Rejected},e.prototype._addHandler=function(e,t){this._handlers.push({onFulfilled:e,onRejected:t})},e.prototype._callHandler=function(e){this._isFulfilled()&&isFunction(e.onFulfilled)?e.onFulfilled(this._value):this._isRejected()&&isFunction(e.onRejected)&&e.onRejected(this._value)},e.prototype.then=function(t,i){var n=this;switch(this._state){case State.Pending:return new e(function(e,r){n._addHandler(function(i){nextTick(function(){try{isFunction(t)?e(t(i)):e(i)}catch(e){r(e)}})},function(t){nextTick(function(){try{isFunction(i)?e(i(t)):r(t)}catch(e){r(e)}})})});case State.Fulfilled:return new e(function(e,i){nextTick(function(){try{isFunction(t)?e(t(n._value)):e(n._value)}catch(e){i(e)}})});case State.Rejected:return new e(function(e,t){nextTick(function(){try{isFunction(i)?e(i(n._value)):t(n._value)}catch(e){t(e)}})})}},e}(),Promise$1="undefined"!=typeof Promise?Promise:TinyPromise,serverOnlyRequire;try{serverOnlyRequire=eval("require")}catch(e){serverOnlyRequire=function(){return null}}var serverOnlyRequire$1=serverOnlyRequire;function promiseResolve(e){return new Promise$1(function(t){return t(e)})}function tinyFetch(e,t){return void 0===t&&(t={}),new Promise$1(function(i,n){var r=new XMLHttpRequest;if(r.open(t.method||"get",e,!0),t.headers)for(var s in t.headers)r.setRequestHeader(s,t.headers[s]);function o(){var e=[],t=[],i={},n=void 0;return r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(r,s,o){var a=s;return e.push(a=a.toLowerCase()),t.push([a,o]),n=i[a],i[a]=n?n+","+o:o,""}),{ok:2==(r.status/100|0),status:r.status,statusText:r.statusText,url:r.responseURL,clone:o,text:function(){return promiseResolve(r.responseText)},json:function(){return promiseResolve(r.responseText).then(JSON.parse)},blob:function(){return promiseResolve(new Blob([r.response]))},headers:{keys:function(){return e},entries:function(){return t},get:function(e){return i[e.toLowerCase()]},has:function(e){return e.toLowerCase()in i}}}}r.withCredentials="include"===t.credentials,r.onload=function(){i(o())},r.onerror=n,r.send(t.body)})}var fetch="object"==typeof global&&"function"==typeof global.fetch?global.fetch:"undefined"==typeof window?serverOnlyRequire$1("node-fetch"):void 0!==window.fetch?window.fetch:tinyFetch;function assign(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=Object(e),r=1;r<arguments.length;r++){var s=arguments[r];if(null!=s)for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(n[o]=s[o])}return n}function throttle(e,t,i){var n,r,s;void 0===i&&(i={});var o=null,a=0,u=function(){a=!1===i.leading?0:Date.now(),o=null,s=e.apply(n,r),o||(n=r=null)};return function(){var c=Date.now();a||!1!==i.leading||(a=c);var d=t-(c-a);return n=this,r=arguments,d<=0||d>t?(o&&(clearTimeout(o),o=null),a=c,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=setTimeout(u,d)),s}}var camelCaseToKebabCase=function(e){return e?e.replace(/([A-Z])/g,function(e){return"-"+e[0].toLowerCase()}):""},Animator=function(){function e(){}return e.prototype.bindAnimations=function(e){for(var t=0,i=e;t<i.length;t++){var n=i[t];switch(n.trigger){case"pageLoad":this.triggerAnimation(n);break;case"hover":this.bindHoverAnimation(n);break;case"scrollInView":this.bindScrollInViewAnimation(n)}}},e.prototype.warnElementNotPresent=function(e){console.warn("Cannot animate element: element with ID "+e+" not found!")},e.prototype.augmentAnimation=function(e,t){for(var i=this.getAllStylesUsed(e),n=getComputedStyle(t),r=0,s=[e.steps[0].styles,e.steps[e.steps.length-1].styles];r<s.length;r++)for(var o=s[r],a=0,u=i;a<u.length;a++){var c=u[a];c in o||(o[c]=n[c])}},e.prototype.getAllStylesUsed=function(e){for(var t=[],i=0,n=e.steps;i<n.length;i++){var r=n[i];for(var s in r.styles)-1===t.indexOf(s)&&t.push(s)}return t},e.prototype.triggerAnimation=function(e){var t=this,i=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));i.length?Array.from(i).forEach(function(i){t.augmentAnimation(e,i),i.style.transition="none",i.style.transitionDelay="0",assign(i.style,e.steps[0].styles),setTimeout(function(){i.style.transition="all "+e.duration+"s "+camelCaseToKebabCase(e.easing),e.delay&&(i.style.transitionDelay=e.delay+"s"),assign(i.style,e.steps[1].styles),setTimeout(function(){i.style.transition="",i.style.transitionDelay=""},1e3*(e.delay||0)+1e3*e.duration+100)})}):this.warnElementNotPresent(e.elementId||e.id||"")},e.prototype.bindHoverAnimation=function(e){var t=this,i=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));i.length?Array.from(i).forEach(function(i){t.augmentAnimation(e,i);var n=e.steps[0].styles,r=e.steps[1].styles;function s(){assign(i.style,n)}s(),i.addEventListener("mouseenter",function(){assign(i.style,r)}),i.addEventListener("mouseleave",s),setTimeout(function(){i.style.transition="all "+e.duration+"s "+camelCaseToKebabCase(e.easing),e.delay&&(i.style.transitionDelay=e.delay+"s")})}):this.warnElementNotPresent(e.elementId||e.id||"")},e.prototype.bindScrollInViewAnimation=function(e){var t=this,i=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));i.length?Array.from(i).forEach(function(i){t.augmentAnimation(e,i);var n=!1;function r(){var t,r,o;!n&&(t=i.getBoundingClientRect(),r=window.innerHeight,o=0*r,t.bottom>o&&t.top<r-o)&&(n=!0,setTimeout(function(){assign(i.style,e.steps[1].styles),document.removeEventListener("scroll",s),setTimeout(function(){i.style.transition="",i.style.transitionDelay=""},1e3*(1e3*e.duration+(e.delay||0))+100)}))}var s=throttle(r,200,{leading:!1});var o=e.steps[0].styles;assign(i.style,o),setTimeout(function(){i.style.transition="all "+e.duration+"s "+camelCaseToKebabCase(e.easing),e.delay&&(i.style.transitionDelay=e.delay+"s")}),document.addEventListener("scroll",s,{capture:!0,passive:!0}),r()}):this.warnElementNotPresent(e.elementId||e.id||"")},e}(),fieldContentRegExp=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Cookies=function(){function e(e,t){this.request=e,this.response=t}return e.prototype.get=function(e){var t=this.request.headers.cookie;if(t){var i=t.match(getPattern(e));if(i)return i[1]}},e.prototype.set=function(e,t,i){var n=this.response,r=this.request,s=n.getHeader("Set-Cookie")||[],o=void 0!==this.secure?!!this.secure:"https"===r.protocol||r.connection.encrypted,a=new Cookie(e,t,i);if("string"==typeof s&&(s=[s]),!o&&i&&i.secure)throw new Error("Cannot send secure cookie over unencrypted connection");return a.secure=o,i&&"secure"in i&&(a.secure=!!i.secure),pushCookie(s,a),n.setHeader.call(n,"Set-Cookie",s),this},e}(),Cookie=function(){function e(e,t,i){if(this.path="/",this.domain=void 0,this.httpOnly=!0,this.sameSite=!1,this.secure=!1,this.overwrite=!1,this.name="",this.value="",!fieldContentRegExp.test(e))throw new TypeError("argument name is invalid");if(t&&!fieldContentRegExp.test(t))throw new TypeError("argument value is invalid");t||(this.expires=new Date(0)),this.name=e,this.value=t||"",i.expires&&(this.expires=i.expires),i.secure&&(this.secure=i.secure)}return e.prototype.toString=function(){return this.name+"="+this.value},e.prototype.toHeader=function(){var e=this.toString();return this.maxAge&&(this.expires=new Date(Date.now()+this.maxAge)),this.path&&(e+="; path="+this.path),this.expires&&(e+="; expires="+this.expires.toUTCString()),this.domain&&(e+="; domain="+this.domain),e+="; SameSite="+(!0===this.sameSite?"strict":"None"),this.secure&&(e+="; secure"),this.httpOnly&&(e+="; httponly"),e},e}();function getPattern(e){return new RegExp("(?:^|;) *"+e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"=([^;]*)")}function pushCookie(e,t){if(t.overwrite)for(var i=e.length-1;i>=0;i--)0===e[i].indexOf(t.name+"=")&&e.splice(i,1);e.push(t.toHeader())}function omit(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=Object.assign({},e),r=0,s=t;r<s.length;r++){delete n[s[r]]}return n}var isReactNative="object"==typeof navigator&&"ReactNative"===navigator.product,validEnvList=["production","qa","development","dev","cdn-qa","cloud","fast","cdn2"];function getQueryParam(e,t){for(var i=(e.split("?")[1]||"").split("&"),n=0;n<i.length;n++){var r=i[n].split("=");if(decodeURIComponent(r[0])===t)return decodeURIComponent(r[1])}return null}var urlParser={parse:function(e){var t=document.createElement("a");t.href=e;for(var i={},n="username password host hostname port protocol origin pathname search hash".split(" "),r=n.length;r--;)i[n[r]]=t[n[r]];return!i.pathname&&""!==i.pathname||"string"!=typeof i.pathname||0===i.pathname.indexOf("/")||(i.pathname="/"+i.pathname),i}},parse=isReactNative?function(){return{}}:"object"==typeof window?urlParser.parse:serverOnlyRequire$1("url").parse;function setCookie(e,t,i){var n="";i&&(n="; expires="+i.toUTCString());var r=!isBrowser||"https:"===location.protocol;document.cookie=e+"="+(t||"")+n+"; path=/"+(r?";secure":"")+"; SameSite=None"}function getCookie(e){return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null}function size(e){return Object.keys(e).length}function find(e,t){for(var i=e,n=i.length>>>0,r=arguments[1],s=0;s<n;s++){var o=i[s];if(t.call(r,o,s,i))return o}}var sessionStorageKey="builderSessionId",isBrowser="undefined"!=typeof window&&!isReactNative,isIframe=isBrowser&&window.top!==window.self;function BuilderComponent(e){return void 0===e&&(e={}),Builder.Component(e)}var Builder=function(){function e(t,i,n,r){var s=this;if(void 0===t&&(t=null),void 0===r&&(r=!1),this.request=i,this.response=n,this.authToken="",this.eventsQueue=[],this.throttledClearEventsQueue=throttle(function(){s.processEventsQueue()},100),this.env="production",this.isUsed=!1,this.sessionId=this.getSessionId(),this.targetContent=!0,this.cookies=null,this.cachebust=!1,this.overrideParams="",this.noCache=!1,this.overrideHost="",this.preview=!1,this.canTrack$=new BehaviorSubject(!this.browserTrackingDisabled),this.apiKey$=new BehaviorSubject(null),this.editingMode$=new BehaviorSubject(isIframe),this.editingModel$=new BehaviorSubject(null),this.userAgent="object"==typeof navigator&&navigator.userAgent||"",this.autoTrack=!!e.isBrowser&&!(this.isDevelopmentEnv||e.isBrowser&&-1!==location.search.indexOf("builder.preview=")),this.useNewContentApi=!1,this.blockContentLoading="",this.observersByKey={},this.overrides={},this.getContentQueue=null,this.priorContentQueue=null,this.testCookiePrefix="builder.tests",this.cookieQueue=[],e.isBrowser&&!r&&e.singletonInstance)return e.singletonInstance;this.request&&this.response&&(this.setUserAgent(this.request.headers["user-agent"]||""),this.cookies=new Cookies(this.request,this.response)),t&&(this.apiKey=t),isBrowser&&this.bindMessageListeners(),isIframe&&this.messageFrameLoaded(),this.canTrack$.subscribe(function(e){if(e){if("undefined"!=typeof sessionStorage)try{sessionStorage.getItem(sessionStorageKey)||sessionStorage.setItem(sessionStorageKey,s.sessionId)}catch(e){console.debug("Session storage error",e)}s.eventsQueue.length&&s.throttledClearEventsQueue(),s.cookieQueue.length&&(s.cookieQueue.forEach(function(e){s.setCookie(e[0],e[1])}),s.cookieQueue.length=0)}}),isBrowser&&(this.setTestsFromUrl(),this.getOverridesFromQueryString())}return e.register=function(t,i){var n=this.registry[t];if(n||(n=this.registry[t]=[]),n.push(i),e.isBrowser){var r={type:"builder.register",data:{type:t,info:i}};parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}this.registryChange.next(this.registry)},e.registerEditor=function(t){if(e.isBrowser){window.postMessage({type:"builder.registerEditor",data:omit(t,"component")},"*");var i=location.host;"localhost:1234"!==i&&-1===i.indexOf("builder.io")&&console.error("Builder.registerEditor() called in the wrong environment! You cannot load custom editors from your app, they must be loaded through the Builder.io app itself. Follow the readme here for more details: https://github.com/builderio/builder/tree/master/plugins/cloudinary or contact chat us in our Spectrum community for help: https://spectrum.chat/builder")}this.editors.push(t)},e.registerPlugin=function(e){this.plugins.push(e)},e.registerAction=function(e){this.actions.push(e)},e.runAction=function(e){if(!("string"==typeof e?find(this.actions,function(t){return t.name===e}):e))throw new Error("Action not found: "+e)},e.fields=function(e,t){var i;null===(i=window.parent)||void 0===i||i.postMessage({type:"builder.fields",data:{name:e,fields:t}},"*")},e.set=function(t){if(e.isBrowser){Object.assign(this.settings,t);var i={type:"builder.settingsChange",data:this.settings};parent.postMessage(i,"*")}this.settingsChange.next(this.settings)},e.import=function(t){if(e.isBrowser){var i=window.System;if(i)return i.import("https://cdn.builder.io/systemjs/"+t);console.warn("System.js not available. Please include System.js when using Builder.import")}else console.warn("Builder.import used on the server - this should only be used in the browser")},Object.defineProperty(e,"editingPage",{get:function(){return this._editingPage},set:function(e){this._editingPage=e,isBrowser&&isIframe&&(e?document.body.classList.add("builder-editing-page"):document.body.classList.remove("builder-editing-page"))},enumerable:!0,configurable:!0}),e.prepareComponentSpecToSend=function(e){return __assign(__assign(__assign({},e),e.inputs&&{inputs:e.inputs.map(function(e){for(var t,i=0,n=["onChange","showIf"];i<n.length;i++){var r=n[i];if(e[r]&&"function"==typeof e[r]){var s=e[r];e=__assign(__assign({},e),((t={})[r]="return ("+s.toString()+").apply(this, arguments)",t))}}return e})}),{hooks:Object.keys(e.hooks||{}).reduce(function(t,i){var n=e.hooks&&e.hooks[i];return n?(t[i]="string"==typeof n?n:"return ("+n.toString()+").apply(this, arguments)",t):t},{}),class:void 0})},e.registerComponent=function(e,t){var i,n=__assign(__assign({class:e},e.builderOptions),t);if(this.addComponent(n),isBrowser){var r=this.prepareComponentSpecToSend(n);null===(i=window.parent)||void 0===i||i.postMessage({type:"builder.registerComponent",data:r},"*")}},e.addComponent=function(e){var t=find(this.components,function(t){return t.name===e.name});if(t){if(t.class&&!e.class)return;this.components.splice(this.components.indexOf(t),1,e)}else this.components.push(e)},e.component=function(e){var t=this;return void 0===e&&(e={}),function(i){var n,r=__assign(__assign({},e),{class:i});r.name||(r.name=i.name),t.addComponent(r);var s=t.prepareComponentSpecToSend(r);return isBrowser&&(null===(n=window.parent)||void 0===n||n.postMessage({type:"builder.registerComponent",data:s},"*")),i}},Object.defineProperty(e,"Component",{get:function(){return this.component},enumerable:!0,configurable:!0}),e.prototype.processEventsQueue=function(){if(this.eventsQueue.length){var e=this.eventsQueue;this.eventsQueue=[];var t=this.host;fetch(t+"/api/v1/track",{method:"POST",body:JSON.stringify({events:e}),headers:{"content-type":"application/json"},mode:"cors"})}},Object.defineProperty(e.prototype,"browserTrackingDisabled",{get:function(){return e.isBrowser&&"1"===navigator.doNotTrack},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canTrack",{get:function(){return this.canTrack$.value&&!this.browserTrackingDisabled},set:function(e){this.canTrack!==e&&this.canTrack$.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editingMode",{get:function(){return this.editingMode$.value},set:function(e){e!==this.editingMode&&this.editingMode$.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editingModel",{get:function(){return this.editingModel$.value},set:function(e){e!==this.editingModel&&this.editingModel$.next(e)},enumerable:!0,configurable:!0}),e.prototype.findParentElement=function(e,t,i){if(void 0===i&&(i=!0),!(e instanceof HTMLElement))return null;var n=i?e:e.parentElement;do{if(!n)return null;if(t(n))return n}while(n=n.parentElement);return null},e.prototype.findBuilderParent=function(e){return this.findParentElement(e,function(e){var t=e.getAttribute("builder-id")||e.id;return Boolean(t&&0===t.indexOf("builder-"))})},e.prototype.setUserAgent=function(e){this.userAgent=e||""},e.prototype.track=function(t,i){void 0===i&&(i={}),isIframe||!isBrowser||e.isPreviewing||(this.eventsQueue.push({type:t,data:__assign(__assign({},omit(i,"meta")),{metadata:__assign(__assign({sdkVersion:e.VERSION,url:location.href},i.meta),i.metadata),ownerId:this.apiKey,userAttributes:this.getUserAttributes(),sessionId:this.sessionId})}),this.canTrack&&this.throttledClearEventsQueue())},e.prototype.getSessionId=function(){var t=this,i=null;try{e.isBrowser&&"undefined"!=typeof sessionStorage&&sessionStorage.getItem(sessionStorageKey)}catch(e){console.debug("Session storage error",e)}return i||(i=(Date.now()+Math.random()).toString(36)),e.isBrowser&&setTimeout(function(){if(t.canTrack&&"undefined"!=typeof sessionStorage&&i)try{sessionStorage.setItem(sessionStorageKey,i)}catch(e){console.debug("Session storage error",e)}}),i},e.prototype.trackImpression=function(t,i){isIframe||!isBrowser||e.isPreviewing||(this.eventsQueue.push({type:"impression",data:{contentId:t,variationId:i!==t?i:void 0,ownerId:this.apiKey,userAttributes:this.getUserAttributes(),sessionId:this.sessionId}}),this.throttledClearEventsQueue())},e.prototype.trackConversion=function(t,i,n){isIframe||!isBrowser||e.isPreviewing||(this.eventsQueue.push({type:"conversion",data:{amount:t,contentId:i,variationId:n,ownerId:this.apiKey,userAttributes:this.getUserAttributes(),sessionId:this.sessionId}}),this.throttledClearEventsQueue())},Object.defineProperty(e.prototype,"isDevelopmentEnv",{get:function(){return e.isIframe||e.isBrowser&&("localhost"===location.hostname||""!==location.port)||"production"!==this.env},enumerable:!0,configurable:!0}),e.prototype.trackInteraction=function(t,i,n,r){if(void 0===n&&(n=!1),!isIframe&&isBrowser&&!e.isPreviewing){var s=r&&r.target,o=s&&this.findBuilderParent(s),a={};if(r){var u=r.clientX,c=r.clientY;if(s){var d=u-(f=s.getBoundingClientRect()).left,l=c-f.top,h=g(d/f.width),p=g(l/f.height);a.targetOffset={x:h,y:p}}if(o){var f;d=u-(f=o.getBoundingClientRect()).left,l=c-f.top,h=g(d/f.width),p=g(l/f.height);a.builderTargetOffset={x:h,y:p}}}var v=o&&(o.getAttribute("builder-id")||o.id);v&&o&&(a.builderElementIndex=[].slice.call(document.getElementsByClassName(v)).indexOf(o)),this.eventsQueue.push({type:"click",data:{contentId:t,metadata:a,variationId:i!==t?i:void 0,ownerId:this.apiKey,unique:!n,targetBuilderElement:v||void 0,userAttributes:this.getUserAttributes(),sessionId:this.sessionId}}),this.throttledClearEventsQueue()}function g(e){return Math.round(1e3*e)/1e3}},e.prototype.component=function(t){return void 0===t&&(t={}),e.component(t)},Object.defineProperty(e.prototype,"apiKey",{get:function(){return this.apiKey$.value},set:function(e){this.apiKey$.next(e)},enumerable:!0,configurable:!0}),e.prototype.modifySearch=function(e){return e.replace(/(^|&|\?)(builder_.*?)=/gi,function(e,t,i){return t+i.replace(/_/g,".")+"="})},e.prototype.setTestsFromUrl=function(){var e=this.getLocation().search,t=QueryString.parseDeep(this.modifySearch(e||"").substr(1)),i=t.builder&&t.builder.tests;if(i&&"object"==typeof i)for(var n in i)i.hasOwnProperty(n)&&this.setTestCookie(n,i[n])},e.prototype.resetOverrides=function(){e.overrideUserAttributes={},this.cachebust=!1,this.noCache=!1,this.preview=!1,this.overrideHost="",this.editingModel=null,this.overrides={},this.env="production",this.userAgent="",this.request=void 0,this.response=void 0},e.prototype.getOverridesFromQueryString=function(){var t=this.getLocation(),i=QueryString.parseDeep(this.modifySearch(t.search||"").substr(1)),n=i.builder;if(n){var r=n.userAttributes,s=n.overrides,o=n.env,a=n.host,u=n.api,c=n.cachebust,d=n.noCache,l=n.preview,h=n.editing,p=n.frameEditing,f=n.params;if(r&&this.setUserAttributes(r),s&&(this.overrides=s),validEnvList.indexOf(o||u)>-1&&(this.env=o||u),e.isEditing){var v=p||h||l;v&&"true"!==v&&(this.editingModel=v)}a&&(this.overrideHost=a),c&&(this.cachebust=!0),d&&(this.noCache=!0),l&&(this.preview=!0),i&&(this.overrideParams=f)}},e.prototype.messageFrameLoaded=function(){var e;null===(e=window.parent)||void 0===e||e.postMessage({type:"builder.loaded",data:{value:!0}},"*")},e.prototype.bindMessageListeners=function(){var t=this;isBrowser&&addEventListener("message",function(i){var n,r,s,o,a=parse(i.origin);if(a.hostname&&("builder.io"===a.hostname||a.hostname.endsWith(".builder.io")||"localhost"===a.hostname)){var u=i.data;if(u)switch(u.type){case"builder.ping":null===(n=window.parent)||void 0===n||n.postMessage({type:"builder.pong",data:{}},"*");break;case"builder.register":if(i.source===window)break;var c=u.data;if(!c)break;var d=c.type,l=c.info,h=e.registry[d];h||(h=e.registry[d]=[]),h.push(l),e.registryChange.next(e.registry);break;case"builder.settingsChange":if(i.source===window)break;var p=u.data;if(!p)break;Object.assign(e.settings,p),e.settingsChange.next(e.settings);break;case"builder.registerEditor":if(i.source===window)break;var f=u.data;if(!f)break;var v=!!f.component;e.editors.every(function(t,i){return f.name!==t.name||!(t.component&&!v)&&(e.editors[i]=t,!1)});break;case"builder.triggerAnimation":e.animator.triggerAnimation(u.data);break;case"builder.contentUpdate":var g=u.data.key||u.data.alias||u.data.entry||u.data.modelName,m=u.data.data,y=t.observersByKey[g];y&&y.next([m]);break;case"builder.getComponents":null===(r=window.parent)||void 0===r||r.postMessage({type:"builder.components",data:e.components.map(function(t){return e.prepareComponentSpecToSend(t)})},"*");break;case"builder.editingModel":t.editingModel=u.data.model;break;case"builder.registerComponent":var b=u.data;e.addComponent(b);break;case"builder.blockContentLoading":"string"==typeof u.data.model&&(t.blockContentLoading=u.data.model);break;case"builder.editingMode":u.data?(t.editingMode=!0,document.body.classList.add("builder-editing")):(t.editingMode=!1,document.body.classList.remove("builder-editing"));break;case"builder.editingPageMode":var w=u.data;e.editingPage=w;break;case"builder.overrideUserAttributes":var C=u.data;assign(e.overrideUserAttributes,C),t.flushGetContentQueue(!0);break;case"builder.overrideTestGroup":var k=u.data,S=k.variationId,_=k.contentId;S&&_&&(t.setTestCookie(_,S),t.flushGetContentQueue(!0));break;case"builder.evaluate":var B=u.data.text,I=u.data.arguments||[],x=u.data.id,A=new Function(B),O=void 0,P=null;try{O=A.apply(t,I)}catch(e){P=e}P?null===(s=window.parent)||void 0===s||s.postMessage({type:"builder.evaluateError",data:{id:x,error:P.message}},"*"):O&&"function"==typeof O.then?O.then(function(e){var t;null===(t=window.parent)||void 0===t||t.postMessage({type:"builder.evaluateResult",data:{id:x,result:e}},"*")}).catch(console.error):null===(o=window.parent)||void 0===o||o.postMessage({type:"builder.evaluateResult",data:{result:O,id:x}},"*")}}})},Object.defineProperty(e.prototype,"defaultCanTrack",{get:function(){return Boolean(e.isBrowser&&navigator.userAgent.trim()&&!navigator.userAgent.match(/bot|crawler|spider|robot|crawling|prerender|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|phantom|headless|selenium|puppeteer/i))},enumerable:!0,configurable:!0}),e.prototype.init=function(e,t,i,n){return void 0===t&&(t=this.defaultCanTrack),i&&(this.request=i),n&&(this.response=n),this.canTrack=t,this.apiKey=e,this},e.prototype.getLocation=function(){var e={};return this.request&&(e=parse(this.request.url)),"object"==typeof location&&(e=parse(location.href)),""===e.pathname&&(e.pathname="/"),e},e.prototype.getUserAttributes=function(t){void 0===t&&(t=this.userAgent||""),this.isUsed=!0;var i={Android:function(){return t.match(/Android/i)},BlackBerry:function(){return t.match(/BlackBerry/i)},iOS:function(){return t.match(/iPhone|iPad|iPod/i)},Opera:function(){return t.match(/Opera Mini/i)},Windows:function(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any:function(){return i.Android()||i.BlackBerry()||i.iOS()||i.Opera()||i.Windows()}},n=this.getLocation();return __assign({urlPath:n.pathname,host:n.host||n.hostname,device:i.any()?"mobile":"desktop"},e.overrideUserAttributes)},e.prototype.setUserAttributes=function(t){assign(e.overrideUserAttributes,t)},e.prototype.get=function(t,i){void 0===i&&(i={});var n=this;return e.isBrowser||!i.req&&!i.res?i.apiKey&&!this.apiKey&&(this.apiKey=i.apiKey):n=new e(i.apiKey||this.apiKey,i.req,i.res),n.queueGetContent(t,i).map(function(e){var t=e&&e[0],i=t&&t.data;return i?{data:i,id:t.id,variationId:t.testVariationId||t.variationId,testVariationId:t.testVariationId||t.variationId,testVariationName:t.testVariationName}:null})},e.prototype.queueGetContent=function(t,i){var n=this;void 0===i&&(i={});var r=i.key||i.alias||t,s=this.editingModel===t,o=this.observersByKey[r];"DEMO"!==this.apiKey||this.overrides[r]||i.initialContent||(i.initialContent=[]);var a=i.initialContent;if(o&&(!o.value||i.cache))return o.value&&nextTick(function(){o.next(o.value)}),o;s&&e.isBrowser&&parent.postMessage({type:"builder.updateContent"},"*"),a||(this.getContentQueue||(this.getContentQueue=[]),this.getContentQueue.push(__assign(__assign({},i),{model:t,key:r})),this.getContentQueue&&this.getContentQueue.length>=5?this.flushGetContentQueue():nextTick(function(){n.flushGetContentQueue()}));var u=new BehaviorSubject(null);return this.observersByKey[r]=u,a&&nextTick(function(){u.next(a)}),u},e.prototype.requestUrl=function(t){return e.isBrowser?fetch(t,this.authToken?{headers:{Authorization:"Bearer "+this.authToken}}:void 0).then(function(e){return e.json()}):new Promise(function(e,i){(0===t.indexOf("http:")?serverOnlyRequire$1("http"):serverOnlyRequire$1("https")).get(t,function(t){var i="";t.on("data",function(e){i+=e}),t.on("end",function(){e(JSON.parse(i))})}).on("error",function(e){i(e)})})},Object.defineProperty(e.prototype,"host",{get:function(){if(this.overrideHost)return this.overrideHost;if(this.env.includes("//"))return this.env;if(this.env.includes("."))return"http://"+this.env;switch(this.env){case"qa":return"https://qa.builder.io";case"fast":return"https://fast.builder.io";case"cloud":return"https://cloud.builder.io";case"cdn2":return"https://cdn2.builder.io";case"cdn-qa":return"https://cdn-qa.builder.io";case"development":case"dev":return"http://localhost:5000";default:return"https://cdn.builder.io"}},enumerable:!0,configurable:!0}),e.prototype.flushGetContentQueue=function(t,i){var n=this;if(void 0===t&&(t=!1),!this.apiKey)throw new Error("Builder needs to be initialized with an API key!");if(t||this.getContentQueue){var r=i||(t?this.priorContentQueue:this.getContentQueue)||[];this.getOverridesFromQueryString();var s={omit:"meta.componentsUsed"},o="undefined"!=typeof location?QueryString.parseDeep(location.search.substr(1)):{},a=r&&r[0].userAttributes?r[0].userAttributes:this.targetContent?this.getUserAttributes():{urlPath:this.getLocation().pathname};if(s.userAttributes=e.useNewApi?a:JSON.stringify(a),t||i||(this.priorContentQueue=r,this.getContentQueue=null),(this.cachebust||isIframe||o.cachebust||o["builder.cachebust"]||"production"!==this.env)&&(s.cachebust=!0),e.isEditing&&(s.isEditing=!0),(this.noCache||"production"!==this.env)&&(s.noCache=!0),size(this.overrides))for(var u in this.overrides)this.overrides.hasOwnProperty(u)&&(s["overrides."+u]=this.overrides[u]);if(e.useNewApi&&!e.isReact&&(s.prerender=!0),e.useNewApi)for(var c=0,d=r;c<d.length;c++){var l=d[c];l.format&&(s.format=l.format),l.static&&(s.static=l.static),l.cachebust&&(s.cachebust=l.cachebust),"number"==typeof l.cacheSeconds&&(s.cacheSeconds=l.cacheSeconds);for(var h=0,p=["prerender","extractCss","limit","offset","query","preview","model","entry","rev","static"];h<p.length;h++){var f=l[u=p[h]];void 0!==f&&(s.options=s.options||{},s.options[l.key]=s.options[l.key]||{},s.options[l.key][u]=JSON.stringify(f))}}this.preview&&(s.preview="true");var v=Object.keys(s).length>0,g=this.useNewContentApi?"https://lambda.builder.codes":this.host,m=r.map(function(e){return encodeURIComponent(e.key)}).join(",");if(this.overrideParams)assign(s,QueryString.parse(this.overrideParams));var y=e.useNewApi?QueryString.stringifyDeep(s):QueryString.stringify(s);return this.requestUrl(g+"/api/v1/"+(e.useNewApi?"query":"content")+"/"+this.apiKey+"/"+m+(s&&v?"?"+y:"")).then(function(t){for(var i=0,s=r;i<s.length;i++){var o=s[i],a=o.key;if(o.model!==n.blockContentLoading){n.editingModel===o.model&&e.isEditing&&parent.postMessage({type:"builder.updateContent"},"*");var u=n.observersByKey[a];if(!u)return;var c=t[a],d=c;if(c){var l=n.processResultsForTests(d);u.next(l)}else{if((n.getLocation().search||"").includes("builder.preview="+o.model)){u.next([{id:"preview",name:"Preview",data:{}}])}u.next([])}}}},function(e){for(var t=0,i=r;t<i.length;t++){var s=i[t],o=n.observersByKey[s.key];if(!o)return;o.error(e)}})}},e.prototype.processResultsForTests=function(e){var t,i=this,n=e.map(function(e){if(!e.variations)return e;var t=i.getTestCookie(e.id),n=t===e.id?e:e.variations[t];if(n)return __assign(__assign({},e),{data:n.data,variationId:t,testVariationId:t,testVariationName:n.name});if(e.variations&&size(e.variations)){var r=0,s=Math.random();for(var o in e.variations){var a=e.variations[o];if(s<(r+=a.testRatio)){i.setTestCookie(e.id,a.id);var u=a.name||(a.id===e.id?"Default variation":"");return __assign(__assign({},e),{data:a.data,variationId:a.id,testVariationId:a.id,variationName:u,testVariationName:u})}}i.setTestCookie(e.id,e.id)}return __assign(__assign(__assign({},e),{variationId:e.id}),e.variations&&size(e.variations)&&{testVariationId:e.id,testVariationName:"Default variation"})});return isIframe&&(null===(t=window.parent)||void 0===t||t.postMessage({type:"builder.contentResults",data:{results:n}},"*")),n},e.prototype.getTestCookie=function(e){return this.getCookie(this.testCookiePrefix+"."+e)},e.prototype.setTestCookie=function(e,t){if(this.canTrack){var i=new Date;return i.setDate(i.getDate()+30),this.setCookie(this.testCookiePrefix+"."+e,t,i)}this.cookieQueue.push([e,t])},e.prototype.getCookie=function(t){return this.cookies?this.cookies.get(t):e.isBrowser&&getCookie(t)},e.prototype.setCookie=function(t,i,n){return this.cookies?this.cookies.set(t,i,{expires:n,secure:"https:"===this.getLocation().protocol}):e.isBrowser&&setCookie(t,i,n)},e.prototype.getContent=function(e,t){if(void 0===t&&(t={}),!this.apiKey)throw new Error("Builder needs to be initialized with an API key!");return this.queueGetContent(e)},e.components=[],e.nextTick=nextTick,e.VERSION=version,e.useNewApi=!0,e.animator=new Animator,e.throttle=throttle,e.editors=[],e.plugins=[],e.actions=[],e.registry={},e.registryChange=new BehaviorSubject({}),e._editingPage=!1,e.isIframe=isIframe,e.isBrowser=isBrowser,e.isReactNative=isReactNative,e.isServer=!isBrowser&&!isReactNative,e.previewingModel=e.isBrowser&&getQueryParam(location.href,"builder.preview"),e.settings={},e.settingsChange=new BehaviorSubject({}),e.isEditing=Boolean(isIframe&&(document.referrer&&document.referrer.match(/builder\.io|localhost:1234/)||-1!==location.search.indexOf("builder.frameEditing="))),e.isPreviewing=Boolean(isIframe&&(document.referrer&&document.referrer.match(/builder\.io|localhost:1234/)||-1!==location.search.indexOf("builder.preview=")||-1!==location.search.indexOf("builder.frameEditing="))),e.isReact=!1,e.overrideUserAttributes={},e}(),builder=new Builder(null,void 0,void 0,!0);Builder.singletonInstance=builder,exports.Builder=Builder,exports.BuilderComponent=BuilderComponent,exports.isBrowser=isBrowser,exports.BehaviorSubject=BehaviorSubject,exports.Subscription=Subscription,exports.builder=builder,Object.defineProperty(exports,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("@builder.io/sdk",["exports"],t):t(e.BuilderIO={})}(this,function(exports){"use strict";var __assign=function(){return(__assign=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};!function(){if("undefined"==typeof window||"function"==typeof window.CustomEvent)return!1;window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i}}();var isSafari="undefined"!=typeof window&&/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent);function nextTick(e){if("function"==typeof setImmediate&&"undefined"==typeof window)return setImmediate(e);if(isSafari||"undefined"==typeof MutationObserver)setTimeout(e);else{var t=0,i=new MutationObserver(function(){return e()}),n=document.createTextNode("");i.observe(n,{characterData:!0}),n.data=String(t=++t)}}var QueryString=function(){function e(){}return e.parseDeep=function(e){var t=this.parse(e);return this.deepen(t)},e.stringifyDeep=function(e){var t=this.flatten(e);return this.stringify(t)},e.parse=function(e){for(var t={},i=("?"===e[0]?e.substr(1):e).split("&"),n=0;n<i.length;n++){var r=i[n].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1]||"")}return t},e.stringify=function(e){var t="";for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];t&&(t+="&"),t+=encodeURIComponent(i)+"="+encodeURIComponent(n)}return t},e.deepen=function(e){var t={};for(var i in e){for(var n=t,r=i.split("."),s=r.pop();r.length;){var o=r.shift();n=n[o]=n[o]||{}}n[s]=e[i]}return t},e.flatten=function(e,t,i){for(var n in void 0===i&&(i={}),e){var r=e[n],s=t?t+"."+n:n;r&&"object"==typeof r?this.flatten(r,s,i):i[s]=r}return i},e}(),version="1.1.5-alpha.0",Subscription=function(){function e(e,t){this.listeners=e,this.listener=t,this.unsubscribed=!1,this.otherSubscriptions=[]}return e.prototype.add=function(e){this.otherSubscriptions.push(e)},e.prototype.unsubscribe=function(){if(!this.unsubscribed){if(this.listener&&this.listeners){var e=this.listeners.indexOf(this.listener);e&&this.listeners.splice(e,1)}this.otherSubscriptions.forEach(function(e){return e.unsubscribe()}),this.unsubscribed=!0}},e}(),BehaviorSubject=function(){function e(e){this.value=e,this.listeners=[],this.errorListeners=[]}return e.prototype.next=function(e){this.value=e;for(var t=0,i=this.listeners;t<i.length;t++){(0,i[t])(e)}},e.prototype.map=function(t){var i=new e(t(this.value));return this.subscribe(function(e){i.next(t(e))}),this.catch(function(e){i.error(e)}),i},e.prototype.catch=function(e){return this.errorListeners.push(e),new Subscription(this.errorListeners,e)},e.prototype.error=function(e){for(var t=0,i=this.errorListeners;t<i.length;t++){(0,i[t])(e)}},e.prototype.subscribe=function(e,t){return this.listeners.push(e),t&&this.errorListeners.push(t),new Subscription(this.listeners,e)},e.prototype.toPromise=function(){var e=this;return new Promise(function(t,i){var n=e.subscribe(function(e){t(e),n.unsubscribe()},function(e){i(e),n.unsubscribe()})})},e.prototype.promise=function(){return this.toPromise()},e}(),State={Pending:"Pending",Fulfilled:"Fulfilled",Rejected:"Rejected"};function isFunction(e){return e&&"function"==typeof e}function isObject(e){return e&&"object"==typeof e}var TinyPromise=function(){function e(e){this._state=State.Pending,this._handlers=[],this._value=null,e(this._resolve.bind(this),this._reject.bind(this))}return e.prototype._resolve=function(t){var i=this;if(t instanceof e)t.then(this._resolve.bind(this),this._reject.bind(this));else if(isObject(t)||isFunction(t)){var n=!1;try{var r=t.then;isFunction(r)?r.call(t,function(e){n||i._resolve(e),n=!0},function(e){n||i._reject(e),n=!0}):this._fulfill(t)}catch(e){n||this._reject(e)}}else this._fulfill(t)},e.prototype._fulfill=function(e){var t=this;this._state=State.Fulfilled,this._value=e,this._handlers.forEach(function(e){return t._callHandler(e)})},e.prototype._reject=function(e){var t=this;this._state=State.Rejected,this._value=e,this._handlers.forEach(function(e){return t._callHandler(e)})},e.prototype._isPending=function(){return this._state===State.Pending},e.prototype._isFulfilled=function(){return this._state===State.Fulfilled},e.prototype._isRejected=function(){return this._state===State.Rejected},e.prototype._addHandler=function(e,t){this._handlers.push({onFulfilled:e,onRejected:t})},e.prototype._callHandler=function(e){this._isFulfilled()&&isFunction(e.onFulfilled)?e.onFulfilled(this._value):this._isRejected()&&isFunction(e.onRejected)&&e.onRejected(this._value)},e.prototype.then=function(t,i){var n=this;switch(this._state){case State.Pending:return new e(function(e,r){n._addHandler(function(i){nextTick(function(){try{isFunction(t)?e(t(i)):e(i)}catch(e){r(e)}})},function(t){nextTick(function(){try{isFunction(i)?e(i(t)):r(t)}catch(e){r(e)}})})});case State.Fulfilled:return new e(function(e,i){nextTick(function(){try{isFunction(t)?e(t(n._value)):e(n._value)}catch(e){i(e)}})});case State.Rejected:return new e(function(e,t){nextTick(function(){try{isFunction(i)?e(i(n._value)):t(n._value)}catch(e){t(e)}})})}},e}(),Promise$1="undefined"!=typeof Promise?Promise:TinyPromise,serverOnlyRequire;try{serverOnlyRequire=eval("require")}catch(e){serverOnlyRequire=function(){return null}}var serverOnlyRequire$1=serverOnlyRequire;function promiseResolve(e){return new Promise$1(function(t){return t(e)})}function tinyFetch(e,t){return void 0===t&&(t={}),new Promise$1(function(i,n){var r=new XMLHttpRequest;if(r.open(t.method||"get",e,!0),t.headers)for(var s in t.headers)r.setRequestHeader(s,t.headers[s]);function o(){var e=[],t=[],i={},n=void 0;return r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(r,s,o){var a=s;return e.push(a=a.toLowerCase()),t.push([a,o]),n=i[a],i[a]=n?n+","+o:o,""}),{ok:2==(r.status/100|0),status:r.status,statusText:r.statusText,url:r.responseURL,clone:o,text:function(){return promiseResolve(r.responseText)},json:function(){return promiseResolve(r.responseText).then(JSON.parse)},blob:function(){return promiseResolve(new Blob([r.response]))},headers:{keys:function(){return e},entries:function(){return t},get:function(e){return i[e.toLowerCase()]},has:function(e){return e.toLowerCase()in i}}}}r.withCredentials="include"===t.credentials,r.onload=function(){i(o())},r.onerror=n,r.send(t.body)})}var fetch="object"==typeof global&&"function"==typeof global.fetch?global.fetch:"undefined"==typeof window?serverOnlyRequire$1("node-fetch"):void 0!==window.fetch?window.fetch:tinyFetch;function assign(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=Object(e),r=1;r<arguments.length;r++){var s=arguments[r];if(null!=s)for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(n[o]=s[o])}return n}function throttle(e,t,i){var n,r,s;void 0===i&&(i={});var o=null,a=0,u=function(){a=!1===i.leading?0:Date.now(),o=null,s=e.apply(n,r),o||(n=r=null)};return function(){var c=Date.now();a||!1!==i.leading||(a=c);var d=t-(c-a);return n=this,r=arguments,d<=0||d>t?(o&&(clearTimeout(o),o=null),a=c,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=setTimeout(u,d)),s}}var camelCaseToKebabCase=function(e){return e?e.replace(/([A-Z])/g,function(e){return"-"+e[0].toLowerCase()}):""},Animator=function(){function e(){}return e.prototype.bindAnimations=function(e){for(var t=0,i=e;t<i.length;t++){var n=i[t];switch(n.trigger){case"pageLoad":this.triggerAnimation(n);break;case"hover":this.bindHoverAnimation(n);break;case"scrollInView":this.bindScrollInViewAnimation(n)}}},e.prototype.warnElementNotPresent=function(e){console.warn("Cannot animate element: element with ID "+e+" not found!")},e.prototype.augmentAnimation=function(e,t){for(var i=this.getAllStylesUsed(e),n=getComputedStyle(t),r=0,s=[e.steps[0].styles,e.steps[e.steps.length-1].styles];r<s.length;r++)for(var o=s[r],a=0,u=i;a<u.length;a++){var c=u[a];c in o||(o[c]=n[c])}},e.prototype.getAllStylesUsed=function(e){for(var t=[],i=0,n=e.steps;i<n.length;i++){var r=n[i];for(var s in r.styles)-1===t.indexOf(s)&&t.push(s)}return t},e.prototype.triggerAnimation=function(e){var t=this,i=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));i.length?Array.from(i).forEach(function(i){t.augmentAnimation(e,i),i.style.transition="none",i.style.transitionDelay="0",assign(i.style,e.steps[0].styles),setTimeout(function(){i.style.transition="all "+e.duration+"s "+camelCaseToKebabCase(e.easing),e.delay&&(i.style.transitionDelay=e.delay+"s"),assign(i.style,e.steps[1].styles),setTimeout(function(){i.style.transition="",i.style.transitionDelay=""},1e3*(e.delay||0)+1e3*e.duration+100)})}):this.warnElementNotPresent(e.elementId||e.id||"")},e.prototype.bindHoverAnimation=function(e){var t=this,i=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));i.length?Array.from(i).forEach(function(i){t.augmentAnimation(e,i);var n=e.steps[0].styles,r=e.steps[1].styles;function s(){assign(i.style,n)}s(),i.addEventListener("mouseenter",function(){assign(i.style,r)}),i.addEventListener("mouseleave",s),setTimeout(function(){i.style.transition="all "+e.duration+"s "+camelCaseToKebabCase(e.easing),e.delay&&(i.style.transitionDelay=e.delay+"s")})}):this.warnElementNotPresent(e.elementId||e.id||"")},e.prototype.bindScrollInViewAnimation=function(e){var t=this,i=Array.prototype.slice.call(document.getElementsByClassName(e.elementId||e.id||""));i.length?Array.from(i).forEach(function(i){t.augmentAnimation(e,i);var n=!1;function r(){var t,r,o;!n&&(t=i.getBoundingClientRect(),r=window.innerHeight,o=0*r,t.bottom>o&&t.top<r-o)&&(n=!0,setTimeout(function(){assign(i.style,e.steps[1].styles),document.removeEventListener("scroll",s),setTimeout(function(){i.style.transition="",i.style.transitionDelay=""},1e3*(1e3*e.duration+(e.delay||0))+100)}))}var s=throttle(r,200,{leading:!1});var o=e.steps[0].styles;assign(i.style,o),setTimeout(function(){i.style.transition="all "+e.duration+"s "+camelCaseToKebabCase(e.easing),e.delay&&(i.style.transitionDelay=e.delay+"s")}),document.addEventListener("scroll",s,{capture:!0,passive:!0}),r()}):this.warnElementNotPresent(e.elementId||e.id||"")},e}(),fieldContentRegExp=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Cookies=function(){function e(e,t){this.request=e,this.response=t}return e.prototype.get=function(e){var t=this.request.headers.cookie;if(t){var i=t.match(getPattern(e));if(i)return i[1]}},e.prototype.set=function(e,t,i){var n=this.response,r=this.request,s=n.getHeader("Set-Cookie")||[],o=void 0!==this.secure?!!this.secure:"https"===r.protocol||r.connection.encrypted,a=new Cookie(e,t,i);if("string"==typeof s&&(s=[s]),!o&&i&&i.secure)throw new Error("Cannot send secure cookie over unencrypted connection");return a.secure=o,i&&"secure"in i&&(a.secure=!!i.secure),pushCookie(s,a),n.setHeader.call(n,"Set-Cookie",s),this},e}(),Cookie=function(){function e(e,t,i){if(this.path="/",this.domain=void 0,this.httpOnly=!0,this.sameSite=!1,this.secure=!1,this.overwrite=!1,this.name="",this.value="",!fieldContentRegExp.test(e))throw new TypeError("argument name is invalid");if(t&&!fieldContentRegExp.test(t))throw new TypeError("argument value is invalid");t||(this.expires=new Date(0)),this.name=e,this.value=t||"",i.expires&&(this.expires=i.expires),i.secure&&(this.secure=i.secure)}return e.prototype.toString=function(){return this.name+"="+this.value},e.prototype.toHeader=function(){var e=this.toString();return this.maxAge&&(this.expires=new Date(Date.now()+this.maxAge)),this.path&&(e+="; path="+this.path),this.expires&&(e+="; expires="+this.expires.toUTCString()),this.domain&&(e+="; domain="+this.domain),e+="; SameSite="+(!0===this.sameSite?"strict":"None"),this.secure&&(e+="; secure"),this.httpOnly&&(e+="; httponly"),e},e}();function getPattern(e){return new RegExp("(?:^|;) *"+e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"=([^;]*)")}function pushCookie(e,t){if(t.overwrite)for(var i=e.length-1;i>=0;i--)0===e[i].indexOf(t.name+"=")&&e.splice(i,1);e.push(t.toHeader())}function omit(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=Object.assign({},e),r=0,s=t;r<s.length;r++){delete n[s[r]]}return n}var isReactNative="object"==typeof navigator&&"ReactNative"===navigator.product,validEnvList=["production","qa","development","dev","cdn-qa","cloud","fast","cdn2"];function getQueryParam(e,t){for(var i=(e.split("?")[1]||"").split("&"),n=0;n<i.length;n++){var r=i[n].split("=");if(decodeURIComponent(r[0])===t)return decodeURIComponent(r[1])}return null}var urlParser={parse:function(e){var t=document.createElement("a");t.href=e;for(var i={},n="username password host hostname port protocol origin pathname search hash".split(" "),r=n.length;r--;)i[n[r]]=t[n[r]];return!i.pathname&&""!==i.pathname||"string"!=typeof i.pathname||0===i.pathname.indexOf("/")||(i.pathname="/"+i.pathname),i}},parse=isReactNative?function(){return{}}:"object"==typeof window?urlParser.parse:serverOnlyRequire$1("url").parse;function setCookie(e,t,i){var n="";i&&(n="; expires="+i.toUTCString());var r=!isBrowser||"https:"===location.protocol;document.cookie=e+"="+(t||"")+n+"; path=/"+(r?";secure":"")+"; SameSite=None"}function getCookie(e){return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null}function size(e){return Object.keys(e).length}function find(e,t){for(var i=e,n=i.length>>>0,r=arguments[1],s=0;s<n;s++){var o=i[s];if(t.call(r,o,s,i))return o}}var sessionStorageKey="builderSessionId",isBrowser="undefined"!=typeof window&&!isReactNative,isIframe=isBrowser&&window.top!==window.self;function BuilderComponent(e){return void 0===e&&(e={}),Builder.Component(e)}var Builder=function(){function e(t,i,n,r){var s=this;if(void 0===t&&(t=null),void 0===r&&(r=!1),this.request=i,this.response=n,this.authToken="",this.eventsQueue=[],this.throttledClearEventsQueue=throttle(function(){s.processEventsQueue()},100),this.env="production",this.sessionId=this.getSessionId(),this.targetContent=!0,this.cookies=null,this.cachebust=!1,this.overrideParams="",this.noCache=!1,this.overrideHost="",this.preview=!1,this.canTrack$=new BehaviorSubject(!this.browserTrackingDisabled),this.apiKey$=new BehaviorSubject(null),this.editingMode$=new BehaviorSubject(isIframe),this.editingModel$=new BehaviorSubject(null),this.userAgent="object"==typeof navigator&&navigator.userAgent||"",this.autoTrack=!!e.isBrowser&&!(this.isDevelopmentEnv||e.isBrowser&&-1!==location.search.indexOf("builder.preview=")),this.useNewContentApi=!1,this.blockContentLoading="",this.observersByKey={},this.overrides={},this.getContentQueue=null,this.priorContentQueue=null,this.testCookiePrefix="builder.tests",this.cookieQueue=[],e.isBrowser&&!r&&e.singletonInstance)return e.singletonInstance;this.request&&this.response&&(this.setUserAgent(this.request.headers["user-agent"]||""),this.cookies=new Cookies(this.request,this.response)),t&&(this.apiKey=t),isBrowser&&this.bindMessageListeners(),isIframe&&this.messageFrameLoaded(),this.canTrack$.subscribe(function(e){if(e){if("undefined"!=typeof sessionStorage)try{sessionStorage.getItem(sessionStorageKey)||sessionStorage.setItem(sessionStorageKey,s.sessionId)}catch(e){console.debug("Session storage error",e)}s.eventsQueue.length&&s.throttledClearEventsQueue(),s.cookieQueue.length&&(s.cookieQueue.forEach(function(e){s.setCookie(e[0],e[1])}),s.cookieQueue.length=0)}}),isBrowser&&(this.setTestsFromUrl(),this.getOverridesFromQueryString())}return e.register=function(t,i){var n=this.registry[t];if(n||(n=this.registry[t]=[]),n.push(i),e.isBrowser){var r={type:"builder.register",data:{type:t,info:i}};parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}this.registryChange.next(this.registry)},e.registerEditor=function(t){if(e.isBrowser){window.postMessage({type:"builder.registerEditor",data:omit(t,"component")},"*");var i=location.host;"localhost:1234"!==i&&-1===i.indexOf("builder.io")&&console.error("Builder.registerEditor() called in the wrong environment! You cannot load custom editors from your app, they must be loaded through the Builder.io app itself. Follow the readme here for more details: https://github.com/builderio/builder/tree/master/plugins/cloudinary or contact chat us in our Spectrum community for help: https://spectrum.chat/builder")}this.editors.push(t)},e.registerPlugin=function(e){this.plugins.push(e)},e.registerAction=function(e){this.actions.push(e)},e.runAction=function(e){if(!("string"==typeof e?find(this.actions,function(t){return t.name===e}):e))throw new Error("Action not found: "+e)},e.fields=function(e,t){var i;null===(i=window.parent)||void 0===i||i.postMessage({type:"builder.fields",data:{name:e,fields:t}},"*")},e.set=function(t){if(e.isBrowser){Object.assign(this.settings,t);var i={type:"builder.settingsChange",data:this.settings};parent.postMessage(i,"*")}this.settingsChange.next(this.settings)},e.import=function(t){if(e.isBrowser){var i=window.System;if(i)return i.import("https://cdn.builder.io/systemjs/"+t);console.warn("System.js not available. Please include System.js when using Builder.import")}else console.warn("Builder.import used on the server - this should only be used in the browser")},Object.defineProperty(e,"editingPage",{get:function(){return this._editingPage},set:function(e){this._editingPage=e,isBrowser&&isIframe&&(e?document.body.classList.add("builder-editing-page"):document.body.classList.remove("builder-editing-page"))},enumerable:!0,configurable:!0}),e.prepareComponentSpecToSend=function(e){return __assign(__assign(__assign({},e),e.inputs&&{inputs:e.inputs.map(function(e){for(var t,i=0,n=["onChange","showIf"];i<n.length;i++){var r=n[i];if(e[r]&&"function"==typeof e[r]){var s=e[r];e=__assign(__assign({},e),((t={})[r]="return ("+s.toString()+").apply(this, arguments)",t))}}return e})}),{hooks:Object.keys(e.hooks||{}).reduce(function(t,i){var n=e.hooks&&e.hooks[i];return n?(t[i]="string"==typeof n?n:"return ("+n.toString()+").apply(this, arguments)",t):t},{}),class:void 0})},e.registerComponent=function(e,t){var i,n=__assign(__assign({class:e},e.builderOptions),t);if(this.addComponent(n),isBrowser){var r=this.prepareComponentSpecToSend(n);null===(i=window.parent)||void 0===i||i.postMessage({type:"builder.registerComponent",data:r},"*")}},e.addComponent=function(e){var t=find(this.components,function(t){return t.name===e.name});if(t){if(t.class&&!e.class)return;this.components.splice(this.components.indexOf(t),1,e)}else this.components.push(e)},e.component=function(e){var t=this;return void 0===e&&(e={}),function(i){var n,r=__assign(__assign({},e),{class:i});r.name||(r.name=i.name),t.addComponent(r);var s=t.prepareComponentSpecToSend(r);return isBrowser&&(null===(n=window.parent)||void 0===n||n.postMessage({type:"builder.registerComponent",data:s},"*")),i}},Object.defineProperty(e,"Component",{get:function(){return this.component},enumerable:!0,configurable:!0}),e.prototype.processEventsQueue=function(){if(this.eventsQueue.length){var e=this.eventsQueue;this.eventsQueue=[];var t=this.host;fetch(t+"/api/v1/track",{method:"POST",body:JSON.stringify({events:e}),headers:{"content-type":"application/json"},mode:"cors"}).catch(function(){})}},Object.defineProperty(e.prototype,"browserTrackingDisabled",{get:function(){return e.isBrowser&&"1"===navigator.doNotTrack},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canTrack",{get:function(){return this.canTrack$.value},set:function(e){this.canTrack!==e&&this.canTrack$.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editingMode",{get:function(){return this.editingMode$.value},set:function(e){e!==this.editingMode&&this.editingMode$.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editingModel",{get:function(){return this.editingModel$.value},set:function(e){e!==this.editingModel&&this.editingModel$.next(e)},enumerable:!0,configurable:!0}),e.prototype.findParentElement=function(e,t,i){if(void 0===i&&(i=!0),!(e instanceof HTMLElement))return null;var n=i?e:e.parentElement;do{if(!n)return null;if(t(n))return n}while(n=n.parentElement);return null},e.prototype.findBuilderParent=function(e){return this.findParentElement(e,function(e){var t=e.getAttribute("builder-id")||e.id;return Boolean(t&&0===t.indexOf("builder-"))})},e.prototype.setUserAgent=function(e){this.userAgent=e||""},e.prototype.track=function(t,i){void 0===i&&(i={}),isIframe||!isBrowser||e.isPreviewing||(this.eventsQueue.push({type:t,data:__assign(__assign({},omit(i,"meta")),{metadata:__assign(__assign({sdkVersion:e.VERSION,url:location.href},i.meta),i.metadata),ownerId:this.apiKey,userAttributes:this.getUserAttributes(),sessionId:this.sessionId})}),this.canTrack&&this.throttledClearEventsQueue())},e.prototype.getSessionId=function(){var t=this,i=null;try{e.isBrowser&&"undefined"!=typeof sessionStorage&&sessionStorage.getItem(sessionStorageKey)}catch(e){console.debug("Session storage error",e)}return i||(i=(Date.now()+Math.random()).toString(36)),e.isBrowser&&setTimeout(function(){try{t.canTrack&&"undefined"!=typeof sessionStorage&&i&&sessionStorage.setItem(sessionStorageKey,i)}catch(e){console.debug("Session storage error",e)}}),i},e.prototype.trackImpression=function(t,i){isIframe||!isBrowser||e.isPreviewing||(this.eventsQueue.push({type:"impression",data:{contentId:t,variationId:i!==t?i:void 0,ownerId:this.apiKey,userAttributes:this.getUserAttributes(),sessionId:this.sessionId}}),this.throttledClearEventsQueue())},e.prototype.trackConversion=function(t,i,n){isIframe||!isBrowser||e.isPreviewing||(this.eventsQueue.push({type:"conversion",data:{amount:t,contentId:i,variationId:n,ownerId:this.apiKey,userAttributes:this.getUserAttributes(),sessionId:this.sessionId}}),this.throttledClearEventsQueue())},Object.defineProperty(e.prototype,"isDevelopmentEnv",{get:function(){return e.isIframe||e.isBrowser&&("localhost"===location.hostname||""!==location.port)||"production"!==this.env},enumerable:!0,configurable:!0}),e.prototype.trackInteraction=function(t,i,n,r){if(void 0===n&&(n=!1),!isIframe&&isBrowser&&!e.isPreviewing){var s=r&&r.target,o=s&&this.findBuilderParent(s),a={};if(r){var u=r.clientX,c=r.clientY;if(s){var d=u-(f=s.getBoundingClientRect()).left,l=c-f.top,h=g(d/f.width),p=g(l/f.height);a.targetOffset={x:h,y:p}}if(o){var f;d=u-(f=o.getBoundingClientRect()).left,l=c-f.top,h=g(d/f.width),p=g(l/f.height);a.builderTargetOffset={x:h,y:p}}}var v=o&&(o.getAttribute("builder-id")||o.id);v&&o&&(a.builderElementIndex=[].slice.call(document.getElementsByClassName(v)).indexOf(o)),this.eventsQueue.push({type:"click",data:{contentId:t,metadata:a,variationId:i!==t?i:void 0,ownerId:this.apiKey,unique:!n,targetBuilderElement:v||void 0,userAttributes:this.getUserAttributes(),sessionId:this.sessionId}}),this.throttledClearEventsQueue()}function g(e){return Math.round(1e3*e)/1e3}},e.prototype.component=function(t){return void 0===t&&(t={}),e.component(t)},Object.defineProperty(e.prototype,"apiKey",{get:function(){return this.apiKey$.value},set:function(e){this.apiKey$.next(e)},enumerable:!0,configurable:!0}),e.prototype.modifySearch=function(e){return e.replace(/(^|&|\?)(builder_.*?)=/gi,function(e,t,i){return t+i.replace(/_/g,".")+"="})},e.prototype.setTestsFromUrl=function(){var e=this.getLocation().search,t=QueryString.parseDeep(this.modifySearch(e||"").substr(1)),i=t.builder&&t.builder.tests;if(i&&"object"==typeof i)for(var n in i)i.hasOwnProperty(n)&&this.setTestCookie(n,i[n])},e.prototype.resetOverrides=function(){e.overrideUserAttributes={},this.cachebust=!1,this.noCache=!1,this.preview=!1,this.overrideHost="",this.editingModel=null,this.overrides={},this.env="production",this.userAgent="",this.request=void 0,this.response=void 0},e.prototype.getOverridesFromQueryString=function(){var t=this.getLocation(),i=QueryString.parseDeep(this.modifySearch(t.search||"").substr(1)),n=i.builder;if(n){var r=n.userAttributes,s=n.overrides,o=n.env,a=n.host,u=n.api,c=n.cachebust,d=n.noCache,l=n.preview,h=n.editing,p=n.frameEditing,f=n.params;if(r&&this.setUserAttributes(r),s&&(this.overrides=s),validEnvList.indexOf(o||u)>-1&&(this.env=o||u),e.isEditing){var v=p||h||l;v&&"true"!==v&&(this.editingModel=v)}a&&(this.overrideHost=a),c&&(this.cachebust=!0),d&&(this.noCache=!0),l&&(this.preview=!0),i&&(this.overrideParams=f)}},e.prototype.messageFrameLoaded=function(){var e;null===(e=window.parent)||void 0===e||e.postMessage({type:"builder.loaded",data:{value:!0}},"*")},e.prototype.bindMessageListeners=function(){var t=this;isBrowser&&addEventListener("message",function(i){var n,r,s,o,a,u=parse(i.origin);if(!(-1===["builder.register","builder.registerComponent"].indexOf(null===(n=i.data)||void 0===n?void 0:n.type))||u.hostname&&("builder.io"===u.hostname||u.hostname.endsWith(".builder.io")||"localhost"===u.hostname)){var c=i.data;if(c)switch(c.type){case"builder.ping":null===(r=window.parent)||void 0===r||r.postMessage({type:"builder.pong",data:{}},"*");break;case"builder.register":if(i.source===window)break;var d=c.data;if(!d)break;var l=d.type,h=d.info,p=e.registry[l];p||(p=e.registry[l]=[]),p.push(h),e.registryChange.next(e.registry);break;case"builder.settingsChange":if(i.source===window)break;var f=c.data;if(!f)break;Object.assign(e.settings,f),e.settingsChange.next(e.settings);break;case"builder.registerEditor":if(i.source===window)break;var v=c.data;if(!v)break;var g=!!v.component;e.editors.every(function(t,i){return v.name!==t.name||!(t.component&&!g)&&(e.editors[i]=t,!1)});break;case"builder.triggerAnimation":e.animator.triggerAnimation(c.data);break;case"builder.contentUpdate":var m=c.data.key||c.data.alias||c.data.entry||c.data.modelName,y=c.data.data,b=t.observersByKey[m];b&&b.next([y]);break;case"builder.getComponents":null===(s=window.parent)||void 0===s||s.postMessage({type:"builder.components",data:e.components.map(function(t){return e.prepareComponentSpecToSend(t)})},"*");break;case"builder.editingModel":t.editingModel=c.data.model;break;case"builder.registerComponent":var w=c.data;e.addComponent(w);break;case"builder.blockContentLoading":"string"==typeof c.data.model&&(t.blockContentLoading=c.data.model);break;case"builder.editingMode":c.data?(t.editingMode=!0,document.body.classList.add("builder-editing")):(t.editingMode=!1,document.body.classList.remove("builder-editing"));break;case"builder.editingPageMode":var C=c.data;e.editingPage=C;break;case"builder.overrideUserAttributes":var k=c.data;assign(e.overrideUserAttributes,k),t.flushGetContentQueue(!0);break;case"builder.overrideTestGroup":var S=c.data,_=S.variationId,B=S.contentId;_&&B&&(t.setTestCookie(B,_),t.flushGetContentQueue(!0));break;case"builder.evaluate":var I=c.data.text,x=c.data.arguments||[],A=c.data.id,O=new Function(I),P=void 0,T=null;try{P=O.apply(t,x)}catch(e){T=e}T?null===(o=window.parent)||void 0===o||o.postMessage({type:"builder.evaluateError",data:{id:A,error:T.message}},"*"):P&&"function"==typeof P.then?P.then(function(e){var t;null===(t=window.parent)||void 0===t||t.postMessage({type:"builder.evaluateResult",data:{id:A,result:e}},"*")}).catch(console.error):null===(a=window.parent)||void 0===a||a.postMessage({type:"builder.evaluateResult",data:{result:P,id:A}},"*")}}})},Object.defineProperty(e.prototype,"defaultCanTrack",{get:function(){return Boolean(e.isBrowser&&navigator.userAgent.trim()&&!navigator.userAgent.match(/bot|crawler|spider|robot|crawling|prerender|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|phantom|headless|selenium|puppeteer/i)&&!this.browserTrackingDisabled)},enumerable:!0,configurable:!0}),e.prototype.init=function(e,t,i,n){return void 0===t&&(t=this.defaultCanTrack),i&&(this.request=i),n&&(this.response=n),this.canTrack=t,this.apiKey=e,this},e.prototype.getLocation=function(){var e={};return this.request&&(e=parse(this.request.url)),"object"==typeof location&&(e=parse(location.href)),""===e.pathname&&(e.pathname="/"),e},e.prototype.getUserAttributes=function(t){void 0===t&&(t=this.userAgent||"");var i={Android:function(){return t.match(/Android/i)},BlackBerry:function(){return t.match(/BlackBerry/i)},iOS:function(){return t.match(/iPhone|iPod/i)},Opera:function(){return t.match(/Opera Mini/i)},Windows:function(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any:function(){return i.Android()||i.BlackBerry()||i.iOS()||i.Opera()||i.Windows()}},n=t.match(/Tablet|iPad/i),r=this.getLocation();return __assign({urlPath:r.pathname,host:r.host||r.hostname,device:n?"tablet":i.any()?"mobile":"desktop"},e.overrideUserAttributes)},e.prototype.setUserAttributes=function(t){assign(e.overrideUserAttributes,t)},e.prototype.get=function(t,i){void 0===i&&(i={});var n=this;return e.isBrowser||!i.req&&!i.res?i.apiKey&&!this.apiKey&&(this.apiKey=i.apiKey):n=new e(i.apiKey||this.apiKey,i.req,i.res),n.queueGetContent(t,i).map(function(e){var t=e&&e[0],i=t&&t.data;return i?{data:i,id:t.id,variationId:t.testVariationId||t.variationId,testVariationId:t.testVariationId||t.variationId,testVariationName:t.testVariationName}:null})},e.prototype.queueGetContent=function(t,i){var n=this;void 0===i&&(i={});var r=i.key||i.alias||t,s=this.editingModel===t,o=this.observersByKey[r];"DEMO"!==this.apiKey||this.overrides[r]||i.initialContent||(i.initialContent=[]);var a=i.initialContent;if(o&&(!o.value||i.cache))return o.value&&nextTick(function(){o.next(o.value)}),o;s&&e.isBrowser&&parent.postMessage({type:"builder.updateContent"},"*"),a||(this.getContentQueue||(this.getContentQueue=[]),this.getContentQueue.push(__assign(__assign({},i),{model:t,key:r})),this.getContentQueue&&this.getContentQueue.length>=5?this.flushGetContentQueue():nextTick(function(){n.flushGetContentQueue()}));var u=new BehaviorSubject(null);return this.observersByKey[r]=u,a&&nextTick(function(){u.next(a)}),u},e.prototype.requestUrl=function(t){return e.isBrowser?fetch(t,this.authToken?{headers:{Authorization:"Bearer "+this.authToken}}:void 0).then(function(e){return e.json()}):new Promise(function(e,i){(0===t.indexOf("http:")?serverOnlyRequire$1("http"):serverOnlyRequire$1("https")).get(t,function(t){var i="";t.on("data",function(e){i+=e}),t.on("end",function(){e(JSON.parse(i))})}).on("error",function(e){i(e)})})},Object.defineProperty(e.prototype,"host",{get:function(){if(this.overrideHost)return this.overrideHost;if(this.env.includes("//"))return this.env;if(this.env.includes("."))return"http://"+this.env;switch(this.env){case"qa":return"https://qa.builder.io";case"fast":return"https://fast.builder.io";case"cloud":return"https://cloud.builder.io";case"cdn2":return"https://cdn2.builder.io";case"cdn-qa":return"https://cdn-qa.builder.io";case"development":case"dev":return"http://localhost:5000";default:return"https://cdn.builder.io"}},enumerable:!0,configurable:!0}),e.prototype.flushGetContentQueue=function(t,i){var n,r,s=this;if(void 0===t&&(t=!1),!this.apiKey)throw new Error("Builder needs to be initialized with an API key!");if(t||this.getContentQueue){var o=i||(t?this.priorContentQueue:this.getContentQueue)||[];this.getOverridesFromQueryString();var a={omit:"meta.componentsUsed"},u="undefined"!=typeof location?QueryString.parseDeep(location.search.substr(1)):{},c=o&&o[0].userAttributes?o[0].userAttributes:this.targetContent?this.getUserAttributes():{urlPath:this.getLocation().pathname},d=null===(n=i)||void 0===n?void 0:n.find(function(e){return e.url});if((null===(r=d)||void 0===r?void 0:r.url)&&(c.urlPath=d.url.split("?")[0]),a.userAttributes=e.useNewApi?c:JSON.stringify(c),t||i||(this.priorContentQueue=o,this.getContentQueue=null),(this.cachebust||isIframe||u.cachebust||u["builder.cachebust"]||"production"!==this.env)&&(a.cachebust=!0),e.isEditing&&(a.isEditing=!0),(this.noCache||"production"!==this.env)&&(a.noCache=!0),size(this.overrides))for(var l in this.overrides)this.overrides.hasOwnProperty(l)&&(a["overrides."+l]=this.overrides[l]);if(e.useNewApi&&!e.isReact&&(a.prerender=!0),e.useNewApi)for(var h=0,p=o;h<p.length;h++){var f=p[h];f.format&&(a.format=f.format),f.static&&(a.static=f.static),f.cachebust&&(a.cachebust=f.cachebust),"number"==typeof f.cacheSeconds&&(a.cacheSeconds=f.cacheSeconds);for(var v=0,g=["prerender","extractCss","limit","offset","query","preview","model","entry","rev","static"];v<g.length;v++){var m=f[l=g[v]];void 0!==m&&(a.options=a.options||{},a.options[f.key]=a.options[f.key]||{},a.options[f.key][l]=JSON.stringify(m))}}this.preview&&(a.preview="true");var y=Object.keys(a).length>0,b=this.useNewContentApi?"https://lambda.builder.codes":this.host,w=o.map(function(e){return encodeURIComponent(e.key)}).join(",");if(this.overrideParams)assign(a,omit(QueryString.parse(this.overrideParams),"apiKey"));var C=e.useNewApi?QueryString.stringifyDeep(a):QueryString.stringify(a);return this.requestUrl(b+"/api/v1/"+(e.useNewApi?"query":"content")+"/"+this.apiKey+"/"+w+(a&&y?"?"+C:"")).then(function(t){for(var i=0,n=o;i<n.length;i++){var r=n[i],a=r.key;if(r.model!==s.blockContentLoading){s.editingModel===r.model&&e.isEditing&&parent.postMessage({type:"builder.updateContent"},"*");var u=s.observersByKey[a];if(!u)return;var c=t[a],d=c;if(c){var l=s.processResultsForTests(d);u.next(l)}else{if((s.getLocation().search||"").includes("builder.preview="+r.model)){u.next([{id:"preview",name:"Preview",data:{}}])}u.next([])}}}},function(e){for(var t=0,i=o;t<i.length;t++){var n=i[t],r=s.observersByKey[n.key];if(!r)return;r.error(e)}})}},e.prototype.processResultsForTests=function(e){var t,i=this,n=e.map(function(e){if(!e.variations)return e;var t=i.getTestCookie(e.id),n=t===e.id?e:e.variations[t];if(n)return __assign(__assign({},e),{data:n.data,variationId:t,testVariationId:t,testVariationName:n.name});if(e.variations&&size(e.variations)){var r=0,s=Math.random();for(var o in e.variations){var a=e.variations[o];if(s<(r+=a.testRatio)){i.setTestCookie(e.id,a.id);var u=a.name||(a.id===e.id?"Default variation":"");return __assign(__assign({},e),{data:a.data,variationId:a.id,testVariationId:a.id,variationName:u,testVariationName:u})}}i.setTestCookie(e.id,e.id)}return __assign(__assign(__assign({},e),{variationId:e.id}),e.variations&&size(e.variations)&&{testVariationId:e.id,testVariationName:"Default variation"})});return isIframe&&(null===(t=window.parent)||void 0===t||t.postMessage({type:"builder.contentResults",data:{results:n}},"*")),n},e.prototype.getTestCookie=function(e){return this.getCookie(this.testCookiePrefix+"."+e)},e.prototype.setTestCookie=function(e,t){if(this.canTrack){var i=new Date;return i.setDate(i.getDate()+30),this.setCookie(this.testCookiePrefix+"."+e,t,i)}this.cookieQueue.push([e,t])},e.prototype.getCookie=function(t){return this.cookies?this.cookies.get(t):e.isBrowser&&getCookie(t)},e.prototype.setCookie=function(t,i,n){return this.cookies?this.cookies.set(t,i,{expires:n,secure:"https:"===this.getLocation().protocol}):e.isBrowser&&setCookie(t,i,n)},e.prototype.getContent=function(e,t){if(void 0===t&&(t={}),!this.apiKey)throw new Error("Builder needs to be initialized with an API key!");return this.queueGetContent(e)},e.components=[],e.nextTick=nextTick,e.VERSION=version,e.useNewApi=!0,e.animator=new Animator,e.throttle=throttle,e.editors=[],e.plugins=[],e.actions=[],e.registry={},e.registryChange=new BehaviorSubject({}),e._editingPage=!1,e.isIframe=isIframe,e.isBrowser=isBrowser,e.isReactNative=isReactNative,e.isServer=!isBrowser&&!isReactNative,e.previewingModel=e.isBrowser&&getQueryParam(location.href,"builder.preview"),e.settings={},e.settingsChange=new BehaviorSubject({}),e.isEditing=Boolean(isIframe&&(document.referrer&&document.referrer.match(/builder\.io|localhost:1234/)||-1!==location.search.indexOf("builder.frameEditing="))),e.isPreviewing=Boolean(document.referrer&&document.referrer.match(/builder\.io|localhost:1234/)||-1!==location.search.indexOf("builder.preview=")||-1!==location.search.indexOf("builder.frameEditing=")),e.isReact=!1,e.overrideUserAttributes={},e}(),builder=new Builder(null,void 0,void 0,!0);Builder.singletonInstance=builder,exports.Builder=Builder,exports.BuilderComponent=BuilderComponent,exports.isBrowser=isBrowser,exports.BehaviorSubject=BehaviorSubject,exports.Subscription=Subscription,exports.builder=builder,Object.defineProperty(exports,"__esModule",{value:!0})});
//# sourceMappingURL=index.browser.js.map
/// <reference types="node" />
import { ServerRequest, ServerResponse } from 'http';
import './polyfills/custom-event-polyfill';
import { IncomingMessage, ServerResponse } from 'http';
import { nextTick } from './functions/next-tick.function';

@@ -9,6 +10,6 @@ import { BehaviorSubject } from './classes/observable.class';

import Cookies from './classes/cookies.class';
import { BuilderContent } from './types/content';
export declare type Url = any;
export declare const isReactNative: boolean;
export declare const validEnvList: string[];
export declare type Observer<T = any> = any;
export declare const isBrowser: boolean;

@@ -48,2 +49,3 @@ export declare const isIframe: boolean;

userAttributes?: UserAttributes;
url?: string;
cacheSeconds?: number;

@@ -107,2 +109,14 @@ limit?: number;

}[];
/** Regex field validation for all string types (text, longText, html, url, etc) */
regex?: {
/** pattern to test, like "^\/[a-z]$" */
pattern: string;
/** flags for the RegExp constructor, e.g. "gi" */
options?: string;
/**
* Friendly message to display to end-users if the regex fails, e.g.
* "You must use a relative url starting with '/...' "
*/
message: string;
};
advanced?: boolean;

@@ -208,2 +222,3 @@ onChange?: Function | string;

priority?: number;
persist?: boolean;
advanced?: boolean;

@@ -221,3 +236,3 @@ items: InsertMenuItem[];

export declare class Builder {
protected request?: ServerRequest | undefined;
protected request?: IncomingMessage | undefined;
protected response?: ServerResponse | undefined;

@@ -276,3 +291,2 @@ static components: Component[];

env: string;
protected isUsed: boolean;
sessionId: string;

@@ -313,3 +327,3 @@ targetContent: boolean;

set apiKey(key: string | null);
constructor(apiKey?: string | null, request?: ServerRequest | undefined, response?: ServerResponse | undefined, forceNewInstance?: boolean);
constructor(apiKey?: string | null, request?: IncomingMessage | undefined, response?: ServerResponse | undefined, forceNewInstance?: boolean);
private modifySearch;

@@ -323,6 +337,6 @@ setTestsFromUrl(): void;

observersByKey: {
[key: string]: Observer<any> | undefined;
[key: string]: BehaviorSubject<BuilderContent[]> | undefined;
};
get defaultCanTrack(): boolean;
init(apiKey: string, canTrack?: boolean, req?: ServerRequest, res?: ServerResponse): this;
init(apiKey: string, canTrack?: boolean, req?: IncomingMessage, res?: ServerResponse): this;
getLocation(): Url;

@@ -333,7 +347,7 @@ getUserAttributes(userAgent?: string): UserAttributes;

};
setUserAttributes(options: object): void;
private getContentQueue;
private priorContentQueue;
setUserAttributes(options: object): void;
get(modelName: string, options?: GetContentOptions & {
req?: ServerRequest;
req?: IncomingMessage;
res?: ServerResponse;

@@ -348,4 +362,4 @@ apiKey?: string;

} | null, any>;
queueGetContent(modelName: string, options?: GetContentOptions): BehaviorSubject<any, any>;
requestUrl(url: string): PromiseLike<any>;
queueGetContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
requestUrl(url: string): Promise<any>;
get host(): string;

@@ -360,4 +374,4 @@ private flushGetContentQueue;

setCookie(name: string, value: any, expires?: Date): false | void | Cookies;
getContent(modelName: string, options?: GetContentOptions): BehaviorSubject<any, any>;
getContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
}
export {};

@@ -14,2 +14,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
require("./polyfills/custom-event-polyfill");
var next_tick_function_1 = require("./functions/next-tick.function");

@@ -129,3 +130,2 @@ var query_string_class_1 = require("./classes/query-string.class");

this.env = 'production';
this.isUsed = false;
this.sessionId = this.getSessionId();

@@ -418,2 +418,4 @@ this.targetContent = true;

mode: 'cors',
}).catch(function () {
// Not the end of the world
});

@@ -430,3 +432,3 @@ };

get: function () {
return this.canTrack$.value && !this.browserTrackingDisabled;
return this.canTrack$.value;
},

@@ -525,10 +527,10 @@ set: function (canTrack) {

setTimeout(function () {
if (_this.canTrack && typeof sessionStorage !== 'undefined' && sessionId) {
try {
try {
if (_this.canTrack && typeof sessionStorage !== 'undefined' && sessionId) {
sessionStorage.setItem(sessionStorageKey, sessionId);
}
catch (err) {
console.debug('Session storage error', err);
}
}
catch (err) {
console.debug('Session storage error', err);
}
});

@@ -750,8 +752,10 @@ }

addEventListener('message', function (event) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
var url = parse(event.origin);
if (!(url.hostname &&
(url.hostname === 'builder.io' ||
url.hostname.endsWith('.builder.io') ||
url.hostname === 'localhost'))) {
var isRestricted = ['builder.register', 'builder.registerComponent'].indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === -1;
if (isRestricted &&
!(url.hostname &&
(url.hostname === 'builder.io' ||
url.hostname.endsWith('.builder.io') ||
url.hostname === 'localhost'))) {
return;

@@ -763,3 +767,3 @@ }

case 'builder.ping': {
(_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
(_b = window.parent) === null || _b === void 0 ? void 0 : _b.postMessage({
type: 'builder.pong',

@@ -839,3 +843,3 @@ data: {},

case 'builder.getComponents':
(_b = window.parent) === null || _b === void 0 ? void 0 : _b.postMessage({
(_c = window.parent) === null || _c === void 0 ? void 0 : _c.postMessage({
type: 'builder.components',

@@ -879,3 +883,3 @@ data: Builder.components.map(function (item) { return Builder.prepareComponentSpecToSend(item); }),

case 'builder.overrideTestGroup':
var _e = data.data, variationId = _e.variationId, contentId = _e.contentId;
var _f = data.data, variationId = _f.variationId, contentId = _f.contentId;
if (variationId && contentId) {

@@ -901,3 +905,3 @@ _this.setTestCookie(contentId, variationId);

if (error) {
(_c = window.parent) === null || _c === void 0 ? void 0 : _c.postMessage({
(_d = window.parent) === null || _d === void 0 ? void 0 : _d.postMessage({
type: 'builder.evaluateError',

@@ -920,3 +924,3 @@ data: { id: id_1, error: error.message },

else {
(_d = window.parent) === null || _d === void 0 ? void 0 : _d.postMessage({
(_e = window.parent) === null || _e === void 0 ? void 0 : _e.postMessage({
type: 'builder.evaluateResult',

@@ -938,3 +942,4 @@ data: { result: result, id: id_1 },

navigator.userAgent.trim() &&
!navigator.userAgent.match(/bot|crawler|spider|robot|crawling|prerender|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|phantom|headless|selenium|puppeteer/i));
!navigator.userAgent.match(/bot|crawler|spider|robot|crawling|prerender|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|phantom|headless|selenium|puppeteer/i) &&
!this.browserTrackingDisabled);
},

@@ -976,5 +981,2 @@ enumerable: true,

if (userAgent === void 0) { userAgent = this.userAgent || ''; }
this.isUsed = true;
// TODO: detect desktop browser and OS too
// TODO: add user agent lib back
var isMobile = {

@@ -988,3 +990,3 @@ Android: function () {

iOS: function () {
return userAgent.match(/iPhone|iPad|iPod/i);
return userAgent.match(/iPhone|iPod/i);
},

@@ -1005,14 +1007,7 @@ Opera: function () {

};
// FIXME
var isTablet = userAgent.match(/Tablet|iPad/i);
var url = this.getLocation();
// const device = ua.getDevice();
// TODO: get these from exension as well
return __assign({
// Removing because blowing out cache keys
// queryString: url.search,
urlPath: url.pathname,
// Removinf for now because of cache keys
// referrer: document.referrer,
// language: navigator.language.split('-')[0],
host: url.host || url.hostname, device: isMobile.any() ? 'mobile' : 'desktop' }, Builder.overrideUserAttributes);
return __assign({ urlPath: url.pathname, host: url.host || url.hostname,
// TODO: maybe an option to choose to target off of mobile/tablet/desktop or just mobile/desktop
device: isTablet ? 'tablet' : isMobile.any() ? 'mobile' : 'desktop' }, Builder.overrideUserAttributes);
};

@@ -1200,2 +1195,3 @@ Builder.prototype.setUserAttributes = function (options) {

// FIXME: HACK: only checks first in queue for user attributes overrides, should check all
// TODO: merge user attributes provided here with defaults and current user attiributes (?)
queue && queue[0].userAttributes

@@ -1208,2 +1204,6 @@ ? queue[0].userAttributes

};
var urlQueueItem = useQueue === null || useQueue === void 0 ? void 0 : useQueue.find(function (item) { return item.url; });
if (urlQueueItem === null || urlQueueItem === void 0 ? void 0 : urlQueueItem.url) {
userAttributes.urlPath = urlQueueItem.url.split('?')[0];
}
// TODO: merge in the attribute from query string ones

@@ -1290,3 +1290,3 @@ // TODO: make this an option per component/request

if (this.overrideParams) {
var params = query_string_class_1.QueryString.parse(this.overrideParams);
var params = omit_function_1.omit(query_string_class_1.QueryString.parse(this.overrideParams), 'apiKey');
assign_function_1.assign(queryParams, params);

@@ -1443,6 +1443,5 @@ }

location.search.indexOf('builder.frameEditing=') !== -1));
Builder.isPreviewing = Boolean(exports.isIframe &&
((document.referrer && document.referrer.match(/builder\.io|localhost:1234/)) ||
location.search.indexOf('builder.preview=') !== -1 ||
location.search.indexOf('builder.frameEditing=') !== -1));
Builder.isPreviewing = Boolean((document.referrer && document.referrer.match(/builder\.io|localhost:1234/)) ||
location.search.indexOf('builder.preview=') !== -1 ||
location.search.indexOf('builder.frameEditing=') !== -1);
Builder.isReact = false;

@@ -1449,0 +1448,0 @@ Builder.overrideUserAttributes = {};

@@ -16,3 +16,3 @@ export declare class TinyPromise<T = any> {

}
declare const _default: PromiseConstructorLike;
declare const _default: PromiseConstructor;
export default _default;

@@ -16,5 +16,5 @@ export interface SimplifiedFetchOptions {

clone: () => any;
text: () => PromiseLike<string>;
json: () => PromiseLike<any>;
blob: () => PromiseLike<Blob>;
text: () => Promise<string>;
json: () => Promise<any>;
blob: () => Promise<Blob>;
headers: {

@@ -27,3 +27,3 @@ keys: () => string[];

}
export declare function tinyFetch(url: string, options?: SimplifiedFetchOptions): PromiseLike<SimpleFetchResponse>;
export declare function tinyFetch(url: string, options?: SimplifiedFetchOptions): Promise<SimpleFetchResponse>;
export declare const fetch: typeof tinyFetch;

@@ -43,2 +43,10 @@ declare type JSONValue = string | number | boolean | JSONObject | JSONArray;

};
code?: {
bindings?: {
[key: string]: string;
};
actions?: {
[key: string]: string;
};
};
repeat?: {

@@ -45,0 +53,0 @@ collection: string;

{
"name": "@builder.io/sdk",
"version": "1.1.4",
"version": "1.1.5-alpha.1",
"unpkg": "./dist/index.browser.js",

@@ -20,8 +20,10 @@ "main": "./dist/index.cjs.js",

"tsc": "tsc --module commonjs",
"release": "npm run build && npm publish",
"release:patch": "npm run build && npm version patch && npm publish",
"release:patch:nightly": "npm run build && npm version patch && npm publish",
"release:dev": "npm run build && npm version prerelease --no-git-tag-version && npm publish --tag dev"
"release": "npm run build && ALLOW_PUBLISH=true npm publish",
"release:patch": "npm run build && npm version patch && ALLOW_PUBLISH=true npm publish",
"release:patch:nightly": "npm run build && npm version patch && ALLOW_PUBLISH=true npm publish",
"release:dev": "npm run build && npm version prerelease --no-git-tag-version && ALLOW_PUBLISH=true npm publish --tag dev",
"prepublishOnly": "block-publish"
},
"devDependencies": {
"@builder.io/block-publish": "^1.1.2",
"@medv/finder": "^1.1.1",

@@ -55,3 +57,3 @@ "@types/axios": "^0.14.0",

},
"gitHead": "f233cba190317de3644fff198e765660205cd7f1"
"gitHead": "5bd1ff6d6f0ce9c7be0900101f0e62d6d64b7743"
}

@@ -10,2 +10,3 @@ # Builder Core

// Optional custom targeting
builder.setUserAttributes({

@@ -16,3 +17,8 @@ userIsLoggedIn: true,

builder.get(YOUR_MODEL_NAME).subscribe(({ data }) => {
builder.get(YOUR_MODEL_NAME, {
// Optional custom query
query: {
'data.customField.$gt': 100
}
}).promise().then(({ data }) => {
// Do something with the data

@@ -19,0 +25,0 @@ })

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet