#!/usr/bin/env node
var ge=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),we=e=>{throw TypeError(e)};var se=(e,t,n)=>{if(t!=null){typeof t!="object"&&typeof t!="function"&&we("Object expected");var i,r;n&&(i=t[ge("asyncDispose")]),i===void 0&&(i=t[ge("dispose")],n&&(r=i)),typeof i!="function"&&we("Object not disposable"),r&&(i=function(){try{r.call(this)}catch(s){return Promise.reject(s)}}),e.push([n,i,t])}else n&&e.push([n]);return t},oe=(e,t,n)=>{var i=typeof SuppressedError=="function"?SuppressedError:function(a,o,l,u){return u=Error(l),u.name="SuppressedError",u.error=a,u.suppressed=o,u},r=a=>t=n?new i(a,t,"An error was suppressed during disposal"):(n=!0,a),s=a=>{for(;a=e.pop();)try{var o=a[1]&&a[1].call(a[2]);if(a[0])return Promise.resolve(o).then(s,l=>(r(l),s()))}catch(l){r(l)}if(n)throw t};return s()};import Ke from"mri";function R(e,t=process.argv.slice(2)){for(let[r,s]of t.entries())s==="-"&&(t[r]="__IO_DEFAULT_VALUE__");let n=Ke(t);for(let r in n){let s=n[r];r!=="_"&&Array.isArray(s)&&(s=s[s.length-1]),s==="__IO_DEFAULT_VALUE__"&&(s="-"),n[r]=s}let i={_:n._};for(let[r,{type:s,alias:a,default:o=s==="boolean"?!1:null}]of Object.entries(e)){if(i[r]=o,a){let l=a.slice(1);n[l]!==void 0&&(i[r]=be(n[l],s))}{let l=r.slice(2);n[l]!==void 0&&(i[r]=be(n[l],s))}}return i}function be(e,t){switch(t){case"string":return Y(e);case"boolean":return G(e);case"number":return K(e);case"boolean | string":return G(e)??Y(e);case"number | string":return K(e)??Y(e);case"boolean | number":return G(e)??K(e);case"boolean | number | string":return G(e)??K(e)??Y(e);default:throw new Error(`Unhandled type: ${t}`)}}function G(e){if(e===!0||e===!1)return e;if(e==="true")return!0;if(e==="false")return!1}function K(e){if(typeof e=="number")return e;{let t=Number(e);if(!Number.isNaN(t))return t}}function Y(e){return`${e}`}import Xe from"@parcel/watcher";import{compile as et,env as tt,Instrumentation as _e,optimize as nt,toSourceMap as Z}from"@tailwindcss/node";import{clearRequireCache as it}from"@tailwindcss/node/require-cache";import{Scanner as rt}from"@tailwindcss/oxide";import{existsSync as st}from"fs";import k from"fs/promises";import g from"path";var L=class{#e=new Set([]);queueMacrotask(t){let n=setTimeout(t,0);return this.add(()=>{clearTimeout(n)})}add(t){return this.#e.add(t),()=>{this.#e.delete(t),t()}}async dispose(){for(let t of this.#e)await t();this.#e.clear()}};import Je from"fs";import xe from"path";import{stripVTControlCharacters as Qe}from"util";import S from"picocolors";import ye from"enhanced-resolve";import Ye from"fs";import{createRequire as Ve}from"module";var qe=Ve(import.meta.url).resolve;function Se(e){if(typeof globalThis.__tw_resolve=="function"){let t=globalThis.__tw_resolve(e);if(t)return t}return qe(e)}var Pt=ye.ResolverFactory.createResolver({fileSystem:new ye.CachedInputFileSystem(Ye,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});function Ce(e){let t=typeof e=="number"?BigInt(e):e;return t<1000n?`${t}ns`:(t/=1000n,t<1000n?`${t}\xB5s`:(t/=1000n,t<1000n?`${t}ms`:(t/=1000n,t<60n?`${t}s`:(t/=60n,t<60n?`${t}m`:(t/=60n,t<24n?`${t}h`:(t/=24n,`${t}d`))))))}var V={indent:2};function q(){return`${S.italic(S.bold(S.blue("\u2248")))} tailwindcss ${S.blue(`v${He()}`)}`}function v(e){return`${S.dim(S.blue("`"))}${S.blue(e)}${S.dim(S.blue("`"))}`}function J(e,t=process.cwd(),{preferAbsoluteIfShorter:n=!0}={}){let i=xe.relative(t,e);return i.startsWith("..")||(i=`.${xe.sep}${i}`),n&&i.length>e.length?e:i}function ae(e,t){let n=e.split(" "),i=[],r="",s=0;for(let a of n){let o=Qe(a).length;s+o+1>t&&(i.push(r),r="",s=0),r+=(s?" ":"")+a,s+=o+(s?1:0)}return s&&i.push(r),i}function P(e){let t=Ce(e);return e<=50*1e6?S.green(t):e<=300*1e6?S.blue(t):e<=1e3*1e6?S.yellow(t):S.red(t)}function B(e,t=0){return`${" ".repeat(t+V.indent)}${e}`}function x(e=""){process.stderr.write(`${e}
`)}function Q(e=""){process.stdout.write(`${e}
`)}function He(){if(typeof globalThis.__tw_version=="string")return globalThis.__tw_version;let{version:e}=JSON.parse(Je.readFileSync(Se("tailwindcss/package.json"),"utf-8"));return e}import H from"fs/promises";import Ze from"path";function le(){return new Promise((e,t)=>{let n="";process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>e(n)),process.stdin.on("error",i=>t(i))})}async function ue(e,t){if(!await H.stat(e).then(i=>i.isCharacterDevice()||i.isFIFO()).catch(()=>!1))try{if(await H.readFile(e,"utf8")===t)return}catch{}await H.mkdir(Ze.dirname(e),{recursive:!0}),await H.writeFile(e,t,"utf8")}var Te=String.raw,c=tt.DEBUG;function N(){return{"--input":{type:"string",description:"Input file",alias:"-i"},"--output":{type:"string",description:"Output file",alias:"-o",default:"-"},"--watch":{type:"boolean | string",description:"Watch for changes and rebuild as needed, and use `always` to keep watching when stdin is closed",alias:"-w",values:["always"]},"--minify":{type:"boolean",description:"Optimize and minify the output",alias:"-m"},"--optimize":{type:"boolean",description:"Optimize the output without minifying"},"--cwd":{type:"string",description:"The current working directory",default:"."},"--map":{type:"boolean | string",description:"Generate a source map",default:!1},"--silent":{type:"boolean",description:"Suppress non-error output"}}}async function ce(e){try{return await e()}catch(t){x([Oe("Error:"),A("\u250C")].concat(`${t}`.split(`
`).map(n=>`${A("\u2502")} ${n}`)).concat(A("\u2514")).join(`
`)),process.exit(1)}}async function pe(e){var I=[];try{e["--silent"]||x(q());e["--silent"]||x();let t=se(I,new _e);c&&t.start("[@tailwindcss/cli] (initial build)");let n=g.resolve(e["--cwd"]);e["--output"]&&e["--output"]!=="-"&&(e["--output"]=g.resolve(n,e["--output"]));e["--input"]&&e["--input"]!=="-"&&(e["--input"]=g.resolve(n,e["--input"]),st(e["--input"])||(x(`Specified input file ${v(J(e["--input"]))} does not exist.`),process.exit(1)));e["--input"]===e["--output"]&&e["--input"]!=="-"&&(x(`Specified input file ${v(J(e["--input"]))} and output file ${v(J(e["--output"]))} are identical.`),process.exit(1));e["--map"]==="-"&&(x("Use --map without a value to inline the source map"),process.exit(1));e["--map"]&&e["--map"]!==!0&&(e["--map"]=g.resolve(n,e["--map"]));let i=process.hrtime.bigint();let r=e["--input"]?e["--input"]==="-"?await le():await k.readFile(e["--input"],"utf-8"):Te`
        @import 'tailwindcss';
      `;let s={css:"",optimizedCss:""};async function a(T,b,d,y){let C=T;if(d["--minify"]||d["--optimize"])if(T!==s.css){c&&y.start("Optimize CSS");let E=nt(T,{file:d["--input"]??"input.css",minify:d["--minify"]??!1,map:b?.raw??void 0});c&&y.end("Optimize CSS"),s.css=T,s.optimizedCss=E.code,E.map&&(b=Z(E.map)),C=E.code}else C=s.optimizedCss;if(b){if(d["--map"]===!0)C+=`
`,C+=b.inline;else if(typeof d["--map"]=="string"){let E=d["--output"]&&d["--output"]!=="-"?g.dirname(g.resolve(d["--output"])):process.cwd(),ee=g.resolve(d["--map"]),f=g.relative(E,ee);C+=`
`,C+=b.comment(f),c&&y.start("Write source map"),await ue(d["--map"],b.raw),c&&y.end("Write source map")}}c&&y.start("Write output"),d["--output"]&&d["--output"]!=="-"?await ue(d["--output"],C):Q(C),c&&y.end("Write output")}let o=e["--input"]&&e["--input"]!=="-"?g.resolve(e["--input"]):null;let l=o?g.dirname(o):process.cwd();let u=o?[o]:[];let w=u;async function m(T,b){c&&b.start("Setup compiler");let d=await et(T,{from:e["--output"]?o??"stdin.css":void 0,base:l,onDependency(E){u.push(E)}}),y=(d.root==="none"?[]:d.root===null?[{base:n,pattern:"**/*",negated:!1}]:[{...d.root,negated:!1}]).concat(d.sources);y.push({base:g.dirname(process.execPath),pattern:g.basename(process.execPath),negated:!0}),o!==null&&y.push({base:g.dirname(o),pattern:g.basename(o),negated:!1});let C=new rt({sources:y});return c&&b.end("Setup compiler"),[d,C]}let[p,h]=await ce(()=>m(r,t));if(e["--watch"]){let T=[];T.push(await Ee(await $e(h),async function b(d){try{var y=[];try{if(d.length===1&&d[0]===e["--output"])return;let f=se(y,new _e);c&&f.start("[@tailwindcss/cli] (watcher)");let M=process.hrtime.bigint();let W=[];let te="incremental";let he=u;for(let $ of d){if(he.includes($)){te="full";break}W.push({file:$,extension:g.extname($).slice(1)})}let ne="";let ie=null;if(te==="full"){let $=e["--input"]?e["--input"]==="-"?await le():await k.readFile(e["--input"],"utf-8"):Te`
                  @import 'tailwindcss';
                `;it(he),w=u.slice(),u=o?[o]:[],[p,h]=await m($,f),w=u.slice(),c&&f.start("Scan for candidates");let re=h.scan();c&&f.end("Scan for candidates"),c&&f.start("Setup new watchers");let We=await Ee(await $e(h),b);c&&f.end("Setup new watchers"),c&&f.start("Cleanup old watchers"),await Promise.all(T.splice(0).map(Ge=>Ge())),c&&f.end("Cleanup old watchers"),T.push(We),c&&f.start("Build CSS"),ne=p.build(re),c&&f.end("Build CSS"),e["--map"]&&(c&&f.start("Build Source Map"),ie=Z(p.buildSourceMap()),c&&f.end("Build Source Map"))}else if(te==="incremental"){c&&f.start("Scan for candidates");let $=h.scanFiles(W);if(c&&f.end("Scan for candidates"),$.length<=0){let re=process.hrtime.bigint();e["--silent"]||x(`Done in ${P(re-M)}`);return}c&&f.start("Build CSS"),ne=p.build($),c&&f.end("Build CSS"),e["--map"]&&(c&&f.start("Build Source Map"),ie=Z(p.buildSourceMap()),c&&f.end("Build Source Map"))}await a(ne,ie,e,f);let Me=process.hrtime.bigint();e["--silent"]||x(`Done in ${P(Me-M)}`)}catch(C){var E=C,ee=!0}finally{oe(y,E,ee)}}catch(f){u=w,x([Oe("Error:"),A("\u250C")].concat(`${f}`.split(`
`).map(W=>`${A("\u2502")} ${W}`)).concat(A("\u2514")).join(`
`));let M=process.hrtime.bigint();e["--silent"]||x(`Done in ${P(M-i)}`)}})),e["--watch"]!=="always"&&process.stdin.on("end",()=>{Promise.all(T.map(b=>b())).then(()=>process.exit(0),()=>process.exit(1))}),process.stdin.resume()}c&&t.start("Scan for candidates");let _=h.scan();c&&t.end("Scan for candidates");c&&t.start("Build CSS");let U=await ce(()=>p.build(_));c&&t.end("Build CSS");let z=null;e["--map"]&&(c&&t.start("Build Source Map"),z=await ce(()=>Z(p.buildSourceMap())),c&&t.end("Build Source Map"));await a(U,z,e,t);let D=process.hrtime.bigint();e["--silent"]||x(`Done in ${P(D-i)}`)}catch(ze){var De=ze,Ie=!0}finally{oe(I,De,Ie)}}async function Ee(e,t){e=e.sort((o,l)=>o.length-l.length);let n=[];for(let o=0;o<e.length;++o)for(let l=0;l<o;++l)e[o].startsWith(`${e[l]}/`)&&n.push(e[o]);e=e.filter(o=>!n.includes(o));let i=new L,r=new Set,s=new L;async function a(){await s.dispose(),s.queueMacrotask(()=>{t(Array.from(r)),r.clear()})}for(let o of e){let{unsubscribe:l}=await Xe.subscribe(o,async(u,w)=>{if(u){console.error(u);return}await Promise.all(w.map(async m=>{if(m.type==="delete"){r.add(m.path);return}let p=null;try{p=await k.lstat(m.path)}catch{}!p?.isFile()&&!p?.isSymbolicLink()||r.add(m.path)})),await a()});i.add(l)}return async()=>{await i.dispose(),await s.dispose()}}async function $e(e){let t=(await Promise.all(e.normalizedSources.map(async n=>{let i=g.resolve(n.base),r=await k.realpath(i).catch(()=>i);return k.stat(r).then(s=>s.isDirectory()?[r]:[]).catch(()=>[])}))).flat(1);return Array.from(new Set(t))}function A(e){return`\x1B[2m${e}\x1B[22m`}function Oe(e){return`\x1B[31m${e}\x1B[39m`}import{__unstable__loadDesignSystem as ve}from"@tailwindcss/node";import at from"fs/promises";import Ae from"path";import{createInterface as lt}from"readline";function de(e,t){let n=e.length,i=t.length,r=n<i?n:i;for(let s=0;s<r;s++){let a=e.charCodeAt(s),o=t.charCodeAt(s);if(a>=48&&a<=57&&o>=48&&o<=57){let l=s,u=s+1,w=s,m=s+1;for(a=e.charCodeAt(u);a>=48&&a<=57;)a=e.charCodeAt(++u);for(o=t.charCodeAt(m);o>=48&&o<=57;)o=t.charCodeAt(++m);let p=e.slice(l,u),h=t.slice(w,m),_=Number(p)-Number(h);if(_)return _;if(p<h)return-1;if(p>h)return 1;continue}if(a!==o)return a-o}return e.length-t.length}var X=new Uint8Array(256);function Re(e,t){let n=0,i=[],r=0,s=e.length,a=t.charCodeAt(0);for(let o=0;o<s;o++){let l=e.charCodeAt(o);if(n===0&&l===a){i.push(e.slice(r,o)),r=o+1;continue}switch(l){case 92:o+=1;break;case 39:case 34:for(;++o<s;){let u=e.charCodeAt(o);if(u===92){o+=1;continue}if(u===l)break}break;case 40:X[n]=41,n++;break;case 91:X[n]=93,n++;break;case 123:X[n]=125,n++;break;case 93:case 125:case 41:n>0&&l===X[n-1]&&n--;break}}return i.push(e.slice(r)),i}import O from"picocolors";function F({render:e=!0,invalid:t,usage:n,options:i}){let r=process.stdout.columns??80,s=[],a=e?Q:(o="")=>{s.push(o)};if(a(q()),t&&(a(),a(`${O.dim("Invalid command:")} ${t}`)),n&&n.length>0){a(),a(O.dim("Usage:"));for(let[o,l]of n.entries()){let u=l.slice(0,l.indexOf("[")),w=l.slice(l.indexOf("["));w=w.replace(/\[.*?\]/g,h=>O.dim(h));let p=ae(w,r-V.indent-u.length-1);p.length>1&&o!==0&&a(),a(B(`${u}${p.shift()}`));for(let h of p)a(B(h,u.length))}}if(i){let o=0;for(let{alias:m}of Object.values(i))m&&(o=Math.max(o,m.length));let l=[],u=0;for(let[m,{alias:p,values:h}]of Object.entries(i)){h?.length&&(m+=`[=${h.join(", ")}]`);let _=[p&&`${p.padStart(o)}`,p?m:" ".repeat(o+2)+m].filter(Boolean).join(", ");l.push(_),u=Math.max(u,_.length)}a(),a(O.dim("Options:"));let w=8;for(let{description:m,default:p=null}of Object.values(i)){let h=l.shift(),_=w+(u-h.length),U=2,z=r-h.length-_-U-V.indent,D=ae(p!==null?`${m} ${O.dim(`[default:\u202F${v(`${p}`)}]`)}`:m,z);a(B(`${O.blue(h)} ${O.dim(O.gray("\xB7")).repeat(_)} ${D.shift()}`));for(let I of D)a(B(`${" ".repeat(h.length+_+U)}${I}`))}}if(!e)return s.join(`
`)}var ut=String.raw;function fe(){return"tailwindcss canonicalize [classes...]"}function ct(){return"tailwindcss canonicalize --css input.css [classes...]"}function pt(){return"tailwindcss canonicalize --stream [--css input.css]"}function Le(){return{"--css":{type:"string",description:'CSS entry file used to load the Tailwind design system (defaults to `@import "tailwindcss";`)'},"--format":{type:"string",description:"Output format",default:"text",values:["text","json","jsonl"]},"--stream":{type:"boolean",description:"Read candidate groups from stdin line by line and write results to stdout",default:!1}}}var Pe={"--help":{type:"boolean",description:"Display usage information",alias:"-h",default:!1}};async function Be({argv:e=process.argv.slice(2),cwd:t=process.cwd(),stdin:n=null,stdinIsTTY:i=process.stdin.isTTY,stdoutIsTTY:r=process.stdout.isTTY}={}){try{let s=R({...Le(),...Pe},e),a=wt(s["--format"]??"text");if(r&&e.length===0||s["--help"])return{exitCode:0,stdout:ke()??"",stderr:""};if(s["--stream"])return await dt({css:s["--css"],cwd:t,format:a,input:process.stdin,output:process.stdout}),{exitCode:0,stdout:"",stderr:""};let o=s._.length>0?s._:await ft({stdin:n,stdinIsTTY:i});if(o.length===0)return bt("No candidate groups provided");let l=await ht({css:s["--css"],cwd:t,inputs:o});return{exitCode:0,stdout:gt(l,a),stderr:""}}catch(s){return{exitCode:1,stdout:"",stderr:s instanceof Error?s.message:String(s)}}}async function dt({css:e,cwd:t,format:n,input:i,output:r}){let s=await Fe(e,t),a=lt({input:i}),o=!0;n==="json"&&r.write("[");for await(let l of a){let u=je(s,l);switch(n){case"text":{r.write(u.output+`
`);break}case"jsonl":{r.write(JSON.stringify(u)+`
`);break}case"json":{o?r.write(`
`):r.write(`,
`),r.write(Ct(JSON.stringify(u,null,2),2)),o=!1;break}}}n==="json"&&r.write(o?"]":`
]`)}function ft({stdin:e,stdinIsTTY:t}){return e!==null?Promise.resolve(Ne(e)):t?Promise.resolve([]):mt().then(Ne)}async function mt(){return new Promise((e,t)=>{let n="";process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>e(n)),process.stdin.on("error",i=>t(i))})}async function ht({css:e,cwd:t=process.cwd(),inputs:n}){let i=await Fe(e,t);return n.map(r=>je(i,r))}function gt(e,t){switch(t){case"json":return JSON.stringify(e,null,2);case"jsonl":return e.map(n=>JSON.stringify(n)).join(`
`);case"text":return e.map(n=>n.output).join(`
`)}}function ke(){return F({render:!1,usage:[fe(),ct(),pt()],options:{...Le(),...Pe}})}async function Fe(e,t){if(e===null)return ve(ut`
        @import 'tailwindcss';
      `,{base:t});let n=Ae.resolve(t,e),i=await at.readFile(n,"utf8");return ve(i,{base:Ae.dirname(n)})}function Ne(e){return e.split(/\r?\n/g).map(t=>t.trim()).filter(t=>t.length>0)}function wt(e){if(e==="text"||e==="json"||e==="jsonl")return e;throw new Error(`Invalid value for --format: ${e}`)}function bt(e){return{exitCode:1,stdout:ke()??"",stderr:e}}function yt(e){let t=e.trim();return t.length===0?[]:Re(t," ").map(n=>n.trim()).filter(n=>n.length>0)}function St(e,t){let n=yt(t);return n=e.canonicalizeCandidates(n,{collapse:!0,logicalToPhysical:!0}),xt(e.getClassOrder(n)).join(" ")}function je(e,t){let n=St(e,t);return{input:t,output:n,changed:n!==t}}function Ct(e,t){let n=" ".repeat(t);return e.split(`
`).map(i=>n+i).join(`
`)}function xt(e){return e.slice().sort(([t,n],[i,r])=>n===r?de(t,i):n===null?-1:r===null?1:_t(n-r)||de(t,i)).map(([t])=>t)}function _t(e){return e>0n?1:e===0n?0:-1}var j={"--help":{type:"boolean",description:"Display usage information",alias:"-h"}};function me(e="tailwindcss"){return`${e} [--input input.css] [--output output.css] [--watch] [options\u2026]`}function Ue({invalid:e}={}){F({invalid:e,usage:[me("tailwindcss"),me("tailwindcss build"),fe()],commands:{build:"Build your CSS",canonicalize:"Canonicalize candidate lists"},options:{...N(),...j}})}async function Et(){let e=process.argv.slice(2),t=e[0],n=R({...N(),...j},e);if(t==="build"){let r=R({...N(),...j},e.slice(1));(process.stdout.isTTY&&e.length===1||r["--help"])&&(F({usage:[me("tailwindcss build")],options:{...N(),...j}}),process.exit(0)),await pe(r);return}if(t==="canonicalize"){let r=await Be({argv:e.slice(1)});r.stdout.length>0&&process.stdout.write(`${r.stdout}
`),r.stderr.length>0&&process.stderr.write(`${r.stderr}
`),process.exitCode=r.exitCode;return}(process.stdout.isTTY&&t===void 0||n["--help"])&&(Ue(),process.exit(0)),t&&!t.startsWith("-")&&(Ue({invalid:t}),process.exit(1));let i=R({...N(),...j});await pe(i)}await Et();
