@widgetic/embed-sdk 2.0.8 → 2.0.9
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/README.md +21 -1
- package/dist/browser/chunks/ABTestManager.js +1 -1
- package/dist/browser/chunks/advanced.js +1 -1
- package/dist/browser/chunks/api.js +1 -1
- package/dist/browser/chunks/core.js +1 -1
- package/dist/browser/chunks/display.js +1 -1
- package/dist/browser/chunks/media.js +1 -1
- package/dist/browser/chunks/messaging.js +1 -1
- package/dist/browser/chunks/renderers.js +1 -1
- package/dist/browser/chunks/scanner.js +1 -1
- package/dist/browser/chunks/security.js +1 -1
- package/dist/browser/embed-bootstrap.js +1 -1
- package/dist/browser/embed-sdk.js +1 -1
- package/dist/esm/chunks/ABTestManager.js +1 -1
- package/dist/esm/chunks/advanced.js +1 -1
- package/dist/esm/chunks/api.js +1 -1
- package/dist/esm/chunks/core.js +1 -1
- package/dist/esm/chunks/display.js +1 -1
- package/dist/esm/chunks/media.js +1 -1
- package/dist/esm/chunks/messaging.js +1 -1
- package/dist/esm/chunks/renderers.js +1 -1
- package/dist/esm/chunks/scanner.js +1 -1
- package/dist/esm/chunks/security.js +1 -1
- package/dist/esm/embed-bootstrap.js +1 -1
- package/dist/esm/embed-sdk.js +1 -1
- package/dist/umd/embed-bootstrap.js +1 -1
- package/dist/umd/embed-sdk.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -141,7 +141,27 @@ npm run lint
|
|
|
141
141
|
|
|
142
142
|
In this checkout the SDK consumes the sibling `api-sdk` package through a link in `node_modules` that points at the checkout itself, so an edit in the sibling stays invisible here until that package rebuilds its `dist/`. `npm run i` reinstalls `node_modules` and links the sibling again; `npm run lapisdk` links it again after a fresh `node_modules`. The dev-alias workflow that the adopting apps use, and why, is described in [the dev-tools README](../dev-tools/README.md).
|
|
143
143
|
|
|
144
|
-
Publishing
|
|
144
|
+
## Publishing
|
|
145
|
+
|
|
146
|
+
GitLab CI on `main` publishes this package and then replaces `https://cdn.widgetic.com/sdks/browser/embed-sdk.js`. The npm job is a Trusted Publisher (`NPM_ID_TOKEN`). It does not use a long-lived token.
|
|
147
|
+
|
|
148
|
+
1. Bump `version` in `package.json`.
|
|
149
|
+
2. Commit and push `main`.
|
|
150
|
+
3. The `publish` job runs `npm publish` when that version is not already on npm, then uploads `dist/umd/embed-sdk.js` to the CDN and purges the cached copies.
|
|
151
|
+
|
|
152
|
+
The CDN upload needs six CI/CD variables on this project, protected, environment scope `cdn`: `CLOUDFLARE_PUBLIC_ENDPOINT`, `R2_WIDGETS_NAME`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ZONE_ID`. The last two are what let the job purge the cached file.
|
|
153
|
+
|
|
154
|
+
When the GitLab job fails with `ci_quota_exceeded`, publish from a laptop. That does not use CI minutes. The group's remaining minutes are at [Usage quotas](https://gitlab.com/groups/widgeticai/-/usage_quotas), on the pipelines tab.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm ci
|
|
158
|
+
npm run build
|
|
159
|
+
npm publish --access public
|
|
160
|
+
npm run publish:cdn:dry-run
|
|
161
|
+
npm run publish:cdn -- --purge
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`npm publish` needs the token in `~/.npmrc`. Do not commit that file. The dry run changes nothing. The last command asks you to type `publish`, uploads the file, and purges the cache. Check `npm view @widgetic/embed-sdk version` and the `last-modified` header of `https://cdn.widgetic.com/sdks/browser/embed-sdk.js`. What the upload checks, and how to roll back, is in `__docs/05-advanced/06-publishing-to-cdn.md`.
|
|
145
165
|
|
|
146
166
|
## License
|
|
147
167
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./vendor.js";import{a as t,d as i}from"./core.js";import{W as n}from"./api.js";import{WidgeticMessenger as s}from"./messaging.js";import{Configuration as r,ABTestingApi as o,CompositionsApi as a}from"@widgetic/api-sdk";import{t as d}from"./advanced.js";import"./renderers.js";import"./media.js";import"./display.js";import"./scanner.js";import"./performance.js";import"./security.js";class c{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this}off(e,t){const i=this.listeners.get(e);return i&&(i.delete(t),0===i.size&&this.listeners.delete(e)),this}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}emit(e,...t){const i=this.listeners.get(e);return!(!i||0===i.size)&&(i.forEach((e=>{try{e(...t)}catch(e){}})),!0)}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}}class l extends c{constructor(){super(),this.assignments=new Map,this.conversionSetups=new Map,this.trackedConversions=new Set;const e=new r({basePath:t()});this.abTestingApi=new o(e),this.compositionsApi=new a(e),this.widgetManager=n.getInstance(),this.messenger=new s,this.setupEventListeners()}static getInstance(){return l.instance||(l.instance=new l),l.instance}setupEventListeners(){this.widgetManager.addEventListener("widget_ready",(e=>{this.setupWidgetConversionTracking(e.widgetId)})),this.widgetManager.addEventListener("custom_event",(e=>{this.handleWidgetCustomEvent(e)})),this.widgetManager.addEventListener("media_play",(e=>{this.handleMediaEvent("plays",e)})),this.widgetManager.addEventListener("form_submit",(e=>{this.handleFormEvent("submissions",e)})),this.widgetManager.addEventListener("widget_click",(e=>{this.handleClickEvent(e)}))}getTestConfig(t){return e(this,void 0,void 0,(function*(){var n;try{const s=yield this.abTestingApi.getABTestConfig({id:t});if(!s)return i.warn("A/B test not found",{experimentId:t}),null;const r=(yield Promise.all((s.variants||[]).map((t=>e(this,void 0,void 0,(function*(){try{const e=t.composition_id||t.compositionId||"";return{id:t.id||"",compositionId:e,embedCode:this.generateEmbedCode(e),trafficPercentage:t.traffic_percentage||t.trafficPercentage||0}}catch(e){return i.error("Failed to fetch composition for variant",{variantId:t.id,compositionId:t.compositionId,error:e}),null}})))))).filter((e=>null!==e));if(0===r.length)return i.warn("No valid variants found for A/B test",{experimentId:t}),null;const o={experimentId:s.test_id||t,isActive:"running"===s.status,winningVariant:void 0,variants:r,successMetrics:s.success_metrics||["impressions"],primaryMetric:(null===(n=s.success_metrics)||void 0===n?void 0:n[0])||"impressions"};return i.info("A/B test config loaded",{experimentId:t,config:o}),o}catch(e){return e&&"object"==typeof e&&"status"in e&&404===e.status?(i.warn("A/B test not found",{experimentId:t}),null):(i.error("Failed to load A/B test config",{experimentId:t,error:e}),null)}}))}getVariantAssignment(t,n){return e(this,void 0,void 0,(function*(){try{const e=yield this.getTestConfig(t);if(!e)return null;if(e.winningVariant){const i=e.variants.find((t=>t.id===e.winningVariant));if(i){const e={variantId:i.id,compositionId:i.compositionId,embedCode:i.embedCode};return localStorage.setItem(`ab_test_${t}`,JSON.stringify(e)),this.assignments.set(t,e),i}}const i=this.selectVariant(e.variants,n);if(!i)return null;const s={variantId:i.id,compositionId:i.compositionId,embedCode:i.embedCode};return localStorage.setItem(`ab_test_${t}`,JSON.stringify(s)),this.assignments.set(t,s),yield this.setupConversionTracking(t,e,s),i}catch(e){return i.error("Failed to get variant assignment",{experimentId:t,error:e}),null}}))}setupConversionTracking(t,n,s){return e(this,void 0,void 0,(function*(){try{const e=yield this.findTrackingTargets(s.compositionId,n.successMetrics),r={experimentId:t,variantId:s.variantId,metrics:n.successMetrics,trackingTargets:e};this.conversionSetups.set(t,r),i.debug("Conversion tracking setup complete",{experimentId:t,trackingTargets:e})}catch(e){i.error("Failed to setup conversion tracking",{experimentId:t,error:e})}}))}findTrackingTargets(t,n){return e(this,void 0,void 0,(function*(){try{const e={},t={clicks:["button","a","[data-click-track]","[onclick]"],conversions:["form",'button[type="submit"]',"[data-conversion]"],plays:["video","audio","[data-play]",".play-button"],submissions:["form","[data-form]"],downloads:["a[download]","[data-download]"],signups:["form","[data-signup]",".signup-form"]};for(const i of n){const n=t[i]||[];e[i]=n}return e}catch(e){return i.error("Failed to find tracking targets",{compositionId:t,error:e}),{}}}))}selectorExistsInContent(e,t){const i=e.toLowerCase();if(t.startsWith("[")&&t.endsWith("]")){const e=t.slice(1,-1);return i.includes(e)}if(t.startsWith(".")){const e=t.slice(1);return i.includes(`class="${e}"`)||i.includes(`class='${e}'`)}return i.includes(`<${t}`)}setupWidgetConversionTracking(t){return e(this,void 0,void 0,(function*(){for(const[e,n]of Array.from(this.conversionSetups.entries()))try{if(!this.widgetManager.getWidget(t))continue;const s=this.messenger.createWidgetController(t);n.metrics.includes("clicks")&&(yield this.setupClickTracking(s,e,n.variantId)),(n.metrics.includes("submissions")||n.metrics.includes("conversions"))&&(yield this.setupFormTracking(s,e,n.variantId)),n.metrics.includes("plays")&&(yield this.setupMediaTracking(s,e,n.variantId)),i.debug("Widget conversion tracking setup",{widgetId:t,experimentId:e})}catch(n){i.error("Failed to setup widget conversion tracking",{widgetId:t,experimentId:e,error:n})}}))}setupClickTracking(t,i,n){return e(this,void 0,void 0,(function*(){t.subscribe("click",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"clicks",{element:t.element,timestamp:t.timestamp})})))),yield t.callFunction("setupEventListener","click",(e=>{var t;this.trackConversion(i,n,"clicks",{target:null===(t=e.target)||void 0===t?void 0:t.tagName,timestamp:Date.now()})}))}))}setupFormTracking(t,i,n){return e(this,void 0,void 0,(function*(){t.subscribe("form-submit",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"submissions",{formData:t.formData,timestamp:t.timestamp})})))),t.subscribe("conversion",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"conversions",{conversionType:t.type,value:t.value,timestamp:t.timestamp})}))))}))}setupMediaTracking(t,i,n){return e(this,void 0,void 0,(function*(){t.subscribe("media-play",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"plays",{mediaType:t.mediaType,duration:t.duration,timestamp:t.timestamp})}))))}))}handleWidgetCustomEvent(t){return e(this,void 0,void 0,(function*(){var e;for(const[i,n]of Array.from(this.conversionSetups.entries()))if((null===(e=t.data)||void 0===e?void 0:e.experimentId)===i){const e=t.data.conversionType||"custom";yield this.trackConversion(i,n.variantId,e,t.data)}}))}handleMediaEvent(t,i){return e(this,void 0,void 0,(function*(){for(const[e,n]of Array.from(this.conversionSetups.entries()))n.metrics.includes(t)&&(yield this.trackConversion(e,n.variantId,t,i.data))}))}handleFormEvent(t,i){return e(this,void 0,void 0,(function*(){for(const[e,n]of Array.from(this.conversionSetups.entries()))n.metrics.includes(t)&&(yield this.trackConversion(e,n.variantId,t,i.data))}))}handleClickEvent(t){return e(this,void 0,void 0,(function*(){for(const[e,i]of Array.from(this.conversionSetups.entries()))i.metrics.includes("clicks")&&(yield this.trackConversion(e,i.variantId,"clicks",t.data))}))}trackConversion(t,n,s,r,o){return e(this,void 0,void 0,(function*(){try{const e=`${t}_${n}_${(null==o?void 0:o.userId)||(null==o?void 0:o.sessionId)||"anonymous"}`;if(this.trackedConversions.has(e))return void i.debug("Conversion already tracked for this user",{experimentId:t,variantId:n,conversionType:s});const a={experimentId:t,variantId:n,userId:null==o?void 0:o.userId,sessionId:(null==o?void 0:o.sessionId)||this.getSessionId(),conversionType:s,timestamp:(new Date).toISOString()},c={event_type:"conversion",data:d(a)};yield this.abTestingApi.trackABTestEvent({trackABTestEventRequest:c}),this.trackedConversions.add(e),this.emit("conversion",{experimentId:t,variantId:n,conversionType:s,data:r}),i.info("Conversion tracked",{experimentId:t,variantId:n,conversionType:s,data:r})}catch(e){i.error("Failed to track conversion",{experimentId:t,variantId:n,conversionType:s,error:e})}}))}trackImpression(t,n,s){return e(this,void 0,void 0,(function*(){try{const e={experimentId:t,variantId:n,userId:null==s?void 0:s.userId,sessionId:(null==s?void 0:s.sessionId)||this.getSessionId(),timestamp:(new Date).toISOString()},r={event_type:"impression",data:d(e)};yield this.abTestingApi.trackABTestEvent({trackABTestEventRequest:r}),i.debug("Impression tracked",{experimentId:t,variantId:n})}catch(e){i.error("Failed to track impression",{experimentId:t,variantId:n,error:e})}}))}validateGoalTracking(t,n){return e(this,void 0,void 0,(function*(){const e=[],s=[];try{for(const i of t){const t=yield this.validateVariantCapabilities(i,n);e.push(...t)}if(e.length>0){const t=Array.from(new Set(e.map((e=>e.metric))));s.push(`Consider adding trackable elements to your compositions for: ${t.join(", ")}`),t.includes("clicks")&&s.push("Add clickable elements like buttons, links, or interactive components"),t.includes("submissions")&&s.push("Add form elements to track form submissions"),t.includes("plays")&&s.push("Add media elements (audio/video) to track media plays"),t.includes("conversions")&&s.push("Implement custom conversion tracking using widgetic:conversion events")}const r=0===e.length;return i.info("Goal tracking validation completed",{variants:t.length,successMetrics:n,issues:e.length,isValid:r}),{isValid:r,issues:e,recommendations:s}}catch(e){return i.error("Goal tracking validation failed",{error:e}),{isValid:!1,issues:[{variant:"all",metric:"system",reason:"Validation system error"}],recommendations:["Please try again or contact support"]}}}))}validateVariantCapabilities(t,n){return e(this,void 0,void 0,(function*(){const e=[];try{const s=document.createElement("div");s.style.cssText="position: absolute; top: -9999px; left: -9999px; width: 1px; height: 1px;",document.body.appendChild(s);try{const r={compositionId:t.composition_id,renderMode:"auto",displayMode:"inline",resize:"fill-width",width:1,height:1},o=`validation_${t.composition_id}_${Date.now()}`;if(yield this.widgetManager.registerWidget(o,r,s)){const s=this.messenger.getWidgetController(o);let r=null;if(s)try{r=yield s.callFunction("getCapabilities",[])}catch(e){i.warn("Widget does not expose getCapabilities method",{compositionId:t.composition_id})}for(const i of n){const n=this.checkMetricSupport(t,i,r);n&&e.push(n)}yield this.widgetManager.unregisterWidget(o)}else for(const i of n)e.push({variant:t.name,metric:i,reason:"Widget failed to load for validation"})}finally{document.body.removeChild(s)}}catch(s){i.error("Failed to validate variant capabilities",{variant:t.name,error:s});for(const i of n)e.push({variant:t.name,metric:i,reason:"Validation error occurred"})}return e}))}checkMetricSupport(e,t,i){var n;if(!i)return{variant:e.name,metric:t,reason:"Widget capabilities could not be determined"};switch(t){case"clicks":if(!this.hasClickableCapabilities(i))return{variant:e.name,metric:t,reason:"No clickable elements or interactive capabilities found"};break;case"submissions":if(!i.textCapabilities||!(null===(n=i.textCapabilities.fields)||void 0===n?void 0:n.length))return{variant:e.name,metric:t,reason:"No form fields or text input capabilities found"};break;case"plays":if(!i.mediaCapabilities||!i.mediaCapabilities.supportsPlay)return{variant:e.name,metric:t,reason:"No media playback capabilities found"};break;case"conversions":if("static"===i.type||!i.supportsEvents)return{variant:e.name,metric:t,reason:"Widget may not support custom conversion events"};break;default:return{variant:e.name,metric:t,reason:`Unknown success metric: ${t}`}}return null}hasClickableCapabilities(e){var t,i,n,s;if(["interactive","form","media","gallery"].includes(e.type))return!0;if(null===(t=e.mediaCapabilities)||void 0===t?void 0:t.supportsPlay)return!0;if(null===(i=e.contentCapabilities)||void 0===i?void 0:i.supportsNavigation)return!0;if(null===(s=null===(n=e.textCapabilities)||void 0===n?void 0:n.fields)||void 0===s?void 0:s.length)return!0;const r=["play","pause","next","previous","goTo","setText","submit","click","interact"];return!!e.exposedFunctions&&r.some((t=>e.exposedFunctions.includes(t)))}selectVariant(e,t){if(!e||0===e.length)return null;const i=t.userId||t.sessionId||"anonymous",n=this.createDeterministicHash(i),s=Math.abs(n)%100;let r=0;for(const t of e)if(r+=t.trafficPercentage,s<r)return t;return e[e.length-1]}createDeterministicHash(e){let t=0;for(let i=0;i<e.length;i++){t=(t<<5)-t+e.charCodeAt(i),t&=t}return t}createAssignment(t,n,s){return e(this,void 0,void 0,(function*(){try{const e=this.detectDeviceType(s.userAgent),r={experimentId:t,variantId:n.variantId,userId:s.userId,sessionId:s.sessionId||this.getSessionId(),userAgent:s.userAgent||navigator.userAgent,ipAddress:s.ipAddress,deviceType:e},o=d(r);yield this.abTestingApi.createABTestAssignment({createABTestAssignmentRequest:o}),i.debug("Assignment created in backend",{experimentId:t,variantId:n.variantId})}catch(e){i.error("Failed to create assignment in backend",{experimentId:t,error:e})}}))}generateEmbedCode(e){return`<widgetic-widget composition-id="${e}"></widgetic-widget>`}getSessionId(){let e=localStorage.getItem("widgetic_session_id");return e||(e="session_"+Math.random().toString(36).substr(2,9)+"_"+Date.now(),localStorage.setItem("widgetic_session_id",e)),e}detectDeviceType(e){if(!e)return"desktop";const t=e.toLowerCase();return/tablet|ipad|playbook|silk/.test(t)?"tablet":/mobile|iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/.test(t)?"mobile":"desktop"}}l.instance=null;export{l as ABTestManager};
|
|
1
|
+
import{_ as e}from"./vendor.js";import{e as t,h as i}from"./core.js";import{W as n}from"./api.js";import{WidgeticMessenger as s}from"./messaging.js";import{C as r,h as o,a,t as d}from"./advanced.js";import"./renderers.js";import"./media.js";import"./display.js";import"./scanner.js";import"./performance.js";import"./security.js";class c{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this}off(e,t){const i=this.listeners.get(e);return i&&(i.delete(t),0===i.size&&this.listeners.delete(e)),this}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}emit(e,...t){const i=this.listeners.get(e);return!(!i||0===i.size)&&(i.forEach((e=>{try{e(...t)}catch(e){}})),!0)}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}}class l extends c{constructor(){super(),this.assignments=new Map,this.conversionSetups=new Map,this.trackedConversions=new Set;const e=new r({basePath:t()});this.abTestingApi=new o(e),this.compositionsApi=new a(e),this.widgetManager=n.getInstance(),this.messenger=new s,this.setupEventListeners()}static getInstance(){return l.instance||(l.instance=new l),l.instance}setupEventListeners(){this.widgetManager.addEventListener("widget_ready",(e=>{this.setupWidgetConversionTracking(e.widgetId)})),this.widgetManager.addEventListener("custom_event",(e=>{this.handleWidgetCustomEvent(e)})),this.widgetManager.addEventListener("media_play",(e=>{this.handleMediaEvent("plays",e)})),this.widgetManager.addEventListener("form_submit",(e=>{this.handleFormEvent("submissions",e)})),this.widgetManager.addEventListener("widget_click",(e=>{this.handleClickEvent(e)}))}getTestConfig(t){return e(this,void 0,void 0,(function*(){var n;try{const s=yield this.abTestingApi.getABTestConfig({id:t});if(!s)return i.warn("A/B test not found",{experimentId:t}),null;const r=(yield Promise.all((s.variants||[]).map((t=>e(this,void 0,void 0,(function*(){try{const e=t.composition_id||t.compositionId||"";return{id:t.id||"",compositionId:e,embedCode:this.generateEmbedCode(e),trafficPercentage:t.traffic_percentage||t.trafficPercentage||0}}catch(e){return i.error("Failed to fetch composition for variant",{variantId:t.id,compositionId:t.compositionId,error:e}),null}})))))).filter((e=>null!==e));if(0===r.length)return i.warn("No valid variants found for A/B test",{experimentId:t}),null;const o={experimentId:s.test_id||t,isActive:"running"===s.status,winningVariant:void 0,variants:r,successMetrics:s.success_metrics||["impressions"],primaryMetric:(null===(n=s.success_metrics)||void 0===n?void 0:n[0])||"impressions"};return i.info("A/B test config loaded",{experimentId:t,config:o}),o}catch(e){return e&&"object"==typeof e&&"status"in e&&404===e.status?(i.warn("A/B test not found",{experimentId:t}),null):(i.error("Failed to load A/B test config",{experimentId:t,error:e}),null)}}))}getVariantAssignment(t,n){return e(this,void 0,void 0,(function*(){try{const e=yield this.getTestConfig(t);if(!e)return null;if(e.winningVariant){const i=e.variants.find((t=>t.id===e.winningVariant));if(i){const e={variantId:i.id,compositionId:i.compositionId,embedCode:i.embedCode};return localStorage.setItem(`ab_test_${t}`,JSON.stringify(e)),this.assignments.set(t,e),i}}const i=this.selectVariant(e.variants,n);if(!i)return null;const s={variantId:i.id,compositionId:i.compositionId,embedCode:i.embedCode};return localStorage.setItem(`ab_test_${t}`,JSON.stringify(s)),this.assignments.set(t,s),yield this.setupConversionTracking(t,e,s),i}catch(e){return i.error("Failed to get variant assignment",{experimentId:t,error:e}),null}}))}setupConversionTracking(t,n,s){return e(this,void 0,void 0,(function*(){try{const e=yield this.findTrackingTargets(s.compositionId,n.successMetrics),r={experimentId:t,variantId:s.variantId,metrics:n.successMetrics,trackingTargets:e};this.conversionSetups.set(t,r),i.debug("Conversion tracking setup complete",{experimentId:t,trackingTargets:e})}catch(e){i.error("Failed to setup conversion tracking",{experimentId:t,error:e})}}))}findTrackingTargets(t,n){return e(this,void 0,void 0,(function*(){try{const e={},t={clicks:["button","a","[data-click-track]","[onclick]"],conversions:["form",'button[type="submit"]',"[data-conversion]"],plays:["video","audio","[data-play]",".play-button"],submissions:["form","[data-form]"],downloads:["a[download]","[data-download]"],signups:["form","[data-signup]",".signup-form"]};for(const i of n){const n=t[i]||[];e[i]=n}return e}catch(e){return i.error("Failed to find tracking targets",{compositionId:t,error:e}),{}}}))}selectorExistsInContent(e,t){const i=e.toLowerCase();if(t.startsWith("[")&&t.endsWith("]")){const e=t.slice(1,-1);return i.includes(e)}if(t.startsWith(".")){const e=t.slice(1);return i.includes(`class="${e}"`)||i.includes(`class='${e}'`)}return i.includes(`<${t}`)}setupWidgetConversionTracking(t){return e(this,void 0,void 0,(function*(){for(const[e,n]of Array.from(this.conversionSetups.entries()))try{if(!this.widgetManager.getWidget(t))continue;const s=this.messenger.createWidgetController(t);n.metrics.includes("clicks")&&(yield this.setupClickTracking(s,e,n.variantId)),(n.metrics.includes("submissions")||n.metrics.includes("conversions"))&&(yield this.setupFormTracking(s,e,n.variantId)),n.metrics.includes("plays")&&(yield this.setupMediaTracking(s,e,n.variantId)),i.debug("Widget conversion tracking setup",{widgetId:t,experimentId:e})}catch(n){i.error("Failed to setup widget conversion tracking",{widgetId:t,experimentId:e,error:n})}}))}setupClickTracking(t,i,n){return e(this,void 0,void 0,(function*(){t.subscribe("click",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"clicks",{element:t.element,timestamp:t.timestamp})})))),yield t.callFunction("setupEventListener","click",(e=>{var t;this.trackConversion(i,n,"clicks",{target:null===(t=e.target)||void 0===t?void 0:t.tagName,timestamp:Date.now()})}))}))}setupFormTracking(t,i,n){return e(this,void 0,void 0,(function*(){t.subscribe("form-submit",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"submissions",{formData:t.formData,timestamp:t.timestamp})})))),t.subscribe("conversion",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"conversions",{conversionType:t.type,value:t.value,timestamp:t.timestamp})}))))}))}setupMediaTracking(t,i,n){return e(this,void 0,void 0,(function*(){t.subscribe("media-play",(t=>e(this,void 0,void 0,(function*(){yield this.trackConversion(i,n,"plays",{mediaType:t.mediaType,duration:t.duration,timestamp:t.timestamp})}))))}))}handleWidgetCustomEvent(t){return e(this,void 0,void 0,(function*(){var e;for(const[i,n]of Array.from(this.conversionSetups.entries()))if((null===(e=t.data)||void 0===e?void 0:e.experimentId)===i){const e=t.data.conversionType||"custom";yield this.trackConversion(i,n.variantId,e,t.data)}}))}handleMediaEvent(t,i){return e(this,void 0,void 0,(function*(){for(const[e,n]of Array.from(this.conversionSetups.entries()))n.metrics.includes(t)&&(yield this.trackConversion(e,n.variantId,t,i.data))}))}handleFormEvent(t,i){return e(this,void 0,void 0,(function*(){for(const[e,n]of Array.from(this.conversionSetups.entries()))n.metrics.includes(t)&&(yield this.trackConversion(e,n.variantId,t,i.data))}))}handleClickEvent(t){return e(this,void 0,void 0,(function*(){for(const[e,i]of Array.from(this.conversionSetups.entries()))i.metrics.includes("clicks")&&(yield this.trackConversion(e,i.variantId,"clicks",t.data))}))}trackConversion(t,n,s,r,o){return e(this,void 0,void 0,(function*(){try{const e=`${t}_${n}_${(null==o?void 0:o.userId)||(null==o?void 0:o.sessionId)||"anonymous"}`;if(this.trackedConversions.has(e))return void i.debug("Conversion already tracked for this user",{experimentId:t,variantId:n,conversionType:s});const a={experimentId:t,variantId:n,userId:null==o?void 0:o.userId,sessionId:(null==o?void 0:o.sessionId)||this.getSessionId(),conversionType:s,timestamp:(new Date).toISOString()},c={event_type:"conversion",data:d(a)};yield this.abTestingApi.trackABTestEvent({trackABTestEventRequest:c}),this.trackedConversions.add(e),this.emit("conversion",{experimentId:t,variantId:n,conversionType:s,data:r}),i.info("Conversion tracked",{experimentId:t,variantId:n,conversionType:s,data:r})}catch(e){i.error("Failed to track conversion",{experimentId:t,variantId:n,conversionType:s,error:e})}}))}trackImpression(t,n,s){return e(this,void 0,void 0,(function*(){try{const e={experimentId:t,variantId:n,userId:null==s?void 0:s.userId,sessionId:(null==s?void 0:s.sessionId)||this.getSessionId(),timestamp:(new Date).toISOString()},r={event_type:"impression",data:d(e)};yield this.abTestingApi.trackABTestEvent({trackABTestEventRequest:r}),i.debug("Impression tracked",{experimentId:t,variantId:n})}catch(e){i.error("Failed to track impression",{experimentId:t,variantId:n,error:e})}}))}validateGoalTracking(t,n){return e(this,void 0,void 0,(function*(){const e=[],s=[];try{for(const i of t){const t=yield this.validateVariantCapabilities(i,n);e.push(...t)}if(e.length>0){const t=Array.from(new Set(e.map((e=>e.metric))));s.push(`Consider adding trackable elements to your compositions for: ${t.join(", ")}`),t.includes("clicks")&&s.push("Add clickable elements like buttons, links, or interactive components"),t.includes("submissions")&&s.push("Add form elements to track form submissions"),t.includes("plays")&&s.push("Add media elements (audio/video) to track media plays"),t.includes("conversions")&&s.push("Implement custom conversion tracking using widgetic:conversion events")}const r=0===e.length;return i.info("Goal tracking validation completed",{variants:t.length,successMetrics:n,issues:e.length,isValid:r}),{isValid:r,issues:e,recommendations:s}}catch(e){return i.error("Goal tracking validation failed",{error:e}),{isValid:!1,issues:[{variant:"all",metric:"system",reason:"Validation system error"}],recommendations:["Please try again or contact support"]}}}))}validateVariantCapabilities(t,n){return e(this,void 0,void 0,(function*(){const e=[];try{const s=document.createElement("div");s.style.cssText="position: absolute; top: -9999px; left: -9999px; width: 1px; height: 1px;",document.body.appendChild(s);try{const r={compositionId:t.composition_id,renderMode:"auto",displayMode:"inline",resize:"fill-width",width:1,height:1},o=`validation_${t.composition_id}_${Date.now()}`;if(yield this.widgetManager.registerWidget(o,r,s)){const s=this.messenger.getWidgetController(o);let r=null;if(s)try{r=yield s.callFunction("getCapabilities",[])}catch(e){i.warn("Widget does not expose getCapabilities method",{compositionId:t.composition_id})}for(const i of n){const n=this.checkMetricSupport(t,i,r);n&&e.push(n)}yield this.widgetManager.unregisterWidget(o)}else for(const i of n)e.push({variant:t.name,metric:i,reason:"Widget failed to load for validation"})}finally{document.body.removeChild(s)}}catch(s){i.error("Failed to validate variant capabilities",{variant:t.name,error:s});for(const i of n)e.push({variant:t.name,metric:i,reason:"Validation error occurred"})}return e}))}checkMetricSupport(e,t,i){var n;if(!i)return{variant:e.name,metric:t,reason:"Widget capabilities could not be determined"};switch(t){case"clicks":if(!this.hasClickableCapabilities(i))return{variant:e.name,metric:t,reason:"No clickable elements or interactive capabilities found"};break;case"submissions":if(!i.textCapabilities||!(null===(n=i.textCapabilities.fields)||void 0===n?void 0:n.length))return{variant:e.name,metric:t,reason:"No form fields or text input capabilities found"};break;case"plays":if(!i.mediaCapabilities||!i.mediaCapabilities.supportsPlay)return{variant:e.name,metric:t,reason:"No media playback capabilities found"};break;case"conversions":if("static"===i.type||!i.supportsEvents)return{variant:e.name,metric:t,reason:"Widget may not support custom conversion events"};break;default:return{variant:e.name,metric:t,reason:`Unknown success metric: ${t}`}}return null}hasClickableCapabilities(e){var t,i,n,s;if(["interactive","form","media","gallery"].includes(e.type))return!0;if(null===(t=e.mediaCapabilities)||void 0===t?void 0:t.supportsPlay)return!0;if(null===(i=e.contentCapabilities)||void 0===i?void 0:i.supportsNavigation)return!0;if(null===(s=null===(n=e.textCapabilities)||void 0===n?void 0:n.fields)||void 0===s?void 0:s.length)return!0;const r=["play","pause","next","previous","goTo","setText","submit","click","interact"];return!!e.exposedFunctions&&r.some((t=>e.exposedFunctions.includes(t)))}selectVariant(e,t){if(!e||0===e.length)return null;const i=t.userId||t.sessionId||"anonymous",n=this.createDeterministicHash(i),s=Math.abs(n)%100;let r=0;for(const t of e)if(r+=t.trafficPercentage,s<r)return t;return e[e.length-1]}createDeterministicHash(e){let t=0;for(let i=0;i<e.length;i++){t=(t<<5)-t+e.charCodeAt(i),t&=t}return t}createAssignment(t,n,s){return e(this,void 0,void 0,(function*(){try{const e=this.detectDeviceType(s.userAgent),r={experimentId:t,variantId:n.variantId,userId:s.userId,sessionId:s.sessionId||this.getSessionId(),userAgent:s.userAgent||navigator.userAgent,ipAddress:s.ipAddress,deviceType:e},o=d(r);yield this.abTestingApi.createABTestAssignment({createABTestAssignmentRequest:o}),i.debug("Assignment created in backend",{experimentId:t,variantId:n.variantId})}catch(e){i.error("Failed to create assignment in backend",{experimentId:t,error:e})}}))}generateEmbedCode(e){return`<widgetic-widget composition-id="${e}"></widgetic-widget>`}getSessionId(){let e=localStorage.getItem("widgetic_session_id");return e||(e="session_"+Math.random().toString(36).substr(2,9)+"_"+Date.now(),localStorage.setItem("widgetic_session_id",e)),e}detectDeviceType(e){if(!e)return"desktop";const t=e.toLowerCase();return/tablet|ipad|playbook|silk/.test(t)?"tablet":/mobile|iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/.test(t)?"mobile":"desktop"}}l.instance=null;export{l as ABTestManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as t}from"./vendor.js";import{l as e,c as i,n as o}from"./core.js";import{Configuration as n,AuthenticationApi as s,CompositionsApi as r}from"@widgetic/api-sdk";import{getMessenger as a}from"./messaging.js";const d=t=>null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t);function c(t){if(Array.isArray(t))return t.map(c);if(!d(t))return t;const e={};for(const[i,o]of Object.entries(t)){e[i.replace(/[_-](\w)/g,((t,e)=>e?e.toUpperCase():""))]=Array.isArray(o)?o.map(c):d(o)?c(o):o}return e}function l(t){if(Array.isArray(t))return t.map(l);if(!d(t))return t;const e={};for(const[i,o]of Object.entries(t)){e[i.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[\s-]+/g,"_").toLowerCase()]=Array.isArray(o)?o.map(l):d(o)?l(o):o}return e}class h{constructor(){this.sessionCache=null,this.sessionCacheExpiry=0,this.ownershipCache=new Map;const t=o(),e=new n({basePath:t.basePath,apiKey:t.apiKey,credentials:"include"});this.authApi=new s(e),this.compositionsApi=new r(e)}checkAuthentication(){return t(this,void 0,void 0,(function*(){try{if(this.sessionCache&&Date.now()<this.sessionCacheExpiry)return{isAuthenticated:!0,session:this.sessionCache,user:this.sessionCache.user,canEdit:!0};const t=c(yield this.authApi.getSession());return t&&t.accessToken&&t.user?(this.sessionCache=t,this.sessionCacheExpiry=Date.now()+3e5,e.info("User authenticated for editing",{userId:t.user.id,email:t.user.email}),{isAuthenticated:!0,session:t,user:t.user,canEdit:!0}):{isAuthenticated:!1,canEdit:!1}}catch(t){return e.debug("Authentication check failed",{error:t}),t instanceof Response&&t.status,{isAuthenticated:!1,canEdit:!1}}}))}checkCompositionOwnership(i){return t(this,void 0,void 0,(function*(){var t;try{const o=this.ownershipCache.get(i);if(o)return o;const n=yield this.checkAuthentication();if(!n.isAuthenticated||!(null===(t=n.session)||void 0===t?void 0:t.user)){const t={isOwner:!1,canEdit:!1,error:"User not authenticated"};return this.ownershipCache.set(i,t),t}const s=c(yield this.compositionsApi.getCompositionById({id:i}));if(!s){const t={isOwner:!1,canEdit:!1,error:"Composition not found"};return this.ownershipCache.set(i,t),t}const r=s.creatorId===n.session.user.id,a={isOwner:r,canEdit:r,composition:s,error:r?void 0:"User does not own this composition"};return this.ownershipCache.set(i,a),setTimeout((()=>{this.ownershipCache.delete(i)}),12e4),e.debug("Composition ownership checked",{compositionId:i,isOwner:r,userId:n.session.user.id,compositionCreatorId:s.creatorId}),a}catch(t){e.warn("Failed to check composition ownership",{compositionId:i,error:t});const o={isOwner:!1,canEdit:!1,error:t instanceof Error?t.message:"Unknown error"};return this.ownershipCache.set(i,o),o}}))}canEditComposition(e){return t(this,void 0,void 0,(function*(){return(yield this.checkCompositionOwnership(e)).canEdit}))}getCurrentUser(){return t(this,void 0,void 0,(function*(){return(yield this.checkAuthentication()).user||null}))}clearCache(){this.sessionCache=null,this.sessionCacheExpiry=0,this.ownershipCache.clear(),e.debug("Authentication cache cleared")}checkMultipleCompositions(e){return t(this,void 0,void 0,(function*(){const i=new Map;return(yield this.checkAuthentication()).isAuthenticated?(yield Promise.all(e.map((e=>t(this,void 0,void 0,(function*(){const t=yield this.checkCompositionOwnership(e);i.set(e,t)}))))),i):(e.forEach((t=>{i.set(t,{isOwner:!1,canEdit:!1,error:"User not authenticated"})})),i)}))}isEditingEnabled(){return i.ENABLE_EDITING}}let u=null;function p(){return u||(u=new h),u}class g{constructor(t={}){this.host=null,this.container=null,this.content=null,this.destroyed=!1,this.options=Object.assign({target:"widgetic-portal",className:"",style:"",clickThrough:!1,zIndex:99999999},t),this.createPortal()}createPortal(){this.host=this.findOrCreateHost(),this.container=document.createElement("div"),this.container.className=(this.options.className?this.options.className+" ":"")+"widgetic-portal-contents",this.container.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: ${this.options.zIndex};\n pointer-events: ${this.options.clickThrough?"none":"auto"};\n ${this.options.style}\n `,this.options.clickThrough?this.container.style.pointerEvents="none":this.container.style.pointerEvents="auto",this.host.appendChild(this.container),e.debug("Portal created",{target:this.options.target,host:this.host,container:this.container})}findOrCreateHost(){let t=null;if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const e=`.${this.options.target}`;t=document.querySelector(e)}return t||(t=document.createElement("div"),t.classList.add("string"==typeof this.options.target?this.options.target:"widgetic-portal"),document.body.appendChild(t),e.debug("Portal host created",{target:this.options.target,host:t})),t}mount(t){this.destroyed?e.warn("Cannot mount content to destroyed portal"):this.container?(this.content&&this.unmount(),t.style.pointerEvents="auto",this.content=t,this.container.appendChild(t),e.debug("Content mounted to portal",{content:t})):e.error("Portal container not available")}unmount(){this.content&&this.container&&this.container.contains(this.content)&&(this.container.removeChild(this.content),this.content=null,e.debug("Content unmounted from portal"))}destroy(){if(!this.destroyed){if(this.unmount(),this.container&&this.host&&this.host.contains(this.container)&&this.host.removeChild(this.container),this.host&&0===this.host.childNodes.length&&this.host.parentNode){const t="string"==typeof this.options.target?this.options.target:"widgetic-portal";this.host.classList.contains(t)&&this.host.parentNode.removeChild(this.host)}this.destroyed=!0,this.host=null,this.container=null,this.content=null,e.debug("Portal destroyed")}}getContainer(){return this.container}isDestroyed(){return this.destroyed}updateOptions(t){this.destroyed?e.warn("Cannot update options on destroyed portal"):(this.options=Object.assign(Object.assign({},this.options),t),this.container&&(void 0!==t.className&&(this.container.className=(t.className?t.className+" ":"")+"widgetic-portal-contents"),void 0!==t.style&&(this.container.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: ${this.options.zIndex};\n pointer-events: ${this.options.clickThrough,"none"};\n ${this.options.style}\n `),void 0!==t.clickThrough&&(this.container.style.pointerEvents=(t.clickThrough,"none"))),e.debug("Portal options updated",{options:this.options}))}}function m(t){return new g(t)}class y{constructor(t={}){this.config=t,this.loadPromise=null,this.sdkInstance=null,this.isLoading=!1,this.loadTimeout=3e4,this.config=Object.assign({basePath:t.basePath||this.getUISdkBaseUrl(),version:t.version||"latest",debug:t.debug||!1},t)}getUISdkBaseUrl(){return"development"===i.NODE_ENV?i.CLIENT_URL:`${i.PRODUCTION_URL}/ui-sdk`}loadUISdk(){return t(this,void 0,void 0,(function*(){if(this.sdkInstance)return this.sdkInstance;if(this.loadPromise)return this.loadPromise;this.isLoading=!0,this.loadPromise=this.performLoad();try{return this.sdkInstance=yield this.loadPromise,e.info("UI SDK loaded successfully",{basePath:this.config.basePath,version:this.config.version}),this.sdkInstance}catch(t){throw e.error("Failed to load UI SDK",{error:t,config:this.config}),this.loadPromise=null,t}finally{this.isLoading=!1}}))}performLoad(){return t(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const o=setTimeout((()=>{i(new Error("UI SDK load timeout"))}),this.loadTimeout);try{if(window.WidgeticUI)return clearTimeout(o),void t(window.WidgeticUI);const n=document.createElement("script");n.src=`${this.config.basePath}/widgetic-ui.js`,n.async=!0,n.crossOrigin="anonymous",n.onload=()=>{clearTimeout(o),window.WidgeticUI?(e.debug("UI SDK script loaded from external source"),t(window.WidgeticUI)):i(new Error("UI SDK script loaded but WidgeticUI not available"))},n.onerror=()=>{clearTimeout(o),i(new Error("Failed to load UI SDK script"))},document.head.appendChild(n),e.debug("Loading UI SDK",{src:n.src})}catch(t){clearTimeout(o),i(t)}}))}))}isLoaded(){return null!==this.sdkInstance}isLoadingState(){return this.isLoading}getInstance(){return this.sdkInstance}initializeUISdk(i){return t(this,void 0,void 0,(function*(){const t=yield this.loadUISdk();return yield t.init(Object.assign(Object.assign({},this.config),i)),e.info("UI SDK initialized",{config:Object.assign(Object.assign({},this.config),i)}),t}))}cleanup(){return t(this,void 0,void 0,(function*(){if(this.sdkInstance){try{yield this.sdkInstance.destroy()}catch(t){e.warn("Error during UI SDK cleanup",{error:t})}this.sdkInstance=null}this.loadPromise=null,this.isLoading=!1,window.WidgeticUI&&delete window.WidgeticUI,e.debug("UI SDK cleanup complete")}))}preload(){return t(this,void 0,void 0,(function*(){try{yield this.loadUISdk(),e.debug("UI SDK preloaded successfully")}catch(t){e.warn("UI SDK preload failed",{error:t})}}))}}let v=null;function f(t){return v||(v=new y(t)),v}class w{constructor(t={}){this.options=t,this.sessions=new Map,this.defaultOptions={showEditButton:!0,editButtonText:"✏️ Edit",editButtonPosition:"top-right",enableClickToEdit:!0,autoDetectAuth:!0},this.options=Object.assign(Object.assign({},this.defaultOptions),t)}addOverlay(i,o){return t(this,void 0,void 0,(function*(){try{if(!this.options.autoDetectAuth)return void(yield this.createOverlay(i,o,!0));const t=p(),n=yield t.checkCompositionOwnership(o);n.canEdit?(yield this.createOverlay(i,o,!0),e.debug("Editor overlay added for owned composition",{compositionId:o})):e.debug("Editor overlay not added - user cannot edit",{compositionId:o,reason:n.error})}catch(t){e.warn("Failed to add editor overlay",{compositionId:o,error:t})}}))}createOverlay(i,o,n){return t(this,void 0,void 0,(function*(){if(this.sessions.has(o))return;const t=document.createElement("div");if(t.className="widgetic-editor-overlay",t.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10000;\n pointer-events: none;\n ${this.getOverlayStyles()}\n `,this.options.showEditButton&&n){const e=this.createEditButton(o);t.appendChild(e)}this.options.enableClickToEdit&&n&&this.addClickToEdit(t,o);const s=i.parentElement;if(s){"static"===window.getComputedStyle(s).position&&(s.style.position="relative"),s.appendChild(t)}else i.style.position="relative",i.appendChild(t);const r={compositionId:o,isOpen:!1,overlay:t};this.sessions.set(o,r),e.debug("Editor overlay created",{compositionId:o})}))}createEditButton(e){const i=document.createElement("button");return i.className="widgetic-edit-button",i.textContent=this.options.editButtonText||"✏️ Edit",i.style.cssText=`\n position: absolute;\n ${this.getButtonPositionStyles()}\n background: #007bff;\n color: white;\n border: none;\n border-radius: 4px;\n padding: 8px 12px;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n pointer-events: auto;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n transition: all 0.2s ease;\n z-index: 10001;\n ${this.getCustomButtonStyles()}\n `,i.addEventListener("mouseenter",(()=>{i.style.background="#0056b3",i.style.transform="scale(1.05)"})),i.addEventListener("mouseleave",(()=>{i.style.background="#007bff",i.style.transform="scale(1)"})),i.addEventListener("click",(i=>t(this,void 0,void 0,(function*(){i.preventDefault(),i.stopPropagation(),yield this.openEditor(e)})))),i}getButtonPositionStyles(){const t="10px";switch(this.options.editButtonPosition||"top-right"){case"top-left":return`top: ${t}; left: ${t};`;case"top-right":default:return`top: ${t}; right: ${t};`;case"bottom-left":return`bottom: ${t}; left: ${t};`;case"bottom-right":return`bottom: ${t}; right: ${t};`}}getCustomButtonStyles(){return this.options.editButtonStyle?Object.entries(this.options.editButtonStyle).map((([t,e])=>`${this.camelToKebab(t)}: ${e};`)).join(" "):""}getOverlayStyles(){return this.options.overlayStyle?Object.entries(this.options.overlayStyle).map((([t,e])=>`${this.camelToKebab(t)}: ${e};`)).join(" "):""}camelToKebab(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}addClickToEdit(e,i){e.style.cursor="pointer",e.style.pointerEvents="auto",e.addEventListener("click",(o=>t(this,void 0,void 0,(function*(){o.target===e&&(o.preventDefault(),o.stopPropagation(),yield this.openEditor(i))})))),e.addEventListener("mouseenter",(()=>{e.style.backgroundColor="rgba(0, 123, 255, 0.1)",e.style.border="2px dashed #007bff"})),e.addEventListener("mouseleave",(()=>{e.style.backgroundColor="transparent",e.style.border="none"}))}createEditorContainer(){const t=new g({target:"widgetic-editor-portal",className:"widgetic-editor-modal",zIndex:1e5,clickThrough:!1});const e=document.createElement("div");e.className="widgetic-editor-modal-backdrop",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n ";const i=document.createElement("div");return i.className="widgetic-editor-content",i.style.cssText="\n width: 90vw;\n height: 90vh;\n max-width: 1200px;\n max-height: 800px;\n background: white;\n border-radius: 8px;\n overflow: hidden;\n position: relative;\n ",e.appendChild(i),t.mount(e),{container:e,portal:t}}openEditor(i){return t(this,void 0,void 0,(function*(){try{const t=this.sessions.get(i);if(!t)return void e.warn("No editor session found",{compositionId:i});if(t.isOpen)return void e.debug("Editor already open",{compositionId:i});e.info("Opening composition editor",{compositionId:i});const o=f(),n=yield o.initializeUISdk(),{container:s,portal:r}=this.createEditorContainer(),d=yield n.mountCompositionEditor(s.querySelector(".widgetic-editor-content"),i,{onSave:t=>this.handleEditorSave(i,t),onClose:()=>this.closeEditor(i),onPreview:t=>this.handleEditorPreview(i,t)}),c=a().createWidgetController(i);if(t.isOpen=!0,t.editorContainer=s,t.editorInstance=d,t.widgetController=c,t.portal=r,t.overlay){const e=t.overlay.querySelector(".widgetic-edit-button");e&&(e.style.display="none")}e.info("Composition editor opened successfully",{compositionId:i})}catch(t){e.error("Failed to open editor",{compositionId:i,error:t}),this.showError("Failed to open editor. Please try again.",i)}}))}handleEditorSave(i,o){return t(this,void 0,void 0,(function*(){try{e.info("Saving composition changes",{compositionId:i,data:o});const t=this.sessions.get(i);(null==t?void 0:t.widgetController)&&(yield t.widgetController.updateConfig(o),yield t.widgetController.refresh()),yield this.closeEditor(i),e.info("Composition saved successfully",{compositionId:i})}catch(t){e.error("Failed to save composition",{compositionId:i,error:t}),this.showError("Failed to save changes. Please try again.",i)}}))}handleEditorPreview(i,o){return t(this,void 0,void 0,(function*(){try{const t=this.sessions.get(i);(null==t?void 0:t.widgetController)&&(yield t.widgetController.callFunction("preview",o))}catch(t){e.warn("Preview update failed",{compositionId:i,error:t})}}))}closeEditor(i){return t(this,void 0,void 0,(function*(){const t=this.sessions.get(i);if(t&&t.isOpen)try{if(t.editorInstance&&t.editorContainer){const e=f().getInstance();e&&(yield e.unmountCompositionEditor(t.editorContainer))}if(t.portal&&t.portal.destroy(),t.overlay){const e=t.overlay.querySelector(".widgetic-edit-button");e&&(e.style.display="block")}t.isOpen=!1,t.editorContainer=void 0,t.editorInstance=void 0,t.portal=void 0,e.info("Editor closed",{compositionId:i})}catch(t){e.error("Error closing editor",{compositionId:i,error:t})}}))}showError(t,e){const i=document.createElement("div");i.style.cssText="\n position: fixed;\n top: 20px;\n right: 20px;\n background: #dc3545;\n color: white;\n padding: 12px 16px;\n border-radius: 4px;\n z-index: 100001;\n font-size: 14px;\n max-width: 300px;\n ",i.textContent=t,document.body.appendChild(i),setTimeout((()=>{i.parentNode&&i.parentNode.removeChild(i)}),5e3)}removeOverlay(t){const i=this.sessions.get(t);i&&(i.isOpen&&this.closeEditor(t),i.overlay&&i.overlay.parentNode&&i.overlay.parentNode.removeChild(i.overlay),i.portal&&i.portal.destroy(),this.sessions.delete(t),e.debug("Editor overlay removed",{compositionId:t}))}isEditorOpen(t){var e;return(null===(e=this.sessions.get(t))||void 0===e?void 0:e.isOpen)||!1}getActiveSessions(){return Array.from(this.sessions.keys())}cleanup(){for(const t of this.sessions.keys())this.removeOverlay(t);e.debug("Editor overlay cleanup complete")}}let b=null;function E(t){return b||(b=new w(t)),b}var C=Object.freeze({__proto__:null,EditorOverlay:w,getEditorOverlay:E,resetEditorOverlay:function(){b&&(b.cleanup(),b=null)}});export{E as a,f as b,m as c,c as d,C as e,p as g,l as t};
|
|
1
|
+
import{_ as e}from"./vendor.js";import{c as t,l as n,a as i}from"./core.js";import{getMessenger as o}from"./messaging.js";var s="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};const r="http://localhost:3000/v1".replace(/\/+$/,"");class a{constructor(e){if(this.configuration={basePath:r,headers:{},middleware:[]},"string"==typeof e){const t=(null==e?void 0:e.startsWith("Bearer "))?e.slice(7):e;this.configuration.apiKey=e=>s(this,void 0,void 0,(function*(){return"authorization"===(null==e?void 0:e.toLowerCase())?`Bearer ${t}`:t})),this.configuration.accessToken=()=>s(this,void 0,void 0,(function*(){return t})),this.configuration.headers={"Content-Type":"application/json"}}else if(e){this.configuration=Object.assign(Object.assign({},e),{basePath:e.basePath||r});if("string"==typeof e.accessToken&&e.accessToken){const t=e.accessToken,n=t.startsWith("Bearer ")?t.slice(7):t;this.configuration.apiKey=e=>s(this,void 0,void 0,(function*(){return"authorization"===(null==e?void 0:e.toLowerCase())?`Bearer ${n}`:n})),this.configuration.accessToken=()=>s(this,void 0,void 0,(function*(){return n}))}e.headers||(this.configuration.headers={"Content-Type":"application/json"})}}set config(e){this.configuration=e}get basePath(){return null!=this.configuration.basePath?this.configuration.basePath:r}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||p}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const e=this.configuration.apiKey;if(e)return"function"==typeof e?e:()=>e}get accessToken(){const e=this.configuration.accessToken;if(e)return"function"==typeof e?e:()=>s(this,void 0,void 0,(function*(){return e}))}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const d=new a;class u{constructor(e=d){this.configuration=e,this.fetchApi=(e,t)=>s(this,void 0,void 0,(function*(){let n,i={url:e,init:t};this.middleware&&Array.isArray(this.middleware)||(this.middleware=[]);for(const e of this.middleware)e.pre&&(i=(yield e.pre(Object.assign({fetch:this.fetchApi},i)))||i);try{n=yield(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(e){for(const t of this.middleware)t.onError&&(n=(yield t.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:e,response:n?n.clone():void 0}))||n);if(void 0===n)throw e instanceof Error?new l(e,"The request failed and the interceptors did not return an alternative response"):e}for(const e of this.middleware)e.post&&(n=(yield e.post({fetch:this.fetchApi,url:i.url,init:i.init,response:n.clone()}))||n);return n})),"string"!=typeof e&&(!e||e instanceof a)||(e=new a(e)),this.configuration=e,this.middleware=this.configuration.middleware||[]}withMiddleware(...e){const t=this.clone();return t.middleware=t.middleware.concat(...e),t}withPreMiddleware(...e){const t=e.map((e=>({pre:e})));return this.withMiddleware(...t)}withPostMiddleware(...e){const t=e.map((e=>({post:e})));return this.withMiddleware(...t)}isJsonMime(e){return!!e&&u.jsonRegex.test(e)}request(e,t){return s(this,void 0,void 0,(function*(){var n;const{url:i,init:o}=yield this.createFetchParams(e,t),s=new Headers(Object.assign(Object.assign(Object.assign({},this.configuration.headers),e.headers||{}),o.headers||{})),r=Object.assign(Object.assign({},o),{headers:s}),a=yield this.fetchApi(i,r);if(a&&a.status>=200&&a.status<300)return a;const d=a.clone();let u="Response returned an error code",l=null;try{const e=yield d.json(),t=e.error,i=t&&"object"==typeof t?t.message:t;u=e.message||i||u;const o=null===(n=null==e?void 0:e.error)||void 0===n?void 0:n.code;"string"==typeof o&&o.length>0&&(l=o)}catch(e){try{u=yield d.text()}catch(e){u=a.statusText}}throw new c(a,u,l)}))}createFetchParams(e,t){return s(this,void 0,void 0,(function*(){let n=(this.configuration.basePath||r).replace(/\/+$/,"")+(e.path.startsWith("/")?e.path:`/${e.path}`);void 0!==e.query&&0!==Object.keys(e.query).length&&(n+="?"+this.configuration.queryParamsStringify(e.query));const i=Object.assign({},this.configuration.headers,e.headers);Object.keys(i).forEach((e=>void 0===i[e]?delete i[e]:{}));const o=this.configuration.apiKey;if(o&&!i.Authorization)try{const e=yield o("Authorization");e&&(i.Authorization=e.startsWith("Bearer ")?e:`Bearer ${e}`)}catch(e){}const a="function"==typeof t?t:()=>s(this,void 0,void 0,(function*(){return t})),d={method:e.method,headers:i,body:e.body,credentials:this.configuration.credentials},u=Object.assign(Object.assign({},d),yield a({init:d,context:e}));let c;var l;l=u.body,c="undefined"!=typeof FormData&&l instanceof FormData||u.body instanceof URLSearchParams||function(e){return"undefined"!=typeof Blob&&e instanceof Blob}(u.body)?u.body:this.isJsonMime(i["Content-Type"])?JSON.stringify(u.body):u.body;return{url:n,init:Object.assign(Object.assign({},u),{body:c})}}))}clone(){const e=new(0,this.constructor)(this.configuration);return e.middleware=this.middleware.slice(),e}}u.jsonRegex=new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$","i");class c extends Error{constructor(e,t,n=null){super(t),this.response=e,this.name="ResponseError",this.code=n}}class l extends Error{constructor(e,t){super(t),this.cause=e,this.name="FetchError"}}class h extends Error{constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}function p(e,t=""){return Object.keys(e).map((n=>f(n,e[n],t))).filter((e=>e.length>0)).join("&")}function f(e,t,n=""){const i=n+(n.length?`[${e}]`:e);if(t instanceof Array){const e=t.map((e=>encodeURIComponent(String(e)))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${e}`}if(t instanceof Set){return f(e,Array.from(t),n)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?p(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}function m(e,t){return Object.keys(e).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:t(e[i])})),{})}class g{constructor(e,t=e=>e){this.raw=e,this.transformer=t}unwrapSuccessEnvelope(e){if(e&&"object"==typeof e&&"success"in e&&"data"in e){const{success:t,data:n,meta:i}=e,o="boolean"!=typeof t||t;return Array.isArray(n)?{success:o,data:n,meta:i,rawData:n}:n&&"object"==typeof n?Object.assign({success:o,data:n,meta:i},n):{success:o,data:n,meta:i}}return e}value(){return s(this,void 0,void 0,(function*(){const e=yield this.raw.json();return this.transformer(this.unwrapSuccessEnvelope(e))}))}}class v{constructor(e){this.raw=e}value(){return s(this,void 0,void 0,(function*(){}))}}function w(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,abTestId:null==e.abTestId?void 0:e.abTestId,compositionId:null==e.compositionId?void 0:e.compositionId,name:null==e.name?void 0:e.name,description:null==e.description?void 0:e.description,trafficPercentage:null==e.trafficPercentage?void 0:e.trafficPercentage,embedCode:null==e.embedCode?void 0:e.embedCode,totalImpressions:null==e.totalImpressions?void 0:e.totalImpressions,totalConversions:null==e.totalConversions?void 0:e.totalConversions,conversionRate:null==e.conversionRate?void 0:e.conversionRate,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt)}}(e)}function y(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,creatorId:null==e.creatorId?void 0:e.creatorId,organizationId:null==e.organizationId?void 0:e.organizationId,workspaceType:null==e.workspaceType?void 0:e.workspaceType,name:null==e.name?void 0:e.name,description:null==e.description?void 0:e.description,status:null==e.status?void 0:e.status,successMetrics:null==e.successMetrics?void 0:e.successMetrics,primaryMetric:null==e.primaryMetric?void 0:e.primaryMetric,confidenceLevel:null==e.confidenceLevel?void 0:e.confidenceLevel,minSampleSize:null==e.minSampleSize?void 0:e.minSampleSize,autoGraduate:null==e.autoGraduate?void 0:e.autoGraduate,graduationThreshold:null==e.graduationThreshold?void 0:e.graduationThreshold,startDate:null==e.startDate?void 0:new Date(e.startDate),endDate:null==e.endDate?void 0:new Date(e.endDate),durationDays:null==e.durationDays?void 0:e.durationDays,winningVariantId:null==e.winningVariantId?void 0:e.winningVariantId,graduatedAt:null==e.graduatedAt?void 0:new Date(e.graduatedAt),statisticalSignificance:null==e.statisticalSignificance?void 0:e.statisticalSignificance,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt),variants:null==e.variants?void 0:e.variants.map(w)}}(e)}function I(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,ab_test_id:null==e.ab_test_id?void 0:e.ab_test_id,variant_id:null==e.variant_id?void 0:e.variant_id,user_id:null==e.user_id?void 0:e.user_id,session_id:null==e.session_id?void 0:e.session_id,user_identifier_hash:null==e.user_identifier_hash?void 0:e.user_identifier_hash,assigned_at:null==e.assigned_at?void 0:new Date(e.assigned_at)}}(e)}function R(e){return function(e){if(null==e)return e;return{hasMeaningfulContrast:null==e.hasMeaningfulContrast?void 0:e.hasMeaningfulContrast,primaryDriver:null==e.primaryDriver?void 0:e.primaryDriver,cognitiveClarityScore:null==e.cognitiveClarityScore?void 0:e.cognitiveClarityScore,safeToGraduate:null==e.safeToGraduate?void 0:e.safeToGraduate,qualitativeReason:null==e.qualitativeReason?void 0:e.qualitativeReason}}(e)}function T(e){return function(e){if(null==e)return e;return{action:null==e.action?void 0:e.action,reason:null==e.reason?void 0:e.reason,minAdditionalSamples:null==e.minAdditionalSamples?void 0:e.minAdditionalSamples}}(e)}function q(e){return function(e){if(null==e)return e;return{totalImpressions:null==e.totalImpressions?void 0:e.totalImpressions,totalConversions:null==e.totalConversions?void 0:e.totalConversions,overallConversionRate:null==e.overallConversionRate?void 0:e.overallConversionRate,statisticalPower:null==e.statisticalPower?void 0:e.statisticalPower,confidenceLevel:null==e.confidenceLevel?void 0:e.confidenceLevel}}(e)}function C(e){return function(e){if(null==e)return e;return{variantId:null==e.variantId?void 0:e.variantId,variantName:null==e.variantName?void 0:e.variantName,impressions:null==e.impressions?void 0:e.impressions,conversions:null==e.conversions?void 0:e.conversions,conversionRate:null==e.conversionRate?void 0:e.conversionRate,confidenceIntervalLower:null==e.confidenceIntervalLower?void 0:e.confidenceIntervalLower,confidenceIntervalUpper:null==e.confidenceIntervalUpper?void 0:e.confidenceIntervalUpper,zScore:null==e.zScore?void 0:e.zScore,pValue:null==e.pValue?void 0:e.pValue,isWinner:null==e.isWinner?void 0:e.isWinner,liftPercentage:null==e.liftPercentage?void 0:e.liftPercentage,statisticalSignificance:null==e.statisticalSignificance?void 0:e.statisticalSignificance,bayesianProbabilityToBeatControl:null==e.bayesianProbabilityToBeatControl?void 0:e.bayesianProbabilityToBeatControl}}(e)}function k(e){return function(e){if(null==e)return e;return{overall:null==e.overall?void 0:q(e.overall),variants:null==e.variants?void 0:e.variants.map(C),recommendation:null==e.recommendation?void 0:T(e.recommendation)}}(e)}function A(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,translationId:null==e.translationId?void 0:e.translationId,compositionId:null==e.compositionId?void 0:e.compositionId,languageCode:null==e.languageCode?void 0:e.languageCode,languageName:null==e.languageName?void 0:e.languageName,isRoot:null==e.isRoot?void 0:e.isRoot,embedCode:null==e.embedCode?void 0:e.embedCode,totalViews:null==e.totalViews?void 0:e.totalViews,status:null==e.status?void 0:e.status,translationProgress:null==e.translationProgress?void 0:e.translationProgress,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt)}}(e)}function b(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,creatorId:null==e.creatorId?void 0:e.creatorId,name:null==e.name?void 0:e.name,description:null==e.description?void 0:e.description,rootCompositionId:null==e.rootCompositionId?void 0:e.rootCompositionId,rootLanguage:null==e.rootLanguage?void 0:e.rootLanguage,status:null==e.status?void 0:e.status,embedCode:null==e.embedCode?void 0:e.embedCode,selectedLanguages:null==e.selectedLanguages?void 0:e.selectedLanguages,totalViews:null==e.totalViews?void 0:e.totalViews,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt),variants:null==e.variants?void 0:e.variants.map(A)}}(e)}function S(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:b(e.data),message:null==e.message?void 0:e.message}}(e)}function B(e){return function(e){if(null==e)return e;return{id:e.id,composition_id:e.composition_id,date:new Date(e.date),country:e.country,region:null==e.region?void 0:e.region,city:null==e.city?void 0:e.city,views:e.views,unique_users:e.unique_users,created_at:null==e.created_at?void 0:new Date(e.created_at),updated_at:null==e.updated_at?void 0:new Date(e.updated_at)}}(e)}function E(e){return function(e){if(null==e)return e;return{total_views:null==e.total_views?void 0:e.total_views,unique_views:null==e.unique_views?void 0:e.unique_views,total_interactions:null==e.total_interactions?void 0:e.total_interactions,unique_interactions:null==e.unique_interactions?void 0:e.unique_interactions,average_session_time:null==e.average_session_time?void 0:e.average_session_time,bounce_rate:null==e.bounce_rate?void 0:e.bounce_rate}}(e)}function _(e){return function(e){if(null==e)return e;return{id:e.id,compositionId:e.compositionId,date:new Date(e.date),deviceType:e.deviceType,views:e.views,uniqueUsers:e.uniqueUsers,avgSessionDuration:e.avgSessionDuration,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt)}}(e)}function D(e){return function(e){if(null==e)return e;return{id:e.id,composition_id:e.composition_id,timestamp:new Date(e.timestamp),event_type:e.event_type,event_data:null==e.event_data?void 0:e.event_data,user_id:null==e.user_id?void 0:e.user_id,session_id:null==e.session_id?void 0:e.session_id,ip_address:null==e.ip_address?void 0:e.ip_address,user_agent:null==e.user_agent?void 0:e.user_agent,referrer:null==e.referrer?void 0:e.referrer,created_at:null==e.created_at?void 0:new Date(e.created_at)}}(e)}function U(e){return function(e){if(null==e)return e;return{id:e.id,composition_id:e.composition_id,date:new Date(e.date),source:e.source,source_url:null==e.source_url?void 0:e.source_url,views:e.views,unique_users:e.unique_users,created_at:null==e.created_at?void 0:new Date(e.created_at),updated_at:null==e.updated_at?void 0:new Date(e.updated_at)}}(e)}function P(e){return function(e){if(null==e)return e;return{summary:E(e.summary),devices:e.devices.map(_),geography:e.geography.map(B),referrers:e.referrers.map(U),events:null==e.events?void 0:e.events.map(D)}}(e)}function W(e){return function(e){if(null==e)return e;return{composition_id:e.composition_id,event_type:e.event_type,event_data:e.event_data,user_id:e.user_id,session_id:e.session_id,ip_address:e.ip_address,user_agent:e.user_agent,referrer:e.referrer}}(e,!1)}function K(e){return function(e){if(null==e)return e;return{events:e.events.map(W)}}(e,!1)}function z(e){return function(e){if(null==e)return e;return{canAccess:null==e.canAccess?void 0:e.canAccess,reason:null==e.reason?void 0:e.reason}}(e)}function O(e){return function(e){if(null==e)return e;return{canAccess:null==e.canAccess?void 0:e.canAccess,reason:null==e.reason?void 0:e.reason}}(e)}function x(e){return function(e){if(null==e)return e;return{should_stop:null==e.should_stop?void 0:e.should_stop,reason:null==e.reason?void 0:e.reason,new_status:null==e.new_status?void 0:e.new_status}}(e)}function j(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:x(e.data)}}(e)}function $(e){return function(e){if(null==e)return e;return{id:e.id,creatorId:e.creatorId,widgetId:e.widgetId,name:e.name,content:e.content,contentVersion:null==e.contentVersion?void 0:e.contentVersion,status:e.status,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),embedSettings:null==e.embedSettings?void 0:e.embedSettings,design:null==e.design?void 0:e.design,databaseId:null==e.databaseId?void 0:e.databaseId,projectId:null==e.projectId?void 0:e.projectId,managedUserId:null==e.managedUserId?void 0:e.managedUserId}}(e)}function G(e){return function(e){if(null==e)return e;return{name:e.name,type:e.type}}(e)}function L(e){return function(e){if(null==e)return e;return{name:e.name,columns:e.columns.map(G),rows:e.rows}}(e)}function M(e){return function(e){if(null==e)return e;return{compositionId:e.compositionId,hasData:e.hasData,tables:e.tables.map(L)}}(e)}function V(e){return function(e){if(null==e)return e;return{value:e.value,count:e.count}}(e)}function N(e){return function(e){if(null==e)return e;return{compositionId:e.compositionId,table:e.table,totalRows:e.totalRows,tallies:null==e.tallies?null:e.tallies.map(V),moreGroups:e.moreGroups,columns:e.columns,rows:null==e.rows?null:e.rows,moreRows:e.moreRows}}(e)}function F(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,compositionId:null==e.compositionId?void 0:e.compositionId,version:null==e.version?void 0:e.version,content:null==e.content?void 0:e.content,createdAt:null==e.createdAt?void 0:new Date(e.createdAt)}}(e)}function H(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:I(e.data)}}(e)}function J(e){return function(e){if(null==e)return e;return{name:e.name,description:e.description,compositionId:e.compositionId,trafficPercentage:e.trafficPercentage}}(e,!1)}function Z(e){return function(e){if(null==e)return e;return{name:e.name,description:e.description,status:e.status,workspaceType:e.workspaceType,variants:e.variants.map(J),successMetrics:e.successMetrics,primaryMetric:e.primaryMetric,confidenceLevel:e.confidenceLevel,minSampleSize:e.minSampleSize,autoGraduate:e.autoGraduate,graduationThreshold:e.graduationThreshold,startDate:null==e.startDate?void 0:e.startDate.toISOString(),endDate:null==e.endDate?void 0:e.endDate.toISOString(),durationDays:e.durationDays}}(e,!1)}function Q(e){return function(e){if(null==e)return e;return Object.assign(Object.assign({},e),{position:e.position})}(e,!1)}function X(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:$(e.data)}}(e)}function Y(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:b(e.data),message:null==e.message?void 0:e.message}}(e)}function ee(e){return function(e){if(null==e)return e;return{x:null==e.x?void 0:e.x,y:null==e.y?void 0:e.y}}(e)}function te(e){return function(e){if(null==e)return e;return{width:null==e.width?void 0:e.width,height:null==e.height?void 0:e.height}}(e)}function ne(e){return function(e){if(null==e)return e;return{componentId:null==e.componentId?void 0:e.componentId,path:null==e.path?void 0:e.path,planId:null==e.planId?void 0:e.planId,status:null==e.status?void 0:e.status,position:null==e.position?void 0:ee(e.position),size:null==e.size?void 0:te(e.size)}}(e)}function ie(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,creatorId:null==e.creatorId?void 0:e.creatorId,description:null==e.description?void 0:e.description,type:null==e.type?void 0:e.type,content:null==e.content?void 0:e.content,isPublic:null==e.isPublic?void 0:e.isPublic,isDraft:null==e.isDraft?void 0:e.isDraft,shareId:null==e.shareId?void 0:e.shareId,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt),jsPath:null==e.jsPath?void 0:e.jsPath,canvasId:null==e.canvasId?void 0:e.canvasId,repoId:null==e.repoId?void 0:e.repoId,databaseId:null==e.databaseId?void 0:e.databaseId,version:null==e.version?void 0:e.version,componentsMetadata:null==e.componentsMetadata?void 0:e.componentsMetadata.map(ne),cpgSchemaId:null==e.cpgSchemaId?void 0:e.cpgSchemaId,lastCpgCommitSha:null==e.lastCpgCommitSha?void 0:e.lastCpgCommitSha,organizationId:null==e.organizationId?void 0:e.organizationId,projectFolder:null==e.projectFolder?void 0:e.projectFolder,workspaceType:null==e.workspaceType?void 0:e.workspaceType,managedUserId:null==e.managedUserId?void 0:e.managedUserId,warnings:null==e.warnings?void 0:e.warnings}}(e)}function oe(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:ie(e.data),meta:null==e.meta?void 0:e.meta}}(e)}function se(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:y(e.data)}}(e)}function re(e){return function(e){if(null==e)return e;return{id:e.id,compositionId:e.compositionId,date:new Date(e.date),totalViews:e.totalViews,uniqueViews:e.uniqueViews,totalInteractions:e.totalInteractions,uniqueInteractions:e.uniqueInteractions,totalSessionTime:e.totalSessionTime,averageSessionTime:e.averageSessionTime,bounceRate:e.bounceRate,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt)}}(e)}function ae(e){return function(e){if(null==e)return e;return{deleted:null==e.deleted?void 0:e.deleted,contentVersion:null==e.contentVersion?void 0:e.contentVersion}}(e)}function de(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,message:null==e.message?void 0:e.message}}(e)}function ue(e){return function(e){if(null==e)return e;return{operationId:null==e.operationId?void 0:e.operationId}}(e)}function ce(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:ue(e.data)}}(e)}function le(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,creatorId:null==e.creatorId?void 0:e.creatorId,description:null==e.description?void 0:e.description,type:null==e.type?void 0:e.type,content:null==e.content?void 0:e.content,isPublic:null==e.isPublic?void 0:e.isPublic,isDraft:null==e.isDraft?void 0:e.isDraft,shareId:null==e.shareId?void 0:e.shareId,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt),jsPath:null==e.jsPath?void 0:e.jsPath,canvasId:null==e.canvasId?void 0:e.canvasId,repoId:null==e.repoId?void 0:e.repoId,databaseId:null==e.databaseId?void 0:e.databaseId,version:null==e.version?void 0:e.version,componentsMetadata:null==e.componentsMetadata?void 0:e.componentsMetadata.map(ne),cpgSchemaId:null==e.cpgSchemaId?void 0:e.cpgSchemaId,lastCpgCommitSha:null==e.lastCpgCommitSha?void 0:e.lastCpgCommitSha,organizationId:null==e.organizationId?void 0:e.organizationId,projectFolder:null==e.projectFolder?void 0:e.projectFolder,workspaceType:null==e.workspaceType?void 0:e.workspaceType,managedUserId:null==e.managedUserId?void 0:e.managedUserId}}(e)}function he(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:le(e.data),warnings:null==e.warnings?void 0:e.warnings}}(e)}function pe(e){return function(e){if(null==e)return e;return{token:null==e.token?void 0:e.token,tokenType:null==e.tokenType?void 0:e.tokenType,expiresIn:null==e.expiresIn?void 0:e.expiresIn,expiresAt:null==e.expiresAt?void 0:new Date(e.expiresAt),scopes:null==e.scopes?void 0:e.scopes}}(e)}function fe(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:pe(e.data)}}(e)}function me(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,composition_id:null==e.composition_id?void 0:e.composition_id,traffic_percentage:null==e.traffic_percentage?void 0:e.traffic_percentage}}(e)}function ge(e){return function(e){if(null==e)return e;return{test_id:null==e.test_id?void 0:e.test_id,name:null==e.name?void 0:e.name,status:null==e.status?void 0:e.status,variants:null==e.variants?void 0:e.variants.map(me),success_metrics:null==e.success_metrics?void 0:e.success_metrics}}(e)}function ve(e){return function(e){if(null==e)return e;return{page:null==e.page?void 0:e.page,size:null==e.size?void 0:e.size,total:null==e.total?void 0:e.total}}(e)}function we(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map($),meta:null==e.meta?void 0:ve(e.meta)}}(e)}function ye(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,description:null==e.description?void 0:e.description,category:null==e.category?void 0:e.category}}(e)}function Ie(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(ye)}}(e)}function Re(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,description:null==e.description?void 0:e.description}}(e)}function Te(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(Re)}}(e)}function qe(e){return function(e){if(null==e)return e;return{version:null==e.version?void 0:e.version,widgetType:null==e.widgetType?void 0:e.widgetType,type:null==e.type?void 0:e.type,content:null==e.content?void 0:e.content,contentItems:null==e.contentItems?void 0:e.contentItems,metadata:null==e.metadata?void 0:e.metadata}}(e)}function Ce(e){return function(e){if(null==e)return e;return{version:null==e.version?void 0:e.version,widgetType:null==e.widgetType?void 0:e.widgetType,type:null==e.type?void 0:e.type,theme:null==e.theme?void 0:e.theme,componentGroups:null==e.componentGroups?void 0:e.componentGroups,metadata:null==e.metadata?void 0:e.metadata}}(e)}function ke(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,version:null==e.version?void 0:e.version,type:null==e.type?void 0:e.type,componentGroups:null==e.componentGroups?void 0:e.componentGroups,defaults:null==e.defaults?void 0:e.defaults}}(e)}function Ae(e){return function(e){if(null==e)return e;return{compositionId:null==e.compositionId?void 0:e.compositionId,widgetId:null==e.widgetId?void 0:e.widgetId,version:null==e.version?void 0:e.version,previewUrl:null==e.previewUrl?void 0:e.previewUrl}}(e)}function be(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(F)}}(e)}function Se(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,error:null==e.error?void 0:e.error}}(e)}function Be(e){return function(e){if(null==e)return e;return{compositions:null==e.compositions?void 0:e.compositions.map($),errors:null==e.errors?void 0:e.errors.map(Se)}}(e)}function Ee(e){return function(e){if(null==e)return e;return{presets:null==e.presets?void 0:e.presets}}(e)}function _e(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Ee(e.data)}}(e)}function De(e){return function(e){if(null==e)return e;return{name:null==e.name?void 0:e.name,nativeName:null==e.nativeName?void 0:e.nativeName,region:null==e.region?void 0:e.region,isPreselected:null==e.isPreselected?void 0:e.isPreselected}}(e)}function Ue(e){return function(e){if(null==e)return e;return{languages:null==e.languages?void 0:m(e.languages,De),preselected:null==e.preselected?void 0:e.preselected}}(e)}function Pe(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Ue(e.data)}}(e)}function We(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:b(e.data)}}(e)}function Ke(e){return function(e){if(null==e)return e;return{languageCode:null==e.languageCode?void 0:e.languageCode,views:null==e.views?void 0:e.views,percentage:null==e.percentage?void 0:e.percentage}}(e)}function ze(e){return function(e){if(null==e)return e;return{languageCode:null==e.languageCode?void 0:e.languageCode,views:null==e.views?void 0:e.views}}(e)}function Oe(e){return function(e){if(null==e)return e;return{totalViews:null==e.totalViews?void 0:e.totalViews,languageBreakdown:null==e.languageBreakdown?void 0:e.languageBreakdown.map(Ke),topPerformingLanguages:null==e.topPerformingLanguages?void 0:e.topPerformingLanguages.map(ze),completionStatus:null==e.completionStatus?void 0:e.completionStatus}}(e)}function xe(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Oe(e.data)}}(e)}function je(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,name:null==e.name?void 0:e.name,rootLanguage:null==e.rootLanguage?void 0:e.rootLanguage,rootCompositionId:null==e.rootCompositionId?void 0:e.rootCompositionId,languageCompositions:null==e.languageCompositions?void 0:e.languageCompositions,status:null==e.status?void 0:e.status}}(e)}function $e(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:je(e.data)}}(e)}function Ge(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(b),count:null==e.count?void 0:e.count}}(e)}function Le(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,composition_id:null==e.composition_id?void 0:e.composition_id,name:null==e.name?void 0:e.name,traffic_percentage:null==e.traffic_percentage?void 0:e.traffic_percentage}}(e)}function Me(e){return function(e){if(null==e)return e;return{id:null==e.id?void 0:e.id,version:null==e.version?void 0:e.version,commitSha:null==e.commitSha?void 0:e.commitSha,commitTitle:null==e.commitTitle?void 0:e.commitTitle,artifactUrl:null==e.artifactUrl?void 0:e.artifactUrl,publishedAt:null==e.publishedAt?void 0:new Date(e.publishedAt),isPublished:null==e.isPublished?void 0:e.isPublished,prompt:null==e.prompt?void 0:e.prompt,publishedBy:null==e.publishedBy?void 0:e.publishedBy}}(e)}function Ve(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(Me)}}(e)}function Ne(e){return function(e){if(null==e)return e;return{page:null==e.page?void 0:e.page,size:null==e.size?void 0:e.size,total:null==e.total?void 0:e.total,limit:null==e.limit?void 0:e.limit,offset:null==e.offset?void 0:e.offset,hasNextPage:null==e.hasNextPage?void 0:e.hasNextPage,hasPreviousPage:null==e.hasPreviousPage?void 0:e.hasPreviousPage}}(e)}function Fe(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(le),meta:null==e.meta?void 0:Ne(e.meta)}}(e)}function He(e){return function(e){if(null==e)return e;return{widgets:null==e.widgets?void 0:e.widgets.map(le),errors:null==e.errors?void 0:e.errors.map(Se)}}(e)}function Je(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:R(e.data)}}(e)}function Ze(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:k(e.data)}}(e)}function Qe(e){return function(e){if(null==e)return e;return{count:null==e.count?void 0:e.count,workspace_type:null==e.workspace_type?void 0:e.workspace_type}}(e)}function Xe(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data.map(y),meta:null==e.meta?void 0:Qe(e.meta)}}(e)}function Ye(e){return function(e){if(null==e)return e;return{id:e.id,compositionId:e.compositionId,year:e.year,month:e.month,startDate:new Date(e.startDate),endDate:new Date(e.endDate),totalViews:e.totalViews,uniqueViews:e.uniqueViews,totalInteractions:e.totalInteractions,uniqueInteractions:e.uniqueInteractions,totalSessionTime:e.totalSessionTime,averageSessionTime:e.averageSessionTime,bounceRate:e.bounceRate,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt)}}(e)}function et(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:e.data}}(e)}function tt(e){return function(e){if(null==e)return e;return{widgetId:null==e.widgetId?void 0:e.widgetId,version:null==e.version?void 0:e.version,commitTitle:null==e.commitTitle?void 0:e.commitTitle}}(e)}function nt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:tt(e.data)}}(e)}function it(e){return function(e){if(null==e)return e;return{email:e.email}}(e,!1)}function ot(e){return function(e){if(null==e)return e;return{valid:null==e.valid?void 0:e.valid,errors:null==e.errors?void 0:e.errors,warnings:null==e.warnings?void 0:e.warnings}}(e)}function st(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,contentVersion:null==e.contentVersion?void 0:e.contentVersion,validationResult:null==e.validationResult?void 0:ot(e.validationResult),compositionUpdated:null==e.compositionUpdated?void 0:e.compositionUpdated,realtimeUpdateSent:null==e.realtimeUpdateSent?void 0:e.realtimeUpdateSent}}(e)}function rt(e){return function(e){if(null==e)return e;return{widgetId:null==e.widgetId?void 0:e.widgetId,version:null==e.version?void 0:e.version,artifactUrl:null==e.artifactUrl?void 0:e.artifactUrl,commitSha:null==e.commitSha?void 0:e.commitSha,commitTitle:null==e.commitTitle?void 0:e.commitTitle}}(e)}function at(e){return function(e){if(null==e)return e;return{data:null==e.data?void 0:rt(e.data),message:null==e.message?void 0:e.message}}(e)}function dt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:at(e.data)}}(e)}function ut(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:y(e.data),message:null==e.message?void 0:e.message}}(e)}function ct(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:y(e.data),message:null==e.message?void 0:e.message}}(e)}function lt(e){return function(e){if(null==e)return e;return{limit:null==e.limit?void 0:e.limit,hasNextPage:null==e.hasNextPage?void 0:e.hasNextPage,hasPreviousPage:null==e.hasPreviousPage?void 0:e.hasPreviousPage,nextCursor:null==e.nextCursor?void 0:e.nextCursor,previousCursor:null==e.previousCursor?void 0:e.previousCursor}}(e)}function ht(e){return function(e){if(null==e)return e;return{pagination:null==e.pagination?void 0:lt(e.pagination)}}(e)}function pt(e){return function(e){if(null==e)return e;return{success:e.success,message:null==e.message?void 0:e.message,data:e.data,meta:null==e.meta?void 0:ht(e.meta)}}(e)}function ft(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,message:null==e.message?void 0:e.message}}(e)}function mt(e){return function(e){if(null==e)return e;return{experiment_id:e.experiment_id,variant_id:e.variant_id,conversion_type:e.conversion_type,timestamp:null==e.timestamp?void 0:e.timestamp.toISOString(),user_id:e.user_id}}(e,!1)}function gt(e){return function(e){if(null==e)return e;return{event_type:e.event_type,data:mt(e.data)}}(e,!1)}function vt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,message:null==e.message?void 0:e.message,count:null==e.count?void 0:e.count}}(e)}function wt(e){return function(e){if(null==e)return e;return{experiment_id:e.experiment_id,variant_id:e.variant_id,conversion_type:e.conversion_type,timestamp:null==e.timestamp?void 0:e.timestamp.toISOString()}}(e,!1)}function yt(e){return function(e){if(null==e)return e;return{event_type:e.event_type,data:wt(e.data)}}(e,!1)}function It(e){return function(e){if(null==e)return e;return{events:e.events.map(yt)}}(e,!1)}function Rt(e){return function(e){if(null==e)return e;return{name:e.name,description:e.description,status:e.status,successMetrics:e.successMetrics,primaryMetric:e.primaryMetric,confidenceLevel:e.confidenceLevel,minSampleSize:e.minSampleSize,autoGraduate:e.autoGraduate,graduationThreshold:e.graduationThreshold,startDate:null==e.startDate?void 0:e.startDate.toISOString(),endDate:null==e.endDate?void 0:e.endDate.toISOString(),durationDays:e.durationDays}}(e,!1)}function Tt(e){return function(e){if(null==e)return e;return{token:e.token,email:e.email}}(e,!1)}function qt(e){return function(e){if(null==e)return e;return{repositoryId:null==e.repositoryId?void 0:e.repositoryId}}(e)}function Ct(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:qt(e.data),meta:null==e.meta?void 0:e.meta}}(e)}function kt(e){return function(e){if(null==e)return e;return{thumbnailUrl:null==e.thumbnailUrl?void 0:e.thumbnailUrl}}(e)}function At(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:kt(e.data)}}(e)}function bt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,message:null==e.message?void 0:e.message}}(e)}function St(e){return function(e){if(null==e)return e;return{valid:null==e.valid?void 0:e.valid,errors:null==e.errors?void 0:e.errors,warnings:null==e.warnings?void 0:e.warnings,sanitizedContent:null==e.sanitizedContent?void 0:e.sanitizedContent}}(e)}function Bt(e){return function(e){if(null==e)return e;return{valid:null==e.valid?void 0:e.valid,reason:null==e.reason?void 0:e.reason,message:null==e.message?void 0:e.message}}(e)}function Et(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Bt(e.data)}}(e)}function _t(e){return function(e){if(null==e)return e;return{valid:null==e.valid?void 0:e.valid,tokenType:null==e.tokenType?void 0:e.tokenType,scopes:null==e.scopes?void 0:e.scopes,userId:null==e.userId?void 0:e.userId,expiresAt:null==e.expiresAt?void 0:new Date(e.expiresAt)}}(e)}function Dt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:_t(e.data)}}(e)}function Ut(e){return function(e){if(null==e)return e;return{test_id:null==e.test_id?void 0:e.test_id,test_name:null==e.test_name?void 0:e.test_name,status:null==e.status?void 0:e.status,impact:null==e.impact?void 0:e.impact}}(e)}function Pt(e){return function(e){if(null==e)return e;return{test_id:null==e.test_id?void 0:e.test_id,test_name:null==e.test_name?void 0:e.test_name,status:null==e.status?void 0:e.status,reason:null==e.reason?void 0:e.reason}}(e)}function Wt(e){return function(e){if(null==e)return e;return{can_delete:null==e.can_delete?void 0:e.can_delete,blockers:null==e.blockers?void 0:e.blockers.map(Pt),warnings:null==e.warnings?void 0:e.warnings.map(Ut)}}(e)}function Kt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Wt(e.data)}}(e)}function zt(e){return function(e){if(null==e)return e;return{variant:null==e.variant?void 0:e.variant,metric:null==e.metric?void 0:e.metric,reason:null==e.reason?void 0:e.reason}}(e)}function Ot(e){return function(e){if(null==e)return e;return{is_valid:null==e.is_valid?void 0:e.is_valid,issues:null==e.issues?void 0:e.issues.map(zt),recommendations:null==e.recommendations?void 0:e.recommendations}}(e)}function xt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Ot(e.data)}}(e)}function jt(e){return function(e){if(null==e)return e;return{composition_id:e.composition_id,name:e.name}}(e,!1)}function $t(e){return function(e){if(null==e)return e;return{variants:e.variants.map(jt),success_metrics:e.success_metrics}}(e,!1)}function Gt(e){return function(e){if(null==e)return e;return{can_delete:null==e.can_delete?void 0:e.can_delete,affected_compositions:null==e.affected_compositions?void 0:e.affected_compositions,blockers:null==e.blockers?void 0:e.blockers.map(Pt),warnings:null==e.warnings?void 0:e.warnings.map(Ut)}}(e)}function Lt(e){return function(e){if(null==e)return e;return{success:null==e.success?void 0:e.success,data:null==e.data?void 0:Gt(e.data)}}(e)}function Mt(e){return function(e){if(null==e)return e;return{id:e.id,compositionId:e.compositionId,year:e.year,weekNumber:e.weekNumber,startDate:new Date(e.startDate),endDate:new Date(e.endDate),totalViews:e.totalViews,uniqueViews:e.uniqueViews,totalInteractions:e.totalInteractions,uniqueInteractions:e.uniqueInteractions,totalSessionTime:e.totalSessionTime,averageSessionTime:e.averageSessionTime,bounceRate:e.bounceRate,createdAt:null==e.createdAt?void 0:new Date(e.createdAt),updatedAt:null==e.updatedAt?void 0:new Date(e.updatedAt)}}(e)}var Vt="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class Nt extends u{assignVariantRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling assignVariant().');if(null==e.assignVariantRequest)throw new h("assignVariantRequest",'Required parameter "assignVariantRequest" was null or undefined when calling assignVariant().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/ab-tests/{id}/assign".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.assignVariantRequest,o=s,null==o?o:{user_id:o.user_id,session_id:o.session_id})},t);var o,s;return new g(i,(e=>w(e)))}))}assignVariant(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.assignVariantRaw(e,t);return yield n.value()}))}checkWorkspaceABTestAutoStopRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling checkWorkspaceABTestAutoStop().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling checkWorkspaceABTestAutoStop().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/auto-stop-check".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>j(e)))}))}checkWorkspaceABTestAutoStop(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.checkWorkspaceABTestAutoStopRaw(e,t);return yield n.value()}))}createABTestAssignmentRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.createABTestAssignmentRequest)throw new h("createABTestAssignmentRequest",'Required parameter "createABTestAssignmentRequest" was null or undefined when calling createABTestAssignment().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/ab-tests/assignments",method:"POST",headers:n,query:{},body:(s=e.createABTestAssignmentRequest,o=s,null==o?o:{experiment_id:o.experiment_id,variant_id:o.variant_id,user_id:o.user_id,session_id:o.session_id,device_type:o.device_type,user_agent:o.user_agent,ip_address:o.ip_address,country_code:o.country_code})},t);var o,s;return new g(i,(e=>H(e)))}))}createABTestAssignment(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.createABTestAssignmentRaw(e,t);return yield n.value()}))}createWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling createWorkspaceABTest().');if(null==e.createABTestRequest)throw new h("createABTestRequest",'Required parameter "createABTestRequest" was null or undefined when calling createWorkspaceABTest().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))),method:"POST",headers:n,query:{},body:Z(e.createABTestRequest)},t);return new g(i,(e=>se(e)))}))}createWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.createWorkspaceABTestRaw(e,t);return yield n.value()}))}deleteWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling deleteWorkspaceABTest().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling deleteWorkspaceABTest().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"DELETE",headers:n,query:{}},t);return new g(i,(e=>de(e)))}))}deleteWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.deleteWorkspaceABTestRaw(e,t);return yield n.value()}))}getABTestConfigRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getABTestConfig().');const n=yield this.request({path:"/ab-tests/{id}/config".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:{},query:{}},t);return new g(n,(e=>ge(e)))}))}getABTestConfig(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.getABTestConfigRaw(e,t);return yield n.value()}))}getAvailableMetricsRaw(e){return Vt(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("apiKeyAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/metrics/available",method:"GET",headers:t,query:{}},e);return new g(n,(e=>Ie(e)))}))}getAvailableMetrics(e){return Vt(this,void 0,void 0,(function*(){const t=yield this.getAvailableMetricsRaw(e);return yield t.value()}))}getAvailableSuccessMetricsRaw(e){return Vt(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("apiKeyAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/ab-tests/metrics/available",method:"GET",headers:t,query:{}},e);return new g(n,(e=>Te(e)))}))}getAvailableSuccessMetrics(e){return Vt(this,void 0,void 0,(function*(){const t=yield this.getAvailableSuccessMetricsRaw(e);return yield t.value()}))}getVariantConfigRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getVariantConfig().');const n=yield this.request({path:"/ab-tests/variants/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:{},query:{}},t);return new g(n,(e=>Le(e)))}))}getVariantConfig(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.getVariantConfigRaw(e,t);return yield n.value()}))}getWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling getWorkspaceABTest().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling getWorkspaceABTest().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>se(e)))}))}getWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.getWorkspaceABTestRaw(e,t);return yield n.value()}))}getWorkspaceABTestDiagnosisRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling getWorkspaceABTestDiagnosis().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling getWorkspaceABTestDiagnosis().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/diagnosis".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>Je(e)))}))}getWorkspaceABTestDiagnosis(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.getWorkspaceABTestDiagnosisRaw(e,t);return yield n.value()}))}getWorkspaceABTestStatisticsRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling getWorkspaceABTestStatistics().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling getWorkspaceABTestStatistics().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/statistics".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>Ze(e)))}))}getWorkspaceABTestStatistics(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.getWorkspaceABTestStatisticsRaw(e,t);return yield n.value()}))}listWorkspaceABTestsRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling listWorkspaceABTests().');const n={};null!=e.status&&(n.status=e.status);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/workspaces/{workspaceId}/ab-tests".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))),method:"GET",headers:i,query:n},t);return new g(o,(e=>Xe(e)))}))}listWorkspaceABTests(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.listWorkspaceABTestsRaw(e,t);return yield n.value()}))}pauseWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling pauseWorkspaceABTest().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling pauseWorkspaceABTest().');const n={};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/pause".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"POST",headers:n,query:{}},t);return new g(i,(e=>se(e)))}))}pauseWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.pauseWorkspaceABTestRaw(e,t);return yield n.value()}))}setWorkspaceABTestDurationRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling setWorkspaceABTestDuration().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling setWorkspaceABTestDuration().');if(null==e.setWorkspaceABTestDurationRequest)throw new h("setWorkspaceABTestDurationRequest",'Required parameter "setWorkspaceABTestDurationRequest" was null or undefined when calling setWorkspaceABTestDuration().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/duration".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"PUT",headers:n,query:{},body:(s=e.setWorkspaceABTestDurationRequest,o=s,null==o?o:{duration_days:o.duration_days})},t);var o,s;return new g(i,(e=>ut(e)))}))}setWorkspaceABTestDuration(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.setWorkspaceABTestDurationRaw(e,t);return yield n.value()}))}startWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling startWorkspaceABTest().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling startWorkspaceABTest().');const n={};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/start".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"POST",headers:n,query:{}},t);return new g(i,(e=>se(e)))}))}startWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.startWorkspaceABTestRaw(e,t);return yield n.value()}))}stopWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling stopWorkspaceABTest().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling stopWorkspaceABTest().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}/stop".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"POST",headers:n,query:{},body:(s=e.stopWorkspaceABTestRequest,o=s,null==o?o:{winning_variant_id:o.winning_variant_id,winningVariantId:o.winningVariantId})},t);var o,s;return new g(i,(e=>ct(e)))}))}stopWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.stopWorkspaceABTestRaw(e,t);return yield n.value()}))}trackABTestEventRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.trackABTestEventRequest)throw new h("trackABTestEventRequest",'Required parameter "trackABTestEventRequest" was null or undefined when calling trackABTestEvent().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/ab-tests/analytics/events",method:"POST",headers:n,query:{},body:gt(e.trackABTestEventRequest)},t);return new g(i,(e=>ft(e)))}))}trackABTestEvent(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.trackABTestEventRaw(e,t);return yield n.value()}))}trackBulkABTestEventsRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.trackBulkABTestEventsRequest)throw new h("trackBulkABTestEventsRequest",'Required parameter "trackBulkABTestEventsRequest" was null or undefined when calling trackBulkABTestEvents().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/ab-tests/analytics/bulk",method:"POST",headers:n,query:{},body:It(e.trackBulkABTestEventsRequest)},t);return new g(i,(e=>vt(e)))}))}trackBulkABTestEvents(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.trackBulkABTestEventsRaw(e,t);return yield n.value()}))}updateWorkspaceABTestRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling updateWorkspaceABTest().');if(null==e.testId)throw new h("testId",'Required parameter "testId" was null or undefined when calling updateWorkspaceABTest().');if(null==e.updateABTestRequest)throw new h("updateABTestRequest",'Required parameter "updateABTestRequest" was null or undefined when calling updateWorkspaceABTest().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/{testId}".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))).replace("{testId}",encodeURIComponent(String(e.testId))),method:"PUT",headers:n,query:{},body:Rt(e.updateABTestRequest)},t);return new g(i,(e=>se(e)))}))}updateWorkspaceABTest(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.updateWorkspaceABTestRaw(e,t);return yield n.value()}))}validateWorkspaceCompositionDeletionRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling validateWorkspaceCompositionDeletion().');if(null==e.validateWorkspaceCompositionDeletionRequest)throw new h("validateWorkspaceCompositionDeletionRequest",'Required parameter "validateWorkspaceCompositionDeletionRequest" was null or undefined when calling validateWorkspaceCompositionDeletion().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/validate-composition-deletion".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))),method:"POST",headers:n,query:{},body:(s=e.validateWorkspaceCompositionDeletionRequest,o=s,null==o?o:{composition_ids:o.composition_ids})},t);var o,s;return new g(i,(e=>Kt(e)))}))}validateWorkspaceCompositionDeletion(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.validateWorkspaceCompositionDeletionRaw(e,t);return yield n.value()}))}validateWorkspaceGoalTrackingRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling validateWorkspaceGoalTracking().');if(null==e.validateWorkspaceGoalTrackingRequest)throw new h("validateWorkspaceGoalTrackingRequest",'Required parameter "validateWorkspaceGoalTrackingRequest" was null or undefined when calling validateWorkspaceGoalTracking().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/validate-goal-tracking".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))),method:"POST",headers:n,query:{},body:$t(e.validateWorkspaceGoalTrackingRequest)},t);return new g(i,(e=>xt(e)))}))}validateWorkspaceGoalTracking(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.validateWorkspaceGoalTrackingRaw(e,t);return yield n.value()}))}validateWorkspaceWidgetDeletionRaw(e,t){return Vt(this,void 0,void 0,(function*(){if(null==e.workspaceId)throw new h("workspaceId",'Required parameter "workspaceId" was null or undefined when calling validateWorkspaceWidgetDeletion().');if(null==e.validateWorkspaceWidgetDeletionRequest)throw new h("validateWorkspaceWidgetDeletionRequest",'Required parameter "validateWorkspaceWidgetDeletionRequest" was null or undefined when calling validateWorkspaceWidgetDeletion().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/workspaces/{workspaceId}/ab-tests/validate-widget-deletion".replace("{workspaceId}",encodeURIComponent(String(e.workspaceId))),method:"POST",headers:n,query:{},body:(s=e.validateWorkspaceWidgetDeletionRequest,o=s,null==o?o:{widget_id:o.widget_id})},t);var o,s;return new g(i,(e=>Lt(e)))}))}validateWorkspaceWidgetDeletion(e,t){return Vt(this,void 0,void 0,(function*(){const n=yield this.validateWorkspaceWidgetDeletionRaw(e,t);return yield n.value()}))}}var Ft="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class Ht extends u{analyticsEventsBulkPostRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.analyticsEventsBulkPostRequest)throw new h("analyticsEventsBulkPostRequest",'Required parameter "analyticsEventsBulkPostRequest" was null or undefined when calling analyticsEventsBulkPost().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/analytics/events/bulk",method:"POST",headers:n,query:{},body:K(e.analyticsEventsBulkPostRequest)},t);return new g(i,(e=>e.map(D)))}))}analyticsEventsBulkPost(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.analyticsEventsBulkPostRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsDailyGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsDailyGet().');const n={};null!=e.startDate&&(n.start_date=e.startDate.toISOString().substring(0,10)),null!=e.endDate&&(n.end_date=e.endDate.toISOString().substring(0,10)),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/daily".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(re)))}))}compositionsIdAnalyticsDailyGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsDailyGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsDashboardGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsDashboardGet().');const n={};null!=e.startDate&&(n.start_date=e.startDate.toISOString().substring(0,10)),null!=e.endDate&&(n.end_date=e.endDate.toISOString().substring(0,10)),null!=e.includeEvents&&(n.include_events=e.includeEvents);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/dashboard".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>P(e)))}))}compositionsIdAnalyticsDashboardGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsDashboardGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsDevicesGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsDevicesGet().');const n={};null!=e.startDate&&(n.start_date=e.startDate.toISOString().substring(0,10)),null!=e.endDate&&(n.end_date=e.endDate.toISOString().substring(0,10)),null!=e.deviceType&&(n.device_type=e.deviceType),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/devices".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(_)))}))}compositionsIdAnalyticsDevicesGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsDevicesGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsEventsGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsEventsGet().');const n={};null!=e.startDate&&(n.start_date=e.startDate.toISOString().substring(0,10)),null!=e.endDate&&(n.end_date=e.endDate.toISOString().substring(0,10)),null!=e.eventType&&(n.event_type=e.eventType),null!=e.userId&&(n.user_id=e.userId),null!=e.sessionId&&(n.session_id=e.sessionId),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/events".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(D)))}))}compositionsIdAnalyticsEventsGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsEventsGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsEventsPostRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsEventsPost().');if(null==e.newAnalyticsEvent)throw new h("newAnalyticsEvent",'Required parameter "newAnalyticsEvent" was null or undefined when calling compositionsIdAnalyticsEventsPost().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/analytics/events".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:W(e.newAnalyticsEvent)},t);return new g(i,(e=>D(e)))}))}compositionsIdAnalyticsEventsPost(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsEventsPostRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsGeographyGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsGeographyGet().');const n={};null!=e.startDate&&(n.start_date=e.startDate.toISOString().substring(0,10)),null!=e.endDate&&(n.end_date=e.endDate.toISOString().substring(0,10)),null!=e.country&&(n.country=e.country),null!=e.region&&(n.region=e.region),null!=e.city&&(n.city=e.city),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/geography".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(B)))}))}compositionsIdAnalyticsGeographyGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsGeographyGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsMonthlyGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsMonthlyGet().');const n={};null!=e.month&&(n.month=e.month),null!=e.year&&(n.year=e.year),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/monthly".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(Ye)))}))}compositionsIdAnalyticsMonthlyGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsMonthlyGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsReferrersGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsReferrersGet().');const n={};null!=e.startDate&&(n.start_date=e.startDate.toISOString().substring(0,10)),null!=e.endDate&&(n.end_date=e.endDate.toISOString().substring(0,10)),null!=e.source&&(n.source=e.source),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/referrers".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(U)))}))}compositionsIdAnalyticsReferrersGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsReferrersGetRaw(e,t);return yield n.value()}))}compositionsIdAnalyticsWeeklyGetRaw(e,t){return Ft(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling compositionsIdAnalyticsWeeklyGet().');const n={};null!=e.weekNumber&&(n.week_number=e.weekNumber),null!=e.year&&(n.year=e.year),null!=e.limit&&(n.limit=e.limit),null!=e.offset&&(n.offset=e.offset);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/analytics/weekly".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>e.map(Mt)))}))}compositionsIdAnalyticsWeeklyGet(e,t){return Ft(this,void 0,void 0,(function*(){const n=yield this.compositionsIdAnalyticsWeeklyGetRaw(e,t);return yield n.value()}))}flushAxiomEventsRaw(e){return Ft(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("bearerAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/analytics/axiom/flush",method:"POST",headers:t,query:{}},e);return new g(n,(e=>pt(e)))}))}flushAxiomEvents(e){return Ft(this,void 0,void 0,(function*(){const t=yield this.flushAxiomEventsRaw(e);return yield t.value()}))}getAxiomStatusRaw(e){return Ft(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("bearerAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/analytics/axiom/status",method:"GET",headers:t,query:{}},e);return new g(n,(e=>pt(e)))}))}getAxiomStatus(e){return Ft(this,void 0,void 0,(function*(){const t=yield this.getAxiomStatusRaw(e);return yield t.value()}))}}var Jt="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class Zt extends u{completeSignupRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.completeSignupRequest)throw new h("completeSignupRequest",'Required parameter "completeSignupRequest" was null or undefined when calling completeSignup().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/complete-signup",method:"POST",headers:n,query:{},body:(s=e.completeSignupRequest,o=s,null==o?o:{userId:o.userId,email:o.email,role:o.role,plan:o.plan,token:o.token})},t);var o,s;return new v(i)}))}completeSignup(e,t){return Jt(this,void 0,void 0,(function*(){yield this.completeSignupRaw(e,t)}))}confirmEmailRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.updateEmailRequest)throw new h("updateEmailRequest",'Required parameter "updateEmailRequest" was null or undefined when calling confirmEmail().');const n={"Content-Type":"application/json"},i=yield this.request({path:"/auth/confirm-email",method:"POST",headers:n,query:{},body:Tt(e.updateEmailRequest)},t);return new v(i)}))}confirmEmail(e,t){return Jt(this,void 0,void 0,(function*(){yield this.confirmEmailRaw(e,t)}))}consumeOAuthSessionBridgeRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.bridgeId)throw new h("bridgeId",'Required parameter "bridgeId" was null or undefined when calling consumeOAuthSessionBridge().');const n=yield this.request({path:"/auth/oauth-session/{bridgeId}".replace("{bridgeId}",encodeURIComponent(String(e.bridgeId))),method:"GET",headers:{},query:{}},t);return new v(n)}))}consumeOAuthSessionBridge(e,t){return Jt(this,void 0,void 0,(function*(){yield this.consumeOAuthSessionBridgeRaw(e,t)}))}deleteAccountRaw(e,t){return Jt(this,void 0,void 0,(function*(){const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/auth/delete-account",method:"POST",headers:n,query:{},body:(s=e.deleteAccountRequest,o=s,null==o?o:{password:o.password})},t);var o,s;return new v(i)}))}deleteAccount(){return Jt(this,arguments,void 0,(function*(e={},t){yield this.deleteAccountRaw(e,t)}))}getSessionRaw(e){return Jt(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("apiKeyAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/auth/session",method:"GET",headers:t,query:{}},e);return new v(n)}))}getSession(e){return Jt(this,void 0,void 0,(function*(){yield this.getSessionRaw(e)}))}getUserMetadataRaw(e){return Jt(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("apiKeyAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/auth/get-metadata",method:"GET",headers:t,query:{}},e);return new v(n)}))}getUserMetadata(e){return Jt(this,void 0,void 0,(function*(){yield this.getUserMetadataRaw(e)}))}initiateOAuthRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.provider)throw new h("provider",'Required parameter "provider" was null or undefined when calling initiateOAuth().');const n={};null!=e.redirectTo&&(n.redirectTo=e.redirectTo),null!=e.role&&(n.role=e.role),null!=e.plan&&(n.plan=e.plan);const i=yield this.request({path:"/auth/oauth/{provider}".replace("{provider}",encodeURIComponent(String(e.provider))),method:"GET",headers:{},query:n},t);return new v(i)}))}initiateOAuth(e,t){return Jt(this,void 0,void 0,(function*(){yield this.initiateOAuthRaw(e,t)}))}loginUserRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.loginUserRequest)throw new h("loginUserRequest",'Required parameter "loginUserRequest" was null or undefined when calling loginUser().');const n={"Content-Type":"application/json"},i=yield this.request({path:"/auth/login",method:"POST",headers:n,query:{},body:(s=e.loginUserRequest,o=s,null==o?o:{email:o.email,password:o.password})},t);var o,s;return new g(i,(e=>et(e)))}))}loginUser(e,t){return Jt(this,void 0,void 0,(function*(){const n=yield this.loginUserRaw(e,t);return yield n.value()}))}logoutUserRaw(e){return Jt(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("apiKeyAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/auth/logout",method:"POST",headers:t,query:{}},e);return new v(n)}))}logoutUser(e){return Jt(this,void 0,void 0,(function*(){yield this.logoutUserRaw(e)}))}refreshSessionRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.refreshSessionRequest)throw new h("refreshSessionRequest",'Required parameter "refreshSessionRequest" was null or undefined when calling refreshSession().');const n={"Content-Type":"application/json"},i=yield this.request({path:"/auth/refresh",method:"POST",headers:n,query:{},body:(s=e.refreshSessionRequest,o=s,null==o?o:{refresh_token:o.refresh_token})},t);var o,s;return new v(i)}))}refreshSession(e,t){return Jt(this,void 0,void 0,(function*(){yield this.refreshSessionRaw(e,t)}))}resendConfirmationRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.resetPasswordRequest)throw new h("resetPasswordRequest",'Required parameter "resetPasswordRequest" was null or undefined when calling resendConfirmation().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/resend-confirmation",method:"POST",headers:n,query:{},body:it(e.resetPasswordRequest)},t);return new v(i)}))}resendConfirmation(e,t){return Jt(this,void 0,void 0,(function*(){yield this.resendConfirmationRaw(e,t)}))}resetPasswordRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.resetPasswordRequest)throw new h("resetPasswordRequest",'Required parameter "resetPasswordRequest" was null or undefined when calling resetPassword().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/reset-password",method:"POST",headers:n,query:{},body:it(e.resetPasswordRequest)},t);return new v(i)}))}resetPassword(e,t){return Jt(this,void 0,void 0,(function*(){yield this.resetPasswordRaw(e,t)}))}signupUserRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.signupUserRequest)throw new h("signupUserRequest",'Required parameter "signupUserRequest" was null or undefined when calling signupUser().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/signup",method:"POST",headers:n,query:{},body:(s=e.signupUserRequest,o=s,null==o?o:{email:o.email,password:o.password,role:o.role,plan:o.plan,inviteCode:o.inviteCode,name:o.name,returnTo:o.returnTo})},t);var o,s;return new v(i)}))}signupUser(e,t){return Jt(this,void 0,void 0,(function*(){yield this.signupUserRaw(e,t)}))}signupWithInvitationRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.signupWithInvitationRequest)throw new h("signupWithInvitationRequest",'Required parameter "signupWithInvitationRequest" was null or undefined when calling signupWithInvitation().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/signup-with-invitation",method:"POST",headers:n,query:{},body:(s=e.signupWithInvitationRequest,o=s,null==o?o:{email:o.email,password:o.password,role:o.role,plan:o.plan,invitationId:o.invitationId,organizationId:o.organizationId})},t);var o,s;return new v(i)}))}signupWithInvitation(e,t){return Jt(this,void 0,void 0,(function*(){yield this.signupWithInvitationRaw(e,t)}))}updateEmailRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.updateEmailRequest)throw new h("updateEmailRequest",'Required parameter "updateEmailRequest" was null or undefined when calling updateEmail().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/update-email",method:"POST",headers:n,query:{},body:Tt(e.updateEmailRequest)},t);return new v(i)}))}updateEmail(e,t){return Jt(this,void 0,void 0,(function*(){yield this.updateEmailRaw(e,t)}))}updateNameRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.updateNameRequest)throw new h("updateNameRequest",'Required parameter "updateNameRequest" was null or undefined when calling updateName().');const n={"Content-Type":"application/json"},i=yield this.request({path:"/auth/update-name",method:"POST",headers:n,query:{},body:(s=e.updateNameRequest,o=s,null==o?o:{token:o.token,name:o.name})},t);var o,s;return new v(i)}))}updateName(e,t){return Jt(this,void 0,void 0,(function*(){yield this.updateNameRaw(e,t)}))}updatePasswordRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.updatePasswordRequest)throw new h("updatePasswordRequest",'Required parameter "updatePasswordRequest" was null or undefined when calling updatePassword().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/auth/update-password",method:"POST",headers:n,query:{},body:(s=e.updatePasswordRequest,o=s,null==o?o:{token:o.token,email:o.email,password:o.password})},t);var o,s;return new v(i)}))}updatePassword(e,t){return Jt(this,void 0,void 0,(function*(){yield this.updatePasswordRaw(e,t)}))}updateUserMetadataRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.updateUserMetadataRequest)throw new h("updateUserMetadataRequest",'Required parameter "updateUserMetadataRequest" was null or undefined when calling updateUserMetadata().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/auth/update-metadata",method:"POST",headers:n,query:{},body:(s=e.updateUserMetadataRequest,o=s,null==o?o:{metadata:o.metadata})},t);var o,s;return new v(i)}))}updateUserMetadata(e,t){return Jt(this,void 0,void 0,(function*(){yield this.updateUserMetadataRaw(e,t)}))}validateInviteCodeRaw(e,t){return Jt(this,void 0,void 0,(function*(){if(null==e.code)throw new h("code",'Required parameter "code" was null or undefined when calling validateInviteCode().');const n={};null!=e.code&&(n.code=e.code);const i=yield this.request({path:"/auth/invite-code",method:"GET",headers:{},query:n},t);return new g(i,(e=>Et(e)))}))}validateInviteCode(e,t){return Jt(this,void 0,void 0,(function*(){const n=yield this.validateInviteCodeRaw(e,t);return yield n.value()}))}}var Qt="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class Xt extends u{checkCompositionAccessRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling checkCompositionAccess().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/access".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>z(e)))}))}checkCompositionAccess(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.checkCompositionAccessRaw(e,t);return yield n.value()}))}createCompositionContentItemRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling createCompositionContentItem().');if(null==e.list)throw new h("list",'Required parameter "list" was null or undefined when calling createCompositionContentItem().');if(null==e.createCompositionContentItemRequest)throw new h("createCompositionContentItemRequest",'Required parameter "createCompositionContentItemRequest" was null or undefined when calling createCompositionContentItem().');const n={"Content-Type":"application/json"};if(null!=e.ifMatch&&(n["If-Match"]=String(e.ifMatch)),null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/content/{list}/items".replace("{id}",encodeURIComponent(String(e.id))).replace("{list}",encodeURIComponent(String(e.list))),method:"POST",headers:n,query:{},body:Q(e.createCompositionContentItemRequest)},t);return new v(i)}))}createCompositionContentItem(e,t){return Qt(this,void 0,void 0,(function*(){yield this.createCompositionContentItemRaw(e,t)}))}createCompositionDatabaseRecordRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling createCompositionDatabaseRecord().');if(null==e.table)throw new h("table",'Required parameter "table" was null or undefined when calling createCompositionDatabaseRecord().');if(null==e.body)throw new h("body",'Required parameter "body" was null or undefined when calling createCompositionDatabaseRecord().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/database/{table}".replace("{id}",encodeURIComponent(String(e.id))).replace("{table}",encodeURIComponent(String(e.table))),method:"POST",headers:n,query:{},body:e.body},t);return new v(i)}))}createCompositionDatabaseRecord(e,t){return Qt(this,void 0,void 0,(function*(){yield this.createCompositionDatabaseRecordRaw(e,t)}))}createCompositionRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.newComposition)throw new h("newComposition",'Required parameter "newComposition" was null or undefined when calling createComposition().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions",method:"POST",headers:n,query:{},body:(s=e.newComposition,o=s,null==o?o:{name:o.name,widgetId:o.widgetId,creatorId:o.creatorId,content:o.content,status:o.status,embedSettings:o.embedSettings,design:o.design,databaseSchema:o.databaseSchema,projectId:o.projectId,managedUserId:o.managedUserId,managedUserExternalId:o.managedUserExternalId})},t);var o,s;return new g(i,(e=>X(e)))}))}createComposition(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.createCompositionRaw(e,t);return yield n.value()}))}deleteCompositionContentItemRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling deleteCompositionContentItem().');if(null==e.list)throw new h("list",'Required parameter "list" was null or undefined when calling deleteCompositionContentItem().');if(null==e.itemId)throw new h("itemId",'Required parameter "itemId" was null or undefined when calling deleteCompositionContentItem().');const n={};if(null!=e.ifMatch&&(n["If-Match"]=String(e.ifMatch)),null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/content/{list}/items/{itemId}".replace("{id}",encodeURIComponent(String(e.id))).replace("{list}",encodeURIComponent(String(e.list))).replace("{itemId}",encodeURIComponent(String(e.itemId))),method:"DELETE",headers:n,query:{}},t);return new g(i,(e=>ae(e)))}))}deleteCompositionContentItem(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.deleteCompositionContentItemRaw(e,t);return yield n.value()}))}deleteCompositionDataSourceRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling deleteCompositionDataSource().');const n={};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/data-source".replace("{id}",encodeURIComponent(String(e.id))),method:"DELETE",headers:n,query:{}},t);return new v(i)}))}deleteCompositionDataSource(e,t){return Qt(this,void 0,void 0,(function*(){yield this.deleteCompositionDataSourceRaw(e,t)}))}deleteCompositionDatabaseRecordRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling deleteCompositionDatabaseRecord().');if(null==e.table)throw new h("table",'Required parameter "table" was null or undefined when calling deleteCompositionDatabaseRecord().');if(null==e.recordId)throw new h("recordId",'Required parameter "recordId" was null or undefined when calling deleteCompositionDatabaseRecord().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/database/{table}/{recordId}".replace("{id}",encodeURIComponent(String(e.id))).replace("{table}",encodeURIComponent(String(e.table))).replace("{recordId}",encodeURIComponent(String(e.recordId))),method:"DELETE",headers:n,query:{}},t);return new v(i)}))}deleteCompositionDatabaseRecord(e,t){return Qt(this,void 0,void 0,(function*(){yield this.deleteCompositionDatabaseRecordRaw(e,t)}))}deleteCompositionRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling deleteComposition().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"DELETE",headers:n,query:{}},t);return new v(i)}))}deleteComposition(e,t){return Qt(this,void 0,void 0,(function*(){yield this.deleteCompositionRaw(e,t)}))}describeCompositionEntriesRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling describeCompositionEntries().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/entries".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>M(e)))}))}describeCompositionEntries(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.describeCompositionEntriesRaw(e,t);return yield n.value()}))}duplicateCompositionRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling duplicateComposition().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/duplicate".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.duplicateCompositionRequest,o=s,null==o?o:{name:o.name,includeDatabase:o.includeDatabase})},t);var o,s;return new g(i,(e=>ce(e)))}))}duplicateComposition(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.duplicateCompositionRaw(e,t);return yield n.value()}))}getAllCompositionsRaw(e,t){return Qt(this,void 0,void 0,(function*(){const n={};null!=e.page&&(n.page=e.page),null!=e.size&&(n.size=e.size),null!=e.sort&&(n.sort=e.sort),null!=e.widgetId&&(n.widget_id=e.widgetId),null!=e.workspace&&(n.workspace=e.workspace),null!=e.projectFolder&&(n.project_folder=e.projectFolder),null!=e.status&&(n.status=e.status),null!=e.include&&(n.include=e.include),null!=e.managedUserId&&(n.managedUserId=e.managedUserId),null!=e.managedUserExternalId&&(n.managedUserExternalId=e.managedUserExternalId);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions",method:"GET",headers:i,query:n},t);return new g(o,(e=>we(e)))}))}getAllCompositions(){return Qt(this,arguments,void 0,(function*(e={},t){const n=yield this.getAllCompositionsRaw(e,t);return yield n.value()}))}getCompositionByIdRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionById().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>X(e)))}))}getCompositionById(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionByIdRaw(e,t);return yield n.value()}))}getCompositionContentSchemaRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionContentSchema().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/schema/content".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>qe(e)))}))}getCompositionContentSchema(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionContentSchemaRaw(e,t);return yield n.value()}))}getCompositionContentRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionContent().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/content".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i)}))}getCompositionContent(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionContentRaw(e,t);return yield n.value()}))}getCompositionDataSourceRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionDataSource().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/data-source".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new v(i)}))}getCompositionDataSource(e,t){return Qt(this,void 0,void 0,(function*(){yield this.getCompositionDataSourceRaw(e,t)}))}getCompositionDatabaseRecordRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionDatabaseRecord().');if(null==e.table)throw new h("table",'Required parameter "table" was null or undefined when calling getCompositionDatabaseRecord().');if(null==e.recordId)throw new h("recordId",'Required parameter "recordId" was null or undefined when calling getCompositionDatabaseRecord().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/database/{table}/{recordId}".replace("{id}",encodeURIComponent(String(e.id))).replace("{table}",encodeURIComponent(String(e.table))).replace("{recordId}",encodeURIComponent(String(e.recordId))),method:"GET",headers:n,query:{}},t);return new v(i)}))}getCompositionDatabaseRecord(e,t){return Qt(this,void 0,void 0,(function*(){yield this.getCompositionDatabaseRecordRaw(e,t)}))}getCompositionDatabaseRecordsRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionDatabaseRecords().');if(null==e.table)throw new h("table",'Required parameter "table" was null or undefined when calling getCompositionDatabaseRecords().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/database/{table}".replace("{id}",encodeURIComponent(String(e.id))).replace("{table}",encodeURIComponent(String(e.table))),method:"GET",headers:n,query:{}},t);return new v(i)}))}getCompositionDatabaseRecords(e,t){return Qt(this,void 0,void 0,(function*(){yield this.getCompositionDatabaseRecordsRaw(e,t)}))}getCompositionDesignSchemaRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionDesignSchema().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/schema/design".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>Ce(e)))}))}getCompositionDesignSchema(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionDesignSchemaRaw(e,t);return yield n.value()}))}getCompositionDesignRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionDesign().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/design".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i)}))}getCompositionDesign(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionDesignRaw(e,t);return yield n.value()}))}getCompositionEmbedSchemaRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionEmbedSchema().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/schema/embed".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>ke(e)))}))}getCompositionEmbedSchema(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionEmbedSchemaRaw(e,t);return yield n.value()}))}getCompositionEmbedSettingsRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionEmbedSettings().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/embed-settings".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i)}))}getCompositionEmbedSettings(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionEmbedSettingsRaw(e,t);return yield n.value()}))}getCompositionPreviewRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionPreview().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/preview".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>Ae(e)))}))}getCompositionPreview(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionPreviewRaw(e,t);return yield n.value()}))}getCompositionVersionsRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getCompositionVersions().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/versions".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>be(e)))}))}getCompositionVersions(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionVersionsRaw(e,t);return yield n.value()}))}getCompositionsBatchRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.getCompositionsBatchRequest)throw new h("getCompositionsBatchRequest",'Required parameter "getCompositionsBatchRequest" was null or undefined when calling getCompositionsBatch().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/batch",method:"POST",headers:n,query:{},body:(s=e.getCompositionsBatchRequest,o=s,null==o?o:{compositionIds:o.compositionIds})},t);var o,s;return new g(i,(e=>Be(e)))}))}getCompositionsBatch(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.getCompositionsBatchRaw(e,t);return yield n.value()}))}patchCompositionContentItemRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling patchCompositionContentItem().');if(null==e.list)throw new h("list",'Required parameter "list" was null or undefined when calling patchCompositionContentItem().');if(null==e.itemId)throw new h("itemId",'Required parameter "itemId" was null or undefined when calling patchCompositionContentItem().');if(null==e.requestBody)throw new h("requestBody",'Required parameter "requestBody" was null or undefined when calling patchCompositionContentItem().');const n={"Content-Type":"application/json"};if(null!=e.ifMatch&&(n["If-Match"]=String(e.ifMatch)),null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/content/{list}/items/{itemId}".replace("{id}",encodeURIComponent(String(e.id))).replace("{list}",encodeURIComponent(String(e.list))).replace("{itemId}",encodeURIComponent(String(e.itemId))),method:"PATCH",headers:n,query:{},body:e.requestBody},t);return new v(i)}))}patchCompositionContentItem(e,t){return Qt(this,void 0,void 0,(function*(){yield this.patchCompositionContentItemRaw(e,t)}))}readCompositionEntriesRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling readCompositionEntries().');if(null==e.table)throw new h("table",'Required parameter "table" was null or undefined when calling readCompositionEntries().');const n={};null!=e.groupBy&&(n.groupBy=e.groupBy),null!=e.rows&&(n.rows=e.rows),null!=e.aggregate&&(n.aggregate=e.aggregate),null!=e.column&&(n.column=e.column),null!=e.since&&(n.since=e.since.toISOString()),null!=e.until&&(n.until=e.until.toISOString()),null!=e.context&&(n.context=e.context),null!=e.filter&&(n.filter=e.filter);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/compositions/{id}/entries/{table}".replace("{id}",encodeURIComponent(String(e.id))).replace("{table}",encodeURIComponent(String(e.table))),method:"GET",headers:i,query:n},t);return new g(o,(e=>N(e)))}))}readCompositionEntries(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.readCompositionEntriesRaw(e,t);return yield n.value()}))}setCompositionDataSourceRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling setCompositionDataSource().');if(null==e.setCompositionDataSourceRequest)throw new h("setCompositionDataSourceRequest",'Required parameter "setCompositionDataSourceRequest" was null or undefined when calling setCompositionDataSource().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/data-source".replace("{id}",encodeURIComponent(String(e.id))),method:"PUT",headers:n,query:{},body:(s=e.setCompositionDataSourceRequest,o=s,null==o?o:{url:o.url,refresh_seconds:o.refresh_seconds})},t);var o,s;return new v(i)}))}setCompositionDataSource(e,t){return Qt(this,void 0,void 0,(function*(){yield this.setCompositionDataSourceRaw(e,t)}))}setDynamicContentRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling setDynamicContent().');if(null==e.setDynamicContentRequest)throw new h("setDynamicContentRequest",'Required parameter "setDynamicContentRequest" was null or undefined when calling setDynamicContent().');const n={"Content-Type":"application/json"};if(null!=e.ifMatch&&(n["If-Match"]=String(e.ifMatch)),null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/content".replace("{id}",encodeURIComponent(String(e.id))),method:"PUT",headers:n,query:{},body:(s=e.setDynamicContentRequest,o=s,null==o?o:{content:o.content,validate:o.validate,partial:o.partial,version:o.version,source:o.source})},t);var o,s;return new g(i,(e=>st(e)))}))}setDynamicContent(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.setDynamicContentRaw(e,t);return yield n.value()}))}updateCompositionDatabaseRecordRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling updateCompositionDatabaseRecord().');if(null==e.table)throw new h("table",'Required parameter "table" was null or undefined when calling updateCompositionDatabaseRecord().');if(null==e.recordId)throw new h("recordId",'Required parameter "recordId" was null or undefined when calling updateCompositionDatabaseRecord().');if(null==e.body)throw new h("body",'Required parameter "body" was null or undefined when calling updateCompositionDatabaseRecord().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/database/{table}/{recordId}".replace("{id}",encodeURIComponent(String(e.id))).replace("{table}",encodeURIComponent(String(e.table))).replace("{recordId}",encodeURIComponent(String(e.recordId))),method:"PUT",headers:n,query:{},body:e.body},t);return new v(i)}))}updateCompositionDatabaseRecord(e,t){return Qt(this,void 0,void 0,(function*(){yield this.updateCompositionDatabaseRecordRaw(e,t)}))}updateCompositionStatusRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling updateCompositionStatus().');if(null==e.updateCompositionStatusRequest)throw new h("updateCompositionStatusRequest",'Required parameter "updateCompositionStatusRequest" was null or undefined when calling updateCompositionStatus().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/status".replace("{id}",encodeURIComponent(String(e.id))),method:"PUT",headers:n,query:{},body:(s=e.updateCompositionStatusRequest,o=s,null==o?o:{status:o.status})},t);var o,s;return new g(i,(e=>$(e)))}))}updateCompositionStatus(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.updateCompositionStatusRaw(e,t);return yield n.value()}))}updateCompositionRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling updateComposition().');if(null==e.updateComposition)throw new h("updateComposition",'Required parameter "updateComposition" was null or undefined when calling updateComposition().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"PUT",headers:n,query:{},body:(s=e.updateComposition,o=s,null==o?o:{name:o.name,widgetId:o.widgetId,content:o.content,status:o.status,embedSettings:o.embedSettings,design:o.design,projectId:o.projectId})},t);var o,s;return new g(i,(e=>X(e)))}))}updateComposition(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.updateCompositionRaw(e,t);return yield n.value()}))}validateCompositionContentRaw(e,t){return Qt(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling validateCompositionContent().');if(null==e.body)throw new h("body",'Required parameter "body" was null or undefined when calling validateCompositionContent().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/compositions/{id}/content/validate".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:e.body},t);return new g(i,(e=>St(e)))}))}validateCompositionContent(e,t){return Qt(this,void 0,void 0,(function*(){const n=yield this.validateCompositionContentRaw(e,t);return yield n.value()}))}}var Yt="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class en extends u{exchangeTokenRaw(e,t){return Yt(this,void 0,void 0,(function*(){if(null==e.exchangeTokenRequest)throw new h("exchangeTokenRequest",'Required parameter "exchangeTokenRequest" was null or undefined when calling exchangeToken().');const n={"Content-Type":"application/json"};this.configuration&&this.configuration.apiKey&&(n.Authorization=yield this.configuration.apiKey("Authorization"));const i=yield this.request({path:"/tokens/exchange",method:"POST",headers:n,query:{},body:(s=e.exchangeTokenRequest,o=s,null==o?o:{scopes:o.scopes,expiresIn:o.expiresIn})},t);var o,s;return new g(i,(e=>fe(e)))}))}exchangeToken(e,t){return Yt(this,void 0,void 0,(function*(){const n=yield this.exchangeTokenRaw(e,t);return yield n.value()}))}validateTokenRaw(e){return Yt(this,void 0,void 0,(function*(){const t={};if(this.configuration&&this.configuration.apiKey&&(t.Authorization=yield this.configuration.apiKey("Authorization")),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,n=yield e("BearerAuth",[]);n&&(t.Authorization=`Bearer ${n}`)}const n=yield this.request({path:"/tokens/validate",method:"GET",headers:t,query:{}},e);return new g(n,(e=>Dt(e)))}))}validateToken(e){return Yt(this,void 0,void 0,(function*(){const t=yield this.validateTokenRaw(e);return yield t.value()}))}}var tn="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class nn extends u{addLanguagesToTranslationRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling addLanguagesToTranslation().');if(null==e.addLanguagesToTranslationRequest)throw new h("addLanguagesToTranslationRequest",'Required parameter "addLanguagesToTranslationRequest" was null or undefined when calling addLanguagesToTranslation().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations/{id}/languages".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.addLanguagesToTranslationRequest,o=s,null==o?o:{languages:o.languages})},t);var o,s;return new g(i,(e=>S(e)))}))}addLanguagesToTranslation(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.addLanguagesToTranslationRaw(e,t);return yield n.value()}))}createTranslationRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.createTranslationRequest)throw new h("createTranslationRequest",'Required parameter "createTranslationRequest" was null or undefined when calling createTranslation().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations",method:"POST",headers:n,query:{},body:(s=e.createTranslationRequest,o=s,null==o?o:{name:o.name,description:o.description,root_composition_id:o.root_composition_id,root_language:o.root_language,selected_languages:o.selected_languages})},t);var o,s;return new g(i,(e=>Y(e)))}))}createTranslation(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.createTranslationRaw(e,t);return yield n.value()}))}deleteTranslationRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling deleteTranslation().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"DELETE",headers:n,query:{}},t);return new g(i,(e=>bt(e)))}))}deleteTranslation(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.deleteTranslationRaw(e,t);return yield n.value()}))}getLanguagePresetsRaw(e){return tn(this,void 0,void 0,(function*(){const t=yield this.request({path:"/translations/language-presets",method:"GET",headers:{},query:{}},e);return new g(t,(e=>_e(e)))}))}getLanguagePresets(e){return tn(this,void 0,void 0,(function*(){const t=yield this.getLanguagePresetsRaw(e);return yield t.value()}))}getSupportedLanguagesRaw(e){return tn(this,void 0,void 0,(function*(){const t=yield this.request({path:"/translations/supported-languages",method:"GET",headers:{},query:{}},e);return new g(t,(e=>Pe(e)))}))}getSupportedLanguages(e){return tn(this,void 0,void 0,(function*(){const t=yield this.getSupportedLanguagesRaw(e);return yield t.value()}))}getTranslationRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getTranslation().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>We(e)))}))}getTranslation(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.getTranslationRaw(e,t);return yield n.value()}))}getTranslationAnalyticsRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getTranslationAnalytics().');const n={};null!=e.period&&(n.period=e.period);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/translations/{id}/analytics".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:i,query:n},t);return new g(o,(e=>xe(e)))}))}getTranslationAnalytics(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.getTranslationAnalyticsRaw(e,t);return yield n.value()}))}getTranslationConfigRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getTranslationConfig().');const n=yield this.request({path:"/translations/{id}/config".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:{},query:{}},t);return new g(n,(e=>$e(e)))}))}getTranslationConfig(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.getTranslationConfigRaw(e,t);return yield n.value()}))}getTranslationsRaw(e,t){return tn(this,void 0,void 0,(function*(){const n={};null!=e.status&&(n.status=e.status);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/translations",method:"GET",headers:i,query:n},t);return new g(o,(e=>Ge(e)))}))}getTranslations(){return tn(this,arguments,void 0,(function*(e={},t){const n=yield this.getTranslationsRaw(e,t);return yield n.value()}))}removeLanguageFromTranslationRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling removeLanguageFromTranslation().');if(null==e.languageCode)throw new h("languageCode",'Required parameter "languageCode" was null or undefined when calling removeLanguageFromTranslation().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations/{id}/languages/{languageCode}".replace("{id}",encodeURIComponent(String(e.id))).replace("{languageCode}",encodeURIComponent(String(e.languageCode))),method:"DELETE",headers:n,query:{}},t);return new g(i,(e=>S(e)))}))}removeLanguageFromTranslation(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.removeLanguageFromTranslationRaw(e,t);return yield n.value()}))}retranslateExperimentRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling retranslateExperiment().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations/{id}/retranslate".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.retranslateExperimentRequest,o=s,null==o?o:{languages:o.languages})},t);var o,s;return new g(i,(e=>bt(e)))}))}retranslateExperiment(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.retranslateExperimentRaw(e,t);return yield n.value()}))}submitTranslationAnalyticsEventRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling submitTranslationAnalyticsEvent().');if(null==e.submitTranslationAnalyticsEventRequest)throw new h("submitTranslationAnalyticsEventRequest",'Required parameter "submitTranslationAnalyticsEventRequest" was null or undefined when calling submitTranslationAnalyticsEvent().');const n={"Content-Type":"application/json"};null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey));const i=yield this.request({path:"/translations/{id}/analytics/events".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.submitTranslationAnalyticsEventRequest,o=s,null==o?o:{eventType:o.eventType,language:o.language,compositionId:o.compositionId,metadata:o.metadata})},t);var o,s;return new v(i)}))}submitTranslationAnalyticsEvent(e,t){return tn(this,void 0,void 0,(function*(){yield this.submitTranslationAnalyticsEventRaw(e,t)}))}updateTranslationStatusRaw(e,t){return tn(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling updateTranslationStatus().');if(null==e.updateTranslationStatusRequest)throw new h("updateTranslationStatusRequest",'Required parameter "updateTranslationStatusRequest" was null or undefined when calling updateTranslationStatus().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("BearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/translations/{id}/status".replace("{id}",encodeURIComponent(String(e.id))),method:"PUT",headers:n,query:{},body:(s=e.updateTranslationStatusRequest,o=s,null==o?o:{status:o.status})},t);var o,s;return new g(i,(e=>S(e)))}))}updateTranslationStatus(e,t){return tn(this,void 0,void 0,(function*(){const n=yield this.updateTranslationStatusRaw(e,t);return yield n.value()}))}}var on="undefined"!=typeof window&&window.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))};class sn extends u{checkWidgetAccessRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling checkWidgetAccess().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/access".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>O(e)))}))}checkWidgetAccess(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.checkWidgetAccessRaw(e,t);return yield n.value()}))}createCompositionFromWidgetRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling createCompositionFromWidget().');if(null==e.createCompositionFromWidgetRequest)throw new h("createCompositionFromWidgetRequest",'Required parameter "createCompositionFromWidgetRequest" was null or undefined when calling createCompositionFromWidget().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/composition".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.createCompositionFromWidgetRequest,o=s,null==o?o:{name:o.name,content:o.content,design:o.design,embed_settings:o.embed_settings,locale:o.locale,managed_user_id:o.managed_user_id})},t);var o,s;return new g(i,(e=>X(e)))}))}createCompositionFromWidget(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.createCompositionFromWidgetRaw(e,t);return yield n.value()}))}createWidgetRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.newWidget)throw new h("newWidget",'Required parameter "newWidget" was null or undefined when calling createWidget().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets",method:"POST",headers:n,query:{},body:(s=e.newWidget,o=s,null==o?o:{name:o.name,type:o.type,content:o.content,isPublic:o.isPublic,isDraft:o.isDraft,canvasId:o.canvasId,projectId:o.projectId,organizationId:o.organizationId,workspaceType:o.workspaceType,managedUserId:o.managedUserId,managedUserExternalId:o.managedUserExternalId})},t);var o,s;return new g(i,(e=>oe(e)))}))}createWidget(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.createWidgetRaw(e,t);return yield n.value()}))}deleteWidgetRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling deleteWidget().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("bearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"DELETE",headers:n,query:{},body:(s=e.deleteWidgetRequest,o=s,null==o?o:{reason:o.reason})},t);var o,s;return new v(i)}))}deleteWidget(e,t){return on(this,void 0,void 0,(function*(){yield this.deleteWidgetRaw(e,t)}))}detachWidgetRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling detachWidget().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/detach".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{}},t);return new v(i)}))}detachWidget(e,t){return on(this,void 0,void 0,(function*(){yield this.detachWidgetRaw(e,t)}))}duplicateWidgetRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling duplicateWidget().');const n={"Content-Type":"application/json"};if(null!=e.idempotencyKey&&(n["Idempotency-Key"]=String(e.idempotencyKey)),this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("bearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/duplicate".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.duplicateWidgetRequest,o=s,null==o?o:{name:o.name,canvas_id:o.canvas_id,managedUserId:o.managedUserId,managedUserExternalId:o.managedUserExternalId})},t);var o,s;return new g(i,(e=>he(e)))}))}duplicateWidget(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.duplicateWidgetRaw(e,t);return yield n.value()}))}getWidgetContentSchemaRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getWidgetContentSchema().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/schema/content".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i)}))}getWidgetContentSchema(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.getWidgetContentSchemaRaw(e,t);return yield n.value()}))}getWidgetDesignSchemaRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling getWidgetDesignSchema().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/schema/design".replace("{id}",encodeURIComponent(String(e.id))),method:"GET",headers:n,query:{}},t);return new g(i)}))}getWidgetDesignSchema(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.getWidgetDesignSchemaRaw(e,t);return yield n.value()}))}getWidgetPublishHistoryRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.widgetId)throw new h("widgetId",'Required parameter "widgetId" was null or undefined when calling getWidgetPublishHistory().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("bearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{widgetId}/publish-history".replace("{widgetId}",encodeURIComponent(String(e.widgetId))),method:"GET",headers:n,query:{}},t);return new g(i,(e=>Ve(e)))}))}getWidgetPublishHistory(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.getWidgetPublishHistoryRaw(e,t);return yield n.value()}))}getWidgetsBatchRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.getWidgetsBatchRequest)throw new h("getWidgetsBatchRequest",'Required parameter "getWidgetsBatchRequest" was null or undefined when calling getWidgetsBatch().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/batch",method:"POST",headers:n,query:{},body:(s=e.getWidgetsBatchRequest,o=s,null==o?o:{widgetIds:o.widgetIds})},t);var o,s;return new g(i,(e=>He(e)))}))}getWidgetsBatch(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.getWidgetsBatchRaw(e,t);return yield n.value()}))}getWidgetsRaw(e,t){return on(this,void 0,void 0,(function*(){const n={};null!=e.page&&(n.page=e.page),null!=e.size&&(n.size=e.size),null!=e.canvasId&&(n.canvasId=e.canvasId),null!=e.managedUserId&&(n.managedUserId=e.managedUserId),null!=e.managedUserExternalId&&(n.managedUserExternalId=e.managedUserExternalId);const i={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(i.Authorization=`Bearer ${t}`)}const o=yield this.request({path:"/widgets",method:"GET",headers:i,query:n},t);return new g(o,(e=>Fe(e)))}))}getWidgets(){return on(this,arguments,void 0,(function*(e={},t){const n=yield this.getWidgetsRaw(e,t);return yield n.value()}))}renameWidgetPublishHistoryTitleRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.widgetId)throw new h("widgetId",'Required parameter "widgetId" was null or undefined when calling renameWidgetPublishHistoryTitle().');if(null==e.version)throw new h("version",'Required parameter "version" was null or undefined when calling renameWidgetPublishHistoryTitle().');if(null==e.renameWidgetPublishHistoryTitleRequest)throw new h("renameWidgetPublishHistoryTitleRequest",'Required parameter "renameWidgetPublishHistoryTitleRequest" was null or undefined when calling renameWidgetPublishHistoryTitle().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("bearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{widgetId}/publish-history/{version}/title".replace("{widgetId}",encodeURIComponent(String(e.widgetId))).replace("{version}",encodeURIComponent(String(e.version))),method:"PATCH",headers:n,query:{},body:(s=e.renameWidgetPublishHistoryTitleRequest,o=s,null==o?o:{commitTitle:o.commitTitle})},t);var o,s;return new g(i,(e=>nt(e)))}))}renameWidgetPublishHistoryTitle(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.renameWidgetPublishHistoryTitleRaw(e,t);return yield n.value()}))}setWidgetPublishHistoryLiveRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.widgetId)throw new h("widgetId",'Required parameter "widgetId" was null or undefined when calling setWidgetPublishHistoryLive().');if(null==e.version)throw new h("version",'Required parameter "version" was null or undefined when calling setWidgetPublishHistoryLive().');const n={};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("bearerAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{widgetId}/publish-history/{version}/set-live".replace("{widgetId}",encodeURIComponent(String(e.widgetId))).replace("{version}",encodeURIComponent(String(e.version))),method:"POST",headers:n,query:{}},t);return new g(i,(e=>dt(e)))}))}setWidgetPublishHistoryLive(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.setWidgetPublishHistoryLiveRaw(e,t);return yield n.value()}))}updateWidgetRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling updateWidget().');if(null==e.updateWidgetRequest)throw new h("updateWidgetRequest",'Required parameter "updateWidgetRequest" was null or undefined when calling updateWidget().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}".replace("{id}",encodeURIComponent(String(e.id))),method:"PATCH",headers:n,query:{},body:(s=e.updateWidgetRequest,o=s,null==o?o:{name:o.name,description:o.description,canvasId:o.canvasId,projectId:o.projectId,projectFolder:o.projectFolder})},t);var o,s;return new v(i)}))}updateWidget(e,t){return on(this,void 0,void 0,(function*(){yield this.updateWidgetRaw(e,t)}))}updateWidgetRepositoryRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling updateWidgetRepository().');if(null==e.updateWidgetRepositoryRequest)throw new h("updateWidgetRepositoryRequest",'Required parameter "updateWidgetRepositoryRequest" was null or undefined when calling updateWidgetRepository().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/repository".replace("{id}",encodeURIComponent(String(e.id))),method:"PUT",headers:n,query:{},body:(s=e.updateWidgetRepositoryRequest,o=s,null==o?o:{repositoryId:o.repositoryId})},t);var o,s;return new g(i,(e=>Ct(e)))}))}updateWidgetRepository(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.updateWidgetRepositoryRaw(e,t);return yield n.value()}))}uploadWidgetThumbnailRaw(e,t){return on(this,void 0,void 0,(function*(){if(null==e.id)throw new h("id",'Required parameter "id" was null or undefined when calling uploadWidgetThumbnail().');if(null==e.uploadWidgetThumbnailRequest)throw new h("uploadWidgetThumbnailRequest",'Required parameter "uploadWidgetThumbnailRequest" was null or undefined when calling uploadWidgetThumbnail().');const n={"Content-Type":"application/json"};if(this.configuration&&this.configuration.accessToken){const e=this.configuration.accessToken,t=yield e("apiKeyAuth",[]);t&&(n.Authorization=`Bearer ${t}`)}const i=yield this.request({path:"/widgets/{id}/thumbnail".replace("{id}",encodeURIComponent(String(e.id))),method:"POST",headers:n,query:{},body:(s=e.uploadWidgetThumbnailRequest,o=s,null==o?o:{imageDataUrl:o.imageDataUrl})},t);var o,s;return new g(i,(e=>At(e)))}))}uploadWidgetThumbnail(e,t){return on(this,void 0,void 0,(function*(){const n=yield this.uploadWidgetThumbnailRaw(e,t);return yield n.value()}))}}const rn=e=>null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e);function an(e){if(Array.isArray(e))return e.map(an);if(!rn(e))return e;const t={};for(const[n,i]of Object.entries(e)){t[n.replace(/[_-](\w)/g,((e,t)=>t?t.toUpperCase():""))]=Array.isArray(i)?i.map(an):rn(i)?an(i):i}return t}function dn(e){if(Array.isArray(e))return e.map(dn);if(!rn(e))return e;const t={};for(const[n,i]of Object.entries(e)){t[n.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[\s-]+/g,"_").toLowerCase()]=Array.isArray(i)?i.map(dn):rn(i)?dn(i):i}return t}class un{constructor(){this.sessionCache=null,this.sessionCacheExpiry=0,this.ownershipCache=new Map;const e=t(),n=new a({basePath:e.basePath,apiKey:e.apiKey,credentials:"include"});this.authApi=new Zt(n),this.compositionsApi=new Xt(n)}checkAuthentication(){return e(this,void 0,void 0,(function*(){try{if(this.sessionCache&&Date.now()<this.sessionCacheExpiry)return{isAuthenticated:!0,session:this.sessionCache,user:this.sessionCache.user,canEdit:!0};const e=an(yield this.authApi.getSession());return e&&e.accessToken&&e.user?(this.sessionCache=e,this.sessionCacheExpiry=Date.now()+3e5,n.info("User authenticated for editing",{userId:e.user.id,email:e.user.email}),{isAuthenticated:!0,session:e,user:e.user,canEdit:!0}):{isAuthenticated:!1,canEdit:!1}}catch(e){return n.debug("Authentication check failed",{error:e}),e instanceof Response&&e.status,{isAuthenticated:!1,canEdit:!1}}}))}checkCompositionOwnership(t){return e(this,void 0,void 0,(function*(){var e;try{const i=this.ownershipCache.get(t);if(i)return i;const o=yield this.checkAuthentication();if(!o.isAuthenticated||!(null===(e=o.session)||void 0===e?void 0:e.user)){const e={isOwner:!1,canEdit:!1,error:"User not authenticated"};return this.ownershipCache.set(t,e),e}const s=an(yield this.compositionsApi.getCompositionById({id:t}));if(!s){const e={isOwner:!1,canEdit:!1,error:"Composition not found"};return this.ownershipCache.set(t,e),e}const r=s.creatorId===o.session.user.id,a={isOwner:r,canEdit:r,composition:s,error:r?void 0:"User does not own this composition"};return this.ownershipCache.set(t,a),setTimeout((()=>{this.ownershipCache.delete(t)}),12e4),n.debug("Composition ownership checked",{compositionId:t,isOwner:r,userId:o.session.user.id,compositionCreatorId:s.creatorId}),a}catch(e){n.warn("Failed to check composition ownership",{compositionId:t,error:e});const i={isOwner:!1,canEdit:!1,error:e instanceof Error?e.message:"Unknown error"};return this.ownershipCache.set(t,i),i}}))}canEditComposition(t){return e(this,void 0,void 0,(function*(){return(yield this.checkCompositionOwnership(t)).canEdit}))}getCurrentUser(){return e(this,void 0,void 0,(function*(){return(yield this.checkAuthentication()).user||null}))}clearCache(){this.sessionCache=null,this.sessionCacheExpiry=0,this.ownershipCache.clear(),n.debug("Authentication cache cleared")}checkMultipleCompositions(t){return e(this,void 0,void 0,(function*(){const n=new Map;return(yield this.checkAuthentication()).isAuthenticated?(yield Promise.all(t.map((t=>e(this,void 0,void 0,(function*(){const e=yield this.checkCompositionOwnership(t);n.set(t,e)}))))),n):(t.forEach((e=>{n.set(e,{isOwner:!1,canEdit:!1,error:"User not authenticated"})})),n)}))}isEditingEnabled(){return i.ENABLE_EDITING}}let cn=null;function ln(){return cn||(cn=new un),cn}class hn{constructor(e={}){this.host=null,this.container=null,this.content=null,this.destroyed=!1,this.options=Object.assign({target:"widgetic-portal",className:"",style:"",clickThrough:!1,zIndex:99999999},e),this.createPortal()}createPortal(){this.host=this.findOrCreateHost(),this.container=document.createElement("div"),this.container.className=(this.options.className?this.options.className+" ":"")+"widgetic-portal-contents",this.container.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: ${this.options.zIndex};\n pointer-events: ${this.options.clickThrough?"none":"auto"};\n ${this.options.style}\n `,this.options.clickThrough?this.container.style.pointerEvents="none":this.container.style.pointerEvents="auto",this.host.appendChild(this.container),n.debug("Portal created",{target:this.options.target,host:this.host,container:this.container})}findOrCreateHost(){let e=null;if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=`.${this.options.target}`;e=document.querySelector(t)}return e||(e=document.createElement("div"),e.classList.add("string"==typeof this.options.target?this.options.target:"widgetic-portal"),document.body.appendChild(e),n.debug("Portal host created",{target:this.options.target,host:e})),e}mount(e){this.destroyed?n.warn("Cannot mount content to destroyed portal"):this.container?(this.content&&this.unmount(),e.style.pointerEvents="auto",this.content=e,this.container.appendChild(e),n.debug("Content mounted to portal",{content:e})):n.error("Portal container not available")}unmount(){this.content&&this.container&&this.container.contains(this.content)&&(this.container.removeChild(this.content),this.content=null,n.debug("Content unmounted from portal"))}destroy(){if(!this.destroyed){if(this.unmount(),this.container&&this.host&&this.host.contains(this.container)&&this.host.removeChild(this.container),this.host&&0===this.host.childNodes.length&&this.host.parentNode){const e="string"==typeof this.options.target?this.options.target:"widgetic-portal";this.host.classList.contains(e)&&this.host.parentNode.removeChild(this.host)}this.destroyed=!0,this.host=null,this.container=null,this.content=null,n.debug("Portal destroyed")}}getContainer(){return this.container}isDestroyed(){return this.destroyed}updateOptions(e){this.destroyed?n.warn("Cannot update options on destroyed portal"):(this.options=Object.assign(Object.assign({},this.options),e),this.container&&(void 0!==e.className&&(this.container.className=(e.className?e.className+" ":"")+"widgetic-portal-contents"),void 0!==e.style&&(this.container.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: ${this.options.zIndex};\n pointer-events: ${this.options.clickThrough,"none"};\n ${this.options.style}\n `),void 0!==e.clickThrough&&(this.container.style.pointerEvents=(e.clickThrough,"none"))),n.debug("Portal options updated",{options:this.options}))}}function pn(e){return new hn(e)}class fn{constructor(e={}){this.config=e,this.loadPromise=null,this.sdkInstance=null,this.isLoading=!1,this.loadTimeout=3e4,this.config=Object.assign({basePath:e.basePath||this.getUISdkBaseUrl(),version:e.version||"latest",debug:e.debug||!1},e)}getUISdkBaseUrl(){return"development"===i.NODE_ENV?i.CLIENT_URL:`${i.PRODUCTION_URL}/ui-sdk`}loadUISdk(){return e(this,void 0,void 0,(function*(){if(this.sdkInstance)return this.sdkInstance;if(this.loadPromise)return this.loadPromise;this.isLoading=!0,this.loadPromise=this.performLoad();try{return this.sdkInstance=yield this.loadPromise,n.info("UI SDK loaded successfully",{basePath:this.config.basePath,version:this.config.version}),this.sdkInstance}catch(e){throw n.error("Failed to load UI SDK",{error:e,config:this.config}),this.loadPromise=null,e}finally{this.isLoading=!1}}))}performLoad(){return e(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const i=setTimeout((()=>{t(new Error("UI SDK load timeout"))}),this.loadTimeout);try{if(window.WidgeticUI)return clearTimeout(i),void e(window.WidgeticUI);const o=document.createElement("script");o.src=`${this.config.basePath}/widgetic-ui.js`,o.async=!0,o.crossOrigin="anonymous",o.onload=()=>{clearTimeout(i),window.WidgeticUI?(n.debug("UI SDK script loaded from external source"),e(window.WidgeticUI)):t(new Error("UI SDK script loaded but WidgeticUI not available"))},o.onerror=()=>{clearTimeout(i),t(new Error("Failed to load UI SDK script"))},document.head.appendChild(o),n.debug("Loading UI SDK",{src:o.src})}catch(e){clearTimeout(i),t(e)}}))}))}isLoaded(){return null!==this.sdkInstance}isLoadingState(){return this.isLoading}getInstance(){return this.sdkInstance}initializeUISdk(t){return e(this,void 0,void 0,(function*(){const e=yield this.loadUISdk();return yield e.init(Object.assign(Object.assign({},this.config),t)),n.info("UI SDK initialized",{config:Object.assign(Object.assign({},this.config),t)}),e}))}cleanup(){return e(this,void 0,void 0,(function*(){if(this.sdkInstance){try{yield this.sdkInstance.destroy()}catch(e){n.warn("Error during UI SDK cleanup",{error:e})}this.sdkInstance=null}this.loadPromise=null,this.isLoading=!1,window.WidgeticUI&&delete window.WidgeticUI,n.debug("UI SDK cleanup complete")}))}preload(){return e(this,void 0,void 0,(function*(){try{yield this.loadUISdk(),n.debug("UI SDK preloaded successfully")}catch(e){n.warn("UI SDK preload failed",{error:e})}}))}}let mn=null;function gn(e){return mn||(mn=new fn(e)),mn}class vn{constructor(e={}){this.options=e,this.sessions=new Map,this.defaultOptions={showEditButton:!0,editButtonText:"✏️ Edit",editButtonPosition:"top-right",enableClickToEdit:!0,autoDetectAuth:!0},this.options=Object.assign(Object.assign({},this.defaultOptions),e)}addOverlay(t,i){return e(this,void 0,void 0,(function*(){try{if(!this.options.autoDetectAuth)return void(yield this.createOverlay(t,i,!0));const e=ln(),o=yield e.checkCompositionOwnership(i);o.canEdit?(yield this.createOverlay(t,i,!0),n.debug("Editor overlay added for owned composition",{compositionId:i})):n.debug("Editor overlay not added - user cannot edit",{compositionId:i,reason:o.error})}catch(e){n.warn("Failed to add editor overlay",{compositionId:i,error:e})}}))}createOverlay(t,i,o){return e(this,void 0,void 0,(function*(){if(this.sessions.has(i))return;const e=document.createElement("div");if(e.className="widgetic-editor-overlay",e.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10000;\n pointer-events: none;\n ${this.getOverlayStyles()}\n `,this.options.showEditButton&&o){const t=this.createEditButton(i);e.appendChild(t)}this.options.enableClickToEdit&&o&&this.addClickToEdit(e,i);const s=t.parentElement;if(s){"static"===window.getComputedStyle(s).position&&(s.style.position="relative"),s.appendChild(e)}else t.style.position="relative",t.appendChild(e);const r={compositionId:i,isOpen:!1,overlay:e};this.sessions.set(i,r),n.debug("Editor overlay created",{compositionId:i})}))}createEditButton(t){const n=document.createElement("button");return n.className="widgetic-edit-button",n.textContent=this.options.editButtonText||"✏️ Edit",n.style.cssText=`\n position: absolute;\n ${this.getButtonPositionStyles()}\n background: #007bff;\n color: white;\n border: none;\n border-radius: 4px;\n padding: 8px 12px;\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n pointer-events: auto;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n transition: all 0.2s ease;\n z-index: 10001;\n ${this.getCustomButtonStyles()}\n `,n.addEventListener("mouseenter",(()=>{n.style.background="#0056b3",n.style.transform="scale(1.05)"})),n.addEventListener("mouseleave",(()=>{n.style.background="#007bff",n.style.transform="scale(1)"})),n.addEventListener("click",(n=>e(this,void 0,void 0,(function*(){n.preventDefault(),n.stopPropagation(),yield this.openEditor(t)})))),n}getButtonPositionStyles(){const e="10px";switch(this.options.editButtonPosition||"top-right"){case"top-left":return`top: ${e}; left: ${e};`;case"top-right":default:return`top: ${e}; right: ${e};`;case"bottom-left":return`bottom: ${e}; left: ${e};`;case"bottom-right":return`bottom: ${e}; right: ${e};`}}getCustomButtonStyles(){return this.options.editButtonStyle?Object.entries(this.options.editButtonStyle).map((([e,t])=>`${this.camelToKebab(e)}: ${t};`)).join(" "):""}getOverlayStyles(){return this.options.overlayStyle?Object.entries(this.options.overlayStyle).map((([e,t])=>`${this.camelToKebab(e)}: ${t};`)).join(" "):""}camelToKebab(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}addClickToEdit(t,n){t.style.cursor="pointer",t.style.pointerEvents="auto",t.addEventListener("click",(i=>e(this,void 0,void 0,(function*(){i.target===t&&(i.preventDefault(),i.stopPropagation(),yield this.openEditor(n))})))),t.addEventListener("mouseenter",(()=>{t.style.backgroundColor="rgba(0, 123, 255, 0.1)",t.style.border="2px dashed #007bff"})),t.addEventListener("mouseleave",(()=>{t.style.backgroundColor="transparent",t.style.border="none"}))}createEditorContainer(){const e=new hn({target:"widgetic-editor-portal",className:"widgetic-editor-modal",zIndex:1e5,clickThrough:!1});const t=document.createElement("div");t.className="widgetic-editor-modal-backdrop",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n ";const n=document.createElement("div");return n.className="widgetic-editor-content",n.style.cssText="\n width: 90vw;\n height: 90vh;\n max-width: 1200px;\n max-height: 800px;\n background: white;\n border-radius: 8px;\n overflow: hidden;\n position: relative;\n ",t.appendChild(n),e.mount(t),{container:t,portal:e}}openEditor(t){return e(this,void 0,void 0,(function*(){try{const e=this.sessions.get(t);if(!e)return void n.warn("No editor session found",{compositionId:t});if(e.isOpen)return void n.debug("Editor already open",{compositionId:t});n.info("Opening composition editor",{compositionId:t});const i=gn(),s=yield i.initializeUISdk(),{container:r,portal:a}=this.createEditorContainer(),d=yield s.mountCompositionEditor(r.querySelector(".widgetic-editor-content"),t,{onSave:e=>this.handleEditorSave(t,e),onClose:()=>this.closeEditor(t),onPreview:e=>this.handleEditorPreview(t,e)}),u=o().createWidgetController(t);if(e.isOpen=!0,e.editorContainer=r,e.editorInstance=d,e.widgetController=u,e.portal=a,e.overlay){const t=e.overlay.querySelector(".widgetic-edit-button");t&&(t.style.display="none")}n.info("Composition editor opened successfully",{compositionId:t})}catch(e){n.error("Failed to open editor",{compositionId:t,error:e}),this.showError("Failed to open editor. Please try again.",t)}}))}handleEditorSave(t,i){return e(this,void 0,void 0,(function*(){try{n.info("Saving composition changes",{compositionId:t,data:i});const e=this.sessions.get(t);(null==e?void 0:e.widgetController)&&(yield e.widgetController.updateConfig(i),yield e.widgetController.refresh()),yield this.closeEditor(t),n.info("Composition saved successfully",{compositionId:t})}catch(e){n.error("Failed to save composition",{compositionId:t,error:e}),this.showError("Failed to save changes. Please try again.",t)}}))}handleEditorPreview(t,i){return e(this,void 0,void 0,(function*(){try{const e=this.sessions.get(t);(null==e?void 0:e.widgetController)&&(yield e.widgetController.callFunction("preview",i))}catch(e){n.warn("Preview update failed",{compositionId:t,error:e})}}))}closeEditor(t){return e(this,void 0,void 0,(function*(){const e=this.sessions.get(t);if(e&&e.isOpen)try{if(e.editorInstance&&e.editorContainer){const t=gn().getInstance();t&&(yield t.unmountCompositionEditor(e.editorContainer))}if(e.portal&&e.portal.destroy(),e.overlay){const t=e.overlay.querySelector(".widgetic-edit-button");t&&(t.style.display="block")}e.isOpen=!1,e.editorContainer=void 0,e.editorInstance=void 0,e.portal=void 0,n.info("Editor closed",{compositionId:t})}catch(e){n.error("Error closing editor",{compositionId:t,error:e})}}))}showError(e,t){const n=document.createElement("div");n.style.cssText="\n position: fixed;\n top: 20px;\n right: 20px;\n background: #dc3545;\n color: white;\n padding: 12px 16px;\n border-radius: 4px;\n z-index: 100001;\n font-size: 14px;\n max-width: 300px;\n ",n.textContent=e,document.body.appendChild(n),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n)}),5e3)}removeOverlay(e){const t=this.sessions.get(e);t&&(t.isOpen&&this.closeEditor(e),t.overlay&&t.overlay.parentNode&&t.overlay.parentNode.removeChild(t.overlay),t.portal&&t.portal.destroy(),this.sessions.delete(e),n.debug("Editor overlay removed",{compositionId:e}))}isEditorOpen(e){var t;return(null===(t=this.sessions.get(e))||void 0===t?void 0:t.isOpen)||!1}getActiveSessions(){return Array.from(this.sessions.keys())}cleanup(){for(const e of this.sessions.keys())this.removeOverlay(e);n.debug("Editor overlay cleanup complete")}}let wn=null;function yn(e){return wn||(wn=new vn(e)),wn}var In=Object.freeze({__proto__:null,EditorOverlay:vn,getEditorOverlay:yn,resetEditorOverlay:function(){wn&&(wn.cleanup(),wn=null)}});export{Ht as A,a as C,en as T,sn as W,Xt as a,yn as b,pn as c,gn as d,nn as e,an as f,ln as g,Nt as h,In as i,dn as t};
|