/* Write Custom Media from CSS File
/* ==========================================================================
966942
async function writeCustomMediaToCssFile(to, customMedia) {
	const cssContent = Object.keys(customMedia).reduce((cssLines, name) => {
		cssLines.push(`@custom-media ${name} ${customMedia[name]};`);

		return cssLines;
	}, []).join('\n');
	const css = `${cssContent}\n`;

	await writeFile(to, css);
}
175996
function (out) {
            out.write("<div class=\"" + this.CSS_CLASS + "\">");

            if (this._cfg.contentMacro) {
                out.callMacro(this._cfg.contentMacro);
            }

            out.write("</div>");
        }
3352
function cssToSss (css, file) {
    if (path.extname(file) === '.css') {
      return postcss().process(css, { stringifier: sugarss }).then(function (result) {
        return result.css
      })
    } else {
      return css
    }
  }
96183
function (out) {

                var cfg = this._cfg, cssPrefix = this._cssPrefix;

                var sizeInfo = {
                    style : '',
                    className : 'xFrameContent ' + cssPrefix + 'c ' + cfg.cssClass
                };

                this._appendInnerSizeInfo(sizeInfo);

                out.write(['<span class="xFixedHeightFrame_w ', cssPrefix, 'w">'].join(''));
                var hasBorder = this._hasBorder(this._cfg.stateObject.skipLeftBorder, this._cfg.iconsLeft);
                out.write(['<span  ', hasBorder ? '' : 'style="display:none;"', ' class="xFixedHeightFrame_bme ',
                        cssPrefix, 'b ', cssPrefix, 'bkgA"></span>'].join(''));
                this._writeExtraMarkupBegin(out);
                out.write(['<span class="xFixedHeightFrame_bme ', cssPrefix, 'm ', cssPrefix, 'bkgB" >',
                        '<span style="', sizeInfo.style, '" class="', sizeInfo.className, '">'].join(''));
            }
1253815
function flattenCss(fileName, fileContents, cssImportIgnore) {
        //Find the last slash in the name.
        fileName = fileName.replace(lang.backSlashRegExp, "/");
        var endIndex = fileName.lastIndexOf("/"),
            //Make a file path based on the last slash.
            //If no slash, so must be just a file name. Use empty string then.
            filePath = (endIndex !== -1) ? fileName.substring(0, endIndex + 1) : "";

        //Make sure we have a delimited ignore list to make matching faster
        if (cssImportIgnore && cssImportIgnore.charAt(cssImportIgnore.length - 1) !== ",") {
            cssImportIgnore += ",";
        }

        return fileContents.replace(cssImportRegExp, function (fullMatch, urlStart, importFileName, urlEnd, mediaTypes) {
            //Only process media type "all" or empty media type rules.
            if (mediaTypes && ((mediaTypes.replace(/^\s\s*/, '').replace(/\s\s*$/, '')) !== "all")) {
                return fullMatch;
            }

            importFileName = cleanCssUrlQuotes(importFileName);

            //Ignore the file import if it is part of an ignore list.
            if (cssImportIgnore && cssImportIgnore.indexOf(importFileName + ",") !== -1) {
                return fullMatch;
            }

            //Make sure we have a unix path for the rest of the operation.
            importFileName = importFileName.replace(lang.backSlashRegExp, "/");

            try {
                //if a relative path, then tack on the filePath.
                //If it is not a relative path, then the readFile below will fail,
                //and we will just skip that import.
                var fullImportFileName = importFileName.charAt(0) === "/" ? importFileName : filePath + importFileName,
                    importContents = file.readFile(fullImportFileName), i,
                    importEndIndex, importPath, fixedUrlMatch, colonIndex, parts;

                //Make sure to flatten any nested imports.
                importContents = flattenCss(fullImportFileName, importContents);

                //Make the full import path
                importEndIndex = importFileName.lastIndexOf("/");

                //Make a file path based on the last slash.
                //If no slash, so must be just a file name. Use empty string then.
                importPath = (importEndIndex !== -1) ? importFileName.substring(0, importEndIndex + 1) : "";

                //Modify URL paths to match the path represented by this file.
                importContents = importContents.replace(cssUrlRegExp, function (fullMatch, urlMatch) {
                    fixedUrlMatch = cleanCssUrlQuotes(urlMatch);
                    fixedUrlMatch = fixedUrlMatch.replace(lang.backSlashRegExp, "/");

                    //Only do the work for relative URLs. Skip things that start with / or have
                    //a protocol.
                    colonIndex = fixedUrlMatch.indexOf(":");
                    if (fixedUrlMatch.charAt(0) !== "/" && (colonIndex === -1 || colonIndex > fixedUrlMatch.indexOf("/"))) {
                        //It is a relative URL, tack on the path prefix
                        urlMatch = importPath + fixedUrlMatch;
                    } else {
                        logger.trace(importFileName + "\n  URL not a relative URL, skipping: " + urlMatch);
                    }

                    //Collapse .. and .
                    parts = urlMatch.split("/");
                    for (i = parts.length - 1; i > 0; i--) {
                        if (parts[i] === ".") {
                            parts.splice(i, 1);
                        } else if (parts[i] === "..") {
                            if (i !== 0 && parts[i - 1] !== "..") {
                                parts.splice(i - 1, 2);
                                i -= 1;
                            }
                        }
                    }

                    return "url(" + parts.join("/") + ")";
                });

                return importContents;
            } catch (e) {
                logger.trace(fileName + "\n  Cannot inline css import, skipping: " + importFileName);
                return fullMatch;
            }
        });
    }
