text: import AppKit
  import Foundation
  
  // MARK: - PublishNeedsAuth
  
  public class PublishNeedsAuth: NSBox {
  
    // MARK: Lifecycle
  
    public init(_ parameters: Parameters) {
      self.parameters = parameters
  
      super.init(frame: .zero)
  
      setUpViews()
      setUpConstraints()
  
      update()
    }
  
    public convenience init(workspaceName: String) {
      self.init(Parameters(workspaceName: workspaceName))
    }
  
    public convenience init() {
      self.init(Parameters())
    }
  
    public required init?(coder aDecoder: NSCoder) {
      self.parameters = Parameters()
  
      super.init(coder: aDecoder)
  
      setUpViews()
      setUpConstraints()
  
      update()
    }
  
    // MARK: Public
  
    public var workspaceName: String {
      get { return parameters.workspaceName }
      set {
        if parameters.workspaceName != newValue {
          parameters.workspaceName = newValue
        }
      }
    }
  
    public var onClickGithubButton: (() -> Void)? {
      get { return parameters.onClickGithubButton }
      set { parameters.onClickGithubButton = newValue }
    }
  
    public var onClickGoogleButton: (() -> Void)? {
      get { return parameters.onClickGoogleButton }
      set { parameters.onClickGoogleButton = newValue }
    }
  
    public var parameters: Parameters {
      didSet {
        if parameters != oldValue {
          update()
        }
      }
    }
  
    // MARK: Private
  
    private var titleContainerView = NSBox()
    private var publishTextView = LNATextField(labelWithString: "")
    private var workspaceTitleView = LNATextField(labelWithString: "")
    private var vSpacerView = NSBox()
    private var bodyTextView = LNATextField(labelWithString: "")
    private var vSpacer1View = NSBox()
    private var viewView = NSBox()
    private var gitHubButtonView = PrimaryButton()
    private var vSpacer2View = NSBox()
    private var googleButtonView = PrimaryButton()
  
    private var publishTextViewTextStyle = TextStyles.titleLight
    private var workspaceTitleViewTextStyle = TextStyles.title
    private var bodyTextViewTextStyle = TextStyles.body
  
    private func setUpViews() {
      boxType = .custom
      borderType = .noBorder
      contentViewMargins = .zero
      titleContainerView.boxType = .custom
      titleContainerView.borderType = .noBorder
      titleContainerView.contentViewMargins = .zero
      vSpacerView.boxType = .custom
      vSpacerView.borderType = .noBorder
      vSpacerView.contentViewMargins = .zero
      bodyTextView.lineBreakMode = .byWordWrapping
      vSpacer1View.boxType = .custom
      vSpacer1View.borderType = .noBorder
      vSpacer1View.contentViewMargins = .zero
      viewView.boxType = .custom
      viewView.borderType = .noBorder
      viewView.contentViewMargins = .zero
      publishTextView.lineBreakMode = .byWordWrapping
      workspaceTitleView.lineBreakMode = .byWordWrapping
      vSpacer2View.boxType = .custom
      vSpacer2View.borderType = .noBorder
      vSpacer2View.contentViewMargins = .zero
  
      addSubview(titleContainerView)
      addSubview(vSpacerView)
      addSubview(bodyTextView)
      addSubview(vSpacer1View)
      addSubview(viewView)
      titleContainerView.addSubview(publishTextView)
      titleContainerView.addSubview(workspaceTitleView)
      viewView.addSubview(gitHubButtonView)
      viewView.addSubview(vSpacer2View)
      viewView.addSubview(googleButtonView)
  
      publishTextView.attributedStringValue = publishTextViewTextStyle.apply(to: "Publish ")
      publishTextViewTextStyle = TextStyles.titleLight
      publishTextView.attributedStringValue = publishTextViewTextStyle.apply(to: publishTextView.attributedStringValue)
      workspaceTitleViewTextStyle = TextStyles.title
      workspaceTitleView.attributedStringValue =
        workspaceTitleViewTextStyle.apply(to: workspaceTitleView.attributedStringValue)
      vSpacerView.fillColor = #colorLiteral(red: 0.847058823529, green: 0.847058823529, blue: 0.847058823529, alpha: 1)
      bodyTextView.attributedStringValue =
        bodyTextViewTextStyle
          .apply(to:
          "Lona can automatically generate a website and design/code libraries from your workspace. In order to do this, you’ll need to connect a GitHub or Google account.")
      bodyTextViewTextStyle = TextStyles.body
      bodyTextView.attributedStringValue = bodyTextViewTextStyle.apply(to: bodyTextView.attributedStringValue)
      vSpacer1View.fillColor = #colorLiteral(red: 0.847058823529, green: 0.847058823529, blue: 0.847058823529, alpha: 1)
      gitHubButtonView.titleText = "Sign in with GitHub"
      vSpacer2View.fillColor = #colorLiteral(red: 0.847058823529, green: 0.847058823529, blue: 0.847058823529, alpha: 1)
      googleButtonView.titleText = "Sign in with Google"
    }
  
    private func setUpConstraints() {
      translatesAutoresizingMaskIntoConstraints = false
      titleContainerView.translatesAutoresizingMaskIntoConstraints = false
      vSpacerView.translatesAutoresizingMaskIntoConstraints = false
      bodyTextView.translatesAutoresizingMaskIntoConstraints = false
      vSpacer1View.translatesAutoresizingMaskIntoConstraints = false
      viewView.translatesAutoresizingMaskIntoConstraints = false
      publishTextView.translatesAutoresizingMaskIntoConstraints = false
      workspaceTitleView.translatesAutoresizingMaskIntoConstraints = false
      gitHubButtonView.translatesAutoresizingMaskIntoConstraints = false
      vSpacer2View.translatesAutoresizingMaskIntoConstraints = false
      googleButtonView.translatesAutoresizingMaskIntoConstraints = false
  
      let titleContainerViewTopAnchorConstraint = titleContainerView.topAnchor.constraint(equalTo: topAnchor)
      let titleContainerViewLeadingAnchorConstraint = titleContainerView.leadingAnchor.constraint(equalTo: leadingAnchor)
      let titleContainerViewTrailingAnchorConstraint = titleContainerView
        .trailingAnchor
        .constraint(equalTo: trailingAnchor)
      let vSpacerViewTopAnchorConstraint = vSpacerView.topAnchor.constraint(equalTo: titleContainerView.bottomAnchor)
      let vSpacerViewLeadingAnchorConstraint = vSpacerView.leadingAnchor.constraint(equalTo: leadingAnchor)
      let bodyTextViewTopAnchorConstraint = bodyTextView.topAnchor.constraint(equalTo: vSpacerView.bottomAnchor)
      let bodyTextViewLeadingAnchorConstraint = bodyTextView.leadingAnchor.constraint(equalTo: leadingAnchor)
      let bodyTextViewTrailingAnchorConstraint = bodyTextView.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor)
      let vSpacer1ViewTopAnchorConstraint = vSpacer1View.topAnchor.constraint(equalTo: bodyTextView.bottomAnchor)
      let vSpacer1ViewLeadingAnchorConstraint = vSpacer1View.leadingAnchor.constraint(equalTo: leadingAnchor)
      let viewViewBottomAnchorConstraint = viewView.bottomAnchor.constraint(equalTo: bottomAnchor)
      let viewViewTopAnchorConstraint = viewView.topAnchor.constraint(equalTo: vSpacer1View.bottomAnchor)
      let viewViewLeadingAnchorConstraint = viewView.leadingAnchor.constraint(equalTo: leadingAnchor)
      let publishTextViewHeightAnchorParentConstraint = publishTextView
        .heightAnchor
        .constraint(lessThanOrEqualTo: titleContainerView.heightAnchor)
      let workspaceTitleViewHeightAnchorParentConstraint = workspaceTitleView
        .heightAnchor
        .constraint(lessThanOrEqualTo: titleContainerView.heightAnchor)
      let publishTextViewLeadingAnchorConstraint = publishTextView
        .leadingAnchor
        .constraint(equalTo: titleContainerView.leadingAnchor)
      let publishTextViewTopAnchorConstraint = publishTextView.topAnchor.constraint(equalTo: titleContainerView.topAnchor)
      let publishTextViewBottomAnchorConstraint = publishTextView
        .bottomAnchor
        .constraint(equalTo: titleContainerView.bottomAnchor)
      let workspaceTitleViewLeadingAnchorConstraint = workspaceTitleView
        .leadingAnchor
        .constraint(equalTo: publishTextView.trailingAnchor)
      let workspaceTitleViewTopAnchorConstraint = workspaceTitleView
        .topAnchor
        .constraint(equalTo: titleContainerView.topAnchor)
      let workspaceTitleViewBottomAnchorConstraint = workspaceTitleView
        .bottomAnchor
        .constraint(equalTo: titleContainerView.bottomAnchor)
      let vSpacerViewHeightAnchorConstraint = vSpacerView.heightAnchor.constraint(equalToConstant: 32)
      let vSpacerViewWidthAnchorConstraint = vSpacerView.widthAnchor.constraint(equalToConstant: 0)
      let vSpacer1ViewHeightAnchorConstraint = vSpacer1View.heightAnchor.constraint(equalToConstant: 72)
      let vSpacer1ViewWidthAnchorConstraint = vSpacer1View.widthAnchor.constraint(equalToConstant: 0)
      let viewViewWidthAnchorConstraint = viewView.widthAnchor.constraint(equalToConstant: 250)
      let gitHubButtonViewTopAnchorConstraint = gitHubButtonView.topAnchor.constraint(equalTo: viewView.topAnchor)
      let gitHubButtonViewLeadingAnchorConstraint = gitHubButtonView
        .leadingAnchor
        .constraint(equalTo: viewView.leadingAnchor)
      let gitHubButtonViewTrailingAnchorConstraint = gitHubButtonView
        .trailingAnchor
        .constraint(equalTo: viewView.trailingAnchor)
      let vSpacer2ViewTopAnchorConstraint = vSpacer2View.topAnchor.constraint(equalTo: gitHubButtonView.bottomAnchor)
      let vSpacer2ViewLeadingAnchorConstraint = vSpacer2View.leadingAnchor.constraint(equalTo: viewView.leadingAnchor)
      let googleButtonViewBottomAnchorConstraint = googleButtonView
        .bottomAnchor
        .constraint(equalTo: viewView.bottomAnchor)
      let googleButtonViewTopAnchorConstraint = googleButtonView.topAnchor.constraint(equalTo: vSpacer2View.bottomAnchor)
      let googleButtonViewLeadingAnchorConstraint = googleButtonView
        .leadingAnchor
        .constraint(equalTo: viewView.leadingAnchor)
      let googleButtonViewTrailingAnchorConstraint = googleButtonView
        .trailingAnchor
        .constraint(equalTo: viewView.trailingAnchor)
      let vSpacer2ViewHeightAnchorConstraint = vSpacer2View.heightAnchor.constraint(equalToConstant: 8)
      let vSpacer2ViewWidthAnchorConstraint = vSpacer2View.widthAnchor.constraint(equalToConstant: 0)
  
      publishTextViewHeightAnchorParentConstraint.priority = NSLayoutConstraint.Priority.defaultLow
      workspaceTitleViewHeightAnchorParentConstraint.priority = NSLayoutConstraint.Priority.defaultLow
  
      NSLayoutConstraint.activate([
        titleContainerViewTopAnchorConstraint,
        titleContainerViewLeadingAnchorConstraint,
        titleContainerViewTrailingAnchorConstraint,
        vSpacerViewTopAnchorConstraint,
        vSpacerViewLeadingAnchorConstraint,
        bodyTextViewTopAnchorConstraint,
        bodyTextViewLeadingAnchorConstraint,
        bodyTextViewTrailingAnchorConstraint,
        vSpacer1ViewTopAnchorConstraint,
        vSpacer1ViewLeadingAnchorConstraint,
        viewViewBottomAnchorConstraint,
        viewViewTopAnchorConstraint,
        viewViewLeadingAnchorConstraint,
        publishTextViewHeightAnchorParentConstraint,
        workspaceTitleViewHeightAnchorParentConstraint,
        publishTextViewLeadingAnchorConstraint,
        publishTextViewTopAnchorConstraint,
        publishTextViewBottomAnchorConstraint,
        workspaceTitleViewLeadingAnchorConstraint,
        workspaceTitleViewTopAnchorConstraint,
        workspaceTitleViewBottomAnchorConstraint,
        vSpacerViewHeightAnchorConstraint,
        vSpacerViewWidthAnchorConstraint,
        vSpacer1ViewHeightAnchorConstraint,
        vSpacer1ViewWidthAnchorConstraint,
        viewViewWidthAnchorConstraint,
        gitHubButtonViewTopAnchorConstraint,
        gitHubButtonViewLeadingAnchorConstraint,
        gitHubButtonViewTrailingAnchorConstraint,
        vSpacer2ViewTopAnchorConstraint,
        vSpacer2ViewLeadingAnchorConstraint,
        googleButtonViewBottomAnchorConstraint,
        googleButtonViewTopAnchorConstraint,
        googleButtonViewLeadingAnchorConstraint,
        googleButtonViewTrailingAnchorConstraint,
        vSpacer2ViewHeightAnchorConstraint,
        vSpacer2ViewWidthAnchorConstraint
      ])
    }
  
    private func update() {
      workspaceTitleView.attributedStringValue = workspaceTitleViewTextStyle.apply(to: workspaceName)
      gitHubButtonView.onClick = handleOnClickGithubButton
      googleButtonView.onClick = handleOnClickGoogleButton
    }
  
    private func handleOnClickGithubButton() {
      onClickGithubButton?()
    }
  
    private func handleOnClickGoogleButton() {
      onClickGoogleButton?()
    }
  }
  
  // MARK: - Parameters
  
  extension PublishNeedsAuth {
    public struct Parameters: Equatable {
      public var workspaceName: String
      public var onClickGithubButton: (() -> Void)?
      public var onClickGoogleButton: (() -> Void)?
  
      public init(
        workspaceName: String,
        onClickGithubButton: (() -> Void)? = nil,
        onClickGoogleButton: (() -> Void)? = nil)
      {
        self.workspaceName = workspaceName
        self.onClickGithubButton = onClickGithubButton
        self.onClickGoogleButton = onClickGoogleButton
      }
  
      public init() {
        self.init(workspaceName: "")
      }
  
      public static func ==(lhs: Parameters, rhs: Parameters) -> Bool {
        return lhs.workspaceName == rhs.workspaceName
      }
    }
  }
  
  // MARK: - Model
  
  extension PublishNeedsAuth {
    public struct Model: LonaViewModel, Equatable {
      public var id: String?
      public var parameters: Parameters
      public var type: String {
        return "PublishNeedsAuth"
      }
  
      public init(id: String? = nil, parameters: Parameters) {
        self.id = id
        self.parameters = parameters
      }
  
      public init(_ parameters: Parameters) {
        self.parameters = parameters
      }
  
      public init(
        workspaceName: String,
        onClickGithubButton: (() -> Void)? = nil,
        onClickGoogleButton: (() -> Void)? = nil)
      {
        self
          .init(
            Parameters(
              workspaceName: workspaceName,
              onClickGithubButton: onClickGithubButton,
              onClickGoogleButton: onClickGoogleButton))
      }
  
      public init() {
        self.init(workspaceName: "")
      }
    }
  }
  