import { isDemo } from "@saasquatch/component-boilerplate";
import { useState, withHooks } from "@saasquatch/stencil-hooks";
import { Component, Prop, h } from "@stencil/core";
import deepmerge from "deepmerge";
import { getProps } from "../../utils/utils";
import { ShareLinkView } from "./sqm-share-link-view";
import { useShareLink } from "./useShareLink";
/**
 * @uiName Share Link
 * @exampleGroup Sharing
 * @validParents ["sqm-portal-container", "sqm-titled-section", "div","sqm-hero","sqm-referral-card","sqm-instant-access-registration","sqb-program-section","sqb-conditional-section"]
 * @example Share Link - <sqm-share-link tooltip-text="Copied to Clipboard" tooltip-lifespan="1000"></sqm-share-link>
 */
export class ShareLink {
  constructor() {
    /**
     * Shown inside a tooltip after someone has successfully copied the link to their clipboard
     *
     * @uiName Tooltip text
     */
    this.tooltiptext = "Copied to Clipboard";
    /**
     * The number of milliseconds that the tooltip appears for
     *
     * @uiName Tooltip lifespan
     */
    this.tooltiplifespan = 1000;
    /**
     * Change the text alignment
     *
     * @uiName Share link alignment
     * @uiType string
     * @uiEnum ["left", "center", "right"]
     * @uiEnumNames ["Left", "Center", "Right"]
     * @uiGroup Style
     */
    this.textAlign = "left";
    /**
     * @uiName Copy button label
     */
    this.copyButtonLabel = "Copy Link";
    /**
     * The type of the button that is used (primary or secondary).
     * @uiName Button Type
     * @uiType string
     * @uiEnum ["primary", "secondary"]
     * @uiEnumNames ["Primary", "Secondary"]
     * @uiGroup Style
     */
    this.buttonType = "primary";
    /**
     * Set the copy button style and placement
     *
     * @uiName Button style
     * @uiType string
     * @uiEnum ["icon", "button-outside", "button-below"]
     * @uiEnumNames ["Icon", "Button outside", "Button below"]
     * @uiGroup Style
     */
    this.buttonStyle = "icon";
    /**
     * Let advocates customize their share links up to 5 times.
     *
     * @uiName Allow customization
     * @uiType boolean
     * @uiGroup Customizable Vanity Link
     * @uiWidget CustomLinkSwitch
     * @requiredFlavor impact
     */
    this.allowCustomization = false;
    /**
     * Text for the cancel button in editing mode
     *
     * @uiName Cancel button label
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.cancelLabelText = "Cancel";
    /**
     * Tooltip text shown when link customization is disabled
     *
     * @uiName Customize disabled tooltip
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.customizeDisabledTooltip = "Link customization is not available.";
    /**
     * Displayed below the share link.
     *
     * @uiName Customize link button label
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.customizeLinkButtonLabel = "Customize Link";
    /**
     * Message shown when the URL has been edited 5 times. To display a clickable link, use {supportLink} as a placeholder.
     *
     * @uiName Edit limit reached text
     * @uiType string
     * @uiWidget textarea
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.editLimitReachedText = "5 edit limit reached. To make more changes, please contact {supportLink}.";
    /**
     * Subtext shown while the user is customizing their URL.
     *
     * @uiName Edit limit text
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.editLimitText = "You can edit your link up to {editsRemaining} more time(s).";
    /**
     * Description text shown when the link contains invalid special characters.
     *
     * @uiName Invalid characters error description
     * @uiType string
     * @uiWidget textarea
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.invalidCharactersErrorDescription = "Special characters can break the link when sharing.";
    /**
     * Title of the error message shown when the link contains invalid special characters.
     *
     * @uiName Invalid characters error title
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.invalidCharactersErrorTitle = "Please use only letters, numbers, dashes and underscores";
    /**
     * Description text shown when the link has already been taken
     *
     * @uiName Link taken error message
     * @uiType string
     * @uiWidget textarea
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.linkTakenErrorDescription = "Try adding numbers, a dash or underscore to create a unique link.";
    /**
     * Title of the error message shown when the link has already been taken
     *
     * @uiName Link taken error title
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.linkTakenErrorTitle = "This link is already taken";
    /**
     * Description text shown when the link contains profanity or brand names.
     *
     * @uiName Restricted words error description
     * @uiType string
     * @uiWidget textarea
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.restrictedWordsErrorDescription = "This link contains a restricted word.";
    /**
     * Title of the error message shown when the link contains profanity or brand names.
     *
     * @uiName Restricted words error title
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.restrictedWordsErrorTitle = "Please try a different link";
    /**
     * Text for the save button in editing mode
     *
     * @uiName Save button label
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.saveLabelText = "Save";
    /**
     * Text for the save button while saving is in progress
     *
     * @uiName Saving button label
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.savingLabelText = "Saving...";
    /**
     * Label shown above the link input while editing
     *
     * @uiName Edit input label
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.editLabelText = "Enter your link";
    /**
     * Text shown when nearing the character limit. Use {charactersRemaining} as a placeholder for the count.
     *
     * @uiName Characters remaining text
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.charactersRemainingText = "Characters remaining: {charactersRemaining}";
    /**
     * Text shown while the link is being validated
     *
     * @uiName Validating label
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.validatingLabelText = "Validating...";
    /**
     * @uiName Min characters text
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.minCharactersText = "Minimum 3 characters.";
    /**
     * Display text for the support link in the edit limit reached message
     *
     * @uiName Support link text
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.supportLinkText = "Support";
    /**
     * Title shown when saving fails with an unknown error
     *
     * @uiName Save error title
     * @uiType string
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.saveErrorTitle = "Error";
    /**
     * Description shown when saving fails with an unknown error
     *
     * @uiName Save error description
     * @uiType string
     * @uiWidget textarea
     * @uiGroup Customizable Vanity Link
     * @requiredFlavor impact
     */
    this.saveErrorDescription = "Failed to save custom link. Please try again.";
    withHooks(this);
  }
  disconnectedCallback() { }
  render() {
    const thisProps = getProps(this);
    const props = isDemo()
      ? useDemoShareLink(thisProps)
      : useShareLink(thisProps);
    return h(ShareLinkView, Object.assign({}, props));
  }
  static get is() { return "sqm-share-link"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "programId": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Program ID",
            "name": "uiName"
          }, {
            "text": "programSelector",
            "name": "uiWidget"
          }],
        "text": "The ID of the program that should generate the link. Defaults to the program ID in context where this widget is loaded."
      },
      "attribute": "program-id",
      "reflect": false
    },
    "tooltiptext": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Tooltip text",
            "name": "uiName"
          }],
        "text": "Shown inside a tooltip after someone has successfully copied the link to their clipboard"
      },
      "attribute": "tooltip-text",
      "reflect": false,
      "defaultValue": "\"Copied to Clipboard\""
    },
    "tooltiplifespan": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Tooltip lifespan",
            "name": "uiName"
          }],
        "text": "The number of milliseconds that the tooltip appears for"
      },
      "attribute": "tooltip-lifespan",
      "reflect": false,
      "defaultValue": "1000"
    },
    "textAlign": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "\"left\" | \"center\" | \"right\"",
        "resolved": "\"center\" | \"left\" | \"right\"",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Share link alignment",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "[\"left\", \"center\", \"right\"]",
            "name": "uiEnum"
          }, {
            "text": "[\"Left\", \"Center\", \"Right\"]",
            "name": "uiEnumNames"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "Change the text alignment"
      },
      "attribute": "text-align",
      "reflect": false,
      "defaultValue": "\"left\""
    },
    "copyButtonLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Copy button label",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "copy-button-label",
      "reflect": false,
      "defaultValue": "\"Copy Link\""
    },
    "backgroundColor": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Background color",
            "name": "uiName"
          }, {
            "text": "color",
            "name": "uiWidget"
          }, {
            "text": "color",
            "name": "format"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "Background color of share link container"
      },
      "attribute": "background-color",
      "reflect": false
    },
    "borderColor": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Border color",
            "name": "uiName"
          }, {
            "text": "color",
            "name": "uiWidget"
          }, {
            "text": "color",
            "name": "format"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "Border color of share link container"
      },
      "attribute": "border-color",
      "reflect": false
    },
    "textColor": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Text color",
            "name": "uiName"
          }, {
            "text": "color",
            "name": "uiWidget"
          }, {
            "text": "color",
            "name": "format"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "Color of the text and copy icon"
      },
      "attribute": "text-color",
      "reflect": false
    },
    "borderRadius": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Border Radius",
            "name": "uiName"
          }, {
            "text": "number",
            "name": "uiType"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "The border radius on the share link container (in pixels)"
      },
      "attribute": "border-radius",
      "reflect": false
    },
    "buttonType": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "\"primary\" | \"secondary\"",
        "resolved": "\"primary\" | \"secondary\"",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Button Type",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "[\"primary\", \"secondary\"]",
            "name": "uiEnum"
          }, {
            "text": "[\"Primary\", \"Secondary\"]",
            "name": "uiEnumNames"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "The type of the button that is used (primary or secondary)."
      },
      "attribute": "button-type",
      "reflect": false,
      "defaultValue": "\"primary\""
    },
    "buttonStyle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "\"icon\" | \"button-outside\" | \"button-below\"",
        "resolved": "\"button-below\" | \"button-outside\" | \"icon\"",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Button style",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "[\"icon\", \"button-outside\", \"button-below\"]",
            "name": "uiEnum"
          }, {
            "text": "[\"Icon\", \"Button outside\", \"Button below\"]",
            "name": "uiEnumNames"
          }, {
            "text": "Style",
            "name": "uiGroup"
          }],
        "text": "Set the copy button style and placement"
      },
      "attribute": "copy-button-style",
      "reflect": false,
      "defaultValue": "\"icon\""
    },
    "allowCustomization": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Allow customization",
            "name": "uiName"
          }, {
            "text": "boolean",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "CustomLinkSwitch",
            "name": "uiWidget"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Let advocates customize their share links up to 5 times."
      },
      "attribute": "allow-customization",
      "reflect": false,
      "defaultValue": "false"
    },
    "cancelLabelText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Cancel button label",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Text for the cancel button in editing mode"
      },
      "attribute": "cancel-label-text",
      "reflect": false,
      "defaultValue": "\"Cancel\""
    },
    "customizeDisabledTooltip": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Customize disabled tooltip",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Tooltip text shown when link customization is disabled"
      },
      "attribute": "customize-disabled-tooltip",
      "reflect": false,
      "defaultValue": "\"Link customization is not available.\""
    },
    "customizeLinkButtonLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Customize link button label",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Displayed below the share link."
      },
      "attribute": "customize-link-button-label",
      "reflect": false,
      "defaultValue": "\"Customize Link\""
    },
    "editLimitReachedText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Edit limit reached text",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "textarea",
            "name": "uiWidget"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Message shown when the URL has been edited 5 times. To display a clickable link, use {supportLink} as a placeholder."
      },
      "attribute": "edit-limit-reached-text",
      "reflect": false,
      "defaultValue": "\"5 edit limit reached. To make more changes, please contact {supportLink}.\""
    },
    "editLimitText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Edit limit text",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Subtext shown while the user is customizing their URL."
      },
      "attribute": "edit-limit-text",
      "reflect": false,
      "defaultValue": "\"You can edit your link up to {editsRemaining} more time(s).\""
    },
    "invalidCharactersErrorDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Invalid characters error description",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "textarea",
            "name": "uiWidget"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Description text shown when the link contains invalid special characters."
      },
      "attribute": "invalid-characters-error-description",
      "reflect": false,
      "defaultValue": "\"Special characters can break the link when sharing.\""
    },
    "invalidCharactersErrorTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Invalid characters error title",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Title of the error message shown when the link contains invalid special characters."
      },
      "attribute": "invalid-characters-error-title",
      "reflect": false,
      "defaultValue": "\"Please use only letters, numbers, dashes and underscores\""
    },
    "linkTakenErrorDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Link taken error message",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "textarea",
            "name": "uiWidget"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Description text shown when the link has already been taken"
      },
      "attribute": "link-taken-error-description",
      "reflect": false,
      "defaultValue": "\"Try adding numbers, a dash or underscore to create a unique link.\""
    },
    "linkTakenErrorTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Link taken error title",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Title of the error message shown when the link has already been taken"
      },
      "attribute": "link-taken-error-title",
      "reflect": false,
      "defaultValue": "\"This link is already taken\""
    },
    "restrictedWordsErrorDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Restricted words error description",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "textarea",
            "name": "uiWidget"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Description text shown when the link contains profanity or brand names."
      },
      "attribute": "restricted-words-error-description",
      "reflect": false,
      "defaultValue": "\"This link contains a restricted word.\""
    },
    "restrictedWordsErrorTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Restricted words error title",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Title of the error message shown when the link contains profanity or brand names."
      },
      "attribute": "restricted-words-error-title",
      "reflect": false,
      "defaultValue": "\"Please try a different link\""
    },
    "saveLabelText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Save button label",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Text for the save button in editing mode"
      },
      "attribute": "save-label-text",
      "reflect": false,
      "defaultValue": "\"Save\""
    },
    "savingLabelText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Saving button label",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Text for the save button while saving is in progress"
      },
      "attribute": "saving-label-text",
      "reflect": false,
      "defaultValue": "\"Saving...\""
    },
    "editLabelText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Edit input label",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Label shown above the link input while editing"
      },
      "attribute": "edit-label-text",
      "reflect": false,
      "defaultValue": "\"Enter your link\""
    },
    "charactersRemainingText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Characters remaining text",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Text shown when nearing the character limit. Use {charactersRemaining} as a placeholder for the count."
      },
      "attribute": "characters-remaining-text",
      "reflect": false,
      "defaultValue": "\"Characters remaining: {charactersRemaining}\""
    },
    "validatingLabelText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Validating label",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Text shown while the link is being validated"
      },
      "attribute": "validating-label-text",
      "reflect": false,
      "defaultValue": "\"Validating...\""
    },
    "minCharactersText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Min characters text",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": ""
      },
      "attribute": "min-characters-text",
      "reflect": false,
      "defaultValue": "\"Minimum 3 characters.\""
    },
    "supportLinkText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Support link text",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Display text for the support link in the edit limit reached message"
      },
      "attribute": "support-link-text",
      "reflect": false,
      "defaultValue": "\"Support\""
    },
    "saveErrorTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Save error title",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Title shown when saving fails with an unknown error"
      },
      "attribute": "save-error-title",
      "reflect": false,
      "defaultValue": "\"Error\""
    },
    "saveErrorDescription": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Save error description",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "textarea",
            "name": "uiWidget"
          }, {
            "text": "Customizable Vanity Link",
            "name": "uiGroup"
          }, {
            "text": "impact",
            "name": "requiredFlavor"
          }],
        "text": "Description shown when saving fails with an unknown error"
      },
      "attribute": "save-error-description",
      "reflect": false,
      "defaultValue": "\"Failed to save custom link. Please try again.\""
    },
    "demoData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DemoData<ShareLinkViewProps>",
        "resolved": "{ copyTextViewProps?: CopyTextViewProps; allowCustomization?: boolean; customizeLinkLabel?: string; saveLabelText?: string; savingLabelText?: string; cancelLabelText?: string; editLabelText?: string; charactersRemainingText?: string; validatingLabelText?: string; isEditing?: boolean; editValue?: string; domainPrefix?: string; editsRemaining?: number; maxEdits?: number; limitReached?: boolean; validationError?: ValidationErrorInfo; isValidating?: boolean; isSaving?: boolean; characterLimit?: number; minCharacters?: number; charactersRemaining?: number; editLimitText?: string; editLimitReachedText?: string; minCharactersText?: string; supportLinkText?: string; customizeDisabled?: boolean; customizeDisabledTooltip?: string; onCustomizeClick?: () => void; onEditValueChange?: (value: string) => void; onSave?: () => void; onCancel?: () => void; }",
        "references": {
          "DemoData": {
            "location": "import",
            "path": "../../global/demo"
          },
          "ShareLinkViewProps": {
            "location": "import",
            "path": "./sqm-share-link-view"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "undocumented"
          }, {
            "text": "object",
            "name": "uiType"
          }],
        "text": ""
      }
    }
  }; }
}
function useDemoShareLink(props) {
  var _a;
  const [open, setOpen] = useState(false);
  const [isEditing, setIsEditing] = useState(false);
  const [editValue, setEditValue] = useState("");
  const copyString = "https://www.example.com/sharelink/abc";
  const domainPrefix = "https://www.example.com/";
  const baseProps = {
    copyTextViewProps: {
      copyString,
      tooltiptext: props.tooltiptext,
      textAlign: props.textAlign,
      buttonStyle: props.buttonStyle,
      backgroundColor: props.backgroundColor,
      textColor: props.textColor,
      borderRadius: props.borderRadius,
      buttonType: props.buttonType,
      copyButtonLabel: props.copyButtonLabel,
      borderColor: props.borderColor,
      open,
      onClick: () => {
        navigator.clipboard.writeText(copyString);
        setOpen(true);
        setTimeout(() => setOpen(false), props.tooltiplifespan);
      },
    },
    allowCustomization: props.allowCustomization,
    customizeLinkLabel: props.customizeLinkButtonLabel,
    saveLabelText: props.saveLabelText,
    savingLabelText: props.savingLabelText,
    cancelLabelText: props.cancelLabelText,
    editLabelText: props.editLabelText,
    charactersRemainingText: props.charactersRemainingText,
    validatingLabelText: props.validatingLabelText,
    isEditing,
    editValue,
    domainPrefix,
    editsRemaining: 5,
    maxEdits: 5,
    limitReached: false,
    validationError: null,
    isValidating: false,
    isSaving: false,
    characterLimit: 15,
    minCharacters: 3,
    charactersRemaining: 15 - editValue.length,
    editLimitText: props.editLimitText,
    editLimitReachedText: props.editLimitReachedText,
    supportLinkText: props.supportLinkText,
    minCharactersText: props.minCharactersText,
    customizeDisabled: false,
    customizeDisabledTooltip: (_a = props.customizeDisabledTooltip) !== null && _a !== void 0 ? _a : "Link customization is not available.",
    onCustomizeClick: () => {
      setIsEditing(true);
      setEditValue("");
    },
    onEditValueChange: (value) => {
      setEditValue(value);
    },
    onSave: () => {
      setIsEditing(false);
    },
    onCancel: () => {
      setIsEditing(false);
      setEditValue("");
    },
  };
  return deepmerge(baseProps, props.demoData || {}, {
    arrayMerge: (_, a) => a,
  });
}
