modern-idoc 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -438,18 +438,21 @@ class Reactivable extends Observable {
438
438
  setPropertyAccessor(accessor) {
439
439
  this._propertyAccessor = accessor;
440
440
  this.getPropertyDeclarations().forEach((declaration, key) => {
441
- if (declaration.internal || declaration.alias && declaration.alias !== key) {
442
- return;
443
- }
444
- let newValue = this.offsetGet(key);
445
- let oldValue = this._properties.get(key);
446
- if (newValue === void 0 && oldValue !== void 0) {
447
- newValue = oldValue;
448
- oldValue = void 0;
441
+ const proxyed = declaration.internal || declaration.alias && declaration.alias !== key;
442
+ const newValue = accessor.getProperty?.(key);
443
+ let oldValue;
444
+ if (proxyed) {
445
+ oldValue = this.offsetGet(key);
446
+ } else {
447
+ oldValue = this._properties.get(key);
449
448
  }
450
- this.offsetSet(key, newValue);
451
- if (!Object.is(newValue, oldValue)) {
452
- this.requestUpdate(key, newValue, oldValue);
449
+ if (newValue !== void 0 && !Object.is(newValue, oldValue)) {
450
+ if (proxyed) {
451
+ this.offsetSet(key, newValue);
452
+ } else {
453
+ this._properties.set(key, newValue);
454
+ this.requestUpdate(key, newValue, oldValue);
455
+ }
453
456
  }
454
457
  });
455
458
  return this;
@@ -1178,7 +1181,7 @@ function normalizeColorFill(fill) {
1178
1181
  if (typeof fill === "string") {
1179
1182
  obj = { color: fill };
1180
1183
  } else {
1181
- obj = fill;
1184
+ obj = { ...fill };
1182
1185
  }
1183
1186
  return {
1184
1187
  color: normalizeColor(obj.color)
@@ -1190,7 +1193,7 @@ function normalizeGradientFill(fill) {
1190
1193
  if (typeof fill === "string") {
1191
1194
  obj = { image: fill };
1192
1195
  } else {
1193
- obj = fill;
1196
+ obj = { ...fill };
1194
1197
  }
1195
1198
  if (obj.image) {
1196
1199
  const { type, ...props } = normalizeGradient(obj.image)[0] ?? {};
@@ -1205,7 +1208,11 @@ function normalizeGradientFill(fill) {
1205
1208
  };
1206
1209
  }
1207
1210
  }
1208
- return obj;
1211
+ return pick(obj, [
1212
+ "linearGradient",
1213
+ "radialGradient",
1214
+ "rotateWithShape"
1215
+ ]);
1209
1216
  }
1210
1217
 
1211
1218
  function normalizeImageFill(fill) {
@@ -1213,9 +1220,17 @@ function normalizeImageFill(fill) {
1213
1220
  if (typeof fill === "string") {
1214
1221
  obj = { image: fill };
1215
1222
  } else {
1216
- obj = fill;
1217
- }
1218
- return obj;
1223
+ obj = { ...fill };
1224
+ }
1225
+ return pick(obj, [
1226
+ "image",
1227
+ "cropRect",
1228
+ "stretchRect",
1229
+ "tile",
1230
+ "dpi",
1231
+ "opacity",
1232
+ "rotateWithShape"
1233
+ ]);
1219
1234
  }
1220
1235
 
1221
1236
  function normalizePresetFill(fill) {
@@ -1223,13 +1238,23 @@ function normalizePresetFill(fill) {
1223
1238
  if (typeof fill === "string") {
1224
1239
  obj = { preset: fill };
1225
1240
  } else {
1226
- obj = fill;
1241
+ obj = { ...fill };
1227
1242
  }
1228
- return {
1229
- preset: obj.preset,
1230
- foregroundColor: isNone(obj.foregroundColor) ? void 0 : normalizeColor(obj.foregroundColor),
1231
- backgroundColor: isNone(obj.backgroundColor) ? void 0 : normalizeColor(obj.backgroundColor)
1232
- };
1243
+ if (isNone(obj.foregroundColor)) {
1244
+ delete obj.foregroundColor;
1245
+ } else {
1246
+ obj.foregroundColor = normalizeColor(obj.foregroundColor);
1247
+ }
1248
+ if (isNone(obj.backgroundColor)) {
1249
+ delete obj.backgroundColor;
1250
+ } else {
1251
+ obj.backgroundColor = normalizeColor(obj.backgroundColor);
1252
+ }
1253
+ return pick(obj, [
1254
+ "preset",
1255
+ "foregroundColor",
1256
+ "backgroundColor"
1257
+ ]);
1233
1258
  }
1234
1259
 
1235
1260
  function isColorFillObject(fill) {
@@ -1354,7 +1379,14 @@ function normalizeOutline(outline) {
1354
1379
  } else {
1355
1380
  return {
1356
1381
  ...normalizeFill(outline),
1357
- ...pick(outline, ["width", "style", "lineCap", "lineJoin", "headEnd", "tailEnd"])
1382
+ ...pick(outline, [
1383
+ "width",
1384
+ "style",
1385
+ "lineCap",
1386
+ "lineJoin",
1387
+ "headEnd",
1388
+ "tailEnd"
1389
+ ])
1358
1390
  };
1359
1391
  }
1360
1392
  }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(o,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(o=typeof globalThis<"u"?globalThis:o||self,G(o.modernIdoc={}))})(this,(function(o){"use strict";function G(t){return typeof t=="string"?{src:t}:t}var _e={grad:.9,turn:360,rad:360/(2*Math.PI)},D=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},y=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},z=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},mt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},vt=function(t){return{r:z(t.r,0,255),g:z(t.g,0,255),b:z(t.b,0,255),a:z(t.a)}},et=function(t){return{r:y(t.r),g:y(t.g),b:y(t.b),a:y(t.a,3)}},we=/^#([0-9a-f]{3,8})$/i,U=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},yt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=Math.max(e,n,r),u=a-Math.min(e,n,r),l=u?a===e?(n-r)/u:a===n?2+(r-e)/u:4+(e-n)/u:0;return{h:60*(l<0?l+6:l),s:a?u/a*100:0,v:a/255*100,a:i}},bt=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var a=Math.floor(e),u=r*(1-n),l=r*(1-(e-a)*n),f=r*(1-(1-e+a)*n),m=a%6;return{r:255*[r,l,u,u,f,r][m],g:255*[f,r,r,l,u,u][m],b:255*[u,u,f,r,r,l][m],a:i}},St=function(t){return{h:mt(t.h),s:z(t.s,0,100),l:z(t.l,0,100),a:z(t.a)}},_t=function(t){return{h:y(t.h),s:y(t.s),l:y(t.l),a:y(t.a,3)}},wt=function(t){return bt((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},T=function(t){return{h:(e=yt(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},Ce=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ze=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ee=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ct={string:[[function(t){var e=we.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?y(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?y(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=ze.exec(t)||Ee.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:vt({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Ce.exec(t)||Pe.exec(t);if(!e)return null;var n,r,i=St({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(_e[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return wt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=i===void 0?1:i;return D(e)&&D(n)&&D(r)?vt({r:Number(e),g:Number(n),b:Number(r),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,a=i===void 0?1:i;if(!D(e)||!D(n)||!D(r))return null;var u=St({h:Number(e),s:Number(n),l:Number(r),a:Number(a)});return wt(u)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,a=i===void 0?1:i;if(!D(e)||!D(n)||!D(r))return null;var u=(function(l){return{h:mt(l.h),s:z(l.s,0,100),v:z(l.v,0,100),a:z(l.a)}})({h:Number(e),s:Number(n),v:Number(r),a:Number(a)});return bt(u)},"hsv"]]},Pt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},Fe=function(t){return typeof t=="string"?Pt(t.trim(),Ct.string):typeof t=="object"&&t!==null?Pt(t,Ct.object):[null,void 0]},nt=function(t,e){var n=T(t);return{h:n.h,s:z(n.s+100*e,0,100),l:n.l,a:n.a}},rt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},zt=function(t,e){var n=T(t);return{h:n.h,s:n.s,l:z(n.l+100*e,0,100),a:n.a}},Et=(function(){function t(e){this.parsed=Fe(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return y(rt(this.rgba),2)},t.prototype.isDark=function(){return rt(this.rgba)<.5},t.prototype.isLight=function(){return rt(this.rgba)>=.5},t.prototype.toHex=function(){return e=et(this.rgba),n=e.r,r=e.g,i=e.b,u=(a=e.a)<1?U(y(255*a)):"","#"+U(n)+U(r)+U(i)+u;var e,n,r,i,a,u},t.prototype.toRgb=function(){return et(this.rgba)},t.prototype.toRgbString=function(){return e=et(this.rgba),n=e.r,r=e.g,i=e.b,(a=e.a)<1?"rgba("+n+", "+r+", "+i+", "+a+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,a},t.prototype.toHsl=function(){return _t(T(this.rgba))},t.prototype.toHslString=function(){return e=_t(T(this.rgba)),n=e.h,r=e.s,i=e.l,(a=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+a+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,a},t.prototype.toHsv=function(){return e=yt(this.rgba),{h:y(e.h),s:y(e.s),v:y(e.v),a:y(e.a,3)};var e},t.prototype.invert=function(){return L({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),L(nt(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),L(nt(this.rgba,-e))},t.prototype.grayscale=function(){return L(nt(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),L(zt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),L(zt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?L({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):y(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=T(this.rgba);return typeof e=="number"?L({h:e,s:n.s,l:n.l,a:n.a}):y(n.h)},t.prototype.isEqual=function(e){return this.toHex()===L(e).toHex()},t})(),L=function(t){return t instanceof Et?t:new Et(t)};class Oe{eventListeners=new Map;addEventListener(e,n,r){const i={value:n,options:r},a=this.eventListeners.get(e);return a?Array.isArray(a)?a.push(i):this.eventListeners.set(e,[a,i]):this.eventListeners.set(e,i),this}removeEventListener(e,n,r){if(!n)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let u=0,l=i.length;u<l;u++){const f=i[u];(f.value!==n||typeof r=="object"&&r?.once&&(typeof f.options=="boolean"||!f.options?.once))&&a.push(f)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===n&&(typeof r=="boolean"||!r?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,...n){const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let i=r.length,a=0;a<i;a++){const u=r[a];typeof u.options=="object"&&u.options?.once&&this.off(e,u.value,u.options),u.value.apply(this,n)}else typeof r.options=="object"&&r.options?.once&&this.off(e,r.value,r.options),r.value.apply(this,n);return!0}else return!1}on(e,n,r){return this.addEventListener(e,n,r)}once(e,n){return this.addEventListener(e,n,{once:!0})}off(e,n,r){return this.removeEventListener(e,n,r)}emit(e,...n){this.dispatchEvent(e,...n)}}function h(t){return t==null||t==="none"}function N(t,e=0,n=10**e){return Math.round(n*t)/n+0}function _(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>_(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=_(i,e):n[r]=i)}return n}function K(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function q(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}return!1}function Ft(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function Ot(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function Lt(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ft(t,e.split("."),n))}function Dt(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ot(t,e.split("."),n)}class Nt{_observers=new Map;on(e,n){let r=this._observers.get(e);return r===void 0&&this._observers.set(e,r=new Set),r.add(n),this}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};return this.on(e,r),this}off(e,n){const r=this._observers.get(e);return r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e)),this}emit(e,...n){return Array.from((this._observers.get(e)||new Map).values()).forEach(r=>r(...n)),this}destroy(){this._observers=new Map}}class Le{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}const x=Symbol("internal"),it=Symbol("properties"),At=Symbol("inited");function V(t){let e;if(Object.hasOwn(t,it))e=t[it];else{const n=Object.getPrototypeOf(t);e=new Map(n?V(n):void 0),t[it]=e}return e}function ot(t,e){Object.hasOwn(t,x)||(t[x]=new Map);let n=t[x].get(e);return n||(n=Symbol(e),t[x].set(e,n)),n}function at(t,e={}){const{default:n,fallback:r,alias:i,internal:a}=e,u=()=>typeof n=="function"?n():n,l=()=>typeof r=="function"?r():r;function f(){let g;if(i&&i!==t?g=Lt(this,i):!a&&typeof this.getProperty<"u"?g=this.getProperty(t):g=this[ot(this,t)],g=g??l(),g===void 0&&n!==void 0&&!this[At]){this[At]=!0;const p=u();p!==void 0&&(m.call(this,p),g=p)}return g}function m(g){const p=f.call(this);i&&i!==t?Dt(this,i,g):!a&&typeof this.setProperty<"u"?this.setProperty(t,g):this[ot(this,t)]=g,this.onUpdateProperty?.(t,g,p)}return{get:f,set:m}}function Rt(t,e,n={}){V(t).set(e,n);const r=at(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){r.set.call(this,i)},configurable:!0,enumerable:!0})}function De(t){return function(e,n){if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Rt(e.constructor,n,t)}}function Ne(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=at(r,t);return{init(a){return V(this.constructor).set(r,t),i.set.call(this,a),a},get(){return i.get.call(this)},set(a){i.set.call(this,a)}}}}class Ae extends Nt{_propertyAccessor;_properties=new Map;_updatedProperties=new Map;_changedProperties=new Set;_updatingPromise=Promise.resolve();_updating=!1;constructor(e){super(),this.setProperties(e)}isDirty(e){return e?this._updatedProperties.has(e):this._updatedProperties.size>0}offsetGet(e){return this[e]}offsetSet(e,n){this[e]=n}getProperty(e,n){return this._propertyAccessor?.getProperty?this._propertyAccessor.getProperty(e,n):this._properties.get(e)??n}setProperty(e,n){this._propertyAccessor?.setProperty?.(e,n),this._properties.set(e,n)}getProperties(e){const n={};for(const[r,i]of this.getPropertyDeclarations())!i.internal&&!i.alias&&(!e||e.includes(r))&&(n[r]=this.getProperty(r));return n}setProperties(e){if(e&&typeof e=="object")for(const[n]of this.getPropertyDeclarations())n in e&&this.offsetSet(n,e[n]);return this}resetProperties(){for(const[e,n]of this.getPropertyDeclarations())this.offsetSet(e,typeof n.default=="function"?n.default():n.default);return this}getPropertyDeclarations(){return V(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}setPropertyAccessor(e){return this._propertyAccessor=e,this.getPropertyDeclarations().forEach((n,r)=>{if(n.internal||n.alias&&n.alias!==r)return;let i=this.offsetGet(r),a=this._properties.get(r);i===void 0&&a!==void 0&&(i=a,a=void 0),this.offsetSet(r,i),Object.is(i,a)||this.requestUpdate(r,i,a)}),this}async _nextTick(){return"requestAnimationFrame"in globalThis?new Promise(e=>globalThis.requestAnimationFrame(e)):Promise.resolve()}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await this._nextTick(),this._updating&&(this.onUpdate(),this._updating=!1)}onUpdate(){this._update(this._updatedProperties),this._updatedProperties=new Map}onUpdateProperty(e,n,r){Object.is(n,r)||this.requestUpdate(e,n,r)}requestUpdate(e,n,r){e!==void 0&&(this._updatedProperties.set(e,r),this._changedProperties.add(e),this._updateProperty(e,n,r),this.emit("updateProperty",e,n,r)),this._updating||(this._updatingPromise=this._enqueueUpdate())}_update(e){}_updateProperty(e,n,r){}toJSON(){const e={};return this._properties.forEach((n,r)=>{n!==void 0&&(n&&typeof n=="object"?"toJSON"in n&&typeof n.toJSON=="function"?e[r]=n.toJSON():Array.isArray(n)?e[r]=[...n]:e[r]={...n}:e[r]=n)}),e}clone(){return new this.constructor(this.toJSON())}}function st(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,L(e)}function Re(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function J(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const k="#000000FF";function It(t){return st(t).isValid()}function S(t,e=!1){const n=st(t);if(!n.isValid()){if(typeof t=="string")return t;const l=`Failed to normalizeColor ${t}`;if(e)throw new Error(l);return console.warn(l),k}const{r,g:i,b:a,a:u}=Re(n.rgba);return`#${J(r)}${J(i)}${J(a)}${J(N(u*255))}`}var X=X||{};X.parse=(function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function n(s){const c=new Error(`${e}: ${s}`);throw c.source=e,c}function r(){const s=i();return e.length>0&&n("Invalid input not EOF"),s}function i(){return M(a)}function a(){return u("linear-gradient",t.linearGradient,f)||u("repeating-linear-gradient",t.repeatingLinearGradient,f)||u("radial-gradient",t.radialGradient,p)||u("repeating-radial-gradient",t.repeatingRadialGradient,p)}function u(s,c,d){return l(c,b=>{const I=d();return I&&(v(t.comma)||n("Missing comma before color stops")),{type:s,orientation:I,colorStops:M(ht)}})}function l(s,c){const d=v(s);if(d){v(t.startCall)||n("Missing (");const b=c(d);return v(t.endCall)||n("Missing )"),b}}function f(){const s=m();if(s)return s;const c=P("position-keyword",t.positionKeywords,1);return c?{type:"directional",value:c.value}:g()}function m(){return P("directional",t.sideOrCorner,1)}function g(){return P("angular",t.angleValue,1)||P("angular",t.radianValue,1)}function p(){let s,c=w(),d;return c&&(s=[],s.push(c),d=e,v(t.comma)&&(c=w(),c?s.push(c):e=d)),s}function w(){let s=C()||A();if(s)s.at=O();else{const c=E();if(c){s=c;const d=O();d&&(s.at=d)}else{const d=O();if(d)s={type:"default-radial",at:d};else{const b=R();b&&(s={type:"default-radial",at:b})}}}return s}function C(){const s=P("shape",/^(circle)/i,0);return s&&(s.style=Se()||E()),s}function A(){const s=P("shape",/^(ellipse)/i,0);return s&&(s.style=R()||tt()||E()),s}function E(){return P("extent-keyword",t.extentKeywords,1)}function O(){if(P("position",/^at/,0)){const s=R();return s||n("Missing positioning value"),s}}function R(){const s=W();if(s.x||s.y)return{type:"position",value:s}}function W(){return{x:tt(),y:tt()}}function M(s){let c=s();const d=[];if(c)for(d.push(c);v(t.comma);)c=s(),c?d.push(c):n("One extra comma");return d}function ht(){const s=Ke();return s||n("Expected color definition"),s.length=tt(),s}function Ke(){return xe()||Qe()||Ze()||Xe()||Je()||Ye()||qe()}function qe(){return P("literal",t.literalColor,0)}function xe(){return P("hex",t.hexColor,1)}function Je(){return l(t.rgbColor,()=>({type:"rgb",value:M(B)}))}function Xe(){return l(t.rgbaColor,()=>({type:"rgba",value:M(B)}))}function Ye(){return l(t.varColor,()=>({type:"var",value:tn()}))}function Ze(){return l(t.hslColor,()=>{v(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const c=B();v(t.comma);let d=v(t.percentageValue);const b=d?d[1]:null;v(t.comma),d=v(t.percentageValue);const I=d?d[1]:null;return(!b||!I)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[c,b,I]}})}function Qe(){return l(t.hslaColor,()=>{const s=B();v(t.comma);let c=v(t.percentageValue);const d=c?c[1]:null;v(t.comma),c=v(t.percentageValue);const b=c?c[1]:null;v(t.comma);const I=B();return(!d||!b)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[s,d,b,I]}})}function tn(){return v(t.variableName)[1]}function B(){return v(t.number)[1]}function tt(){return P("%",t.percentageValue,1)||en()||nn()||Se()}function en(){return P("position-keyword",t.positionKeywords,1)}function nn(){return l(t.calcValue,()=>{let s=1,c=0;for(;s>0&&c<e.length;){const b=e.charAt(c);b==="("?s++:b===")"&&s--,c++}s>0&&n("Missing closing parenthesis in calc() expression");const d=e.substring(0,c-1);return pt(c-1),{type:"calc",value:d}})}function Se(){return P("px",t.pixelValue,1)||P("em",t.emValue,1)}function P(s,c,d){const b=v(c);if(b)return{type:s,value:b[d]}}function v(s){let c,d;return d=/^\s+/.exec(e),d&&pt(d[0].length),c=s.exec(e),c&&pt(c[0].length),c}function pt(s){e=e.substr(s)}return function(s){return e=s.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}})();const Gt=X.parse.bind(X);var Y=Y||{};Y.stringify=(function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,a){n+=t.visit(i),a<r-1&&(n+=", ")}),n},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}})();const Ie=Y.stringify.bind(Y);function jt(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let a=N(r/e,3),u="#00000000";switch(n.type){case"rgb":u=S({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":u=S({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":u=S(n.value);break;case"hex":u=S(`#${n.value}`);break}switch(n.length?.type){case"%":a=Number(n.length.value)/100;break}return{offset:a,color:u}})}function Mt(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:jt(t.colorStops)}}function Tt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:jt(t.colorStops)}}function $(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Vt(t){return Gt(t).map(e=>{switch(e?.type){case"linear-gradient":return Mt(e);case"repeating-linear-gradient":return{...Mt(e),repeat:!0};case"radial-gradient":return Tt(e);case"repeating-radial-gradient":return{...Tt(e),repeat:!0};default:return}}).filter(Boolean)}function kt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:S(e.color)}}function $t(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Vt(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Ht(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Wt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:h(e.foregroundColor)?void 0:S(e.foregroundColor),backgroundColor:h(e.backgroundColor)?void 0:S(e.backgroundColor)}}function Bt(t){return!h(t.color)}function Ut(t){return typeof t=="string"?It(t):Bt(t)}function Kt(t){return!h(t.image)&&$(t.image)||!!t.linearGradient||!!t.radialGradient}function qt(t){return typeof t=="string"?$(t):Kt(t)}function xt(t){return!h(t.image)&&!$(t.image)}function Jt(t){return typeof t=="string"?!$(t):xt(t)}function Xt(t){return!h(t.preset)}function Yt(t){return typeof t=="string"?!1:Xt(t)}function F(t){const e=t&&typeof t=="object"?t.enabled:void 0;return Ut(t)?_({enabled:e,...kt(t)}):qt(t)?_({enabled:e,...$t(t)}):Jt(t)?_({enabled:e,...Ht(t)}):Yt(t)?_({enabled:e,...Wt(t)}):{}}function Zt(t){return typeof t=="string"?{...F(t)}:{...F(t),...K(t,["fillWithShape"])}}function ut(){return{color:k,offsetX:0,offsetY:0,blurRadius:1}}function lt(t){return{...ut(),..._({...t,color:h(t.color)?k:S(t.color)})}}function Qt(){return{...ut(),scaleX:1,scaleY:1}}function te(t){return{...Qt(),...lt(t)}}function Ge(t){return t}function ee(t){return _({...t,softEdge:h(t.softEdge)?void 0:t.softEdge,outerShadow:h(t.outerShadow)?void 0:te(t.outerShadow),innerShadow:h(t.innerShadow)?void 0:lt(t.innerShadow)})}function ne(t){return typeof t=="string"?{...F(t)}:{...F(t),...K(t,["fillWithShape"])}}const je="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Me=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=je[n[t]&63];return e};const re=()=>Me(10),ie=re;function H(t){return typeof t=="string"?{...F(t)}:{...F(t),...K(t,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function oe(t){return typeof t=="string"?{color:S(t)}:{...t,color:h(t.color)?k:S(t.color)}}function ae(){return{boxShadow:"none"}}function se(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function ue(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function le(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ce(){return{...ue(),...le(),...ae(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function fe(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function de(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ge(){return{...fe(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function he(){return{...de(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function pe(){return{...he(),...ge(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function j(t){return _({...t,color:h(t.color)?void 0:S(t.color),backgroundColor:h(t.backgroundColor)?void 0:S(t.backgroundColor),borderColor:h(t.borderColor)?void 0:S(t.borderColor),outlineColor:h(t.outlineColor)?void 0:S(t.outlineColor),shadowColor:h(t.shadowColor)?void 0:S(t.shadowColor)})}function Te(){return{...ce(),...pe()}}const ct=/\r\n|\n\r|\n|\r/,Ve=new RegExp(`${ct.source}|<br\\/>`,"g"),ke=new RegExp(`^(${ct.source})$`),ft=`
2
- `;function $e(t){return ct.test(t)}function dt(t){return ke.test(t)}function me(t){return t.replace(Ve,ft)}function Z(t){const e=[];function n(){return e[e.length-1]}function r(l,f,m){const g=l?j(l):{},p=f?F(f):void 0,w=m?H(m):void 0,C=_({...g,fill:p,outline:w,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=C:e.push(C),C}function i(l="",f,m,g){const p=f?j(f):{},w=m?F(m):void 0,C=g?H(g):void 0;Array.from(l).forEach(A=>{if(dt(A)){const{fragments:E,fill:O,outline:R,...W}=n()||r();E.length||E.push(_({...p,fill:w,outline:C,content:ft})),r(W,O,R)}else{const E=n()||r(),O=E.fragments[E.fragments.length-1];if(O){const{content:R,fill:W,outline:M,...ht}=O;if(q(w,W)&&q(C,M)&&q(p,ht)){O.content=`${R}${A}`;return}}E.fragments.push(_({...p,fill:w,outline:C,content:A}))}})}(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l=="string")r(),i(l);else if(gt(l)){const{content:f,fill:m,outline:g,...p}=l;r(p,m,g),i(f)}else if(ve(l)){const{fragments:f,fill:m,outline:g,...p}=l;r(p,m,g),f.forEach(w=>{const{content:C,fill:A,outline:E,...O}=w;i(C,O,A,E)})}else Array.isArray(l)?(r(),l.forEach(f=>{if(typeof f=="string")i(f);else if(gt(f)){const{content:m,fill:g,outline:p,...w}=f;i(m,w,g,p)}})):console.warn("Failed to parse text content",l)});const u=n();return u&&!u.fragments.length&&u.fragments.push({content:""}),e}function ve(t){return t&&typeof t=="object"&&"fragments"in t&&Array.isArray(t.fragments)}function gt(t){return t&&typeof t=="object"&&"content"in t&&typeof t.content=="string"}function ye(t){return typeof t=="string"||Array.isArray(t)?{content:Z(t)}:_({...t,content:Z(t.content??""),style:t.style?j(t.style):void 0,effects:t.effects?t.effects.map(e=>j(e)):void 0,measureDom:t.measureDom,fonts:t.fonts,fill:t.fill?F(t.fill):void 0,outline:t.outline?H(t.outline):void 0})}function He(t){return Z(t).map(e=>{const n=me(e.fragments.flatMap(r=>r.content).join(""));return dt(n)?"":n}).join(ft)}function be(t){return typeof t=="string"?{src:t}:t}function Q(t){return _({...t,id:t.id??ie(),style:h(t.style)?void 0:j(t.style),text:h(t.text)?void 0:ye(t.text),background:h(t.background)?void 0:Zt(t.background),shape:h(t.shape)?void 0:se(t.shape),fill:h(t.fill)?void 0:F(t.fill),outline:h(t.outline)?void 0:H(t.outline),foreground:h(t.foreground)?void 0:ne(t.foreground),shadow:h(t.shadow)?void 0:oe(t.shadow),video:h(t.video)?void 0:be(t.video),audio:h(t.audio)?void 0:G(t.audio),effect:h(t.effect)?void 0:ee(t.effect),children:t.children?.map(e=>Q(e))})}function We(t){return Q(t)}function Be(t){const e={};for(const n in t.children){const r=Q(t.children[n]);delete r.children,e[n]=r}return{...t,children:e}}function Ue(t){const{children:e,...n}=t;function r(f){const{parentId:m,childrenIds:g,...p}=f;return{...p,children:[]}}const i={},a=[],u={...n,children:a};function l(f){if(!e[f]||i[f])return;const m=e[f],g=r(m);i[f]=g;const p=m.parentId;if(p){l(p);const w=e[p],C=i[p];if(!C)return;w?.childrenIds&&C?.children&&(C.children[w.childrenIds.indexOf(f)]=g)}else a.push(g)}for(const f in e)l(f);return u}o.EventEmitter=Oe,o.Observable=Nt,o.RawWeakMap=Le,o.Reactivable=Ae,o.clearUndef=_,o.defaultColor=k,o.defineProperty=Rt,o.flatDocumentToDocument=Ue,o.getDeclarations=V,o.getDefaultElementStyle=ce,o.getDefaultHighlightStyle=fe,o.getDefaultInnerShadow=ut,o.getDefaultLayoutStyle=ue,o.getDefaultListStyleStyle=de,o.getDefaultOuterShadow=Qt,o.getDefaultShadowStyle=ae,o.getDefaultStyle=Te,o.getDefaultTextInlineStyle=ge,o.getDefaultTextLineStyle=he,o.getDefaultTextStyle=pe,o.getDefaultTransformStyle=le,o.getNestedValue=Ft,o.getObjectValueByPath=Lt,o.getPropertyDescriptor=at,o.getPropertyInternalKey=ot,o.hasCRLF=$e,o.idGenerator=ie,o.isCRLF=dt,o.isColor=It,o.isColorFill=Ut,o.isColorFillObject=Bt,o.isEqualObject=q,o.isFragmentObject=gt,o.isGradient=$,o.isGradientFill=qt,o.isGradientFillObject=Kt,o.isImageFill=Jt,o.isImageFillObject=xt,o.isNone=h,o.isParagraphObject=ve,o.isPresetFill=Yt,o.isPresetFillObject=Xt,o.nanoid=re,o.normalizeAudio=G,o.normalizeBackground=Zt,o.normalizeCRLF=me,o.normalizeColor=S,o.normalizeColorFill=kt,o.normalizeDocument=We,o.normalizeEffect=ee,o.normalizeElement=Q,o.normalizeFill=F,o.normalizeFlatDocument=Be,o.normalizeForeground=ne,o.normalizeGradient=Vt,o.normalizeGradientFill=$t,o.normalizeImageFill=Ht,o.normalizeInnerShadow=lt,o.normalizeOuterShadow=te,o.normalizeOutline=H,o.normalizePresetFill=Wt,o.normalizeShadow=oe,o.normalizeShape=se,o.normalizeSoftEdge=Ge,o.normalizeStyle=j,o.normalizeText=ye,o.normalizeTextContent=Z,o.normalizeVideo=be,o.parseColor=st,o.parseGradient=Gt,o.pick=K,o.property=De,o.property2=Ne,o.round=N,o.setNestedValue=Ot,o.setObjectValueByPath=Dt,o.stringifyGradient=Ie,o.textContentToString=He,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(o=typeof globalThis<"u"?globalThis:o||self,j(o.modernIdoc={}))})(this,(function(o){"use strict";function j(t){return typeof t=="string"?{src:t}:t}var _e={grad:.9,turn:360,rad:360/(2*Math.PI)},D=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},y=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=Math.pow(10,e)),Math.round(r*t)/r+0},z=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=1),t>r?r:t>e?t:e},mt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},vt=function(t){return{r:z(t.r,0,255),g:z(t.g,0,255),b:z(t.b,0,255),a:z(t.a)}},et=function(t){return{r:y(t.r),g:y(t.g),b:y(t.b),a:y(t.a,3)}},we=/^#([0-9a-f]{3,8})$/i,K=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},yt=function(t){var e=t.r,r=t.g,n=t.b,i=t.a,a=Math.max(e,r,n),u=a-Math.min(e,r,n),l=u?a===e?(r-n)/u:a===r?2+(n-e)/u:4+(e-r)/u:0;return{h:60*(l<0?l+6:l),s:a?u/a*100:0,v:a/255*100,a:i}},bt=function(t){var e=t.h,r=t.s,n=t.v,i=t.a;e=e/360*6,r/=100,n/=100;var a=Math.floor(e),u=n*(1-r),l=n*(1-(e-a)*r),f=n*(1-(1-e+a)*r),m=a%6;return{r:255*[n,l,u,u,f,n][m],g:255*[f,n,n,l,u,u][m],b:255*[u,u,f,n,n,l][m],a:i}},St=function(t){return{h:mt(t.h),s:z(t.s,0,100),l:z(t.l,0,100),a:z(t.a)}},_t=function(t){return{h:y(t.h),s:y(t.s),l:y(t.l),a:y(t.a,3)}},wt=function(t){return bt((r=(e=t).s,{h:e.h,s:(r*=((n=e.l)<50?n:100-n)/100)>0?2*r/(n+r)*100:0,v:n+r,a:e.a}));var e,r,n},V=function(t){return{h:(e=yt(t)).h,s:(i=(200-(r=e.s))*(n=e.v)/100)>0&&i<200?r*n/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,r,n,i},Ce=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ze=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ee=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ct={string:[[function(t){var e=we.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?y(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?y(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=ze.exec(t)||Ee.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:vt({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Ce.exec(t)||Pe.exec(t);if(!e)return null;var r,n,i=St({h:(r=e[1],n=e[2],n===void 0&&(n="deg"),Number(r)*(_e[n]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return wt(i)},"hsl"]],object:[[function(t){var e=t.r,r=t.g,n=t.b,i=t.a,a=i===void 0?1:i;return D(e)&&D(r)&&D(n)?vt({r:Number(e),g:Number(r),b:Number(n),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,r=t.s,n=t.l,i=t.a,a=i===void 0?1:i;if(!D(e)||!D(r)||!D(n))return null;var u=St({h:Number(e),s:Number(r),l:Number(n),a:Number(a)});return wt(u)},"hsl"],[function(t){var e=t.h,r=t.s,n=t.v,i=t.a,a=i===void 0?1:i;if(!D(e)||!D(r)||!D(n))return null;var u=(function(l){return{h:mt(l.h),s:z(l.s,0,100),v:z(l.v,0,100),a:z(l.a)}})({h:Number(e),s:Number(r),v:Number(n),a:Number(a)});return bt(u)},"hsv"]]},Pt=function(t,e){for(var r=0;r<e.length;r++){var n=e[r][0](t);if(n)return[n,e[r][1]]}return[null,void 0]},Fe=function(t){return typeof t=="string"?Pt(t.trim(),Ct.string):typeof t=="object"&&t!==null?Pt(t,Ct.object):[null,void 0]},rt=function(t,e){var r=V(t);return{h:r.h,s:z(r.s+100*e,0,100),l:r.l,a:r.a}},nt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},zt=function(t,e){var r=V(t);return{h:r.h,s:r.s,l:z(r.l+100*e,0,100),a:r.a}},Et=(function(){function t(e){this.parsed=Fe(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return y(nt(this.rgba),2)},t.prototype.isDark=function(){return nt(this.rgba)<.5},t.prototype.isLight=function(){return nt(this.rgba)>=.5},t.prototype.toHex=function(){return e=et(this.rgba),r=e.r,n=e.g,i=e.b,u=(a=e.a)<1?K(y(255*a)):"","#"+K(r)+K(n)+K(i)+u;var e,r,n,i,a,u},t.prototype.toRgb=function(){return et(this.rgba)},t.prototype.toRgbString=function(){return e=et(this.rgba),r=e.r,n=e.g,i=e.b,(a=e.a)<1?"rgba("+r+", "+n+", "+i+", "+a+")":"rgb("+r+", "+n+", "+i+")";var e,r,n,i,a},t.prototype.toHsl=function(){return _t(V(this.rgba))},t.prototype.toHslString=function(){return e=_t(V(this.rgba)),r=e.h,n=e.s,i=e.l,(a=e.a)<1?"hsla("+r+", "+n+"%, "+i+"%, "+a+")":"hsl("+r+", "+n+"%, "+i+"%)";var e,r,n,i,a},t.prototype.toHsv=function(){return e=yt(this.rgba),{h:y(e.h),s:y(e.s),v:y(e.v),a:y(e.a,3)};var e},t.prototype.invert=function(){return L({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),L(rt(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),L(rt(this.rgba,-e))},t.prototype.grayscale=function(){return L(rt(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),L(zt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),L(zt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?L({r:(r=this.rgba).r,g:r.g,b:r.b,a:e}):y(this.rgba.a,3);var r},t.prototype.hue=function(e){var r=V(this.rgba);return typeof e=="number"?L({h:e,s:r.s,l:r.l,a:r.a}):y(r.h)},t.prototype.isEqual=function(e){return this.toHex()===L(e).toHex()},t})(),L=function(t){return t instanceof Et?t:new Et(t)};class Oe{eventListeners=new Map;addEventListener(e,r,n){const i={value:r,options:n},a=this.eventListeners.get(e);return a?Array.isArray(a)?a.push(i):this.eventListeners.set(e,[a,i]):this.eventListeners.set(e,i),this}removeEventListener(e,r,n){if(!r)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let u=0,l=i.length;u<l;u++){const f=i[u];(f.value!==r||typeof n=="object"&&n?.once&&(typeof f.options=="boolean"||!f.options?.once))&&a.push(f)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===r&&(typeof n=="boolean"||!n?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,...r){const n=this.eventListeners.get(e);if(n){if(Array.isArray(n))for(let i=n.length,a=0;a<i;a++){const u=n[a];typeof u.options=="object"&&u.options?.once&&this.off(e,u.value,u.options),u.value.apply(this,r)}else typeof n.options=="object"&&n.options?.once&&this.off(e,n.value,n.options),n.value.apply(this,r);return!0}else return!1}on(e,r,n){return this.addEventListener(e,r,n)}once(e,r){return this.addEventListener(e,r,{once:!0})}off(e,r,n){return this.removeEventListener(e,r,n)}emit(e,...r){this.dispatchEvent(e,...r)}}function h(t){return t==null||t==="none"}function N(t,e=0,r=10**e){return Math.round(r*t)/r+0}function _(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(n=>_(n,e)):t;const r={};for(const n in t){const i=t[n];i!=null&&(e?r[n]=_(i,e):r[n]=i)}return r}function A(t,e){const r={};return e.forEach(n=>{n in t&&(r[n]=t[n])}),r}function q(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){const r=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!r.length||r.every(n=>t[n]===e[n])}return!1}function Ft(t,e,r){const n=e.length-1;if(n<0)return t===void 0?r:t;for(let i=0;i<n;i++){if(t==null)return r;t=t[e[i]]}return t==null||t[e[n]]===void 0?r:t[e[n]]}function Ot(t,e,r){const n=e.length-1;for(let i=0;i<n;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[n]]=r}function Lt(t,e,r){return t==null||!e||typeof e!="string"?r:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ft(t,e.split("."),r))}function Dt(t,e,r){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Ot(t,e.split("."),r)}class Nt{_observers=new Map;on(e,r){let n=this._observers.get(e);return n===void 0&&this._observers.set(e,n=new Set),n.add(r),this}once(e,r){const n=(...i)=>{this.off(e,n),r(...i)};return this.on(e,n),this}off(e,r){const n=this._observers.get(e);return n!==void 0&&(n.delete(r),n.size===0&&this._observers.delete(e)),this}emit(e,...r){return Array.from((this._observers.get(e)||new Map).values()).forEach(n=>n(...r)),this}destroy(){this._observers=new Map}}class Le{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const r=e.__v_raw;r&&(e=this._toRaw(r))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,r){return this._map.set(this._toRaw(e),this._toRaw(r)),this}}const x=Symbol("internal"),it=Symbol("properties"),At=Symbol("inited");function k(t){let e;if(Object.hasOwn(t,it))e=t[it];else{const r=Object.getPrototypeOf(t);e=new Map(r?k(r):void 0),t[it]=e}return e}function ot(t,e){Object.hasOwn(t,x)||(t[x]=new Map);let r=t[x].get(e);return r||(r=Symbol(e),t[x].set(e,r)),r}function at(t,e={}){const{default:r,fallback:n,alias:i,internal:a}=e,u=()=>typeof r=="function"?r():r,l=()=>typeof n=="function"?n():n;function f(){let g;if(i&&i!==t?g=Lt(this,i):!a&&typeof this.getProperty<"u"?g=this.getProperty(t):g=this[ot(this,t)],g=g??l(),g===void 0&&r!==void 0&&!this[At]){this[At]=!0;const p=u();p!==void 0&&(m.call(this,p),g=p)}return g}function m(g){const p=f.call(this);i&&i!==t?Dt(this,i,g):!a&&typeof this.setProperty<"u"?this.setProperty(t,g):this[ot(this,t)]=g,this.onUpdateProperty?.(t,g,p)}return{get:f,set:m}}function Rt(t,e,r={}){k(t).set(e,r);const n=at(e,r);Object.defineProperty(t.prototype,e,{get(){return n.get.call(this)},set(i){n.set.call(this,i)},configurable:!0,enumerable:!0})}function De(t){return function(e,r){if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Rt(e.constructor,r,t)}}function Ne(t={}){return function(e,r){const n=r.name;if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=at(n,t);return{init(a){return k(this.constructor).set(n,t),i.set.call(this,a),a},get(){return i.get.call(this)},set(a){i.set.call(this,a)}}}}class Ae extends Nt{_propertyAccessor;_properties=new Map;_updatedProperties=new Map;_changedProperties=new Set;_updatingPromise=Promise.resolve();_updating=!1;constructor(e){super(),this.setProperties(e)}isDirty(e){return e?this._updatedProperties.has(e):this._updatedProperties.size>0}offsetGet(e){return this[e]}offsetSet(e,r){this[e]=r}getProperty(e,r){return this._propertyAccessor?.getProperty?this._propertyAccessor.getProperty(e,r):this._properties.get(e)??r}setProperty(e,r){this._propertyAccessor?.setProperty?.(e,r),this._properties.set(e,r)}getProperties(e){const r={};for(const[n,i]of this.getPropertyDeclarations())!i.internal&&!i.alias&&(!e||e.includes(n))&&(r[n]=this.getProperty(n));return r}setProperties(e){if(e&&typeof e=="object")for(const[r]of this.getPropertyDeclarations())r in e&&this.offsetSet(r,e[r]);return this}resetProperties(){for(const[e,r]of this.getPropertyDeclarations())this.offsetSet(e,typeof r.default=="function"?r.default():r.default);return this}getPropertyDeclarations(){return k(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}setPropertyAccessor(e){return this._propertyAccessor=e,this.getPropertyDeclarations().forEach((r,n)=>{const i=r.internal||r.alias&&r.alias!==n,a=e.getProperty?.(n);let u;i?u=this.offsetGet(n):u=this._properties.get(n),a!==void 0&&!Object.is(a,u)&&(i?this.offsetSet(n,a):(this._properties.set(n,a),this.requestUpdate(n,a,u)))}),this}async _nextTick(){return"requestAnimationFrame"in globalThis?new Promise(e=>globalThis.requestAnimationFrame(e)):Promise.resolve()}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await this._nextTick(),this._updating&&(this.onUpdate(),this._updating=!1)}onUpdate(){this._update(this._updatedProperties),this._updatedProperties=new Map}onUpdateProperty(e,r,n){Object.is(r,n)||this.requestUpdate(e,r,n)}requestUpdate(e,r,n){e!==void 0&&(this._updatedProperties.set(e,n),this._changedProperties.add(e),this._updateProperty(e,r,n),this.emit("updateProperty",e,r,n)),this._updating||(this._updatingPromise=this._enqueueUpdate())}_update(e){}_updateProperty(e,r,n){}toJSON(){const e={};return this._properties.forEach((r,n)=>{r!==void 0&&(r&&typeof r=="object"?"toJSON"in r&&typeof r.toJSON=="function"?e[n]=r.toJSON():Array.isArray(r)?e[n]=[...r]:e[n]={...r}:e[n]=r)}),e}clone(){return new this.constructor(this.toJSON())}}function st(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,L(e)}function Re(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function J(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const $="#000000FF";function It(t){return st(t).isValid()}function S(t,e=!1){const r=st(t);if(!r.isValid()){if(typeof t=="string")return t;const l=`Failed to normalizeColor ${t}`;if(e)throw new Error(l);return console.warn(l),$}const{r:n,g:i,b:a,a:u}=Re(r.rgba);return`#${J(n)}${J(i)}${J(a)}${J(N(u*255))}`}var X=X||{};X.parse=(function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function r(s){const c=new Error(`${e}: ${s}`);throw c.source=e,c}function n(){const s=i();return e.length>0&&r("Invalid input not EOF"),s}function i(){return T(a)}function a(){return u("linear-gradient",t.linearGradient,f)||u("repeating-linear-gradient",t.repeatingLinearGradient,f)||u("radial-gradient",t.radialGradient,p)||u("repeating-radial-gradient",t.repeatingRadialGradient,p)}function u(s,c,d){return l(c,b=>{const G=d();return G&&(v(t.comma)||r("Missing comma before color stops")),{type:s,orientation:G,colorStops:T(ht)}})}function l(s,c){const d=v(s);if(d){v(t.startCall)||r("Missing (");const b=c(d);return v(t.endCall)||r("Missing )"),b}}function f(){const s=m();if(s)return s;const c=P("position-keyword",t.positionKeywords,1);return c?{type:"directional",value:c.value}:g()}function m(){return P("directional",t.sideOrCorner,1)}function g(){return P("angular",t.angleValue,1)||P("angular",t.radianValue,1)}function p(){let s,c=w(),d;return c&&(s=[],s.push(c),d=e,v(t.comma)&&(c=w(),c?s.push(c):e=d)),s}function w(){let s=C()||R();if(s)s.at=O();else{const c=E();if(c){s=c;const d=O();d&&(s.at=d)}else{const d=O();if(d)s={type:"default-radial",at:d};else{const b=I();b&&(s={type:"default-radial",at:b})}}}return s}function C(){const s=P("shape",/^(circle)/i,0);return s&&(s.style=Se()||E()),s}function R(){const s=P("shape",/^(ellipse)/i,0);return s&&(s.style=I()||tt()||E()),s}function E(){return P("extent-keyword",t.extentKeywords,1)}function O(){if(P("position",/^at/,0)){const s=I();return s||r("Missing positioning value"),s}}function I(){const s=B();if(s.x||s.y)return{type:"position",value:s}}function B(){return{x:tt(),y:tt()}}function T(s){let c=s();const d=[];if(c)for(d.push(c);v(t.comma);)c=s(),c?d.push(c):r("One extra comma");return d}function ht(){const s=Ke();return s||r("Expected color definition"),s.length=tt(),s}function Ke(){return xe()||Qe()||Ze()||Xe()||Je()||Ye()||qe()}function qe(){return P("literal",t.literalColor,0)}function xe(){return P("hex",t.hexColor,1)}function Je(){return l(t.rgbColor,()=>({type:"rgb",value:T(U)}))}function Xe(){return l(t.rgbaColor,()=>({type:"rgba",value:T(U)}))}function Ye(){return l(t.varColor,()=>({type:"var",value:tr()}))}function Ze(){return l(t.hslColor,()=>{v(t.percentageValue)&&r("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const c=U();v(t.comma);let d=v(t.percentageValue);const b=d?d[1]:null;v(t.comma),d=v(t.percentageValue);const G=d?d[1]:null;return(!b||!G)&&r("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[c,b,G]}})}function Qe(){return l(t.hslaColor,()=>{const s=U();v(t.comma);let c=v(t.percentageValue);const d=c?c[1]:null;v(t.comma),c=v(t.percentageValue);const b=c?c[1]:null;v(t.comma);const G=U();return(!d||!b)&&r("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[s,d,b,G]}})}function tr(){return v(t.variableName)[1]}function U(){return v(t.number)[1]}function tt(){return P("%",t.percentageValue,1)||er()||rr()||Se()}function er(){return P("position-keyword",t.positionKeywords,1)}function rr(){return l(t.calcValue,()=>{let s=1,c=0;for(;s>0&&c<e.length;){const b=e.charAt(c);b==="("?s++:b===")"&&s--,c++}s>0&&r("Missing closing parenthesis in calc() expression");const d=e.substring(0,c-1);return pt(c-1),{type:"calc",value:d}})}function Se(){return P("px",t.pixelValue,1)||P("em",t.emValue,1)}function P(s,c,d){const b=v(c);if(b)return{type:s,value:b[d]}}function v(s){let c,d;return d=/^\s+/.exec(e),d&&pt(d[0].length),c=s.exec(e),c&&pt(c[0].length),c}function pt(s){e=e.substr(s)}return function(s){return e=s.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),n()}})();const Gt=X.parse.bind(X);var Y=Y||{};Y.stringify=(function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var r=t.visit(e.orientation);return r&&(r+=", "),e.type+"("+r+t.visit(e.colorStops)+")"},visit_shape:function(e){var r=e.value,n=t.visit(e.at),i=t.visit(e.style);return i&&(r+=" "+i),n&&(r+=" at "+n),r},"visit_default-radial":function(e){var r="",n=t.visit(e.at);return n&&(r+=n),r},"visit_extent-keyword":function(e){var r=e.value,n=t.visit(e.at);return n&&(r+=" at "+n),r},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,r){var n=e,i=t.visit(r.length);return i&&(n+=" "+i),n},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var r="",n=e.length;return e.forEach(function(i,a){r+=t.visit(i),a<n-1&&(r+=", ")}),r},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var r=t["visit_"+e.type];if(r)return r(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}})();const Ie=Y.stringify.bind(Y);function jt(t){const e=t.length-1;return t.map((r,n)=>{const i=r.value;let a=N(n/e,3),u="#00000000";switch(r.type){case"rgb":u=S({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":u=S({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":u=S(r.value);break;case"hex":u=S(`#${r.value}`);break}switch(r.length?.type){case"%":a=Number(r.length.value)/100;break}return{offset:a,color:u}})}function Mt(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:jt(t.colorStops)}}function Tt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:jt(t.colorStops)}}function W(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Vt(t){return Gt(t).map(e=>{switch(e?.type){case"linear-gradient":return Mt(e);case"repeating-linear-gradient":return{...Mt(e),repeat:!0};case"radial-gradient":return Tt(e);case"repeating-radial-gradient":return{...Tt(e),repeat:!0};default:return}}).filter(Boolean)}function kt(t){let e;return typeof t=="string"?e={color:t}:e={...t},{color:S(e.color)}}function $t(t){let e;if(typeof t=="string"?e={image:t}:e={...t},e.image){const{type:r,...n}=Vt(e.image)[0]??{};switch(r){case"radial-gradient":return{radialGradient:n};case"linear-gradient":return{linearGradient:n}}}return A(e,["linearGradient","radialGradient","rotateWithShape"])}function Wt(t){let e;return typeof t=="string"?e={image:t}:e={...t},A(e,["image","cropRect","stretchRect","tile","dpi","opacity","rotateWithShape"])}function Ht(t){let e;return typeof t=="string"?e={preset:t}:e={...t},h(e.foregroundColor)?delete e.foregroundColor:e.foregroundColor=S(e.foregroundColor),h(e.backgroundColor)?delete e.backgroundColor:e.backgroundColor=S(e.backgroundColor),A(e,["preset","foregroundColor","backgroundColor"])}function Bt(t){return!h(t.color)}function Ut(t){return typeof t=="string"?It(t):Bt(t)}function Kt(t){return!h(t.image)&&W(t.image)||!!t.linearGradient||!!t.radialGradient}function qt(t){return typeof t=="string"?W(t):Kt(t)}function xt(t){return!h(t.image)&&!W(t.image)}function Jt(t){return typeof t=="string"?!W(t):xt(t)}function Xt(t){return!h(t.preset)}function Yt(t){return typeof t=="string"?!1:Xt(t)}function F(t){const e=t&&typeof t=="object"?t.enabled:void 0;return Ut(t)?_({enabled:e,...kt(t)}):qt(t)?_({enabled:e,...$t(t)}):Jt(t)?_({enabled:e,...Wt(t)}):Yt(t)?_({enabled:e,...Ht(t)}):{}}function Zt(t){return typeof t=="string"?{...F(t)}:{...F(t),...A(t,["fillWithShape"])}}function ut(){return{color:$,offsetX:0,offsetY:0,blurRadius:1}}function lt(t){return{...ut(),..._({...t,color:h(t.color)?$:S(t.color)})}}function Qt(){return{...ut(),scaleX:1,scaleY:1}}function te(t){return{...Qt(),...lt(t)}}function Ge(t){return t}function ee(t){return _({...t,softEdge:h(t.softEdge)?void 0:t.softEdge,outerShadow:h(t.outerShadow)?void 0:te(t.outerShadow),innerShadow:h(t.innerShadow)?void 0:lt(t.innerShadow)})}function re(t){return typeof t=="string"?{...F(t)}:{...F(t),...A(t,["fillWithShape"])}}const je="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Me=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=je[r[t]&63];return e};const ne=()=>Me(10),ie=ne;function H(t){return typeof t=="string"?{...F(t)}:{...F(t),...A(t,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function oe(t){return typeof t=="string"?{color:S(t)}:{...t,color:h(t.color)?$:S(t.color)}}function ae(){return{boxShadow:"none"}}function se(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function ue(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function le(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ce(){return{...ue(),...le(),...ae(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function fe(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function de(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ge(){return{...fe(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function he(){return{...de(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function pe(){return{...he(),...ge(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function M(t){return _({...t,color:h(t.color)?void 0:S(t.color),backgroundColor:h(t.backgroundColor)?void 0:S(t.backgroundColor),borderColor:h(t.borderColor)?void 0:S(t.borderColor),outlineColor:h(t.outlineColor)?void 0:S(t.outlineColor),shadowColor:h(t.shadowColor)?void 0:S(t.shadowColor)})}function Te(){return{...ce(),...pe()}}const ct=/\r\n|\n\r|\n|\r/,Ve=new RegExp(`${ct.source}|<br\\/>`,"g"),ke=new RegExp(`^(${ct.source})$`),ft=`
2
+ `;function $e(t){return ct.test(t)}function dt(t){return ke.test(t)}function me(t){return t.replace(Ve,ft)}function Z(t){const e=[];function r(){return e[e.length-1]}function n(l,f,m){const g=l?M(l):{},p=f?F(f):void 0,w=m?H(m):void 0,C=_({...g,fill:p,outline:w,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=C:e.push(C),C}function i(l="",f,m,g){const p=f?M(f):{},w=m?F(m):void 0,C=g?H(g):void 0;Array.from(l).forEach(R=>{if(dt(R)){const{fragments:E,fill:O,outline:I,...B}=r()||n();E.length||E.push(_({...p,fill:w,outline:C,content:ft})),n(B,O,I)}else{const E=r()||n(),O=E.fragments[E.fragments.length-1];if(O){const{content:I,fill:B,outline:T,...ht}=O;if(q(w,B)&&q(C,T)&&q(p,ht)){O.content=`${I}${R}`;return}}E.fragments.push(_({...p,fill:w,outline:C,content:R}))}})}(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l=="string")n(),i(l);else if(gt(l)){const{content:f,fill:m,outline:g,...p}=l;n(p,m,g),i(f)}else if(ve(l)){const{fragments:f,fill:m,outline:g,...p}=l;n(p,m,g),f.forEach(w=>{const{content:C,fill:R,outline:E,...O}=w;i(C,O,R,E)})}else Array.isArray(l)?(n(),l.forEach(f=>{if(typeof f=="string")i(f);else if(gt(f)){const{content:m,fill:g,outline:p,...w}=f;i(m,w,g,p)}})):console.warn("Failed to parse text content",l)});const u=r();return u&&!u.fragments.length&&u.fragments.push({content:""}),e}function ve(t){return t&&typeof t=="object"&&"fragments"in t&&Array.isArray(t.fragments)}function gt(t){return t&&typeof t=="object"&&"content"in t&&typeof t.content=="string"}function ye(t){return typeof t=="string"||Array.isArray(t)?{content:Z(t)}:_({...t,content:Z(t.content??""),style:t.style?M(t.style):void 0,effects:t.effects?t.effects.map(e=>M(e)):void 0,measureDom:t.measureDom,fonts:t.fonts,fill:t.fill?F(t.fill):void 0,outline:t.outline?H(t.outline):void 0})}function We(t){return Z(t).map(e=>{const r=me(e.fragments.flatMap(n=>n.content).join(""));return dt(r)?"":r}).join(ft)}function be(t){return typeof t=="string"?{src:t}:t}function Q(t){return _({...t,id:t.id??ie(),style:h(t.style)?void 0:M(t.style),text:h(t.text)?void 0:ye(t.text),background:h(t.background)?void 0:Zt(t.background),shape:h(t.shape)?void 0:se(t.shape),fill:h(t.fill)?void 0:F(t.fill),outline:h(t.outline)?void 0:H(t.outline),foreground:h(t.foreground)?void 0:re(t.foreground),shadow:h(t.shadow)?void 0:oe(t.shadow),video:h(t.video)?void 0:be(t.video),audio:h(t.audio)?void 0:j(t.audio),effect:h(t.effect)?void 0:ee(t.effect),children:t.children?.map(e=>Q(e))})}function He(t){return Q(t)}function Be(t){const e={};for(const r in t.children){const n=Q(t.children[r]);delete n.children,e[r]=n}return{...t,children:e}}function Ue(t){const{children:e,...r}=t;function n(f){const{parentId:m,childrenIds:g,...p}=f;return{...p,children:[]}}const i={},a=[],u={...r,children:a};function l(f){if(!e[f]||i[f])return;const m=e[f],g=n(m);i[f]=g;const p=m.parentId;if(p){l(p);const w=e[p],C=i[p];if(!C)return;w?.childrenIds&&C?.children&&(C.children[w.childrenIds.indexOf(f)]=g)}else a.push(g)}for(const f in e)l(f);return u}o.EventEmitter=Oe,o.Observable=Nt,o.RawWeakMap=Le,o.Reactivable=Ae,o.clearUndef=_,o.defaultColor=$,o.defineProperty=Rt,o.flatDocumentToDocument=Ue,o.getDeclarations=k,o.getDefaultElementStyle=ce,o.getDefaultHighlightStyle=fe,o.getDefaultInnerShadow=ut,o.getDefaultLayoutStyle=ue,o.getDefaultListStyleStyle=de,o.getDefaultOuterShadow=Qt,o.getDefaultShadowStyle=ae,o.getDefaultStyle=Te,o.getDefaultTextInlineStyle=ge,o.getDefaultTextLineStyle=he,o.getDefaultTextStyle=pe,o.getDefaultTransformStyle=le,o.getNestedValue=Ft,o.getObjectValueByPath=Lt,o.getPropertyDescriptor=at,o.getPropertyInternalKey=ot,o.hasCRLF=$e,o.idGenerator=ie,o.isCRLF=dt,o.isColor=It,o.isColorFill=Ut,o.isColorFillObject=Bt,o.isEqualObject=q,o.isFragmentObject=gt,o.isGradient=W,o.isGradientFill=qt,o.isGradientFillObject=Kt,o.isImageFill=Jt,o.isImageFillObject=xt,o.isNone=h,o.isParagraphObject=ve,o.isPresetFill=Yt,o.isPresetFillObject=Xt,o.nanoid=ne,o.normalizeAudio=j,o.normalizeBackground=Zt,o.normalizeCRLF=me,o.normalizeColor=S,o.normalizeColorFill=kt,o.normalizeDocument=He,o.normalizeEffect=ee,o.normalizeElement=Q,o.normalizeFill=F,o.normalizeFlatDocument=Be,o.normalizeForeground=re,o.normalizeGradient=Vt,o.normalizeGradientFill=$t,o.normalizeImageFill=Wt,o.normalizeInnerShadow=lt,o.normalizeOuterShadow=te,o.normalizeOutline=H,o.normalizePresetFill=Ht,o.normalizeShadow=oe,o.normalizeShape=se,o.normalizeSoftEdge=Ge,o.normalizeStyle=M,o.normalizeText=ye,o.normalizeTextContent=Z,o.normalizeVideo=be,o.parseColor=st,o.parseGradient=Gt,o.pick=A,o.property=De,o.property2=Ne,o.round=N,o.setNestedValue=Ot,o.setObjectValueByPath=Dt,o.stringifyGradient=Ie,o.textContentToString=We,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.mjs CHANGED
@@ -436,18 +436,21 @@ class Reactivable extends Observable {
436
436
  setPropertyAccessor(accessor) {
437
437
  this._propertyAccessor = accessor;
438
438
  this.getPropertyDeclarations().forEach((declaration, key) => {
439
- if (declaration.internal || declaration.alias && declaration.alias !== key) {
440
- return;
441
- }
442
- let newValue = this.offsetGet(key);
443
- let oldValue = this._properties.get(key);
444
- if (newValue === void 0 && oldValue !== void 0) {
445
- newValue = oldValue;
446
- oldValue = void 0;
439
+ const proxyed = declaration.internal || declaration.alias && declaration.alias !== key;
440
+ const newValue = accessor.getProperty?.(key);
441
+ let oldValue;
442
+ if (proxyed) {
443
+ oldValue = this.offsetGet(key);
444
+ } else {
445
+ oldValue = this._properties.get(key);
447
446
  }
448
- this.offsetSet(key, newValue);
449
- if (!Object.is(newValue, oldValue)) {
450
- this.requestUpdate(key, newValue, oldValue);
447
+ if (newValue !== void 0 && !Object.is(newValue, oldValue)) {
448
+ if (proxyed) {
449
+ this.offsetSet(key, newValue);
450
+ } else {
451
+ this._properties.set(key, newValue);
452
+ this.requestUpdate(key, newValue, oldValue);
453
+ }
451
454
  }
452
455
  });
453
456
  return this;
@@ -1176,7 +1179,7 @@ function normalizeColorFill(fill) {
1176
1179
  if (typeof fill === "string") {
1177
1180
  obj = { color: fill };
1178
1181
  } else {
1179
- obj = fill;
1182
+ obj = { ...fill };
1180
1183
  }
1181
1184
  return {
1182
1185
  color: normalizeColor(obj.color)
@@ -1188,7 +1191,7 @@ function normalizeGradientFill(fill) {
1188
1191
  if (typeof fill === "string") {
1189
1192
  obj = { image: fill };
1190
1193
  } else {
1191
- obj = fill;
1194
+ obj = { ...fill };
1192
1195
  }
1193
1196
  if (obj.image) {
1194
1197
  const { type, ...props } = normalizeGradient(obj.image)[0] ?? {};
@@ -1203,7 +1206,11 @@ function normalizeGradientFill(fill) {
1203
1206
  };
1204
1207
  }
1205
1208
  }
1206
- return obj;
1209
+ return pick(obj, [
1210
+ "linearGradient",
1211
+ "radialGradient",
1212
+ "rotateWithShape"
1213
+ ]);
1207
1214
  }
1208
1215
 
1209
1216
  function normalizeImageFill(fill) {
@@ -1211,9 +1218,17 @@ function normalizeImageFill(fill) {
1211
1218
  if (typeof fill === "string") {
1212
1219
  obj = { image: fill };
1213
1220
  } else {
1214
- obj = fill;
1215
- }
1216
- return obj;
1221
+ obj = { ...fill };
1222
+ }
1223
+ return pick(obj, [
1224
+ "image",
1225
+ "cropRect",
1226
+ "stretchRect",
1227
+ "tile",
1228
+ "dpi",
1229
+ "opacity",
1230
+ "rotateWithShape"
1231
+ ]);
1217
1232
  }
1218
1233
 
1219
1234
  function normalizePresetFill(fill) {
@@ -1221,13 +1236,23 @@ function normalizePresetFill(fill) {
1221
1236
  if (typeof fill === "string") {
1222
1237
  obj = { preset: fill };
1223
1238
  } else {
1224
- obj = fill;
1239
+ obj = { ...fill };
1225
1240
  }
1226
- return {
1227
- preset: obj.preset,
1228
- foregroundColor: isNone(obj.foregroundColor) ? void 0 : normalizeColor(obj.foregroundColor),
1229
- backgroundColor: isNone(obj.backgroundColor) ? void 0 : normalizeColor(obj.backgroundColor)
1230
- };
1241
+ if (isNone(obj.foregroundColor)) {
1242
+ delete obj.foregroundColor;
1243
+ } else {
1244
+ obj.foregroundColor = normalizeColor(obj.foregroundColor);
1245
+ }
1246
+ if (isNone(obj.backgroundColor)) {
1247
+ delete obj.backgroundColor;
1248
+ } else {
1249
+ obj.backgroundColor = normalizeColor(obj.backgroundColor);
1250
+ }
1251
+ return pick(obj, [
1252
+ "preset",
1253
+ "foregroundColor",
1254
+ "backgroundColor"
1255
+ ]);
1231
1256
  }
1232
1257
 
1233
1258
  function isColorFillObject(fill) {
@@ -1352,7 +1377,14 @@ function normalizeOutline(outline) {
1352
1377
  } else {
1353
1378
  return {
1354
1379
  ...normalizeFill(outline),
1355
- ...pick(outline, ["width", "style", "lineCap", "lineJoin", "headEnd", "tailEnd"])
1380
+ ...pick(outline, [
1381
+ "width",
1382
+ "style",
1383
+ "lineCap",
1384
+ "lineJoin",
1385
+ "headEnd",
1386
+ "tailEnd"
1387
+ ])
1356
1388
  };
1357
1389
  }
1358
1390
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.9.6",
4
+ "version": "0.9.8",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",