Flip East and West in rules like cursor: nw-resize;
@param $css string
@return string
772060
private static function fixCursorProperties($css) {
		$css = preg_replace(
			self::$patterns['cursor_east'],
			'$1' . self::$patterns['tmpToken'],
			$css
		);
		$css = preg_replace(self::$patterns['cursor_west'], '$1e-resize', $css);
		$css = str_replace(self::$patterns['tmpToken'], 'w-resize', $css);

		return $css;
	}
988908
private function getCss($cssFiles = array())
    {
        $css = '';
        foreach ($cssFiles as $file) {
            if (file_exists($file)) {
                $css .= file_get_contents($file) . "\n";
            }
        }
        return $css;
    }
793092
protected function stripPrependCssCharsetUtf8($css)
    {
        if (!($css = (string) $css)) {
            return $css; // Nothing to do.
        }
        $css        = $this->stripExistingCssCharsets($css);
        return $css = $css ? '@charset "UTF-8";'."\n".$css : $css;
    }
765225
public static function parse_css($styles='') {
		ref\cast::string($styles, true);

		// Remove comments.
		while (false !== ($start = mb::strpos($styles, '/*'))) {
			if (false !== ($end = mb::strpos($styles, '*/'))) {
				$styles = \str_replace(
					mb::substr($styles, $start, ($end - $start + 2)),
					'',
					$styles
				);
			}
			else {
				$styles = mb::substr($styles, 0, $start);
			}
		}

		// A few more types of comment wrappers we might see.
		$styles = \str_replace(
			array('<!--', '//-->', '-->', '//<![CDATA[', '//]]>', '<![CDATA[', ']]>'),
			'',
			$styles
		);

		// Standardize quoting.
		ref\sanitize::quotes($styles);
		$styles = \str_replace("'", '"', $styles);

		// Whitespace.
		ref\sanitize::whitespace($styles, 0);

		// Early bail.
		if (! $styles) {
			return array();
		}

		// Substitute brackets for unlikely characters to make parsing easier
		// hopefully nobody's using braille in their stylesheets...
		$styles = \preg_replace('/\{(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u', '⠁', $styles);
		$styles = \preg_replace('/\}(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u', '⠈', $styles);

		// Put spaces behind and after parentheses.
		$styles = \preg_replace(
			'/\s*(\()\s*(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u',
			' (',
			$styles
		);
		$styles = \preg_replace(
			'/\s*(\))\s*(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u',
			') ',
			$styles
		);

		// Make sure {} have no whitespace on either end.
		$styles = \preg_replace('/\s*(⠁|⠈|@)\s*/u', '$1', $styles);

		// Push @ rules to their own lines.
		$styles = \str_replace('@', "\n@", $styles);
		$styles = \explode("\n", $styles);
		$styles = \array_map('trim', $styles);

		// Push all rulesets to their own lines (leaving @media-type ones on their own for now).
		foreach ($styles as $k=>$v) {
			// @rule.
			if (0 === \strpos($styles[$k], '@')) {
				// Nested, like @media.
				if (false !== \strpos($styles[$k], '⠈⠈')) {
					$styles[$k] = \preg_replace('/(⠈{2,})/u', "$1\n", $styles[$k]);
				}
				// Not nested, but has properties, like @font-face.
				elseif (false !== \strpos($styles[$k], '⠈')) {
					$styles[$k] = \str_replace('⠈', "⠈\n", $styles[$k]);
				}
				// Just a line, like @import.
				elseif (\preg_match('/;(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/', $styles[$k])) {
					$styles[$k] = \preg_replace(
						'/;(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u',
						";\n",
						$styles[$k],
						1
					);
				}

				$tmp = \explode("\n", $styles[$k]);
				$length = \count($tmp);
				for ($x = 1; $x < $length; ++$x) {
					$tmp[$x] = \str_replace('⠈', "⠈\n", $tmp[$x]);
				}
				$styles[$k] = \implode("\n", $tmp);
			}// end @.
			else {
				$styles[$k] = \str_replace('⠈', "⠈\n", $styles[$k]);
			}
		}
		$styles = \implode("\n", $styles);

		// One more quick formatting thing, we can get rid of spaces
		// between closing) and punctuation.
		$styles = \preg_replace(
			'/\)\s(,|;)(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u',
			')$1',
			$styles
		);

		// And between RGB/URL stuff.
		$styles = \preg_replace('/(url|rgba?)\s+\(/', '$1(', $styles);

		$styles = \explode("\n", $styles);
		$styles = \array_filter($styles, 'strlen');

		$out = array();

		// One more time around!
		foreach ($styles as $k=>$v) {
			$styles[$k] = \trim($styles[$k]);

			// Nested rule.
			if (
				(0 === \strpos($styles[$k], '@')) &&
				(false !== \strpos($styles[$k], '⠈⠈'))
			) {
				$tmp = constants::CSS_NESTED;

				// What kind of @ is this?
				\preg_match_all('/^@([a-z\-]+)/ui', $styles[$k], $matches);
				$tmp['@'] = mb::strtolower($matches[1][0]);

				// Find the outermost bit.
				if (false === ($start = mb::strpos($styles[$k], '⠁'))) {
					continue;
				}

				$tmp['selector'] = mb::strtolower(
					\trim(
						mb::substr($styles[$k], 0, $start)
					),
					false,
					true
				);
				$chunk = mb::substr($styles[$k], $start + 1, -1);
				$chunk = \str_replace(array('⠁', '⠈'), array('{', '}'), $chunk);
				$tmp['nest'] = static::parse_css($chunk);

				// And build the raw.
				$tmp['raw'] = $tmp['selector'] . '{';
				foreach ($tmp['nest'] as $n) {
					$tmp['raw'] .= $n['raw'];
				}
				$tmp['raw'] .= '}';
			}// end @.
			else {
				$tmp = constants::CSS_FLAT;

				if (0 === \strpos($styles[$k], '@')) {
					// What kind of @ is this?
					\preg_match_all('/^@([a-z\-]+)/ui', $styles[$k], $matches);
					$tmp['@'] = mb::strtolower($matches[1][0], false);
				}

				// A normal {k:v, k:v}.
				\preg_match_all('/^([^⠁]+)⠁([^⠈]*)⠈/u', $styles[$k], $matches);
				if (\count($matches[0])) {
					// Sorting out selectors is easy.
					$tmp['selectors'] = \explode(',', $matches[1][0]);
					$tmp['selectors'] = \array_map('trim', $tmp['selectors']);

					// Rules a little trickier.
					$rules = \explode(';', $matches[2][0]);
					$rules = \array_map('trim', $rules);
					$rules = \array_filter($rules, 'strlen');
					if (! \count($rules)) {
						continue;
					}

					foreach ($rules as $k2=>$v2) {
						$rules[$k2] = \rtrim($rules[$k2], ';') . ';';
						if (\preg_match(
							'/:(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/',
							$rules[$k2]
						)) {
							$rules[$k2] = \preg_replace(
								'/:(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)/u',
								"\n",
								$rules[$k2],
								1
							);
							list($key, $value) = \explode("\n", $rules[$k2]);
							$key = mb::strtolower(\trim($key), false);
							$value = \trim($value);
							$tmp['rules'][$key] = $value;
						}
						else {
							$tmp['rules']['__NONE__'] = $value;
						}
					}

					// Build the raw.
					$tmp['raw'] = \implode(',', $tmp['selectors']) . '{';
					foreach ($tmp['rules'] as $k=>$v) {
						if ('__NONE__' === $k) {
							$tmp['raw'] .= $v;
						}
						else {
							$tmp['raw'] .= "$k:$v";
						}
					}
					$tmp['raw'] .= '}';
				}
				// Who knows?
				else {
					$styles[$k] = \str_replace(array('⠁', '⠈'), array('{', '}'), $styles[$k]);
					$styles[$k] = \trim(\rtrim(\trim($styles[$k]), ';'));
					if (\substr($styles[$k], -1) !== '}') {
						$styles[$k] .= ';';
					}
					$tmp['rules'][] = $styles[$k];
					$tmp['raw'] = $styles[$k];
				}
			}

			$out[] = $tmp;
		}

		return $out;
	}
