@stacksjs/bun-router 0.1.7 → 0.1.8

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 (100) hide show
  1. package/dist/chunk-4wd1d6ay.js +416 -0
  2. package/dist/{chunk-nf3kv7kv.js → chunk-8rrs7556.js} +1 -1
  3. package/dist/{chunk-3y4gaz7v.js → chunk-m4aaj9ay.js} +1 -1
  4. package/dist/cli.js +30 -59
  5. package/dist/container/index.js +1 -1
  6. package/dist/index.js +2 -2
  7. package/package.json +9 -1
  8. package/dist/chunk-03m2j6h7.js +0 -2
  9. package/dist/chunk-08cw7ejr.js +0 -3
  10. package/dist/chunk-0e4g0fyv.js +0 -62
  11. package/dist/chunk-0mmn02yw.js +0 -2
  12. package/dist/chunk-126c9qm3.js +0 -2
  13. package/dist/chunk-12p13817.js +0 -2
  14. package/dist/chunk-14v65c37.js +0 -4
  15. package/dist/chunk-1b6a7t3v.js +0 -231
  16. package/dist/chunk-1wenkmk0.js +0 -2
  17. package/dist/chunk-2152npfd.js +0 -2
  18. package/dist/chunk-26w23krx.js +0 -2
  19. package/dist/chunk-2g8m379z.js +0 -10
  20. package/dist/chunk-2rr178et.js +0 -1654
  21. package/dist/chunk-2w8f3swz.js +0 -29
  22. package/dist/chunk-4r1x4afz.js +0 -12
  23. package/dist/chunk-4wyw66zk.js +0 -2
  24. package/dist/chunk-4z5sf8ag.js +0 -2
  25. package/dist/chunk-58tfvayh.js +0 -4
  26. package/dist/chunk-5be9x5cq.js +0 -3
  27. package/dist/chunk-5dp83qcx.js +0 -397
  28. package/dist/chunk-5f0d9j9a.js +0 -2
  29. package/dist/chunk-5z52b0fc.js +0 -28
  30. package/dist/chunk-5zrnk2kq.js +0 -4
  31. package/dist/chunk-6bbmkwng.js +0 -3
  32. package/dist/chunk-6dmqtdnq.js +0 -2
  33. package/dist/chunk-6e91956t.js +0 -3
  34. package/dist/chunk-6rv8w5jk.js +0 -2
  35. package/dist/chunk-6x1feysm.js +0 -3
  36. package/dist/chunk-7qnxdedn.js +0 -321
  37. package/dist/chunk-7y72hm1x.js +0 -2
  38. package/dist/chunk-8hbhfh6b.js +0 -194
  39. package/dist/chunk-8kfzygg5.js +0 -3
  40. package/dist/chunk-8wpj3fqe.js +0 -351
  41. package/dist/chunk-8wydx2we.js +0 -2
  42. package/dist/chunk-8zjnjvv7.js +0 -2
  43. package/dist/chunk-9805tt8n.js +0 -341
  44. package/dist/chunk-988h4bzr.js +0 -2
  45. package/dist/chunk-9b6a58ac.js +0 -2
  46. package/dist/chunk-a8fcaywb.js +0 -2
  47. package/dist/chunk-bfjwn7yg.js +0 -2
  48. package/dist/chunk-bp2522mm.js +0 -2
  49. package/dist/chunk-brpgjyqg.js +0 -3
  50. package/dist/chunk-bswe62q4.js +0 -48
  51. package/dist/chunk-c3v796c8.js +0 -943
  52. package/dist/chunk-ccqmwdry.js +0 -2
  53. package/dist/chunk-ck0crwnx.js +0 -2
  54. package/dist/chunk-cqgkxcb4.js +0 -2
  55. package/dist/chunk-dntnakjy.js +0 -2
  56. package/dist/chunk-dxg045wj.js +0 -5
  57. package/dist/chunk-e3qej0jr.js +0 -4
  58. package/dist/chunk-ettdpnrw.js +0 -60
  59. package/dist/chunk-ezqwq17j.js +0 -185
  60. package/dist/chunk-ezx3qsez.js +0 -2
  61. package/dist/chunk-f72nnjy4.js +0 -15413
  62. package/dist/chunk-fna5n0ey.js +0 -246
  63. package/dist/chunk-fqhckdt8.js +0 -2
  64. package/dist/chunk-fr6hbx25.js +0 -2
  65. package/dist/chunk-g9cwng6w.js +0 -3
  66. package/dist/chunk-gd3za5x0.js +0 -2
  67. package/dist/chunk-gf28608k.js +0 -2
  68. package/dist/chunk-h1dj6v8q.js +0 -3
  69. package/dist/chunk-hjxe7k2g.js +0 -2
  70. package/dist/chunk-hrkgznbn.js +0 -2
  71. package/dist/chunk-j6h5v0br.js +0 -2
  72. package/dist/chunk-kjtjbcq4.js +0 -71
  73. package/dist/chunk-mgb01qdv.js +0 -14
  74. package/dist/chunk-n24c9whp.js +0 -2
  75. package/dist/chunk-n2j24b0h.js +0 -4540
  76. package/dist/chunk-nhmtg01n.js +0 -84
  77. package/dist/chunk-p0qhpnqh.js +0 -70
  78. package/dist/chunk-p0w1x8y2.js +0 -3
  79. package/dist/chunk-p3dk1w2w.js +0 -216
  80. package/dist/chunk-q4e9pxs7.js +0 -3
  81. package/dist/chunk-q5dv1kyy.js +0 -2
  82. package/dist/chunk-qnqgf9tq.js +0 -2
  83. package/dist/chunk-qvwy1808.js +0 -898
  84. package/dist/chunk-r18f77vc.js +0 -12
  85. package/dist/chunk-r63za1mr.js +0 -2
  86. package/dist/chunk-rft8gw92.js +0 -7851
  87. package/dist/chunk-ryvmyskt.js +0 -4211
  88. package/dist/chunk-sa6mx308.js +0 -2
  89. package/dist/chunk-sw0chtw4.js +0 -4
  90. package/dist/chunk-va0pc7hx.js +0 -2
  91. package/dist/chunk-vcp8dnjq.js +0 -412
  92. package/dist/chunk-vg1erq1q.js +0 -2
  93. package/dist/chunk-vsh4390q.js +0 -358
  94. package/dist/chunk-w0jv49ch.js +0 -11
  95. package/dist/chunk-wm805tte.js +0 -35
  96. package/dist/chunk-xg9xscqz.js +0 -1
  97. package/dist/chunk-xj9h6mc9.js +0 -2
  98. package/dist/chunk-ytvzwrq3.js +0 -51
  99. package/dist/chunk-zde7ebc4.js +0 -288
  100. package/dist/chunk-zmqsv2xy.js +0 -2
