@mlightcad/common 1.2.5 → 1.2.7
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/common.js +935 -395
- package/dist/common.umd.cjs +1 -1
- package/lib/AcCmColor.d.ts +106 -132
- package/lib/AcCmColor.d.ts.map +1 -1
- package/lib/AcCmColor.js +356 -493
- package/lib/AcCmColor.js.map +1 -1
- package/lib/AcCmColorMethod.d.ts +17 -0
- package/lib/AcCmColorMethod.d.ts.map +1 -0
- package/lib/AcCmColorMethod.js +18 -0
- package/lib/AcCmColorMethod.js.map +1 -0
- package/lib/AcCmColorUtil.d.ts +45 -12
- package/lib/AcCmColorUtil.d.ts.map +1 -1
- package/lib/AcCmColorUtil.js +254 -15
- package/lib/AcCmColorUtil.js.map +1 -1
- package/lib/AcCmEntityColor.d.ts +119 -0
- package/lib/AcCmEntityColor.d.ts.map +1 -0
- package/lib/AcCmEntityColor.js +198 -0
- package/lib/AcCmEntityColor.js.map +1 -0
- package/lib/AcCmLodashUtils.d.ts +6 -0
- package/lib/AcCmLodashUtils.d.ts.map +1 -1
- package/lib/AcCmLodashUtils.js +31 -0
- package/lib/AcCmLodashUtils.js.map +1 -1
- package/lib/AcCmTransparency.d.ts +201 -0
- package/lib/AcCmTransparency.d.ts.map +1 -0
- package/lib/AcCmTransparency.js +315 -0
- package/lib/AcCmTransparency.js.map +1 -0
- package/lib/AcCmTransparencyMethod.d.ts +16 -0
- package/lib/AcCmTransparencyMethod.d.ts.map +1 -0
- package/lib/AcCmTransparencyMethod.js +17 -0
- package/lib/AcCmTransparencyMethod.js.map +1 -0
- package/lib/index.d.ts +6 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/dist/common.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
function
|
|
1
|
+
function W(r, e) {
|
|
2
2
|
for (var t = 0; t < e.length; t++) {
|
|
3
|
-
const
|
|
4
|
-
if (typeof
|
|
5
|
-
for (const o in
|
|
6
|
-
if (o !== "default" && !(o in
|
|
7
|
-
const i = Object.getOwnPropertyDescriptor(
|
|
8
|
-
i && Object.defineProperty(
|
|
3
|
+
const s = e[t];
|
|
4
|
+
if (typeof s != "string" && !Array.isArray(s)) {
|
|
5
|
+
for (const o in s)
|
|
6
|
+
if (o !== "default" && !(o in r)) {
|
|
7
|
+
const i = Object.getOwnPropertyDescriptor(s, o);
|
|
8
|
+
i && Object.defineProperty(r, o, i.get ? i : {
|
|
9
9
|
enumerable: !0,
|
|
10
|
-
get: () =>
|
|
10
|
+
get: () => s[o]
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
return Object.freeze(Object.defineProperty(
|
|
15
|
+
return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
var n = /* @__PURE__ */ ((r) => (r[r.ByColor = 1] = "ByColor", r[r.ByACI = 2] = "ByACI", r[r.ByLayer = 3] = "ByLayer", r[r.ByBlock = 4] = "ByBlock", r[r.None = 0] = "None", r))(n || {});
|
|
18
|
+
const G = {
|
|
18
19
|
aliceblue: 15792383,
|
|
19
20
|
antiquewhite: 16444375,
|
|
20
21
|
aqua: 65535,
|
|
@@ -159,7 +160,7 @@ const I = {
|
|
|
159
160
|
whitesmoke: 16119285,
|
|
160
161
|
yellow: 16776960,
|
|
161
162
|
yellowgreen: 10145074
|
|
162
|
-
},
|
|
163
|
+
}, N = [
|
|
163
164
|
0,
|
|
164
165
|
16711680,
|
|
165
166
|
16776960,
|
|
@@ -418,266 +419,543 @@ const I = {
|
|
|
418
419
|
16777215,
|
|
419
420
|
0
|
|
420
421
|
];
|
|
421
|
-
|
|
422
|
-
return Math.max(e, Math.min(t, n));
|
|
423
|
-
}
|
|
424
|
-
const C = class C {
|
|
422
|
+
class b {
|
|
425
423
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
424
|
+
* Returns the RGB color value for a given AutoCAD color index.
|
|
425
|
+
*
|
|
426
|
+
* @param {number} index - The AutoCAD color index value (0-255).
|
|
427
|
+
* @returns {number} The RGB color value as a 24-bit integer.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* // Get the RGB value for color index 1 (red)
|
|
432
|
+
* const redColor = AcCmColorUtil.getAcadColor(1); // returns 16711680 (0xFF0000)
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```typescript
|
|
437
|
+
* // Get special inheritance colors
|
|
438
|
+
* const byBlock = AcCmColorUtil.getAcadColor(0); // "ByBlock" color
|
|
439
|
+
* const byLayer = AcCmColorUtil.getAcadColor(256); // "ByLayer" color
|
|
440
|
+
* ```
|
|
428
441
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
442
|
+
static getColorByIndex(e) {
|
|
443
|
+
return N[e];
|
|
431
444
|
}
|
|
432
445
|
/**
|
|
433
|
-
*
|
|
446
|
+
* Finds the AutoCAD color index associated with a given RGB value.
|
|
434
447
|
*
|
|
435
|
-
* @
|
|
448
|
+
* @private
|
|
449
|
+
* @param {number} color - The RGB value to find an index for.
|
|
450
|
+
* @returns {number | undefined} The color index if found, undefined otherwise.
|
|
436
451
|
*/
|
|
437
|
-
|
|
438
|
-
|
|
452
|
+
static getIndexByColor(e) {
|
|
453
|
+
const t = N.length - 1;
|
|
454
|
+
for (let s = 1; s < t; ++s)
|
|
455
|
+
if (N[s] === e)
|
|
456
|
+
return s;
|
|
439
457
|
}
|
|
440
458
|
/**
|
|
441
|
-
*
|
|
459
|
+
* Returns the RGB color value for a given CSS color name.
|
|
460
|
+
*
|
|
461
|
+
* @param {string} name - The CSS color name (e.g., "red", "blue", "aliceblue").
|
|
462
|
+
* @returns {number | undefined} The RGB color value as a 24-bit integer, or undefined if the name is not found.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* // Get the RGB value for a standard color name
|
|
467
|
+
* const redColor = AcCmColorUtil.getColorByName("red"); // returns 16711680 (0xFF0000)
|
|
468
|
+
* const blueColor = AcCmColorUtil.getColorByName("blue"); // returns 255 (0x0000FF)
|
|
469
|
+
* ```
|
|
442
470
|
*
|
|
443
|
-
* @
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* // Handle undefined for unknown color names
|
|
474
|
+
* const unknownColor = AcCmColorUtil.getColorByName("unknown"); // returns undefined
|
|
475
|
+
* ```
|
|
444
476
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
477
|
+
static getColorByName(e) {
|
|
478
|
+
return G[e.toLowerCase()];
|
|
447
479
|
}
|
|
448
480
|
/**
|
|
449
|
-
*
|
|
481
|
+
* Finds the color name associated with a given RGB value.
|
|
450
482
|
*
|
|
451
|
-
* @
|
|
483
|
+
* @param {number} rgb - The RGB value to find a name for.
|
|
484
|
+
* @returns {string | undefined} The color name if found, undefined otherwise.
|
|
452
485
|
*/
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
e = "0" + e;
|
|
458
|
-
return `0x${e}`;
|
|
459
|
-
}
|
|
460
|
-
return "";
|
|
486
|
+
static getNameByColor(e) {
|
|
487
|
+
for (const [t, s] of Object.entries(G))
|
|
488
|
+
if (s === e)
|
|
489
|
+
return t;
|
|
461
490
|
}
|
|
462
491
|
/**
|
|
463
|
-
*
|
|
492
|
+
* Finds the color name associated with a given color index.
|
|
464
493
|
*
|
|
465
|
-
* @
|
|
494
|
+
* @param {number} index - The color index to find a name for.
|
|
495
|
+
* @returns {string | undefined} The color name if found, undefined otherwise.
|
|
466
496
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
497
|
+
static getNameByIndex(e) {
|
|
498
|
+
const t = this.getColorByIndex(e);
|
|
499
|
+
return this.getNameByColor(t);
|
|
469
500
|
}
|
|
501
|
+
}
|
|
502
|
+
class B {
|
|
470
503
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @
|
|
504
|
+
* Constructs a new AcCmColor.
|
|
505
|
+
* @param method Initial color method (defaults to `ByColor`)
|
|
506
|
+
* @param value Internal packed value
|
|
474
507
|
*/
|
|
475
|
-
|
|
476
|
-
|
|
508
|
+
constructor(e = n.ByLayer, t) {
|
|
509
|
+
this._colorMethod = e, this._colorMethod == n.ByColor && t == null ? this._value = 16777215 : this._colorMethod == n.ByACI ? t == null ? this._value = 8 : t === 0 ? this._colorMethod = n.ByBlock : t === 256 ? this._colorMethod = n.ByLayer : this._value = Math.max(0, Math.min(t, 256)) : this._value = t;
|
|
510
|
+
}
|
|
511
|
+
// ---------------------------------------------------------------------
|
|
512
|
+
// Color method
|
|
513
|
+
// ---------------------------------------------------------------------
|
|
514
|
+
/** Gets the current color method. */
|
|
515
|
+
get colorMethod() {
|
|
516
|
+
return this._colorMethod;
|
|
477
517
|
}
|
|
478
518
|
/**
|
|
479
|
-
*
|
|
519
|
+
* Sets the color method.
|
|
480
520
|
*
|
|
481
|
-
*
|
|
521
|
+
* Note: Changing the method does not modify `_value`.
|
|
482
522
|
*/
|
|
523
|
+
set colorMethod(e) {
|
|
524
|
+
this._colorMethod = e;
|
|
525
|
+
}
|
|
526
|
+
// ---------------------------------------------------------------------
|
|
527
|
+
// RGB accessors (ByColor)
|
|
528
|
+
// ---------------------------------------------------------------------
|
|
529
|
+
/** Gets the red component (0–255). */
|
|
530
|
+
get red() {
|
|
531
|
+
const e = this.RGB;
|
|
532
|
+
return e != null ? e >> 16 & 255 : void 0;
|
|
533
|
+
}
|
|
534
|
+
/** Gets the green component (0–255). */
|
|
483
535
|
get green() {
|
|
484
|
-
|
|
536
|
+
const e = this.RGB;
|
|
537
|
+
return e != null ? e >> 8 & 255 : void 0;
|
|
538
|
+
}
|
|
539
|
+
/** Gets the blue component (0–255). */
|
|
540
|
+
get blue() {
|
|
541
|
+
const e = this.RGB;
|
|
542
|
+
return e != null ? e & 255 : void 0;
|
|
485
543
|
}
|
|
486
544
|
/**
|
|
487
|
-
* Gets the
|
|
545
|
+
* Gets the packed RGB value (0xRRGGBB).
|
|
488
546
|
*
|
|
489
|
-
*
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
547
|
+
* - For `ByColor`, returns `_value` directly
|
|
548
|
+
* - For `ByACI`, converts index to RGB via `AcCmColorUtil`
|
|
549
|
+
* - For `ByLayer` or `ByBlock`, returns `_value` directly
|
|
550
|
+
*/
|
|
551
|
+
get RGB() {
|
|
552
|
+
switch (this._colorMethod) {
|
|
553
|
+
case n.ByColor:
|
|
554
|
+
case n.ByBlock:
|
|
555
|
+
case n.ByLayer:
|
|
556
|
+
return this._value;
|
|
557
|
+
case n.ByACI:
|
|
558
|
+
return this._value ? b.getColorByIndex(this._value) : this._value;
|
|
559
|
+
default:
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
493
562
|
}
|
|
494
563
|
/**
|
|
495
|
-
*
|
|
496
|
-
* 0 and 256 are special values.
|
|
564
|
+
* Sets the RGB color.
|
|
497
565
|
*
|
|
498
|
-
* @
|
|
566
|
+
* @param r Red component (0–255)
|
|
567
|
+
* @param g Green component (0–255)
|
|
568
|
+
* @param b Blue component (0–255)
|
|
569
|
+
* @returns The current instance for chaining
|
|
499
570
|
*/
|
|
500
|
-
|
|
501
|
-
|
|
571
|
+
setRGB(e, t, s) {
|
|
572
|
+
const o = Math.max(0, Math.min(255, Math.round(e))), i = Math.max(0, Math.min(255, Math.round(t))), a = Math.max(0, Math.min(255, Math.round(s)));
|
|
573
|
+
return this._value = o << 16 | i << 8 | a, this._colorMethod = n.ByColor, this;
|
|
502
574
|
}
|
|
503
575
|
/**
|
|
504
|
-
* Sets the
|
|
505
|
-
* 256 is set, 256 will be used.
|
|
506
|
-
* - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
|
|
507
|
-
* is not displayed through a block reference (for example, it is directly owned by the model space
|
|
508
|
-
* block table record) and its color is 0, then it will display as though its color were 7.
|
|
509
|
-
* - 256 indicates that the entity uses the color specified in the layer table record it references.
|
|
576
|
+
* Sets the RGB color by a single packed number (0xRRGGBB).
|
|
510
577
|
*
|
|
511
|
-
* @param
|
|
578
|
+
* @param value Packed RGB number
|
|
512
579
|
*/
|
|
513
|
-
|
|
514
|
-
e == null
|
|
580
|
+
setRGBValue(e) {
|
|
581
|
+
return e == null || !Number.isFinite(e) ? (console.warn("Invalid RGB value:", e), this) : (this._value = e & 16777215, this._colorMethod = n.ByColor, this);
|
|
515
582
|
}
|
|
516
583
|
/**
|
|
517
|
-
*
|
|
584
|
+
* Sets the RGB color from a CSS color string.
|
|
518
585
|
*
|
|
519
|
-
*
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
586
|
+
* Examples:
|
|
587
|
+
* - "#FF00FF"
|
|
588
|
+
* - "#F0F"
|
|
589
|
+
* - "rgb(255,0,255)"
|
|
590
|
+
* - "rgba(255,0,255,0.5)"
|
|
591
|
+
* - "red" (named colors)
|
|
592
|
+
*
|
|
593
|
+
* @param cssString CSS color string
|
|
594
|
+
* @returns The current instance for chaining
|
|
595
|
+
*/
|
|
596
|
+
setRGBFromCss(e) {
|
|
597
|
+
if (!e) return this;
|
|
598
|
+
const t = e.trim().toLowerCase();
|
|
599
|
+
if (t.startsWith("#")) {
|
|
600
|
+
let i = 0, a = 0, c = 0;
|
|
601
|
+
if (t.length === 7)
|
|
602
|
+
i = parseInt(t.substr(1, 2), 16), a = parseInt(t.substr(3, 2), 16), c = parseInt(t.substr(5, 2), 16);
|
|
603
|
+
else if (t.length === 4)
|
|
604
|
+
i = parseInt(t[1] + t[1], 16), a = parseInt(t[2] + t[2], 16), c = parseInt(t[3] + t[3], 16);
|
|
605
|
+
else
|
|
606
|
+
return console.warn("Invalid hex color:", e), this;
|
|
607
|
+
return this.setRGB(i, a, c);
|
|
608
|
+
}
|
|
609
|
+
const s = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
610
|
+
if (s) {
|
|
611
|
+
const i = parseInt(s[1], 10), a = parseInt(s[2], 10), c = parseInt(s[3], 10);
|
|
612
|
+
return this.setRGB(i, a, c);
|
|
613
|
+
}
|
|
614
|
+
const o = b.getColorByName(e);
|
|
615
|
+
return o !== void 0 ? this.setRGBValue(o) : (console.warn("Unknown CSS color string:", e), this);
|
|
523
616
|
}
|
|
524
617
|
/**
|
|
525
|
-
* Sets the color
|
|
618
|
+
* Sets the color as a scalar grayscale value.
|
|
526
619
|
*
|
|
527
|
-
* @param
|
|
620
|
+
* @param scalar Scalar value (0–255)
|
|
621
|
+
* @returns The current instance for chaining
|
|
528
622
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const t = I[e.toLowerCase()];
|
|
532
|
-
t !== void 0 ? (this._colorName = e, this._color = t, this._colorIndex = this.getColorIndexByValue(this._color)) : console.warn("Unknown color: " + e);
|
|
533
|
-
} else
|
|
534
|
-
this._colorName = null;
|
|
623
|
+
setScalar(e) {
|
|
624
|
+
return this.setRGB(e, e, e);
|
|
535
625
|
}
|
|
536
626
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
* @returns {boolean} True if the color has no name, false otherwise.
|
|
627
|
+
* Gets the hexadecimal representation of the color (e.g., "0xFF00FF").
|
|
540
628
|
*/
|
|
541
|
-
get
|
|
542
|
-
|
|
629
|
+
get hexColor() {
|
|
630
|
+
const e = this.RGB;
|
|
631
|
+
return e == null ? void 0 : "0x" + e.toString(16).padStart(6, "0").toUpperCase();
|
|
543
632
|
}
|
|
544
633
|
/**
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* @returns {boolean} True if the color has no index, false otherwise.
|
|
634
|
+
* Gets the CSS RGB color string (e.g., "rgb(255,0,255)").
|
|
548
635
|
*/
|
|
549
|
-
get
|
|
550
|
-
|
|
636
|
+
get cssColor() {
|
|
637
|
+
const e = this.RGB;
|
|
638
|
+
if (e != null)
|
|
639
|
+
return `rgb(${e >> 16 & 255},${e >> 8 & 255},${e & 255})`;
|
|
640
|
+
}
|
|
641
|
+
// ---------------------------------------------------------------------
|
|
642
|
+
// ACI accessors (ByACI)
|
|
643
|
+
// ---------------------------------------------------------------------
|
|
644
|
+
/** Gets the AutoCAD Color Index (ACI), or undefined if not ByACI, ByBlock, or ByLayer. */
|
|
645
|
+
get colorIndex() {
|
|
646
|
+
return this._colorMethod === n.ByACI ? this._value : this._colorMethod === n.ByLayer ? 256 : this._colorMethod === n.ByBlock ? 0 : void 0;
|
|
551
647
|
}
|
|
552
648
|
/**
|
|
553
|
-
*
|
|
649
|
+
* Sets the AutoCAD Color Index (0–256).
|
|
650
|
+
*
|
|
651
|
+
* - 0 sets the color method to `ByBlock`
|
|
652
|
+
* - 256 sets the color method to `ByLayer`
|
|
653
|
+
* - 1–255 sets the color method to `ByACI`
|
|
554
654
|
*
|
|
555
|
-
* @
|
|
655
|
+
* @param index ACI index
|
|
556
656
|
*/
|
|
557
|
-
|
|
558
|
-
|
|
657
|
+
set colorIndex(e) {
|
|
658
|
+
if (e == null) return;
|
|
659
|
+
const t = Math.max(0, Math.min(256, Math.round(e)));
|
|
660
|
+
t === 0 ? (this._colorMethod = n.ByBlock, this._value = void 0) : t === 256 ? (this._colorMethod = n.ByLayer, this._value = void 0) : (this._colorMethod = n.ByACI, this._value = t);
|
|
559
661
|
}
|
|
560
662
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* @returns {AcCmColor} The current instance.
|
|
663
|
+
* Returns true if the color method is ByColor (explicit RGB).
|
|
564
664
|
*/
|
|
565
|
-
|
|
566
|
-
return this.
|
|
665
|
+
get isByColor() {
|
|
666
|
+
return this._colorMethod === n.ByColor;
|
|
567
667
|
}
|
|
568
668
|
/**
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
* @returns {boolean} True if the color is "ByBlock", false otherwise.
|
|
669
|
+
* Returns true if the color method is ByACI.
|
|
572
670
|
*/
|
|
573
|
-
get
|
|
574
|
-
return this.
|
|
671
|
+
get isByACI() {
|
|
672
|
+
return this._colorMethod === n.ByACI;
|
|
673
|
+
}
|
|
674
|
+
// ---------------------------------------------------------------------
|
|
675
|
+
// Layer / Block helpers
|
|
676
|
+
// ---------------------------------------------------------------------
|
|
677
|
+
/** Returns true if the color method is ByLayer. */
|
|
678
|
+
get isByLayer() {
|
|
679
|
+
return this._colorMethod === n.ByLayer;
|
|
575
680
|
}
|
|
576
681
|
/**
|
|
577
|
-
* Sets the color to
|
|
578
|
-
*
|
|
579
|
-
* @returns {AcCmColor} The current instance.
|
|
682
|
+
* Sets the color to ByLayer.
|
|
683
|
+
* @param value - Option layer color value
|
|
580
684
|
*/
|
|
581
|
-
|
|
582
|
-
return this.
|
|
685
|
+
setByLayer(e) {
|
|
686
|
+
return this._colorMethod = n.ByLayer, e == null ? this._value = 256 : this._value = e, this;
|
|
687
|
+
}
|
|
688
|
+
/** Returns true if the color method is ByBlock. */
|
|
689
|
+
get isByBlock() {
|
|
690
|
+
return this._colorMethod === n.ByBlock;
|
|
583
691
|
}
|
|
584
692
|
/**
|
|
585
|
-
* Sets the color
|
|
586
|
-
*
|
|
587
|
-
* @param {number} scalar - The scalar value (0-255).
|
|
588
|
-
* @returns {AcCmColor} The current instance.
|
|
693
|
+
* Sets the color to ByBlock.
|
|
694
|
+
* @param value - Option layer color value
|
|
589
695
|
*/
|
|
590
|
-
|
|
591
|
-
return this.
|
|
696
|
+
setByBlock(e) {
|
|
697
|
+
return this._colorMethod = n.ByBlock, e == null ? this._value = 0 : this._value = e, this;
|
|
592
698
|
}
|
|
699
|
+
// ---------------------------------------------------------------------
|
|
700
|
+
// Color name (dynamic)
|
|
701
|
+
// ---------------------------------------------------------------------
|
|
593
702
|
/**
|
|
594
|
-
*
|
|
703
|
+
* Gets the color name.
|
|
595
704
|
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
* @param {number} b - The blue component (0-255).
|
|
599
|
-
* @returns {AcCmColor} The current instance.
|
|
705
|
+
* For `ByColor` or `ByACI`, resolves the name via `AcCmColorUtil`.
|
|
706
|
+
* For `ByLayer` or `ByBlock`, returns the corresponding string.
|
|
600
707
|
*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
708
|
+
get colorName() {
|
|
709
|
+
switch (this._colorMethod) {
|
|
710
|
+
case n.ByLayer:
|
|
711
|
+
return "ByLayer";
|
|
712
|
+
case n.ByBlock:
|
|
713
|
+
return "ByBlock";
|
|
714
|
+
case n.ByColor:
|
|
715
|
+
return this._value ? b.getNameByColor(this._value) : "";
|
|
716
|
+
case n.ByACI:
|
|
717
|
+
return this._value ? b.getNameByIndex(this._value) : "";
|
|
718
|
+
default:
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
604
721
|
}
|
|
605
722
|
/**
|
|
606
723
|
* Sets the color by name.
|
|
607
724
|
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
725
|
+
* Resolves the name to an RGB value via `AcCmColorUtil`.
|
|
726
|
+
*
|
|
727
|
+
* @param name Color name
|
|
610
728
|
*/
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
729
|
+
set colorName(e) {
|
|
730
|
+
if (!e) return;
|
|
731
|
+
const t = b.getColorByName(e);
|
|
732
|
+
t !== void 0 ? (this._value = t, this._colorMethod = n.ByColor) : console.warn("Unknown color name:", e);
|
|
614
733
|
}
|
|
734
|
+
// ---------------------------------------------------------------------
|
|
735
|
+
// Clone / Copy / Equals
|
|
736
|
+
// ---------------------------------------------------------------------
|
|
615
737
|
/**
|
|
616
|
-
*
|
|
738
|
+
* Creates a clone of this color instance.
|
|
617
739
|
*
|
|
618
|
-
* @returns
|
|
740
|
+
* @returns A new AcCmColor instance with the same method and value
|
|
619
741
|
*/
|
|
620
742
|
clone() {
|
|
621
|
-
const e = new
|
|
622
|
-
return e.
|
|
743
|
+
const e = new B();
|
|
744
|
+
return e._colorMethod = this._colorMethod, e._value = this._value, e;
|
|
623
745
|
}
|
|
624
746
|
/**
|
|
625
|
-
* Copies
|
|
747
|
+
* Copies color values from another AcCmColor instance.
|
|
626
748
|
*
|
|
627
|
-
* @param
|
|
628
|
-
* @returns
|
|
749
|
+
* @param other The source color
|
|
750
|
+
* @returns The current instance
|
|
629
751
|
*/
|
|
630
752
|
copy(e) {
|
|
631
|
-
return this.
|
|
753
|
+
return this._colorMethod = e._colorMethod, this._value = e._value, this;
|
|
632
754
|
}
|
|
633
755
|
/**
|
|
634
|
-
* Checks
|
|
756
|
+
* Checks equality with another color.
|
|
635
757
|
*
|
|
636
|
-
* @param
|
|
637
|
-
* @returns
|
|
758
|
+
* @param other The color to compare
|
|
759
|
+
* @returns True if color method and value are identical
|
|
638
760
|
*/
|
|
639
761
|
equals(e) {
|
|
640
|
-
return
|
|
762
|
+
return this._colorMethod === e._colorMethod && this._value === e._value;
|
|
641
763
|
}
|
|
764
|
+
// ---------------------------------------------------------------------
|
|
765
|
+
// String representation
|
|
766
|
+
// ---------------------------------------------------------------------
|
|
642
767
|
/**
|
|
643
768
|
* Returns a string representation of the color.
|
|
644
769
|
*
|
|
645
|
-
*
|
|
770
|
+
* - "ByLayer" for ByLayer colors
|
|
771
|
+
* - "ByBlock" for ByBlock colors
|
|
772
|
+
* - One number for color index
|
|
773
|
+
* - Three comma-separated numbers for RGB color
|
|
646
774
|
*/
|
|
647
775
|
toString() {
|
|
648
|
-
|
|
776
|
+
switch (this._colorMethod) {
|
|
777
|
+
case n.ByLayer:
|
|
778
|
+
return "ByLayer";
|
|
779
|
+
case n.ByBlock:
|
|
780
|
+
return "ByBlock";
|
|
781
|
+
case n.ByACI:
|
|
782
|
+
return this._value !== void 0 ? String(this._value) : "";
|
|
783
|
+
case n.ByColor:
|
|
784
|
+
return this._value ? `${this.red},${this.green},${this.blue}` : "";
|
|
785
|
+
default:
|
|
786
|
+
return "";
|
|
787
|
+
}
|
|
649
788
|
}
|
|
650
789
|
/**
|
|
651
|
-
*
|
|
790
|
+
* Creates one AcCmColor from one string
|
|
791
|
+
*/
|
|
792
|
+
static fromString(e) {
|
|
793
|
+
if (!e) return;
|
|
794
|
+
const t = e.trim();
|
|
795
|
+
if (/^bylayer$/i.test(t))
|
|
796
|
+
return new B(n.ByLayer);
|
|
797
|
+
if (/^byblock$/i.test(t))
|
|
798
|
+
return new B(n.ByBlock);
|
|
799
|
+
if (/^\d{1,3},\d{1,3},\d{1,3}$/i.test(t)) {
|
|
800
|
+
const [o, i, a] = t.split(",").map(Number), c = new B(n.ByColor);
|
|
801
|
+
return c.setRGB(o, i, a), c;
|
|
802
|
+
}
|
|
803
|
+
if (/^\d+$/.test(t)) {
|
|
804
|
+
const o = parseInt(t, 10);
|
|
805
|
+
return new B(n.ByACI, o);
|
|
806
|
+
}
|
|
807
|
+
const s = b.getColorByName(t);
|
|
808
|
+
if (s != null)
|
|
809
|
+
return new B(n.ByColor, s);
|
|
810
|
+
console.warn("Unknown color name:", e);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
class oe {
|
|
814
|
+
/**
|
|
815
|
+
* Constructs a new `AcCmEntityColor`.
|
|
652
816
|
*
|
|
653
|
-
* @
|
|
654
|
-
* @param
|
|
655
|
-
* @returns {string | null} The color name if found, null otherwise.
|
|
817
|
+
* @param method Initial color method (defaults to `ByColor`)
|
|
818
|
+
* @param value Internal packed value (defaults to `0`)
|
|
656
819
|
*/
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if (r === e)
|
|
660
|
-
return t;
|
|
661
|
-
return null;
|
|
820
|
+
constructor(e = n.ByColor, t = 0) {
|
|
821
|
+
this._colorMethod = e, this._value = t;
|
|
662
822
|
}
|
|
663
823
|
/**
|
|
664
|
-
*
|
|
824
|
+
* Gets the method used to determine the final color.
|
|
825
|
+
*/
|
|
826
|
+
get colorMethd() {
|
|
827
|
+
return this._colorMethod;
|
|
828
|
+
}
|
|
829
|
+
// ---------------------------------------------------------------------
|
|
830
|
+
// RGB accessors
|
|
831
|
+
// ---------------------------------------------------------------------
|
|
832
|
+
/**
|
|
833
|
+
* Gets the red component (0–255). Only valid when colorMethod = ByColor.
|
|
834
|
+
*/
|
|
835
|
+
get red() {
|
|
836
|
+
return this._value >> 16 & 255;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Sets the red component and updates the packed RGB value.
|
|
840
|
+
*/
|
|
841
|
+
set red(e) {
|
|
842
|
+
this._colorMethod = n.ByColor, this._value = this._value & 65535 | (e & 255) << 16;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Gets the green component (0–255). Only valid when colorMethod = ByColor.
|
|
846
|
+
*/
|
|
847
|
+
get green() {
|
|
848
|
+
return this._value >> 8 & 255;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Sets the green component and updates the packed RGB value.
|
|
852
|
+
*/
|
|
853
|
+
set green(e) {
|
|
854
|
+
this._colorMethod = n.ByColor, this._value = this._value & 16711935 | (e & 255) << 8;
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Gets the blue component (0–255). Only valid when colorMethod = ByColor.
|
|
858
|
+
*/
|
|
859
|
+
get blue() {
|
|
860
|
+
return this._value & 255;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Sets the blue component and updates the packed RGB value.
|
|
864
|
+
*/
|
|
865
|
+
set blue(e) {
|
|
866
|
+
this._colorMethod = n.ByColor, this._value = this._value & 16776960 | e & 255;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Sets all RGB components.
|
|
665
870
|
*
|
|
666
|
-
* @
|
|
667
|
-
* @param
|
|
668
|
-
* @
|
|
669
|
-
*/
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
for (let r = 1; r < t; ++r)
|
|
673
|
-
if (T[r] === e)
|
|
674
|
-
return r;
|
|
675
|
-
return null;
|
|
871
|
+
* @param r Red (0–255)
|
|
872
|
+
* @param g Green (0–255)
|
|
873
|
+
* @param b Blue (0–255)
|
|
874
|
+
*/
|
|
875
|
+
setRGB(e, t, s) {
|
|
876
|
+
this._colorMethod = n.ByColor, this._value = (e & 255) << 16 | (t & 255) << 8 | s & 255;
|
|
676
877
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
878
|
+
// ---------------------------------------------------------------------
|
|
879
|
+
// ACI accessors
|
|
880
|
+
// ---------------------------------------------------------------------
|
|
881
|
+
/**
|
|
882
|
+
* Gets the AutoCAD Color Index (ACI). Only valid when colorMethod = ByACI.
|
|
883
|
+
*/
|
|
884
|
+
get colorIndex() {
|
|
885
|
+
return this._value;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Sets the AutoCAD Color Index (ACI).
|
|
889
|
+
*/
|
|
890
|
+
set colorIndex(e) {
|
|
891
|
+
this._colorMethod = n.ByACI, this._value = e;
|
|
892
|
+
}
|
|
893
|
+
// ---------------------------------------------------------------------
|
|
894
|
+
// Layer index accessors
|
|
895
|
+
// ---------------------------------------------------------------------
|
|
896
|
+
/**
|
|
897
|
+
* Gets the referenced layer index. Only valid when colorMethod = ByLayer.
|
|
898
|
+
*/
|
|
899
|
+
get layerIndex() {
|
|
900
|
+
return this._value;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Sets the layer index for ByLayer color mode.
|
|
904
|
+
*/
|
|
905
|
+
set layerIndex(e) {
|
|
906
|
+
this._colorMethod = n.ByLayer, this._value = e;
|
|
907
|
+
}
|
|
908
|
+
// ---------------------------------------------------------------------
|
|
909
|
+
// Utility methods
|
|
910
|
+
// ---------------------------------------------------------------------
|
|
911
|
+
/**
|
|
912
|
+
* Returns true if the color method is ByColor (explicit RGB).
|
|
913
|
+
*/
|
|
914
|
+
isByColor() {
|
|
915
|
+
return this._colorMethod === n.ByColor;
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Returns true if the color method is ByLayer.
|
|
919
|
+
*/
|
|
920
|
+
isByLayer() {
|
|
921
|
+
return this._colorMethod === n.ByLayer;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Returns true if the color method is ByBlock.
|
|
925
|
+
*/
|
|
926
|
+
isByBlock() {
|
|
927
|
+
return this._colorMethod === n.ByBlock;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Returns true if the color method is ByACI.
|
|
931
|
+
*/
|
|
932
|
+
isByACI() {
|
|
933
|
+
return this._colorMethod === n.ByACI;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Returns true if color is uninitialized or invalid.
|
|
937
|
+
*/
|
|
938
|
+
isNone() {
|
|
939
|
+
return this._colorMethod === n.None;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Gets the packed internal value.
|
|
943
|
+
*
|
|
944
|
+
* - RGB → packed 24-bit integer
|
|
945
|
+
* - ACI → index
|
|
946
|
+
* - Layer → index
|
|
947
|
+
*/
|
|
948
|
+
get rawValue() {
|
|
949
|
+
return this._value;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Sets a raw internal value. The meaning depends on `colorMethod`.
|
|
953
|
+
*/
|
|
954
|
+
set rawValue(e) {
|
|
955
|
+
this._value = e;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
const ne = {
|
|
681
959
|
/**
|
|
682
960
|
* Throw error ILLEGAL_PARAMETERS when cannot instantiate from given parameter
|
|
683
961
|
*/
|
|
@@ -713,7 +991,7 @@ const te = {
|
|
|
713
991
|
return new Error("Not implemented yet");
|
|
714
992
|
}
|
|
715
993
|
};
|
|
716
|
-
class
|
|
994
|
+
class ie {
|
|
717
995
|
/**
|
|
718
996
|
* Creates {@link AcCmEventDispatcher} object.
|
|
719
997
|
*/
|
|
@@ -722,13 +1000,13 @@ class re {
|
|
|
722
1000
|
}
|
|
723
1001
|
addEventListener(e, t) {
|
|
724
1002
|
this._listeners === void 0 && (this._listeners = {});
|
|
725
|
-
const
|
|
726
|
-
|
|
1003
|
+
const s = this._listeners;
|
|
1004
|
+
s[e] === void 0 && (s[e] = []), s[e].indexOf(t) === -1 && s[e].push(t);
|
|
727
1005
|
}
|
|
728
1006
|
hasEventListener(e, t) {
|
|
729
1007
|
if (this._listeners === void 0) return !1;
|
|
730
|
-
const
|
|
731
|
-
return
|
|
1008
|
+
const s = this._listeners;
|
|
1009
|
+
return s[e] !== void 0 && s[e].indexOf(t) !== -1;
|
|
732
1010
|
}
|
|
733
1011
|
removeEventListener(e, t) {
|
|
734
1012
|
if (this._listeners === void 0) return;
|
|
@@ -744,16 +1022,16 @@ class re {
|
|
|
744
1022
|
*/
|
|
745
1023
|
dispatchEvent(e) {
|
|
746
1024
|
if (this._listeners === void 0) return;
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
1025
|
+
const s = this._listeners[e.type];
|
|
1026
|
+
if (s !== void 0) {
|
|
749
1027
|
e.target = this;
|
|
750
|
-
const o =
|
|
751
|
-
for (let i = 0,
|
|
1028
|
+
const o = s.slice(0);
|
|
1029
|
+
for (let i = 0, a = o.length; i < a; i++)
|
|
752
1030
|
o[i].call(this, e);
|
|
753
1031
|
}
|
|
754
1032
|
}
|
|
755
1033
|
}
|
|
756
|
-
class
|
|
1034
|
+
class D {
|
|
757
1035
|
constructor() {
|
|
758
1036
|
this.listeners = [];
|
|
759
1037
|
}
|
|
@@ -783,223 +1061,237 @@ class U {
|
|
|
783
1061
|
* @param payload Input payload passed to listener
|
|
784
1062
|
*/
|
|
785
1063
|
dispatch(e, ...t) {
|
|
786
|
-
for (const
|
|
787
|
-
|
|
1064
|
+
for (const s of this.listeners)
|
|
1065
|
+
s.call(null, e, ...t);
|
|
788
1066
|
}
|
|
789
1067
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1068
|
+
function C(r) {
|
|
1069
|
+
return r === null || typeof r != "object" ? r : Array.isArray(r) ? [...r] : { ...r };
|
|
1070
|
+
}
|
|
1071
|
+
function F(r) {
|
|
1072
|
+
if (r === null || typeof r != "object")
|
|
1073
|
+
return r;
|
|
1074
|
+
if (r instanceof Date)
|
|
1075
|
+
return new Date(r.getTime());
|
|
1076
|
+
if (r instanceof RegExp)
|
|
1077
|
+
return new RegExp(r.source, r.flags);
|
|
1078
|
+
if (Array.isArray(r))
|
|
1079
|
+
return r.map(F);
|
|
1080
|
+
const e = {};
|
|
1081
|
+
for (const t in r)
|
|
1082
|
+
Object.prototype.hasOwnProperty.call(r, t) && (e[t] = F(r[t]));
|
|
1083
|
+
return e;
|
|
1084
|
+
}
|
|
1085
|
+
function Y(r, ...e) {
|
|
1086
|
+
for (const t of e)
|
|
1087
|
+
if (t)
|
|
1088
|
+
for (const s in t)
|
|
1089
|
+
Object.prototype.hasOwnProperty.call(t, s) && r[s] === void 0 && (r[s] = t[s]);
|
|
1090
|
+
return r;
|
|
1091
|
+
}
|
|
1092
|
+
function Z(r, e) {
|
|
1093
|
+
return r != null && Object.prototype.hasOwnProperty.call(r, e);
|
|
1094
|
+
}
|
|
1095
|
+
function J(r) {
|
|
1096
|
+
return r == null ? !0 : Array.isArray(r) || typeof r == "string" ? r.length === 0 : r instanceof Map || r instanceof Set ? r.size === 0 : typeof r == "object" ? Object.keys(r).length === 0 : !1;
|
|
1097
|
+
}
|
|
1098
|
+
function M(r, e) {
|
|
1099
|
+
if (r === e)
|
|
1100
|
+
return !0;
|
|
1101
|
+
if (r == null || e == null)
|
|
1102
|
+
return r === e;
|
|
1103
|
+
if (typeof r != typeof e)
|
|
1104
|
+
return !1;
|
|
1105
|
+
if (typeof r != "object")
|
|
1106
|
+
return r === e;
|
|
1107
|
+
if (Array.isArray(r) !== Array.isArray(e))
|
|
1108
|
+
return !1;
|
|
1109
|
+
if (Array.isArray(r)) {
|
|
1110
|
+
if (r.length !== e.length)
|
|
1111
|
+
return !1;
|
|
1112
|
+
for (let o = 0; o < r.length; o++)
|
|
1113
|
+
if (!M(r[o], e[o]))
|
|
1114
|
+
return !1;
|
|
1115
|
+
return !0;
|
|
1116
|
+
}
|
|
1117
|
+
const t = Object.keys(r), s = Object.keys(e);
|
|
1118
|
+
if (t.length !== s.length)
|
|
1119
|
+
return !1;
|
|
1120
|
+
for (const o of t)
|
|
1121
|
+
if (!Object.prototype.hasOwnProperty.call(
|
|
1122
|
+
e,
|
|
1123
|
+
o
|
|
1124
|
+
) || !M(
|
|
1125
|
+
r[o],
|
|
1126
|
+
e[o]
|
|
1127
|
+
))
|
|
1128
|
+
return !1;
|
|
1129
|
+
return !0;
|
|
1130
|
+
}
|
|
1131
|
+
var X = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
1132
|
+
function Q(r) {
|
|
1133
|
+
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
793
1134
|
}
|
|
794
1135
|
var q = { exports: {} };
|
|
795
|
-
(function(
|
|
1136
|
+
(function(r) {
|
|
796
1137
|
(function(e, t) {
|
|
797
|
-
|
|
798
|
-
})(
|
|
1138
|
+
r.exports ? r.exports = t() : e.log = t();
|
|
1139
|
+
})(X, function() {
|
|
799
1140
|
var e = function() {
|
|
800
|
-
}, t = "undefined",
|
|
1141
|
+
}, t = "undefined", s = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), o = [
|
|
801
1142
|
"trace",
|
|
802
1143
|
"debug",
|
|
803
1144
|
"info",
|
|
804
1145
|
"warn",
|
|
805
1146
|
"error"
|
|
806
|
-
], i = {},
|
|
807
|
-
function
|
|
808
|
-
var
|
|
809
|
-
if (typeof
|
|
810
|
-
return
|
|
1147
|
+
], i = {}, a = null;
|
|
1148
|
+
function c(h, d) {
|
|
1149
|
+
var l = h[d];
|
|
1150
|
+
if (typeof l.bind == "function")
|
|
1151
|
+
return l.bind(h);
|
|
811
1152
|
try {
|
|
812
|
-
return Function.prototype.bind.call(
|
|
1153
|
+
return Function.prototype.bind.call(l, h);
|
|
813
1154
|
} catch {
|
|
814
1155
|
return function() {
|
|
815
|
-
return Function.prototype.apply.apply(
|
|
1156
|
+
return Function.prototype.apply.apply(l, [h, arguments]);
|
|
816
1157
|
};
|
|
817
1158
|
}
|
|
818
1159
|
}
|
|
819
|
-
function
|
|
1160
|
+
function I() {
|
|
820
1161
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
821
1162
|
}
|
|
822
|
-
function
|
|
823
|
-
return
|
|
1163
|
+
function m(h) {
|
|
1164
|
+
return h === "debug" && (h = "log"), typeof console === t ? !1 : h === "trace" && s ? I : console[h] !== void 0 ? c(console, h) : console.log !== void 0 ? c(console, "log") : e;
|
|
824
1165
|
}
|
|
825
|
-
function
|
|
826
|
-
for (var
|
|
827
|
-
var
|
|
828
|
-
this[
|
|
1166
|
+
function _() {
|
|
1167
|
+
for (var h = this.getLevel(), d = 0; d < o.length; d++) {
|
|
1168
|
+
var l = o[d];
|
|
1169
|
+
this[l] = d < h ? e : this.methodFactory(l, h, this.name);
|
|
829
1170
|
}
|
|
830
|
-
if (this.log = this.debug, typeof console === t &&
|
|
1171
|
+
if (this.log = this.debug, typeof console === t && h < this.levels.SILENT)
|
|
831
1172
|
return "No console available for logging";
|
|
832
1173
|
}
|
|
833
|
-
function
|
|
1174
|
+
function x(h) {
|
|
834
1175
|
return function() {
|
|
835
|
-
typeof console !== t && (
|
|
1176
|
+
typeof console !== t && (_.call(this), this[h].apply(this, arguments));
|
|
836
1177
|
};
|
|
837
1178
|
}
|
|
838
|
-
function
|
|
839
|
-
return
|
|
1179
|
+
function f(h, d, l) {
|
|
1180
|
+
return m(h) || x.apply(this, arguments);
|
|
840
1181
|
}
|
|
841
|
-
function
|
|
842
|
-
var
|
|
843
|
-
typeof
|
|
844
|
-
function
|
|
845
|
-
var
|
|
846
|
-
if (!(typeof window === t || !
|
|
1182
|
+
function S(h, d) {
|
|
1183
|
+
var l = this, E, R, w, p = "loglevel";
|
|
1184
|
+
typeof h == "string" ? p += ":" + h : typeof h == "symbol" && (p = void 0);
|
|
1185
|
+
function z(u) {
|
|
1186
|
+
var g = (o[u] || "silent").toUpperCase();
|
|
1187
|
+
if (!(typeof window === t || !p)) {
|
|
847
1188
|
try {
|
|
848
|
-
window.localStorage[
|
|
1189
|
+
window.localStorage[p] = g;
|
|
849
1190
|
return;
|
|
850
1191
|
} catch {
|
|
851
1192
|
}
|
|
852
1193
|
try {
|
|
853
|
-
window.document.cookie = encodeURIComponent(
|
|
1194
|
+
window.document.cookie = encodeURIComponent(p) + "=" + g + ";";
|
|
854
1195
|
} catch {
|
|
855
1196
|
}
|
|
856
1197
|
}
|
|
857
1198
|
}
|
|
858
|
-
function
|
|
859
|
-
var
|
|
860
|
-
if (!(typeof window === t || !
|
|
1199
|
+
function P() {
|
|
1200
|
+
var u;
|
|
1201
|
+
if (!(typeof window === t || !p)) {
|
|
861
1202
|
try {
|
|
862
|
-
|
|
1203
|
+
u = window.localStorage[p];
|
|
863
1204
|
} catch {
|
|
864
1205
|
}
|
|
865
|
-
if (typeof
|
|
1206
|
+
if (typeof u === t)
|
|
866
1207
|
try {
|
|
867
|
-
var
|
|
868
|
-
|
|
869
|
-
|
|
1208
|
+
var g = window.document.cookie, A = encodeURIComponent(p), U = g.indexOf(A + "=");
|
|
1209
|
+
U !== -1 && (u = /^([^;]+)/.exec(
|
|
1210
|
+
g.slice(U + A.length + 1)
|
|
870
1211
|
)[1]);
|
|
871
1212
|
} catch {
|
|
872
1213
|
}
|
|
873
|
-
return
|
|
1214
|
+
return l.levels[u] === void 0 && (u = void 0), u;
|
|
874
1215
|
}
|
|
875
1216
|
}
|
|
876
|
-
function
|
|
877
|
-
if (!(typeof window === t || !
|
|
1217
|
+
function H() {
|
|
1218
|
+
if (!(typeof window === t || !p)) {
|
|
878
1219
|
try {
|
|
879
|
-
window.localStorage.removeItem(
|
|
1220
|
+
window.localStorage.removeItem(p);
|
|
880
1221
|
} catch {
|
|
881
1222
|
}
|
|
882
1223
|
try {
|
|
883
|
-
window.document.cookie = encodeURIComponent(
|
|
1224
|
+
window.document.cookie = encodeURIComponent(p) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
884
1225
|
} catch {
|
|
885
1226
|
}
|
|
886
1227
|
}
|
|
887
1228
|
}
|
|
888
|
-
function
|
|
889
|
-
var
|
|
890
|
-
if (typeof
|
|
891
|
-
return
|
|
892
|
-
throw new TypeError("log.setLevel() called with invalid level: " +
|
|
1229
|
+
function L(u) {
|
|
1230
|
+
var g = u;
|
|
1231
|
+
if (typeof g == "string" && l.levels[g.toUpperCase()] !== void 0 && (g = l.levels[g.toUpperCase()]), typeof g == "number" && g >= 0 && g <= l.levels.SILENT)
|
|
1232
|
+
return g;
|
|
1233
|
+
throw new TypeError("log.setLevel() called with invalid level: " + u);
|
|
893
1234
|
}
|
|
894
|
-
|
|
1235
|
+
l.name = h, l.levels = {
|
|
895
1236
|
TRACE: 0,
|
|
896
1237
|
DEBUG: 1,
|
|
897
1238
|
INFO: 2,
|
|
898
1239
|
WARN: 3,
|
|
899
1240
|
ERROR: 4,
|
|
900
1241
|
SILENT: 5
|
|
901
|
-
},
|
|
902
|
-
return
|
|
903
|
-
},
|
|
904
|
-
return
|
|
905
|
-
},
|
|
906
|
-
|
|
907
|
-
},
|
|
908
|
-
|
|
909
|
-
},
|
|
910
|
-
|
|
911
|
-
},
|
|
912
|
-
|
|
913
|
-
},
|
|
914
|
-
if (
|
|
915
|
-
for (var
|
|
916
|
-
i[
|
|
917
|
-
}, E =
|
|
918
|
-
|
|
1242
|
+
}, l.methodFactory = d || f, l.getLevel = function() {
|
|
1243
|
+
return w ?? R ?? E;
|
|
1244
|
+
}, l.setLevel = function(u, g) {
|
|
1245
|
+
return w = L(u), g !== !1 && z(w), _.call(l);
|
|
1246
|
+
}, l.setDefaultLevel = function(u) {
|
|
1247
|
+
R = L(u), P() || l.setLevel(u, !1);
|
|
1248
|
+
}, l.resetLevel = function() {
|
|
1249
|
+
w = null, H(), _.call(l);
|
|
1250
|
+
}, l.enableAll = function(u) {
|
|
1251
|
+
l.setLevel(l.levels.TRACE, u);
|
|
1252
|
+
}, l.disableAll = function(u) {
|
|
1253
|
+
l.setLevel(l.levels.SILENT, u);
|
|
1254
|
+
}, l.rebuild = function() {
|
|
1255
|
+
if (a !== l && (E = L(a.getLevel())), _.call(l), a === l)
|
|
1256
|
+
for (var u in i)
|
|
1257
|
+
i[u].rebuild();
|
|
1258
|
+
}, E = L(
|
|
1259
|
+
a ? a.getLevel() : "WARN"
|
|
919
1260
|
);
|
|
920
|
-
var
|
|
921
|
-
|
|
1261
|
+
var T = P();
|
|
1262
|
+
T != null && (w = L(T)), _.call(l);
|
|
922
1263
|
}
|
|
923
|
-
|
|
924
|
-
if (typeof
|
|
1264
|
+
a = new S(), a.getLogger = function(d) {
|
|
1265
|
+
if (typeof d != "symbol" && typeof d != "string" || d === "")
|
|
925
1266
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
926
|
-
var
|
|
927
|
-
return
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
)),
|
|
1267
|
+
var l = i[d];
|
|
1268
|
+
return l || (l = i[d] = new S(
|
|
1269
|
+
d,
|
|
1270
|
+
a.methodFactory
|
|
1271
|
+
)), l;
|
|
931
1272
|
};
|
|
932
1273
|
var j = typeof window !== t ? window.log : void 0;
|
|
933
|
-
return
|
|
934
|
-
return typeof window !== t && window.log ===
|
|
935
|
-
},
|
|
1274
|
+
return a.noConflict = function() {
|
|
1275
|
+
return typeof window !== t && window.log === a && (window.log = j), a;
|
|
1276
|
+
}, a.getLoggers = function() {
|
|
936
1277
|
return i;
|
|
937
|
-
},
|
|
1278
|
+
}, a.default = a, a;
|
|
938
1279
|
});
|
|
939
1280
|
})(q);
|
|
940
|
-
var
|
|
941
|
-
const
|
|
1281
|
+
var $ = q.exports;
|
|
1282
|
+
const ee = /* @__PURE__ */ Q($), te = /* @__PURE__ */ W({
|
|
942
1283
|
__proto__: null,
|
|
943
|
-
default:
|
|
944
|
-
}, [
|
|
945
|
-
|
|
946
|
-
const
|
|
1284
|
+
default: ee
|
|
1285
|
+
}, [$]), le = !0, O = te;
|
|
1286
|
+
O.setLevel("debug");
|
|
1287
|
+
const ae = (r) => {
|
|
947
1288
|
try {
|
|
948
|
-
|
|
1289
|
+
O.setLevel(r);
|
|
949
1290
|
} catch (e) {
|
|
950
|
-
|
|
1291
|
+
O.setLevel("error"), O.error(e);
|
|
951
1292
|
}
|
|
952
1293
|
};
|
|
953
|
-
|
|
954
|
-
return n === null || typeof n != "object" ? n : Array.isArray(n) ? [...n] : { ...n };
|
|
955
|
-
}
|
|
956
|
-
function Z(n, ...e) {
|
|
957
|
-
for (const t of e)
|
|
958
|
-
if (t)
|
|
959
|
-
for (const r in t)
|
|
960
|
-
Object.prototype.hasOwnProperty.call(t, r) && n[r] === void 0 && (n[r] = t[r]);
|
|
961
|
-
return n;
|
|
962
|
-
}
|
|
963
|
-
function J(n, e) {
|
|
964
|
-
return n != null && Object.prototype.hasOwnProperty.call(n, e);
|
|
965
|
-
}
|
|
966
|
-
function X(n) {
|
|
967
|
-
return n == null ? !0 : Array.isArray(n) || typeof n == "string" ? n.length === 0 : n instanceof Map || n instanceof Set ? n.size === 0 : typeof n == "object" ? Object.keys(n).length === 0 : !1;
|
|
968
|
-
}
|
|
969
|
-
function _(n, e) {
|
|
970
|
-
if (n === e)
|
|
971
|
-
return !0;
|
|
972
|
-
if (n == null || e == null)
|
|
973
|
-
return n === e;
|
|
974
|
-
if (typeof n != typeof e)
|
|
975
|
-
return !1;
|
|
976
|
-
if (typeof n != "object")
|
|
977
|
-
return n === e;
|
|
978
|
-
if (Array.isArray(n) !== Array.isArray(e))
|
|
979
|
-
return !1;
|
|
980
|
-
if (Array.isArray(n)) {
|
|
981
|
-
if (n.length !== e.length)
|
|
982
|
-
return !1;
|
|
983
|
-
for (let o = 0; o < n.length; o++)
|
|
984
|
-
if (!_(n[o], e[o]))
|
|
985
|
-
return !1;
|
|
986
|
-
return !0;
|
|
987
|
-
}
|
|
988
|
-
const t = Object.keys(n), r = Object.keys(e);
|
|
989
|
-
if (t.length !== r.length)
|
|
990
|
-
return !1;
|
|
991
|
-
for (const o of t)
|
|
992
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
993
|
-
e,
|
|
994
|
-
o
|
|
995
|
-
) || !_(
|
|
996
|
-
n[o],
|
|
997
|
-
e[o]
|
|
998
|
-
))
|
|
999
|
-
return !1;
|
|
1000
|
-
return !0;
|
|
1001
|
-
}
|
|
1002
|
-
class F {
|
|
1294
|
+
class V {
|
|
1003
1295
|
/**
|
|
1004
1296
|
* Create one object to store attributes. For performance reason, values of attributes passed to constructor
|
|
1005
1297
|
* will not be cloned to `attributes` property. So it means that value of `attributes` property in this object
|
|
@@ -1008,11 +1300,11 @@ class F {
|
|
|
1008
1300
|
*/
|
|
1009
1301
|
constructor(e, t) {
|
|
1010
1302
|
this.events = {
|
|
1011
|
-
attrChanged: new
|
|
1012
|
-
modelChanged: new
|
|
1303
|
+
attrChanged: new D(),
|
|
1304
|
+
modelChanged: new D()
|
|
1013
1305
|
}, this._changing = !1, this._previousAttributes = {}, this._pending = !1;
|
|
1014
|
-
const
|
|
1015
|
-
t &&
|
|
1306
|
+
const s = e || {};
|
|
1307
|
+
t && Y(s, t), this.attributes = s, this.changed = {};
|
|
1016
1308
|
}
|
|
1017
1309
|
/**
|
|
1018
1310
|
* Gets the value of an attribute.
|
|
@@ -1043,31 +1335,31 @@ class F {
|
|
|
1043
1335
|
get(e) {
|
|
1044
1336
|
return this.attributes[e];
|
|
1045
1337
|
}
|
|
1046
|
-
set(e, t,
|
|
1338
|
+
set(e, t, s) {
|
|
1047
1339
|
if (e == null) return this;
|
|
1048
1340
|
let o;
|
|
1049
|
-
typeof e == "object" ? (o = e,
|
|
1050
|
-
const i =
|
|
1051
|
-
this._changing = !0,
|
|
1052
|
-
const
|
|
1053
|
-
for (const
|
|
1054
|
-
t = o[
|
|
1055
|
-
if (!
|
|
1056
|
-
|
|
1057
|
-
for (let
|
|
1341
|
+
typeof e == "object" ? (o = e, s = t) : (o = {}, o[e] = t), s || (s = {});
|
|
1342
|
+
const i = s.unset, a = s.silent, c = [], I = this._changing;
|
|
1343
|
+
this._changing = !0, I || (this._previousAttributes = C(this.attributes), this.changed = {});
|
|
1344
|
+
const m = this.attributes, _ = this.changed, x = this._previousAttributes;
|
|
1345
|
+
for (const f in o)
|
|
1346
|
+
t = o[f], M(m[f], t) || c.push(f), M(x[f], t) ? delete _[f] : _[f] = t, i ? delete m[f] : m[f] = t;
|
|
1347
|
+
if (!a) {
|
|
1348
|
+
c.length && (this._pending = s);
|
|
1349
|
+
for (let f = 0; f < c.length; f++)
|
|
1058
1350
|
this.events.attrChanged.dispatch({
|
|
1059
1351
|
object: this,
|
|
1060
|
-
attrName:
|
|
1061
|
-
attrValue:
|
|
1062
|
-
options:
|
|
1352
|
+
attrName: c[f],
|
|
1353
|
+
attrValue: m[c[f]],
|
|
1354
|
+
options: s
|
|
1063
1355
|
});
|
|
1064
1356
|
}
|
|
1065
|
-
if (
|
|
1066
|
-
if (!
|
|
1357
|
+
if (I) return this;
|
|
1358
|
+
if (!a)
|
|
1067
1359
|
for (; this._pending; )
|
|
1068
|
-
|
|
1360
|
+
s = this._pending, this._pending = !1, this.events.modelChanged.dispatch({
|
|
1069
1361
|
object: this,
|
|
1070
|
-
options:
|
|
1362
|
+
options: s
|
|
1071
1363
|
});
|
|
1072
1364
|
return this._pending = !1, this._changing = !1, this;
|
|
1073
1365
|
}
|
|
@@ -1079,7 +1371,7 @@ class F {
|
|
|
1079
1371
|
* If you specify an attribute name, determine if that attribute has changed.
|
|
1080
1372
|
*/
|
|
1081
1373
|
hasChanged(e) {
|
|
1082
|
-
return e == null ? !
|
|
1374
|
+
return e == null ? !J(this.changed) : Z(this.changed, e);
|
|
1083
1375
|
}
|
|
1084
1376
|
/**
|
|
1085
1377
|
* Return an object containing all the attributes that have changed. Useful for determining what parts
|
|
@@ -1089,13 +1381,13 @@ class F {
|
|
|
1089
1381
|
* the model, determining if there *would be* a change.
|
|
1090
1382
|
*/
|
|
1091
1383
|
changedAttributes(e) {
|
|
1092
|
-
if (!e) return this.hasChanged() ?
|
|
1093
|
-
const t = this._changing ? this._previousAttributes : this.attributes,
|
|
1384
|
+
if (!e) return this.hasChanged() ? C(this.changed) : {};
|
|
1385
|
+
const t = this._changing ? this._previousAttributes : this.attributes, s = {};
|
|
1094
1386
|
for (const o in e) {
|
|
1095
1387
|
const i = e[o];
|
|
1096
|
-
|
|
1388
|
+
M(t[o], i) || (s[o] = i);
|
|
1097
1389
|
}
|
|
1098
|
-
return
|
|
1390
|
+
return s;
|
|
1099
1391
|
}
|
|
1100
1392
|
/**
|
|
1101
1393
|
* Get the previous value of an attribute, recorded at the time the last `"change"` event was fired.
|
|
@@ -1107,17 +1399,17 @@ class F {
|
|
|
1107
1399
|
* Get all of the attributes of the model at the time of the previous `"change"` event.
|
|
1108
1400
|
*/
|
|
1109
1401
|
previousAttributes() {
|
|
1110
|
-
return
|
|
1402
|
+
return C(this._previousAttributes);
|
|
1111
1403
|
}
|
|
1112
1404
|
/**
|
|
1113
1405
|
* Create a new model with identical attributes to this one.
|
|
1114
1406
|
*/
|
|
1115
1407
|
clone() {
|
|
1116
|
-
const e =
|
|
1117
|
-
return new
|
|
1408
|
+
const e = C(this.attributes);
|
|
1409
|
+
return new V(e);
|
|
1118
1410
|
}
|
|
1119
1411
|
}
|
|
1120
|
-
class
|
|
1412
|
+
class k {
|
|
1121
1413
|
/**
|
|
1122
1414
|
* Private constructor to enforce singleton pattern.
|
|
1123
1415
|
*/
|
|
@@ -1129,7 +1421,7 @@ class b {
|
|
|
1129
1421
|
* @returns The shared AcCmPerformanceCollector instance.
|
|
1130
1422
|
*/
|
|
1131
1423
|
static getInstance() {
|
|
1132
|
-
return
|
|
1424
|
+
return k.instance || (k.instance = new k()), k.instance;
|
|
1133
1425
|
}
|
|
1134
1426
|
/**
|
|
1135
1427
|
* Adds or replaces a performance entry by name.
|
|
@@ -1176,7 +1468,7 @@ class b {
|
|
|
1176
1468
|
return this.entries.delete(e);
|
|
1177
1469
|
}
|
|
1178
1470
|
}
|
|
1179
|
-
class
|
|
1471
|
+
class he {
|
|
1180
1472
|
/**
|
|
1181
1473
|
* Converts a byte count to a human-readable string using appropriate size units.
|
|
1182
1474
|
*
|
|
@@ -1201,11 +1493,253 @@ class se {
|
|
|
1201
1493
|
*/
|
|
1202
1494
|
static formatBytes(e, t = 2) {
|
|
1203
1495
|
if (e === 0) return "0 B";
|
|
1204
|
-
const
|
|
1205
|
-
return `${parseFloat(
|
|
1496
|
+
const s = 1024, o = Math.max(0, t), i = ["B", "KB", "MB", "GB", "TB"], a = Math.floor(Math.log(e) / Math.log(s)), c = e / Math.pow(s, a);
|
|
1497
|
+
return `${parseFloat(c.toFixed(o))} ${i[a]}`;
|
|
1206
1498
|
}
|
|
1207
1499
|
}
|
|
1208
|
-
|
|
1500
|
+
var y = /* @__PURE__ */ ((r) => (r[r.ByLayer = 0] = "ByLayer", r[r.ByBlock = 1] = "ByBlock", r[r.ByAlpha = 2] = "ByAlpha", r[r.ErrorValue = 3] = "ErrorValue", r))(y || {});
|
|
1501
|
+
class v {
|
|
1502
|
+
/**
|
|
1503
|
+
* Creates a new transparency object.
|
|
1504
|
+
*
|
|
1505
|
+
* @param alpha
|
|
1506
|
+
* When provided, constructs with `ByAlpha` method and sets alpha.
|
|
1507
|
+
* Must be between 0 and 255.
|
|
1508
|
+
*/
|
|
1509
|
+
constructor(e) {
|
|
1510
|
+
e !== void 0 ? (this._method = y.ByAlpha, this._alpha = v.clampAlpha(e)) : (this._method = y.ByLayer, this._alpha = 255);
|
|
1511
|
+
}
|
|
1512
|
+
/** Gets the current transparency method */
|
|
1513
|
+
get method() {
|
|
1514
|
+
return this._method;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Sets the transparency method.
|
|
1518
|
+
* If setting to ByAlpha with no prior alpha, alpha stays 255 (opaque).
|
|
1519
|
+
*
|
|
1520
|
+
* @param method The new transparency method
|
|
1521
|
+
*/
|
|
1522
|
+
set method(e) {
|
|
1523
|
+
this._method = e;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Gets the alpha value.
|
|
1527
|
+
* Only meaningful if `method === ByAlpha`.
|
|
1528
|
+
*/
|
|
1529
|
+
get alpha() {
|
|
1530
|
+
return this._alpha;
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* Sets the alpha value and force the method to `ByAlpha`.
|
|
1534
|
+
*
|
|
1535
|
+
* @param alpha 0–255 alpha, clamped internally if out of range
|
|
1536
|
+
*/
|
|
1537
|
+
set alpha(e) {
|
|
1538
|
+
this._alpha = v.clampAlpha(e), this._method = y.ByAlpha;
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Gets the AutoCAD-style transparency percentage.
|
|
1542
|
+
*
|
|
1543
|
+
* Mapping rules:
|
|
1544
|
+
* - 0% = fully opaque (alpha = 255)
|
|
1545
|
+
* - 100% = fully transparent (alpha = 0)
|
|
1546
|
+
*
|
|
1547
|
+
* This matches how AutoCAD displays and stores transparency
|
|
1548
|
+
* values in UI and DXF files.
|
|
1549
|
+
*
|
|
1550
|
+
* If the transparency method is not `ByAlpha`,
|
|
1551
|
+
* this method returns `undefined`, because AutoCAD
|
|
1552
|
+
* does not define a percentage for ByLayer or ByBlock.
|
|
1553
|
+
*
|
|
1554
|
+
* @returns Transparency percentage (0–100), or undefined
|
|
1555
|
+
*/
|
|
1556
|
+
get percentage() {
|
|
1557
|
+
if (this._method === y.ByAlpha)
|
|
1558
|
+
return Math.round((1 - this._alpha / 255) * 100);
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Sets the transparency using an AutoCAD-style percentage.
|
|
1562
|
+
*
|
|
1563
|
+
* Mapping rules (AutoCAD compatible):
|
|
1564
|
+
* - 0% → fully opaque (alpha = 255)
|
|
1565
|
+
* - 100% → fully transparent (alpha = 0)
|
|
1566
|
+
*
|
|
1567
|
+
* Internally, the alpha value is calculated as:
|
|
1568
|
+
* alpha = round(255 × (1 − percentage / 100))
|
|
1569
|
+
*
|
|
1570
|
+
* This method:
|
|
1571
|
+
* - Forces the transparency method to `ByAlpha`
|
|
1572
|
+
* - Clamps the percentage to the range 0–100
|
|
1573
|
+
* - Preserves ObjectARX value semantics
|
|
1574
|
+
*
|
|
1575
|
+
* @param percentage Transparency percentage (0–100)
|
|
1576
|
+
* @returns This instance (for fluent chaining)
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* const t = new AcCmTransparency();
|
|
1580
|
+
* t.setPercentage(50); // ≈ alpha 128
|
|
1581
|
+
*
|
|
1582
|
+
* t.setPercentage(0); // alpha = 255 (opaque)
|
|
1583
|
+
* t.setPercentage(100); // alpha = 0 (clear)
|
|
1584
|
+
*/
|
|
1585
|
+
set percentage(e) {
|
|
1586
|
+
const t = Math.max(0, Math.min(100, e)), s = Math.round(255 * (1 - t / 100));
|
|
1587
|
+
this.alpha = s;
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Ensures alpha always stays within 0–255.
|
|
1591
|
+
*/
|
|
1592
|
+
static clampAlpha(e) {
|
|
1593
|
+
return Math.max(0, Math.min(255, Math.floor(e)));
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* True if the method is `ByAlpha`.
|
|
1597
|
+
*/
|
|
1598
|
+
get isByAlpha() {
|
|
1599
|
+
return this._method === y.ByAlpha;
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* True if the method is `ByBlock`.
|
|
1603
|
+
*/
|
|
1604
|
+
get isByBlock() {
|
|
1605
|
+
return this._method === y.ByBlock;
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* True if the method is `ByLayer`.
|
|
1609
|
+
*/
|
|
1610
|
+
get isByLayer() {
|
|
1611
|
+
return this._method === y.ByLayer;
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* True if transparency is exactly clear (alpha==0 and ByAlpha).
|
|
1615
|
+
*/
|
|
1616
|
+
get isClear() {
|
|
1617
|
+
return this.isByAlpha && this._alpha === 0;
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* True if transparency is solid (alpha==255 and ByAlpha).
|
|
1621
|
+
*/
|
|
1622
|
+
get isSolid() {
|
|
1623
|
+
return this.isByAlpha && this._alpha === 255;
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* True if current state is invalid (ErrorValue).
|
|
1627
|
+
*/
|
|
1628
|
+
get isInvalid() {
|
|
1629
|
+
return this._method === y.ErrorValue;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Convert this transparency to an integer suitable for storage.
|
|
1633
|
+
* Uses a simple bit-encoding: highbits for method and lowbits for alpha.
|
|
1634
|
+
*
|
|
1635
|
+
* 31 24 23 8 7 0
|
|
1636
|
+
* +-------------+--------------+------------+
|
|
1637
|
+
* | flags | reserved | alpha |
|
|
1638
|
+
* +-------------+--------------+------------+
|
|
1639
|
+
*/
|
|
1640
|
+
serialize() {
|
|
1641
|
+
return this._method << 24 | this._alpha;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Creates a deep copy of this transparency object.
|
|
1645
|
+
*
|
|
1646
|
+
* This mirrors the value-semantics of ObjectARX `AcCmTransparency`,
|
|
1647
|
+
* where copying results in an independent object with the same
|
|
1648
|
+
* transparency method and alpha value.
|
|
1649
|
+
*
|
|
1650
|
+
* @returns A new `AcCmTransparency` instance with identical state.
|
|
1651
|
+
*/
|
|
1652
|
+
clone() {
|
|
1653
|
+
const e = new v();
|
|
1654
|
+
return e._method = this._method, e._alpha = this._alpha, e;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Compares this transparency with another one for equality.
|
|
1658
|
+
*
|
|
1659
|
+
* Two `AcCmTransparency` objects are considered equal if:
|
|
1660
|
+
* - Their transparency methods are identical
|
|
1661
|
+
* - Their alpha values are identical
|
|
1662
|
+
*
|
|
1663
|
+
* This mirrors the value semantics of ObjectARX
|
|
1664
|
+
* `AcCmTransparency`.
|
|
1665
|
+
*
|
|
1666
|
+
* @param other The transparency to compare with
|
|
1667
|
+
* @returns True if both represent the same transparency
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* const a = new AcCmTransparency(128);
|
|
1671
|
+
* const b = new AcCmTransparency(128);
|
|
1672
|
+
* a.equals(b); // true
|
|
1673
|
+
*/
|
|
1674
|
+
equals(e) {
|
|
1675
|
+
return this._method === e._method && this._alpha === e._alpha;
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Returns a human-readable string representation of the transparency.
|
|
1679
|
+
*
|
|
1680
|
+
* Behavior:
|
|
1681
|
+
* - `"ByLayer"` if transparency is inherited from layer
|
|
1682
|
+
* - `"ByBlock"` if transparency is inherited from block
|
|
1683
|
+
* - Numeric alpha value (`"0"`–`"255"`) if method is `ByAlpha`
|
|
1684
|
+
*
|
|
1685
|
+
* This format is intentionally simple and mirrors common
|
|
1686
|
+
* AutoCAD UI and DXF text usage.
|
|
1687
|
+
*
|
|
1688
|
+
* @returns String representation of the transparency
|
|
1689
|
+
*
|
|
1690
|
+
* @example
|
|
1691
|
+
* new AcCmTransparency().toString(); // "ByLayer"
|
|
1692
|
+
* new AcCmTransparency(128).toString(); // "128"
|
|
1693
|
+
*/
|
|
1694
|
+
toString() {
|
|
1695
|
+
return this.isByLayer ? "ByLayer" : this.isByBlock ? "ByBlock" : this._alpha.toString();
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Creates an `AcCmTransparency` instance from a string representation.
|
|
1699
|
+
*
|
|
1700
|
+
* Accepted formats:
|
|
1701
|
+
* - `"ByLayer"` (case-insensitive)
|
|
1702
|
+
* - `"ByBlock"` (case-insensitive)
|
|
1703
|
+
* - Numeric alpha value `"0"`–`"255"`
|
|
1704
|
+
*
|
|
1705
|
+
* Invalid or out-of-range values will produce an
|
|
1706
|
+
* `ErrorValue` transparency.
|
|
1707
|
+
*
|
|
1708
|
+
* @param value String to parse
|
|
1709
|
+
* @returns Parsed `AcCmTransparency` instance
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* AcCmTransparency.fromString("ByLayer");
|
|
1713
|
+
* AcCmTransparency.fromString("128");
|
|
1714
|
+
* AcCmTransparency.fromString("ByBlock");
|
|
1715
|
+
*/
|
|
1716
|
+
static fromString(e) {
|
|
1717
|
+
const t = e.trim();
|
|
1718
|
+
if (/^bylayer$/i.test(t)) {
|
|
1719
|
+
const i = new v();
|
|
1720
|
+
return i._method = y.ByLayer, i;
|
|
1721
|
+
}
|
|
1722
|
+
if (/^byblock$/i.test(t)) {
|
|
1723
|
+
const i = new v();
|
|
1724
|
+
return i._method = y.ByBlock, i;
|
|
1725
|
+
}
|
|
1726
|
+
const s = Number(t);
|
|
1727
|
+
if (Number.isInteger(s) && s >= 0 && s <= 255)
|
|
1728
|
+
return new v(s);
|
|
1729
|
+
const o = new v();
|
|
1730
|
+
return o._method = y.ErrorValue, o;
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Deserialize an integer back into a transparency object.
|
|
1734
|
+
*
|
|
1735
|
+
* @param value 32-bit stored transparency representation
|
|
1736
|
+
*/
|
|
1737
|
+
static deserialize(e) {
|
|
1738
|
+
const t = e >>> 24 & 255, s = e & 255, o = Object.values(y)[t] ?? y.ErrorValue, i = new v();
|
|
1739
|
+
return i._method = o, i._alpha = v.clampAlpha(s), i;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
class ue {
|
|
1209
1743
|
/**
|
|
1210
1744
|
* Creates a new task with the specified name.
|
|
1211
1745
|
*
|
|
@@ -1228,7 +1762,7 @@ class ie {
|
|
|
1228
1762
|
throw new Error("run() must be implemented by subclass");
|
|
1229
1763
|
}
|
|
1230
1764
|
}
|
|
1231
|
-
class
|
|
1765
|
+
class ce {
|
|
1232
1766
|
constructor() {
|
|
1233
1767
|
this.tasks = [], this.onProgress = () => {
|
|
1234
1768
|
}, this.onComplete = () => {
|
|
@@ -1244,9 +1778,9 @@ class le {
|
|
|
1244
1778
|
* @returns Promise that resolves with the result of the callback
|
|
1245
1779
|
*/
|
|
1246
1780
|
scheduleTask(e) {
|
|
1247
|
-
return new Promise((t,
|
|
1781
|
+
return new Promise((t, s) => {
|
|
1248
1782
|
const o = () => {
|
|
1249
|
-
Promise.resolve(e()).then(t).catch(
|
|
1783
|
+
Promise.resolve(e()).then(t).catch(s);
|
|
1250
1784
|
};
|
|
1251
1785
|
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(o) : setTimeout(o, 0);
|
|
1252
1786
|
});
|
|
@@ -1282,31 +1816,31 @@ class le {
|
|
|
1282
1816
|
*/
|
|
1283
1817
|
async run(e) {
|
|
1284
1818
|
const t = this.tasks.length;
|
|
1285
|
-
let
|
|
1819
|
+
let s = e;
|
|
1286
1820
|
for (let o = 0; o < t; o++) {
|
|
1287
1821
|
const i = this.tasks[o];
|
|
1288
1822
|
try {
|
|
1289
|
-
|
|
1290
|
-
const
|
|
1291
|
-
return this.onProgress((o + 1) / t, i),
|
|
1823
|
+
s = await this.scheduleTask(async () => {
|
|
1824
|
+
const a = await i.run(s);
|
|
1825
|
+
return this.onProgress((o + 1) / t, i), a;
|
|
1292
1826
|
});
|
|
1293
|
-
} catch (
|
|
1294
|
-
if (this.onError({ error:
|
|
1827
|
+
} catch (a) {
|
|
1828
|
+
if (this.onError({ error: a, taskIndex: o, task: i }))
|
|
1295
1829
|
break;
|
|
1296
1830
|
}
|
|
1297
1831
|
}
|
|
1298
|
-
this.onComplete(
|
|
1832
|
+
this.onComplete(s);
|
|
1299
1833
|
}
|
|
1300
1834
|
}
|
|
1301
|
-
class
|
|
1835
|
+
class re {
|
|
1302
1836
|
/**
|
|
1303
1837
|
* Create a new AcCmLoadingManager instance
|
|
1304
1838
|
* @param onLoad this function will be called when all loaders are done.
|
|
1305
1839
|
* @param onProgress this function will be called when an item is complete.
|
|
1306
1840
|
* @param onError this function will be called a loader encounters errors.
|
|
1307
1841
|
*/
|
|
1308
|
-
constructor(e, t,
|
|
1309
|
-
this.isLoading = !1, this.itemsLoaded = 0, this.itemsTotal = 0, this.urlModifier = void 0, this.handlers = [], this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError =
|
|
1842
|
+
constructor(e, t, s) {
|
|
1843
|
+
this.isLoading = !1, this.itemsLoaded = 0, this.itemsTotal = 0, this.urlModifier = void 0, this.handlers = [], this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = s;
|
|
1310
1844
|
}
|
|
1311
1845
|
/**
|
|
1312
1846
|
* This should be called by any loader using the manager when the loader starts loading an url.
|
|
@@ -1374,7 +1908,7 @@ class Q {
|
|
|
1374
1908
|
* @returns Return the registered loader for the given file path.
|
|
1375
1909
|
*/
|
|
1376
1910
|
getHandler(e) {
|
|
1377
|
-
for (let t = 0,
|
|
1911
|
+
for (let t = 0, s = this.handlers.length; t < s; t += 2) {
|
|
1378
1912
|
const o = this.handlers[t], i = this.handlers[t + 1];
|
|
1379
1913
|
if (o.global && (o.lastIndex = 0), o.test(e))
|
|
1380
1914
|
return i;
|
|
@@ -1382,14 +1916,14 @@ class Q {
|
|
|
1382
1916
|
return null;
|
|
1383
1917
|
}
|
|
1384
1918
|
}
|
|
1385
|
-
const
|
|
1386
|
-
class
|
|
1919
|
+
const se = /* @__PURE__ */ new re();
|
|
1920
|
+
class de {
|
|
1387
1921
|
/**
|
|
1388
1922
|
* Creates a new AcCmLoader instance.
|
|
1389
1923
|
* @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
|
|
1390
1924
|
*/
|
|
1391
1925
|
constructor(e) {
|
|
1392
|
-
this.manager = e !== void 0 ? e :
|
|
1926
|
+
this.manager = e !== void 0 ? e : se, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {};
|
|
1393
1927
|
}
|
|
1394
1928
|
/**
|
|
1395
1929
|
* This method is equivalent to 'load', but returns a Promise.
|
|
@@ -1400,8 +1934,8 @@ class ae {
|
|
|
1400
1934
|
* @returns Return a promise.
|
|
1401
1935
|
*/
|
|
1402
1936
|
loadAsync(e, t) {
|
|
1403
|
-
return new Promise((
|
|
1404
|
-
this.load(e,
|
|
1937
|
+
return new Promise((s, o) => {
|
|
1938
|
+
this.load(e, s, t, o);
|
|
1405
1939
|
});
|
|
1406
1940
|
}
|
|
1407
1941
|
/**
|
|
@@ -1455,24 +1989,30 @@ class ae {
|
|
|
1455
1989
|
}
|
|
1456
1990
|
}
|
|
1457
1991
|
export {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1992
|
+
B as AcCmColor,
|
|
1993
|
+
n as AcCmColorMethod,
|
|
1994
|
+
b as AcCmColorUtil,
|
|
1995
|
+
oe as AcCmEntityColor,
|
|
1996
|
+
ne as AcCmErrors,
|
|
1997
|
+
ie as AcCmEventDispatcher,
|
|
1998
|
+
D as AcCmEventManager,
|
|
1999
|
+
de as AcCmLoader,
|
|
2000
|
+
re as AcCmLoadingManager,
|
|
2001
|
+
V as AcCmObject,
|
|
2002
|
+
k as AcCmPerformanceCollector,
|
|
2003
|
+
ue as AcCmTask,
|
|
2004
|
+
ce as AcCmTaskScheduler,
|
|
2005
|
+
v as AcCmTransparency,
|
|
2006
|
+
y as AcCmTransparencyMethod,
|
|
2007
|
+
he as AcTrStringUtil,
|
|
2008
|
+
le as DEBUG_MODE,
|
|
2009
|
+
se as DefaultLoadingManager,
|
|
2010
|
+
C as clone,
|
|
2011
|
+
F as deepClone,
|
|
2012
|
+
Y as defaults,
|
|
2013
|
+
Z as has,
|
|
2014
|
+
J as isEmpty,
|
|
2015
|
+
M as isEqual,
|
|
2016
|
+
O as log,
|
|
2017
|
+
ae as setLogLevel
|
|
1478
2018
|
};
|