"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// node_modules/string-template/index.js
var require_string_template = __commonJS({
  "node_modules/string-template/index.js"(exports2, module2) {
    "use strict";
    var nargs = /\{([0-9a-zA-Z_]+)\}/g;
    module2.exports = template;
    function template(string) {
      var args;
      if (arguments.length === 2 && typeof arguments[1] === "object") {
        args = arguments[1];
      } else {
        args = new Array(arguments.length - 1);
        for (var i = 1; i < arguments.length; ++i) {
          args[i - 1] = arguments[i];
        }
      }
      if (!args || !args.hasOwnProperty) {
        args = {};
      }
      return string.replace(nargs, function replaceArg(match, i2, index) {
        var result;
        if (string[index - 1] === "{" && string[index + match.length] === "}") {
          return i2;
        } else {
          result = args.hasOwnProperty(i2) ? args[i2] : null;
          if (result === null || result === void 0) {
            return "";
          }
          return result;
        }
      });
    }
  }
});

// packages/@ng-atomic/schematics/src/lib/style-header/index.ts
var style_header_exports = {};
__export(style_header_exports, {
  default: () => style_header_default
});
module.exports = __toCommonJS(style_header_exports);
var import_strings = require("@angular-devkit/core/src/utils/strings");
var import_string_template = __toESM(require_string_template());
var import_path = require("path");

// packages/@ng-atomic/schematics/src/lib/_utilities/save-file.ts
function saveFile(host, path, callback) {
  host.exists(path) ? host.overwrite(path, callback(host.read(path).toString("utf-8"))) : host.create(path, callback(""));
  return host;
}

// packages/@ng-atomic/schematics/src/lib/style-header/index.ts
var buildOptions = (options) => ({
  ...options,
  name: options?.name || (0, import_path.basename)(options.path, ".scss").split(".")?.[0],
  type: options?.type || (0, import_path.basename)(options.path, ".scss").split(".").reverse()?.[0]
});
var buildStyle = ({ styleHeader, name, type }) => (0, import_string_template.default)(styleHeader, { name: (0, import_strings.dasherize)(name), type });
var style_header_default = (_options) => (host) => {
  const { path, ...extra } = buildOptions(_options);
  return saveFile(host, path, (src) => `${buildStyle(extra)}${src}`);
};
//# sourceMappingURL=index.js.map
