/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@uniformdev/canvas@20.57.1/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__typeError=e=>{throw TypeError(e)},__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of __getOwnPropNames(t))__hasOwnProp.call(e,n)||n===r||__defProp(e,n,{get:()=>t[n],enumerable:!(i=__getOwnPropDesc(t,n))||i.enumerable});return e},__toESM=(e,t,r)=>(r=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?r:__defProp(r,"default",{value:e,enumerable:!0}),e)),__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),__accessCheck=(e,t,r)=>t.has(e)||__typeError("Cannot "+r),__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>t.has(e)?__typeError("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),require_yocto_queue=__commonJS({"../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(e,t){var r=class{constructor(e){this.value=e,this.next=void 0}},i=class{constructor(){this.clear()}enqueue(e){const t=new r(e);this._head?(this._tail.next=t,this._tail=t):(this._head=t,this._tail=t),this._size++}dequeue(){const e=this._head;if(e)return this._head=this._head.next,this._size--,e.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let e=this._head;for(;e;)yield e.value,e=e.next}};t.exports=i}}),require_p_limit=__commonJS({"../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(e,t){var r=require_yocto_queue();t.exports=e=>{if(!Number.isInteger(e)&&e!==1/0||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const t=new r;let i=0;const n=async(e,r,...n)=>{i++;const o=(async()=>e(...n))();r(o);try{await o}catch(e){}i--,t.size>0&&t.dequeue()()},o=(r,...o)=>new Promise((s=>{((r,o,...s)=>{t.enqueue(n.bind(null,r,o,...s)),(async()=>{await Promise.resolve(),i<e&&t.size>0&&t.dequeue()()})()})(r,s,...o)}));return Object.defineProperties(o,{activeCount:{get:()=>i},pendingCount:{get:()=>t.size},clearQueue:{value:()=>{t.clear()}}}),o}}}),require_retry_operation=__commonJS({"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(e,t){function r(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=r,r.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},r.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},r.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(void 0===r){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1)}var i=this;return this._timer=setTimeout((function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout((function(){i._operationTimeoutCb(i._attempts)}),i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)}),r),this._options.unref&&this._timer.unref(),!0},r.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){r._operationTimeoutCb()}),r._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},r.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},r.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},r.prototype.start=r.prototype.try,r.prototype.errors=function(){return this._errors},r.prototype.attempts=function(){return this._attempts},r.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,r=0,i=0;i<this._errors.length;i++){var n=this._errors[i],o=n.message,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=n,r=s)}return t}}}),require_retry=__commonJS({"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(e){var t=require_retry_operation();e.operation=function(r){var i=e.timeouts(r);return new t(i,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],n=0;n<t.retries;n++)i.push(this.createTimeout(n,t));return e&&e.forever&&!i.length&&i.push(this.createTimeout(n,t)),i.sort((function(e,t){return e-t})),i},e.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,i=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return i=Math.min(i,t.maxTimeout)},e.wrap=function(t,r,i){if(r instanceof Array&&(i=r,r=null),!i)for(var n in i=[],t)"function"==typeof t[n]&&i.push(n);for(var o=0;o<i.length;o++){var s=i[o],a=t[s];t[s]=function(i){var n=e.operation(r),o=Array.prototype.slice.call(arguments,1),s=o.pop();o.push((function(e){n.retry(e)||(e&&(arguments[0]=n.mainError()),s.apply(this,arguments))})),n.attempt((function(){i.apply(t,o)}))}.bind(t,a),t[s].options=r}}}}),require_retry2=__commonJS({"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(e,t){t.exports=require_retry()}}),src_exports={};__export(src_exports,{ASSETS_SOURCE_CUSTOM_URL:()=>ASSETS_SOURCE_CUSTOM_URL,ASSETS_SOURCE_UNIFORM:()=>ASSETS_SOURCE_UNIFORM,ASSET_PARAMETER_TYPE:()=>ASSET_PARAMETER_TYPE,ATTRIBUTE_COMPONENT_ID:()=>ATTRIBUTE_COMPONENT_ID,ATTRIBUTE_MULTILINE:()=>ATTRIBUTE_MULTILINE,ATTRIBUTE_PARAMETER_ID:()=>ATTRIBUTE_PARAMETER_ID,ATTRIBUTE_PARAMETER_TYPE:()=>ATTRIBUTE_PARAMETER_TYPE,ATTRIBUTE_PARAMETER_VALUE:()=>ATTRIBUTE_PARAMETER_VALUE,ATTRIBUTE_PLACEHOLDER:()=>ATTRIBUTE_PLACEHOLDER,ApiClientError:()=>import_api19.ApiClientError,BatchEntry:()=>BatchEntry,BlockFormatError:()=>BlockFormatError,CANVAS_BLOCK_PARAM_TYPE:()=>CANVAS_BLOCK_PARAM_TYPE,CANVAS_COMPONENT_DISPLAY_NAME_PARAM:()=>CANVAS_COMPONENT_DISPLAY_NAME_PARAM,CANVAS_CONTEXTUAL_EDITING_PARAM:()=>CANVAS_CONTEXTUAL_EDITING_PARAM,CANVAS_DRAFT_STATE:()=>CANVAS_DRAFT_STATE,CANVAS_EDITOR_STATE:()=>CANVAS_EDITOR_STATE,CANVAS_ENRICHMENT_TAG_PARAM:()=>CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_HYPOTHESIS_PARAM:()=>CANVAS_HYPOTHESIS_PARAM,CANVAS_INTENT_TAG_PARAM:()=>CANVAS_INTENT_TAG_PARAM,CANVAS_INTERNAL_PARAM_PREFIX:()=>CANVAS_INTERNAL_PARAM_PREFIX,CANVAS_LOCALE_TAG_PARAM:()=>CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT:()=>CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE:()=>CANVAS_LOCALIZATION_TYPE,CANVAS_PERSONALIZATION_ALGORITHM_PARAM:()=>CANVAS_PERSONALIZATION_ALGORITHM_PARAM,CANVAS_PERSONALIZATION_ALGORITHM_TYPE:()=>CANVAS_PERSONALIZATION_ALGORITHM_TYPE,CANVAS_PERSONALIZATION_EVENT_NAME_PARAM:()=>CANVAS_PERSONALIZATION_EVENT_NAME_PARAM,CANVAS_PERSONALIZATION_PARAM:()=>CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZATION_TAKE_PARAM:()=>CANVAS_PERSONALIZATION_TAKE_PARAM,CANVAS_PERSONALIZE_SLOT:()=>CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE:()=>CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE:()=>CANVAS_PUBLISHED_STATE,CANVAS_SLOT_SECTION_GROUP_TYPE_PARAM:()=>CANVAS_SLOT_SECTION_GROUP_TYPE_PARAM,CANVAS_SLOT_SECTION_MAX_PARAM:()=>CANVAS_SLOT_SECTION_MAX_PARAM,CANVAS_SLOT_SECTION_MIN_PARAM:()=>CANVAS_SLOT_SECTION_MIN_PARAM,CANVAS_SLOT_SECTION_NAME_PARAM:()=>CANVAS_SLOT_SECTION_NAME_PARAM,CANVAS_SLOT_SECTION_SLOT:()=>CANVAS_SLOT_SECTION_SLOT,CANVAS_SLOT_SECTION_SPECIFIC_PARAM:()=>CANVAS_SLOT_SECTION_SPECIFIC_PARAM,CANVAS_SLOT_SECTION_TYPE:()=>CANVAS_SLOT_SECTION_TYPE,CANVAS_TEST_SLOT:()=>CANVAS_TEST_SLOT,CANVAS_TEST_TYPE:()=>CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM:()=>CANVAS_TEST_VARIANT_PARAM,CANVAS_VIZ_CONTROL_PARAM:()=>CANVAS_VIZ_CONTROL_PARAM,CANVAS_VIZ_DI_RULE:()=>CANVAS_VIZ_DI_RULE,CANVAS_VIZ_DYNAMIC_TOKEN_RULE:()=>CANVAS_VIZ_DYNAMIC_TOKEN_RULE,CANVAS_VIZ_LOCALE_RULE:()=>CANVAS_VIZ_LOCALE_RULE,CANVAS_VIZ_QUIRKS_RULE:()=>CANVAS_VIZ_QUIRKS_RULE,CanvasClient:()=>CanvasClient,CanvasClientError:()=>CanvasClientError,CategoryClient:()=>CategoryClient,ChildEnhancerBuilder:()=>ChildEnhancerBuilder,ContentClient:()=>ContentClient,DataSourceClient:()=>DataSourceClient,DataTypeClient:()=>DataTypeClient,EDGE_CACHE_DISABLED:()=>EDGE_CACHE_DISABLED,EDGE_DEFAULT_CACHE_TTL:()=>EDGE_DEFAULT_CACHE_TTL,EDGE_MAX_CACHE_TTL:()=>EDGE_MAX_CACHE_TTL,EDGE_MIN_CACHE_TTL:()=>EDGE_MIN_CACHE_TTL,EMPTY_COMPOSITION:()=>EMPTY_COMPOSITION,EnhancerBuilder:()=>EnhancerBuilder,EntityReleasesClient:()=>EntityReleasesClient,IN_CONTEXT_EDITOR_COMPONENT_END_ROLE:()=>IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,IN_CONTEXT_EDITOR_COMPONENT_START_ROLE:()=>IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM:()=>IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID:()=>IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM:()=>IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM,IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM:()=>IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM:()=>IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,IS_RENDERED_BY_UNIFORM_ATTRIBUTE:()=>IS_RENDERED_BY_UNIFORM_ATTRIBUTE,IntegrationPropertyEditorsClient:()=>IntegrationPropertyEditorsClient,LOCALE_DYNAMIC_INPUT_NAME:()=>LOCALE_DYNAMIC_INPUT_NAME,LabelClient:()=>LabelClient,LocaleClient:()=>LocaleClient,PLACEHOLDER_ID:()=>PLACEHOLDER_ID,PreviewClient:()=>PreviewClient,ProjectClient:()=>ProjectClient,PromptClient:()=>PromptClient,RelationshipClient:()=>RelationshipClient,ReleaseClient:()=>ReleaseClient,ReleaseContentsClient:()=>ReleaseContentsClient,RouteClient:()=>RouteClient,SECRET_QUERY_STRING_PARAM:()=>SECRET_QUERY_STRING_PARAM,UncachedCanvasClient:()=>UncachedCanvasClient,UncachedCategoryClient:()=>UncachedCategoryClient,UncachedContentClient:()=>UncachedContentClient,UncachedLabelClient:()=>UncachedLabelClient,UniqueBatchEntries:()=>UniqueBatchEntries,WorkflowClient:()=>WorkflowClient,autoFixParameterGroups:()=>autoFixParameterGroups,bindExpressionEscapeChars:()=>bindExpressionEscapeChars,bindExpressionPrefix:()=>bindExpressionPrefix,bindVariables:()=>bindVariables,bindVariablesToObject:()=>bindVariablesToObject,compose:()=>compose,convertEntryToPutEntry:()=>convertEntryToPutEntry,convertToBindExpression:()=>convertToBindExpression,createBatchEnhancer:()=>createBatchEnhancer,createCanvasChannel:()=>createCanvasChannel,createDynamicInputVisibilityRule:()=>createDynamicInputVisibilityRule,createDynamicTokenVisibilityRule:()=>createDynamicTokenVisibilityRule,createLimitPolicy:()=>createLimitPolicy,createLocaleVisibilityRule:()=>createLocaleVisibilityRule,createQuirksVisibilityRule:()=>createQuirksVisibilityRule,createUniformApiEnhancer:()=>createUniformApiEnhancer,createVariableReference:()=>createVariableReference,enhance:()=>enhance,escapeBindExpressionDefaultValue:()=>escapeBindExpressionDefaultValue,evaluateNodeVisibilityParameter:()=>evaluateNodeVisibilityParameter,evaluatePropertyCriteria:()=>evaluatePropertyCriteria,evaluateVisibilityCriteriaGroup:()=>evaluateVisibilityCriteriaGroup,evaluateWalkTreeNodeVisibility:()=>evaluateWalkTreeNodeVisibility,evaluateWalkTreePropertyCriteria:()=>evaluateWalkTreePropertyCriteria,extractLocales:()=>extractLocales,findParameterInNodeTree:()=>findParameterInNodeTree,flattenValues:()=>flattenValues,generateComponentPlaceholderId:()=>generateComponentPlaceholderId,generateHash:()=>generateHash,getBlockValue:()=>getBlockValue,getComponentJsonPointer:()=>getComponentJsonPointer,getComponentPath:()=>getComponentPath,getDataSourceVariantFromRouteGetParams:()=>getDataSourceVariantFromRouteGetParams,getEffectivePropertyValue:()=>getEffectivePropertyValue,getLocalizedPropertyValues:()=>getLocalizedPropertyValues,getNounForLocation:()=>getNounForLocation,getNounForNode:()=>getNounForNode,getParameterAttributes:()=>getParameterAttributes,getPropertiesValue:()=>getPropertiesValue,hasReferencedVariables:()=>hasReferencedVariables,isAddComponentMessage:()=>isAddComponentMessage,isAllowedReferrer:()=>isAllowedReferrer,isAssetParamValue:()=>isAssetParamValue,isAssetParamValueItem:()=>isAssetParamValueItem,isComponentActionMessage:()=>isComponentActionMessage,isComponentPlaceholderId:()=>isComponentPlaceholderId,isContextStorageUpdatedMessage:()=>isContextStorageUpdatedMessage,isDismissPlaceholderMessage:()=>isDismissPlaceholderMessage,isEntryData:()=>isEntryData,isLinkParamValue:()=>isLinkParamValue,isMovingComponentMessage:()=>isMovingComponentMessage,isNestedNodeType:()=>isNestedNodeType,isOpenParameterEditorMessage:()=>isOpenParameterEditorMessage,isReadyMessage:()=>isReadyMessage,isReportRenderedCompositionsMessage:()=>isReportRenderedCompositionsMessage,isRequestComponentSuggestionMessage:()=>isRequestComponentSuggestionMessage,isRootEntryReference:()=>isRootEntryReference,isSelectComponentMessage:()=>isSelectComponentMessage,isSelectParameterMessage:()=>isSelectParameterMessage,isSuggestComponentMessage:()=>isSuggestComponentMessage,isSystemComponentDefinition:()=>isSystemComponentDefinition,isTriggerCompositionActionMessage:()=>isTriggerCompositionActionMessage,isUpdateAiActionsMessage:()=>isUpdateAiActionsMessage,isUpdateComponentParameterMessage:()=>isUpdateComponentParameterMessage,isUpdateComponentReferencesMessage:()=>isUpdateComponentReferencesMessage,isUpdateCompositionInternalMessage:()=>isUpdateCompositionInternalMessage,isUpdateCompositionMessage:()=>isUpdateCompositionMessage,isUpdateContextualEditingStateInternalMessage:()=>isUpdateContextualEditingStateInternalMessage,isUpdateFeatureFlagsMessage:()=>isUpdateFeatureFlagsMessage,isUpdatePreviewSettingsMessage:()=>isUpdatePreviewSettingsMessage,localize:()=>localize,mapSlotToPersonalizedVariations:()=>mapSlotToPersonalizedVariations,mapSlotToTestVariations:()=>mapSlotToTestVariations,mergeAssetConfigWithDefaults:()=>mergeAssetConfigWithDefaults,nullLimitPolicy:()=>nullLimitPolicy,parseComponentPlaceholderId:()=>parseComponentPlaceholderId,parseVariableExpression:()=>parseVariableExpression,version:()=>version,walkNodeTree:()=>walkNodeTree,walkPropertyValues:()=>walkPropertyValues}),module.exports=__toCommonJS(src_exports);var import_api2=require("@uniformdev/context/api"),import_api=require("@uniformdev/context/api"),import_p_limit=__toESM(require_p_limit()),import_retry=__toESM(require_retry2(),1),networkErrorMsgs=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed"]),AbortError=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},decorateErrorWithCounts=(e,t,r)=>{const i=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=i,e},isNetworkError=e=>networkErrorMsgs.has(e),getDOMException=e=>void 0===globalThis.DOMException?new Error(e):new DOMException(e);async function pRetry(e,t){return new Promise(((r,i)=>{t={onFailedAttempt(){},retries:10,...t};const n=import_retry.default.operation(t);n.attempt((async o=>{try{r(await e(o))}catch(e){if(!(e instanceof Error))return void i(new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));if(e instanceof AbortError)n.stop(),i(e.originalError);else if(e instanceof TypeError&&!isNetworkError(e.message))n.stop(),i(e);else{decorateErrorWithCounts(e,o,t);try{await t.onFailedAttempt(e)}catch(e){return void i(e)}n.retry(e)||i(n.mainError())}}})),t.signal&&!t.signal.aborted&&t.signal.addEventListener("abort",(()=>{n.stop();const e=void 0===t.signal.reason?getDOMException("The operation was aborted."):t.signal.reason;i(e instanceof Error?e:getDOMException(e))}),{once:!0})}))}var AbortError2=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function pThrottle({limit:e,interval:t,strict:r}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const i=new Map;let n=0,o=0;const s=[];const a=r?function(){const r=Date.now();if(s.length<e)return s.push(r),0;const i=s.shift()+t;return r>=i?(s.push(r),0):(s.push(i),i-r)}:function(){const r=Date.now();return r-n>t?(o=1,n=r,0):(o<e?o++:(n+=t,o=1),n-r)};return e=>{const t=function(...r){if(!t.isEnabled)return(async()=>e.apply(this,r))();let n;return new Promise(((t,o)=>{n=setTimeout((()=>{t(e.apply(this,r)),i.delete(n)}),a()),i.set(n,o)}))};return t.abort=()=>{for(const e of i.keys())clearTimeout(e),i.get(e)(new AbortError2);i.clear(),s.splice(0,s.length)},t.isEnabled=!0,t}}function createLimitPolicy({throttle:e={interval:1e3,limit:10},retry:t={retries:1,factor:1.66},limit:r=10}){const i=e?pThrottle(e):null,n=r?(0,import_p_limit.default)(r):null;return function(e){let r=async()=>await e();if(i){r=i(r)}if(n){const e=r;r=()=>n(e)}if(t){const e=r;r=()=>pRetry(e,{...t,onFailedAttempt:async e=>{if(t.onFailedAttempt&&await t.onFailedAttempt(e),e instanceof import_api.ApiClientError&&"number"==typeof e.statusCode&&e.statusCode>=400&&e.statusCode<500&&429!==e.statusCode&&408!==e.statusCode)throw e}})}return r()}}var _contentTypesUrl,_entriesUrl,nullLimitPolicy=async e=>await e(),CANVAS_URL="/api/v1/canvas",CanvasClient=class extends import_api2.ApiClient{constructor(e){var t;e.limitPolicy||(e.limitPolicy=createLimitPolicy({})),super(e),this.edgeApiHost=null!=(t=e.edgeApiHost)?t:"https://uniform.global",this.edgeApiRequestInit=e.disableSWR?{headers:{"x-disable-swr":"true"}}:void 0}async getCompositionList(e={}){const{projectId:t}=this.options,{resolveData:r,filters:i,...n}=e,o=(0,import_api2.rewriteFiltersForApi)(i);if(!r){const e=this.createUrl(CANVAS_URL,{...n,projectId:t,...o});return this.apiClient(e)}const s={...n,projectId:t,diagnostics:"boolean"==typeof e.diagnostics?e.diagnostics:"no-data"===e.diagnostics?"no-data":void 0,...o},a=this.createUrl("/api/v1/compositions",s,this.edgeApiHost);return this.apiClient(a,this.edgeApiRequestInit)}getCompositionByNodePath(e){return this.getOneComposition(e)}getCompositionByNodeId(e){return this.getOneComposition(e)}getCompositionBySlug(e){return this.getOneComposition(e)}getCompositionById(e){return this.getOneComposition(e)}getCompositionDefaults(e){return this.getOneComposition(e)}async getCompositionHistory(e){const t=this.createUrl("/api/v1/canvas-history",{...e,projectId:this.options.projectId});return this.apiClient(t)}getOneComposition({skipDataResolution:e,diagnostics:t,...r}){const{projectId:i}=this.options;if(e)return this.apiClient(this.createUrl(CANVAS_URL,{...r,projectId:i}));const n={...r,projectId:i,diagnostics:"boolean"==typeof t?t:"no-data"===t?"no-data":void 0},o=this.createUrl("/api/v1/composition",n,this.edgeApiHost);return this.apiClient(o,this.edgeApiRequestInit)}async updateComposition(e,t){const r=this.createUrl(CANVAS_URL),i={};(null==t?void 0:t.ifUnmodifiedSince)&&(i["x-if-unmodified-since"]=t.ifUnmodifiedSince);const{response:n}=await this.apiClientWithResponse(r,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0,headers:i});return{modified:n.headers.get("x-modified-at")}}async removeComposition(e){const t=this.createUrl(CANVAS_URL),{projectId:r}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){const{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return this.apiClient(r)}async updateComponentDefinition(e){const t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){const t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},UncachedCanvasClient=class extends CanvasClient{constructor(e){super({...e,bypassCache:!0})}},import_api3=require("@uniformdev/context/api"),CATEGORIES_URL="/api/v1/categories",CategoryClient=class extends import_api3.ApiClient{constructor(e){e.limitPolicy||(e.limitPolicy=createLimitPolicy({})),super(e)}async getCategories(e){const{projectId:t}=this.options,r=this.createUrl("/api/v1/categories",{...e,projectId:t});return await this.apiClient(r)}async upsertCategories(e){const{projectId:t}=this.options,r=this.createUrl(CATEGORIES_URL);return await this.apiClient(r,{method:"PUT",body:JSON.stringify({categories:e,projectId:t}),expectNoContent:!0})}async removeCategory(e){const{projectId:t}=this.options,r=this.createUrl(CATEGORIES_URL);return await this.apiClient(r,{method:"DELETE",body:JSON.stringify({projectId:t,categoryId:e.categoryId}),expectNoContent:!0})}},UncachedCategoryClient=class extends CategoryClient{constructor(e){super({...e,bypassCache:!0})}},import_api4=require("@uniformdev/context/api"),_ContentClient=class e extends import_api4.ApiClient{constructor(e){var t;super(e),this.edgeApiHost=null!=(t=e.edgeApiHost)?t:"https://uniform.global"}getContentTypes(t){const{projectId:r}=this.options,i=this.createUrl(__privateGet(e,_contentTypesUrl),{...t,projectId:r});return this.apiClient(i)}getEntries(t){const{projectId:r}=this.options,{skipDataResolution:i,filters:n,...o}=t,s=(0,import_api4.rewriteFiltersForApi)(n);if(i){const t=this.createUrl(__privateGet(e,_entriesUrl),{...o,...s,projectId:r});return this.apiClient(t)}const a=this.createUrl(__privateGet(e,_entriesUrl),{...this.getEdgeOptions(o),...s},this.edgeApiHost);return this.apiClient(a,this.options.disableSWR?{headers:{"x-disable-swr":"true"}}:void 0)}async getEntryHistory(e){const t=this.createUrl("/api/v1/entries-history",{...e,projectId:this.options.projectId});return this.apiClient(t)}async upsertContentType(t,r={}){const i=this.createUrl(__privateGet(e,_contentTypesUrl));"object"==typeof t.contentType.slugSettings&&null!==t.contentType.slugSettings&&0===Object.keys(t.contentType.slugSettings).length&&delete t.contentType.slugSettings,await this.apiClient(i,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0,headers:r.autogenerateDataTypes?{"x-uniform-autogenerate-data-types":"true"}:{}})}async upsertEntry(t,r){const i=this.createUrl(__privateGet(e,_entriesUrl)),n={};(null==r?void 0:r.ifUnmodifiedSince)&&(n["x-if-unmodified-since"]=r.ifUnmodifiedSince);const{response:o}=await this.apiClientWithResponse(i,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0,headers:n});return{modified:o.headers.get("x-modified-at")}}async deleteContentType(t){const r=this.createUrl(__privateGet(e,_contentTypesUrl));await this.apiClient(r,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async deleteEntry(t){const r=this.createUrl(__privateGet(e,_entriesUrl));await this.apiClient(r,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}getEdgeOptions(e){const{projectId:t}=this.options,{skipDataResolution:r,...i}=e;return{projectId:t,...i,diagnostics:"boolean"==typeof e.diagnostics?e.diagnostics:"no-data"===e.diagnostics?"no-data":void 0}}};_contentTypesUrl=new WeakMap,_entriesUrl=new WeakMap,__privateAdd(_ContentClient,_contentTypesUrl,"/api/v1/content-types"),__privateAdd(_ContentClient,_entriesUrl,"/api/v1/entries");var _url,ContentClient=_ContentClient,UncachedContentClient=class extends ContentClient{constructor(e){super({...e,bypassCache:!0})}},import_api5=require("@uniformdev/context/api"),dataSourceUrl="/api/v1/data-source",dataSourcesUrl="/api/v1/data-sources",DataSourceClient=class extends import_api5.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(dataSourceUrl,{...e,projectId:t});return await this.apiClient(r)}async getList(e){const{projectId:t}=this.options,r=this.createUrl(dataSourcesUrl,{...e,projectId:t});return await this.apiClient(r)}async upsert(e){const t=this.createUrl(dataSourceUrl);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){const t=this.createUrl(dataSourceUrl);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},import_api6=require("@uniformdev/context/api"),_DataTypeClient=class e extends import_api6.ApiClient{constructor(e){super(e)}async get(t){const{projectId:r}=this.options,i=this.createUrl(__privateGet(e,_url),{...t,projectId:r});return await this.apiClient(i)}async upsert(t){const r=this.createUrl(__privateGet(e,_url));await this.apiClient(r,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){const r=this.createUrl(__privateGet(e,_url));await this.apiClient(r,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}};__privateAdd(_DataTypeClient,_url=new WeakMap,"/api/v1/data-types");var DataTypeClient=_DataTypeClient,BatchEntry=class{constructor(e,t,r){this._resolve=e,this._reject=t,this.args=r,this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function createBatchEnhancer({handleBatch:e,shouldQueue:t,limitPolicy:r}){let i=[];return{enhanceOne:async e=>!t||t(e)?new Promise(((t,r)=>{i.push(new BatchEntry(t,r,e))})):void 0,completeAll:async()=>{if(i.length>0){try{await e(i)}catch(e){i.forEach((t=>t.reject(e)))}if(i.some((e=>!e.isCompleted)))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}const t=i.length;return i=[],t},limitPolicy:r}}var compose=(e,...t)=>({enhanceOne:r=>{let i="enhanceOne"in e?e.enhanceOne(r):e(r);for(const e of t){const t=isPromise(i)?i:Promise.resolve(i),n="enhanceOne"in e?e.enhanceOne:e;i=t.then((e=>n({...r,parameter:{type:r.parameter.type,value:e}})))}return i},completeAll:async()=>{var r,i;for(const e of t)if("completeAll"in e)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return null!=(i="completeAll"in e?null==(r=e.completeAll)?void 0:r.call(e):0)?i:0}});function isPromise(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function getComponentPath(e){const t=[];for(let r=e.length-1;r>=0;r--){const i=e[r],n=e[r+1];if("type"in i&&"slot"!==i.type){if("block"===i.type){const{fieldName:e,blockIndexFn:r}=i,o=r();if(e&&void 0!==o){const r=n&&"type"in n&&"block"===n.type?"fields":"parameters";t.push(`${r}.${e}.value[${o}]`)}}continue}const o=i.parentSlotIndexFn(),{parentSlot:s}=i;s&&void 0!==o&&t.push(`${s}[${o}]`)}return`.${t.join(".")}`}var CANVAS_PERSONALIZE_TYPE="$personalization",CANVAS_TEST_TYPE="$test",CANVAS_LOCALIZATION_TYPE="$localization",CANVAS_SLOT_SECTION_TYPE="$slotSection",CANVAS_INTENT_TAG_PARAM="intentTag",CANVAS_LOCALE_TAG_PARAM="locale",CANVAS_BLOCK_PARAM_TYPE="$block",CANVAS_PERSONALIZE_SLOT="pz",CANVAS_TEST_SLOT="test",CANVAS_LOCALIZATION_SLOT="localized",CANVAS_SLOT_SECTION_SLOT="$slotSectionItems",CANVAS_SLOT_SECTION_NAME_PARAM="name",CANVAS_SLOT_SECTION_MIN_PARAM="min",CANVAS_SLOT_SECTION_MAX_PARAM="max",CANVAS_SLOT_SECTION_GROUP_TYPE_PARAM="groupType",CANVAS_SLOT_SECTION_SPECIFIC_PARAM="specific",CANVAS_DRAFT_STATE=0,CANVAS_PUBLISHED_STATE=64,CANVAS_EDITOR_STATE=63,CANVAS_PERSONALIZATION_PARAM="$pzCrit",CANVAS_PERSONALIZATION_EVENT_NAME_PARAM="trackingEventName",CANVAS_PERSONALIZATION_ALGORITHM_PARAM="algorithm",CANVAS_PERSONALIZATION_ALGORITHM_TYPE="pzAlgorithm",CANVAS_PERSONALIZATION_TAKE_PARAM="count",CANVAS_TEST_VARIANT_PARAM="$tstVrnt",CANVAS_ENRICHMENT_TAG_PARAM="$enr",CANVAS_INTERNAL_PARAM_PREFIX="$internal_",CANVAS_COMPONENT_DISPLAY_NAME_PARAM=`${CANVAS_INTERNAL_PARAM_PREFIX}displayName`,CANVAS_HYPOTHESIS_PARAM=`${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`,CANVAS_CONTEXTUAL_EDITING_PARAM="$contextualEditing",SECRET_QUERY_STRING_PARAM="secret",IN_CONTEXT_EDITOR_QUERY_STRING_PARAM="is_incontext_editing_mode",IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM="is_incontext_editing_playground",IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM="is_incontext_editing_forced_settings",IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM="is_config_check",IN_CONTEXT_EDITOR_COMPONENT_START_ROLE="uniform-component-start",IN_CONTEXT_EDITOR_COMPONENT_END_ROLE="uniform-component-end",IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID="uniform-canvas-preview-script",IS_RENDERED_BY_UNIFORM_ATTRIBUTE="data-is-rendered-by-uniform",PLACEHOLDER_ID="placeholder",EMPTY_COMPOSITION={_id:"_empty_composition_id",_name:"An empty composition used for contextual editing",type:"_empty_composition_type"},EDGE_MIN_CACHE_TTL=10,EDGE_MAX_CACHE_TTL=86400,EDGE_DEFAULT_CACHE_TTL=30,EDGE_CACHE_DISABLED=-1,ASSET_PARAMETER_TYPE="asset",ASSETS_SOURCE_UNIFORM="uniform-assets",ASSETS_SOURCE_CUSTOM_URL="custom-url";function isRootEntryReference(e){return"root"===e.type&&isEntryData(e.node)}function isEntryData(e){return Boolean(e&&"object"==typeof e&&"fields"in e)}function isAssetParamValue(e){return Array.isArray(e)&&(!(e.length>0)||isAssetParamValueItem(e[0]))}function isAssetParamValueItem(e){return Boolean(e instanceof Object&&"_source"in e&&"fields"in e&&e.fields instanceof Object&&"url"in e.fields&&e.fields.url instanceof Object)}function isLinkParamValue(e){return"object"==typeof e&&null!==e&&"type"in e&&"path"in e}function getPropertiesValue(e){return"parameters"in e&&e.parameters?e.parameters:"fields"in e&&e.fields?e.fields:void 0}function getLocalizedPropertyValues(e){if(!e)return e;const t=new Map;if(void 0!==e.value&&t.set(void 0,e.value),void 0!==e.locales)for(const[r,i]of Object.entries(e.locales))t.set(r,i);return t}function flattenValues(e,t={}){return e?Array.isArray(e)&&t.toSingle?e.length>0?flattenSingleNodeValues(e[0]):void 0:Array.isArray(e)?e.map((e=>flattenSingleNodeValues(e,t))):flattenSingleNodeValues(e,t):e}function flattenSingleNodeValues(e,t={}){const{levels:r=1}=t,i=getPropertiesValue(e);return i?Object.fromEntries(Object.entries(i).map((([e,i])=>{const n=i?i.value:i;if(r>0&&Array.isArray(n)&&(isNestedNodeType(i.type)||i.type===ASSET_PARAMETER_TYPE)){const i={...t,levels:r-1};return[e,n.map((e=>flattenValues(e,i)))]}return[e,n]}))):i}var escapeCharacter="\\",variablePrefix="${",variableSuffix="}";function parseVariableExpression(e,t){if("string"!=typeof e)throw new TypeError("Variable expression must be a string");let r=0,i=0,n=0;const o=(e,r)=>(n++,null==t?void 0:t(e,r));let s="text";for(let t=0;t<e.length;t++){const a=e[t];if(r>i&&(i=r),a!==variablePrefix[0]||e[t+1]!==variablePrefix[1])if(a!==variableSuffix||"variable"!==s)i++;else{if(e[t-1]===escapeCharacter){i++;continue}if(s="text",i>r){if(!1===o(e.substring(r,i).replace(/\\([${}])/g,"$1"),"variable"))return n;r=i+variableSuffix.length}}else{if(e[t-1]===escapeCharacter){if(i-=escapeCharacter.length,!1===o(e.substring(r,i),"text"))return n;r=t,i=t+1;continue}if("variable"===s){const t=r-variablePrefix.length;if(!1===o(e.substring(t,i),"text"))return n;r=i}else if(i>r){if(!1===o(e.substring(r,i),"text"))return n;r=i}s="variable",t+=variablePrefix.length-1,r+=variablePrefix.length}}return"variable"===s&&(s="text",r-=variablePrefix.length),r<e.length&&o(e.substring(r),s),n}function hasReferencedVariables(e){if(void 0===e)return 0;let t=0;return parseVariableExpression(e,((e,r)=>{"variable"===r&&t++})),t}function walkNodeTree(e,t,r){var i,n;const o=[{ancestorsAndSelf:Array.isArray(e)?e:[{node:e,type:"root"}],context:null==r?void 0:r.initialContext}],s=new Map;do{const e=o.pop();if(!e)continue;const a=e.ancestorsAndSelf[0];let l,c=!0,p=null!=(i=s.get(a.node))?i:e.context;if(l="root"===a.type&&isRootEntryReference(a)||"block"===a.type?{type:"entry",node:a.node,ancestorsAndSelf:e.ancestorsAndSelf,actions:{replace:e=>{Object.assign(a.node,e);["fields","_dataResources","_author"].forEach((t=>{e[t]||delete a.node[t]}))},remove:()=>{const t=e.ancestorsAndSelf[0],r=e.ancestorsAndSelf[1];if("block"!==t.type)throw new Error("Unknown node type");{const{fieldName:e,blockIndexFn:i}=t,n=i(),o=getBlockValue(r.node,e);if(o.splice(n,1),0===o.length){delete getPropertiesValue(r.node)[e]}}c=!1},insertAfter:t=>{const r=e.ancestorsAndSelf[0];if("block"!==r.type)throw new Error("Unknown type");const{fieldName:i,blockIndexFn:n}=r,s=n(),a=e.ancestorsAndSelf[1],l=Array.isArray(t)?t:[t];i&&void 0!==s&&(getPropertiesValue(a.node)[i].value.splice(s+1,0,...l),o.unshift(...l.map((t=>({ancestorsAndSelf:[{type:"block",node:t,fieldName:i,blockIndexFn:()=>getPropertiesValue(a.node)[i].value.findIndex((e=>e===t))},...e.ancestorsAndSelf.slice(1)],context:p})))))},stopProcessingDescendants(){c=!1},setDescendantsContext(e){p=e},setChildContext(e,t){s.set(e,t)}},context:p}:{type:"component",node:a.node,ancestorsAndSelf:e.ancestorsAndSelf,actions:{replace:e=>{Object.assign(a.node,e);["parameters","variant","slots","data","_pattern","_patternError","_dataResources","_overridability","_overrides","_patternDataResources"].forEach((t=>{e[t]||delete a.node[t]}))},remove:()=>{const t=e.ancestorsAndSelf[0],r=e.ancestorsAndSelf[1];if("root"===t.type)throw new Error("Unable to delete root node.");if("slot"!==t.type)throw new Error("Unknown node type");{const{parentSlot:e,parentSlotIndexFn:i}=t,n=i();r.node.slots[e].splice(n,1)}c=!1},insertAfter:t=>{const r=Array.isArray(t)?t:[t],i=e.ancestorsAndSelf[0];if("root"===i.type)throw new Error("Unable to insert after root node.");if("slot"!==i.type)throw new Error("Unknown type");{const{parentSlot:t,parentSlotIndexFn:n}=i,s=n(),a=e.ancestorsAndSelf[1];t&&void 0!==s&&(a.node.slots[t].splice(s+1,0,...r),o.unshift(...r.map((r=>({type:"slot",ancestorsAndSelf:[{type:"slot",node:r,parentSlot:t,parentSlotIndexFn:()=>a.node.slots[t].findIndex((e=>e===r))},...e.ancestorsAndSelf.slice(1)],context:p})))))}},stopProcessingDescendants(){c=!1},setDescendantsContext(e){p=e},setChildContext(e,t){s.set(e,t)}},context:p},t(l),!c)continue;const u="slots"in a.node&&a.node.slots;if(u){const t=Object.keys(u);for(let r=t.length-1;r>=0;r--){const i=t[r],n=u[i];for(let t=n.length-1;t>=0;t--){const r=n[t],s=()=>a.node.slots[i].findIndex((e=>e===r));o.push({ancestorsAndSelf:[{type:"slot",node:r,parentSlot:i,parentSlotIndexFn:s},...e.ancestorsAndSelf],context:p})}}}const d=getPropertiesValue(a.node);if(d){const t=Object.entries(d);for(let i=t.length-1;i>=0;i--){const[s,l]=t[i];if(!isNestedNodeType(l.type))continue;if("string"==typeof l.value&&hasReferencedVariables(l.value)>0)continue;if(!Array.isArray(l.value)){const t=new BlockFormatError(`${getComponentPath(e.ancestorsAndSelf)}`,s,l.value);if(null==r?void 0:r.throwForInvalidBlockValues)throw t;console.warn(`Skipped invalid block value: ${t.message}}`);continue}const c=null!=(n=l.value)?n:[];for(let t=c.length-1;t>=0;t--){const r=c[t],i=()=>getBlockValue(a.node,s).findIndex((e=>e===r));o.push({ancestorsAndSelf:[{type:"block",node:r,fieldName:s,blockIndexFn:i},...e.ancestorsAndSelf],context:p})}}}}while(o.length>0)}function isNestedNodeType(e){return e===CANVAS_BLOCK_PARAM_TYPE}function getBlockValue(e,t){var r;const i=null==(r=getPropertiesValue(e))?void 0:r[t];return(null==i?void 0:i.value)&&i.type===CANVAS_BLOCK_PARAM_TYPE&&Array.isArray(i.value)?i.value:[]}var BlockFormatError=class e extends Error{constructor(t,r,i){super(`${t} has an invalid block property value on ${r}. Block values must be arrays of blocks (BlockValue type), but received ${null===i?"null":typeof i}`),this.componentPath=t,this.propertyId=r,this.blockValue=i,Object.setPrototypeOf(this,e.prototype)}};async function enhance({composition:e,enhancers:t,context:r,onErrors:i=e=>{throw new Error(e.map((e=>`${e.message}\n ${"object"==typeof e.error&&"stack"in e.error?e.error.stack:e.error}`)).join("\n\n"))}}){const n=[],o=new Set,s=new Set;walkNodeTree(e,(({type:e,node:i,ancestorsAndSelf:a,actions:l})=>{var c;if("component"!==e)return void l.stopProcessingDescendants();Object.entries(null!=(c=i.parameters)?c:{}).forEach((([e,o])=>{const l=t.resolveParameterEnhancer(i,e,o);l&&(s.add(l),n.push(enhanceParameter(i,a,e,o,l,r)))}));const p=t.resolveComponentEnhancers(i);n.push(enhanceComponent(i,a,p,r)),o.add(p)})),n.push(...Array.from(o).flatMap((e=>Array.from(e).map((async([,e])=>{var t;try{if(e.completeAll){const r=null!=(t=e.limitPolicy)?t:nullLimitPolicy;await r((()=>e.completeAll()))}}catch(e){return{error:e,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))))),n.push(...Array.from(s).map((async e=>{var t;try{if(e.completeAll){const r=null!=(t=e.limitPolicy)?t:nullLimitPolicy;await r((()=>e.completeAll()))}}catch(e){return{error:e,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}})));const a=(await Promise.all(n)).flatMap((e=>Array.isArray(e)?e:[e])).filter((e=>e));a.length&&i(a)}async function enhanceComponent(e,t,r,i){return r.size&&(e.data={}),await Promise.all(Array.from(r).map((async([r,n])=>{var o;try{const t=n.completeAll?nullLimitPolicy:null!=(o=n.limitPolicy)?o:nullLimitPolicy,s=await t((async()=>n.enhanceOne({component:e,context:i})));null!=s&&(e.data[r]=s)}catch(i){const n=`Component ${getComponentPath(t)} (type: ${e.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete e.data[r],{message:n,error:i}}})))}async function enhanceParameter(e,t,r,i,n,o){var s;try{const t=n.completeAll?nullLimitPolicy:null!=(s=n.limitPolicy)?s:nullLimitPolicy,a=await t((async()=>n.enhanceOne({parameter:i,parameterName:r,component:e,context:o})));null===a?delete e.parameters[r]:e.parameters[r]=void 0===a?{...i,value:i.value}:{...i,value:a}}catch(n){const o=`Component ${getComponentPath(t)} (type: ${e.type}): enhancing parameter ${r} (type: ${i.type}) threw exception. Parameter will be removed.`;return delete e.parameters[r],{message:o,error:n}}}var ChildEnhancerBuilder=class{constructor(){this._paramMatches=Array(),this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach((e=>this._paramMatches.push({name:e,enhancer:this._resolveParameterEnhancer(t)}))),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach((e=>this._paramMatches.push({type:e,enhancer:this._resolveParameterEnhancer(t)}))),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,"function"==typeof t?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var r;return null==(r=this._paramMatches.find((r=>r.name&&r.name===e||r.type&&r.type===t.type||!r.type&&!r.name)))?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return"function"==typeof e?{enhanceOne:e}:e}},EnhancerBuilder=class{constructor(){this._componentIndex={},this._rootBuilder=new ChildEnhancerBuilder}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach((e=>{this._componentIndex[e]=this._componentIndex[e]||new ChildEnhancerBuilder,t(this._componentIndex[e])})),this}resolveParameterEnhancer(e,t,r){const i=this._componentIndex[e.type];if(i){const e=i.resolveParameterEnhancer(t,r);if(e)return e}return this._rootBuilder.resolveParameterEnhancer(t,r)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers();const r=this._componentIndex[e.type];if(r){t=new Map(t);for(const[e,i]of r.resolveComponentEnhancers())t.set(e,i)}return t}};function getComponentJsonPointer(e){const t=[];for(let r=e.length-1;r>=0;r--){const i=e[r],n=e[r+1];if("type"in i&&"slot"!==i.type){if("block"===i.type){const{fieldName:e,blockIndexFn:r}=i,o=r();if(e&&void 0!==o){const r=getNounForLocation(n);t.push(`${r}/${e}/value/${o}`)}}continue}const o=i.parentSlotIndexFn(),{parentSlot:s}=i;s&&void 0!==o&&t.push(`slots/${s}/${o}`)}return`/${t.join("/")}`}function getNounForLocation(e){let t="parameters";return e&&"type"in e&&("block"===e.type||isRootEntryReference(e))&&(t="fields"),t}function getNounForNode(e){let t="parameters";return isEntryData(e)&&(t="fields"),t}function findParameterInNodeTree(e,t){const r=[];return walkNodeTree(e,(({node:e,ancestorsAndSelf:i})=>{const n=getPropertiesValue(e);n&&Object.entries(n).filter((([r,i])=>t(i,r,e))).forEach((([t,n])=>{r.push({key:t,pointer:(1===i.length?"":getComponentJsonPointer(i))+`/${getNounForNode(e)}/${t}`,parameter:n})}))})),r}var bindExpressionPrefix="#",bindExpressionEscapeChars=new Set(["#","\\","[","]",":"]);function convertToBindExpression(e){if("jptr"===e.syntax){const t=[`${bindExpressionPrefix}${e.syntax}:${escapeNestedVariableExpressions(escapeBindExpressionReservedChars(e.pointer))}`];return e.failureAction&&"t"!==e.failureAction&&t.push(`fa=${e.failureAction}`),e.failureLogLevel&&"w"!==e.failureLogLevel&&t.push(`fl=${e.failureLogLevel}`),e.failureDefault&&t.push(`fd=${escapeBindExpressionDefaultValue(e.failureDefault)}`),t.join(":")}throw new Error(`Unsupported dynamic token binding syntax '${e.syntax}'`)}function escapeNestedVariableExpressions(e){return e.replace(/\$\{([^}]+)\}/g,"$[$1]")}function escapeBindExpressionReservedChars(e){return e.split("").map((e=>bindExpressionEscapeChars.has(e)?`\\${":"===e?";":e}`:e)).join("")}function escapeBindExpressionDefaultValue(e){return escapeBindExpressionReservedChars(e).replace("=","\\+")}function createVariableReference(e){return`\${${e.replace(/([${}])/g,"\\$1")}}`}function getEffectivePropertyValue({property:e,conditionIndex:t,locale:r,strict:i,greedyLocaleMatching:n}){var o,s,a,l;if(!e)return;let c=e.value;if(t>=0){const r=null==(s=null==(o=e.conditions)?void 0:o[t])?void 0:s.value;if(null===r)return;(void 0!==r||i)&&(c=r)}if(r){const o=getLocaleMatch(e.locales,r,n);if((void 0!==o||i)&&(c=o),t>=0){const o=null==(l=null==(a=getLocaleMatch(e.localesConditions,r,n))?void 0:a[t])?void 0:l.value;if(null===o)return;(void 0!==o||i)&&(c=o)}}return e.connectedData&&(c=createVariableReference(convertToBindExpression(e.connectedData))),c}function getLocaleMatch(e,t,r){if(!e)return;const i=e[t];return void 0===i&&r?Object.values(e)[0]:i}function evaluateVisibilityCriteriaGroup(e){const{criteriaGroup:t,simplifyCriteria:r}=e,i=!("&"===t.op||!t.op);let n=!1;for(let o=t.clauses.length-1;o>=0;o--){const s=evaluateCriterion(t.clauses[o],e);if(null===s)n=!0;else{if(s===i)return i;null!==s&&r&&t.clauses.splice(o,1)}}return n?null:!i}function evaluateCriterion(e,t){var r;if("clauses"in e)return evaluateVisibilityCriteriaGroup({...t,criteriaGroup:e});const i=null!=(r=e.source)?r:e.rule,n=Array.isArray(e.value)?e.value:void 0!==e.value?[e.value]:void 0;if("string"==typeof i&&hasReferencedVariables(i)>0||(null==n?void 0:n.some((e=>"string"==typeof e&&hasReferencedVariables(e)>0))))return null;const o=t.rules[e.rule];return o?o(e):null}function evaluateNodeVisibilityParameter({parameter:e,...t}){if(null==e?void 0:e.explicitlyHidden)return!1;if(!(null==e?void 0:e.criteria))return!0;return evaluateVisibilityCriteriaGroup({...t,criteriaGroup:e.criteria})}function evaluatePropertyCriteria({baseValue:e,conditionalValues:t,keepIndeterminate:r,...i}){let n=!0;const o={currentValue:e,remainingConditionalValues:i.simplifyCriteria&&t?[...t]:t,currentConditionIndex:-1};if(!t)return o;const s=[];for(let e=0;e<t.length;e++){const a=t[e];if(o.matched){s.push(e);continue}const l=evaluateVisibilityCriteriaGroup({...i,criteriaGroup:a.when});null===l?r?n=!1:s.push(e):!0===l?(o.matched=a,o.currentValue=a.value,o.currentConditionIndex=e,s.push(e)):s.push(e)}if(i.simplifyCriteria)for(let e=s.length-1;e>=0;e--)o.remainingConditionalValues.splice(s[e],1);return n&&(o.remainingConditionalValues=void 0),o}var CANVAS_VIZ_CONTROL_PARAM="$viz";function evaluateNodeVisibility({node:e,...t}){var r;const i=getPropertiesValue(e),n=null==(r=null==i?void 0:i[CANVAS_VIZ_CONTROL_PARAM])?void 0:r.value,o=evaluateNodeVisibilityParameter({...t,parameter:n});return(null==n?void 0:n.criteria)&&0===n.criteria.clauses.length&&t.simplifyCriteria&&(null==i||delete i[CANVAS_VIZ_CONTROL_PARAM]),o}function evaluateWalkTreeNodeVisibility({rules:e,showIndeterminate:t,rootNodeInvisibleHandling:r="throw",context:i}){const{type:n,node:o,actions:s,ancestorsAndSelf:a}=i;if("component"!==n)return!0;const l=evaluateNodeVisibility({node:o,rules:e,simplifyCriteria:!0});return!(null===l&&!t||!1===l)||(1===a.length&&"ignore"===r||s.remove(),!1)}function evaluateWalkTreePropertyCriteria({rules:e,node:t,keepIndeterminate:r}){const i=getPropertiesValue(t);i&&Object.entries(i).forEach((([t,n])=>{var o,s,a;if(n.locales||n.localesConditions){[...Object.keys(null!=(o=n.locales)?o:{}),...Object.keys(null!=(s=n.localesConditions)?s:{})].forEach((t=>{var i,o,s,a;const{currentValue:l,remainingConditionalValues:c}=evaluatePropertyCriteria({baseValue:null==(i=n.locales)?void 0:i[t],conditionalValues:null==(o=n.localesConditions)?void 0:o[t],rules:e,simplifyCriteria:!0,keepIndeterminate:r});null==l?null==(s=n.locales)||delete s[t]:(null!=n.locales||(n.locales={}),n.locales[t]=l),(null==c?void 0:c.length)?(null!=n.localesConditions||(n.localesConditions={}),n.localesConditions[t]=c):null==(a=n.localesConditions)||delete a[t]})),Object.keys(null!=(a=n.localesConditions)?a:{}).length||delete n.localesConditions,n.locales||n.localesConditions||delete i[t]}else{const{currentValue:o,remainingConditionalValues:s}=evaluatePropertyCriteria({baseValue:n.value,conditionalValues:n.conditions,rules:e,simplifyCriteria:!0,keepIndeterminate:r});null===o?delete i[t]:void 0!==o?n.value=o:delete n.value,void 0===s?delete n.conditions:n.conditions=s}}))}var isEvaluator=(e,t)=>Array.isArray(e)?e.includes(t):e===t,containsEvaluator=(e,t)=>Array.isArray(e)?e.some((e=>t.includes(e))):t.includes(e),startsWithEvaluator=(e,t)=>Array.isArray(e)?e.some((e=>t.startsWith(e))):t.startsWith(e),endsWithEvaluator=(e,t)=>Array.isArray(e)?e.some((e=>t.endsWith(e))):t.endsWith(e),emptyEvaluator=(e,t)=>""===t,stringOperatorEvaluators={is:isEvaluator,has:containsEvaluator,startswith:startsWithEvaluator,endswith:endsWithEvaluator,empty:emptyEvaluator},numericOperatorEvaluators={gt:(e,t)=>e>t,lt:(e,t)=>e<t};function evaluateNumericOperator(e,t){const{op:r,value:i}=e,n=numericOperatorEvaluators[r];if(!n)return null;if("string"==typeof t&&""===t.trim()||"string"==typeof i&&""===i.trim())return!1;const o=Number(t),s=Number(i);return!isNaN(o)&&!isNaN(s)&&n(o,s)}function evaluateStringMatch(e,t,r){const{op:i,value:n}=e;if(r&&!r.has(i))return null;if(i in numericOperatorEvaluators)return evaluateNumericOperator(e,t);let o=i;const s=i.startsWith("!");s&&(o=o.slice(1));const a=stringOperatorEvaluators[o];if(!a)return null;const l=a(n,t);return s?!l:l}var dynamicInputVisibilityOperators=new Set(["is","!is","has","!has","startswith","!startswith","endswith","!endswith","empty","!empty"]),CANVAS_VIZ_DI_RULE="$di";function createDynamicInputVisibilityRule(e){return{[CANVAS_VIZ_DI_RULE]:t=>{const{source:r}=t,i=r?e[r]:void 0;return evaluateStringMatch(t,null!=i?i:"",dynamicInputVisibilityOperators)}}}var dynamicTokenVisibilityOperators=new Set(["is","!is","has","!has","startswith","!startswith","endswith","!endswith","empty","!empty","gt","lt"]),CANVAS_VIZ_DYNAMIC_TOKEN_RULE="$dt";function toStringValue(e){return"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):""}function toStringCriteriaValue(e){return Array.isArray(e)?e.map((e=>toStringValue(e))):toStringValue(e)}function isUnbound(e){return null==e||"string"==typeof e&&hasReferencedVariables(e)>0}function createDynamicTokenVisibilityRule(){return{[CANVAS_VIZ_DYNAMIC_TOKEN_RULE]:e=>{const{source:t,value:r}=e;if(isUnbound(t))return null;const i=toStringValue(t),n=toStringCriteriaValue(r);return evaluateStringMatch({...e,value:n},i,dynamicTokenVisibilityOperators)}}}var localeVisibilityOperators=new Set(["is","!is"]),CANVAS_VIZ_LOCALE_RULE="$locale";function createLocaleVisibilityRule(e){return{[CANVAS_VIZ_LOCALE_RULE]:t=>!!e&&evaluateStringMatch(t,e,localeVisibilityOperators)}}var quirksVisibilityOperators=new Set(["is","!is","has","!has","startswith","!startswith","endswith","!endswith","empty","!empty"]),CANVAS_VIZ_QUIRKS_RULE="$qk";function createQuirksVisibilityRule(e){return{[CANVAS_VIZ_QUIRKS_RULE]:t=>{const{source:r}=t,i=r?e[r]:void 0;return evaluateStringMatch(t,null!=i?i:"",quirksVisibilityOperators)}}}function extractLocales({component:e}){var t;const r={},i=null==(t=e.slots)?void 0:t[CANVAS_LOCALIZATION_SLOT];return null==i||i.forEach((e=>{var t;const i=null==(t=e.parameters)?void 0:t[CANVAS_LOCALE_TAG_PARAM];(null==i?void 0:i.value)&&"string"==typeof i.value&&(r[i.value]=r[i.value]||[],r[i.value].push(e))})),r}function localize(e){const t=e.nodes,r=e.locale;if(!r)return;const i=createLocaleVisibilityRule(r);walkNodeTree(t,(e=>{const{type:t,node:n,actions:o}=e;if("component"!==t)return void localizeProperties(n,r,i);if(evaluateWalkTreeNodeVisibility({context:e,rules:i,showIndeterminate:!0,rootNodeInvisibleHandling:"ignore"}))if(n.type===CANVAS_LOCALIZATION_TYPE){const e=extractLocales({component:n});let t;if(r&&(t=e[r]),null==t?void 0:t.length){t.forEach((e=>{removeLocaleProperty(e),localizeProperties(e,r,i)}));const[e,...n]=t;o.replace(e),n.length&&o.insertAfter(n)}else o.remove()}else localizeProperties(n,r,i)}))}function removeLocaleProperty(e){const t=getPropertiesValue(e);(null==t?void 0:t[CANVAS_LOCALE_TAG_PARAM])&&delete t[CANVAS_LOCALE_TAG_PARAM],t&&0===Object.keys(t).length&&("fields"in e&&delete e.fields,"parameters"in e&&delete e.parameters)}function localizeProperties(e,t,r){const i=getPropertiesValue(e);i&&(Object.entries(i).forEach((([e,r])=>{var n,o;t||(delete r.locales,delete r.localesConditions);const s=t?null==(n=r.locales)?void 0:n[t]:void 0;void 0!==s&&(r.value=s);const a=t?null==(o=r.localesConditions)?void 0:o[t]:void 0;void 0!==a&&(r.conditions=a),delete r.locales,delete r.localesConditions,void 0===r.value&&void 0===r.conditions&&delete i[e]})),evaluateWalkTreePropertyCriteria({node:e,rules:r,keepIndeterminate:!0}))}var UniqueBatchEntries=class{constructor(e,t){this.groups=e.reduce(((e,r)=>{var i;const n=t(r.args);return e[n]=null!=(i=e[n])?i:[],e[n].push(r),e}),{})}resolveKey(e,t){this.groups[e].forEach((e=>e.resolve(t)))}resolveRemaining(e){Object.keys(this.groups).forEach((t=>{this.groups[t].forEach((t=>{t.isCompleted||t.resolve(e)}))}))}};function walkPropertyValues(e,t){var r,i;[void 0,...new Set([...Object.keys(null!=(r=e.locales)?r:{}),...Object.keys(null!=(i=e.localesConditions)?i:{})])].forEach((r=>{var i,n;for(let o=(null!=(n=void 0===r?e.conditions:null==(i=e.localesConditions)?void 0:i[r])?n:[]).length-1;o>=-1;o--){const i=getEffectivePropertyValue({property:e,locale:r,conditionIndex:o,strict:!0});t({locale:r,conditionIndex:o,value:i})}}))}var _baseUrl,import_api7=require("@uniformdev/context/api"),releaseContentsUrl="/api/v1/entity-releases",EntityReleasesClient=class extends import_api7.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(releaseContentsUrl,{...e,projectId:t});return await this.apiClient(r)}},import_api8=require("@uniformdev/context/api"),_IntegrationPropertyEditorsClient=class e extends import_api8.ApiClient{constructor(e){super(e),this.teamId=e.teamId}get(t){const r=this.createUrl(__privateGet(e,_baseUrl),{...t,teamId:this.teamId});return this.apiClient(r)}async deploy(t){const r=this.createUrl(__privateGet(e,_baseUrl));await this.apiClient(r,{method:"PUT",body:JSON.stringify({...t,teamId:this.teamId}),expectNoContent:!0})}async delete(t){const r=this.createUrl(__privateGet(e,_baseUrl));await this.apiClient(r,{method:"DELETE",body:JSON.stringify({...t,teamId:this.teamId}),expectNoContent:!0})}};__privateAdd(_IntegrationPropertyEditorsClient,_baseUrl=new WeakMap,"/api/v1/integration-property-editors");var _url2,_projectsUrl,IntegrationPropertyEditorsClient=_IntegrationPropertyEditorsClient,import_api9=require("@uniformdev/context/api"),LABELS_URL="/api/v1/labels",LabelClient=class extends import_api9.ApiClient{async getLabels(e){const{projectId:t}=this.options,r=this.createUrl(LABELS_URL,{...e,projectId:t});return await this.apiClient(r)}async upsertLabel(e){const{projectId:t}=this.options,r=this.createUrl(LABELS_URL);await this.apiClient(r,{method:"PUT",body:JSON.stringify({...e,projectId:t}),expectNoContent:!0})}async removeLabel(e){const{projectId:t}=this.options,r=this.createUrl(LABELS_URL);await this.apiClient(r,{method:"DELETE",body:JSON.stringify({...e,projectId:t}),expectNoContent:!0})}},UncachedLabelClient=class extends LabelClient{constructor(e){super({...e,bypassCache:!0})}},import_api10=require("@uniformdev/context/api"),localesUrl="/api/v1/locales",LocaleClient=class extends import_api10.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(localesUrl,{...e,projectId:t});return await this.apiClient(r)}async upsert(e){const t=this.createUrl(localesUrl);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){const t=this.createUrl(localesUrl);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},generateHash=({composition:e,secret:t})=>{if(!t)return;const r=`${JSON.stringify(e)}-${t}`;let i=0;for(let e=0;e<r.length;e++){i=(i<<5)-i+r.charCodeAt(e),i|=0}return i},isSelectComponentMessage=e=>"select-component"===e.type&&void 0!==e.id,isReadyMessage=e=>"ready"===e.type,isComponentActionMessage=e=>"trigger-component-action"===e.type,isUpdateCompositionMessage=e=>"update-composition"===e.type,isUpdateCompositionInternalMessage=e=>"update-composition-internal"===e.type,isAddComponentMessage=e=>"add-component"===e.type,isMovingComponentMessage=e=>"move-component"===e.type,isUpdateComponentParameterMessage=e=>"update-component-parameter"===e.type,isDismissPlaceholderMessage=e=>"dismiss-placeholder"===e.type,isTriggerCompositionActionMessage=e=>"trigger-composition-action"===e.type,isUpdatePreviewSettingsMessage=e=>"update-preview-settings"===e.type,isUpdateFeatureFlagsMessage=e=>"update-feature-flags"===e.type,isUpdateAiActionsMessage=e=>"update-ai-actions"===e.type,isUpdateContextualEditingStateInternalMessage=e=>"update-contextual-editing-state-internal"===e.type,isReportRenderedCompositionsMessage=e=>"report-rendered-compositions"===e.type,isSelectParameterMessage=e=>"select-parameter"===e.type,isOpenParameterEditorMessage=e=>"open-parameter-editor"===e.type,isUpdateComponentReferencesMessage=e=>"update-component-references"===e.type,isRequestComponentSuggestionMessage=e=>"request-component-suggestion"===e.type,isSuggestComponentMessage=e=>"suggest-component"===e.type,isContextStorageUpdatedMessage=e=>"context-storage-command-executed"===e.type,createCanvasChannel=({listenTo:e,broadcastTo:t})=>{let r=0;const i={},n=[...t],o=e=>{n.forEach((t=>null==t?void 0:t.postMessage(JSON.stringify(e),"*")));for(const t in i){const r=i[t];r.types.includes(e.type)&&r.handler(e,new MessageEvent(e.type))}},s=e=>{if("string"!=typeof e.data)return;let t=null;try{const r=JSON.parse(e.data);Object.hasOwn(r,"type")&&(t=r)}catch(e){}if(t)for(const r in i){const n=i[r];n.types.includes(t.type)&&n.handler(t,e)}};e.forEach((e=>e.addEventListener("message",s)));return{broadcastTo:n,ready:e=>{var t,r,i;if("undefined"==typeof window)return;const n=null==(t=window.__UNIFORM_CONTEXTUAL_EDITING__)?void 0:t.framework,s=null==(r=window.__UNIFORM_CONTEXTUAL_EDITING__)?void 0:r.version,a=null==(i=window.__UNIFORM_CONTEXTUAL_EDITING__)?void 0:i.canvasPackageVersion,l={type:"ready",framework:n,version:s,rsc:null==e?void 0:e.rsc,canvasPackageVersion:a};o(l)},destroy:()=>{e.forEach((e=>e.removeEventListener("message",s)))},addBroadcastTarget:e=>{n.includes(e)||n.push(e)},triggerComponentAction:e=>{const t={...e,type:"trigger-component-action"};o(t)},selectComponent:e=>{o({type:"select-component",id:e})},updateComposition:(e,t)=>{const r={type:"update-composition",composition:e,hash:generateHash({composition:e,secret:t}),eventTimestamp:Date.now()};o(r)},updateCompositionInternal:(e,t,r)=>{const i={type:"update-composition-internal",composition:e,hash:t,eventTimestamp:null!=r?r:Date.now()};o(i)},on:(e,t)=>{const n=++r;return i[n]={types:Array.isArray(e)?e:[e],handler:t},()=>{delete i[n]}},addComponent:e=>{const t={...e,type:"add-component"};o(t)},moveComponent:e=>{const t={...e,type:"move-component"};o(t)},updateComponentParameter:e=>{const t={...e,type:"update-component-parameter"};o(t)},dismissPlaceholder:e=>{const t={...e,type:"dismiss-placeholder"};o(t)},triggerCompositionAction:e=>{const t={...e,type:"trigger-composition-action"};o(t)},updatePreviewSettings:e=>{const t={...e,type:"update-preview-settings"};o(t)},updateFeatureFlags:e=>{const t={...e,type:"update-feature-flags"};o(t)},updateAiActions:e=>{const t={...e,type:"update-ai-actions"};o(t)},updateContextualEditingStateInternal:e=>{const t={...e,type:"update-contextual-editing-state-internal"};o(t)},selectParameter:e=>{const t={...e,type:"select-parameter"};o(t)},openParameterEditor:e=>{const t={...e,type:"open-parameter-editor"};o(t)},reportRenderedCompositions:e=>{const t={...e,type:"report-rendered-compositions"};o(t)},editorStateUpdated:()=>{o({type:"editor-state-updated"})},updateComponentReferences:e=>{const t={...e,type:"update-component-references"};o(t)},requestComponentSuggestion:e=>{const t={...e,type:"request-component-suggestion"};o(t)},suggestComponent:e=>{const t={...e,type:"suggest-component"};o(t)},requestPageHtml:e=>{const t={...e,type:"request-page-html"};o(t)},sendPageHtml:e=>{const t={...e,type:"send-page-html"};o(t)},contextStorageUpdated:e=>{const t={...e,type:"context-storage-command-executed"};o(t)}}},import_api11=require("@uniformdev/context/api"),previewUrlsUrl="/api/v1/preview-urls",previewViewportsUrl="/api/v1/preview-viewports",PreviewClient=class extends import_api11.ApiClient{constructor(e){super(e)}async getPreviewUrl({id:e}){var t;return null!=(t=(await this.getPreviewUrls({id:e})).previewUrls[0])?t:null}async getPreviewUrls(e){const{projectId:t}=this.options,r=this.createUrl(previewUrlsUrl,{...e,projectId:t});return await this.apiClient(r)}async upsertPreviewUrl(e){const t=this.createUrl(previewUrlsUrl);return await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId})})}async deletePreviewUrl(e){const t=this.createUrl(previewUrlsUrl);return await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId})})}async getPreviewViewport({id:e}){var t;return null!=(t=(await this.getPreviewViewports({id:e})).previewViewports[0])?t:null}async getPreviewViewports(e){const{projectId:t}=this.options,r=this.createUrl(previewViewportsUrl,{...e,projectId:t});return await this.apiClient(r)}async upsertPreviewViewport(e){const t=this.createUrl(previewViewportsUrl);return await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId})})}async deletePreviewViewport(e){const t=this.createUrl(previewViewportsUrl);return await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId})})}},import_api12=require("@uniformdev/context/api"),_ProjectClient=class e extends import_api12.ApiClient{constructor(e){super({...e,bypassCache:!0})}async get(t){const r=this.createUrl(__privateGet(e,_url2),{...t});return await this.apiClient(r)}async getProjects(t){const r=this.createUrl(__privateGet(e,_projectsUrl),t?{...t}:{});return await this.apiClient(r)}async upsert(t){const r=this.createUrl(__privateGet(e,_url2));return await this.apiClient(r,{method:"PUT",body:JSON.stringify({...t})})}async delete(t){const r=this.createUrl(__privateGet(e,_url2));await this.apiClient(r,{method:"DELETE",body:JSON.stringify({...t}),expectNoContent:!0})}};_url2=new WeakMap,_projectsUrl=new WeakMap,__privateAdd(_ProjectClient,_url2,"/api/v1/project"),__privateAdd(_ProjectClient,_projectsUrl,"/api/v1/projects");var ProjectClient=_ProjectClient,import_api13=require("@uniformdev/context/api"),PromptsUrl="/api/v1/prompts",PromptClient=class extends import_api13.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(PromptsUrl,{...e,projectId:t});return await this.apiClient(r)}async upsert(e){const t=this.createUrl(PromptsUrl);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){const t=this.createUrl(PromptsUrl);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},import_api14=require("@uniformdev/context/api"),RELATIONSHIPS_URL="/api/v1/relationships",RelationshipClient=class extends import_api14.ApiClient{constructor(e){super(e),this.get=async e=>{const{projectId:t}=this.options,r=this.createUrl(RELATIONSHIPS_URL,{...e,projectId:t});return this.apiClient(r)}}},import_api15=require("@uniformdev/context/api"),releasesUrl="/api/v1/releases",ReleaseClient=class extends import_api15.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(releasesUrl,{...e,projectId:t});return await this.apiClient(r)}async upsert(e){const t=this.createUrl(releasesUrl);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){const t=this.createUrl(releasesUrl);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async ready(e){const t=this.createUrl(releasesUrl);await this.apiClient(t,{method:"PATCH",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},import_api16=require("@uniformdev/context/api"),releaseContentsUrl2="/api/v1/release-contents",ReleaseContentsClient=class extends import_api16.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(releaseContentsUrl2,{...e,projectId:t});return await this.apiClient(r)}async remove(e){const t=this.createUrl(releaseContentsUrl2);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},import_api17=require("@uniformdev/context/api"),ROUTE_URL="/api/v1/route",RouteClient=class extends import_api17.ApiClient{constructor(e){var t;e.limitPolicy||(e.limitPolicy=createLimitPolicy({})),super(e),this.edgeApiHost=null!=(t=e.edgeApiHost)?t:"https://uniform.global"}async getRoute(e){const{projectId:t}=this.options,r=this.createUrl(ROUTE_URL,{...e,projectId:t},this.edgeApiHost);return await this.apiClient(r,this.options.disableSWR?{headers:{"x-disable-swr":"true"}}:void 0)}},LOCALE_DYNAMIC_INPUT_NAME="locale",mergeAssetConfigWithDefaults=e=>{var t;return{...e,allowedTypes:null!=(t=e.allowedTypes)?t:["image"]}};function autoFixParameterGroups(e){var t;const r=null!=(t=e.filter((e=>"group"===e.type)))?t:[];if(0===r.length)return!1;let i=!1;for(;r.length>0;){const t=r.shift(),n=t.typeConfig&&"object"==typeof t.typeConfig&&"childrenParams"in t.typeConfig&&Array.isArray(t.typeConfig.childrenParams)?t.typeConfig.childrenParams:[],o=new Set(n),s=e.findIndex((e=>e.id===t.id)),a=o.size;for(let t=s+1;t<=s+a;t++){const r=e[t];if(r){if(!o.has(r.id))break;o.delete(r.id)}}if(o.size>0){const t=Array.from(o);let r=s+a-o.size;for(const i of t){const t=e.findIndex((e=>e.id===i));if(-1!==t){const[i]=e.splice(t,1);t>r&&r++,e.splice(r,0,i)}else n.splice(n.indexOf(i),1)}i=!0}}return i}var createUniformApiEnhancer=({apiUrl:e})=>async t=>{const r=await fetch(e,{method:"post",body:JSON.stringify({composition:t.composition,hash:t.hash}),headers:{"Content-Type":"application/json"}}),i=await r.json();if(!r.ok)throw new Error("Error reading enhanced composition");return i.composition};function convertEntryToPutEntry(e){return{entry:{type:e.entry.type,_dataResources:e.entry._dataResources,_id:e.entry._id,_name:e.entry._name,_slug:e.entry._slug,_pattern:e.entry._pattern,_overridability:e.entry._overridability,_overrides:e.entry._overrides,fields:e.entry.fields,_locales:e.entry._locales,_thumbnail:e.entry._thumbnail,_patternDataResources:e.entry._patternDataResources},pattern:e.pattern,state:e.state,projectId:e.projectId,releaseId:e.releaseId,workflowId:e.workflowId,workflowStageId:e.workflowStageId,editionId:e.editionId,editionName:e.editionName,editionPriority:e.editionPriority}}var getDataSourceVariantFromRouteGetParams=(e,t)=>{var r,i;return"dataSourceVariant"in e?e.dataSourceVariant:(null!=(i=null!=(r=null==e?void 0:e.state)?r:t)?i:CANVAS_PUBLISHED_STATE)!==CANVAS_PUBLISHED_STATE?"unpublished":void 0},ATTRIBUTE_COMPONENT_ID="data-uniform-component-id",ATTRIBUTE_PARAMETER_ID="data-uniform-parameter-id",ATTRIBUTE_PARAMETER_VALUE="data-uniform-parameter-value",ATTRIBUTE_PARAMETER_TYPE="data-uniform-parameter-type",ATTRIBUTE_PLACEHOLDER="data-uniform-placeholder",ATTRIBUTE_MULTILINE="data-uniform-is-multiline",getParameterAttributes=({id:e,component:t,placeholder:r,isMultiline:i=!1})=>{var n,o,s;const a=null==t?void 0:t._id,l=null==(n=null==t?void 0:t.parameters)?void 0:n[e],c=null==l?void 0:l.value,p=null==l?void 0:l.type,u=null!=(s=null==(o=null==l?void 0:l._contextualEditing)?void 0:o.isEditable)&&s;return{[ATTRIBUTE_COMPONENT_ID]:a,[ATTRIBUTE_PARAMETER_ID]:e,[ATTRIBUTE_PARAMETER_VALUE]:String(null!=c?c:""),[ATTRIBUTE_PARAMETER_TYPE]:p,[ATTRIBUTE_PLACEHOLDER]:r,[ATTRIBUTE_MULTILINE]:i,contentEditable:u}},isAllowedReferrer=e=>Boolean(null==e?void 0:e.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//)),isSystemComponentDefinition=e=>e.startsWith("$");function mapSlotToPersonalizedVariations(e){return e?e.map(((e,t)=>{var r,i;const n=null==(i=null==(r=e.parameters)?void 0:r[CANVAS_PERSONALIZATION_PARAM])?void 0:i.value,o=(null==n?void 0:n.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:n}})):[]}function mapSlotToTestVariations(e){return e?e.map(((e,t)=>{var r,i,n;const o=null==(i=null==(r=e.parameters)?void 0:r[CANVAS_TEST_VARIANT_PARAM])?void 0:i.value,s=null!=(n=null==o?void 0:o.id)?n:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:s,testDistribution:null==o?void 0:o.testDistribution,control:null==o?void 0:o.control}})):[]}var SEPARATOR="_",isComponentPlaceholderId=e=>e===PLACEHOLDER_ID||"string"==typeof e&&(null==e?void 0:e.startsWith(PLACEHOLDER_ID)),generateComponentPlaceholderId=(e,t,r)=>{if(1===t)return PLACEHOLDER_ID;let i=[PLACEHOLDER_ID,e];return r&&(i=[...i,r.nodeId,r.slotId]),i.join(SEPARATOR)},parseComponentPlaceholderId=e=>{if(!isComponentPlaceholderId(e))return;const t=e.split(SEPARATOR),r={id:t[1]};return t[2]&&(r.parent={nodeId:t[2],slotId:t[3]}),r};function bindVariables({variables:e,value:t,errorPrefix:r="Variable",handleBinding:i}){let n=0,o=0;const s=[],a=(e,t,i)=>{const n=t[e];return void 0===n?(i.push(`${r} "${e}" is not defined`),""):n},l=[];return parseVariableExpression(t,((t,r)=>{if(o++,"text"===r)return void l.push(t);const c=(null!=i?i:a)(t,e,s);n++,l.push(c)})),{result:1===o?l[0]:l.join(""),boundCount:n,errors:s.length>0?s:void 0}}var import_immer=require("immer");function bindVariablesToObject(e){return bindVariablesToObjectRecursive(e)}function bindVariablesToObjectRecursive({value:e,recursivePath:t,...r}){let i=0;const n=[];if("string"==typeof e)return bindVariables({...r,value:e});if("object"!=typeof e||null===e)return{boundCount:0,result:e};const o=handleRichTextNodeBinding(e,r);if(void 0!==o)return o;const s=((0,import_immer.isDraft)(e)?(e,t)=>(t(e),e):import_immer.produce)(e,(e=>{Object.entries(e).forEach((([o,s])=>{const a=t?`${t}.${o}`:o;if("string"==typeof s){const t=bindVariables({...r,value:s});return void((s!==t.result||t.errors)&&(i+=t.boundCount,e[o]=t.result,t.errors&&n.push(...t.errors.map((e=>"string"==typeof e?`${a}: ${e}`:(e.message=`${a}: ${e.message}`,e))))))}const l=bindVariablesToObjectRecursive({...r,value:s,recursivePath:a});(l.boundCount||l.errors)&&(i+=l.boundCount,e[o]=l.result,l.errors&&n.push(...l.errors))}))}));return{boundCount:i,result:s,errors:n.length>0?n:void 0}}function handleRichTextNodeBinding(e,t){if("type"in e&&"variable"===e.type&&"reference"in e&&"string"==typeof e.reference&&"version"in e&&1===e.version){const r=bindVariables({...t,value:createVariableReference(e.reference)}),i={detail:0,format:0,mode:"normal",style:"",text:r.result,type:"text",version:1};return{...r,result:i}}}var import_api19=require("@uniformdev/context/api"),version="20.57.1",import_api18=require("@uniformdev/context/api"),workflowsUrl="/api/v1/workflows",WorkflowClient=class extends import_api18.ApiClient{constructor(e){super(e)}async get(e){const{projectId:t}=this.options,r=this.createUrl(workflowsUrl,{...e,projectId:t});return await this.apiClient(r)}async upsert(e){const t=this.createUrl(workflowsUrl);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){const t=this.createUrl(workflowsUrl);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},CanvasClientError=import_api19.ApiClientError;
//# sourceMappingURL=/sm/423869546379d48c73d658b5ec2335dbf44279fa4725fffd812ed65233712acd.map