UNPKG

@betha-plataforma/estrutura-componentes

Version:

Coleção de Web Components para compor a estrutura de uma aplicação front-end da Betha Sistemas.

1 lines 12.5 kB
const e="estrutura-componentes";let t,n,l,o=!1,s=!1,r=!1,i=!1;const c="undefined"!=typeof window?window:{},a=c.CSS,f=c.document||{head:{}},u={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},d=(()=>(f.head.attachShadow+"").indexOf("[native")>-1)(),p=e=>Promise.resolve(e),$=(()=>{try{return new CSSStyleSheet,!0}catch(e){}return!1})(),m=(e,t,n)=>{n&&n.map(([n,l,o])=>{const s=b(e,n),r=y(t,o),i=h(n);u.ael(s,l,r,i),(t.o=t.o||[]).push(()=>u.rel(s,l,r,i))})},y=(e,t)=>n=>{256&e.t?e.s[t](n):(e.i=e.i||[]).push([t,n])},b=(e,t)=>8&t?c:e,h=e=>0!=(2&e),w="http://www.w3.org/1999/xlink",g=new WeakMap,v=e=>"sc-"+e.u,k={},_=e=>"object"==(e=typeof e)||"function"===e,j="undefined"!=typeof Deno,S=!(j||"undefined"==typeof global||"function"!=typeof require||!global.process||"string"!=typeof __filename||global.origin&&"string"==typeof global.origin),C=(j&&Deno,S?process:j&&Deno,S?process:j&&Deno,(e,t,...n)=>{let l=null,o=null,s=null,r=!1,i=!1,c=[];const a=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?a(l):null!=l&&"boolean"!=typeof l&&((r="function"!=typeof e&&!_(l))&&(l+=""),r&&i?c[c.length-1].p+=l:c.push(r?M(null,l):l),i=r)};if(a(n),t){t.key&&(o=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter(t=>e[t]).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,c,R);const f=M(e,null);return f.$=t,c.length>0&&(f.m=c),f.h=o,f.g=s,f}),M=(e,t)=>({t:0,v:e,p:t,k:null,m:null,$:null,h:null,g:null}),O={},R={forEach:(e,t)=>e.map(x).forEach(t),map:(e,t)=>e.map(x).map(t).map(D)},x=e=>({vattrs:e.$,vchildren:e.m,vkey:e.h,vname:e.g,vtag:e.v,vtext:e.p}),D=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),C(e.vtag,t,...e.vchildren||[])}const t=M(e.vtag,e.vtext);return t.$=e.vattrs,t.m=e.vchildren,t.h=e.vkey,t.g=e.vname,t},P=(e,t,n,l,o,s)=>{if(n!==l){let i=ye(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,o=E(n),s=E(l);t.remove(...o.filter(e=>e&&!s.includes(e))),t.add(...s.filter(e=>e&&!o.includes(e)))}else if("style"===t){for(const t in n)l&&null!=l[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in l)n&&l[t]===n[t]||(t.includes("-")?e.style.setProperty(t,l[t]):e.style[t]=l[t])}else if("key"===t);else if("ref"===t)l&&l(e);else if(i||"o"!==t[0]||"n"!==t[1]){const c=_(l);if((i||c&&null!==l)&&!o)try{if(e.tagName.includes("-"))e[t]=l;else{let o=null==l?"":l;"list"===t?i=!1:null!=n&&e[t]==o||(e[t]=o)}}catch(r){}let f=!1;a!==(a=a.replace(/^xlink\:?/,""))&&(t=a,f=!0),null==l||!1===l?!1===l&&""!==e.getAttribute(t)||(f?e.removeAttributeNS(w,t):e.removeAttribute(t)):(!i||4&s||o)&&!c&&(l=!0===l?"":l,f?e.setAttributeNS(w,t,l):e.setAttribute(t,l))}else t="-"===t[2]?t.slice(3):ye(c,a)?a.slice(2):a[2]+t.slice(3),n&&u.rel(e,t,n,!1),l&&u.ael(e,t,l,!1)}},T=/\s/,E=e=>e?e.split(T):[],L=(e,t,n,l)=>{const o=11===t.k.nodeType&&t.k.host?t.k.host:t.k,s=e&&e.$||k,r=t.$||k;for(l in s)l in r||P(o,l,s[l],void 0,n,t.t);for(l in r)P(o,l,s[l],r[l],n,t.t)},N=(e,s,i,c)=>{let a,u,d,p=s.m[i],$=0;if(o||(r=!0,"slot"===p.v&&(t&&c.classList.add(t+"-s"),p.t|=p.m?2:1)),null!==p.p)a=p.k=f.createTextNode(p.p);else if(1&p.t)a=p.k=f.createTextNode("");else if(a=p.k=f.createElement(2&p.t?"slot-fb":p.v),L(null,p,!1),null!=t&&a["s-si"]!==t&&a.classList.add(a["s-si"]=t),p.m)for($=0;$<p.m.length;++$)u=N(e,p,$,a),u&&a.appendChild(u);return a["s-hn"]=l,3&p.t&&(a["s-sr"]=!0,a["s-cr"]=n,a["s-sn"]=p.g||"",d=e&&e.m&&e.m[i],d&&d.v===p.v&&e.k&&U(e.k,!1)),a},U=(e,t)=>{u.t|=1;const n=e.childNodes;for(let o=n.length-1;o>=0;o--){const e=n[o];e["s-hn"]!==l&&e["s-ol"]&&(H(e).insertBefore(e,F(e)),e["s-ol"].remove(),e["s-ol"]=void 0,r=!0),t&&U(e,t)}u.t&=-2},W=(e,t,n,o,s,r)=>{let i,c=e["s-cr"]&&e["s-cr"].parentNode||e;for(c.shadowRoot&&c.tagName===l&&(c=c.shadowRoot);s<=r;++s)o[s]&&(i=N(null,n,s,e),i&&(o[s].k=i,c.insertBefore(i,F(t))))},q=(e,t,n,l,o)=>{for(;t<=n;++t)(l=e[t])&&(o=l.k,J(l),s=!0,o["s-ol"]?o["s-ol"].remove():U(o,!0),o.remove())},A=(e,t)=>e.v===t.v&&("slot"===e.v?e.g===t.g:e.h===t.h),F=e=>e&&e["s-ol"]||e,H=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,V=(e,t)=>{const n=t.k=e.k,l=e.m,o=t.m,s=t.p;let r;null===s?("slot"===t.v||L(e,t,!1),null!==l&&null!==o?((e,t,n,l)=>{let o,s,r=0,i=0,c=0,a=0,f=t.length-1,u=t[0],d=t[f],p=l.length-1,$=l[0],m=l[p];for(;r<=f&&i<=p;)if(null==u)u=t[++r];else if(null==d)d=t[--f];else if(null==$)$=l[++i];else if(null==m)m=l[--p];else if(A(u,$))V(u,$),u=t[++r],$=l[++i];else if(A(d,m))V(d,m),d=t[--f],m=l[--p];else if(A(u,m))"slot"!==u.v&&"slot"!==m.v||U(u.k.parentNode,!1),V(u,m),e.insertBefore(u.k,d.k.nextSibling),u=t[++r],m=l[--p];else if(A(d,$))"slot"!==u.v&&"slot"!==m.v||U(d.k.parentNode,!1),V(d,$),e.insertBefore(d.k,u.k),d=t[--f],$=l[++i];else{for(c=-1,a=r;a<=f;++a)if(t[a]&&null!==t[a].h&&t[a].h===$.h){c=a;break}c>=0?(s=t[c],s.v!==$.v?o=N(t&&t[i],n,c,e):(V(s,$),t[c]=void 0,o=s.k),$=l[++i]):(o=N(t&&t[i],n,i,e),$=l[++i]),o&&H(u.k).insertBefore(o,F(u.k))}r>f?W(e,null==l[p+1]?null:l[p+1].k,n,l,i,p):i>p&&q(t,r,f)})(n,l,t,o):null!==o?(null!==e.p&&(n.textContent=""),W(n,null,t,o,0,o.length-1)):null!==l&&q(l,0,l.length-1)):(r=n["s-cr"])?r.parentNode.textContent=s:e.p!==s&&(n.data=s)},z=e=>{let t,n,l,o,s,r,i=e.childNodes;for(n=0,l=i.length;n<l;n++)if(t=i[n],1===t.nodeType){if(t["s-sr"])for(s=t["s-sn"],t.hidden=!1,o=0;o<l;o++)if(i[o]["s-hn"]!==t["s-hn"])if(r=i[o].nodeType,""!==s){if(1===r&&s===i[o].getAttribute("slot")){t.hidden=!0;break}}else if(1===r||3===r&&""!==i[o].textContent.trim()){t.hidden=!0;break}z(t)}},B=[],G=e=>{let t,n,l,o,r,i,c=0,a=e.childNodes,f=a.length;for(;c<f;c++){if(t=a[c],t["s-sr"]&&(n=t["s-cr"]))for(l=n.parentNode.childNodes,o=t["s-sn"],i=l.length-1;i>=0;i--)n=l[i],n["s-cn"]||n["s-nr"]||n["s-hn"]===t["s-hn"]||(I(n,o)?(r=B.find(e=>e._===n),s=!0,n["s-sn"]=n["s-sn"]||o,r?r.j=t:B.push({j:t,_:n}),n["s-sr"]&&B.map(e=>{I(e._,n["s-sn"])&&(r=B.find(e=>e._===n),r&&!e.j&&(e.j=r.j))})):B.some(e=>e._===n)||B.push({_:n}));1===t.nodeType&&G(t)}},I=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,J=e=>{e.$&&e.$.ref&&e.$.ref(null),e.m&&e.m.map(J)},K=e=>pe(e).S,Q=(e,t,n)=>{const l=K(e);return{emit:e=>X(l,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},X=(e,t,n)=>{const l=u.ce(t,n);return e.dispatchEvent(l),l},Y=(e,t)=>{t&&!e.C&&t["s-p"]&&t["s-p"].push(new Promise(t=>e.C=t))},Z=(e,t)=>{if(e.t|=16,!(4&e.t))return Y(e,e.M),Me(()=>ee(e,t));e.t|=512},ee=(e,t)=>{const n=e.s;let l;return t&&(e.t|=256,e.i&&(e.i.map(([e,t])=>re(n,e,t)),e.i=null),l=re(n,"componentWillLoad")),ie(l,()=>te(e,n,t))},te=(e,i,c)=>{const a=e.S,p=a["s-rc"];c&&(e=>{const t=e.O,n=e.S,l=t.t,o=((e,t)=>{let n=v(t),l=ge.get(n);if(e=11===e.nodeType?e:f,l)if("string"==typeof l){let t,o=g.get(e=e.head||e);o||g.set(e,o=new Set),o.has(n)||(t=f.createElement("style"),t.innerHTML=l,e.insertBefore(t,e.querySelector("link")),o&&o.add(n))}else e.adoptedStyleSheets.includes(l)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,l]);return n})(d&&n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(e);((e,i)=>{const c=e.S,a=e.O,p=e.R||M(null,null),$=(e=>e&&e.v===O)(i)?i:C(null,null,i);if(l=c.tagName,a.D&&($.$=$.$||{},a.D.map(([e,t])=>$.$[t]=c[e])),$.v=null,$.t|=4,e.R=$,$.k=p.k=c.shadowRoot||c,t=c["s-sc"],n=c["s-cr"],o=d&&0!=(1&a.t),s=!1,V(p,$),u.t|=1,r){let e,t,n,l,o,s;G($.k);let r=0;for(;r<B.length;r++)e=B[r],t=e._,t["s-ol"]||(n=f.createTextNode(""),n["s-nr"]=t,t.parentNode.insertBefore(t["s-ol"]=n,t));for(r=0;r<B.length;r++)if(e=B[r],t=e._,e.j){for(l=e.j.parentNode,o=e.j.nextSibling,n=t["s-ol"];n=n.previousSibling;)if(s=n["s-nr"],s&&s["s-sn"]===t["s-sn"]&&l===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&l!==t.parentNode||t.nextSibling!==o)&&t!==o&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),l.insertBefore(t,o))}else 1===t.nodeType&&(t.hidden=!0)}s&&z($.k),u.t&=-2,B.length=0})(e,ne(e,i)),p&&(p.map(e=>e()),a["s-rc"]=void 0);{const t=a["s-p"],n=()=>le(e);0===t.length?n():(Promise.all(t).then(n),e.t|=4,t.length=0)}},ne=(e,t)=>{try{t=t.render(),e.t&=-17,e.t|=2}catch(n){be(n)}return t},le=e=>{const t=e.S,n=e.M;re(e.s,"componentDidRender"),64&e.t||(e.t|=64,ce(t),e.P(t),n||se()),e.T(t),e.C&&(e.C(),e.C=void 0),512&e.t&&Ce(()=>Z(e,!1)),e.t&=-517},oe=e=>{{const t=pe(e),n=t.S.isConnected;return n&&2==(18&t.t)&&Z(t,!1),n}},se=()=>{ce(f.documentElement),Ce(()=>X(c,"appload",{detail:{namespace:"estrutura-componentes"}}))},re=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(l){be(l)}},ie=(e,t)=>e&&e.then?e.then(t):t(),ce=e=>e.classList.add("hydrated"),ae=(e,t,n)=>{if(t.L){e.watchers&&(t.N=e.watchers);const l=Object.entries(t.L),o=e.prototype;if(l.map(([e,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(o,e,{get(){return((e,t)=>pe(this).U.get(t))(0,e)},set(n){((e,t,n,l)=>{const o=pe(e),s=o.U.get(t),r=o.t,i=o.s;if(n=((e,t)=>null==e||_(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(n,l.L[t][0]),!(8&r&&void 0!==s||n===s)&&(o.U.set(t,n),i)){if(l.N&&128&r){const e=l.N[t];e&&e.map(e=>{try{i[e](n,s,t)}catch(l){be(l)}})}2==(18&r)&&Z(o,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(o,e,{value(...t){const n=pe(this);return n.W.then(()=>n.s[e](...t))}})}),1&n){const n=new Map;o.attributeChangedCallback=function(e,t,l){u.jmp(()=>{const t=n.get(e);this[t]=(null!==l||"boolean"!=typeof this[t])&&l})},e.observedAttributes=l.filter(([e,t])=>15&t[0]).map(([e,l])=>{const o=l[1]||e;return n.set(o,e),512&l[0]&&t.D.push([e,o]),o})}}return e},fe=e=>{re(e,"connectedCallback")},ue=(e,t={})=>{const n=[],l=t.exclude||[],o=c.customElements,s=f.head,r=s.querySelector("meta[charset]"),i=f.createElement("style"),a=[];let p,y=!0;Object.assign(u,t),u.l=new URL(t.resourcesUrl||"./",f.baseURI).href,e.map(e=>e[1].map(t=>{const s={t:t[0],u:t[1],L:t[2],q:t[3]};s.L=t[2],s.q=t[3],s.D=[],s.N={},!d&&1&s.t&&(s.t|=8);const r=s.u,i=class extends HTMLElement{constructor(e){super(e),me(e=this,s),1&s.t&&(d?e.attachShadow({mode:"open"}):"shadowRoot"in e||(e.shadowRoot=e))}connectedCallback(){p&&(clearTimeout(p),p=null),y?a.push(this):u.jmp(()=>(e=>{if(0==(1&u.t)){const t=pe(e),n=t.O,l=()=>{};if(1&t.t)m(e,t,n.q),fe(t.s);else{t.t|=1,12&n.t&&(e=>{const t=e["s-cr"]=f.createComment("");t["s-cn"]=!0,e.insertBefore(t,e.firstChild)})(e);{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){Y(t,t.M=n);break}}n.L&&Object.entries(n.L).map(([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}}),Ce(()=>(async(e,t,n,l,o)=>{if(0==(32&t.t)){{if(t.t|=32,(o=we(n)).then){const e=()=>{};o=await o,e()}o.isProxied||(n.N=o.watchers,ae(o,n,2),o.isProxied=!0);const e=()=>{};t.t|=8;try{new o(t)}catch(i){be(i)}t.t&=-9,t.t|=128,e(),fe(t.s)}if(o.style){let e=o.style;const t=v(n);if(!ge.has(t)){const l=()=>{};8&n.t&&(e=await __sc_import_estrutura_componentes("./p-ebb4d602.js").then(n=>n.scopeCss(e,t,!1))),((e,t,n)=>{let l=ge.get(e);$&&n?(l=l||new CSSStyleSheet,l.replace(t)):l=t,ge.set(e,l)})(t,e,!!(1&n.t)),l()}}}const s=t.M,r=()=>Z(t,!0);s&&s["s-rc"]?s["s-rc"].push(r):r()})(0,t,n))}l()}})(this))}disconnectedCallback(){u.jmp(()=>(()=>{if(0==(1&u.t)){const e=pe(this),t=e.s;e.o&&(e.o.map(e=>e()),e.o=void 0),re(t,"disconnectedCallback")}})())}forceUpdate(){oe(this)}componentOnReady(){return pe(this).A}};s.F=e[0],l.includes(r)||o.get(r)||(n.push(r),o.define(r,ae(i,s,1)))})),i.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",i.setAttribute("data-styles",""),s.insertBefore(i,r?r.nextSibling:s.firstChild),y=!1,a.length?a.map(e=>e.connectedCallback()):u.jmp(()=>p=setTimeout(se,30))},de=new WeakMap,pe=e=>de.get(e),$e=(e,t)=>de.set(t.s=e,t),me=(e,t)=>{const n={t:0,S:e,O:t,U:new Map};return n.W=new Promise(e=>n.T=e),n.A=new Promise(e=>n.P=e),e["s-p"]=[],e["s-rc"]=[],m(e,n,t.q),de.set(e,n)},ye=(e,t)=>t in e,be=e=>console.error(e),he=new Map,we=e=>{const t=e.u.replace(/-/g,"_"),n=e.F,l=he.get(n);return l?l[t]:__sc_import_estrutura_componentes(`./${n}.entry.js`).then(e=>(he.set(n,e),e[t]),be)},ge=new Map,ve=[],ke=[],_e=(e,t)=>n=>{e.push(n),i||(i=!0,t&&4&u.t?Ce(Se):u.raf(Se))},je=e=>{for(let n=0;n<e.length;n++)try{e[n](performance.now())}catch(t){be(t)}e.length=0},Se=()=>{je(ve),je(ke),(i=ve.length>0)&&u.raf(Se)},Ce=e=>p().then(e),Me=_e(ke,!0);export{a as C,O as H,e as N,p as a,ue as b,Q as c,f as d,oe as f,K as g,C as h,u as p,$e as r,c as w}