text: /**
  * @license Apache-2.0
  *
  * Copyright (c) 2021 The Stdlib Authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  
  'use strict';
  
  // MODULES //
  
  var isFunction = require( '@stdlib/assert/is-function' );
  var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
  var copy = require( '@stdlib/utils/copy' );
  var validate = require( './validate.js' );
  var defaults = require( './defaults.json' );
  var query = require( './query.js' );
  
  
  // VARIABLES //
  
  var DEFAULT_HTTP_PORT = 80;
  var DEFAULT_HTTPS_PORT = 443;
  
  
  // MAIN //
  
  /**
  * Returns a function for creating a GitHub repository.
  *
  * @param {Object} options - function options
  * @param {string} options.token - GitHub access token
  * @param {string} [options.useragent] - user agent string
  * @param {string} [options.org] - organization name
  * @param {string} [options.desc=""] - repository description
  * @param {string} [options.homepage=""] - repository homepage
  * @param {number} [options.team] - team id (organizations)
  * @param {string} [options.gitignore] - .gitignore template
  * @param {string} [options.license] - LICENSE template
  * @param {boolean} [options.private=false] - boolean indicating whether a repository should be private
  * @param {boolean} [options.issues=true] - boolean indicating whether issues should be enabled
  * @param {boolean} [options.projects=true] - boolean indicating whether project boards should be enabled
  * @param {boolean} [options.wiki=true] - boolean indicating whether a repository should have a wiki
  * @param {boolean} [options.downloads=true] - boolean indicating whether downloads should be enabled
  * @param {boolean} [options.init=false] - boolean indicating whether to initialize the repository with an empty README
  * @param {boolean} [options.allowSquashMerge=true] - boolean indicating whether to allow squash-merging
  * @param {boolean} [options.allowMergeCommit=true] - boolean indicating whether to allow merging pull requests with a merge commit
  * @param {boolean} [options.allowRebaseMerge=true] - boolean indicating whether to allow rebase-merging pull requests
  * @param {Function} clbk - callback to invoke upon query completion
  * @throws {TypeError} callback argument must be a function
  * @returns {Function} function for creating a GitHub repository
  */
  function factory( options, clbk ) {
  	var opts;
  	var err;
  	opts = copy( defaults );
  	err = validate( opts, options );
  	if ( err ) {
  		throw err;
  	}
  	if ( opts.port === null ) {
  		if ( opts.protocol === 'https' ) {
  			opts.port = DEFAULT_HTTPS_PORT;
  		} else {
  			opts.port = DEFAULT_HTTP_PORT;
  		}
  	}
  	if ( !isFunction( clbk ) ) {
  		throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
  	}
  	return createRepo;
  
  	/**
  	* Creates a GitHub repository.
  	*
  	* @private
  	* @param {string} name - repository name
  	* @throws {TypeError} repository name must be a string primitive
  	* @returns {void}
  	*/
  	function createRepo( name ) {
  		if ( !isString( name ) ) {
  			throw new TypeError( 'invalid argument. Repository name must be a string primitive. Value: `' + name + '`.' );
  		}
  		query( name, opts, done );
  		/**
  		* Callback invoked after receiving an API response.
  		*
  		* @private
  		* @param {(Error|null)} error - error object
  		* @param {ObjectArray} data - query data
  		* @param {Object} info - response info
  		* @returns {void}
  		*/
  		function done( error, data, info ) {
  			error = error || null;
  			data = data || null;
  			info = info || null;
  			clbk( error, data, info );
  		}
  	}
  }
  
  
  // EXPORTS //
  
  module.exports = factory;
  