PageSourceSearch

https://www.iowaattorneygeneral.gov/core/modules/system/dependenci…ilities-53e391bb3a38dcb760494d9e37e79e3a.js

js iowaattorneygeneral.gov collected 2026-10-02 02:40:49 UTC 2,451 bytes, 145 lines download raw bytes

1export default class pluginUtilities {
2
3	// Lighten a color by increasing lightness
4	static lightenColor(color, amount = 25) {
5		const rgb = this.#parseColor(color);
6		const hsl = this.#rgbToHsl(rgb.r, rgb.g, rgb.b);
7
8		// Increase lightness, cap at 90% to avoid white
9		hsl.l = Math.min(90, hsl.l + amount);
10
11		const newRgb = this.#hslToRgb(hsl.h, hsl.s, hsl.l);
12
13		return `rgb(${newRgb.r}, ${newRgb.g}, ${newRgb.b})`;
14	}
15
16	/* Private Methods */
17
18	// Convert any color format to RGB values
19	static #parseColor(color) {
20		// Create a temporary element to parse the color
21		const temp = document.createElement("div");
22
23		temp.style.color = color;
24
25		document.body.appendChild(temp);
26
27		const computed = window.getComputedStyle(temp).color;
28
29		document.body.removeChild(temp);
30
31		// Extract RGB values from computed style (returns "rgb(r, g, b)" or "rgba(r, g, b, a)")
32		const match = computed.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
33
34		if (match) {
35			return {
36				r: parseInt(match[1]),
37				g: parseInt(match[2]),
38				b: parseInt(match[3])
39			};
40		}
41
42		// Fallback to default blue
43		return {
44			r: 0,
45			g: 102,
46			b: 204
47		};
48	}
49
50	// Convert RGB to HSL
51	static #rgbToHsl(r, g, b) {
52		r /= 255;
53		g /= 255;
54		b /= 255;
55
56		const max = Math.max(r, g, b);
57		const min = Math.min(r, g, b);
58
59		let h, s, l = (max + min) / 2;
60
61		if (max === min) {
62			h = s = 0;
63		}
64		else {
65			const d = max - min;
66
67			s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
68
69			switch (max) {
70				case r:
71					h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
72
73					break;
74
75				case g:
76					h = ((b - r) / d + 2) / 6;
77
78					break;
79
80				case b:
81					h = ((r - g) / d + 4) / 6;
82
83					break;
84			}
85		}
86
87		return {
88			h: h * 360,
89			s: s * 100,
90			l: l * 100
91		};
92	}
93
94	// Convert HSL to RGB
95	static #hslToRgb(h, s, l) {
96		h /= 360;
97		s /= 100;
98		l /= 100;
99
100		let r, g, b;
101
102		if (s === 0) {
103			r = g = b = l;
104		}
105		else {
106			const hue2rgb = (p, q, t) => {
107				if (t < 0) {
108					t += 1;
109				}
110
111				if (t > 1) {
112					t -= 1;
113				}
114
115				if (t < 1/6) {
116					return p + (q - p) * 6 * t;
117				}
118
119				if (t < 1/2) {
120					return q;
121				}
122
123				if (t < 2/3) {
124					return p + (q - p) * (2/3 - t) * 6;
125				}
126
127				return p;
128			};
129
130			const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
131			const p = 2 * l - q;
132
133			r = hue2rgb(p, q, h + 1/3);
134			g = hue2rgb(p, q, h);
135			b = hue2rgb(p, q, h - 1/3);
136		}
137
138		return {
139			r: Math.round(r * 255),
140			g: Math.round(g * 255),
141			b: Math.round(b * 255)
142		};
143	}
144
145}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.