712413
public static function extractImports($css)
    {
        $imports = [];
        preg_match_all(static::IMPORT_PATTERN, $css, $matches, PREG_SET_ORDER);
        if (empty($matches)) {
            return $imports;
        }
        foreach ($matches as $match) {
            $url = empty($match[2]) ? $match[4] : $match[2];
            $imports[] = $url;
        }
        return $imports;
    }
479670
public function convertToRadius($css)
    {
        // explode the value
        $css = explode(' ', $css);

        foreach ($css as $k => $v) {
            $v = trim($v);
            if ($v) {
                $v = $this->convertToMM($v, 0);
                if ($v!==null) {
                    $css[$k] = $v;
                } else {
                    unset($css[$k]);
                }
            } else {
                unset($css[$k]);
            }
        }

        return array_values($css);
    }
101140
private function replaceLocalUrlTags($css)
    {
        $urlMatches = array();

        preg_match_all(
            '!url\((?P<urls>.[^)]*)\)!isU',
            $css, $urlMatches
        );

        foreach ($urlMatches[0] as $key => $tag) {
            if (!$this->isExternalStylesheet($tag)) {
                $url = $this->getBasePath() . $urlMatches['urls'][$key];

                $css = str_replace(
                    $tag,
                    'url(' . $url . ')',
                    $css
                );
            }
        }

        return $css;
    }
