text: /**
   * @license
   * Copyright (c) 2014, 2019, Oracle and/or its affiliates.
   * The Universal Permissive License (UPL), Version 1.0
   * @ignore
   */
  define(["ojs/ojcore","ojs/ojcontext","ojs/ojcomponentcore","ojs/ojlabel","ojs/ojlogger","ojs/ojthemeutils"],function(e,t,l,a,n,o){"use strict";var i={properties:{colspanWrap:{type:"string",enumValues:["nowrap","wrap"]},direction:{type:"string",enumValues:["column","row"],value:"column"},labelEdge:{type:"string",enumValues:["inside","start","top"]},labelWidth:{type:"string",value:"33%"},labelWrapping:{type:"string",enumValues:["truncate","wrap"],value:"wrap"},maxColumns:{type:"number",value:1}},methods:{setProperty:{},getProperty:{},setProperties:{},refresh:{},getNodeBySubId:{},getSubIdByNode:{}},extension:{}};Object.freeze(i);var r=0;function s(e){var l,a,i,s,d,u,c=this,f=e.element,m="-labelled-by",p="data-oj-formlayout-bonus-dom",h="["+p+"]",b=!0,v=!1;function y(){a&&(a(),a=null)}function g(){l&&(l(),l=null)}function x(e){return"inside"===f.labelEdge||"inside"===e.labelEdge||"none"===e.labelEdge}function j(e){var t=null;return x(e)?t:(e instanceof Element&&"labelHint"in e&&""!==e.labelHint&&(H(e),t=function(e){var t=e.labelledBy;if(t){var l=document.getElementById(t);l&&n.error("The oj-form-layout descendent component with id "+e.id+' has both label-hint and labelled-by. Remove labelled-by="'+t+'" since no matching element was found in the document, and a label will be created using the label-hint.')}var a=document.createElement("oj-label");a.setAttribute(p,""),a.setAttribute("data-oj-internal",""),a.setAttribute("data-oj-binding-provider","none"),a.setAttribute("data-oj-context","");var o=document.createElement("span");return o.id=e.id+"|hint",o.textContent=e.labelHint,function(e,t){var l=t,a=e.helpHints;a&&(a.definition||a.source)&&(l.help=a),l.showRequired=e.required}(e,a),a.appendChild(o),function(e,t){var l=e,a=t;l.id=a.id+m,l.setAttribute("for",a.id)}(a,e),a}(e),e.parentElement.insertBefore(t,e),function(e){e.addEventListener("labelHintChanged",C),e.addEventListener("helpHintsChanged",E),e.addEventListener("requiredChanged",L)}(e)),t)}function C(e){var t=e.target,l=document.getElementById(t.id+"|hint");l&&(l.innerText=e.detail.value)}function E(e){var t=w(e.target);t&&(t.help=e.detail.value)}function L(e){var t=w(e.target);t&&(t.showRequired=e.detail.value)}function w(e){return"labelledBy"in e?document.getElementById(e.labelledBy):f.querySelector('oj-label[for="'+e.id+'"]')}function B(e,t){var l=1;return"column"===f.direction?"100%":(e&&"colspan"in e&&e.colspan&&(l=Math.min(Math.floor(e.colspan),t)),Math.floor(1e5/f.maxColumns)/1e3*l+"%")}function N(){if(!u&&(u=d,"start"===f.labelEdge&&"row"===f.direction)){var e=f.labelWidth.match(/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/);switch(e[2]){case"vw":case"vmin":case"vmax":case"%":u=e[1]/f.maxColumns+e[2]}}return u}function O(e,t){var l=M("oj-flex-item");return l.style.flexGrow="0",l.style.flexShrink="1",l.style.flexBasis=t,l.style.maxWidth=t,l.style.width=t,e.appendChild(l),l}function A(e,t){var l=f.maxColumns,a=t%l,n=B();if("column"!==f.direction&&e&&a>0)for(var o=a;o<l;o++)O(e,n)}function W(e,t,l,a){var n,o;n=l?M("oj-flex"):e.previousElementSibling;var i=t?N():B(e,a);t||(o=O(n,"0px"));var r=M("oj-flex-item");if(n.appendChild(r),e.parentElement.insertBefore(n,e),r.appendChild(e),t){r.style.flexGrow="0",r.style.flexShrink="0",r.style.flexBasis=i,r.style.maxWidth=i,r.style.width=i;var s=M("oj-flex-item");n.appendChild(s),"row"===f.direction&&"top"===f.labelEdge&&(s.appendChild(e),r.style.flex="0 1 0px",r.style.maxWidth="0px",r.style.width="0px",r.classList.add("oj-formlayout-label-comp-flex-item"),s.classList.add("oj-formlayout-label-comp-flex-item")),i=function(e,t){return"start"===f.labelEdge?"calc("+B(e,t)+" - "+N()+")":B(e,t)}(e,a),s.appendChild(t),s.style.flexGrow="1",s.style.flexShrink="1",s.style.flexBasis=i,s.style.maxWidth=i,s.style.width=i,"OJ-FORM-LAYOUT"===t.tagName&&s.classList.add("oj-formlayout-nested-formlayout")}else"labelHint"in e&&x(e)?("row"===f.direction&&(o.style.flex="0 1 0px",o.style.maxWidth="0px",o.style.width="0px",o.classList.add("oj-formlayout-label-comp-flex-item"),r.classList.add("oj-formlayout-label-comp-flex-item")),r.style.flex="1 1 0",r.style.maxWidth=i,r.style.width=i):(i=B(e,a),r.style.flexGrow="1",r.style.flexShrink="1",r.style.flexBasis=i,r.style.maxWidth=i,r.style.width=i,o.classList.add("oj-formlayout-no-label-flex-item"),r.classList.add("oj-formlayout-no-label-flex-item"),"OJ-LABEL-VALUE"===e.tagName?(o.classList.add("oj-formlayout-nested-labelvalue"),r.classList.add("oj-formlayout-nested-labelvalue"),e.setAttribute("data-oj-colspan",a),e.refresh()):"OJ-FORM-LAYOUT"===e.tagName&&r.classList.add("oj-formlayout-nested-formlayout"));return n}function M(e){var t=document.createElement("div");return t.setAttribute(p,""),t.setAttribute("data-oj-internal",""),t.classList.add(e),t}function S(e){for(var t=e,l=!0;t!==f;){if("OJ-FORM-LAYOUT"===t.tagName){l=!1;break}if(null==(t=t.parentElement)){l=!1;break}}return l}function R(e){for(;e.firstElementChild;){var t=e.firstElementChild;e.parentNode.insertBefore(t,e);t.refresh&&t.classList.contains("oj-complete")&&t.refresh()}e.parentNode.removeChild(e)}function H(e){var t=e;t.id||(t.id="oflId_"+r,r+=1)}function T(e){var t=o.parseJSONFromFontFamily("oj-form-layout-option-defaults")||{};e?(e.props.labelEdge||(f.labelEdge=t.labelEdge),e.props.colspanWrap||(f.colspanWrap=t.colspanWrap)):(f.labelEdge||(f.labelEdge=t.labelEdge),f.colspanWrap||(f.colspanWrap=t.colspanWrap))}T(e),c._rootElementMutationObserver=new MutationObserver(function(e){document.body.contains(f)?(!function(e){for(var t=e.length,l=0;l<t;l++){var a=e[l];if("childList"===a.type)for(var n=a.addedNodes.length,o=0;o<n;o++){var r=a.addedNodes[o];r.parentNode===f&&i.appendChild(r)}}}(e),function(e){for(var t=!0,l=e.length,a=["colspan","label-hint"],n=0;n<l;n++){var o=e[n];if("childList"===o.type&&((i=o.target)===f||i&&"DIV"===i.tagName&&i.hasAttribute(p))&&S(o.target)){t=!1;break}if("attributes"===o.type&&a.includes(o.attributeName)){t=!1;break}}var i;return t}(e)||(!function(e){for(var t=e.length,l=0;l<t;l++){var a=e[l];if("childList"===a.type)for(var n=a.removedNodes.length,o=0;o<n;o++){var i=a.removedNodes[o];1===i.nodeType&&(i.removeEventListener("labelHintChanged",C),i.removeEventListener("helpHintsChanged",E),i.removeEventListener("requiredChanged",L))}}}(e),f.refresh())):this.disconnect()}),this.createDOM=function(){for(f.classList.add("oj-form-layout"),(i=document.createElement("div")).classList.add("oj-form"),i.setAttribute("data-oj-context",""),i.setAttribute("data-oj-internal",""),i.setAttribute(p,"");f.firstChild;)i.appendChild(f.firstChild);f.appendChild(i)},this.updateDOM=function(){function e(){!function(){if(!a){var e=t.getContext(f).getBusyContext(),l={description:"The oj-form-layout component with id = '"+f.id+"' is being rendered."};a=e.addBusyState(l)}}(),T(),s=[],u=null,d="start"===f.labelEdge?f.labelWidth:"100%",t.getContext(i).getBusyContext().whenReady().then(function(){!function(){if(!l){var e=t.getContext(i).getBusyContext(),a={description:"The oj-form div for oj-form-layout component with id = '"+f.id+"' is being rendered."};l=e.addBusyState(a)}}(),c._rootElementMutationObserver.disconnect(),function(){var e=f.maxColumns;if("start"===f.labelEdge){var t=parseInt(f.labelWidth,10);(isNaN(t)||t>0)&&i.classList.add("oj-form-cols-labels-inline"),i.classList.add("oj-formlayout-labels-inline"),i.classList.remove("oj-form-cols")}else i.classList.add("oj-form-cols"),i.classList.remove("oj-form-cols-labels-inline"),i.classList.remove("oj-formlayout-labels-inline");"truncate"===f.labelWrapping?i.classList.add("oj-formlayout-labels-nowrap"):i.classList.remove("oj-formlayout-labels-nowrap");"row"===f.direction?(e=1,i.classList.add("oj-formlayout-form-across")):(e=f.maxColumns,i.classList.remove("oj-formlayout-form-across"));i.style.columnCount=e,i.style.webkitColumnCount=e,i.style.MozColumnCount=e}(),b||function(){for(var e=i.querySelectorAll(h),t=e.length,l=0;l<t;++l){var a=e[l];S(a)&&("OJ-LABEL"===a.tagName?(a.for="",a.parentElement.removeChild(a)):R(a))}}(),function(){var e=i.firstElementChild,t=0,l="column"===f.direction;for(;e;){var a=e.tagName.toLowerCase();if(-1!==a.indexOf("-"))if("oj-label"===a){var n=e;if(!(e=e.nextElementSibling))throw H(f),H(n),g(),y(),new Error("oj-form-layout component with id='"+f.id+"' has an oj-label child element with id='"+n.id+"' but has no next sibling element that it is associated with.")}else"oj-label-value"===a?b||e.refresh():e.classList.contains("oj-complete")?j(e):((l||t%f.maxColumns==0)&&e.setAttribute("data-oj-needs-oj-flex-div",""),s.push(e));t+=1,e=e.nextElementSibling}}(),function(){var e,t=[],l=i.children.length,a="column"===f.direction,o=0,r=0;!function(e,t){for(var l=t,a=e.length-1;a>=0;a--)l[a]=e[a]}(i.children,t);var d,u=f.maxColumns,c=0,m=!1,p=!1;for(;o<l;){var h=t[o];if(d=1,-1===s.indexOf(h)){var b=h.tagName.toLowerCase();if("oj-label"===b){var v=t[o+=1];e=W(h,v,a||r%u==0)}else if("labelHint"in h&&x(h))e=W(h,null,a||r%u==0);else{if("colspan"in h&&h.getAttribute("colspan"))if(a)m||(n.error('Colspan attribute is ignored unless direction is set to "row"'),m=!0);else{var y=u-c;d=Math.floor(h.colspan),"wrap"===f.colspanWrap&&y<d&&c>0?(A(e,r),r+=y,c=0,d=Math.min(d,u)):d=Math.min(d,y),!p&&u>1&&(p=!0)}e=W(h,null,a||r%u==0,d)}}c=(r+=d)%u,o+=1}p&&!a?i.classList.add("oj-form-control-full-width"):i.classList.remove("oj-form-control-full-width");A(e,r)}(),c._rootElementMutationObserver.observe(f,{childList:!0,subtree:!0,attributes:!0}),b&&(b=!1),g(),y()})}var o;v||(!(b||!f.hasAttribute("data-oj-context"))&&!(o=t.getContext(f).getBusyContext()).isReady()?(v=!0,o.whenReady().then(function(){v=!1,e()})):e())}}s.getDynamicDefaults=function(){return{labelEdge:(o.parseJSONFromFontFamily("oj-form-layout-option-defaults")||{}).labelEdge}},i.extension._CONSTRUCTOR=s,i.extension._TRACK_CHILDREN="nearestCustomElement",e.CustomElementBridge.register("oj-form-layout",{metadata:i})});