text: define(["exports", "../../@polymer/polymer/polymer-element.js", "../hax-body-behaviors/lib/HAXWiring.js", "../lrn-vocab/lrn-vocab.js"], function (_exports, _polymerElement, _HAXWiring, _lrnVocab) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.GlossaryTerm = void 0;
  
    function _templateObject_334c51c0cf4a11e9b8b15bd4e98e0211() {
      var data = babelHelpers.taggedTemplateLiteral(["\n      <style>\n        :host {\n          display: inline-block;\n        }\n\n        :host([hidden]) {\n          display: none;\n        }\n\n        lrn-vocab {\n          display: inline;\n        }\n      </style>\n      <template is=\"dom-if\" if=\"[[!_fallback]]\">\n        <lrn-vocab term=\"[[display]]\">\n          <div>[[definition]]</div>\n        </lrn-vocab>\n      </template>\n      <template is=\"dom-if\" if=\"[[_fallback]]\">\n        <slot></slot>\n      </template>\n    "]);
  
      _templateObject_334c51c0cf4a11e9b8b15bd4e98e0211 = function _templateObject_334c51c0cf4a11e9b8b15bd4e98e0211() {
        return data;
      };
  
      return data;
    }
  
    /**
     * `glossary-term`
     * ``
     *
     * @microcopy - language worth noting:
     *  -
     *
     * @customElement
     * @polymer
     * @demo demo/index.html
     */
    var GlossaryTerm =
    /*#__PURE__*/
    function (_PolymerElement) {
      babelHelpers.inherits(GlossaryTerm, _PolymerElement);
      babelHelpers.createClass(GlossaryTerm, null, [{
        key: "template",
        // render function
        get: function get() {
          return (0, _polymerElement.html)(_templateObject_334c51c0cf4a11e9b8b15bd4e98e0211());
        } // haxProperty definition
  
      }, {
        key: "haxProperties",
        get: function get() {
          return {
            canScale: true,
            canPosition: true,
            canEditSource: false,
            gizmo: {
              title: "Glossary term",
              description: "",
              icon: "icons:android",
              color: "green",
              groups: ["Term"],
              handles: [{
                type: "todo:read-the-docs-for-usage"
              }],
              meta: {
                author: "heyMP",
                owner: "PSU"
              }
            },
            settings: {
              quick: [],
              configure: [{
                property: "name",
                description: "",
                inputMethod: "textfield",
                required: false,
                icon: "icons:android"
              }, {
                property: "definition",
                description: "",
                inputMethod: "textfield",
                required: false,
                icon: "icons:android"
              }, {
                property: "display",
                description: "",
                inputMethod: "textfield",
                required: false,
                icon: "icons:android"
              }],
              advanced: []
            }
          };
        } // properties available to the custom element for data binding
  
      }, {
        key: "properties",
        get: function get() {
          return {
            name: {
              name: "name",
              type: String,
              value: "",
              reflectToAttribute: false
            },
            definition: {
              name: "display",
              type: String,
              value: "",
              reflectToAttribute: false
            },
            display: {
              name: "display",
              type: String,
              value: "",
              reflectToAttribute: false
            },
            serviceType: {
              name: "serviceType",
              type: String,
              value: "file"
            },
            endpoint: {
              name: "endpoint",
              type: String,
              value: ""
            },
            _fallback: {
              name: "_fallback",
              type: Boolean,
              value: true,
              reflectToAttribute: false,
              observer: false
            }
          };
        }
        /**
         * Store the tag name to make it easier to obtain directly.
         * @notice function name must be here for tooling to operate correctly
         */
  
      }, {
        key: "tag",
        get: function get() {
          return "glossary-term";
        }
      }, {
        key: "observers",
        get: function get() {
          return [// Observer method name, followed by a list of dependencies, in parenthesis
          "__endpointMethodChanged(endpoint, serviceType)"];
        }
        /**
         * life cycle, element is afixed to the DOM
         */
  
      }]);
  
      function GlossaryTerm() {
        var _this;
  
        babelHelpers.classCallCheck(this, GlossaryTerm);
        _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(GlossaryTerm).call(this));
        _this.HAXWiring = new _HAXWiring.HAXWiring();
  
        _this.HAXWiring.setup(GlossaryTerm.haxProperties, GlossaryTerm.tag, babelHelpers.assertThisInitialized(_this));
  
        return _this;
      }
  
      babelHelpers.createClass(GlossaryTerm, [{
        key: "__endpointMethodChanged",
        value: function __endpointMethodChanged(endpoint, serviceType) {
          var _this2 = this;
  
          // fetch definition
          if (endpoint) {
            if (serviceType === "file") {
              fetch(endpoint, {
                method: "GET",
                headers: {
                  "Content-Type": "application/json"
                }
              }).then(function (r) {
                return r.json();
              }).then(function (r) {
                var foundterm = r.terms.find(function (i) {
                  return i.name === _this2.name;
                });
  
                if (foundterm) {
                  _this2.definition = foundterm.definition;
                  _this2._fallback = false;
                } else {
                  _this2._fallback = true;
                }
              });
            } else if (serviceType === "graphql") {
              fetch(this.endpoint, {
                method: "POST",
                headers: {
                  "Content-Type": "application/json"
                },
                body: JSON.stringify({
                  query: "{ term(name: \"".concat(this.name, "\") { name definition } }")
                })
              }).then(function (r) {
                return r.json();
              }).then(function (r) {
                try {
                  _this2.definition = r.data.term.definition;
                  _this2._fallback = false;
                } catch (error) {}
              });
            }
          }
        }
        /**
         * life cycle, element is removed from the DOM
         */
        //disconnectedCallback() {}
  
      }]);
      return GlossaryTerm;
    }(_polymerElement.PolymerElement);
  
    _exports.GlossaryTerm = GlossaryTerm;
    window.customElements.define(GlossaryTerm.tag, GlossaryTerm);
  });