@uniformdev/canvas 16.2.1-nuxt.249 → 16.2.1-nuxt.325

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ var Y=Object.create;var E=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ne=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ye=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+n+'" is not supported')});var Ce=(n,e)=>()=>(n&&(e=n(n=0)),e);var _=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},S=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of X(e))!te.call(n,o)&&o!==t&&E(n,o,{get:()=>e[o],enumerable:!(r=Q(e,o))||r.enumerable});return n};var re=(n,e,t)=>(t=n!=null?Y(ee(n)):{},S(e||!n||!n.__esModule?E(t,"default",{value:n,enumerable:!0}):t,n)),Te=n=>S(E({},"__esModule",{value:!0}),n);var ge=(n,e,t)=>(ne(n,typeof e!="symbol"?e+"":e,t),t),O=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var oe=(n,e,t)=>(O(n,e,"read from private field"),t?t.call(n):e.get(n)),Pe=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},ie=(n,e,t,r)=>(O(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Ae=(n,e,t,r)=>({set _(o){ie(n,e,o,t)},get _(){return oe(n,e,r)}});var M=_((Se,k)=>{function u(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.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))}k.exports=u;u.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};u.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};u.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};u.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};u.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};u.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};u.prototype.start=u.prototype.try;u.prototype.errors=function(){return this._errors};u.prototype.attempts=function(){return this._attempts};u.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(n[i]||0)+1;n[i]=s,s>=t&&(e=o,t=s)}return e}});var V=_(f=>{var se=M();f.operation=function(n){var e=f.timeouts(n);return new se(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};f.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};f.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};f.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var o=0;o<t.length;o++){var i=t[o],s=n[i];n[i]=function(c){var m=f.operation(e),p=Array.prototype.slice.call(arguments,1),l=p.pop();p.push(function(h){m.retry(h)||(h&&(arguments[0]=m.mainError()),l.apply(this,arguments))}),m.attempt(function(){c.apply(n,p)})}.bind(n,s),n[i].options=e}}});var B=_((Ne,$)=>{$.exports=V()});function P(n,e){let t=[{ancestorsAndSelf:[{component:n,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=t.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:a=>{Object.assign(o.component,a),["parameters","variant","slots","data","_pattern","_patternError"].forEach(m=>{a[m]||delete o.component[m]})},removeComponent:()=>{let{parentSlot:a,parentSlotIndex:c}=r.ancestorsAndSelf[0],m=r.ancestorsAndSelf[1];if(a&&typeof c!="undefined")m.component.slots[a].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:a=>{let c=Array.isArray(a)?a:[a],{parentSlot:m,parentSlotIndex:p}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(m&&typeof p!="undefined")l.component.slots[m].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let a=Object.keys(s);for(let c=a.length-1;c>=0;c--){let m=a[c],p=s[m];for(let l=p.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:p[l],parentSlot:m,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(t.length>0)}function v(n){let e=[];for(let t=n.length-1;t>=0;t--){let{parentSlot:r,parentSlotIndex:o}=n[t];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var N=class{constructor(e,t){this.groups=e.reduce((r,o)=>{var s;let i=t(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,t){this.groups[e].forEach(r=>r.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var A=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},L=class{constructor(){this._componentIndex={};this._rootBuilder=new A}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new A,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,r)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){t=new Map(t);for(let[o,i]of r.resolveComponentEnhancers())t.set(o,i)}return t}};var w=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 be({handleBatch:n,shouldQueue:e,limitPolicy:t}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((a,c)=>{r.push(new w(a,c,s))})},completeAll:async()=>{if(r.length>0){try{await n(r)}catch(a){r.forEach(c=>c.reject(a))}if(r.some(a=>!a.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:t}}var x=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function b({limit:n,interval:e,strict:t}){if(!Number.isFinite(n))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let p=Date.now();return p-o>e?(i=1,o=p,0):(i<n?i++:(o+=e,i=1),o-p)}let a=[];function c(){let p=Date.now();if(a.length<n)return a.push(p),0;let l=a.shift()+e;return p>=l?(a.push(p),0):(a.push(l),l-p)}let m=t?c:s;return p=>{let l=function(...h){if(!l.isEnabled)return(async()=>p.apply(this,h))();let y;return new Promise((C,W)=>{y=setTimeout(()=>{C(p.apply(this,h)),r.delete(y)},m()),r.set(y,W)})};return l.abort=()=>{for(let h of r.keys())clearTimeout(h),r.get(h)(new x);r.clear(),a.splice(0,a.length)},l.isEnabled=!0,l}}var U=re(B(),1),ae=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),R=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}},ce=(n,e,t)=>{let r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},pe=n=>ae.has(n),D=n=>globalThis.DOMException===void 0?new Error(n):new DOMException(n);async function I(n,e){return new Promise((t,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=U.default.operation(e);o.attempt(async i=>{try{t(await n(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof R)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!pe(s.message))o.stop(),r(s);else{ce(s,i,e);try{await e.onFailedAttempt(s)}catch(a){r(a);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?D("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:D(i))},{once:!0})})}function j({throttle:n={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=n?b(n):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>I(s,e)}return i()}}var d=async n=>await n();async function Fe({composition:n,enhancers:e,context:t,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
2
+ ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
+
4
+ `))}}){let o=[],i=new Set,s=new Set;P(n,(c,m)=>{var l;Object.entries((l=c.parameters)!=null?l:{}).forEach(([h,y])=>{let C=e.resolveParameterEnhancer(c,h,y);C&&(s.add(C),o.push(le(c,m,h,y,C,t)))});let p=e.resolveComponentEnhancers(c);o.push(me(c,m,p,t)),i.add(p)}),o.push(...Array.from(i).flatMap(c=>Array.from(c).map(async([,m])=>{var p;try{m.completeAll&&await((p=m.limitPolicy)!=null?p:d)(()=>m.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async c=>{var m;try{c.completeAll&&await((m=c.limitPolicy)!=null?m:d)(()=>c.completeAll())}catch(p){return{error:p,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(o)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&r(a)}async function me(n,e,t,r){return t.size&&(n.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let c=await(i.completeAll?d:(s=i.limitPolicy)!=null?s:d)(async()=>i.enhanceOne({component:n,context:r}));c!=null&&(n.data[o]=c)}catch(a){let c=`Component ${v(e)} (type: ${n.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete n.data[o],{message:c,error:a}}}))}async function le(n,e,t,r,o,i){var s;try{let c=await(o.completeAll?d:(s=o.limitPolicy)!=null?s:d)(async()=>o.enhanceOne({parameter:r,parameterName:t,component:n,context:i}));c===null?delete n.parameters[t]:typeof c=="undefined"?n.parameters[t]={...r,value:r.value}:n.parameters[t]={...r,value:c}}catch(a){let c=`Component ${v(e)} (type: ${n.type}): enhancing parameter ${t} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete n.parameters[t],{message:c,error:a}}}var ze=(n,...e)=>({enhanceOne:r=>{let o="enhanceOne"in n?n.enhanceOne(r):n(r);for(let i of e){let s=ue(o)?o:Promise.resolve(o),a="enhanceOne"in i?i.enhanceOne:i;o=s.then(c=>a({...r,parameter:{type:r.parameter.type,value:c}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in n?(r=n.completeAll)==null?void 0:r.call(n):0)!=null?o:0}});function ue(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var T=class extends Error{constructor(t,r,o,i,s,a){super(`${t}
5
+ ${i}${s?" "+s:""} (${r} ${o}${a?` Request ID: ${a}`:""})`);this.errorMessage=t;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=a;Object.setPrototypeOf(this,T.prototype)}},g=class{constructor(e){var r,o,i,s,a,c;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(a=e.limitPolicy)!=null?a:j({}),bypassCache:(c=e.bypassCache)!=null?c:!1}}async getCompositionList(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionById(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(r)}async updateComponentDefinition(e){let 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){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(r["x-bypass-cache"]="true");let o=await this.options.fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...r}});if(!o.ok){let s="";try{let a=await o.text();try{let c=JSON.parse(a);c.errorMessage?s=Array.isArray(c.errorMessage)?c.errorMessage.join(", "):c.errorMessage:s=a}catch(c){s=a}}catch(a){s="General error"}throw new T(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,g.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},F=class extends g{constructor(e){super({...e,bypassCache:!0})}};var Je="$personalization",We="$test",G="$localization",Ye="intentTag",z="locale",Qe="pz",Xe="test",H="localized",et=0,tt=64,K="$pzCrit",Z="$tstVrnt",nt="$enr";var ot=n=>n.startsWith("$");function at(n){return n?n.map((e,t)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[K])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:r}}):[]}function mt(n){return n?n.map((e,t)=>{var i,s,a;let r=(s=(i=e.parameters)==null?void 0:i[Z])==null?void 0:s.value,o=(a=r==null?void 0:r.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var q="https://js.pusher.com/7.0.3/pusher.min.js";async function he(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((n,e)=>{let t=setTimeout(()=>{window.Pusher&&n(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${q}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=q,r.addEventListener("load",()=>{clearTimeout(t),n(window.Pusher)}),document.head.appendChild(r)})}async function ut(){let n=await he();if(!n)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new n("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=t.subscribe(r);return{unsubscribe:()=>t.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function J(n,e,t){return`${n}.${e}@${t}`}function yt({projectId:n,compositionId:e,compositionState:t=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=J(n,e,t),a=r(s),c=a.addEventHandler(i,o);return()=>{c(),a.unsubscribe()}}function fe({component:n}){var r;let e={},t=(r=n.slots)==null?void 0:r[H];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[z];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function gt({composition:n,locale:e}){P(n,(t,r,o)=>{if(t.type===G){let i=fe({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),a;if(s&&(a=i[s]),a!=null&&a.length){let[c,...m]=a;o.replaceComponent(c),m.length&&o.insertAfter(m)}else o.removeComponent()}})}export{ye as a,Ce as b,_ as c,Ee as d,re as e,Te as f,ge as g,oe as h,Pe as i,ie as j,Ae as k,P as l,v as m,N as n,A as o,L as p,w as q,be as r,j as s,d as t,Fe as u,ze as v,T as w,g as x,F as y,Je as z,We as A,G as B,Ye as C,z as D,Qe as E,Xe as F,H as G,et as H,tt as I,K as J,Z as K,nt as L,ot as M,at as N,mt as O,ut as P,J as Q,yt as R,fe as S,gt as T};
package/dist/cli/cli.d.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  import { UniformCLIPlugin } from '@uniformdev/cli';
2
- import { r as ComponentDefinition, v as CompositionAPIResponse } from '../createEventBus-c826147a.js';
2
+ import { A as CanvasDefinitions } from '../createEventBus-97db7eb7.js';
3
3
  import { UniformPackage } from '@uniformdev/cli/sync';
4
4
  import 'pusher-js';
5
5
 
6
- declare type CanvasPackage = UniformPackage & {
7
- components?: Array<ComponentDefinition>;
8
- compositions?: Array<CompositionAPIResponse>;
9
- };
6
+ declare type CanvasPackage = UniformPackage & CanvasDefinitions;
10
7
  declare function readCanvasPackage(filename: string, assertExists: boolean): CanvasPackage;
11
8
  declare function writeCanvasPackage(filename: string, packageContents: CanvasPackage): void;
12
9
 
package/dist/cli/cli.js CHANGED
@@ -78,7 +78,7 @@ ${v.join(`
78
78
  `),void 0,"versionWarning"),f(this,V,"f").key[a]=!0,t.alias&&this.alias(a,t.alias);let p=t.deprecate||t.deprecated;p&&this.deprecateOption(a,p);let i=t.demand||t.required||t.require;i&&this.demand(a,i),t.demandOption&&this.demandOption(a,typeof t.demandOption=="string"?t.demandOption:void 0),t.conflicts&&this.conflicts(a,t.conflicts),"default"in t&&this.default(a,t.default),t.implies!==void 0&&this.implies(a,t.implies),t.nargs!==void 0&&this.nargs(a,t.nargs),t.config&&this.config(a,t.configParser),t.normalize&&this.normalize(a),t.choices&&this.choices(a,t.choices),t.coerce&&this.coerce(a,t.coerce),t.group&&this.group(a,t.group),(t.boolean||t.type==="boolean")&&(this.boolean(a),t.alias&&this.boolean(t.alias)),(t.array||t.type==="array")&&(this.array(a),t.alias&&this.array(t.alias)),(t.number||t.type==="number")&&(this.number(a),t.alias&&this.number(t.alias)),(t.string||t.type==="string")&&(this.string(a),t.alias&&this.string(t.alias)),(t.count||t.type==="count")&&this.count(a),typeof t.global=="boolean"&&this.global(a,t.global),t.defaultDescription&&(f(this,V,"f").defaultDescription[a]=t.defaultDescription),t.skipValidation&&this.skipValidation(a);let r=t.describe||t.description||t.desc;this.describe(a,r),t.hidden&&this.hide(a),t.requiresArg&&this.requiresArg(a)}return this}options(a,t){return this.option(a,t)}parse(a,t,p){E("[string|array] [function|boolean|object] [function]",[a,t,p],arguments.length),this[Sr](),typeof a=="undefined"&&(a=f(this,k1,"f")),typeof t=="object"&&(D(this,ya,t,"f"),t=p),typeof t=="function"&&(D(this,ze,t,"f"),t=!1),t||D(this,k1,a,"f"),f(this,ze,"f")&&D(this,Qe,!1,"f");let i=this[St](a,!!t),r=this.parsed;return f(this,Je,"f").setParsed(this.parsed),de(i)?i.then(d=>(f(this,ze,"f")&&f(this,ze,"f").call(this,f(this,U1,"f"),d,f(this,Ae,"f")),d)).catch(d=>{throw f(this,ze,"f")&&f(this,ze,"f")(d,this.parsed.argv,f(this,Ae,"f")),d}).finally(()=>{this[Li](),this.parsed=r}):(f(this,ze,"f")&&f(this,ze,"f").call(this,f(this,U1,"f"),i,f(this,Ae,"f")),this[Li](),this.parsed=r,i)}parseAsync(a,t,p){let i=this.parse(a,t,p);return de(i)?i:Promise.resolve(i)}parseSync(a,t,p){let i=this.parse(a,t,p);if(de(i))throw new ae(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(a){return E("<object>",[a],arguments.length),D(this,vp,a,"f"),this}pkgConf(a,t){E("<string> [string]",[a,t],arguments.length);let p=null,i=this[Ti](t||f(this,wa,"f"));return i[a]&&typeof i[a]=="object"&&(p=lp(i[a],t||f(this,wa,"f"),this[Aa]()["deep-merge-config"]||!1,f(this,q,"f")),f(this,V,"f").configObjects=(f(this,V,"f").configObjects||[]).concat(p)),this}positional(a,t){E("<string> <object>",[a,t],arguments.length);let p=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=B1(t,(d,n)=>d==="type"&&!["string","number","boolean"].includes(n)?!1:p.includes(d));let i=f(this,xt,"f").fullCommands[f(this,xt,"f").fullCommands.length-1],r=i?f(this,he,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Ha(r).forEach(d=>{let n=r[d];Array.isArray(n)?n.indexOf(a)!==-1&&(t[d]=!0):n[a]&&!(d in t)&&(t[d]=n[a])}),this.group(a,f(this,W,"f").getPositionalGroupName()),this.option(a,t)}recommendCommands(a=!0){return E("[boolean]",[a],arguments.length),D(this,gp,a,"f"),this}required(a,t,p){return this.demand(a,t,p)}require(a,t,p){return this.demand(a,t,p)}requiresArg(a){return E("<array|string|object> [number]",[a],arguments.length),typeof a=="string"&&f(this,V,"f").narg[a]?this:(this[Ya](this.requiresArg.bind(this),"narg",a,NaN),this)}showCompletionScript(a,t){return E("[string] [string]",[a,t],arguments.length),a=a||this.$0,f(this,Wa,"f").log(f(this,Je,"f").generateCompletionScript(a,t||f(this,qe,"f")||"completion")),this}showHelp(a){if(E("[string|function]",[a],arguments.length),D(this,He,!0,"f"),!f(this,W,"f").hasCachedHelpMessage()){if(!this.parsed){let p=this[St](f(this,k1,"f"),void 0,void 0,0,!0);if(de(p))return p.then(()=>{f(this,W,"f").showHelp(a)}),this}let t=f(this,he,"f").runDefaultBuilderOn(this);if(de(t))return t.then(()=>{f(this,W,"f").showHelp(a)}),this}return f(this,W,"f").showHelp(a),this}scriptName(a){return this.customScriptName=!0,this.$0=a,this}showHelpOnFail(a,t){return E("[boolean|string] [string]",[a,t],arguments.length),f(this,W,"f").showHelpOnFail(a,t),this}showVersion(a){return E("[string|function]",[a],arguments.length),f(this,W,"f").showVersion(a),this}skipValidation(a){return E("<array|string>",[a],arguments.length),this[$1]("skipValidation",a),this}strict(a){return E("[boolean]",[a],arguments.length),D(this,Ca,a!==!1,"f"),this}strictCommands(a){return E("[boolean]",[a],arguments.length),D(this,xa,a!==!1,"f"),this}strictOptions(a){return E("[boolean]",[a],arguments.length),D(this,Sa,a!==!1,"f"),this}string(a){return E("<array|string>",[a],arguments.length),this[$1]("string",a),this[Ea](a),this}terminalWidth(){return E([],0),f(this,q,"f").process.stdColumns}updateLocale(a){return this.updateStrings(a)}updateStrings(a){return E("<object>",[a],arguments.length),D(this,ba,!1,"f"),f(this,q,"f").y18n.updateLocale(a),this}usage(a,t,p,i){if(E("<string|null|undefined> [string|boolean] [function|object] [function]",[a,t,p,i],arguments.length),t!==void 0){if(je(a,null,f(this,q,"f")),(a||"").match(/^\$0( |$)/))return this.command(a,t,p,i);throw new ae(".usage() description must start with $0 if being used as alias for .command()")}else return f(this,W,"f").usage(a),this}version(a,t,p){let i="version";if(E("[boolean|string] [string] [string]",[a,t,p],arguments.length),f(this,c1,"f")&&(this[Oi](f(this,c1,"f")),f(this,W,"f").version(void 0),D(this,c1,null,"f")),arguments.length===0)p=this[Nr](),a=i;else if(arguments.length===1){if(a===!1)return this;p=a,a=i}else arguments.length===2&&(p=t,t=void 0);return D(this,c1,typeof a=="string"?a:i,"f"),t=t||f(this,W,"f").deferY18nLookup("Show version number"),f(this,W,"f").version(p||void 0),this.boolean(f(this,c1,"f")),this.describe(f(this,c1,"f"),t),this}wrap(a){return E("<number|null|undefined>",[a],arguments.length),f(this,W,"f").wrap(a),this}[(he=new WeakMap,wa=new WeakMap,xt=new WeakMap,Je=new WeakMap,qe=new WeakMap,mp=new WeakMap,U1=new WeakMap,ba=new WeakMap,cp=new WeakMap,Qe=new WeakMap,up=new WeakMap,Ze=new WeakMap,m1=new WeakMap,He=new WeakMap,Xe=new WeakMap,fp=new WeakMap,Wa=new WeakMap,Ae=new WeakMap,V=new WeakMap,hp=new WeakMap,vp=new WeakMap,ze=new WeakMap,ya=new WeakMap,Ga=new WeakMap,_a=new WeakMap,k1=new WeakMap,gp=new WeakMap,q=new WeakMap,Ca=new WeakMap,xa=new WeakMap,Sa=new WeakMap,W=new WeakMap,c1=new WeakMap,le=new WeakMap,_r)](a){if(!a._||!a["--"])return a;a._.push.apply(a._,a["--"]);try{delete a["--"]}catch(t){}return a}[Cr](){return{log:(...a)=>{this[wp]()||console.log(...a),D(this,He,!0,"f"),f(this,Ae,"f").length&&D(this,Ae,f(this,Ae,"f")+`
79
79
  `,"f"),D(this,Ae,f(this,Ae,"f")+a.join(" "),"f")},error:(...a)=>{this[wp]()||console.error(...a),D(this,He,!0,"f"),f(this,Ae,"f").length&&D(this,Ae,f(this,Ae,"f")+`
80
80
  `,"f"),D(this,Ae,f(this,Ae,"f")+a.join(" "),"f")}}}[Oi](a){Ha(f(this,V,"f")).forEach(t=>{if((i=>i==="configObjects")(t))return;let p=f(this,V,"f")[t];Array.isArray(p)?p.includes(a)&&p.splice(p.indexOf(a),1):typeof p=="object"&&delete p[a]}),delete f(this,W,"f").getDescriptions()[a]}[xr](a,t,p){f(this,cp,"f")[p]||(f(this,q,"f").process.emitWarning(a,t),f(this,cp,"f")[p]=!0)}[Sr](){f(this,up,"f").push({options:f(this,V,"f"),configObjects:f(this,V,"f").configObjects.slice(0),exitProcess:f(this,Qe,"f"),groups:f(this,m1,"f"),strict:f(this,Ca,"f"),strictCommands:f(this,xa,"f"),strictOptions:f(this,Sa,"f"),completionCommand:f(this,qe,"f"),output:f(this,Ae,"f"),exitError:f(this,U1,"f"),hasOutput:f(this,He,"f"),parsed:this.parsed,parseFn:f(this,ze,"f"),parseContext:f(this,ya,"f")}),f(this,W,"f").freeze(),f(this,le,"f").freeze(),f(this,he,"f").freeze(),f(this,Ze,"f").freeze()}[Ar](){let a="",t;return/\b(node|iojs|electron)(\.exe)?$/.test(f(this,q,"f").process.argv()[0])?t=f(this,q,"f").process.argv().slice(1,2):t=f(this,q,"f").process.argv().slice(0,1),a=t.map(p=>{let i=this[Mr](f(this,wa,"f"),p);return p.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<p.length?i:p}).join(" ").trim(),f(this,q,"f").getEnv("_")&&f(this,q,"f").getProcessArgvBin()===f(this,q,"f").getEnv("_")&&(a=f(this,q,"f").getEnv("_").replace(`${f(this,q,"f").path.dirname(f(this,q,"f").process.execPath())}/`,"")),a}[Aa](){return f(this,vp,"f")}[Di](){if(!f(this,ba,"f"))return;let a=f(this,q,"f").getEnv("LC_ALL")||f(this,q,"f").getEnv("LC_MESSAGES")||f(this,q,"f").getEnv("LANG")||f(this,q,"f").getEnv("LANGUAGE")||"en_US";this.locale(a.replace(/[.:].*/,""))}[Nr](){return this[Ti]().version||"unknown"}[Er](a){let t=a["--"]?a["--"]:a._;for(let p=0,i;(i=t[p])!==void 0;p++)f(this,q,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(t[p]=Number(i));return a}[Ti](a){let t=a||"*";if(f(this,Ga,"f")[t])return f(this,Ga,"f")[t];let p={};try{let i=a||f(this,q,"f").mainFilename;!a&&f(this,q,"f").path.extname(i)&&(i=f(this,q,"f").path.dirname(i));let r=f(this,q,"f").findUp(i,(d,n)=>{if(n.includes("package.json"))return"package.json"});je(r,void 0,f(this,q,"f")),p=JSON.parse(f(this,q,"f").readFileSync(r,"utf8"))}catch(i){}return f(this,Ga,"f")[t]=p||{},f(this,Ga,"f")[t]}[$1](a,t){t=[].concat(t),t.forEach(p=>{p=this[Ii](p),f(this,V,"f")[a].push(p)})}[Ya](a,t,p,i){this[Pi](a,t,p,i,(r,d,n)=>{f(this,V,"f")[r][d]=n})}[Fi](a,t,p,i){this[Pi](a,t,p,i,(r,d,n)=>{f(this,V,"f")[r][d]=(f(this,V,"f")[r][d]||[]).concat(n)})}[Pi](a,t,p,i,r){if(Array.isArray(p))p.forEach(d=>{a(d,i)});else if((d=>typeof d=="object")(p))for(let d of Ha(p))a(d,p[d]);else r(t,this[Ii](p),i)}[Ii](a){return a==="__proto__"?"___proto___":a}[Vi](a,t){return this[Ya](this[Vi].bind(this),"key",a,t),this}[Li](){var a,t,p,i,r,d,n,o,l,s,m,c;let u=f(this,up,"f").pop();je(u,void 0,f(this,q,"f"));let v;a=this,t=this,p=this,i=this,r=this,d=this,n=this,o=this,l=this,s=this,m=this,c=this,{options:{set value(g){D(a,V,g,"f")}}.value,configObjects:v,exitProcess:{set value(g){D(t,Qe,g,"f")}}.value,groups:{set value(g){D(p,m1,g,"f")}}.value,output:{set value(g){D(i,Ae,g,"f")}}.value,exitError:{set value(g){D(r,U1,g,"f")}}.value,hasOutput:{set value(g){D(d,He,g,"f")}}.value,parsed:this.parsed,strict:{set value(g){D(n,Ca,g,"f")}}.value,strictCommands:{set value(g){D(o,xa,g,"f")}}.value,strictOptions:{set value(g){D(l,Sa,g,"f")}}.value,completionCommand:{set value(g){D(s,qe,g,"f")}}.value,parseFn:{set value(g){D(m,ze,g,"f")}}.value,parseContext:{set value(g){D(c,ya,g,"f")}}.value}=u,f(this,V,"f").configObjects=v,f(this,W,"f").unfreeze(),f(this,le,"f").unfreeze(),f(this,he,"f").unfreeze(),f(this,Ze,"f").unfreeze()}[Or](a,t){return ga(t,p=>(a(p),p))}getInternalMethods(){return{getCommandInstance:this[Dr].bind(this),getContext:this[Tr].bind(this),getHasOutput:this[Fr].bind(this),getLoggerInstance:this[Pr].bind(this),getParseContext:this[Ir].bind(this),getParserConfiguration:this[Aa].bind(this),getUsageInstance:this[Vr].bind(this),getValidationInstance:this[Lr].bind(this),hasParseCallback:this[wp].bind(this),isGlobalContext:this[jr].bind(this),postProcess:this[Na].bind(this),reset:this[ji].bind(this),runValidation:this[Mi].bind(this),runYargsParserAndExecuteCommands:this[St].bind(this),setHasOutput:this[Br].bind(this)}}[Dr](){return f(this,he,"f")}[Tr](){return f(this,xt,"f")}[Fr](){return f(this,He,"f")}[Pr](){return f(this,Wa,"f")}[Ir](){return f(this,ya,"f")||{}}[Vr](){return f(this,W,"f")}[Lr](){return f(this,le,"f")}[wp](){return!!f(this,ze,"f")}[jr](){return f(this,fp,"f")}[Na](a,t,p,i){return p||de(a)||(t||(a=this[_r](a)),(this[Aa]()["parse-positional-numbers"]||this[Aa]()["parse-positional-numbers"]===void 0)&&(a=this[Er](a)),i&&(a=va(a,this,f(this,Ze,"f").getMiddleware(),!1))),a}[ji](a={}){D(this,V,f(this,V,"f")||{},"f");let t={};t.local=f(this,V,"f").local||[],t.configObjects=f(this,V,"f").configObjects||[];let p={};t.local.forEach(d=>{p[d]=!0,(a[d]||[]).forEach(n=>{p[n]=!0})}),Object.assign(f(this,_a,"f"),Object.keys(f(this,m1,"f")).reduce((d,n)=>{let o=f(this,m1,"f")[n].filter(l=>!(l in p));return o.length>0&&(d[n]=o),d},{})),D(this,m1,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(d=>{t[d]=(f(this,V,"f")[d]||[]).filter(n=>!p[n])}),r.forEach(d=>{t[d]=B1(f(this,V,"f")[d],n=>!p[n])}),t.envPrefix=f(this,V,"f").envPrefix,D(this,V,t,"f"),D(this,W,f(this,W,"f")?f(this,W,"f").reset(p):ur(this,f(this,q,"f")),"f"),D(this,le,f(this,le,"f")?f(this,le,"f").reset(p):br(this,f(this,W,"f"),f(this,q,"f")),"f"),D(this,he,f(this,he,"f")?f(this,he,"f").reset():lr(f(this,W,"f"),f(this,le,"f"),f(this,Ze,"f"),f(this,q,"f")),"f"),f(this,Je,"f")||D(this,Je,vr(this,f(this,W,"f"),f(this,he,"f"),f(this,q,"f")),"f"),f(this,Ze,"f").reset(),D(this,qe,null,"f"),D(this,Ae,"","f"),D(this,U1,null,"f"),D(this,He,!1,"f"),this.parsed=!1,this}[Mr](a,t){return f(this,q,"f").path.relative(a,t)}[St](a,t,p,i=0,r=!1){let d=!!p||r;a=a||f(this,k1,"f"),f(this,V,"f").__=f(this,q,"f").y18n.__,f(this,V,"f").configuration=this[Aa]();let n=!!f(this,V,"f").configuration["populate--"],o=Object.assign({},f(this,V,"f").configuration,{"populate--":!0}),l=f(this,q,"f").Parser.detailed(a,Object.assign({},f(this,V,"f"),{configuration:{"parse-positional-numbers":!1,...o}})),s=Object.assign(l.argv,f(this,ya,"f")),m,c=l.aliases,u=!1,v=!1;Object.keys(s).forEach(g=>{g===f(this,Xe,"f")&&s[g]?u=!0:g===f(this,c1,"f")&&s[g]&&(v=!0)}),s.$0=this.$0,this.parsed=l,i===0&&f(this,W,"f").clearCachedHelpMessage();try{if(this[Di](),t)return this[Na](s,n,!!p,!1);f(this,Xe,"f")&&[f(this,Xe,"f")].concat(c[f(this,Xe,"f")]||[]).filter(T=>T.length>1).includes(""+s._[s._.length-1])&&(s._.pop(),u=!0),D(this,fp,!1,"f");let g=f(this,he,"f").getCommands(),h=f(this,Je,"f").completionKey in s,C=u||h||r;if(s._.length){if(g.length){let x;for(let T=i||0,B;s._[T]!==void 0;T++)if(B=String(s._[T]),g.includes(B)&&B!==f(this,qe,"f")){let R=f(this,he,"f").runCommand(B,this,l,T+1,r,u||v||r);return this[Na](R,n,!!p,!1)}else if(!x&&B!==f(this,qe,"f")){x=B;break}!f(this,he,"f").hasDefaultCommand()&&f(this,gp,"f")&&x&&!C&&f(this,le,"f").recommendCommands(x,g)}f(this,qe,"f")&&s._.includes(f(this,qe,"f"))&&!h&&(f(this,Qe,"f")&&R1(!0),this.showCompletionScript(),this.exit(0))}if(f(this,he,"f").hasDefaultCommand()&&!C){let x=f(this,he,"f").runCommand(null,this,l,0,r,u||v||r);return this[Na](x,n,!!p,!1)}if(h){f(this,Qe,"f")&&R1(!0),a=[].concat(a);let x=a.slice(a.indexOf(`--${f(this,Je,"f").completionKey}`)+1);return f(this,Je,"f").getCompletion(x,(T,B)=>{if(T)throw new ae(T.message);(B||[]).forEach(R=>{f(this,Wa,"f").log(R)}),this.exit(0)}),this[Na](s,!n,!!p,!1)}if(f(this,He,"f")||(u?(f(this,Qe,"f")&&R1(!0),d=!0,this.showHelp("log"),this.exit(0)):v&&(f(this,Qe,"f")&&R1(!0),d=!0,f(this,W,"f").showVersion("log"),this.exit(0))),!d&&f(this,V,"f").skipValidation.length>0&&(d=Object.keys(s).some(x=>f(this,V,"f").skipValidation.indexOf(x)>=0&&s[x]===!0)),!d){if(l.error)throw new ae(l.error.message);if(!h){let x=this[Mi](c,{},l.error);p||(m=va(s,this,f(this,Ze,"f").getMiddleware(),!0)),m=this[Or](x,m!=null?m:s),de(m)&&!p&&(m=m.then(()=>va(s,this,f(this,Ze,"f").getMiddleware(),!1)))}}}catch(g){if(g instanceof ae)f(this,W,"f").fail(g.message,g);else throw g}return this[Na](m!=null?m:s,n,!!p,!0)}[Mi](a,t,p,i){let r={...this.getDemandedOptions()};return d=>{if(p)throw new ae(p.message);f(this,le,"f").nonOptionCount(d),f(this,le,"f").requiredArguments(d,r);let n=!1;f(this,xa,"f")&&(n=f(this,le,"f").unknownCommands(d)),f(this,Ca,"f")&&!n?f(this,le,"f").unknownArguments(d,a,t,!!i):f(this,Sa,"f")&&f(this,le,"f").unknownArguments(d,a,{},!1,!1),f(this,le,"f").limitedChoices(d),f(this,le,"f").implications(d),f(this,le,"f").conflicting(d)}}[Br](){D(this,He,!0,"f")}[Ea](a){if(typeof a=="string")f(this,V,"f").key[a]=!0;else for(let t of a)f(this,V,"f").key[t]=!0}};function mr(e){return!!e&&typeof e.getInternalMethods=="function"}var _s=Rr(dr),Ka=_s;var Ri=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function Ui({limit:e,interval:a,strict:t}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(a))throw new TypeError("Expected `interval` to be a finite number");let p=new Map,i=0,r=0;function d(){let s=Date.now();return s-i>a?(r=1,i=s,0):(r<e?r++:(i+=a,r=1),i-s)}let n=[];function o(){let s=Date.now();if(n.length<e)return n.push(s),0;let m=n.shift()+a;return s>=m?(n.push(s),0):(n.push(m),m-s)}let l=t?o:d;return s=>{let m=function(...c){if(!m.isEnabled)return(async()=>s.apply(this,c))();let u;return new Promise((v,g)=>{u=setTimeout(()=>{v(s.apply(this,c)),p.delete(u)},l()),p.set(u,g)})};return m.abort=()=>{for(let c of p.keys())clearTimeout(c),p.get(c)(new Ri);p.clear(),n.splice(0,n.length)},m.isEnabled=!0,m}}var Wr=n1(Hr(),1),xs=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),ki=class extends Error{constructor(a){super(),a instanceof Error?(this.originalError=a,{message:a}=a):(this.originalError=new Error(a),this.originalError.stack=this.stack),this.name="AbortError",this.message=a}},Ss=(e,a,t)=>{let p=t.retries-(a-1);return e.attemptNumber=a,e.retriesLeft=p,e},As=e=>xs.has(e),zr=e=>globalThis.DOMException===void 0?new Error(e):new DOMException(e);async function $i(e,a){return new Promise((t,p)=>{a={onFailedAttempt(){},retries:10,...a};let i=Wr.default.operation(a);i.attempt(async r=>{try{t(await e(r))}catch(d){if(!(d instanceof Error)){p(new TypeError(`Non-error was thrown: "${d}". You should only throw errors.`));return}if(d instanceof ki)i.stop(),p(d.originalError);else if(d instanceof TypeError&&!As(d.message))i.stop(),p(d);else{Ss(d,r,a);try{await a.onFailedAttempt(d)}catch(n){p(n);return}i.retry(d)||p(i.mainError())}}}),a.signal&&!a.signal.aborted&&a.signal.addEventListener("abort",()=>{i.stop();let r=a.signal.reason===void 0?zr("The operation was aborted."):a.signal.reason;p(r instanceof Error?r:zr(r))},{once:!0})})}function Gr({throttle:e={interval:1e3,limit:10},retry:a={retries:1,factor:1.66}}){let t=e?Ui(e):null;return function(i){let r=async()=>await i();if(t&&(r=t(r)),a){let d=r;r=()=>$i(d,a)}return r()}}var At=class extends Error{constructor(t,p,i,r,d,n){super(`${t}
81
- ${r}${d?" "+d:""} (${p} ${i}${n?` Request ID: ${n}`:""})`);this.errorMessage=t;this.fetchMethod=p;this.fetchUri=i;this.statusCode=r;this.statusText=d;this.requestId=n;Object.setPrototypeOf(this,At.prototype)}},Nt=class{constructor(a){var p,i,r,d,n,o;if(!a.apiKey&&!a.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=a.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...a,fetch:t,apiHost:(p=a.apiHost)!=null?p:"https://uniform.app",apiKey:(i=a.apiKey)!=null?i:null,projectId:(r=a.projectId)!=null?r:null,bearerToken:(d=a.bearerToken)!=null?d:null,limitPolicy:(n=a.limitPolicy)!=null?n:Gr({}),bypassCache:(o=a.bypassCache)!=null?o:!1}}async getCompositionList(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas",{...a,projectId:t});return await this.apiClient(p)}async getCompositionBySlug(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas",{...a,projectId:t});return await this.apiClient(p)}async getCompositionById(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas",{...a,projectId:t});return await this.apiClient(p)}async updateComposition(a){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(a){let t=this.createUrl("/api/v1/canvas"),{projectId:p}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:p}),expectNoContent:!0})}async getComponentDefinitions(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas-definitions",{...a,projectId:t});return await this.apiClient(p)}async updateComponentDefinition(a){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(a){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(a,t){return this.options.limitPolicy(async()=>{var r;let p=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},i=await this.options.fetch(a.toString(),{...t,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...t==null?void 0:t.headers,...p}});if(!i.ok){let d="";try{let n=await i.text();try{let o=JSON.parse(n);o.errorMessage?d=Array.isArray(o.errorMessage)?o.errorMessage.join(", "):o.errorMessage:d=n}catch(o){d=n}}catch(n){d="General error"}throw new At(d,(r=t==null?void 0:t.method)!=null?r:"GET",a.toString(),i.status,i.statusText,Nt.getRequestId(i))}return t!=null&&t.expectNoContent?null:await i.json()})}createUrl(a,t){let p=new URL(`${this.options.apiHost}${a}`);return Object.entries(t!=null?t:{}).forEach(([i,r])=>{var d;typeof r!==void 0&&r!==null&&p.searchParams.append(i,(d=r==null?void 0:r.toString())!=null?d:"")}),p}static getRequestId(a){let t=a.headers.get("apigw-requestid");if(t)return t}},ie=class extends Nt{constructor(a){super({...a,bypassCache:!0})}};var Ns=Object.create,Kr=Object.defineProperty,Es=Object.getOwnPropertyDescriptor,Os=Object.getOwnPropertyNames,Ds=Object.getPrototypeOf,Ts=Object.prototype.hasOwnProperty,Yr=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(a,t)=>(typeof require!="undefined"?require:a)[t]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')}),u1=(e,a)=>()=>(a||e((a={exports:{}}).exports,a),a.exports),Fs=(e,a,t,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of Os(a))!Ts.call(e,i)&&i!==t&&Kr(e,i,{get:()=>a[i],enumerable:!(p=Es(a,i))||p.enumerable});return e},qi=(e,a,t)=>(t=e!=null?Ns(Ds(e)):{},Fs(a||!e||!e.__esModule?Kr(t,"default",{value:e,enumerable:!0}):t,e)),Ps=u1((e,a)=>{"use strict";a.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}),Jr=u1((e,a)=>{var t=Ps(),p={};for(let d of Object.keys(t))p[t[d]]=d;var i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};a.exports=i;for(let d of Object.keys(i)){if(!("channels"in i[d]))throw new Error("missing channels property: "+d);if(!("labels"in i[d]))throw new Error("missing channel labels property: "+d);if(i[d].labels.length!==i[d].channels)throw new Error("channel and label counts mismatch: "+d);let{channels:n,labels:o}=i[d];delete i[d].channels,delete i[d].labels,Object.defineProperty(i[d],"channels",{value:n}),Object.defineProperty(i[d],"labels",{value:o})}i.rgb.hsl=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255,s=Math.min(n,o,l),m=Math.max(n,o,l),c=m-s,u,v;m===s?u=0:n===m?u=(o-l)/c:o===m?u=2+(l-n)/c:l===m&&(u=4+(n-o)/c),u=Math.min(u*60,360),u<0&&(u+=360);let g=(s+m)/2;return m===s?v=0:g<=.5?v=c/(m+s):v=c/(2-m-s),[u,v*100,g*100]},i.rgb.hsv=function(d){let n,o,l,s,m,c=d[0]/255,u=d[1]/255,v=d[2]/255,g=Math.max(c,u,v),h=g-Math.min(c,u,v),C=function(x){return(g-x)/6/h+1/2};return h===0?(s=0,m=0):(m=h/g,n=C(c),o=C(u),l=C(v),c===g?s=l-o:u===g?s=1/3+n-l:v===g&&(s=2/3+o-n),s<0?s+=1:s>1&&(s-=1)),[s*360,m*100,g*100]},i.rgb.hwb=function(d){let n=d[0],o=d[1],l=d[2],s=i.rgb.hsl(d)[0],m=1/255*Math.min(n,Math.min(o,l));return l=1-1/255*Math.max(n,Math.max(o,l)),[s,m*100,l*100]},i.rgb.cmyk=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255,s=Math.min(1-n,1-o,1-l),m=(1-n-s)/(1-s)||0,c=(1-o-s)/(1-s)||0,u=(1-l-s)/(1-s)||0;return[m*100,c*100,u*100,s*100]};function r(d,n){return(d[0]-n[0])**2+(d[1]-n[1])**2+(d[2]-n[2])**2}i.rgb.keyword=function(d){let n=p[d];if(n)return n;let o=1/0,l;for(let s of Object.keys(t)){let m=t[s],c=r(d,m);c<o&&(o=c,l=s)}return l},i.keyword.rgb=function(d){return t[d]},i.rgb.xyz=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255;n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,l=l>.04045?((l+.055)/1.055)**2.4:l/12.92;let s=n*.4124+o*.3576+l*.1805,m=n*.2126+o*.7152+l*.0722,c=n*.0193+o*.1192+l*.9505;return[s*100,m*100,c*100]},i.rgb.lab=function(d){let n=i.rgb.xyz(d),o=n[0],l=n[1],s=n[2];o/=95.047,l/=100,s/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,l=l>.008856?l**(1/3):7.787*l+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let m=116*l-16,c=500*(o-l),u=200*(l-s);return[m,c,u]},i.hsl.rgb=function(d){let n=d[0]/360,o=d[1]/100,l=d[2]/100,s,m,c;if(o===0)return c=l*255,[c,c,c];l<.5?s=l*(1+o):s=l+o-l*o;let u=2*l-s,v=[0,0,0];for(let g=0;g<3;g++)m=n+1/3*-(g-1),m<0&&m++,m>1&&m--,6*m<1?c=u+(s-u)*6*m:2*m<1?c=s:3*m<2?c=u+(s-u)*(2/3-m)*6:c=u,v[g]=c*255;return v},i.hsl.hsv=function(d){let n=d[0],o=d[1]/100,l=d[2]/100,s=o,m=Math.max(l,.01);l*=2,o*=l<=1?l:2-l,s*=m<=1?m:2-m;let c=(l+o)/2,u=l===0?2*s/(m+s):2*o/(l+o);return[n,u*100,c*100]},i.hsv.rgb=function(d){let n=d[0]/60,o=d[1]/100,l=d[2]/100,s=Math.floor(n)%6,m=n-Math.floor(n),c=255*l*(1-o),u=255*l*(1-o*m),v=255*l*(1-o*(1-m));switch(l*=255,s){case 0:return[l,v,c];case 1:return[u,l,c];case 2:return[c,l,v];case 3:return[c,u,l];case 4:return[v,c,l];case 5:return[l,c,u]}},i.hsv.hsl=function(d){let n=d[0],o=d[1]/100,l=d[2]/100,s=Math.max(l,.01),m,c;c=(2-o)*l;let u=(2-o)*s;return m=o*s,m/=u<=1?u:2-u,m=m||0,c/=2,[n,m*100,c*100]},i.hwb.rgb=function(d){let n=d[0]/360,o=d[1]/100,l=d[2]/100,s=o+l,m;s>1&&(o/=s,l/=s);let c=Math.floor(6*n),u=1-l;m=6*n-c,(c&1)!==0&&(m=1-m);let v=o+m*(u-o),g,h,C;switch(c){default:case 6:case 0:g=u,h=v,C=o;break;case 1:g=v,h=u,C=o;break;case 2:g=o,h=u,C=v;break;case 3:g=o,h=v,C=u;break;case 4:g=v,h=o,C=u;break;case 5:g=u,h=o,C=v;break}return[g*255,h*255,C*255]},i.cmyk.rgb=function(d){let n=d[0]/100,o=d[1]/100,l=d[2]/100,s=d[3]/100,m=1-Math.min(1,n*(1-s)+s),c=1-Math.min(1,o*(1-s)+s),u=1-Math.min(1,l*(1-s)+s);return[m*255,c*255,u*255]},i.xyz.rgb=function(d){let n=d[0]/100,o=d[1]/100,l=d[2]/100,s,m,c;return s=n*3.2406+o*-1.5372+l*-.4986,m=n*-.9689+o*1.8758+l*.0415,c=n*.0557+o*-.204+l*1.057,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,m=m>.0031308?1.055*m**(1/2.4)-.055:m*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,s=Math.min(Math.max(0,s),1),m=Math.min(Math.max(0,m),1),c=Math.min(Math.max(0,c),1),[s*255,m*255,c*255]},i.xyz.lab=function(d){let n=d[0],o=d[1],l=d[2];n/=95.047,o/=100,l/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,l=l>.008856?l**(1/3):7.787*l+16/116;let s=116*o-16,m=500*(n-o),c=200*(o-l);return[s,m,c]},i.lab.xyz=function(d){let n=d[0],o=d[1],l=d[2],s,m,c;m=(n+16)/116,s=o/500+m,c=m-l/200;let u=m**3,v=s**3,g=c**3;return m=u>.008856?u:(m-16/116)/7.787,s=v>.008856?v:(s-16/116)/7.787,c=g>.008856?g:(c-16/116)/7.787,s*=95.047,m*=100,c*=108.883,[s,m,c]},i.lab.lch=function(d){let n=d[0],o=d[1],l=d[2],s;s=Math.atan2(l,o)*360/2/Math.PI,s<0&&(s+=360);let m=Math.sqrt(o*o+l*l);return[n,m,s]},i.lch.lab=function(d){let n=d[0],o=d[1],l=d[2]/360*2*Math.PI,s=o*Math.cos(l),m=o*Math.sin(l);return[n,s,m]},i.rgb.ansi16=function(d,n=null){let[o,l,s]=d,m=n===null?i.rgb.hsv(d)[2]:n;if(m=Math.round(m/50),m===0)return 30;let c=30+(Math.round(s/255)<<2|Math.round(l/255)<<1|Math.round(o/255));return m===2&&(c+=60),c},i.hsv.ansi16=function(d){return i.rgb.ansi16(i.hsv.rgb(d),d[2])},i.rgb.ansi256=function(d){let n=d[0],o=d[1],l=d[2];return n===o&&o===l?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(o/255*5)+Math.round(l/255*5)},i.ansi16.rgb=function(d){let n=d%10;if(n===0||n===7)return d>50&&(n+=3.5),n=n/10.5*255,[n,n,n];let o=(~~(d>50)+1)*.5,l=(n&1)*o*255,s=(n>>1&1)*o*255,m=(n>>2&1)*o*255;return[l,s,m]},i.ansi256.rgb=function(d){if(d>=232){let m=(d-232)*10+8;return[m,m,m]}d-=16;let n,o=Math.floor(d/36)/5*255,l=Math.floor((n=d%36)/6)/5*255,s=n%6/5*255;return[o,l,s]},i.rgb.hex=function(d){let n=(((Math.round(d[0])&255)<<16)+((Math.round(d[1])&255)<<8)+(Math.round(d[2])&255)).toString(16).toUpperCase();return"000000".substring(n.length)+n},i.hex.rgb=function(d){let n=d.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];let o=n[0];n[0].length===3&&(o=o.split("").map(u=>u+u).join(""));let l=parseInt(o,16),s=l>>16&255,m=l>>8&255,c=l&255;return[s,m,c]},i.rgb.hcg=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255,s=Math.max(Math.max(n,o),l),m=Math.min(Math.min(n,o),l),c=s-m,u,v;return c<1?u=m/(1-c):u=0,c<=0?v=0:s===n?v=(o-l)/c%6:s===o?v=2+(l-n)/c:v=4+(n-o)/c,v/=6,v%=1,[v*360,c*100,u*100]},i.hsl.hcg=function(d){let n=d[1]/100,o=d[2]/100,l=o<.5?2*n*o:2*n*(1-o),s=0;return l<1&&(s=(o-.5*l)/(1-l)),[d[0],l*100,s*100]},i.hsv.hcg=function(d){let n=d[1]/100,o=d[2]/100,l=n*o,s=0;return l<1&&(s=(o-l)/(1-l)),[d[0],l*100,s*100]},i.hcg.rgb=function(d){let n=d[0]/360,o=d[1]/100,l=d[2]/100;if(o===0)return[l*255,l*255,l*255];let s=[0,0,0],m=n%1*6,c=m%1,u=1-c,v=0;switch(Math.floor(m)){case 0:s[0]=1,s[1]=c,s[2]=0;break;case 1:s[0]=u,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=c;break;case 3:s[0]=0,s[1]=u,s[2]=1;break;case 4:s[0]=c,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=u}return v=(1-o)*l,[(o*s[0]+v)*255,(o*s[1]+v)*255,(o*s[2]+v)*255]},i.hcg.hsv=function(d){let n=d[1]/100,o=d[2]/100,l=n+o*(1-n),s=0;return l>0&&(s=n/l),[d[0],s*100,l*100]},i.hcg.hsl=function(d){let n=d[1]/100,o=d[2]/100*(1-n)+.5*n,l=0;return o>0&&o<.5?l=n/(2*o):o>=.5&&o<1&&(l=n/(2*(1-o))),[d[0],l*100,o*100]},i.hcg.hwb=function(d){let n=d[1]/100,o=d[2]/100,l=n+o*(1-n);return[d[0],(l-n)*100,(1-l)*100]},i.hwb.hcg=function(d){let n=d[1]/100,o=d[2]/100,l=1-o,s=l-n,m=0;return s<1&&(m=(l-s)/(1-s)),[d[0],s*100,m*100]},i.apple.rgb=function(d){return[d[0]/65535*255,d[1]/65535*255,d[2]/65535*255]},i.rgb.apple=function(d){return[d[0]/255*65535,d[1]/255*65535,d[2]/255*65535]},i.gray.rgb=function(d){return[d[0]/100*255,d[0]/100*255,d[0]/100*255]},i.gray.hsl=function(d){return[0,0,d[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(d){return[0,100,d[0]]},i.gray.cmyk=function(d){return[0,0,0,d[0]]},i.gray.lab=function(d){return[d[0],0,0]},i.gray.hex=function(d){let n=Math.round(d[0]/100*255)&255,o=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(o.length)+o},i.rgb.gray=function(d){return[(d[0]+d[1]+d[2])/3/255*100]}}),Is=u1((e,a)=>{var t=Jr();function p(){let n={},o=Object.keys(t);for(let l=o.length,s=0;s<l;s++)n[o[s]]={distance:-1,parent:null};return n}function i(n){let o=p(),l=[n];for(o[n].distance=0;l.length;){let s=l.pop(),m=Object.keys(t[s]);for(let c=m.length,u=0;u<c;u++){let v=m[u],g=o[v];g.distance===-1&&(g.distance=o[s].distance+1,g.parent=s,l.unshift(v))}}return o}function r(n,o){return function(l){return o(n(l))}}function d(n,o){let l=[o[n].parent,n],s=t[o[n].parent][n],m=o[n].parent;for(;o[m].parent;)l.unshift(o[m].parent),s=r(t[o[m].parent][m],s),m=o[m].parent;return s.conversion=l,s}a.exports=function(n){let o=i(n),l={},s=Object.keys(o);for(let m=s.length,c=0;c<m;c++){let u=s[c];o[u].parent!==null&&(l[u]=d(u,o))}return l}}),Vs=u1((e,a)=>{var t=Jr(),p=Is(),i={},r=Object.keys(t);function d(o){let l=function(...s){let m=s[0];return m==null?m:(m.length>1&&(s=m),o(s))};return"conversion"in o&&(l.conversion=o.conversion),l}function n(o){let l=function(...s){let m=s[0];if(m==null)return m;m.length>1&&(s=m);let c=o(s);if(typeof c=="object")for(let u=c.length,v=0;v<u;v++)c[v]=Math.round(c[v]);return c};return"conversion"in o&&(l.conversion=o.conversion),l}r.forEach(o=>{i[o]={},Object.defineProperty(i[o],"channels",{value:t[o].channels}),Object.defineProperty(i[o],"labels",{value:t[o].labels});let l=p(o);Object.keys(l).forEach(s=>{let m=l[s];i[o][s]=n(m),i[o][s].raw=d(m)})}),a.exports=i}),Ls=u1((e,a)=>{"use strict";var t=(m,c)=>(...u)=>`\x1B[${m(...u)+c}m`,p=(m,c)=>(...u)=>{let v=m(...u);return`\x1B[${38+c};5;${v}m`},i=(m,c)=>(...u)=>{let v=m(...u);return`\x1B[${38+c};2;${v[0]};${v[1]};${v[2]}m`},r=m=>m,d=(m,c,u)=>[m,c,u],n=(m,c,u)=>{Object.defineProperty(m,c,{get:()=>{let v=u();return Object.defineProperty(m,c,{value:v,enumerable:!0,configurable:!0}),v},enumerable:!0,configurable:!0})},o,l=(m,c,u,v)=>{o===void 0&&(o=Vs());let g=v?10:0,h={};for(let[C,x]of Object.entries(o)){let T=C==="ansi16"?"ansi":C;C===c?h[T]=m(u,g):typeof x=="object"&&(h[T]=m(x[c],g))}return h};function s(){let m=new Map,c={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};c.color.gray=c.color.blackBright,c.bgColor.bgGray=c.bgColor.bgBlackBright,c.color.grey=c.color.blackBright,c.bgColor.bgGrey=c.bgColor.bgBlackBright;for(let[u,v]of Object.entries(c)){for(let[g,h]of Object.entries(v))c[g]={open:`\x1B[${h[0]}m`,close:`\x1B[${h[1]}m`},v[g]=c[g],m.set(h[0],h[1]);Object.defineProperty(c,u,{value:v,enumerable:!1})}return Object.defineProperty(c,"codes",{value:m,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",n(c.color,"ansi",()=>l(t,"ansi16",r,!1)),n(c.color,"ansi256",()=>l(p,"ansi256",r,!1)),n(c.color,"ansi16m",()=>l(i,"rgb",d,!1)),n(c.bgColor,"ansi",()=>l(t,"ansi16",r,!0)),n(c.bgColor,"ansi256",()=>l(p,"ansi256",r,!0)),n(c.bgColor,"ansi16m",()=>l(i,"rgb",d,!0)),c}Object.defineProperty(a,"exports",{enumerable:!0,get:s})}),js=u1((e,a)=>{"use strict";a.exports=(t,p=process.argv)=>{let i=t.startsWith("-")?"":t.length===1?"-":"--",r=p.indexOf(i+t),d=p.indexOf("--");return r!==-1&&(d===-1||r<d)}}),Ms=u1((e,a)=>{"use strict";var t=Yr("os"),p=Yr("tty"),i=js(),{env:r}=process,d;i("no-color")||i("no-colors")||i("color=false")||i("color=never")?d=0:(i("color")||i("colors")||i("color=true")||i("color=always"))&&(d=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?d=1:r.FORCE_COLOR==="false"?d=0:d=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function n(s){return s===0?!1:{level:s,hasBasic:!0,has256:s>=2,has16m:s>=3}}function o(s,m){if(d===0)return 0;if(i("color=16m")||i("color=full")||i("color=truecolor"))return 3;if(i("color=256"))return 2;if(s&&!m&&d===void 0)return 0;let c=d||0;if(r.TERM==="dumb")return c;if(process.platform==="win32"){let u=t.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(u=>u in r)||r.CI_NAME==="codeship"?1:c;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){let u=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:c}function l(s){let m=o(s,s&&s.isTTY);return n(m)}a.exports={supportsColor:l,stdout:n(o(!0,p.isatty(1))),stderr:n(o(!0,p.isatty(2)))}}),Bs=u1((e,a)=>{"use strict";var t=(i,r,d)=>{let n=i.indexOf(r);if(n===-1)return i;let o=r.length,l=0,s="";do s+=i.substr(l,n-l)+r+d,l=n+o,n=i.indexOf(r,l);while(n!==-1);return s+=i.substr(l),s},p=(i,r,d,n)=>{let o=0,l="";do{let s=i[n-1]==="\r";l+=i.substr(o,(s?n-1:n)-o)+r+(s?`\r
81
+ ${r}${d?" "+d:""} (${p} ${i}${n?` Request ID: ${n}`:""})`);this.errorMessage=t;this.fetchMethod=p;this.fetchUri=i;this.statusCode=r;this.statusText=d;this.requestId=n;Object.setPrototypeOf(this,At.prototype)}},Nt=class{constructor(a){var p,i,r,d,n,o;if(!a.apiKey&&!a.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=a.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...a,fetch:t,apiHost:(p=a.apiHost)!=null?p:"https://uniform.app",apiKey:(i=a.apiKey)!=null?i:null,projectId:(r=a.projectId)!=null?r:null,bearerToken:(d=a.bearerToken)!=null?d:null,limitPolicy:(n=a.limitPolicy)!=null?n:Gr({}),bypassCache:(o=a.bypassCache)!=null?o:!1}}async getCompositionList(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas",{...a,projectId:t});return await this.apiClient(p)}async getCompositionBySlug(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas",{...a,projectId:t});return await this.apiClient(p)}async getCompositionById(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas",{...a,projectId:t});return await this.apiClient(p)}async updateComposition(a){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(a){let t=this.createUrl("/api/v1/canvas"),{projectId:p}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:p}),expectNoContent:!0})}async getComponentDefinitions(a){let{projectId:t}=this.options,p=this.createUrl("/api/v1/canvas-definitions",{...a,projectId:t});return await this.apiClient(p)}async updateComponentDefinition(a){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(a){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(a,t){return this.options.limitPolicy(async()=>{var r;let p=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(p["x-bypass-cache"]="true");let i=await this.options.fetch(a.toString(),{...t,headers:{...t==null?void 0:t.headers,...p}});if(!i.ok){let d="";try{let n=await i.text();try{let o=JSON.parse(n);o.errorMessage?d=Array.isArray(o.errorMessage)?o.errorMessage.join(", "):o.errorMessage:d=n}catch(o){d=n}}catch(n){d="General error"}throw new At(d,(r=t==null?void 0:t.method)!=null?r:"GET",a.toString(),i.status,i.statusText,Nt.getRequestId(i))}return t!=null&&t.expectNoContent?null:await i.json()})}createUrl(a,t){let p=new URL(`${this.options.apiHost}${a}`);return Object.entries(t!=null?t:{}).forEach(([i,r])=>{var d;typeof r!==void 0&&r!==null&&p.searchParams.append(i,(d=r==null?void 0:r.toString())!=null?d:"")}),p}static getRequestId(a){let t=a.headers.get("apigw-requestid");if(t)return t}},ie=class extends Nt{constructor(a){super({...a,bypassCache:!0})}};var Ns=Object.create,Kr=Object.defineProperty,Es=Object.getOwnPropertyDescriptor,Os=Object.getOwnPropertyNames,Ds=Object.getPrototypeOf,Ts=Object.prototype.hasOwnProperty,Yr=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(a,t)=>(typeof require!="undefined"?require:a)[t]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')}),u1=(e,a)=>()=>(a||e((a={exports:{}}).exports,a),a.exports),Fs=(e,a,t,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of Os(a))!Ts.call(e,i)&&i!==t&&Kr(e,i,{get:()=>a[i],enumerable:!(p=Es(a,i))||p.enumerable});return e},qi=(e,a,t)=>(t=e!=null?Ns(Ds(e)):{},Fs(a||!e||!e.__esModule?Kr(t,"default",{value:e,enumerable:!0}):t,e)),Ps=u1((e,a)=>{"use strict";a.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}),Jr=u1((e,a)=>{var t=Ps(),p={};for(let d of Object.keys(t))p[t[d]]=d;var i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};a.exports=i;for(let d of Object.keys(i)){if(!("channels"in i[d]))throw new Error("missing channels property: "+d);if(!("labels"in i[d]))throw new Error("missing channel labels property: "+d);if(i[d].labels.length!==i[d].channels)throw new Error("channel and label counts mismatch: "+d);let{channels:n,labels:o}=i[d];delete i[d].channels,delete i[d].labels,Object.defineProperty(i[d],"channels",{value:n}),Object.defineProperty(i[d],"labels",{value:o})}i.rgb.hsl=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255,s=Math.min(n,o,l),m=Math.max(n,o,l),c=m-s,u,v;m===s?u=0:n===m?u=(o-l)/c:o===m?u=2+(l-n)/c:l===m&&(u=4+(n-o)/c),u=Math.min(u*60,360),u<0&&(u+=360);let g=(s+m)/2;return m===s?v=0:g<=.5?v=c/(m+s):v=c/(2-m-s),[u,v*100,g*100]},i.rgb.hsv=function(d){let n,o,l,s,m,c=d[0]/255,u=d[1]/255,v=d[2]/255,g=Math.max(c,u,v),h=g-Math.min(c,u,v),C=function(x){return(g-x)/6/h+1/2};return h===0?(s=0,m=0):(m=h/g,n=C(c),o=C(u),l=C(v),c===g?s=l-o:u===g?s=1/3+n-l:v===g&&(s=2/3+o-n),s<0?s+=1:s>1&&(s-=1)),[s*360,m*100,g*100]},i.rgb.hwb=function(d){let n=d[0],o=d[1],l=d[2],s=i.rgb.hsl(d)[0],m=1/255*Math.min(n,Math.min(o,l));return l=1-1/255*Math.max(n,Math.max(o,l)),[s,m*100,l*100]},i.rgb.cmyk=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255,s=Math.min(1-n,1-o,1-l),m=(1-n-s)/(1-s)||0,c=(1-o-s)/(1-s)||0,u=(1-l-s)/(1-s)||0;return[m*100,c*100,u*100,s*100]};function r(d,n){return(d[0]-n[0])**2+(d[1]-n[1])**2+(d[2]-n[2])**2}i.rgb.keyword=function(d){let n=p[d];if(n)return n;let o=1/0,l;for(let s of Object.keys(t)){let m=t[s],c=r(d,m);c<o&&(o=c,l=s)}return l},i.keyword.rgb=function(d){return t[d]},i.rgb.xyz=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255;n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,l=l>.04045?((l+.055)/1.055)**2.4:l/12.92;let s=n*.4124+o*.3576+l*.1805,m=n*.2126+o*.7152+l*.0722,c=n*.0193+o*.1192+l*.9505;return[s*100,m*100,c*100]},i.rgb.lab=function(d){let n=i.rgb.xyz(d),o=n[0],l=n[1],s=n[2];o/=95.047,l/=100,s/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,l=l>.008856?l**(1/3):7.787*l+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let m=116*l-16,c=500*(o-l),u=200*(l-s);return[m,c,u]},i.hsl.rgb=function(d){let n=d[0]/360,o=d[1]/100,l=d[2]/100,s,m,c;if(o===0)return c=l*255,[c,c,c];l<.5?s=l*(1+o):s=l+o-l*o;let u=2*l-s,v=[0,0,0];for(let g=0;g<3;g++)m=n+1/3*-(g-1),m<0&&m++,m>1&&m--,6*m<1?c=u+(s-u)*6*m:2*m<1?c=s:3*m<2?c=u+(s-u)*(2/3-m)*6:c=u,v[g]=c*255;return v},i.hsl.hsv=function(d){let n=d[0],o=d[1]/100,l=d[2]/100,s=o,m=Math.max(l,.01);l*=2,o*=l<=1?l:2-l,s*=m<=1?m:2-m;let c=(l+o)/2,u=l===0?2*s/(m+s):2*o/(l+o);return[n,u*100,c*100]},i.hsv.rgb=function(d){let n=d[0]/60,o=d[1]/100,l=d[2]/100,s=Math.floor(n)%6,m=n-Math.floor(n),c=255*l*(1-o),u=255*l*(1-o*m),v=255*l*(1-o*(1-m));switch(l*=255,s){case 0:return[l,v,c];case 1:return[u,l,c];case 2:return[c,l,v];case 3:return[c,u,l];case 4:return[v,c,l];case 5:return[l,c,u]}},i.hsv.hsl=function(d){let n=d[0],o=d[1]/100,l=d[2]/100,s=Math.max(l,.01),m,c;c=(2-o)*l;let u=(2-o)*s;return m=o*s,m/=u<=1?u:2-u,m=m||0,c/=2,[n,m*100,c*100]},i.hwb.rgb=function(d){let n=d[0]/360,o=d[1]/100,l=d[2]/100,s=o+l,m;s>1&&(o/=s,l/=s);let c=Math.floor(6*n),u=1-l;m=6*n-c,(c&1)!==0&&(m=1-m);let v=o+m*(u-o),g,h,C;switch(c){default:case 6:case 0:g=u,h=v,C=o;break;case 1:g=v,h=u,C=o;break;case 2:g=o,h=u,C=v;break;case 3:g=o,h=v,C=u;break;case 4:g=v,h=o,C=u;break;case 5:g=u,h=o,C=v;break}return[g*255,h*255,C*255]},i.cmyk.rgb=function(d){let n=d[0]/100,o=d[1]/100,l=d[2]/100,s=d[3]/100,m=1-Math.min(1,n*(1-s)+s),c=1-Math.min(1,o*(1-s)+s),u=1-Math.min(1,l*(1-s)+s);return[m*255,c*255,u*255]},i.xyz.rgb=function(d){let n=d[0]/100,o=d[1]/100,l=d[2]/100,s,m,c;return s=n*3.2406+o*-1.5372+l*-.4986,m=n*-.9689+o*1.8758+l*.0415,c=n*.0557+o*-.204+l*1.057,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,m=m>.0031308?1.055*m**(1/2.4)-.055:m*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,s=Math.min(Math.max(0,s),1),m=Math.min(Math.max(0,m),1),c=Math.min(Math.max(0,c),1),[s*255,m*255,c*255]},i.xyz.lab=function(d){let n=d[0],o=d[1],l=d[2];n/=95.047,o/=100,l/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,l=l>.008856?l**(1/3):7.787*l+16/116;let s=116*o-16,m=500*(n-o),c=200*(o-l);return[s,m,c]},i.lab.xyz=function(d){let n=d[0],o=d[1],l=d[2],s,m,c;m=(n+16)/116,s=o/500+m,c=m-l/200;let u=m**3,v=s**3,g=c**3;return m=u>.008856?u:(m-16/116)/7.787,s=v>.008856?v:(s-16/116)/7.787,c=g>.008856?g:(c-16/116)/7.787,s*=95.047,m*=100,c*=108.883,[s,m,c]},i.lab.lch=function(d){let n=d[0],o=d[1],l=d[2],s;s=Math.atan2(l,o)*360/2/Math.PI,s<0&&(s+=360);let m=Math.sqrt(o*o+l*l);return[n,m,s]},i.lch.lab=function(d){let n=d[0],o=d[1],l=d[2]/360*2*Math.PI,s=o*Math.cos(l),m=o*Math.sin(l);return[n,s,m]},i.rgb.ansi16=function(d,n=null){let[o,l,s]=d,m=n===null?i.rgb.hsv(d)[2]:n;if(m=Math.round(m/50),m===0)return 30;let c=30+(Math.round(s/255)<<2|Math.round(l/255)<<1|Math.round(o/255));return m===2&&(c+=60),c},i.hsv.ansi16=function(d){return i.rgb.ansi16(i.hsv.rgb(d),d[2])},i.rgb.ansi256=function(d){let n=d[0],o=d[1],l=d[2];return n===o&&o===l?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(o/255*5)+Math.round(l/255*5)},i.ansi16.rgb=function(d){let n=d%10;if(n===0||n===7)return d>50&&(n+=3.5),n=n/10.5*255,[n,n,n];let o=(~~(d>50)+1)*.5,l=(n&1)*o*255,s=(n>>1&1)*o*255,m=(n>>2&1)*o*255;return[l,s,m]},i.ansi256.rgb=function(d){if(d>=232){let m=(d-232)*10+8;return[m,m,m]}d-=16;let n,o=Math.floor(d/36)/5*255,l=Math.floor((n=d%36)/6)/5*255,s=n%6/5*255;return[o,l,s]},i.rgb.hex=function(d){let n=(((Math.round(d[0])&255)<<16)+((Math.round(d[1])&255)<<8)+(Math.round(d[2])&255)).toString(16).toUpperCase();return"000000".substring(n.length)+n},i.hex.rgb=function(d){let n=d.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];let o=n[0];n[0].length===3&&(o=o.split("").map(u=>u+u).join(""));let l=parseInt(o,16),s=l>>16&255,m=l>>8&255,c=l&255;return[s,m,c]},i.rgb.hcg=function(d){let n=d[0]/255,o=d[1]/255,l=d[2]/255,s=Math.max(Math.max(n,o),l),m=Math.min(Math.min(n,o),l),c=s-m,u,v;return c<1?u=m/(1-c):u=0,c<=0?v=0:s===n?v=(o-l)/c%6:s===o?v=2+(l-n)/c:v=4+(n-o)/c,v/=6,v%=1,[v*360,c*100,u*100]},i.hsl.hcg=function(d){let n=d[1]/100,o=d[2]/100,l=o<.5?2*n*o:2*n*(1-o),s=0;return l<1&&(s=(o-.5*l)/(1-l)),[d[0],l*100,s*100]},i.hsv.hcg=function(d){let n=d[1]/100,o=d[2]/100,l=n*o,s=0;return l<1&&(s=(o-l)/(1-l)),[d[0],l*100,s*100]},i.hcg.rgb=function(d){let n=d[0]/360,o=d[1]/100,l=d[2]/100;if(o===0)return[l*255,l*255,l*255];let s=[0,0,0],m=n%1*6,c=m%1,u=1-c,v=0;switch(Math.floor(m)){case 0:s[0]=1,s[1]=c,s[2]=0;break;case 1:s[0]=u,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=c;break;case 3:s[0]=0,s[1]=u,s[2]=1;break;case 4:s[0]=c,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=u}return v=(1-o)*l,[(o*s[0]+v)*255,(o*s[1]+v)*255,(o*s[2]+v)*255]},i.hcg.hsv=function(d){let n=d[1]/100,o=d[2]/100,l=n+o*(1-n),s=0;return l>0&&(s=n/l),[d[0],s*100,l*100]},i.hcg.hsl=function(d){let n=d[1]/100,o=d[2]/100*(1-n)+.5*n,l=0;return o>0&&o<.5?l=n/(2*o):o>=.5&&o<1&&(l=n/(2*(1-o))),[d[0],l*100,o*100]},i.hcg.hwb=function(d){let n=d[1]/100,o=d[2]/100,l=n+o*(1-n);return[d[0],(l-n)*100,(1-l)*100]},i.hwb.hcg=function(d){let n=d[1]/100,o=d[2]/100,l=1-o,s=l-n,m=0;return s<1&&(m=(l-s)/(1-s)),[d[0],s*100,m*100]},i.apple.rgb=function(d){return[d[0]/65535*255,d[1]/65535*255,d[2]/65535*255]},i.rgb.apple=function(d){return[d[0]/255*65535,d[1]/255*65535,d[2]/255*65535]},i.gray.rgb=function(d){return[d[0]/100*255,d[0]/100*255,d[0]/100*255]},i.gray.hsl=function(d){return[0,0,d[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(d){return[0,100,d[0]]},i.gray.cmyk=function(d){return[0,0,0,d[0]]},i.gray.lab=function(d){return[d[0],0,0]},i.gray.hex=function(d){let n=Math.round(d[0]/100*255)&255,o=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(o.length)+o},i.rgb.gray=function(d){return[(d[0]+d[1]+d[2])/3/255*100]}}),Is=u1((e,a)=>{var t=Jr();function p(){let n={},o=Object.keys(t);for(let l=o.length,s=0;s<l;s++)n[o[s]]={distance:-1,parent:null};return n}function i(n){let o=p(),l=[n];for(o[n].distance=0;l.length;){let s=l.pop(),m=Object.keys(t[s]);for(let c=m.length,u=0;u<c;u++){let v=m[u],g=o[v];g.distance===-1&&(g.distance=o[s].distance+1,g.parent=s,l.unshift(v))}}return o}function r(n,o){return function(l){return o(n(l))}}function d(n,o){let l=[o[n].parent,n],s=t[o[n].parent][n],m=o[n].parent;for(;o[m].parent;)l.unshift(o[m].parent),s=r(t[o[m].parent][m],s),m=o[m].parent;return s.conversion=l,s}a.exports=function(n){let o=i(n),l={},s=Object.keys(o);for(let m=s.length,c=0;c<m;c++){let u=s[c];o[u].parent!==null&&(l[u]=d(u,o))}return l}}),Vs=u1((e,a)=>{var t=Jr(),p=Is(),i={},r=Object.keys(t);function d(o){let l=function(...s){let m=s[0];return m==null?m:(m.length>1&&(s=m),o(s))};return"conversion"in o&&(l.conversion=o.conversion),l}function n(o){let l=function(...s){let m=s[0];if(m==null)return m;m.length>1&&(s=m);let c=o(s);if(typeof c=="object")for(let u=c.length,v=0;v<u;v++)c[v]=Math.round(c[v]);return c};return"conversion"in o&&(l.conversion=o.conversion),l}r.forEach(o=>{i[o]={},Object.defineProperty(i[o],"channels",{value:t[o].channels}),Object.defineProperty(i[o],"labels",{value:t[o].labels});let l=p(o);Object.keys(l).forEach(s=>{let m=l[s];i[o][s]=n(m),i[o][s].raw=d(m)})}),a.exports=i}),Ls=u1((e,a)=>{"use strict";var t=(m,c)=>(...u)=>`\x1B[${m(...u)+c}m`,p=(m,c)=>(...u)=>{let v=m(...u);return`\x1B[${38+c};5;${v}m`},i=(m,c)=>(...u)=>{let v=m(...u);return`\x1B[${38+c};2;${v[0]};${v[1]};${v[2]}m`},r=m=>m,d=(m,c,u)=>[m,c,u],n=(m,c,u)=>{Object.defineProperty(m,c,{get:()=>{let v=u();return Object.defineProperty(m,c,{value:v,enumerable:!0,configurable:!0}),v},enumerable:!0,configurable:!0})},o,l=(m,c,u,v)=>{o===void 0&&(o=Vs());let g=v?10:0,h={};for(let[C,x]of Object.entries(o)){let T=C==="ansi16"?"ansi":C;C===c?h[T]=m(u,g):typeof x=="object"&&(h[T]=m(x[c],g))}return h};function s(){let m=new Map,c={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};c.color.gray=c.color.blackBright,c.bgColor.bgGray=c.bgColor.bgBlackBright,c.color.grey=c.color.blackBright,c.bgColor.bgGrey=c.bgColor.bgBlackBright;for(let[u,v]of Object.entries(c)){for(let[g,h]of Object.entries(v))c[g]={open:`\x1B[${h[0]}m`,close:`\x1B[${h[1]}m`},v[g]=c[g],m.set(h[0],h[1]);Object.defineProperty(c,u,{value:v,enumerable:!1})}return Object.defineProperty(c,"codes",{value:m,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",n(c.color,"ansi",()=>l(t,"ansi16",r,!1)),n(c.color,"ansi256",()=>l(p,"ansi256",r,!1)),n(c.color,"ansi16m",()=>l(i,"rgb",d,!1)),n(c.bgColor,"ansi",()=>l(t,"ansi16",r,!0)),n(c.bgColor,"ansi256",()=>l(p,"ansi256",r,!0)),n(c.bgColor,"ansi16m",()=>l(i,"rgb",d,!0)),c}Object.defineProperty(a,"exports",{enumerable:!0,get:s})}),js=u1((e,a)=>{"use strict";a.exports=(t,p=process.argv)=>{let i=t.startsWith("-")?"":t.length===1?"-":"--",r=p.indexOf(i+t),d=p.indexOf("--");return r!==-1&&(d===-1||r<d)}}),Ms=u1((e,a)=>{"use strict";var t=Yr("os"),p=Yr("tty"),i=js(),{env:r}=process,d;i("no-color")||i("no-colors")||i("color=false")||i("color=never")?d=0:(i("color")||i("colors")||i("color=true")||i("color=always"))&&(d=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?d=1:r.FORCE_COLOR==="false"?d=0:d=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function n(s){return s===0?!1:{level:s,hasBasic:!0,has256:s>=2,has16m:s>=3}}function o(s,m){if(d===0)return 0;if(i("color=16m")||i("color=full")||i("color=truecolor"))return 3;if(i("color=256"))return 2;if(s&&!m&&d===void 0)return 0;let c=d||0;if(r.TERM==="dumb")return c;if(process.platform==="win32"){let u=t.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(u=>u in r)||r.CI_NAME==="codeship"?1:c;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){let u=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:c}function l(s){let m=o(s,s&&s.isTTY);return n(m)}a.exports={supportsColor:l,stdout:n(o(!0,p.isatty(1))),stderr:n(o(!0,p.isatty(2)))}}),Bs=u1((e,a)=>{"use strict";var t=(i,r,d)=>{let n=i.indexOf(r);if(n===-1)return i;let o=r.length,l=0,s="";do s+=i.substr(l,n-l)+r+d,l=n+o,n=i.indexOf(r,l);while(n!==-1);return s+=i.substr(l),s},p=(i,r,d,n)=>{let o=0,l="";do{let s=i[n-1]==="\r";l+=i.substr(o,(s?n-1:n)-o)+r+(s?`\r
82
82
  `:`
83
83
  `)+d,o=n+1,n=i.indexOf(`
84
84
  `,o)}while(n!==-1);return l+=i.substr(o),l};a.exports={stringReplaceAll:t,stringEncaseCRLFWithFirstIndex:p}}),Rs=u1((e,a)=>{"use strict";var t=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,p=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,i=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,r=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,d=new Map([["n",`
@@ -114,7 +114,7 @@ ${v.join(`
114
114
  `+e.slice(i,r),i=r+1),d=n;return o+=`
115
115
  `,e.length-i>a&&d>i?o+=e.slice(i,d)+`
116
116
  `+e.slice(d+1):o+=e.slice(i),o.slice(1)}function e8(e){for(var a="",t=0,p,i=0;i<e.length;t>=65536?i+=2:i++)t=Et(e,i),p=Ve[t],!p&&Ft(t)?(a+=e[i],t>=65536&&(a+=e[i+1])):a+=p||zl(t);return a}function a8(e,a,t){var p="",i=e.tag,r,d,n;for(r=0,d=t.length;r<d;r+=1)n=t[r],e.replacer&&(n=e.replacer.call(t,String(r),n)),(A1(e,a,n,!1,!1)||typeof n=="undefined"&&A1(e,a,null,!1,!1))&&(p!==""&&(p+=","+(e.condenseFlow?"":" ")),p+=e.dump);e.tag=i,e.dump="["+p+"]"}function l0(e,a,t,p){var i="",r=e.tag,d,n,o;for(d=0,n=t.length;d<n;d+=1)o=t[d],e.replacer&&(o=e.replacer.call(t,String(d),o)),(A1(e,a+1,o,!0,!0,!1,!0)||typeof o=="undefined"&&A1(e,a+1,null,!0,!0,!1,!0))&&((!p||i!=="")&&(i+=Ji(e,a)),e.dump&&Dt===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=r,e.dump=i||"[]"}function t8(e,a,t){var p="",i=e.tag,r=Object.keys(t),d,n,o,l,s;for(d=0,n=r.length;d<n;d+=1)s="",p!==""&&(s+=", "),e.condenseFlow&&(s+='"'),o=r[d],l=t[o],e.replacer&&(l=e.replacer.call(t,o,l)),A1(e,a,o,!1,!1)&&(e.dump.length>1024&&(s+="? "),s+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),A1(e,a,l,!1,!1)&&(s+=e.dump,p+=s));e.tag=i,e.dump="{"+p+"}"}function p8(e,a,t,p){var i="",r=e.tag,d=Object.keys(t),n,o,l,s,m,c;if(e.sortKeys===!0)d.sort();else if(typeof e.sortKeys=="function")d.sort(e.sortKeys);else if(e.sortKeys)throw new Be("sortKeys must be a boolean or a function");for(n=0,o=d.length;n<o;n+=1)c="",(!p||i!=="")&&(c+=Ji(e,a)),l=d[n],s=t[l],e.replacer&&(s=e.replacer.call(t,l,s)),A1(e,a+1,l,!0,!0,!0)&&(m=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,m&&(e.dump&&Dt===e.dump.charCodeAt(0)?c+="?":c+="? "),c+=e.dump,m&&(c+=Ji(e,a)),A1(e,a+1,s,!0,m)&&(e.dump&&Dt===e.dump.charCodeAt(0)?c+=":":c+=": ",c+=e.dump,i+=c));e.tag=r,e.dump=i||"{}"}function m0(e,a,t){var p,i,r,d,n,o;for(i=t?e.explicitTypes:e.implicitTypes,r=0,d=i.length;r<d;r+=1)if(n=i[r],(n.instanceOf||n.predicate)&&(!n.instanceOf||typeof a=="object"&&a instanceof n.instanceOf)&&(!n.predicate||n.predicate(a))){if(t?n.multi&&n.representName?e.tag=n.representName(a):e.tag=n.tag:e.tag="?",n.represent){if(o=e.styleMap[n.tag]||n.defaultStyle,N0.call(n.represent)==="[object Function]")p=n.represent(a,o);else if(E0.call(n.represent,o))p=n.represent[o](a,o);else throw new Be("!<"+n.tag+'> tag resolver accepts not "'+o+'" style');e.dump=p}return!0}return!1}function A1(e,a,t,p,i,r,d){e.tag=null,e.dump=t,m0(e,t,!1)||m0(e,t,!0);var n=N0.call(e.dump),o=p,l;p&&(p=e.flowLevel<0||e.flowLevel>a);var s=n==="[object Object]"||n==="[object Array]",m,c;if(s&&(m=e.duplicates.indexOf(t),c=m!==-1),(e.tag!==null&&e.tag!=="?"||c||e.indent!==2&&a>0)&&(i=!1),c&&e.usedDuplicates[m])e.dump="*ref_"+m;else{if(s&&c&&!e.usedDuplicates[m]&&(e.usedDuplicates[m]=!0),n==="[object Object]")p&&Object.keys(e.dump).length!==0?(p8(e,a,e.dump,i),c&&(e.dump="&ref_"+m+e.dump)):(t8(e,a,e.dump),c&&(e.dump="&ref_"+m+" "+e.dump));else if(n==="[object Array]")p&&e.dump.length!==0?(e.noArrayIndent&&!d&&a>0?l0(e,a-1,e.dump,i):l0(e,a,e.dump,i),c&&(e.dump="&ref_"+m+e.dump)):(a8(e,a,e.dump),c&&(e.dump="&ref_"+m+" "+e.dump));else if(n==="[object String]")e.tag!=="?"&&Zl(e,e.dump,a,r,o);else{if(n==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Be("unacceptable kind of an object to dump "+n)}e.tag!==null&&e.tag!=="?"&&(l=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?l="!"+l:l.slice(0,18)==="tag:yaml.org,2002:"?l="!!"+l.slice(18):l="!<"+l+">",e.dump=l+" "+e.dump)}return!0}function i8(e,a){var t=[],p=[],i,r;for(Zi(e,t,p),i=0,r=p.length;i<r;i+=1)a.duplicates.push(t[p[i]]);a.usedDuplicates=new Array(r)}function Zi(e,a,t){var p,i,r;if(e!==null&&typeof e=="object")if(i=a.indexOf(e),i!==-1)t.indexOf(i)===-1&&t.push(i);else if(a.push(e),Array.isArray(e))for(i=0,r=e.length;i<r;i+=1)Zi(e[i],a,t);else for(p=Object.keys(e),i=0,r=p.length;i<r;i+=1)Zi(e[p[i]],a,t)}function d8(e,a){a=a||{};var t=new Gl(a);t.noRefs||i8(e,t);var p=e;return t.replacer&&(p=t.replacer.call({"":p},"",p)),A1(t,0,p,!0,!0)?t.dump+`
117
- `:""}var r8=d8,n8={dump:r8};function pd(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var M0=A0.load,x7=A0.loadAll,B0=n8.dump;var S7=pd("safeLoad","load"),A7=pd("safeLoadAll","loadAll"),N7=pd("safeDump","dump");var b6=require("fs"),T2=require("path"),y6=require("fs"),_6=n1(rn(),1),D2=n1(Bo(),1),C6=n1(require("fs"),1);function F1(){}F1.prototype={diff:function(a,t){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=p.callback;typeof p=="function"&&(i=p,p={}),this.options=p;var r=this;function d(g){return i?(setTimeout(function(){i(void 0,g)},0),!0):g}a=this.castInput(a),t=this.castInput(t),a=this.removeEmpty(this.tokenize(a)),t=this.removeEmpty(this.tokenize(t));var n=t.length,o=a.length,l=1,s=n+o;p.maxEditLength&&(s=Math.min(s,p.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],t,a,0);if(m[0].newPos+1>=n&&c+1>=o)return d([{value:this.join(t),count:t.length}]);function u(){for(var g=-1*l;g<=l;g+=2){var h=void 0,C=m[g-1],x=m[g+1],T=(x?x.newPos:0)-g;C&&(m[g-1]=void 0);var B=C&&C.newPos+1<n,R=x&&0<=T&&T<o;if(!B&&!R){m[g]=void 0;continue}if(!B||R&&C.newPos<x.newPos?(h=a5(x),r.pushComponent(h.components,void 0,!0)):(h=C,h.newPos++,r.pushComponent(h.components,!0,void 0)),T=r.extractCommon(h,t,a,g),h.newPos+1>=n&&T+1>=o)return d(e5(r,h.components,t,a,r.useLongestToken));m[g]=h}l++}if(i)(function g(){setTimeout(function(){if(l>s)return i();u()||g()},0)})();else for(;l<=s;){var v=u();if(v)return v}},pushComponent:function(a,t,p){var i=a[a.length-1];i&&i.added===t&&i.removed===p?a[a.length-1]={count:i.count+1,added:t,removed:p}:a.push({count:1,added:t,removed:p})},extractCommon:function(a,t,p,i){for(var r=t.length,d=p.length,n=a.newPos,o=n-i,l=0;n+1<r&&o+1<d&&this.equals(t[n+1],p[o+1]);)n++,o++,l++;return l&&a.components.push({count:l}),a.newPos=n,o},equals:function(a,t){return this.options.comparator?this.options.comparator(a,t):a===t||this.options.ignoreCase&&a.toLowerCase()===t.toLowerCase()},removeEmpty:function(a){for(var t=[],p=0;p<a.length;p++)a[p]&&t.push(a[p]);return t},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function e5(e,a,t,p,i){for(var r=0,d=a.length,n=0,o=0;r<d;r++){var l=a[r];if(l.removed){if(l.value=e.join(p.slice(o,o+l.count)),o+=l.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!l.added&&i){var s=t.slice(n,n+l.count);s=s.map(function(u,v){var g=p[o+v];return g.length>u.length?g:u}),l.value=e.join(s)}else l.value=e.join(t.slice(n,n+l.count));n+=l.count,l.added||(o+=l.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function a5(e){return{newPos:e.newPos,components:e.components.slice(0)}}var fc=new F1;var Ro=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Uo=/\S/,ko=new F1;ko.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!Uo.test(e)&&!Uo.test(a)};ko.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<a.length-1;t++)!a[t+1]&&a[t+2]&&Ro.test(a[t])&&Ro.test(a[t+2])&&(a[t]+=a[t+2],a.splice(t+1,2),t--);return a};var f2=new F1;f2.tokenize=function(e){var a=[],t=e.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var p=0;p<t.length;p++){var i=t[p];p%2&&!this.options.newlineIsToken?a[a.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),a.push(i))}return a};function h2(e,a,t){return f2.diff(e,a,t)}var t5=new F1;t5.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var p5=new F1;p5.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Kp(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Kp=function(a){return typeof a}:Kp=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Kp(e)}var i5=Object.prototype.toString,ct=new F1;ct.useLongestToken=!0;ct.tokenize=f2.tokenize;ct.castInput=function(e){var a=this.options,t=a.undefinedReplacement,p=a.stringifyReplacer,i=p===void 0?function(r,d){return typeof d=="undefined"?t:d}:p;return typeof e=="string"?e:JSON.stringify(c2(e,null,null,i),i," ")};ct.equals=function(e,a){return F1.prototype.equals.call(ct,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function $o(e,a,t){return ct.diff(e,a,t)}function c2(e,a,t,p,i){a=a||[],t=t||[],p&&(e=p(i,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return t[r];var d;if(i5.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),t.push(d),r=0;r<e.length;r+=1)d[r]=c2(e[r],a,t,p,i);return a.pop(),t.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),Kp(e)==="object"&&e!==null){a.push(e),d={},t.push(d);var n=[],o;for(o in e)e.hasOwnProperty(o)&&n.push(o);for(n.sort(),r=0;r<n.length;r+=1)o=n[r],d[o]=c2(e[o],a,t,p,o);a.pop(),t.pop()}else d=e;return d}var u2=new F1;u2.tokenize=function(e){return e.slice()};u2.join=u2.removeEmpty=function(e){return e};var A6=n1(w6(),1);async function ta({objects:e,selectIdentifier:a,selectDisplayName:t=a,onSyncComplete:p}){let i=e.reduce((n,o)=>{let l=a(o);if(n[l])throw new Error(`Identifier ${l} was not unique.`);return n[l]={id:l,object:o,providerId:l,displayName:t(o)},n},{});async function*r(){for(let n of Object.values(i))yield n}function d(){return Object.entries(i).sort((n,o)=>n[0].localeCompare(o[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete i[n]},writeObject:async n=>{let o=a(n.object);i[o]=n},extractCurrent:d,onSyncComplete:p?n=>p(n,d()):void 0}}var S3=qi(Hi());function ne(e){var a,t;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(t=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?t:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function oe(e){return console.log(`\u{1F991} Using proxy ${e}`),(a,t)=>{if(e){let p={...t,agent:new _6.HttpsProxyAgent(e)};return(0,D2.default)(a,p)}return(0,D2.default)(a,t)}}function se(e){var a,t,p;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(p=(t=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?t:process.env.UPM_CLI_PROJECT_ID)!=null?p:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function pa(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function ia(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function da(e){let a=(0,T2.extname)(e);return a===".yaml"||a===".yml"||a===".json"}function b1(e,a,t){let p;if(t&&!a){let i=(0,T2.extname)(t);i===".yaml"||i===".yml"?a="yaml":i===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":p=JSON.stringify(e,null,2);break;case"yaml":p=B0(e);break;default:throw new Error(`Unsupported format: ${a}`)}t?(0,b6.writeFileSync)(t,p,"utf8"):console.log(p)}function gt(e){let a=(0,y6.readFileSync)(e,"utf8");return M0(a,{filename:e,json:!0})}async function*oi(e,a){let t=a.pageSize||100,p=0,i=[];do{i=await e(p,t);for(let r of i)yield r;p+=t}while(i.length===t)}async function ra({directory:e,format:a="yaml",selectIdentifier:t,selectDisplayName:p=t}){(0,ri.existsSync)(e)||(0,ri.mkdirSync)(e,{recursive:!0});let i=await(0,ni.readdir)(e,"utf-8"),r=new Set(i.filter(o=>{let l=(0,Kt.extname)(o);return l===".json"||l===".yaml"||l===".yml"})),d=o=>(0,Kt.join)(e,`${o}.${a}`);async function*n(){for(let o of r){let l=(0,Kt.join)(e,o);try{let s=await gt(l);yield{id:t(s),displayName:p(s),providerId:l,object:s}}catch(s){throw console.error(S3.default.red(`Failed to read ${l}, data is likely invalid.
117
+ `:""}var r8=d8,n8={dump:r8};function pd(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var M0=A0.load,x7=A0.loadAll,B0=n8.dump;var S7=pd("safeLoad","load"),A7=pd("safeLoadAll","loadAll"),N7=pd("safeDump","dump");var b6=require("fs"),T2=require("path"),y6=require("fs"),_6=n1(rn(),1),D2=n1(Bo(),1),C6=n1(require("fs"),1);function F1(){}F1.prototype={diff:function(a,t){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=p.callback;typeof p=="function"&&(i=p,p={}),this.options=p;var r=this;function d(g){return i?(setTimeout(function(){i(void 0,g)},0),!0):g}a=this.castInput(a),t=this.castInput(t),a=this.removeEmpty(this.tokenize(a)),t=this.removeEmpty(this.tokenize(t));var n=t.length,o=a.length,l=1,s=n+o;p.maxEditLength&&(s=Math.min(s,p.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],t,a,0);if(m[0].newPos+1>=n&&c+1>=o)return d([{value:this.join(t),count:t.length}]);function u(){for(var g=-1*l;g<=l;g+=2){var h=void 0,C=m[g-1],x=m[g+1],T=(x?x.newPos:0)-g;C&&(m[g-1]=void 0);var B=C&&C.newPos+1<n,R=x&&0<=T&&T<o;if(!B&&!R){m[g]=void 0;continue}if(!B||R&&C.newPos<x.newPos?(h=a5(x),r.pushComponent(h.components,void 0,!0)):(h=C,h.newPos++,r.pushComponent(h.components,!0,void 0)),T=r.extractCommon(h,t,a,g),h.newPos+1>=n&&T+1>=o)return d(e5(r,h.components,t,a,r.useLongestToken));m[g]=h}l++}if(i)(function g(){setTimeout(function(){if(l>s)return i();u()||g()},0)})();else for(;l<=s;){var v=u();if(v)return v}},pushComponent:function(a,t,p){var i=a[a.length-1];i&&i.added===t&&i.removed===p?a[a.length-1]={count:i.count+1,added:t,removed:p}:a.push({count:1,added:t,removed:p})},extractCommon:function(a,t,p,i){for(var r=t.length,d=p.length,n=a.newPos,o=n-i,l=0;n+1<r&&o+1<d&&this.equals(t[n+1],p[o+1]);)n++,o++,l++;return l&&a.components.push({count:l}),a.newPos=n,o},equals:function(a,t){return this.options.comparator?this.options.comparator(a,t):a===t||this.options.ignoreCase&&a.toLowerCase()===t.toLowerCase()},removeEmpty:function(a){for(var t=[],p=0;p<a.length;p++)a[p]&&t.push(a[p]);return t},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function e5(e,a,t,p,i){for(var r=0,d=a.length,n=0,o=0;r<d;r++){var l=a[r];if(l.removed){if(l.value=e.join(p.slice(o,o+l.count)),o+=l.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!l.added&&i){var s=t.slice(n,n+l.count);s=s.map(function(u,v){var g=p[o+v];return g.length>u.length?g:u}),l.value=e.join(s)}else l.value=e.join(t.slice(n,n+l.count));n+=l.count,l.added||(o+=l.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function a5(e){return{newPos:e.newPos,components:e.components.slice(0)}}var fc=new F1;var Ro=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Uo=/\S/,ko=new F1;ko.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!Uo.test(e)&&!Uo.test(a)};ko.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<a.length-1;t++)!a[t+1]&&a[t+2]&&Ro.test(a[t])&&Ro.test(a[t+2])&&(a[t]+=a[t+2],a.splice(t+1,2),t--);return a};var f2=new F1;f2.tokenize=function(e){var a=[],t=e.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var p=0;p<t.length;p++){var i=t[p];p%2&&!this.options.newlineIsToken?a[a.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),a.push(i))}return a};function h2(e,a,t){return f2.diff(e,a,t)}var t5=new F1;t5.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var p5=new F1;p5.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Kp(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Kp=function(a){return typeof a}:Kp=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Kp(e)}var i5=Object.prototype.toString,ct=new F1;ct.useLongestToken=!0;ct.tokenize=f2.tokenize;ct.castInput=function(e){var a=this.options,t=a.undefinedReplacement,p=a.stringifyReplacer,i=p===void 0?function(r,d){return typeof d=="undefined"?t:d}:p;return typeof e=="string"?e:JSON.stringify(c2(e,null,null,i),i," ")};ct.equals=function(e,a){return F1.prototype.equals.call(ct,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function $o(e,a,t){return ct.diff(e,a,t)}function c2(e,a,t,p,i){a=a||[],t=t||[],p&&(e=p(i,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return t[r];var d;if(i5.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),t.push(d),r=0;r<e.length;r+=1)d[r]=c2(e[r],a,t,p,i);return a.pop(),t.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),Kp(e)==="object"&&e!==null){a.push(e),d={},t.push(d);var n=[],o;for(o in e)e.hasOwnProperty(o)&&n.push(o);for(n.sort(),r=0;r<n.length;r+=1)o=n[r],d[o]=c2(e[o],a,t,p,o);a.pop(),t.pop()}else d=e;return d}var u2=new F1;u2.tokenize=function(e){return e.slice()};u2.join=u2.removeEmpty=function(e){return e};var A6=n1(w6(),1);async function ta({objects:e,selectIdentifier:a,selectDisplayName:t=a,onSyncComplete:p}){let i=e.reduce((n,o)=>{let l=a(o);if(n[l])throw new Error(`Identifier ${l} was not unique.`);return n[l]={id:l,object:o,providerId:l,displayName:t(o)},n},{});async function*r(){for(let n of Object.values(i))yield n}function d(){return Object.entries(i).sort((n,o)=>n[0].localeCompare(o[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete i[n]},writeObject:async n=>{let o=a(n.object);i[o]=n},extractCurrent:d,onSyncComplete:p?n=>p(n,d()):void 0}}var S3=qi(Hi());function ne(e){var a,t;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(t=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?t:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function oe(e){return e&&console.log(`\u{1F991} Using proxy ${e}`),(a,t)=>{if(e){let p={...t,agent:new _6.HttpsProxyAgent(e)};return(0,D2.default)(a,p)}return(0,D2.default)(a,t)}}function se(e){var a,t,p;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(p=(t=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?t:process.env.UPM_CLI_PROJECT_ID)!=null?p:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function pa(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function ia(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function da(e){let a=(0,T2.extname)(e);return a===".yaml"||a===".yml"||a===".json"}function b1(e,a,t){let p;if(t&&!a){let i=(0,T2.extname)(t);i===".yaml"||i===".yml"?a="yaml":i===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":p=JSON.stringify(e,null,2);break;case"yaml":p=B0(e);break;default:throw new Error(`Unsupported format: ${a}`)}t?(0,b6.writeFileSync)(t,p,"utf8"):console.log(p)}function gt(e){let a=(0,y6.readFileSync)(e,"utf8");return M0(a,{filename:e,json:!0})}async function*oi(e,a){let t=a.pageSize||100,p=0,i=[];do{i=await e(p,t);for(let r of i)yield r;p+=t}while(i.length===t)}async function ra({directory:e,format:a="yaml",selectIdentifier:t,selectDisplayName:p=t}){(0,ri.existsSync)(e)||(0,ri.mkdirSync)(e,{recursive:!0});let i=await(0,ni.readdir)(e,"utf-8"),r=new Set(i.filter(o=>{let l=(0,Kt.extname)(o);return l===".json"||l===".yaml"||l===".yml"})),d=o=>(0,Kt.join)(e,`${o}.${a}`);async function*n(){for(let o of r){let l=(0,Kt.join)(e,o);try{let s=await gt(l);yield{id:t(s),displayName:p(s),providerId:l,object:s}}catch(s){throw console.error(S3.default.red(`Failed to read ${l}, data is likely invalid.
118
118
  ${s==null?void 0:s.message}`)),s}}}return{objects:n(),deleteObject:async o=>{await(0,ni.unlink)(o)},writeObject:async o=>{b1(o.object,a,d(o.id))}}}function x6(e,a){if(!a&&!C6.default.existsSync(e))return{};let t=gt(e);if(typeof t!="object")throw new Error(`Package ${e} does not appear valid.`);return t}function S6(e,a){b1(a,void 0,e)}async function na({source:e,target:a,compareContents:t=(n,o)=>(0,A6.default)(n.object,o.object,(l,s,m)=>m==="created"||m==="modified"?!0:void 0),mode:p,allowEmptySource:i=!1,whatIf:r=!1,log:d=()=>{}}){var n,o;let l=new Map;for await(let c of a.objects)l.set(c.id,c);let s=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,v=l.get(u);if(v){if(!t(c,v)&&(p==="createOrUpdate"||p==="mirror")){let g=async(h,C)=>{var x;if(!r)try{await a.writeObject(h,C)}catch(T){throw new di(T,h)}d({action:"update",id:u,providerId:h.providerId,displayName:(x=h.displayName)!=null?x:h.providerId,whatIf:r,diff:$o(C.object,h.object)})};s.push(g(c,v))}l.delete(u)}else{let g=async(h,C)=>{var x;if(!r)try{await a.writeObject(h)}catch(T){throw new di(T,h)}d({action:"create",id:C,providerId:C,displayName:(x=h.displayName)!=null?x:h.providerId,whatIf:r,diff:h2("",JSON.stringify(h.object,null,2))})};s.push(g(c,u))}}if(await Promise.all(s),p==="mirror"){if(!m&&!i)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];l.forEach(async u=>{let v=async g=>{var h;if(!r)try{await a.deleteObject(g.providerId)}catch(C){throw new di(C,g)}d({action:"delete",id:g.id,providerId:g.providerId,displayName:(h=g.displayName)!=null?h:g.providerId,whatIf:r,diff:h2(JSON.stringify(g.object,null,2),"")})};c.push(v(u))}),await Promise.all(c)}await Promise.all([(n=e.onSyncComplete)==null?void 0:n.call(e,!1),(o=a.onSyncComplete)==null?void 0:o.call(a,!0)])}var di=class extends Error{constructor(e,a){var t;super(`Error syncing ${(t=a.displayName)!=null?t:a.providerId} (${a.providerId})
119
119
  ${e}`),this.stack=void 0,Object.setPrototypeOf(this,di.prototype)}},vt=qi(Hi());function oa(e){let{diffMode:a="off",indent:t,prefix:p}=e!=null?e:{};return function({action:i,displayName:r,whatIf:d,diff:n}){let o="";switch(i){case"create":o=vt.default.green("[A]");break;case"update":o=vt.default.white("[U]");break;case"delete":o=vt.default.yellow("[D]");break}let l="";(a==="on"||a==="update"&&i==="update")&&(l=`
120
120
  `+n.map(s=>s.added?vt.default.green(s.value):s.removed?vt.default.red(s.value):s.value).join("")),console.log(`${t!=null?t:""}${d?vt.default.gray("[WHATIF]"):""}${o}${p!=null?p:""} ${r}${l}`)}}var N6={command:"get <id>",describe:"Fetch a component definition",builder:e=>pa(ne(se(e.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:p,format:i,project:r,filename:d})=>{let n=oe(t),l=await new ie({apiKey:a,apiHost:e,fetch:n,projectId:r}).getComponentDefinitions({componentId:p,limit:1});l.componentDefinitions.length===0?(console.error("Component did not exist"),process.exit(1)):b1(l.componentDefinitions[0],i,d)}};var E6={command:"list",describe:"List component definitions",aliases:["ls"],builder:e=>pa(ne(se(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20}})))),handler:async({apiHost:e,apiKey:a,proxy:t,limit:p,offset:i,format:r,filename:d,project:n})=>{let o=oe(t),s=await new ie({apiKey:a,apiHost:e,fetch:o,projectId:n}).getComponentDefinitions({limit:p,offset:i});b1(s.componentDefinitions,r,d)}};var F2=class{constructor(a){hi(this,"value");hi(this,"next");this.value=a}},y1,Ra,Ua,Jt=class{constructor(){Zt(this,y1,void 0);Zt(this,Ra,void 0);Zt(this,Ua,void 0);this.clear()}enqueue(a){let t=new F2(a);j1(this,y1)?(j1(this,Ra).next=t,x1(this,Ra,t)):(x1(this,y1,t),x1(this,Ra,t)),vi(this,Ua)._++}dequeue(){let a=j1(this,y1);if(!!a)return x1(this,y1,j1(this,y1).next),vi(this,Ua)._--,a.value}clear(){x1(this,y1,void 0),x1(this,Ra,void 0),x1(this,Ua,0)}get size(){return j1(this,Ua)}*[Symbol.iterator](){let a=j1(this,y1);for(;a;)yield a.value,a=a.next}};y1=new WeakMap,Ra=new WeakMap,Ua=new WeakMap;function P2(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let a=new Jt,t=0,p=()=>{t--,a.size>0&&a.dequeue()()},i=async(n,o,l)=>{t++;let s=(async()=>n(...l))();o(s);try{await s}catch(m){}p()},r=(n,o,l)=>{a.enqueue(i.bind(void 0,n,o,l)),(async()=>(await Promise.resolve(),t<e&&a.size>0&&a.dequeue()()))()},d=(n,...o)=>new Promise(l=>{r(n,l,o)});return Object.defineProperties(d,{activeCount:{get:()=>t},pendingCount:{get:()=>a.size},clearQueue:{value:()=>{a.clear()}}}),d}function si(e){let a={...e};return delete a.projectId,delete a.state,a}function _1(e){return e.option("state",{type:"string",describe:"Composition state to fetch.",choices:["preview","published"],default:"preview"})}function sa(e){let a=Number(e);if(!isNaN(a))return a;if(!e)return 64;if(typeof e!="string")throw new Error('state must be "published", "preview", or a number');return e==="preview"?0:64}var la=P2(8);var ma=e=>e.id,ca=e=>`${e.name} (pid: ${e.id})`;function li({client:e}){async function*a(){let t=oi(async(p,i)=>(await e.getComponentDefinitions({limit:i,offset:p})).componentDefinitions,{pageSize:100});for await(let p of t)yield{id:ma(p),displayName:ca(p),providerId:p.id,object:p}}return{objects:a(),deleteObject:async t=>{await e.removeComponentDefinition({componentId:t})},writeObject:async t=>{await e.updateComponentDefinition({componentDefinition:t.object})}}}function V1(e,a){return x6(e,a)}function Qt(e,a){S6(e,a)}var O6={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:e=>ne(se(ia(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:p,format:i,mode:r,whatIf:d,project:n,diff:o})=>{var v;let l=oe(t),s=new ie({apiKey:a,apiHost:e,fetch:l,projectId:n,limitPolicy:la}),m=li({client:s}),c;if(da(p)){let g=V1(p,!1);c=await ta({objects:(v=g.components)!=null?v:[],selectIdentifier:ma,selectDisplayName:ca,onSyncComplete:async(h,C)=>{g.components=C,Qt(p,g)}})}else c=await ra({directory:p,selectIdentifier:ma,selectDisplayName:ca,format:i});await na({source:m,target:c,mode:r,whatIf:d,log:oa({diffMode:o})})}};var D6={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Canvas",builder:e=>ne(se(ia(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:p,mode:i,whatIf:r,project:d,diff:n})=>{var u;let o=oe(t),l=new ie({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:la}),s;if(da(p)){let v=V1(p,!0);s=await ta({objects:(u=v.components)!=null?u:[],selectIdentifier:ma,selectDisplayName:ca})}else s=await ra({directory:p,selectIdentifier:ma,selectDisplayName:ca});let c=li({client:l});await na({source:s,target:c,mode:i,whatIf:r,log:oa({diffMode:n})})}};var T6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:e=>ne(se(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:p,project:i})=>{let r=oe(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:i}).removeComponentDefinition({componentId:p})}};var F6={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:e=>ne(se(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:p,project:i})=>{let r=oe(t),d=new ie({apiKey:a,apiHost:e,fetch:r,projectId:i}),n=gt(p);await d.updateComponentDefinition({componentDefinition:n})}};var P6={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:e=>e.command(O6).command(D6).command(N6).command(T6).command(E6).command(F6).demandCommand(),handler:()=>{Ka.help()}};var I6={command:"get <id>",describe:"Fetch a composition",builder:e=>pa(ne(se(_1(e.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:a,proxy:t,id:p,format:i,filename:r,state:d,project:n,resolvePatterns:o})=>{let l=oe(t),s=new ie({apiKey:a,apiHost:e,fetch:l,projectId:n}),m=si(await s.getCompositionById({compositionId:p,state:sa(d),skipPatternResolution:!o}));b1(m,i,r)}};var V6={command:"list",describe:"List compositions",aliases:["ls"],builder:e=>pa(ne(se(_1(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20},resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:a,proxy:t,limit:p,offset:i,format:r,filename:d,project:n,state:o,resolvePatterns:l})=>{let s=oe(t),c=await new ie({apiKey:a,apiHost:e,fetch:s,projectId:n}).getCompositionList({limit:p,offset:i,state:sa(o),skipPatternResolution:!l});b1(c.compositions,r,d)}};var ua=e=>e.composition._id,fa=e=>{var a,t;return`${(t=(a=e.composition._name)!=null?a:e.composition._slug)!=null?t:e.composition._id} (pid: ${e.composition._id})`};function mi({client:e,state:a}){let t=sa(a);async function*p(){let i=oi(async(r,d)=>(await e.getCompositionList({limit:d,offset:r,state:t,skipPatternResolution:!0})).compositions,{pageSize:100});for await(let r of i)yield{id:ua(r),displayName:fa(r),providerId:r.composition._id,object:si(r)}}return{objects:p(),deleteObject:async i=>{await e.removeComposition({compositionId:i})},writeObject:async i=>{await e.updateComposition({...i.object,state:t})}}}var L6={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:e=>ne(se(_1(ia(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:p,format:i,mode:r,whatIf:d,state:n,project:o,diff:l})=>{var g;let s=oe(t),m=new ie({apiKey:a,apiHost:e,fetch:s,projectId:o,limitPolicy:la}),c=mi({client:m,state:n}),u=da(p),v;if(u){let h=V1(p,!1);v=await ta({objects:(g=h==null?void 0:h.compositions)!=null?g:[],selectIdentifier:ua,selectDisplayName:fa,onSyncComplete:async(C,x)=>{h.compositions=x,Qt(p,h)}})}else v=await ra({directory:p,selectIdentifier:ua,selectDisplayName:fa,format:i});await na({source:c,target:v,mode:r,whatIf:d,log:oa({diffMode:l})})}};var j6={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Canvas",builder:e=>ne(se(_1(ia(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:p,mode:i,whatIf:r,state:d,project:n,diff:o})=>{var v;let l=oe(t),s=new ie({apiKey:a,apiHost:e,fetch:l,projectId:n,limitPolicy:la}),m;if(da(p)){let g=V1(p,!0);m=await ta({objects:(v=g.compositions)!=null?v:[],selectIdentifier:ua,selectDisplayName:fa})}else m=await ra({directory:p,selectIdentifier:ua,selectDisplayName:fa});let u=mi({client:s,state:d});await na({source:m,target:u,mode:i,whatIf:r,log:oa({diffMode:o})})}};var M6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:e=>ne(se(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:p,project:i})=>{let r=oe(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:i}).removeComposition({compositionId:p})}};var B6={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:e=>ne(se(_1(e.positional("filename",{demandOption:!0,describe:"Composition file to put"})))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:p,project:i,state:r})=>{let d=oe(t),n=new ie({apiKey:a,apiHost:e,fetch:d,projectId:i}),o=gt(p);await n.updateComposition({...o,state:sa(r)})}};var R6={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:e=>e.command(L6).command(j6).command(I6).command(M6).command(V6).command(B6).demandCommand(),handler:()=>{Ka.help()}};var N3={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:e=>e.command(R6).command(P6).demandCommand(),handler:()=>{Ka.showHelp()}}]};0&&(module.exports={readCanvasPackage,uniformCLI,writeCanvasPackage});
package/dist/cli/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{H as r4,I as vd,a as Z,b as ud,c as z,d as fd,e as $p,f as hd,g as ei,h as ma,i as kp,j as P1,k as ai,y as ne}from"../chunk-BJ45Y4JT.mjs";var or=z((mm,nr)=>{var Ka=1e3,Ja=Ka*60,Qa=Ja*60,Ea=Qa*24,Ul=Ea*7,$l=Ea*365.25;nr.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return kl(e);if(p==="number"&&isFinite(e))return a.long?Hl(e):ql(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function kl(e){if(e=String(e),!(e.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!a){var p=parseFloat(a[1]),t=(a[2]||"ms").toLowerCase();switch(t){case"years":case"year":case"yrs":case"yr":case"y":return p*$l;case"weeks":case"week":case"w":return p*Ul;case"days":case"day":case"d":return p*Ea;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Qa;case"minutes":case"minute":case"mins":case"min":case"m":return p*Ja;case"seconds":case"second":case"secs":case"sec":case"s":return p*Ka;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function ql(e){var a=Math.abs(e);return a>=Ea?Math.round(e/Ea)+"d":a>=Qa?Math.round(e/Qa)+"h":a>=Ja?Math.round(e/Ja)+"m":a>=Ka?Math.round(e/Ka)+"s":e+"ms"}function Hl(e){var a=Math.abs(e);return a>=Ea?ct(e,a,Ea,"day"):a>=Qa?ct(e,a,Qa,"hour"):a>=Ja?ct(e,a,Ja,"minute"):a>=Ka?ct(e,a,Ka,"second"):e+" ms"}function ct(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var Ri=z((cm,sr)=>{function zl(e){p.debug=p,p.default=p,p.coerce=o,p.disable=r,p.enable=i,p.enabled=d,p.humanize=or(),p.destroy=s,Object.keys(e).forEach(l=>{p[l]=e[l]}),p.names=[],p.skips=[],p.formatters={};function a(l){let m=0;for(let c=0;c<l.length;c++)m=(m<<5)-m+l.charCodeAt(c),m|=0;return p.colors[Math.abs(m)%p.colors.length]}p.selectColor=a;function p(l){let m,c=null,u,v;function g(...h){if(!g.enabled)return;let C=g,x=Number(new Date),T=x-(m||x);C.diff=T,C.prev=m,C.curr=x,m=x,h[0]=p.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let B=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(L,O)=>{if(L==="%%")return"%";B++;let G=p.formatters[O];if(typeof G=="function"){let X=h[B];L=G.call(C,X),h.splice(B,1),B--}return L}),p.formatArgs.call(C,h),(C.log||p.log).apply(C,h)}return g.namespace=l,g.useColors=p.useColors(),g.color=p.selectColor(l),g.extend=t,g.destroy=p.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==p.namespaces&&(u=p.namespaces,v=p.enabled(l)),v),set:h=>{c=h}}),typeof p.init=="function"&&p.init(g),g}function t(l,m){let c=p(this.namespace+(typeof m=="undefined"?":":m)+l);return c.log=this.log,c}function i(l){p.save(l),p.namespaces=l,p.names=[],p.skips=[];let m,c=(typeof l=="string"?l:"").split(/[\s,]+/),u=c.length;for(m=0;m<u;m++)!c[m]||(l=c[m].replace(/\*/g,".*?"),l[0]==="-"?p.skips.push(new RegExp("^"+l.slice(1)+"$")):p.names.push(new RegExp("^"+l+"$")))}function r(){let l=[...p.names.map(n),...p.skips.map(n).map(m=>"-"+m)].join(",");return p.enable(""),l}function d(l){if(l[l.length-1]==="*")return!0;let m,c;for(m=0,c=p.skips.length;m<c;m++)if(p.skips[m].test(l))return!1;for(m=0,c=p.names.length;m<c;m++)if(p.names[m].test(l))return!0;return!1}function n(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function o(l){return l instanceof Error?l.stack||l.message:l}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return p.enable(p.load()),p}sr.exports=zl});var lr=z((Ye,ut)=>{Ye.formatArgs=Yl;Ye.save=Gl;Ye.load=Kl;Ye.useColors=Wl;Ye.storage=Jl();Ye.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ye.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Wl(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Yl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ut.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let p=0,t=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(p++,i==="%c"&&(t=p))}),e.splice(t,0,a)}Ye.log=console.debug||console.log||(()=>{});function Gl(e){try{e?Ye.storage.setItem("debug",e):Ye.storage.removeItem("debug")}catch(a){}}function Kl(){let e;try{e=Ye.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function Jl(){try{return localStorage}catch(e){}}ut.exports=Ri()(Ye);var{formatters:Ql}=ut.exports;Ql.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var cr=z((um,mr)=>{"use strict";mr.exports=(e,a=process.argv)=>{let p=e.startsWith("-")?"":e.length===1?"-":"--",t=a.indexOf(p+e),i=a.indexOf("--");return t!==-1&&(i===-1||t<i)}});var hr=z((fm,fr)=>{"use strict";var Zl=Z("os"),ur=Z("tty"),a1=cr(),{env:Ee}=process,$1;a1("no-color")||a1("no-colors")||a1("color=false")||a1("color=never")?$1=0:(a1("color")||a1("colors")||a1("color=true")||a1("color=always"))&&($1=1);"FORCE_COLOR"in Ee&&(Ee.FORCE_COLOR==="true"?$1=1:Ee.FORCE_COLOR==="false"?$1=0:$1=Ee.FORCE_COLOR.length===0?1:Math.min(parseInt(Ee.FORCE_COLOR,10),3));function Ui(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function $i(e,a){if($1===0)return 0;if(a1("color=16m")||a1("color=full")||a1("color=truecolor"))return 3;if(a1("color=256"))return 2;if(e&&!a&&$1===void 0)return 0;let p=$1||0;if(Ee.TERM==="dumb")return p;if(process.platform==="win32"){let t=Zl.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Ee)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in Ee)||Ee.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in Ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ee.TEAMCITY_VERSION)?1:0;if(Ee.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Ee){let t=parseInt((Ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ee.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ee.TERM)||"COLORTERM"in Ee?1:p}function Xl(e){let a=$i(e,e&&e.isTTY);return Ui(a)}fr.exports={supportsColor:Xl,stdout:Ui($i(!0,ur.isatty(1))),stderr:Ui($i(!0,ur.isatty(2)))}});var gr=z((Fe,ht)=>{var e8=Z("tty"),ft=Z("util");Fe.init=n8;Fe.log=i8;Fe.formatArgs=p8;Fe.save=d8;Fe.load=r8;Fe.useColors=a8;Fe.destroy=ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Fe.colors=[6,2,3,4,5,1];try{let e=hr();e&&(e.stderr||e).level>=2&&(Fe.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}Fe.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{let p=a.substring(6).toLowerCase().replace(/_([a-z])/g,(i,r)=>r.toUpperCase()),t=process.env[a];return/^(yes|on|true|enabled)$/i.test(t)?t=!0:/^(no|off|false|disabled)$/i.test(t)?t=!1:t==="null"?t=null:t=Number(t),e[p]=t,e},{});function a8(){return"colors"in Fe.inspectOpts?Boolean(Fe.inspectOpts.colors):e8.isatty(process.stderr.fd)}function p8(e){let{namespace:a,useColors:p}=this;if(p){let t=this.color,i="\x1B[3"+(t<8?t:"8;5;"+t),r=` ${i};1m${a} \x1B[0m`;e[0]=r+e[0].split(`
1
+ import{H as r4,I as vd,a as Z,b as ud,c as z,d as fd,e as $p,f as hd,g as ei,h as ma,i as kp,j as P1,k as ai,y as ne}from"../chunk-VQFPUXRX.mjs";var or=z((mm,nr)=>{var Ka=1e3,Ja=Ka*60,Qa=Ja*60,Ea=Qa*24,Ul=Ea*7,$l=Ea*365.25;nr.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return kl(e);if(p==="number"&&isFinite(e))return a.long?Hl(e):ql(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function kl(e){if(e=String(e),!(e.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!a){var p=parseFloat(a[1]),t=(a[2]||"ms").toLowerCase();switch(t){case"years":case"year":case"yrs":case"yr":case"y":return p*$l;case"weeks":case"week":case"w":return p*Ul;case"days":case"day":case"d":return p*Ea;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Qa;case"minutes":case"minute":case"mins":case"min":case"m":return p*Ja;case"seconds":case"second":case"secs":case"sec":case"s":return p*Ka;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function ql(e){var a=Math.abs(e);return a>=Ea?Math.round(e/Ea)+"d":a>=Qa?Math.round(e/Qa)+"h":a>=Ja?Math.round(e/Ja)+"m":a>=Ka?Math.round(e/Ka)+"s":e+"ms"}function Hl(e){var a=Math.abs(e);return a>=Ea?ct(e,a,Ea,"day"):a>=Qa?ct(e,a,Qa,"hour"):a>=Ja?ct(e,a,Ja,"minute"):a>=Ka?ct(e,a,Ka,"second"):e+" ms"}function ct(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var Ri=z((cm,sr)=>{function zl(e){p.debug=p,p.default=p,p.coerce=o,p.disable=r,p.enable=i,p.enabled=d,p.humanize=or(),p.destroy=s,Object.keys(e).forEach(l=>{p[l]=e[l]}),p.names=[],p.skips=[],p.formatters={};function a(l){let m=0;for(let c=0;c<l.length;c++)m=(m<<5)-m+l.charCodeAt(c),m|=0;return p.colors[Math.abs(m)%p.colors.length]}p.selectColor=a;function p(l){let m,c=null,u,v;function g(...h){if(!g.enabled)return;let C=g,x=Number(new Date),T=x-(m||x);C.diff=T,C.prev=m,C.curr=x,m=x,h[0]=p.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let B=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(L,O)=>{if(L==="%%")return"%";B++;let G=p.formatters[O];if(typeof G=="function"){let X=h[B];L=G.call(C,X),h.splice(B,1),B--}return L}),p.formatArgs.call(C,h),(C.log||p.log).apply(C,h)}return g.namespace=l,g.useColors=p.useColors(),g.color=p.selectColor(l),g.extend=t,g.destroy=p.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==p.namespaces&&(u=p.namespaces,v=p.enabled(l)),v),set:h=>{c=h}}),typeof p.init=="function"&&p.init(g),g}function t(l,m){let c=p(this.namespace+(typeof m=="undefined"?":":m)+l);return c.log=this.log,c}function i(l){p.save(l),p.namespaces=l,p.names=[],p.skips=[];let m,c=(typeof l=="string"?l:"").split(/[\s,]+/),u=c.length;for(m=0;m<u;m++)!c[m]||(l=c[m].replace(/\*/g,".*?"),l[0]==="-"?p.skips.push(new RegExp("^"+l.slice(1)+"$")):p.names.push(new RegExp("^"+l+"$")))}function r(){let l=[...p.names.map(n),...p.skips.map(n).map(m=>"-"+m)].join(",");return p.enable(""),l}function d(l){if(l[l.length-1]==="*")return!0;let m,c;for(m=0,c=p.skips.length;m<c;m++)if(p.skips[m].test(l))return!1;for(m=0,c=p.names.length;m<c;m++)if(p.names[m].test(l))return!0;return!1}function n(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function o(l){return l instanceof Error?l.stack||l.message:l}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return p.enable(p.load()),p}sr.exports=zl});var lr=z((Ye,ut)=>{Ye.formatArgs=Yl;Ye.save=Gl;Ye.load=Kl;Ye.useColors=Wl;Ye.storage=Jl();Ye.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ye.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Wl(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Yl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ut.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let p=0,t=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(p++,i==="%c"&&(t=p))}),e.splice(t,0,a)}Ye.log=console.debug||console.log||(()=>{});function Gl(e){try{e?Ye.storage.setItem("debug",e):Ye.storage.removeItem("debug")}catch(a){}}function Kl(){let e;try{e=Ye.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function Jl(){try{return localStorage}catch(e){}}ut.exports=Ri()(Ye);var{formatters:Ql}=ut.exports;Ql.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var cr=z((um,mr)=>{"use strict";mr.exports=(e,a=process.argv)=>{let p=e.startsWith("-")?"":e.length===1?"-":"--",t=a.indexOf(p+e),i=a.indexOf("--");return t!==-1&&(i===-1||t<i)}});var hr=z((fm,fr)=>{"use strict";var Zl=Z("os"),ur=Z("tty"),a1=cr(),{env:Ee}=process,$1;a1("no-color")||a1("no-colors")||a1("color=false")||a1("color=never")?$1=0:(a1("color")||a1("colors")||a1("color=true")||a1("color=always"))&&($1=1);"FORCE_COLOR"in Ee&&(Ee.FORCE_COLOR==="true"?$1=1:Ee.FORCE_COLOR==="false"?$1=0:$1=Ee.FORCE_COLOR.length===0?1:Math.min(parseInt(Ee.FORCE_COLOR,10),3));function Ui(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function $i(e,a){if($1===0)return 0;if(a1("color=16m")||a1("color=full")||a1("color=truecolor"))return 3;if(a1("color=256"))return 2;if(e&&!a&&$1===void 0)return 0;let p=$1||0;if(Ee.TERM==="dumb")return p;if(process.platform==="win32"){let t=Zl.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Ee)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in Ee)||Ee.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in Ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ee.TEAMCITY_VERSION)?1:0;if(Ee.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Ee){let t=parseInt((Ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ee.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ee.TERM)||"COLORTERM"in Ee?1:p}function Xl(e){let a=$i(e,e&&e.isTTY);return Ui(a)}fr.exports={supportsColor:Xl,stdout:Ui($i(!0,ur.isatty(1))),stderr:Ui($i(!0,ur.isatty(2)))}});var gr=z((Fe,ht)=>{var e8=Z("tty"),ft=Z("util");Fe.init=n8;Fe.log=i8;Fe.formatArgs=p8;Fe.save=d8;Fe.load=r8;Fe.useColors=a8;Fe.destroy=ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Fe.colors=[6,2,3,4,5,1];try{let e=hr();e&&(e.stderr||e).level>=2&&(Fe.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}Fe.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{let p=a.substring(6).toLowerCase().replace(/_([a-z])/g,(i,r)=>r.toUpperCase()),t=process.env[a];return/^(yes|on|true|enabled)$/i.test(t)?t=!0:/^(no|off|false|disabled)$/i.test(t)?t=!1:t==="null"?t=null:t=Number(t),e[p]=t,e},{});function a8(){return"colors"in Fe.inspectOpts?Boolean(Fe.inspectOpts.colors):e8.isatty(process.stderr.fd)}function p8(e){let{namespace:a,useColors:p}=this;if(p){let t=this.color,i="\x1B[3"+(t<8?t:"8;5;"+t),r=` ${i};1m${a} \x1B[0m`;e[0]=r+e[0].split(`
2
2
  `).join(`
3
3
  `+r),e.push(i+"m+"+ht.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=t8()+a+" "+e[0]}function t8(){return Fe.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i8(...e){return process.stderr.write(ft.format(...e)+`
4
4
  `)}function d8(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function r8(){return process.env.DEBUG}function n8(e){e.inspectOpts={};let a=Object.keys(Fe.inspectOpts);for(let p=0;p<a.length;p++)e.inspectOpts[a[p]]=Fe.inspectOpts[a[p]]}ht.exports=Ri()(Fe);var{formatters:vr}=ht.exports;vr.o=function(e){return this.inspectOpts.colors=this.useColors,ft.inspect(e,this.inspectOpts).split(`
@@ -113,7 +113,7 @@ ${v.join(`
113
113
  `+e.slice(i,r),i=r+1),d=n;return o+=`
114
114
  `,e.length-i>a&&d>i?o+=e.slice(i,d)+`
115
115
  `+e.slice(d+1):o+=e.slice(i),o.slice(1)}function Pl(e){for(var a="",p=0,t,i=0;i<e.length;p>=65536?i+=2:i++)p=bp(e,i),t=Le[p],!t&&xp(p)?(a+=e[i],p>=65536&&(a+=e[i+1])):a+=t||xl(p);return a}function Il(e,a,p){var t="",i=e.tag,r,d,n;for(r=0,d=p.length;r<d;r+=1)n=p[r],e.replacer&&(n=e.replacer.call(p,String(r),n)),(C1(e,a,n,!1,!1)||typeof n=="undefined"&&C1(e,a,null,!1,!1))&&(t!==""&&(t+=","+(e.condenseFlow?"":" ")),t+=e.dump);e.tag=i,e.dump="["+t+"]"}function P0(e,a,p,t){var i="",r=e.tag,d,n,o;for(d=0,n=p.length;d<n;d+=1)o=p[d],e.replacer&&(o=e.replacer.call(p,String(d),o)),(C1(e,a+1,o,!0,!0,!1,!0)||typeof o=="undefined"&&C1(e,a+1,null,!0,!0,!1,!0))&&((!t||i!=="")&&(i+=Fi(e,a)),e.dump&&_p===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=r,e.dump=i||"[]"}function Vl(e,a,p){var t="",i=e.tag,r=Object.keys(p),d,n,o,s,l;for(d=0,n=r.length;d<n;d+=1)l="",t!==""&&(l+=", "),e.condenseFlow&&(l+='"'),o=r[d],s=p[o],e.replacer&&(s=e.replacer.call(p,o,s)),C1(e,a,o,!1,!1)&&(e.dump.length>1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),C1(e,a,s,!1,!1)&&(l+=e.dump,t+=l));e.tag=i,e.dump="{"+t+"}"}function Ll(e,a,p,t){var i="",r=e.tag,d=Object.keys(p),n,o,s,l,m,c;if(e.sortKeys===!0)d.sort();else if(typeof e.sortKeys=="function")d.sort(e.sortKeys);else if(e.sortKeys)throw new Re("sortKeys must be a boolean or a function");for(n=0,o=d.length;n<o;n+=1)c="",(!t||i!=="")&&(c+=Fi(e,a)),s=d[n],l=p[s],e.replacer&&(l=e.replacer.call(p,s,l)),C1(e,a+1,s,!0,!0,!0)&&(m=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,m&&(e.dump&&_p===e.dump.charCodeAt(0)?c+="?":c+="? "),c+=e.dump,m&&(c+=Fi(e,a)),C1(e,a+1,l,!0,m)&&(e.dump&&_p===e.dump.charCodeAt(0)?c+=":":c+=": ",c+=e.dump,i+=c));e.tag=r,e.dump=i||"{}"}function I0(e,a,p){var t,i,r,d,n,o;for(i=p?e.explicitTypes:e.implicitTypes,r=0,d=i.length;r<d;r+=1)if(n=i[r],(n.instanceOf||n.predicate)&&(!n.instanceOf||typeof a=="object"&&a instanceof n.instanceOf)&&(!n.predicate||n.predicate(a))){if(p?n.multi&&n.representName?e.tag=n.representName(a):e.tag=n.tag:e.tag="?",n.represent){if(o=e.styleMap[n.tag]||n.defaultStyle,G0.call(n.represent)==="[object Function]")t=n.represent(a,o);else if(K0.call(n.represent,o))t=n.represent[o](a,o);else throw new Re("!<"+n.tag+'> tag resolver accepts not "'+o+'" style');e.dump=t}return!0}return!1}function C1(e,a,p,t,i,r,d){e.tag=null,e.dump=p,I0(e,p,!1)||I0(e,p,!0);var n=G0.call(e.dump),o=t,s;t&&(t=e.flowLevel<0||e.flowLevel>a);var l=n==="[object Object]"||n==="[object Array]",m,c;if(l&&(m=e.duplicates.indexOf(p),c=m!==-1),(e.tag!==null&&e.tag!=="?"||c||e.indent!==2&&a>0)&&(i=!1),c&&e.usedDuplicates[m])e.dump="*ref_"+m;else{if(l&&c&&!e.usedDuplicates[m]&&(e.usedDuplicates[m]=!0),n==="[object Object]")t&&Object.keys(e.dump).length!==0?(Ll(e,a,e.dump,i),c&&(e.dump="&ref_"+m+e.dump)):(Vl(e,a,e.dump),c&&(e.dump="&ref_"+m+" "+e.dump));else if(n==="[object Array]")t&&e.dump.length!==0?(e.noArrayIndent&&!d&&a>0?P0(e,a-1,e.dump,i):P0(e,a,e.dump,i),c&&(e.dump="&ref_"+m+e.dump)):(Il(e,a,e.dump),c&&(e.dump="&ref_"+m+" "+e.dump));else if(n==="[object String]")e.tag!=="?"&&Tl(e,e.dump,a,r,o);else{if(n==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Re("unacceptable kind of an object to dump "+n)}e.tag!==null&&e.tag!=="?"&&(s=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?s="!"+s:s.slice(0,18)==="tag:yaml.org,2002:"?s="!!"+s.slice(18):s="!<"+s+">",e.dump=s+" "+e.dump)}return!0}function jl(e,a){var p=[],t=[],i,r;for(Ii(e,p,t),i=0,r=t.length;i<r;i+=1)a.duplicates.push(p[t[i]]);a.usedDuplicates=new Array(r)}function Ii(e,a,p){var t,i,r;if(e!==null&&typeof e=="object")if(i=a.indexOf(e),i!==-1)p.indexOf(i)===-1&&p.push(i);else if(a.push(e),Array.isArray(e))for(i=0,r=e.length;i<r;i+=1)Ii(e[i],a,p);else for(t=Object.keys(e),i=0,r=t.length;i<r;i+=1)Ii(e[t[i]],a,p)}function Ml(e,a){a=a||{};var p=new Al(a);p.noRefs||jl(e,p);var t=e;return p.replacer&&(t=p.replacer.call({"":t},"",t)),C1(p,0,t,!0,!0)?p.dump+`
116
- `:""}var Bl=Ml,Rl={dump:Bl};function Bi(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var dr=Y0.load,rm=Y0.loadAll,rr=Rl.dump;var nm=Bi("safeLoad","load"),om=Bi("safeLoadAll","loadAll"),sm=Bi("safeDump","dump");var k6=$p(Er(),1),sd=$p(d6(),1);import{writeFileSync as s3}from"fs";import{extname as $6}from"path";import{readFileSync as l3}from"fs";import m3 from"fs";function O1(){}O1.prototype={diff:function(a,p){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=t.callback;typeof t=="function"&&(i=t,t={}),this.options=t;var r=this;function d(g){return i?(setTimeout(function(){i(void 0,g)},0),!0):g}a=this.castInput(a),p=this.castInput(p),a=this.removeEmpty(this.tokenize(a)),p=this.removeEmpty(this.tokenize(p));var n=p.length,o=a.length,s=1,l=n+o;t.maxEditLength&&(l=Math.min(l,t.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],p,a,0);if(m[0].newPos+1>=n&&c+1>=o)return d([{value:this.join(p),count:p.length}]);function u(){for(var g=-1*s;g<=s;g+=2){var h=void 0,C=m[g-1],x=m[g+1],T=(x?x.newPos:0)-g;C&&(m[g-1]=void 0);var B=C&&C.newPos+1<n,R=x&&0<=T&&T<o;if(!B&&!R){m[g]=void 0;continue}if(!B||R&&C.newPos<x.newPos?(h=V9(x),r.pushComponent(h.components,void 0,!0)):(h=C,h.newPos++,r.pushComponent(h.components,!0,void 0)),T=r.extractCommon(h,p,a,g),h.newPos+1>=n&&T+1>=o)return d(I9(r,h.components,p,a,r.useLongestToken));m[g]=h}s++}if(i)(function g(){setTimeout(function(){if(s>l)return i();u()||g()},0)})();else for(;s<=l;){var v=u();if(v)return v}},pushComponent:function(a,p,t){var i=a[a.length-1];i&&i.added===p&&i.removed===t?a[a.length-1]={count:i.count+1,added:p,removed:t}:a.push({count:1,added:p,removed:t})},extractCommon:function(a,p,t,i){for(var r=p.length,d=t.length,n=a.newPos,o=n-i,s=0;n+1<r&&o+1<d&&this.equals(p[n+1],t[o+1]);)n++,o++,s++;return s&&a.components.push({count:s}),a.newPos=n,o},equals:function(a,p){return this.options.comparator?this.options.comparator(a,p):a===p||this.options.ignoreCase&&a.toLowerCase()===p.toLowerCase()},removeEmpty:function(a){for(var p=[],t=0;t<a.length;t++)a[t]&&p.push(a[t]);return p},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function I9(e,a,p,t,i){for(var r=0,d=a.length,n=0,o=0;r<d;r++){var s=a[r];if(s.removed){if(s.value=e.join(t.slice(o,o+s.count)),o+=s.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!s.added&&i){var l=p.slice(n,n+s.count);l=l.map(function(u,v){var g=t[o+v];return g.length>u.length?g:u}),s.value=e.join(l)}else s.value=e.join(p.slice(n,n+s.count));n+=s.count,s.added||(o+=s.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function V9(e){return{newPos:e.newPos,components:e.components.slice(0)}}var pc=new O1;var r6=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,n6=/\S/,o6=new O1;o6.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!n6.test(e)&&!n6.test(a)};o6.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),p=0;p<a.length-1;p++)!a[p+1]&&a[p+2]&&r6.test(a[p])&&r6.test(a[p+2])&&(a[p]+=a[p+2],a.splice(p+1,2),p--);return a};var G2=new O1;G2.tokenize=function(e){var a=[],p=e.split(/(\n|\r\n)/);p[p.length-1]||p.pop();for(var t=0;t<p.length;t++){var i=p[t];t%2&&!this.options.newlineIsToken?a[a.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),a.push(i))}return a};function K2(e,a,p){return G2.diff(e,a,p)}var L9=new O1;L9.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var j9=new O1;j9.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Mt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Mt=function(a){return typeof a}:Mt=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Mt(e)}var M9=Object.prototype.toString,np=new O1;np.useLongestToken=!0;np.tokenize=G2.tokenize;np.castInput=function(e){var a=this.options,p=a.undefinedReplacement,t=a.stringifyReplacer,i=t===void 0?function(r,d){return typeof d=="undefined"?p:d}:t;return typeof e=="string"?e:JSON.stringify(W2(e,null,null,i),i," ")};np.equals=function(e,a){return O1.prototype.equals.call(np,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function s6(e,a,p){return np.diff(e,a,p)}function W2(e,a,p,t,i){a=a||[],p=p||[],t&&(e=t(i,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return p[r];var d;if(M9.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),p.push(d),r=0;r<e.length;r+=1)d[r]=W2(e[r],a,p,t,i);return a.pop(),p.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),Mt(e)==="object"&&e!==null){a.push(e),d={},p.push(d);var n=[],o;for(o in e)e.hasOwnProperty(o)&&n.push(o);for(n.sort(),r=0;r<n.length;r+=1)o=n[r],d[o]=W2(e[o],a,p,t,o);a.pop(),p.pop()}else d=e;return d}var Y2=new O1;Y2.tokenize=function(e){return e.slice()};Y2.join=Y2.removeEmpty=function(e){return e};var z6=$p(R6(),1);async function Q1({objects:e,selectIdentifier:a,selectDisplayName:p=a,onSyncComplete:t}){let i=e.reduce((n,o)=>{let s=a(o);if(n[s])throw new Error(`Identifier ${s} was not unique.`);return n[s]={id:s,object:o,providerId:s,displayName:p(o)},n},{});async function*r(){for(let n of Object.values(i))yield n}function d(){return Object.entries(i).sort((n,o)=>n[0].localeCompare(o[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete i[n]},writeObject:async n=>{let o=a(n.object);i[o]=n},extractCurrent:d,onSyncComplete:t?n=>t(n,d()):void 0}}var t3=Si(Ai());function oe(e){var a,p;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(p=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?p:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function se(e){return console.log(`\u{1F991} Using proxy ${e}`),(a,p)=>{if(e){let t={...p,agent:new k6.HttpsProxyAgent(e)};return(0,sd.default)(a,t)}return(0,sd.default)(a,p)}}function le(e){var a,p,t;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(t=(p=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?p:process.env.UPM_CLI_PROJECT_ID)!=null?t:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function Z1(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function X1(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function ea(e){let a=$6(e);return a===".yaml"||a===".yml"||a===".json"}function g1(e,a,p){let t;if(p&&!a){let i=$6(p);i===".yaml"||i===".yml"?a="yaml":i===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":t=JSON.stringify(e,null,2);break;case"yaml":t=rr(e);break;default:throw new Error(`Unsupported format: ${a}`)}p?s3(p,t,"utf8"):console.log(t)}function cp(e){let a=l3(e,"utf8");return dr(a,{filename:e,json:!0})}async function*Gt(e,a){let p=a.pageSize||100,t=0,i=[];do{i=await e(t,p);for(let r of i)yield r;t+=p}while(i.length===p)}async function aa({directory:e,format:a="yaml",selectIdentifier:p,selectDisplayName:t=p}){i3(e)||d3(e,{recursive:!0});let i=await r3(e,"utf-8"),r=new Set(i.filter(o=>{let s=o3(o);return s===".json"||s===".yaml"||s===".yml"})),d=o=>U6(e,`${o}.${a}`);async function*n(){for(let o of r){let s=U6(e,o);try{let l=await cp(s);yield{id:p(l),displayName:t(l),providerId:s,object:l}}catch(l){throw console.error(t3.default.red(`Failed to read ${s}, data is likely invalid.
116
+ `:""}var Bl=Ml,Rl={dump:Bl};function Bi(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var dr=Y0.load,rm=Y0.loadAll,rr=Rl.dump;var nm=Bi("safeLoad","load"),om=Bi("safeLoadAll","loadAll"),sm=Bi("safeDump","dump");var k6=$p(Er(),1),sd=$p(d6(),1);import{writeFileSync as s3}from"fs";import{extname as $6}from"path";import{readFileSync as l3}from"fs";import m3 from"fs";function O1(){}O1.prototype={diff:function(a,p){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=t.callback;typeof t=="function"&&(i=t,t={}),this.options=t;var r=this;function d(g){return i?(setTimeout(function(){i(void 0,g)},0),!0):g}a=this.castInput(a),p=this.castInput(p),a=this.removeEmpty(this.tokenize(a)),p=this.removeEmpty(this.tokenize(p));var n=p.length,o=a.length,s=1,l=n+o;t.maxEditLength&&(l=Math.min(l,t.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],p,a,0);if(m[0].newPos+1>=n&&c+1>=o)return d([{value:this.join(p),count:p.length}]);function u(){for(var g=-1*s;g<=s;g+=2){var h=void 0,C=m[g-1],x=m[g+1],T=(x?x.newPos:0)-g;C&&(m[g-1]=void 0);var B=C&&C.newPos+1<n,R=x&&0<=T&&T<o;if(!B&&!R){m[g]=void 0;continue}if(!B||R&&C.newPos<x.newPos?(h=V9(x),r.pushComponent(h.components,void 0,!0)):(h=C,h.newPos++,r.pushComponent(h.components,!0,void 0)),T=r.extractCommon(h,p,a,g),h.newPos+1>=n&&T+1>=o)return d(I9(r,h.components,p,a,r.useLongestToken));m[g]=h}s++}if(i)(function g(){setTimeout(function(){if(s>l)return i();u()||g()},0)})();else for(;s<=l;){var v=u();if(v)return v}},pushComponent:function(a,p,t){var i=a[a.length-1];i&&i.added===p&&i.removed===t?a[a.length-1]={count:i.count+1,added:p,removed:t}:a.push({count:1,added:p,removed:t})},extractCommon:function(a,p,t,i){for(var r=p.length,d=t.length,n=a.newPos,o=n-i,s=0;n+1<r&&o+1<d&&this.equals(p[n+1],t[o+1]);)n++,o++,s++;return s&&a.components.push({count:s}),a.newPos=n,o},equals:function(a,p){return this.options.comparator?this.options.comparator(a,p):a===p||this.options.ignoreCase&&a.toLowerCase()===p.toLowerCase()},removeEmpty:function(a){for(var p=[],t=0;t<a.length;t++)a[t]&&p.push(a[t]);return p},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function I9(e,a,p,t,i){for(var r=0,d=a.length,n=0,o=0;r<d;r++){var s=a[r];if(s.removed){if(s.value=e.join(t.slice(o,o+s.count)),o+=s.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!s.added&&i){var l=p.slice(n,n+s.count);l=l.map(function(u,v){var g=t[o+v];return g.length>u.length?g:u}),s.value=e.join(l)}else s.value=e.join(p.slice(n,n+s.count));n+=s.count,s.added||(o+=s.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function V9(e){return{newPos:e.newPos,components:e.components.slice(0)}}var pc=new O1;var r6=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,n6=/\S/,o6=new O1;o6.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!n6.test(e)&&!n6.test(a)};o6.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),p=0;p<a.length-1;p++)!a[p+1]&&a[p+2]&&r6.test(a[p])&&r6.test(a[p+2])&&(a[p]+=a[p+2],a.splice(p+1,2),p--);return a};var G2=new O1;G2.tokenize=function(e){var a=[],p=e.split(/(\n|\r\n)/);p[p.length-1]||p.pop();for(var t=0;t<p.length;t++){var i=p[t];t%2&&!this.options.newlineIsToken?a[a.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),a.push(i))}return a};function K2(e,a,p){return G2.diff(e,a,p)}var L9=new O1;L9.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var j9=new O1;j9.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Mt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Mt=function(a){return typeof a}:Mt=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Mt(e)}var M9=Object.prototype.toString,np=new O1;np.useLongestToken=!0;np.tokenize=G2.tokenize;np.castInput=function(e){var a=this.options,p=a.undefinedReplacement,t=a.stringifyReplacer,i=t===void 0?function(r,d){return typeof d=="undefined"?p:d}:t;return typeof e=="string"?e:JSON.stringify(W2(e,null,null,i),i," ")};np.equals=function(e,a){return O1.prototype.equals.call(np,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function s6(e,a,p){return np.diff(e,a,p)}function W2(e,a,p,t,i){a=a||[],p=p||[],t&&(e=t(i,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return p[r];var d;if(M9.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),p.push(d),r=0;r<e.length;r+=1)d[r]=W2(e[r],a,p,t,i);return a.pop(),p.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),Mt(e)==="object"&&e!==null){a.push(e),d={},p.push(d);var n=[],o;for(o in e)e.hasOwnProperty(o)&&n.push(o);for(n.sort(),r=0;r<n.length;r+=1)o=n[r],d[o]=W2(e[o],a,p,t,o);a.pop(),p.pop()}else d=e;return d}var Y2=new O1;Y2.tokenize=function(e){return e.slice()};Y2.join=Y2.removeEmpty=function(e){return e};var z6=$p(R6(),1);async function Q1({objects:e,selectIdentifier:a,selectDisplayName:p=a,onSyncComplete:t}){let i=e.reduce((n,o)=>{let s=a(o);if(n[s])throw new Error(`Identifier ${s} was not unique.`);return n[s]={id:s,object:o,providerId:s,displayName:p(o)},n},{});async function*r(){for(let n of Object.values(i))yield n}function d(){return Object.entries(i).sort((n,o)=>n[0].localeCompare(o[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete i[n]},writeObject:async n=>{let o=a(n.object);i[o]=n},extractCurrent:d,onSyncComplete:t?n=>t(n,d()):void 0}}var t3=Si(Ai());function oe(e){var a,p;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(p=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?p:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function se(e){return e&&console.log(`\u{1F991} Using proxy ${e}`),(a,p)=>{if(e){let t={...p,agent:new k6.HttpsProxyAgent(e)};return(0,sd.default)(a,t)}return(0,sd.default)(a,p)}}function le(e){var a,p,t;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(t=(p=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?p:process.env.UPM_CLI_PROJECT_ID)!=null?t:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function Z1(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function X1(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function ea(e){let a=$6(e);return a===".yaml"||a===".yml"||a===".json"}function g1(e,a,p){let t;if(p&&!a){let i=$6(p);i===".yaml"||i===".yml"?a="yaml":i===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":t=JSON.stringify(e,null,2);break;case"yaml":t=rr(e);break;default:throw new Error(`Unsupported format: ${a}`)}p?s3(p,t,"utf8"):console.log(t)}function cp(e){let a=l3(e,"utf8");return dr(a,{filename:e,json:!0})}async function*Gt(e,a){let p=a.pageSize||100,t=0,i=[];do{i=await e(t,p);for(let r of i)yield r;t+=p}while(i.length===p)}async function aa({directory:e,format:a="yaml",selectIdentifier:p,selectDisplayName:t=p}){i3(e)||d3(e,{recursive:!0});let i=await r3(e,"utf-8"),r=new Set(i.filter(o=>{let s=o3(o);return s===".json"||s===".yaml"||s===".yml"})),d=o=>U6(e,`${o}.${a}`);async function*n(){for(let o of r){let s=U6(e,o);try{let l=await cp(s);yield{id:p(l),displayName:t(l),providerId:s,object:l}}catch(l){throw console.error(t3.default.red(`Failed to read ${s}, data is likely invalid.
117
117
  ${l==null?void 0:l.message}`)),l}}}return{objects:n(),deleteObject:async o=>{await n3(o)},writeObject:async o=>{g1(o.object,a,d(o.id))}}}function q6(e,a){if(!a&&!m3.existsSync(e))return{};let p=cp(e);if(typeof p!="object")throw new Error(`Package ${e} does not appear valid.`);return p}function H6(e,a){g1(a,void 0,e)}async function pa({source:e,target:a,compareContents:p=(n,o)=>(0,z6.default)(n.object,o.object,(s,l,m)=>m==="created"||m==="modified"?!0:void 0),mode:t,allowEmptySource:i=!1,whatIf:r=!1,log:d=()=>{}}){var n,o;let s=new Map;for await(let c of a.objects)s.set(c.id,c);let l=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,v=s.get(u);if(v){if(!p(c,v)&&(t==="createOrUpdate"||t==="mirror")){let g=async(h,C)=>{var x;if(!r)try{await a.writeObject(h,C)}catch(T){throw new Yt(T,h)}d({action:"update",id:u,providerId:h.providerId,displayName:(x=h.displayName)!=null?x:h.providerId,whatIf:r,diff:s6(C.object,h.object)})};l.push(g(c,v))}s.delete(u)}else{let g=async(h,C)=>{var x;if(!r)try{await a.writeObject(h)}catch(T){throw new Yt(T,h)}d({action:"create",id:C,providerId:C,displayName:(x=h.displayName)!=null?x:h.providerId,whatIf:r,diff:K2("",JSON.stringify(h.object,null,2))})};l.push(g(c,u))}}if(await Promise.all(l),t==="mirror"){if(!m&&!i)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];s.forEach(async u=>{let v=async g=>{var h;if(!r)try{await a.deleteObject(g.providerId)}catch(C){throw new Yt(C,g)}d({action:"delete",id:g.id,providerId:g.providerId,displayName:(h=g.displayName)!=null?h:g.providerId,whatIf:r,diff:K2(JSON.stringify(g.object,null,2),"")})};c.push(v(u))}),await Promise.all(c)}await Promise.all([(n=e.onSyncComplete)==null?void 0:n.call(e,!1),(o=a.onSyncComplete)==null?void 0:o.call(a,!0)])}var Yt=class extends Error{constructor(e,a){var p;super(`Error syncing ${(p=a.displayName)!=null?p:a.providerId} (${a.providerId})
118
118
  ${e}`),this.stack=void 0,Object.setPrototypeOf(this,Yt.prototype)}},mp=Si(Ai());function ta(e){let{diffMode:a="off",indent:p,prefix:t}=e!=null?e:{};return function({action:i,displayName:r,whatIf:d,diff:n}){let o="";switch(i){case"create":o=mp.default.green("[A]");break;case"update":o=mp.default.white("[U]");break;case"delete":o=mp.default.yellow("[D]");break}let s="";(a==="on"||a==="update"&&i==="update")&&(s=`
119
119
  `+n.map(l=>l.added?mp.default.green(l.value):l.removed?mp.default.red(l.value):l.value).join("")),console.log(`${p!=null?p:""}${d?mp.default.gray("[WHATIF]"):""}${o}${t!=null?t:""} ${r}${s}`)}}var W6={command:"get <id>",describe:"Fetch a component definition",builder:e=>Z1(oe(le(e.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,format:i,project:r,filename:d})=>{let n=se(p),s=await new ne({apiKey:a,apiHost:e,fetch:n,projectId:r}).getComponentDefinitions({componentId:t,limit:1});s.componentDefinitions.length===0?(console.error("Component did not exist"),process.exit(1)):g1(s.componentDefinitions[0],i,d)}};var Y6={command:"list",describe:"List component definitions",aliases:["ls"],builder:e=>Z1(oe(le(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20}})))),handler:async({apiHost:e,apiKey:a,proxy:p,limit:t,offset:i,format:r,filename:d,project:n})=>{let o=se(p),l=await new ne({apiKey:a,apiHost:e,fetch:o,projectId:n}).getComponentDefinitions({limit:t,offset:i});g1(l.componentDefinitions,r,d)}};var ld=class{constructor(a){ei(this,"value");ei(this,"next");this.value=a}},w1,ja,Ma,Up=class{constructor(){kp(this,w1,void 0);kp(this,ja,void 0);kp(this,Ma,void 0);this.clear()}enqueue(a){let p=new ld(a);ma(this,w1)?(ma(this,ja).next=p,P1(this,ja,p)):(P1(this,w1,p),P1(this,ja,p)),ai(this,Ma)._++}dequeue(){let a=ma(this,w1);if(!!a)return P1(this,w1,ma(this,w1).next),ai(this,Ma)._--,a.value}clear(){P1(this,w1,void 0),P1(this,ja,void 0),P1(this,Ma,0)}get size(){return ma(this,Ma)}*[Symbol.iterator](){let a=ma(this,w1);for(;a;)yield a.value,a=a.next}};w1=new WeakMap,ja=new WeakMap,Ma=new WeakMap;function md(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let a=new Up,p=0,t=()=>{p--,a.size>0&&a.dequeue()()},i=async(n,o,s)=>{p++;let l=(async()=>n(...s))();o(l);try{await l}catch(m){}t()},r=(n,o,s)=>{a.enqueue(i.bind(void 0,n,o,s)),(async()=>(await Promise.resolve(),p<e&&a.size>0&&a.dequeue()()))()},d=(n,...o)=>new Promise(s=>{r(n,s,o)});return Object.defineProperties(d,{activeCount:{get:()=>p},pendingCount:{get:()=>a.size},clearQueue:{value:()=>{a.clear()}}}),d}function Kt(e){let a={...e};return delete a.projectId,delete a.state,a}function b1(e){return e.option("state",{type:"string",describe:"Composition state to fetch.",choices:["preview","published"],default:"preview"})}function ia(e){let a=Number(e);if(!isNaN(a))return a;if(!e)return 64;if(typeof e!="string")throw new Error('state must be "published", "preview", or a number');return e==="preview"?0:64}var da=md(8);var ra=e=>e.id,na=e=>`${e.name} (pid: ${e.id})`;function Jt({client:e}){async function*a(){let p=Gt(async(t,i)=>(await e.getComponentDefinitions({limit:i,offset:t})).componentDefinitions,{pageSize:100});for await(let t of p)yield{id:ra(t),displayName:na(t),providerId:t.id,object:t}}return{objects:a(),deleteObject:async p=>{await e.removeComponentDefinition({componentId:p})},writeObject:async p=>{await e.updateComponentDefinition({componentDefinition:p.object})}}}function oa(e,a){return q6(e,a)}function Qt(e,a){H6(e,a)}var G6={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:e=>oe(le(X1(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:o})=>{var v;let s=se(p),l=new ne({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:da}),m=Jt({client:l}),c;if(ea(t)){let g=oa(t,!1);c=await Q1({objects:(v=g.components)!=null?v:[],selectIdentifier:ra,selectDisplayName:na,onSyncComplete:async(h,C)=>{g.components=C,Qt(t,g)}})}else c=await aa({directory:t,selectIdentifier:ra,selectDisplayName:na,format:i});await pa({source:m,target:c,mode:r,whatIf:d,log:ta({diffMode:o})})}};var K6={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Canvas",builder:e=>oe(le(X1(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let o=se(p),s=new ne({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:da}),l;if(ea(t)){let v=oa(t,!0);l=await Q1({objects:(u=v.components)!=null?u:[],selectIdentifier:ra,selectDisplayName:na})}else l=await aa({directory:t,selectIdentifier:ra,selectDisplayName:na});let c=Jt({client:s});await pa({source:l,target:c,mode:i,whatIf:r,log:ta({diffMode:n})})}};var J6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:e=>oe(le(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,project:i})=>{let r=se(p);await new ne({apiKey:a,apiHost:e,fetch:r,projectId:i}).removeComponentDefinition({componentId:t})}};var Q6={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:e=>oe(le(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:p,filename:t,project:i})=>{let r=se(p),d=new ne({apiKey:a,apiHost:e,fetch:r,projectId:i}),n=cp(t);await d.updateComponentDefinition({componentDefinition:n})}};var Z6={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:e=>e.command(G6).command(K6).command(W6).command(J6).command(Y6).command(Q6).demandCommand(),handler:()=>{Ha.help()}};var X6={command:"get <id>",describe:"Fetch a composition",builder:e=>Z1(oe(le(b1(e.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,format:i,filename:r,state:d,project:n,resolvePatterns:o})=>{let s=se(p),l=new ne({apiKey:a,apiHost:e,fetch:s,projectId:n}),m=Kt(await l.getCompositionById({compositionId:t,state:ia(d),skipPatternResolution:!o}));g1(m,i,r)}};var e4={command:"list",describe:"List compositions",aliases:["ls"],builder:e=>Z1(oe(le(b1(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20},resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:a,proxy:p,limit:t,offset:i,format:r,filename:d,project:n,state:o,resolvePatterns:s})=>{let l=se(p),c=await new ne({apiKey:a,apiHost:e,fetch:l,projectId:n}).getCompositionList({limit:t,offset:i,state:ia(o),skipPatternResolution:!s});g1(c.compositions,r,d)}};var sa=e=>e.composition._id,la=e=>{var a,p;return`${(p=(a=e.composition._name)!=null?a:e.composition._slug)!=null?p:e.composition._id} (pid: ${e.composition._id})`};function Zt({client:e,state:a}){let p=ia(a);async function*t(){let i=Gt(async(r,d)=>(await e.getCompositionList({limit:d,offset:r,state:p,skipPatternResolution:!0})).compositions,{pageSize:100});for await(let r of i)yield{id:sa(r),displayName:la(r),providerId:r.composition._id,object:Kt(r)}}return{objects:t(),deleteObject:async i=>{await e.removeComposition({compositionId:i})},writeObject:async i=>{await e.updateComposition({...i.object,state:p})}}}var a4={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:e=>oe(le(b1(X1(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,state:n,project:o,diff:s})=>{var g;let l=se(p),m=new ne({apiKey:a,apiHost:e,fetch:l,projectId:o,limitPolicy:da}),c=Zt({client:m,state:n}),u=ea(t),v;if(u){let h=oa(t,!1);v=await Q1({objects:(g=h==null?void 0:h.compositions)!=null?g:[],selectIdentifier:sa,selectDisplayName:la,onSyncComplete:async(C,x)=>{h.compositions=x,Qt(t,h)}})}else v=await aa({directory:t,selectIdentifier:sa,selectDisplayName:la,format:i});await pa({source:c,target:v,mode:r,whatIf:d,log:ta({diffMode:s})})}};var p4={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Canvas",builder:e=>oe(le(b1(X1(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,state:d,project:n,diff:o})=>{var v;let s=se(p),l=new ne({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:da}),m;if(ea(t)){let g=oa(t,!0);m=await Q1({objects:(v=g.compositions)!=null?v:[],selectIdentifier:sa,selectDisplayName:la})}else m=await aa({directory:t,selectIdentifier:sa,selectDisplayName:la});let u=Zt({client:l,state:d});await pa({source:m,target:u,mode:i,whatIf:r,log:ta({diffMode:o})})}};var t4={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:e=>oe(le(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,project:i})=>{let r=se(p);await new ne({apiKey:a,apiHost:e,fetch:r,projectId:i}).removeComposition({compositionId:t})}};var i4={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:e=>oe(le(b1(e.positional("filename",{demandOption:!0,describe:"Composition file to put"})))),handler:async({apiHost:e,apiKey:a,proxy:p,filename:t,project:i,state:r})=>{let d=se(p),n=new ne({apiKey:a,apiHost:e,fetch:d,projectId:i}),o=cp(t);await n.updateComposition({...o,state:ia(r)})}};var d4={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:e=>e.command(a4).command(p4).command(X6).command(t4).command(e4).command(i4).demandCommand(),handler:()=>{Ha.help()}};var Zf={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:e=>e.command(d4).command(Z6).demandCommand(),handler:()=>{Ha.showHelp()}}]};export{oa as readCanvasPackage,Zf as uniformCLI,Qt as writeCanvasPackage};
@@ -215,7 +215,7 @@ interface external$1 {
215
215
  /** @description Friendly name of the component definition */
216
216
  name: string;
217
217
  /**
218
- * @description Icon name for the component definition (e.g. 'screen')
218
+ * @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
219
219
  * @default screen
220
220
  */
221
221
  icon?: string;
@@ -422,7 +422,7 @@ interface components$1 {
422
422
  /** @description Friendly name of the component definition */
423
423
  name: string;
424
424
  /**
425
- * @description Icon name for the component definition (e.g. 'screen')
425
+ * @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
426
426
  * @default screen
427
427
  */
428
428
  icon?: string;
@@ -853,7 +853,7 @@ interface external {
853
853
  /** @description Friendly name of the component definition */
854
854
  name: string;
855
855
  /**
856
- * @description Icon name for the component definition (e.g. 'screen')
856
+ * @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
857
857
  * @default screen
858
858
  */
859
859
  icon?: string;
@@ -1008,6 +1008,11 @@ declare type ComponentInstance = SharedComponents['ComponentInstance'] & {
1008
1008
  };
1009
1009
  /** Defines the shape of the root component in a composition */
1010
1010
  declare type RootComponentInstance = SharedComponents['RootComponentInstance'];
1011
+ /** Defines single structure to keep all canvas models (used in CLI commands and Starter content generations) */
1012
+ declare type CanvasDefinitions = {
1013
+ components?: Array<ComponentDefinition>;
1014
+ compositions?: Array<CompositionGetResponse>;
1015
+ };
1011
1016
 
1012
1017
  /**
1013
1018
  * Pusher-js is large (80k) and not tree shakable so it is always bundled if directly referenced,
@@ -1034,4 +1039,4 @@ declare global {
1034
1039
  */
1035
1040
  declare function createEventBus(): Promise<PreviewEventBus | undefined>;
1036
1041
 
1037
- export { ChannelSubscription as A, createEventBus as B, ComponentInstance as C, PreviewEventBus as P, RootComponentInstance as R, ComponentParameter as a, CompositionGetParameters as b, CompositionPutParameters as c, CompositionDeleteParameters as d, ComponentDefinitionGetParameters as e, ComponentDefinitionPutParameters as f, ComponentDefinitionDeleteParameters as g, ComponentDefinitionGetResponse as h, ComponentDefinitionAPIResponse as i, ComponentDefinitionAPIPutRequest as j, ComponentDefinitionAPIDeleteRequest as k, ComponentDefinitionListAPIOptions as l, ComponentDefinitionParameter as m, ComponentDefinitionVariant as n, ComponentDefinitionSlugSettings as o, ComponentDefinitionSlot as p, ComponentDefinitionPermission as q, ComponentDefinition as r, CreatingComponentDefinition as s, CompositionGetResponse as t, CompositionGetListResponse as u, CompositionAPIResponse as v, CompositionAPIDeleteRequest as w, CompositionListAPIResponse as x, CompositionAPIOptions as y, ComponentParameterBinding as z };
1042
+ export { CanvasDefinitions as A, ChannelSubscription as B, ComponentInstance as C, createEventBus as D, PreviewEventBus as P, RootComponentInstance as R, ComponentParameter as a, CompositionGetParameters as b, CompositionPutParameters as c, CompositionDeleteParameters as d, ComponentDefinitionGetParameters as e, ComponentDefinitionPutParameters as f, ComponentDefinitionDeleteParameters as g, ComponentDefinitionGetResponse as h, ComponentDefinitionAPIResponse as i, ComponentDefinitionAPIPutRequest as j, ComponentDefinitionAPIDeleteRequest as k, ComponentDefinitionListAPIOptions as l, ComponentDefinitionParameter as m, ComponentDefinitionVariant as n, ComponentDefinitionSlugSettings as o, ComponentDefinitionSlot as p, ComponentDefinitionPermission as q, ComponentDefinition as r, CreatingComponentDefinition as s, CompositionGetResponse as t, CompositionGetListResponse as u, CompositionAPIResponse as v, CompositionAPIDeleteRequest as w, CompositionListAPIResponse as x, CompositionAPIOptions as y, ComponentParameterBinding as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionPutParameters, d as CompositionDeleteParameters, e as ComponentDefinitionGetParameters, f as ComponentDefinitionPutParameters, g as ComponentDefinitionDeleteParameters, P as PreviewEventBus } from './createEventBus-c826147a.js';
2
- export { A as ChannelSubscription, r as ComponentDefinition, k as ComponentDefinitionAPIDeleteRequest, j as ComponentDefinitionAPIPutRequest, i as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, h as ComponentDefinitionGetResponse, l as ComponentDefinitionListAPIOptions, m as ComponentDefinitionParameter, q as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, p as ComponentDefinitionSlot, o as ComponentDefinitionSlugSettings, n as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, z as ComponentParameterBinding, w as CompositionAPIDeleteRequest, y as CompositionAPIOptions, v as CompositionAPIResponse, d as CompositionDeleteParameters, u as CompositionGetListResponse, b as CompositionGetParameters, t as CompositionGetResponse, x as CompositionListAPIResponse, c as CompositionPutParameters, s as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, B as createEventBus } from './createEventBus-c826147a.js';
1
+ import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionPutParameters, d as CompositionDeleteParameters, e as ComponentDefinitionGetParameters, f as ComponentDefinitionPutParameters, g as ComponentDefinitionDeleteParameters, P as PreviewEventBus } from './createEventBus-97db7eb7.js';
2
+ export { A as CanvasDefinitions, B as ChannelSubscription, r as ComponentDefinition, k as ComponentDefinitionAPIDeleteRequest, j as ComponentDefinitionAPIPutRequest, i as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, h as ComponentDefinitionGetResponse, l as ComponentDefinitionListAPIOptions, m as ComponentDefinitionParameter, q as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, p as ComponentDefinitionSlot, o as ComponentDefinitionSlugSettings, n as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, z as ComponentParameterBinding, w as CompositionAPIDeleteRequest, y as CompositionAPIOptions, v as CompositionAPIResponse, d as CompositionDeleteParameters, u as CompositionGetListResponse, b as CompositionGetParameters, t as CompositionGetResponse, x as CompositionListAPIResponse, c as CompositionPutParameters, s as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, D as createEventBus } from './createEventBus-97db7eb7.js';
3
3
  import { Options } from 'p-throttle';
4
4
  import { Options as Options$1 } from 'p-retry';
5
5
  import { PersonalizedVariant, TestVariant } from '@uniformdev/context';
@@ -470,7 +470,7 @@ declare class CanvasClient {
470
470
  }[] | undefined;
471
471
  slugSettings?: {
472
472
  required?: "no" | "yes" | "disabled" | undefined;
473
- unique?: "no" | "local" | "global" | undefined;
473
+ unique?: "global" | "no" | "local" | undefined;
474
474
  regularExpression?: string | undefined;
475
475
  regularExpressionMessage?: string | undefined;
476
476
  } | undefined;
@@ -541,14 +541,6 @@ declare const CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
541
541
  declare const CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
542
542
  /** Public ID of the Uniform Context enrichment tag parameter on Canvas components */
543
543
  declare const CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
544
- /** Component type of 'loop' system component */
545
- declare const CANVAS_LOOP_TYPE = "$loop";
546
- /** Name of parameter on loop component that defines the name of the resource to expose for the iterator */
547
- declare const CANVAS_LOOP_RESOURCE_PARAMETER = "$loopResource";
548
- /** Name of the parameter that stores the binding for the loop */
549
- declare const CANVAS_LOOP_PARAMETER = "$loopBinding";
550
- /** Name of the slot that the loop component exposes for the iterator body */
551
- declare const CANVAS_LOOP_SLOT = "body";
552
544
 
553
545
  /** Determines if a given Canvas component type is a system-defined type */
554
546
  declare const isSystemComponentDefinition: (componentType: string) => boolean;
@@ -592,47 +584,4 @@ declare function localize({ composition, locale, }: {
592
584
  }) => string | undefined);
593
585
  }): void;
594
586
 
595
- /**
596
- * Resource objects that can be bound to on a composition
597
- * @deprecated Do not use
598
- */
599
- declare type CompositionResources = Record<string, unknown>;
600
-
601
- /** @deprecated Do not use */
602
- declare type BindParameterResult = {
603
- bound: boolean;
604
- value?: unknown;
605
- };
606
- /** @deprecated Do not use */
607
- declare function bindParameter(parameter: ComponentParameter, resources: CompositionResources): BindParameterResult;
608
-
609
- /** @deprecated Do not use */
610
- declare type BindParametersResult = {
611
- hasBindings: boolean;
612
- errors: Error[];
613
- result: ComponentInstance;
614
- };
615
- /** @deprecated Do not use */
616
- declare type BindParametersOptions = {
617
- /**
618
- * If true, any binding errors are thrown. Otherwise, they are returned in the result.
619
- * @default true
620
- */
621
- throwErrors?: boolean;
622
- /**
623
- * If true, loop components are bound and replaced by their enumerated values.
624
- * If false, loop components are untouched and remain in the composition data with bindings still in the loop body.
625
- * @default true
626
- */
627
- expandLoops?: boolean;
628
- /**
629
- * If true, leaves binding expressions behind in the resulting composition.
630
- * If false, binding expressions are removed from the resulting composition.
631
- * @default false
632
- */
633
- preserveBindings?: boolean;
634
- };
635
- /** @deprecated Do not use */
636
- declare function bindParameters(composition: ComponentInstance, resources: CompositionResources, options?: BindParametersOptions): BindParametersResult;
637
-
638
- export { BatchEnhancer, BatchEntry, BindParameterResult, BindParametersOptions, BindParametersResult, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_LOOP_PARAMETER, CANVAS_LOOP_RESOURCE_PARAMETER, CANVAS_LOOP_SLOT, CANVAS_LOOP_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, CanvasClientOptions, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionResources, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, WalkComponentTreeActions, bindParameter, bindParameters, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
587
+ export { BatchEnhancer, BatchEntry, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, CanvasClientOptions, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, WalkComponentTreeActions, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-BJ45Y4JT.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,D as CANVAS_LOOP_PARAMETER,C as CANVAS_LOOP_RESOURCE_PARAMETER,E as CANVAS_LOOP_SLOT,B as CANVAS_LOOP_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,N as bindParameter,O as bindParameters,k as compose,g as createBatchEnhancer,I as createEventBus,h as createLimitPolicy,j as enhance,L as extractLocales,J as getChannelName,b as getComponentPath,F as isSystemComponentDefinition,M as localize,G as mapSlotToPersonalizedVariations,H as mapSlotToTestVariations,i as nullLimitPolicy,K as subscribeToComposition,a as walkComponentTree};
1
+ import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-VQFPUXRX.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,E as createEventBus,h as createLimitPolicy,j as enhance,H as extractLocales,F as getChannelName,b as getComponentPath,B as isSystemComponentDefinition,I as localize,C as mapSlotToPersonalizedVariations,D as mapSlotToTestVariations,i as nullLimitPolicy,G as subscribeToComposition,a as walkComponentTree};
package/dist/index.js CHANGED
@@ -1,11 +1,5 @@
1
- "use strict";var he=Object.create;var b=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var I=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ee=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})},Z=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of de(e))!Ce.call(n,o)&&o!==t&&b(n,o,{get:()=>e[o],enumerable:!(r=fe(e,o))||r.enumerable});return n};var q=(n,e,t)=>(t=n!=null?he(ye(n)):{},Z(e||!n||!n.__esModule?b(t,"default",{value:n,enumerable:!0}):t,n)),Pe=n=>Z(b({},"__esModule",{value:!0}),n);var Q=I((We,W)=>{function h(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.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))}W.exports=h;h.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};h.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};h.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};h.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};h.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};h.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};h.prototype.start=h.prototype.try;h.prototype.errors=function(){return this._errors};h.prototype.attempts=function(){return this._attempts};h.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(n[i]||0)+1;n[i]=s,s>=t&&(e=o,t=s)}return e}});var X=I(A=>{var Ae=Q();A.operation=function(n){var e=A.timeouts(n);return new Ae(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};A.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};A.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};A.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var o=0;o<t.length;o++){var i=t[o],s=n[i];n[i]=function(a){var p=A.operation(e),m=Array.prototype.slice.call(arguments,1),l=m.pop();m.push(function(u){p.retry(u)||(u&&(arguments[0]=p.mainError()),l.apply(this,arguments))}),p.attempt(function(){a.apply(n,m)})}.bind(n,s),n[i].options=e}}});var te=I((Xe,ee)=>{ee.exports=X()});var ze={};Ee(ze,{BatchEntry:()=>w,CANVAS_DRAFT_STATE:()=>ft,CANVAS_ENRICHMENT_TAG_PARAM:()=>Be,CANVAS_INTENT_TAG_PARAM:()=>Le,CANVAS_LOCALE_TAG_PARAM:()=>j,CANVAS_LOCALIZATION_SLOT:()=>U,CANVAS_LOCALIZATION_TYPE:()=>k,CANVAS_LOOP_PARAMETER:()=>H,CANVAS_LOOP_RESOURCE_PARAMETER:()=>z,CANVAS_LOOP_SLOT:()=>J,CANVAS_LOOP_TYPE:()=>G,CANVAS_PERSONALIZATION_PARAM:()=>D,CANVAS_PERSONALIZE_SLOT:()=>Ne,CANVAS_PERSONALIZE_TYPE:()=>Oe,CANVAS_PUBLISHED_STATE:()=>dt,CANVAS_TEST_SLOT:()=>$e,CANVAS_TEST_TYPE:()=>Se,CANVAS_TEST_VARIANT_PARAM:()=>F,CanvasClient:()=>_,CanvasClientError:()=>T,ChildEnhancerBuilder:()=>v,EnhancerBuilder:()=>S,UncachedCanvasClient:()=>V,UniqueBatchEntries:()=>O,bindParameter:()=>Y,bindParameters:()=>pe,compose:()=>Re,createBatchEnhancer:()=>ge,createEventBus:()=>Ue,createLimitPolicy:()=>M,enhance:()=>be,extractLocales:()=>ie,getChannelName:()=>K,getComponentPath:()=>g,isSystemComponentDefinition:()=>Me,localize:()=>Fe,mapSlotToPersonalizedVariations:()=>Ve,mapSlotToTestVariations:()=>ke,nullLimitPolicy:()=>C,subscribeToComposition:()=>De,walkComponentTree:()=>P});module.exports=Pe(ze);function P(n,e){let t=[{ancestorsAndSelf:[{component:n,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=t.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(o.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(p=>{c[p]||delete o.component[p]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:a}=r.ancestorsAndSelf[0],p=r.ancestorsAndSelf[1];if(c&&typeof a!="undefined")p.component.slots[c].splice(a,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let a=Array.isArray(c)?c:[c],{parentSlot:p,parentSlotIndex:m}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(p&&typeof m!="undefined")l.component.slots[p].splice(m+1,0,...a);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let c=Object.keys(s);for(let a=c.length-1;a>=0;a--){let p=c[a],m=s[p];for(let l=m.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:m[l],parentSlot:p,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(t.length>0)}function g(n){let e=[];for(let t=n.length-1;t>=0;t--){let{parentSlot:r,parentSlotIndex:o}=n[t];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var O=class{constructor(e,t){this.groups=e.reduce((r,o)=>{var s;let i=t(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,t){this.groups[e].forEach(r=>r.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var v=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},S=class{constructor(){this._componentIndex={};this._rootBuilder=new v}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new v,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,r)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){t=new Map(t);for(let[o,i]of r.resolveComponentEnhancers())t.set(o,i)}return t}};var w=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 ge({handleBatch:n,shouldQueue:e,limitPolicy:t}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{r.push(new w(c,a,s))})},completeAll:async()=>{if(r.length>0){try{await n(r)}catch(c){r.forEach(a=>a.reject(c))}if(r.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:t}}var L=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function N({limit:n,interval:e,strict:t}){if(!Number.isFinite(n))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let m=Date.now();return m-o>e?(i=1,o=m,0):(i<n?i++:(o+=e,i=1),o-m)}let c=[];function a(){let m=Date.now();if(c.length<n)return c.push(m),0;let l=c.shift()+e;return m>=l?(c.push(m),0):(c.push(l),l-m)}let p=t?a:s;return m=>{let l=function(...u){if(!l.isEnabled)return(async()=>m.apply(this,u))();let d;return new Promise((f,y)=>{d=setTimeout(()=>{f(m.apply(this,u)),r.delete(d)},p()),r.set(d,y)})};return l.abort=()=>{for(let u of r.keys())clearTimeout(u),r.get(u)(new L);r.clear(),c.splice(0,c.length)},l.isEnabled=!0,l}}var re=q(te(),1),Te=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),$=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}},_e=(n,e,t)=>{let r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},ve=n=>Te.has(n),ne=n=>globalThis.DOMException===void 0?new Error(n):new DOMException(n);async function B(n,e){return new Promise((t,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=re.default.operation(e);o.attempt(async i=>{try{t(await n(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof $)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!ve(s.message))o.stop(),r(s);else{_e(s,i,e);try{await e.onFailedAttempt(s)}catch(c){r(c);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?ne("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:ne(i))},{once:!0})})}function M({throttle:n={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=n?N(n):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>B(s,e)}return i()}}var C=async n=>await n();async function be({composition:n,enhancers:e,context:t,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
1
+ "use strict";var Y=Object.create;var A=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var w=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ne=(r,e)=>{for(var t in e)A(r,t,{get:e[t],enumerable:!0})},U=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of X(e))!te.call(r,o)&&o!==t&&A(r,o,{get:()=>e[o],enumerable:!(n=Q(e,o))||n.enumerable});return r};var re=(r,e,t)=>(t=r!=null?Y(ee(r)):{},U(e||!r||!r.__esModule?A(t,"default",{value:r,enumerable:!0}):t,r)),oe=r=>U(A({},"__esModule",{value:!0}),r);var F=w((Ve,j)=>{function u(r,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(r)),this._timeouts=r,this._options=e||{},this._maxRetryTime=e&&e.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))}j.exports=u;u.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};u.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};u.prototype.retry=function(r){if(this._timeout&&clearTimeout(this._timeout),!r)return!1;var e=new Date().getTime();if(r&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(r),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(r);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},t),this._options.unref&&this._timer.unref(),!0};u.prototype.attempt=function(r,e){this._fn=r,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};u.prototype.try=function(r){console.log("Using RetryOperation.try() is deprecated"),this.attempt(r)};u.prototype.start=function(r){console.log("Using RetryOperation.start() is deprecated"),this.attempt(r)};u.prototype.start=u.prototype.try;u.prototype.errors=function(){return this._errors};u.prototype.attempts=function(){return this._attempts};u.prototype.mainError=function(){if(this._errors.length===0)return null;for(var r={},e=null,t=0,n=0;n<this._errors.length;n++){var o=this._errors[n],i=o.message,s=(r[i]||0)+1;r[i]=s,s>=t&&(e=o,t=s)}return e}});var G=w(d=>{var se=F();d.operation=function(r){var e=d.timeouts(r);return new se(e,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})};d.timeouts=function(r){if(r instanceof Array)return[].concat(r);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in r)e[t]=r[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],o=0;o<e.retries;o++)n.push(this.createTimeout(o,e));return r&&r.forever&&!n.length&&n.push(this.createTimeout(o,e)),n.sort(function(i,s){return i-s}),n};d.createTimeout=function(r,e){var t=e.randomize?Math.random()+1:1,n=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,r));return n=Math.min(n,e.maxTimeout),n};d.wrap=function(r,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var n in r)typeof r[n]=="function"&&t.push(n)}for(var o=0;o<t.length;o++){var i=t[o],s=r[i];r[i]=function(c){var m=d.operation(e),p=Array.prototype.slice.call(arguments,1),l=p.pop();p.push(function(h){m.retry(h)||(h&&(arguments[0]=m.mainError()),l.apply(this,arguments))}),m.attempt(function(){c.apply(r,p)})}.bind(r,s),r[i].options=e}}});var H=w((Be,z)=>{z.exports=G()});var Re={};ne(Re,{BatchEntry:()=>v,CANVAS_DRAFT_STATE:()=>Xe,CANVAS_ENRICHMENT_TAG_PARAM:()=>ge,CANVAS_INTENT_TAG_PARAM:()=>Ce,CANVAS_LOCALE_TAG_PARAM:()=>M,CANVAS_LOCALIZATION_SLOT:()=>V,CANVAS_LOCALIZATION_TYPE:()=>k,CANVAS_PERSONALIZATION_PARAM:()=>$,CANVAS_PERSONALIZE_SLOT:()=>Ee,CANVAS_PERSONALIZE_TYPE:()=>de,CANVAS_PUBLISHED_STATE:()=>et,CANVAS_TEST_SLOT:()=>Te,CANVAS_TEST_TYPE:()=>ye,CANVAS_TEST_VARIANT_PARAM:()=>B,CanvasClient:()=>E,CanvasClientError:()=>C,ChildEnhancerBuilder:()=>P,EnhancerBuilder:()=>b,UncachedCanvasClient:()=>L,UniqueBatchEntries:()=>x,compose:()=>he,createBatchEnhancer:()=>ie,createEventBus:()=>we,createLimitPolicy:()=>N,enhance:()=>me,extractLocales:()=>J,getChannelName:()=>D,getComponentPath:()=>_,isSystemComponentDefinition:()=>Pe,localize:()=>be,mapSlotToPersonalizedVariations:()=>Ae,mapSlotToTestVariations:()=>_e,nullLimitPolicy:()=>f,subscribeToComposition:()=>xe,walkComponentTree:()=>g});module.exports=oe(Re);function g(r,e){let t=[{ancestorsAndSelf:[{component:r,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let n=t.pop();if(!n)continue;let o=n.ancestorsAndSelf[0],i=!0;e(o.component,n.ancestorsAndSelf,{replaceComponent:a=>{Object.assign(o.component,a),["parameters","variant","slots","data","_pattern","_patternError"].forEach(m=>{a[m]||delete o.component[m]})},removeComponent:()=>{let{parentSlot:a,parentSlotIndex:c}=n.ancestorsAndSelf[0],m=n.ancestorsAndSelf[1];if(a&&typeof c!="undefined")m.component.slots[a].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:a=>{let c=Array.isArray(a)?a:[a],{parentSlot:m,parentSlotIndex:p}=n.ancestorsAndSelf[0],l=n.ancestorsAndSelf[1];if(m&&typeof p!="undefined")l.component.slots[m].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let a=Object.keys(s);for(let c=a.length-1;c>=0;c--){let m=a[c],p=s[m];for(let l=p.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:p[l],parentSlot:m,parentSlotIndex:l},...n.ancestorsAndSelf]})}}}while(t.length>0)}function _(r){let e=[];for(let t=r.length-1;t>=0;t--){let{parentSlot:n,parentSlotIndex:o}=r[t];n&&o!==void 0&&e.push(`${n}[${o}]`)}return`.${e.join(".")}`}var x=class{constructor(e,t){this.groups=e.reduce((n,o)=>{var s;let i=t(o.args);return n[i]=(s=n[i])!=null?s:[],n[i].push(o),n},{})}resolveKey(e,t){this.groups[e].forEach(n=>n.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(n=>{n.isCompleted||n.resolve(e)})})}};var P=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var n;return(n=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:n.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},b=class{constructor(){this._componentIndex={};this._rootBuilder=new P}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new P,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,n){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,n);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,n)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),n=this._componentIndex[e.type];if(n){t=new Map(t);for(let[o,i]of n.resolveComponentEnhancers())t.set(o,i)}return t}};var v=class{constructor(e,t,n){this._resolve=e;this._reject=t;this.args=n;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 ie({handleBatch:r,shouldQueue:e,limitPolicy:t}){let n=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((a,c)=>{n.push(new v(a,c,s))})},completeAll:async()=>{if(n.length>0){try{await r(n)}catch(a){n.forEach(c=>c.reject(a))}if(n.some(a=>!a.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=n.length;return n=[],s},limitPolicy:t}}var R=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function I({limit:r,interval:e,strict:t}){if(!Number.isFinite(r))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let n=new Map,o=0,i=0;function s(){let p=Date.now();return p-o>e?(i=1,o=p,0):(i<r?i++:(o+=e,i=1),o-p)}let a=[];function c(){let p=Date.now();if(a.length<r)return a.push(p),0;let l=a.shift()+e;return p>=l?(a.push(p),0):(a.push(l),l-p)}let m=t?c:s;return p=>{let l=function(...h){if(!l.isEnabled)return(async()=>p.apply(this,h))();let y;return new Promise((T,W)=>{y=setTimeout(()=>{T(p.apply(this,h)),n.delete(y)},m()),n.set(y,W)})};return l.abort=()=>{for(let h of n.keys())clearTimeout(h),n.get(h)(new R);n.clear(),a.splice(0,a.length)},l.isEnabled=!0,l}}var Z=re(H(),1),ae=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),S=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}},ce=(r,e,t)=>{let n=t.retries-(e-1);return r.attemptNumber=e,r.retriesLeft=n,r},pe=r=>ae.has(r),K=r=>globalThis.DOMException===void 0?new Error(r):new DOMException(r);async function O(r,e){return new Promise((t,n)=>{e={onFailedAttempt(){},retries:10,...e};let o=Z.default.operation(e);o.attempt(async i=>{try{t(await r(i))}catch(s){if(!(s instanceof Error)){n(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof S)o.stop(),n(s.originalError);else if(s instanceof TypeError&&!pe(s.message))o.stop(),n(s);else{ce(s,i,e);try{await e.onFailedAttempt(s)}catch(a){n(a);return}o.retry(s)||n(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?K("The operation was aborted."):e.signal.reason;n(i instanceof Error?i:K(i))},{once:!0})})}function N({throttle:r={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=r?I(r):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>O(s,e)}return i()}}var f=async r=>await r();async function me({composition:r,enhancers:e,context:t,onErrors:n=o=>{throw new Error(o.map(i=>`${i.message}
2
2
  ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
3
 
4
- `))}}){let o=[],i=new Set,s=new Set;P(n,(a,p)=>{var l;Object.entries((l=a.parameters)!=null?l:{}).forEach(([u,d])=>{let f=e.resolveParameterEnhancer(a,u,d);f&&(s.add(f),o.push(xe(a,p,u,d,f,t)))});let m=e.resolveComponentEnhancers(a);o.push(we(a,p,m,t)),i.add(m)}),o.push(...Array.from(i).flatMap(a=>Array.from(a).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:C)(()=>p.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async a=>{var p;try{a.completeAll&&await((p=a.limitPolicy)!=null?p:C)(()=>a.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(o)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);c.length&&r(c)}async function we(n,e,t,r){return t.size&&(n.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let a=await(i.completeAll?C:(s=i.limitPolicy)!=null?s:C)(async()=>i.enhanceOne({component:n,context:r}));a!=null&&(n.data[o]=a)}catch(c){let a=`Component ${g(e)} (type: ${n.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete n.data[o],{message:a,error:c}}}))}async function xe(n,e,t,r,o,i){var s;try{let a=await(o.completeAll?C:(s=o.limitPolicy)!=null?s:C)(async()=>o.enhanceOne({parameter:r,parameterName:t,component:n,context:i}));a===null?delete n.parameters[t]:typeof a=="undefined"?n.parameters[t]={...r,value:r.value}:n.parameters[t]={...r,value:a}}catch(c){let a=`Component ${g(e)} (type: ${n.type}): enhancing parameter ${t} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete n.parameters[t],{message:a,error:c}}}var Re=(n,...e)=>({enhanceOne:r=>{let o="enhanceOne"in n?n.enhanceOne(r):n(r);for(let i of e){let s=Ie(o)?o:Promise.resolve(o),c="enhanceOne"in i?i.enhanceOne:i;o=s.then(a=>c({...r,parameter:{type:r.parameter.type,value:a}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in n?(r=n.completeAll)==null?void 0:r.call(n):0)!=null?o:0}});function Ie(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var T=class extends Error{constructor(t,r,o,i,s,c){super(`${t}
5
- ${i}${s?" "+s:""} (${r} ${o}${c?` Request ID: ${c}`:""})`);this.errorMessage=t;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=c;Object.setPrototypeOf(this,T.prototype)}},_=class{constructor(e){var r,o,i,s,c,a;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(c=e.limitPolicy)!=null?c:M({}),bypassCache:(a=e.bypassCache)!=null?a:!1}}async getCompositionList(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async getCompositionById(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(r)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(r)}async updateComponentDefinition(e){let 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){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...t,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...t==null?void 0:t.headers,...r}});if(!o.ok){let s="";try{let c=await o.text();try{let a=JSON.parse(c);a.errorMessage?s=Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage:s=c}catch(a){s=c}}catch(c){s="General error"}throw new T(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,_.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},V=class extends _{constructor(e){super({...e,bypassCache:!0})}};var Oe="$personalization",Se="$test",k="$localization",Le="intentTag",j="locale",Ne="pz",$e="test",U="localized",ft=0,dt=64,D="$pzCrit",F="$tstVrnt",Be="$enr",G="$loop",z="$loopResource",H="$loopBinding",J="body";var Me=n=>n.startsWith("$");function Ve(n){return n?n.map((e,t)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[D])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:r}}):[]}function ke(n){return n?n.map((e,t)=>{var i,s,c;let r=(s=(i=e.parameters)==null?void 0:i[F])==null?void 0:s.value,o=(c=r==null?void 0:r.id)!=null?c:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var oe="https://js.pusher.com/7.0.3/pusher.min.js";async function je(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((n,e)=>{let t=setTimeout(()=>{window.Pusher&&n(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${oe}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=oe,r.addEventListener("load",()=>{clearTimeout(t),n(window.Pusher)}),document.head.appendChild(r)})}async function Ue(){let n=await je();if(!n)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new n("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=t.subscribe(r);return{unsubscribe:()=>t.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function K(n,e,t){return`${n}.${e}@${t}`}function De({projectId:n,compositionId:e,compositionState:t=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=K(n,e,t),c=r(s),a=c.addEventHandler(i,o);return()=>{a(),c.unsubscribe()}}function ie({component:n}){var r;let e={},t=(r=n.slots)==null?void 0:r[U];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[j];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function Fe({composition:n,locale:e}){P(n,(t,r,o)=>{if(t.type===k){let i=ie({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),c;if(s&&(c=i[s]),c!=null&&c.length){let[a,...p]=c;o.replaceComponent(a),p.length&&o.insertAfter(p)}else o.removeComponent()}})}var x=require("json-pointer");function ae(n,e){if(typeof n.pointer=="string")return se(e,n.pointer);let t={};return Object.entries(n.pointer).forEach(([r,o])=>{(0,x.set)(t,r,se(e,o))}),t}function se(n,e){try{return(0,x.get)(n,e)}catch(t){throw new Error(`Unable to resolve resource pointer '${e}': ${t.message}
6
-
7
- Resources:
8
- ${JSON.stringify(n,null,2)}`)}}function Y(n,e){if(!(n!=null&&n.binding))return{bound:!1};switch(n.binding.syntax){case"jptr":return{bound:!0,value:ae(n.binding,e)};default:throw new Error(`Unsupported binding syntax '${n.binding.syntax}'`)}}var ce=q(require("rfdc"));var Ge=(0,ce.default)();function pe(n,e,t){let{throwErrors:r=!0,expandLoops:o=!0,preserveBindings:i=!1}=t||{},s=Ge(n),c=!1,a=[];if(P(s,(p,m,l)=>{var u,d;if(!!p.parameters&&(Object.entries(p.parameters).forEach(([f,y])=>{try{let E=Y(y,e);E.bound&&(c=!0,y.value=E.value,i||delete y.binding)}catch(E){a.push(new Error(`Failed to bind parameter ${f} in component ${g(m)}: ${E.message}`)),delete p.parameters[f]}}),p.type===G&&(l.stopProcessingDescendants(),o))){let f=(d=(u=p.slots)==null?void 0:u[J])!=null?d:[],y=p.parameters[H].value;if(!Array.isArray(y)){a.push(new Error(`Failed to bind loop component ${g(m)}: loop is not bound to an array of data`));return}let E={...t,throwErrors:!1};y.reverse().forEach(me=>{let le={...e,[p.parameters[z].value]:me};f.forEach(ue=>{let R=pe(ue,le,E);R.errors.length>0?a.push(...R.errors):l.insertAfter(R.result)})}),l.removeComponent()}}),r&&a.length>0)throw new Error(`${a.length} error${a.length!==1?"s":""} occurred while binding parameters to resources.
9
-
10
- ${a.map(p=>p.message).join(`
11
- `)}`);return{hasBindings:c,errors:a,result:s}}0&&(module.exports={BatchEntry,CANVAS_DRAFT_STATE,CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_INTENT_TAG_PARAM,CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE,CANVAS_LOOP_PARAMETER,CANVAS_LOOP_RESOURCE_PARAMETER,CANVAS_LOOP_SLOT,CANVAS_LOOP_TYPE,CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE,CANVAS_TEST_SLOT,CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM,CanvasClient,CanvasClientError,ChildEnhancerBuilder,EnhancerBuilder,UncachedCanvasClient,UniqueBatchEntries,bindParameter,bindParameters,compose,createBatchEnhancer,createEventBus,createLimitPolicy,enhance,extractLocales,getChannelName,getComponentPath,isSystemComponentDefinition,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
4
+ `))}}){let o=[],i=new Set,s=new Set;g(r,(c,m)=>{var l;Object.entries((l=c.parameters)!=null?l:{}).forEach(([h,y])=>{let T=e.resolveParameterEnhancer(c,h,y);T&&(s.add(T),o.push(ue(c,m,h,y,T,t)))});let p=e.resolveComponentEnhancers(c);o.push(le(c,m,p,t)),i.add(p)}),o.push(...Array.from(i).flatMap(c=>Array.from(c).map(async([,m])=>{var p;try{m.completeAll&&await((p=m.limitPolicy)!=null?p:f)(()=>m.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async c=>{var m;try{c.completeAll&&await((m=c.limitPolicy)!=null?m:f)(()=>c.completeAll())}catch(p){return{error:p,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(o)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&n(a)}async function le(r,e,t,n){return t.size&&(r.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let c=await(i.completeAll?f:(s=i.limitPolicy)!=null?s:f)(async()=>i.enhanceOne({component:r,context:n}));c!=null&&(r.data[o]=c)}catch(a){let c=`Component ${_(e)} (type: ${r.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete r.data[o],{message:c,error:a}}}))}async function ue(r,e,t,n,o,i){var s;try{let c=await(o.completeAll?f:(s=o.limitPolicy)!=null?s:f)(async()=>o.enhanceOne({parameter:n,parameterName:t,component:r,context:i}));c===null?delete r.parameters[t]:typeof c=="undefined"?r.parameters[t]={...n,value:n.value}:r.parameters[t]={...n,value:c}}catch(a){let c=`Component ${_(e)} (type: ${r.type}): enhancing parameter ${t} (type: ${n.type}) threw exception. Parameter will be removed.`;return delete r.parameters[t],{message:c,error:a}}}var he=(r,...e)=>({enhanceOne:n=>{let o="enhanceOne"in r?r.enhanceOne(n):r(n);for(let i of e){let s=fe(o)?o:Promise.resolve(o),a="enhanceOne"in i?i.enhanceOne:i;o=s.then(c=>a({...n,parameter:{type:n.parameter.type,value:c}}))}return o},completeAll:async()=>{var n,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in r?(n=r.completeAll)==null?void 0:n.call(r):0)!=null?o:0}});function fe(r){return!!r&&(typeof r=="object"||typeof r=="function")&&typeof r.then=="function"}var C=class extends Error{constructor(t,n,o,i,s,a){super(`${t}
5
+ ${i}${s?" "+s:""} (${n} ${o}${a?` Request ID: ${a}`:""})`);this.errorMessage=t;this.fetchMethod=n;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=a;Object.setPrototypeOf(this,C.prototype)}},E=class{constructor(e){var n,o,i,s,a,c;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(n=e.apiHost)!=null?n:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(a=e.limitPolicy)!=null?a:N({}),bypassCache:(c=e.bypassCache)!=null?c:!1}}async getCompositionList(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async getCompositionBySlug(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async getCompositionById(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:n}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:n}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(n)}async updateComponentDefinition(e){let 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){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let n=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`};this.options.bypassCache&&(n["x-bypass-cache"]="true");let o=await this.options.fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...n}});if(!o.ok){let s="";try{let a=await o.text();try{let c=JSON.parse(a);c.errorMessage?s=Array.isArray(c.errorMessage)?c.errorMessage.join(", "):c.errorMessage:s=a}catch(c){s=a}}catch(a){s="General error"}throw new C(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,E.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let n=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&n.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),n}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},L=class extends E{constructor(e){super({...e,bypassCache:!0})}};var de="$personalization",ye="$test",k="$localization",Ce="intentTag",M="locale",Ee="pz",Te="test",V="localized",Xe=0,et=64,$="$pzCrit",B="$tstVrnt",ge="$enr";var Pe=r=>r.startsWith("$");function Ae(r){return r?r.map((e,t)=>{var i,s;let n=(s=(i=e.parameters)==null?void 0:i[$])==null?void 0:s.value,o=(n==null?void 0:n.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:n}}):[]}function _e(r){return r?r.map((e,t)=>{var i,s,a;let n=(s=(i=e.parameters)==null?void 0:i[B])==null?void 0:s.value,o=(a=n==null?void 0:n.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var q="https://js.pusher.com/7.0.3/pusher.min.js";async function ve(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((r,e)=>{let t=setTimeout(()=>{window.Pusher&&r(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${q}"><\/script> manually.`)},5e3),n=document.createElement("script");n.src=q,n.addEventListener("load",()=>{clearTimeout(t),r(window.Pusher)}),document.head.appendChild(n)})}async function we(){let r=await ve();if(!r)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new r("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:n=>{let o=t.subscribe(n);return{unsubscribe:()=>t.unsubscribe(n),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function D(r,e,t){return`${r}.${e}@${t}`}function xe({projectId:r,compositionId:e,compositionState:t=0,eventBus:{subscribe:n},callback:o,event:i="updated"}){let s=D(r,e,t),a=n(s),c=a.addEventHandler(i,o);return()=>{c(),a.unsubscribe()}}function J({component:r}){var n;let e={},t=(n=r.slots)==null?void 0:n[V];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[M];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function be({composition:r,locale:e}){g(r,(t,n,o)=>{if(t.type===k){let i=J({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),a;if(s&&(a=i[s]),a!=null&&a.length){let[c,...m]=a;o.replaceComponent(c),m.length&&o.insertAfter(m)}else o.removeComponent()}})}0&&(module.exports={BatchEntry,CANVAS_DRAFT_STATE,CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_INTENT_TAG_PARAM,CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE,CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE,CANVAS_TEST_SLOT,CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM,CanvasClient,CanvasClientError,ChildEnhancerBuilder,EnhancerBuilder,UncachedCanvasClient,UniqueBatchEntries,compose,createBatchEnhancer,createEventBus,createLimitPolicy,enhance,extractLocales,getChannelName,getComponentPath,isSystemComponentDefinition,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-BJ45Y4JT.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,D as CANVAS_LOOP_PARAMETER,C as CANVAS_LOOP_RESOURCE_PARAMETER,E as CANVAS_LOOP_SLOT,B as CANVAS_LOOP_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,N as bindParameter,O as bindParameters,k as compose,g as createBatchEnhancer,I as createEventBus,h as createLimitPolicy,j as enhance,L as extractLocales,J as getChannelName,b as getComponentPath,F as isSystemComponentDefinition,M as localize,G as mapSlotToPersonalizedVariations,H as mapSlotToTestVariations,i as nullLimitPolicy,K as subscribeToComposition,a as walkComponentTree};
1
+ import{A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-VQFPUXRX.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,E as createEventBus,h as createLimitPolicy,j as enhance,H as extractLocales,F as getChannelName,b as getComponentPath,B as isSystemComponentDefinition,I as localize,C as mapSlotToPersonalizedVariations,D as mapSlotToTestVariations,i as nullLimitPolicy,G as subscribeToComposition,a as walkComponentTree};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "16.2.1-nuxt.249+6d2287689",
3
+ "version": "16.2.1-nuxt.325+c1c2247c8",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -47,10 +47,9 @@
47
47
  "update-openapi": "tsx ./scripts/update-openapi.cts"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/json-pointer": "^1.0.31",
51
50
  "@types/retry": "0.12.1",
52
51
  "@types/yargs": "17.0.10",
53
- "@uniformdev/cli": "^16.2.1-nuxt.249+6d2287689",
52
+ "@uniformdev/cli": "^16.2.1-nuxt.325+c1c2247c8",
54
53
  "p-limit": "4.0.0",
55
54
  "p-retry": "5.1.1",
56
55
  "p-throttle": "5.0.0",
@@ -58,9 +57,7 @@
58
57
  "yargs": "17.5.1"
59
58
  },
60
59
  "dependencies": {
61
- "@uniformdev/context": "^16.2.1-nuxt.249+6d2287689",
62
- "json-pointer": "^0.6.2",
63
- "rfdc": "^1.3.0"
60
+ "@uniformdev/context": "^16.2.1-nuxt.325+c1c2247c8"
64
61
  },
65
62
  "files": [
66
63
  "/dist"
@@ -68,5 +65,5 @@
68
65
  "publishConfig": {
69
66
  "access": "public"
70
67
  },
71
- "gitHead": "6d2287689097cb256d17483ea3726d4bb87b2fa6"
68
+ "gitHead": "c1c2247c820522de8ca9707a76e5697b0e3df334"
72
69
  }
@@ -1,11 +0,0 @@
1
- var pe=Object.create;var T=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var fe=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Le=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Ne=(t,e)=>()=>(t&&(e=t(t=0)),e);var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$e=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of le(e))!he.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=me(e,o))||r.enumerable});return t};var de=(t,e,n)=>(n=t!=null?pe(ue(t)):{},N(e||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t)),Be=t=>N(T({},"__esModule",{value:!0}),t);var Me=(t,e,n)=>(fe(t,typeof e!="symbol"?e+"":e,n),n),$=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var ye=(t,e,n)=>($(t,e,"read from private field"),n?n.call(t):e.get(t)),Ve=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},Ce=(t,e,n,r)=>($(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),ke=(t,e,n,r)=>({set _(o){Ce(t,e,o,n)},get _(){return ye(t,e,r)}});var k=x((Je,V)=>{function h(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.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))}V.exports=h;h.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};h.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};h.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0};h.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};h.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};h.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};h.prototype.start=h.prototype.try;h.prototype.errors=function(){return this._errors};h.prototype.attempts=function(){return this._attempts};h.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(t[i]||0)+1;t[i]=s,s>=n&&(e=o,n=s)}return e}});var j=x(E=>{var Ee=k();E.operation=function(t){var e=E.timeouts(t);return new Ee(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};E.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return t&&t.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(i,s){return i-s}),r};E.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,r=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return r=Math.min(r,e.maxTimeout),r};E.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var r in t)typeof t[r]=="function"&&n.push(r)}for(var o=0;o<n.length;o++){var i=n[o],s=t[i];t[i]=function(a){var p=E.operation(e),m=Array.prototype.slice.call(arguments,1),l=m.pop();m.push(function(u){p.retry(u)||(u&&(arguments[0]=p.mainError()),l.apply(this,arguments))}),p.attempt(function(){a.apply(t,m)})}.bind(t,s),t[i].options=e}}});var D=x((Ye,U)=>{U.exports=j()});function g(t,e){let n=[{ancestorsAndSelf:[{component:t,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let r=n.pop();if(!r)continue;let o=r.ancestorsAndSelf[0],i=!0;e(o.component,r.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(o.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(p=>{c[p]||delete o.component[p]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:a}=r.ancestorsAndSelf[0],p=r.ancestorsAndSelf[1];if(c&&typeof a!="undefined")p.component.slots[c].splice(a,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let a=Array.isArray(c)?c:[c],{parentSlot:p,parentSlotIndex:m}=r.ancestorsAndSelf[0],l=r.ancestorsAndSelf[1];if(p&&typeof m!="undefined")l.component.slots[p].splice(m+1,0,...a);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let c=Object.keys(s);for(let a=c.length-1;a>=0;a--){let p=c[a],m=s[p];for(let l=m.length-1;l>=0;l--)n.push({ancestorsAndSelf:[{component:m[l],parentSlot:p,parentSlotIndex:l},...r.ancestorsAndSelf]})}}}while(n.length>0)}function A(t){let e=[];for(let n=t.length-1;n>=0;n--){let{parentSlot:r,parentSlotIndex:o}=t[n];r&&o!==void 0&&e.push(`${r}[${o}]`)}return`.${e.join(".")}`}var B=class{constructor(e,n){this.groups=e.reduce((r,o)=>{var s;let i=n(o.args);return r[i]=(s=r[i])!=null?s:[],r[i].push(o),r},{})}resolveKey(e,n){this.groups[e].forEach(r=>r.resolve(n))}resolveRemaining(e){Object.keys(this.groups).forEach(n=>{this.groups[n].forEach(r=>{r.isCompleted||r.resolve(e)})})}};var b=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(n)})),this}parameterType(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,enhancer:this._resolveParameterEnhancer(n)})),this}data(e,n){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,typeof n=="function"?{enhanceOne:n}:n),this}resolveParameterEnhancer(e,n){var r;return(r=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===n.type||!o.type&&!o.name))==null?void 0:r.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},M=class{constructor(){this._componentIndex={};this._rootBuilder=new b}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,n){return this._rootBuilder.parameterName(e,n),this}parameterType(e,n){return this._rootBuilder.parameterType(e,n),this}data(e,n){return this._rootBuilder.data(e,n),this}component(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>{this._componentIndex[o]=this._componentIndex[o]||new b,n(this._componentIndex[o])}),this}resolveParameterEnhancer(e,n,r){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(n,r);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(n,r)}resolveComponentEnhancers(e){let n=this._rootBuilder.resolveComponentEnhancers(),r=this._componentIndex[e.type];if(r){n=new Map(n);for(let[o,i]of r.resolveComponentEnhancers())n.set(o,i)}return n}};var R=class{constructor(e,n,r){this._resolve=e;this._reject=n;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 Ge({handleBatch:t,shouldQueue:e,limitPolicy:n}){let r=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{r.push(new R(c,a,s))})},completeAll:async()=>{if(r.length>0){try{await t(r)}catch(c){r.forEach(a=>a.reject(c))}if(r.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=r.length;return r=[],s},limitPolicy:n}}var I=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function O({limit:t,interval:e,strict:n}){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,i=0;function s(){let m=Date.now();return m-o>e?(i=1,o=m,0):(i<t?i++:(o+=e,i=1),o-m)}let c=[];function a(){let m=Date.now();if(c.length<t)return c.push(m),0;let l=c.shift()+e;return m>=l?(c.push(m),0):(c.push(l),l-m)}let p=n?a:s;return m=>{let l=function(...u){if(!l.isEnabled)return(async()=>m.apply(this,u))();let d;return new Promise((f,y)=>{d=setTimeout(()=>{f(m.apply(this,u)),r.delete(d)},p()),r.set(d,y)})};return l.abort=()=>{for(let u of r.keys())clearTimeout(u),r.get(u)(new I);r.clear(),c.splice(0,c.length)},l.isEnabled=!0,l}}var G=de(D(),1),Pe=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),S=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}},ge=(t,e,n)=>{let r=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=r,t},Ae=t=>Pe.has(t),F=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function L(t,e){return new Promise((n,r)=>{e={onFailedAttempt(){},retries:10,...e};let o=G.default.operation(e);o.attempt(async i=>{try{n(await t(i))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof S)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!Ae(s.message))o.stop(),r(s);else{ge(s,i,e);try{await e.onFailedAttempt(s)}catch(c){r(c);return}o.retry(s)||r(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?F("The operation was aborted."):e.signal.reason;r(i instanceof Error?i:F(i))},{once:!0})})}function z({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?O(t):null;return function(o){let i=async()=>await o();if(n&&(i=n(i)),e){let s=i;i=()=>L(s,e)}return i()}}var P=async t=>await t();async function ot({composition:t,enhancers:e,context:n,onErrors:r=o=>{throw new Error(o.map(i=>`${i.message}
2
- ${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
3
-
4
- `))}}){let o=[],i=new Set,s=new Set;g(t,(a,p)=>{var l;Object.entries((l=a.parameters)!=null?l:{}).forEach(([u,d])=>{let f=e.resolveParameterEnhancer(a,u,d);f&&(s.add(f),o.push(_e(a,p,u,d,f,n)))});let m=e.resolveComponentEnhancers(a);o.push(Te(a,p,m,n)),i.add(m)}),o.push(...Array.from(i).flatMap(a=>Array.from(a).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:P)(()=>p.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async a=>{var p;try{a.completeAll&&await((p=a.limitPolicy)!=null?p:P)(()=>a.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(o)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);c.length&&r(c)}async function Te(t,e,n,r){return n.size&&(t.data={}),await Promise.all(Array.from(n).map(async([o,i])=>{var s;try{let a=await(i.completeAll?P:(s=i.limitPolicy)!=null?s:P)(async()=>i.enhanceOne({component:t,context:r}));a!=null&&(t.data[o]=a)}catch(c){let a=`Component ${A(e)} (type: ${t.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete t.data[o],{message:a,error:c}}}))}async function _e(t,e,n,r,o,i){var s;try{let a=await(o.completeAll?P:(s=o.limitPolicy)!=null?s:P)(async()=>o.enhanceOne({parameter:r,parameterName:n,component:t,context:i}));a===null?delete t.parameters[n]:typeof a=="undefined"?t.parameters[n]={...r,value:r.value}:t.parameters[n]={...r,value:a}}catch(c){let a=`Component ${A(e)} (type: ${t.type}): enhancing parameter ${n} (type: ${r.type}) threw exception. Parameter will be removed.`;return delete t.parameters[n],{message:a,error:c}}}var st=(t,...e)=>({enhanceOne:r=>{let o="enhanceOne"in t?t.enhanceOne(r):t(r);for(let i of e){let s=ve(o)?o:Promise.resolve(o),c="enhanceOne"in i?i.enhanceOne:i;o=s.then(a=>c({...r,parameter:{type:r.parameter.type,value:a}}))}return o},completeAll:async()=>{var r,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in t?(r=t.completeAll)==null?void 0:r.call(t):0)!=null?o:0}});function ve(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var _=class extends Error{constructor(n,r,o,i,s,c){super(`${n}
5
- ${i}${s?" "+s:""} (${r} ${o}${c?` Request ID: ${c}`:""})`);this.errorMessage=n;this.fetchMethod=r;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=c;Object.setPrototypeOf(this,_.prototype)}},v=class{constructor(e){var r,o,i,s,c,a;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let n=e.fetch;if(!n)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")n=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")n=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:n,apiHost:(r=e.apiHost)!=null?r:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(c=e.limitPolicy)!=null?c:z({}),bypassCache:(a=e.bypassCache)!=null?a:!1}}async getCompositionList(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async getCompositionBySlug(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async getCompositionById(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas",{...e,projectId:n});return await this.apiClient(r)}async updateComposition(e){let n=this.createUrl("/api/v1/canvas");await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let n=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:n}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:n});return await this.apiClient(r)}async updateComponentDefinition(e){let n=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let n=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,n){return this.options.limitPolicy(async()=>{var i;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...n,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...n==null?void 0:n.headers,...r}});if(!o.ok){let s="";try{let c=await o.text();try{let a=JSON.parse(c);a.errorMessage?s=Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage:s=c}catch(a){s=c}}catch(c){s="General error"}throw new _(s,(i=n==null?void 0:n.method)!=null?i:"GET",e.toString(),o.status,o.statusText,v.getRequestId(o))}return n!=null&&n.expectNoContent?null:await o.json()})}createUrl(e,n){let r=new URL(`${this.options.apiHost}${e}`);return Object.entries(n!=null?n:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&r.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),r}static getRequestId(e){let n=e.headers.get("apigw-requestid");if(n)return n}},H=class extends v{constructor(e){super({...e,bypassCache:!0})}};var lt="$personalization",ut="$test",J="$localization",ht="intentTag",K="locale",ft="pz",dt="test",Y="localized",yt=0,Ct=64,Z="$pzCrit",q="$tstVrnt",Et="$enr",W="$loop",Q="$loopResource",X="$loopBinding",ee="body";var gt=t=>t.startsWith("$");function _t(t){return t?t.map((e,n)=>{var i,s;let r=(s=(i=e.parameters)==null?void 0:i[Z])==null?void 0:s.value,o=(r==null?void 0:r.name)||`pz-${n}-${e.type}`;return{...e,id:o,pz:r}}):[]}function wt(t){return t?t.map((e,n)=>{var i,s,c;let r=(s=(i=e.parameters)==null?void 0:i[q])==null?void 0:s.value,o=(c=r==null?void 0:r.id)!=null?c:"testId"in e?e.testId:`ab-${n}-${e.type}`;return{...e,id:o}}):[]}var te="https://js.pusher.com/7.0.3/pusher.min.js";async function be(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((t,e)=>{let n=setTimeout(()=>{window.Pusher&&t(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${te}"><\/script> manually.`)},5e3),r=document.createElement("script");r.src=te,r.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(r)})}async function Rt(){let t=await be();if(!t)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let n=new t("7b5f5abd160fea549ffe",{cluster:"mt1"});n.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:r=>{let o=n.subscribe(r);return{unsubscribe:()=>n.unsubscribe(r),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function ne(t,e,n){return`${t}.${e}@${n}`}function Lt({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:r},callback:o,event:i="updated"}){let s=ne(t,e,n),c=r(s),a=c.addEventHandler(i,o);return()=>{a(),c.unsubscribe()}}function we({component:t}){var r;let e={},n=(r=t.slots)==null?void 0:r[Y];return n==null||n.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[K];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function Mt({composition:t,locale:e}){g(t,(n,r,o)=>{if(n.type===J){let i=we({component:n}),s=typeof e=="string"?e:e({component:n,locales:i}),c;if(s&&(c=i[s]),c!=null&&c.length){let[a,...p]=c;o.replaceComponent(a),p.length&&o.insertAfter(p)}else o.removeComponent()}})}import{get as xe,set as Re}from"json-pointer";function oe(t,e){if(typeof t.pointer=="string")return re(e,t.pointer);let n={};return Object.entries(t.pointer).forEach(([r,o])=>{Re(n,r,re(e,o))}),n}function re(t,e){try{return xe(t,e)}catch(n){throw new Error(`Unable to resolve resource pointer '${e}': ${n.message}
6
-
7
- Resources:
8
- ${JSON.stringify(t,null,2)}`)}}function ie(t,e){if(!(t!=null&&t.binding))return{bound:!1};switch(t.binding.syntax){case"jptr":return{bound:!0,value:oe(t.binding,e)};default:throw new Error(`Unsupported binding syntax '${t.binding.syntax}'`)}}import Ie from"rfdc";var Oe=Ie();function Se(t,e,n){let{throwErrors:r=!0,expandLoops:o=!0,preserveBindings:i=!1}=n||{},s=Oe(t),c=!1,a=[];if(g(s,(p,m,l)=>{var u,d;if(!!p.parameters&&(Object.entries(p.parameters).forEach(([f,y])=>{try{let C=ie(y,e);C.bound&&(c=!0,y.value=C.value,i||delete y.binding)}catch(C){a.push(new Error(`Failed to bind parameter ${f} in component ${A(m)}: ${C.message}`)),delete p.parameters[f]}}),p.type===W&&(l.stopProcessingDescendants(),o))){let f=(d=(u=p.slots)==null?void 0:u[ee])!=null?d:[],y=p.parameters[X].value;if(!Array.isArray(y)){a.push(new Error(`Failed to bind loop component ${A(m)}: loop is not bound to an array of data`));return}let C={...n,throwErrors:!1};y.reverse().forEach(se=>{let ae={...e,[p.parameters[Q].value]:se};f.forEach(ce=>{let w=Se(ce,ae,C);w.errors.length>0?a.push(...w.errors):l.insertAfter(w.result)})}),l.removeComponent()}}),r&&a.length>0)throw new Error(`${a.length} error${a.length!==1?"s":""} occurred while binding parameters to resources.
9
-
10
- ${a.map(p=>p.message).join(`
11
- `)}`);return{hasBindings:c,errors:a,result:s}}export{Le as a,Ne as b,x as c,$e as d,de as e,Be as f,Me as g,ye as h,Ve as i,Ce as j,ke as k,g as l,A as m,B as n,b as o,M as p,R as q,Ge as r,z as s,P as t,ot as u,st as v,_ as w,v as x,H as y,lt as z,ut as A,J as B,ht as C,K as D,ft as E,dt as F,Y as G,yt as H,Ct as I,Z as J,q as K,Et as L,W as M,Q as N,X as O,ee as P,gt as Q,_t as R,wt as S,Rt as T,ne as U,Lt as V,we as W,Mt as X,ie as Y,Se as Z};