"use strict";const e=require("../validator.js"),t=require("../version.js"),o=require("../utils.js"),s=e=>`data${e.replace(/^(\w)/,((e,t)=>t.toUpperCase()))}`,r=e=>`default${e.replace(/^(\w)/,((e,t)=>t.toUpperCase()))}`,i=[{key:"ariaHidden",type:Boolean},{key:"ariaRole",type:String},{key:"ariaLabel",type:String},{key:"ariaLabelledby",type:String},{key:"ariaDescribedby",type:String},{key:"ariaBusy",type:Boolean}],n=(e,t=!1)=>!(e===Boolean&&!t)&&(e===String?"":void 0),a={...i.reduce(((e,t)=>({...e,[t.key]:{type:t.type,default:n(t.type)}})),{}),customStyle:{type:[String,Object],default:""}};function l(e){if(!e.externalClasses)return{};const{externalClasses:t}=e;return(Array.isArray(t)?t:[t]).reduce(((e,t)=>({...e,[o.toCamel(t)]:{type:String,default:""}})),{})}exports.uniComponent=function(i){const{newProps:p,emits:y}=function(e,t){const s={},i=[],a=/^on[A-Z][a-z]/,l=Object.values(t).map((e=>e.key)),p=l.map((e=>r(e)));return Object.keys(e).forEach((t=>{const r=e[t].type||e[t];if(a.test(t)&&e[t].type===Function){const e=t.replace(/^on/,""),s=e.charAt(0).toLowerCase()+e.slice(1);i.push(o.hyphenate(s),s)}else if(l.indexOf(t)>-1||p.indexOf(t)>-1){const e=Array.isArray(r)?r:[r];s[t]={type:[null,...e],default:null}}else[Boolean,String].indexOf(e[t].type)>-1&&void 0===e[t].default?s[t]={...e[t],default:n(e[t].type,!0)}:s[t]={..."object"==typeof e[t]?e[t]:{},type:(y=r,Array.isArray(y)?(y.sort(((e,t)=>e===Boolean?-1:t===Boolean?1:0)),y):y)};var y})),{newProps:s,emits:i}}(i.props||{},i.controlledProps||{});var c;i.props={...l(i),...p,...a},i.emits=Array.from(new Set([...i.emits||[],...(c=i.controlledProps||{},Object.values(c).map((e=>`update:${e.key}`))),...y])),i.options={...i.options||{},multipleSlots:!0},t.canUseVirtualHost()&&null==i.options.virtualHost&&(i.options.virtualHost=!0),i.options.styleIsolation||(i.options.styleIsolation="shared"),i.name&&(i.name=o.toPascal(i.name));const u=function(t){!t.properties&&t.props&&(t.properties=t.props),t.properties&&Object.keys(t.properties).forEach((o=>{let s=t.properties[o];e.isPlainObject(s)||(s={type:s}),t.properties[o]=s})),t.methods||(t.methods={}),t.lifetimes||(t.lifetimes={});const o=t.created,{controlledProps:i=[]}=t;return t.created=function(...e){o&&o.apply(this,e),i.forEach((({key:e})=>{const t=r(e),o=s(e);this[o]=this[e],null==this[e]&&(this._selfControlled=!0),null==this[e]&&null!=this[t]&&(this[o]=this[t])}))},t.methods._trigger=function(e,t,o){const r=i.find((t=>t.event===e));if(r){const{key:e}=r;this._selfControlled&&(this[s(e)]=t[e]),this.$emit(`update:${e}`,t[e],o)}this.$emit(e,t,o)},t}(i);return u};