@@ -1,943 +0,0 @@
1
- // @bun
2
- import{Zu as y}from"./chunk-nf3kv7kv.js";import{execFile as Kt,spawn as Gt}from"child_process";import{mkdtempSync as Qt,readFileSync as Yt,writeFileSync as Jt}from"fs";import{tmpdir as Xt}from"os";import{join as Ee}from"path";import{promisify as Zt}from"util";import{existsSync as Ye}from"fs";import{spawn as ie}from"child_process";import{createHash as rr}from"crypto";import{chmodSync as Q,copyFileSync as U,cpSync as nr,existsSync as Y,lstatSync as ir,mkdirSync as D,mkdtempSync as Se,readFileSync as ar,readdirSync as sr,rmSync as z,writeFileSync as O}from"fs";import{homedir as or,tmpdir as _e}from"os";import{basename as Ae,join as m}from"path";import{deflateRawSync as cr}from"zlib";import{EventEmitter as Vr}from"events";import{EventEmitter as Jr}from"events";import{createReadStream as Nt,createWriteStream as pi,existsSync as ct,mkdirSync as dt,readFileSync as De,statSync as Le,unlinkSync as N,writeFileSync as mi}from"fs";import{join as me,basename as lt,dirname as $e}from"path";import{execFileSync as C,spawn as re}from"child_process";import{createHash as ke}from"crypto";import{EventEmitter as gi}from"events";var Wt=Object.defineProperty,zt=(e)=>e;function jt(e,t){this[e]=zt.bind(null,t)}var wt=(e,t)=>{for(var r in t)Wt(e,r,{get:t[r],enumerable:!0,configurable:!0,set:jt.bind(t,r)})};function er(e){if(e){if(!Ye(e))throw Error(`Custom Craft binary path not found: ${e}`);return e}let t=typeof process<"u"?process.env.CRAFT_BIN:void 0;if(t){if(!Ye(t))throw Error(`CRAFT_BIN points to ${t}, which does not exist`);return t}return"craft"}function tr(e){return[`Craft native binary not found (tried "${e}").`,"","Craft ships through the pantry package registry. Install it with:",""," pantry install craft","","or, in a project, declare it in deps.yaml / pantry.jsonc and run"," pantry install","","See https://pantry.dev/quickstart for pantry installation instructions.","For monorepo development you can also point CRAFT_BIN at a local build."].join(`
3
- `)}var dr=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e})();function lr(e){let t=4294967295;for(let r=0;r<e.length;r++)t=dr[(t^e[r])&255]^t>>>8;return(t^4294967295)>>>0}function ur(e){let t=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1,r=e.getFullYear()-1980<<9|e.getMonth()+1<<5|e.getDate();return{time:t&65535,date:r&65535}}function fr(e){let{time:t,date:r}=ur(new Date),n=[],i=[],a=0;for(let l of e){let u=Buffer.from(l.name,"utf8"),f=cr(l.data,{level:9}),w=lr(l.data),p=Buffer.alloc(30);p.writeUInt32LE(67324752,0),p.writeUInt16LE(20,4),p.writeUInt16LE(0,6),p.writeUInt16LE(8,8),p.writeUInt16LE(t,10),p.writeUInt16LE(r,12),p.writeUInt32LE(w,14),p.writeUInt32LE(f.length,18),p.writeUInt32LE(l.data.length,22),p.writeUInt16LE(u.length,26),p.writeUInt16LE(0,28),n.push(p,u,f);let g=Buffer.alloc(46);g.writeUInt32LE(33639248,0),g.writeUInt16LE(20,4),g.writeUInt16LE(20,6),g.writeUInt16LE(0,8),g.writeUInt16LE(8,10),g.writeUInt16LE(t,12),g.writeUInt16LE(r,14),g.writeUInt32LE(w,16),g.writeUInt32LE(f.length,20),g.writeUInt32LE(l.data.length,24),g.writeUInt16LE(u.length,28),g.writeUInt16LE(0,30),g.writeUInt16LE(0,32),g.writeUInt16LE(0,34),g.writeUInt16LE(0,36),g.writeUInt32LE(0,38),g.writeUInt32LE(a,42),i.push(g,u),a+=p.length+u.length+f.length}let c=Buffer.concat(i),d=Buffer.alloc(22);return d.writeUInt32LE(101010256,0),d.writeUInt16LE(0,4),d.writeUInt16LE(0,6),d.writeUInt16LE(e.length,8),d.writeUInt16LE(e.length,10),d.writeUInt32LE(c.length,12),d.writeUInt32LE(a,16),d.writeUInt16LE(0,20),Buffer.concat([...n,c,d])}function hr(e,t,r,n){let i=`${r}${n}`.trim();return`${e} exited with code ${t}${i?`: ${i}`:""}`}async function wr(e){let t=[];if(!e.binaryPath||!Y(e.binaryPath))throw Error(`Binary not found: ${e.binaryPath}`);let r=e.platforms||[gt()],n=e.outDir||m(process.cwd(),"dist");if(!Y(n))D(n,{recursive:!0});for(let i of r)switch(i){case"macos":t.push(...await pr(e,n));break;case"windows":t.push(...await mr(e,n));break;case"linux":t.push(...await gr(e,n));break}return t}async function pr(e,t){let r=[],{name:n,version:i,bundleId:a=`com.myapp.${n.toLowerCase()}`}=e,c=e.macos||{},d=!c.appStore,l=m(t,`${n}.app`),u=kr({name:n,version:i,bundleId:a,buildNumber:c.buildNumber,category:c.category,minimumSystemVersion:c.minimumSystemVersion,menuBarOnly:c.menuBarOnly,binaryPath:e.binaryPath,iconPath:e.iconPath,provisioningProfile:c.provisioningProfile,additionalExecutables:c.additionalExecutables,outputPath:l});if(!u.success)return r.push({success:!1,platform:"macos",format:"app",error:u.error}),r;if(c.signIdentity){let f=await J("codesign",br({path:l,identity:c.signIdentity,entitlements:c.entitlements,hardenedRuntime:d}));if(!f.success)return r.push({success:!1,platform:"macos",format:"app",error:f.error}),r}else if(c.appStore)return r.push({success:!1,platform:"macos",format:"pkg",error:'App Store packaging requires macos.signIdentity (a "3rd Party Mac Developer Application" identity)'}),r;if(r.push({success:!0,platform:"macos",format:"app",outputPath:l}),c.dmg!==!1){let f=m(t,`${n}-${i}.dmg`),w=await Cr({appBundlePath:l,outputPath:f,volumeName:n});if(r.push({success:w.success,platform:"macos",format:"dmg",outputPath:w.outputPath,error:w.error}),w.success)r.push(...await Je(c,f,"dmg"))}if(c.pkg||c.appStore){let f=m(t,`${n}-${i}.pkg`),w=await $r({appBundlePath:l,outputPath:f,identifier:a,version:i,appStore:c.appStore===!0,installerIdentity:c.installerIdentity});if(r.push({success:w.success,platform:"macos",format:c.appStore?"pkg (app store)":"pkg",outputPath:w.outputPath,error:w.error}),w.success&&!c.appStore)r.push(...await Je(c,f,"pkg"))}return r}async function Je(e,t,r){if(!e.notarize)return[];if(!e.appleId||!e.applePassword||!e.teamId)return[{success:!1,platform:"macos",format:`${r} (notarize)`,error:"Notarization requires macos.appleId, macos.applePassword and macos.teamId"}];let n=await J("xcrun",xr({artifactPath:t,appleId:e.appleId,applePassword:e.applePassword,teamId:e.teamId}));if(!n.success)return[{success:!1,platform:"macos",format:`${r} (notarize)`,error:n.error}];let i=await J("xcrun",["stapler","staple",t]);return[{success:i.success,platform:"macos",format:`${r} (notarize)`,outputPath:i.success?t:void 0,error:i.success?void 0:i.error}]}async function mr(e,t){let r=[],{name:n,version:i}=e,a=e.windows||{};if(a.msi!==!1){let c=await Lr({name:n,version:i,binaryPath:e.binaryPath,outputPath:m(t,`${n}-${i}.msi`),manufacturer:e.author||"Unknown",architecture:a.architecture||Mr(process.arch),certificatePath:a.certificatePath,certificatePassword:a.certificatePassword});r.push({success:c.success,platform:"windows",format:"msi",outputPath:c.outputPath,error:c.error})}if(a.zip||a.msi===!1){let c=await Rr({name:n,version:i,binaryPath:e.binaryPath,outputPath:m(t,`${n}-${i}-windows.zip`)});r.push({success:c.success,platform:"windows",format:"zip",outputPath:c.outputPath,error:c.error})}return r}async function gr(e,t){let r=[],{name:n,version:i}=e,a=e.linux||{};if(a.deb!==!1){let c=await Fr({name:n,version:i,binaryPath:e.binaryPath,outputPath:m(t,`${n}_${i}_amd64.deb`),description:e.description||"",maintainer:e.author||"Unknown",dependencies:a.debDependencies||["libgtk-3-0","libwebkit2gtk-4.1-37"]});r.push({success:c.success,platform:"linux",format:"deb",outputPath:c.outputPath,error:c.error})}if(a.rpm){let c=await Ur({name:n,version:i,binaryPath:e.binaryPath,outputPath:m(t,`${n}-${i}-1.x86_64.rpm`),description:e.description||"",requires:a.rpmDependencies||["gtk3","webkit2gtk3"]});r.push({success:c.success,platform:"linux",format:"rpm",outputPath:c.outputPath,error:c.error})}if(a.appImage){let c=await Or({name:n,version:i,binaryPath:e.binaryPath,outputPath:m(t,`${n}-${i}-x86_64.AppImage`),iconPath:e.iconPath});r.push({success:c.success,platform:"linux",format:"appimage",outputPath:c.outputPath,error:c.error})}return r}function yr(e){let t=[["CFBundleExecutable",e.name],["CFBundleIdentifier",e.bundleId],["CFBundleName",e.name],["CFBundleShortVersionString",e.version],["CFBundleVersion",e.buildNumber||e.version],["CFBundlePackageType","APPL"],["NSHighResolutionCapable",!0]];if(e.iconName)t.push(["CFBundleIconFile",e.iconName]);if(e.category)t.push(["LSApplicationCategoryType",e.category]);if(e.minimumSystemVersion)t.push(["LSMinimumSystemVersion",e.minimumSystemVersion]);if(e.menuBarOnly)t.push(["LSUIElement",!0]);return`<?xml version="1.0" encoding="UTF-8"?>
4
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
5
- <plist version="1.0">
6
- <dict>
7
- ${t.map(([n,i])=>` <key>${W(n)}</key>
8
- ${i===!0?" <true/>":` <string>${W(i)}</string>`}`).join(`
9
- `)}
10
- </dict>
11
- </plist>`}function br(e){return["--force","--sign",e.identity,"--timestamp",...e.hardenedRuntime?["--options","runtime"]:[],...e.entitlements?["--entitlements",e.entitlements]:[],"--deep",e.path]}function vr(e){return["--component",e.appBundlePath,"/Applications","--sign",e.identity,e.outputPath]}function xr(e){return["notarytool","submit",e.artifactPath,"--apple-id",e.appleId,"--password",e.applePassword,"--team-id",e.teamId,"--wait"]}function kr(e){try{let{name:t,binaryPath:r,iconPath:n,provisioningProfile:i,additionalExecutables:a,outputPath:c}=e,d=m(c,"Contents"),l=m(d,"MacOS");D(l,{recursive:!0}),D(m(d,"Resources"),{recursive:!0}),U(r,m(l,t)),Q(m(l,t),493);for(let f of a||[]){if(!Y(f))return{success:!1,error:`Additional executable not found: ${f}`};let w=m(l,Ae(f));U(f,w),Q(w,493)}let u;if(n){if(!Y(n))return{success:!1,error:`Icon not found: ${n}`};u=Ae(n).replace(/\.icns$/i,""),U(n,m(d,"Resources",`${u}.icns`))}if(i){if(!Y(i))return{success:!1,error:`Provisioning profile not found: ${i}`};U(i,m(d,"embedded.provisionprofile"))}return O(m(d,"Info.plist"),yr({...e,iconName:u})),{success:!0}}catch(t){return{success:!1,error:t.message}}}var Sr=1048576;function pt(e){let t=ir(e);if(!t.isDirectory())return t.size;return sr(e).reduce((r,n)=>r+pt(m(e,n)),0)}function _r(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`DMG content size must be a non-negative safe integer: ${e}`);let t=Math.ceil(e/Sr);return Math.max(64,Math.ceil(t*1.25)+32)}function Ir(e,t){return["create","-volname",e.volumeName,"-srcfolder",e.appBundlePath,"-size",`${_r(t)}m`,"-ov","-format","ULMO",e.outputPath]}var mt=3;function Tr(e,t,r=mt){if(!Number.isInteger(t)||t<1||!Number.isInteger(r)||r<1)throw Error("hdiutil retry attempts must be positive integers");return t<r&&/(?:resource busy|resource temporarily unavailable)/i.test(e)}function J(e,t){return new Promise((r)=>{let n=ie(e,t),i="",a="";n.stdout?.on("data",(c)=>{i+=c.toString()}),n.stderr?.on("data",(c)=>{a+=c.toString()}),n.on("close",(c)=>{if(c===0)r({success:!0});else r({success:!1,error:hr(e,c,i,a)})}),n.on("error",(c)=>r({success:!1,error:c.message}))})}var Pr=(e)=>J("hdiutil",e);async function Cr(e){if(!/^[^/:\n]{1,27}$/.test(e.volumeName))return{success:!1,error:`Invalid DMG volume name "${e.volumeName}"; must be 1..27 chars without /, :, or newline`};let t=Ir(e,pt(e.appBundlePath)),r=[];for(let n=1;n<=mt;n++){let i=await Pr(t);if(i.success)return{success:!0,outputPath:e.outputPath};if(r.push(`attempt ${n}: ${i.error}`),!Tr(i.error,n))return{success:!1,error:r.join(`
12
- `)};z(e.outputPath,{force:!0}),await new Promise((a)=>setTimeout(a,n*2000))}return{success:!1,error:r.join(`
13
- `)}}async function $r(e){if(!/^[a-zA-Z0-9._-]+$/.test(e.identifier)||!e.identifier.includes("."))return{success:!1,error:`Invalid pkg identifier "${e.identifier}"; expected reverse-DNS like com.example.app`};if(!/^[A-Za-z0-9._+-]+$/.test(e.version))return{success:!1,error:`Invalid pkg version "${e.version}"`};if(e.appStore){if(!e.installerIdentity)return{success:!1,error:'App Store packaging requires macos.installerIdentity (a "3rd Party Mac Developer Installer" identity)'};let r=await J("productbuild",vr({appBundlePath:e.appBundlePath,outputPath:e.outputPath,identity:e.installerIdentity}));return r.success?{success:!0,outputPath:e.outputPath}:{success:!1,error:r.error}}let t=Se(m(_e(),"craft-pkg-"));try{let r=m(t,"Applications");D(r,{recursive:!0}),nr(e.appBundlePath,m(r,Ae(e.appBundlePath)),{recursive:!0});let n=await J("pkgbuild",["--root",t,"--identifier",e.identifier,"--version",e.version,"--install-location","/",...e.installerIdentity?["--sign",e.installerIdentity]:[],e.outputPath]);return n.success?{success:!0,outputPath:e.outputPath}:{success:!1,error:n.error}}finally{z(t,{recursive:!0,force:!0})}}function W(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Er(e){let t=e.replace(/[^A-Za-z0-9_.]/g,"_");return/^[A-Za-z_]/.test(t)?t:`_${t}`}function Ar(e){let t=rr("sha256").update(e).digest("hex").slice(0,32).split("");t[12]="4",t[16]=(Number.parseInt(t[16],16)&3|8).toString(16);let r=t.join("").toUpperCase();return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function Mr(e){if(e==="ia32"||e==="x86")return"x86";if(e==="x64"||e==="arm64")return e;throw Error(`Unsupported Windows package architecture: ${e}`)}function Br(e,t){if(!/^[0-9]+\.[0-9]+\.[0-9]+(?:\.[0-9]+)?$/.test(e.version))throw Error(`MSI version must have 3 or 4 numeric parts: ${e.version}`);let r=Er(e.name),n=e.manufacturer.trim()||"Unknown",i=Ar(`${n}/${e.name}`),a=e.architecture==="x86"?"ProgramFilesFolder":"ProgramFiles64Folder",c=e.architecture==="x86"?"no":"yes";return`<?xml version="1.0" encoding="UTF-8"?>
14
- <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
15
- <Product Id="*" Name="${W(e.name)}" Language="1033" Version="${e.version}" Manufacturer="${W(n)}" UpgradeCode="${i}">
16
- <Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine" Platform="${e.architecture}" />
17
- <MajorUpgrade AllowDowngrades="yes" />
18
- <MediaTemplate EmbedCab="yes" />
19
- <Directory Id="TARGETDIR" Name="SourceDir">
20
- <Directory Id="${a}">
21
- <Directory Id="INSTALLFOLDER" Name="${W(e.name)}">
22
- <Component Id="${r}Executable" Guid="*" Win64="${c}">
23
- <File Id="${r}File" Source="${W(t)}" KeyPath="yes" />
24
- </Component>
25
- </Directory>
26
- </Directory>
27
- </Directory>
28
- <Feature Id="ProductFeature" Title="${W(e.name)}" Level="1">
29
- <ComponentRef Id="${r}Executable" />
30
- </Feature>
31
- </Product>
32
- </Wix>
33
- `}function Dr(e){if(e.length===0||e.trim()!==e||/[<>:"/\\|?*\u0000-\u001F]/.test(e)||/[. ]$/.test(e))throw Error(`Invalid Windows application name: ${JSON.stringify(e)}`);if(/^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(e))throw Error(`Reserved Windows application name: ${JSON.stringify(e)}`);return`${e}.exe`}function de(e,t,r){return new Promise((n,i)=>{let a=ie(e,t,{cwd:r,stdio:"inherit",windowsHide:!0});a.once("error",i),a.once("close",(c)=>c===0?n():i(Error(`${e} exited with code ${c}`)))})}async function Lr(e){let t=Se(m(_e(),"craft-msi-"));try{let r=Dr(e.name),n=m(t,r),i=m(t,"installer.wxs"),a=m(t,"installer.wixobj");if(U(e.binaryPath,n),O(i,Br(e,r)),await de("candle.exe",["-nologo","-out",a,i],t),await de("light.exe",["-nologo","-sval","-out",e.outputPath,a],t),e.certificatePath){let c=["sign","/fd","sha256","/tr","https://timestamp.digicert.com","/td","sha256","/f",e.certificatePath];if(e.certificatePassword)c.push("/p",e.certificatePassword);c.push(e.outputPath),await de("signtool.exe",c),await de("signtool.exe",["verify","/pa","/all",e.outputPath])}return{success:!0,outputPath:e.outputPath}}catch(r){let n=r instanceof Error?r.message:String(r);return{success:!1,error:/ENOENT|not found/i.test(n)?`WiX Toolset not found: ${n}`:n}}finally{z(t,{recursive:!0,force:!0})}}async function Rr(e){try{let t=new Uint8Array(ar(e.binaryPath)),r=fr([{name:`${e.name}.exe`,data:t}]);return O(e.outputPath,r),{success:!0,outputPath:e.outputPath}}catch(t){return{success:!1,error:`Failed to write ZIP: ${t.message}`}}}async function Fr(e){return new Promise((t)=>{try{let r=e.name.toLowerCase(),n=/^[a-z0-9._+-]+$/,i=/^[A-Za-z0-9._+-]+$/;if(!n.test(r)){t({success:!1,error:`DEB package name must match ${n} (got: ${r})`});return}if(!i.test(e.version)){t({success:!1,error:`DEB version must match ${i} (got: ${e.version})`});return}let a=(A)=>A.replace(/[\r\n]+/g," ").trim(),c=a(e.description),d=a(e.maintainer);for(let A of e.dependencies)if(!/^[a-z0-9._+-]+(?:\s*\([^)\n,]+\))?$/i.test(A)){t({success:!1,error:`Invalid DEB dependency "${A}"`});return}let l=Se(m(_e(),"craft-deb-")),u=m(l,"DEBIAN"),f=m(l,"usr","bin"),w=m(l,"usr","share","applications");D(u,{recursive:!0}),D(f,{recursive:!0}),D(w,{recursive:!0});let p=r;U(e.binaryPath,m(f,p)),Q(m(f,p),493);let g=`Package: ${r}
34
- Version: ${e.version}
35
- Section: utils
36
- Priority: optional
37
- Architecture: amd64
38
- Depends: ${e.dependencies.join(", ")}
39
- Maintainer: ${d}
40
- Description: ${c||e.name}
41
- `;O(m(u,"control"),g);let v=`[Desktop Entry]
42
- Type=Application
43
- Name=${e.name}
44
- Exec=/usr/bin/${p}
45
- Terminal=false
46
- Categories=Utility;
47
- `;O(m(w,`${p}.desktop`),v);let k=ie("dpkg-deb",["--build",l,e.outputPath]);k.on("close",(A)=>{if(z(l,{recursive:!0,force:!0}),A===0)t({success:!0,outputPath:e.outputPath});else t({success:!1,error:`dpkg-deb exited with code ${A}`})}),k.on("error",(A)=>{z(l,{recursive:!0,force:!0}),t({success:!1,error:A.message})})}catch(r){t({success:!1,error:r.message})}})}async function Ur(e){return new Promise((t)=>{try{let r=m(or(),"rpmbuild"),n=m(r,"SPECS"),i=m(r,"SOURCES"),a=m(r,"BUILD"),c=m(r,"RPMS");D(n,{recursive:!0}),D(i,{recursive:!0}),D(a,{recursive:!0}),D(c,{recursive:!0});let d=/^[a-z0-9._+-]+$/i,l=/^[A-Za-z0-9._+-]+$/,u=e.name.toLowerCase();if(!d.test(u))return t({success:!1,error:`RPM package name must match ${d} (got: ${u})`});if(!l.test(e.version))return t({success:!1,error:`RPM version must match ${l} (got: ${e.version})`});let w=((S)=>S.replace(/[\r\n]+/g," ").replace(/%/g,"%%"))(e.description||e.name),p=(e.description||e.name).split(/\r?\n/).map((S)=>S.replace(/%/g,"%%")).join(`
48
- `),g=e.requires.map((S)=>{if(!d.test(S))throw Error(`RPM Requires entry must match ${d} (got: ${S})`);return S}).join(", ");U(e.binaryPath,m(i,u));let v=`Name: ${u}
49
- Version: ${e.version}
50
- Release: 1%{?dist}
51
- Summary: ${w}
52
- License: MIT
53
- Requires: ${g}
54
-
55
- %description
56
- ${p}
57
-
58
- %install
59
- mkdir -p %{buildroot}/usr/bin
60
- install -m 755 %{SOURCE0} %{buildroot}/usr/bin/${u}
61
-
62
- %files
63
- /usr/bin/${u}
64
- `,k=m(n,`${e.name.toLowerCase()}.spec`);O(k,v);let A=ie("rpmbuild",["-bb",k]);A.on("close",(S)=>{if(S===0){let R=`${e.name.toLowerCase()}-${e.version}-1.x86_64.rpm`,ce=m(c,"x86_64",R);try{U(ce,e.outputPath),t({success:!0,outputPath:e.outputPath})}catch{t({success:!1,error:"Failed to copy built RPM"})}}else t({success:!1,error:`rpmbuild exited with code ${S}`})}),A.on("error",(S)=>{t({success:!1,error:S.message})})}catch(r){t({success:!1,error:r.message})}})}async function Or(e){return new Promise((t)=>{try{let r=Se(m(_e(),"craft-appimage-")),n=m(r,`${e.name}.AppDir`),i=m(n,"usr","bin"),a=m(n,"usr","share");D(i,{recursive:!0}),D(a,{recursive:!0});let c=e.name.toLowerCase();U(e.binaryPath,m(i,c)),Q(m(i,c),493);let d=`#!/bin/bash
65
- SELF=$(readlink -f "$0")
66
- HERE=\${SELF%/*}
67
- export PATH="\${HERE}/usr/bin/:\${PATH}"
68
- exec "\${HERE}/usr/bin/${c}" "$@"
69
- `;O(m(n,"AppRun"),d),Q(m(n,"AppRun"),493);let l=`[Desktop Entry]
70
- Type=Application
71
- Name=${e.name}
72
- Exec=${c}
73
- Terminal=false
74
- Categories=Utility;
75
- Icon=${c}
76
- `;if(O(m(n,`${c}.desktop`),l),e.iconPath&&Y(e.iconPath))U(e.iconPath,m(n,`${c}.png`));else{let f=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);O(m(n,`${c}.png`),f)}let u=ie("appimagetool",[n,e.outputPath],{env:{...process.env,ARCH:"x86_64"}});u.on("close",(f)=>{if(z(r,{recursive:!0,force:!0}),f===0)Q(e.outputPath,493),t({success:!0,outputPath:e.outputPath});else t({success:!1,error:`appimagetool exited with code ${f}. Install from https://appimage.github.io/appimagetool/`})}),u.on("error",(f)=>{z(r,{recursive:!0,force:!0}),t({success:!1,error:`appimagetool not found: ${f.message}`})})}catch(r){t({success:!1,error:r.message})}})}function gt(){switch(process.platform){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}async function Ri(e){return wr({...e,platforms:[gt()]})}class Hr{backgroundAudio=null;toneFrequencies={bell:880,chime:1046.5,gong:440,gentle:523.25};async playTone(e,t=1.5){let r=null;try{if(r=new(window.AudioContext||window.webkitAudioContext),r.state==="suspended"&&typeof r.resume==="function")await r.resume();let n=r.createOscillator(),i=r.createGain();n.connect(i),i.connect(r.destination),n.frequency.value=this.toneFrequencies[e],n.type="sine";let a=r.currentTime;i.gain.setValueAtTime(0.3,a),i.gain.exponentialRampToValueAtTime(0.01,a+t),n.start(a),n.stop(a+t),n.onended=()=>{r.close().catch(()=>{})}}catch(n){throw console.error("Failed to play tone:",n),r?.close().catch(()=>{}),n instanceof Error?n:Error(String(n))}}playBackgroundNoise(e,t=0.5){this.stopBackgroundNoise();try{let r=new(window.AudioContext||window.webkitAudioContext),n=r.createGain();switch(n.gain.value=t,e){case"whitenoise":this.generateWhiteNoise(r,n);break;case"brownnoise":this.generateBrownNoise(r,n);break;case"ocean":this.generateOceanWaves(r,n);break;case"rain":this.generateRain(r,n);break;case"forest":this.generateForest(r,n);break}}catch(r){console.error("Failed to generate background noise:",r)}}stopBackgroundNoise(){if(this.backgroundAudio)try{if(this.backgroundAudio.source)this.backgroundAudio.source.stop();if(this.backgroundAudio.source2)this.backgroundAudio.source2.stop();if(this.backgroundAudio.context)this.backgroundAudio.context.close();this.backgroundAudio=null}catch(e){console.error("Failed to stop background noise:",e)}}setVolume(e){if(this.backgroundAudio&&this.backgroundAudio.gain)this.backgroundAudio.gain.gain.value=e}generateWhiteNoise(e,t){let r=2*e.sampleRate,n=e.createBuffer(1,r,e.sampleRate),i=n.getChannelData(0);for(let c=0;c<r;c++)i[c]=Math.random()*2-1;let a=e.createBufferSource();a.buffer=n,a.loop=!0,a.connect(t),t.connect(e.destination),a.start(0),this.backgroundAudio={source:a,context:e,gain:t}}generateBrownNoise(e,t){let r=2*e.sampleRate,n=e.createBuffer(1,r,e.sampleRate),i=n.getChannelData(0),a=0;for(let d=0;d<r;d++){let l=Math.random()*2-1;i[d]=(a+0.02*l)/1.02,a=i[d],i[d]*=3.5}let c=e.createBufferSource();c.buffer=n,c.loop=!0,c.connect(t),t.connect(e.destination),c.start(0),this.backgroundAudio={source:c,context:e,gain:t}}generateOceanWaves(e,t){let r=2*e.sampleRate,n=e.createBuffer(1,r,e.sampleRate),i=n.getChannelData(0),a=0;for(let f=0;f<r;f++){let w=Math.random()*2-1;i[f]=(a+0.02*w)/1.02,a=i[f],i[f]*=2}let c=e.createBufferSource();c.buffer=n,c.loop=!0;let d=e.createBiquadFilter();d.type="lowpass",d.frequency.value=800,d.Q.value=1;let l=e.createOscillator();l.frequency.value=0.15;let u=e.createGain();u.gain.value=0.3,c.connect(d),d.connect(t),l.connect(u),u.connect(t.gain),t.connect(e.destination),c.start(0),l.start(0),this.backgroundAudio={source:c,source2:l,context:e,gain:t}}generateRain(e,t){let r=2*e.sampleRate,n=e.createBuffer(1,r,e.sampleRate),i=n.getChannelData(0);for(let d=0;d<r;d++){let l=Math.random()>0.98?2:1;i[d]=(Math.random()*2-1)*l}let a=e.createBufferSource();a.buffer=n,a.loop=!0;let c=e.createBiquadFilter();c.type="highpass",c.frequency.value=400,c.Q.value=0.5,a.connect(c),c.connect(t),t.connect(e.destination),a.start(0),this.backgroundAudio={source:a,context:e,gain:t}}generateForest(e,t){let r=2*e.sampleRate,n=e.createBuffer(1,r,e.sampleRate),i=n.getChannelData(0),a=0,c=0,d=0,l=0,u=0,f=0,w=0;for(let v=0;v<r;v++){let k=Math.random()*2-1;a=0.99886*a+k*0.0555179,c=0.99332*c+k*0.0750759,d=0.969*d+k*0.153852,l=0.8665*l+k*0.3104856,u=0.55*u+k*0.5329522,f=-0.7616*f-k*0.016898,i[v]=(a+c+d+l+u+f+w+k*0.5362)*0.11,w=k*0.115926}let p=e.createBufferSource();p.buffer=n,p.loop=!0;let g=e.createBiquadFilter();g.type="bandpass",g.frequency.value=1200,g.Q.value=0.8,p.connect(g),g.connect(t),t.connect(e.destination),p.start(0),this.backgroundAudio={source:p,context:e,gain:t}}}function Fi(){return typeof window<"u"&&!!window.craft}function yt(){if(typeof window>"u")return null;return window.craft??null}function Ui(){return yt()?.bridge?.call??null}function Nr(e){return`${e} not available. Must run in Craft environment.`}function Oi(e){let t=yt();if(!t)throw Error(Nr(e));return t}function Pe(){return typeof globalThis<"u"&&typeof globalThis.localStorage<"u"}class qr{key;defaults;constructor(e,t){this.key=e,this.defaults=t}load(){if(!Pe())return this.defaults;try{let e=localStorage.getItem(this.key);if(e){let t=JSON.parse(e);if(Array.isArray(t)||Array.isArray(this.defaults))return t;if(t!==null&&typeof t==="object"&&this.defaults!==null&&typeof this.defaults==="object")return{...this.defaults,...t};return t}}catch(e){console.error(`Failed to load ${this.key}:`,e)}return this.defaults}save(e){if(!Pe())return;try{localStorage.setItem(this.key,JSON.stringify(e))}catch(t){console.error(`Failed to save ${this.key}:`,t)}}update(e){let t=this.load();if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&e!==null&&typeof e==="object"&&!Array.isArray(e)){this.save({...t,...e});return}this.save(e)}clear(){if(!Pe())return;try{localStorage.removeItem(this.key)}catch(e){console.error(`Failed to clear ${this.key}:`,e)}}}class G{duration;onTick;onComplete;intervalId=null;timeRemaining=0;isRunning=!1;endAt=0;static now=()=>Date.now();constructor(e,t,r){this.duration=e,this.onTick=t,this.onComplete=r,this.timeRemaining=e}start(){if(this.isRunning)return;this.isRunning=!0,this.endAt=G.now()+this.timeRemaining*1000,this.intervalId=setInterval(()=>{let e=Math.max(0,this.endAt-G.now());if(this.timeRemaining=Math.ceil(e/1000),this.onTick(this.timeRemaining),this.timeRemaining<=0)this.pause(),this.onComplete?.()},250)}pause(){if(!this.isRunning)return;if(this.isRunning=!1,this.intervalId)clearInterval(this.intervalId),this.intervalId=null}reset(){this.pause(),this.timeRemaining=this.duration,this.endAt=G.now()+this.duration*1000,this.onTick(this.timeRemaining)}setDuration(e){if(this.duration=e,this.timeRemaining=e,this.isRunning)this.endAt=G.now()+e*1000}getTimeRemaining(){return this.timeRemaining}running(){return this.isRunning}static formatTime(e){let t=Math.max(0,Math.floor(e)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}static _setClockForTests(e){G.now=e??(()=>Date.now())}}function Me(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==="function")return e.randomUUID();if(e&&typeof e.getRandomValues==="function"){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,(n)=>n.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20,32)}`}throw Error("[Craft] No Web Crypto available; cannot generate secure IDs")}var T={UNKNOWN:-1,TIMEOUT:-2,QUEUE_FULL:-3,BINARY_DISABLED:-4,EXPECTED_BINARY:-5,BRIDGE_DESTROYED:-6,BUSY:-7,PROTOCOL_MISMATCH:-8,DISCONNECTED:-9},Ce=1;function Wr(e,t){return`${e}_${Date.now().toString(36)}_${t.toString(36)}`}class bt extends Vr{config;pendingRequests=new Map;offlineQueue=[];connected=!1;streams=new Map;batchBuffer=[];batchTimer=null;destroyed=!1;idPrefix=`msg-${Me().slice(0,8)}`;idCounter=Math.floor(Math.random()*1e9);nextMessageId(){if(this.idCounter>=Number.MAX_SAFE_INTEGER-1)this.idCounter=Math.floor(Math.random()*1e9);return this.idCounter++,Wr(this.idPrefix,this.idCounter)}boundHandleMessage=null;craftReadyHandler=null;constructor(e={}){super();this.setMaxListeners(100),this.config={timeout:30000,retries:3,retryDelay:1000,queueSize:1000,batchSize:10,batchDelay:50,enableOfflineQueue:!0,enableBinaryTransfer:!0,maxConcurrentRequests:1e4,parentOrigin:null,...e},this.setupBridge()}setupBridge(){if(typeof window>"u")return;if(this.boundHandleMessage=this.handleMessage.bind(this),window.addEventListener("message",this.boundHandleMessage),window.addEventListener("craft-bridge-message",this.boundHandleMessage),window.craft)Promise.resolve().then(()=>this.setConnected(!0));else this.craftReadyHandler=()=>{if(this.craftReadyHandler)window.removeEventListener("craft:ready",this.craftReadyHandler),this.craftReadyHandler=null;this.setConnected(!0)},window.addEventListener("craft:ready",this.craftReadyHandler,{once:!0})}teardownBridgeListeners(){if(typeof window>"u")return;if(this.boundHandleMessage)window.removeEventListener("message",this.boundHandleMessage),window.removeEventListener("craft-bridge-message",this.boundHandleMessage),this.boundHandleMessage=null;if(this.craftReadyHandler)window.removeEventListener("craft:ready",this.craftReadyHandler),this.craftReadyHandler=null}handleMessage(e){let t;try{t="detail"in e?e.detail:typeof e.data==="string"?JSON.parse(e.data):e.data}catch(r){console.warn("[Craft Bridge] Failed to parse message:",r);return}if(!t||!t.id)return;if(t.type==="response"&&!this.isOwnId(t.id))return;switch(t.type){case"response":this.handleResponse(t);break;case"event":this.handleEvent(t);break;case"stream":this.handleStream(t);break}}isOwnId(e){return typeof e==="string"&&e.startsWith(`${this.idPrefix}_`)}handleResponse(e){let t=this.pendingRequests.get(e.id);if(!t)return;if(clearTimeout(t.timeout),this.pendingRequests.delete(e.id),e.error)t.reject(new _(e.error.message,e.error.code,e.error.data));else t.resolve(e.result)}handleEvent(e){if(e.method)this.emit(e.method,e.params)}handleStream(e){if(!e.streamId)return;let t=this.streams.get(e.streamId);if(!t)return;switch(e.streamEvent){case"data":t.onData(e.result);break;case"end":t.onEnd(),this.streams.delete(e.streamId);break;case"error":t.onError(Error(e.error?.message||"Stream error")),this.streams.delete(e.streamId);break}}async request(e,t,r){return this.requestWithRetry(e,t,this.config.retries,r?.timeout)}async requestWithRetry(e,t,r,n){try{return await this.sendRequest(e,t,n)}catch(i){if(r>0&&this.isRetryableError(i))return await this.delay(this.config.retryDelay),this.requestWithRetry(e,t,r-1,n);throw i}}isRetryableError(e){if(e instanceof _)return e.code===T.UNKNOWN||e.code===T.TIMEOUT;return!1}async sendRequest(e,t,r){if(this.destroyed)throw new _("Bridge destroyed",T.BRIDGE_DESTROYED);if(this.pendingRequests.size>=this.config.maxConcurrentRequests)throw new _(`Bridge busy: ${this.pendingRequests.size} in-flight requests exceeds maxConcurrentRequests=${this.config.maxConcurrentRequests}`,T.BUSY);let n=r??this.config.timeout,i={id:this.nextMessageId(),type:"request",method:e,params:t};if(!this.connected&&this.config.enableOfflineQueue){if(this.offlineQueue.length>=this.config.queueSize)throw new _("Offline queue full",T.QUEUE_FULL);return this.offlineQueue.push(i),new Promise((a,c)=>{this.pendingRequests.set(i.id,{resolve:a,reject:c,timeout:setTimeout(()=>{this.pendingRequests.delete(i.id);let d=this.offlineQueue.findIndex((l)=>l.id===i.id);if(d>=0)this.offlineQueue.splice(d,1);c(new _("Request timeout (offline)",T.TIMEOUT))},n)})})}return new Promise((a,c)=>{let d=setTimeout(()=>{this.pendingRequests.delete(i.id),c(new _("Request timeout",T.TIMEOUT))},n);if(this.pendingRequests.set(i.id,{resolve:a,reject:c,timeout:d}),!this.send(i))clearTimeout(d),this.pendingRequests.delete(i.id),c(new _("No bridge transport available \u2014 not running inside a Craft host",T.UNKNOWN))})}async handshake(){let e=await this.request("_handshake",{sdkVersion:Ce});if(e?.version!==Ce)throw new _(`Bridge protocol mismatch: SDK speaks v${Ce}, native speaks v${e?.version??"unknown"}`,T.PROTOCOL_MISMATCH);return{nativeVersion:e.version}}notify(e,t){let r={id:this.nextMessageId(),type:"request",method:e,params:t};this.send(r)}stream(e,t,r){let n=r?.bufferLimit??1000,i=this.nextMessageId(),a={id:this.nextMessageId(),type:"request",method:e,params:t,streamId:i},c=[],d=!1,l,u=!1,f=null,w=null,p=null,g={onData:(v)=>{f=v;while(c.length>0)v(c.shift())},onEnd:(v)=>{if(w=v,d)v()},onError:(v)=>{if(p=v,l)v(l)},cancel:()=>{if(u)return;if(u=!0,!this.streams.has(i))return;this.streams.delete(i),this.send({id:this.nextMessageId(),type:"request",method:"_cancelStream",params:{streamId:i}})}};return this.streams.set(i,{onData:(v)=>{if(f){f(v);return}if(c.length>=n){let k=new _(`Stream buffer overflow: ${c.length} events buffered with no consumer (limit=${n})`,T.BUSY);if(l=k,p)p(k);this.streams.delete(i),this.send({id:this.nextMessageId(),type:"request",method:"_cancelStream",params:{streamId:i}});return}c.push(v)},onEnd:()=>{if(d=!0,w)w()},onError:(v)=>{if(l=v,p)p(v)}}),this.send(a),g}async sendBinary(e,t){if(!this.config.enableBinaryTransfer)throw new _("Binary transfer not enabled",T.BINARY_DISABLED);let r=this.arrayBufferToBase64(t instanceof ArrayBuffer?new Uint8Array(t):t);await this.request(e,{_binary:!0,data:r})}async receiveBinary(e,t){if(!this.config.enableBinaryTransfer)throw new _("Binary transfer not enabled",T.BINARY_DISABLED);let r=await this.request(e,t);if(r._binary)return this.base64ToArrayBuffer(r.data);throw new _("Expected binary response",T.EXPECTED_BINARY)}async batch(e){return this.request("_batch",{requests:e})}addToBatch(e,t){if(this.batchBuffer.push({id:this.nextMessageId(),type:"request",method:e,params:t}),this.batchBuffer.length>=this.config.batchSize)this.flushBatch();else if(!this.batchTimer)this.batchTimer=setTimeout(()=>this.flushBatch(),this.config.batchDelay)}flushBatch(){if(this.batchTimer)clearTimeout(this.batchTimer),this.batchTimer=null;if(this.destroyed){this.batchBuffer=[];return}if(this.batchBuffer.length===0)return;let e=this.batchBuffer;if(this.batchBuffer=[],!this.connected){if(this.config.enableOfflineQueue)for(let t of e){if(this.offlineQueue.length>=this.config.queueSize)break;this.offlineQueue.push(t)}return}this.send({id:this.nextMessageId(),type:"request",method:"_batch",params:{requests:e}})}setConnected(e){let t=this.connected;if(this.connected=e,e&&!t)this.emit("connected"),this.flushOfflineQueue();else if(!e&&t){this.emit("disconnected");for(let[r,n]of this.pendingRequests)clearTimeout(n.timeout),n.reject(new _("Bridge disconnected",T.DISCONNECTED)),this.pendingRequests.delete(r)}}flushOfflineQueue(){let e=this.offlineQueue;this.offlineQueue=[];for(let t of e)this.send(t)}send(e){let t;try{t=JSON.stringify(e)}catch(r){return this.failPendingForMessage(e,new _(`Failed to serialize bridge message: ${r.message}`,T.UNKNOWN,{originalError:String(r)})),!1}try{if(typeof window<"u"){if(window.webkit?.messageHandlers?.craft)return window.webkit.messageHandlers.craft.postMessage(e),!0;if(window.CraftBridge)return window.CraftBridge.postMessage(t),!0;if(window.craftIPC)return window.craftIPC.send("bridge-message",e),!0;if(window.parent!==window&&this.config.parentOrigin)return window.parent.postMessage(e,this.config.parentOrigin),!0}if(typeof process<"u"&&typeof process.send==="function")return process.send(e),!0;return!1}catch(r){return this.failPendingForMessage(e,new _(`Bridge transport rejected the message: ${r.message}`,T.UNKNOWN)),!1}}failPendingForMessage(e,t){let r=this.pendingRequests.get(e.id);if(!r)return;clearTimeout(r.timeout),this.pendingRequests.delete(e.id),r.reject(t)}delay(e){return new Promise((t)=>setTimeout(t,e))}arrayBufferToBase64(e){let t=[],r=8192;for(let n=0;n<e.byteLength;n+=8192)t.push(String.fromCharCode(...e.subarray(n,n+8192)));return btoa(t.join(""))}base64ToArrayBuffer(e){let t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}destroy(){if(this.destroyed)return;this.destroyed=!0;for(let[,e]of this.pendingRequests)clearTimeout(e.timeout),e.reject(new _("Bridge destroyed",T.BRIDGE_DESTROYED));if(this.pendingRequests.clear(),this.streams.clear(),this.offlineQueue=[],this.batchBuffer=[],this.batchTimer)clearTimeout(this.batchTimer),this.batchTimer=null;this.teardownBridgeListeners(),this.removeAllListeners()}}class _ extends Error{code;data;constructor(e,t,r){super(e);this.name="BridgeError",this.code=t,this.data=r}}var le=null,ue=null;function x(e){if(!le)return le=new bt(e),ue=e??null,le;if(e&&ue&&!zr(e,ue))console.warn("[Craft Bridge] getBridge() ignored a follow-up config that differs from the "+"original \u2014 the singleton was already constructed. Use createBridge() for "+"independent instances, or call resetGlobalBridge() first.");else if(e&&!ue)console.warn("[Craft Bridge] getBridge() ignored a follow-up config \u2014 singleton already "+"exists with no recorded config. Use createBridge() for independent instances.");return le}function zr(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of r)if(e[n]!==t[n])return!1;return!0}var jr=30000;function vt(){if(typeof window>"u")return null;return window}function Kr(){let e=vt();if(!e)return;if(e.__craftBridgePending=e.__craftBridgePending||{},!e.__craftBridgeResolve)e.__craftBridgeResolve=(t,r)=>{let n=e.__craftBridgePending[t];if(!n||n.length===0)return!1;return n.shift().resolve(r),!0};if(!e.__craftBridgeReject)e.__craftBridgeReject=(t,r)=>{let n=e.__craftBridgePending[t];if(!n||n.length===0)return!1;return n.shift().reject(r instanceof Error?r:Error(String(r))),!0}}function I(){return typeof window<"u"&&!!window.webkit?.messageHandlers?.craft}function Re(e){if(!I())return!1;return window.webkit.messageHandlers.craft.postMessage(e),!0}function L(e,t,r={}){if(!I())return Promise.reject(Error("No WKWebView host"));Kr();let n=r.timeoutMs??jr,i=vt();return new Promise((a,c)=>{let d=!1,l=i.__craftBridgePending[e]=i.__craftBridgePending[e]||[],u,f={resolve:(w)=>{if(d)return;d=!0,clearTimeout(u);let p=l.indexOf(f);if(p>=0)l.splice(p,1);a(w)},reject:(w)=>{if(d)return;d=!0,clearTimeout(u);let p=l.indexOf(f);if(p>=0)l.splice(p,1);c(w)}};l.push(f),u=setTimeout(()=>{f.reject(Error(`[WKWebView] ${e} timed out after ${n}ms`))},n);try{window.webkit.messageHandlers.craft.postMessage(t)}catch(w){f.reject(w)}})}class ge{_id;_listeners=new Map;_closed=!1;_domListeners=[];constructor(e){this._id=e,this._setupEventListeners()}get id(){return this._id}get isClosed(){return this._closed}_setupEventListeners(){if(typeof Xe<"u")["show","hide","focus","blur","minimize","maximize","unmaximize","restore","resize","move","close","closed","enter-fullscreen","leave-fullscreen","ready-to-show"].forEach((t)=>{let r=(i)=>{if(i.detail?.windowId===this._id||!i.detail?.windowId)this._emit(t,i.detail?.data)},n=`craft:window:${t}`;globalThis.window.addEventListener(n,r),this._domListeners.push({type:n,handler:r})})}_cleanupEventListeners(){if(typeof Xe<"u"){for(let{type:e,handler:t}of this._domListeners)globalThis.window.removeEventListener(e,t);this._domListeners=[]}}_emit(e,t){let r=this._listeners.get(e);if(r)r.forEach((n)=>n(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>{this._listeners.get(e)?.delete(t)}}once(e,t){let r=(n)=>{this._listeners.get(e)?.delete(r),t(n)};return this.on(e,r)}off(e,t){this._listeners.get(e)?.delete(t)}async show(){await this._call("show")}async hide(){await this._call("hide")}async toggle(){await this._call("toggle")}async focus(){await this._call("focus")}async blur(){await this._call("blur")}async minimize(){await this._call("minimize")}async maximize(){await this._call("maximize")}async unmaximize(){await this._call("unmaximize")}async restore(){await this._call("restore")}async close(){await this._call("close"),this._closed=!0,this._cleanupEventListeners()}async destroy(){await this._call("destroy"),this._closed=!0,this._cleanupEventListeners()}async setFullscreen(e=!0){await this._call("setFullscreen",{fullscreen:e})}async toggleFullscreen(){await this._call("toggleFullscreen")}async setTitle(e){await this._call("setTitle",{title:e})}async getTitle(){return this._call("getTitle")}async setSize(e,t,r){await this._call("setSize",{width:e,height:t,animate:r})}async getSize(){return this._call("getSize")}async setMinimumSize(e,t){await this._call("setMinimumSize",{width:e,height:t})}async setMaximumSize(e,t){await this._call("setMaximumSize",{width:e,height:t})}async setPosition(e,t,r){await this._call("setPosition",{x:e,y:t,animate:r})}async moveBy(e,t){await this._call("moveBy",{dx:e,dy:t})}async getPosition(){return this._call("getPosition")}async setBounds(e,t){await this._call("setBounds",{...e,animate:t})}async getBounds(){return this._call("getBounds")}async center(){await this._call("center")}async setAlwaysOnTop(e,t){await this._call("setAlwaysOnTop",{alwaysOnTop:e,level:t})}async isAlwaysOnTop(){return this._call("isAlwaysOnTop")}async setResizable(e){await this._call("setResizable",{resizable:e})}async isResizable(){return this._call("isResizable")}async setMovable(e){await this._call("setMovable",{movable:e})}async startDrag(){await this._call("startDrag")}async isMovable(){return this._call("isMovable")}async setMinSize(e,t){await this._call("setMinSize",{width:e,height:t})}async setMaxSize(e,t){await this._call("setMaxSize",{width:e,height:t})}async setOpacity(e){await this._call("setOpacity",{opacity:Math.max(0,Math.min(1,e))})}async getOpacity(){return this._call("getOpacity")}async setBackgroundColor(e){await this._call("setBackgroundColor",{color:e})}async getState(){return this._call("getState")}async setVibrancy(e){await this._call("setVibrancy",{vibrancy:e})}async setTrafficLightPosition(e){await this._call("setTrafficLightPosition",e)}async setWindowLevel(e){await this._call("setWindowLevel",{level:e})}async setHasShadow(e){await this._call("setHasShadow",{hasShadow:e})}async setBackgroundMaterial(e){await this._call("setBackgroundMaterial",{material:e})}async flashFrame(e){await this._call("flashFrame",{flash:e})}async setOverlayIcon(e,t){await this._call("setOverlayIcon",{icon:e,description:t})}async loadHTML(e){await this._call("loadHTML",{html:e})}async loadURL(e){await this._call("loadURL",{url:e})}async reload(){await this._call("reload")}async executeJavaScript(e){return this._call("executeJavaScript",{code:e})}async _call(e,t){if(I())return L(`window.${e}`,{type:"window",action:e,windowId:this._id,data:t});return x().request(`window.${e}`,{windowId:this._id,...t})}}class xt{_windows=new Map;_currentWindow=null;_idCounter=0;constructor(){if(typeof globalThis.window<"u")this._currentWindow=new ge("main"),this._windows.set("main",this._currentWindow)}get current(){if(!this._currentWindow)this._currentWindow=new ge("main"),this._windows.set("main",this._currentWindow);return this._currentWindow}get all(){return Array.from(this._windows.values())}get(e){return this._windows.get(e)}async create(e={}){let t=`window_${++this._idCounter}_${Date.now()}`;await x().request("window.create",{id:t,...e});let n=new ge(t);return this._windows.set(t,n),n}async getFocused(){let t=await x().request("window.getFocused");return t?this._windows.get(t)||null:null}show=()=>this.current.show();hide=()=>this.current.hide();toggle=()=>this.current.toggle();minimize=()=>this.current.minimize();maximize=()=>this.current.maximize();close=()=>this.current.close();focus=()=>this.current.focus();center=()=>this.current.center();setFullscreen=(e)=>this.current.setFullscreen(e);toggleFullscreen=()=>this.current.toggleFullscreen();setTitle=(e)=>this.current.setTitle(e);setSize=(e,t,r)=>this.current.setSize(e,t,r);setPosition=(e,t,r)=>this.current.setPosition(e,t,r);moveBy=(e,t)=>this.current.moveBy(e,t);setBounds=(e,t)=>this.current.setBounds(e,t);setAlwaysOnTop=(e)=>this.current.setAlwaysOnTop(e);setOpacity=(e)=>this.current.setOpacity(e);setBackgroundColor=(e)=>this.current.setBackgroundColor(e);setVibrancy=(e)=>this.current.setVibrancy(e);setResizable=(e)=>this.current.setResizable(e);startDrag=()=>this.current.startDrag();getState=()=>this.current.getState();on=(e,t)=>this.current.on(e,t);once=(e,t)=>this.current.once(e,t)}var Fe=new xt,Ni=Fe,Xe=Fe;function qi(e={},t={}){let r=typeof e==="string"?{...t,html:e}:e;return Fe.create(r)}class be{_id;_options;_listeners=new Map;_menuHandlers=new Map;_destroyed=!1;_domListeners=[];constructor(e,t={}){this._id=e,this._options=t,this._setupEventListeners()}get id(){return this._id}get isDestroyed(){return this._destroyed}_isForThisTray(e){if(!e)return!0;let t=e.trayId??e.id;if(t===void 0||t===null)return!0;return t===this._id}_addDomListener(e,t){if(typeof window>"u")return;window.addEventListener(e,t),this._domListeners.push({type:e,handler:t})}_setupEventListeners(){if(typeof window<"u")this._addDomListener("craft:tray:click",(e)=>{if(this._isForThisTray(e.detail))this._emit("click",e.detail)}),this._addDomListener("craft:tray:rightClick",(e)=>{if(this._isForThisTray(e.detail))this._emit("right-click",e.detail)}),this._addDomListener("craft:tray:doubleClick",(e)=>{if(this._isForThisTray(e.detail))this._emit("double-click",e.detail)}),this._addDomListener("craft:tray:menuAction",(e)=>{if(!this._isForThisTray(e.detail))return;let t=e.detail?.action;this._emit("menu-click",{menuId:t,action:t});let r=this._menuHandlers.get(t);if(r)r()}),this._addDomListener("craft:tray:dropFiles",(e)=>{if(this._isForThisTray(e.detail))this._emit("drop-files",{files:e.detail?.files||[]})}),this._addDomListener("craft:tray:dropText",(e)=>{if(this._isForThisTray(e.detail))this._emit("drop-text",{text:e.detail?.text||""})})}_teardownDomListeners(){if(typeof window>"u")return;for(let{type:e,handler:t}of this._domListeners)window.removeEventListener(e,t);this._domListeners=[]}_emit(e,t){let r=this._listeners.get(e);if(r)r.forEach((n)=>n(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>{this._listeners.get(e)?.delete(t)}}once(e,t){let r=(n)=>{this._listeners.get(e)?.delete(r),t(n)};return this.on(e,r)}off(e,t){this._listeners.get(e)?.delete(t)}async setTitle(e){this._options.title=e,await this._call("setTitle",e)}getTitle(){return this._options.title||""}async setIcon(e){this._options.icon=e,await this._call("setIcon",e)}async setTooltip(e){this._options.tooltip=e,await this._call("setTooltip",e)}async setMenu(e){this._options.menu=e;let t=(n)=>n.map((i,a)=>{let c={...i};if(!c.id&&c.label)c.id=`menu_${a}_${Date.now()}`;if(c.submenu)c.submenu=t(c.submenu);return c}),r=t(e);await this._call("setMenu",JSON.stringify(r))}async updateMenuItem(e,t){await this._call("updateMenuItem",JSON.stringify({id:e,updates:t}))}onMenuAction(e,t){return this._menuHandlers.set(e,t),()=>{this._menuHandlers.delete(e)}}async show(){await this._call("show","")}async hide(){await this._call("hide","")}async setHighlightMode(e){await this._call("setHighlightMode",e)}async displayBalloon(e){await this._call("displayBalloon",JSON.stringify(e))}async removeBalloon(){await this._call("removeBalloon","")}async getBounds(){return this._call("getBounds","")}async destroy(){await this._call("destroy",""),this._destroyed=!0,this._listeners.clear(),this._menuHandlers.clear(),this._teardownDomListeners()}onClickShowWindow(){return this.on("click",()=>{if(typeof window<"u"&&window.craft?.window?.show)window.craft.window.show()})}onClickToggleWindow(){return this.on("click",()=>{if(typeof window<"u"&&window.craft?.window?.toggle)window.craft.window.toggle()})}async _call(e,t){if(typeof window<"u"&&window.webkit?.messageHandlers?.craft)return new Promise((n,i)=>{try{window.webkit.messageHandlers.craft.postMessage({type:"tray",action:e,data:typeof t==="string"?t:JSON.stringify(t)}),n(void 0)}catch(a){i(a)}});return x().request(`tray.${e}`,{data:t})}}class kt{_tray;_config;_windowVisible=!1;constructor(e={}){this._config={showWindowOnClick:!0,windowWidth:320,windowHeight:400,windowPosition:"trayBottomCenter",hideDockIcon:!0,...e},this._tray=new be("menubar",{title:e.title,icon:e.icon,tooltip:e.tooltip,menu:e.menu}),this._setupBehavior()}get tray(){return this._tray}get isWindowVisible(){return this._windowVisible}_setupBehavior(){if(this._config.showWindowOnClick)this._tray.on("click",()=>{this.toggleWindow()});if(this._config.hideDockIcon)this._hideDockIcon()}async _hideDockIcon(){if(typeof window<"u"&&window.craft?.app?.hideDockIcon)await window.craft.app.hideDockIcon()}async showWindow(){if(typeof window<"u"&&window.craft?.window?.show)await window.craft.window.show(),this._windowVisible=!0}async hideWindow(){if(typeof window<"u"&&window.craft?.window?.hide)await window.craft.window.hide(),this._windowVisible=!1}async toggleWindow(){if(this._windowVisible)await this.hideWindow();else await this.showWindow()}setTitle(e){return this._tray.setTitle(e)}setIcon(e){return this._tray.setIcon(e)}setMenu(e){return this._tray.setMenu(e)}onMenuAction(e,t){return this._tray.onMenuAction(e,t)}async quit(){if(typeof window<"u"&&window.craft?.app?.quit)await window.craft.app.quit()}}class St{_trays=new Map;_mainTray=null;get main(){if(!this._mainTray)this._mainTray=new be("main"),this._trays.set("main",this._mainTray);return this._mainTray}create(e,t={}){let r=new be(e,t);if(this._trays.set(e,r),!this._mainTray)this._mainTray=r;return r}get(e){return this._trays.get(e)}async destroy(e){let t=this._trays.get(e);if(t){if(await t.destroy(),this._trays.delete(e),this._mainTray?.id===e)this._mainTray=null}}async destroyAll(){for(let e of this._trays.values())await e.destroy();this._trays.clear(),this._mainTray=null}setTitle=(e)=>this.main.setTitle(e);setIcon=(e)=>this.main.setIcon(e);setTooltip=(e)=>this.main.setTooltip(e);setMenu=(e)=>this.main.setMenu(e);onMenuAction=(e,t)=>this.main.onMenuAction(e,t);onClick=(e)=>this.main.on("click",e);onRightClick=(e)=>this.main.on("right-click",e);onClickToggleWindow=()=>this.main.onClickToggleWindow()}var Gr=new St,Vi=Gr;function Wi(e){return new kt(e)}function zi(...e){return e}function ji(){return{type:"separator"}}function Ki(e,t={}){return{label:e,type:"normal",...t}}function Gi(e,t,r={}){return{label:e,type:"checkbox",checked:t,...r}}function Qi(e,t,r={}){return{label:e,type:"submenu",submenu:t,...r}}class _t{_listeners=new Map;_shortcuts=new Map;_info=null;_preferences=null;_domListeners=[];_mediaQuery=null;_mediaQueryHandler=null;constructor(){this._setupEventListeners()}_addDomListener(e,t){if(typeof window>"u")return;window.addEventListener(e,t),this._domListeners.push({type:e,handler:t})}destroy(){if(typeof window<"u"){for(let{type:e,handler:t}of this._domListeners)window.removeEventListener(e,t);if(this._domListeners=[],this._mediaQuery&&this._mediaQueryHandler)this._mediaQuery.removeEventListener("change",this._mediaQueryHandler),this._mediaQuery=null,this._mediaQueryHandler=null}this._listeners.clear(),this._shortcuts.clear(),this._info=null,this._preferences=null}_setupEventListeners(){if(typeof window<"u"){["ready","activate","deactivate","will-quit","quit","before-quit","window-all-closed","open-file","open-url","theme-changed","accent-color-changed","display-added","display-removed","display-metrics-changed","power-suspend","power-resume","power-on-ac","power-on-battery","lock-screen","unlock-screen","user-did-become-active","user-did-resign-active"].forEach((r)=>{let n=(i)=>{if(r==="theme-changed"||r==="accent-color-changed"||r==="display-added"||r==="display-removed"||r==="display-metrics-changed")this._preferences=null;this._emit(r,i.detail)};this._addDomListener(`craft:app:${r}`,n)});let t=(r)=>{let n=r.detail?.accelerator,i=this._shortcuts.get(n);if(i)i()};if(this._addDomListener("craft:shortcut",t),window.matchMedia)this._mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this._mediaQueryHandler=(r)=>{this._preferences=null,this._emit("theme-changed",{theme:r.matches?"dark":"light"})},this._mediaQuery.addEventListener("change",this._mediaQueryHandler)}}_emit(e,t){let r=this._listeners.get(e);if(r)r.forEach((n)=>n(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>{this._listeners.get(e)?.delete(t)}}once(e,t){let r=(n)=>{this._listeners.get(e)?.delete(r),t(n)};return this.on(e,r)}off(e,t){this._listeners.get(e)?.delete(t)}async quit(){await this._call("quit")}async exit(e=0){await this._call("exit",{code:e})}async relaunch(e){await this._call("relaunch",e)}async hide(){await this._call("hide")}async show(){await this._call("show")}async focus(){await this._call("focus")}async hideDockIcon(){await this._call("hideDockIcon")}async showDockIcon(){await this._call("showDockIcon")}async setBadge(e){await this._call("setBadge",{badge:e?.toString()??""})}async getBadge(){return this._call("getBadge")}async bounce(e="informational"){return this._call("bounce",{type:e})}async cancelBounce(e){await this._call("cancelBounce",{id:e})}async setDockIcon(e){await this._call("setDockIcon",{icon:e})}async getInfo(){if(!this._info)this._info=await this._call("getInfo");return this._info}async getName(){return(await this.getInfo()).name}async getVersion(){return(await this.getInfo()).version}async getAppPath(){return(await this.getInfo()).appPath}async getPath(e){return this._call("getPath",{name:e})}async getSystemPreferences(){if(!this._preferences)this._preferences=await this._call("getSystemPreferences");return this._preferences}async isDarkMode(){if(typeof window<"u"&&window.matchMedia)return window.matchMedia("(prefers-color-scheme: dark)").matches;return(await this.getSystemPreferences()).isDarkMode}async getAccentColor(){return(await this.getSystemPreferences()).accentColor}async isReducedMotion(){if(typeof window<"u"&&window.matchMedia)return window.matchMedia("(prefers-reduced-motion: reduce)").matches;return(await this.getSystemPreferences()).reducedMotion}async getLocale(){if(typeof navigator<"u")return navigator.language||"en-US";return(await this.getSystemPreferences()).locale}async getDisplays(){return this._call("getDisplays")}async getPrimaryDisplay(){return this._call("getPrimaryDisplay")}async getDisplayAtPoint(e,t){return this._call("getDisplayAtPoint",{x:e,y:t})}async notify(e){await this._call("notify",e)}async isNotificationSupported(){if(typeof Notification<"u")return Notification.permission!=="denied";return this._call("isNotificationSupported")}async registerShortcut(e,t){return this._shortcuts.set(e,t),this._call("registerShortcut",{accelerator:e})}async unregisterShortcut(e){this._shortcuts.delete(e),await this._call("unregisterShortcut",{accelerator:e})}async unregisterAllShortcuts(){this._shortcuts.clear(),await this._call("unregisterAllShortcuts")}async isShortcutRegistered(e){return this._call("isShortcutRegistered",{accelerator:e})}async setAppearance(e){await this._call("setAppearance",{appearance:e})}async getAppearance(){return this._call("getAppearance")}async startPowerSaveBlocker(e){return this._call("startPowerSaveBlocker",{type:e})}async stopPowerSaveBlocker(e){await this._call("stopPowerSaveBlocker",{id:e})}async isPowerSaveBlockerActive(e){return this._call("isPowerSaveBlockerActive",{id:e})}async getIdleTime(){return this._call("getIdleTime")}async setLoginItemSettings(e){await this._call("setLoginItemSettings",e)}async getLoginItemSettings(){return this._call("getLoginItemSettings")}async _call(e,t){if(I())return L(`app.${e}`,{type:"app",action:e,data:t});return x().request(`app.${e}`,t)}}var P=new _t,Yi=P,Ji=()=>P.quit(),Xi=()=>P.hide(),Zi=()=>P.focus(),ea=()=>P.hideDockIcon(),ta=()=>P.showDockIcon(),ra=(e)=>P.setBadge(e),na=()=>P.getInfo(),ia=()=>P.getVersion(),aa=()=>P.getName(),sa=(e)=>P.getPath(e),oa=()=>P.isDarkMode(),ca=()=>P.getLocale(),da=(e)=>P.notify(e),la=(e,t)=>P.registerShortcut(e,t),ua=(e)=>P.unregisterShortcut(e);function j(){if(typeof window<"u"&&window.craft?.fs)return window.craft.fs;return null}async function M(e,t){return x().request(e,t)}function E(e,t){if(typeof e!=="string"||e.length===0)throw Error("Invalid path: must be a non-empty string");if(e.includes("\x00"))throw Error("Invalid path: contains null byte");let r=e;try{r=decodeURIComponent(e)}catch{throw Error("Invalid path: malformed percent-encoding")}let n=r.replace(/\\/g,"/").split("/");for(let i of n)if(i==="..")throw Error(`Path traversal detected: "${e}" contains a ".." segment`);if(t){let i=t.endsWith("/")?t:`${t}/`,a=r.startsWith("/")?r:`${i}${r}`;if(!a.startsWith(i)&&a!==t)throw Error(`Path escapes root: "${e}" not within "${t}"`)}}function Qr(e){let t=[],r=32768;for(let n=0;n<e.byteLength;n+=32768)t.push(String.fromCharCode(...e.subarray(n,n+32768)));if(typeof btoa==="function")return btoa(t.join(""));return Buffer.from(e).toString("base64")}function Yr(e){if(typeof atob==="function"){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}return new Uint8Array(Buffer.from(e,"base64"))}var fa={async readFile(e){E(e);let t=j();if(t)return t.readFile(e);if(typeof window<"u"&&window.craft)return M("fs.readFile",{path:e});let{readFile:r}=await import("fs/promises");return r(e,"utf-8")},async writeFile(e,t){E(e);let r=j();if(r)return r.writeFile(e,t);if(typeof window<"u"&&window.craft){await M("fs.writeFile",{path:e,content:t});return}let{writeFile:n}=await import("fs/promises");return n(e,t,"utf-8")},async readDir(e){E(e);let t=(i)=>i.filter((a)=>a!=="."&&a!==".."),r=j();if(r)return t(await r.readDir(e));if(typeof window<"u"&&window.craft)return t(await M("fs.readDir",{path:e}));let{readdir:n}=await import("fs/promises");return t(await n(e))},async mkdir(e){E(e);let t=j();if(t)return t.mkdir(e);if(typeof window<"u"&&window.craft){await M("fs.mkdir",{path:e});return}let{mkdir:r}=await import("fs/promises");await r(e,{recursive:!0})},async remove(e){E(e);let t=j();if(t)return t.remove(e);if(typeof window<"u"&&window.craft){await M("fs.remove",{path:e});return}let{rm:r}=await import("fs/promises");return r(e,{recursive:!0,force:!0})},async exists(e){E(e);let t=j();if(t)return t.exists(e);if(typeof window<"u"&&window.craft)return M("fs.exists",{path:e});let{access:r}=await import("fs/promises");try{return await r(e),!0}catch{return!1}}};async function ha(e){if(E(e),typeof window<"u"&&window.craft){let r=await M("fs.readBinaryFile",{path:e});return Yr(r.data)}let{readFile:t}=await import("fs/promises");return t(e)}async function wa(e,t){if(E(e),typeof window<"u"&&window.craft){await M("fs.writeBinaryFile",{path:e,_binary:!0,data:Qr(t)});return}let{writeFile:r}=await import("fs/promises");return r(e,t)}async function pa(e){if(E(e),typeof window<"u"&&window.craft){let n=await M("fs.stat",{path:e});return{size:n.size,isFile:n.isFile,isDirectory:n.isDirectory,modifiedAt:new Date(n.modifiedAt),createdAt:new Date(n.createdAt)}}let{stat:t}=await import("fs/promises"),r=await t(e);return{size:r.size,isFile:r.isFile(),isDirectory:r.isDirectory(),modifiedAt:r.mtime,createdAt:r.birthtime}}async function ma(e,t){if(E(e),E(t),typeof window<"u"&&window.craft){await M("fs.copy",{src:e,dest:t});return}let{cp:r}=await import("fs/promises");return r(e,t,{recursive:!0,dereference:!1,verbatimSymlinks:!0})}async function ga(e,t){if(E(e),E(t),typeof window<"u"&&window.craft){await M("fs.move",{src:e,dest:t});return}let{rename:r}=await import("fs/promises");return r(e,t)}var Ze=!1;async function ya(e,t,r={}){E(e);let n=r.recursive??!0;if(typeof window<"u"&&window.craft){let d=typeof globalThis.crypto<"u"&&"randomUUID"in globalThis.crypto?globalThis.crypto.randomUUID():`${Date.now()}_${performance.now()}`;await M("fs.watch",{path:e,watchId:d,recursive:n});let l=(u)=>{if(u.detail.watchId===d)t(u.detail.eventType,u.detail.filename)};return window.addEventListener("craft:fs:watch",l),()=>{window.removeEventListener("craft:fs:watch",l),M("fs.unwatch",{watchId:d})}}let i=await import("fs"),a=typeof process<"u"?process.platform:"";if(n&&a==="linux"&&!Ze)Ze=!0,console.warn("[Craft fs.watch] recursive watching is not supported by node:fs.watch on linux; only direct children of the path will fire events. Use the Craft bridge for true recursion.");let c=i.watch(e,{recursive:n&&a!=="linux"},(d,l)=>{if(l)t(d,l)});return()=>c.close()}async function fe(e,t){return x().request(e,t)}var Xr=/^\s*(?:--[^\n]*\n\s*)*(INSERT|UPDATE|DELETE|REPLACE|DROP|CREATE|ALTER|TRUNCATE|ATTACH|DETACH|VACUUM|REINDEX|PRAGMA)\b/i,Zr=new Jr().setMaxListeners(0),et=64;function he(e,t="identifier"){if(typeof e!=="string"||e.length===0)throw Error(`Invalid ${t} name: must be a non-empty string`);if(e.length>et)throw Error(`Invalid ${t} name: "${e.slice(0,16)}\u2026" exceeds ${et} characters`);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw Error(`Invalid ${t} name: "${e}". ${t} names must contain only letters, numbers, and underscores.`)}function en(e){if(e===null||e===void 0)return"NULL";if(typeof e==="boolean")return e?"1":"0";if(typeof e==="number"){if(!Number.isFinite(e))throw Error(`Invalid DEFAULT: ${e} is not a finite number`);return String(e)}if(typeof e==="string")return`'${e.replace(/'/g,"''")}'`;throw Error(`Invalid DEFAULT: ${typeof e} cannot be encoded as a SQL literal`)}var va={async execute(e,t){if(typeof window<"u"&&window.craft?.db)return window.craft.db.execute(e,t);throw Error("Database API not available. Must run in Craft environment.")},async query(e,t){if(typeof window<"u"&&window.craft?.db)return window.craft.db.query(e,t);throw Error("Database API not available. Must run in Craft environment.")},async beginTransaction(){if(typeof window<"u"&&window.craft?.db)return window.craft.db.beginTransaction();throw Error("Database API not available. Must run in Craft environment.")},async commit(){if(typeof window<"u"&&window.craft?.db)return window.craft.db.commit();throw Error("Database API not available. Must run in Craft environment.")},async rollback(){if(typeof window<"u"&&window.craft?.db)return window.craft.db.rollback();throw Error("Database API not available. Must run in Craft environment.")}};async function xa(e){let t=e.replace(/\\/g,"/");if(t.includes("/../")||t.startsWith("../")||t.endsWith("/..")||t===".."||e.includes("\x00"))throw Error(`Invalid database name: "${e}" contains path traversal or invalid characters`);return new It(e)}class It{name;isOpen=!1;readOnly;_inTransactionHelper=!1;constructor(e,t){this.name=e,this.readOnly=t?.readOnly===!0}isReadOnly(){return this.readOnly}async open(){if(typeof window<"u"&&window.craft){await fe("db.open",{name:this.name}),this.isOpen=!0;return}throw Error("Database API not available. Must run in Craft environment.")}async close(){if(typeof window<"u"&&window.craft){await fe("db.close",{name:this.name}),this.isOpen=!1;return}throw Error("Database API not available. Must run in Craft environment.")}async execute(e,t){if(!this.isOpen)await this.open();if(Zr.emit("db:execute",{name:this.name,sql:e,paramsCount:t?.length??0,readOnly:this.readOnly}),this.readOnly&&Xr.test(e))throw Error(`Database "${this.name}" is read-only; rejected mutating statement: ${e.slice(0,64)}`);if(typeof window<"u"&&window.craft){let r=await fe("db.execute",{name:this.name,sql:e,params:t||[]});return{rowsAffected:r.rowsAffected,lastInsertId:r.lastInsertId}}throw Error("Database API not available. Must run in Craft environment.")}async query(e,t){if(!this.isOpen)await this.open();if(typeof window<"u"&&window.craft)return fe("db.query",{name:this.name,sql:e,params:t||[]});throw Error("Database API not available. Must run in Craft environment.")}async get(e,t){let r=await this.query(e,t);return r.length>0?r[0]:null}async transaction(e){if(this._inTransactionHelper)throw Error("[Craft DB] transaction() is already active on this connection. "+"Nested transactions are not supported \u2014 refactor inner code to take "+"an existing handle, or use SAVEPOINT directly.");this._inTransactionHelper=!0;try{await this.execute("BEGIN TRANSACTION");try{let t=await e();return await this.execute("COMMIT"),t}catch(t){try{await this.execute("ROLLBACK")}catch(r){if(console.error("[Craft DB] ROLLBACK failed after transaction error:",r),t instanceof Error)t.cause=r}throw t}}finally{this._inTransactionHelper=!1}}async createTable(e,t){he(e,"table");let r=t.map((i)=>{he(i.name,"column");let a=`${i.name} ${i.type}`;if(i.primaryKey)a+=" PRIMARY KEY";if(i.autoIncrement)a+=" AUTOINCREMENT";if(i.notNull)a+=" NOT NULL";if(i.unique)a+=" UNIQUE";if(i.default!==void 0)a+=` DEFAULT ${en(i.default)}`;return a}),n=`CREATE TABLE IF NOT EXISTS ${e} (${r.join(", ")})`;await this.execute(n)}async dropTable(e){he(e,"table"),await this.execute(`DROP TABLE IF EXISTS ${e}`)}async tableExists(e){return he(e,"table"),(await this.query("SELECT name FROM sqlite_master WHERE type='table' AND name=?",[e])).length>0}}class tn{db;tableName;constructor(e,t="kv_store"){this.db=e,this.tableName=t}async init(){await this.db.createTable(this.tableName,[{name:"key",type:"TEXT",primaryKey:!0},{name:"value",type:"TEXT"},{name:"updated_at",type:"INTEGER"}])}async get(e){let t=await this.db.get(`SELECT value FROM ${this.tableName} WHERE key = ?`,[e]);if(t)try{return JSON.parse(t.value)}catch(r){return console.debug("[Craft DB] Failed to parse stored value for key, returning raw:",r),t.value}return null}async set(e,t){let r=JSON.stringify(t);await this.db.execute(`INSERT OR REPLACE INTO ${this.tableName} (key, value, updated_at) VALUES (?, ?, ?)`,[e,r,Date.now()])}async delete(e){await this.db.execute(`DELETE FROM ${this.tableName} WHERE key = ?`,[e])}async has(e){return await this.db.get(`SELECT key FROM ${this.tableName} WHERE key = ?`,[e])!==null}async keys(){return(await this.db.query(`SELECT key FROM ${this.tableName}`)).map((t)=>t.key)}async clear(){await this.db.execute(`DELETE FROM ${this.tableName}`)}}function rn(e){if(e===void 0||e===null)return{kind:"none",value:void 0};if(typeof e==="string")return{kind:"string",value:e};if(e instanceof ArrayBuffer)return{kind:"binary",value:e};if(ArrayBuffer.isView(e))return{kind:"binary",value:e};if(typeof Blob<"u"&&e instanceof Blob)return{kind:"binary",value:e};if(typeof FormData<"u"&&e instanceof FormData)return{kind:"form",value:e};if(typeof URLSearchParams<"u"&&e instanceof URLSearchParams)return{kind:"form",value:e};if(typeof ReadableStream<"u"&&e instanceof ReadableStream)return{kind:"binary",value:e};if(e!==null&&typeof e==="object"&&e[Symbol.asyncIterator]!==void 0)return{kind:"binary",value:e};return{kind:"json",value:JSON.stringify(e)}}function nn(e,t){let r=t.toLowerCase();for(let n of Object.keys(e))if(n.toLowerCase()===r)return!0;return!1}var an={async fetch(e,t){if(typeof window<"u"&&window.craft?.http)return window.craft.http.fetch(e,t);return globalThis.fetch(e,t)},async download(e,t,r){if(typeof window<"u"&&window.craft?.http){let n=r,i=r?(a)=>n?.(a):void 0;try{return await window.craft.http.download(e,t,i)}finally{n=void 0}}throw Error("Download API requires Craft environment")},async upload(e,t,r){if(typeof window<"u"&&window.craft?.http){let n=r,i=r?(a)=>n?.(a):void 0;try{return await window.craft.http.upload(e,t,i)}finally{n=void 0}}throw Error("Upload API requires Craft environment")}};class Tt{baseUrl;defaultHeaders;timeout;constructor(e={}){this.baseUrl=e.baseUrl||"",this.defaultHeaders=e.headers||{},this.timeout=e.timeout||30000}async get(e,t){return this.request("GET",e,t)}async post(e,t,r){return this.request("POST",e,{...r,body:t})}async put(e,t,r){return this.request("PUT",e,{...r,body:t})}async patch(e,t,r){return this.request("PATCH",e,{...r,body:t})}async delete(e,t){return this.request("DELETE",e,t)}async head(e,t){return this.request("HEAD",e,t)}async request(e,t,r={}){let n=this.buildUrl(t,r.params),i={...this.defaultHeaders,...r.headers},a=rn(r.body);if(a.kind==="json"&&!nn(i,"content-type"))i["Content-Type"]="application/json";let c=r.timeout||this.timeout,d=new AbortController,l=setTimeout(()=>d.abort(),c);try{let u=await an.fetch(n,{method:e,headers:i,body:a.value,signal:d.signal,...typeof r.timeout==="number"||typeof this.timeout==="number"?{timeoutMs:c}:{}}),f,w=u.headers.get("content-type")??"";if(w.includes("application/json"))try{f=await u.json()}catch{f=await u.text()}else if(w.startsWith("text/"))f=await u.text();else if(w.includes("octet-stream")||w.startsWith("image/")||w.startsWith("audio/")||w.startsWith("video/")||w.startsWith("application/"))f=await u.arrayBuffer();else if(u.body===null)f=null;else f=await u.text();return{data:f,status:u.status,statusText:u.statusText,headers:Object.fromEntries(u.headers.entries()),ok:u.ok}}catch(u){if(u instanceof Error&&u.name==="AbortError")throw new Pt("Request timeout",0,"TIMEOUT");throw u}finally{clearTimeout(l)}}buildUrl(e,t){let r=e.startsWith("http")?e:`${this.baseUrl}${e}`;if(t){let n=new URLSearchParams;for(let[a,c]of Object.entries(t))n.append(a,String(c));let i=n.toString();if(i)r+=(r.includes("?")?"&":"?")+i}return r}setHeader(e,t){this.defaultHeaders[e]=t}removeHeader(e){delete this.defaultHeaders[e]}setBearerToken(e){this.setHeader("Authorization",`Bearer ${e}`)}}class Pt extends Error{status;code;constructor(e,t,r="HTTP_ERROR"){super(e);this.name="HttpError",this.status=t,this.code=r}}class sn{ws=null;url;reconnectAttempts=0;maxReconnectAttempts;reconnectDelay;handlers=new Map;messageHandler=null;constructor(e,t={}){this.url=e,this.maxReconnectAttempts=t.maxReconnectAttempts||5,this.reconnectDelay=t.reconnectDelay||1000}connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,e()},this.ws.onerror=(r)=>{t(Error("WebSocket connection failed"))},this.ws.onclose=()=>{this.attemptReconnect()},this.messageHandler=(r)=>{try{let n=JSON.parse(r.data),i=n.type||"message",a=this.handlers.get(i);if(a)a.forEach((c)=>c(n.payload||n))}catch{let n=this.handlers.get("message");if(n)n.forEach((i)=>i(r.data))}},this.ws.onmessage=this.messageHandler})}disconnect(){if(this.maxReconnectAttempts=0,this.ws)this.ws.close(),this.ws=null}send(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw Error("WebSocket not connected");this.ws.send(JSON.stringify({type:e,payload:t}))}sendRaw(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw Error("WebSocket not connected");this.ws.send(e)}on(e,t){if(!this.handlers.has(e))this.handlers.set(e,new Set);return this.handlers.get(e).add(t),()=>{this.handlers.get(e)?.delete(t)}}attemptReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return;this.reconnectAttempts++;let e=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);setTimeout(()=>{this.connect().catch(()=>{})},e)}get connected(){return this.ws?.readyState===WebSocket.OPEN}}function ka(e){return new Tt(e)}class H extends Error{name="CraftCryptoError";cause;constructor(e,t){super(e,t);if(t&&"cause"in t)this.cause=t.cause}}class Ct extends H{name="LegacyCiphertextError";constructor(){super("Ciphertext was produced by a pre-versioning Craft crypto release. Re-encrypt the value with the current API to migrate to the v1 wire format.")}}var tt=1,K=16,we=12,Be=16,ve=600000,ne={async randomBytes(e){if(typeof window<"u"&&window.craft?.crypto)return window.craft.crypto.randomBytes(e);if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.getRandomValues==="function"){let r=new Uint8Array(e),n=65536;for(let i=0;i<e;i+=65536){let a=r.subarray(i,Math.min(i+65536,e));globalThis.crypto.getRandomValues(a)}return r}let{randomBytes:t}=await import("crypto");return new Uint8Array(t(e))},async hash(e,t){if(typeof window<"u"&&window.craft?.crypto)return window.craft.crypto.hash(e,t);if(e==="md5"){if(!(typeof process<"u"&&process.versions?.node))throw new H("MD5 is not available in this runtime \u2014 WebCrypto does not implement it. "+"Use sha256/sha512, or call this from Node.");let{createHash:i}=await import("crypto");return i("md5").update(t).digest("hex")}if(typeof globalThis.crypto<"u"&&globalThis.crypto.subtle){let i=new TextEncoder().encode(t),a=await globalThis.crypto.subtle.digest(e==="sha256"?"SHA-256":"SHA-512",i);return $t(a)}let{createHash:r}=await import("crypto");return r(e).update(t).digest("hex")},async encrypt(e,t){if(typeof window<"u"&&window.craft?.crypto)return window.craft.crypto.encrypt(e,t);let r=await ne.randomBytes(K),n=await ne.randomBytes(we),i=await rt(t,r),a=await on(i,n,new TextEncoder().encode(e)),c=new Uint8Array(1+r.length+n.length+a.length);return c[0]=tt,c.set(r,1),c.set(n,1+r.length),c.set(a,1+r.length+n.length),ye(c.buffer)},async decrypt(e,t){if(typeof window<"u"&&window.craft?.crypto)return window.craft.crypto.decrypt(e,t);let r=Et(e);if(r.length<1+K+we+Be)throw new H("Ciphertext too short to be valid");if(r[0]!==tt)throw new Ct;let i=r.slice(1,1+K),a=r.slice(1+K,1+K+we),c=r.slice(1+K+we),d=await rt(t,i);try{let l=await cn(d,a,c);return new TextDecoder().decode(l)}catch(l){throw new H("Decryption failed (wrong key or corrupted data)",{cause:l})}}};function X(e){return e}async function rt(e,t){if(typeof globalThis.crypto<"u"&&globalThis.crypto.subtle){let n=new TextEncoder,i=await globalThis.crypto.subtle.importKey("raw",n.encode(e),"PBKDF2",!1,["deriveKey"]);return globalThis.crypto.subtle.deriveKey({name:"PBKDF2",salt:X(t),iterations:ve,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}let{pbkdf2Sync:r}=await import("crypto");return new Uint8Array(r(e,t,ve,32,"sha256"))}async function on(e,t,r){if(e instanceof Uint8Array){let{createCipheriv:i}=await import("crypto"),a=i("aes-256-gcm",e,t),c=a.update(r),d=a.final(),l=a.getAuthTag(),u=new Uint8Array(c.length+d.length+l.length);return u.set(c,0),u.set(d,c.length),u.set(l,c.length+d.length),u}let n=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:X(t)},e,X(r));return new Uint8Array(n)}async function cn(e,t,r){if(e instanceof Uint8Array){let{createDecipheriv:i}=await import("crypto"),a=r.subarray(r.length-Be),c=r.subarray(0,r.length-Be),d=i("aes-256-gcm",e,t);d.setAuthTag(a);let l=d.update(c),u=d.final(),f=new Uint8Array(l.length+u.length);return f.set(l,0),f.set(u,l.length),f}let n=await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:X(t)},e,X(r));return new Uint8Array(n)}function $t(e){return Array.from(new Uint8Array(e)).map((t)=>t.toString(16).padStart(2,"0")).join("")}function ye(e){let t=new Uint8Array(e),r=[],n=8192;for(let i=0;i<t.byteLength;i+=8192)r.push(String.fromCharCode(...t.subarray(i,i+8192)));if(typeof btoa<"u")return btoa(r.join(""));return Buffer.from(t).toString("base64")}function Et(e){if(typeof atob<"u"){let t;try{t=atob(e)}catch(n){throw new H("Invalid base64 input",{cause:n})}let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}return new Uint8Array(Buffer.from(e,"base64"))}function Sa(){if(typeof globalThis.crypto<"u"&&"randomUUID"in globalThis.crypto)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,(r)=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}async function _a(e,t){let r=t??"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if(r.length===0)throw new H("randomString: charset cannot be empty");if(!Number.isInteger(e)||e<0)throw new H("randomString: length must be a non-negative integer");if(e===0)return"";let n=256-256%r.length,i=await ne.randomBytes(e*2),a="",c=0;while(a.length<e){if(c>=i.length)i=await ne.randomBytes(e*2),c=0;if(i[c]<n)a+=r[i[c]%r.length];c++}return a}async function Ia(e,t,r){if(typeof globalThis.crypto<"u"&&globalThis.crypto.subtle){let i=new TextEncoder,a=await globalThis.crypto.subtle.importKey("raw",i.encode(t),{name:"HMAC",hash:e==="sha256"?"SHA-256":"SHA-512"},!1,["sign"]),c=await globalThis.crypto.subtle.sign("HMAC",a,i.encode(r));return $t(c)}return(await import("crypto")).createHmac(e,t).update(r).digest("hex")}function dn(e,t){let r=new TextEncoder,n=r.encode(e),i=r.encode(t),a=Math.max(n.length,i.length),c=n.length^i.length;for(let d=0;d<a;d++)c|=(n[d]??0)^(i[d]??0);return c===0}async function ln(e,t){let r;if(t)try{r=Et(t)}catch(a){throw new H("hashPassword: salt must be base64-encoded",{cause:a})}else r=await ne.randomBytes(16);let n=ye(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength));if(typeof globalThis.crypto<"u"&&globalThis.crypto.subtle){let a=new TextEncoder,c=await globalThis.crypto.subtle.importKey("raw",a.encode(e),"PBKDF2",!1,["deriveBits"]),d=await globalThis.crypto.subtle.deriveBits({name:"PBKDF2",salt:X(r),iterations:ve,hash:"SHA-256"},c,256);return{hash:ye(d),salt:n}}let{pbkdf2:i}=await import("crypto");return new Promise((a,c)=>{i(e,r,ve,32,"sha256",(d,l)=>{if(d)c(d);else a({hash:ye(l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)),salt:n})})})}async function Ta(e,t,r){let n=await ln(e,r);return dn(n.hash,t)}async function q(e,t){return x().request(e,t)}var V=typeof process<"u"?process.env:{},Pa=new Proxy(V,{get(e,t){return V[t]},set(e,t,r){return V[t]=r,!0},deleteProperty(e,t){return delete V[t],!0},ownKeys(){return Reflect.ownKeys(V)},getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(V,t)},has(e,t){return t in V}});function s(){if(typeof globalThis<"u"){let e=globalThis;if(e.craft?._platform)return e.craft._platform;if(e.__CRAFT_PLATFORM__)return e.__CRAFT_PLATFORM__}if(typeof process<"u"&&process.platform)return process.platform;if(typeof navigator<"u"&&typeof navigator.userAgent==="string"){let e=navigator.userAgent.toLowerCase();if(e.includes("iphone")||e.includes("ipad"))return"ios";if(e.includes("android"))return"android";if(e.includes("mac"))return"darwin";if(e.includes("win"))return"win32";if(e.includes("linux"))return"linux"}return"unknown"}function Ca(){let e=s();return e==="darwin"||e==="macos"||e==="win32"||e==="windows"||e==="linux"}function $a(){let e=s();return e==="ios"||e==="android"}function o(){return typeof window<"u"&&typeof window.craft<"u"}async function Ea(){if(typeof window<"u"&&window.craft)return q("process.getSystemInfo");if(typeof process<"u"){let t=await import("os");return{platform:process.platform,arch:process.arch,osVersion:t.release(),hostname:t.hostname(),cpuCount:t.cpus().length,totalMemory:t.totalmem(),freeMemory:t.freemem(),uptime:t.uptime()}}let e=typeof navigator<"u"&&typeof navigator.hardwareConcurrency==="number"?navigator.hardwareConcurrency:1;return{platform:s(),arch:"unknown",osVersion:"unknown",hostname:"unknown",cpuCount:e,totalMemory:0,freeMemory:0,uptime:0}}async function Aa(e,t){if(typeof window<"u"&&window.craft)return q("process.exec",{command:e,...t});let{exec:r}=await import("child_process"),{promisify:n}=await import("util"),i=n(r);try{let{stdout:a,stderr:c}=await i(e,{cwd:t?.cwd,env:t?.env?{...process.env,...t.env}:void 0,timeout:t?.timeout,maxBuffer:t?.maxBuffer||1048576});return{stdout:a,stderr:c,exitCode:0}}catch(a){return{stdout:a.stdout||"",stderr:a.stderr||a.message,exitCode:a.code||1}}}class At{command;args;options;processId=null;onStdoutHandlers=[];onStderrHandlers=[];onExitHandlers=[];domListeners=[];exited=!1;constructor(e,t=[],r={}){this.command=e,this.args=t,this.options=r}addDomListener(e,t){if(typeof window>"u")return;window.addEventListener(e,t),this.domListeners.push({type:e,handler:t})}removeDomListeners(){if(typeof window>"u")return;for(let{type:e,handler:t}of this.domListeners)window.removeEventListener(e,t);this.domListeners=[]}get pid(){return this.processId}async start(){if(typeof window<"u"&&window.craft){let e=await q("process.spawn",{command:this.command,args:this.args,...this.options});this.processId=e.pid;let t=(i)=>{if(i.detail.pid===this.processId)this.onStdoutHandlers.forEach((a)=>a(i.detail.data))},r=(i)=>{if(i.detail.pid===this.processId)this.onStderrHandlers.forEach((a)=>a(i.detail.data))},n=(i)=>{if(i.detail.pid===this.processId)this.exited=!0,this.onExitHandlers.forEach((a)=>a(i.detail.code)),this.removeDomListeners()};this.addDomListener("craft:process:stdout",t),this.addDomListener("craft:process:stderr",r),this.addDomListener("craft:process:exit",n);return}throw Error("spawn() requires Craft environment")}async write(e){if(typeof window<"u"&&window.craft&&this.processId)await q("process.stdin",{pid:this.processId,data:e})}async kill(e="SIGTERM"){if(typeof window<"u"&&window.craft&&this.processId){if(await q("process.kill",{pid:this.processId,signal:e}),this.exited)this.removeDomListeners()}}onStdout(e){return this.onStdoutHandlers.push(e),()=>{let t=this.onStdoutHandlers.indexOf(e);if(t>=0)this.onStdoutHandlers.splice(t,1)}}onStderr(e){return this.onStderrHandlers.push(e),()=>{let t=this.onStderrHandlers.indexOf(e);if(t>=0)this.onStderrHandlers.splice(t,1)}}onExit(e){return this.onExitHandlers.push(e),()=>{let t=this.onExitHandlers.indexOf(e);if(t>=0)this.onExitHandlers.splice(t,1)}}}function Ma(e,t,r){return new At(e,t,r)}function Ba(){if(typeof process<"u")return process.cwd();return"/"}async function Da(){if(typeof window<"u"&&window.craft)return q("process.homeDir");if(typeof process<"u")return(await import("os")).homedir();return"/"}async function La(){if(typeof window<"u"&&window.craft)return q("process.tempDir");if(typeof process<"u")return(await import("os")).tmpdir();return"/tmp"}function Ra(e=0){if(typeof window<"u"){let t=window.craft?.app;if(t&&typeof t.quit==="function"){t.quit(e);return}}if(typeof process<"u"&&typeof process.exit==="function")process.exit(e)}function Fa(){if(typeof process<"u")return process.argv;return[]}async function Ua(e){if(typeof window<"u"&&window.craft){await q("process.open",{target:e});return}let t=s(),{execFile:r}=await import("child_process"),{promisify:n}=await import("util"),i=n(r);switch(t){case"darwin":case"macos":await i("open",[e]);return;case"win32":case"windows":await i("cmd.exe",["/c","start",'""',e]);return;case"linux":await i("xdg-open",[e]);return;default:throw Error(`Unsupported platform: ${t}`)}}var nt="__craft_web_device_id__";function un(){if(typeof globalThis<"u"&&globalThis.localStorage)try{let e=globalThis.localStorage,t=e.getItem(nt);if(t&&/^web-[0-9a-f-]+$/i.test(t))return t;let r=`web-${Me()}`;return e.setItem(nt,r),r}catch{}return`web-${Me()}`}var Oa={async getInfo(){let e=b();if(typeof window<"u"&&e?.device)return e.device.getInfo();return{platform:pe(),osVersion:"unknown",model:"unknown",manufacturer:"unknown",deviceId:un(),isTablet:!1,screen:{width:typeof window<"u"?window.innerWidth||0:0,height:typeof window<"u"?window.innerHeight||0:0,scale:typeof window<"u"?window.devicePixelRatio||1:1},battery:{level:100,isCharging:!1},network:{type:"wifi",isConnected:typeof navigator<"u"?navigator.onLine??!0:!0}}},async getCapabilities(){let e=b();if(typeof window<"u"&&e?.device)return e.device.getCapabilities();return{camera:!0,biometrics:!1,nfc:!1,bluetooth:!1,gps:"geolocation"in navigator,accelerometer:!1,gyroscope:!1,haptics:"vibrate"in navigator,ar:!1,faceId:!1,touchId:!1}},isMobile(){let e=pe();return e==="ios"||e==="android"},isIOS(){return pe()==="ios"},isAndroid(){return pe()==="android"},getLocale(){return navigator?.language||"en-US"},getTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}},Ha={async impact(e="medium"){let t=b();if(typeof window<"u"&&t?.haptics)return t.haptics.impact(e);if("vibrate"in navigator){let r={light:10,medium:20,heavy:30,soft:5,rigid:25}[e];navigator.vibrate(r)}},async notification(e="success"){let t=b();if(typeof window<"u"&&t?.haptics)return t.haptics.notification(e);if("vibrate"in navigator){let r={success:[10,30,10],warning:[30,30,30],error:[50,50,50,50,50]};navigator.vibrate(r[e])}},async selection(){let e=b();if(typeof window<"u"&&e?.haptics)return e.haptics.selection();if("vibrate"in navigator)navigator.vibrate(5)},async vibrate(e){let t=b();if(typeof window<"u"&&t?.haptics)return t.haptics.vibrate(e);if("vibrate"in navigator)navigator.vibrate(e)}},Na={async check(e){let t=b();if(typeof window<"u"&&t?.permissions)return t.permissions.check(e);try{let r=fn(e);if(r&&navigator.permissions){let n=await navigator.permissions.query({name:r});return hn(n.state)}}catch{}return"undetermined"},async request(e){let t=b();if(typeof window<"u"&&t?.permissions)return t.permissions.request(e);try{if(e==="camera"||e==="microphone"){let r={};if(e==="camera")r.video=!0;if(e==="microphone")r.audio=!0;return(await navigator.mediaDevices.getUserMedia(r)).getTracks().forEach((i)=>i.stop()),"granted"}if(e==="location")return new Promise((r)=>{navigator.geolocation.getCurrentPosition(()=>r("granted"),()=>r("denied"))});if(e==="notifications")return await Notification.requestPermission()==="granted"?"granted":"denied"}catch{return"denied"}return"undetermined"},async checkMultiple(e){let t={};for(let r of e)t[r]=await this.check(r);return t},async requestMultiple(e){let t={};for(let r of e)t[r]=await this.request(r);return t},async openSettings(){let e=b();if(typeof window<"u"&&e?.permissions)return e.permissions.openSettings()}},qa={async takePicture(e={}){let t=b();if(typeof window<"u"&&t?.camera)return t.camera.takePicture(e);throw Error("Camera API not available. Must run in Craft environment.")},async pickImage(){let e=b();if(typeof window<"u"&&e?.camera)return e.camera.pickImage();return new Promise((t,r)=>{let n=document.createElement("input");n.type="file",n.accept="image/*",n.onchange=async()=>{let i=n.files?.[0];if(i){let a=new FileReader;a.onload=()=>{let c=a.result.split(",")[1];t({base64:c,uri:URL.createObjectURL(i),width:0,height:0,mimeType:i.type})},a.onerror=()=>r(Error("Failed to read file")),a.readAsDataURL(i)}else r(Error("No file selected"))},n.click()})},async pickMultiple(e={}){let t=b();if(typeof window<"u"&&t?.camera)return t.camera.pickMultiple(e);throw Error("Camera API not available. Must run in Craft environment.")},async isAvailable(){let e=b();if(typeof window<"u"&&e?.camera)return e.camera.isAvailable();try{return(await navigator.mediaDevices.enumerateDevices()).some((r)=>r.kind==="videoinput")}catch{return!1}}},Va={async isAvailable(){let e=b();if(typeof window<"u"&&e?.biometrics)return e.biometrics.isAvailable();return!1},async getBiometricType(){let e=b();if(typeof window<"u"&&e?.biometrics)return e.biometrics.getBiometricType();return null},async authenticate(e){let t=b();if(typeof window<"u"&&t?.biometrics)return t.biometrics.authenticate(e);throw Error("Biometrics not available")}},Wa={async set(e,t){let r=b();if(typeof window<"u"&&r?.secureStorage)return r.secureStorage.set(e,t);localStorage.setItem(`secure_${e}`,t)},async get(e){let t=b();if(typeof window<"u"&&t?.secureStorage)return t.secureStorage.get(e);return localStorage.getItem(`secure_${e}`)},async delete(e){let t=b();if(typeof window<"u"&&t?.secureStorage)return t.secureStorage.delete(e);localStorage.removeItem(`secure_${e}`)},async clear(){let e=b();if(typeof window<"u"&&e?.secureStorage)return e.secureStorage.clear();Object.keys(localStorage).filter((t)=>t.startsWith("secure_")).forEach((t)=>localStorage.removeItem(t))}},za={async getCurrentPosition(e={}){let t=b();if(typeof window<"u"&&t?.location)return t.location.getCurrentPosition(e);return new Promise((r,n)=>{navigator.geolocation.getCurrentPosition((i)=>r({latitude:i.coords.latitude,longitude:i.coords.longitude,altitude:i.coords.altitude??void 0,accuracy:i.coords.accuracy,heading:i.coords.heading??void 0,speed:i.coords.speed??void 0,timestamp:i.timestamp}),n,{enableHighAccuracy:e.enableHighAccuracy,timeout:e.timeout,maximumAge:e.maximumAge})})},watchPosition(e,t={}){let r=b();if(typeof window<"u"&&r?.location)return r.location.watchPosition(e,t);return navigator.geolocation.watchPosition((n)=>e({latitude:n.coords.latitude,longitude:n.coords.longitude,altitude:n.coords.altitude??void 0,accuracy:n.coords.accuracy,heading:n.coords.heading??void 0,speed:n.coords.speed??void 0,timestamp:n.timestamp}),console.error,{enableHighAccuracy:t.enableHighAccuracy,timeout:t.timeout,maximumAge:t.maximumAge})},clearWatch(e){let t=b();if(typeof window<"u"&&t?.location)return t.location.clearWatch(e);navigator.geolocation.clearWatch(e)}},ja={async share(e){let t=b();if(typeof window<"u"&&t?.share)return t.share.share(e);if(navigator.share)await navigator.share({title:e.title,text:e.text,url:e.url});else throw Error("Share API not available")},isAvailable(){let e=b();if(typeof window<"u"&&e?.share)return!0;return"share"in navigator}},Ka={getState(){let e=b();if(typeof window<"u"&&e?.lifecycle)return e.lifecycle.getState();return document.visibilityState==="visible"?"active":"background"},onStateChange(e){let t=b();if(typeof window<"u"&&t?.lifecycle)return t.lifecycle.onStateChange(e);let r=()=>{e(document.visibilityState==="visible"?"active":"background")};return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)}},Ga={async show(e){let t=b();if(typeof window<"u"&&t?.notifications)return t.notifications.show(e);if("Notification"in window&&Notification.permission==="granted")new Notification(e.title,{body:e.body})},async schedule(e){let t=b();if(typeof window<"u"&&t?.notifications)return t.notifications.schedule(e);throw Error("Scheduled notifications not available in web")},async cancelAll(){let e=b();if(typeof window<"u"&&e?.notifications)return e.notifications.cancelAll()},async setBadge(e){let t=b();if(typeof window<"u"&&t?.notifications)return t.notifications.setBadge(e)}};function pe(){if(typeof window>"u")return"linux";let e=navigator.userAgent.toLowerCase();if(/iphone|ipad|ipod/.test(e))return"ios";if(/android/.test(e))return"android";if(/macintosh|mac os x/.test(e))return"macos";if(/windows/.test(e))return"windows";return"linux"}function fn(e){return{camera:"camera",microphone:"microphone",location:"geolocation",notifications:"notifications"}[e]||null}function hn(e){return{granted:"granted",denied:"denied",prompt:"undetermined"}[e]}function b(){if(typeof window<"u")return window.craft;return}var Qa={async isAvailable(){if(!o()||s()!=="ios")return!1;return window.craft?.carplay?.isAvailable?.()??!1},async isConnected(){if(!o()||s()!=="ios")return!1;return window.craft?.carplay?.isConnected?.()??!1},onConnect(e){if(!o()||s()!=="ios")return;window.craft?.carplay?.onConnect?.(e)},onDisconnect(e){if(!o()||s()!=="ios")return;window.craft?.carplay?.onDisconnect?.(e)},async pushTemplate(e,t=!0){if(!o()||s()!=="ios")return;return window.craft?.carplay?.pushTemplate?.(e,t)},async popTemplate(e=!0){if(!o()||s()!=="ios")return;return window.craft?.carplay?.popTemplate?.(e)},async popToRootTemplate(e=!0){if(!o()||s()!=="ios")return;return window.craft?.carplay?.popToRootTemplate?.(e)},async presentTemplate(e,t=!0){if(!o()||s()!=="ios")return;return window.craft?.carplay?.presentTemplate?.(e,t)},async dismissTemplate(e=!0){if(!o()||s()!=="ios")return;return window.craft?.carplay?.dismissTemplate?.(e)},onSelectListItem(e){if(!o()||s()!=="ios")return;window.craft?.carplay?.onSelectListItem?.(e)},onSelectGridItem(e){if(!o()||s()!=="ios")return;window.craft?.carplay?.onSelectGridItem?.(e)},async updateNowPlaying(e){if(!o()||s()!=="ios")return;return window.craft?.carplay?.updateNowPlaying?.(e)}},Ya={isAppClip(){if(!o()||s()!=="ios")return!1;return window.craft?.appClips?.isAppClip?.()??!1},onInvoke(e){if(!o()||s()!=="ios")return;window.craft?.appClips?.onInvoke?.(e)},async getInvocation(){if(!o()||s()!=="ios")return null;return window.craft?.appClips?.getInvocation?.()},async promptToInstallFullApp(){if(!o()||s()!=="ios")return;return window.craft?.appClips?.promptToInstallFullApp?.()},async requestEphemeralNotificationPermission(){if(!o()||s()!=="ios")return!1;return window.craft?.appClips?.requestEphemeralNotificationPermission?.()??!1},async confirmLocation(e){if(!o()||s()!=="ios")return!1;return window.craft?.appClips?.confirmLocation?.(e)??!1}},Ja={async areSupported(){if(!o()||s()!=="ios")return!1;return window.craft?.liveActivities?.areSupported?.()??!1},async areEnabled(){if(!o()||s()!=="ios")return!1;return window.craft?.liveActivities?.areEnabled?.()??!1},async start(e){if(!o()||s()!=="ios")return{id:`mock-${Date.now()}`};return window.craft?.liveActivities?.start?.(e)??{id:`mock-${Date.now()}`}},async update(e,t,r){if(!o()||s()!=="ios")return;return window.craft?.liveActivities?.update?.(e,t,r)},async end(e,t,r){if(!o()||s()!=="ios")return;return window.craft?.liveActivities?.end?.(e,t,r)},async getAll(){if(!o()||s()!=="ios")return[];return window.craft?.liveActivities?.getAll?.()??[]},async requestPushToken(e){if(!o()||s()!=="ios")return null;return window.craft?.liveActivities?.requestPushToken?.(e)}},Xa={async isAvailable(){if(!o()||s()!=="ios")return!1;return window.craft?.sharePlay?.isAvailable?.()??!1},async getSessionState(){if(!o()||s()!=="ios")return null;return window.craft?.sharePlay?.getSessionState?.()},async getParticipants(){if(!o()||s()!=="ios")return[];return window.craft?.sharePlay?.getParticipants?.()??[]},async startActivity(e){if(!o()||s()!=="ios")return!1;return window.craft?.sharePlay?.startActivity?.(e)??!1},async endActivity(){if(!o()||s()!=="ios")return;return window.craft?.sharePlay?.endActivity?.()},async broadcast(e){if(!o()||s()!=="ios")return;return window.craft?.sharePlay?.broadcast?.(e)},async send(e,t){if(!o()||s()!=="ios")return;return window.craft?.sharePlay?.send?.(e,t)},onMessage(e){if(!o()||s()!=="ios")return;window.craft?.sharePlay?.onMessage?.(e)},onSessionStateChange(e){if(!o()||s()!=="ios")return;window.craft?.sharePlay?.onSessionStateChange?.(e)},onParticipantsChange(e){if(!o()||s()!=="ios")return;window.craft?.sharePlay?.onParticipantsChange?.(e)},async coordinatePlayback(e){if(!o()||s()!=="ios")return;return window.craft?.sharePlay?.coordinatePlayback?.(e)}},Za={async getProducts(e){if(!o()||s()!=="ios")return[];return window.craft?.storeKit?.getProducts?.(e)??[]},async purchase(e,t){if(!o()||s()!=="ios")return{success:!1,error:"StoreKit not available"};return window.craft?.storeKit?.purchase?.(e,t)??{success:!1}},async isEntitled(e){if(!o()||s()!=="ios")return!1;return window.craft?.storeKit?.isEntitled?.(e)??!1},async getCurrentEntitlements(){if(!o()||s()!=="ios")return[];return window.craft?.storeKit?.getCurrentEntitlements?.()??[]},async getTransactionHistory(e){if(!o()||s()!=="ios")return[];return window.craft?.storeKit?.getTransactionHistory?.(e)??[]},async restorePurchases(){if(!o()||s()!=="ios")return;return window.craft?.storeKit?.restorePurchases?.()},async finishTransaction(e){if(!o()||s()!=="ios")return;return window.craft?.storeKit?.finishTransaction?.(e)},async getSubscriptionStatus(e){if(!o()||s()!=="ios")return null;return window.craft?.storeKit?.getSubscriptionStatus?.(e)},async presentOfferCodeRedemption(){if(!o()||s()!=="ios")return;return window.craft?.storeKit?.presentOfferCodeRedemption?.()},async presentManageSubscriptions(){if(!o()||s()!=="ios")return;return window.craft?.storeKit?.presentManageSubscriptions?.()},async beginRefundRequest(e){if(!o()||s()!=="ios")return"failed";return window.craft?.storeKit?.beginRefundRequest?.(e)??"failed"},onTransactionUpdate(e){if(!o()||s()!=="ios")return;window.craft?.storeKit?.onTransactionUpdate?.(e)},async showPriceConsentIfNeeded(){if(!o()||s()!=="ios")return;return window.craft?.storeKit?.showPriceConsentIfNeeded?.()}},es={register(e){if(!o()||s()!=="ios")return;window.craft?.appIntents?.register?.(e)},unregister(e){if(!o()||s()!=="ios")return;window.craft?.appIntents?.unregister?.(e)},onPerform(e,t){if(!o()||s()!=="ios")return;window.craft?.appIntents?.onPerform?.(e,t)},async donate(e,t){if(!o()||s()!=="ios")return;return window.craft?.appIntents?.donate?.(e,t)},async deleteDonations(e){if(!o()||s()!=="ios")return;return window.craft?.appIntents?.deleteDonations?.(e)},async updateSpotlightIndex(e,t){if(!o()||s()!=="ios")return;return window.craft?.appIntents?.updateSpotlightIndex?.(e,t)}},ts={async configure(e){if(!o()||s()!=="ios")return;return window.craft?.tipKit?.configure?.(e)},register(e){if(!o()||s()!=="ios")return;window.craft?.tipKit?.register?.(e)},async shouldShow(e){if(!o()||s()!=="ios")return!1;return window.craft?.tipKit?.shouldShow?.(e)??!1},async invalidate(e,t){if(!o()||s()!=="ios")return;return window.craft?.tipKit?.invalidate?.(e,t)},async trackEvent(e){if(!o()||s()!=="ios")return;return window.craft?.tipKit?.trackEvent?.(e)},async setParameter(e,t){if(!o()||s()!=="ios")return;return window.craft?.tipKit?.setParameter?.(e,t)},async showPopover(e,t){if(!o()||s()!=="ios")return;return window.craft?.tipKit?.showPopover?.(e,t)},onAction(e,t){if(!o()||s()!=="ios")return;window.craft?.tipKit?.onAction?.(e,t)},async resetDatastore(){if(!o()||s()!=="ios")return;return window.craft?.tipKit?.resetDatastore?.()}},rs={async getAuthorizationStatus(){if(!o()||s()!=="ios")return"notDetermined";return window.craft?.focusFilters?.getAuthorizationStatus?.()??"notDetermined"},async requestAuthorization(){if(!o()||s()!=="ios")return!1;return window.craft?.focusFilters?.requestAuthorization?.()??!1},async getFocusStatus(){if(!o()||s()!=="ios")return{isFocusActive:!1};return window.craft?.focusFilters?.getFocusStatus?.()??{isFocusActive:!1}},register(e){if(!o()||s()!=="ios")return;window.craft?.focusFilters?.register?.(e)},async getCurrentFilterSettings(){if(!o()||s()!=="ios")return null;return window.craft?.focusFilters?.getCurrentFilterSettings?.()},onFocusChange(e){if(!o()||s()!=="ios")return;window.craft?.focusFilters?.onFocusChange?.(e)},onFilterChange(e){if(!o()||s()!=="ios")return;window.craft?.focusFilters?.onFilterChange?.(e)}},ns={async isSupported(){if(!o()||s()!=="android")return!1;return window.craft?.materialYou?.isSupported?.()??!1},async getColors(e=!1){if(!o()||s()!=="android")return null;return window.craft?.materialYou?.getColors?.(e)},async getColorsFromSource(e){if(!o()||s()!=="android")return null;return window.craft?.materialYou?.getColorsFromSource?.(e)},onColorsChange(e){if(!o()||s()!=="android")return;window.craft?.materialYou?.onColorsChange?.(e)},async applyToSystemBars(e){if(!o()||s()!=="android")return;return window.craft?.materialYou?.applyToSystemBars?.(e)},async generateScheme(e,t=!1){if(!o()||s()!=="android")return null;return window.craft?.materialYou?.generateScheme?.(e,t)}},is={async isAvailable(){if(!o()||s()!=="android")return!1;return window.craft?.photoPicker?.isAvailable?.()??!1},async pickImage(){if(!o()||s()!=="android")return null;return window.craft?.photoPicker?.pickImage?.()},async pickImages(e=10){if(!o()||s()!=="android")return[];return window.craft?.photoPicker?.pickImages?.(e)??[]},async pickVideo(){if(!o()||s()!=="android")return null;return window.craft?.photoPicker?.pickVideo?.()},async pickVideos(e=10){if(!o()||s()!=="android")return[];return window.craft?.photoPicker?.pickVideos?.(e)??[]},async pickMedia(e){if(!o()||s()!=="android")return[];return window.craft?.photoPicker?.pickMedia?.(e)??[]},async getPersistedUri(e){if(!o()||s()!=="android")return null;return window.craft?.photoPicker?.getPersistedUri?.(e)}},as={async enqueue(e){if(!o()||s()!=="android")return`mock-${Date.now()}`;return window.craft?.workManager?.enqueue?.(e)??`mock-${Date.now()}`},async enqueueUnique(e,t){if(!o()||s()!=="android")return`mock-${Date.now()}`;return window.craft?.workManager?.enqueueUnique?.(e,t)??`mock-${Date.now()}`},async cancelByName(e){if(!o()||s()!=="android")return;return window.craft?.workManager?.cancelByName?.(e)},async cancelById(e){if(!o()||s()!=="android")return;return window.craft?.workManager?.cancelById?.(e)},async cancelByTag(e){if(!o()||s()!=="android")return;return window.craft?.workManager?.cancelByTag?.(e)},async cancelAll(){if(!o()||s()!=="android")return;return window.craft?.workManager?.cancelAll?.()},async getWorkInfo(e){if(!o()||s()!=="android")return null;return window.craft?.workManager?.getWorkInfo?.(e)},async getWorkInfoById(e){if(!o()||s()!=="android")return null;return window.craft?.workManager?.getWorkInfoById?.(e)},async getWorkInfoByTag(e){if(!o()||s()!=="android")return[];return window.craft?.workManager?.getWorkInfoByTag?.(e)??[]},observeWork(e,t){if(!o()||s()!=="android")return()=>{};return window.craft?.workManager?.observeWork?.(e,t)??(()=>{})},async pruneWork(){if(!o()||s()!=="android")return;return window.craft?.workManager?.pruneWork?.()},onWork(e,t){if(!o()||s()!=="android")return;window.craft?.workManager?.onWork?.(e,t)}},ss={async start(e){if(!o()||s()!=="android")return;return window.craft?.foregroundService?.start?.(e)},async stop(){if(!o()||s()!=="android")return;return window.craft?.foregroundService?.stop?.()},async updateNotification(e){if(!o()||s()!=="android")return;return window.craft?.foregroundService?.updateNotification?.(e)},async isRunning(){if(!o()||s()!=="android")return!1;return window.craft?.foregroundService?.isRunning?.()??!1},onAction(e){if(!o()||s()!=="android")return;window.craft?.foregroundService?.onAction?.(e)}},os={async isSupported(){if(!o()||s()!=="android")return!1;return window.craft?.predictiveBack?.isSupported?.()??!1},enable(){if(!o()||s()!=="android")return;window.craft?.predictiveBack?.enable?.()},disable(){if(!o()||s()!=="android")return;window.craft?.predictiveBack?.disable?.()},onStart(e){if(!o()||s()!=="android")return;window.craft?.predictiveBack?.onStart?.(e)},onProgress(e){if(!o()||s()!=="android")return;window.craft?.predictiveBack?.onProgress?.(e)},onCommit(e){if(!o()||s()!=="android")return;window.craft?.predictiveBack?.onCommit?.()},onCancel(e){if(!o()||s()!=="android")return;window.craft?.predictiveBack?.onCancel?.(e)}},cs={async isSupported(){if(!o()||s()!=="android")return!1;return window.craft?.appLanguage?.isSupported?.()??!1},async getAvailableLanguages(){if(!o()||s()!=="android")return[];return window.craft?.appLanguage?.getAvailableLanguages?.()??[]},async getCurrentLanguage(){if(!o()||s()!=="android")return null;return window.craft?.appLanguage?.getCurrentLanguage?.()},async setLanguage(e){if(!o()||s()!=="android")return;return window.craft?.appLanguage?.setLanguage?.(e)},async resetToSystem(){if(!o()||s()!=="android")return;return window.craft?.appLanguage?.resetToSystem?.()},async openSettings(){if(!o()||s()!=="android")return;return window.craft?.appLanguage?.openSettings?.()}},ds={async getActiveWidgets(e){if(!o()||s()!=="android")return[];return window.craft?.widgets?.getActiveWidgets?.(e)??[]},async updateWidget(e,t){if(!o()||s()!=="android")return;return window.craft?.widgets?.updateWidget?.(e,t)},async updateAllWidgets(e,t){if(!o()||s()!=="android")return;return window.craft?.widgets?.updateAllWidgets?.(e,t)},async requestPin(e){if(!o()||s()!=="android")return!1;return window.craft?.widgets?.requestPin?.(e)??!1},async isSupported(){if(!o()||s()!=="android")return!1;return window.craft?.widgets?.isSupported?.()??!1},onUpdate(e,t){if(!o()||s()!=="android")return;window.craft?.widgets?.onUpdate?.(e,t)},onInteraction(e){if(!o()||s()!=="android")return;window.craft?.widgets?.onInteraction?.(e)},onResize(e){if(!o()||s()!=="android")return;window.craft?.widgets?.onResize?.(e)},onDelete(e){if(!o()||s()!=="android")return;window.craft?.widgets?.onDelete?.(e)}},ls={async connect(){if(!o()||s()!=="android")return!1;return window.craft?.playBilling?.connect?.()??!1},async disconnect(){if(!o()||s()!=="android")return;return window.craft?.playBilling?.disconnect?.()},async getProducts(e,t){if(!o()||s()!=="android")return[];return window.craft?.playBilling?.getProducts?.(e,t)??[]},async purchase(e,t){if(!o()||s()!=="android")return{success:!1,error:"Play Billing not available"};return window.craft?.playBilling?.purchase?.(e,t)??{success:!1}},async getPurchases(e){if(!o()||s()!=="android")return[];return window.craft?.playBilling?.getPurchases?.(e)??[]},async acknowledgePurchase(e){if(!o()||s()!=="android")return!1;return window.craft?.playBilling?.acknowledgePurchase?.(e)??!1},async consumePurchase(e){if(!o()||s()!=="android")return!1;return window.craft?.playBilling?.consumePurchase?.(e)??!1},async isSubscribed(e){if(!o()||s()!=="android")return!1;return window.craft?.playBilling?.isSubscribed?.(e)??!1},onPurchasesUpdated(e){if(!o()||s()!=="android")return;window.craft?.playBilling?.onPurchasesUpdated?.(e)},async showSubscriptionManagement(e){if(!o()||s()!=="android")return;return window.craft?.playBilling?.showSubscriptionManagement?.(e)}},us={async isAvailable(){if(!o()||s()!=="macos")return!1;return window.craft?.touchBar?.isAvailable?.()??!1},set(e){if(!o()||s()!=="macos")return;window.craft?.touchBar?.set?.(e)},updateItem(e,t){if(!o()||s()!=="macos")return;window.craft?.touchBar?.updateItem?.(e,t)},clear(){if(!o()||s()!=="macos")return;window.craft?.touchBar?.clear?.()},onTap(e,t){if(!o()||s()!=="macos")return;window.craft?.touchBar?.onTap?.(e,t)},onSliderChange(e,t){if(!o()||s()!=="macos")return;window.craft?.touchBar?.onSliderChange?.(e,t)},onColorChange(e,t){if(!o()||s()!=="macos")return;window.craft?.touchBar?.onColorChange?.(e,t)},onScrubberSelect(e,t){if(!o()||s()!=="macos")return;window.craft?.touchBar?.onScrubberSelect?.(e,t)},onSegmentSelect(e,t){if(!o()||s()!=="macos")return;window.craft?.touchBar?.onSegmentSelect?.(e,t)},setEscapeKeyVisible(e){if(!o()||s()!=="macos")return;window.craft?.touchBar?.setEscapeKeyVisible?.(e)}},fs={async isSupported(){if(!o()||s()!=="macos")return!1;return window.craft?.desktopWidgets?.isSupported?.()??!1},register(e){if(!o()||s()!=="macos")return;window.craft?.desktopWidgets?.register?.(e)},provideTimeline(e,t){if(!o()||s()!=="macos")return;window.craft?.desktopWidgets?.provideTimeline?.(e,t)},async reloadTimeline(e){if(!o()||s()!=="macos")return;return window.craft?.desktopWidgets?.reloadTimeline?.(e)},async reloadAllTimelines(){if(!o()||s()!=="macos")return;return window.craft?.desktopWidgets?.reloadAllTimelines?.()},async getCurrentConfigurations(e){if(!o()||s()!=="macos")return[];return window.craft?.desktopWidgets?.getCurrentConfigurations?.(e)??[]},onWidgetURL(e,t){if(!o()||s()!=="macos")return;window.craft?.desktopWidgets?.onWidgetURL?.(e,t)}},hs={async isActive(){if(!o()||s()!=="macos")return!1;return window.craft?.stageManager?.isActive?.()??!1},async isAvailable(){if(!o()||s()!=="macos")return!1;return window.craft?.stageManager?.isAvailable?.()??!1},async getActiveSet(){if(!o()||s()!=="macos")return[];return window.craft?.stageManager?.getActiveSet?.()??[]},async createSet(e){if(!o()||s()!=="macos")return;return window.craft?.stageManager?.createSet?.(e)},async addToCurrentSet(e){if(!o()||s()!=="macos")return;return window.craft?.stageManager?.addToCurrentSet?.(e)},async removeFromCurrentSet(e){if(!o()||s()!=="macos")return;return window.craft?.stageManager?.removeFromCurrentSet?.(e)},onActiveSetChange(e){if(!o()||s()!=="macos")return;window.craft?.stageManager?.onActiveSetChange?.(e)},onStateChange(e){if(!o()||s()!=="macos")return;window.craft?.stageManager?.onStateChange?.(e)}},ws={startActivity(e){if(!o()||s()!=="macos")return;window.craft?.handoff?.startActivity?.(e)},updateActivity(e){if(!o()||s()!=="macos")return;window.craft?.handoff?.updateActivity?.(e)},invalidateActivity(){if(!o()||s()!=="macos")return;window.craft?.handoff?.invalidateActivity?.()},onContinue(e){if(!o()||s()!=="macos")return;window.craft?.handoff?.onContinue?.(e)},async hasRemoteClipboardContent(){if(!o()||s()!=="macos")return!1;return window.craft?.handoff?.hasRemoteClipboardContent?.()??!1},async shareViaAirDrop(e){if(!o()||s()!=="macos")return!1;return window.craft?.handoff?.shareViaAirDrop?.(e)??!1},async isAvailable(){if(!o()||s()!=="macos")return!1;return window.craft?.handoff?.isAvailable?.()??!1}},ps={async isAvailable(){if(!o()||s()!=="macos")return!1;return window.craft?.sidecar?.isAvailable?.()??!1},async getAvailableDevices(){if(!o()||s()!=="macos")return[];return window.craft?.sidecar?.getAvailableDevices?.()??[]},async getConnectedDevice(){if(!o()||s()!=="macos")return null;return window.craft?.sidecar?.getConnectedDevice?.()},async connect(e){if(!o()||s()!=="macos")return!1;return window.craft?.sidecar?.connect?.(e)??!1},async disconnect(){if(!o()||s()!=="macos")return;return window.craft?.sidecar?.disconnect?.()},async moveWindowToSidecar(e){if(!o()||s()!=="macos")return;return window.craft?.sidecar?.moveWindowToSidecar?.(e)},onConnectionChange(e){if(!o()||s()!=="macos")return;window.craft?.sidecar?.onConnectionChange?.(e)}},ms={async indexItems(e){if(!o()||s()!=="macos")return;return window.craft?.spotlight?.indexItems?.(e)},async deleteItems(e){if(!o()||s()!=="macos")return;return window.craft?.spotlight?.deleteItems?.(e)},async deleteItemsInDomain(e){if(!o()||s()!=="macos")return;return window.craft?.spotlight?.deleteItemsInDomain?.(e)},async deleteAllItems(){if(!o()||s()!=="macos")return;return window.craft?.spotlight?.deleteAllItems?.()},onContinueActivity(e){if(!o()||s()!=="macos")return;window.craft?.spotlight?.onContinueActivity?.(e)},async getIndexingStatus(){if(!o()||s()!=="macos")return{isIndexing:!1,itemCount:0};return window.craft?.spotlight?.getIndexingStatus?.()??{isIndexing:!1,itemCount:0}}},gs={register(e){if(!o()||s()!=="macos")return;window.craft?.quickActions?.register?.(e)},unregister(e){if(!o()||s()!=="macos")return;window.craft?.quickActions?.unregister?.(e)},onInvoke(e,t){if(!o()||s()!=="macos")return;window.craft?.quickActions?.onInvoke?.(e,t)}},ys={onReceive(e){if(!o()||s()!=="macos")return;window.craft?.shareExtension?.onReceive?.(e)},async complete(e=!0){if(!o()||s()!=="macos")return;return window.craft?.shareExtension?.complete?.(e)},async cancel(){if(!o()||s()!=="macos")return;return window.craft?.shareExtension?.cancel?.()}},bs={enableTabs(){if(!o()||s()!=="macos")return;window.craft?.windowManagement?.enableTabs?.()},disableTabs(){if(!o()||s()!=="macos")return;window.craft?.windowManagement?.disableTabs?.()},async newTab(e){if(!o()||s()!=="macos")return"";return window.craft?.windowManagement?.newTab?.(e)??""},async closeTab(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.closeTab?.()},async getTabGroups(){if(!o()||s()!=="macos")return[];return window.craft?.windowManagement?.getTabGroups?.()??[]},async selectTab(e){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.selectTab?.(e)},async moveTabToNewWindow(e){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.moveTabToNewWindow?.(e)},async mergeAllWindows(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.mergeAllWindows?.()},async enterFullScreen(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.enterFullScreen?.()},async exitFullScreen(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.exitFullScreen?.()},async toggleFullScreen(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.toggleFullScreen?.()},async createSplitView(e,t){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.createSplitView?.(e,t)},async exitSplitView(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.exitSplitView?.()},async tileLeft(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.tileLeft?.()},async tileRight(){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.tileRight?.()},async moveToSpace(e){if(!o()||s()!=="macos")return;return window.craft?.windowManagement?.moveToSpace?.(e)},onTabChange(e){if(!o()||s()!=="macos")return;window.craft?.windowManagement?.onTabChange?.(e)},onFullScreenChange(e){if(!o()||s()!=="macos")return;window.craft?.windowManagement?.onFullScreenChange?.(e)}},vs={async isSupported(){if(!o()||s()!=="windows")return!1;return window.craft?.jumpList?.isSupported?.()??!1},async set(e){if(!o()||s()!=="windows")return;return window.craft?.jumpList?.set?.(e)},async clear(){if(!o()||s()!=="windows")return;return window.craft?.jumpList?.clear?.()},async addToRecent(e){if(!o()||s()!=="windows")return;return window.craft?.jumpList?.addToRecent?.(e)},async clearRecent(){if(!o()||s()!=="windows")return;return window.craft?.jumpList?.clearRecent?.()},async addToFrequent(e){if(!o()||s()!=="windows")return;return window.craft?.jumpList?.addToFrequent?.(e)},async clearFrequent(){if(!o()||s()!=="windows")return;return window.craft?.jumpList?.clearFrequent?.()},onItemClick(e){if(!o()||s()!=="windows")return;window.craft?.jumpList?.onItemClick?.(e)}},xs={async setState(e){if(!o()||s()!=="windows")return;return window.craft?.taskbarProgress?.setState?.(e)},async setProgress(e){if(!o()||s()!=="windows")return;return window.craft?.taskbarProgress?.setProgress?.(Math.max(0,Math.min(1,e)))},async clear(){if(!o()||s()!=="windows")return;return window.craft?.taskbarProgress?.clear?.()},async flash(e){if(!o()||s()!=="windows")return;return window.craft?.taskbarProgress?.flash?.(e)},async stopFlash(){if(!o()||s()!=="windows")return;return window.craft?.taskbarProgress?.stopFlash?.()},async setOverlayIcon(e,t){if(!o()||s()!=="windows")return;return window.craft?.taskbarProgress?.setOverlayIcon?.(e,t)}},ks={async isSupported(){if(!o()||s()!=="windows")return!1;return window.craft?.toastNotifications?.isSupported?.()??!1},async show(e,t){if(!o()||s()!=="windows")return;return window.craft?.toastNotifications?.show?.(e,t)},async update(e,t){if(!o()||s()!=="windows")return;return window.craft?.toastNotifications?.update?.(e,t)},async hide(e){if(!o()||s()!=="windows")return;return window.craft?.toastNotifications?.hide?.(e)},async hideGroup(e){if(!o()||s()!=="windows")return;return window.craft?.toastNotifications?.hideGroup?.(e)},async clearAll(){if(!o()||s()!=="windows")return;return window.craft?.toastNotifications?.clearAll?.()},async getHistory(){if(!o()||s()!=="windows")return[];return window.craft?.toastNotifications?.getHistory?.()??[]},onActivated(e){if(!o()||s()!=="windows")return;window.craft?.toastNotifications?.onActivated?.(e)},onDismissed(e){if(!o()||s()!=="windows")return;window.craft?.toastNotifications?.onDismissed?.(e)}},Ss={async getAvailability(){if(!o()||s()!=="windows")return{isAvailable:!1,biometricTypes:[],supportsCompanionDevice:!1};return window.craft?.windowsHello?.getAvailability?.()??{isAvailable:!1,biometricTypes:[],supportsCompanionDevice:!1}},async authenticate(e){if(!o()||s()!=="windows")return{success:!1,error:"notConfigured"};return window.craft?.windowsHello?.authenticate?.(e)??{success:!1}},async createCredential(e,t){if(!o()||s()!=="windows")return{success:!1,error:"Windows Hello not available"};return window.craft?.windowsHello?.createCredential?.(e,t)??{success:!1}},async signWithCredential(e,t,r){if(!o()||s()!=="windows")return{success:!1,error:"Windows Hello not available"};return window.craft?.windowsHello?.signWithCredential?.(e,t,r)??{success:!1}},async deleteCredential(e){if(!o()||s()!=="windows")return!1;return window.craft?.windowsHello?.deleteCredential?.(e)??!1},async hasCredential(e){if(!o()||s()!=="windows")return!1;return window.craft?.windowsHello?.hasCredential?.(e)??!1}},_s={async isSupported(){if(!o()||s()!=="windows")return!1;return window.craft?.windowsWidgets?.isSupported?.()??!1},register(e){if(!o()||s()!=="windows")return;window.craft?.windowsWidgets?.register?.(e)},unregister(e){if(!o()||s()!=="windows")return;window.craft?.windowsWidgets?.unregister?.(e)},onContentRequested(e,t){if(!o()||s()!=="windows")return;window.craft?.windowsWidgets?.onContentRequested?.(e,t)},async updateContent(e,t){if(!o()||s()!=="windows")return;return window.craft?.windowsWidgets?.updateContent?.(e,t)},onAction(e,t){if(!o()||s()!=="windows")return;window.craft?.windowsWidgets?.onAction?.(e,t)},onCustomize(e,t){if(!o()||s()!=="windows")return;window.craft?.windowsWidgets?.onCustomize?.(e,t)}},Is={async getCurrentVersion(){if(!o()||s()!=="windows")return null;return window.craft?.msixUpdate?.getCurrentVersion?.()},async checkForUpdates(){if(!o()||s()!=="windows")return{isAvailable:!1,isMandatory:!1};return window.craft?.msixUpdate?.checkForUpdates?.()??{isAvailable:!1,isMandatory:!1}},async downloadAndInstall(e){if(!o()||s()!=="windows")return{success:!1,error:"MSIX not available"};return window.craft?.msixUpdate?.downloadAndInstall?.(e)??{success:!1}},onDownloadProgress(e){if(!o()||s()!=="windows")return;window.craft?.msixUpdate?.onDownloadProgress?.(e)},async isPackaged(){if(!o()||s()!=="windows")return!1;return window.craft?.msixUpdate?.isPackaged?.()??!1},async getInstallLocation(){if(!o()||s()!=="windows")return null;return window.craft?.msixUpdate?.getInstallLocation?.()}},Ts={onShare(e){if(!o()||s()!=="windows")return;window.craft?.shareTarget?.onShare?.(e)},async wasLaunchedAsShareTarget(){if(!o()||s()!=="windows")return!1;return window.craft?.shareTarget?.wasLaunchedAsShareTarget?.()??!1},async getSharedData(){if(!o()||s()!=="windows")return[];return window.craft?.shareTarget?.getSharedData?.()??[]}},Ps={async getState(){if(!o()||s()!=="windows")return"disabled";return window.craft?.startupTask?.getState?.()??"disabled"},async request(){if(!o()||s()!=="windows")return"disabled";return window.craft?.startupTask?.request?.()??"disabled"},async disable(){if(!o()||s()!=="windows")return;return window.craft?.startupTask?.disable?.()}},Cs={async isSupported(){if(!o()||s()!=="windows")return!1;return window.craft?.secondaryTiles?.isSupported?.()??!1},async pin(e){if(!o()||s()!=="windows")return!1;return window.craft?.secondaryTiles?.pin?.(e)??!1},async unpin(e){if(!o()||s()!=="windows")return!1;return window.craft?.secondaryTiles?.unpin?.(e)??!1},async exists(e){if(!o()||s()!=="windows")return!1;return window.craft?.secondaryTiles?.exists?.(e)??!1},async getAll(){if(!o()||s()!=="windows")return[];return window.craft?.secondaryTiles?.getAll?.()??[]},async updateTile(e,t){if(!o()||s()!=="windows")return;return window.craft?.secondaryTiles?.updateTile?.(e,t)},async updateBadge(e,t){if(!o()||s()!=="windows")return;return window.craft?.secondaryTiles?.updateBadge?.(e,t)},async clearTile(e){if(!o()||s()!=="windows")return;return window.craft?.secondaryTiles?.clearTile?.(e)},onLaunch(e){if(!o()||s()!=="windows")return;window.craft?.secondaryTiles?.onLaunch?.(e)}},Ue=300000,Oe=3600000;async function wn(e={}){let t=e.multiple?"openFiles":"openFile";if(I()){let n=await L(t,{type:"dialog",action:t,data:e},{timeoutMs:Ue}),i=!!(n&&n.canceled===!0),a=Array.isArray(n?.filePaths)?n.filePaths:[];return{canceled:i,filePaths:a}}return x().request(`dialog.${t}`,e)}async function pn(e={}){if(I()){let r=await L("openFolder",{type:"dialog",action:"openFolder",data:e},{timeoutMs:Ue}),n=!!(r&&r.canceled===!0),i=Array.isArray(r?.filePaths)?r.filePaths:[];return{canceled:n,filePaths:i}}return x().request("dialog.openFolder",e)}async function mn(e={}){if(I()){let r=await L("saveFile",{type:"dialog",action:"saveFile",data:e},{timeoutMs:Ue}),n=!!(r&&r.canceled===!0),i=typeof r?.filePath==="string"?r.filePath:void 0;return{canceled:n,filePath:i}}return x().request("dialog.saveFile",e)}async function gn(e){let t=typeof e==="string"?{title:e}:e;if(I()){let n=await L("showAlert",{type:"dialog",action:"showAlert",data:t},{timeoutMs:Oe});if(n&&typeof n.buttonIndex==="number")return n.buttonIndex;return 0}return x().request("dialog.showAlert",t)}async function yn(e){let t=typeof e==="string"?{title:e}:e;if(I()){let n=await L("showConfirm",{type:"dialog",action:"showConfirm",data:t},{timeoutMs:Oe});return!!(n&&n.ok===!0)}return x().request("dialog.showConfirm",t)}async function bn(e,t){if(I()){let n=await L("showPrompt",{type:"dialog",action:"showPrompt",data:{title:e,defaultValue:t}},{timeoutMs:Oe});if(n&&typeof n.value==="string")return n.value;return null}return x().request("dialog.showPrompt",{title:e,defaultValue:t})}var $s={openFile:wn,openFolder:pn,saveFile:mn,showAlert:gn,showConfirm:yn,showPrompt:bn},ae=5000;async function Mt(e){if(I()){Re({type:"clipboard",action:"writeText",data:{text:e}});return}return x().request("clipboard.writeText",{text:e})}async function Bt(){if(I()){let t=await L("readText",{type:"clipboard",action:"readText"},{timeoutMs:ae});return t&&typeof t.text==="string"?t.text:""}return x().request("clipboard.readText")}async function Dt(e){if(I()){Re({type:"clipboard",action:"writeHTML",data:{html:e}});return}return x().request("clipboard.writeHTML",{html:e})}async function Lt(){if(I()){let t=await L("readHTML",{type:"clipboard",action:"readHTML"},{timeoutMs:ae});return t&&typeof t.html==="string"?t.html:""}return x().request("clipboard.readHTML")}async function vn(){if(I()){Re({type:"clipboard",action:"clear"});return}return x().request("clipboard.clear")}async function xn(){if(I()){let t=await L("hasText",{type:"clipboard",action:"hasText"},{timeoutMs:ae});return!!(t&&t.value===!0)}return x().request("clipboard.hasText")}async function kn(){if(I()){let t=await L("hasHTML",{type:"clipboard",action:"hasHTML"},{timeoutMs:ae});return!!(t&&t.value===!0)}return x().request("clipboard.hasHTML")}async function Sn(){if(I()){let t=await L("hasImage",{type:"clipboard",action:"hasImage"},{timeoutMs:ae});return!!(t&&t.value===!0)}return x().request("clipboard.hasImage")}async function _n(e){let t=[];if(e.text)t.push(Mt(e.text));if(e.html)t.push(Dt(e.html));await Promise.all(t)}async function In(){let[e,t]=await Promise.all([Bt().catch((r)=>{console.debug("[Craft Clipboard] readText failed:",r);return}),Lt().catch((r)=>{console.debug("[Craft Clipboard] readHTML failed:",r);return})]);return{text:e||void 0,html:t||void 0}}var Es={writeText:Mt,readText:Bt,writeHTML:Dt,readHTML:Lt,clear:vn,hasText:xn,hasHTML:kn,hasImage:Sn,write:_n,read:In};async function it(e,t){if(typeof navigator>"u"||!navigator.mediaDevices)return!1;try{if(navigator.permissions)try{let i=await navigator.permissions.query({name:e});if(i.state==="granted")return!0;if(i.state==="denied")return!1}catch{}let n=(await navigator.mediaDevices.enumerateDevices()).filter((i)=>i.kind===t);if(n.length===0)return!1;return n.some((i)=>typeof i.label==="string"&&i.label.length>0)}catch{return!1}}var As={async enumerateDevices(){if(typeof navigator>"u"||!navigator.mediaDevices)return[];try{return(await navigator.mediaDevices.enumerateDevices()).map((t)=>({deviceId:t.deviceId,groupId:t.groupId,kind:t.kind,label:t.label||`${t.kind} (${t.deviceId.slice(0,8)}...)`}))}catch{return[]}},async getCameras(){return(await this.enumerateDevices()).filter((t)=>t.kind==="videoinput")},async getMicrophones(){return(await this.enumerateDevices()).filter((t)=>t.kind==="audioinput")},async getSpeakers(){return(await this.enumerateDevices()).filter((t)=>t.kind==="audiooutput")},async getCamera(e){if(typeof navigator>"u"||!navigator.mediaDevices)throw Error("Media devices not available");let t={video:e?{deviceId:e.deviceId?{exact:e.deviceId}:void 0,facingMode:e.facingMode,width:e.width,height:e.height,frameRate:e.frameRate,aspectRatio:e.aspectRatio}:!0,audio:!1};return navigator.mediaDevices.getUserMedia(t)},async getMicrophone(e){if(typeof navigator>"u"||!navigator.mediaDevices)throw Error("Media devices not available");let t={video:!1,audio:e?{deviceId:e.deviceId?{exact:e.deviceId}:void 0,echoCancellation:e.echoCancellation,noiseSuppression:e.noiseSuppression,autoGainControl:e.autoGainControl,sampleRate:e.sampleRate,channelCount:e.channelCount}:!0};return navigator.mediaDevices.getUserMedia(t)},async getMediaStream(e){if(typeof navigator>"u"||!navigator.mediaDevices)throw Error("Media devices not available");let t={video:e.video===!0?!0:e.video?this._buildVideoConstraints(e.video):!1,audio:e.audio===!0?!0:e.audio?this._buildAudioConstraints(e.audio):!1};return navigator.mediaDevices.getUserMedia(t)},async hasCameraAccess(){return it("camera","videoinput")},async hasMicrophoneAccess(){return it("microphone","audioinput")},async requestPermission(e={}){let{camera:t=!1,microphone:r=!1}=e;if(!t&&!r)return!0;try{return(await this.getMediaStream({video:t,audio:r})).getTracks().forEach((i)=>i.stop()),!0}catch{return!1}},stopStream(e){e.getTracks().forEach((t)=>t.stop())},onDeviceChange(e){if(typeof navigator>"u"||!navigator.mediaDevices)return()=>{};return navigator.mediaDevices.addEventListener("devicechange",e),()=>navigator.mediaDevices.removeEventListener("devicechange",e)},_buildVideoConstraints(e){return{deviceId:e.deviceId?{exact:e.deviceId}:void 0,facingMode:e.facingMode,width:e.width,height:e.height,frameRate:e.frameRate,aspectRatio:e.aspectRatio}},_buildAudioConstraints(e){return{deviceId:e.deviceId?{exact:e.deviceId}:void 0,echoCancellation:e.echoCancellation,noiseSuppression:e.noiseSuppression,autoGainControl:e.autoGainControl,sampleRate:e.sampleRate,channelCount:e.channelCount}}};function Tn(e){switch(e){case"macos":case"darwin":return{width:220,platform:{macos:{vibrancy:!0,material:"sidebar",trafficLightsInSidebar:!1,hideTitlebarSeparator:!1}}};case"windows":case"win32":return{width:200,platform:{windows:{material:"mica",rounded:!0}}};case"linux":return{width:200,platform:{linux:{theme:"auto"}}};default:return{width:220}}}function Pn(e,t){let n=`
77
- .craft-sidebar {
78
- width: ${e.width||220}px;
79
- height: 100%;
80
- display: flex;
81
- flex-direction: column;
82
- user-select: none;
83
- font-family: var(--craft-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
84
- font-size: var(--craft-font-size, 13px);
85
- }
86
- .craft-sidebar-header {
87
- padding: 12px 16px;
88
- border-bottom: 1px solid var(--craft-border);
89
- }
90
- .craft-sidebar-header-title {
91
- font-weight: 600;
92
- font-size: 14px;
93
- }
94
- .craft-sidebar-header-subtitle {
95
- font-size: 11px;
96
- opacity: 0.7;
97
- margin-top: 2px;
98
- }
99
- .craft-sidebar-search {
100
- padding: 8px 12px;
101
- }
102
- .craft-sidebar-search input {
103
- width: 100%;
104
- padding: 6px 10px;
105
- border-radius: var(--craft-radius, 6px);
106
- border: 1px solid var(--craft-border);
107
- background: var(--craft-input-bg);
108
- color: var(--craft-text);
109
- font-size: 13px;
110
- outline: none;
111
- }
112
- .craft-sidebar-search input:focus {
113
- border-color: var(--craft-accent);
114
- }
115
- .craft-sidebar-content {
116
- flex: 1;
117
- overflow-y: auto;
118
- overflow-x: hidden;
119
- padding: 4px 0;
120
- }
121
- .craft-sidebar-section {
122
- margin-bottom: 8px;
123
- }
124
- .craft-sidebar-section-header {
125
- display: flex;
126
- align-items: center;
127
- padding: 6px 12px;
128
- font-size: 11px;
129
- font-weight: 600;
130
- text-transform: uppercase;
131
- letter-spacing: 0.5px;
132
- opacity: 0.6;
133
- cursor: pointer;
134
- }
135
- .craft-sidebar-section-header:hover {
136
- opacity: 0.8;
137
- }
138
- .craft-sidebar-section-chevron {
139
- width: 12px;
140
- height: 12px;
141
- margin-right: 4px;
142
- transition: transform 0.15s;
143
- }
144
- .craft-sidebar-section-header.collapsed .craft-sidebar-section-chevron {
145
- transform: rotate(-90deg);
146
- }
147
- .craft-sidebar-section-items {
148
- transition: max-height 0.2s ease-out, opacity 0.15s;
149
- }
150
- .craft-sidebar-section-items.collapsed {
151
- max-height: 0;
152
- opacity: 0;
153
- overflow: hidden;
154
- }
155
- .craft-sidebar-item {
156
- display: flex;
157
- align-items: center;
158
- padding: 6px 12px 6px 16px;
159
- margin: 1px 8px;
160
- border-radius: var(--craft-radius, 6px);
161
- cursor: pointer;
162
- gap: 8px;
163
- transition: background 0.1s;
164
- }
165
- .craft-sidebar-item:hover {
166
- background: var(--craft-hover);
167
- }
168
- .craft-sidebar-item.selected {
169
- background: var(--craft-accent);
170
- color: var(--craft-accent-text, #fff);
171
- }
172
- .craft-sidebar-item-icon {
173
- width: 16px;
174
- height: 16px;
175
- flex-shrink: 0;
176
- }
177
- .craft-sidebar-item-label {
178
- flex: 1;
179
- white-space: nowrap;
180
- overflow: hidden;
181
- text-overflow: ellipsis;
182
- }
183
- .craft-sidebar-item-badge {
184
- padding: 2px 6px;
185
- border-radius: 10px;
186
- font-size: 11px;
187
- font-weight: 500;
188
- background: var(--craft-badge-bg);
189
- }
190
- .craft-sidebar-item.selected .craft-sidebar-item-badge {
191
- background: rgba(255,255,255,0.25);
192
- }
193
- .craft-sidebar-footer {
194
- padding: 8px 12px;
195
- border-top: 1px solid var(--craft-border);
196
- display: flex;
197
- gap: 4px;
198
- }
199
- `,i="";if(t==="macos"||t==="darwin"){let a=e.platform?.macos;i=`
200
- :root {
201
- --craft-font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
202
- --craft-bg: ${a?.vibrancy?"rgba(246,246,246,0.8)":"#f6f6f6"};
203
- --craft-bg-dark: ${a?.vibrancy?"rgba(30,30,30,0.8)":"#1e1e1e"};
204
- --craft-text: #1d1d1f;
205
- --craft-text-dark: #f5f5f7;
206
- --craft-border: rgba(0,0,0,0.1);
207
- --craft-border-dark: rgba(255,255,255,0.1);
208
- --craft-hover: rgba(0,0,0,0.04);
209
- --craft-hover-dark: rgba(255,255,255,0.06);
210
- --craft-accent: #007aff;
211
- --craft-accent-text: #fff;
212
- --craft-input-bg: rgba(0,0,0,0.05);
213
- --craft-input-bg-dark: rgba(255,255,255,0.08);
214
- --craft-badge-bg: rgba(0,0,0,0.08);
215
- --craft-badge-bg-dark: rgba(255,255,255,0.1);
216
- --craft-radius: 6px;
217
- }
218
- .craft-sidebar {
219
- background: var(--craft-bg);
220
- color: var(--craft-text);
221
- ${a?.vibrancy?"backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);":""}
222
- border-right: 1px solid var(--craft-border);
223
- }
224
- @media (prefers-color-scheme: dark) {
225
- .craft-sidebar {
226
- background: var(--craft-bg-dark);
227
- color: var(--craft-text-dark);
228
- border-color: var(--craft-border-dark);
229
- }
230
- .craft-sidebar-item:hover { background: var(--craft-hover-dark); }
231
- .craft-sidebar-search input { background: var(--craft-input-bg-dark); }
232
- .craft-sidebar-item-badge { background: var(--craft-badge-bg-dark); }
233
- }
234
- `}else if(t==="windows"||t==="win32"){let a=e.platform?.windows;i=`
235
- :root {
236
- --craft-font-family: 'Segoe UI Variable', 'Segoe UI', sans-serif;
237
- --craft-bg: ${a?.material==="mica"?"rgba(243,243,243,0.9)":"#f3f3f3"};
238
- --craft-bg-dark: ${a?.material==="mica"?"rgba(32,32,32,0.9)":"#202020"};
239
- --craft-text: #1a1a1a;
240
- --craft-text-dark: #fff;
241
- --craft-border: rgba(0,0,0,0.08);
242
- --craft-border-dark: rgba(255,255,255,0.08);
243
- --craft-hover: rgba(0,0,0,0.04);
244
- --craft-hover-dark: rgba(255,255,255,0.06);
245
- --craft-accent: #0078d4;
246
- --craft-accent-text: #fff;
247
- --craft-input-bg: #fff;
248
- --craft-input-bg-dark: rgba(255,255,255,0.06);
249
- --craft-badge-bg: rgba(0,0,0,0.05);
250
- --craft-badge-bg-dark: rgba(255,255,255,0.08);
251
- --craft-radius: ${a?.rounded?"4px":"0"};
252
- }
253
- .craft-sidebar {
254
- background: var(--craft-bg);
255
- color: var(--craft-text);
256
- ${a?.material!=="none"?"backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);":""}
257
- }
258
- @media (prefers-color-scheme: dark) {
259
- .craft-sidebar {
260
- background: var(--craft-bg-dark);
261
- color: var(--craft-text-dark);
262
- }
263
- .craft-sidebar-item:hover { background: var(--craft-hover-dark); }
264
- .craft-sidebar-search input { background: var(--craft-input-bg-dark); border-color: var(--craft-border-dark); }
265
- .craft-sidebar-item-badge { background: var(--craft-badge-bg-dark); }
266
- }
267
- `}else i=`
268
- :root {
269
- --craft-font-family: 'Cantarell', 'Ubuntu', sans-serif;
270
- --craft-bg: #f6f5f4;
271
- --craft-bg-dark: #303030;
272
- --craft-text: #2e3436;
273
- --craft-text-dark: #fff;
274
- --craft-border: rgba(0,0,0,0.12);
275
- --craft-border-dark: rgba(255,255,255,0.12);
276
- --craft-hover: rgba(0,0,0,0.05);
277
- --craft-hover-dark: rgba(255,255,255,0.08);
278
- --craft-accent: #3584e4;
279
- --craft-accent-text: #fff;
280
- --craft-input-bg: #fff;
281
- --craft-input-bg-dark: rgba(255,255,255,0.08);
282
- --craft-badge-bg: rgba(0,0,0,0.08);
283
- --craft-badge-bg-dark: rgba(255,255,255,0.12);
284
- --craft-radius: 6px;
285
- }
286
- .craft-sidebar {
287
- background: var(--craft-bg);
288
- color: var(--craft-text);
289
- border-right: 1px solid var(--craft-border);
290
- }
291
- @media (prefers-color-scheme: dark) {
292
- .craft-sidebar {
293
- background: var(--craft-bg-dark);
294
- color: var(--craft-text-dark);
295
- border-color: var(--craft-border-dark);
296
- }
297
- .craft-sidebar-item:hover { background: var(--craft-hover-dark); }
298
- .craft-sidebar-search input { background: var(--craft-input-bg-dark); border-color: var(--craft-border-dark); }
299
- .craft-sidebar-item-badge { background: var(--craft-badge-bg-dark); }
300
- }
301
- `;return n+i}function F(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Cn(e){let t=(n)=>`
302
- <div class="craft-sidebar-item${n.selected?" selected":""}" data-id="${F(n.id)}">
303
- ${n.icon?`<span class="craft-sidebar-item-icon">${$n(n.icon,n.tintColor)}</span>`:""}
304
- <span class="craft-sidebar-item-label">${F(n.label)}</span>
305
- ${n.badge!==void 0?`<span class="craft-sidebar-item-badge">${F(String(n.badge))}</span>`:""}
306
- </div>
307
- `,r=(n)=>`
308
- <div class="craft-sidebar-section" data-section="${F(n.id)}">
309
- ${n.title?`
310
- <div class="craft-sidebar-section-header${n.collapsed?" collapsed":""}" data-section-toggle="${F(n.id)}">
311
- ${n.collapsible!==!1?'<svg class="craft-sidebar-section-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>':""}
312
- ${F(n.title)}
313
- </div>
314
- `:""}
315
- <div class="craft-sidebar-section-items${n.collapsed?" collapsed":""}" data-section-items="${F(n.id)}">
316
- ${n.items.map(t).join("")}
317
- </div>
318
- </div>
319
- `;return`
320
- <aside class='craft-sidebar'>
321
- ${e.headerTitle?`
322
- <div class='craft-sidebar-header'>
323
- <div class='craft-sidebar-header-title'>${F(e.headerTitle)}</div>
324
- ${e.headerSubtitle?`<div class="craft-sidebar-header-subtitle">${F(e.headerSubtitle)}</div>`:""}
325
- </div>
326
- `:""}
327
- ${e.showSearch?`
328
- <div class='craft-sidebar-search'>
329
- <input type='text' placeholder='${F(e.searchPlaceholder||"Search")}' data-sidebar-search>
330
- </div>
331
- `:""}
332
- <div class='craft-sidebar-content'>
333
- ${e.sections?.map(r).join("")||""}
334
- ${e.items?.map(t).join("")||""}
335
- </div>
336
- </aside>
337
- `}function $n(e,t){let r=F(t||"currentColor"),n={folder:`<svg viewBox='0 0 24 24' fill='${r}'><path d='M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z'/></svg>`,file:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/><polyline points='13 2 13 9 20 9'/></svg>`,home:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/></svg>`,download:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/><polyline points='7 10 12 15 17 10'/><line x1='12' y1='15' x2='12' y2='3'/></svg>`,cloud:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z'/></svg>`,star:`<svg viewBox='0 0 24 24' fill='${r}'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>`,settings:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><circle cx='12' cy='12' r='3'/><path d='M12 1v2m0 18v2M4.22 4.22l1.42 1.42m12.72 12.72 1.42 1.42M1 12h2m18 0h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42'/></svg>`,user:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>`,users:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87m-4-12a4 4 0 0 1 0 7.75'/></svg>`,clock:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><circle cx='12' cy='12' r='10'/><polyline points='12 6 12 12 16 14'/></svg>`,computer:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><rect x='2' y='3' width='20' height='14' rx='2' ry='2'/><line x1='8' y1='21' x2='16' y2='21'/><line x1='12' y1='17' x2='12' y2='21'/></svg>`,globe:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><circle cx='12' cy='12' r='10'/><line x1='2' y1='12' x2='22' y2='12'/><path d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'/></svg>`,tag:`<svg viewBox='0 0 24 24' fill='${r}'><circle cx='12' cy='12' r='8'/></svg>`,wifi:`<svg viewBox='0 0 24 24' fill='none' stroke='${r}' stroke-width='2'><path d='M5 12.55a11 11 0 0 1 14.08 0M1.42 9a16 16 0 0 1 21.16 0M8.53 16.11a6 6 0 0 1 6.95 0M12 20h.01'/></svg>`};return n[e]||n.file}class se{config;element=null;onSelectHandler;onSearchHandler;listenerCleanups=[];constructor(e={}){let t=s(),r=Tn(t);this.config={...r,...e}}render(){let e=s();return{html:Cn(this.config),css:Pn(this.config,e)}}mount(e="body"){let t=typeof e==="string"?document.querySelector(e):e;if(!t){console.error("[Sidebar] Container not found");return}let{html:r,css:n}=this.render(),i=document.createElement("style");i.textContent=n,document.head.appendChild(i),t.insertAdjacentHTML("afterbegin",r),this.element=t.querySelector(".craft-sidebar"),this.attachEventListeners()}update(e){if(this.config={...this.config,...e},this.element){this.detachEventListeners();let{html:t}=this.render();this.element.outerHTML=t,this.element=document.querySelector(".craft-sidebar"),this.attachEventListeners()}}destroy(){if(this.detachEventListeners(),this.element)this.element.remove(),this.element=null}detachEventListeners(){for(let e of this.listenerCleanups)e();this.listenerCleanups=[]}selectItem(e){if(!this.element)return;this.element.querySelectorAll(".craft-sidebar-item").forEach((t)=>{t.classList.toggle("selected",t.getAttribute("data-id")===e)})}onSelect(e){this.onSelectHandler=e}onSearch(e){this.onSearchHandler=e}attachEventListeners(){if(!this.element)return;let e=(r,n,i)=>{r.addEventListener(n,i),this.listenerCleanups.push(()=>r.removeEventListener(n,i))};this.element.querySelectorAll(".craft-sidebar-item").forEach((r)=>{e(r,"click",()=>{let n=r.getAttribute("data-id");if(!n)return;if(this.element?.querySelectorAll(".craft-sidebar-item").forEach((i)=>{i.classList.remove("selected")}),r.classList.add("selected"),this.onSelectHandler){let i=this.findItem(n);this.onSelectHandler({itemId:n,item:i||{id:n,label:""}})}})}),this.element.querySelectorAll("[data-section-toggle]").forEach((r)=>{e(r,"click",()=>{let n=r.getAttribute("data-section-toggle"),i=this.element?.querySelector(`[data-section-items='${n}']`);if(i)r.classList.toggle("collapsed"),i.classList.toggle("collapsed")})});let t=this.element.querySelector("[data-sidebar-search]");if(t){let r=this.config.searchDebounceMs??80,n=null;this.listenerCleanups.push(()=>{if(n)clearTimeout(n)}),e(t,"input",()=>{let i=t.value.toLowerCase();if(this.element?.querySelectorAll(".craft-sidebar-item").forEach((a)=>{let c=a.querySelector(".craft-sidebar-item-label")?.textContent?.toLowerCase()||"";a.style.display=c.includes(i)?"":"none"}),!this.onSearchHandler)return;if(r<=0){this.onSearchHandler({query:t.value});return}if(n)clearTimeout(n);n=setTimeout(()=>{n=null,this.onSearchHandler?.({query:t.value})},r)})}}findItem(e){let t=(r)=>{for(let n of r){if(n.id===e)return n;if(n.children){let i=t(n.children);if(i)return i}}};if(this.config.items){let r=t(this.config.items);if(r)return r}for(let r of this.config.sections||[]){let n=t(r.items);if(n)return n}}}function En(e={}){return new se(e)}function An(e){let t=s(),r=t==="macos"||t==="darwin";return new se({sections:e||[{id:"favorites",title:"Favorites",collapsible:!0,items:[{id:"home",label:"Home",icon:"home"},{id:"desktop",label:"Desktop",icon:"computer"},{id:"documents",label:"Documents",icon:"folder"},{id:"downloads",label:"Downloads",icon:"download"}]},{id:"cloud",title:r?"iCloud":"Cloud",collapsible:!0,items:[{id:"cloud-drive",label:r?"iCloud Drive":"Cloud Storage",icon:"cloud"}]},{id:"locations",title:"Locations",collapsible:!0,items:[{id:"this-pc",label:r?"This Mac":"This PC",icon:"computer"},{id:"network",label:"Network",icon:"globe"}]}],showSearch:!0,searchPlaceholder:"Search"})}function Mn(e){return new se({items:e,showSearch:!0,searchPlaceholder:"Search settings",platform:{macos:{vibrancy:!0,trafficLightsInSidebar:!0,hideTitlebarSeparator:!0},windows:{material:"mica",rounded:!0}}})}var Ms={create:En,file:An,settings:Mn,Sidebar:se},Bn={};wt(Bn,{updateTouchBarItem:()=>ri,updateToolbarItem:()=>Zn,tahoeStyle:()=>He,sidebarSeparator:()=>Hn,sidebarSection:()=>On,sidebarItem:()=>Un,showQuickLook:()=>zn,showFontPicker:()=>Qn,showDatePicker:()=>Yn,showColorPicker:()=>Gn,setTouchBar:()=>ti,setToolbarVisible:()=>ei,setToolbar:()=>Xn,orbstackStyle:()=>qe,hideQuickLook:()=>jn,default:()=>si,createTahoeSidebar:()=>Dn,createTableView:()=>Wn,createSplitView:()=>Nn,createSidebar:()=>Fn,createProgress:()=>Jn,createOutlineView:()=>Vn,createOrbStackSidebar:()=>Rn,createFileBrowser:()=>qn,createArcSidebar:()=>Ln,canQuickLook:()=>Kn,arcStyle:()=>Ne,TableViewInstance:()=>je,StyleSheet:()=>Ft,SplitViewInstance:()=>Ve,Sidebar:()=>te,ProgressInstance:()=>Ke,Platform:()=>Rt,OutlineViewInstance:()=>ze,FileBrowserInstance:()=>We,Animated:()=>Ot});var He={style:"tahoe",width:220,minWidth:150,maxWidth:350,collapsible:!0,collapsedWidth:0,resizable:!0,background:"sidebar",showSeparator:!1,searchable:!0,searchPlaceholder:"Search",dragAndDrop:!0},Ne={style:"arc",width:260,minWidth:48,maxWidth:320,collapsible:!0,collapsedWidth:48,resizable:!0,background:"under-window",showSeparator:!0,searchable:!0,searchPlaceholder:"Search tabs...",dragAndDrop:!0},qe={style:"orbstack",width:200,minWidth:160,maxWidth:280,collapsible:!0,collapsedWidth:0,resizable:!1,background:"#1a1a1a",showSeparator:!0,separatorColor:"#333",searchable:!1,dragAndDrop:!1};class te{_id;_config;_listeners=new Map;_items=new Map;_selectedId=null;_destroyed=!1;constructor(e={}){this._id=`sidebar_${Date.now()}`,this._config=this._applyStylePreset(e),this._indexItems(),this._setupEventListeners()}get id(){return this._id}get config(){return{...this._config}}get selectedId(){return this._selectedId}get selectedItem(){return this._selectedId?this._items.get(this._selectedId)||null:null}get isCollapsed(){return this._config.collapsed||!1}_applyStylePreset(e){let t={};switch(e.style){case"tahoe":t=He;break;case"arc":t=Ne;break;case"orbstack":t=qe;break}return{...t,...e}}_indexItems(){this._items.clear();let e=(t)=>{if(!t)return;t.forEach((r)=>{if(this._items.set(r.id,r),r.children)e(r.children)})};e(this._config.items),this._config.sections?.forEach((t)=>{e(t.items)})}_setupEventListeners(){if(typeof window<"u")["select","double-click","context-menu","expand","collapse","resize","search","drag-start","drag-end","drop","reorder","header-action","footer-action"].forEach((t)=>{window.addEventListener(`craft:sidebar:${t}`,(r)=>{if(r.detail?.sidebarId===this._id){if(t==="select")this._selectedId=r.detail?.item?.id||null;this._emit(t,r.detail)}})})}_emit(e,t){let r=this._listeners.get(e);if(r)r.forEach((n)=>n(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>{this._listeners.get(e)?.delete(t)}}once(e,t){let r=(n)=>{this._listeners.get(e)?.delete(r),t(n)};return this.on(e,r)}off(e,t){this._listeners.get(e)?.delete(t)}async create(){await this._call("create",{config:this._config})}async update(e){this._config={...this._config,...e},this._indexItems(),await this._call("update",{config:this._config})}async collapse(){this._config.collapsed=!0,await this._call("collapse")}async expand(){this._config.collapsed=!1,await this._call("expand")}async toggle(){if(this._config.collapsed)await this.expand();else await this.collapse()}async setWidth(e){this._config.width=Math.max(this._config.minWidth||0,Math.min(e,this._config.maxWidth||1/0)),await this._call("setWidth",{width:this._config.width})}async destroy(){await this._call("destroy"),this._destroyed=!0,this._listeners.clear()}async select(e){this._selectedId=e,await this._call("select",{itemId:e})}async clearSelection(){this._selectedId=null,await this._call("clearSelection")}getItem(e){return this._items.get(e)}async addItem(e,t){this._items.set(e.id,e),await this._call("addItem",{item:e,...t})}async updateItem(e,t){let r=this._items.get(e);if(r)Object.assign(r,t),await this._call("updateItem",{itemId:e,updates:t})}async removeItem(e){if(this._items.delete(e),this._selectedId===e)this._selectedId=null;await this._call("removeItem",{itemId:e})}async setItems(e){this._config.items=e,this._indexItems(),await this._call("setItems",{items:e})}async setSections(e){this._config.sections=e,this._indexItems(),await this._call("setSections",{sections:e})}async expandItem(e){let t=this._items.get(e);if(t)t.expanded=!0,await this._call("expandItem",{itemId:e})}async collapseItem(e){let t=this._items.get(e);if(t)t.expanded=!1,await this._call("collapseItem",{itemId:e})}async scrollToItem(e){await this._call("scrollToItem",{itemId:e})}async setBadge(e,t){let r=this._items.get(e);if(r)r.badge=t??void 0,await this._call("setBadge",{itemId:e,badge:t})}async addSection(e,t){if(!this._config.sections)this._config.sections=[];if(t!==void 0)this._config.sections.splice(t,0,e);else this._config.sections.push(e);e.items.forEach((r)=>this._items.set(r.id,r)),await this._call("addSection",{section:e,index:t})}async updateSection(e,t){let r=this._config.sections?.find((n)=>n.id===e);if(r){if(Object.assign(r,t),t.items)t.items.forEach((n)=>this._items.set(n.id,n));await this._call("updateSection",{sectionId:e,updates:t})}}async removeSection(e){let t=this._config.sections?.findIndex((r)=>r.id===e);if(t!==void 0&&t>=0&&this._config.sections)this._config.sections[t].items.forEach((n)=>this._items.delete(n.id)),this._config.sections.splice(t,1),await this._call("removeSection",{sectionId:e})}async collapseSection(e){let t=this._config.sections?.find((r)=>r.id===e);if(t)t.collapsed=!0,await this._call("collapseSection",{sectionId:e})}async expandSection(e){let t=this._config.sections?.find((r)=>r.id===e);if(t)t.collapsed=!1,await this._call("expandSection",{sectionId:e})}async setSearchQuery(e){await this._call("setSearchQuery",{query:e})}async clearSearch(){await this._call("clearSearch")}async focusSearch(){await this._call("focusSearch")}async _call(e,t){let r={sidebarId:this._id,...t};if(typeof window<"u"&&window.webkit?.messageHandlers?.craft)return new Promise((i,a)=>{try{window.webkit.messageHandlers.craft.postMessage({type:"sidebar",action:e,data:r}),i(void 0)}catch(c){a(c)}});return x().request(`sidebar.${e}`,r)}}function Dn(e={}){return new te({...He,...e,style:"tahoe"})}function Ln(e={}){return new te({...Ne,...e,style:"arc"})}function Rn(e={}){return new te({...qe,...e,style:"orbstack"})}function Fn(e={}){return new te(e)}function Un(e,t,r={}){return{id:e,label:t,...r}}function On(e,t,r={}){return{id:e,items:t,...r}}function Hn(e){return{id:e||`separator_${Date.now()}`,label:"",disabled:!0}}var at=0;function oe(e){return at++,`${e}_${Date.now()}_${at}`}async function Nn(e={}){let t=e.id||oe("splitview");return await h("component.createSplitView",{id:t,config:e}),new Ve(t,e)}class Ve{id;type="splitView";_config;_listeners=new Map;constructor(e,t){this.id=e,this._config=t,this._setupListeners()}_setupListeners(){if(typeof window<"u")window.addEventListener(`craft:splitView:${this.id}:resize`,(e)=>{this._emit("resize",e.detail)})}_emit(e,t){this._listeners.get(e)?.forEach((r)=>r(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>this._listeners.get(e)?.delete(t)}async update(e){Object.assign(this._config,e),await h("component.update",{id:this.id,props:e})}async destroy(){await h("component.destroy",{id:this.id})}async show(){await h("component.show",{id:this.id})}async hide(){await h("component.hide",{id:this.id})}async focus(){await h("component.focus",{id:this.id})}async setPosition(e,t){this._config.position=e,await h("splitView.setPosition",{id:this.id,position:e,animated:t})}async getPosition(){return h("splitView.getPosition",{id:this.id})}async collapsePane(e){await h("splitView.collapsePane",{id:this.id,index:e})}async expandPane(e){await h("splitView.expandPane",{id:this.id,index:e})}}async function qn(e={}){let t=e.id||oe("filebrowser");return await h("component.createFileBrowser",{id:t,config:e}),new We(t,e)}class We{id;type="fileBrowser";_config;_listeners=new Map;constructor(e,t){this.id=e,this._config=t,this._setupListeners()}_setupListeners(){if(typeof window<"u")["select","open","navigate","context-menu"].forEach((t)=>{window.addEventListener(`craft:fileBrowser:${this.id}:${t}`,(r)=>{this._emit(t,r.detail)})})}_emit(e,t){this._listeners.get(e)?.forEach((r)=>r(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>this._listeners.get(e)?.delete(t)}async update(e){Object.assign(this._config,e),await h("component.update",{id:this.id,props:e})}async destroy(){await h("component.destroy",{id:this.id})}async show(){await h("component.show",{id:this.id})}async hide(){await h("component.hide",{id:this.id})}async focus(){await h("component.focus",{id:this.id})}async getSelection(){return h("fileBrowser.getSelection",{id:this.id})}async setSelection(e){await h("fileBrowser.setSelection",{id:this.id,paths:e})}async navigateTo(e){await h("fileBrowser.navigateTo",{id:this.id,path:e})}async goBack(){await h("fileBrowser.goBack",{id:this.id})}async goForward(){await h("fileBrowser.goForward",{id:this.id})}async goUp(){await h("fileBrowser.goUp",{id:this.id})}async refresh(){await h("fileBrowser.refresh",{id:this.id})}async createFolder(e){return h("fileBrowser.createFolder",{id:this.id,name:e})}async deleteSelection(e){await h("fileBrowser.deleteSelection",{id:this.id,moveToTrash:e})}async getCurrentPath(){return h("fileBrowser.getCurrentPath",{id:this.id})}}async function Vn(e={}){let t=e.id||oe("outlineview");return await h("component.createOutlineView",{id:t,config:e}),new ze(t,e)}class ze{id;type="outlineView";_config;_listeners=new Map;constructor(e,t){this.id=e,this._config=t,this._setupListeners()}_setupListeners(){if(typeof window<"u")["select","double-click","expand","collapse","reorder","edit"].forEach((t)=>{window.addEventListener(`craft:outlineView:${this.id}:${t}`,(r)=>{this._emit(t,r.detail)})})}_emit(e,t){this._listeners.get(e)?.forEach((r)=>r(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>this._listeners.get(e)?.delete(t)}async update(e){Object.assign(this._config,e),await h("component.update",{id:this.id,props:e})}async destroy(){await h("component.destroy",{id:this.id})}async show(){await h("component.show",{id:this.id})}async hide(){await h("component.hide",{id:this.id})}async focus(){await h("component.focus",{id:this.id})}async setItems(e){this._config.items=e,await h("outlineView.setItems",{id:this.id,items:e})}async addItem(e,t,r){await h("outlineView.addItem",{id:this.id,item:e,parentId:t,index:r})}async updateItem(e,t){await h("outlineView.updateItem",{id:this.id,itemId:e,updates:t})}async removeItem(e){await h("outlineView.removeItem",{id:this.id,itemId:e})}async expandItem(e){await h("outlineView.expandItem",{id:this.id,itemId:e})}async collapseItem(e){await h("outlineView.collapseItem",{id:this.id,itemId:e})}async selectItem(e){await h("outlineView.selectItem",{id:this.id,itemId:e})}async getSelection(){return h("outlineView.getSelection",{id:this.id})}async scrollToItem(e){await h("outlineView.scrollToItem",{id:this.id,itemId:e})}}async function Wn(e={}){let t=e.id||oe("tableview");return await h("component.createTableView",{id:t,config:e}),new je(t,e)}class je{id;type="tableView";_config;_listeners=new Map;constructor(e,t){this.id=e,this._config=t,this._setupListeners()}_setupListeners(){if(typeof window<"u")["select","double-click","sort","edit","column-resize","column-reorder"].forEach((t)=>{window.addEventListener(`craft:tableView:${this.id}:${t}`,(r)=>{this._emit(t,r.detail)})})}_emit(e,t){this._listeners.get(e)?.forEach((r)=>r(t))}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>this._listeners.get(e)?.delete(t)}async update(e){Object.assign(this._config,e),await h("component.update",{id:this.id,props:e})}async destroy(){await h("component.destroy",{id:this.id})}async show(){await h("component.show",{id:this.id})}async hide(){await h("component.hide",{id:this.id})}async focus(){await h("component.focus",{id:this.id})}async setColumns(e){this._config.columns=e,await h("tableView.setColumns",{id:this.id,columns:e})}async setRows(e){this._config.rows=e,await h("tableView.setRows",{id:this.id,rows:e})}async addRow(e,t){await h("tableView.addRow",{id:this.id,row:e,index:t})}async updateRow(e,t){await h("tableView.updateRow",{id:this.id,rowId:e,values:t})}async removeRow(e){await h("tableView.removeRow",{id:this.id,rowId:e})}async getSelection(){return h("tableView.getSelection",{id:this.id})}async selectRows(e){await h("tableView.selectRows",{id:this.id,rowIds:e})}async sortBy(e,t){await h("tableView.sortBy",{id:this.id,columnId:e,direction:t})}async scrollToRow(e){await h("tableView.scrollToRow",{id:this.id,rowId:e})}}async function zn(e){await h("quickLook.show",e)}async function jn(){await h("quickLook.hide",{})}async function Kn(e){return h("quickLook.canPreview",{path:e})}async function Gn(e={}){return h("colorPicker.show",e)}async function Qn(e={}){return h("fontPicker.show",e)}async function Yn(e={}){let t=await h("datePicker.show",e);return t?new Date(t):null}async function Jn(e={}){let t=e.id||oe("progress");return await h("component.createProgress",{id:t,config:e}),new Ke(t,e)}class Ke{id;type="progress";_config;_listeners=new Map;constructor(e,t){this.id=e,this._config=t}on(e,t){if(!this._listeners.has(e))this._listeners.set(e,new Set);return this._listeners.get(e).add(t),()=>this._listeners.get(e)?.delete(t)}async update(e){Object.assign(this._config,e),await h("component.update",{id:this.id,props:e})}async destroy(){await h("component.destroy",{id:this.id})}async show(){await h("component.show",{id:this.id})}async hide(){await h("component.hide",{id:this.id})}async focus(){await h("component.focus",{id:this.id})}async setValue(e){this._config.value=e,await h("progress.setValue",{id:this.id,value:e})}async startAnimation(){await h("progress.startAnimation",{id:this.id})}async stopAnimation(){await h("progress.stopAnimation",{id:this.id})}}async function Xn(e){await h("toolbar.set",e)}async function Zn(e,t){await h("toolbar.updateItem",{itemId:e,updates:t})}async function ei(e){await h("toolbar.setVisible",{visible:e})}async function ti(e){await h("touchBar.set",e)}async function ri(e,t){await h("touchBar.updateItem",{itemId:e,updates:t})}async function h(e,t){if(typeof window<"u"&&window.webkit?.messageHandlers?.craft)return new Promise((n,i)=>{try{window.webkit.messageHandlers.craft.postMessage({type:"native-ui",method:e,params:t}),n(void 0)}catch(a){i(a)}});return x().request(e,t)}var Rt={OS:ni(),Version:ii(),isIOS(){return this.OS==="ios"},isAndroid(){return this.OS==="android"},isWeb(){return this.OS==="web"},select(e){if(this.OS==="ios"&&e.ios!==void 0)return e.ios;if(this.OS==="android"&&e.android!==void 0)return e.android;if(this.OS==="web"&&e.web!==void 0)return e.web;return e.default}},Ft={create(e){return e},flatten(e){if(!e)return;if(Array.isArray(e))return Object.assign({},...e);return e},absoluteFill:{position:"absolute",top:0,left:0,right:0,bottom:0},hairlineWidth:typeof window<"u"?1/(window.devicePixelRatio||1):1};class Ut{_value;_listeners=[];constructor(e){this._value=e}setValue(e){this._value=e,this._listeners.forEach((t)=>t(e))}getValue(){return this._value}addListener(e){return this._listeners.push(e),String(this._listeners.length-1)}removeListener(e){let t=parseInt(e,10);if(t>=0&&t<this._listeners.length)this._listeners.splice(t,1)}removeAllListeners(){this._listeners=[]}}function st(e,t){return{start(r){let n=e.getValue(),i=Date.now(),a=t.duration||300,c=()=>{let d=Date.now()-i-(t.delay||0);if(d<0){requestAnimationFrame(c);return}let l=Math.min(d/a,1),u=t.easing?t.easing(l):l,f=n+(t.toValue-n)*u;if(e.setValue(f),l<1)requestAnimationFrame(c);else r?.({finished:!0})};requestAnimationFrame(c)},stop(){}}}var Ot={Value:Ut,timing:st,spring(e,t){return{start(r){let n=300*(t.friction||7)/7;st(e,{toValue:t.toValue,duration:n,easing:(i)=>1-(1-i)**3,useNativeDriver:t.useNativeDriver}).start(r)},stop(){}}},parallel(e){return{start(t){let r=0,n=e.length;if(n===0){t?.({finished:!0});return}e.forEach((i)=>{i.start(()=>{if(r++,r===n)t?.({finished:!0})})})},stop(){}}},sequence(e){return{start(t){let r=(n)=>{if(n>=e.length){t?.({finished:!0});return}e[n].start(()=>r(n+1))};r(0)},stop(){}}}};function ni(){if(typeof window>"u")return"web";let e=navigator.userAgent.toLowerCase();if(/iphone|ipad|ipod/.test(e))return"ios";if(/android/.test(e))return"android";return"web"}function ii(){if(typeof window>"u")return"unknown";let e=navigator.userAgent,t=e.match(/(?:iPhone|iPad|iPod).*?OS (\d+)/)||e.match(/Android (\d+)/);return t?t[1]:"unknown"}var ai={Platform:Rt,StyleSheet:Ft,Animated:Ot},si=ai;function oi(e,...t){let r="";for(let n=0;n<e.length;n++)if(r+=e[n],n<t.length)r+=String(t[n]);return r.replace(/\s+/g," ").trim()}function Ht(...e){let t=[];for(let r of e){if(!r)continue;if(typeof r==="string"||typeof r==="number")t.push(String(r));else if(Array.isArray(r)){let n=Ht(...r);if(n)t.push(n)}else if(typeof r==="object"){for(let[n,i]of Object.entries(r))if(i)t.push(n)}}return t.join(" ")}function ci(e){return(t={})=>{let r=[];if(e.base)r.push(e.base);for(let[n,i]of Object.entries(e.variants)){let a=t[n]??e.defaultVariants?.[n];if(a!==void 0&&i[a])r.push(i[a])}if(e.compoundVariants)for(let n of e.compoundVariants){let{className:i,...a}=n,c=!0;for(let[d,l]of Object.entries(a))if((t[d]??e.defaultVariants?.[d])!==l){c=!1;break}if(c&&i)r.push(i)}if(t.className)r.push(t.className);return r.join(" ")}}function Bs(e){let t={},r=e.split(/\s+/).filter(Boolean);for(let n of r){let i=di(n);if(i)Object.assign(t,i)}return t}function di(e){let t=e.match(/^([pm])([trblxy])?-(\d+(?:\.\d+)?|px)$/);if(t){let[,u,f,w]=t,p=w==="px"?1:parseFloat(w)*4,g=u==="p"?"padding":"margin";if(!f)return{[g]:p};if(f==="x")return{[`${g}Left`]:p,[`${g}Right`]:p};if(f==="y")return{[`${g}Top`]:p,[`${g}Bottom`]:p};return{[`${g}${{t:"Top",r:"Right",b:"Bottom",l:"Left"}[f]}`]:p}}let r=e.match(/^(w|h|min-w|max-w|min-h|max-h)-(\d+|full|screen|auto)$/);if(r){let[,u,f]=r,w={w:"width",h:"height","min-w":"minWidth","max-w":"maxWidth","min-h":"minHeight","max-h":"maxHeight"},g={full:"100%",screen:"100vh",auto:"auto"}[f]??parseFloat(f)*4;return{[w[u]]:g}}if(e==="flex")return{display:"flex"};if(e==="flex-1")return{flex:1};if(e==="flex-row")return{flexDirection:"row"};if(e==="flex-col")return{flexDirection:"column"};if(e==="flex-wrap")return{flexWrap:"wrap"};if(e==="items-center")return{alignItems:"center"};if(e==="items-start")return{alignItems:"flex-start"};if(e==="items-end")return{alignItems:"flex-end"};if(e==="justify-center")return{justifyContent:"center"};if(e==="justify-start")return{justifyContent:"flex-start"};if(e==="justify-end")return{justifyContent:"flex-end"};if(e==="justify-between")return{justifyContent:"space-between"};if(e==="justify-around")return{justifyContent:"space-around"};let n=e.match(/^gap-(\d+(?:\.\d+)?)$/);if(n)return{gap:parseFloat(n[1])*4};let i={"rounded-none":0,"rounded-sm":2,rounded:4,"rounded-md":6,"rounded-lg":8,"rounded-xl":12,"rounded-2xl":16,"rounded-3xl":24,"rounded-full":9999};if(i[e]!==void 0)return{borderRadius:i[e]};let a={"text-xs":12,"text-sm":14,"text-base":16,"text-lg":18,"text-xl":20,"text-2xl":24,"text-3xl":30,"text-4xl":36};if(a[e])return{fontSize:a[e]};let c={"font-thin":"100","font-extralight":"200","font-light":"300","font-normal":"400","font-medium":"500","font-semibold":"600","font-bold":"700","font-extrabold":"800","font-black":"900"};if(c[e])return{fontWeight:c[e]};if(e==="text-left")return{textAlign:"left"};if(e==="text-center")return{textAlign:"center"};if(e==="text-right")return{textAlign:"right"};let d=e.match(/^(bg|text|border)-(\w+)-(\d{2,3})$/);if(d){let[,u,f,w]=d,p=li(f,parseInt(w,10));if(p)return{[{bg:"backgroundColor",text:"color",border:"borderColor"}[u]]:p}}if(e==="bg-white")return{backgroundColor:"#ffffff"};if(e==="bg-black")return{backgroundColor:"#000000"};if(e==="bg-transparent")return{backgroundColor:"transparent"};if(e==="text-white")return{color:"#ffffff"};if(e==="text-black")return{color:"#000000"};let l=e.match(/^opacity-(\d+)$/);if(l)return{opacity:parseInt(l[1],10)/100};if(e==="relative")return{position:"relative"};if(e==="absolute")return{position:"absolute"};if(e==="hidden")return{display:"none"};if(e==="block")return{display:"block"};if(e==="inline")return{display:"inline"};if(e==="overflow-hidden")return{overflow:"hidden"};if(e==="overflow-scroll")return{overflow:"scroll"};if(e==="overflow-auto")return{overflow:"auto"};return null}function li(e,t){return{slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843"}}[e]?.[t]??null}function Ds(e){return JSON.stringify({content:e.content,output:e.output,minify:e.minify??!1,darkMode:e.darkMode??"class",jit:e.jit??!0,theme:e.theme??{}},null,2)}async function Ls(e){if(typeof window<"u"){console.warn("buildCSS can only be run in Node.js environment");return}let{exec:t}=await import("child_process"),{promisify:r}=await import("util"),n=r(t),i=["build","--content",e.content.join(","),"--output",e.output];if(e.minify)i.push("--minify");try{await n(`headwind ${i.join(" ")}`),console.log(`CSS built successfully: ${e.output}`)}catch(a){throw console.error("Failed to build CSS:",a),a}}var xe={sidebar:`
338
- w-[250px] h-full flex flex-col
339
- bg-white/55 dark:bg-[#1e1e23]/55
340
- backdrop-blur-[60px] backdrop-saturate-[1.8]
341
- text-black dark:text-white
342
- select-none
343
- `,content:`
344
- flex-1 overflow-y-auto overflow-x-hidden
345
- px-[10px] pb-[10px]
346
- `,section:`
347
- flex flex-col gap-[2px]
348
- `,sectionHeader:`
349
- pl-[8px] pr-[6px] pt-[16px] pb-[5px]
350
- text-[11px] font-semibold leading-[13px]
351
- text-[#3c3c43]/60 dark:text-[#ebebf5]/60
352
- `,sectionHeaderCollapsible:`
353
- group flex items-center w-full
354
- pl-[8px] pr-[6px] pt-[16px] pb-[5px]
355
- text-[11px] font-semibold leading-[13px]
356
- text-[#3c3c43]/60 dark:text-[#ebebf5]/60
357
- cursor-default
358
- `,collapseChevron:`
359
- ml-auto h-[11px] w-[11px]
360
- text-[#3c3c43]/45 dark:text-[#ebebf5]/45
361
- opacity-0 group-hover:opacity-100
362
- transition-all duration-200
363
- `,item:`
364
- flex w-full items-center
365
- h-[30px] rounded-[9px] pl-[4px] pr-[8px]
366
- text-[13px] leading-[16px] text-black dark:text-white
367
- cursor-default transition-colors duration-150 ease-out
368
- hover:bg-black/4 dark:hover:bg-white/6
369
- active:bg-black/10 dark:active:bg-white/18
370
- `,itemSelected:`
371
- flex w-full items-center
372
- h-[30px] rounded-[9px] pl-[4px] pr-[8px]
373
- text-[13px] leading-[16px] text-black dark:text-white
374
- cursor-default
375
- bg-black/8 dark:bg-white/14
376
- `,disclosure:`
377
- flex h-[16px] w-[18px] shrink-0 items-center justify-center
378
- `,disclosureChevron:`
379
- h-[11px] w-[11px]
380
- text-[#3c3c43]/55 dark:text-[#ebebf5]/55
381
- transition-transform duration-200 ease-out
382
- `,itemIcon:`
383
- h-[17px] w-[17px] flex-shrink-0
384
- text-[#0088ff]
385
- `,itemIconSelected:`
386
- h-[17px] w-[17px] flex-shrink-0
387
- text-[#0088ff]
388
- `,itemIconSlot:`
389
- flex h-[20px] w-[22px] shrink-0 items-center justify-center mr-[7px]
390
- `,itemLabel:`
391
- flex-1 truncate
392
- `,itemBadge:`
393
- ml-[8px] shrink-0 tabular-nums
394
- text-[13px] leading-[16px]
395
- text-[#3c3c43]/60 dark:text-[#ebebf5]/60
396
- `,itemBadgeSelected:`
397
- ml-[8px] shrink-0 tabular-nums
398
- text-[13px] leading-[16px]
399
- text-[#3c3c43]/60 dark:text-[#ebebf5]/60
400
- `,children:`
401
- ml-[16px] mt-[2px] flex flex-col gap-[2px]
402
- `,dragIndicator:`
403
- absolute left-0 right-0 h-0.5 bg-[#0088ff]
404
- pointer-events-none
405
- `,searchContainer:`
406
- px-[10px] pb-[6px]
407
- `,searchInput:`
408
- h-[28px] w-full rounded-[8px] px-[8px]
409
- text-[13px] text-black dark:text-white
410
- placeholder:text-[#3c3c43]/50 dark:placeholder:text-[#ebebf5]/50
411
- bg-black/5 dark:bg-white/10
412
- border border-transparent
413
- focus:outline-none focus:ring-2 focus:ring-[#0088ff]/60
414
- transition-all duration-150
415
- `,header:`
416
- h-[52px] px-[21px] flex items-center gap-3
417
- `,headerAvatar:`
418
- w-[30px] h-[30px] rounded-full bg-black/10 dark:bg-white/15
419
- flex items-center justify-center text-[13px] font-semibold
420
- `,headerTitle:`
421
- text-[13px] font-medium text-black dark:text-white
422
- `,headerSubtitle:`
423
- text-[11px] text-[#3c3c43]/60 dark:text-[#ebebf5]/60
424
- `,footer:`
425
- px-[10px] pb-[8px] pt-[4px] flex items-center gap-2
426
- `,footerButton:`
427
- grid h-[28px] w-[28px] place-items-center rounded-[7px]
428
- text-[#3c3c43]/70 dark:text-[#ebebf5]/70
429
- hover:bg-black/5 dark:hover:bg-white/10
430
- transition-colors duration-150
431
- `},Ge={sidebar:`
432
- w-64 h-full flex flex-col
433
- bg-neutral-100 dark:bg-neutral-900
434
- border-r border-neutral-200 dark:border-neutral-800
435
- transition-all duration-300 ease-out
436
- select-none
437
- `,sidebarCollapsed:`
438
- w-12 h-full flex flex-col
439
- bg-neutral-100 dark:bg-neutral-900
440
- border-r border-neutral-200 dark:border-neutral-800
441
- transition-all duration-300 ease-out
442
- select-none
443
- `,topBar:`
444
- h-10 px-2 flex items-center justify-between
445
- border-b border-neutral-200 dark:border-neutral-800
446
- `,collapseButton:`
447
- p-1.5 rounded-lg
448
- text-neutral-500 dark:text-neutral-400
449
- hover:bg-neutral-200 dark:hover:bg-neutral-800
450
- transition-colors duration-150
451
- `,newTabButton:`
452
- p-1.5 rounded-lg
453
- text-neutral-500 dark:text-neutral-400
454
- hover:bg-neutral-200 dark:hover:bg-neutral-800
455
- transition-colors duration-150
456
- `,content:`
457
- flex-1 overflow-y-auto overflow-x-hidden
458
- py-2
459
- scrollbar-thin scrollbar-thumb-neutral-300 dark:scrollbar-thumb-neutral-700
460
- `,pinnedSection:`
461
- px-2 pb-3 mb-2 border-b border-neutral-200 dark:border-neutral-800
462
- `,pinnedLabel:`
463
- px-2 py-1 text-[10px] font-semibold uppercase tracking-wider
464
- text-neutral-400 dark:text-neutral-500
465
- `,sectionHeader:`
466
- px-3 py-2 flex items-center justify-between
467
- text-[11px] font-semibold uppercase tracking-wider
468
- text-neutral-500 dark:text-neutral-400
469
- `,space:`
470
- mb-3
471
- `,spaceHeader:`
472
- px-2 py-1.5 mx-2 rounded-lg flex items-center gap-2
473
- cursor-pointer
474
- hover:bg-neutral-200/50 dark:hover:bg-neutral-800/50
475
- transition-colors duration-150
476
- `,spaceIcon:`
477
- w-5 h-5 rounded-md flex items-center justify-center text-xs
478
- `,spaceName:`
479
- flex-1 text-[12px] font-medium text-neutral-700 dark:text-neutral-200
480
- `,spaceCount:`
481
- text-[11px] text-neutral-400 dark:text-neutral-500
482
- `,item:`
483
- flex items-center gap-2.5 px-3 py-2 mx-2 rounded-xl
484
- text-[13px] text-neutral-700 dark:text-neutral-300
485
- cursor-pointer transition-all duration-200
486
- hover:bg-neutral-200/70 dark:hover:bg-neutral-800/70
487
- group
488
- `,itemSelected:`
489
- flex items-center gap-2.5 px-3 py-2 mx-2 rounded-xl
490
- text-[13px] text-white font-medium
491
- cursor-pointer transition-all duration-200
492
- bg-gradient-to-r from-purple-500 to-pink-500
493
- shadow-lg shadow-purple-500/25
494
- `,itemCollapsed:`
495
- flex items-center justify-center p-2.5 mx-1.5 rounded-xl
496
- cursor-pointer transition-all duration-200
497
- hover:bg-neutral-200/70 dark:hover:bg-neutral-800/70
498
- group relative
499
- `,itemCollapsedSelected:`
500
- flex items-center justify-center p-2.5 mx-1.5 rounded-xl
501
- cursor-pointer transition-all duration-200
502
- bg-gradient-to-r from-purple-500 to-pink-500
503
- shadow-lg shadow-purple-500/25
504
- `,itemFavicon:`
505
- w-4 h-4 rounded flex-shrink-0
506
- bg-neutral-300 dark:bg-neutral-700
507
- `,itemFaviconSelected:`
508
- w-4 h-4 rounded flex-shrink-0
509
- `,itemLabel:`
510
- flex-1 truncate
511
- `,itemClose:`
512
- p-0.5 rounded opacity-0 group-hover:opacity-100
513
- text-neutral-400 hover:text-neutral-600
514
- dark:text-neutral-500 dark:hover:text-neutral-300
515
- hover:bg-neutral-300/50 dark:hover:bg-neutral-700/50
516
- transition-all duration-150
517
- `,itemCloseSelected:`
518
- p-0.5 rounded opacity-0 group-hover:opacity-100
519
- text-white/60 hover:text-white
520
- hover:bg-white/20
521
- transition-all duration-150
522
- `,tooltip:`
523
- absolute left-full ml-2 px-2 py-1 rounded-md
524
- text-[12px] text-white bg-neutral-800 dark:bg-neutral-700
525
- whitespace-nowrap opacity-0 group-hover:opacity-100
526
- pointer-events-none transition-opacity duration-150
527
- z-50
528
- `,todaySection:`
529
- px-2 pt-2
530
- `,todayLabel:`
531
- px-2 py-1 text-[10px] font-semibold uppercase tracking-wider
532
- text-neutral-400 dark:text-neutral-500
533
- `,bottomBar:`
534
- px-2 py-2 border-t border-neutral-200 dark:border-neutral-800
535
- flex items-center gap-1
536
- `,bottomButton:`
537
- flex-1 py-2 rounded-lg flex items-center justify-center gap-2
538
- text-[12px] text-neutral-600 dark:text-neutral-400
539
- hover:bg-neutral-200 dark:hover:bg-neutral-800
540
- transition-colors duration-150
541
- `,spaceColors:{red:"bg-red-500",orange:"bg-orange-500",yellow:"bg-yellow-500",green:"bg-green-500",blue:"bg-blue-500",purple:"bg-purple-500",pink:"bg-pink-500"},selectedGradients:{purple:"bg-gradient-to-r from-purple-500 to-pink-500 shadow-purple-500/25",blue:"bg-gradient-to-r from-blue-500 to-cyan-500 shadow-blue-500/25",green:"bg-gradient-to-r from-green-500 to-emerald-500 shadow-green-500/25",orange:"bg-gradient-to-r from-orange-500 to-amber-500 shadow-orange-500/25",red:"bg-gradient-to-r from-red-500 to-rose-500 shadow-red-500/25"}},Qe={sidebar:`
542
- w-52 h-full flex flex-col
543
- bg-[#1a1a1a] dark:bg-[#1a1a1a]
544
- border-r border-[#2a2a2a]
545
- select-none
546
- `,header:`
547
- h-12 px-3 flex items-center justify-between
548
- border-b border-[#2a2a2a]
549
- `,headerTitle:`
550
- text-[13px] font-semibold text-white
551
- `,headerAction:`
552
- p-1 rounded
553
- text-neutral-500 hover:text-neutral-300
554
- hover:bg-white/5
555
- transition-colors duration-150
556
- `,content:`
557
- flex-1 overflow-y-auto overflow-x-hidden
558
- py-1
559
- scrollbar-thin scrollbar-thumb-neutral-700 scrollbar-track-transparent
560
- `,section:`
561
- py-1
562
- `,sectionHeader:`
563
- px-3 py-2 flex items-center justify-between
564
- text-[11px] font-medium uppercase tracking-wider
565
- text-neutral-500
566
- `,sectionHeaderClickable:`
567
- px-3 py-2 flex items-center justify-between cursor-pointer
568
- text-[11px] font-medium uppercase tracking-wider
569
- text-neutral-500 hover:text-neutral-400
570
- transition-colors duration-150
571
- `,sectionCount:`
572
- text-[10px] px-1.5 py-0.5 rounded
573
- bg-neutral-800 text-neutral-400
574
- `,divider:`
575
- my-1 mx-3 border-t border-[#2a2a2a]
576
- `,item:`
577
- flex items-center gap-2.5 px-3 py-1.5
578
- text-[13px] text-neutral-300
579
- cursor-pointer transition-colors duration-150
580
- hover:bg-white/5 hover:text-white
581
- `,itemSelected:`
582
- flex items-center gap-2.5 px-3 py-1.5
583
- text-[13px] text-white font-medium
584
- cursor-pointer
585
- bg-white/10
586
- `,itemWithIndicator:`
587
- flex items-center gap-2.5 px-3 py-1.5
588
- text-[13px] text-neutral-300
589
- cursor-pointer transition-colors duration-150
590
- hover:bg-white/5 hover:text-white
591
- relative
592
- `,runningIndicator:`
593
- w-1.5 h-1.5 rounded-full bg-green-500
594
- absolute left-1
595
- `,stoppedIndicator:`
596
- w-1.5 h-1.5 rounded-full bg-neutral-600
597
- absolute left-1
598
- `,itemIcon:`
599
- w-4 h-4 flex-shrink-0
600
- text-neutral-500
601
- `,itemIconSelected:`
602
- w-4 h-4 flex-shrink-0
603
- text-white
604
- `,itemLabel:`
605
- flex-1 truncate
606
- `,itemStatus:`
607
- text-[11px] text-neutral-500
608
- `,itemActions:`
609
- flex items-center gap-1 opacity-0 group-hover:opacity-100
610
- transition-opacity duration-150
611
- `,itemActionButton:`
612
- p-1 rounded
613
- text-neutral-500 hover:text-white
614
- hover:bg-white/10
615
- transition-colors duration-150
616
- `,group:`
617
- group
618
- `,groupHeader:`
619
- flex items-center gap-2 px-3 py-1.5 cursor-pointer
620
- text-[13px] text-neutral-400
621
- hover:bg-white/5 hover:text-neutral-200
622
- transition-colors duration-150
623
- `,groupChevron:`
624
- w-3 h-3 text-neutral-600
625
- transition-transform duration-200
626
- `,groupChevronExpanded:`
627
- w-3 h-3 text-neutral-600
628
- transition-transform duration-200
629
- rotate-90
630
- `,groupContent:`
631
- overflow-hidden transition-all duration-200
632
- `,footer:`
633
- px-3 py-2 border-t border-[#2a2a2a]
634
- flex items-center justify-between
635
- `,footerText:`
636
- text-[11px] text-neutral-500
637
- `,footerButton:`
638
- p-1.5 rounded
639
- text-neutral-500 hover:text-white
640
- hover:bg-white/10
641
- transition-colors duration-150
642
- `,contextMenu:`
643
- min-w-40 py-1 rounded-lg
644
- bg-[#252525] border border-[#3a3a3a]
645
- shadow-xl shadow-black/50
646
- `,contextMenuItem:`
647
- px-3 py-1.5 flex items-center gap-2
648
- text-[13px] text-neutral-300
649
- cursor-pointer
650
- hover:bg-white/10
651
- transition-colors duration-100
652
- `,contextMenuItemDanger:`
653
- px-3 py-1.5 flex items-center gap-2
654
- text-[13px] text-red-400
655
- cursor-pointer
656
- hover:bg-red-500/10
657
- transition-colors duration-100
658
- `,contextMenuDivider:`
659
- my-1 border-t border-[#3a3a3a]
660
- `,emptyState:`
661
- flex flex-col items-center justify-center py-8
662
- text-neutral-500
663
- `,emptyStateIcon:`
664
- w-8 h-8 mb-2 text-neutral-600
665
- `,emptyStateText:`
666
- text-[13px]
667
- `,loadingSpinner:`
668
- w-4 h-4 border-2 border-neutral-600 border-t-neutral-400
669
- rounded-full animate-spin
670
- `},Rs={transitionFast:"transition-all duration-150",transitionNormal:"transition-all duration-200",transitionSlow:"transition-all duration-300",scrollbarThin:"scrollbar-thin scrollbar-track-transparent",scrollbarLight:"scrollbar-thumb-black/10 hover:scrollbar-thumb-black/20",scrollbarDark:"scrollbar-thumb-white/10 hover:scrollbar-thumb-white/20",focusRing:"focus:outline-none focus:ring-2 focus:ring-blue-500/50",focusRingInset:"focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500/50",truncate:"truncate",lineClamp2:"line-clamp-2",flexCenter:"flex items-center justify-center",flexBetween:"flex items-center justify-between",flexStart:"flex items-center justify-start",hideScrollbar:"scrollbar-none [-ms-overflow-style:none] [scrollbar-width:none]"},Fs=`
671
- :root {
672
- /* Tahoe style variables */
673
- --sidebar-tahoe-bg: rgba(255, 255, 255, 0.7);
674
- --sidebar-tahoe-bg-dark: rgba(30, 30, 30, 0.7);
675
- --sidebar-tahoe-border: rgba(0, 0, 0, 0.05);
676
- --sidebar-tahoe-border-dark: rgba(255, 255, 255, 0.05);
677
- --sidebar-tahoe-text: #404040;
678
- --sidebar-tahoe-text-dark: #e5e5e5;
679
- --sidebar-tahoe-text-muted: #737373;
680
- --sidebar-tahoe-text-muted-dark: #a3a3a3;
681
- --sidebar-tahoe-selected: #3b82f6;
682
- --sidebar-tahoe-hover: rgba(0, 0, 0, 0.05);
683
- --sidebar-tahoe-hover-dark: rgba(255, 255, 255, 0.05);
684
-
685
- /* Arc style variables */
686
- --sidebar-arc-bg: #f5f5f5;
687
- --sidebar-arc-bg-dark: #171717;
688
- --sidebar-arc-border: #e5e5e5;
689
- --sidebar-arc-border-dark: #262626;
690
- --sidebar-arc-selected-from: #a855f7;
691
- --sidebar-arc-selected-to: #ec4899;
692
- --sidebar-arc-hover: rgba(0, 0, 0, 0.05);
693
- --sidebar-arc-hover-dark: rgba(255, 255, 255, 0.05);
694
-
695
- /* OrbStack style variables */
696
- --sidebar-orb-bg: #1a1a1a;
697
- --sidebar-orb-border: #2a2a2a;
698
- --sidebar-orb-text: #d4d4d4;
699
- --sidebar-orb-text-muted: #737373;
700
- --sidebar-orb-selected: rgba(255, 255, 255, 0.1);
701
- --sidebar-orb-hover: rgba(255, 255, 255, 0.05);
702
- --sidebar-orb-accent: #22c55e;
703
- }
704
- `;function Us(e){switch(e){case"tahoe":return xe;case"arc":return Ge;case"orbstack":return Qe;default:return xe}}var B={home:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'/></svg>",folder:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z'/></svg>",document:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'/></svg>",star:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z'/></svg>",download:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4'/></svg>",cloud:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z'/></svg>",settings:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z'/><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'/></svg>",plus:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 4v16m8-8H4'/></svg>",search:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/></svg>",chevronRight:"<svg class='h-3 w-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5l7 7-7 7'/></svg>",chevronDown:"<svg class='h-3 w-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/></svg>",x:"<svg class='h-3 w-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 18L18 6M6 6l12 12'/></svg>",menu:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 12h16M4 18h16'/></svg>",container:"<svg class='h-4 w-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4'/></svg>",linux:"<svg class='h-4 w-4' fill='currentColor' viewBox='0 0 24 24'><path d='M12.504 0c-.155 0-.311.001-.465.003-.653.014-1.304.07-1.952.17-1.328.205-2.607.596-3.796 1.157-1.189.56-2.28 1.293-3.234 2.174-.954.88-1.757 1.9-2.384 3.022-.627 1.122-1.07 2.342-1.313 3.608-.244 1.266-.286 2.575-.126 3.855.16 1.28.519 2.517 1.066 3.666.547 1.149 1.274 2.197 2.152 3.105.877.908 1.9 1.666 3.025 2.249 1.126.583 2.349.984 3.609 1.192 1.261.208 2.555.218 3.82.029 1.265-.189 2.497-.576 3.642-1.148 1.145-.572 2.187-1.32 3.086-2.212.898-.892 1.643-1.922 2.212-3.045.568-1.123.952-2.332 1.138-3.577.186-1.245.176-2.518-.03-3.766-.206-1.248-.607-2.462-1.191-3.588-.583-1.125-1.343-2.15-2.25-3.029-.907-.879-1.957-1.607-3.1-2.156-1.142-.548-2.377-.913-3.643-1.078-.653-.085-1.31-.125-1.966-.125z'/></svg>"};function Z(e){return B[e]||B.document}function ui(e){let t=xe,r=(i,a=0)=>{let c=i.selected,d=c?t.itemSelected:t.item,l=c?t.itemIconSelected:t.itemIcon,u=c?t.itemBadgeSelected:t.itemBadge,w=(i.children?.length??0)>0?`<span class='${t.disclosureChevron}${i.expanded?" rotate-90":""}'>${B.chevronRight}</span>`:"",p=i.color?` style='color: ${i.color}'`:"",g=`
705
- <div class='${d}' data-id='${i.id}'${a>0?` style='padding-left: ${4+a*16}px'`:""}>
706
- <span class='${t.disclosure}'>${w}</span>
707
- <span class='${t.itemIconSlot}'><span class='${l}'${p}>${Z(i.icon||"document")}</span></span>
708
- <span class='${t.itemLabel}'>${i.label}</span>
709
- ${i.badge?`<span class='${u}'>${i.badge}</span>`:""}
710
- </div>
711
- `;if(i.children&&i.expanded)i.children.forEach((v)=>{g+=r(v,a+1)});return g},n=(i)=>`
712
- <div class='${t.section}'>
713
- ${i.title?`
714
- <div class="${i.collapsible?t.sectionHeaderCollapsible:t.sectionHeader}" data-section="${i.id}">
715
- <span class='truncate'>${i.title}</span>
716
- ${i.collapsible?`<span class='${t.collapseChevron}${i.collapsed?" -rotate-90":""}'>${B.chevronDown}</span>`:""}
717
- </div>
718
- `:""}
719
- ${!i.collapsed?i.items.map((a)=>r(a)).join(""):""}
720
- </div>
721
- `;return`
722
- <div class='${t.sidebar}'>
723
- ${e.header?`
724
- <div class='${t.header}'>
725
- ${e.header.avatar?`
726
- <div class="${t.headerAvatar}">${e.header.avatar}</div>
727
- `:""}
728
- <div>
729
- ${e.header.title?`<div class="${t.headerTitle}">${e.header.title}</div>`:""}
730
- ${e.header.subtitle?`<div class="${t.headerSubtitle}">${e.header.subtitle}</div>`:""}
731
- </div>
732
- </div>
733
- `:""}
734
-
735
- ${e.showSearch?`
736
- <div class='${t.searchContainer}'>
737
- <input type='text' class='${t.searchInput}' placeholder='${e.searchPlaceholder||"Search"}' />
738
- </div>
739
- `:""}
740
-
741
- <div class='${t.content}'>
742
- ${e.sections?e.sections.map((i)=>n(i)).join(""):""}
743
- ${e.items?e.items.map((i)=>r(i)).join(""):""}
744
- </div>
745
-
746
- ${e.footer?`
747
- <div class='${t.footer}'>
748
- ${e.footer.items?.map((i)=>`
749
- <button class="${t.footerButton}" data-id="${i.id}">
750
- ${Z(i.icon||"settings")}
751
- </button>
752
- `).join("")||""}
753
- </div>
754
- `:""}
755
- </div>
756
- `}function fi(e,t=!1){let r=Ge,n=t?r.sidebarCollapsed:r.sidebar,i=(c)=>{let d=c.selected;if(t)return`
757
- <div class='${d?r.itemCollapsedSelected:r.itemCollapsed}' data-id='${c.id}'>
758
- <span class="${d?r.itemFaviconSelected:r.itemFavicon}">
759
- ${c.icon?Z(c.icon):""}
760
- </span>
761
- <div class='${r.tooltip}'>${c.label}</div>
762
- </div>
763
- `;let l=d?r.itemSelected:r.item,u=d?r.itemCloseSelected:r.itemClose;return`
764
- <div class='${l} group' data-id='${c.id}'>
765
- <span class="${d?r.itemFaviconSelected:r.itemFavicon}">
766
- ${c.icon?Z(c.icon):""}
767
- </span>
768
- <span class='${r.itemLabel}'>${c.label}</span>
769
- <button class='${u}'>${B.x}</button>
770
- </div>
771
- `},a=(c)=>{let d=r.spaceColors[c.color]||r.spaceColors.purple;return`
772
- <div class='${r.space}'>
773
- <div class='${r.spaceHeader}' data-space='${c.id}'>
774
- <div class='${d} ${r.spaceIcon}'>${c.title?.[0]||"\u2022"}</div>
775
- ${!t?`
776
- <span class='${r.spaceName}'>${c.title}</span>
777
- <span class='${r.spaceCount}'>${c.items.length}</span>
778
- `:""}
779
- </div>
780
- ${!c.collapsed?c.items.map((l)=>i(l)).join(""):""}
781
- </div>
782
- `};return`
783
- <div class='${n}'>
784
- <div class='${r.topBar}'>
785
- <button class='${r.collapseButton}' id='arc-collapse-toggle'>
786
- ${B.menu}
787
- </button>
788
- ${!t?`
789
- <button class='${r.newTabButton}'>
790
- ${B.plus}
791
- </button>
792
- `:""}
793
- </div>
794
-
795
- <div class='${r.content}'>
796
- ${e.sections?.[0]?.title==="Pinned"?`
797
- <div class='${r.pinnedSection}'>
798
- ${!t?`<div class="${r.pinnedLabel}">Pinned</div>`:""}
799
- ${e.sections[0].items.map((c)=>i(c)).join("")}
800
- </div>
801
- `:""}
802
-
803
- ${e.sections?.slice(e.sections[0]?.title==="Pinned"?1:0).map((c)=>a(c)).join("")||""}
804
- ${e.items?e.items.map((c)=>i(c)).join(""):""}
805
- </div>
806
-
807
- <div class='${r.bottomBar}'>
808
- ${!t?`
809
- <button class='${r.bottomButton}'>
810
- ${B.download}
811
- <span>Downloads</span>
812
- </button>
813
- `:`
814
- <button class='${r.collapseButton}'>
815
- ${B.download}
816
- </button>
817
- `}
818
- </div>
819
- </div>
820
- `}function hi(e){let t=Qe,r=(a)=>{let c=a.selected,d=c?t.itemSelected:t.item,l=c?t.itemIconSelected:t.itemIcon,u=a.status&&a.status!=="none",f=a.status==="running"?t.runningIndicator:t.stoppedIndicator;return`
821
- <div class='${d} group' data-id='${a.id}' ${u?"style='padding-left: 20px'":""}>
822
- ${u?`<div class='${f}'></div>`:""}
823
- <span class='${l}'>${Z(a.icon||"container")}</span>
824
- <span class='${t.itemLabel}'>${a.label}</span>
825
- ${a.status?`<span class='${t.itemStatus}'>${a.status}</span>`:""}
826
- <div class='${t.itemActions}'>
827
- <button class='${t.itemActionButton}'>${B.settings}</button>
828
- </div>
829
- </div>
830
- `},n=(a)=>`
831
- <div class='${t.section}'>
832
- ${a.title?`
833
- <div class="${a.collapsible?t.sectionHeaderClickable:t.sectionHeader}" data-section="${a.id}">
834
- <span>${a.title}</span>
835
- ${a.items.length>0?`<span class="${t.sectionCount}">${a.items.length}</span>`:""}
836
- </div>
837
- `:""}
838
- ${!a.collapsed?a.items.map((c)=>r(c)).join(""):""}
839
- </div>
840
- `,i=(a)=>{let c=a.expanded?t.groupChevronExpanded:t.groupChevron;return`
841
- <div class='${t.group}'>
842
- <div class='${t.groupHeader}' data-group='${a.id}'>
843
- <span class='${c}'>${B.chevronRight}</span>
844
- <span class='${t.itemIcon}'>${Z(a.icon||"folder")}</span>
845
- <span class='${t.itemLabel}'>${a.label}</span>
846
- </div>
847
- ${a.expanded&&a.children?`
848
- <div class='${t.groupContent}'>
849
- ${a.children.map((d)=>r(d)).join("")}
850
- </div>
851
- `:""}
852
- </div>
853
- `};return`
854
- <div class='${t.sidebar}'>
855
- <div class='${t.header}'>
856
- <span class='${t.headerTitle}'>${e.header?.title||"OrbStack"}</span>
857
- <button class='${t.headerAction}'>${B.plus}</button>
858
- </div>
859
-
860
- <div class='${t.content}'>
861
- ${e.sections?e.sections.map((a)=>n(a)).join(""):""}
862
- ${e.items?e.items.map((a)=>a.children?i(a):r(a)).join(""):""}
863
- </div>
864
-
865
- <div class='${t.footer}'>
866
- <span class='${t.footerText}'>v4.0.0</span>
867
- <button class='${t.footerButton}'>${B.settings}</button>
868
- </div>
869
- </div>
870
- `}var Os={header:{title:"MacBook Pro",subtitle:"256 GB available",avatar:"\uD83D\uDCBB"},showSearch:!0,searchPlaceholder:"Search",sections:[{id:"favorites",title:"Favorites",collapsible:!0,items:[{id:"airdrop",label:"AirDrop",icon:"cloud"},{id:"recents",label:"Recents",icon:"document",badge:12},{id:"applications",label:"Applications",icon:"folder"},{id:"desktop",label:"Desktop",icon:"home",selected:!0},{id:"documents",label:"Documents",icon:"folder"},{id:"downloads",label:"Downloads",icon:"download",badge:3}]},{id:"icloud",title:"iCloud",collapsible:!0,items:[{id:"icloud-drive",label:"iCloud Drive",icon:"cloud"},{id:"shared",label:"Shared",icon:"folder"}]},{id:"tags",title:"Tags",collapsible:!0,collapsed:!0,items:[{id:"red",label:"Red"},{id:"orange",label:"Orange"}]}],footer:{items:[{id:"settings",label:"Settings",icon:"settings"}]}},Hs={sections:[{id:"pinned",title:"Pinned",items:[{id:"github",label:"GitHub",icon:"document",selected:!0},{id:"twitter",label:"Twitter",icon:"document"},{id:"figma",label:"Figma",icon:"document"}]},{id:"work",title:"Work",items:[{id:"slack",label:"Slack - Acme Inc",icon:"document"},{id:"notion",label:"Notion",icon:"document"},{id:"linear",label:"Linear",icon:"document"}]},{id:"personal",title:"Personal",items:[{id:"youtube",label:"YouTube",icon:"document"},{id:"spotify",label:"Spotify",icon:"document"}]}]},Ns={header:{title:"OrbStack"},sections:[{id:"machines",title:"Machines",items:[{id:"ubuntu",label:"ubuntu",icon:"linux",status:"running",selected:!0},{id:"fedora",label:"fedora",icon:"linux",status:"stopped"},{id:"alpine",label:"alpine",icon:"linux",status:"stopped"}]},{id:"containers",title:"Containers",items:[{id:"postgres",label:"postgres:15",icon:"container",status:"running"},{id:"redis",label:"redis:7",icon:"container",status:"running"},{id:"nginx",label:"nginx:latest",icon:"container",status:"stopped"}]}]};function qs(e,t){return`
871
- <!DOCTYPE html>
872
- <html lang="en" class="${t==="orbstack"?"dark":""}">
873
- <head>
874
- <meta charset='UTF-8'>
875
- <meta name='viewport' content='width=device-width, initial-scale=1.0'>
876
- <title>Craft Sidebar - ${t}</title>
877
- <script src='https://cdn.tailwindcss.com'></script>
878
- <style>
879
- /* Custom scrollbar */
880
- .scrollbar-thin::-webkit-scrollbar { width: 6px; }
881
- .scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
882
- .scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
883
- .dark .scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
884
- .scrollbar-none::-webkit-scrollbar { display: none; }
885
-
886
- /* Backdrop blur fallback */
887
- @supports not (backdrop-filter: blur(1px)) {
888
- .backdrop-blur-xl { background: rgba(255,255,255,0.95); }
889
- .dark .backdrop-blur-xl { background: rgba(30,30,30,0.95); }
890
- }
891
- </style>
892
- </head>
893
- <body class='flex min-h-screen ${t==="orbstack"?"bg-[#0f0f0f]":"bg-neutral-50 dark:bg-neutral-900"}'>
894
- ${e}
895
- <div class='flex-1 p-8'>
896
- <div class='text-neutral-400 dark:text-neutral-500'>
897
- Content area - select items in the sidebar
898
- </div>
899
- </div>
900
- <script>
901
- // Add click handlers
902
- document.querySelectorAll('[data-id]').forEach(el => {
903
- el.addEventListener('click', () => {
904
- console.log('Selected:', el.dataset.id);
905
- // You would update selection state here
906
- });
907
- });
908
- </script>
909
- </body>
910
- </html>
911
- `}var Vs={tw:oi,cx:Ht,variants:ci,sidebar:{tahoe:xe,arc:Ge,orbstack:Qe},templates:{tahoe:ui,arc:fi,orbstack:hi}},Ws={configureProduction(e={}){if(typeof window<"u"){if(!e.enableDevTools)window.__REACT_DEVTOOLS_GLOBAL_HOOK__={isDisabled:!0}}},createLazyFactory(){return(e,t={})=>{let r=null,n=async()=>{if(!r)r=e();await r};if(t.preload)if(typeof requestIdleCallback<"u")requestIdleCallback(()=>n());else setTimeout(()=>n(),0);return{load:n}}},createDebouncedValueHook(e){let t=null,r;return(n)=>{if(t)clearTimeout(t);return t=setTimeout(()=>{r=n,t=null},e),r??n}},createThrottle(e,t){let r=0;return(...n)=>{let i=Date.now();if(i-r>=t)e(...n),r=i}}},zs={configureProduction(e,t={}){if(!e?.config)return;if(!t.enableDevTools&&e.config.devtools!==void 0)e.config.devtools=!1;if(e.config.performance!==void 0)e.config.performance=t.performance||!1;if(t.errorHandler)e.config.errorHandler=t.errorHandler;if(t.warnHandler)e.config.warnHandler=t.warnHandler},createAsyncConfig(e={}){let{delay:t=200,timeout:r=30000,retries:n=3}=e;return{delay:t,timeout:r,onError(i,a,c,d){if(d<=n)a();else c()}}},createCacheFactory(e={}){let{maxAge:t=0,maxEntries:r=1000}=e;if(!Number.isInteger(r)||r<1)throw Error(`createCacheFactory: maxEntries must be a positive integer (got ${r})`);let n=new Map;return{cache:n,get(i,a){let c=Date.now(),d=n.get(i);if(d&&(t===0||c-d.timestamp<t))return n.delete(i),n.set(i,d),d.value;let l=a();n.set(i,{value:l,timestamp:c});while(n.size>r){let u=n.keys().next().value;if(u===void 0)break;n.delete(u)}return l},invalidate(i){if(i)n.delete(i);else n.clear()}}}},js={createMemoizer(e,t){let r,n;return(i)=>{if(r!==void 0&&r===i&&n!==void 0)return n;let a=e(i);if(n!==void 0&&t&&t(n,a))return n;return r=i,n=a,a}},createDebouncedSetter(e=300){let t;return{set(r,n){if(t)clearTimeout(t);t=setTimeout(()=>{n(r),t=void 0},e)},cancel(){if(t)clearTimeout(t),t=void 0}}},createThrottledSetter(e=100){let t=0,r,n;return{set(i,a){let c=Date.now();if(c-t>=e)a(i),t=c;else if(r={value:i,callback:a},!n)n=setTimeout(()=>{if(r)r.callback(r.value),r=void 0;t=Date.now(),n=void 0},e-(c-t))}}},createLazyActionConfig(e={}){return{threshold:e.threshold??0,rootMargin:e.rootMargin??"50px"}},createAcceleratedTransitionConfig(e,t={}){let{duration:r=300,easing:n="cubic-bezier(0.4, 0, 0.2, 1)"}=t;return{type:e,duration:r,easing:n,willChange:{fade:"opacity",slide:"transform, opacity",scale:"transform, opacity"}[e]}}},ot={defer(e){if(typeof requestIdleCallback<"u")requestIdleCallback(e);else setTimeout(e,0)},preload(e,t){if(typeof document>"u")return;e.forEach((r)=>{let n=document.createElement("link");if(n.rel="preload",n.href=r,n.as=t,t==="font")n.crossOrigin="anonymous";document.head.appendChild(n)})},prefetch(e){if(typeof document>"u")return;e.forEach((t)=>{let r=document.createElement("link");r.rel="prefetch",r.href=t,document.head.appendChild(r)})},createLazyLoader(e,t={}){if(typeof IntersectionObserver>"u")return null;return new IntersectionObserver((r)=>{r.forEach((n)=>{if(n.isIntersecting)e(n)})},{rootMargin:"50px",threshold:0,...t})},measureRender(e){let t;return{start(){if(typeof performance<"u")t=performance.now(),performance.mark(`${e}-start`)},end(){if(typeof performance<"u"&&t){let r=performance.now();if(performance.mark(`${e}-end`),performance.measure(e,`${e}-start`,`${e}-end`),typeof process<"u"&&process.env?.NODE_ENV==="development")console.log(`[Craft] ${e} rendered in ${(r-t).toFixed(2)}ms`)}}}},memoize(e,t={}){let{maxSize:r=100,ttl:n=0}=t,i=new Map,a=[];return(...c)=>{let d=JSON.stringify(c),l=Date.now(),u=i.get(d);if(u){if(n===0||l-u.timestamp<n)return u.value;i.delete(d),a.splice(a.indexOf(d),1)}let f=e(...c);i.set(d,{value:f,timestamp:l}),a.push(d);while(a.length>r){let w=a.shift();i.delete(w)}return f}},batchDOMUpdates(e){if(typeof requestAnimationFrame<"u")requestAnimationFrame(()=>{e.forEach((t)=>t())});else e.forEach((t)=>t())},debounce(e,t){let r,n=(...i)=>{if(r)clearTimeout(r);r=setTimeout(()=>{e(...i),r=void 0},t)};return n.cancel=()=>{if(r)clearTimeout(r),r=void 0},n},throttle(e,t){let r=0;return(...n)=>{let i=Date.now();if(i-r>=t)e(...n),r=i}},detectReducedMotion(){if(typeof window>"u")return!1;return window.matchMedia("(prefers-reduced-motion: reduce)").matches},detectLowEndDevice(){if(typeof navigator>"u")return!1;let e=navigator.deviceMemory;if(e&&e<4)return!0;let t=navigator.hardwareConcurrency;if(t&&t<4)return!0;if(navigator.connection?.saveData)return!0;return!1},getAdaptiveQuality(){let e=ot.detectLowEndDevice(),t=ot.detectReducedMotion();if(e||t)return"low";if(typeof window<"u"){if((window.devicePixelRatio||1)>=2)return"high"}return"medium"}},wi={};wt(wi,{updaterCommand:()=>bi,generateUpdateManifest:()=>yi,default:()=>vi,DeltaGenerator:()=>ee,AutoUpdater:()=>Ie});function ut(e,t,r){let n=C("find",[e,"-name",t,"-type",r,"-print0"]),i=String.fromCharCode(0);return n.toString("utf-8").split(i).filter((c)=>c.length>0)[0]??""}class Ie extends gi{config;updateInfo=null;downloadPath=null;checkTimer=null;cachedEtag=null;cachedLastModified=null;cachedManifest=null;emitError(e){if(this.listenerCount("error")>0)this.emit("error",e);else console.error("[Updater]",e)}constructor(e){super();let t=e.updateUrl;if(typeof t!=="string"||t.length===0)throw Error("Updater: updateUrl is required");if(!/^(?:https:|file:)\/\//i.test(t))throw Error(`Updater: updateUrl must use https:// (got: ${t})`);this.config={autoDownload:!0,autoInstall:!1,channel:"stable",checkInterval:3600000,...e}}startAutoCheck(){if(this.checkForUpdates(),this.config.checkInterval)this.checkTimer=setInterval(()=>{this.checkForUpdates()},this.config.checkInterval)}stopAutoCheck(){if(this.checkTimer)clearInterval(this.checkTimer),this.checkTimer=null}async checkForUpdates(){this.emit("checking-for-update");try{let e=this.getPlatform(),t=`${this.config.updateUrl}?v=${this.config.currentVersion}&channel=${this.config.channel}&platform=${e}`,r={};if(this.cachedEtag)r["If-None-Match"]=this.cachedEtag;if(this.cachedLastModified)r["If-Modified-Since"]=this.cachedLastModified;let n=await fetch(t,{headers:r});if(n.status===304&&this.cachedManifest){if(this.isNewerVersion(this.cachedManifest.version,this.config.currentVersion))return this.updateInfo=this.cachedManifest,this.emit("update-available",this.cachedManifest),this.cachedManifest;return this.emit("update-not-available"),null}if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();if(this.cachedEtag=n.headers.get("etag")||null,this.cachedLastModified=n.headers.get("last-modified")||null,this.cachedManifest=i,this.isNewerVersion(i.version,this.config.currentVersion)){if(i.minVersion&&this.isNewerVersion(i.minVersion,this.config.currentVersion))console.log(`Update requires minimum version ${i.minVersion}`);if(this.updateInfo=i,this.emit("update-available",i),this.config.autoDownload)await this.downloadUpdate();return i}else return this.emit("update-not-available"),null}catch(e){return this.emitError(e),null}}async downloadUpdate(){if(!this.updateInfo)throw Error("No update available");let e=this.getPlatform(),t=this.updateInfo.platforms[e];if(!t)throw Error(`No update available for platform: ${e}`);let r=t.delta?.find((u)=>u.fromVersion===this.config.currentVersion),n=r||t,i=r?.url||t.url,a=r?.size||t.size,c=r?.sha256||t.sha256,d=me(this.config.appPath,"..",".craft-updates");dt(d,{recursive:!0});let l=lt(i);this.downloadPath=me(d,l);try{let u=await fetch(i);if(!u.ok)throw Error(`Download failed: HTTP ${u.status}`);let w=parseInt(u.headers.get("content-length")||"0",10)||a,p=0,g=Date.now(),v=pi(this.downloadPath),k=u.body?.getReader();if(!k)throw Error("Failed to get response reader");while(!0){let{done:S,value:R}=await k.read();if(S)break;v.write(R),p+=R.length;let ce=(Date.now()-g)/1000,qt=p/ce,Vt={phase:"downloading",percent:Math.round(p/w*100),bytesDownloaded:p,bytesTotal:w,speed:qt};this.emit("download-progress",Vt)}if(v.end(),await new Promise((S,R)=>{v.once("finish",S),v.once("error",R)}),await this.computeFileHash(this.downloadPath)!==c)throw N(this.downloadPath),Error("Download verification failed: hash mismatch");if(r){if(!Le(this.config.appPath).isFile())throw Error("Delta updates require appPath to point to the installed bundle file");let S=this.downloadPath,R=me(d,`reconstructed-${lt(t.url)}`);if(await ee.apply(this.config.appPath,S,R),await this.computeFileHash(R)!==t.sha256){try{N(R)}catch{}throw Error("Delta reconstruction failed: full bundle hash mismatch")}N(S),this.downloadPath=R}if(this.config.publicKeyPem&&!t.signature)throw N(this.downloadPath),Error("Updater: publicKeyPem is configured but the manifest entry has no signature. Refusing to install unsigned update.");if(t.signature){if(!await this.verifySignature(this.downloadPath,t.signature))throw N(this.downloadPath),Error("Download verification failed: invalid signature")}if(this.emit("update-downloaded",{path:this.downloadPath,version:this.updateInfo.version,isDelta:!!r}),this.config.autoInstall)await this.installUpdate();return this.downloadPath}catch(u){return this.emitError(u),null}}async installUpdate(e=!0){if(!this.downloadPath||!ct(this.downloadPath))throw Error("No update downloaded");if(this.updateInfo){let n=this.getPlatform(),i=this.updateInfo.platforms[n];if(i){if(await this.computeFileHash(this.downloadPath)!==i.sha256){try{N(this.downloadPath)}catch{}throw Error(`Updater.installUpdate: pre-install hash mismatch on ${this.downloadPath}. `+"The downloaded bundle changed between download and install \u2014 refusing to run installer.")}if(this.config.publicKeyPem&&!i.signature)throw Error("Updater.installUpdate: publicKeyPem is configured but manifest has no signature. Refusing to install unsigned update.");if(i.signature){if(!await this.verifySignature(this.downloadPath,i.signature)){try{N(this.downloadPath)}catch{}throw Error("Updater.installUpdate: invalid signature on downloaded bundle")}}}}this.emit("before-quit-for-update");let t=this.getPlatform(),r={phase:"installing",percent:0};this.emit("download-progress",r);try{switch(t){case"darwin":await this.installMacOSUpdate();break;case"win32":await this.installWindowsUpdate();break;case"linux":await this.installLinuxUpdate();break}if(this.downloadPath&&ct(this.downloadPath))N(this.downloadPath);if(r.phase="done",r.percent=100,this.emit("download-progress",r),e)this.restartApp()}catch(n){throw r.phase="error",this.emitError(n),n}}async installMacOSUpdate(){let e=this.downloadPath,t=this.config.appPath;if(e.endsWith(".zip")){let r=me($e(e),"extracted");dt(r,{recursive:!0}),C("unzip",["-o",e,"-d",r]);let n=ut(r,"*.app","d");if(n){let{rmSync:a,renameSync:c}=await import("fs");a(t,{recursive:!0,force:!0}),c(n,t)}let{rmSync:i}=await import("fs");i(r,{recursive:!0,force:!0})}else if(e.endsWith(".dmg")){let n=C("hdiutil",["attach",e,"-nobrowse"]).toString().match(/\/Volumes\/[^\n]+/)?.[0];if(n){let i=ut(n,"*.app","d");if(i){let{rmSync:a,cpSync:c}=await import("fs");a(t,{recursive:!0,force:!0}),c(i,t,{recursive:!0})}C("hdiutil",["detach",n])}}else if(e.endsWith(".pkg")){try{C("pkgutil",["--check-signature",e],{stdio:"pipe"})}catch(r){throw Error(`Refusing to install ${e}: pkgutil --check-signature failed. The .pkg is not signed by a trusted Apple certificate chain. Underlying error: ${r.message}`)}C("sudo",["installer","-pkg",e,"-target","/"])}}async installWindowsUpdate(){let e=this.downloadPath;if(e.endsWith(".exe"))re(e,["/S","/SILENT","/VERYSILENT"],{detached:!0,stdio:"ignore"});else if(e.endsWith(".msi"))re("msiexec",["/i",e,"/quiet","/norestart"],{detached:!0,stdio:"ignore"});else if(e.endsWith(".zip")){let t=$e(this.config.appPath);C("powershell",["-NoProfile","-NonInteractive","-Command","Expand-Archive -Force -Path $env:CRAFT_UPDATE_SRC -DestinationPath $env:CRAFT_UPDATE_DST"],{env:{...process.env,CRAFT_UPDATE_SRC:e,CRAFT_UPDATE_DST:t}})}}async installLinuxUpdate(){let e=this.downloadPath;if(e.endsWith(".AppImage")){C("chmod",["+x",e]);let{renameSync:t}=await import("fs");t(e,this.config.appPath)}else if(e.endsWith(".deb"))C("sudo",["dpkg","-i",e]);else if(e.endsWith(".rpm"))C("sudo",["rpm","-U",e]);else if(e.endsWith(".tar.gz")){let t=$e(this.config.appPath);C("tar",["-xzf",e,"-C",t])}}restartApp(){let e=this.getPlatform(),t=this.config.appPath;switch(e){case"darwin":re("open",["-n",t],{detached:!0,stdio:"ignore"});break;case"win32":re(t,[],{detached:!0,stdio:"ignore"});break;case"linux":re(t,[],{detached:!0,stdio:"ignore"});break}process.exit(0)}getPlatform(){switch(process.platform){case"darwin":return"darwin";case"win32":return"win32";default:return"linux"}}isNewerVersion(e,t){let r=e.split(".").map(Number),n=t.split(".").map(Number);for(let i=0;i<Math.max(r.length,n.length);i++){let a=r[i]||0,c=n[i]||0;if(a>c)return!0;if(a<c)return!1}return!1}async computeFileHash(e){return new Promise((t,r)=>{let n=ke("sha256"),i=Nt(e);i.on("data",(a)=>n.update(a)),i.on("end",()=>t(n.digest("hex"))),i.on("error",r)})}async verifySignature(e,t){let r=this.config.publicKeyPem;if(!r)throw Error("Updater.verifySignature: publicKeyPem is not configured. Refusing to install signed update without a verification key.");let n=this.config.signatureAlgorithm??"ed25519",{createPublicKey:i,verify:a,createVerify:c}=await import("crypto"),d;try{d=i({key:r,format:"pem"})}catch(w){throw Error(`Updater.verifySignature: invalid publicKeyPem: ${w.message}`)}let l;try{l=Buffer.from(t,"base64")}catch{return!1}let u=De(e);if(n==="ed25519")return a(null,u,d,l);let f=c("SHA256");return f.update(u),f.end(),f.verify(d,l)}getUpdateInfo(){return this.updateInfo}getDownloadPath(){return this.downloadPath}}class ee{static async generate(e,t,r){try{C("bsdiff",[e,t,r]);let n=Le(r),i=await ee.computeHash(r);return{size:n.size,sha256:i}}catch{C("xdelta3",["-e","-s",e,t,r]);let n=Le(r),i=await ee.computeHash(r);return{size:n.size,sha256:i}}}static async apply(e,t,r){try{C("bspatch",[e,r,t])}catch{C("xdelta3",["-d","-s",e,t,r])}}static async computeHash(e){return new Promise((t,r)=>{let n=ke("sha256"),i=Nt(e);i.on("data",(a)=>n.update(a)),i.on("end",()=>t(n.digest("hex"))),i.on("error",r)})}}function yi(e){let t={version:e.version,releaseDate:new Date().toISOString(),releaseNotes:e.releaseNotes,platforms:{}};for(let[r,n]of Object.entries(e.platforms)){if(!n)continue;let i=De(n.path),a=ke("sha256").update(i).digest("hex");t.platforms[r]={url:n.url,size:i.length,sha256:a,delta:[]};let c=e.deltas?.filter((d)=>d.platform===r)||[];for(let d of c){let l=De(d.path),u=ke("sha256").update(l).digest("hex");t.platforms[r].delta.push({fromVersion:d.fromVersion,url:d.url,size:l.length,sha256:u})}}return t}async function bi(e){let[t,...r]=e;switch(t){case"check":{let n=r[0],i=r[1]||"0.0.0";if(!n)console.error("Usage: craft updater check <update-url> [current-version]"),process.exit(1);let c=await new Ie({updateUrl:n,currentVersion:i,appPath:process.cwd(),autoDownload:!1}).checkForUpdates();if(c){if(console.log(`Update available: ${c.version}`),console.log(`Release date: ${c.releaseDate}`),c.releaseNotes)console.log(`
912
- Release notes:
913
- ${c.releaseNotes}`)}else console.log("No updates available");break}case"generate-delta":{let n=r[0],i=r[1],a=r[2];if(!n||!i||!a)console.error("Usage: craft updater generate-delta <old-file> <new-file> <output>"),process.exit(1);console.log("Generating delta update...");let c=await ee.generate(n,i,a);console.log(`Delta generated: ${a}`),console.log(`Size: ${c.size} bytes`),console.log(`SHA256: ${c.sha256}`);break}case"generate-manifest":{let n=r[0],i=r[1]||"update.json";if(!n)console.error("Usage: craft updater generate-manifest <version> [output]"),process.exit(1);let a={version:n,releaseDate:new Date().toISOString(),platforms:{}};mi(i,JSON.stringify(a,null,2)),console.log(`Manifest generated: ${i}`),console.log("Edit the file to add platform-specific update URLs");break}default:console.log(`
914
- Craft Auto-Updater
915
-
916
- Usage: craft updater <command> [options]
917
-
918
- Commands:
919
- check <url> [version] Check for updates
920
- generate-delta <old> <new> <output> Generate delta update
921
- generate-manifest <version> [output] Generate update manifest
922
-
923
- Examples:
924
- craft updater check https://api.example.com/updates 1.0.0
925
- craft updater generate-delta app-1.0.0.zip app-1.1.0.zip delta-1.0.0-1.1.0.patch
926
- craft updater generate-manifest 1.1.0 update.json
927
- `)}}var vi=Ie,xi=Zt(Kt),ft=!1;function ki(){try{let e=Ee(import.meta.dir,"..","package.json");return JSON.parse(Yt(e,"utf-8")).version??"unknown"}catch{return"unknown"}}async function Si(e){if(ft)return;try{let{stdout:t}=await xi(e,["--version"],{timeout:2000}),r=t.trim().replace(/^v/,""),n=ki();if(n!=="unknown"&&r&&r!==n)ft=!0,console.warn(`\u26A0\uFE0F Craft binary/SDK version mismatch: SDK=${n}, native=${r}.
928
- This is usually fine across patch releases but may produce surprising behavior across minors.`)}catch{}}function ht(){if(typeof process>"u")return!1;let e=(process.env.CRAFT_ENV||"").toLowerCase();if(e==="development"||e==="dev")return!0;if(e==="production"||e==="prod")return!1;let t="development".toLowerCase();if(t==="development"||t==="dev")return!0;if(t==="production"||t==="prod")return!1;let r=process;if(r.pkg||r.isPackaged)return!1;return!0}class Te{process;config;constructor(e={}){if(e.window?.width!==void 0&&(e.window.width<100||e.window.width>1e4))throw Error(`Invalid window width: ${e.window.width}. Must be between 100 and 10000 pixels.`);if(e.window?.height!==void 0&&(e.window.height<100||e.window.height>1e4))throw Error(`Invalid window height: ${e.window.height}. Must be between 100 and 10000 pixels.`);if(e.html&&e.url)console.warn("\u26A0\uFE0F Both html and url provided. URL will take precedence.");this.config={...e,window:{title:"Craft App",width:800,height:600,resizable:!0,frameless:!1,transparent:!1,alwaysOnTop:!1,fullscreen:!1,hotReload:ht(),devTools:ht(),systemTray:!1,...e.window}}}async show(e){if(e)this.config.html=e;if(!this.config.window?.menubarOnly&&!this.config.html&&!this.config.url)throw Error(`No content to display. Provide either html or url:
929
- show(html, options) or loadURL(url, options)`);let t=this.buildArgs(),r=await this.findCraftBinary();return Si(r),this.process=Gt(r,t,{stdio:this.config.quiet?"ignore":"inherit"}),new Promise((n,i)=>{this.process?.on("error",(a)=>{if(a.code==="ENOENT"){i(Error(tr(r)));return}if(a.code==="EACCES"){i(Error(`\u274C Failed to start Craft process: ${a.message}
930
-
931
- Permission denied on the binary at ${r}.
932
- Re-run \`pantry install craft\` to restore correct permissions, or chmod +x the file directly.`));return}i(Error(`\u274C Failed to start Craft process: ${a.message}
933
-
934
- For troubleshooting, visit:
935
- https://github.com/home-lang/craft/issues`))}),this.process?.on("exit",(a)=>{if(a===0||a===null)n();else i(Error(`\u274C Craft process exited with code ${a}
936
-
937
- This may indicate:
938
- `+` \u2022 Invalid window configuration
939
- `+` \u2022 Malformed HTML content
940
- `+` \u2022 System resource constraints
941
-
942
- `+"Check the console output above for more details."))})})}async loadURL(e){return this.config.url=e,this.show()}close(){if(this.process)this.process.kill()}buildArgs(){let e=[],{window:t,html:r,url:n}=this.config;if(!t?.menubarOnly){if(n)e.push("--url",n);else if(r)e.push("--html",r)}if(t?.title)e.push("--title",t.title);if(t?.width)e.push("--width",String(t.width));if(t?.height)e.push("--height",String(t.height));if(t?.x!==void 0)e.push("--x",String(t.x));if(t?.y!==void 0)e.push("--y",String(t.y));if(t?.frameless)e.push("--frameless");if(t?.transparent)e.push("--transparent");if(t?.alwaysOnTop)e.push("--always-on-top");if(t?.fullscreen)e.push("--fullscreen");if(!t?.resizable)e.push("--no-resize");if(t?.darkMode)e.push("--dark");if(t?.hotReload)e.push("--hot-reload");if(t?.devTools===!1)e.push("--no-devtools");if(t?.systemTray)e.push("--system-tray");if(t?.hideDockIcon)e.push("--hide-dock-icon");if(t?.menubarOnly)e.push("--menubar-only");if(t?.titlebarHidden)e.push("--titlebar-hidden");if(t?.webSidebarMaterial){if(e.push("--web-sidebar-material"),t?.webSidebarWidth)e.push("--web-sidebar-width",String(t.webSidebarWidth));if(t?.webSidebarMaterialOpacity!==void 0)e.push("--web-sidebar-material-opacity",String(t.webSidebarMaterialOpacity))}if(t?.icon)e.push("--icon",t.icon);if(t?.nativeSidebar){if(e.push("--native-sidebar"),t?.sidebarWidth)e.push("--sidebar-width",String(t.sidebarWidth));let i=t?.sidebarConfig?{...t.sidebarConfig,variant:t.sidebarConfig.variant??t.sidebarVariant,material:t.sidebarConfig.material??t.sidebarMaterial,backgroundEffect:t.sidebarConfig.backgroundEffect??t.sidebarBackgroundEffect,allowsVibrancy:t.sidebarConfig.allowsVibrancy??t.sidebarAllowsVibrancy}:void 0;if(i?.variant==="desktop")i.material=i.material??"sidebar",i.backgroundEffect=i.backgroundEffect??"vibrancy",i.allowsVibrancy=i.allowsVibrancy??!0;if(i){let a;try{a=JSON.stringify(i)}catch(l){throw Error(`Failed to serialize sidebarConfig: ${l.message}`)}let c=262144;if(a.length<=c&&!a.includes(`
943
- `)&&!a.includes("\r"))e.push("--sidebar-config",a);else{let l=Qt(Ee(Xt(),"craft-sidebar-")),u=Ee(l,"sidebar-config.json");Jt(u,a,"utf-8"),e.push("--sidebar-config-file",u)}}}if(this.config.quiet)e.push("--quiet");return e}async findCraftBinary(){return er(this.config.craftPath)}}function Xs(e){return new Te(e)}async function Zs(e,t){return new Te({html:e,window:t}).show()}async function eo(e,t){return new Te({url:e,window:t}).show()}export{er as $,tr as aa,wr as ba,Ri as ca,Hr as da,Fi as ea,yt as fa,Ui as ga,Nr as ha,Oi as ia,qr as ja,G as ka,ge as la,Fe as ma,Ni as na,Xe as oa,qi as pa,be as qa,kt as ra,Gr as sa,Vi as ta,Wi as ua,zi as va,ji as wa,Ki as xa,Gi as ya,Qi as za,P as Aa,Yi as Ba,Ji as Ca,Xi as Da,Zi as Ea,ea as Fa,ta as Ga,ra as Ha,na as Ia,ia as Ja,aa as Ka,sa as La,oa as Ma,ca as Na,da as Oa,la as Pa,ua as Qa,fa as Ra,ha as Sa,wa as Ta,pa as Ua,ma as Va,ga as Wa,ya as Xa,va as Ya,xa as Za,It as _a,tn as $a,an as ab,Tt as bb,Pt as cb,sn as db,ka as eb,ne as fb,Sa as gb,_a as hb,Ia as ib,dn as jb,ln as kb,Ta as lb,Pa as mb,s as nb,Ca as ob,$a as pb,o as qb,Ea as rb,Aa as sb,At as tb,Ma as ub,Ba as vb,Da as wb,La as xb,Ra as yb,Fa as zb,Ua as Ab,Oa as Bb,Ha as Cb,Na as Db,qa as Eb,Va as Fb,Wa as Gb,za as Hb,ja as Ib,Ka as Jb,Ga as Kb,Qa as Lb,Ya as Mb,Ja as Nb,Xa as Ob,Za as Pb,es as Qb,ts as Rb,rs as Sb,ns as Tb,is as Ub,as as Vb,ss as Wb,os as Xb,cs as Yb,ds as Zb,ls as _b,us as $b,fs as ac,hs as bc,ws as cc,ps as dc,ms as ec,gs as fc,ys as gc,bs as hc,vs as ic,xs as jc,ks as kc,Ss as lc,_s as mc,Is as nc,Ts as oc,Ps as pc,Cs as qc,wn as rc,pn as sc,mn as tc,gn as uc,yn as vc,bn as wc,$s as xc,Mt as yc,Bt as zc,Dt as Ac,Lt as Bc,Es as Cc,As as Dc,se as Ec,En as Fc,An as Gc,Mn as Hc,Ms as Ic,Bn as Jc,He as Kc,Ne as Lc,qe as Mc,Dn as Nc,Ln as Oc,Rn as Pc,Un as Qc,On as Rc,Hn as Sc,Nn as Tc,Ve as Uc,qn as Vc,We as Wc,Vn as Xc,ze as Yc,Wn as Zc,je as _c,zn as $c,jn as ad,Kn as bd,Gn as cd,Qn as dd,Yn as ed,Jn as fd,Ke as gd,Xn as hd,Zn as id,ei as jd,ti as kd,ri as ld,Ft as md,Ot as nd,oi as od,Ht as pd,ci as qd,Bs as rd,Ds as sd,Ls as td,xe as ud,Ge as vd,Qe as wd,Rs as xd,Fs as yd,Us as zd,ui as Ad,fi as Bd,hi as Cd,Os as Dd,Hs as Ed,Ns as Fd,qs as Gd,Vs as Hd,Ws as Id,zs as Jd,js as Kd,ot as Ld,wi as Md,Ie as Nd,yi as Od,Te as Pd,Xs as Qd,Zs as Rd,eo as Sd};