834067
public function getCss(){

		$precision = ini_get('precision');
		@ini_set('precision',16);
		$locale = setlocale(LC_NUMERIC, 0);
		setlocale(LC_NUMERIC, "C");

		try {

	 		$root = new Less_Tree_Ruleset(array(), $this->rules );
			$root->root = true;
			$root->firstRoot = true;


			$this->PreVisitors($root);

			self::$has_extends = false;
			$evaldRoot = $root->compile($this->env);



			$this->PostVisitors($evaldRoot);

			if( Less_Parser::$options['sourceMap'] ){
				$generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options );
				// will also save file
				// FIXME: should happen somewhere else?
				$css = $generator->generateCSS();
			}else{
				$css = $evaldRoot->toCSS();
			}

			if( Less_Parser::$options['compress'] ){
				$css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css);
			}

		} catch (Exception $exc) {
			// Intentional fall-through so we can reset environment
		}

		//reset php settings
		@ini_set('precision',$precision);
		setlocale(LC_NUMERIC, $locale);

		// If you previously defined $this->mb_internal_encoding
		// is required to return the encoding as it was before
		if ($this->mb_internal_encoding != '') {
			@ini_set("mbstring.internal_encoding", $this->mb_internal_encoding);
			$this->mb_internal_encoding = '';
		}

		// Rethrow exception after we handled resetting the environment
		if (!empty($exc)) {
			throw $exc;
		}



		return $css;
	}
508448
public static function css($css = null)
    {
        if (!is_null($css)) {
            return self::$css = array_merge(self::$css, (array) $css);
        }

        if (!$css = static::getMinifiedCss()) {
            $css = array_merge(static::$css, static::baseCss());
        }

        $css = array_filter(array_unique($css));

        return view('admin::partials.css', compact('css'));
    }
1330172
public static function baseCss($css = null)
    {
        if (!is_null($css)) {
            return static::$baseCss = $css;
        }

        $skin = config('admin.skin', 'skin-blue-light');

        array_unshift(static::$baseCss, "vendor/laravel-admin/AdminLTE/dist/css/skins/{$skin}.min.css");

        return static::$baseCss;
    }
448575
public function flip($direction)
    {

        $new = imagecreatetruecolor($this->width, $this->height);
        imagealphablending($new, false);
        imagesavealpha($new, true);

        switch (strtolower($direction)) {

            case 'y':
                for ($y = 0; $y < $this->height; $y++) {
                    imagecopy($new, $this->image, 0, $y, 0, $this->height - $y - 1, $this->width, 1);
                }
                break;

            default:
                for ($x = 0; $x < $this->width; $x++) {
                    imagecopy($new, $this->image, $x, 0, $this->width - $x - 1, 0, 1, $this->height);
                }
                break;

        }

        $this->image = $new;

        return $this;

    }
1362354
public function siblings($css = null)
    {
        $query = $this->_document->getQuery();

        $nodes = [];
        foreach ($this->_nodes as $node) {
            $cur_xpath = $node->getNodePath();
            foreach ($query->css('parent::' . ($css ?: '*'), $node) as $node2) {
                /**
                 * @var \DOMNode $node2
                 */
                /** @noinspection SlowArrayOperationsInLoopInspection */
                if ($node2->getNodePath() !== $cur_xpath) {
                    $nodes[$node2->getNodePath()] = $node2;
                }
            }
        }

        return new SelectorList($this, array_values($nodes));
    }
