text: /**
   * @license
   * Copyright (c) 2014, 2019, Oracle and/or its affiliates.
   * The Universal Permissive License (UPL), Version 1.0
   */
  "use strict";define(["ojs/ojcore","jquery","ojs/ojlogger","ojs/ojcomponentcore","ojs/ojeditablevalue","ojs/ojradiocheckbox","ojs/ojoption","ojs/ojdataprovider"],function(e,t,i,n){var o,s={properties:{describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array<string>|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array<string>|string",value:["notewindow"]},messages:{type:"Array<string>|string",value:["inline"]},validatorHint:{type:"Array<string>|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},labelledBy:{type:"string"},messagesCustom:{type:"Array<Object>",writeback:!0,value:[]},optionRenderer:{type:"function",properties:{component:{type:"Element"},index:{type:"number"},data:{type:"object"}}},options:{type:"oj.DataProvider"},optionsKeys:{type:"object",properties:{label:{type:"string"},value:{type:"string"}}},readonly:{type:"boolean",value:!1},required:{type:"boolean",value:!1},translations:{type:"object",value:{},properties:{readonlyNoValue:{type:"string"},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},value:{type:"any",writeback:!0}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}};o={doValueChangeCheck:!1},e.__registerWidget("oj.ojRadioset",t.oj.editableValue,{version:"1.0.0",defaultElement:"<div>",widgetEventPrefix:"oj",options:{disabled:!1,readOnly:!1,labelledBy:null,optionRenderer:null,options:null,optionsKeys:{},required:!1,value:void 0},refresh:function(){this._super(),this._setup()},widget:function(){return this.uiRadioset},validate:e.EditableValueUtils.validate,_InitOptions:function(t,i){var n,o;this._super(t,i),this._IsCustomElement()||(e.EditableValueUtils.initializeOptionsFromDom([{attribute:"disabled",validateOption:!0},{attribute:"readonly",option:"readOnly",validateOption:!0},{attribute:"required",coerceDomValue:!0,validateOption:!0},{attribute:"title"}],i,this),void 0===i.value&&(this.$radios=this._findRadiosWithMatchingName(),void 0!==(o=0===(n=this.$radios.filter(":checked")).length?void 0:n.val())&&this.option("value",o,{_context:{writeback:!0,internalSet:!0}}),void 0===this.options.value&&(this.options.value=null)))},_ComponentCreate:function(){var i=this.element;if(this._super(),i.uniqueId(),e.RadioCheckboxUtils.generateOptionsFromData.call(this),this._processOjOptions(),this.$radios=this._findRadiosWithMatchingName(),i.is("fieldset"))throw new Error("ojRadioset cannot be bound to a fieldset. Use a div instead.");this.$radios._ojRadioCheckbox().attr("data-oj-internal",""),this.uiRadioset=i.addClass("oj-radioset oj-component").attr("role","radiogroup"),t(i.get(0).childNodes).filter(function(){return!(this.getAttribute&&"contextMenu"===this.getAttribute("slot"))}).wrapAll("<div class='oj-radioset-wrapper'></div>"),this._on(this._events),this._setup()},_ResetComponentState:function(){this._processOjOptions(),this.$radios=this._findRadiosWithMatchingName(),this.$radios.filter(".oj-radio").each(function(){var e=void 0!==t(this).attr("disabled")&&!!t(this).prop("disabled");t(this)._ojRadioCheckbox("option","disabled",e)}),this.$radios.not(".oj-radio")._ojRadioCheckbox()},GetFocusElement:function(){return this._GetContentElement().not(":disabled").first()[0]},_IsRequired:function(){return this.options.required},_SetDisabledDom:function(e){},_refreshRequired:e.EditableValueUtils._refreshRequired,_processOjOptions:function(){if(this._IsCustomElement()){var e,t,i=this._customOptionRenderer.bind(this),n=this.element.children("oj-option");for(e=0,t=n.length;e<t;e++)n[e].customOptionRenderer=i,this.options.readOnly?this._processReadonlyOptions(n[e],!1):this._initInputLabelFromOjOption(n[e]);if((n=this.element.children(".oj-radioset-wrapper").find("oj-option")).length>0)for(e=0,t=n.length;e<t;e++)n[e].customOptionRenderer=i,this.options.readOnly?this._processReadonlyOptions(n[e],!0):this._initInputLabelFromOjOption(n[e])}},_processReadonlyOptions:function(e,t){var i,n=this.options.value,o=e.value;if(t){i=e;do{i=i.parentElement}while(i&&!i.classList.contains("oj-choice-item"));i&&i.classList.contains("oj-choice-item")&&"SPAN"===i.tagName&&i.classList.add("oj-helper-hidden")}else e.classList.add("oj-helper-hidden");if(n)n===o&&(e.classList.remove("oj-helper-hidden"),this._initReadonlyLabelFromOjOption(e,i));else{var s=document.createElement("span"),a=this.getTranslatedString("readonlyNoValue");null!==a&&(s.textContent=a),e.parentElement.insertBefore(s,e)}},_initInputLabelFromOjOption:function(e){var i,n,o=e;t(o).uniqueId();var s=o.getAttribute("id"),a=s+"|rb",r=document.getElementById(a);if(null!==r){var l=o;do{l=l.parentElement}while(l&&!l.classList.contains("oj-choice-item"));l&&l.classList.contains("oj-helper-hidden")&&l.classList.contains("oj-choice-item")&&"SPAN"===l.tagName&&l.classList.remove("oj-helper-hidden"),o&&o.classList.contains("oj-helper-hidden")&&o.classList.remove("oj-helper-hidden"),r&&r.parentElement.classList.contains("oj-helper-hidden")&&r.parentElement.classList.remove("oj-helper-hidden")}else i=document.createElement("span"),r=document.createElement("input"),n=document.createElement("label"),i.setAttribute("class","oj-choice-item"),r.setAttribute("type","radio"),r.setAttribute("value",o.value),r.setAttribute("id",a),n.setAttribute("for",a),o.parentElement.insertBefore(i,o),n.appendChild(o),i.appendChild(r),i.appendChild(n);var d=this.element[0].id,u=o.getAttribute("aria-label"),p=o.getAttribute("aria-labelledby");r.setAttribute("data-oj-option-id",s),d&&""!==d&&r.setAttribute("name",d),u&&""!==u?r.setAttribute("aria-label",u):r.removeAttribute("aria-label"),p&&""!==p?r.setAttribute("aria-labelledby",p):r.removeAttribute("aria-labelledby"),o.disabled?r.setAttribute("disabled",!0):r.removeAttribute("disabled")},_initReadonlyLabelFromOjOption:function(e,i){var n,o,s=e;if(i){t(s).uniqueId();var a=s.getAttribute("id")+"|rb",r=document.getElementById(a);null!==r&&r.parentElement.classList.add("oj-helper-hidden"),i.classList.remove("oj-helper-hidden")}else n=document.createElement("span"),o=document.createElement("label"),n.setAttribute("class","oj-choice-item"),s.parentElement.insertBefore(n,s),o.appendChild(s),n.appendChild(o)},_customOptionRenderer:function(e){var i=e,n=i.getAttribute("id")+"|rb",o=document.getElementById(n);null!==o&&o.classList.contains("oj-radio")&&t(o)._ojRadioCheckbox("option","disabled",i.disabled)},_updateLabelledBy:e.EditableValueUtils._updateLabelledBy,_findRadiosWithMatchingName:function(){var e,t,n=this.element,o=n.find("input[type=radio]:first");return 0===o.length&&i.warn("Could not find any input type=radio within this element"),void 0===(e=o.attr("name"))?n.find("input[type=radio]").not("[name]"):(t='input[type=radio][name="'+e+'"]',n.find(t))},_NotifyContextMenuGesture:function(e,t,i){var n=this.element.find("input[type=radio]"),o=n.filter(":checked"),s=o.length?o:n.filter(":enabled").first();this._OpenContextMenu(t,i,{launcher:s})},_GetMessagingLauncherElement:function(){return this.widget()},_setup:function(){this._propagateDisabled(this.options.disabled),this.element.hasClass("oj-choice-direction-column")||this.element.hasClass("oj-choice-direction-row")||this.element.addClass("oj-choice-direction-column"),this._refreshRequired(this.options.required),this._updateLabelledBy(null,this.options.labelledBy,this.widget())},_events:{change:function(e){this._HandleChangeEvent(e)}},_HandleChangeEvent:function(e){var t=this._GetDisplayValue();this._SetValue(t,e,o)},_GetDisplayValue:function(e){return this._GetElementValue()},_SetDisplayValue:function(i){var n,o,s=this.$radios.length,a=-1,r=this.$radios.get(),l=[];for(n=0;n<s;n++)if(l[n]=this._GetOptionValue(r[n]),l[n]===i){a=n;break}if(-1===a)for(n=0;n<s;n++)if(e.Object.compareValues(l[n],i)){a=n;break}for(n=0;n<s;n++){var d=(o=t(this.$radios[n]))._ojRadioCheckbox("option","checked");n===a?d||o._ojRadioCheckbox("option","checked",!0):d&&o._ojRadioCheckbox("option","checked",!1)}},_GetElementValue:function(){var e=this.$radios.filter(":checked");return 0===e.length?null:this._GetOptionValue(e[0])},_GetOptionValue:function(e){var t,i;return this._IsCustomElement()?(t=document.getElementById(e.getAttribute("data-oj-option-id")))&&(i=t.value):i=e.value,i},_GetDefaultStyleClass:function(){return"oj-radioset"},_GetContentElement:function(){return null!=this.$radios?this.$radios:(this.$radios=this._findRadiosWithMatchingName(),this.$radios)},_AriaRequiredUnsupported:function(){return!0},_AfterSetOptionRequired:e.EditableValueUtils._AfterSetOptionRequired,_propagateDisabled:function(e){var i=!!e;this.$radios.each(function(){t(this).data("oj-_ojRadioCheckbox").__setAncestorComponentDisabled(i)}),this.$radios._ojRadioCheckbox("refreshDisabled")},_setOption:function(t,i,n){var o=this.options.labelledBy;switch(this._super(t,i,n),t){case"disabled":this._propagateDisabled(i);break;case"readOnly":case"value":this._processOjOptions();break;case"labelledBy":this._updateLabelledBy(o,i,this.widget());break;case"options":e.RadioCheckboxUtils.generateOptionsFromData.call(this);break;case"optionsKeys":case"optionRenderer":e.RadioCheckboxUtils.renderOptions.call(this)}},_AfterSetOption:function(e,t,i){switch(this._superApply(arguments),e){case"required":this._AfterSetOptionRequired(e)}},getNodeBySubId:function(t){var i,n,o,s=this._super(t);if(!s)switch(i=this.$radios.get(),t.subId){case"oj-radioset-inputs":s=i;break;case"oj-radioset-radio":if(void 0!==(n=t.value)){var a=i.length,r=-1,l=[];for(o=0;o<a;o++)if(l[o]=this._GetOptionValue(i[o]),l[o]===n){r=o;break}if(-1===r)for(o=0;o<a;o++)if(e.Object.compareValues(l[o],n)){r=o;break}-1!==r&&(s=i[r])}}return s||null},getSubIdByNode:function(e){for(var t=this._GetContentElement()[0].parentElement.parentElement.parentElement,i=e;i&&i!==t;){if("LABEL"===i.nodeName&&(i=document.getElementById(i.for)),"INPUT"===i.nodeName)return{subId:"oj-radioset-radio",value:this._GetOptionValue(i)};i=i.parentElement}return this._super(e)},_destroy:function(){var i=this._super(),n=this.element[0].firstElementChild;return this.$radios&&this.$radios._ojRadioCheckbox("destroy"),t(n).contents().unwrap(),e.RadioCheckboxUtils.removeDataListener.call(this),i}}),s.extension._WIDGET_NAME="ojRadioset",s.extension._ALIASED_PROPS={readonly:"readOnly"},e.CustomElementBridge.register("oj-radioset",{metadata:s})});