@govbr-ds/playground 5.2.0 → 5.2.2

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.
Files changed (48) hide show
  1. package/dist/Playground.d.ts.map +1 -1
  2. package/dist/browser/chunks/babel-PXSNAHUX.js +16 -0
  3. package/dist/browser/chunks/chunk-6DHFEWGX.js +1 -0
  4. package/dist/browser/chunks/{chunk-JM73XHPL.js → chunk-7G6EEGZ4.js} +1 -1
  5. package/dist/{react/chunks/dist-AKMJXMTZ.js → browser/chunks/dist-H5E3DUQZ.js} +1 -1
  6. package/dist/browser/chunks/{dist-VIVGCYF5.js → dist-HT72W6BH.js} +1 -1
  7. package/dist/browser/chunks/{dist-KS4J6S7U.js → dist-MALZEIQI.js} +1 -1
  8. package/dist/browser/chunks/{esm-BWS4JPZG.js → esm-3ZNLC56K.js} +1 -1
  9. package/dist/browser/chunks/{esm-R75BP3LA.js → esm-6SLZNXJD.js} +1 -1
  10. package/dist/browser/chunks/estree-EALESNBX.js +44 -0
  11. package/dist/browser/chunks/html-C5MOHUJO.js +25 -0
  12. package/dist/browser/chunks/postcss-RXMLIASD.js +62 -0
  13. package/dist/browser/chunks/standalone-G7AM3SII.js +29 -0
  14. package/dist/browser/index.d.ts.map +1 -1
  15. package/dist/browser/index.js +24 -24
  16. package/dist/components/Workbench.d.ts.map +1 -1
  17. package/dist/core/index.d.ts +2 -3
  18. package/dist/core/index.d.ts.map +1 -1
  19. package/dist/library/profile.d.ts +1 -1
  20. package/dist/react/chunks/babel-PXSNAHUX.js +16 -0
  21. package/dist/react/chunks/chunk-6DHFEWGX.js +1 -0
  22. package/dist/{browser/chunks/dist-AKMJXMTZ.js → react/chunks/dist-H5E3DUQZ.js} +1 -1
  23. package/dist/react/chunks/{dist-VIVGCYF5.js → dist-HT72W6BH.js} +1 -1
  24. package/dist/react/chunks/{dist-KS4J6S7U.js → dist-MALZEIQI.js} +1 -1
  25. package/dist/react/chunks/{esm-R75BP3LA.js → esm-6SLZNXJD.js} +1 -1
  26. package/dist/react/chunks/{esm-WLDNKOOE.js → esm-YAO6K4CU.js} +1 -1
  27. package/dist/react/chunks/estree-EALESNBX.js +44 -0
  28. package/dist/react/chunks/html-C5MOHUJO.js +25 -0
  29. package/dist/react/chunks/postcss-RXMLIASD.js +62 -0
  30. package/dist/react/chunks/standalone-G7AM3SII.js +29 -0
  31. package/dist/react/index.js +25 -25
  32. package/dist/styles.css +80 -53
  33. package/dist/utils/previewLocale.d.ts +6 -6
  34. package/dist/utils/previewLocale.d.ts.map +1 -1
  35. package/docs/configuration.md +13 -13
  36. package/package.json +7 -7
  37. package/dist/browser/chunks/babel-TRTEHJWP.js +0 -16
  38. package/dist/browser/chunks/chunk-Y6SLVHK3.js +0 -1
  39. package/dist/browser/chunks/estree-UYKKTIFA.js +0 -44
  40. package/dist/browser/chunks/html-TM3VAO62.js +0 -25
  41. package/dist/browser/chunks/postcss-JAVHFEUM.js +0 -62
  42. package/dist/browser/chunks/standalone-IDMVEPER.js +0 -29
  43. package/dist/react/chunks/babel-TRTEHJWP.js +0 -16
  44. package/dist/react/chunks/chunk-Y6SLVHK3.js +0 -1
  45. package/dist/react/chunks/estree-UYKKTIFA.js +0 -44
  46. package/dist/react/chunks/html-TM3VAO62.js +0 -25
  47. package/dist/react/chunks/postcss-JAVHFEUM.js +0 -62
  48. package/dist/react/chunks/standalone-IDMVEPER.js +0 -29
