text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lit-element/lit-element.js"),require("@lrnwebcomponents/schema-behaviors/schema-behaviors.js"),require("@lrnwebcomponents/simple-colors/simple-colors.js")):"function"==typeof define&&define.amd?define(["exports","lit-element/lit-element.js","@lrnwebcomponents/schema-behaviors/schema-behaviors.js","@lrnwebcomponents/simple-colors/simple-colors.js"],t):t((e=e||self).MultipleChoice={},e.litElement_js,e.schemaBehaviors_js,e.simpleColors_js)}(this,function(e,t,n,r){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e,t,n){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function h(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function f(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function y(){var e=h(['\n            <div id="buttons">\n              <paper-button\n                id="check"\n                ?disabled="','"\n                raised\n                @click="','"\n                >','</paper-button\n              >\n              <paper-button\n                id="reset"\n                ?disabled="','"\n                raised\n                @click="','"\n                >',"</paper-button\n              >\n            </div>\n          "]);return y=function(){return e},e}function b(){var e=h(['\n                  <li>\n                    <paper-checkbox\n                      ?disabled="','"\n                      property="oer:answer"\n                      name="','"\n                      ?checked="','"\n                      @checked-changed="','"\n                      >',"</paper-checkbox\n                    >\n                  </li>\n                "]);return b=function(){return e},e}function m(){var e=h(["\n            <ul>\n              ","\n            </ul>\n          "]);return m=function(){return e},e}function g(){var e=h(['\n                  <paper-radio-button\n                    ?disabled="','"\n                    property="oer:answer"\n                    name="','"\n                    ?checked="','"\n                    @checked-changed="','"\n                    >',"</paper-radio-button\n                  >\n                "]);return g=function(){return e},e}function v(){var e=h(["\n            <paper-radio-group>\n              ","\n            </paper-radio-group>\n          "]);return v=function(){return e},e}function w(){var e=h(['\n            <h3><span property="oer:name">',"</span></h3>\n          "]);return w=function(){return e},e}function k(){var e=h(['\n      <meta property="oer:assessing" content="','" />\n      ',"\n      <div>","</div>\n      ","\n      ",'\n      <paper-toast\n        id="toast"\n        scroll-action="cancel"\n        duration="6000"\n        position-target="','"\n        class="fit-bottom ','"\n      >\n        ','\n        <iron-icon\n          icon="','"\n          style="margin-left:16px;"\n        ></iron-icon>\n      </paper-toast>\n    ']);return k=function(){return e},e}function x(){var e=h(['\n        :host {\n          display: block;\n          padding: 16px 16px 54px 16px;\n          background-color: var(--simple-colors-default-theme-grey-1);\n          color: var(--simple-colors-default-theme-grey-12);\n          --paper-checkbox-unchecked-color: var(\n            --simple-colors-default-theme-grey-12\n          );\n          --paper-checkbox-unchecked-ink-color: var(\n            --simple-colors-default-theme-grey-12\n          );\n          --paper-checkbox-checked-color: var(\n            --simple-colors-default-theme-accent-8\n          );\n          --paper-checkbox-checked-ink-color: var(\n            --simple-colors-default-theme-accent-8\n          );\n          --paper-checkbox-checkmark-color: var(\n            --simple-colors-default-theme-grey-1\n          );\n          --paper-checkbox-label-color: var(\n            --simple-colors-default-theme-grey-12\n          );\n          --paper-checkbox-error-color: var(\n            --simple-colors-default-theme-red-8\n          );\n        }\n        :host([accent-color="grey"]),\n        :host([accent-color="red"]),\n        :host([accent-color="green"]) {\n          --paper-checkbox-checked-color: var(\n            --simple-colors-default-theme-blue-8\n          );\n          --paper-checkbox-checked-ink-color: var(\n            --simple-colors-default-theme-blue-8\n          );\n        }\n        :host #check {\n          background-color: var(--simple-colors-default-theme-accent-8);\n          color: var(--simple-colors-default-theme-grey-1);\n        }\n        :host #check:hover {\n          background-color: var(--simple-colors-default-theme-accent-9);\n        }\n        :host([accent-color="red"]) #check,\n        :host([accent-color="green"]) #check {\n          background-color: var(--simple-colors-default-theme-blue-8);\n          color: var(--simple-colors-default-theme-grey-1);\n        }\n        :host([accent-color="red"]) #check:hover,\n        :host([accent-color="green"]) #check:hover {\n          background-color: var(--simple-colors-default-theme-blue-9);\n        }\n        :host([accent-color="grey"]) #check,\n        :host paper-button {\n          background-color: var(--simple-colors-default-theme-grey-1);\n          color: var(--simple-colors-default-theme-grey-12);\n        }\n        :host([accent-color="grey"]) #check:hover,\n        :host paper-button:hover {\n          cursor: pointer;\n          background-color: var(--simple-colors-default-theme-grey-2);\n          color: var(--simple-colors-default-theme-grey-12);\n        }\n        .red {\n          background-color: var(--simple-colors-default-theme-red-8);\n        }\n        .green {\n          background-color: var(--simple-colors-default-theme-green-8);\n        }\n        h3 {\n          margin: 8px;\n        }\n        ul {\n          list-style: none;\n          padding: 0;\n          margin: 0;\n        }\n        ul li {\n          padding: 8px;\n        }\n        paper-radio-button {\n          padding: 8px;\n          display: block;\n        }\n        paper-checkbox {\n          padding: 8px;\n        }\n        iron-icon {\n          display: inline-flex;\n        }\n      ']);return x=function(){return e},e}var j=function(e){function i(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),e=u(this,l(i).call(this)),import("@polymer/paper-toast/paper-toast.js"),import("@polymer/iron-icons/iron-icons.js"),import("@polymer/iron-icon/iron-icon.js"),import("@polymer/paper-button/paper-button.js"),e.randomize=!1,e.hideButtons=!1,e.title="",e.disabled=!1,e.singleOption=!1,e.checkLabel="Check answer",e.resetLabel="Reset",e.hideTitle=!1,e.question="",e.answers=[],e.displayedAnswers=[],e.correctText="Great job!",e.correctIcon="icons:thumb-up",e.incorrectText="Better luck next time!",e.incorrectIcon="icons:thumb-down",e.quizName="default",e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(i,n.SchemaBehaviors(r.SimpleColors)),s(i,null,[{key:"styles",get:function(){return[].concat(f(d(l(i),"styles",this)),[t.css(x())])}},{key:"tag",get:function(){return"multiple-choice"}}]),s(i,[{key:"updated",value:function(e){var t=this;d(l(i.prototype),"updated",this)&&d(l(i.prototype),"updated",this).call(this,e),e.forEach(function(e,n){if(["answers","displayedAnswers"].includes(n)){var r="".concat(n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),"-changed");t.dispatchEvent(new CustomEvent(r,{detail:{value:t[n]}}))}["answers","randomize"].includes(n)&&(t.displayedAnswers=f(t._computeDisplayedAnswers(t.answers,t.randomize))),"singleOption"==n&&t.singleOptionChanged(t[n])})}},{key:"singleOptionChanged",value:function(e){e?(import("@polymer/paper-radio-group/paper-radio-group.js"),import("@polymer/paper-radio-button/paper-radio-button.js")):import("@polymer/paper-checkbox/paper-checkbox.js")}},{key:"render",value:function(){var e=this;return t.html(k(),this.relatedResource,this.hideTitle?"":t.html(w(),this.title),this.question,this.singleOption?t.html(v(),this.displayedAnswers.map(function(n,r){return t.html(g(),e.disabled,r,n.userGuess,e.checkedEvent,n.label)})):t.html(m(),this.displayedAnswers.map(function(n,r){return t.html(b(),e.disabled,r,n.userGuess,e.checkedEvent,n.label)})),this.hideButtons?"":t.html(y(),this.disabled,this._verifyAnswers,this.checkLabel,this.disabled,this.resetAnswers,this.resetLabel),this.positionTarget,this.__toastColor,this.__toastText,this.__toastIcon)}},{key:"checkedEvent",value:function(e){var t=this.displayedAnswers;t[e.target.name].userGuess=e.detail.value,this.displayedAnswers=f(t)}},{key:"resetAnswers",value:function(e){this.shadowRoot.querySelector("#toast").hide(),this.displayedAnswers=[];var t=this.answers;this.answers.forEach(function(e){e.userGuess=!1}),this.answers=f(t)}},{key:"checkAnswers",value:function(){var e=!0;for(var t in this.displayedAnswers)0!=e&&this.displayedAnswers[t].correct&&this.displayedAnswers[t].userGuess?e=!0:this.displayedAnswers[t].correct&&!this.displayedAnswers[t].userGuess?e=!1:!this.displayedAnswers[t].correct&&this.displayedAnswers[t].userGuess&&(e=!1);return e}},{key:"_verifyAnswers",value:function(e){this.shadowRoot.querySelector("#toast").hide();var t=this.checkAnswers();t?(this.__toastColor="green",this.__toastIcon=this.correctIcon,this.__toastText=this.correctText):(this.__toastColor="red",this.__toastIcon=this.incorrectIcon,this.__toastText=this.incorrectText),this.shadowRoot.querySelector("#toast").show();var n={activityDisplay:"answered",objectName:this.quizName,resultSuccess:t};this.dispatchEvent(new CustomEvent("user-engagement",{bubbles:!0,composed:!0,cancelable:!1,detail:n}))}},{key:"_computeDisplayedAnswers",value:function(e,t){if("undefined"!==o(e)&&null!=e&&e.length>0&&t){for(var n,r,i=e,s=i.length;0!==s;)r=Math.floor(Math.random()*s),n=i[s-=1],i[s]=i[r],i[r]=n;return i}return e}},{key:"preProcessHaxNodeToContent",value:function(e){if(e.answers){for(var t=[],n=0;n<e.answers.length;n++){var r=e.answers[n];r.userGuess&&delete r.userGuess,t.push(r)}e.answers=[].concat(t)}return e}},{key:"preProcessHaxInsertContent",value:function(e){return e.properties.answers&&(e.properties.answers=e.properties.answers.map(function(e){return e.userGuess&&delete e.userGuess,e})),e}},{key:"firstUpdated",value:function(e){d(l(i.prototype),"firstUpdated",this)&&d(l(i.prototype),"firstUpdated",this).call(this,e),this.shadowRoot.querySelector("#positionTarget")&&(this.positionTarget=this.shadowRoot.querySelector("#positionTarget")),this.setAttribute("typeof","oer:Assessment"),this.shadowRoot.querySelector("#toast").fitInto=this}}],[{key:"properties",get:function(){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach(function(t){c(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},d(l(i),"properties",this),{title:{type:String},positionTarget:{type:Object},disabled:{type:Boolean},singleOption:{type:Boolean,attribute:"single-option"},checkLabel:{type:String,attribute:"check-label"},resetLabel:{type:String,attribute:"reset-label"},relatedResource:{type:String,attribute:"related-resource"},hideTitle:{type:Boolean,attribute:"hide-title"},question:{type:String},answers:{type:Array},displayedAnswers:{type:Array},correctText:{type:String,attribute:"correct-text"},incorrectText:{type:String,attribute:"incorrect-text"},correctIcon:{type:String,attribute:"correct-icon"},incorrectIcon:{type:String,attribute:"incorrect-icon"},quizName:{type:String,attribute:"quiz-name"},randomize:{type:Boolean,reflect:!0},hideButtons:{type:Boolean,attribute:"hide-buttons"},__toastText:{type:String},__toastColor:{type:String},__toastIcon:{type:String}})}},{key:"haxProperties",get:function(){return{canScale:!0,canPosition:!0,canEditSource:!1,gizmo:{title:"Multiple choice",description:"Multiple choice self check",icon:"icons:list",color:"purple",groups:["Instructional"],handles:[],meta:{author:"ELMS:LN"}},settings:{quick:[{property:"title",title:"Title",description:"The title of the element",inputMethod:"textfield",icon:"editor:title"},{property:"question",title:"Question",description:"Question for users to respond to.",inputMethod:"textfield",icon:"icons:help"}],configure:[{property:"title",title:"Title",description:"The title of the element",inputMethod:"textfield"},{property:"hideTitle",title:"Hide title",description:"Whether or not to display the title",inputMethod:"boolean"},{property:"question",title:"Question",description:"Question for users to respond to.",inputMethod:"textfield"},{property:"randomize",title:"Randomize",description:"Randomize the answers dynamically",inputMethod:"boolean"},{property:"answers",title:"Answer set",description:"Answers in a multiple choice",inputMethod:"array",itemLabel:"label",properties:[{property:"correct",title:"Correct",description:"If this is correct or not",inputMethod:"boolean"},{property:"label",title:"Answer",description:"Possible answer to the question",inputMethod:"textfield",required:!0}]},{property:"correctText",title:"Correct feedback",description:"Feedback when they get it right",inputMethod:"textfield"},{property:"correctIcon",title:"Correct icon",description:"Icon to display when correct answer happens",inputMethod:"iconpicker",options:["icons:trending-flat","icons:launch","icons:pan-tool","icons:link","icons:check","icons:favorite","icons:thumb-up","icons:thumb-down","icons:send"]},{property:"incorrectText",title:"Incorrect feedback",description:"Feedback when they get it wrong",inputMethod:"textfield"},{property:"incorrectIcon",title:"Incorrect icon",description:"Icon to display when wrong answer happens",inputMethod:"iconpicker",options:["icons:trending-flat","icons:launch","icons:pan-tool","icons:link","icons:check","icons:favorite","icons:thumb-up","icons:thumb-down","icons:send"]},{property:"quizName",title:"Name of the quiz",description:"Quiz name passed in",inputMethod:"textfield"}],advanced:[{property:"checkLabel",title:"Check answers label",description:"Label for getting solution feedback",inputMethod:"textfield"},{property:"resetLabel",title:"Reset label",description:"label for the reset button",inputMethod:"textfield"}]},saveOptions:{unsetAttributes:["__utils","displayed-answers","displayedAnswers","colors"]}}}}]),i}();window.customElements.define(j.tag,j),e.MultipleChoice=j,Object.defineProperty(e,"__esModule",{value:!0})});
  //# sourceMappingURL=multiple-choice.umd.js.map
  