255077
function(file) {
    var link = document.createElement("link")
    link.href = file
    link.type = "text/css"
    link.rel = "stylesheet"
    link.media = "screen,print"
    document.getElementsByTagName("head")[0].appendChild(link)
  }
396629
function writeFile(file, content) {
    fs.writeFileSync(file, content);
    files.push(path.relative(app.components.get('path'), file));
}
305279
function writeFile(filename, content) {
  fs.writeFileSync(filename, JSON.stringify(content, null, 2));
}
1282581
function(file, content, callback) {
			fs.writeFile(file, content, 'ascii', function(err) {
				callback(err ? err : null);
			});
		}
167869
function ( arg, media ) {
		return element.create( "link", {rel: "stylesheet", type: "text/css", href: arg, media: media || "print, screen"}, utility.$( "head" )[0] );
	}
1241904
function(pathname, css, req, next) {
          if (!self.options.bless) {
            fs.writeFileSync(pathname, css);
            return next();
          }
          self.splitWithBless(pathname, css);
          return next();
        }
54277
function write (item) {

  var filename = item.file;
  var message = item.message;
  var header = item.header;
  var file = path.join(p_, filename);

  fs.exists(file, function (exists) {
    if (exists) {
      fs.appendFile(file, message, function () {
        task();
      });

    } else {
      if (header) {
        message = header + EOL + message;
      }

      var dir = path.dirname(file);
      fs.exists(dir, function (exists) {
        if (exists) {
          fs.appendFile(file, message, function () {
            task();
          });

        } else {
          fs.mkdirs(dir, function (err) {
            if (err) {
              console.error(err);
              task();
            } else {
              fs.appendFile(file, message, function () {
                task();
              });
            }
          });
        }
      });
    }
  });
}
408265
function bundleCSS() {
    const glob      = require('glob');
    const srcmap    = require('./srcmap');
    const BUILT_PATH = path.join(__dirname, '..', config.dir.built);

    glob.sync('**/*.css', {
        cwd: BUILT_PATH
    }).forEach((file) => {
        const src = fs.readFileSync(path.join(BUILT_PATH, file)).toString()
            .replace(/^\ufeff/gm, '')
            .replace(/\r\n/gm, '\n')
        ;
        const node = srcmap.getNodeFromCode(src);
        node.prepend(banner('.css', path.basename(file, '.css')));
        const bundleSrc = '\ufeff' + srcmap.getCodeFromNode(node, (srcPath) => {
            const regex_src = new RegExp(`${config.dir.src}\\/${config.dir.stylesheet}\\/`);
            return srcPath
                .replace(/\.\.\//g, '')
                .replace(regex_src, SOURCE_MAP_NAMESPACE)
            ;
        }, { multiline: true });
        fs.writeFileSync(path.join(BUILT_PATH, file), bundleSrc);
        fs.writeFileSync(path.join(DST_PATH, file), bundleSrc);
    });
}
1003911
function(file, isCss) {
      var defer = new $.Deferred();
      $.ajax({
        url: file.source,
        dataType: 'text',
        success: function(data) {
          log('File Loaded:' + file.source);
          onElementLoaded(file, data);
          _bytesLoaded += file.size;
          _files[_currentSegment].splice(0, 1);
          updatePercentage();
          // IE8/7 fix
          // http://stackoverflow.com/questions/805384/how-to-apply-inline-and-or-external-css-loaded-dynamically-with-jquery
          if (isCss)
            if (document.createStyleSheet) {
              try {
                document.createStyleSheet(file.source);
              } catch (e) {}
            } else {
              var css;
              css = document.createElement('link');
              css.rel = 'stylesheet';
              css.type = 'text/css';
              css.media = 'all';
              css.href = file.source;
              $head[0].appendChild(css);
            }

          defer.resolve(data);
        }
      });

      return defer.promise();
    }
1019704
function(options) {
    options.resources = {
        css: [],
        js: []
    };
    // - copy template css file
    options.resources.css.push(fileResolver(
        options,
        require.resolve('./resources/docco-template.css')
    ));
    // - copy jquery js file
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jquery/dist/jquery.min.js')
    ));
    // - copy jstree distribution js
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jstree/dist/jstree.js')
    ));
    // - copy jstree search plugin js
    options.resources.js.push(fileResolver(
        options,
        require.resolve('jstree/src/jstree.search.js')
    ));
    // - copy jstree distribution css
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/style.min.css')
    ));
    // - copy jstree distribution images
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/32px.png'),
        '32px.png'
    ));
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/40px.png'),
        '40px.png'
    ));
    options.resources.css.push(fileResolver(
        options,
        require.resolve('jstree/dist/themes/default-dark/throbber.gif'),
        'throbber.gif'
    ));
    // - copy bootstrap js file
    options.resources.js.push(fileResolver(
        options,
        require.resolve('./resources/bootstrap.js')
    ));
    // - copy highlightjs style
    options.resources.css.push(fileResolver(
        options,
        require.resolve('highlight.js/styles/' + options.highlightStyle + '.css')
    ));
    // - copy markdown style
    options.resources.css.push(fileResolver(
        options,
        require.resolve('./resources/gfm.css')
    ));
    // -copy config.css
    if (options.css) {
        options.resources.css.push(fileResolver(
            options,
            options.css
        ));
    }
    return options;
}
702001
function (out) {
            var cfg = this._cfg, cssPrefix = this._cssPrefix; // sclass = cfg.sclass
            out.write(['</span></td>', '<td class="', cssPrefix, 'rs ', cssPrefix, 'bkgC"></td>', '</tr>', '<tr>',
                    '<td class="', cssPrefix, 'blc ', cssPrefix, 'bkgA"></td>', '<td class="', cssPrefix, 'bs ',
                    cssPrefix, 'bkgB">', this.__addFrameIcon(cfg, cssPrefix, 'bottom'), '</td>', '<td class="',
                    cssPrefix, 'brc ', cssPrefix, 'bkgA"></td>', '</tr>', '</tbody></table>'].join(''));

        }
1061229
function generate(file, template, context, minifyResult) {
  let string = template.render(context, {
    'styles.css': templates.styles,
    'embed.js': templates.embedJs
  });
  if (minifyResult) {
    string = minify(string, {
      caseSensitive: true,
      collapseWhitespace: true,
      html5: true,
      minifyCSS: true,
      minifyJS: true,
      removeComments: true,
      removeAttributeQuotes: true
    });
  };
  writeFile(path.join(context.config.destRoot, file), string);
}