@@ -1,11 +1,11 @@
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 Io,b as jo}from"./chunks/chunk-Y6SLVHK3.js";var Rr=Io((qi,Vt)=>{var Cn=(function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",o={};function l(r,s){if(!o[r]){o[r]={};for(var a=0;a<r.length;a++)o[r][r.charAt(a)]=a}return o[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 P=s.charCodeAt(c);a[c*2]=P>>>8,a[c*2+1]=P%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(P){f.push(e(P))}),u.decompress(f.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":u._compress(r,6,function(s){return i.charAt(s)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),u._decompress(r.length,32,function(s){return l(i,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,P={},v={},x="",k="",y="",E=2,_=3,T=2,b=[],m=0,g=0,j;for(j=0;j<r.length;j+=1)if(x=r.charAt(j),Object.prototype.hasOwnProperty.call(P,x)||(P[x]=_++,v[x]=!0),k=y+x,Object.prototype.hasOwnProperty.call(P,k))y=k;else{if(Object.prototype.hasOwnProperty.call(v,y)){if(y.charCodeAt(0)<256){for(c=0;c<T;c++)m=m<<1,g==s-1?(g=0,b.push(a(m)),m=0):g++;for(f=y.charCodeAt(0),c=0;c<8;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1}else{for(f=1,c=0;c<T;c++)m=m<<1|f,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=0;for(f=y.charCodeAt(0),c=0;c<16;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1}E--,E==0&&(E=Math.pow(2,T),T++),delete v[y]}else for(f=P[y],c=0;c<T;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1;E--,E==0&&(E=Math.pow(2,T),T++),P[k]=_++,y=String(x)}if(y!==""){if(Object.prototype.hasOwnProperty.call(v,y)){if(y.charCodeAt(0)<256){for(c=0;c<T;c++)m=m<<1,g==s-1?(g=0,b.push(a(m)),m=0):g++;for(f=y.charCodeAt(0),c=0;c<8;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1}else{for(f=1,c=0;c<T;c++)m=m<<1|f,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=0;for(f=y.charCodeAt(0),c=0;c<16;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1}E--,E==0&&(E=Math.pow(2,T),T++),delete v[y]}else for(f=P[y],c=0;c<T;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1;E--,E==0&&(E=Math.pow(2,T),T++)}for(f=2,c=0;c<T;c++)m=m<<1|f&1,g==s-1?(g=0,b.push(a(m)),m=0):g++,f=f>>1;for(;;)if(m=m<<1,g==s-1){b.push(a(m));break}else g++;return b.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,P=4,v=4,x=3,k="",y=[],E,_,T,b,m,g,j,S={val:a(0),position:s,index:1};for(E=0;E<3;E+=1)c[E]=E;for(T=0,m=Math.pow(2,2),g=1;g!=m;)b=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),T|=(b>0?1:0)*g,g<<=1;switch(f=T){case 0:for(T=0,m=Math.pow(2,8),g=1;g!=m;)b=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),T|=(b>0?1:0)*g,g<<=1;j=e(T);break;case 1:for(T=0,m=Math.pow(2,16),g=1;g!=m;)b=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),T|=(b>0?1:0)*g,g<<=1;j=e(T);break;case 2:return""}for(c[3]=j,_=j,y.push(j);;){if(S.index>r)return"";for(T=0,m=Math.pow(2,x),g=1;g!=m;)b=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),T|=(b>0?1:0)*g,g<<=1;switch(j=T){case 0:for(T=0,m=Math.pow(2,8),g=1;g!=m;)b=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),T|=(b>0?1:0)*g,g<<=1;c[v++]=e(T),j=v-1,P--;break;case 1:for(T=0,m=Math.pow(2,16),g=1;g!=m;)b=S.val&S.position,S.position>>=1,S.position==0&&(S.position=s,S.val=a(S.index++)),T|=(b>0?1:0)*g,g<<=1;c[v++]=e(T),j=v-1,P--;break;case 2:return y.join("")}if(P==0&&(P=Math.pow(2,x),x++),c[j])k=c[j];else if(j===v)k=_+_.charAt(0);else return null;y.push(k),c[v++]=_+k.charAt(0),P--,_=k,P==0&&(P=Math.pow(2,x),x++)}}};return u})();typeof define=="function"&&define.amd?define(function(){return Cn}):typeof Vt<"u"&&Vt!=null?Vt.exports=Cn:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return Cn})});function Ho(e){if(!e||!Array.isArray(e.examples))throw new Error("examples.json precisa de uma lista examples.");let n=new Map,i=new Set,o=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||i.has(f.id))throw new Error(`Exemplo sem id/label ou duplicado: ${f.id}`);i.add(f.id)}return c}).filter(r=>!r.hidden),l=new Set(o.map(r=>r.id)),u=(e.groups??[{id:"default",label:"Exemplos"}]).filter(r=>!r.hidden).map(r=>{let a=(r.examples??o.map(v=>v.id)).flatMap(v=>n.get(v)??[v]),c=a.find(v=>!i.has(v));if(c)throw new Error(`Grupo ${r.id}: exemplo desconhecido ${c}.`);let f=(r.defaultExample&&n.get(r.defaultExample)?.[0])??r.defaultExample,P=a.filter(v=>l.has(v));return{...r,examples:P,defaultExample:f&&P.includes(f)?f:P[0]}}).filter(r=>r.examples.length);return{...e,examples:o,groups:u}}async function yr(e,n={}){if(!("source"in e)||!e.source)return e;let i=n.fetch??globalThis.fetch,o=globalThis.document?.baseURI,l=n.baseUrl??e.runtime.baseUrl,u=l?new URL(l,o).href:o,r=(b,m=u)=>{let g=new URL(b,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,P=async(b,m=!1)=>{let g=await i(r(b,f),{signal:n.signal});if(!(m&&g.status===404)){if(!g.ok)throw new Error(`Falha ao carregar ${b}: HTTP ${g.status}`);if(!(m&&g.headers.get("content-type")?.includes("text/html")))return g.text()}},v=await i(c,{signal:n.signal});if(!v.ok)throw new Error(`Falha ao carregar ${c}: HTTP ${v.status}`);let x=Ho(await v.json());if(!x.examples.length||!x.groups?.length)throw new Error("O manifesto n\xE3o tem exemplos vis\xEDveis.");let k=await Promise.all(x.examples.map(async b=>{if(!b.source&&b.html===void 0&&b.code===void 0)throw new Error(`${b.id}: informe source ou html.`);let m=ee=>b.source?.replace(/\.html?(?=$|[?#])/i,ee),[g,j,S]=await Promise.all([b.html??b.code??P(b.source),b.css??b.styleCode??(b.style?P(b.style):m(".css")!==b.source&&m(".css")?P(m(".css"),!0):void 0),b.javascript??b.scriptCode??(b.script?P(b.script):m(".js")!==b.source&&m(".js")?P(m(".js"),!0):void 0)]);return{...b,html:g,css:j,javascript:S}})),y=x.groups.map(b=>({...b,examples:b.examples.map(m=>k.find(g=>g.id===m))})),E=a?x.examples.find(b=>b.source&&r(b.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?y.find(b=>b.examples.some(m=>m.id===E.id)):y[0];E&&(_.defaultExample=E.id);let T=_.examples.find(b=>b.id===_.defaultExample)??_.examples[0];return{...e,runtime:{...e.runtime,baseUrl:e.runtime.baseUrl??f},example:T,examples:[_,...y.filter(b=>b!==_)]}}var Do=new Set("html head body p li dt dd rt rp optgroup option colgroup thead tbody tfoot tr td th".split(" ")),Bo=new Set("area base br col embed hr img input link meta param source track wbr".split(" "));function vn(e,n,i){let o=e.slice(0,n).split(`
2
- `);return{message:i,from:n,line:o.length,column:o.at(-1).length+1}}function br(e){let n=[];for(let i=e.firstChild;i;i=i.nextSibling)n.push(i);return n}function dt(e){if(!e.trim())return{source:e,elements:[],issues:[]};let n=hr.parser.parse(e),i=[],o=[],l=new Map;n.iterate({enter(r){r.type.isError&&o.push(vn(e,r.from,"HTML incompleto ou malformado."))}});let u=(r,s)=>{if(r.name!=="Element"){br(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(),P=l.get(f)??0;l.set(f,P+1);let v=r.getChild("CloseTag"),x=e.slice(a.to-2,a.to)==="/>";!v&&!x&&!Bo.has(f)&&!Do.has(f)&&o.push(vn(e,a.from,`Feche o elemento <${f}>.`));let k=a.getChildren("Attribute").map(E=>{let _=E.getChild("AttributeName"),T=e.slice(_.from,_.to),b=E.getChild("AttributeValue"),m=b?e.slice(b.from,b.to):"",g=m[0]==='"'||m[0]==="'"?m[0]:"";return{name:T,from:E.from,to:E.to,valueFrom:b?b.from+(g?1:0):void 0,valueTo:b?b.to-(g?1:0):void 0,quote:g,raw:g?m.slice(1,-1):m,dynamic:/^(?:[:@*#]|\[|\(|v-|bind-)/.test(T)||/\{\{|\$\{/.test(m)||!g&&m.startsWith("{")}}),y={tag:f,index:P,id:k.find(E=>E.name==="id"&&!E.dynamic)?.raw,from:r.from,to:r.to,openEnd:x?a.to-2:a.to-1,contentFrom:a.to,contentTo:v?.from??a.to,attributes:k,children:[]};i.push(y),s?.children.push(y),br(r).filter(E=>E.name==="Element").forEach(E=>u(E,y))};return u(n.topNode),{source:e,elements:i,issues:o}}function Fo(e){return e.replace(/^\[\(|\[|\(|:|v-bind:|bind-/,"").replace(/\)\]$|\]$|\)$/,"").replace(/^attr\./,"").replace(/\.(?:prop|attr|camel)$/,"").toLowerCase()}function wn(e,n){return e.attributes.some(i=>Fo(i.name)===n.toLowerCase()&&i.dynamic)}function vr(e,n){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(n==="'"?/'/g:/"/g,n==="'"?"&#39;":"&quot;")}function wr(e,n,i,o){let l=dt(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(wn(u,i))throw new Error("Valor din\xE2mico: edi\xE7\xE3o visual indispon\xEDvel.");if(!/^[a-zA-Z_][\w.:-]*$/.test(i))throw new Error("Nome de atributo inv\xE1lido nos metadados.");let r=u.attributes.find(a=>a.name.toLowerCase()===i.toLowerCase());if(o===null||o===!1)return r?e.slice(0,r.from)+e.slice(r.to):e;if(r&&typeof o=="string"&&r.valueFrom!==void 0&&r.quote)return e.slice(0,r.valueFrom)+vr(o,r.quote)+e.slice(r.valueTo);let s=o===!0?i:`${i}="${vr(o,'"')}"`;return r?e.slice(0,r.from)+s+e.slice(r.to):e.slice(0,u.openEnd)+` ${s}`+e.slice(u.openEnd)}function ct(e,n="",i=""){let o=dt(e).issues.map(l=>({...l,message:`HTML: ${l.message}`}));for(let[l,u,r]of[["CSS",n,gr.parser],["JS",i,fr.parser]])r.parse(u).iterate({enter(s){s.type.isError&&o.push(vn(u,s.from,`${l}: sintaxe incompleta ou inv\xE1lida.`))}});return o}function xn(e,n,i,o){let l=dt(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=!i||i==="default"?u:u?.children.find(f=>f.attributes.some(P=>P.name==="slot"&&P.raw===i));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)+o+e.slice(r.contentTo),c=dt(a).issues;if(c.length)throw new Error(`HTML inv\xE1lido: ${c[0].message}`);return a}function Y(e,n){return n===!0||Array.isArray(n)&&n.includes(e)}import{useEffect as Ft,useRef as zt,useState as Et}from"react";import{createContext as Cr,createElement as Uo,cloneElement as Wo,isValidElement as Vo,useContext as $e,useEffect as ut,useId as Jo,useRef as Ue,useState as Sr,Children as kr}from"react";var Er={profile:"wbc",version:"2.7.0",fontAwesomeVersion:"6.7.2"};function vt(e=Er){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 i=e.version??(n==="wbc"?"2.7.0":void 0);if(!e.moduleUrl&&!i)throw new Error("Informe version ou moduleUrl para WBC v4.");let o=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/${o}@${i}/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 zo=globalThis,xr=zo.__govbrPlaygroundLibraries??=new WeakMap;function En(e){let n=vt(e),i=JSON.stringify(n),o=xr.get(document);if(o)return o.key===i?o.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 xr.set(document,{key:i,promise:l}),l}function Bt(e){let n=vt(e);return[...n.styles.map((i,o)=>({id:`library-style-${o}`,type:"style",href:i})),{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 Pr,jsx as Te,jsxs as Ko}from"react/jsx-runtime";var Ye=Cr(void 0),Tr=Ye.Provider,wt=Cr("wbc");function Mr({library:e,hiddenControls:n,children:i}){let[o,l]=Sr(!1),[u,r]=Sr("");return ut(()=>{let s=!0;return En(e).then(()=>{s&&l(!0)},a=>{s&&r(String(a.message??a))}),()=>{s=!1}},[e]),u?Te("p",{role:"alert",children:u}):o?Te(Ye.Provider,{value:n,children:Te(wt.Provider,{value:e?.profile??"wbc",children:i})}):Te("p",{role:"status",children:"Carregando componentes do Playground\u2026"})}function ve(e,n,i){return Uo(e,n,i)}function se({children:e,type:n="button",title:i,iconOnly:o=!1,emphasis:l=o?"secondary":void 0,...u}){let r=$e(Ye),s=$e(wt);if(Y(u["aria-label"]??(typeof e=="string"?e:""),r))return null;let a=ve("br-button",{...u,type:n,...l?{emphasis:l}:{},...i?{slot:"trigger",key:"trigger"}:{},density:s==="wbc"?"small":"compact",...o?s==="wbc"?{shape:"circle"}:{"icon-only":!0}:{}},e);return i?ve("br-tooltip",{position:"top"},[a,ve("span",{slot:"content",key:"content"},i)]):a}function fe({children:e,onChange:n,value:i,...o}){let l=$e(Ye),u=$e(wt),r=Ue(null);ut(()=>{let c=r.current;if(!c)return;c.value=i;let f=P=>n?.({target:c,currentTarget:c,nativeEvent:P});return c.addEventListener("change",f),()=>c.removeEventListener("change",f)},[n,i,l]);let s=kr.map(e,c=>{if(!Vo(c)||c.type!==B)return c;let f=Array.isArray(i)?i.map(String).includes(String(c.props.value)):String(i??"")===String(c.props.value??"");return Wo(c,{selected:f})});if(Y(o["aria-label"]??"",l))return null;let a=o["aria-label"]??"Selecionar";return ve("br-select",{...o,ref:r,value:i,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,...i}){let o=kr.toArray(e).filter(l=>typeof l=="string"||typeof l=="number").join("");return ve("br-select-option",{...i,value:n,label:o.trim()||String(n)},e)}function Xe({onChange:e,type:n,...i}){let o=$e(Ye),l=$e(wt),u=Ue(null);return ut(()=>{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,o]),Y(i["aria-label"]??"",o)?null:ve(n==="checkbox"?"br-checkbox":"br-input",{...i,ref:u,type:n,density:l==="wbc"?"small":"compact"},null)}function Nr({children:e,onChange:n,...i}){let o=$e(Ye),l=typeof customElements<"u"&&!!customElements.get("br-textarea"),u=Ue(null);return ut(()=>{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,o]),Y(i["aria-label"]??"",o)?null:l?ve("br-textarea",{...i,ref:u},e):Te("textarea",{...i,onChange:n,children:e})}function xt({id:e,label:n,checked:i,onChange:o}){let l=$e(Ye),u=$e(wt),r=Ue(null);return ut(()=>{let s=r.current;if(!s)return;let a=()=>o(!!s.checked);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[o,l]),Y(e,l)?null:ve("br-checkbox",{ref:r,label:n,checked:i,density:u==="wbc"?"small":"compact"},null)}function Ze({label:e="Ferramentas do playground",items:n,active:i,onChange:o,children:l}){let u=Ue(null),r=Ue(new Map),s=Jo().replaceAll(":",""),a=Ue(o),c=Ue(n);a.current=o,c.current=n;let f=typeof customElements<"u"&&!!customElements.get("br-tab"),P=JSON.stringify(n.map(v=>v.id));if(ut(()=>{if(!f||c.current.length<=1)return;let v=u.current;if(!v||!v)return;let x=E=>{E.stopPropagation(),c.current.some(_=>_.id===E.detail.tabId)&&a.current(E.detail.tabId)},k=E=>E.stopPropagation();v.addEventListener("brTabItemPropsChange",k),v.addEventListener("brTabChange",x),i&&v.setActiveTab(i);let y=requestAnimationFrame(()=>{i&&v.setActiveTab(i)});return()=>{cancelAnimationFrame(y),v.removeEventListener("brTabChange",x),v.removeEventListener("brTabItemPropsChange",k)}},[i,P,f]),n.length<=1)return Te(Pr,{children:l});if(!f){let v=n.find(k=>k.id===i)??n[0],x=(k,y)=>{let E;switch(k.key){case"ArrowRight":E=(y+1)%n.length;break;case"ArrowLeft":E=(y-1+n.length)%n.length;break;case"Home":E=0;break;case"End":E=n.length-1;break;default:return}k.preventDefault();let _=n[E];r.current.get(_.id)?.focus(),o(_.id)};return Ko(Pr,{children:[Te("div",{className:"govbr-playground__tool-tabs",role:"tablist","aria-label":e,children:n.map((k,y)=>Te("button",{ref:E=>{E?r.current.set(k.id,E):r.current.delete(k.id)},id:`${s}-tab-${y}`,type:"button",role:"tab","aria-label":k.label,"aria-controls":`${s}-panel`,"aria-selected":i===k.id,tabIndex:i===k.id?0:-1,title:k.iconOnly?k.label:void 0,onClick:()=>o(k.id),onKeyDown:E=>x(E,y),children:k.iconOnly?Te("i",{className:k.icon,"aria-hidden":"true"}):k.label},k.id))}),Te("div",{id:`${s}-panel`,role:"tabpanel","aria-labelledby":`${s}-tab-${n.indexOf(v)}`,tabIndex:0,children:l})]})}return ve("br-tab",{ref:u,"aria-label":e,label:e,density:"small",scrollable:!0},[...n.filter(v=>v.icon).map(v=>ve("i",{key:`icon-${v.id}`,slot:`icon-${v.id}`,className:v.icon,"aria-hidden":"true"},null)),...n.map(v=>ve("br-tab-item",{key:v.id,tabItemId:v.id,label:v.label,title:v.iconOnly?v.label:void 0,iconOnly:v.iconOnly},v.id===i?l:null))])}import{jsx as we,jsxs as Sn}from"react/jsx-runtime";var Ut={layout:"auto",split:60,stackedSplit:60,properties:!1,preset:"code",mobilePanel:"preview"};function qo(e,n){let i={...Ut,...n,layout:n?.layout&&["auto","horizontal","vertical"].includes(n.layout)?n.layout:Ut.layout,preset:n?.preset&&["visual","code","inspection"].includes(n.preset)?n.preset:Ut.preset,split:Number.isFinite(n?.split)?Math.max(20,Math.min(80,n.split)):n?.preset==="visual"?65:Ut.split,properties:n?.properties??(n?.preset==="visual"||n?.preset==="inspection")};try{let o=JSON.parse(localStorage.getItem(`playground-workbench:${e}`)??"null");return o?{layout:["auto","horizontal","vertical"].includes(o.layout)?o.layout:"auto",split:Number.isFinite(o.split)?Math.max(20,Math.min(80,o.split)):i.split,stackedSplit:Number.isFinite(o.stackedSplit)?Math.max(20,Math.min(80,o.stackedSplit)):60,properties:o.properties===!0,mobilePanel:["preview","code","properties"].includes(o.mobilePanel)?o.mobilePanel:"preview",preset:["visual","code","inspection","custom"].includes(o.preset)?o.preset:"code"}:i}catch{return i}}function Lr({id:e,header:n,preview:i,code:o,properties:l,diagnostics:u,diagnosticItems:r=[],onDiagnosticTabChange:s,selectionRequest:a,onCombinedPanelChange:c,initial:f,presentation:P="developer",hiddenControls:v}){let[x,k]=Et(()=>qo(e,f)),[y,E]=Et(0),[_,T]=Et("preview"),[b,m]=Et("properties"),g=zt(null),j=zt(null),S=zt(null),ee=zt(null),[Z,J]=Et(!1),te=y>=1600||y>=700&&(x.layout==="horizontal"||x.layout==="auto"&&y>=1100),F=!!(o||l||r.length)&&(y>=1600||!!(l&&te&&x.properties)),oe=P==="developer"&&(y<700||!te&&y<1100)&&!!(o||l||u||r.length),H=!!(l&&y<1600&&!te&&x.properties),ie=!!(o&&F),W=!!(o&&(oe||y<1600&&x.properties&&!ie)),ue=x.mobilePanel==="code"&&(!o||y>=1600||x.properties)||x.mobilePanel==="properties"&&(!l||H)?"preview":x.mobilePanel,he=M=>k(O=>({...O,mobilePanel:M})),Je=(M,O)=>M.some(D=>D.id===O)?O:M[0]?.id,pe=o?[{id:"code",label:"C\xF3digo-fonte"}]:[],Me=M=>M==="code",xe=[...pe,...l?[{id:"properties",label:"Propriedades"}]:[],...r],Ee=Je(xe,b),Ie=[...oe?[{id:"preview",label:"Preview"}]:[],...W?pe:[],...H?[{id:"properties",label:"Propriedades"}]:[],...F?[]:r],p=Je(Ie,_);Ft(()=>{a&&(k(M=>({...M,properties:!0,preset:"inspection"})),T("properties"),he("properties"))},[a]),Ft(()=>{try{localStorage.setItem(`playground-workbench:${e}`,JSON.stringify(x))}catch{}},[e,x]),Ft(()=>{let M=new ResizeObserver(([O])=>{let D=O.contentRect.width;E(D)});return g.current&&M.observe(g.current),()=>M.disconnect()},[]),Ft(()=>{c?.(oe||F||H||W)},[W,oe,c,H,F]);let C=H||W||!F&&r.length>0,le=M=>{let O=(M?ee:j).current?.getBoundingClientRect(),D=Math.max(1,(M?O?.height:O?.width)??1)-12,ye=M?160:240,je=M?180:280;return{min:Math.min(45,Math.max(20,ye/D*100)),max:Math.max(55,Math.min(80,100-je/D*100))}},I=(M,O)=>{let D=le(O);k(ye=>({...ye,[O?"stackedSplit":"split"]:Math.max(D.min,Math.min(D.max,M)),preset:"custom"}))},q=M=>Y("panels-resize",v)?null:we("div",{ref:M?void 0:S,className:M?"govbr-playground__stacked-divider":"govbr-playground__bench-divider",role:"separator",tabIndex:0,"aria-label":"Redimensionar preview e ferramentas","aria-orientation":M||!te?"horizontal":"vertical","aria-valuemin":20,"aria-valuemax":80,"aria-valuenow":Math.round(M?x.stackedSplit:x.split),onPointerDown:O=>{O.preventDefault(),O.currentTarget.focus(),O.currentTarget.setPointerCapture(O.pointerId),J(!0)},onPointerMove:O=>{if(!O.currentTarget.hasPointerCapture(O.pointerId))return;let D=(M?ee:j).current?.getBoundingClientRect();if(!D)return;let ye=M||!te,je=(ye?D.height:D.width)-12;je>0&&I(((ye?O.clientY-D.top:O.clientX-D.left)-6)/je*100,M)},onPointerUp:O=>{O.currentTarget.hasPointerCapture(O.pointerId)&&O.currentTarget.releasePointerCapture(O.pointerId),J(!1)},onLostPointerCapture:()=>J(!1),onPointerCancel:()=>J(!1),onDoubleClick:()=>I(60,M),onKeyDown:O=>{let D=M||!te,ye=D?"ArrowUp":"ArrowLeft";if(![ye,D?"ArrowDown":"ArrowRight","Home","End"].includes(O.key))return;O.preventDefault();let Ne=le(M),Tt=M?x.stackedSplit:x.split;I(O.key==="Home"?Ne.min:O.key==="End"?Ne.max:Tt+(O.key===ye?-1:1)*(O.shiftKey?10:2),M)}});return Sn("div",{ref:g,className:"govbr-playground__bench","data-resizing":Z,"data-presentation":P,children:[we("header",{className:"govbr-playground__bench-header",children:n}),we("nav",{hidden:Y("mobile-panels",v)||oe||(!o||W)&&(!l||H),className:"govbr-playground__mobile-panels","aria-label":"Painel da bancada",children:[["preview","Preview"],...o&&!W?[["code","C\xF3digo"]]:[],...l&&!H?[["properties","Propriedades"]]:[]].map(([M,O])=>we(se,{"aria-pressed":ue===M,onClick:()=>he(M),children:O},M))}),Sn("div",{ref:ee,className:"govbr-playground__workspace","data-stacked-tools":C,"data-tools-open":C,"data-mobile-tabs":oe,style:{"--stacked-split":`${x.stackedSplit}fr`,"--stacked-rest":`${100-x.stackedSplit}fr`},children:[!oe&&Sn("div",{ref:j,className:"govbr-playground__bench-main","data-layout":x.layout,"data-wide":y>=1600,"data-inspector-tabs":F,"data-only-preview":!o&&!F&&!l,"data-mobile-panel":ue,"data-properties":x.properties&&!!l&&!H,"data-has-code":!!(o&&!W&&!ie),style:{"--bench-split":`${x.split}fr`,"--bench-rest":`${100-x.split}fr`},children:[we("section",{className:"govbr-playground__bench-preview","aria-label":"Visualiza\xE7\xE3o",children:i}),(o&&!W&&!ie||F)&&q(!1),o&&!W&&!ie&&y<1600&&we("section",{className:"govbr-playground__bench-code","aria-label":"Edi\xE7\xE3o",children:o}),l&&!H||F&&xe.length>0?we("aside",{className:"govbr-playground__bench-properties","aria-label":"Inspetor de componentes",children:F?we(Ze,{label:"C\xF3digo-fonte, propriedades e ferramentas",active:Ee,onChange:M=>{m(M),!Me(M)&&M!=="properties"&&s?.(M)},items:xe,children:Me(Ee)?o:Ee==="properties"?l:u}):l}):null]}),C&&!oe&&q(!0),y<1600&&(oe||u||W||H)&&Ie.length>0&&we("div",{className:oe?"govbr-playground__diagnostics govbr-playground__diagnostics--mobile-tabs":"govbr-playground__diagnostics",children:Ie.length?we(Ze,{label:oe?"Preview, c\xF3digo-fonte, propriedades, console e eventos":"C\xF3digo-fonte, propriedades, console e eventos",active:p,onChange:M=>{T(M),!Me(M)&&M!=="properties"&&s?.(M)},items:Ie,children:p==="preview"?we("section",{className:"govbr-playground__bench-preview","aria-label":"Visualiza\xE7\xE3o",children:i}):Me(p)?o:p==="properties"?l:u}):null})]})]})}import{Suspense as Zr,useCallback as Kt,useEffect as z,useMemo as qt,useRef as Re,useState as N}from"react";import{lazy as Go,useMemo as Yo,useRef as Ar,useEffect as Xo}from"react";import{jsx as Or}from"react/jsx-runtime";function Zo(e,n,i){switch(e){case"html":return[i.html({extraTags:Object.fromEntries((n?.components??[]).map(o=>[o.tag,{attrs:Object.fromEntries(o.props.map(l=>[l.attribute,l.values?.length?l.values:null]))}]))})];case"css":return[i.css()];case"typescript":return[i.javascript({typescript:!0})];case"tsx":return[i.javascript({jsx:!0,typescript:!0})];case"javascript":case"jsx":return[i.javascript({jsx:e==="jsx"})];default:return[]}}var Qo=Go(async()=>{let[e,n,i,o,l]=await Promise.all([import("./chunks/esm-WLDNKOOE.js"),import("./chunks/esm-R75BP3LA.js"),import("./chunks/dist-KS4J6S7U.js"),import("./chunks/dist-AKMJXMTZ.js"),import("./chunks/dist-VIVGCYF5.js")]),u=e.default,r={html:i.html,css:o.css,javascript:l.javascript};function s({language:a,themeMode:c,controlManifest:f,readOnly:P=!1,editable:v=!0,sessions:x,sessionKey:k,...y}){let E=Ar(null),_=Ar(void 0),T=()=>{let g=E.current;if(!g?.dom.isConnected||!x||!k)return;let j=x.get(k),S=g.dom.getClientRects().length>0;x.set(k,{state:g.state,top:S?g.scrollDOM.scrollTop:j?.top??0,left:S?g.scrollDOM.scrollLeft:j?.left??0})};Xo(()=>()=>{T(),E.current?.scrollDOM.removeEventListener("scroll",T),_.current!==void 0&&cancelAnimationFrame(_.current)},[x,k]);let b=y["aria-label"]??`Editor de c\xF3digo ${a??"do exemplo"}`,m=Yo(()=>Zo(a,f,r),[a,f]);return Or(u,{...y,root:document,readOnly:P,editable:v&&!P,"aria-label":b,onUpdate:g=>{T(),y.onUpdate?.(g)},onCreateEditor:(g,j)=>{E.current=g,g.scrollDOM.addEventListener("scroll",T,{passive:!0});let S=k?x?.get(k):void 0;if(S){let ee=S.state.doc.toString(),Z=y.value??"",J=0,te=ee.length,F=Z.length;for(;J<te&&J<F&&ee[J]===Z[J];)J++;for(;te>J&&F>J&&ee[te-1]===Z[F-1];)te--,F--;g.setState(ee===Z?S.state:S.state.update({changes:{from:J,to:te,insert:Z.slice(J,F)}}).state),_.current=requestAnimationFrame(()=>{g.requestMeasure({read:()=>null,write:()=>{g.scrollDOM.scrollTop=S.top,g.scrollDOM.scrollLeft=S.left}})})}g.contentDOM.setAttribute("aria-label",b),y.onCreateEditor?.(g,j)},theme:c==="dark"?n.githubDark:n.githubLight,extensions:[...m,...y.extensions??[]]})}return{default:s}});function St(e){return Or(Qo,{...e})}import{Suspense as ei,useEffect as Wt,useMemo as Pn,useState as _e,useRef as ti}from"react";import{jsx as R,jsxs as X}from"react/jsx-runtime";function ni(e){let n=(e.type??"").split("|").map(i=>i.trim()).filter(i=>!["undefined","null",""].includes(i));return n.length&&n.every(i=>["boolean","true","false"].includes(i))?"checkbox":n.includes("number")&&n.includes("string")?"text":e.control}function $r(e){return new DOMParser().parseFromString(e||"","text/html")}function ri(e,n,i){let o=$r(e),l=new Set(n.map(s=>s.tag.toLowerCase())),u=Array.from(o.body.querySelectorAll("*")).filter(s=>l.has(s.localName)),r=u;if(i)try{u=u.filter(s=>s.matches(i))}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 P=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}`:""}${P?` \u2014 ${P}`:""}`}})}function oi(e,n){return n?Array.from(e.body.querySelectorAll(n.tag))[n.index]??null:null}function _r({manifest:e,html:n,tag:i,target:o,readOnly:l=!1,themeMode:u="light",hidden:r,selectedInstance:s,onSelectedInstanceChange:a,onHighlightInstance:c,onHtmlChange:f}){let[P,v]=_e(""),[x,k]=_e(""),[y,E]=_e(""),[_,T]=_e(""),[b,m]=_e(()=>new Set),g=ti({key:""}),j=Pn(()=>dt(n),[n]),S=s||P,ee=e.components??[],Z=Pn(()=>ri(n,ee,o),[n,ee,o]),J=Pn(()=>{let p=[],C=[];for(let le of Z){for(;C.length&&C[C.length-1].depth>=le.depth;)C.pop();let I={...le,children:[]};C.length?C[C.length-1].children.push(I):p.push(I),C.push(I)}return p},[Z]),te=Z.map(p=>`${p.tag}:${p.index}:${p.depth}`).join("|");Wt(()=>{m(new Set)},[te]);let F=p=>{let C=`${p.tag}:${p.index}`,le=C===S,I=()=>{v(C),a?.(C)};return R("li",{children:p.children.length?X("details",{open:!b.has(C),onToggle:q=>{q.stopPropagation();let M=q.currentTarget.open;m(O=>{if(O.has(C)===!M)return O;let D=new Set(O);return M?D.delete(C):D.add(C),D})},children:[R("summary",{className:`govbr-playground__component-tree-item${le?" is-selected":""}`,"aria-current":le?"true":void 0,onClick:I,onPointerEnter:()=>c?.(C),onPointerLeave:()=>c?.(null),onFocus:()=>c?.(C),onBlur:()=>c?.(null),children:p.label}),R("ul",{children:p.children.map(F)})]}):R("span",{className:`govbr-playground__component-tree-item${le?" is-selected":""}`,"aria-current":le?"true":void 0,tabIndex:0,onClick:I,onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),I())},onPointerEnter:()=>c?.(C),onPointerLeave:()=>c?.(null),onFocus:()=>c?.(C),onBlur:()=>c?.(null),children:p.label})},C)},H=(g.current.key===S&&g.current.id?Z.find(p=>p.id===g.current.id):void 0)??Z.find(p=>`${p.tag}:${p.index}`===S)??Z.find(p=>p.tag===i)??Z[0],ie=ee.find(p=>p.tag===H?.tag),W=p=>Y(p,r),ue=ie&&{...ie,props:W("props")?[]:ie.props.filter(p=>!W(`prop:${ie.tag}:${p.attribute}`)),slots:W("slots")?[]:ie.slots.filter(p=>!W(`slot:${ie.tag}:${p.name||"default"}`))},he=oi($r(n),H);if(Wt(()=>{if(H){let p=`${H.tag}:${H.index}`;v(p),g.current={key:p,id:H.id},s&&s!==p&&a?.(p)}else v("")},[H?.tag,H?.index,H?.id,s]),!H||!ue||!he)return R("p",{children:"Nenhum componente control\xE1vel encontrado neste exemplo."});let Je=j.elements.find(p=>p.tag===H.tag&&p.index===H.index),pe=l||j.issues.length>0,Me=p=>{if(!pe)try{f(p()),T("")}catch(C){T(C instanceof Error?C.message:String(C))}},xe=(p,C)=>Me(()=>wr(n,H,p.attribute,p.control==="checkbox"?C:String(C).trim()?String(C):null)),Ee=p=>p.control==="checkbox"?he.hasAttribute(p.attribute):he.getAttribute(p.attribute)??"",Ie=(p,C)=>Me(()=>xn(n,H,p,C));return X("section",{className:"govbr-playground__controls","aria-label":"Controles de propriedades e slots",children:[X("header",{children:[_&&R("p",{role:"alert",children:_}),pe&&R("p",{role:"status",children:"Fonte inv\xE1lida: modelo anterior preservado; corrija o c\xF3digo para editar propriedades."}),R("strong",{children:H.tag}),!W("tree")&&X("details",{open:!0,children:[R("summary",{children:"\xC1rvore de componentes"}),R("ul",{className:"govbr-playground__component-tree",children:J.map(F)})]})]}),!W("search")&&R(Xe,{"aria-label":"Buscar propriedade",placeholder:"Buscar propriedade",value:x,onChange:p=>k(p.target.value)}),!W("groups")&&ue.props.some(p=>p.group)&&X(fe,{"aria-label":"Grupo de propriedades",value:y,onChange:p=>E(p.target.value),children:[R(B,{value:"",children:"Todos os grupos"}),[...new Set(ue.props.map(p=>p.group).filter(Boolean))].map(p=>R(B,{value:p,children:p},p))]}),ue.props.length>0&&X("details",{open:!0,children:[R("summary",{children:"Props"}),X("table",{children:[R("thead",{children:X("tr",{children:[R("th",{children:"Propriedade"}),R("th",{children:"Descri\xE7\xE3o"}),R("th",{children:"Valor"})]})}),R("tbody",{children:[...ue.props].map(p=>({...p,control:ni(p)})).filter(p=>(!y||p.group===y)&&`${p.propertyName} ${p.attribute} ${p.description??""}`.toLocaleLowerCase().includes(x.toLocaleLowerCase())).sort((p,C)=>p.propertyName.localeCompare(C.propertyName)).map(p=>X("tr",{children:[R("th",{scope:"row",children:R("code",{children:p.propertyName})}),R("td",{children:p.description||"Sem descri\xE7\xE3o."}),X("td",{children:[R("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 ")}),R("div",{className:"govbr-playground__property-field",children:Je&&wn(Je,p.attribute)?R("p",{children:"Valor din\xE2mico / edi\xE7\xE3o visual indispon\xEDvel"}):p.control==="json"||/object|array|\[\]/i.test(p.type??"")?R(ii,{value:String(Ee(p)),disabled:pe,label:p.propertyName,onApply:C=>xe(p,C)}):p.control==="checkbox"?R(Xe,{type:"checkbox",disabled:pe,"aria-label":p.propertyName,checked:!!Ee(p),onChange:C=>xe(p,C.target.checked)}):p.control==="select"?X(fe,{disabled:pe,"aria-label":p.propertyName,value:String(Ee(p)),onChange:C=>xe(p,C.target.value),children:[X(B,{value:"",children:["(padr\xE3o",p.default?`: ${p.default}`:"",")"]}),(p.values??[]).map(C=>R(B,{value:C,children:C},C))]}):R(Xe,{type:p.control==="number"?"number":"text",disabled:pe,"aria-label":p.propertyName,placeholder:p.default,value:String(Ee(p)),onChange:C=>xe(p,C.target.value)})})]})]},p.attribute))})]})]}),ue.slots.length>0&&X("details",{children:[R("summary",{children:"Slots"}),ue.slots.map(p=>{let C=p.name==="default"||p.name===""?he:he.querySelector(`[slot="${CSS.escape(p.name)}"]`),le=C&&/\{\{|\$\{/.test(C.innerHTML),I=C?.innerHTML??"";return X("div",{className:"govbr-playground__control-field",children:[X("strong",{children:["Slot ",p.name||"padr\xE3o"]}),R("small",{children:p.description}),!C&&R("p",{children:"Slot ausente: adicione a composi\xE7\xE3o na aba HTML."}),le&&R("p",{children:"Conte\xFAdo din\xE2mico: edite na aba HTML."}),R(ai,{label:`Conte\xFAdo do slot ${p.name||"padr\xE3o"}`,language:"html",themeMode:u,readOnly:pe||!C||!!le,value:I,placeholder:"Digite o conte\xFAdo HTML do slot\u2026",onApply:q=>Ie(p.name,q),validate:q=>{xn(n,H,p.name,q)}},`${H.tag}:${H.index}:slot:${p.name}`)]},p.name)})]})]})}function ii({value:e,disabled:n,label:i,onApply:o}){let[l,u]=_e(e),[r,s]=_e("");return Wt(()=>{u(e),s("")},[e]),X("div",{children:[R(Nr,{disabled:n,"aria-label":`JSON de ${i}`,value:l,onChange:a=>u(a.target.value)}),R(se,{disabled:n,onClick:()=>{try{let a=JSON.parse(l);if(!a||typeof a!="object")throw new Error("Use um objeto ou array JSON.");o(JSON.stringify(a)),s("")}catch{s("Informe um objeto ou array JSON v\xE1lido.")}},children:"Aplicar JSON"}),r&&R("p",{role:"alert",children:r})]})}function ai({label:e,language:n,themeMode:i,readOnly:o,value:l,placeholder:u,onApply:r,validate:s}){let[a,c]=_e(l),[f,P]=_e("");return Wt(()=>{c(l),P("")},[l]),X("div",{className:"govbr-playground__inspector-code",children:[R(ei,{fallback:R("p",{role:"status",children:"Carregando editor\u2026"}),children:R(St,{"aria-label":e,language:n,themeMode:i,value:a,readOnly:o,editable:!o,onChange:c,placeholder:u,height:"auto",minHeight:"7rem",maxHeight:"18rem",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!o}})}),!o&&X(se,{disabled:a===l,onClick:()=>{try{s(a),r(a),P("")}catch(v){P(v instanceof Error?v.message:String(v))}},children:["Aplicar ",n==="css"?"CSS":"HTML"]}),f&&R("p",{role:"alert",children:f})]})}var Nn=jo(Rr(),1),Ir=256*1024,jr=1024*1024,kn=512*1024,Hr=32;function Tn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mn(e){if(!Tn(e)||typeof e.h!="string"||e.h.length>kn||typeof e.c!="string"||e.c.length>kn||e.j!==null&&typeof e.j!="string"||typeof e.j=="string"&&e.j.length>kn||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(!Tn(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(i=>typeof n[i]!="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 Dr(e){if(e.length===0||e.length>Hr||!e.every(Mn))return null;let n=e.length===1?e[0]:{p:e};try{let i=JSON.stringify(n);if(i.length>jr)return null;let o=Nn.default.compressToEncodedURIComponent(i);return o.length<=Ir?o:null}catch{return null}}function Br(e){return Tn(e)&&Array.isArray(e.p)?e.p.slice(0,Hr).filter(Mn):Mn(e)&&e.s?[e]:[]}function Fr(e){try{if(!e||e.length>Ir)return null;let n=o=>{if(!o||o.length>jr)return null;try{return JSON.parse(o)}catch{return null}},i=n(Nn.default.decompressFromEncodedURIComponent(e));if(i!==null)return i;if(typeof atob=="function"&&typeof TextDecoder<"u"){let o=atob(e),l=Uint8Array.from(o,r=>r.charCodeAt(0)),u=new TextDecoder().decode(l);return n(u)}return null}catch{return null}}function Ln(e,n){return`govbr-playground:${e}:${n??"default"}`}function An(e,n){if(typeof window>"u")return null;try{let i=window.localStorage.getItem(Ln(e,n));if(!i||i.length>524288)return null;let o=JSON.parse(i);return typeof o.html!="string"||typeof o.updatedAt!="number"||o.css!==void 0&&typeof o.css!="string"||o.javascript!==void 0&&typeof o.javascript!="string"?null:{html:o.html,css:o.css??"",javascript:o.javascript??"",id:o.id,updatedAt:o.updatedAt}}catch{return null}}function zr(e,n,i=n.id){if(typeof window>"u")return!1;try{let o={...n,css:n.css??"",javascript:n.javascript??"",updatedAt:Date.now()},l=JSON.stringify(o);return l.length>524288?!1:(window.localStorage.setItem(Ln(e,i),l),!0)}catch{return!1}}function Ur(e,n){try{window.localStorage.removeItem(Ln(e,n))}catch{}}function Qe(e){return{entries:[e],index:0}}function On(e,n,i=50){if(e.entries[e.index]===n)return e;let o=e.entries.slice(0,e.index+1);return o.push(n),o.length>i&&o.shift(),{entries:o,index:o.length-1}}function Wr(e,n){let i=e.index+n;return i<0||i>=e.entries.length?{changed:!1,history:e,value:e.entries[e.index]??""}:{changed:!0,history:{...e,index:i},value:e.entries[i]}}function si(){return Promise.all([import("./chunks/standalone-IDMVEPER.js"),import("./chunks/babel-TRTEHJWP.js"),import("./chunks/estree-UYKKTIFA.js"),import("./chunks/html-TM3VAO62.js"),import("./chunks/postcss-JAVHFEUM.js")])}var li;async function pt(e,n){if(!e.trim())return e;let[{format:i},...o]=await(li??=si()),l=o.map(u=>u.default||u).filter(Boolean);try{return await i(e,{parser:n,plugins:l,printWidth:n==="html"?40:80,htmlWhitespaceSensitivity:"ignore",bracketSameLine:!1,singleAttributePerLine:!0})}catch{return e}}async function Pt(e){let[n,i,o]=await Promise.all([pt(e.html,"html"),e.css===void 0?void 0:pt(e.css,"css"),e.javascript===void 0?void 0:pt(e.javascript,"babel")]);return{...e,html:n,css:i,javascript:o}}async function Vr(e){let[n,i]=await Promise.all([Pt(e.example),e.examples&&Promise.all(e.examples.map(async o=>({...o,examples:await Promise.all(o.examples.map(Pt))})))]);return{...e,example:n,examples:i}}var di=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(i=>i[0].toUpperCase()+i.slice(1)).join("")})),Jr=e=>e.replace(/(<\/?)([a-z][a-z0-9]*-[a-z0-9-]+)/gi,(n,i,o)=>`${i}${o.split("-").map(l=>l[0].toUpperCase()+l.slice(1)).join("")}`),Ct=(e,n)=>e.split(`
3
- `).map(i=>i?`${" ".repeat(n)}${i}`:"").join(`
4
- `);function ci(e,n){let i=n.map(l=>l.type==="style"?` <link rel="stylesheet" href="${l.href}">`:l.type==="inline-style"?` <style>
5
- ${Ct(l.content,6)}
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(`
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)}
6
6
  </style>`:"").filter(Boolean).join(`
7
- `),o=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
- ${Ct(l.content,6)}
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)}
9
9
  <\/script>`:"").filter(Boolean).join(`
10
10
  `);return`<!doctype html>
11
11
  <html lang="pt-BR">
@@ -13,17 +13,17 @@ ${Ct(l.content,6)}
13
13
  <meta charset="UTF-8" />
14
14
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
15
15
  <link rel="stylesheet" href="./index.css">
16
- ${i}
16
+ ${o}
17
17
  </head>
18
18
  <body>
19
- ${Ct(e.html,4)}
19
+ ${xt(e.html,4)}
20
20
 
21
- ${o}
21
+ ${i}
22
22
  <script type="module" src="./index.js"><\/script>
23
23
  </body>
24
- </html>`}function Kr(e,n={},i=[]){let l=di(e.html).map(({name:a})=>a),u=Jr(e.html).replace(/\sclass=/g," className=").replace(/\sfor=/g," htmlFor="),r=`<template>
25
- ${Ct(Jr(e.html),2)}
26
- </template>`,s={html:{files:[{filename:"index.html",language:"html",code:ci(e,i)},{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 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'
27
27
  ${l.length?`import { ${l.join(", ")} } from '${n.angular}'
28
28
  `:""}
29
29
  @Component({
@@ -37,7 +37,7 @@ export class AppComponent {}`}]}),n.react&&(s.react={files:[{filename:"App.tsx",
37
37
  `:""}export default function App() {
38
38
  return (
39
39
  <>
40
- ${Ct(u,6)}
40
+ ${xt(u,6)}
41
41
  </>
42
42
  )
43
43
  }`}]}),n.vue&&(s.vue={files:[{filename:"Example.vue",language:"html",code:`${l.length?`<script setup lang="ts">
@@ -46,20 +46,20 @@ import { ${l.join(", ")} } from '${n.vue}'
46
46
 
47
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',
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 qr(e){return e.files.map(({filename:n,language:i,code:o})=>`${i==="html"?`<!-- ${n} -->`:i==="css"?`/* ${n} */`:`// ${n}`}
50
- ${o}`).join(`
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(`
51
51
 
52
- `)}var kt=[{value:"pt-BR",lang:"pt-BR",label:"Portugu\xEAs (Brasil)"},{value:"en-US",lang:"en-US",label:"English (US)"}],Gr="pt-BR";function Yr(e){return kt.find(n=>n.value===e)??kt[0]}var We=e=>e.replace(/<\/(script)/gi,"<\\/$1"),Jt=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),ui=e=>Jt(e).replace(/>/g,"&gt;");function Xr(e,n){let i=vt(e.runtime.library??e.library),o=[...Bt(e.runtime.library??e.library),...e.runtime.resources??[]],l=new Set;for(let y of o){if(!y.id||l.has(y.id))throw new TypeError(`ID de recurso ausente ou duplicado: ${y.id}`);l.add(y.id)}let u=e.runtime.baseUrl?`<base href="${Jt(e.runtime.baseUrl)}">`:"",r=e.runtime.importMap?`<script type="importmap">${We(JSON.stringify({imports:e.runtime.importMap}))}<\/script>`:"",s=o.map(y=>y.type==="style"?`<link rel="stylesheet" href="${Jt(y.href)}"${y.integrity?` integrity="${Jt(y.integrity)}"`:""}${y.crossOrigin?` crossorigin="${y.crossOrigin}"`:""}>`:y.type==="inline-style"?`<style>${We(y.content)}</style>`:"").join(`
53
- `),a=o.flatMap(y=>y.type==="script"||y.type==="module"?[{type:y.type,src:y.src,integrity:y.integrity,crossOrigin:y.crossOrigin}]:y.type==="inline-script"?[{type:"script",content:y.content}]:y.type==="inline-module"?[{type:"module",content:y.content}]:[]),c=e.example.css?`<style data-playground-example>${We(e.example.css)}</style>`:"",f=`<style>${We(e.runtime.modeStyles??"")}
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??"")}
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 ${We(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>`,x=JSON.stringify([...new Set(["click","input","change","focus","blur","submit","reset","invalid","keydown",...e.runtime.eventTypes??[]])]),k=`<script>
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>
59
59
  (function () {
60
60
  const channel = ${JSON.stringify(n)};
61
61
  const parentOrigin = new URL(document.referrer).origin;
62
- const eventTypes = ${x};
62
+ const eventTypes = ${P};
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 @@ ${o}`).join(`
112
112
  window.addEventListener('scroll', paintSelection, true);
113
113
  window.addEventListener('resize', paintSelection);
114
114
 
115
- const inspectionTags = new Set(${We(JSON.stringify((e.controls?.manifest?.components??[]).map(y=>y.tag)))});
115
+ const inspectionTags = new Set(${De(JSON.stringify((e.controls?.manifest?.components??[]).map(b=>b.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 @@ ${o}`).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 = ${We(JSON.stringify(e.example.html))};
151
+ initialTemplate.innerHTML = ${De(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) {
@@ -244,7 +244,7 @@ ${o}`).join(`
244
244
  root.dataset.wbcReducedMotion = String(Boolean(mode.reducedMotion));
245
245
  walkElements(document, (element) => {
246
246
  if (element.localName.includes('-')) {
247
- if (${JSON.stringify(i.profile)} === 'wbc' && 'colorMode' in element) {
247
+ if (${JSON.stringify(o.profile)} === 'wbc' && 'colorMode' in element) {
248
248
  if (!originalColorModes.has(element)) originalColorModes.set(element, element.colorMode);
249
249
  element.colorMode = mode.theme === 'dark' ? 'dark' : originalColorModes.get(element);
250
250
  }
@@ -259,7 +259,7 @@ ${o}`).join(`
259
259
  content.setAttribute('aria-busy', mode.skeleton ? 'true' : 'false');
260
260
  syncBackground();
261
261
  }
262
- let managedHtmlSource = ${We(JSON.stringify(e.example.html))};
262
+ let managedHtmlSource = ${De(JSON.stringify(e.example.html))};
263
263
  function replaceManagedHtml(html) {
264
264
  if (html === managedHtmlSource) return;
265
265
  managedHtmlSource = html;
@@ -351,4 +351,4 @@ ${o}`).join(`
351
351
  syncBackground();
352
352
  parent.postMessage({ type: 'ready', channel }, parentOrigin);
353
353
  })();
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>${ui(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}${k}</body></html>`}function na(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 A}from"react/jsx-runtime";function pi(e){let n={};for(let i of e.split(";")){let o=i.indexOf(":");if(o<0)continue;let l=i.slice(0,o).trim().toLowerCase(),u=i.slice(o+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 mi(e){let[n,...i]=e;if(typeof n!="string"||!n.includes("%c"))return e.map(r=>typeof r=="string"?r:JSON.stringify(r)??String(r)).join(" ");let o=n.split("%c"),l=i.splice(0,o.length-1),u=o.map((r,s)=>h("span",{className:s===0?void 0:"govbr-playground__console-style",style:s>0&&typeof l[s-1]=="string"?pi(l[s-1]):void 0,children:r},`part-${s}`));return i.length&&u.push(A("span",{children:[" ",i.map(r=>typeof r=="string"?r:JSON.stringify(r)??String(r)).join(" ")]},"arguments")),u}function gi(e){let[n,...i]=e;if(typeof n!="string")return e.map(u=>typeof u=="string"?u:JSON.stringify(u)??String(u)).join(" ");let o=(n.match(/%c/g)??[]).length,l=i.splice(0,o);return[n.replace(/%c/g,""),...i.filter(u=>!l.includes(u)).map(u=>typeof u=="string"?u:JSON.stringify(u)??String(u))].join(" ").trim()}function fi({item:e}){let n=gi(e.args);return n.length<=280?h("div",{className:"govbr-playground__console-message",children:mi(e.args)}):A("details",{className:"govbr-playground__console-details",children:[A("summary",{children:[n.slice(0,280),"\u2026 ",h("span",{children:"Ver detalhes"})]}),h("pre",{children:n})]})}var Qr={code:"C\xF3digo-fonte",controls:"Propriedades",console:"Console",events:"Eventos"},et=[{id:"html",label:"HTML",language:"html"},{id:"javascript",label:"JS",language:"javascript"},{id:"css",label:"CSS",language:"css"}],eo=[{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}],$n=(e,n)=>{if(e.some(i=>!i)||new Set(e).size!==e.length)throw new TypeError(`IDs de ${n} ausentes ou duplicados`)},Gt=new Map;function hi(e){let n=e.examples?.find(o=>o.id===e.example.id)??e.examples?.[0],i=n?.examples.find(o=>o.id===n.defaultExample)??n?.examples[0];return{groupId:n?.id??e.example.id??"",exampleId:i?.id??e.example.id??"",example:i??e.example,groupViewport:n?.viewport}}function Ve(e){let n=e?.viewport,i={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 i[{phone:"mobile",iphone:"mobile",android:"mobile",ipad:"tablet"}[n.toLowerCase()]??n.toLowerCase()]??null;if(!n)return null;let o=n.width??n.x,l=n.height??n.y;return n.id&&i[n.id]?i[n.id]:!o&&!l?null:{id:n.id??`custom-${o??"auto"}-${l??"auto"}`,label:n.label??`${o??"100%"} \xD7 ${l??300}`,width:o??"100%",height:l??300}}function yi(e){let n={theme:"light",contrast:!1,skeleton:!1,reducedMotion:!1,locale:Gr,direction:"ltr"};try{let i=JSON.parse(window.localStorage.getItem(`govbr-playground-modes:${e}`)??"null");if(!i||typeof i!="object")return n;let o=kt.some(u=>u.value===i.locale)?i.locale:n.locale,l=i.direction==="ltr"||i.direction==="rtl"?i.direction:i.locale==="pt-BR-rtl"?"rtl":n.direction;return{theme:i.theme==="dark"?"dark":"light",contrast:i.theme!=="dark"&&!!i.contrast,skeleton:!!i.skeleton,reducedMotion:!!i.reducedMotion,locale:o,direction:l}}catch{return n}}function bi({config:e,className:n}){let i=Re(0),[o]=N(()=>hi(e)),[l,u]=N(o.groupId),[r,s]=N(o.exampleId),[a,c]=N(o.example),f=a.ui?.mode??e.ui?.mode??"developer",P=a.ui?.designer?.controls??e.ui?.designer?.controls??"examples",v=f==="designer"?P==="none"?"preview":"designer":"developer",[x,k]=N(()=>ct(o.example.html,o.example.css,o.example.javascript).length?{...o.example,html:"",css:"",javascript:""}:o.example),[y,E]=N(0),[_,T]=N(x);z(()=>{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 b=qt(()=>ct(a.html,a.css,a.javascript),[a.html,a.css,a.javascript]);z(()=>{b.length||T(a)},[a,b]);let[m,g]=N("html"),[j,S]=N("code"),[ee,Z]=N(!1),[J,te]=N("console"),[F,oe]=N(!1);z(()=>{v!=="developer"&&oe(!1)},[v]);let[H,ie]=N(""),[W,ue]=N(0),[he,Je]=N("adjustable"),[pe,Me]=N(180),[xe,Ee]=N(0),[Ie,p]=N(0),[C,le]=N(Number.isFinite(e.ui?.previewMaxHeight)?Math.max(180,Math.min(2e3,e.ui.previewMaxHeight)):600),[I,q]=N("html"),[M,O]=N(0),D=Re(new Map),[ye,je]=N(""),[Ne]=N(()=>yi(e.runtime.id)),[Tt,to]=N(null),[Mt,Nt]=N(()=>Ve(o.example)?.id??Ve({html:"",viewport:o.groupViewport})?.id??"desktop"),[Le,Yt]=N(Ne.theme),[Se,Xt]=N(Ne.contrast),[He,Zt]=N(Ne.skeleton),[De,Qt]=N(Ne.reducedMotion),[tt,Rn]=N(Ne.locale),[Ke,In]=N(Ne.direction),[jn,Lt]=N(""),[no,en]=N([]),[ro,tn]=N([]),[nt,oo]=N(!1),[nn,io]=N("all"),[rn,ao]=N(""),[rt,so]=N(!1),[Hn,Dn]=N(""),[Bn,Fn]=N(!1),zn=Re(null),[on,lo]=N(!1),Un=Re(!1),[mt,co]=N(e.controls?.manifest??null),[Wn,Vn]=N(""),Pe=Re(null),de=Re(null),At=Re(null),[be,gt]=N(null),[Jn,Kn]=N(!1),an=Re(null),me=Re({html:Qe(o.example.html),css:Qe(o.example.css??""),javascript:Qe(o.example.javascript??"")}),[uo,ot]=N(0);$n(e.ui?.actions?.map(t=>t.id)??[],"a\xE7\xF5es"),$n(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.");$n(t.examples.map(d=>d.id??""),`examples de ${t.id}`)}let K=qt(()=>globalThis.crypto?.randomUUID?.()??`pg-${Math.random().toString(36).slice(2)}`,[e.runtime.id]),po=qt(()=>Xr({...e,example:x},K),[e,x,K]),$=t=>e.features?.[t]!==!1,Ae={...e.ui?.hidden,...a.ui?.hidden},Q=t=>Y(t,Ae?.actions),ne=t=>Y(t,Ae?.controls),sn=Y("viewport",Ae?.viewports),ft=t=>Y(t,Ae?.tabs)?!0:t.startsWith("custom:")&&Y(t.slice(7),Ae?.tabs),ln=$("controls")&&!!(e.controls?.manifest||e.controls?.manifestUrl),dn=e.ui?.tabs??[],cn=["code",...ln?["controls"]:[],...$("console")?["console"]:[],...$("events")?["events"]:[],...dn.map(t=>`custom:${t.id}`)].filter(t=>!ft(t)),Ot=cn.filter(t=>["console","events"].includes(t)),qn=Ot.includes(J)?J:Ot[0],$t=cn.filter(t=>!["console","events"].includes(t)&&!(ee&&t==="controls")),it=$t.includes(j)?j:$t[0],ge=et.filter(t=>!ft(t.id)),un=he==="adjustable"&&$("resize")&&!ne("resize"),mo=$("theme")&&!ne("theme"),go=$("contrast")&&!ne("contrast"),at=$("skeleton")&&!ne("skeleton"),st=$("motion")&&!ne("motion"),_t=$("locale")&&!ne("locale"),Rt=$("locale")&&!ne("direction"),Gn=!ne("settings")&&(_t||Rt||at||st||!ne("viewport")&&!sn),Yn=(e.ui?.actions??[]).filter(t=>!Q(t.id)),fo=$("history")&&(!Q("undo")||!Q("redo"))||$("format")&&!Q("format")||$("copy")&&!Q("copy")||$("share")&&!Q("share")||$("reset")&&!Q("reset")||$("fullscreen")&&!Q("fullscreen")||$("stackblitz")&&!!e.onStackblitz&&!Q("stackblitz")||Yn.length>0,Be=e.examples?.find(t=>t.id===l),pn=Ve(a)??Ve({html:"",viewport:Be?.viewport}),Xn=(e.ui?.viewports??eo).filter(t=>!t.hidden&&!Y(t.id,Ae?.viewports)),mn=[...Xn,...Tt?[Tt]:[],...pn&&!Xn.some(t=>t.id===pn.id)?[pn]:[]],Ce=mn.find(t=>t.id===Mt)??mn[0]??eo[0],It=Ce.id==="shared"?Ce.width:e.ui?.previewWidth??Ce.width,Zn=Ce.id==="shared"?Ce.height:e.ui?.previewHeight??Ce.height,Qn=Yr(tt),Oe=e.ui?.stateId??Be?.id??e.example.id??e.runtime.id,er={theme:Le,contrast:Se,skeleton:He,reducedMotion:De,locale:tt,direction:Ke,width:be?.width??(typeof It=="number"||It==="100%"?It:Ce.width),height:be?.height??Zn};z(()=>{ge.length>0&&!ge.some(t=>t.id===m)&&g(ge[0].id)},[m,ge.map(t=>t.id).join("|")]);let tr=async(t,d)=>{let w=++i.current,L=e.examples?.find(re=>re.id===t),G=L?.examples.find(re=>re.id===d)??L?.examples.find(re=>re.id===L.defaultExample)??L?.examples[0];if(!L||!G)return;let U=$("drafts")?An(e.runtime.id,L.id):null,ze=U&&(!d||U.id===d)?L.examples.find(re=>re.id===U.id)??G:G,ce=U&&(!d||U.id===d)?{...ze,...U,id:ze.id}:ze,ae=await Pt(ce);if(w!==i.current)return;D.current.clear(),en([]),tn([]),u(L.id);let ke={...ae,id:ze.id??G.id??L.id};s(ke.id),ie(""),oe(!1);let V=Ve(ke)??Ve({html:"",viewport:L.viewport});V&&Nt(V.id),c(ke),ct(ke.html,ke.css,ke.javascript).length||k(ke);for(let re of et)me.current[re.id]=Qe(ke[re.id]??"");ot(re=>re+1)},gn=Kt((t,d)=>{i.current++,me.current[t]=On(me.current[t],d),c(w=>({...w,[t]:d})),ot(w=>w+1)},[]),ho=Kt(t=>{c(d=>{let w={...d,...t};for(let L of et)typeof t[L.id]=="string"&&(me.current[L.id]=On(me.current[L.id],t[L.id]));return w}),ot(d=>d+1)},[]),fn=()=>{i.current++,E(d=>d+1),D.current.clear();let t=Be?.examples.find(d=>d.id===r)??o.example;Ur(e.runtime.id,l),c(t),ct(t.html,t.css,t.javascript).length||k(t);for(let d of et)me.current[d.id]=Qe(t[d.id]??"");ot(d=>d+1)},lt=t=>{let d=Wr(me.current[m],t);d.changed&&(me.current[m]=d.history,c(w=>({...w,[m]:d.value})),ot(w=>w+1))};z(()=>je(""),[a.html,a.css,a.javascript,I]);let nr=async()=>{let t=jt[I]??jt.html;t&&(await navigator.clipboard.writeText(qr(t)),je("C\xF3digo copiado!"))},rr=async()=>{if(e.onShare){await e.onShare(a),Lt("Link compartilhado.");return}if(typeof window>"u")return;Gt.set(Oe,{h:a.html,j:a.javascript??null,c:a.css??"",s:Oe,exampleId:r,environment:er});let t=Dr(Array.from(Gt.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()),Lt("Link copiado.")},or=async()=>{let t=m==="html"?"html":m==="css"?"css":"babel",d=await pt(a[m]??"",t);gn(m,d)},yo=()=>{document.fullscreenElement===de.current?document.exitFullscreen?.():de.current?.requestFullscreen?.()},bo={toggleTheme:()=>Yt(t=>t==="light"?"dark":"light"),getCode:()=>a,setCode:ho,reset:()=>{$("reset")&&fn()},openFullscreen:()=>{$("fullscreen")&&yo()},undo:()=>{$("history")&&lt(-1)},redo:()=>{$("history")&&lt(1)},copyCode:()=>$("copy")?nr():Promise.resolve(),share:()=>$("share")?rr():Promise.resolve(),format:()=>$("format")?or():Promise.resolve(),openStackblitz:()=>{$("stackblitz")&&e.onStackblitz?.(a)}};z(()=>{if(b.length||(_.javascript??"")===(x.javascript??""))return;let t=window.setTimeout(()=>k(_),500);return()=>window.clearTimeout(t)},[_,x.javascript,b.length]),z(()=>{let t=new ResizeObserver(([d])=>{Ee(Math.round(d.contentRect.width)),p(Math.round(d.contentRect.height))});return At.current=t,de.current&&t.observe(de.current),()=>{t.disconnect(),At.current=null}},[]);let vo=Kt(t=>{At.current?.disconnect(),de.current=t,t&&At.current?.observe(t)},[]),ir=()=>{let t=Pe.current?.contentWindow;t&&(t.postMessage({type:"set-html",channel:K,html:_.html},"*"),t.postMessage({type:"set-css",channel:K,css:_.css??""},"*"))};z(()=>{Pe.current?.contentWindow?.postMessage({type:"set-inspection",channel:K,enabled:F},"*")},[F,K]),z(()=>{let[t,d]=H.split(":");t&&Number.isInteger(Number(d))&&Pe.current?.contentWindow?.postMessage({type:"select-element",channel:K,tag:t,index:Number(d)},"*")},[H,a.html,K]);let wo=Kt(t=>{let[d,w]=t?.split(":")??[],L=Number(w);Pe.current?.contentWindow?.postMessage({type:"highlight-element",channel:K,tag:d??"",index:Number.isInteger(L)?L:-1},"*")},[K]),ar=(()=>{let t=a.background;if(typeof t=="string")return t;if(!t)return;let d=t[Le];return typeof d=="string"?Se?t.contrast:d:d?.[Se?"contrast":"main"]??(Se?t.contrast:void 0)})(),sr=()=>{let t=Pe.current?.contentWindow;t&&t.postMessage({type:"set-mode",channel:K,mode:{theme:Le,background:ar,contrast:Se,skeleton:He,reducedMotion:De,lang:Qn.lang,dir:Ke}},"*")};z(()=>ir(),[_.html,_.css,K]),z(()=>sr(),[Le,Se,He,De,Qn,Ke,K,ar]),z(()=>{try{window.localStorage.setItem(`govbr-playground-modes:${e.runtime.id}`,JSON.stringify({theme:Le,contrast:Se,skeleton:He,reducedMotion:De,locale:tt,direction:Ke}))}catch{}},[e.runtime.id,Le,Se,He,De,tt,Ke,Mt]),z(()=>{if(Un.current)return;Un.current=!0;let t=o.example,d=o.groupId,w=o.exampleId,L=!1;if(typeof window<"u"){let U=new URLSearchParams(window.location.search).get("pg_state"),ze=U?Fr(U):null,ce=Br(ze).find(ae=>ae.s===Oe);if(ce){if(ce.environment){let V=ce.environment;Je("fixed"),Yt(V.theme),Xt(V.theme==="dark"?!1:V.contrast),Zt(V.skeleton),Qt(V.reducedMotion),Rn(V.locale),In(V.direction),to({id:"shared",label:"Cen\xE1rio compartilhado",width:V.width,height:V.height}),Nt("shared"),L=!0}t={...e.examples?.find(V=>V.id===d)?.examples.find(V=>V.id===ce.exampleId)??t,html:ce.h,css:ce.c,javascript:ce.j??"",id:ce.exampleId??t.id},w=ce.exampleId??w}else if($("drafts")){let ae=An(e.runtime.id,d);if(ae){let V=e.examples?.find(re=>re.id===d)?.examples.find(re=>re.id===ae.id);V&&(w=V.id??w??d),t={...V??t,...ae,id:V?.id??w??d}}}}let G=i.current;Pt(t).then(U=>{if(G!==i.current){Fn(!0);return}u(d),s(w),c(U),ct(U.html,U.css,U.javascript).length||k(U);let ze=e.examples?.find(ae=>ae.id===d),ce=Ve(U)??Ve({html:"",viewport:ze?.viewport});ce&&!L&&Nt(ce.id);for(let ae of et)me.current[ae.id]=Qe(U[ae.id]??"");ot(ae=>ae+1),Fn(!0)})},[e.runtime.id,e.ui?.stateId,e.example.id,o.example,o.groupId,o.exampleId,Oe]),z(()=>{!Bn||!$("drafts")||zr(e.runtime.id,{...a,id:r||l},l)},[e.runtime.id,l,r,a,Bn]),z(()=>{Gt.set(Oe,{h:a.html,j:a.javascript??null,c:a.css??"",s:Oe,exampleId:r,environment:er})},[Oe,a.html,a.css,a.javascript,r,Le,Se,He,De,tt,Ke,be,Mt,he,C,pe]),z(()=>()=>{Gt.delete(Oe)},[Oe]),z(()=>{if(mt||!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.");co(d),Vn("")}).catch(d=>{t.signal.aborted||Vn(d instanceof Error?d.message:String(d))}),()=>t.abort()},[mt,e.controls?.manifestUrl]),z(()=>{let t=d=>{if(d.source!==Pe.current?.contentWindow||d.origin!==(e.runtime.allowSameOrigin?window.location.origin:"null")||d.data?.channel!==K)return;let w=d.data.value;if(d.data.type==="preview-size"&&Number.isFinite(w)&&w>0&&w<=1e5&&Me(w),d.data.type==="inspect-element"&&w&&typeof w.tag=="string"&&/^[a-z][a-z0-9]*-[a-z0-9-]+$/.test(w.tag)&&Number.isInteger(w.index)&&w.index>=0&&w.index<=1e4&&(ie(`${w.tag}:${w.index}`),ue(L=>L+1)),d.data.type==="console"&&w&&typeof w=="object"){if(nt||typeof w.method!="string"||!Array.isArray(w.args))return;let L=w;en(G=>[...G.slice(-499),{...L,id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${G.length}`}])}if(d.data.type==="event"&&w&&typeof w=="object"){if(rt||typeof w.eventType!="string")return;let L=w;tn(G=>[...G.slice(-499),{...L,id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${G.length}`}])}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[K,nt,rt,e.runtime.allowSameOrigin]);let xo=()=>void or().catch(t=>Lt(t instanceof Error?t.message:String(t))),Eo=()=>void rr().catch(t=>Lt(t instanceof Error?t.message:String(t))),hn=no.filter(t=>nn==="all"||t.method===nn),yn=ro.filter(t=>!rn||t.eventType.toLowerCase().includes(rn.toLowerCase())),So=a[m]??"",lr=et.find(t=>t.id===m),Po=me.current[m].index>0,Co=me.current[m].index<me.current[m].entries.length-1,ht=qt(()=>Kr(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]),[dr,ko]=N(null);z(()=>{let t=!0;return Promise.all(Object.entries(ht).map(async([d,w])=>[d,{...w,files:await Promise.all(w.files.map(async L=>({...L,code:await pt(L.code,L.language==="html"?"html":L.language==="css"?"css":["typescript","tsx"].includes(L.language)?"babel-ts":"babel")})))}])).then(d=>{t&&ko({source:ht,value:Object.fromEntries(d)})}),()=>{t=!1}},[ht]);let jt=dr?.source===ht?dr.value:ht,cr=["html","angular","react","vue"].filter(t=>jt[t]?t==="html"||$("frameworks")&&!ft("frameworks")&&!ft(t):!1),qe=cr.filter(t=>t!=="html"),Ht=$("editor")&&ge.length>0;z(()=>{I==="html"&&!Ht&&qe.length?q(qe[0]):I!=="html"&&!qe.includes(I)&&q(Ht?"html":qe[0]??"html")},[I,Ht,qe.join("|")]);let yt=jt[I],Ge=yt?.files[Math.min(M,(yt?.files.length??1)-1)],To=[...Ht?ge.map(({id:t,label:d})=>({id:t,label:d})):[],...qe.map(t=>({id:t,label:t[0].toUpperCase()+t.slice(1)}))],Mo=I==="html"?m:I;z(()=>{I!=="html"||ge.some(({id:t})=>t===m)||ge.length&&g(ge[0].id)},[I,m,ge.map(({id:t})=>t).join("|")]),z(()=>{gt(null)},[Mt,l,r]);let Dt=t=>({min:t==="width"?120:100,max:t==="width"?Math.max(120,(de.current?.parentElement?.parentElement?.clientWidth??3840)-16):2160}),ur=(t,d)=>{let w=de.current;if(!w)return;let L=Dt(t),G=Math.round(Math.max(L.min,Math.min(L.max,d)));gt(U=>({width:U?.width??w.clientWidth,height:U?.height??w.parentElement.clientHeight,[t]:G}))},No=(t,d)=>{t.button!==0||!de.current||(t.preventDefault(),t.currentTarget.focus(),t.currentTarget.setPointerCapture(t.pointerId),an.current={axis:d,x:t.clientX,y:t.clientY,width:de.current.clientWidth,height:de.current.parentElement.clientHeight},Kn(!0))},Lo=t=>{let d=an.current;d&&ur(d.axis,d.axis==="width"?d.width+t.clientX-d.x:d.height+t.clientY-d.y)},bn=()=>{an.current=null,Kn(!1)},Ao=(t,d)=>{let w=d==="width"?"ArrowLeft":"ArrowUp";if(![w,d==="width"?"ArrowRight":"ArrowDown","Home","End"].includes(t.key))return;t.preventDefault();let G=Dt(d),U=de.current?.[d==="width"?"clientWidth":"clientHeight"]??G.min;ur(d,t.key==="Home"?G.min:t.key==="End"?G.max:U+(t.key===w?-1:1)*(t.shiftKey?50:10))},bt=be?.width??It,pr=be?.height??Zn,Fe=(t,d,w,L=!1)=>h(se,{type:"button",iconOnly:!0,emphasis:"secondary","aria-label":d,title:d,onClick:w,disabled:L,children:h("i",{className:t,"aria-hidden":"true"})}),mr=mt?h(_r,{manifest:mt,hidden:Ae?.inspector,html:b.length?_.html:a.html,readOnly:b.length>0,themeMode:"light",tag:e.controls?.tag,target:e.controls?.target,selectedInstance:H,onSelectedInstanceChange:ie,onHighlightInstance:wo,onHtmlChange:t=>gn("html",t)}):h("p",{role:Wn?"alert":"status",children:Wn||"Carregando propriedades\u2026"}),Oo=A("div",{className:"govbr-playground__preview-area",children:[A("header",{className:"govbr-playground__preview-header",children:[!ne("preview-title")&&h("strong",{children:"Visualiza\xE7\xE3o"}),!ne("dimensions")&&A("output",{"aria-label":"Dimens\xF5es efetivas",children:[xe," \xD7 ",Ie," px"]}),$("reset")&&!Q("reset")&&Fe("fas fa-sync-alt","Resetar exemplo para o padr\xE3o",fn)]}),A("div",{role:"group","aria-label":"\xC1rea de preview","data-resizable":un,"data-fill-height":!be,"data-resizing":Jn,style:{width:typeof bt=="number"?bt+(un?16:0):bt,height:!be&&Ce.id==="desktop"?"100%":pr},children:[h("div",{ref:vo,className:"govbr-playground__preview",children:h("iframe",{ref:Pe,title:e.ui?.title??"Pr\xE9via interativa",sandbox:`allow-scripts allow-forms${e.runtime.allowSameOrigin?" allow-same-origin":""}`,srcDoc:po,onLoad:()=>{ir(),sr(),Pe.current?.contentWindow?.postMessage({type:"set-inspection",channel:K,enabled:F},"*")},style:{width:"100%",height:"100%",border:0,pointerEvents:Jn?"none":void 0}},y)}),un&&["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":Dt(t).min,"aria-valuemax":Dt(t).max,"aria-valuenow":t==="width"?be?.width??(typeof bt=="number"?bt:de.current?.clientWidth??120):pr,onPointerDown:d=>No(d,t),onPointerMove:Lo,onPointerUp:bn,onPointerCancel:bn,onLostPointerCapture:bn,onKeyDown:d=>Ao(d,t)},t))]})]}),$o=A("div",{className:"govbr-playground__tools",children:[A(Ze,{active:it,onChange:t=>S(t),items:$t.map(t=>({id:t,label:(t.startsWith("custom:")?dn.find(d=>`custom:${d.id}`===t)?.label:void 0)??Qr[t]})),children:[it==="code"&&(fo||cr.length>0)&&A("header",{className:"govbr-playground__code-header",children:[$("history")&&!Q("undo")&&Fe("fas fa-undo","Desfazer",()=>lt(-1),!Po||I!=="html"),$("history")&&!Q("redo")&&Fe("fas fa-redo","Refazer",()=>lt(1),!Co||I!=="html"),$("format")&&!Q("format")&&Fe("fas fa-magic","Formatar",xo,I!=="html"),$("copy")&&!Q("copy")&&Fe("fas fa-copy",ye||(I==="html"?"Copiar HTML, JS e CSS":`Copiar ${I}`),()=>void nr()),$("reset")&&!Q("reset")&&Fe("fas fa-sync-alt","Resetar exemplo para o padr\xE3o",fn),$("share")&&!Q("share")&&Fe("fas fa-share-alt","Compartilhar",Eo),$("stackblitz")&&!Q("stackblitz")&&e.onStackblitz&&Fe("fas fa-bolt","Abrir no StackBlitz",()=>e.onStackblitz?.(a)),Yn.map(t=>h(se,{type:"button",iconOnly:!0,"aria-label":t.label,title:t.label,onClick:()=>void t.onClick(bo),children:h("span",{"aria-hidden":"true",children:t.icon??h("i",{className:"fas fa-bolt"})})},t.id))]}),it==="code"&&($("editor")&&ge.length>0||qe.length>0)&&A("div",{className:"govbr-playground__editor",onKeyDownCapture:t=>{I!=="html"||!(t.target instanceof Element)||!t.target.closest(".cm-editor")||((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="z"?(t.preventDefault(),lt(t.shiftKey?1:-1)):(t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="y"&&(t.preventDefault(),lt(1)))},children:[b.length>0&&A("div",{role:"alert",className:"govbr-playground__source-errors",children:["\xDAltimo preview v\xE1lido preservado.",h("ul",{children:b.slice(0,5).map((t,d)=>A("li",{children:[t.message," Linha ",t.line,", coluna ",t.column,"."]},d))})]}),h(Ze,{label:"C\xF3digo-fonte",active:Mo,onChange:t=>{et.some(({id:d})=>d===t)?(q("html"),g(t)):(q(t),O(0))},items:To,children:I==="html"&&$("editor")&&ge.length>0?h(_n,{children:h(Zr,{fallback:h("div",{role:"status",children:"Carregando editor\u2026"}),children:h(St,{sessionKey:m,sessions:D.current,id:`editor-${K}`,"aria-label":lr.label,language:lr.language,controlManifest:mt,themeMode:"light",value:So,editable:!0,readOnly:!1,onChange:t=>gn(m,t),basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0}},m)})}):yt&&Ge?h(Ze,{label:`Arquivos ${I}`,active:Ge.filename,onChange:t=>O(yt.files.findIndex(d=>d.filename===t)??0),items:yt.files.map(t=>({id:t.filename,label:t.filename})),children:h("section",{className:"govbr-playground__frameworks","aria-label":`C\xF3digo ${I}`,children:h(Zr,{fallback:h("div",{role:"status",children:"Carregando editor\u2026"}),children:h(St,{sessionKey:`${I}-${Ge.filename}`,sessions:D.current,"aria-label":`Snippet ${Ge.filename}`,language:Ge.language,themeMode:"light",value:Ge.code,readOnly:!0,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!1}},`${I}-${Ge.filename}`)})})}):null})]}),it==="controls"&&ln&&mr,it?.startsWith("custom:")&&dn.find(t=>`custom:${t.id}`===it)?.render()]}),jn&&h("div",{className:"govbr-playground__status",role:"status",children:jn})]}),_o=A("div",{className:"govbr-playground__diagnostics-content",children:[qn==="console"&&$("console")&&A("div",{children:[A("div",{className:"govbr-playground__panel-toolbar",children:[A("label",{children:["Tipo de mensagem",A(fe,{"aria-label":"Tipo de mensagem",value:nn,onChange:t=>io(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(se,{iconOnly:!0,"aria-label":nt?"Retomar console":"Pausar console",title:nt?"Retomar console":"Pausar console","aria-pressed":nt,onClick:()=>oo(t=>!t),children:h("i",{className:nt?"fas fa-play":"fas fa-pause","aria-hidden":"true"})}),h(se,{iconOnly:!0,"aria-label":"Copiar console",title:Hn==="console"?"Console copiado!":"Copiar console",onClick:()=>void navigator.clipboard.writeText(JSON.stringify(hn,null,2)).then(()=>Dn("console")),children:h("i",{className:"fas fa-copy","aria-hidden":"true"})}),h(se,{iconOnly:!0,"aria-label":"Limpar console",title:"Limpar console",onClick:()=>en([]),children:h("i",{className:"fas fa-trash-alt","aria-hidden":"true"})})]}),h("ol",{children:hn.map(t=>A("li",{"data-type":t.method,children:[h("time",{children:Number.isFinite(t.occurredAt)?new Date(t.occurredAt).toLocaleTimeString():""})," ",h("strong",{children:t.method}),h(fi,{item:t}),t.source&&A("small",{children:[t.source,":",t.line,":",t.column]})]},t.id))}),hn.length===0&&h("p",{children:"Nenhuma mensagem no console."})]}),qn==="events"&&$("events")&&A("div",{children:[A("div",{className:"govbr-playground__panel-toolbar govbr-playground__events-toolbar",children:[A("label",{className:"govbr-playground__event-filter",children:[h("span",{children:"Filtrar eventos"}),h(Xe,{"aria-label":"Filtrar eventos",value:rn,onChange:t=>ao(t.target.value)})]}),h(se,{iconOnly:!0,"aria-label":rt?"Retomar eventos":"Pausar eventos",title:rt?"Retomar eventos":"Pausar eventos","aria-pressed":rt,onClick:()=>so(t=>!t),children:h("i",{className:rt?"fas fa-play":"fas fa-pause","aria-hidden":"true"})}),h(se,{iconOnly:!0,"aria-label":"Copiar eventos JSON",title:Hn==="events"?"Eventos copiados!":"Copiar eventos JSON",onClick:()=>void navigator.clipboard.writeText(JSON.stringify(yn,null,2)).then(()=>Dn("events")),children:h("i",{className:"fas fa-copy","aria-hidden":"true"})}),h(se,{iconOnly:!0,"aria-label":"Limpar eventos",title:"Limpar eventos",onClick:()=>tn([]),children:h("i",{className:"fas fa-trash-alt","aria-hidden":"true"})})]}),h("ol",{children:yn.map(t=>A("li",{onPointerEnter:()=>Pe.current?.contentWindow?.postMessage({type:"highlight-event",channel:K,targetKey:t.targetKey},"*"),onPointerLeave:()=>Pe.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`}),A("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))}),yn.length===0&&h("p",{children:"Nenhum evento registrado."})]})]}),Ro=A(_n,{children:[e.ui?.componentName&&h("h1",{className:"govbr-playground__component-title",children:e.ui.componentName}),h("div",{className:"govbr-playground__example-line",children:Be&&A(_n,{children:[!ne("example")&&A("label",{children:["Exemplo",h(fe,{"aria-label":"Exemplo ou categoria",value:Be.examples.find(t=>t.id===r)?.category?.id??r,onChange:t=>{let d=Be.examples.find(w=>(w.category?.id??w.id)===t.target.value);d&&tr(l,d.id)},children:Be.examples.filter((t,d,w)=>!t.category||w.findIndex(L=>L.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&&!ne("example")&&!ne("category")&&h(fe,{"aria-label":"Item da categoria",value:r,onChange:t=>tr(l,t.target.value),children:Be.examples.filter(t=>t.category?.id===a.category?.id).map(t=>h(B,{value:t.id,children:t.label??t.id},t.id))})]})}),A("div",{className:"govbr-playground__settings-line",children:[Gn&&A(se,{className:"govbr-playground__settings-trigger",emphasis:"secondary","aria-expanded":on,"aria-haspopup":"dialog",onClick:t=>{let d=zn.current;if(!d)return;if(on){d.hidePopover();return}let w=t.currentTarget.getBoundingClientRect();d.style.top=`${w.bottom+12}px`,d.style.left=`${Math.max(12,Math.min(w.right-420,window.innerWidth-432))}px`,d.showPopover(),d.style.top=`${Math.max(12,Math.min(w.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 ${on?"fa-chevron-up":"fa-chevron-down"}`,"aria-hidden":"true"})]}),mo&&A(fe,{"aria-label":"Tema r\xE1pido",value:Le,onChange:t=>{let d=t.target.value;Yt(d),d==="dark"&&Xt(!1)},children:[h(B,{value:"light",children:"Tema claro"}),h(B,{value:"dark",children:"Tema escuro"})]}),go&&A(fe,{"aria-label":"Contraste r\xE1pido",value:Se?"contrast":"main",disabled:Le==="dark",onChange:t=>Xt(t.target.value==="contrast"),children:[h(B,{value:"main",children:"Modo principal"}),h(B,{value:"contrast",children:"Modo contraste"})]}),(at||st)&&A("span",{className:"govbr-playground__wide-behavior",children:[at&&h(xt,{id:"skeleton",label:"Skeleton",checked:He,onChange:Zt}),st&&h(xt,{id:"motion",label:"Movimento reduzido",checked:De,onChange:Qt})]}),Gn&&A("div",{ref:zn,popover:"auto",role:"dialog","aria-label":"Configura\xE7\xF5es do playground",className:"govbr-playground__settings",onToggle:t=>lo(t.newState==="open"),children:[(_t||Rt||!ne("viewport")&&!sn)&&h("h3",{children:"Ambiente"}),_t&&A("label",{className:"govbr-playground__setting-row",children:[h("span",{children:"Idioma"}),h(fe,{"aria-label":"Idioma",value:tt,onChange:t=>Rn(t.target.value),children:kt.map(t=>h(B,{value:t.value,children:t.label},t.value))})]}),Rt&&A("label",{className:"govbr-playground__setting-row",children:[h("span",{children:"Dire\xE7\xE3o"}),A(fe,{"aria-label":"Dire\xE7\xE3o do texto",value:Ke,onChange:t=>In(t.target.value),children:[h(B,{value:"ltr",children:"LTR"}),h(B,{value:"rtl",children:"RTL"})]})]}),!ne("viewport")&&!sn&&A("div",{className:"govbr-playground__settings-viewport",children:[A("label",{className:"govbr-playground__setting-row",children:[h("span",{children:"Viewport"}),A(fe,{"aria-label":"Viewport",value:be?"custom":Ce.id,onChange:t=>{t.target.value==="custom"?gt({width:de.current?.clientWidth??375,height:de.current?.clientHeight??Ce.height}):(gt(null),Nt(t.target.value))},children:[mn.map(t=>h(B,{value:t.id,children:t.label},t.id)),h(B,{value:"custom",children:"Viewport personalizado"})]})]}),be&&["width","height"].map(t=>A("label",{className:"govbr-playground__viewport-dimension",children:[t==="width"?"Largura":"Altura",h(Xe,{type:"number",min:1,max:1e4,step:1,"aria-label":`${t==="width"?"Largura":"Altura"} do viewport em pixels`,value:be[t],onChange:d=>{let w=d.target.valueAsNumber;Number.isInteger(w)&&w>=1&&w<=1e4&&gt(L=>L&&{...L,[t]:w})}}),h("span",{children:"px"})]},t))]}),(_t||Rt)&&(at||st)&&h("hr",{}),(at||st)&&A("div",{className:"govbr-playground__settings-behavior",children:[h("h3",{children:"Comportamento"}),A("span",{className:"govbr-playground__menu-behavior",children:[at&&h(xt,{id:"skeleton",label:"Skeleton",checked:He,onChange:Zt}),st&&h(xt,{id:"motion",label:"Movimento reduzido",checked:De,onChange:Qt})]})]})]})]}),a.description&&h("p",{className:"govbr-playground__example-description",children:a.description}),a.details&&A("details",{className:"govbr-playground__example-details",children:[h("summary",{children:"Explica\xE7\xE3o detalhada"}),h("p",{children:a.details})]})]});return h(Tr,{value:Ae.controls,children:A("section",{className:n,"data-theme":"light","data-presentation":v,"data-library":e.library?.profile??"wbc","data-has-tools":cn.length>0?"true":"false",children:[h(Lr,{id:e.runtime.id,header:Ro,presentation:v,hiddenControls:Ae?.controls,selectionRequest:W?String(W):void 0,onCombinedPanelChange:Z,initial:e.ui?.workspace,preview:Oo,code:$t.length?$o:void 0,properties:ln&&!ft("controls")?mr:void 0,diagnostics:Ot.length?_o:void 0,diagnosticItems:Ot.map(t=>({id:t,label:Qr[t]})),onDiagnosticTabChange:te},e.runtime.id),h("span",{hidden:!0,children:uo})]})})}function vi(e){let[n,i]=N(null),[o,l]=N("");return z(()=>{let u=!0,r=new AbortController;return l(""),yr(e.config,{signal:r.signal}).then(Vr).then(s=>{u&&i({original:e.config,config:s})}).catch(s=>{u&&l(String(s.message??s))}),()=>{u=!1,r.abort()}},[e.config]),o?h("p",{role:"alert",children:o}):!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(bi,{...e,config:n.config})})}export{Er as DEFAULT_LIBRARY,vi as Playground,Xr as createPreviewDocument,En as ensureLibrary,na as isPlaygroundConfig,Ho as normalizePlaygroundManifest,vt as resolveLibrary,yr as resolvePlaygroundConfig};
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};