@govbr-ds/playground 5.2.2 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import{c as wr}from"./chunks/chunk-WUR2JRNJ.js";import{c as br}from"./chunks/chunk-ZIL2IWZ3.js";import{f as vr}from"./chunks/chunk-EP7B2XPY.js";import"./chunks/chunk-UVFYWQD2.js";import"./chunks/chunk-TFWQIFOZ.js";import"./chunks/chunk-5A3ZKBRD.js";import{a as Fo,b as zo}from"./chunks/chunk-6DHFEWGX.js";var Dr=Fo((Qi,Wt)=>{var Pn=(function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function l(r,s){if(!i[r]){i[r]={};for(var a=0;a<r.length;a++)i[r][r.charAt(a)]=a}return i[r][s]}var u={compressToBase64:function(r){if(r==null)return"";var s=u._compress(r,6,function(a){return n.charAt(a)});switch(s.length%4){default:case 0:return s;case 1:return s+"===";case 2:return s+"==";case 3:return s+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:u._decompress(r.length,32,function(s){return l(n,r.charAt(s))})},compressToUTF16:function(r){return r==null?"":u._compress(r,15,function(s){return e(s+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:u._decompress(r.length,16384,function(s){return r.charCodeAt(s)-32})},compressToUint8Array:function(r){for(var s=u.compress(r),a=new Uint8Array(s.length*2),c=0,f=s.length;c<f;c++){var C=s.charCodeAt(c);a[c*2]=C>>>8,a[c*2+1]=C%256}return a},decompressFromUint8Array:function(r){if(r==null)return u.decompress(r);for(var s=new Array(r.length/2),a=0,c=s.length;a<c;a++)s[a]=r[a*2]*256+r[a*2+1];var f=[];return s.forEach(function(C){f.push(e(C))}),u.decompress(f.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":u._compress(r,6,function(s){return o.charAt(s)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),u._decompress(r.length,32,function(s){return l(o,r.charAt(s))}))},compress:function(r){return u._compress(r,16,function(s){return e(s)})},_compress:function(r,s,a){if(r==null)return"";var c,f,C={},v={},P="",T="",b="",E=2,$=3,M=2,y=[],m=0,g=0,R;for(R=0;R<r.length;R+=1)if(P=r.charAt(R),Object.prototype.hasOwnProperty.call(C,P)||(C[P]=$++,v[P]=!0),T=b+P,Object.prototype.hasOwnProperty.call(C,T))b=T;else{if(Object.prototype.hasOwnProperty.call(v,b)){if(b.charCodeAt(0)<256){for(c=0;c<M;c++)m=m<<1,g==s-1?(g=0,y.push(a(m)),m=0):g++;for(f=b.charCodeAt(0),c=0;c<8;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1}else{for(f=1,c=0;c<M;c++)m=m<<1|f,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=0;for(f=b.charCodeAt(0),c=0;c<16;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1}E--,E==0&&(E=Math.pow(2,M),M++),delete v[b]}else for(f=C[b],c=0;c<M;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1;E--,E==0&&(E=Math.pow(2,M),M++),C[T]=$++,b=String(P)}if(b!==""){if(Object.prototype.hasOwnProperty.call(v,b)){if(b.charCodeAt(0)<256){for(c=0;c<M;c++)m=m<<1,g==s-1?(g=0,y.push(a(m)),m=0):g++;for(f=b.charCodeAt(0),c=0;c<8;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1}else{for(f=1,c=0;c<M;c++)m=m<<1|f,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=0;for(f=b.charCodeAt(0),c=0;c<16;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1}E--,E==0&&(E=Math.pow(2,M),M++),delete v[b]}else for(f=C[b],c=0;c<M;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1;E--,E==0&&(E=Math.pow(2,M),M++)}for(f=2,c=0;c<M;c++)m=m<<1|f&1,g==s-1?(g=0,y.push(a(m)),m=0):g++,f=f>>1;for(;;)if(m=m<<1,g==s-1){y.push(a(m));break}else g++;return y.join("")},decompress:function(r){return r==null?"":r==""?null:u._decompress(r.length,32768,function(s){return r.charCodeAt(s)})},_decompress:function(r,s,a){var c=[],f,C=4,v=4,P=3,T="",b=[],E,$,M,y,m,g,R,S={val:a(0),position:s,index:1};for(E=0;E<3;E+=1)c[E]=E;for(M=0,m=Math.pow(2,2),g=1;g!=m;)y=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),M|=(y>0?1:0)*g,g<<=1;switch(f=M){case 0:for(M=0,m=Math.pow(2,8),g=1;g!=m;)y=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),M|=(y>0?1:0)*g,g<<=1;R=e(M);break;case 1:for(M=0,m=Math.pow(2,16),g=1;g!=m;)y=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),M|=(y>0?1:0)*g,g<<=1;R=e(M);break;case 2:return""}for(c[3]=R,$=R,b.push(R);;){if(S.index>r)return"";for(M=0,m=Math.pow(2,P),g=1;g!=m;)y=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),M|=(y>0?1:0)*g,g<<=1;switch(R=M){case 0:for(M=0,m=Math.pow(2,8),g=1;g!=m;)y=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),M|=(y>0?1:0)*g,g<<=1;c[v++]=e(M),R=v-1,C--;break;case 1:for(M=0,m=Math.pow(2,16),g=1;g!=m;)y=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),M|=(y>0?1:0)*g,g<<=1;c[v++]=e(M),R=v-1,C--;break;case 2:return b.join("")}if(C==0&&(C=Math.pow(2,P),P++),c[R])T=c[R];else if(R===v)T=$+$.charAt(0);else return null;b.push(T),c[v++]=$+T.charAt(0),C--,$=T,C==0&&(C=Math.pow(2,P),P++)}}};return u})();typeof define=="function"&&define.amd?define(function(){return Pn}):typeof Wt<"u"&&Wt!=null?Wt.exports=Pn:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return Pn})});function Uo(e){if(!e||!Array.isArray(e.examples))throw new Error("examples.json precisa de uma lista examples.");let n=new Map,o=new Set,i=e.examples.flatMap(r=>{let{items:s,...a}=r;if(s!==void 0&&(!Array.isArray(s)||!s.length))throw new Error(`Categoria ${r.id} precisa de items n\xE3o vazio.`);let c=s?s.map(f=>{if(f.items)throw new Error("Categorias aninhadas n\xE3o s\xE3o suportadas.");return{...a,...f,id:`${r.id}-${f.id}`,hidden:r.hidden||f.hidden,category:{id:r.id,label:r.label}}}):[a];n.set(r.id,c.map(f=>f.id));for(let f of c){if(!f.id||!f.label||o.has(f.id))throw new Error(`Exemplo sem id/label ou duplicado: ${f.id}`);o.add(f.id)}return c}).filter(r=>!r.hidden),l=new Set(i.map(r=>r.id)),u=(e.groups??[{id:"default",label:"Exemplos"}]).filter(r=>!r.hidden).map(r=>{let a=(r.examples??i.map(v=>v.id)).flatMap(v=>n.get(v)??[v]),c=a.find(v=>!o.has(v));if(c)throw new Error(`Grupo ${r.id}: exemplo desconhecido ${c}.`);let f=(r.defaultExample&&n.get(r.defaultExample)?.[0])??r.defaultExample,C=a.filter(v=>l.has(v));return{...r,examples:C,defaultExample:f&&C.includes(f)?f:C[0]}}).filter(r=>r.examples.length);return{...e,examples:i,groups:u}}async function xr(e,n={}){if(!("source"in e)||!e.source)return e;let o=n.fetch??globalThis.fetch,i=globalThis.document?.baseURI,l=n.baseUrl??e.runtime.baseUrl,u=l?new URL(l,i).href:i,r=(y,m=u)=>{let g=new URL(y,m);if(!["http:","https:"].includes(g.protocol))throw new Error("As fontes precisam de URLs HTTP(S).");return g.href},s=e.source,a="file"in s&&s.file?r(s.file):void 0,c="directory"in s?r("examples.json",r(s.directory.replace(/\/?$/,"/"))):"manifest"in s&&s.manifest?r(s.manifest):r("examples.json",a),f=new URL(".",c).href,C=async(y,m=!1)=>{let g=await o(r(y,f),{signal:n.signal});if(!(m&&g.status===404)){if(!g.ok)throw new Error(`Falha ao carregar ${y}: HTTP ${g.status}`);if(!(m&&g.headers.get("content-type")?.includes("text/html")))return g.text()}},v=await o(c,{signal:n.signal});if(!v.ok)throw new Error(`Falha ao carregar ${c}: HTTP ${v.status}`);let P=Uo(await v.json());if(!P.examples.length||!P.groups?.length)throw new Error("O manifesto n\xE3o tem exemplos vis\xEDveis.");let T=await Promise.all(P.examples.map(async y=>{if(!y.source&&y.html===void 0&&y.code===void 0)throw new Error(`${y.id}: informe source ou html.`);let m=X=>y.source?.replace(/\.html?(?=$|[?#])/i,X),[g,R,S]=await Promise.all([y.html??y.code??C(y.source),y.css??y.styleCode??(y.style?C(y.style):m(".css")!==y.source&&m(".css")?C(m(".css"),!0):void 0),y.javascript??y.scriptCode??(y.script?C(y.script):m(".js")!==y.source&&m(".js")?C(m(".js"),!0):void 0)]);return{...y,html:g,css:R,javascript:S}})),b=P.groups.map(y=>({...y,examples:y.examples.map(m=>T.find(g=>g.id===m))})),E=a?P.examples.find(y=>y.source&&r(y.source,f)===a):void 0;if(a&&!E)throw new Error("O arquivo solicitado n\xE3o est\xE1 nos exemplos vis\xEDveis de examples.json.");let $=E?b.find(y=>y.examples.some(m=>m.id===E.id)):b[0];E&&($.defaultExample=E.id);let M=$.examples.find(y=>y.id===$.defaultExample)??$.examples[0];return{...e,runtime:{...e.runtime,baseUrl:e.runtime.baseUrl??f},example:M,examples:[$,...b.filter(y=>y!==$)]}}var Wo=new Set("html head body p li dt dd rt rp optgroup option colgroup thead tbody tfoot tr td th".split(" ")),Vo=new Set("area base br col embed hr img input link meta param source track wbr".split(" "));function yn(e,n,o){let i=e.slice(0,n).split(`
2
- `);return{message:o,from:n,line:i.length,column:i.at(-1).length+1}}function Er(e){let n=[];for(let o=e.firstChild;o;o=o.nextSibling)n.push(o);return n}function st(e){if(!e.trim())return{source:e,elements:[],issues:[]};let n=wr.parser.parse(e),o=[],i=[],l=new Map;n.iterate({enter(r){r.type.isError&&i.push(yn(e,r.from,"HTML incompleto ou malformado."))}});let u=(r,s)=>{if(r.name!=="Element"){Er(r).forEach(E=>u(E,s));return}let a=r.getChild("OpenTag")??r.getChild("SelfClosingTag");if(!a)return;let c=a.getChild("TagName");if(!c)return;let f=e.slice(c.from,c.to).toLowerCase(),C=l.get(f)??0;l.set(f,C+1);let v=r.getChild("CloseTag"),P=e.slice(a.to-2,a.to)==="/>";!v&&!P&&!Vo.has(f)&&!Wo.has(f)&&i.push(yn(e,a.from,`Feche o elemento <${f}>.`));let T=a.getChildren("Attribute").map(E=>{let $=E.getChild("AttributeName"),M=e.slice($.from,$.to),y=E.getChild("AttributeValue"),m=y?e.slice(y.from,y.to):"",g=m[0]==='"'||m[0]==="'"?m[0]:"";return{name:M,from:E.from,to:E.to,valueFrom:y?y.from+(g?1:0):void 0,valueTo:y?y.to-(g?1:0):void 0,quote:g,raw:g?m.slice(1,-1):m,dynamic:/^(?:[:@*#]|\[|\(|v-|bind-)/.test(M)||/\{\{|\$\{/.test(m)||!g&&m.startsWith("{")}}),b={tag:f,index:C,id:T.find(E=>E.name==="id"&&!E.dynamic)?.raw,from:r.from,to:r.to,openEnd:P?a.to-2:a.to-1,contentFrom:a.to,contentTo:v?.from??a.to,attributes:T,children:[]};o.push(b),s?.children.push(b),Er(r).filter(E=>E.name==="Element").forEach(E=>u(E,b))};return u(n.topNode),{source:e,elements:o,issues:i}}function Jo(e){return e.replace(/^\[\(|\[|\(|:|v-bind:|bind-/,"").replace(/\)\]$|\]$|\)$/,"").replace(/^attr\./,"").replace(/\.(?:prop|attr|camel)$/,"").toLowerCase()}function bn(e,n){return e.attributes.some(o=>Jo(o.name)===n.toLowerCase()&&o.dynamic)}function Sr(e,n){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(n==="'"?/'/g:/"/g,n==="'"?"&#39;":"&quot;")}function Pr(e,n,o,i){let l=st(e);if(l.issues.length)throw new Error(l.issues[0].message);let u=l.elements.find(a=>a.tag===n.tag&&a.index===n.index);if(!u)throw new Error("O elemento selecionado n\xE3o existe mais.");if(bn(u,o))throw new Error("Valor din\xE2mico: edi\xE7\xE3o visual indispon\xEDvel.");if(!/^[a-zA-Z_][\w.:-]*$/.test(o))throw new Error("Nome de atributo inv\xE1lido nos metadados.");let r=u.attributes.find(a=>a.name.toLowerCase()===o.toLowerCase());if(i===null||i===!1)return r?e.slice(0,r.from)+e.slice(r.to):e;if(r&&typeof i=="string"&&r.valueFrom!==void 0&&r.quote)return e.slice(0,r.valueFrom)+Sr(i,r.quote)+e.slice(r.valueTo);let s=i===!0?o:`${o}="${Sr(i,'"')}"`;return r?e.slice(0,r.from)+s+e.slice(r.to):e.slice(0,u.openEnd)+` ${s}`+e.slice(u.openEnd)}function lt(e,n="",o=""){let i=st(e).issues.map(l=>({...l,message:`HTML: ${l.message}`}));for(let[l,u,r]of[["CSS",n,br.parser],["JS",o,vr.parser]])r.parse(u).iterate({enter(s){s.type.isError&&i.push(yn(u,s.from,`${l}: sintaxe incompleta ou inv\xE1lida.`))}});return i}function vn(e,n,o,i){let l=st(e);if(l.issues.length)throw new Error(l.issues[0].message);let u=l.elements.find(f=>f.tag===n.tag&&f.index===n.index),r=!o||o==="default"?u:u?.children.find(f=>f.attributes.some(C=>C.name==="slot"&&C.raw===o));if(!r||r.to<=r.contentFrom)throw new Error("Slot ausente ou sem regi\xE3o de conte\xFAdo: edite a composi\xE7\xE3o na aba HTML.");let s=e.slice(r.contentFrom,r.contentTo);if(/\{\{|\$\{/.test(s))throw new Error("Conte\xFAdo din\xE2mico: edite na aba HTML.");let a=e.slice(0,r.contentFrom)+i+e.slice(r.contentTo),c=st(a).issues;if(c.length)throw new Error(`HTML inv\xE1lido: ${c[0].message}`);return a}function ne(e,n){return n===!0||Array.isArray(n)&&n.includes(e)}import{useEffect as yt,useRef as zt,useState as bt}from"react";import{createContext as Nr,createElement as Ko,cloneElement as Go,isValidElement as Yo,useContext as qe,useEffect as ht,useId as Xo,useRef as Je,useState as Tr,Children as Lr}from"react";var kr={profile:"wbc",version:"2.7.0",fontAwesomeVersion:"6.7.2"};function ft(e=kr){let n=e.profile;if(n!=="wbc"&&n!=="wbc-v4")throw new TypeError("library.profile deve ser wbc ou wbc-v4.");if(e.fontAwesomeVersion!==void 0&&!["5.15.4","6.7.2"].includes(e.fontAwesomeVersion))throw new TypeError("library.fontAwesomeVersion deve ser 5.15.4 ou 6.7.2.");let o=e.version??(n==="wbc"?"2.7.0":void 0);if(!e.moduleUrl&&!o)throw new Error("Informe version ou moduleUrl para WBC v4.");let i=n==="wbc"?"@govbr-ds/webcomponents":"@govbr-ds/components",l=n==="wbc"?"components":"custom-elements";return{profile:n,registration:e.registration??"module",fontAwesomeVersion:e.fontAwesomeVersion??"6.7.2",moduleUrl:e.moduleUrl??`https://cdn.jsdelivr.net/npm/${i}@${o}/dist/${l}/index.js`,styles:e.styles??(n==="wbc"?["https://cdn.jsdelivr.net/npm/@govbr-ds/core@3.6.2/dist/core.min.css"]:[...["tokens.css","theme/light/tokens.css","theme/dark/tokens.css","theme/light/contrast-mode.css","theme/dark/contrast-mode.css"].map(u=>`https://cdn.jsdelivr.net/npm/@govbr-ds/tokens@${e.tokensVersion??"4.0.0-next.39"}/dist/css/${u}`),"https://cdn.jsdelivr.net/npm/@fontsource/noto-sans@5.3.0/latin.css","https://cdn.jsdelivr.net/npm/@fontsource/noto-sans@5.3.0/latin-italic.css"])}}var qo=globalThis,Cr=qo.__govbrPlaygroundLibraries??=new WeakMap;function wn(e){let n=ft(e),o=JSON.stringify(n),i=Cr.get(document);if(i)return i.key===o?i.promise:Promise.reject(new Error("Recarregue a p\xE1gina para trocar a biblioteca do Playground."));let l=(async()=>{if(n.registration==="existing"){await Promise.all(["br-button","br-select"].map(r=>customElements.whenDefined(r)));return}if(customElements.get("br-button"))throw new Error("Uma biblioteca br-* j\xE1 foi registrada. Configure a biblioteca do Playground antes dos componentes do site.");let u=await import(/* webpackIgnore: true */ n.moduleUrl);for(let[r,s]of Object.entries(u))/^defineCustomElement/.test(r)&&typeof s=="function"&&await s();if(!customElements.get("br-button")||!customElements.get("br-select"))throw new Error("O m\xF3dulo da biblioteca n\xE3o registrou br-button e br-select.");await Promise.all(n.styles.map(r=>new Promise((s,a)=>{let c=document.createElement("link");c.rel="stylesheet",c.href=r,c.onload=()=>s(),c.onerror=()=>a(new Error(`Falha ao carregar ${r}`)),document.head.append(c)})))})();return Cr.set(document,{key:o,promise:l}),l}function Bt(e){let n=ft(e);return[...n.styles.map((o,i)=>({id:`library-style-${i}`,type:"style",href:o})),{id:"library-registration",type:"inline-module",content:`import * as library from ${JSON.stringify(n.moduleUrl)}; for (const [name, register] of Object.entries(library)) { if (/^defineCustomElement/.test(name) && typeof register === 'function') await register(); }`}]}import{Fragment as Mr,jsx as Se,jsxs as Zo}from"react/jsx-runtime";var dt=Nr(void 0),Ar=dt.Provider,Ft=Nr("wbc");function Or({library:e,hiddenControls:n,children:o}){let[i,l]=Tr(!1),[u,r]=Tr("");return ht(()=>{let s=!0;return wn(e).then(()=>{s&&l(!0)},a=>{s&&r(String(a.message??a))}),()=>{s=!1}},[e]),u?Se("p",{role:"alert",children:u}):i?Se(dt.Provider,{value:n,children:Se(Ft.Provider,{value:e?.profile??"wbc",children:o})}):Se("p",{role:"status",children:"Carregando componentes do Playground\u2026"})}function Pe(e,n,o){return Ko(e,n,o)}function ie({children:e,type:n="button",title:o,iconOnly:i=!1,emphasis:l=i?"secondary":void 0,...u}){let r=qe(dt),s=qe(Ft);if(ne(u["aria-label"]??(typeof e=="string"?e:""),r))return null;let a=Pe("br-button",{...u,type:n,...l?{emphasis:l}:{},...o?{slot:"trigger",key:"trigger"}:{},density:s==="wbc"?"small":"compact",...i?s==="wbc"?{shape:"circle"}:{"icon-only":!0}:{}},e);return o?Pe("br-tooltip",{position:"top"},[a,Pe("span",{slot:"content",key:"content"},o)]):a}function ve({children:e,onChange:n,value:o,...i}){let l=qe(dt),u=qe(Ft),r=Je(null);ht(()=>{let c=r.current;if(!c)return;c.value=o;let f=C=>n?.({target:c,currentTarget:c,nativeEvent:C});return c.addEventListener("change",f),()=>c.removeEventListener("change",f)},[n,o,l]);let s=Lr.map(e,c=>{if(!Yo(c)||c.type!==B)return c;let f=Array.isArray(o)?o.map(String).includes(String(c.props.value)):String(o??"")===String(c.props.value??"");return Go(c,{selected:f})});if(ne(i["aria-label"]??"",l))return null;let a=i["aria-label"]??"Selecionar";return Pe("br-select",{...i,ref:r,value:o,label:a,...u==="wbc"?{filterable:!1,"hide-search-icon":!0}:{"hide-label":!0,searchable:!1},density:u==="wbc"?"small":"compact"},s)}function B({children:e,value:n,...o}){let i=Lr.toArray(e).filter(l=>typeof l=="string"||typeof l=="number").join("");return Pe("br-select-option",{...o,value:n,label:i.trim()||String(n)},e)}function Ke({onChange:e,type:n,...o}){let i=qe(dt),l=qe(Ft),u=Je(null);return ht(()=>{let r=u.current;if(!r)return;let s=a=>e?.({target:{value:r.value,checked:r.checked,valueAsNumber:Number(r.value)},currentTarget:r,nativeEvent:a});return r.addEventListener("change",s),r.addEventListener("input",s),()=>{r.removeEventListener("change",s),r.removeEventListener("input",s)}},[e,i]),ne(o["aria-label"]??"",i)?null:Pe(n==="checkbox"?"br-checkbox":"br-input",{...o,ref:u,type:n,density:l==="wbc"?"small":"compact"},null)}function $r({children:e,onChange:n,...o}){let i=qe(dt),l=typeof customElements<"u"&&!!customElements.get("br-textarea"),u=Je(null);return ht(()=>{if(!l)return;let r=u.current;if(!r)return;let s=a=>n?.({target:r,currentTarget:r,nativeEvent:a});return r.addEventListener("input",s),()=>r.removeEventListener("input",s)},[n,l,i]),ne(o["aria-label"]??"",i)?null:l?Pe("br-textarea",{...o,ref:u},e):Se("textarea",{...o,onChange:n,children:e})}function Ge({label:e="Ferramentas do playground",items:n,active:o,onChange:i,children:l}){let u=Je(null),r=Je(new Map),s=Xo().replaceAll(":",""),a=Je(i),c=Je(n);a.current=i,c.current=n;let f=typeof customElements<"u"&&!!customElements.get("br-tab"),C=JSON.stringify(n.map(v=>v.id));if(ht(()=>{if(!f||c.current.length<=1)return;let v=u.current;if(!v||!v)return;let P=E=>{E.stopPropagation(),c.current.some($=>$.id===E.detail.tabId)&&a.current(E.detail.tabId)},T=E=>E.stopPropagation();v.addEventListener("brTabItemPropsChange",T),v.addEventListener("brTabChange",P),o&&v.setActiveTab(o);let b=requestAnimationFrame(()=>{o&&v.setActiveTab(o)});return()=>{cancelAnimationFrame(b),v.removeEventListener("brTabChange",P),v.removeEventListener("brTabItemPropsChange",T)}},[o,C,f]),n.length<=1)return Se(Mr,{children:l});if(!f){let v=n.find(T=>T.id===o)??n[0],P=(T,b)=>{let E;switch(T.key){case"ArrowRight":E=(b+1)%n.length;break;case"ArrowLeft":E=(b-1+n.length)%n.length;break;case"Home":E=0;break;case"End":E=n.length-1;break;default:return}T.preventDefault();let $=n[E];r.current.get($.id)?.focus(),i($.id)};return Zo(Mr,{children:[Se("div",{className:"govbr-playground__tool-tabs",role:"tablist","aria-label":e,children:n.map((T,b)=>Se("button",{ref:E=>{E?r.current.set(T.id,E):r.current.delete(T.id)},id:`${s}-tab-${b}`,type:"button",role:"tab","aria-label":T.label,"aria-controls":`${s}-panel`,"aria-selected":o===T.id,tabIndex:o===T.id?0:-1,title:T.iconOnly?T.label:void 0,onClick:()=>i(T.id),onKeyDown:E=>P(E,b),children:T.iconOnly?Se("i",{className:T.icon,"aria-hidden":"true"}):T.label},T.id))}),Se("div",{id:`${s}-panel`,role:"tabpanel","aria-labelledby":`${s}-tab-${n.indexOf(v)}`,tabIndex:0,children:l})]})}return Pe("br-tab",{ref:u,"aria-label":e,label:e,density:"small",scrollable:!0},[...n.filter(v=>v.icon).map(v=>Pe("i",{key:`icon-${v.id}`,slot:`icon-${v.id}`,className:v.icon,"aria-hidden":"true"},null)),...n.map(v=>Pe("br-tab-item",{key:v.id,tabItemId:v.id,label:v.label,title:v.iconOnly?v.label:void 0,iconOnly:v.iconOnly},v.id===o?l:null))])}import{jsx as Ae,jsxs as En}from"react/jsx-runtime";var xn={split:60,stackedSplit:60,properties:!1,preset:"code"};function Qo(e,n){let o={...xn,...n,preset:n?.preset&&["visual","code","inspection"].includes(n.preset)?n.preset:xn.preset,split:Number.isFinite(n?.split)?Math.max(20,Math.min(80,n.split)):n?.preset==="visual"?65:xn.split,properties:n?.properties??(n?.preset==="visual"||n?.preset==="inspection")};try{let i=JSON.parse(localStorage.getItem(`playground-workbench:${e}`)??"null");return i?{split:Number.isFinite(i.split)?Math.max(20,Math.min(80,i.split)):o.split,stackedSplit:Number.isFinite(i.stackedSplit)?Math.max(20,Math.min(80,i.stackedSplit)):60,properties:n?.properties??(n?.preset==="visual"||n?.preset==="inspection"),preset:n?.preset??"code"}:o}catch{return o}}function _r({id:e,header:n,preview:o,code:i,properties:l,diagnostics:u,diagnosticItems:r=[],onDiagnosticTabChange:s,selectionRequest:a,onCombinedPanelChange:c,initial:f,presentation:C="developer",hiddenControls:v}){let[P,T]=bt(()=>Qo(e,f)),[b,E]=bt(0),[$,M]=bt("preview"),[y,m]=bt("properties"),g=zt(null),R=zt(null),S=zt(null),X=zt(null),[Y,V]=bt(!1),Z=b>=1100,H=!!(i||l||r.length)&&(b>=1600||!!(l&&Z&&P.properties)),ae=C==="developer"&&(b<700||!Z&&b<1100)&&!!(i||l||u||r.length),j=!!(l&&b<1600&&!Z&&P.properties),re=!!(i&&H),J=!!(i&&(ae||b<1600&&P.properties&&!re)),ue=(w,A)=>w.some(D=>D.id===A)?A:w[0]?.id,fe=i?[{id:"code",label:"C\xF3digo-fonte"}]:[],Ce=w=>w==="code",ce=[...fe,...l?[{id:"properties",label:"Propriedades"}]:[],...r],_e=ue(ce,y),he=[...ae?[{id:"preview",label:"Preview"}]:[],...J?fe:[],...j?[{id:"properties",label:"Propriedades"}]:[],...H?[]:r],ye=ue(he,$);yt(()=>{a&&(T(w=>({...w,properties:!0,preset:"inspection"})),M("properties"))},[a]),yt(()=>{T(w=>({...w,preset:f?.preset??"code",properties:f?.properties??(f?.preset==="visual"||f?.preset==="inspection"),...Number.isFinite(f?.split)?{split:Math.max(20,Math.min(80,f.split))}:{}}))},[f]),yt(()=>{try{localStorage.setItem(`playground-workbench:${e}`,JSON.stringify(P))}catch{}},[e,P]),yt(()=>{let w=new ResizeObserver(([A])=>{let D=A.contentRect.width;E(D)});return g.current&&w.observe(g.current),()=>w.disconnect()},[]),yt(()=>{c?.(ae||H||j||J)},[J,ae,c,j,H]);let Fe=j||J||!H&&r.length>0,p=w=>{let A=(w?X:R).current?.getBoundingClientRect(),D=Math.max(1,(w?A?.height:A?.width)??1)-12,Q=w?160:240,le=w?180:280;return{min:Math.min(45,Math.max(20,Q/D*100)),max:Math.max(55,Math.min(80,100-le/D*100))}},k=(w,A)=>{let D=p(A);T(Q=>({...Q,[A?"stackedSplit":"split"]:Math.max(D.min,Math.min(D.max,w)),preset:"custom"}))},se=w=>ne("panels-resize",v)?null:Ae("div",{ref:w?void 0:S,className:w?"govbr-playground__stacked-divider":"govbr-playground__bench-divider",role:"separator",tabIndex:0,"aria-label":"Redimensionar preview e ferramentas","aria-orientation":w||!Z?"horizontal":"vertical","aria-valuemin":20,"aria-valuemax":80,"aria-valuenow":Math.round(w?P.stackedSplit:P.split),onPointerDown:A=>{A.preventDefault(),A.currentTarget.focus(),A.currentTarget.setPointerCapture(A.pointerId),V(!0)},onPointerMove:A=>{if(!A.currentTarget.hasPointerCapture(A.pointerId))return;let D=(w?X:R).current?.getBoundingClientRect();if(!D)return;let Q=w||!Z,le=(Q?D.height:D.width)-12;le>0&&k(((Q?A.clientY-D.top:A.clientX-D.left)-6)/le*100,w)},onPointerUp:A=>{A.currentTarget.hasPointerCapture(A.pointerId)&&A.currentTarget.releasePointerCapture(A.pointerId),V(!1)},onLostPointerCapture:()=>V(!1),onPointerCancel:()=>V(!1),onDoubleClick:()=>k(60,w),onKeyDown:A=>{let D=w||!Z,Q=D?"ArrowUp":"ArrowLeft";if(![Q,D?"ArrowDown":"ArrowRight","Home","End"].includes(A.key))return;A.preventDefault();let St=p(w),Pt=w?P.stackedSplit:P.split;k(A.key==="Home"?St.min:A.key==="End"?St.max:Pt+(A.key===Q?-1:1)*(A.shiftKey?10:2),w)}});return En("div",{ref:g,className:"govbr-playground__bench","data-resizing":Y,"data-presentation":C,children:[Ae("header",{className:"govbr-playground__bench-header",children:n}),En("div",{ref:X,className:"govbr-playground__workspace","data-stacked-tools":Fe,"data-tools-open":Fe,"data-mobile-tabs":ae,style:{"--stacked-split":`${P.stackedSplit}fr`,"--stacked-rest":`${100-P.stackedSplit}fr`},children:[!ae&&En("div",{ref:R,className:"govbr-playground__bench-main","data-layout":"auto","data-wide":b>=1600,"data-inspector-tabs":H,"data-only-preview":!i&&!H&&!l,"data-properties":P.properties&&!!l&&!j,"data-has-code":!!(i&&!J&&!re),style:{"--bench-split":`${P.split}fr`,"--bench-rest":`${100-P.split}fr`},children:[Ae("section",{className:"govbr-playground__bench-preview","aria-label":"Visualiza\xE7\xE3o",children:o}),(i&&!J&&!re||H)&&se(!1),i&&!J&&!re&&b<1600&&Ae("section",{className:"govbr-playground__bench-code","aria-label":"Edi\xE7\xE3o",children:i}),l&&!j||H&&ce.length>0?Ae("aside",{className:"govbr-playground__bench-properties","aria-label":"Inspetor de componentes",children:H?Ae(Ge,{label:"C\xF3digo-fonte, propriedades e ferramentas",active:_e,onChange:w=>{m(w),!Ce(w)&&w!=="properties"&&s?.(w)},items:ce,children:Ce(_e)?i:_e==="properties"?l:u}):l}):null]}),Fe&&!ae&&se(!0),b<1600&&(ae||u||J||j)&&he.length>0&&Ae("div",{className:ae?"govbr-playground__diagnostics govbr-playground__diagnostics--mobile-tabs":"govbr-playground__diagnostics",children:he.length?Ae(Ge,{label:ae?"Preview, c\xF3digo-fonte, propriedades, console e eventos":"C\xF3digo-fonte, propriedades, console e eventos",active:ye,onChange:w=>{M(w),!Ce(w)&&w!=="properties"&&s?.(w)},items:he,children:ye==="preview"?Ae("section",{className:"govbr-playground__bench-preview","aria-label":"Visualiza\xE7\xE3o",children:o}):Ce(ye)?i:ye==="properties"?l:u}):null})]})]})}import{Suspense as no,useCallback as Jt,useEffect as F,useMemo as qt,useRef as $e,useState as L}from"react";import{lazy as ei,useMemo as ti,useRef as Ir,useEffect as ni}from"react";import{jsx as Rr}from"react/jsx-runtime";function ri(e,n,o){switch(e){case"html":return[o.html({extraTags:Object.fromEntries((n?.components??[]).map(i=>[i.tag,{attrs:Object.fromEntries(i.props.map(l=>[l.attribute,l.values?.length?l.values:null]))}]))})];case"css":return[o.css()];case"typescript":return[o.javascript({typescript:!0})];case"tsx":return[o.javascript({jsx:!0,typescript:!0})];case"javascript":case"jsx":return[o.javascript({jsx:e==="jsx"})];default:return[]}}var oi=ei(async()=>{let[e,n,o,i,l]=await Promise.all([import("./chunks/esm-YAO6K4CU.js"),import("./chunks/esm-6SLZNXJD.js"),import("./chunks/dist-MALZEIQI.js"),import("./chunks/dist-H5E3DUQZ.js"),import("./chunks/dist-HT72W6BH.js")]),u=e.default,r={html:o.html,css:i.css,javascript:l.javascript};function s({language:a,themeMode:c,controlManifest:f,readOnly:C=!1,editable:v=!0,sessions:P,sessionKey:T,...b}){let E=Ir(null),$=Ir(void 0),M=()=>{let g=E.current;if(!g?.dom.isConnected||!P||!T)return;let R=P.get(T),S=g.dom.getClientRects().length>0;P.set(T,{state:g.state,top:S?g.scrollDOM.scrollTop:R?.top??0,left:S?g.scrollDOM.scrollLeft:R?.left??0})};ni(()=>()=>{M(),E.current?.scrollDOM.removeEventListener("scroll",M),$.current!==void 0&&cancelAnimationFrame($.current)},[P,T]);let y=b["aria-label"]??`Editor de c\xF3digo ${a??"do exemplo"}`,m=ti(()=>ri(a,f,r),[a,f]);return Rr(u,{...b,root:document,readOnly:C,editable:v&&!C,"aria-label":y,onUpdate:g=>{M(),b.onUpdate?.(g)},onCreateEditor:(g,R)=>{E.current=g,g.scrollDOM.addEventListener("scroll",M,{passive:!0});let S=T?P?.get(T):void 0;if(S){let X=S.state.doc.toString(),Y=b.value??"",V=0,Z=X.length,H=Y.length;for(;V<Z&&V<H&&X[V]===Y[V];)V++;for(;Z>V&&H>V&&X[Z-1]===Y[H-1];)Z--,H--;g.setState(X===Y?S.state:S.state.update({changes:{from:V,to:Z,insert:Y.slice(V,H)}}).state),$.current=requestAnimationFrame(()=>{g.requestMeasure({read:()=>null,write:()=>{g.scrollDOM.scrollTop=S.top,g.scrollDOM.scrollLeft=S.left}})})}g.contentDOM.setAttribute("aria-label",y),b.onCreateEditor?.(g,R)},theme:c==="dark"?n.githubDark:n.githubLight,extensions:[...m,...b.extensions??[]]})}return{default:s}});function vt(e){return Rr(oi,{...e})}import{Suspense as ii,useEffect as Ut,useMemo as Sn,useState as Oe,useRef as ai}from"react";import{jsx as _,jsxs as G}from"react/jsx-runtime";function si(e){let n=(e.type??"").split("|").map(o=>o.trim()).filter(o=>!["undefined","null",""].includes(o));return n.length&&n.every(o=>["boolean","true","false"].includes(o))?"checkbox":n.includes("number")&&n.includes("string")?"text":e.control}function jr(e){return new DOMParser().parseFromString(e||"","text/html")}function li(e,n,o){let i=jr(e),l=new Set(n.map(s=>s.tag.toLowerCase())),u=Array.from(i.body.querySelectorAll("*")).filter(s=>l.has(s.localName)),r=u;if(o)try{u=u.filter(s=>s.matches(o))}catch{return[]}return u.map(s=>{let a=s.localName,c=r.filter(v=>v.localName===a).indexOf(s),f=0;for(let v=s.parentElement;v;v=v.parentElement)l.has(v.localName)&&f++;let C=s.getAttribute("label")||s.textContent?.trim().slice(0,60)||"";return{tag:a,index:c,depth:f,id:s.id||void 0,label:`${a}${c?` #${c+1}`:""}${C?` \u2014 ${C}`:""}`}})}function di(e,n){return n?Array.from(e.body.querySelectorAll(n.tag))[n.index]??null:null}function Hr({manifest:e,html:n,tag:o,target:i,readOnly:l=!1,themeMode:u="light",hidden:r,selectedInstance:s,onSelectedInstanceChange:a,onHighlightInstance:c,onHtmlChange:f}){let[C,v]=Oe(""),[P,T]=Oe(""),[b,E]=Oe(""),[$,M]=Oe(""),[y,m]=Oe(()=>new Set),g=ai({key:""}),R=Sn(()=>st(n),[n]),S=s||C,X=e.components??[],Y=Sn(()=>li(n,X,i),[n,X,i]),V=Sn(()=>{let p=[],k=[];for(let se of Y){for(;k.length&&k[k.length-1].depth>=se.depth;)k.pop();let w={...se,children:[]};k.length?k[k.length-1].children.push(w):p.push(w),k.push(w)}return p},[Y]),Z=Y.map(p=>`${p.tag}:${p.index}:${p.depth}`).join("|");Ut(()=>{m(new Set)},[Z]);let H=p=>{let k=`${p.tag}:${p.index}`,se=k===S,w=()=>{v(k),a?.(k)};return _("li",{children:p.children.length?G("details",{open:!y.has(k),onToggle:A=>{A.stopPropagation();let D=A.currentTarget.open;m(Q=>{if(Q.has(k)===!D)return Q;let le=new Set(Q);return D?le.delete(k):le.add(k),le})},children:[_("summary",{className:`govbr-playground__component-tree-item${se?" is-selected":""}`,"aria-current":se?"true":void 0,onClick:w,onPointerEnter:()=>c?.(k),onPointerLeave:()=>c?.(null),onFocus:()=>c?.(k),onBlur:()=>c?.(null),children:p.label}),_("ul",{children:p.children.map(H)})]}):_("span",{className:`govbr-playground__component-tree-item${se?" is-selected":""}`,"aria-current":se?"true":void 0,tabIndex:0,onClick:w,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),w())},onPointerEnter:()=>c?.(k),onPointerLeave:()=>c?.(null),onFocus:()=>c?.(k),onBlur:()=>c?.(null),children:p.label})},k)},j=(g.current.key===S&&g.current.id?Y.find(p=>p.id===g.current.id):void 0)??Y.find(p=>`${p.tag}:${p.index}`===S)??Y.find(p=>p.tag===o)??Y[0],re=X.find(p=>p.tag===j?.tag),J=p=>ne(p,r),ue=re&&{...re,props:J("props")?[]:re.props.filter(p=>!J(`prop:${re.tag}:${p.attribute}`)),slots:J("slots")?[]:re.slots.filter(p=>!J(`slot:${re.tag}:${p.name||"default"}`))},fe=di(jr(n),j);if(Ut(()=>{if(j){let p=`${j.tag}:${j.index}`;v(p),g.current={key:p,id:j.id},s&&s!==p&&a?.(p)}else v("")},[j?.tag,j?.index,j?.id,s]),!j||!ue||!fe)return _("p",{children:"Nenhum componente control\xE1vel encontrado neste exemplo."});let Ce=R.elements.find(p=>p.tag===j.tag&&p.index===j.index),ce=l||R.issues.length>0,_e=p=>{if(!ce)try{f(p()),M("")}catch(k){M(k instanceof Error?k.message:String(k))}},he=(p,k)=>_e(()=>Pr(n,j,p.attribute,p.control==="checkbox"?k:String(k).trim()?String(k):null)),ye=p=>p.control==="checkbox"?fe.hasAttribute(p.attribute):fe.getAttribute(p.attribute)??"",Fe=(p,k)=>_e(()=>vn(n,j,p,k));return G("section",{className:"govbr-playground__controls","aria-label":"Controles de propriedades e slots",children:[G("header",{children:[$&&_("p",{role:"alert",children:$}),ce&&_("p",{role:"status",children:"Fonte inv\xE1lida: modelo anterior preservado; corrija o c\xF3digo para editar propriedades."}),_("strong",{children:j.tag}),!J("tree")&&G("details",{open:!0,children:[_("summary",{children:"\xC1rvore de componentes"}),_("ul",{className:"govbr-playground__component-tree",children:V.map(H)})]})]}),!J("search")&&_(Ke,{"aria-label":"Buscar propriedade",placeholder:"Buscar propriedade",value:P,onChange:p=>T(p.target.value)}),!J("groups")&&ue.props.some(p=>p.group)&&G(ve,{"aria-label":"Grupo de propriedades",value:b,onChange:p=>E(p.target.value),children:[_(B,{value:"",children:"Todos os grupos"}),[...new Set(ue.props.map(p=>p.group).filter(Boolean))].map(p=>_(B,{value:p,children:p},p))]}),ue.props.length>0&&G("details",{open:!0,children:[_("summary",{children:"Props"}),G("table",{children:[_("thead",{children:G("tr",{children:[_("th",{children:"Propriedade"}),_("th",{children:"Descri\xE7\xE3o"}),_("th",{children:"Valor"})]})}),_("tbody",{children:[...ue.props].map(p=>({...p,control:si(p)})).filter(p=>(!b||p.group===b)&&`${p.propertyName} ${p.attribute} ${p.description??""}`.toLocaleLowerCase().includes(P.toLocaleLowerCase())).sort((p,k)=>p.propertyName.localeCompare(k.propertyName)).map(p=>G("tr",{children:[_("th",{scope:"row",children:_("code",{children:p.propertyName})}),_("td",{children:p.description||"Sem descri\xE7\xE3o."}),G("td",{children:[_("small",{children:[`Tipo: ${p.type??p.control}`,p.default!==void 0&&p.default!==null&&String(p.default)!==""?`Padr\xE3o: ${p.default}`:void 0,p.values?.length?`Valores: ${p.values.join(", ")}`:void 0].filter(Boolean).join(" \xB7 ")}),_("div",{className:"govbr-playground__property-field",children:Ce&&bn(Ce,p.attribute)?_("p",{children:"Valor din\xE2mico / edi\xE7\xE3o visual indispon\xEDvel"}):p.control==="json"||/object|array|\[\]/i.test(p.type??"")?_(ci,{value:String(ye(p)),disabled:ce,label:p.propertyName,onApply:k=>he(p,k)}):p.control==="checkbox"?_(Ke,{type:"checkbox",disabled:ce,"aria-label":p.propertyName,checked:!!ye(p),onChange:k=>he(p,k.target.checked)}):p.control==="select"?G(ve,{disabled:ce,"aria-label":p.propertyName,value:String(ye(p)),onChange:k=>he(p,k.target.value),children:[G(B,{value:"",children:["(padr\xE3o",p.default?`: ${p.default}`:"",")"]}),(p.values??[]).map(k=>_(B,{value:k,children:k},k))]}):_(Ke,{type:p.control==="number"?"number":"text",disabled:ce,"aria-label":p.propertyName,placeholder:p.default,value:String(ye(p)),onChange:k=>he(p,k.target.value)})})]})]},p.attribute))})]})]}),ue.slots.length>0&&G("details",{children:[_("summary",{children:"Slots"}),ue.slots.map(p=>{let k=p.name==="default"||p.name===""?fe:fe.querySelector(`[slot="${CSS.escape(p.name)}"]`),se=k&&/\{\{|\$\{/.test(k.innerHTML),w=k?.innerHTML??"";return G("div",{className:"govbr-playground__control-field",children:[G("strong",{children:["Slot ",p.name||"padr\xE3o"]}),_("small",{children:p.description}),!k&&_("p",{children:"Slot ausente: adicione a composi\xE7\xE3o na aba HTML."}),se&&_("p",{children:"Conte\xFAdo din\xE2mico: edite na aba HTML."}),_(ui,{label:`Conte\xFAdo do slot ${p.name||"padr\xE3o"}`,language:"html",themeMode:u,readOnly:ce||!k||!!se,value:w,placeholder:"Digite o conte\xFAdo HTML do slot\u2026",onApply:A=>Fe(p.name,A),validate:A=>{vn(n,j,p.name,A)}},`${j.tag}:${j.index}:slot:${p.name}`)]},p.name)})]})]})}function ci({value:e,disabled:n,label:o,onApply:i}){let[l,u]=Oe(e),[r,s]=Oe("");return Ut(()=>{u(e),s("")},[e]),G("div",{children:[_($r,{disabled:n,"aria-label":`JSON de ${o}`,value:l,onChange:a=>u(a.target.value)}),_(ie,{disabled:n,onClick:()=>{try{let a=JSON.parse(l);if(!a||typeof a!="object")throw new Error("Use um objeto ou array JSON.");i(JSON.stringify(a)),s("")}catch{s("Informe um objeto ou array JSON v\xE1lido.")}},children:"Aplicar JSON"}),r&&_("p",{role:"alert",children:r})]})}function ui({label:e,language:n,themeMode:o,readOnly:i,value:l,placeholder:u,onApply:r,validate:s}){let[a,c]=Oe(l),[f,C]=Oe("");return Ut(()=>{c(l),C("")},[l]),G("div",{className:"govbr-playground__inspector-code",children:[_(ii,{fallback:_("p",{role:"status",children:"Carregando editor\u2026"}),children:_(vt,{"aria-label":e,language:n,themeMode:o,value:a,readOnly:i,editable:!i,onChange:c,placeholder:u,height:"auto",minHeight:"7rem",maxHeight:"18rem",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!i}})}),!i&&G(ie,{disabled:a===l,onClick:()=>{try{s(a),r(a),C("")}catch(v){C(v instanceof Error?v.message:String(v))}},children:["Aplicar ",n==="css"?"CSS":"HTML"]}),f&&_("p",{role:"alert",children:f})]})}var Mn=zo(Dr(),1),Br=256*1024,Fr=1024*1024,Cn=512*1024,zr=32;function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Tn(e){if(!kn(e)||typeof e.h!="string"||e.h.length>Cn||typeof e.c!="string"||e.c.length>Cn||e.j!==null&&typeof e.j!="string"||typeof e.j=="string"&&e.j.length>Cn||e.s!==void 0&&(typeof e.s!="string"||e.s.length>2048)||e.exampleId!==void 0&&(typeof e.exampleId!="string"||e.exampleId.length>128))return!1;if(e.environment!==void 0){let n=e.environment;if(!kn(n)||!["light","dark"].includes(String(n.theme))||!["pt-BR","en-US"].includes(String(n.locale))||!["ltr","rtl"].includes(String(n.direction))||["contrast","skeleton","reducedMotion"].some(o=>typeof n[o]!="boolean")||n.width!=="100%"&&(typeof n.width!="number"||!Number.isFinite(n.width)||n.width<1||n.width>1e4)||typeof n.height!="number"||!Number.isFinite(n.height)||n.height<1||n.height>1e4)return!1}return!0}function Ur(e){if(e.length===0||e.length>zr||!e.every(Tn))return null;let n=e.length===1?e[0]:{p:e};try{let o=JSON.stringify(n);if(o.length>Fr)return null;let i=Mn.default.compressToEncodedURIComponent(o);return i.length<=Br?i:null}catch{return null}}function Wr(e){return kn(e)&&Array.isArray(e.p)?e.p.slice(0,zr).filter(Tn):Tn(e)&&e.s?[e]:[]}function Vr(e){try{if(!e||e.length>Br)return null;let n=i=>{if(!i||i.length>Fr)return null;try{return JSON.parse(i)}catch{return null}},o=n(Mn.default.decompressFromEncodedURIComponent(e));if(o!==null)return o;if(typeof atob=="function"&&typeof TextDecoder<"u"){let i=atob(e),l=Uint8Array.from(i,r=>r.charCodeAt(0)),u=new TextDecoder().decode(l);return n(u)}return null}catch{return null}}function Nn(e,n){return`govbr-playground:${e}:${n??"default"}`}function Ln(e,n){if(typeof window>"u")return null;try{let o=window.localStorage.getItem(Nn(e,n));if(!o||o.length>524288)return null;let i=JSON.parse(o);return typeof i.html!="string"||typeof i.updatedAt!="number"||i.css!==void 0&&typeof i.css!="string"||i.javascript!==void 0&&typeof i.javascript!="string"?null:{html:i.html,css:i.css??"",javascript:i.javascript??"",id:i.id,updatedAt:i.updatedAt}}catch{return null}}function Jr(e,n,o=n.id){if(typeof window>"u")return!1;try{let i={...n,css:n.css??"",javascript:n.javascript??"",updatedAt:Date.now()},l=JSON.stringify(i);return l.length>524288?!1:(window.localStorage.setItem(Nn(e,o),l),!0)}catch{return!1}}function qr(e,n){try{window.localStorage.removeItem(Nn(e,n))}catch{}}function Ye(e){return{entries:[e],index:0}}function An(e,n,o=50){if(e.entries[e.index]===n)return e;let i=e.entries.slice(0,e.index+1);return i.push(n),i.length>o&&i.shift(),{entries:i,index:i.length-1}}function Kr(e,n){let o=e.index+n;return o<0||o>=e.entries.length?{changed:!1,history:e,value:e.entries[e.index]??""}:{changed:!0,history:{...e,index:o},value:e.entries[o]}}function pi(){return Promise.all([import("./chunks/standalone-G7AM3SII.js"),import("./chunks/babel-PXSNAHUX.js"),import("./chunks/estree-EALESNBX.js"),import("./chunks/html-C5MOHUJO.js"),import("./chunks/postcss-RXMLIASD.js")])}var mi;async function ct(e,n){if(!e.trim())return e;let[{format:o},...i]=await(mi??=pi()),l=i.map(u=>u.default||u).filter(Boolean);try{return await o(e,{parser:n,plugins:l,printWidth:n==="html"?40:80,htmlWhitespaceSensitivity:"ignore",bracketSameLine:!1,singleAttributePerLine:!0})}catch{return e}}async function wt(e){let[n,o,i]=await Promise.all([ct(e.html,"html"),e.css===void 0?void 0:ct(e.css,"css"),e.javascript===void 0?void 0:ct(e.javascript,"babel")]);return{...e,html:n,css:o,javascript:i}}async function Gr(e){let[n,o]=await Promise.all([wt(e.example),e.examples&&Promise.all(e.examples.map(async i=>({...i,examples:await Promise.all(i.examples.map(wt))})))]);return{...e,example:n,examples:o}}var gi=e=>[...new Set(Array.from(e.matchAll(/<\/?([a-z][a-z0-9]*-[a-z0-9-]+)/gi),n=>n[1]))].sort().map(n=>({tag:n,name:n.split("-").map(o=>o[0].toUpperCase()+o.slice(1)).join("")})),Yr=e=>e.replace(/(<\/?)([a-z][a-z0-9]*-[a-z0-9-]+)/gi,(n,o,i)=>`${o}${i.split("-").map(l=>l[0].toUpperCase()+l.slice(1)).join("")}`),xt=(e,n)=>e.split(`
1
+ import{c as hr}from"./chunks/chunk-WUR2JRNJ.js";import{c as gr}from"./chunks/chunk-ZIL2IWZ3.js";import{f as fr}from"./chunks/chunk-EP7B2XPY.js";import"./chunks/chunk-UVFYWQD2.js";import"./chunks/chunk-TFWQIFOZ.js";import"./chunks/chunk-5A3ZKBRD.js";import{a as Xo,b as Yo}from"./chunks/chunk-6DHFEWGX.js";var Ur=Xo((fa,Dt)=>{var bn=(function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",a={};function l(r,s){if(!a[r]){a[r]={};for(var i=0;i<r.length;i++)a[r][r.charAt(i)]=i}return a[r][s]}var c={compressToBase64:function(r){if(r==null)return"";var s=c._compress(r,6,function(i){return n.charAt(i)});switch(s.length%4){default:case 0:return s;case 1:return s+"===";case 2:return s+"==";case 3:return s+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:c._decompress(r.length,32,function(s){return l(n,r.charAt(s))})},compressToUTF16:function(r){return r==null?"":c._compress(r,15,function(s){return e(s+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:c._decompress(r.length,16384,function(s){return r.charCodeAt(s)-32})},compressToUint8Array:function(r){for(var s=c.compress(r),i=new Uint8Array(s.length*2),d=0,m=s.length;d<m;d++){var x=s.charCodeAt(d);i[d*2]=x>>>8,i[d*2+1]=x%256}return i},decompressFromUint8Array:function(r){if(r==null)return c.decompress(r);for(var s=new Array(r.length/2),i=0,d=s.length;i<d;i++)s[i]=r[i*2]*256+r[i*2+1];var m=[];return s.forEach(function(x){m.push(e(x))}),c.decompress(m.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":c._compress(r,6,function(s){return o.charAt(s)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),c._decompress(r.length,32,function(s){return l(o,r.charAt(s))}))},compress:function(r){return c._compress(r,16,function(s){return e(s)})},_compress:function(r,s,i){if(r==null)return"";var d,m,x={},y={},T="",A="",w="",C=2,R=3,S=2,k=[],g=0,f=0,I;for(I=0;I<r.length;I+=1)if(T=r.charAt(I),Object.prototype.hasOwnProperty.call(x,T)||(x[T]=R++,y[T]=!0),A=w+T,Object.prototype.hasOwnProperty.call(x,A))w=A;else{if(Object.prototype.hasOwnProperty.call(y,w)){if(w.charCodeAt(0)<256){for(d=0;d<S;d++)g=g<<1,f==s-1?(f=0,k.push(i(g)),g=0):f++;for(m=w.charCodeAt(0),d=0;d<8;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1}else{for(m=1,d=0;d<S;d++)g=g<<1|m,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=0;for(m=w.charCodeAt(0),d=0;d<16;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1}C--,C==0&&(C=Math.pow(2,S),S++),delete y[w]}else for(m=x[w],d=0;d<S;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1;C--,C==0&&(C=Math.pow(2,S),S++),x[A]=R++,w=String(T)}if(w!==""){if(Object.prototype.hasOwnProperty.call(y,w)){if(w.charCodeAt(0)<256){for(d=0;d<S;d++)g=g<<1,f==s-1?(f=0,k.push(i(g)),g=0):f++;for(m=w.charCodeAt(0),d=0;d<8;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1}else{for(m=1,d=0;d<S;d++)g=g<<1|m,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=0;for(m=w.charCodeAt(0),d=0;d<16;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1}C--,C==0&&(C=Math.pow(2,S),S++),delete y[w]}else for(m=x[w],d=0;d<S;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1;C--,C==0&&(C=Math.pow(2,S),S++)}for(m=2,d=0;d<S;d++)g=g<<1|m&1,f==s-1?(f=0,k.push(i(g)),g=0):f++,m=m>>1;for(;;)if(g=g<<1,f==s-1){k.push(i(g));break}else f++;return k.join("")},decompress:function(r){return r==null?"":r==""?null:c._decompress(r.length,32768,function(s){return r.charCodeAt(s)})},_decompress:function(r,s,i){var d=[],m,x=4,y=4,T=3,A="",w=[],C,R,S,k,g,f,I,E={val:i(0),position:s,index:1};for(C=0;C<3;C+=1)d[C]=C;for(S=0,g=Math.pow(2,2),f=1;f!=g;)k=E.val&E.position,E.position>>=1,E.position==0&&(E.position=s,E.val=i(E.index++)),S|=(k>0?1:0)*f,f<<=1;switch(m=S){case 0:for(S=0,g=Math.pow(2,8),f=1;f!=g;)k=E.val&E.position,E.position>>=1,E.position==0&&(E.position=s,E.val=i(E.index++)),S|=(k>0?1:0)*f,f<<=1;I=e(S);break;case 1:for(S=0,g=Math.pow(2,16),f=1;f!=g;)k=E.val&E.position,E.position>>=1,E.position==0&&(E.position=s,E.val=i(E.index++)),S|=(k>0?1:0)*f,f<<=1;I=e(S);break;case 2:return""}for(d[3]=I,R=I,w.push(I);;){if(E.index>r)return"";for(S=0,g=Math.pow(2,T),f=1;f!=g;)k=E.val&E.position,E.position>>=1,E.position==0&&(E.position=s,E.val=i(E.index++)),S|=(k>0?1:0)*f,f<<=1;switch(I=S){case 0:for(S=0,g=Math.pow(2,8),f=1;f!=g;)k=E.val&E.position,E.position>>=1,E.position==0&&(E.position=s,E.val=i(E.index++)),S|=(k>0?1:0)*f,f<<=1;d[y++]=e(S),I=y-1,x--;break;case 1:for(S=0,g=Math.pow(2,16),f=1;f!=g;)k=E.val&E.position,E.position>>=1,E.position==0&&(E.position=s,E.val=i(E.index++)),S|=(k>0?1:0)*f,f<<=1;d[y++]=e(S),I=y-1,x--;break;case 2:return w.join("")}if(x==0&&(x=Math.pow(2,T),T++),d[I])A=d[I];else if(I===y)A=R+R.charAt(0);else return null;w.push(A),d[y++]=R+A.charAt(0),x--,R=A,x==0&&(x=Math.pow(2,T),T++)}}};return c})();typeof define=="function"&&define.amd?define(function(){return bn}):typeof Dt<"u"&&Dt!=null?Dt.exports=bn:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return bn})});function pn(e){if(!e||!Array.isArray(e.examples))throw new Error("examples.json precisa de uma lista examples.");let n=new Map,o=new Set,a=e.examples.flatMap(r=>{let{items:s,...i}=r;if(s!==void 0&&(!Array.isArray(s)||!s.length))throw new Error(`Categoria ${r.id} precisa de items n\xE3o vazio.`);let d=s?s.map(m=>{if(m.items)throw new Error("Categorias aninhadas n\xE3o s\xE3o suportadas.");return{...i,...m,id:`${r.id}-${m.id}`,hidden:r.hidden||m.hidden,category:{id:r.id,label:r.label}}}):[i];n.set(r.id,d.map(m=>m.id));for(let m of d){if(!m.id||!m.label||o.has(m.id))throw new Error(`Exemplo sem id/label ou duplicado: ${m.id}`);o.add(m.id)}return d}).filter(r=>!r.hidden),l=new Set(a.map(r=>r.id)),c=(e.groups??[{id:"default",label:"Exemplos"}]).filter(r=>!r.hidden).map(r=>{let i=(r.examples??a.map(y=>y.id)).flatMap(y=>n.get(y)??[y]),d=i.find(y=>!o.has(y));if(d)throw new Error(`Grupo ${r.id}: exemplo desconhecido ${d}.`);let m=(r.defaultExample&&n.get(r.defaultExample)?.[0])??r.defaultExample,x=i.filter(y=>l.has(y));return{...r,examples:x,defaultExample:m&&x.includes(m)?m:x[0]}}).filter(r=>r.examples.length);return{...e,examples:a,groups:c}}function Zo(e,n={}){let o=pn(e),a=new Map(o.examples.map(s=>[s.id,{...s,html:s.html??s.code??"",css:s.css??s.styleCode,javascript:s.javascript??s.scriptCode}])),l=o.groups.map(s=>({...s,examples:s.examples.map(i=>a.get(i))})),c=l.find(s=>n.exampleId?s.examples.some(i=>i.id===n.exampleId):s.id===n.groupId)??l[0];if(!c)throw new Error("O manifesto n\xE3o tem exemplos vis\xEDveis.");let r=n.exampleId??c.defaultExample;return{example:c.examples.find(s=>s.id===r)??c.examples[0],examples:[{...c,defaultExample:n.exampleId??c.defaultExample},...l.filter(s=>s!==c)]}}async function Qo(e,n){let o=pn(e),a=await Promise.all(o.examples.map(async l=>{if(!l.source&&l.html===void 0&&l.code===void 0)throw new Error(`${l.id}: informe source ou html.`);let c=d=>l.source?.replace(/\.html?(?=$|[?#])/i,d),[r,s,i]=await Promise.all([l.html??l.code??n(l.source),l.css??l.styleCode??(l.style?n(l.style):c(".css")!==l.source&&c(".css")?n(c(".css"),!0):void 0),l.javascript??l.scriptCode??(l.script?n(l.script):c(".js")!==l.source&&c(".js")?n(c(".js"),!0):void 0)]);return{...l,html:r,css:s,javascript:i}}));return{...o,examples:a}}async function yr(e,n={}){if(!("source"in e)||!e.source)return e;let o=n.fetch??globalThis.fetch,a=globalThis.document?.baseURI,l=n.baseUrl??e.runtime.baseUrl,c=l?new URL(l,a).href:a,r=(C,R=c)=>{let S=new URL(C,R);if(!["http:","https:"].includes(S.protocol))throw new Error("As fontes precisam de URLs HTTP(S).");return S.href},s=e.source,i="file"in s&&s.file?r(s.file):void 0,d="directory"in s?r("examples.json",r(s.directory.replace(/\/?$/,"/"))):"manifest"in s&&s.manifest?r(s.manifest):r("examples.json",i),m=new URL(".",d).href,x=async(C,R=!1)=>{let S=await o(r(C,m),{signal:n.signal});if(!(R&&S.status===404)){if(!S.ok)throw new Error(`Falha ao carregar ${C}: HTTP ${S.status}`);if(!(R&&S.headers.get("content-type")?.includes("text/html")))return S.text()}},y=await o(d,{signal:n.signal});if(!y.ok)throw new Error(`Falha ao carregar ${d}: HTTP ${y.status}`);let T=pn(await y.json());if(!T.examples.length||!T.groups?.length)throw new Error("O manifesto n\xE3o tem exemplos vis\xEDveis.");let A=await Qo(T,x),w=i?T.examples.find(C=>C.source&&r(C.source,m)===i):void 0;if(i&&!w)throw new Error("O arquivo solicitado n\xE3o est\xE1 nos exemplos vis\xEDveis de examples.json.");return{...e,runtime:{...e.runtime,baseUrl:e.runtime.baseUrl??m},...Zo(A,{exampleId:w?.id})}}var ei=new Set("html head body p li dt dd rt rp optgroup option colgroup thead tbody tfoot tr td th".split(" ")),ti=new Set("area base br col embed hr img input link meta param source track wbr".split(" "));function mn(e,n,o){let a=e.slice(0,n).split(`
2
+ `);return{message:o,from:n,line:a.length,column:a.at(-1).length+1}}function br(e){let n=[];for(let o=e.firstChild;o;o=o.nextSibling)n.push(o);return n}function rt(e){if(!e.trim())return{source:e,elements:[],issues:[]};let n=hr.parser.parse(e),o=[],a=[],l=new Map;n.iterate({enter(r){r.type.isError&&a.push(mn(e,r.from,"HTML incompleto ou malformado."))}});let c=(r,s)=>{if(r.name!=="Element"){br(r).forEach(C=>c(C,s));return}let i=r.getChild("OpenTag")??r.getChild("SelfClosingTag");if(!i)return;let d=i.getChild("TagName");if(!d)return;let m=e.slice(d.from,d.to).toLowerCase(),x=l.get(m)??0;l.set(m,x+1);let y=r.getChild("CloseTag"),T=e.slice(i.to-2,i.to)==="/>";!y&&!T&&!ti.has(m)&&!ei.has(m)&&a.push(mn(e,i.from,`Feche o elemento <${m}>.`));let A=i.getChildren("Attribute").map(C=>{let R=C.getChild("AttributeName"),S=e.slice(R.from,R.to),k=C.getChild("AttributeValue"),g=k?e.slice(k.from,k.to):"",f=g[0]==='"'||g[0]==="'"?g[0]:"";return{name:S,from:C.from,to:C.to,valueFrom:k?k.from+(f?1:0):void 0,valueTo:k?k.to-(f?1:0):void 0,quote:f,raw:f?g.slice(1,-1):g,dynamic:/^(?:[:@*#]|\[|\(|v-|bind-)/.test(S)||/\{\{|\$\{/.test(g)||!f&&g.startsWith("{")}}),w={tag:m,index:x,id:A.find(C=>C.name==="id"&&!C.dynamic)?.raw,from:r.from,to:r.to,openEnd:T?i.to-2:i.to-1,contentFrom:i.to,contentTo:y?.from??i.to,attributes:A,children:[]};o.push(w),s?.children.push(w),br(r).filter(C=>C.name==="Element").forEach(C=>c(C,w))};return c(n.topNode),{source:e,elements:o,issues:a}}function ni(e){return e.replace(/^\[\(|\[|\(|:|v-bind:|bind-/,"").replace(/\)\]$|\]$|\)$/,"").replace(/^attr\./,"").replace(/\.(?:prop|attr|camel)$/,"").toLowerCase()}function gn(e,n){return e.attributes.some(o=>ni(o.name)===n.toLowerCase()&&o.dynamic)}function vr(e,n){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(n==="'"?/'/g:/"/g,n==="'"?"&#39;":"&quot;")}function wr(e,n,o,a){let l=rt(e);if(l.issues.length)throw new Error(l.issues[0].message);let c=l.elements.find(i=>i.tag===n.tag&&i.index===n.index);if(!c)throw new Error("O elemento selecionado n\xE3o existe mais.");if(gn(c,o))throw new Error("Valor din\xE2mico: edi\xE7\xE3o visual indispon\xEDvel.");if(!/^[a-zA-Z_][\w.:-]*$/.test(o))throw new Error("Nome de atributo inv\xE1lido nos metadados.");let r=c.attributes.find(i=>i.name.toLowerCase()===o.toLowerCase());if(a===null||a===!1)return r?e.slice(0,r.from)+e.slice(r.to):e;if(r&&typeof a=="string"&&r.valueFrom!==void 0&&r.quote)return e.slice(0,r.valueFrom)+vr(a,r.quote)+e.slice(r.valueTo);let s=a===!0?o:`${o}="${vr(a,'"')}"`;return r?e.slice(0,r.from)+s+e.slice(r.to):e.slice(0,c.openEnd)+` ${s}`+e.slice(c.openEnd)}function ot(e,n="",o=""){let a=rt(e).issues.map(l=>({...l,message:`HTML: ${l.message}`}));for(let[l,c,r]of[["CSS",n,gr.parser],["JS",o,fr.parser]])r.parse(c).iterate({enter(s){s.type.isError&&a.push(mn(c,s.from,`${l}: sintaxe incompleta ou inv\xE1lida.`))}});return a}function fn(e,n,o,a){let l=rt(e);if(l.issues.length)throw new Error(l.issues[0].message);let c=l.elements.find(m=>m.tag===n.tag&&m.index===n.index),r=!o||o==="default"?c:c?.children.find(m=>m.attributes.some(x=>x.name==="slot"&&x.raw===o));if(!r||r.to<=r.contentFrom)throw new Error("Slot ausente ou sem regi\xE3o de conte\xFAdo: edite a composi\xE7\xE3o na aba HTML.");let s=e.slice(r.contentFrom,r.contentTo);if(/\{\{|\$\{/.test(s))throw new Error("Conte\xFAdo din\xE2mico: edite na aba HTML.");let i=e.slice(0,r.contentFrom)+a+e.slice(r.contentTo),d=rt(i).issues;if(d.length)throw new Error(`HTML inv\xE1lido: ${d[0].message}`);return i}function ee(e,n){return n===!0||Array.isArray(n)&&n.includes(e)}import{useEffect as jt,useRef as $r,useState as bt}from"react";import{createContext as kr,createElement as oi,cloneElement as ii,isValidElement as ai,useContext as Se,useEffect as Ve,useId as si,useRef as $e,useState as Pr,Children as Tr}from"react";function xr(e,n,o,a="small"){let l=document.createElement("div");l.className="govbr-playground__example-picker";let c=document.createElement("br-input");c.label="Exemplo",c.setAttribute("aria-label","Selecionar exemplo"),c.setAttribute("placeholder","Buscar exemplo\u2026"),c.density=a;let r=document.createElement("div");r.className="govbr-playground__example-results",r.setAttribute("role","group"),r.setAttribute("aria-label","Exemplos dispon\xEDveis"),r.hidden=!0;let s=n,i=y=>[y.category?.label,y.label??y.id??"Exemplo"].filter(Boolean).join(" \u2014 ");c.value=i(s);let d=y=>{y.id!==s.id&&o(y)!==!1&&(s=y),c.value=i(s),c.focus(),r.hidden=!0},m=y=>{r.replaceChildren();for(let T of e.filter(A=>`${i(A)} ${A.id??""}`.toLocaleLowerCase().includes(y.toLocaleLowerCase()))){let A=document.createElement("button");A.type="button",A.textContent=i(T),A.addEventListener("click",()=>d(T)),r.append(A)}if(!r.children.length){let T=document.createElement("p");T.textContent="Nenhum exemplo encontrado.",T.setAttribute("role","status"),r.append(T)}r.hidden=!1};c.addEventListener("click",()=>{r.hidden&&m("")}),c.addEventListener("focusin",()=>{r.hidden&&m("")}),c.addEventListener("input",()=>m(c.value)),l.addEventListener("focusout",y=>{l.contains(y.relatedTarget)||(r.hidden=!0,c.value=i(s))}),l.addEventListener("keydown",y=>{if(y.key==="Escape")c.focus(),r.hidden=!0,c.value=i(s);else if(y.key==="ArrowDown"&&y.target===c)y.preventDefault(),r.hidden&&m(""),r.querySelector("button")?.focus();else if(y.key==="Enter"&&y.target===c){let T=e.filter(A=>i(A).toLocaleLowerCase().includes(c.value.toLocaleLowerCase()));T.length===1&&(y.preventDefault(),d(T[0]))}});let x=y=>{s.id===y.id&&i(s)===i(y)||(s=y,c.value=i(s),r.hidden=!0)};return l.append(c,r),Object.assign(l,{setSelected:x})}var Sr={profile:"wbc",version:"2.7.0",fontAwesomeVersion:"6.7.2"};function ht(e=Sr){let n=e.profile;if(n!=="wbc"&&n!=="wbc-v4")throw new TypeError("library.profile deve ser wbc ou wbc-v4.");if(e.fontAwesomeVersion!==void 0&&!["5.15.4","6.7.2"].includes(e.fontAwesomeVersion))throw new TypeError("library.fontAwesomeVersion deve ser 5.15.4 ou 6.7.2.");let o=e.version??(n==="wbc"?"2.7.0":void 0);if(!e.moduleUrl&&!o)throw new Error("Informe version ou moduleUrl para WBC v4.");let a=n==="wbc"?"@govbr-ds/webcomponents":"@govbr-ds/components",l=n==="wbc"?"components":"custom-elements";return{profile:n,registration:e.registration??"module",fontAwesomeVersion:e.fontAwesomeVersion??"6.7.2",moduleUrl:e.moduleUrl??`https://cdn.jsdelivr.net/npm/${a}@${o}/dist/${l}/index.js`,styles:e.styles??(n==="wbc"?["https://cdn.jsdelivr.net/npm/@govbr-ds/core@3.6.2/dist/core.min.css"]:[...["tokens.css","theme/light/tokens.css","theme/dark/tokens.css","theme/light/contrast-mode.css","theme/dark/contrast-mode.css"].map(c=>`https://cdn.jsdelivr.net/npm/@govbr-ds/tokens@${e.tokensVersion??"4.0.0-next.39"}/dist/css/${c}`),"https://cdn.jsdelivr.net/npm/@fontsource/noto-sans@5.3.0/latin.css","https://cdn.jsdelivr.net/npm/@fontsource/noto-sans@5.3.0/latin-italic.css"])}}var ri=globalThis,Er=ri.__govbrPlaygroundLibraries??=new WeakMap;function hn(e){let n=ht(e),o=JSON.stringify(n),a=Er.get(document);if(a)return a.key===o?a.promise:Promise.reject(new Error("Recarregue a p\xE1gina para trocar a biblioteca do Playground."));let l=(async()=>{if(n.registration==="existing"){await Promise.all(["br-button","br-select"].map(r=>customElements.whenDefined(r)));return}if(customElements.get("br-button"))throw new Error("Uma biblioteca br-* j\xE1 foi registrada. Configure a biblioteca do Playground antes dos componentes do site.");let c=await import(/* webpackIgnore: true */ n.moduleUrl);for(let[r,s]of Object.entries(c))/^defineCustomElement/.test(r)&&typeof s=="function"&&await s();if(!customElements.get("br-button")||!customElements.get("br-select"))throw new Error("O m\xF3dulo da biblioteca n\xE3o registrou br-button e br-select.");await Promise.all(n.styles.map(r=>new Promise((s,i)=>{let d=document.createElement("link");d.rel="stylesheet",d.href=r,d.onload=()=>s(),d.onerror=()=>i(new Error(`Falha ao carregar ${r}`)),document.head.append(d)})))})();return Er.set(document,{key:o,promise:l}),l}function It(e){let n=ht(e);return[...n.styles.map((o,a)=>({id:`library-style-${a}`,type:"style",href:o})),{id:"library-registration",type:"inline-module",content:`import * as library from ${JSON.stringify(n.moduleUrl)}; for (const [name, register] of Object.entries(library)) { if (/^defineCustomElement/.test(name) && typeof register === 'function') await register(); }`}]}import{Fragment as Cr,jsx as se,jsxs as _r}from"react/jsx-runtime";var it=kr(void 0),Nr=it.Provider,We=kr("wbc");function Mr({library:e,hiddenControls:n,children:o}){let[a,l]=Pr(!1),[c,r]=Pr("");return Ve(()=>{let s=!0;return hn(e).then(()=>{s&&l(!0)},i=>{s&&r(String(i.message??i))}),()=>{s=!1}},[e]),c?se("p",{role:"alert",children:c}):a?se(it.Provider,{value:n,children:se(We.Provider,{value:e?.profile??"wbc",children:o})}):se("p",{role:"status",children:"Carregando componentes do Playground\u2026"})}function Le(e,n,o){return oi(e,n,o)}function te({children:e,type:n="button",title:o,iconOnly:a=!1,emphasis:l=a?"secondary":void 0,...c}){let r=Se(it),s=Se(We);if(ee(c["aria-label"]??(typeof e=="string"?e:""),r))return null;let i=Le("br-button",{...c,type:n,...l?{emphasis:l}:{},...o?{slot:"trigger",key:"trigger"}:{},density:s==="wbc"?"small":"compact",...a?s==="wbc"?{shape:"circle"}:{"icon-only":!0}:{}},e);return o?Le("br-tooltip",{position:"top"},[i,Le("span",{slot:"content",key:"content"},o)]):i}function Pe({children:e,onChange:n,value:o,...a}){let l=Se(it),c=Se(We),r=$e(null);Ve(()=>{let d=r.current;if(!d)return;d.value=o;let m=x=>n?.({target:d,currentTarget:d,nativeEvent:x});return d.addEventListener("change",m),()=>d.removeEventListener("change",m)},[n,o,l]);let s=Tr.map(e,d=>{if(!ai(d)||d.type!==U)return d;let m=Array.isArray(o)?o.map(String).includes(String(d.props.value)):String(o??"")===String(d.props.value??"");return ii(d,{selected:m})});if(ee(a["aria-label"]??"",l))return null;let i=a["aria-label"]??"Selecionar";return Le("br-select",{...a,ref:r,value:o,label:i,...c==="wbc"?{filterable:!1,"hide-search-icon":!0}:{"hide-label":!0,searchable:!1},density:c==="wbc"?"small":"compact"},s)}function U({children:e,value:n,...o}){let a=Tr.toArray(e).filter(l=>typeof l=="string"||typeof l=="number").join("");return Le("br-select-option",{...o,value:n,label:a.trim()||String(n)},e)}function at({onChange:e,type:n,...o}){let a=Se(it),l=Se(We),c=$e(null);return Ve(()=>{let r=c.current;if(!r)return;let s=i=>e?.({target:{value:r.value,checked:r.checked,valueAsNumber:Number(r.value)},currentTarget:r,nativeEvent:i});return r.addEventListener("change",s),r.addEventListener("input",s),()=>{r.removeEventListener("change",s),r.removeEventListener("input",s)}},[e,a]),ee(o["aria-label"]??"",a)?null:Le(n==="checkbox"?"br-checkbox":"br-input",{...o,ref:c,type:n,density:l==="wbc"?"small":"compact"},null)}function Lr({children:e,onChange:n,...o}){let a=Se(We),l=Se(it),c=typeof customElements<"u"&&!!customElements.get("br-textarea"),r=$e(null);return Ve(()=>{if(!c)return;let s=r.current;if(!s)return;let i=d=>n?.({target:s,currentTarget:s,nativeEvent:d});return s.addEventListener("input",i),()=>s.removeEventListener("input",i)},[n,c,l]),ee(o["aria-label"]??"",l)?null:c?Le("br-textarea",{...o,ref:r,density:a==="wbc"?"small":"compact"},e):se("textarea",{...o,onChange:n,children:e})}function st({label:e="Ferramentas do playground",items:n,active:o,onChange:a,children:l}){let c=$e(new Map),r=si().replaceAll(":","");if(n.length<=1)return se(Cr,{children:l});let s=n.find(d=>d.id===o)??n[0],i=(d,m)=>{let x;switch(d.key){case"ArrowRight":x=(m+1)%n.length;break;case"ArrowLeft":x=(m-1+n.length)%n.length;break;case"Home":x=0;break;case"End":x=n.length-1;break;default:return}d.preventDefault();let y=n[x];c.current.get(y.id)?.focus(),a(y.id)};return _r(Cr,{children:[se("div",{className:"govbr-playground__tool-tabs",role:"tablist","aria-label":e,children:n.map((d,m)=>se("button",{ref:x=>{x?c.current.set(d.id,x):c.current.delete(d.id)},id:`${r}-tab-${m}`,type:"button",role:"tab","aria-label":d.label,"aria-controls":`${r}-panel`,"aria-selected":s.id===d.id,tabIndex:s.id===d.id?0:-1,title:d.iconOnly?d.label:void 0,onClick:()=>a(d.id),onKeyDown:x=>i(x,m),children:d.iconOnly?se("i",{className:d.icon,"aria-hidden":"true"}):d.label},d.id))}),se("div",{id:`${r}-panel`,role:"tabpanel","aria-labelledby":`${r}-tab-${n.indexOf(s)}`,tabIndex:0,children:l})]})}function yt({title:e,children:n,open:o=!1,className:a}){return Le("br-collapse",{open:o,className:a,density:"small"},[se("span",{slot:"trigger",children:e},"trigger"),se("div",{className:"govbr-playground__section-body",children:n},"content")])}function Ar({label:e,hideLabel:n=!1,checked:o,disabled:a,onChange:l}){let c=$e(null),r=Se(We),s=!!customElements.get("br-switch");return Ve(()=>{if(!s)return;let i=c.current,d=()=>l(!!i.checked);return i.addEventListener("change",d),()=>i.removeEventListener("change",d)},[s,l]),s?Le("br-switch",{ref:c,checked:o,disabled:a,label:n?"":e,"aria-label":n?e:void 0,className:n?"govbr-playground__switch--unlabelled":void 0,density:r==="wbc"?"small":"compact"},null):_r("label",{className:`govbr-playground__native-switch${n?" govbr-playground__switch--unlabelled":""}`,children:[se("input",{type:"checkbox",role:"switch","aria-label":e,checked:o,disabled:a,onChange:i=>l(i.target.checked)}),se("span",{children:e})]})}function Or({examples:e,selected:n,onSelect:o}){let a=$e(null),l=$e(null),c=Se(We),r=$e(o);r.current=o;let s=JSON.stringify(e.map(({id:i,label:d,category:m})=>({id:i,label:d,category:m})));return Ve(()=>{let i=a.current;l.current=xr(e,n,d=>r.current(d),c==="wbc"?"small":"compact"),i.replaceChildren(l.current)},[s,c]),Ve(()=>l.current?.setSelected(n),[n.id,n.label]),se("div",{ref:a})}import{Fragment as li,jsx as vt,jsxs as Ht}from"react/jsx-runtime";var Rr={split:60,stackedSplit:60};function Ir(e,n){let o={...Rr,split:Number.isFinite(n?.split)?Math.max(20,Math.min(80,n.split)):n?.preset==="visual"?65:Rr.split};try{let a=JSON.parse(localStorage.getItem(`playground-workbench:${e}`)??"null");return a?{split:Number.isFinite(a.split)?Math.max(20,Math.min(80,a.split)):o.split,stackedSplit:Number.isFinite(a.stackedSplit)?Math.max(20,Math.min(80,a.stackedSplit)):60}:o}catch{return o}}function jr({id:e,header:n,preview:o,code:a,properties:l,diagnostics:c,diagnosticItems:r=[],onDiagnosticTabChange:s,selectionRequest:i,initial:d,presentation:m="developer",hiddenControls:x}){let[y,T]=bt(()=>Ir(e,d)),[A,w]=bt(0),[C,R]=bt({id:e,initial:d}),S=d?.properties??d?.preset==="inspection"?"properties":"code",[k,g]=bt(S),f=$r(null),I=$r(null),[E,X]=bt(!1),z=A>=900,G=d?.preset==="visual"?"visual":"code",ne=[...a?[{id:"code",label:"C\xF3digo"}]:[],...l?[{id:"properties",label:"Propriedades"}]:[],...r],re=m==="developer"&&G==="code"&&ne.length>0,Ae=ne.some(_=>_.id===k)?k:ne[0]?.id;jt(()=>{T(Ir(e,d)),R({id:e,initial:d}),g(S)},[e,d,S]),jt(()=>{i&&g("properties")},[i]),jt(()=>{if(!(C.id!==e||C.initial!==d))try{localStorage.setItem(`playground-workbench:${e}`,JSON.stringify(y))}catch{}},[e,d,y,C]),jt(()=>{let _=new ResizeObserver(([$])=>{let V=$.contentRect.width;w(V)});return f.current&&_.observe(f.current),()=>_.disconnect()},[]);let j=_=>{let $=I.current?.getBoundingClientRect(),V=Math.max(1,(_?$?.height:$?.width)??1)-12,W=_?160:240,be=_?180:280;return{min:Math.min(45,Math.max(20,W/V*100)),max:Math.max(55,Math.min(80,100-be/V*100))}},le=(_,$)=>{let V=j($);T(W=>({...W,[$?"stackedSplit":"split"]:Math.max(V.min,Math.min(V.max,_))}))},Y=_=>ee("panels-resize",x)?null:vt("div",{className:_?"govbr-playground__stacked-divider":"govbr-playground__bench-divider",role:"separator",tabIndex:0,"aria-label":"Redimensionar preview e ferramentas","aria-orientation":_||!z?"horizontal":"vertical","aria-valuemin":j(_).min,"aria-valuemax":j(_).max,"aria-valuenow":Math.round(_?y.stackedSplit:y.split),onPointerDown:$=>{$.preventDefault(),$.currentTarget.focus(),$.currentTarget.setPointerCapture($.pointerId),X(!0)},onPointerMove:$=>{if(!$.currentTarget.hasPointerCapture($.pointerId))return;let V=I.current?.getBoundingClientRect();if(!V)return;let W=_||!z,be=(W?V.height:V.width)-12;be>0&&le(((W?$.clientY-V.top:$.clientX-V.left)-6)/be*100,_)},onPointerUp:$=>{$.currentTarget.hasPointerCapture($.pointerId)&&$.currentTarget.releasePointerCapture($.pointerId),X(!1)},onLostPointerCapture:()=>X(!1),onPointerCancel:()=>X(!1),onDoubleClick:()=>le(60,_),onKeyDown:$=>{let V=_||!z,W=V?"ArrowUp":"ArrowLeft";if(![W,V?"ArrowDown":"ArrowRight","Home","End"].includes($.key))return;$.preventDefault();let fe=j(_),ve=_?y.stackedSplit:y.split;le($.key==="Home"?fe.min:$.key==="End"?fe.max:ve+($.key===W?-1:1)*($.shiftKey?10:2),_)}});return Ht("div",{ref:f,className:"govbr-playground__bench","data-resizing":E,"data-presentation":m,children:[Ht("header",{className:"govbr-playground__bench-header",children:[m==="developer"&&G==="visual"&&vt("p",{className:"govbr-playground__mode-help",children:"Teste apar\xEAncia e tamanhos de tela."}),n]}),Ht("div",{ref:I,className:"govbr-playground__studio","data-horizontal":z,"data-tools-open":re,style:{"--studio-split":`${z?y.split:y.stackedSplit}fr`,"--studio-rest":`${100-(z?y.split:y.stackedSplit)}fr`},children:[vt("div",{className:"govbr-playground__studio-preview","aria-label":"Visualiza\xE7\xE3o",children:o}),re&&Ht(li,{children:[Y(!z),vt("section",{className:"govbr-playground__studio-tools","aria-label":"C\xF3digo e inspe\xE7\xE3o",children:vt(st,{label:"C\xF3digo e inspe\xE7\xE3o",active:Ae,items:ne,onChange:_=>{g(_),_!=="properties"&&_!=="code"&&s?.(_)},children:Ae==="code"?a:Ae==="properties"?l:c})})]})]})]})}import{Suspense as io,useCallback as zt,useEffect as F,useLayoutEffect as Li,useMemo as Ut,useRef as ge,useState as M}from"react";import{lazy as di,useMemo as ci,useRef as Hr,useEffect as ui}from"react";import{jsx as Dr}from"react/jsx-runtime";function pi(e,n,o){switch(e){case"html":return[o.html({extraTags:Object.fromEntries((n?.components??[]).map(a=>[a.tag,{attrs:Object.fromEntries(a.props.map(l=>[l.attribute,l.values?.length?l.values:null]))}]))})];case"css":return[o.css()];case"typescript":return[o.javascript({typescript:!0})];case"tsx":return[o.javascript({jsx:!0,typescript:!0})];case"javascript":case"jsx":return[o.javascript({jsx:e==="jsx"})];default:return[]}}var mi=di(async()=>{let[e,n,o,a,l]=await Promise.all([import("./chunks/esm-YAO6K4CU.js"),import("./chunks/esm-6SLZNXJD.js"),import("./chunks/dist-MALZEIQI.js"),import("./chunks/dist-H5E3DUQZ.js"),import("./chunks/dist-HT72W6BH.js")]),c=e.default,r={html:o.html,css:a.css,javascript:l.javascript};function s({language:i,themeMode:d,controlManifest:m,readOnly:x=!1,editable:y=!0,sessions:T,sessionKey:A,...w}){let C=Hr(null),R=Hr(void 0),S=()=>{let f=C.current;if(!f?.dom.isConnected||!T||!A)return;let I=T.get(A),E=f.dom.getClientRects().length>0;T.set(A,{state:f.state,top:E?f.scrollDOM.scrollTop:I?.top??0,left:E?f.scrollDOM.scrollLeft:I?.left??0})};ui(()=>()=>{S(),C.current?.scrollDOM.removeEventListener("scroll",S),R.current!==void 0&&cancelAnimationFrame(R.current)},[T,A]);let k=w["aria-label"]??`Editor de c\xF3digo ${i??"do exemplo"}`,g=ci(()=>pi(i,m,r),[i,m]);return Dr(c,{...w,root:document,readOnly:x,editable:y&&!x,"aria-label":k,onUpdate:f=>{S(),w.onUpdate?.(f)},onCreateEditor:(f,I)=>{C.current=f,f.scrollDOM.addEventListener("scroll",S,{passive:!0});let E=A?T?.get(A):void 0;if(E){let X=E.state.doc.toString(),z=w.value??"",G=0,ne=X.length,re=z.length;for(;G<ne&&G<re&&X[G]===z[G];)G++;for(;ne>G&&re>G&&X[ne-1]===z[re-1];)ne--,re--;f.setState(X===z?E.state:E.state.update({changes:{from:G,to:ne,insert:z.slice(G,re)}}).state),R.current=requestAnimationFrame(()=>{f.requestMeasure({read:()=>null,write:()=>{f.scrollDOM.scrollTop=E.top,f.scrollDOM.scrollLeft=E.left}})})}f.contentDOM.setAttribute("aria-label",k),w.onCreateEditor?.(f,I)},theme:d==="dark"?n.githubDark:n.githubLight,extensions:[...g,...w.extensions??[]]})}return{default:s}});function wt(e){return Dr(mi,{...e})}import{Suspense as gi,useEffect as xt,useMemo as yn,useState as Ce,useRef as fi}from"react";import{jsx as P,jsxs as D}from"react/jsx-runtime";function hi(e){let n=(e.type??"").split("|").map(o=>o.trim()).filter(o=>!["undefined","null",""].includes(o));return n.length&&n.every(o=>["boolean","true","false"].includes(o))?"checkbox":n.includes("number")&&n.includes("string")?"text":e.control}function Br(e){return new DOMParser().parseFromString(e||"","text/html")}function yi(e,n,o){let a=Br(e),l=new Set(n.map(s=>s.tag.toLowerCase())),c=Array.from(a.body.querySelectorAll("*")).filter(s=>l.has(s.localName)),r=c;if(o)try{c=c.filter(s=>s.matches(o))}catch{return[]}return c.map(s=>{let i=s.localName,d=r.filter(x=>x.localName===i).indexOf(s),m=0;for(let x=s.parentElement;x;x=x.parentElement)l.has(x.localName)&&m++;return{tag:i,index:d,depth:m,id:s.id||void 0,label:`${i}${d?` #${d+1}`:""}`}})}function bi(e,n){return n?Array.from(e.body.querySelectorAll(n.tag))[n.index]??null:null}function Fr({manifest:e,html:n,tag:o,target:a,readOnly:l=!1,themeMode:c="light",hidden:r,selectedInstance:s,onSelectedInstanceChange:i,onHighlightInstance:d,onHtmlChange:m}){let[x,y]=Ce(""),[T,A]=Ce(""),[w,C]=Ce(""),[R,S]=Ce(""),[k,g]=Ce(()=>new Set),f=fi({key:""}),I=yn(()=>rt(n),[n]),E=s||x,X=e.components??[],z=yn(()=>yi(n,X,a),[n,X,a]),G=yn(()=>{let p=[],b=[];for(let oe of z){for(;b.length&&b[b.length-1].depth>=oe.depth;)b.pop();let he={...oe,children:[]};b.length?b[b.length-1].children.push(he):p.push(he),b.push(he)}return p},[z]),ne=z.map(p=>`${p.tag}:${p.index}:${p.depth}`).join("|");xt(()=>{g(new Set)},[ne]);let re=p=>{let b=`${p.tag}:${p.index}`,oe=b===E,he=()=>{y(b),i?.(b)};return P("li",{children:p.children.length?D("details",{open:!k.has(b),onToggle:ce=>{ce.stopPropagation();let je=ce.currentTarget.open;g(dt=>{if(dt.has(b)===!je)return dt;let qe=new Set(dt);return je?qe.delete(b):qe.add(b),qe})},children:[P("summary",{className:`govbr-playground__component-tree-item${oe?" is-selected":""}`,"aria-current":oe?"true":void 0,onClick:he,onPointerEnter:()=>d?.(b),onPointerLeave:()=>d?.(null),onFocus:()=>d?.(b),onBlur:()=>d?.(null),children:p.label}),P("ul",{children:p.children.map(re)})]}):P("span",{className:`govbr-playground__component-tree-item${oe?" is-selected":""}`,"aria-current":oe?"true":void 0,tabIndex:0,onClick:he,onKeyDown:ce=>{(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),he())},onPointerEnter:()=>d?.(b),onPointerLeave:()=>d?.(null),onFocus:()=>d?.(b),onBlur:()=>d?.(null),children:p.label})},b)},j=(f.current.key===E&&f.current.id?z.find(p=>p.id===f.current.id):void 0)??z.find(p=>`${p.tag}:${p.index}`===E)??z.find(p=>p.tag===o)??z[0],le=X.find(p=>p.tag===j?.tag),Y=p=>ee(p,r),_=le&&{...le,props:Y("props")?[]:le.props.filter(p=>!Y(`prop:${le.tag}:${p.attribute}`)),parts:Y("parts")?[]:(le.parts??[]).filter(p=>!Y(`part:${le.tag}:${p.name}`)),slots:Y("slots")?[]:le.slots.filter(p=>!Y(`slot:${le.tag}:${p.name||"default"}`))},$=bi(Br(n),j);if(xt(()=>{if(j){let p=`${j.tag}:${j.index}`;y(p),f.current={key:p,id:j.id},s&&s!==p&&i?.(p)}else y("")},[j?.tag,j?.index,j?.id,s]),!j||!_||!$)return P("p",{children:"Nenhum componente control\xE1vel encontrado neste exemplo."});let V=I.elements.find(p=>p.tag===j.tag&&p.index===j.index),W=l||I.issues.length>0,be=p=>{if(!W)try{m(p()),S("")}catch(b){S(b instanceof Error?b.message:String(b))}},fe=(p,b)=>be(()=>wr(n,j,p.attribute,p.control==="checkbox"?b===!1&&String(p.default)==="true"?"false":b:String(b).trim()?String(b):null)),ve=p=>p.control==="checkbox"?$.hasAttribute(p.attribute)?$.getAttribute(p.attribute)!=="false":String(p.default)==="true":$.getAttribute(p.attribute)??"",Wt=(p,b)=>be(()=>fn(n,j,p,b));return D("section",{className:"govbr-playground__controls","aria-label":"Controles de propriedades e slots",children:[D("header",{children:[R&&P("p",{role:"alert",children:R}),W&&P("p",{role:"status",children:"Fonte inv\xE1lida: modelo anterior preservado; corrija o c\xF3digo para editar propriedades."}),P("strong",{children:j.tag}),!Y("tree")&&P(yt,{title:"\xC1rvore de componentes",className:"govbr-playground__tree-section",open:!0,children:P("ul",{className:"govbr-playground__component-tree",children:G.map(re)})})]}),_.props.length>0&&P("div",{className:"govbr-playground__props-scroll",children:D(yt,{title:"Props",open:!0,children:[!Y("search")&&P(at,{"aria-label":"Buscar propriedade",placeholder:"Buscar propriedade",value:T,onChange:p=>A(p.target.value)}),!Y("groups")&&_.props.some(p=>p.group)&&D(Pe,{"aria-label":"Grupo de propriedades",value:w,onChange:p=>C(p.target.value),children:[P(U,{value:"",children:"Todos os grupos"}),[...new Set(_.props.map(p=>p.group).filter(Boolean))].map(p=>P(U,{value:p,children:p},p))]}),D("table",{children:[P("thead",{children:D("tr",{children:[P("th",{children:"Propriedade"}),P("th",{children:"Descri\xE7\xE3o"}),P("th",{children:"Valor"})]})}),P("tbody",{children:[..._.props].map(p=>({...p,control:hi(p)})).filter(p=>(!w||p.group===w)&&`${p.propertyName} ${p.attribute} ${p.description??""}`.toLocaleLowerCase().includes(T.toLocaleLowerCase())).sort((p,b)=>p.propertyName.localeCompare(b.propertyName)).map(p=>D("tr",{children:[P("th",{scope:"row",children:P("code",{children:p.propertyName})}),P("td",{children:p.description||"Sem descri\xE7\xE3o."}),D("td",{children:[P("div",{className:"govbr-playground__property-field",children:V&&gn(V,p.attribute)?P("p",{children:"Valor din\xE2mico / edi\xE7\xE3o visual indispon\xEDvel"}):p.control==="json"||/object|array|\[\]/i.test(p.type??"")?P(vi,{value:String(ve(p)),disabled:W,label:p.propertyName,onApply:b=>fe(p,b)}):p.control==="checkbox"?P(Ar,{hideLabel:!0,label:p.propertyName,disabled:W,checked:!!ve(p),onChange:b=>fe(p,b)}):p.control==="select"?D(Pe,{disabled:W,"aria-label":p.propertyName,value:String(ve(p)),onChange:b=>fe(p,b.target.value),children:[P(U,{value:"",children:"Padr\xE3o"}),(p.values??[]).map(b=>P(U,{value:b,children:b},b))]}):xi(p,String(ve(p)))?P(Si,{label:p.propertyName,value:String(ve(p)),defaultValue:p.default,disabled:W,onApply:b=>fe(p,b)}):P(at,{type:p.control==="number"?"number":"text",disabled:W,"aria-label":p.propertyName,placeholder:zr(p),value:String(ve(p)),onChange:b=>fe(p,b.target.value)})}),P(Pi,{property:p})]})]},p.attribute))})]})]})}),D("footer",{className:"govbr-playground__inspector-footer",children:[!Y("slots")&&D(yt,{title:"Slots",children:[_.slots.length===0&&P("p",{children:"Nenhum slot documentado."}),_.slots.map(p=>{let b=p.name==="default"||p.name===""?$:$.querySelector(`[slot="${CSS.escape(p.name)}"]`),oe=b&&/\{\{|\$\{/.test(b.innerHTML),he=b?.innerHTML??"";return D("div",{className:"govbr-playground__control-field",children:[D("strong",{children:["Slot ",p.name||"padr\xE3o"]}),P("small",{children:p.description}),!b&&P("p",{children:"Slot ausente: adicione a composi\xE7\xE3o na aba HTML."}),oe&&P("p",{children:"Conte\xFAdo din\xE2mico: edite na aba HTML."}),P(wi,{label:`Conte\xFAdo do slot ${p.name||"padr\xE3o"}`,language:"html",themeMode:c,readOnly:W||!b||!!oe,value:he,placeholder:"Digite o conte\xFAdo HTML do slot\u2026",onApply:ce=>Wt(p.name,ce),validate:ce=>{fn(n,j,p.name,ce)}},`${j.tag}:${j.index}:slot:${p.name}`)]},p.name)})]}),!Y("parts")&&D(yt,{title:"Parts",children:[_.parts.length===0&&P("p",{children:"Nenhuma part documentada."}),P("dl",{className:"govbr-playground__parts-list",children:_.parts.map(p=>D("div",{children:[P("dt",{children:D("code",{children:[j.tag,"::part(",p.name,")"]})}),P("dd",{children:p.description||"Sem descri\xE7\xE3o."})]},p.name))})]})]})]})}function vi({value:e,disabled:n,label:o,onApply:a}){let[l,c]=Ce(e),[r,s]=Ce("");return xt(()=>{c(e),s("")},[e]),D("div",{children:[P(Lr,{disabled:n,"aria-label":`JSON de ${o}`,value:l,onChange:i=>c(i.target.value)}),P(te,{disabled:n,onClick:()=>{try{let i=JSON.parse(l);if(!i||typeof i!="object")throw new Error("Use um objeto ou array JSON.");a(JSON.stringify(i)),s("")}catch{s("Informe um objeto ou array JSON v\xE1lido.")}},children:"Aplicar JSON"}),r&&P("p",{role:"alert",children:r})]})}function wi({label:e,language:n,themeMode:o,readOnly:a,value:l,placeholder:c,onApply:r,validate:s}){let[i,d]=Ce(l),[m,x]=Ce("");return xt(()=>{d(l),x("")},[l]),D("div",{className:"govbr-playground__inspector-code",children:[P(gi,{fallback:P("p",{role:"status",children:"Carregando editor\u2026"}),children:P(wt,{"aria-label":e,language:n,themeMode:o,value:i,readOnly:a,editable:!a,onChange:d,placeholder:c,height:"auto",minHeight:"7rem",maxHeight:"18rem",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!a}})}),!a&&D(te,{disabled:i===l,onClick:()=>{try{s(i),r(i),x("")}catch(y){x(y instanceof Error?y.message:String(y))}},children:["Aplicar ",n==="css"?"CSS":"HTML"]}),m&&P("p",{role:"alert",children:m})]})}function xi(e,n){return/^(?:#[\da-f]{3,8}\b|(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\()/i.test(n||e.default||"")||/(?:color|colour|background|fill|stroke)$/i.test(e.propertyName)}function Ei(e){if(!CSS.supports("color",e)||/var\(/i.test(e))return"#000000";let n=document.createElement("canvas").getContext("2d");return n.fillStyle=e,n.fillRect(0,0,1,1),"#"+Array.from(n.getImageData(0,0,1,1).data).slice(0,3).map(o=>o.toString(16).padStart(2,"0")).join("")}function Si({label:e,value:n,defaultValue:o,disabled:a,onApply:l}){let[c,r]=Ce(n);xt(()=>r(n),[n]);let s=!c||CSS.supports("color",c),i=c||o||"transparent";return D("div",{className:"govbr-playground__color-editor",children:[P("label",{className:"govbr-playground__color-swatch",style:{backgroundColor:CSS.supports("color",i)?i:"transparent"},children:P("input",{type:"color","aria-label":`Escolher cor de ${e}`,value:Ei(i),disabled:a,onChange:d=>{r(d.target.value),l(d.target.value)}})}),P(at,{"aria-label":`Cor de ${e}`,value:c,placeholder:o||"#rrggbb / rgb(...) / hsl(...)",disabled:a,onChange:d=>r(d.target.value),"aria-invalid":!s}),P(te,{disabled:a||!s||c===n,onClick:()=>l(c),children:"Aplicar cor"}),P("small",{children:"HEX, RGB, HSL ou outra cor CSS v\xE1lida. Alfa pode ser informado no texto."}),!s&&P("p",{role:"status",children:"Informe uma cor CSS v\xE1lida."})]})}function zr(e){let n=e.default?.trim();return n&&!["null","undefined"].includes(n)?n:void 0}function Pi({property:e}){let n=e.values??[],o=n.length?"enum":e.type??{checkbox:"boolean",text:"string",number:"number",select:"enum",json:"object / array"}[e.control],a=zr(e);return D("div",{className:"govbr-playground__property-meta",children:[D("div",{className:"govbr-playground__property-summary",children:[P("code",{className:"govbr-playground__property-type","aria-label":`Tipo: ${o}`,title:`Tipo: ${e.type??o}`,children:o}),a!==void 0&&D("span",{className:"govbr-playground__property-default",children:["Padr\xE3o ",P("code",{children:a})]})]}),n.length>0&&D("details",{className:"govbr-playground__property-values",children:[D("summary",{children:["Valores aceitos (",n.length,")"]}),P("ul",{children:n.map(l=>P("li",{children:P("code",{children:l})},l))})]})]})}var En=Yo(Ur(),1),Vr=256*1024,Wr=1024*1024,vn=512*1024,Jr=32;function wn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xn(e){if(!wn(e)||typeof e.h!="string"||e.h.length>vn||typeof e.c!="string"||e.c.length>vn||e.j!==null&&typeof e.j!="string"||typeof e.j=="string"&&e.j.length>vn||e.s!==void 0&&(typeof e.s!="string"||e.s.length>2048)||e.exampleId!==void 0&&(typeof e.exampleId!="string"||e.exampleId.length>128))return!1;if(e.environment!==void 0){let n=e.environment;if(!wn(n)||!["light","dark"].includes(String(n.theme))||!["pt-BR","en-US"].includes(String(n.locale))||!["ltr","rtl"].includes(String(n.direction))||["contrast","skeleton","reducedMotion"].some(o=>typeof n[o]!="boolean")||n.width!=="100%"&&(typeof n.width!="number"||!Number.isFinite(n.width)||n.width<1||n.width>1e4)||typeof n.height!="number"||!Number.isFinite(n.height)||n.height<1||n.height>1e4)return!1}return!0}function ha(e,n,o,a){return Bt([{h:e,j:n,c:o,s:a}])}function Bt(e){if(e.length===0||e.length>Jr||!e.every(xn))return null;let n=e.length===1?e[0]:{p:e};try{let o=JSON.stringify(n);if(o.length>Wr)return null;let a=En.default.compressToEncodedURIComponent(o);return a.length<=Vr?a:null}catch{return null}}function Kr(e){return wn(e)&&Array.isArray(e.p)?e.p.slice(0,Jr).filter(xn):xn(e)&&e.s?[e]:[]}function ya(e,n){let o=Bt(n);if(!o)return e;let a=new URL(e);return a.searchParams.set("pg_state",o),a.toString()}function qr(e){try{if(!e||e.length>Vr)return null;let n=a=>{if(!a||a.length>Wr)return null;try{return JSON.parse(a)}catch{return null}},o=n(En.default.decompressFromEncodedURIComponent(e));if(o!==null)return o;if(typeof atob=="function"&&typeof TextDecoder<"u"){let a=atob(e),l=Uint8Array.from(a,r=>r.charCodeAt(0)),c=new TextDecoder().decode(l);return n(c)}return null}catch{return null}}function Sn(e,n){return`govbr-playground:${e}:${n??"default"}`}function Pn(e,n){if(typeof window>"u")return null;try{let o=window.localStorage.getItem(Sn(e,n));if(!o||o.length>524288)return null;let a=JSON.parse(o);return typeof a.html!="string"||typeof a.updatedAt!="number"||a.css!==void 0&&typeof a.css!="string"||a.javascript!==void 0&&typeof a.javascript!="string"?null:{html:a.html,css:a.css??"",javascript:a.javascript??"",id:a.id,updatedAt:a.updatedAt}}catch{return null}}function Gr(e,n,o=n.id){if(typeof window>"u")return!1;try{let a={...n,css:n.css??"",javascript:n.javascript??"",updatedAt:Date.now()},l=JSON.stringify(a);return l.length>524288?!1:(window.localStorage.setItem(Sn(e,o),l),!0)}catch{return!1}}function Xr(e,n){try{window.localStorage.removeItem(Sn(e,n))}catch{}}function Je(e){return{entries:[e],index:0}}function Cn(e,n,o=50){if(e.entries[e.index]===n)return e;let a=e.entries.slice(0,e.index+1);return a.push(n),a.length>o&&a.shift(),{entries:a,index:a.length-1}}function Yr(e,n){let o=e.index+n;return o<0||o>=e.entries.length?{changed:!1,history:e,value:e.entries[e.index]??""}:{changed:!0,history:{...e,index:o},value:e.entries[o]}}function Ci(){return Promise.all([import("./chunks/standalone-G7AM3SII.js"),import("./chunks/babel-PXSNAHUX.js"),import("./chunks/estree-EALESNBX.js"),import("./chunks/html-C5MOHUJO.js"),import("./chunks/postcss-RXMLIASD.js")])}var ki;async function lt(e,n){if(!e.trim())return e;let[{format:o},...a]=await(ki??=Ci()),l=a.map(c=>c.default||c).filter(Boolean);try{return await o(e,{parser:n,plugins:l,printWidth:n==="html"?40:80,htmlWhitespaceSensitivity:"ignore",bracketSameLine:!1,singleAttributePerLine:!0})}catch{return e}}async function Et(e){let[n,o,a]=await Promise.all([lt(e.html,"html"),e.css===void 0?void 0:lt(e.css,"css"),e.javascript===void 0?void 0:lt(e.javascript,"babel")]);return{...e,html:n,css:o,javascript:a}}async function Zr(e){let[n,o]=await Promise.all([Et(e.example),e.examples&&Promise.all(e.examples.map(async a=>({...a,examples:await Promise.all(a.examples.map(Et))})))]);return{...e,example:n,examples:o}}var Ti=e=>[...new Set(Array.from(e.matchAll(/<\/?([a-z][a-z0-9]*-[a-z0-9-]+)/gi),n=>n[1]))].sort().map(n=>({tag:n,name:n.split("-").map(o=>o[0].toUpperCase()+o.slice(1)).join("")})),Qr=e=>e.replace(/(<\/?)([a-z][a-z0-9]*-[a-z0-9-]+)/gi,(n,o,a)=>`${o}${a.split("-").map(l=>l[0].toUpperCase()+l.slice(1)).join("")}`),St=(e,n)=>e.split(`
3
3
  `).map(o=>o?`${" ".repeat(n)}${o}`:"").join(`
4
- `);function fi(e,n){let o=n.map(l=>l.type==="style"?` <link rel="stylesheet" href="${l.href}">`:l.type==="inline-style"?` <style>
5
- ${xt(l.content,6)}
4
+ `);function Ni(e,n){let o=n.map(l=>l.type==="style"?` <link rel="stylesheet" href="${l.href}">`:l.type==="inline-style"?` <style>
5
+ ${St(l.content,6)}
6
6
  </style>`:"").filter(Boolean).join(`
7
- `),i=n.map(l=>l.type==="module"||l.type==="script"?` <script type="module" src="${l.src}"><\/script>`:l.type==="inline-module"||l.type==="inline-script"?` <script type="module">
8
- ${xt(l.content,6)}
7
+ `),a=n.map(l=>l.type==="module"||l.type==="script"?` <script type="module" src="${l.src}"><\/script>`:l.type==="inline-module"||l.type==="inline-script"?` <script type="module">
8
+ ${St(l.content,6)}
9
9
  <\/script>`:"").filter(Boolean).join(`
10
10
  `);return`<!doctype html>
11
11
  <html lang="pt-BR">
@@ -16,14 +16,14 @@ ${xt(l.content,6)}
16
16
  ${o}
17
17
  </head>
18
18
  <body>
19
- ${xt(e.html,4)}
19
+ ${St(e.html,4)}
20
20
 
21
- ${i}
21
+ ${a}
22
22
  <script type="module" src="./index.js"><\/script>
23
23
  </body>
24
- </html>`}function Xr(e,n={},o=[]){let l=gi(e.html).map(({name:a})=>a),u=Yr(e.html).replace(/\sclass=/g," className=").replace(/\sfor=/g," htmlFor="),r=`<template>
25
- ${xt(Yr(e.html),2)}
26
- </template>`,s={html:{files:[{filename:"index.html",language:"html",code:fi(e,o)},{filename:"index.css",language:"css",code:e.css??""},{filename:"index.js",language:"javascript",code:e.javascript??""}]}};n.angular&&(s.angular={files:[{filename:"app.component.ts",language:"typescript",code:`import { Component } from '@angular/core'
24
+ </html>`}function eo(e,n={},o=[]){let l=Ti(e.html).map(({name:i})=>i),c=Qr(e.html).replace(/\sclass=/g," className=").replace(/\sfor=/g," htmlFor="),r=`<template>
25
+ ${St(Qr(e.html),2)}
26
+ </template>`,s={html:{files:[{filename:"index.html",language:"html",code:Ni(e,o)},{filename:"index.css",language:"css",code:e.css??""},{filename:"index.js",language:"javascript",code:e.javascript??""}]}};n.angular&&(s.angular={files:[{filename:"app.component.ts",language:"typescript",code:`import { Component } from '@angular/core'
27
27
  ${l.length?`import { ${l.join(", ")} } from '${n.angular}'
28
28
  `:""}
29
29
  @Component({
@@ -37,29 +37,29 @@ export class AppComponent {}`}]}),n.react&&(s.react={files:[{filename:"App.tsx",
37
37
  `:""}export default function App() {
38
38
  return (
39
39
  <>
40
- ${xt(u,6)}
40
+ ${St(c,6)}
41
41
  </>
42
42
  )
43
43
  }`}]}),n.vue&&(s.vue={files:[{filename:"Example.vue",language:"html",code:`${l.length?`<script setup lang="ts">
44
44
  import { ${l.join(", ")} } from '${n.vue}'
45
45
  <\/script>
46
46
 
47
- `:""}${r}`}]});for(let a of["angular","react","vue"]){let c=s[a];c&&(a==="angular"&&(c.files[0].code=c.files[0].code.replace(/ template: `[^]*?`,\n/,` templateUrl: './app.component.html',
47
+ `:""}${r}`}]});for(let i of["angular","react","vue"]){let d=s[i];d&&(i==="angular"&&(d.files[0].code=d.files[0].code.replace(/ template: `[^]*?`,\n/,` templateUrl: './app.component.html',
48
48
  styleUrl: './app.component.css',
49
- `),c.files.push({filename:"app.component.html",language:"html",code:e.html})),c.files.push({filename:a==="angular"?"app.component.css":"styles.css",language:"css",code:e.css??""},{filename:"example.js",language:"javascript",code:e.javascript??""}))}return s}function Zr(e){return e.files.map(({filename:n,language:o,code:i})=>`${o==="html"?`<!-- ${n} -->`:o==="css"?`/* ${n} */`:`// ${n}`}
50
- ${i}`).join(`
49
+ `),d.files.push({filename:"app.component.html",language:"html",code:e.html})),d.files.push({filename:i==="angular"?"app.component.css":"styles.css",language:"css",code:e.css??""},{filename:"example.js",language:"javascript",code:e.javascript??""}))}return s}function to(e){return e.files.map(({filename:n,language:o,code:a})=>`${o==="html"?`<!-- ${n} -->`:o==="css"?`/* ${n} */`:`// ${n}`}
50
+ ${a}`).join(`
51
51
 
52
- `)}var Et=[{value:"pt-BR",lang:"pt-BR",label:"Portugu\xEAs (Brasil)"},{value:"en-US",lang:"en-US",label:"English (US)"}],Qr="pt-BR";function eo(e){return Et.find(n=>n.value===e)??Et[0]}var De=e=>e.replace(/<\/(script)/gi,"<\\/$1"),Vt=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),hi=e=>Vt(e).replace(/>/g,"&gt;");function to(e,n){let o=ft(e.runtime.library??e.library),i=[...Bt(e.runtime.library??e.library),...e.runtime.resources??[]],l=new Set;for(let b of i){if(!b.id||l.has(b.id))throw new TypeError(`ID de recurso ausente ou duplicado: ${b.id}`);l.add(b.id)}let u=e.runtime.baseUrl?`<base href="${Vt(e.runtime.baseUrl)}">`:"",r=e.runtime.importMap?`<script type="importmap">${De(JSON.stringify({imports:e.runtime.importMap}))}<\/script>`:"",s=i.map(b=>b.type==="style"?`<link rel="stylesheet" href="${Vt(b.href)}"${b.integrity?` integrity="${Vt(b.integrity)}"`:""}${b.crossOrigin?` crossorigin="${b.crossOrigin}"`:""}>`:b.type==="inline-style"?`<style>${De(b.content)}</style>`:"").join(`
53
- `),a=i.flatMap(b=>b.type==="script"||b.type==="module"?[{type:b.type,src:b.src,integrity:b.integrity,crossOrigin:b.crossOrigin}]:b.type==="inline-script"?[{type:"script",content:b.content}]:b.type==="inline-module"?[{type:"module",content:b.content}]:[]),c=e.example.css?`<style data-playground-example>${De(e.example.css)}</style>`:"",f=`<style>${De(e.runtime.modeStyles??"")}
52
+ `)}var Pt=[{value:"pt-BR",lang:"pt-BR",label:"Portugu\xEAs (Brasil)"},{value:"en-US",lang:"en-US",label:"English (US)"}],no="pt-BR";function ro(e){return Pt.find(n=>n.value===e)??Pt[0]}var Re=e=>e.replace(/<\/(script)/gi,"<\\/$1"),Ft=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),Mi=e=>Ft(e).replace(/>/g,"&gt;");function oo(e,n){let o=ht(e.runtime.library??e.library),a=[...It(e.runtime.library??e.library),...e.runtime.resources??[]],l=new Set;for(let w of a){if(!w.id||l.has(w.id))throw new TypeError(`ID de recurso ausente ou duplicado: ${w.id}`);l.add(w.id)}let c=e.runtime.baseUrl?`<base href="${Ft(e.runtime.baseUrl)}">`:"",r=e.runtime.importMap?`<script type="importmap">${Re(JSON.stringify({imports:e.runtime.importMap}))}<\/script>`:"",s=a.map(w=>w.type==="style"?`<link rel="stylesheet" href="${Ft(w.href)}"${w.integrity?` integrity="${Ft(w.integrity)}"`:""}${w.crossOrigin?` crossorigin="${w.crossOrigin}"`:""}>`:w.type==="inline-style"?`<style>${Re(w.content)}</style>`:"").join(`
53
+ `),i=a.flatMap(w=>w.type==="script"||w.type==="module"?[{type:w.type,src:w.src,integrity:w.integrity,crossOrigin:w.crossOrigin}]:w.type==="inline-script"?[{type:"script",content:w.content}]:w.type==="inline-module"?[{type:"module",content:w.content}]:[]),d=e.example.css?`<style data-playground-example>${Re(e.example.css)}</style>`:"",m=`<style>${Re(e.runtime.modeStyles??"")}
54
54
  html, body { margin: 0; min-height: 1px; }
55
55
  body { box-sizing: border-box; padding: 24px 16px; }
56
56
  html[data-wbc-reduced-motion='true'] *, html[data-wbc-reduced-motion='true'] *::before, html[data-wbc-reduced-motion='true'] *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
57
57
  [data-wbc-preview-skeleton] { color: transparent !important; border-color: transparent !important; background-color: color-mix(in srgb, currentColor 12%, transparent) !important; }
58
- </style>`;e.runtime.bootstrap&&a.push({type:"module",content:e.runtime.bootstrap}),e.example.javascript&&a.push({type:"module",content:e.example.javascript});let v=`<script type="module">for(const [index,resource] of ${De(JSON.stringify(a))}.entries()){await new Promise((resolve)=>{const script=document.createElement('script');script.async=false;if(resource.type==='module')script.type='module';if(resource.src)script.src=resource.src;else script.textContent=resource.content;if(resource.integrity)script.integrity=resource.integrity;if(resource.crossOrigin)script.crossOrigin=resource.crossOrigin;script.onload=resolve;script.onerror=()=>{console.error('Falha ao carregar recurso do playground:',resource.src??'script inline');resolve()};if(!resource.src&&resource.type==='module'){const eventName='pg-module:'+index;window.addEventListener(eventName,resolve,{once:true});script.textContent+='\\n;window.dispatchEvent(new Event('+JSON.stringify(eventName)+'))'}document.body.append(script);if(!resource.src&&resource.type==='script')resolve()})};window.dispatchEvent(new Event('playground-runtime-ready'))<\/script>`,P=JSON.stringify([...new Set(["click","input","change","focus","blur","submit","reset","invalid","keydown",...e.runtime.eventTypes??[]])]),T=`<script>
58
+ </style>`;e.runtime.bootstrap&&i.push({type:"module",content:e.runtime.bootstrap}),e.example.javascript&&i.push({type:"module",content:e.example.javascript});let y=`<script type="module">for(const [index,resource] of ${Re(JSON.stringify(i))}.entries()){await new Promise((resolve)=>{const script=document.createElement('script');script.async=false;if(resource.type==='module')script.type='module';if(resource.src)script.src=resource.src;else script.textContent=resource.content;if(resource.integrity)script.integrity=resource.integrity;if(resource.crossOrigin)script.crossOrigin=resource.crossOrigin;script.onload=resolve;script.onerror=()=>{console.error('Falha ao carregar recurso do playground:',resource.src??'script inline');resolve()};if(!resource.src&&resource.type==='module'){const eventName='pg-module:'+index;window.addEventListener(eventName,resolve,{once:true});script.textContent+='\\n;window.dispatchEvent(new Event('+JSON.stringify(eventName)+'))'}document.body.append(script);if(!resource.src&&resource.type==='script')resolve()})};window.dispatchEvent(new Event('playground-runtime-ready'))<\/script>`,T=JSON.stringify([...new Set(["click","input","change","focus","blur","submit","reset","invalid","keydown",...e.runtime.eventTypes??[]])]),A=`<script>
59
59
  (function () {
60
60
  const channel = ${JSON.stringify(n)};
61
61
  const parentOrigin = new URL(document.referrer).origin;
62
- const eventTypes = ${P};
62
+ const eventTypes = ${T};
63
63
  const safeValue = (value) => {
64
64
  if (value instanceof Error) return { name: value.name, message: value.message, stack: value.stack };
65
65
  if (value === null || ['string', 'number', 'boolean'].includes(typeof value)) return value;
@@ -112,7 +112,7 @@ ${i}`).join(`
112
112
  window.addEventListener('scroll', paintSelection, true);
113
113
  window.addEventListener('resize', paintSelection);
114
114
 
115
- const inspectionTags = new Set(${De(JSON.stringify((e.controls?.manifest?.components??[]).map(b=>b.tag)))});
115
+ const inspectionTags = new Set(${Re(JSON.stringify((e.controls?.manifest?.components??[]).map(w=>w.tag)))});
116
116
  document.addEventListener('click', (event) => {
117
117
  if (!inspectionEnabled) return;
118
118
  const element = event.composedPath().find((node) => node instanceof Element && document.body.contains(node) && (inspectionTags.size ? inspectionTags.has(node.localName) : node.localName.startsWith('br-')));
@@ -148,7 +148,7 @@ ${i}`).join(`
148
148
  const initialEnd = initialNodes.findIndex((node) => node.nodeType === Node.COMMENT_NODE && node.nodeValue === 'pg-end:' + channel);
149
149
  let managedNodes = initialNodes.slice(initialStart + 1, initialEnd);
150
150
  const initialTemplate = document.createElement('template');
151
- initialTemplate.innerHTML = ${De(JSON.stringify(e.example.html))};
151
+ initialTemplate.innerHTML = ${Re(JSON.stringify(e.example.html))};
152
152
  managedNodes.forEach((node, index) => remember(node, initialTemplate.content.childNodes[index] ?? node));
153
153
  function sync(target, source) {
154
154
  if (target.nodeType !== source.nodeType || target.nodeName !== source.nodeName) {
@@ -220,7 +220,6 @@ ${i}`).join(`
220
220
  element.removeAttribute('data-wbc-preview-skeleton');
221
221
  }
222
222
  }
223
- const originalColorModes = new WeakMap();
224
223
  function syncBackground() {
225
224
  const boards = managedNodes.filter((node) => node instanceof Element && node.hasAttribute('data-dsg-board'));
226
225
  const boardBackground = boards.length === 1 ? getComputedStyle(boards[0]).backgroundColor : '';
@@ -233,21 +232,15 @@ ${i}`).join(`
233
232
  function applyMode(mode) {
234
233
  activeMode = mode;
235
234
  const root = document.documentElement;
235
+ root.removeAttribute('data-wbc-theme');
236
236
  root.dataset.theme = mode.theme === 'dark' ? 'dark' : 'light';
237
- root.dataset.wbcTheme = mode.theme === 'dark' ? 'dark' : 'light';
238
237
  root.dataset.colorMode = mode.contrast ? 'contrast' : 'main';
239
- if (mode.contrast) root.setAttribute('data-contrast', 'enabled'); else root.removeAttribute('data-contrast');
240
- if (mode.contrast) root.setAttribute('data-wbc-high-contrast', 'true'); else root.removeAttribute('data-wbc-high-contrast');
241
238
  if (mode.reducedMotion) root.setAttribute('data-wbc-reduced-motion', 'true'); else root.removeAttribute('data-wbc-reduced-motion');
242
239
  root.lang = mode.lang || 'pt-BR';
243
240
  root.dir = mode.dir || 'ltr';
244
241
  root.dataset.wbcReducedMotion = String(Boolean(mode.reducedMotion));
245
242
  walkElements(document, (element) => {
246
243
  if (element.localName.includes('-')) {
247
- if (${JSON.stringify(o.profile)} === 'wbc' && 'colorMode' in element) {
248
- if (!originalColorModes.has(element)) originalColorModes.set(element, element.colorMode);
249
- element.colorMode = mode.theme === 'dark' ? 'dark' : originalColorModes.get(element);
250
- }
251
244
  if (mode.reducedMotion) element.setAttribute('data-wbc-reduced-motion', 'true');
252
245
  else element.removeAttribute('data-wbc-reduced-motion');
253
246
  }
@@ -259,7 +252,7 @@ ${i}`).join(`
259
252
  content.setAttribute('aria-busy', mode.skeleton ? 'true' : 'false');
260
253
  syncBackground();
261
254
  }
262
- let managedHtmlSource = ${De(JSON.stringify(e.example.html))};
255
+ let managedHtmlSource = ${Re(JSON.stringify(e.example.html))};
263
256
  function replaceManagedHtml(html) {
264
257
  if (html === managedHtmlSource) return;
265
258
  managedHtmlSource = html;
@@ -351,4 +344,4 @@ ${i}`).join(`
351
344
  syncBackground();
352
345
  parent.postMessage({ type: 'ready', channel }, parentOrigin);
353
346
  })();
354
- <\/script>`;return`<!doctype html><html lang="pt-BR"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">${u}${r}${s}${f}${c}<title>${hi(e.ui?.title??"Playground")}</title></head><body><div data-playground-content role="main" style="display:contents"><!--pg-start:${n}-->${e.example.html}<!--pg-end:${n}--></div>${v}${T}</body></html>`}function sa(e){if(!e||typeof e!="object")return!1;let n=e;return typeof n.runtime?.id=="string"&&typeof n.example?.html=="string"}import{Fragment as $n,jsx as h,jsxs as I}from"react/jsx-runtime";function yi(e){let n={};for(let o of e.split(";")){let i=o.indexOf(":");if(i<0)continue;let l=o.slice(0,i).trim().toLowerCase(),u=o.slice(i+1).trim();l==="color"||l==="background"||l==="background-color"?/^(#[\da-f]{3,8}|[a-z]{3,20}|rgba?\([\d.,%\s]+\))$/i.test(u)&&(l==="color"?n.color=u:n.backgroundColor=u):l==="font-weight"&&/^(normal|bold|[1-9]00)$/.test(u)?n.fontWeight=u:l==="font-size"&&/^\d{1,2}px$/.test(u)?n.fontSize=u:l==="padding"&&/^(\d{1,2}px)(\s+\d{1,2}px)?$/.test(u)?n.padding=u:l==="border-radius"&&/^\d{1,2}px$/.test(u)&&(n.borderRadius=u)}return n}function bi(e){let[n,...o]=e;if(typeof n!="string"||!n.includes("%c"))return e.map(r=>typeof r=="string"?r:JSON.stringify(r)??String(r)).join(" ");let i=n.split("%c"),l=o.splice(0,i.length-1),u=i.map((r,s)=>h("span",{className:s===0?void 0:"govbr-playground__console-style",style:s>0&&typeof l[s-1]=="string"?yi(l[s-1]):void 0,children:r},`part-${s}`));return o.length&&u.push(I("span",{children:[" ",o.map(r=>typeof r=="string"?r:JSON.stringify(r)??String(r)).join(" ")]},"arguments")),u}function vi(e){let[n,...o]=e;if(typeof n!="string")return e.map(u=>typeof u=="string"?u:JSON.stringify(u)??String(u)).join(" ");let i=(n.match(/%c/g)??[]).length,l=o.splice(0,i);return[n.replace(/%c/g,""),...o.filter(u=>!l.includes(u)).map(u=>typeof u=="string"?u:JSON.stringify(u)??String(u))].join(" ").trim()}function wi({item:e}){let n=vi(e.args);return n.length<=280?h("div",{className:"govbr-playground__console-message",children:bi(e.args)}):I("details",{className:"govbr-playground__console-details",children:[I("summary",{children:[n.slice(0,280),"\u2026 ",h("span",{children:"Ver detalhes"})]}),h("pre",{children:n})]})}var ro={code:"C\xF3digo-fonte",controls:"Propriedades",console:"Console",events:"Eventos"},Xe=[{id:"html",label:"HTML",language:"html"},{id:"javascript",label:"JS",language:"javascript"},{id:"css",label:"CSS",language:"css"}],oo=[{id:"desktop",label:"Desktop (100%)",width:"100%",height:300},{id:"tablet",label:"Tablet (768 \xD7 600)",width:768,height:600},{id:"mobile",label:"Mobile (375 \xD7 812)",width:375,height:812}],io=["fa-desktop","fa-tablet-alt","fa-mobile-alt","fa-laptop","fa-tv","fa-window-maximize"],On=(e,n)=>{if(e.some(o=>!o)||new Set(e).size!==e.length)throw new TypeError(`IDs de ${n} ausentes ou duplicados`)},Kt=new Map;function xi(e){let n=e.examples?.find(i=>i.id===e.example.id)??e.examples?.[0],o=n?.examples.find(i=>i.id===n.defaultExample)??n?.examples[0];return{groupId:n?.id??e.example.id??"",exampleId:o?.id??e.example.id??"",example:o??e.example,groupViewport:n?.viewport}}function Be(e){let n=e?.viewport,o={desktop:{id:"desktop",label:"Desktop (100%)",width:"100%",height:300},tablet:{id:"tablet",label:"Tablet (768 \xD7 600)",width:768,height:600},mobile:{id:"mobile",label:"Mobile (375 \xD7 812)",width:375,height:812}};if(typeof n=="string")return o[{phone:"mobile",iphone:"mobile",android:"mobile",ipad:"tablet"}[n.toLowerCase()]??n.toLowerCase()]??null;if(!n)return null;let i=n.width??n.x,l=n.height??n.y;return n.id&&o[n.id]?o[n.id]:!i&&!l?null:{id:n.id??`custom-${i??"auto"}-${l??"auto"}`,label:n.label??`${i??"100%"} \xD7 ${l??300}`,width:i??"100%",height:l??300}}function Ei(e){let n={theme:"light",contrast:!1,skeleton:!1,reducedMotion:!1,locale:Qr,direction:"ltr"};try{let o=JSON.parse(window.localStorage.getItem(`govbr-playground-modes:${e}`)??"null");if(!o||typeof o!="object")return n;let i=Et.some(u=>u.value===o.locale)?o.locale:n.locale,l=o.direction==="ltr"||o.direction==="rtl"?o.direction:o.locale==="pt-BR-rtl"?"rtl":n.direction;return{theme:o.theme==="dark"?"dark":"light",contrast:o.theme!=="dark"&&!!o.contrast,skeleton:!!o.skeleton,reducedMotion:!!o.reducedMotion,locale:i,direction:l}}catch{return n}}function Si({config:e,className:n}){let o=$e(0),[i]=L(()=>xi(e)),[l,u]=L(i.groupId),[r,s]=L(i.exampleId),[a,c]=L(i.example),f=a.ui?.mode??e.ui?.mode??"developer",C=a.ui?.designer?.controls??e.ui?.designer?.controls??"examples",v=f==="designer"?C==="none"?"preview":"designer":"developer",[P,T]=L(()=>lt(i.example.html,i.example.css,i.example.javascript).length?{...i.example,html:"",css:"",javascript:""}:i.example),[b,E]=L(0),[$,M]=L(P);F(()=>{let t=e.examples?.flatMap(d=>d.examples).find(d=>d.id===r)??e.example;e.onChange?.(a,t)},[e.onChange,e.examples,e.example,a,r]);let y=qt(()=>lt(a.html,a.css,a.javascript),[a.html,a.css,a.javascript]);F(()=>{y.length||M(a)},[a,y]);let[m,g]=L("html"),[R,S]=L("code"),[X,Y]=L(!1),[V,Z]=L("console"),[H,ae]=L(!1);F(()=>{v!=="developer"&&ae(!1)},[v]);let[j,re]=L(""),[J,ue]=L(0),[fe,Ce]=L("adjustable"),[ce,_e]=L(180),[he,ye]=L(0),[Fe,p]=L(0),[k,se]=L(Number.isFinite(e.ui?.previewMaxHeight)?Math.max(180,Math.min(2e3,e.ui.previewMaxHeight)):600),[w,A]=L("html"),[D,Q]=L(0),le=$e(new Map),[St,Pt]=L(""),[Ze]=L(()=>Ei(e.runtime.id)),[_n,ao]=L(null),[Ct,kt]=L(()=>Be(i.example)?.id??Be({html:"",viewport:i.groupViewport})?.id??"desktop"),[ke,Gt]=L(Ze.theme),[we,Yt]=L(Ze.contrast),[Ie,Xt]=L(Ze.skeleton),[Re,Zt]=L(Ze.reducedMotion),[Qe,In]=L(Ze.locale),[ze,Rn]=L(Ze.direction),[jn,Tt]=L(""),[so,Qt]=L([]),[lo,en]=L([]),[et,co]=L(!1),[tn,uo]=L("all"),[nn,po]=L(""),[tt,mo]=L(!1),[Hn,Dn]=L(""),[Bn,Fn]=L(!1),zn=$e(null),[rn,go]=L(!1),Un=$e(!1),[ut,fo]=L(e.controls?.manifest??null),[Wn,Vn]=L(""),xe=$e(null),pe=$e(null),Mt=$e(null),[be,Nt]=L(null),[Jn,qn]=L(!1),on=$e(null),me=$e({html:Ye(i.example.html),css:Ye(i.example.css??""),javascript:Ye(i.example.javascript??"")}),[ho,nt]=L(0);On(e.ui?.actions?.map(t=>t.id)??[],"a\xE7\xF5es"),On(e.ui?.tabs?.map(t=>t.id)??[],"abas");for(let t of e.examples??[]){if(!t.id||!t.label||t.examples.length===0)throw new TypeError("Cada grupo de exemplos precisa de ID, r\xF3tulo e ao menos um example.");On(t.examples.map(d=>d.id??""),`examples de ${t.id}`)}let q=qt(()=>globalThis.crypto?.randomUUID?.()??`pg-${Math.random().toString(36).slice(2)}`,[e.runtime.id]),yo=qt(()=>to({...e,example:P},q),[e,P,q]),O=t=>e.features?.[t]!==!1,Te={...e.ui?.hidden,...a.ui?.hidden},K=t=>ne(t,Te?.actions),ee=t=>ne(t,Te?.controls),Kn=ne("viewport",Te?.viewports),pt=t=>ne(t,Te?.tabs)?!0:t.startsWith("custom:")&&ne(t.slice(7),Te?.tabs),an=O("controls")&&!!(e.controls?.manifest||e.controls?.manifestUrl),sn=e.ui?.tabs??[],ln=["code",...an?["controls"]:[],...O("console")?["console"]:[],...O("events")?["events"]:[],...sn.map(t=>`custom:${t.id}`)].filter(t=>!pt(t)),Lt=ln.filter(t=>["console","events"].includes(t)),Gn=Lt.includes(V)?V:Lt[0],At=ln.filter(t=>!["console","events"].includes(t)&&!(X&&t==="controls")),rt=At.includes(R)?R:At[0],ge=Xe.filter(t=>!pt(t.id)),dn=fe==="adjustable"&&O("resize")&&!ee("resize"),bo=O("theme")&&!ee("theme"),vo=O("contrast")&&!ee("contrast"),ot=O("skeleton")&&!ee("skeleton"),it=O("motion")&&!ee("motion"),Ot=O("locale")&&!ee("locale"),$t=O("locale")&&!ee("direction"),Yn=!ee("settings")&&(Ot||$t||ot||it),Xn=(e.ui?.actions??[]).filter(t=>!K(t.id)),wo=O("history")&&(!K("undo")||!K("redo"))||O("format")&&!K("format")||O("copy")&&!K("copy")||O("share")&&!K("share")||O("reset")&&!K("reset")||O("fullscreen")&&!K("fullscreen")||O("stackblitz")&&!!e.onStackblitz&&!K("stackblitz")||Xn.length>0,je=e.examples?.find(t=>t.id===l),cn=Be(a)??Be({html:"",viewport:je?.viewport}),Zn=(e.ui?.viewports??oo).filter(t=>!t.hidden&&!ne(t.id,Te?.viewports)),un=[...Zn,..._n?[_n]:[],...cn&&!Zn.some(t=>t.id===cn.id)?[cn]:[]],Me=un.find(t=>t.id===Ct)??un[0]??oo[0],xo=t=>io[t%io.length],Qn=t=>`${t.width==="100%"?"100%":t.width} \xD7 ${t.height} px`,_t=Me.id==="shared"?Me.width:e.ui?.previewWidth??Me.width,er=Me.id==="shared"?Me.height:e.ui?.previewHeight??Me.height,tr=eo(Qe),Ne=e.ui?.stateId??je?.id??e.example.id??e.runtime.id,nr={theme:ke,contrast:we,skeleton:Ie,reducedMotion:Re,locale:Qe,direction:ze,width:be?.width??(typeof _t=="number"||_t==="100%"?_t:Me.width),height:be?.height??er};F(()=>{ge.length>0&&!ge.some(t=>t.id===m)&&g(ge[0].id)},[m,ge.map(t=>t.id).join("|")]);let rr=async(t,d)=>{let x=++o.current,N=e.examples?.find(te=>te.id===t),W=N?.examples.find(te=>te.id===d)??N?.examples.find(te=>te.id===N.defaultExample)??N?.examples[0];if(!N||!W)return;let z=O("drafts")?Ln(e.runtime.id,N.id):null,He=z&&(!d||z.id===d)?N.examples.find(te=>te.id===z.id)??W:W,de=z&&(!d||z.id===d)?{...He,...z,id:He.id}:He,oe=await wt(de);if(x!==o.current)return;le.current.clear(),Qt([]),en([]),u(N.id);let Ee={...oe,id:He.id??W.id??N.id};s(Ee.id),re(""),ae(!1);let U=Be(Ee)??Be({html:"",viewport:N.viewport});U&&kt(U.id),c(Ee),lt(Ee.html,Ee.css,Ee.javascript).length||T(Ee);for(let te of Xe)me.current[te.id]=Ye(Ee[te.id]??"");nt(te=>te+1)},pn=Jt((t,d)=>{o.current++,me.current[t]=An(me.current[t],d),c(x=>({...x,[t]:d})),nt(x=>x+1)},[]),Eo=Jt(t=>{c(d=>{let x={...d,...t};for(let N of Xe)typeof t[N.id]=="string"&&(me.current[N.id]=An(me.current[N.id],t[N.id]));return x}),nt(d=>d+1)},[]),mn=()=>{o.current++,E(d=>d+1),le.current.clear();let t=je?.examples.find(d=>d.id===r)??i.example;qr(e.runtime.id,l),c(t),lt(t.html,t.css,t.javascript).length||T(t);for(let d of Xe)me.current[d.id]=Ye(t[d.id]??"");nt(d=>d+1)},at=t=>{let d=Kr(me.current[m],t);d.changed&&(me.current[m]=d.history,c(x=>({...x,[m]:d.value})),nt(x=>x+1))};F(()=>Pt(""),[a.html,a.css,a.javascript,w]);let or=async()=>{let t=It[w]??It.html;t&&(await navigator.clipboard.writeText(Zr(t)),Pt("C\xF3digo copiado!"))},ir=async()=>{if(e.onShare){await e.onShare(a),Tt("Link compartilhado.");return}if(typeof window>"u")return;Kt.set(Ne,{h:a.html,j:a.javascript??null,c:a.css??"",s:Ne,exampleId:r,environment:nr});let t=Ur(Array.from(Kt.values()));if(!t)throw new Error("O c\xF3digo atual excede o limite de tamanho do link compartilh\xE1vel.");let d=new URL(window.location.href);d.searchParams.set("pg_state",t),await navigator.clipboard.writeText(d.toString()),Tt("Link copiado.")},ar=async()=>{let t=m==="html"?"html":m==="css"?"css":"babel",d=await ct(a[m]??"",t);pn(m,d)},sr=()=>{document.fullscreenElement===pe.current?document.exitFullscreen?.():pe.current?.requestFullscreen?.()},So={toggleTheme:()=>Gt(t=>t==="light"?"dark":"light"),getCode:()=>a,setCode:Eo,reset:()=>{O("reset")&&mn()},openFullscreen:()=>{O("fullscreen")&&sr()},undo:()=>{O("history")&&at(-1)},redo:()=>{O("history")&&at(1)},copyCode:()=>O("copy")?or():Promise.resolve(),share:()=>O("share")?ir():Promise.resolve(),format:()=>O("format")?ar():Promise.resolve(),openStackblitz:()=>{O("stackblitz")&&e.onStackblitz?.(a)}};F(()=>{if(y.length||($.javascript??"")===(P.javascript??""))return;let t=window.setTimeout(()=>T($),500);return()=>window.clearTimeout(t)},[$,P.javascript,y.length]),F(()=>{let t=new ResizeObserver(([d])=>{ye(Math.round(d.contentRect.width)),p(Math.round(d.contentRect.height))});return Mt.current=t,pe.current&&t.observe(pe.current),()=>{t.disconnect(),Mt.current=null}},[]);let Po=Jt(t=>{Mt.current?.disconnect(),pe.current=t,t&&Mt.current?.observe(t)},[]),lr=()=>{let t=xe.current?.contentWindow;t&&(t.postMessage({type:"set-html",channel:q,html:$.html},"*"),t.postMessage({type:"set-css",channel:q,css:$.css??""},"*"))};F(()=>{xe.current?.contentWindow?.postMessage({type:"set-inspection",channel:q,enabled:H},"*")},[H,q]),F(()=>{let[t,d]=j.split(":");t&&Number.isInteger(Number(d))&&xe.current?.contentWindow?.postMessage({type:"select-element",channel:q,tag:t,index:Number(d)},"*")},[j,a.html,q]);let Co=Jt(t=>{let[d,x]=t?.split(":")??[],N=Number(x);xe.current?.contentWindow?.postMessage({type:"highlight-element",channel:q,tag:d??"",index:Number.isInteger(N)?N:-1},"*")},[q]),dr=(()=>{let t=a.background;if(typeof t=="string")return t;if(!t)return;let d=t[ke];return typeof d=="string"?we?t.contrast:d:d?.[we?"contrast":"main"]??(we?t.contrast:void 0)})(),cr=()=>{let t=xe.current?.contentWindow;t&&t.postMessage({type:"set-mode",channel:q,mode:{theme:ke,background:dr,contrast:we,skeleton:Ie,reducedMotion:Re,lang:tr.lang,dir:ze}},"*")};F(()=>lr(),[$.html,$.css,q]),F(()=>cr(),[ke,we,Ie,Re,tr,ze,q,dr]),F(()=>{try{window.localStorage.setItem(`govbr-playground-modes:${e.runtime.id}`,JSON.stringify({theme:ke,contrast:we,skeleton:Ie,reducedMotion:Re,locale:Qe,direction:ze}))}catch{}},[e.runtime.id,ke,we,Ie,Re,Qe,ze,Ct]),F(()=>{if(Un.current)return;Un.current=!0;let t=i.example,d=i.groupId,x=i.exampleId,N=!1;if(typeof window<"u"){let z=new URLSearchParams(window.location.search).get("pg_state"),He=z?Vr(z):null,de=Wr(He).find(oe=>oe.s===Ne);if(de){if(de.environment){let U=de.environment;Ce("fixed"),Gt(U.theme),Yt(U.theme==="dark"?!1:U.contrast),Xt(U.skeleton),Zt(U.reducedMotion),In(U.locale),Rn(U.direction),ao({id:"shared",label:"Cen\xE1rio compartilhado",width:U.width,height:U.height}),kt("shared"),N=!0}t={...e.examples?.find(U=>U.id===d)?.examples.find(U=>U.id===de.exampleId)??t,html:de.h,css:de.c,javascript:de.j??"",id:de.exampleId??t.id},x=de.exampleId??x}else if(O("drafts")){let oe=Ln(e.runtime.id,d);if(oe){let U=e.examples?.find(te=>te.id===d)?.examples.find(te=>te.id===oe.id);U&&(x=U.id??x??d),t={...U??t,...oe,id:U?.id??x??d}}}}let W=o.current;wt(t).then(z=>{if(W!==o.current){Fn(!0);return}u(d),s(x),c(z),lt(z.html,z.css,z.javascript).length||T(z);let He=e.examples?.find(oe=>oe.id===d),de=Be(z)??Be({html:"",viewport:He?.viewport});de&&!N&&kt(de.id);for(let oe of Xe)me.current[oe.id]=Ye(z[oe.id]??"");nt(oe=>oe+1),Fn(!0)})},[e.runtime.id,e.ui?.stateId,e.example.id,i.example,i.groupId,i.exampleId,Ne]),F(()=>{!Bn||!O("drafts")||Jr(e.runtime.id,{...a,id:r||l},l)},[e.runtime.id,l,r,a,Bn]),F(()=>{Kt.set(Ne,{h:a.html,j:a.javascript??null,c:a.css??"",s:Ne,exampleId:r,environment:nr})},[Ne,a.html,a.css,a.javascript,r,ke,we,Ie,Re,Qe,ze,be,Ct,fe,k,ce]),F(()=>()=>{Kt.delete(Ne)},[Ne]),F(()=>{if(ut||!e.controls?.manifestUrl)return;let t=new AbortController;return fetch(e.controls.manifestUrl,{cache:"no-store",signal:t.signal}).then(d=>{if(!d.ok)throw new Error(`Falha ao carregar o manifesto (${d.status}).`);return d.json()}).then(d=>{if(!d||!Array.isArray(d.components))throw new TypeError("O manifesto de controles \xE9 inv\xE1lido.");fo(d),Vn("")}).catch(d=>{t.signal.aborted||Vn(d instanceof Error?d.message:String(d))}),()=>t.abort()},[ut,e.controls?.manifestUrl]),F(()=>{let t=d=>{if(d.source!==xe.current?.contentWindow||d.origin!==(e.runtime.allowSameOrigin?window.location.origin:"null")||d.data?.channel!==q)return;let x=d.data.value;if(d.data.type==="preview-size"&&Number.isFinite(x)&&x>0&&x<=1e5&&_e(x),d.data.type==="inspect-element"&&x&&typeof x.tag=="string"&&/^[a-z][a-z0-9]*-[a-z0-9-]+$/.test(x.tag)&&Number.isInteger(x.index)&&x.index>=0&&x.index<=1e4&&(re(`${x.tag}:${x.index}`),ue(N=>N+1)),d.data.type==="console"&&x&&typeof x=="object"){if(et||typeof x.method!="string"||!Array.isArray(x.args))return;let N=x;Qt(W=>[...W.slice(-499),{...N,id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${W.length}`}])}if(d.data.type==="event"&&x&&typeof x=="object"){if(tt||typeof x.eventType!="string")return;let N=x;en(W=>[...W.slice(-499),{...N,id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${W.length}`}])}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[q,et,tt,e.runtime.allowSameOrigin]);let ko=()=>{ar().catch(t=>Tt(t instanceof Error?t.message:String(t)))},To=()=>{ir().catch(t=>Tt(t instanceof Error?t.message:String(t)))},gn=so.filter(t=>tn==="all"||t.method===tn),fn=lo.filter(t=>!nn||t.eventType.toLowerCase().includes(nn.toLowerCase())),Mo=a[m]??"",ur=Xe.find(t=>t.id===m),No=me.current[m].index>0,Lo=me.current[m].index<me.current[m].entries.length-1,mt=qt(()=>Xr(a,e.runtime.frameworkPackages,[...Bt(e.runtime.library??e.library),...e.runtime.resources??[]]),[a.html,a.css,a.javascript,e.runtime.frameworkPackages,e.runtime.library,e.library,e.runtime.resources]),[pr,Ao]=L(null);F(()=>{let t=!0;return Promise.all(Object.entries(mt).map(async([d,x])=>[d,{...x,files:await Promise.all(x.files.map(async N=>({...N,code:await ct(N.code,N.language==="html"?"html":N.language==="css"?"css":["typescript","tsx"].includes(N.language)?"babel-ts":"babel")})))}])).then(d=>{t&&Ao({source:mt,value:Object.fromEntries(d)})}),()=>{t=!1}},[mt]);let It=pr?.source===mt?pr.value:mt,mr=["html","angular","react","vue"].filter(t=>It[t]?t==="html"||O("frameworks")&&!pt("frameworks")&&!pt(t):!1),Ue=mr.filter(t=>t!=="html"),Rt=O("editor")&&ge.length>0;F(()=>{w==="html"&&!Rt&&Ue.length?A(Ue[0]):w!=="html"&&!Ue.includes(w)&&A(Rt?"html":Ue[0]??"html")},[w,Rt,Ue.join("|")]);let gt=It[w],We=gt?.files[Math.min(D,(gt?.files.length??1)-1)],Oo=[...Rt?ge.map(({id:t,label:d})=>({id:t,label:d})):[],...Ue.map(t=>({id:t,label:t[0].toUpperCase()+t.slice(1)}))],$o=w==="html"?m:w;F(()=>{w!=="html"||ge.some(({id:t})=>t===m)||ge.length&&g(ge[0].id)},[w,m,ge.map(({id:t})=>t).join("|")]),F(()=>{Nt(null)},[Ct,l,r]);let jt=t=>({min:t==="width"?120:100,max:t==="width"?Math.max(120,(pe.current?.parentElement?.parentElement?.clientWidth??3840)-16):2160}),gr=(t,d)=>{let x=pe.current;if(!x)return;let N=jt(t),W=Math.round(Math.max(N.min,Math.min(N.max,d)));Nt(z=>({width:z?.width??x.clientWidth,height:z?.height??x.parentElement.clientHeight,[t]:W}))},_o=(t,d)=>{t.button!==0||!pe.current||(t.preventDefault(),t.currentTarget.focus(),t.currentTarget.setPointerCapture(t.pointerId),on.current={axis:d,x:t.clientX,y:t.clientY,width:pe.current.clientWidth,height:pe.current.parentElement.clientHeight},qn(!0))},Io=t=>{let d=on.current;d&&gr(d.axis,d.axis==="width"?d.width+t.clientX-d.x:d.height+t.clientY-d.y)},hn=()=>{on.current=null,qn(!1)},Ro=(t,d)=>{let x=d==="width"?"ArrowLeft":"ArrowUp";if(![x,d==="width"?"ArrowRight":"ArrowDown","Home","End"].includes(t.key))return;t.preventDefault();let W=jt(d),z=pe.current?.[d==="width"?"clientWidth":"clientHeight"]??W.min;gr(d,t.key==="Home"?W.min:t.key==="End"?W.max:z+(t.key===x?-1:1)*(t.shiftKey?50:10))},Ve=be?.width??_t,Ht=be?.height??er,fr=(be?.width??he)||(typeof Ve=="number"?Ve:375),hr=(be?.height??Fe)||(typeof Ht=="number"?Ht:300),Le=(t,d,x,N=!1)=>h(ie,{type:"button",iconOnly:!0,emphasis:"secondary","aria-label":d,title:d,onClick:x,disabled:N,children:h("i",{className:t,"aria-hidden":"true"})}),Dt=(t,d,x,N,W)=>h(ie,{iconOnly:!0,title:`${t}: ${d?"ativado":"desativado"}`,"aria-label":`Alternar ${t}`,"aria-pressed":d,emphasis:d?"primary":"secondary",onClick:()=>W(!d),children:h("i",{className:`fas ${d?x:N}`,"aria-hidden":"true"})}),yr=ut?h(Hr,{manifest:ut,hidden:Te?.inspector,html:y.length?$.html:a.html,readOnly:y.length>0,themeMode:"light",tag:e.controls?.tag,target:e.controls?.target,selectedInstance:j,onSelectedInstanceChange:re,onHighlightInstance:Co,onHtmlChange:t=>pn("html",t)}):h("p",{role:Wn?"alert":"status",children:Wn||"Carregando propriedades\u2026"}),jo=I("div",{className:"govbr-playground__preview-area",children:[I("header",{className:"govbr-playground__preview-header",children:[!ee("preview-title")&&h("strong",{children:"Viewport"}),(!ee("viewport")&&!Kn||!ee("dimensions")||O("fullscreen")&&!K("fullscreen"))&&I("div",{className:"govbr-playground__viewport-controls",children:[!ee("viewport")&&!Kn&&h("div",{className:"govbr-playground__viewport-buttons",role:"group","aria-label":"Tamanhos de viewport",children:un.map((t,d)=>{let x=!be&&t.id===Me.id,N=t.label.replace(/\s*\([^)]*\)\s*$/,"");return h(ie,{iconOnly:!0,title:`${N} \u2014 ${Qn(t)}`,"aria-label":`${N}, ${Qn(t)}`,"aria-pressed":x,emphasis:x?"primary":"secondary",onClick:()=>{Nt(null),kt(t.id)},children:h("i",{className:`fas ${xo(d)}`,"aria-hidden":"true"})},t.id)})}),!ee("dimensions")&&h("div",{className:"govbr-playground__viewport-dimensions",children:["width","height"].map(t=>I("label",{className:"govbr-playground__viewport-dimension",children:[t==="width"?"L":"A",h(Ke,{type:"number",min:1,max:1e4,step:1,"aria-label":`${t==="width"?"Largura":"Altura"} do viewport em pixels`,value:t==="width"?fr:hr,onChange:d=>{let x=d.target.valueAsNumber;!Number.isInteger(x)||x<1||x>1e4||Nt(N=>({width:N?.width??fr,height:N?.height??hr,[t]:x}))}}),h("span",{children:"px"})]},t))}),O("fullscreen")&&!K("fullscreen")&&Le("fas fa-expand-arrows-alt","Tela cheia",sr)]}),O("reset")&&!K("reset")&&Le("fas fa-sync-alt","Resetar exemplo para o padr\xE3o",mn)]}),I("div",{role:"group","aria-label":"\xC1rea de preview","data-resizable":dn,"data-fill-height":!be,"data-resizing":Jn,style:{width:typeof Ve=="number"?Ve+(dn?16:0):Ve,height:!be&&Me.id==="desktop"?"100%":Ht},children:[h("div",{ref:Po,className:"govbr-playground__preview",children:h("iframe",{ref:xe,title:e.ui?.title??"Pr\xE9via interativa",sandbox:`allow-scripts allow-forms${e.runtime.allowSameOrigin?" allow-same-origin":""}`,srcDoc:yo,onLoad:()=>{lr(),cr(),xe.current?.contentWindow?.postMessage({type:"set-inspection",channel:q,enabled:H},"*")},style:{width:"100%",height:"100%",border:0,pointerEvents:Jn?"none":void 0}},b)}),dn&&["width","height"].map(t=>h("div",{className:`govbr-playground__resize govbr-playground__resize--${t}`,role:"separator",tabIndex:0,"aria-label":t==="width"?"Redimensionar largura do preview":"Redimensionar altura do preview",title:t==="width"?"Arraste para redimensionar a largura":"Arraste para redimensionar a altura","aria-orientation":t==="width"?"vertical":"horizontal","aria-valuemin":jt(t).min,"aria-valuemax":jt(t).max,"aria-valuenow":t==="width"?be?.width??(typeof Ve=="number"?Ve:pe.current?.clientWidth??120):Ht,onPointerDown:d=>_o(d,t),onPointerMove:Io,onPointerUp:hn,onPointerCancel:hn,onLostPointerCapture:hn,onKeyDown:d=>Ro(d,t)},t))]})]}),Ho=I("div",{className:"govbr-playground__tools",children:[I(Ge,{active:rt,onChange:t=>S(t),items:At.map(t=>({id:t,label:(t.startsWith("custom:")?sn.find(d=>`custom:${d.id}`===t)?.label:void 0)??ro[t]})),children:[rt==="code"&&(wo||mr.length>0)&&I("header",{className:"govbr-playground__code-header",children:[O("history")&&!K("undo")&&Le("fas fa-undo","Desfazer",()=>at(-1),!No||w!=="html"),O("history")&&!K("redo")&&Le("fas fa-redo","Refazer",()=>at(1),!Lo||w!=="html"),O("format")&&!K("format")&&Le("fas fa-magic","Formatar",ko,w!=="html"),O("copy")&&!K("copy")&&Le("fas fa-copy",St||(w==="html"?"Copiar HTML, JS e CSS":`Copiar ${w}`),()=>{or()}),O("reset")&&!K("reset")&&Le("fas fa-sync-alt","Resetar exemplo para o padr\xE3o",mn),O("share")&&!K("share")&&Le("fas fa-share-alt","Compartilhar",To),O("stackblitz")&&!K("stackblitz")&&e.onStackblitz&&Le("fas fa-bolt","Abrir no StackBlitz",()=>e.onStackblitz?.(a)),Xn.map(t=>h(ie,{type:"button",iconOnly:!0,"aria-label":t.label,title:t.label,onClick:()=>{t.onClick(So)},children:h("span",{"aria-hidden":"true",children:t.icon??h("i",{className:"fas fa-bolt"})})},t.id))]}),rt==="code"&&(O("editor")&&ge.length>0||Ue.length>0)&&I("div",{className:"govbr-playground__editor",onKeyDownCapture:t=>{w!=="html"||!(t.target instanceof Element)||!t.target.closest(".cm-editor")||((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="z"?(t.preventDefault(),at(t.shiftKey?1:-1)):(t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="y"&&(t.preventDefault(),at(1)))},children:[y.length>0&&I("div",{role:"alert",className:"govbr-playground__source-errors",children:["\xDAltimo preview v\xE1lido preservado.",h("ul",{children:y.slice(0,5).map((t,d)=>I("li",{children:[t.message," Linha ",t.line,", coluna ",t.column,"."]},d))})]}),h(Ge,{label:"C\xF3digo-fonte",active:$o,onChange:t=>{Xe.some(({id:d})=>d===t)?(A("html"),g(t)):(A(t),Q(0))},items:Oo,children:w==="html"&&O("editor")&&ge.length>0?h($n,{children:h(no,{fallback:h("div",{role:"status",children:"Carregando editor\u2026"}),children:h(vt,{sessionKey:m,sessions:le.current,id:`editor-${q}`,"aria-label":ur.label,language:ur.language,controlManifest:ut,themeMode:"light",value:Mo,editable:!0,readOnly:!1,onChange:t=>pn(m,t),basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0}},m)})}):gt&&We?h(Ge,{label:`Arquivos ${w}`,active:We.filename,onChange:t=>Q(gt.files.findIndex(d=>d.filename===t)??0),items:gt.files.map(t=>({id:t.filename,label:t.filename})),children:h("section",{className:"govbr-playground__frameworks","aria-label":`C\xF3digo ${w}`,children:h(no,{fallback:h("div",{role:"status",children:"Carregando editor\u2026"}),children:h(vt,{sessionKey:`${w}-${We.filename}`,sessions:le.current,"aria-label":`Snippet ${We.filename}`,language:We.language,themeMode:"light",value:We.code,readOnly:!0,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!1}},`${w}-${We.filename}`)})})}):null})]}),rt==="controls"&&an&&yr,rt?.startsWith("custom:")&&sn.find(t=>`custom:${t.id}`===rt)?.render()]}),jn&&h("div",{className:"govbr-playground__status",role:"status",children:jn})]}),Do=I("div",{className:"govbr-playground__diagnostics-content",children:[Gn==="console"&&O("console")&&I("div",{children:[I("div",{className:"govbr-playground__panel-toolbar",children:[I("label",{children:["Tipo de mensagem",I(ve,{"aria-label":"Tipo de mensagem",value:tn,onChange:t=>uo(t.target.value),children:[h(B,{value:"all",children:"Todos"}),h(B,{value:"log",children:"Logs"}),h(B,{value:"info",children:"Informa\xE7\xF5es"}),h(B,{value:"warn",children:"Avisos"}),h(B,{value:"error",children:"Erros"}),h(B,{value:"exception",children:"Exce\xE7\xF5es"}),h(B,{value:"unhandledrejection",children:"Promises rejeitadas"})]})]}),h(ie,{iconOnly:!0,"aria-label":et?"Retomar console":"Pausar console",title:et?"Retomar console":"Pausar console","aria-pressed":et,onClick:()=>co(t=>!t),children:h("i",{className:et?"fas fa-play":"fas fa-pause","aria-hidden":"true"})}),h(ie,{iconOnly:!0,"aria-label":"Copiar console",title:Hn==="console"?"Console copiado!":"Copiar console",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(gn,null,2)).then(()=>Dn("console"))},children:h("i",{className:"fas fa-copy","aria-hidden":"true"})}),h(ie,{iconOnly:!0,"aria-label":"Limpar console",title:"Limpar console",onClick:()=>Qt([]),children:h("i",{className:"fas fa-trash-alt","aria-hidden":"true"})})]}),h("ol",{children:gn.map(t=>I("li",{"data-type":t.method,children:[h("time",{children:Number.isFinite(t.occurredAt)?new Date(t.occurredAt).toLocaleTimeString():""})," ",h("strong",{children:t.method}),h(wi,{item:t}),t.source&&I("small",{children:[t.source,":",t.line,":",t.column]})]},t.id))}),gn.length===0&&h("p",{children:"Nenhuma mensagem no console."})]}),Gn==="events"&&O("events")&&I("div",{children:[I("div",{className:"govbr-playground__panel-toolbar govbr-playground__events-toolbar",children:[I("label",{className:"govbr-playground__event-filter",children:[h("span",{children:"Filtrar eventos"}),h(Ke,{"aria-label":"Filtrar eventos",value:nn,onChange:t=>po(t.target.value)})]}),h(ie,{iconOnly:!0,"aria-label":tt?"Retomar eventos":"Pausar eventos",title:tt?"Retomar eventos":"Pausar eventos","aria-pressed":tt,onClick:()=>mo(t=>!t),children:h("i",{className:tt?"fas fa-play":"fas fa-pause","aria-hidden":"true"})}),h(ie,{iconOnly:!0,"aria-label":"Copiar eventos JSON",title:Hn==="events"?"Eventos copiados!":"Copiar eventos JSON",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(fn,null,2)).then(()=>Dn("events"))},children:h("i",{className:"fas fa-copy","aria-hidden":"true"})}),h(ie,{iconOnly:!0,"aria-label":"Limpar eventos",title:"Limpar eventos",onClick:()=>en([]),children:h("i",{className:"fas fa-trash-alt","aria-hidden":"true"})})]}),h("ol",{children:fn.map(t=>I("li",{onPointerEnter:()=>xe.current?.contentWindow?.postMessage({type:"highlight-event",channel:q,targetKey:t.targetKey},"*"),onPointerLeave:()=>xe.current?.contentWindow?.postMessage({type:"highlight-event",channel:q,targetKey:null},"*"),children:[h("strong",{children:t.eventType})," \u2014 ",t.target," ",h("time",{children:Number.isFinite(t.occurredAt)?new Date(t.occurredAt).toLocaleTimeString():`${Math.round(t.timeStamp??0)} ms`}),I("details",{children:[h("summary",{children:"Detalhes do evento"}),h("pre",{children:JSON.stringify({detail:t.detail,currentTarget:t.currentTarget,composedPath:t.composedPath,bubbles:t.bubbles,composed:t.composed,cancelable:t.cancelable},null,2)})]})]},t.id))}),fn.length===0&&h("p",{children:"Nenhum evento registrado."})]})]}),Bo=I($n,{children:[e.ui?.componentName&&h("h1",{className:"govbr-playground__component-title",children:e.ui.componentName}),h("div",{className:"govbr-playground__example-line",children:je&&I($n,{children:[!ee("example")&&I("label",{children:["Exemplo",h(ve,{"aria-label":"Exemplo ou categoria",value:je.examples.find(t=>t.id===r)?.category?.id??r,onChange:t=>{let d=je.examples.find(x=>(x.category?.id??x.id)===t.target.value);d&&rr(l,d.id)},children:je.examples.filter((t,d,x)=>!t.category||x.findIndex(N=>N.category?.id===t.category?.id)===d).map(t=>h(B,{value:t.category?.id??t.id,children:t.category?.label??t.label??t.id},t.category?.id??t.id))})]}),a.category&&!ee("example")&&!ee("category")&&h(ve,{"aria-label":"Item da categoria",value:r,onChange:t=>rr(l,t.target.value),children:je.examples.filter(t=>t.category?.id===a.category?.id).map(t=>h(B,{value:t.id,children:t.label??t.id},t.id))})]})}),I("div",{className:"govbr-playground__settings-line",children:[Yn&&I(ie,{className:"govbr-playground__settings-trigger",emphasis:"secondary","aria-expanded":rn,"aria-haspopup":"dialog",onClick:t=>{let d=zn.current;if(!d)return;if(rn){d.hidePopover();return}let x=t.currentTarget.getBoundingClientRect();d.style.top=`${x.bottom+12}px`,d.style.left=`${Math.max(12,Math.min(x.right-420,window.innerWidth-432))}px`,d.showPopover(),d.style.top=`${Math.max(12,Math.min(x.bottom+12,window.innerHeight-d.offsetHeight-12))}px`},children:[h("i",{className:"fas fa-cog","aria-hidden":"true"}),h("span",{children:"Configura\xE7\xF5es"}),h("i",{className:`fas ${rn?"fa-chevron-up":"fa-chevron-down"}`,"aria-hidden":"true"})]}),bo&&I(ve,{"aria-label":"Tema r\xE1pido",value:ke,onChange:t=>{let d=t.target.value;Gt(d),d==="dark"&&Yt(!1)},children:[h(B,{value:"light",children:"Tema claro"}),h(B,{value:"dark",children:"Tema escuro"})]}),vo&&I(ve,{"aria-label":"Contraste r\xE1pido",value:we?"contrast":"main",disabled:ke==="dark",onChange:t=>Yt(t.target.value==="contrast"),children:[h(B,{value:"main",children:"Modo principal"}),h(B,{value:"contrast",children:"Modo contraste"})]}),(ot||it)&&I("span",{className:"govbr-playground__wide-behavior",children:[ot&&Dt("Skeleton",Ie,"fa-grip-lines","fa-square",Xt),it&&Dt("Movimento reduzido",Re,"fa-walking","fa-running",Zt)]}),Yn&&I("div",{ref:zn,popover:"auto",role:"dialog","aria-label":"Configura\xE7\xF5es do playground",className:"govbr-playground__settings",onToggle:t=>go(t.newState==="open"),children:[(Ot||$t)&&h("h3",{children:"Ambiente"}),Ot&&h("div",{className:"govbr-playground__setting-row",children:h(ve,{"aria-label":"Idioma",value:Qe,onChange:t=>In(t.target.value),children:Et.map(t=>h(B,{value:t.value,children:t.label},t.value))})}),$t&&h("div",{className:"govbr-playground__setting-row",children:I(ve,{"aria-label":"Dire\xE7\xE3o do texto",value:ze,onChange:t=>Rn(t.target.value),children:[h(B,{value:"ltr",children:"LTR"}),h(B,{value:"rtl",children:"RTL"})]})}),(Ot||$t)&&(ot||it)&&h("hr",{}),(ot||it)&&I("div",{className:"govbr-playground__settings-behavior",children:[h("h3",{children:"Comportamento"}),I("span",{className:"govbr-playground__menu-behavior",children:[ot&&Dt("Skeleton",Ie,"fa-grip-lines","fa-square",Xt),it&&Dt("Movimento reduzido",Re,"fa-walking","fa-running",Zt)]})]})]})]}),a.description&&h("p",{className:"govbr-playground__example-description",children:a.description}),a.details&&I("details",{className:"govbr-playground__example-details",children:[h("summary",{children:"Explica\xE7\xE3o detalhada"}),h("p",{children:a.details})]})]});return h(Ar,{value:Te.controls,children:I("section",{className:n,"data-theme":"light","data-presentation":v,"data-library":e.library?.profile??"wbc","data-has-tools":ln.length>0?"true":"false",children:[h(_r,{id:e.runtime.id,header:Bo,presentation:v,hiddenControls:Te?.controls,selectionRequest:J?String(J):void 0,onCombinedPanelChange:Y,initial:a.ui?.workspace??e.ui?.workspace,preview:jo,code:At.length?Ho:void 0,properties:an&&!pt("controls")?yr:void 0,diagnostics:Lt.length?Do:void 0,diagnosticItems:Lt.map(t=>({id:t,label:ro[t]})),onDiagnosticTabChange:Z},e.runtime.id),h("span",{hidden:!0,children:ho})]})})}function Pi(e){let[n,o]=L(null),[i,l]=L("");return F(()=>{let u=!0,r=new AbortController;return l(""),xr(e.config,{signal:r.signal}).then(Gr).then(s=>{u&&o({original:e.config,config:s})}).catch(s=>{u&&l(String(s.message??s))}),()=>{u=!1,r.abort()}},[e.config]),i?h("p",{role:"alert",children:i}):!n||n.original!==e.config?h("p",{role:"status",children:"Formatando exemplos\u2026"}):h(Or,{library:n.config.library,hiddenControls:n.config.ui?.hidden?.controls,children:h(Si,{...e,config:n.config})})}export{kr as DEFAULT_LIBRARY,Pi as Playground,to as createPreviewDocument,wn as ensureLibrary,sa as isPlaygroundConfig,Uo as normalizePlaygroundManifest,ft as resolveLibrary,xr as resolvePlaygroundConfig};
347
+ <\/script>`;return`<!doctype html><html lang="pt-BR"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">${c}${r}${s}${m}${d}<title>${Mi(e.ui?.title??"Playground")}</title></head><body><div data-playground-content role="main" style="display:contents"><!--pg-start:${n}-->${e.example.html}<!--pg-end:${n}--></div>${y}${A}</body></html>`}function Ca(e){if(!e||typeof e!="object")return!1;let n=e;return typeof n.runtime?.id=="string"&&typeof n.example?.html=="string"}import{Fragment as co,jsx as h,jsxs as O}from"react/jsx-runtime";function Ai(e){let n={};for(let o of e.split(";")){let a=o.indexOf(":");if(a<0)continue;let l=o.slice(0,a).trim().toLowerCase(),c=o.slice(a+1).trim();l==="color"||l==="background"||l==="background-color"?/^(#[\da-f]{3,8}|[a-z]{3,20}|rgba?\([\d.,%\s]+\))$/i.test(c)&&(l==="color"?n.color=c:n.backgroundColor=c):l==="font-weight"&&/^(normal|bold|[1-9]00)$/.test(c)?n.fontWeight=c:l==="font-size"&&/^\d{1,2}px$/.test(c)?n.fontSize=c:l==="padding"&&/^(\d{1,2}px)(\s+\d{1,2}px)?$/.test(c)?n.padding=c:l==="border-radius"&&/^\d{1,2}px$/.test(c)&&(n.borderRadius=c)}return n}function Oi(e){let[n,...o]=e;if(typeof n!="string"||!n.includes("%c"))return e.map(r=>typeof r=="string"?r:JSON.stringify(r)??String(r)).join(" ");let a=n.split("%c"),l=o.splice(0,a.length-1),c=a.map((r,s)=>h("span",{className:s===0?void 0:"govbr-playground__console-style",style:s>0&&typeof l[s-1]=="string"?Ai(l[s-1]):void 0,children:r},`part-${s}`));return o.length&&c.push(O("span",{children:[" ",o.map(r=>typeof r=="string"?r:JSON.stringify(r)??String(r)).join(" ")]},"arguments")),c}function _i(e){let[n,...o]=e;if(typeof n!="string")return e.map(c=>typeof c=="string"?c:JSON.stringify(c)??String(c)).join(" ");let a=(n.match(/%c/g)??[]).length,l=o.splice(0,a);return[n.replace(/%c/g,""),...o.filter(c=>!l.includes(c)).map(c=>typeof c=="string"?c:JSON.stringify(c)??String(c))].join(" ").trim()}function $i({item:e}){let n=_i(e.args);return n.length<=280?h("div",{className:"govbr-playground__console-message",children:Oi(e.args)}):O("details",{className:"govbr-playground__console-details",children:[O("summary",{children:[n.slice(0,280),"\u2026 ",h("span",{children:"Ver detalhes"})]}),h("pre",{children:n})]})}var ao={code:"C\xF3digo-fonte",controls:"Propriedades",console:"Console",events:"Eventos"},Ke=[{id:"html",label:"HTML",language:"html"},{id:"javascript",label:"JS",language:"javascript"},{id:"css",label:"CSS",language:"css"}],so=[{id:"desktop",label:"Desktop (100%)",width:"100%",height:300},{id:"tablet",label:"Tablet (768 \xD7 600)",width:768,height:600},{id:"mobile",label:"Mobile (375 \xD7 812)",width:375,height:812}],lo=["fa-desktop","fa-tablet-alt","fa-mobile-alt","fa-laptop","fa-tv","fa-window-maximize"],kn=(e,n)=>{if(e.some(o=>!o)||new Set(e).size!==e.length)throw new TypeError(`IDs de ${n} ausentes ou duplicados`)},Vt=new Map;function Ri(e){let n=e.examples?.find(a=>a.id===e.example.id)??e.examples?.[0],o=n?.examples.find(a=>a.id===n.defaultExample)??n?.examples[0];return{groupId:n?.id??e.example.id??"",exampleId:o?.id??e.example.id??"",example:o??e.example,groupViewport:n?.viewport}}function Ie(e){let n=e?.viewport,o={desktop:{id:"desktop",label:"Desktop (100%)",width:"100%",height:300},tablet:{id:"tablet",label:"Tablet (768 \xD7 600)",width:768,height:600},mobile:{id:"mobile",label:"Mobile (375 \xD7 812)",width:375,height:812}};if(typeof n=="string")return o[{phone:"mobile",iphone:"mobile",android:"mobile",ipad:"tablet"}[n.toLowerCase()]??n.toLowerCase()]??null;if(!n)return null;let a=n.width??n.x,l=n.height??n.y;return n.id&&o[n.id]?o[n.id]:!a&&!l?null:{id:n.id??`custom-${a??"auto"}-${l??"auto"}`,label:n.label??`${a??"100%"} \xD7 ${l??300}`,width:a??"100%",height:l??300}}function Ii(e){let n={theme:"light",contrast:!1,skeleton:!1,reducedMotion:!1,locale:no,direction:"ltr"};try{let o=JSON.parse(window.localStorage.getItem(`govbr-playground-modes:${e}`)??"null");if(!o||typeof o!="object")return n;let a=Pt.some(c=>c.value===o.locale)?o.locale:n.locale,l=o.direction==="ltr"||o.direction==="rtl"?o.direction:o.locale==="pt-BR-rtl"?"rtl":n.direction;return{theme:o.theme==="dark"?"dark":"light",contrast:o.theme!=="dark"&&!!o.contrast,skeleton:!!o.skeleton,reducedMotion:!!o.reducedMotion,locale:a,direction:l}}catch{return n}}function ji({config:e,className:n}){let o=ge(0),[a]=M(()=>Ri(e)),[l,c]=M(a.groupId),[r,s]=M(a.exampleId),[i,d]=M(a.example),m=i.ui?.mode??e.ui?.mode??"developer",x=i.ui?.designer?.controls??e.ui?.designer?.controls??"examples",y=m==="designer"?x==="none"?"preview":"designer":"developer",[T,A]=M(()=>ot(a.example.html,a.example.css,a.example.javascript).length?{...a.example,html:"",css:"",javascript:""}:a.example),[w,C]=M(0),[R,S]=M(T);F(()=>{let t=e.examples?.flatMap(u=>u.examples).find(u=>u.id===r)??e.example;e.onChange?.(i,t)},[e.onChange,e.examples,e.example,i,r]);let k=Ut(()=>ot(i.html,i.css,i.javascript),[i.html,i.css,i.javascript]);F(()=>{k.length||S(i)},[i,k]);let[g,f]=M("html"),[I,E]=M("code"),[X,z]=M("console"),[G,ne]=M(!1);F(()=>{y!=="developer"&&ne(!1)},[y]);let[re,Ae]=M(""),[j,le]=M(0),[Y,_]=M("adjustable"),[$,V]=M(180),[W,be]=M(0),[fe,ve]=M(0),[Wt,p]=M(Number.isFinite(e.ui?.previewMaxHeight)?Math.max(180,Math.min(2e3,e.ui.previewMaxHeight)):600),[b,oe]=M("html"),[he,ce]=M(0),je=ge(new Map),[dt,qe]=M(""),[Ge]=M(()=>Ii(e.runtime.id)),[Tn,uo]=M(null),[Xe,Ct]=M(()=>Ie(a.example)?.id??Ie({html:"",viewport:a.groupViewport})?.id??"desktop"),[Oe,Jt]=M(Ge.theme),[we,Nn]=M(Ge.contrast),[He,Mn]=M(Ge.skeleton),[ye,Ln]=M(Ge.reducedMotion),[Ye,An]=M(Ge.locale),[De,On]=M(Ge.direction),[_n,kt]=M(""),[po,Kt]=M([]),[mo,qt]=M([]),[Ze,go]=M(!1),[Gt,fo]=M("all"),[Xt,ho]=M(""),[Qe,yo]=M(!1),[$n,Rn]=M(""),[In,jn]=M(!1),Hn=ge(!1),[ct,bo]=M(e.controls?.manifest??null),[Dn,Bn]=M(""),xe=ge(null),ue=ge(null),Tt=ge(null),[Z,Be]=M(null),Yt=ge(null),ut=ge(null),Zt=ge(null),[Fn,zn]=M(!1),Qt=ge(null),pe=ge({html:Je(a.example.html),css:Je(a.example.css??""),javascript:Je(a.example.javascript??"")}),[vo,et]=M(0);kn(e.ui?.actions?.map(t=>t.id)??[],"a\xE7\xF5es"),kn(e.ui?.tabs?.map(t=>t.id)??[],"abas");for(let t of e.examples??[]){if(!t.id||!t.label||t.examples.length===0)throw new TypeError("Cada grupo de exemplos precisa de ID, r\xF3tulo e ao menos um example.");kn(t.examples.map(u=>u.id??""),`examples de ${t.id}`)}let K=Ut(()=>globalThis.crypto?.randomUUID?.()??`pg-${Math.random().toString(36).slice(2)}`,[e.runtime.id]),wo=Ut(()=>oo({...e,example:T},K),[e,T,K]),L=t=>e.features?.[t]!==!1,ke={...e.ui?.hidden,...i.ui?.hidden},q=t=>ee(t,ke?.actions),ie=t=>ee(t,ke?.controls),Un=ee("viewport",ke?.viewports),pt=t=>ee(t,ke?.tabs)?!0:t.startsWith("custom:")&&ee(t.slice(7),ke?.tabs),Vn=L("controls")&&!!(e.controls?.manifest||e.controls?.manifestUrl),en=e.ui?.tabs??[],tn=["code",...Vn?["controls"]:[],...L("console")?["console"]:[],...L("events")?["events"]:[],...en.map(t=>`custom:${t.id}`)].filter(t=>!pt(t)),Nt=tn.filter(t=>["console","events"].includes(t)),Wn=Nt.includes(X)?X:Nt[0],Mt=tn.filter(t=>!["console","events","controls"].includes(t)),mt=Mt.includes(I)?I:Mt[0],me=Ke.filter(t=>!pt(t.id)),Lt=Y==="adjustable"&&L("resize")&&!ie("resize"),xo=L("theme")&&!ie("theme"),Eo=L("contrast")&&!ie("contrast"),So=L("skeleton")&&!ie("skeleton"),Po=L("motion")&&!ie("motion"),Jn=L("locale")&&!ie("locale"),Kn=L("locale")&&!ie("direction"),Co=!ie("settings")&&(Jn||Kn),qn=(e.ui?.actions??[]).filter(t=>!q(t.id)),ko=L("history")&&(!q("undo")||!q("redo"))||L("format")&&!q("format")||L("copy")&&!q("copy")||L("share")&&!q("share")||L("reset")&&!q("reset")||L("fullscreen")&&!q("fullscreen")||L("stackblitz")&&!!e.onStackblitz&&!q("stackblitz")||qn.length>0,tt=e.examples?.find(t=>t.id===l),nn=Ie(i)??Ie({html:"",viewport:tt?.viewport}),Gn=(e.ui?.viewports??so).filter(t=>!t.hidden&&!ee(t.id,ke?.viewports)),rn=[...Gn,...Tn?[Tn]:[],...nn&&!Gn.some(t=>t.id===nn.id)?[nn]:[]],Te=rn.find(t=>t.id===Xe)??rn[0]??so[0],To=t=>lo[t%lo.length],Xn=t=>`${t.width==="100%"?"100%":t.width} \xD7 ${t.height} px`,At=Te.id==="shared"?Te.width:e.ui?.previewWidth??Te.width,Yn=Te.id==="shared"?Te.height:e.ui?.previewHeight??Te.height,Zn=ro(Ye),Ne=e.ui?.stateId??tt?.id??e.example.id??e.runtime.id,Qn={theme:Oe,contrast:we,skeleton:He,reducedMotion:ye,locale:Ye,direction:De,width:Z?.width??(typeof At=="number"||At==="100%"?At:Te.width),height:Z?.height??Yn};F(()=>{me.length>0&&!me.some(t=>t.id===g)&&f(me[0].id)},[g,me.map(t=>t.id).join("|")]);let No=async(t,u)=>{let v=++o.current,N=e.examples?.find(Q=>Q.id===t),H=N?.examples.find(Q=>Q.id===u)??N?.examples.find(Q=>Q.id===N.defaultExample)??N?.examples[0];if(!N||!H)return;let B=L("drafts")?Pn(e.runtime.id,N.id):null,_e=B&&(!u||B.id===u)?N.examples.find(Q=>Q.id===B.id)??H:H,de=B&&(!u||B.id===u)?{..._e,...B,id:_e.id}:_e,ae=await Et(de);if(v!==o.current)return;je.current.clear(),Kt([]),qt([]),c(N.id);let Ee={...ae,id:_e.id??H.id??N.id};s(Ee.id),Ae(""),ne(!1);let J=Ie(Ee)??Ie({html:"",viewport:N.viewport});J&&Ct(J.id),d(Ee),ot(Ee.html,Ee.css,Ee.javascript).length||A(Ee);for(let Q of Ke)pe.current[Q.id]=Je(Ee[Q.id]??"");et(Q=>Q+1)},on=zt((t,u)=>{o.current++,pe.current[t]=Cn(pe.current[t],u),d(v=>({...v,[t]:u})),et(v=>v+1)},[]),Mo=zt(t=>{d(u=>{let v={...u,...t};for(let N of Ke)typeof t[N.id]=="string"&&(pe.current[N.id]=Cn(pe.current[N.id],t[N.id]));return v}),et(u=>u+1)},[]),an=()=>{o.current++,C(u=>u+1),je.current.clear();let t=tt?.examples.find(u=>u.id===r)??a.example;Xr(e.runtime.id,l),d(t),ot(t.html,t.css,t.javascript).length||A(t);for(let u of Ke)pe.current[u.id]=Je(t[u.id]??"");et(u=>u+1)},nt=t=>{let u=Yr(pe.current[g],t);u.changed&&(pe.current[g]=u.history,d(v=>({...v,[g]:u.value})),et(v=>v+1))};F(()=>qe(""),[i.html,i.css,i.javascript,b]);let er=async()=>{let t=Ot[b]??Ot.html;t&&(await navigator.clipboard.writeText(to(t)),qe("C\xF3digo copiado!"))},tr=async()=>{if(e.onShare){await e.onShare(i),kt("Link compartilhado.");return}if(typeof window>"u")return;Vt.set(Ne,{h:i.html,j:i.javascript??null,c:i.css??"",s:Ne,exampleId:r,environment:Qn});let t=Bt(Array.from(Vt.values()));if(!t)throw new Error("O c\xF3digo atual excede o limite de tamanho do link compartilh\xE1vel.");let u=new URL(window.location.href);u.searchParams.set("pg_state",t),await navigator.clipboard.writeText(u.toString()),kt("Link copiado.")},nr=async()=>{let t=g==="html"?"html":g==="css"?"css":"babel",u=await lt(i[g]??"",t);on(g,u)},rr=()=>{document.fullscreenElement===ue.current?document.exitFullscreen?.():ue.current?.requestFullscreen?.()},Lo={toggleTheme:()=>Jt(t=>t==="light"?"dark":"light"),getCode:()=>i,setCode:Mo,reset:()=>{L("reset")&&an()},openFullscreen:()=>{L("fullscreen")&&rr()},undo:()=>{L("history")&&nt(-1)},redo:()=>{L("history")&&nt(1)},copyCode:()=>L("copy")?er():Promise.resolve(),share:()=>L("share")?tr():Promise.resolve(),format:()=>L("format")?nr():Promise.resolve(),openStackblitz:()=>{L("stackblitz")&&e.onStackblitz?.(i)}};F(()=>{if(k.length||(R.javascript??"")===(T.javascript??""))return;let t=window.setTimeout(()=>A(R),500);return()=>window.clearTimeout(t)},[R,T.javascript,k.length]),F(()=>{let t=new ResizeObserver(([u])=>{be(Math.round(u.contentRect.width)),ve(Math.round(u.contentRect.height))});return Tt.current=t,ue.current&&t.observe(ue.current),()=>{t.disconnect(),Tt.current=null}},[]);let Ao=zt(t=>{Tt.current?.disconnect(),ue.current=t,t&&Tt.current?.observe(t)},[]),or=()=>{let t=xe.current?.contentWindow;t&&(t.postMessage({type:"set-html",channel:K,html:R.html},"*"),t.postMessage({type:"set-css",channel:K,css:R.css??""},"*"))};F(()=>{xe.current?.contentWindow?.postMessage({type:"set-inspection",channel:K,enabled:G},"*")},[G,K]),F(()=>{let[t,u]=re.split(":");t&&Number.isInteger(Number(u))&&xe.current?.contentWindow?.postMessage({type:"select-element",channel:K,tag:t,index:Number(u)},"*")},[re,i.html,K]);let Oo=zt(t=>{let[u,v]=t?.split(":")??[],N=Number(v);xe.current?.contentWindow?.postMessage({type:"highlight-element",channel:K,tag:u??"",index:Number.isInteger(N)?N:-1},"*")},[K]),ir=(()=>{let t=i.background;if(typeof t=="string")return t;if(!t)return;let u=t[Oe];return typeof u=="string"?we?t.contrast:u:u?.[we?"contrast":"main"]??(we?t.contrast:void 0)})(),ar=()=>{let t=xe.current?.contentWindow;t&&t.postMessage({type:"set-mode",channel:K,mode:{theme:Oe,background:ir,contrast:we,skeleton:He,reducedMotion:ye,lang:Zn.lang,dir:De}},"*")};F(()=>or(),[R.html,R.css,K]),F(()=>ar(),[Oe,we,He,ye,Zn,De,K,ir]),F(()=>{try{window.localStorage.setItem(`govbr-playground-modes:${e.runtime.id}`,JSON.stringify({theme:Oe,contrast:we,skeleton:He,reducedMotion:ye,locale:Ye,direction:De}))}catch{}},[e.runtime.id,Oe,we,He,ye,Ye,De,Xe]),F(()=>{if(Hn.current)return;Hn.current=!0;let t=a.example,u=a.groupId,v=a.exampleId,N=!1;if(typeof window<"u"){let B=new URLSearchParams(window.location.search).get("pg_state"),_e=B?qr(B):null,de=Kr(_e).find(ae=>ae.s===Ne);if(de){if(de.environment){let J=de.environment;_("fixed"),Jt(J.theme),Nn(J.contrast),Mn(J.skeleton),Ln(J.reducedMotion),An(J.locale),On(J.direction),uo({id:"shared",label:"Cen\xE1rio compartilhado",width:J.width,height:J.height}),Ct("shared"),N=!0}t={...e.examples?.find(J=>J.id===u)?.examples.find(J=>J.id===de.exampleId)??t,html:de.h,css:de.c,javascript:de.j??"",id:de.exampleId??t.id},v=de.exampleId??v}else if(L("drafts")){let ae=Pn(e.runtime.id,u);if(ae){let J=e.examples?.find(Q=>Q.id===u)?.examples.find(Q=>Q.id===ae.id);J&&(v=J.id??v??u),t={...J??t,...ae,id:J?.id??v??u}}}}let H=o.current;Et(t).then(B=>{if(H!==o.current){jn(!0);return}c(u),s(v),d(B),ot(B.html,B.css,B.javascript).length||A(B);let _e=e.examples?.find(ae=>ae.id===u),de=Ie(B)??Ie({html:"",viewport:_e?.viewport});de&&!N&&Ct(de.id);for(let ae of Ke)pe.current[ae.id]=Je(B[ae.id]??"");et(ae=>ae+1),jn(!0)})},[e.runtime.id,e.ui?.stateId,e.example.id,a.example,a.groupId,a.exampleId,Ne]),F(()=>{!In||!L("drafts")||Gr(e.runtime.id,{...i,id:r||l},l)},[e.runtime.id,l,r,i,In]),F(()=>{Vt.set(Ne,{h:i.html,j:i.javascript??null,c:i.css??"",s:Ne,exampleId:r,environment:Qn})},[Ne,i.html,i.css,i.javascript,r,Oe,we,He,ye,Ye,De,Z,Xe,Y,Wt,$]),F(()=>()=>{Vt.delete(Ne)},[Ne]),F(()=>{if(ct||!e.controls?.manifestUrl)return;let t=new AbortController;return fetch(e.controls.manifestUrl,{cache:"no-store",signal:t.signal}).then(u=>{if(!u.ok)throw new Error(`Falha ao carregar o manifesto (${u.status}).`);return u.json()}).then(u=>{if(!u||!Array.isArray(u.components))throw new TypeError("O manifesto de controles \xE9 inv\xE1lido.");bo(u),Bn("")}).catch(u=>{t.signal.aborted||Bn(u instanceof Error?u.message:String(u))}),()=>t.abort()},[ct,e.controls?.manifestUrl]),F(()=>{let t=u=>{if(u.source!==xe.current?.contentWindow||u.origin!==(e.runtime.allowSameOrigin?window.location.origin:"null")||u.data?.channel!==K)return;let v=u.data.value;if(u.data.type==="preview-size"&&Number.isFinite(v)&&v>0&&v<=1e5&&V(v),u.data.type==="inspect-element"&&v&&typeof v.tag=="string"&&/^[a-z][a-z0-9]*-[a-z0-9-]+$/.test(v.tag)&&Number.isInteger(v.index)&&v.index>=0&&v.index<=1e4&&(Ae(`${v.tag}:${v.index}`),le(N=>N+1)),u.data.type==="console"&&v&&typeof v=="object"){if(Ze||typeof v.method!="string"||!Array.isArray(v.args))return;let N=v;Kt(H=>[...H.slice(-499),{...N,id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${H.length}`}])}if(u.data.type==="event"&&v&&typeof v=="object"){if(Qe||typeof v.eventType!="string")return;let N=v;qt(H=>[...H.slice(-499),{...N,id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${H.length}`}])}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[K,Ze,Qe,e.runtime.allowSameOrigin]);let _o=()=>{nr().catch(t=>kt(t instanceof Error?t.message:String(t)))},$o=()=>{tr().catch(t=>kt(t instanceof Error?t.message:String(t)))},sn=po.filter(t=>Gt==="all"||t.method===Gt),ln=mo.filter(t=>!Xt||t.eventType.toLowerCase().includes(Xt.toLowerCase())),Ro=i[g]??"",sr=Ke.find(t=>t.id===g),Io=pe.current[g].index>0,jo=pe.current[g].index<pe.current[g].entries.length-1,gt=Ut(()=>eo(i,e.runtime.frameworkPackages,[...It(e.runtime.library??e.library),...e.runtime.resources??[]]),[i.html,i.css,i.javascript,e.runtime.frameworkPackages,e.runtime.library,e.library,e.runtime.resources]),[lr,Ho]=M(null);F(()=>{let t=!0;return Promise.all(Object.entries(gt).map(async([u,v])=>[u,{...v,files:await Promise.all(v.files.map(async N=>({...N,code:await lt(N.code,N.language==="html"?"html":N.language==="css"?"css":["typescript","tsx"].includes(N.language)?"babel-ts":"babel")})))}])).then(u=>{t&&Ho({source:gt,value:Object.fromEntries(u)})}),()=>{t=!1}},[gt]);let Ot=lr?.source===gt?lr.value:gt,dr=["html","angular","react","vue"].filter(t=>Ot[t]?t==="html"||L("frameworks")&&!pt("frameworks")&&!pt(t):!1),Fe=dr.filter(t=>t!=="html"),_t=L("editor")&&me.length>0;F(()=>{b==="html"&&!_t&&Fe.length?oe(Fe[0]):b!=="html"&&!Fe.includes(b)&&oe(_t?"html":Fe[0]??"html")},[b,_t,Fe.join("|")]);let ft=Ot[b],ze=ft?.files[Math.min(he,(ft?.files.length??1)-1)],Do=[..._t?me.map(({id:t,label:u})=>({id:t,label:u})):[],...Fe.map(t=>({id:t,label:t[0].toUpperCase()+t.slice(1)}))],Bo=b==="html"?g:b;F(()=>{b!=="html"||me.some(({id:t})=>t===g)||me.length&&f(me[0].id)},[b,g,me.map(({id:t})=>t).join("|")]),F(()=>{Be(null)},[Xe,l,r]),Li(()=>{let t=Zt.current;Zt.current=null;let u=Yt.current;if(ye&&ut.current?.cancel(),!t||!u||ye||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let v=u.getBoundingClientRect();if(Math.abs(t.width-v.width)<1&&Math.abs(t.height-v.height)<1)return;let N=getComputedStyle(u),H=N.getPropertyValue("--br-motion-duration-fast-3").trim()||"150ms",B=Number.parseFloat(H)*(H.endsWith("ms")?1:1e3);ut.current=u.animate([{width:`${t.width}px`,height:`${t.height}px`,flex:"0 0 auto"},{width:`${v.width}px`,height:`${v.height}px`,flex:"0 0 auto"}],{duration:B,easing:N.getPropertyValue("--br-motion-easing-ease-out").trim()||"ease-out"})},[Xe,Z,ye]),F(()=>()=>ut.current?.cancel(),[]);let $t=t=>({min:t==="width"?120:100,max:t==="width"?Math.max(120,(ue.current?.parentElement?.parentElement?.clientWidth??3840)-16):2160}),cr=(t,u)=>{let v=ue.current;if(!v)return;let N=$t(t),H=Math.round(Math.max(N.min,Math.min(N.max,u)));Be(B=>({width:B?.width??v.clientWidth,height:B?.height??v.clientHeight,[t]:H}))},Fo=(t,u)=>{if(t.button!==0||!ue.current)return;t.preventDefault();let v=ue.current.clientWidth,N=ue.current.clientHeight;ut.current?.cancel(),Be({width:v,height:N}),t.currentTarget.focus(),t.currentTarget.setPointerCapture(t.pointerId),Qt.current={axis:u,x:t.clientX,y:t.clientY,width:v,height:N},zn(!0)},zo=t=>{let u=Qt.current;u&&cr(u.axis,u.axis==="width"?u.width+t.clientX-u.x:u.height+t.clientY-u.y)},dn=()=>{Qt.current=null,zn(!1)},Uo=(t,u)=>{let v=u==="width"?"ArrowLeft":"ArrowUp";if(![v,u==="width"?"ArrowRight":"ArrowDown","Home","End"].includes(t.key))return;t.preventDefault();let H=$t(u),B=ue.current?.[u==="width"?"clientWidth":"clientHeight"]??H.min;cr(u,t.key==="Home"?H.min:t.key==="End"?H.max:B+(t.key===v?-1:1)*(t.shiftKey?50:10))},Ue=Z?.width??At,Rt=Z?.height??Yn,cn=(Z?.width??W)||(typeof Ue=="number"?Ue:375),un=(Z?.height??fe)||(typeof Rt=="number"?Rt:300),Me=(t,u,v,N=!1)=>h(te,{type:"button",iconOnly:!0,emphasis:"secondary","aria-label":u,title:u,onClick:v,disabled:N,children:h("i",{className:t,"aria-hidden":"true"})}),ur=(t,u,v,N,H)=>h(te,{iconOnly:!0,title:`${t}: ${u?"ativado":"desativado"}`,"aria-label":`Alternar ${t}`,"aria-pressed":u,emphasis:u?"primary":"secondary",onClick:()=>H(!u),children:h("i",{className:`fas ${u?v:N}`,"aria-hidden":"true"})}),Vo=ct?h(Fr,{manifest:ct,hidden:ke?.inspector,html:k.length?R.html:i.html,readOnly:k.length>0,themeMode:"light",tag:e.controls?.tag,target:e.controls?.target,selectedInstance:re,onSelectedInstanceChange:Ae,onHighlightInstance:Oo,onHtmlChange:t=>on("html",t)}):h("p",{role:Dn?"alert":"status",children:Dn||"Carregando propriedades\u2026"}),[pr,Wo]=M(100),mr=ge(null),Jo=O("div",{className:"govbr-playground__preview-area","data-reduced-motion":ye,style:{"--preview-zoom":pr/100},children:[O("header",{className:"govbr-playground__preview-header",children:[(!ie("viewport")&&!Un||!ie("dimensions")||L("fullscreen")&&!q("fullscreen"))&&O("div",{className:"govbr-playground__viewport-controls",children:[O("label",{children:["Zoom"," ",h(Pe,{"aria-label":"Zoom do preview",value:pr,onChange:t=>Wo(Number(t.target.value)),children:[50,75,100,125,150].map(t=>O(U,{value:t,children:[t,"%"]},t))})]}),!ie("viewport")&&!Un&&O("div",{className:"govbr-playground__viewport-buttons",role:"group","aria-label":"Tamanhos de viewport",children:[!ie("preview-title")&&h("strong",{children:"Viewport"}),rn.map((t,u)=>{let v=!Z&&t.id===Te.id,N=t.label.replace(/\s*\([^)]*\)\s*$/,"");return h(te,{iconOnly:!0,title:`${N} \u2014 ${Xn(t)}`,"aria-label":`${N}, ${Xn(t)}`,"aria-pressed":v,emphasis:v?"primary":"secondary",onClick:()=>{if(t.id===Xe&&!Z)return;let H=Yt.current?.getBoundingClientRect();Zt.current=H?{width:H.width,height:H.height}:null,ut.current?.cancel(),Be(null),Ct(t.id)},children:h("i",{className:`fas ${To(u)}`,"aria-hidden":"true"})},t.id)}),!ie("dimensions")&&h(te,{"aria-pressed":!!Z,onClick:t=>{let u=mr.current;if(!u)return;u.showPopover();let v=t.currentTarget.getBoundingClientRect();u.style.left=`${Math.max(8,Math.min(v.left,window.innerWidth-u.offsetWidth-8))}px`,u.style.top=`${Math.max(8,Math.min(v.bottom+8,window.innerHeight-u.offsetHeight-8))}px`},children:"Personalizado"})]}),!ie("dimensions")&&h("div",{ref:mr,popover:"auto",role:"dialog","aria-label":"Viewport personalizado",className:"govbr-playground__viewport-popover",children:O("fieldset",{className:"govbr-playground__custom-viewport",children:[h("legend",{children:Z?"Viewport personalizado":"Dimens\xF5es do viewport"}),O("div",{className:"govbr-playground__custom-size",children:[["width","height"].map(t=>O("label",{children:[t==="width"?"Largura":"Altura",h("input",{type:"number",min:1,max:1e4,step:1,"aria-label":`${t==="width"?"Largura":"Altura"} do viewport em pixels`,value:t==="width"?cn:un,onChange:u=>{let v=u.target.valueAsNumber;!Number.isInteger(v)||v<1||v>1e4||Be({width:cn,height:un,[t]:v})}}),h("span",{children:"px"})]},t)),h("button",{type:"button","aria-label":"Inverter largura e altura",title:"Inverter largura e altura",onClick:()=>Be({width:un,height:cn}),children:"\u21C4"}),Z&&h("button",{type:"button",onClick:()=>Be(null),children:"Restaurar preset"})]})]})})]}),O("div",{role:"group","aria-label":"A\xE7\xF5es do preview",className:"govbr-playground__preview-actions",children:[L("reset")&&!q("reset")&&Me("fas fa-sync-alt","Resetar exemplo para o padr\xE3o",an),So&&ur("Skeleton",He,"fa-bone","fa-bone",Mn),Po&&ur("Movimento reduzido",ye,"fa-walking","fa-running",Ln),L("fullscreen")&&!q("fullscreen")&&Me("fas fa-expand-arrows-alt","Tela cheia",rr)]})]}),O("div",{ref:Yt,role:"group","aria-label":"\xC1rea de preview","data-resizable":Lt,"data-fill-height":!Z,"data-resizing":Fn,style:{width:typeof Ue=="number"?Ue+(Lt?16:0):Ue,height:!Z&&Te.id==="desktop"?"100%":Rt+(Lt?16:0)},children:[O("div",{ref:Ao,className:"govbr-playground__preview",children:[O("output",{className:"govbr-playground__viewport-size","aria-label":"Tamanho atual do viewport",children:[Math.round(W),"x",Math.round(fe)]}),h("iframe",{ref:xe,title:e.ui?.title??"Pr\xE9via interativa",sandbox:`allow-scripts allow-forms${e.runtime.allowSameOrigin?" allow-same-origin":""}`,srcDoc:wo,onLoad:()=>{or(),ar(),xe.current?.contentWindow?.postMessage({type:"set-inspection",channel:K,enabled:G},"*")},style:{width:"100%",height:"100%",border:0,pointerEvents:Fn?"none":void 0}},w)]}),Lt&&["width","height"].map(t=>h("div",{className:`govbr-playground__resize govbr-playground__resize--${t}`,role:"separator",tabIndex:0,"aria-label":t==="width"?"Redimensionar largura do preview":"Redimensionar altura do preview",title:t==="width"?"Arraste para redimensionar a largura":"Arraste para redimensionar a altura","aria-orientation":t==="width"?"vertical":"horizontal","aria-valuemin":$t(t).min,"aria-valuemax":$t(t).max,"aria-valuenow":t==="width"?Z?.width??(typeof Ue=="number"?Ue:ue.current?.clientWidth??120):Rt,onPointerDown:u=>Fo(u,t),onPointerMove:zo,onPointerUp:dn,onPointerCancel:dn,onLostPointerCapture:dn,onKeyDown:u=>Uo(u,t)},t))]})]}),Ko=O("div",{className:"govbr-playground__tools",children:[O(st,{active:mt,onChange:t=>E(t),items:Mt.map(t=>({id:t,label:(t.startsWith("custom:")?en.find(u=>`custom:${u.id}`===t)?.label:void 0)??ao[t]})),children:[mt==="code"&&(ko||dr.length>0)&&O("header",{className:"govbr-playground__code-header",children:[L("history")&&!q("undo")&&Me("fas fa-undo","Desfazer",()=>nt(-1),!Io||b!=="html"),L("history")&&!q("redo")&&Me("fas fa-redo","Refazer",()=>nt(1),!jo||b!=="html"),L("format")&&!q("format")&&Me("fas fa-magic","Formatar",_o,b!=="html"),L("copy")&&!q("copy")&&Me("fas fa-copy",dt||(b==="html"?"Copiar HTML, JS e CSS":`Copiar ${b}`),()=>{er()}),L("reset")&&!q("reset")&&Me("fas fa-sync-alt","Resetar exemplo para o padr\xE3o",an),L("share")&&!q("share")&&Me("fas fa-share-alt","Compartilhar",$o),L("stackblitz")&&!q("stackblitz")&&e.onStackblitz&&Me("fas fa-bolt","Abrir no StackBlitz",()=>e.onStackblitz?.(i)),qn.map(t=>h(te,{type:"button",iconOnly:!0,"aria-label":t.label,title:t.label,onClick:()=>{t.onClick(Lo)},children:h("span",{"aria-hidden":"true",children:t.icon??h("i",{className:"fas fa-bolt"})})},t.id))]}),mt==="code"&&(L("editor")&&me.length>0||Fe.length>0)&&O("div",{className:"govbr-playground__editor",onKeyDownCapture:t=>{b!=="html"||!(t.target instanceof Element)||!t.target.closest(".cm-editor")||((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="z"?(t.preventDefault(),nt(t.shiftKey?1:-1)):(t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="y"&&(t.preventDefault(),nt(1)))},children:[k.length>0&&O("div",{role:"alert",className:"govbr-playground__source-errors",children:["\xDAltimo preview v\xE1lido preservado.",h("ul",{children:k.slice(0,5).map((t,u)=>O("li",{children:[t.message," Linha ",t.line,", coluna ",t.column,"."]},u))})]}),h(st,{label:"C\xF3digo-fonte",active:Bo,onChange:t=>{Ke.some(({id:u})=>u===t)?(oe("html"),f(t)):(oe(t),ce(0))},items:Do,children:b==="html"&&L("editor")&&me.length>0?h(co,{children:h(io,{fallback:h("div",{role:"status",children:"Carregando editor\u2026"}),children:h(wt,{sessionKey:g,sessions:je.current,id:`editor-${K}`,"aria-label":sr.label,language:sr.language,controlManifest:ct,themeMode:"light",value:Ro,editable:!0,readOnly:!1,onChange:t=>on(g,t),basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0}},g)})}):ft&&ze?h(st,{label:`Arquivos ${b}`,active:ze.filename,onChange:t=>ce(ft.files.findIndex(u=>u.filename===t)??0),items:ft.files.map(t=>({id:t.filename,label:t.filename})),children:h("section",{className:"govbr-playground__frameworks","aria-label":`C\xF3digo ${b}`,children:h(io,{fallback:h("div",{role:"status",children:"Carregando editor\u2026"}),children:h(wt,{sessionKey:`${b}-${ze.filename}`,sessions:je.current,"aria-label":`Snippet ${ze.filename}`,language:ze.language,themeMode:"light",value:ze.code,readOnly:!0,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!1}},`${b}-${ze.filename}`)})})}):null})]}),mt?.startsWith("custom:")&&en.find(t=>`custom:${t.id}`===mt)?.render()]}),_n&&h("div",{className:"govbr-playground__status",role:"status",children:_n})]}),qo=O("div",{className:"govbr-playground__diagnostics-content",children:[Wn==="console"&&L("console")&&O("div",{children:[O("div",{className:"govbr-playground__panel-toolbar",children:[O("label",{children:["Tipo de mensagem",O(Pe,{"aria-label":"Tipo de mensagem",value:Gt,onChange:t=>fo(t.target.value),children:[h(U,{value:"all",children:"Todos"}),h(U,{value:"log",children:"Logs"}),h(U,{value:"info",children:"Informa\xE7\xF5es"}),h(U,{value:"warn",children:"Avisos"}),h(U,{value:"error",children:"Erros"}),h(U,{value:"exception",children:"Exce\xE7\xF5es"}),h(U,{value:"unhandledrejection",children:"Promises rejeitadas"})]})]}),h(te,{iconOnly:!0,"aria-label":Ze?"Retomar console":"Pausar console",title:Ze?"Retomar console":"Pausar console","aria-pressed":Ze,onClick:()=>go(t=>!t),children:h("i",{className:Ze?"fas fa-play":"fas fa-pause","aria-hidden":"true"})}),h(te,{iconOnly:!0,"aria-label":"Copiar console",title:$n==="console"?"Console copiado!":"Copiar console",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(sn,null,2)).then(()=>Rn("console"))},children:h("i",{className:"fas fa-copy","aria-hidden":"true"})}),h(te,{iconOnly:!0,"aria-label":"Limpar console",title:"Limpar console",onClick:()=>Kt([]),children:h("i",{className:"fas fa-trash-alt","aria-hidden":"true"})})]}),h("ol",{children:sn.map(t=>O("li",{"data-type":t.method,children:[h("time",{children:Number.isFinite(t.occurredAt)?new Date(t.occurredAt).toLocaleTimeString():""})," ",h("strong",{children:t.method}),h($i,{item:t}),t.source&&O("small",{children:[t.source,":",t.line,":",t.column]})]},t.id))}),sn.length===0&&h("p",{children:"Nenhuma mensagem no console."})]}),Wn==="events"&&L("events")&&O("div",{children:[O("div",{className:"govbr-playground__panel-toolbar govbr-playground__events-toolbar",children:[O("label",{className:"govbr-playground__event-filter",children:[h("span",{children:"Filtrar eventos"}),h(at,{"aria-label":"Filtrar eventos",value:Xt,onChange:t=>ho(t.target.value)})]}),h(te,{iconOnly:!0,"aria-label":Qe?"Retomar eventos":"Pausar eventos",title:Qe?"Retomar eventos":"Pausar eventos","aria-pressed":Qe,onClick:()=>yo(t=>!t),children:h("i",{className:Qe?"fas fa-play":"fas fa-pause","aria-hidden":"true"})}),h(te,{iconOnly:!0,"aria-label":"Copiar eventos JSON",title:$n==="events"?"Eventos copiados!":"Copiar eventos JSON",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(ln,null,2)).then(()=>Rn("events"))},children:h("i",{className:"fas fa-copy","aria-hidden":"true"})}),h(te,{iconOnly:!0,"aria-label":"Limpar eventos",title:"Limpar eventos",onClick:()=>qt([]),children:h("i",{className:"fas fa-trash-alt","aria-hidden":"true"})})]}),h("ol",{children:ln.map(t=>O("li",{onPointerEnter:()=>xe.current?.contentWindow?.postMessage({type:"highlight-event",channel:K,targetKey:t.targetKey},"*"),onPointerLeave:()=>xe.current?.contentWindow?.postMessage({type:"highlight-event",channel:K,targetKey:null},"*"),children:[h("strong",{children:t.eventType})," \u2014 ",t.target," ",h("time",{children:Number.isFinite(t.occurredAt)?new Date(t.occurredAt).toLocaleTimeString():`${Math.round(t.timeStamp??0)} ms`}),O("details",{children:[h("summary",{children:"Detalhes do evento"}),h("pre",{children:JSON.stringify({detail:t.detail,currentTarget:t.currentTarget,composedPath:t.composedPath,bubbles:t.bubbles,composed:t.composed,cancelable:t.cancelable},null,2)})]})]},t.id))}),ln.length===0&&h("p",{children:"Nenhum evento registrado."})]})]}),Go=O(co,{children:[e.ui?.componentName&&h("h1",{className:"govbr-playground__component-title",children:e.ui.componentName}),h("div",{className:"govbr-playground__example-line",children:tt&&!ie("example")&&h(Or,{examples:tt.examples,selected:tt.examples.find(t=>t.id===r)??i,onSelect:t=>No(l,t.id)})}),O("div",{className:"govbr-playground__environment-line",children:[xo&&O(Pe,{"aria-label":"Tema r\xE1pido",value:Oe,onChange:t=>{let u=t.target.value;Jt(u)},children:[h(U,{value:"light",children:"Tema claro"}),h(U,{value:"dark",children:"Tema escuro"})]}),Eo&&O(Pe,{"aria-label":"Contraste r\xE1pido",value:we?"contrast":"main",onChange:t=>Nn(t.target.value==="contrast"),children:[h(U,{value:"main",children:"Modo principal"}),h(U,{value:"contrast",children:"Modo contraste"})]}),Co&&O("div",{className:"govbr-playground__environment-fields",role:"group","aria-label":"Idioma e dire\xE7\xE3o",children:[Jn&&h("div",{className:"govbr-playground__environment-field",children:h(Pe,{"aria-label":"Idioma",value:Ye,onChange:t=>An(t.target.value),children:Pt.map(t=>h(U,{value:t.value,children:t.label},t.value))})}),Kn&&h("div",{className:"govbr-playground__environment-field",children:O(Pe,{"aria-label":"Dire\xE7\xE3o do texto",value:De,onChange:t=>On(t.target.value),children:[h(U,{value:"ltr",children:"LTR"}),h(U,{value:"rtl",children:"RTL"})]})})]})]}),i.description&&h("p",{className:"govbr-playground__example-description",children:i.description}),i.details&&O("details",{className:"govbr-playground__example-details",children:[h("summary",{children:"Explica\xE7\xE3o detalhada"}),h("p",{children:i.details})]})]});return h(Nr,{value:ke.controls,children:O("section",{className:n,"data-theme":"light","data-presentation":y,"data-library":e.library?.profile??"wbc","data-has-tools":tn.length>0?"true":"false",children:[h(jr,{id:i.ui?.workspace&&i.id?`${e.runtime.id}:example:${i.id}`:e.runtime.id,header:Go,presentation:y,hiddenControls:ke?.controls,selectionRequest:j?String(j):void 0,initial:i.ui?.workspace??e.ui?.workspace,preview:Jo,code:Mt.length?Ko:void 0,properties:Vn&&!pt("controls")?Vo:void 0,diagnostics:Nt.length?qo:void 0,diagnosticItems:Nt.map(t=>({id:t,label:ao[t]})),onDiagnosticTabChange:z},e.runtime.id),h("span",{hidden:!0,children:vo})]})})}function Hi(e){let[n,o]=M(null),[a,l]=M("");return F(()=>{let c=!0,r=new AbortController;return l(""),yr(e.config,{signal:r.signal}).then(Zr).then(s=>{c&&o({original:e.config,config:s})}).catch(s=>{c&&l(String(s.message??s))}),()=>{c=!1,r.abort()}},[e.config]),a?h("p",{role:"alert",children:a}):!n||n.original!==e.config?h("p",{role:"status",children:"Formatando exemplos\u2026"}):h(Mr,{library:n.config.library,hiddenControls:n.config.ui?.hidden?.controls,children:h(ji,{...e,config:n.config})})}export{Sr as DEFAULT_LIBRARY,Wr as MAX_DECOMPRESSED_STATE_LENGTH,Vr as MAX_ENCODED_STATE_LENGTH,Jr as MAX_PLAYGROUND_STATES,vn as MAX_SOURCE_LENGTH,Hi as Playground,ya as buildPlaygroundShareUrl,oo as createPreviewDocument,qr as decodePlaygroundState,ha as encodePlaygroundState,Bt as encodePlaygroundStates,hn as ensureLibrary,Kr as getEncodedPlaygroundStates,Qo as hydratePlaygroundManifest,xn as isEncodedPlaygroundState,Ca as isPlaygroundConfig,pn as normalizePlaygroundManifest,Zo as preparePlaygroundExamples,ht as resolveLibrary,yr as resolvePlaygroundConfig};