"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../../../comma-separated-tokens@2.0.3/node_modules/comma-separated-tokens/index.cjs.js"),a=require("../../../../space-separated-tokens@2.0.2/node_modules/space-separated-tokens/index.cjs.js"),g=require("../../../../hast-util-parse-selector@4.0.0/node_modules/hast-util-parse-selector/lib/index.cjs.js"),A=require("../../../../property-information@7.1.0/node_modules/property-information/lib/find.cjs.js"),u=require("../../../../property-information@7.1.0/node_modules/property-information/lib/normalize.cjs.js");function N(r,e,n){const t=n?k(n):void 0;function i(o,f,...y){let s;if(o==null){s={type:"root",children:[]};const c=f;y.unshift(c)}else{s=g.parseSelector(o,e);const c=s.tagName.toLowerCase(),l=t?t.get(c):void 0;if(s.tagName=l||c,j(f))y.unshift(f);else for(const[h,b]of Object.entries(f))S(r,s.properties,h,b)}for(const c of y)d(s.children,c);return s.type==="element"&&s.tagName==="template"&&(s.content={type:"root",children:s.children},s.children=[]),s}return i}function j(r){if(r===null||typeof r!="object"||Array.isArray(r))return!0;if(typeof r.type!="string")return!1;const e=r,n=Object.keys(r);for(const t of n){const i=e[t];if(i&&typeof i=="object"){if(!Array.isArray(i))return!0;const o=i;for(const f of o)if(typeof f!="number"&&typeof f!="string")return!0}}return!!("children"in r&&Array.isArray(r.children))}function S(r,e,n,t){const i=A.find(r,n);let o;if(t!=null){if(typeof t=="number"){if(Number.isNaN(t))return;o=t}else typeof t=="boolean"?o=t:typeof t=="string"?i.spaceSeparated?o=a.parse(t):i.commaSeparated?o=p.parse(t):i.commaOrSpaceSeparated?o=a.parse(p.parse(t).join(" ")):o=m(i,i.property,t):Array.isArray(t)?o=[...t]:o=i.property==="style"?w(t):String(t);if(Array.isArray(o)){const f=[];for(const y of o)f.push(m(i,i.property,y));o=f}i.property==="className"&&Array.isArray(e.className)&&(o=e.className.concat(o)),e[i.property]=o}}function d(r,e){if(e!=null)if(typeof e=="number"||typeof e=="string")r.push({type:"text",value:String(e)});else if(Array.isArray(e))for(const n of e)d(r,n);else if(typeof e=="object"&&"type"in e)e.type==="root"?d(r,e.children):r.push(e);else throw new Error("Expected node, nodes, or string, got `"+e+"`")}function m(r,e,n){if(typeof n=="string"){if(r.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((r.boolean||r.overloadedBoolean)&&(n===""||u.normalize(n)===u.normalize(e)))return!0}return n}function w(r){const e=[];for(const[n,t]of Object.entries(r))e.push([n,t].join(": "));return e.join("; ")}function k(r){const e=new Map;for(const n of r)e.set(n.toLowerCase(),n);return e}exports.createH=N;
//# sourceMappingURL=create-h.cjs.js.map