490523
private static function fixLeftAndRight($css) {
		$css = preg_replace(self::$patterns['left'], self::$patterns['tmpToken'], $css);
		$css = preg_replace(self::$patterns['right'], 'left', $css);
		$css = str_replace(self::$patterns['tmpToken'], 'right', $css);

		return $css;
	}
1281323
public function html_first($css)
    {
        if ($nodes = $this->_document->getQuery()->css($css, $this->_node)) {
            $node = $nodes->item(0);
            return $node->ownerDocument->saveHTML($node);
        } else {
            return null;
        }
    }
475804
protected function process($css)
        {
            $css = str_replace("\r\n", "\n", $css);

            // preserve empty comment after '>'
            // http://www.webdevout.net/css-hacks#in_css-selectors
            $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);

            // preserve empty comment between property and value
            // http://css-discuss.incutio.com/?page=BoxModelHack
            $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
            $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);

            // apply callback to all valid comments (and strip out surrounding ws
            $css = preg_replace_callback(
                '@\\s*/\\*([\\s\\S]*?)\\*/\\s*@',
                array(
                    $this,
                    '_commentCB'
                ),
                $css
            );

            // remove ws around { } and last semicolon in declaration block
            $css = preg_replace('/\\s*{\\s*/', '{', $css);
            $css = preg_replace('/;?\\s*}\\s*/', '}', $css);

            // remove ws surrounding semicolons
            $css = preg_replace('/\\s*;\\s*/', ';', $css);

            // remove ws around urls
            $css = preg_replace('/
                    url\\(      # url(
                    \\s*
                    ([^\\)]+?)  # 1 = the URL (really just a bunch of non right parenthesis)
                    \\s*
                    \\)         # )
                /x',
                'url($1)',
                $css
            );

            // remove ws between rules and colons
            $css = preg_replace('/
                    \\s*
                    ([{;])              # 1 = beginning of block or rule separator
                    \\s*
                    ([\\*_]?[\\w\\-]+)  # 2 = property (and maybe IE filter)
                    \\s*
                    :
                    \\s*
                    (\\b|[#\'"])        # 3 = first character of a value
                /x',
                '$1$2:$3',
                $css
            );

            // remove ws in selectors
            $css = preg_replace_callback('/
                    (?:              # non-capture
                        \\s*
                        [^~>+,\\s]+  # selector part
                        \\s*
                        [,>+~]       # combinators
                    )+
                    \\s*
                    [^~>+,\\s]+      # selector part
                    {                # open declaration block
                /x',
                array(
                    $this,
                    '_selectorsCB'
                ),
                $css
            );

            // minimize hex colors
            $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i', '$1#$2$3$4$5', $css);

            // remove spaces between font families
            $css = preg_replace_callback('/font-family:([^;}]+)([;}])/', array($this, '_fontFamilyCB'), $css);

            $css = preg_replace('/@import\\s+url/', '@import url', $css);

            // replace any ws involving newlines with a single newline
            $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);

            // separate common descendent selectors w/ newlines (to limit line lengths)
            $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);

            // Use newline after 1st numeric value (to limit line lengths).
            $css = preg_replace('/
                ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
                \\s+
                /x',
                "$1\n",
                $css
            );

            // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
            $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);

            return trim($css);
        }
534260
function rightMargin( $yOffset = false )
    {
        if ( $yOffset === false )
        {
            $yOffset = $this->yOffset();
        }

        foreach ( $this->RightMarginArray as $rightMargin )
        {
            if ( $yOffset > $rightMargin['start'] &&
                 $yOffset < $rightMargin['stop'] )
            {
                return $rightMargin['margin'];
            }
        }

        return $this->ez['rightMargin'];
    }
1184845
private function splitIntoRules($css)
	{
		$rules = preg_split('/}/', trim($this->stripComments($css)));

		// complete any rules by append } to them
		array_walk($rules,
			function (&$s) {
				!empty($s) && $s = trim("$s}");
			});

		// clears out any empty rules
		return array_filter($rules);
	}