modern-idoc 0.6.18 → 0.6.19

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
@@ -904,26 +904,39 @@ function defineProperty(constructor, key, declaration = {}) {
904
904
  getDeclarations(constructor).set(key, declaration);
905
905
  const {
906
906
  default: defaultValue,
907
- alias = key
907
+ alias
908
908
  } = declaration;
909
- const _alias = alias === key ? Symbol.for(String(alias)) : alias;
909
+ const internalKey = Symbol.for(String(key));
910
910
  const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
911
911
  const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key) || {
912
912
  get() {
913
- if (typeof _alias === "string") {
914
- return this.offsetGet ? this.offsetGet(_alias) : getObjectValueByPath(this, _alias);
913
+ if (alias && alias !== key) {
914
+ if (typeof alias === "string") {
915
+ return getObjectValueByPath(this, alias);
916
+ } else {
917
+ return this[alias];
918
+ }
915
919
  } else {
916
- return this[_alias];
920
+ if (typeof key === "string" && this.offsetGet) {
921
+ return this.offsetGet(key);
922
+ } else {
923
+ return this[internalKey];
924
+ }
917
925
  }
918
926
  },
919
927
  set(value) {
920
- if (typeof _alias === "string") {
921
- if (this.offsetSet) {
922
- this.offsetSet(_alias, value);
928
+ if (alias && alias !== key) {
929
+ if (typeof alias === "string") {
930
+ setObjectValueByPath(this, alias, value);
931
+ } else {
932
+ this[alias] = value;
923
933
  }
924
- setObjectValueByPath(this, _alias, value);
925
934
  } else {
926
- this[_alias] = value;
935
+ if (typeof key === "string" && this.offsetSet) {
936
+ this.offsetSet(key, value);
937
+ } else {
938
+ this[internalKey] = value;
939
+ }
927
940
  }
928
941
  }
929
942
  };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(o,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(o=typeof globalThis<"u"?globalThis:o||self,E(o.modernIdoc={}))})(this,function(o){"use strict";function E(t){return typeof t=="string"?{src:t}:t}var ce={grad:.9,turn:360,rad:360/(2*Math.PI)},_=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},m=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},S=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ut=function(t){return{r:S(t.r,0,255),g:S(t.g,0,255),b:S(t.b,0,255),a:S(t.a)}},x=function(t){return{r:m(t.r),g:m(t.g),b:m(t.b),a:m(t.a,3)}},fe=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},lt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,l=Math.max(e,n,r),c=l-Math.min(e,n,r),s=c?l===e?(n-r)/c:l===n?2+(r-e)/c:4+(e-n)/c:0;return{h:60*(s<0?s+6:s),s:l?c/l*100:0,v:l/255*100,a:i}},st=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var l=Math.floor(e),c=r*(1-n),s=r*(1-(e-l)*n),f=r*(1-(1-e+l)*n),h=l%6;return{r:255*[r,s,c,c,f,r][h],g:255*[f,r,r,s,c,c][h],b:255*[c,c,f,r,r,s][h],a:i}},ct=function(t){return{h:at(t.h),s:S(t.s,0,100),l:S(t.l,0,100),a:S(t.a)}},ft=function(t){return{h:m(t.h),s:m(t.s),l:m(t.l),a:m(t.a,3)}},dt=function(t){return st((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},L=function(t){return{h:(e=lt(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},de=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gt={string:[[function(t){var e=fe.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?m(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?m(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=he.exec(t)||ve.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:ut({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=de.exec(t)||ge.exec(t);if(!e)return null;var n,r,i=ct({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(ce[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return dt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,l=i===void 0?1:i;return _(e)&&_(n)&&_(r)?ut({r:Number(e),g:Number(n),b:Number(r),a:Number(l)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,l=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var c=ct({h:Number(e),s:Number(n),l:Number(r),a:Number(l)});return dt(c)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,l=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var c=function(s){return{h:at(s.h),s:S(s.s,0,100),v:S(s.v,0,100),a:S(s.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(l)});return st(c)},"hsv"]]},ht=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]},me=function(t){return typeof t=="string"?ht(t.trim(),gt.string):typeof t=="object"&&t!==null?ht(t,gt.object):[null,void 0]},K=function(t,e){var n=L(t);return{h:n.h,s:S(n.s+100*e,0,100),l:n.l,a:n.a}},X=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},vt=function(t,e){var n=L(t);return{h:n.h,s:n.s,l:S(n.l+100*e,0,100),a:n.a}},mt=function(){function t(e){this.parsed=me(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 m(X(this.rgba),2)},t.prototype.isDark=function(){return X(this.rgba)<.5},t.prototype.isLight=function(){return X(this.rgba)>=.5},t.prototype.toHex=function(){return e=x(this.rgba),n=e.r,r=e.g,i=e.b,c=(l=e.a)<1?A(m(255*l)):"","#"+A(n)+A(r)+A(i)+c;var e,n,r,i,l,c},t.prototype.toRgb=function(){return x(this.rgba)},t.prototype.toRgbString=function(){return e=x(this.rgba),n=e.r,r=e.g,i=e.b,(l=e.a)<1?"rgba("+n+", "+r+", "+i+", "+l+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,l},t.prototype.toHsl=function(){return ft(L(this.rgba))},t.prototype.toHslString=function(){return e=ft(L(this.rgba)),n=e.h,r=e.s,i=e.l,(l=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+l+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,l},t.prototype.toHsv=function(){return e=lt(this.rgba),{h:m(e.h),s:m(e.s),v:m(e.v),a:m(e.a,3)};var e},t.prototype.invert=function(){return w({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),w(K(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(K(this.rgba,-e))},t.prototype.grayscale=function(){return w(K(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),w(vt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),w(vt(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"?w({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):m(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=L(this.rgba);return typeof e=="number"?w({h:e,s:n.s,l:n.l,a:n.a}):m(n.h)},t.prototype.isEqual=function(e){return this.toHex()===w(e).toHex()},t}(),w=function(t){return t instanceof mt?t:new mt(t)};function g(t){return t==null||t==="none"}function N(t,e=0,n=10**e){return Math.round(n*t)/n+0}function O(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>O(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=O(i,e):n[r]=i)}return n}function M(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function pt(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 bt(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 yt(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(/^\./,""),pt(t,e.split("."),n))}function St(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n)}class Ct{_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}}function Y(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,w(e)}function pe(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function T(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const G="#000000FF";function wt(t){return Y(t).isValid()}function b(t,e=!1){const n=Y(t);if(!n.isValid()){if(typeof t=="string")return t;const s=`Failed to normalizeColor ${t}`;if(e)throw new Error(s);return console.warn(s),G}const{r,g:i,b:l,a:c}=pe(n.rgba);return`#${T(r)}${T(i)}${T(l)}${T(N(c*255))}`}var $=$||{};$.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(a){const u=new Error(`${e}: ${a}`);throw u.source=e,u}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return B(l)}function l(){return c("linear-gradient",t.linearGradient,f)||c("repeating-linear-gradient",t.repeatingLinearGradient,f)||c("radial-gradient",t.radialGradient,z)||c("repeating-radial-gradient",t.repeatingRadialGradient,z)}function c(a,u,d){return s(u,p=>{const R=d();return R&&(v(t.comma)||n("Missing comma before color stops")),{type:a,orientation:R,colorStops:B(Ee)}})}function s(a,u){const d=v(a);if(d){v(t.startCall)||n("Missing (");const p=u(d);return v(t.endCall)||n("Missing )"),p}}function f(){const a=h();if(a)return a;const u=y("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:C()}function h(){return y("directional",t.sideOrCorner,1)}function C(){return y("angular",t.angleValue,1)||y("angular",t.radianValue,1)}function z(){let a,u=D(),d;return u&&(a=[],a.push(u),d=e,v(t.comma)&&(u=D(),u?a.push(u):e=d)),a}function D(){let a=et()||Oe();if(a)a.at=rt();else{const u=nt();if(u){a=u;const d=rt();d&&(a.at=d)}else{const d=rt();if(d)a={type:"default-radial",at:d};else{const p=it();p&&(a={type:"default-radial",at:p})}}}return a}function et(){const a=y("shape",/^(circle)/i,0);return a&&(a.style=se()||nt()),a}function Oe(){const a=y("shape",/^(ellipse)/i,0);return a&&(a.style=it()||j()||nt()),a}function nt(){return y("extent-keyword",t.extentKeywords,1)}function rt(){if(y("position",/^at/,0)){const a=it();return a||n("Missing positioning value"),a}}function it(){const a=Re();if(a.x||a.y)return{type:"position",value:a}}function Re(){return{x:j(),y:j()}}function B(a){let u=a();const d=[];if(u)for(d.push(u);v(t.comma);)u=a(),u?d.push(u):n("One extra comma");return d}function Ee(){const a=ke();return a||n("Expected color definition"),a.length=j(),a}function ke(){return Le()||Ae()||Pe()||Ie()||Ge()||Ve()||De()}function De(){return y("literal",t.literalColor,0)}function Le(){return y("hex",t.hexColor,1)}function Ge(){return s(t.rgbColor,()=>({type:"rgb",value:B(P)}))}function Ie(){return s(t.rgbaColor,()=>({type:"rgba",value:B(P)}))}function Ve(){return s(t.varColor,()=>({type:"var",value:Me()}))}function Pe(){return s(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 u=P();v(t.comma);let d=v(t.percentageValue);const p=d?d[1]:null;v(t.comma),d=v(t.percentageValue);const R=d?d[1]:null;return(!p||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,p,R]}})}function Ae(){return s(t.hslaColor,()=>{const a=P();v(t.comma);let u=v(t.percentageValue);const d=u?u[1]:null;v(t.comma),u=v(t.percentageValue);const p=u?u[1]:null;v(t.comma);const R=P();return(!d||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,d,p,R]}})}function Me(){return v(t.variableName)[1]}function P(){return v(t.number)[1]}function j(){return y("%",t.percentageValue,1)||Te()||$e()||se()}function Te(){return y("position-keyword",t.positionKeywords,1)}function $e(){return s(t.calcValue,()=>{let a=1,u=0;for(;a>0&&u<e.length;){const p=e.charAt(u);p==="("?a++:p===")"&&a--,u++}a>0&&n("Missing closing parenthesis in calc() expression");const d=e.substring(0,u-1);return ot(u-1),{type:"calc",value:d}})}function se(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(a,u,d){const p=v(u);if(p)return{type:a,value:p[d]}}function v(a){let u,d;return d=/^\s+/.exec(e),d&&ot(d[0].length),u=a.exec(e),u&&ot(u[0].length),u}function ot(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const zt=$.parse.bind($);var H=H||{};H.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,l){n+=t.visit(i),l<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 be=H.stringify.bind(H);function _t(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let l=N(r/e,3),c="#00000000";switch(n.type){case"rgb":c=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":c=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":c=b(n.value);break;case"hex":c=b(`#${n.value}`);break}switch(n.length?.type){case"%":l=Number(n.length.value)/100;break}return{offset:l,color:c}})}function Ft(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:_t(t.colorStops)}}function Nt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:_t(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Ot(t){return zt(t).map(e=>{switch(e?.type){case"linear-gradient":return Ft(e);case"repeating-linear-gradient":return{...Ft(e),repeat:!0};case"radial-gradient":return Nt(e);case"repeating-radial-gradient":return{...Nt(e),repeat:!0};default:return}}).filter(Boolean)}function Rt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function Et(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Ot(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function kt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Dt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:g(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:g(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Lt(t){return!g(t.color)}function Gt(t){return typeof t=="string"?wt(t):Lt(t)}function It(t){return!g(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):It(t)}function Pt(t){return!g(t.image)&&!I(t.image)}function At(t){return typeof t=="string"?!I(t):Pt(t)}function Mt(t){return!g(t.preset)}function Tt(t){return typeof t=="string"?!1:Mt(t)}function F(t){return Gt(t)?Rt(t):Vt(t)?Et(t):At(t)?kt(t):Tt(t)?Dt(t):{}}function $t(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["fillWithShape"])}}const Ht=new Ct;function q(t){let e=Ht.get(t);if(!e){const n=Object.getPrototypeOf(t);e=new Map(n?q(n):void 0),Ht.set(t,e)}return e}function Wt(t,e,n={}){q(t).set(e,n);const{default:r,alias:i=e}=n,l=i===e?Symbol.for(String(i)):i,c=()=>typeof r=="function"?r():r,s=Object.getOwnPropertyDescriptor(t.prototype,e)||{get(){return typeof l=="string"?this.offsetGet?this.offsetGet(l):yt(this,l):this[l]},set(f){typeof l=="string"?(this.offsetSet&&this.offsetSet(l,f),St(this,l,f)):this[l]=f}};Object.defineProperty(t.prototype,e,{get(){let f=s.get?.call(this);return f===void 0&&(f=c(),f!==void 0&&s.set?.call(this,f)),f},set(f){let h=s.get?.call(this);h===void 0&&(h=c()),s.set?.call(this,f),this.requestUpdate?.(e,f,h,n)},configurable:!0,enumerable:!0})}function ye(t){return function(e,n){Wt(e.constructor,n,t)}}function U(){return{color:G,offsetX:0,offsetY:0,blurRadius:1}}function Z(t){return{...U(),...O({...t,color:g(t.color)?G:b(t.color)})}}function Bt(){return{...U(),scaleX:1,scaleY:1}}function jt(t){return{...Bt(),...Z(t)}}function Se(t){return t}function xt(t){return O({...t,softEdge:g(t.softEdge)?void 0:t.softEdge,outerShadow:g(t.outerShadow)?void 0:jt(t.outerShadow),innerShadow:g(t.innerShadow)?void 0:Z(t.innerShadow)})}function Kt(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["fillWithShape"])}}function Xt(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["width","style","headEnd","tailEnd"])}}function Yt(t){return typeof t=="string"?{color:b(t)}:{...t,color:g(t.color)?G:b(t.color)}}function qt(){return{boxShadow:"none"}}function Ut(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 Zt(){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 Jt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Qt(){return{...Zt(),...Jt(),...qt(),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 te(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ee(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ne(){return{...te(),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 re(){return{...ee(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ie(){return{...re(),...ne(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function k(t){return O({...t,color:g(t.color)?void 0:b(t.color),backgroundColor:g(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:g(t.borderColor)?void 0:b(t.borderColor),outlineColor:g(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:g(t.shadowColor)?void 0:b(t.shadowColor)})}function Ce(){return{...Qt(),...ie()}}const J=/\r\n|\n\r|\n|\r/,we=new RegExp(`${J.source}|<br\\/>`,"g"),ze=new RegExp(`^(${J.source})$`),W=`
2
- `;function _e(t){return J.test(t)}function Q(t){return ze.test(t)}function oe(t){return t.replace(we,W)}function ae(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function V(t){const e=[];function n(){return e[e.length-1]}function r(s={}){let f=e[e.length-1];return f?.fragments.length===0?(f={...s,fragments:[]},e[e.length-1]=f):(f={...s,fragments:[]},e.push(f)),f}function i(s="",f={}){Array.from(s).forEach(h=>{if(Q(h)){const{fragments:C,...z}=n()||r();C.length||C.push({...f,content:W}),r(z)}else{const C=n()||r(),z=C.fragments[C.fragments.length-1];if(z){const{content:D,...et}=z;if(ae(f,et)){z.content=`${D}${h}`;return}}C.fragments.push({...f,content:h})}})}(Array.isArray(t)?t:[t]).forEach(s=>{if(typeof s=="string")r(),i(s);else if("content"in s){const{content:f,...h}=s;r(k(h)),i(f)}else if("fragments"in s){const{fragments:f,...h}=s;r(k(h)),f.forEach(C=>{const{content:z,...D}=C;i(z,k(D))})}else Array.isArray(s)?(r(),s.forEach(f=>{if(typeof f=="string")i(f);else{const{content:h,...C}=f;i(h,k(C))}})):console.warn("Failed to parse text content",s)});const c=n();return c&&!c.fragments.length&&c.fragments.push({content:W}),e}function ue(t){return typeof t=="string"?{content:V(t)}:"content"in t?{...t,content:V(t.content)}:{content:V(t)}}function Fe(t){return V(t).map(e=>{const n=oe(e.fragments.flatMap(r=>r.content).join(""));return Q(n)?"":n}).join(W)}function le(t){return typeof t=="string"?{src:t}:t}function tt(t){return O({...t,style:g(t.style)?void 0:k(t.style),text:g(t.text)?void 0:ue(t.text),background:g(t.background)?void 0:$t(t.background),shape:g(t.shape)?void 0:Ut(t.shape),fill:g(t.fill)?void 0:F(t.fill),outline:g(t.outline)?void 0:Xt(t.outline),foreground:g(t.foreground)?void 0:Kt(t.foreground),shadow:g(t.shadow)?void 0:Yt(t.shadow),video:g(t.video)?void 0:le(t.video),audio:g(t.audio)?void 0:E(t.audio),effect:g(t.effect)?void 0:xt(t.effect),children:t.children?.map(e=>tt(e))})}function Ne(t){return tt(t)}o.RawWeakMap=Ct,o.clearUndef=O,o.defaultColor=G,o.defineProperty=Wt,o.getDeclarations=q,o.getDefaultElementStyle=Qt,o.getDefaultHighlightStyle=te,o.getDefaultInnerShadow=U,o.getDefaultLayoutStyle=Zt,o.getDefaultListStyleStyle=ee,o.getDefaultOuterShadow=Bt,o.getDefaultShadowStyle=qt,o.getDefaultStyle=Ce,o.getDefaultTextInlineStyle=ne,o.getDefaultTextLineStyle=re,o.getDefaultTextStyle=ie,o.getDefaultTransformStyle=Jt,o.getNestedValue=pt,o.getObjectValueByPath=yt,o.hasCRLF=_e,o.isCRLF=Q,o.isColor=wt,o.isColorFill=Gt,o.isColorFillObject=Lt,o.isEqualStyle=ae,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=It,o.isImageFill=At,o.isImageFillObject=Pt,o.isNone=g,o.isPresetFill=Tt,o.isPresetFillObject=Mt,o.normalizeAudio=E,o.normalizeBackground=$t,o.normalizeCRLF=oe,o.normalizeColor=b,o.normalizeColorFill=Rt,o.normalizeDocument=Ne,o.normalizeEffect=xt,o.normalizeElement=tt,o.normalizeFill=F,o.normalizeForeground=Kt,o.normalizeGradient=Ot,o.normalizeGradientFill=Et,o.normalizeImageFill=kt,o.normalizeInnerShadow=Z,o.normalizeOuterShadow=jt,o.normalizeOutline=Xt,o.normalizePresetFill=Dt,o.normalizeShadow=Yt,o.normalizeShape=Ut,o.normalizeSoftEdge=Se,o.normalizeStyle=k,o.normalizeText=ue,o.normalizeTextContent=V,o.normalizeVideo=le,o.parseColor=Y,o.parseGradient=zt,o.pick=M,o.property=ye,o.round=N,o.setNestedValue=bt,o.setObjectValueByPath=St,o.stringifyGradient=be,o.textContentToString=Fe,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(o=typeof globalThis<"u"?globalThis:o||self,E(o.modernIdoc={}))})(this,function(o){"use strict";function E(t){return typeof t=="string"?{src:t}:t}var ce={grad:.9,turn:360,rad:360/(2*Math.PI)},_=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},m=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},S=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ut=function(t){return{r:S(t.r,0,255),g:S(t.g,0,255),b:S(t.b,0,255),a:S(t.a)}},x=function(t){return{r:m(t.r),g:m(t.g),b:m(t.b),a:m(t.a,3)}},fe=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},lt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,f=Math.max(e,n,r),s=f-Math.min(e,n,r),l=s?f===e?(n-r)/s:f===n?2+(r-e)/s:4+(e-n)/s:0;return{h:60*(l<0?l+6:l),s:f?s/f*100:0,v:f/255*100,a:i}},st=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var f=Math.floor(e),s=r*(1-n),l=r*(1-(e-f)*n),c=r*(1-(1-e+f)*n),h=f%6;return{r:255*[r,l,s,s,c,r][h],g:255*[c,r,r,l,s,s][h],b:255*[s,s,c,r,r,l][h],a:i}},ct=function(t){return{h:at(t.h),s:S(t.s,0,100),l:S(t.l,0,100),a:S(t.a)}},ft=function(t){return{h:m(t.h),s:m(t.s),l:m(t.l),a:m(t.a,3)}},dt=function(t){return st((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},G=function(t){return{h:(e=lt(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},de=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gt={string:[[function(t){var e=fe.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?m(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?m(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=he.exec(t)||ve.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:ut({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=de.exec(t)||ge.exec(t);if(!e)return null;var n,r,i=ct({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(ce[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return dt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,f=i===void 0?1:i;return _(e)&&_(n)&&_(r)?ut({r:Number(e),g:Number(n),b:Number(r),a:Number(f)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,f=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var s=ct({h:Number(e),s:Number(n),l:Number(r),a:Number(f)});return dt(s)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,f=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var s=function(l){return{h:at(l.h),s:S(l.s,0,100),v:S(l.v,0,100),a:S(l.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(f)});return st(s)},"hsv"]]},ht=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]},me=function(t){return typeof t=="string"?ht(t.trim(),gt.string):typeof t=="object"&&t!==null?ht(t,gt.object):[null,void 0]},K=function(t,e){var n=G(t);return{h:n.h,s:S(n.s+100*e,0,100),l:n.l,a:n.a}},X=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},vt=function(t,e){var n=G(t);return{h:n.h,s:n.s,l:S(n.l+100*e,0,100),a:n.a}},mt=function(){function t(e){this.parsed=me(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 m(X(this.rgba),2)},t.prototype.isDark=function(){return X(this.rgba)<.5},t.prototype.isLight=function(){return X(this.rgba)>=.5},t.prototype.toHex=function(){return e=x(this.rgba),n=e.r,r=e.g,i=e.b,s=(f=e.a)<1?A(m(255*f)):"","#"+A(n)+A(r)+A(i)+s;var e,n,r,i,f,s},t.prototype.toRgb=function(){return x(this.rgba)},t.prototype.toRgbString=function(){return e=x(this.rgba),n=e.r,r=e.g,i=e.b,(f=e.a)<1?"rgba("+n+", "+r+", "+i+", "+f+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,f},t.prototype.toHsl=function(){return ft(G(this.rgba))},t.prototype.toHslString=function(){return e=ft(G(this.rgba)),n=e.h,r=e.s,i=e.l,(f=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+f+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,f},t.prototype.toHsv=function(){return e=lt(this.rgba),{h:m(e.h),s:m(e.s),v:m(e.v),a:m(e.a,3)};var e},t.prototype.invert=function(){return w({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),w(K(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(K(this.rgba,-e))},t.prototype.grayscale=function(){return w(K(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),w(vt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),w(vt(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"?w({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):m(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=G(this.rgba);return typeof e=="number"?w({h:e,s:n.s,l:n.l,a:n.a}):m(n.h)},t.prototype.isEqual=function(e){return this.toHex()===w(e).toHex()},t}(),w=function(t){return t instanceof mt?t:new mt(t)};function g(t){return t==null||t==="none"}function N(t,e=0,n=10**e){return Math.round(n*t)/n+0}function O(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>O(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=O(i,e):n[r]=i)}return n}function M(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function pt(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 bt(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 yt(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(/^\./,""),pt(t,e.split("."),n))}function St(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n)}class Ct{_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}}function Y(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,w(e)}function pe(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function T(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const k="#000000FF";function wt(t){return Y(t).isValid()}function b(t,e=!1){const n=Y(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:f,a:s}=pe(n.rgba);return`#${T(r)}${T(i)}${T(f)}${T(N(s*255))}`}var $=$||{};$.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(a){const u=new Error(`${e}: ${a}`);throw u.source=e,u}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return B(f)}function f(){return s("linear-gradient",t.linearGradient,c)||s("repeating-linear-gradient",t.repeatingLinearGradient,c)||s("radial-gradient",t.radialGradient,z)||s("repeating-radial-gradient",t.repeatingRadialGradient,z)}function s(a,u,d){return l(u,p=>{const R=d();return R&&(v(t.comma)||n("Missing comma before color stops")),{type:a,orientation:R,colorStops:B(Ee)}})}function l(a,u){const d=v(a);if(d){v(t.startCall)||n("Missing (");const p=u(d);return v(t.endCall)||n("Missing )"),p}}function c(){const a=h();if(a)return a;const u=y("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:C()}function h(){return y("directional",t.sideOrCorner,1)}function C(){return y("angular",t.angleValue,1)||y("angular",t.radianValue,1)}function z(){let a,u=L(),d;return u&&(a=[],a.push(u),d=e,v(t.comma)&&(u=L(),u?a.push(u):e=d)),a}function L(){let a=et()||Oe();if(a)a.at=rt();else{const u=nt();if(u){a=u;const d=rt();d&&(a.at=d)}else{const d=rt();if(d)a={type:"default-radial",at:d};else{const p=it();p&&(a={type:"default-radial",at:p})}}}return a}function et(){const a=y("shape",/^(circle)/i,0);return a&&(a.style=se()||nt()),a}function Oe(){const a=y("shape",/^(ellipse)/i,0);return a&&(a.style=it()||j()||nt()),a}function nt(){return y("extent-keyword",t.extentKeywords,1)}function rt(){if(y("position",/^at/,0)){const a=it();return a||n("Missing positioning value"),a}}function it(){const a=Re();if(a.x||a.y)return{type:"position",value:a}}function Re(){return{x:j(),y:j()}}function B(a){let u=a();const d=[];if(u)for(d.push(u);v(t.comma);)u=a(),u?d.push(u):n("One extra comma");return d}function Ee(){const a=De();return a||n("Expected color definition"),a.length=j(),a}function De(){return Ge()||Ae()||Pe()||Ie()||ke()||Ve()||Le()}function Le(){return y("literal",t.literalColor,0)}function Ge(){return y("hex",t.hexColor,1)}function ke(){return l(t.rgbColor,()=>({type:"rgb",value:B(P)}))}function Ie(){return l(t.rgbaColor,()=>({type:"rgba",value:B(P)}))}function Ve(){return l(t.varColor,()=>({type:"var",value:Me()}))}function Pe(){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 u=P();v(t.comma);let d=v(t.percentageValue);const p=d?d[1]:null;v(t.comma),d=v(t.percentageValue);const R=d?d[1]:null;return(!p||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,p,R]}})}function Ae(){return l(t.hslaColor,()=>{const a=P();v(t.comma);let u=v(t.percentageValue);const d=u?u[1]:null;v(t.comma),u=v(t.percentageValue);const p=u?u[1]:null;v(t.comma);const R=P();return(!d||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,d,p,R]}})}function Me(){return v(t.variableName)[1]}function P(){return v(t.number)[1]}function j(){return y("%",t.percentageValue,1)||Te()||$e()||se()}function Te(){return y("position-keyword",t.positionKeywords,1)}function $e(){return l(t.calcValue,()=>{let a=1,u=0;for(;a>0&&u<e.length;){const p=e.charAt(u);p==="("?a++:p===")"&&a--,u++}a>0&&n("Missing closing parenthesis in calc() expression");const d=e.substring(0,u-1);return ot(u-1),{type:"calc",value:d}})}function se(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(a,u,d){const p=v(u);if(p)return{type:a,value:p[d]}}function v(a){let u,d;return d=/^\s+/.exec(e),d&&ot(d[0].length),u=a.exec(e),u&&ot(u[0].length),u}function ot(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const zt=$.parse.bind($);var H=H||{};H.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,f){n+=t.visit(i),f<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 be=H.stringify.bind(H);function _t(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let f=N(r/e,3),s="#00000000";switch(n.type){case"rgb":s=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":s=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":s=b(n.value);break;case"hex":s=b(`#${n.value}`);break}switch(n.length?.type){case"%":f=Number(n.length.value)/100;break}return{offset:f,color:s}})}function Ft(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:_t(t.colorStops)}}function Nt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:_t(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Ot(t){return zt(t).map(e=>{switch(e?.type){case"linear-gradient":return Ft(e);case"repeating-linear-gradient":return{...Ft(e),repeat:!0};case"radial-gradient":return Nt(e);case"repeating-radial-gradient":return{...Nt(e),repeat:!0};default:return}}).filter(Boolean)}function Rt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function Et(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Ot(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Dt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Lt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:g(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:g(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Gt(t){return!g(t.color)}function kt(t){return typeof t=="string"?wt(t):Gt(t)}function It(t){return!g(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):It(t)}function Pt(t){return!g(t.image)&&!I(t.image)}function At(t){return typeof t=="string"?!I(t):Pt(t)}function Mt(t){return!g(t.preset)}function Tt(t){return typeof t=="string"?!1:Mt(t)}function F(t){return kt(t)?Rt(t):Vt(t)?Et(t):At(t)?Dt(t):Tt(t)?Lt(t):{}}function $t(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["fillWithShape"])}}const Ht=new Ct;function q(t){let e=Ht.get(t);if(!e){const n=Object.getPrototypeOf(t);e=new Map(n?q(n):void 0),Ht.set(t,e)}return e}function Wt(t,e,n={}){q(t).set(e,n);const{default:r,alias:i}=n,f=Symbol.for(String(e)),s=()=>typeof r=="function"?r():r,l=Object.getOwnPropertyDescriptor(t.prototype,e)||{get(){return i&&i!==e?typeof i=="string"?yt(this,i):this[i]:typeof e=="string"&&this.offsetGet?this.offsetGet(e):this[f]},set(c){i&&i!==e?typeof i=="string"?St(this,i,c):this[i]=c:typeof e=="string"&&this.offsetSet?this.offsetSet(e,c):this[f]=c}};Object.defineProperty(t.prototype,e,{get(){let c=l.get?.call(this);return c===void 0&&(c=s(),c!==void 0&&l.set?.call(this,c)),c},set(c){let h=l.get?.call(this);h===void 0&&(h=s()),l.set?.call(this,c),this.requestUpdate?.(e,c,h,n)},configurable:!0,enumerable:!0})}function ye(t){return function(e,n){Wt(e.constructor,n,t)}}function U(){return{color:k,offsetX:0,offsetY:0,blurRadius:1}}function Z(t){return{...U(),...O({...t,color:g(t.color)?k:b(t.color)})}}function Bt(){return{...U(),scaleX:1,scaleY:1}}function jt(t){return{...Bt(),...Z(t)}}function Se(t){return t}function xt(t){return O({...t,softEdge:g(t.softEdge)?void 0:t.softEdge,outerShadow:g(t.outerShadow)?void 0:jt(t.outerShadow),innerShadow:g(t.innerShadow)?void 0:Z(t.innerShadow)})}function Kt(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["fillWithShape"])}}function Xt(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["width","style","headEnd","tailEnd"])}}function Yt(t){return typeof t=="string"?{color:b(t)}:{...t,color:g(t.color)?k:b(t.color)}}function qt(){return{boxShadow:"none"}}function Ut(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 Zt(){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 Jt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Qt(){return{...Zt(),...Jt(),...qt(),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 te(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ee(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ne(){return{...te(),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 re(){return{...ee(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ie(){return{...re(),...ne(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function D(t){return O({...t,color:g(t.color)?void 0:b(t.color),backgroundColor:g(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:g(t.borderColor)?void 0:b(t.borderColor),outlineColor:g(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:g(t.shadowColor)?void 0:b(t.shadowColor)})}function Ce(){return{...Qt(),...ie()}}const J=/\r\n|\n\r|\n|\r/,we=new RegExp(`${J.source}|<br\\/>`,"g"),ze=new RegExp(`^(${J.source})$`),W=`
2
+ `;function _e(t){return J.test(t)}function Q(t){return ze.test(t)}function oe(t){return t.replace(we,W)}function ae(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function V(t){const e=[];function n(){return e[e.length-1]}function r(l={}){let c=e[e.length-1];return c?.fragments.length===0?(c={...l,fragments:[]},e[e.length-1]=c):(c={...l,fragments:[]},e.push(c)),c}function i(l="",c={}){Array.from(l).forEach(h=>{if(Q(h)){const{fragments:C,...z}=n()||r();C.length||C.push({...c,content:W}),r(z)}else{const C=n()||r(),z=C.fragments[C.fragments.length-1];if(z){const{content:L,...et}=z;if(ae(c,et)){z.content=`${L}${h}`;return}}C.fragments.push({...c,content:h})}})}(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l=="string")r(),i(l);else if("content"in l){const{content:c,...h}=l;r(D(h)),i(c)}else if("fragments"in l){const{fragments:c,...h}=l;r(D(h)),c.forEach(C=>{const{content:z,...L}=C;i(z,D(L))})}else Array.isArray(l)?(r(),l.forEach(c=>{if(typeof c=="string")i(c);else{const{content:h,...C}=c;i(h,D(C))}})):console.warn("Failed to parse text content",l)});const s=n();return s&&!s.fragments.length&&s.fragments.push({content:W}),e}function ue(t){return typeof t=="string"?{content:V(t)}:"content"in t?{...t,content:V(t.content)}:{content:V(t)}}function Fe(t){return V(t).map(e=>{const n=oe(e.fragments.flatMap(r=>r.content).join(""));return Q(n)?"":n}).join(W)}function le(t){return typeof t=="string"?{src:t}:t}function tt(t){return O({...t,style:g(t.style)?void 0:D(t.style),text:g(t.text)?void 0:ue(t.text),background:g(t.background)?void 0:$t(t.background),shape:g(t.shape)?void 0:Ut(t.shape),fill:g(t.fill)?void 0:F(t.fill),outline:g(t.outline)?void 0:Xt(t.outline),foreground:g(t.foreground)?void 0:Kt(t.foreground),shadow:g(t.shadow)?void 0:Yt(t.shadow),video:g(t.video)?void 0:le(t.video),audio:g(t.audio)?void 0:E(t.audio),effect:g(t.effect)?void 0:xt(t.effect),children:t.children?.map(e=>tt(e))})}function Ne(t){return tt(t)}o.RawWeakMap=Ct,o.clearUndef=O,o.defaultColor=k,o.defineProperty=Wt,o.getDeclarations=q,o.getDefaultElementStyle=Qt,o.getDefaultHighlightStyle=te,o.getDefaultInnerShadow=U,o.getDefaultLayoutStyle=Zt,o.getDefaultListStyleStyle=ee,o.getDefaultOuterShadow=Bt,o.getDefaultShadowStyle=qt,o.getDefaultStyle=Ce,o.getDefaultTextInlineStyle=ne,o.getDefaultTextLineStyle=re,o.getDefaultTextStyle=ie,o.getDefaultTransformStyle=Jt,o.getNestedValue=pt,o.getObjectValueByPath=yt,o.hasCRLF=_e,o.isCRLF=Q,o.isColor=wt,o.isColorFill=kt,o.isColorFillObject=Gt,o.isEqualStyle=ae,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=It,o.isImageFill=At,o.isImageFillObject=Pt,o.isNone=g,o.isPresetFill=Tt,o.isPresetFillObject=Mt,o.normalizeAudio=E,o.normalizeBackground=$t,o.normalizeCRLF=oe,o.normalizeColor=b,o.normalizeColorFill=Rt,o.normalizeDocument=Ne,o.normalizeEffect=xt,o.normalizeElement=tt,o.normalizeFill=F,o.normalizeForeground=Kt,o.normalizeGradient=Ot,o.normalizeGradientFill=Et,o.normalizeImageFill=Dt,o.normalizeInnerShadow=Z,o.normalizeOuterShadow=jt,o.normalizeOutline=Xt,o.normalizePresetFill=Lt,o.normalizeShadow=Yt,o.normalizeShape=Ut,o.normalizeSoftEdge=Se,o.normalizeStyle=D,o.normalizeText=ue,o.normalizeTextContent=V,o.normalizeVideo=le,o.parseColor=Y,o.parseGradient=zt,o.pick=M,o.property=ye,o.round=N,o.setNestedValue=bt,o.setObjectValueByPath=St,o.stringifyGradient=be,o.textContentToString=Fe,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -902,26 +902,39 @@ function defineProperty(constructor, key, declaration = {}) {
902
902
  getDeclarations(constructor).set(key, declaration);
903
903
  const {
904
904
  default: defaultValue,
905
- alias = key
905
+ alias
906
906
  } = declaration;
907
- const _alias = alias === key ? Symbol.for(String(alias)) : alias;
907
+ const internalKey = Symbol.for(String(key));
908
908
  const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
909
909
  const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key) || {
910
910
  get() {
911
- if (typeof _alias === "string") {
912
- return this.offsetGet ? this.offsetGet(_alias) : getObjectValueByPath(this, _alias);
911
+ if (alias && alias !== key) {
912
+ if (typeof alias === "string") {
913
+ return getObjectValueByPath(this, alias);
914
+ } else {
915
+ return this[alias];
916
+ }
913
917
  } else {
914
- return this[_alias];
918
+ if (typeof key === "string" && this.offsetGet) {
919
+ return this.offsetGet(key);
920
+ } else {
921
+ return this[internalKey];
922
+ }
915
923
  }
916
924
  },
917
925
  set(value) {
918
- if (typeof _alias === "string") {
919
- if (this.offsetSet) {
920
- this.offsetSet(_alias, value);
926
+ if (alias && alias !== key) {
927
+ if (typeof alias === "string") {
928
+ setObjectValueByPath(this, alias, value);
929
+ } else {
930
+ this[alias] = value;
921
931
  }
922
- setObjectValueByPath(this, _alias, value);
923
932
  } else {
924
- this[_alias] = value;
933
+ if (typeof key === "string" && this.offsetSet) {
934
+ this.offsetSet(key, value);
935
+ } else {
936
+ this[internalKey] = value;
937
+ }
925
938
  }
926
939
  }
927
940
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.6.18",
4
+ "version": "0.6.19",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",