@stacksjs/stx 0.2.194 → 0.2.196

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 (130) hide show
  1. package/dist/chunk-0ae6chzd.js +4 -0
  2. package/dist/chunk-0w0mrtme.js +2 -0
  3. package/dist/chunk-0y46fbkx.js +3 -0
  4. package/dist/chunk-118a77bs.js +4471 -0
  5. package/dist/chunk-12nvcvtn.js +3 -0
  6. package/dist/chunk-14ynv5ah.js +2 -0
  7. package/dist/chunk-1e25ksp6.js +3 -0
  8. package/dist/chunk-1mhc4g86.js +43 -0
  9. package/dist/chunk-1thssz8x.js +2 -0
  10. package/dist/chunk-1yk07x7b.js +2 -0
  11. package/dist/chunk-2zkj69dg.js +13 -0
  12. package/dist/chunk-338316c2.js +2 -0
  13. package/dist/chunk-3952ykhb.js +1655 -0
  14. package/dist/chunk-3es366z4.js +3 -0
  15. package/dist/chunk-3m49eb4v.js +2 -0
  16. package/dist/chunk-3nmpfsw5.js +2 -0
  17. package/dist/chunk-3vy1q9da.js +2 -0
  18. package/dist/chunk-4a4h28pp.js +3022 -0
  19. package/dist/chunk-4pf61rcb.js +2 -0
  20. package/dist/chunk-5anpcnde.js +2 -0
  21. package/dist/chunk-5mkkre22.js +505 -0
  22. package/dist/chunk-5n0dt838.js +2 -0
  23. package/dist/chunk-5s2y052b.js +2 -0
  24. package/dist/chunk-5v64c8tr.js +2 -0
  25. package/dist/chunk-5xd7vge2.js +2 -0
  26. package/dist/chunk-6bxcjdp4.js +2 -0
  27. package/dist/chunk-6msvxnbr.js +2 -0
  28. package/dist/chunk-7kger0se.js +1280 -0
  29. package/dist/chunk-7ry55nms.js +3 -0
  30. package/dist/chunk-7s0wfa4e.js +24 -0
  31. package/dist/chunk-7w4c5w2b.js +2 -0
  32. package/dist/chunk-8src5smc.js +15 -0
  33. package/dist/chunk-937effkz.js +2 -0
  34. package/dist/chunk-9b82d4g5.js +3 -0
  35. package/dist/chunk-9xh78snm.js +3 -0
  36. package/dist/chunk-a2899x2t.js +2 -0
  37. package/dist/chunk-abpw3b39.js +2 -0
  38. package/dist/chunk-avwj12at.js +194 -0
  39. package/dist/chunk-b6jhznkh.js +71 -0
  40. package/dist/chunk-bpa2jeyw.js +3 -0
  41. package/dist/chunk-cbc56wpd.js +3 -0
  42. package/dist/chunk-dhpy0h9y.js +2 -0
  43. package/dist/chunk-dtmwr674.js +302 -0
  44. package/dist/chunk-dxfcyj8t.js +2 -0
  45. package/dist/chunk-e0460y7f.js +29 -0
  46. package/dist/chunk-ede7zpjf.js +2 -0
  47. package/dist/chunk-ehfzp7xe.js +2 -0
  48. package/dist/chunk-fd77g6t6.js +2 -0
  49. package/dist/chunk-fnkxbnka.js +30 -0
  50. package/dist/chunk-fvjh7rx0.js +84 -0
  51. package/dist/chunk-g19skgmw.js +18 -0
  52. package/dist/chunk-gcnrdgrq.js +3 -0
  53. package/dist/chunk-h2wpnxrh.js +8 -0
  54. package/dist/chunk-hb83d0qc.js +2 -0
  55. package/dist/chunk-hncp9gz6.js +8 -0
  56. package/dist/chunk-ht51fz7w.js +4 -0
  57. package/dist/chunk-hyrjade7.js +321 -0
  58. package/dist/chunk-hyyzp99b.js +2 -0
  59. package/dist/chunk-jpbk42j7.js +2 -0
  60. package/dist/chunk-jr5tp4ks.js +2 -0
  61. package/dist/chunk-k03b9z9e.js +898 -0
  62. package/dist/chunk-kjr22neh.js +3 -0
  63. package/dist/chunk-mjt5e2jy.js +2 -0
  64. package/dist/chunk-mkm91b6w.js +2 -0
  65. package/dist/chunk-mtr2f82n.js +2 -0
  66. package/dist/chunk-n8zpm7xb.js +397 -0
  67. package/dist/chunk-ndnc7k2n.js +22 -0
  68. package/dist/chunk-nenge2m2.js +2 -0
  69. package/dist/chunk-nngpktr2.js +2 -0
  70. package/dist/chunk-nsjyn31z.js +2 -0
  71. package/dist/chunk-nye9brje.js +147 -0
  72. package/dist/chunk-p5kp35dy.js +2 -0
  73. package/dist/chunk-pw0rzgpv.js +3 -0
  74. package/dist/chunk-q020t182.js +2 -0
  75. package/dist/chunk-q4gp9egt.js +4 -0
  76. package/dist/chunk-q8szpd6w.js +3 -0
  77. package/dist/chunk-q9n5swx7.js +3 -0
  78. package/dist/chunk-qpcwahse.js +2 -0
  79. package/dist/chunk-qz75kx6n.js +231 -0
  80. package/dist/chunk-r41nsgym.js +116 -0
  81. package/dist/chunk-r4qnvxhv.js +18 -0
  82. package/dist/chunk-r6p4ws0a.js +3809 -0
  83. package/dist/chunk-rdf7d42n.js +2 -0
  84. package/dist/chunk-rs2fa3g1.js +2 -0
  85. package/dist/chunk-ryjpp51z.js +499 -0
  86. package/dist/chunk-s018d32j.js +30 -0
  87. package/dist/chunk-spn8e3b3.js +2 -0
  88. package/dist/chunk-sry9atvv.js +2 -0
  89. package/dist/chunk-st5qggks.js +3 -0
  90. package/dist/chunk-tywvd1zc.js +11 -0
  91. package/dist/chunk-v3ryxw4v.js +2 -0
  92. package/dist/chunk-va9k88da.js +2 -0
  93. package/dist/chunk-vgk5v31k.js +216 -0
  94. package/dist/chunk-vj320kyr.js +2 -0
  95. package/dist/chunk-vr3qtsj4.js +2 -0
  96. package/dist/chunk-w0ng9e1m.js +341 -0
  97. package/dist/chunk-w29sv5jf.js +2 -0
  98. package/dist/chunk-whq99ytc.js +7987 -0
  99. package/dist/chunk-wnaddtv3.js +288 -0
  100. package/dist/chunk-wtengj6h.js +2 -0
  101. package/dist/chunk-x0ks1fer.js +1194 -0
  102. package/dist/chunk-x0zh76yv.js +4 -0
  103. package/dist/chunk-x13f5bbe.js +358 -0
  104. package/dist/chunk-xfp10a23.js +2 -0
  105. package/dist/chunk-xp3fp266.js +11 -0
  106. package/dist/chunk-xz019t7t.js +2 -0
  107. package/dist/chunk-y35rktea.js +12 -0
  108. package/dist/chunk-y4hkqsgw.js +4 -0
  109. package/dist/chunk-yab6d6kb.js +28 -0
  110. package/dist/chunk-yckd6ks5.js +3 -0
  111. package/dist/chunk-ycn1vnv2.js +5 -0
  112. package/dist/chunk-yf3bmmkk.js +8 -0
  113. package/dist/chunk-ygr11tgz.js +3 -0
  114. package/dist/chunk-ymccpdg6.js +351 -0
  115. package/dist/chunk-yr2wc2pa.js +3 -0
  116. package/dist/chunk-yv340gxj.js +2 -0
  117. package/dist/chunk-z2sp0k8d.js +3 -0
  118. package/dist/chunk-z5cm0bwn.js +11 -0
  119. package/dist/chunk-zda3hvde.js +14 -0
  120. package/dist/chunk-zgvga8rc.js +5 -0
  121. package/dist/chunk-zqbw8zqq.js +3 -0
  122. package/dist/cli.js +108 -27481
  123. package/dist/craft-entry.js +9 -5
  124. package/dist/craft.js +7 -18503
  125. package/dist/database.js +2 -2
  126. package/dist/pwa.js +8 -16603
  127. package/dist/ssg.js +52 -15512
  128. package/dist/variable-extractor.js +12 -2
  129. package/dist/visual-testing.js +1 -1
  130. package/package.json +5 -5
@@ -0,0 +1,3022 @@
1
+ // @bun
2
+ import{nk as m}from"./chunk-g19skgmw.js";import{hu as z}from"./chunk-pw0rzgpv.js";import{existsSync as s,mkdirSync as T,copyFileSync as F,chmodSync as A}from"fs";import{join as Z,basename as Yq}from"path";import{spawn as j,execSync as Zq}from"child_process";import{tmpdir as c,homedir as P,platform as Lq}from"os";var Iq=`
3
+ <script>
4
+ (function() {
5
+ 'use strict';
6
+
7
+ // Skip if already initialized or not in Craft environment
8
+ if (window.__craftBridgeInitialized) return;
9
+ window.__craftBridgeInitialized = true;
10
+
11
+ // Message ID counter
12
+ let messageId = 0;
13
+ const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
14
+
15
+ // Pending requests
16
+ const pending = new Map();
17
+
18
+ // Event listeners
19
+ const eventListeners = new Map();
20
+
21
+ // Configuration
22
+ const config = {
23
+ debug: false,
24
+ timeout: 30000
25
+ };
26
+
27
+ // Send message to native
28
+ function send(message) {
29
+ const json = JSON.stringify(message);
30
+
31
+ if (config.debug) {
32
+ console.log('[Craft Bridge] Sending:', message.method, message.params);
33
+ }
34
+
35
+ // iOS WKWebView
36
+ if (window.webkit?.messageHandlers?.craft) {
37
+ window.webkit.messageHandlers.craft.postMessage(message);
38
+ return true;
39
+ }
40
+
41
+ // Android WebView
42
+ if (window.CraftBridge) {
43
+ window.CraftBridge.postMessage(json);
44
+ return true;
45
+ }
46
+
47
+ // Electron IPC
48
+ if (window.craftIPC) {
49
+ window.craftIPC.send('bridge-message', message);
50
+ return true;
51
+ }
52
+
53
+ return false;
54
+ }
55
+
56
+ // Make a request and wait for response
57
+ function request(method, params) {
58
+ return new Promise((resolve, reject) => {
59
+ const id = generateId();
60
+ const timeout = setTimeout(() => {
61
+ pending.delete(id);
62
+ reject(new Error('Request timeout: ' + method));
63
+ }, config.timeout);
64
+
65
+ pending.set(id, { resolve, reject, timeout });
66
+
67
+ const sent = send({
68
+ id,
69
+ type: 'request',
70
+ method,
71
+ params
72
+ });
73
+
74
+ if (!sent) {
75
+ clearTimeout(timeout);
76
+ pending.delete(id);
77
+ // Return gracefully if not in Craft environment
78
+ resolve(undefined);
79
+ }
80
+ });
81
+ }
82
+
83
+ // Handle incoming messages
84
+ function handleMessage(event) {
85
+ let data;
86
+ try {
87
+ data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
88
+ }
89
+ catch (e) {
90
+ return;
91
+ }
92
+
93
+ if (!data || !data.id) return;
94
+
95
+ if (config.debug) {
96
+ console.log('[Craft Bridge] Received:', data);
97
+ }
98
+
99
+ if (data.type === 'response') {
100
+ const req = pending.get(data.id);
101
+ if (req) {
102
+ clearTimeout(req.timeout);
103
+ pending.delete(data.id);
104
+ if (data.error) {
105
+ req.reject(new Error(data.error.message));
106
+ }
107
+ else {
108
+ req.resolve(data.result);
109
+ }
110
+ }
111
+ }
112
+ else if (data.type === 'event' && data.method) {
113
+ const listeners = eventListeners.get(data.method) || [];
114
+ listeners.forEach(fn => fn(data.params));
115
+ }
116
+ }
117
+
118
+ // Listen for messages
119
+ window.addEventListener('message', handleMessage);
120
+ window.addEventListener('craft-bridge-message', handleMessage);
121
+
122
+ // Check if running in Craft
123
+ function isCraft() {
124
+ return !!(
125
+ window.webkit?.messageHandlers?.craft ||
126
+ window.CraftBridge ||
127
+ window.craftIPC
128
+ );
129
+ }
130
+
131
+ // Subscribe to events
132
+ function on(event, callback) {
133
+ if (!eventListeners.has(event)) {
134
+ eventListeners.set(event, []);
135
+ }
136
+ eventListeners.get(event).push(callback);
137
+ return () => {
138
+ const listeners = eventListeners.get(event);
139
+ const idx = listeners.indexOf(callback);
140
+ if (idx > -1) listeners.splice(idx, 1);
141
+ };
142
+ }
143
+
144
+ function sendNativeUI(action, data) {
145
+ if (window.webkit?.messageHandlers?.craft) {
146
+ window.webkit.messageHandlers.craft.postMessage({ t: 'nativeUI', a: action, d: data || {} });
147
+ return true;
148
+ }
149
+
150
+ if (window.CraftBridge?.postMessage) {
151
+ window.CraftBridge.postMessage(JSON.stringify({ t: 'nativeUI', a: action, d: data || {} }));
152
+ return true;
153
+ }
154
+
155
+ return send({
156
+ id: generateId(),
157
+ type: 'nativeUI',
158
+ action,
159
+ data: data || {}
160
+ });
161
+ }
162
+
163
+ // Live component handles, keyed by id, so an event coming back from the host
164
+ // can be routed to the callbacks registered on the right one. Without this
165
+ // the onSelect/onSpaceChange callbacks were stored and never invoked.
166
+ const sidebars = new Map();
167
+ const spacesSidebars = new Map();
168
+
169
+ function createNativeUIFacade() {
170
+ class Sidebar {
171
+ constructor(id) {
172
+ this.id = id;
173
+ this._selectCallbacks = [];
174
+ }
175
+ addSection(section) {
176
+ sendNativeUI('addSidebarSection', { sidebarId: this.id, section });
177
+ return this;
178
+ }
179
+ setSelectedItem(itemId) {
180
+ sendNativeUI('setSelectedItem', { sidebarId: this.id, itemId });
181
+ return this;
182
+ }
183
+ onSelect(callback) {
184
+ this._selectCallbacks.push(callback);
185
+ return this;
186
+ }
187
+ destroy() {
188
+ sidebars.delete(this.id);
189
+ sendNativeUI('destroyComponent', { id: this.id, type: 'sidebar' });
190
+ }
191
+ }
192
+
193
+ /**
194
+ * An Arc-style sidebar of swipeable spaces.
195
+ *
196
+ * Separate from Sidebar rather than an option on it: a source list selects
197
+ * one row out of many, while a spaces sidebar selects one whole SCENE, and
198
+ * a host that renders the switcher natively (a segmented control in the
199
+ * toolbar, a Touch Bar strip) needs the space list, not the item list.
200
+ */
201
+ class SpacesSidebar {
202
+ constructor(id) {
203
+ this.id = id;
204
+ this._spaceCallbacks = [];
205
+ }
206
+ setSpaces(spaces) {
207
+ sendNativeUI('setSidebarSpaces', { sidebarId: this.id, spaces });
208
+ return this;
209
+ }
210
+ setActiveSpace(spaceId) {
211
+ sendNativeUI('setActiveSpace', { sidebarId: this.id, spaceId });
212
+ return this;
213
+ }
214
+ onSpaceChange(callback) {
215
+ this._spaceCallbacks.push(callback);
216
+ return this;
217
+ }
218
+ destroy() {
219
+ spacesSidebars.delete(this.id);
220
+ sendNativeUI('destroyComponent', { id: this.id, type: 'spacesSidebar' });
221
+ }
222
+ }
223
+
224
+ class FileBrowser {
225
+ constructor(id) {
226
+ this.id = id;
227
+ }
228
+ addFile(file) {
229
+ sendNativeUI('addFile', { browserId: this.id, file });
230
+ return this;
231
+ }
232
+ addFiles(files) {
233
+ sendNativeUI('addFiles', { browserId: this.id, files });
234
+ return this;
235
+ }
236
+ clearFiles() {
237
+ sendNativeUI('clearFiles', { browserId: this.id });
238
+ return this;
239
+ }
240
+ destroy() {
241
+ sendNativeUI('destroyComponent', { id: this.id, type: 'fileBrowser' });
242
+ }
243
+ }
244
+
245
+ class SplitView {
246
+ constructor(id, sidebar, browser) {
247
+ this.id = id;
248
+ this.sidebar = sidebar;
249
+ this.browser = browser;
250
+ }
251
+ setDividerPosition(position) {
252
+ sendNativeUI('setDividerPosition', { splitViewId: this.id, position });
253
+ return this;
254
+ }
255
+ destroy() {
256
+ sendNativeUI('destroyComponent', { id: this.id, type: 'splitView' });
257
+ }
258
+ }
259
+
260
+ // Host -> page. The host names the component in the payload; we look up the
261
+ // handle and fan out to whatever the page registered on it.
262
+ on('sidebar.select', function(params) {
263
+ const sidebar = sidebars.get(params && params.sidebarId);
264
+ if (sidebar) sidebar._selectCallbacks.forEach(fn => fn(params.itemId));
265
+ });
266
+ on('sidebar.spaceChange', function(params) {
267
+ const sidebar = spacesSidebars.get(params && params.sidebarId);
268
+ if (sidebar) sidebar._spaceCallbacks.forEach(fn => fn(params.spaceId));
269
+ });
270
+
271
+ return {
272
+ createSidebar(options) {
273
+ const opts = options || {};
274
+ const id = opts.id || 'sidebar-' + Date.now() + '-' + Math.random().toString(36).slice(2);
275
+ sendNativeUI('createSidebar', Object.assign({}, opts, { id }));
276
+ const sidebar = new Sidebar(id);
277
+ sidebars.set(id, sidebar);
278
+ return sidebar;
279
+ },
280
+ createSpacesSidebar(options) {
281
+ const opts = options || {};
282
+ const id = opts.id || 'spaces-' + Date.now() + '-' + Math.random().toString(36).slice(2);
283
+ sendNativeUI('createSpacesSidebar', Object.assign({}, opts, { id }));
284
+ const sidebar = new SpacesSidebar(id);
285
+ spacesSidebars.set(id, sidebar);
286
+ return sidebar;
287
+ },
288
+ createFileBrowser(options) {
289
+ const opts = options || {};
290
+ const id = opts.id || 'browser-' + Date.now() + '-' + Math.random().toString(36).slice(2);
291
+ sendNativeUI('createFileBrowser', Object.assign({}, opts, { id }));
292
+ return new FileBrowser(id);
293
+ },
294
+ createSplitView(options) {
295
+ if (!options?.sidebar || !options?.browser) {
296
+ throw new Error('createSplitView requires sidebar and browser options');
297
+ }
298
+ const id = options.id || 'splitview-' + Date.now() + '-' + Math.random().toString(36).slice(2);
299
+ sendNativeUI('createSplitView', {
300
+ id,
301
+ sidebarId: options.sidebar.id,
302
+ browserId: options.browser.id
303
+ });
304
+ return new SplitView(id, options.sidebar, options.browser);
305
+ },
306
+ showQuickLook(options) {
307
+ sendNativeUI('showQuickLook', options);
308
+ },
309
+ closeQuickLook() {
310
+ sendNativeUI('closeQuickLook', {});
311
+ },
312
+ toggleQuickLook(options) {
313
+ sendNativeUI('toggleQuickLook', options);
314
+ }
315
+ };
316
+ }
317
+
318
+ const existingCraft = window.craft || {};
319
+ const nativeUI = existingCraft.nativeUI || createNativeUIFacade();
320
+ const componentAPI = existingCraft.components || Object.assign({}, nativeUI, {
321
+ updateComponent: (id, props) => request('component.update', { componentId: id, props }),
322
+ destroyComponent: (id) => request('component.destroy', { componentId: id })
323
+ });
324
+
325
+ // Build the craft API object
326
+ window.craft = Object.assign({}, existingCraft, {
327
+ // Meta
328
+ isCraft,
329
+ on,
330
+ config,
331
+
332
+ // Window API
333
+ window: {
334
+ show: () => request('window.show'),
335
+ hide: () => request('window.hide'),
336
+ close: () => request('window.close'),
337
+ minimize: () => request('window.minimize'),
338
+ maximize: () => request('window.maximize'),
339
+ restore: () => request('window.restore'),
340
+ focus: () => request('window.focus'),
341
+ blur: () => request('window.blur'),
342
+ setTitle: (title) => request('window.setTitle', { title }),
343
+ setSize: (width, height) => request('window.setSize', { width, height }),
344
+ setPosition: (x, y) => request('window.setPosition', { x, y }),
345
+ setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
346
+ setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
347
+ getSize: () => request('window.getSize'),
348
+ getPosition: () => request('window.getPosition'),
349
+ isFullscreen: () => request('window.isFullscreen'),
350
+ isMaximized: () => request('window.isMaximized'),
351
+ isMinimized: () => request('window.isMinimized'),
352
+ isVisible: () => request('window.isVisible'),
353
+ center: () => request('window.center'),
354
+ toggleFullscreen: () => request('window.toggleFullscreen'),
355
+ startDrag: () => request('window.startDrag'),
356
+ },
357
+
358
+ // System Tray/Menubar API
359
+ tray: {
360
+ setTitle: (title) => request('tray.setTitle', { title }),
361
+ setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
362
+ setIcon: (icon) => request('tray.setIcon', { icon }),
363
+ setMenu: (menu) => request('tray.setMenu', { menu }),
364
+ show: () => request('tray.show'),
365
+ hide: () => request('tray.hide'),
366
+ onClick: (callback) => on('tray.click', callback),
367
+ onDoubleClick: (callback) => on('tray.doubleClick', callback),
368
+ onRightClick: (callback) => on('tray.rightClick', callback),
369
+ },
370
+
371
+ // App API
372
+ app: {
373
+ quit: () => request('app.quit'),
374
+ hide: () => request('app.hide'),
375
+ show: () => request('app.show'),
376
+ focus: () => request('app.focus'),
377
+ getInfo: () => request('app.getInfo'),
378
+ getVersion: () => request('app.getVersion'),
379
+ getName: () => request('app.getName'),
380
+ getPath: (name) => request('app.getPath', { name }),
381
+ isDarkMode: () => request('app.isDarkMode'),
382
+ getLocale: () => request('app.getLocale'),
383
+ setBadge: (badge) => request('app.setBadge', { badge }),
384
+ hideDockIcon: () => request('app.hideDockIcon'),
385
+ showDockIcon: () => request('app.showDockIcon'),
386
+ notify: (options) => request('app.notify', options),
387
+ registerShortcut: (accelerator, callback) => {
388
+ const id = generateId();
389
+ on('shortcut.' + id, callback);
390
+ return request('app.registerShortcut', { accelerator, id });
391
+ },
392
+ unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
393
+ },
394
+
395
+ // Dialog API
396
+ dialog: {
397
+ openFile: (options) => request('dialog.openFile', options),
398
+ openFolder: (options) => request('dialog.openFolder', options),
399
+ saveFile: (options) => request('dialog.saveFile', options),
400
+ showAlert: (options) => request('dialog.showAlert', options),
401
+ showConfirm: (options) => request('dialog.showConfirm', options),
402
+ showPrompt: (options) => request('dialog.showPrompt', options),
403
+ showColorPicker: (options) => request('dialog.showColorPicker', options),
404
+ },
405
+
406
+ // Clipboard API
407
+ clipboard: {
408
+ writeText: (text) => request('clipboard.writeText', { text }),
409
+ readText: () => request('clipboard.readText'),
410
+ writeHTML: (html) => request('clipboard.writeHTML', { html }),
411
+ readHTML: () => request('clipboard.readHTML'),
412
+ clear: () => request('clipboard.clear'),
413
+ },
414
+
415
+ // File System API (limited for security)
416
+ fs: {
417
+ readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
418
+ writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
419
+ exists: (path) => request('fs.exists', { path }),
420
+ stat: (path) => request('fs.stat', { path }),
421
+ readDir: (path) => request('fs.readDir', { path }),
422
+ createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
423
+ remove: (path, recursive) => request('fs.remove', { path, recursive }),
424
+ },
425
+
426
+ // Process/Shell API (limited for security)
427
+ process: {
428
+ exec: (command, options) => request('process.exec', { command, ...options }),
429
+ spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
430
+ env: () => request('process.env'),
431
+ cwd: () => request('process.cwd'),
432
+ platform: () => request('process.platform'),
433
+ },
434
+
435
+ // Gesture stream
436
+ //
437
+ // A webview's wheel events carry no phase information, so a page can only
438
+ // guess where a trackpad swipe begins and ends \u2014 typically with an idle
439
+ // timeout, which mistimes the release and cannot see momentum at all. The
440
+ // host holds the real NSEvent, so it forwards the phases instead:
441
+ //
442
+ // { axis: 'horizontal' | 'vertical',
443
+ // phase: 'begin' | 'change' | 'end',
444
+ // deltaX, deltaY, // points since the last event
445
+ // velocityX, velocityY, // points per second, at 'end'
446
+ // momentum: boolean } // the OS is coasting, not the finger
447
+ //
448
+ // Consumers must stay correct when nothing ever arrives: a host without
449
+ // gesture support simply never emits, so keep the wheel path bound and let
450
+ // a begin phase take over from it.
451
+ gestures: {
452
+ onSwipe: (callback) => on('gesture.swipe', callback),
453
+ },
454
+
455
+ // Native component helpers
456
+ nativeUI,
457
+ components: componentAPI
458
+ });
459
+
460
+ // Dispatch ready event
461
+ window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
462
+
463
+ if (config.debug) {
464
+ console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
465
+ }
466
+ })();
467
+ </script>
468
+ `;function D(q={}){let{debug:U=!1,timeout:$=30000}=q;return`
469
+ <script>
470
+ (function() {
471
+ 'use strict';
472
+
473
+ // Skip if already initialized or not in Craft environment
474
+ if (window.__craftBridgeInitialized) return;
475
+ window.__craftBridgeInitialized = true;
476
+
477
+ // Message ID counter
478
+ let messageId = 0;
479
+ const generateId = () => 'msg_' + Date.now() + '_' + (++messageId);
480
+
481
+ // Pending requests
482
+ const pending = new Map();
483
+
484
+ // Event listeners
485
+ const eventListeners = new Map();
486
+
487
+ // Configuration
488
+ const config = {
489
+ debug: false,
490
+ timeout: 30000
491
+ };
492
+
493
+ // Send message to native
494
+ function send(message) {
495
+ const json = JSON.stringify(message);
496
+
497
+ if (config.debug) {
498
+ console.log('[Craft Bridge] Sending:', message.method, message.params);
499
+ }
500
+
501
+ // iOS WKWebView
502
+ if (window.webkit?.messageHandlers?.craft) {
503
+ window.webkit.messageHandlers.craft.postMessage(message);
504
+ return true;
505
+ }
506
+
507
+ // Android WebView
508
+ if (window.CraftBridge) {
509
+ window.CraftBridge.postMessage(json);
510
+ return true;
511
+ }
512
+
513
+ // Electron IPC
514
+ if (window.craftIPC) {
515
+ window.craftIPC.send('bridge-message', message);
516
+ return true;
517
+ }
518
+
519
+ return false;
520
+ }
521
+
522
+ // Make a request and wait for response
523
+ function request(method, params) {
524
+ return new Promise((resolve, reject) => {
525
+ const id = generateId();
526
+ const timeout = setTimeout(() => {
527
+ pending.delete(id);
528
+ reject(new Error('Request timeout: ' + method));
529
+ }, config.timeout);
530
+
531
+ pending.set(id, { resolve, reject, timeout });
532
+
533
+ const sent = send({
534
+ id,
535
+ type: 'request',
536
+ method,
537
+ params
538
+ });
539
+
540
+ if (!sent) {
541
+ clearTimeout(timeout);
542
+ pending.delete(id);
543
+ // Return gracefully if not in Craft environment
544
+ resolve(undefined);
545
+ }
546
+ });
547
+ }
548
+
549
+ // Handle incoming messages
550
+ function handleMessage(event) {
551
+ let data;
552
+ try {
553
+ data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
554
+ }
555
+ catch (e) {
556
+ return;
557
+ }
558
+
559
+ if (!data || !data.id) return;
560
+
561
+ if (config.debug) {
562
+ console.log('[Craft Bridge] Received:', data);
563
+ }
564
+
565
+ if (data.type === 'response') {
566
+ const req = pending.get(data.id);
567
+ if (req) {
568
+ clearTimeout(req.timeout);
569
+ pending.delete(data.id);
570
+ if (data.error) {
571
+ req.reject(new Error(data.error.message));
572
+ }
573
+ else {
574
+ req.resolve(data.result);
575
+ }
576
+ }
577
+ }
578
+ else if (data.type === 'event' && data.method) {
579
+ const listeners = eventListeners.get(data.method) || [];
580
+ listeners.forEach(fn => fn(data.params));
581
+ }
582
+ }
583
+
584
+ // Listen for messages
585
+ window.addEventListener('message', handleMessage);
586
+ window.addEventListener('craft-bridge-message', handleMessage);
587
+
588
+ // Check if running in Craft
589
+ function isCraft() {
590
+ return !!(
591
+ window.webkit?.messageHandlers?.craft ||
592
+ window.CraftBridge ||
593
+ window.craftIPC
594
+ );
595
+ }
596
+
597
+ // Subscribe to events
598
+ function on(event, callback) {
599
+ if (!eventListeners.has(event)) {
600
+ eventListeners.set(event, []);
601
+ }
602
+ eventListeners.get(event).push(callback);
603
+ return () => {
604
+ const listeners = eventListeners.get(event);
605
+ const idx = listeners.indexOf(callback);
606
+ if (idx > -1) listeners.splice(idx, 1);
607
+ };
608
+ }
609
+
610
+ function sendNativeUI(action, data) {
611
+ if (window.webkit?.messageHandlers?.craft) {
612
+ window.webkit.messageHandlers.craft.postMessage({ t: 'nativeUI', a: action, d: data || {} });
613
+ return true;
614
+ }
615
+
616
+ if (window.CraftBridge?.postMessage) {
617
+ window.CraftBridge.postMessage(JSON.stringify({ t: 'nativeUI', a: action, d: data || {} }));
618
+ return true;
619
+ }
620
+
621
+ return send({
622
+ id: generateId(),
623
+ type: 'nativeUI',
624
+ action,
625
+ data: data || {}
626
+ });
627
+ }
628
+
629
+ // Live component handles, keyed by id, so an event coming back from the host
630
+ // can be routed to the callbacks registered on the right one. Without this
631
+ // the onSelect/onSpaceChange callbacks were stored and never invoked.
632
+ const sidebars = new Map();
633
+ const spacesSidebars = new Map();
634
+
635
+ function createNativeUIFacade() {
636
+ class Sidebar {
637
+ constructor(id) {
638
+ this.id = id;
639
+ this._selectCallbacks = [];
640
+ }
641
+ addSection(section) {
642
+ sendNativeUI('addSidebarSection', { sidebarId: this.id, section });
643
+ return this;
644
+ }
645
+ setSelectedItem(itemId) {
646
+ sendNativeUI('setSelectedItem', { sidebarId: this.id, itemId });
647
+ return this;
648
+ }
649
+ onSelect(callback) {
650
+ this._selectCallbacks.push(callback);
651
+ return this;
652
+ }
653
+ destroy() {
654
+ sidebars.delete(this.id);
655
+ sendNativeUI('destroyComponent', { id: this.id, type: 'sidebar' });
656
+ }
657
+ }
658
+
659
+ /**
660
+ * An Arc-style sidebar of swipeable spaces.
661
+ *
662
+ * Separate from Sidebar rather than an option on it: a source list selects
663
+ * one row out of many, while a spaces sidebar selects one whole SCENE, and
664
+ * a host that renders the switcher natively (a segmented control in the
665
+ * toolbar, a Touch Bar strip) needs the space list, not the item list.
666
+ */
667
+ class SpacesSidebar {
668
+ constructor(id) {
669
+ this.id = id;
670
+ this._spaceCallbacks = [];
671
+ }
672
+ setSpaces(spaces) {
673
+ sendNativeUI('setSidebarSpaces', { sidebarId: this.id, spaces });
674
+ return this;
675
+ }
676
+ setActiveSpace(spaceId) {
677
+ sendNativeUI('setActiveSpace', { sidebarId: this.id, spaceId });
678
+ return this;
679
+ }
680
+ onSpaceChange(callback) {
681
+ this._spaceCallbacks.push(callback);
682
+ return this;
683
+ }
684
+ destroy() {
685
+ spacesSidebars.delete(this.id);
686
+ sendNativeUI('destroyComponent', { id: this.id, type: 'spacesSidebar' });
687
+ }
688
+ }
689
+
690
+ class FileBrowser {
691
+ constructor(id) {
692
+ this.id = id;
693
+ }
694
+ addFile(file) {
695
+ sendNativeUI('addFile', { browserId: this.id, file });
696
+ return this;
697
+ }
698
+ addFiles(files) {
699
+ sendNativeUI('addFiles', { browserId: this.id, files });
700
+ return this;
701
+ }
702
+ clearFiles() {
703
+ sendNativeUI('clearFiles', { browserId: this.id });
704
+ return this;
705
+ }
706
+ destroy() {
707
+ sendNativeUI('destroyComponent', { id: this.id, type: 'fileBrowser' });
708
+ }
709
+ }
710
+
711
+ class SplitView {
712
+ constructor(id, sidebar, browser) {
713
+ this.id = id;
714
+ this.sidebar = sidebar;
715
+ this.browser = browser;
716
+ }
717
+ setDividerPosition(position) {
718
+ sendNativeUI('setDividerPosition', { splitViewId: this.id, position });
719
+ return this;
720
+ }
721
+ destroy() {
722
+ sendNativeUI('destroyComponent', { id: this.id, type: 'splitView' });
723
+ }
724
+ }
725
+
726
+ // Host -> page. The host names the component in the payload; we look up the
727
+ // handle and fan out to whatever the page registered on it.
728
+ on('sidebar.select', function(params) {
729
+ const sidebar = sidebars.get(params && params.sidebarId);
730
+ if (sidebar) sidebar._selectCallbacks.forEach(fn => fn(params.itemId));
731
+ });
732
+ on('sidebar.spaceChange', function(params) {
733
+ const sidebar = spacesSidebars.get(params && params.sidebarId);
734
+ if (sidebar) sidebar._spaceCallbacks.forEach(fn => fn(params.spaceId));
735
+ });
736
+
737
+ return {
738
+ createSidebar(options) {
739
+ const opts = options || {};
740
+ const id = opts.id || 'sidebar-' + Date.now() + '-' + Math.random().toString(36).slice(2);
741
+ sendNativeUI('createSidebar', Object.assign({}, opts, { id }));
742
+ const sidebar = new Sidebar(id);
743
+ sidebars.set(id, sidebar);
744
+ return sidebar;
745
+ },
746
+ createSpacesSidebar(options) {
747
+ const opts = options || {};
748
+ const id = opts.id || 'spaces-' + Date.now() + '-' + Math.random().toString(36).slice(2);
749
+ sendNativeUI('createSpacesSidebar', Object.assign({}, opts, { id }));
750
+ const sidebar = new SpacesSidebar(id);
751
+ spacesSidebars.set(id, sidebar);
752
+ return sidebar;
753
+ },
754
+ createFileBrowser(options) {
755
+ const opts = options || {};
756
+ const id = opts.id || 'browser-' + Date.now() + '-' + Math.random().toString(36).slice(2);
757
+ sendNativeUI('createFileBrowser', Object.assign({}, opts, { id }));
758
+ return new FileBrowser(id);
759
+ },
760
+ createSplitView(options) {
761
+ if (!options?.sidebar || !options?.browser) {
762
+ throw new Error('createSplitView requires sidebar and browser options');
763
+ }
764
+ const id = options.id || 'splitview-' + Date.now() + '-' + Math.random().toString(36).slice(2);
765
+ sendNativeUI('createSplitView', {
766
+ id,
767
+ sidebarId: options.sidebar.id,
768
+ browserId: options.browser.id
769
+ });
770
+ return new SplitView(id, options.sidebar, options.browser);
771
+ },
772
+ showQuickLook(options) {
773
+ sendNativeUI('showQuickLook', options);
774
+ },
775
+ closeQuickLook() {
776
+ sendNativeUI('closeQuickLook', {});
777
+ },
778
+ toggleQuickLook(options) {
779
+ sendNativeUI('toggleQuickLook', options);
780
+ }
781
+ };
782
+ }
783
+
784
+ const existingCraft = window.craft || {};
785
+ const nativeUI = existingCraft.nativeUI || createNativeUIFacade();
786
+ const componentAPI = existingCraft.components || Object.assign({}, nativeUI, {
787
+ updateComponent: (id, props) => request('component.update', { componentId: id, props }),
788
+ destroyComponent: (id) => request('component.destroy', { componentId: id })
789
+ });
790
+
791
+ // Build the craft API object
792
+ window.craft = Object.assign({}, existingCraft, {
793
+ // Meta
794
+ isCraft,
795
+ on,
796
+ config,
797
+
798
+ // Window API
799
+ window: {
800
+ show: () => request('window.show'),
801
+ hide: () => request('window.hide'),
802
+ close: () => request('window.close'),
803
+ minimize: () => request('window.minimize'),
804
+ maximize: () => request('window.maximize'),
805
+ restore: () => request('window.restore'),
806
+ focus: () => request('window.focus'),
807
+ blur: () => request('window.blur'),
808
+ setTitle: (title) => request('window.setTitle', { title }),
809
+ setSize: (width, height) => request('window.setSize', { width, height }),
810
+ setPosition: (x, y) => request('window.setPosition', { x, y }),
811
+ setFullscreen: (fullscreen) => request('window.setFullscreen', { fullscreen }),
812
+ setAlwaysOnTop: (alwaysOnTop) => request('window.setAlwaysOnTop', { alwaysOnTop }),
813
+ getSize: () => request('window.getSize'),
814
+ getPosition: () => request('window.getPosition'),
815
+ isFullscreen: () => request('window.isFullscreen'),
816
+ isMaximized: () => request('window.isMaximized'),
817
+ isMinimized: () => request('window.isMinimized'),
818
+ isVisible: () => request('window.isVisible'),
819
+ center: () => request('window.center'),
820
+ toggleFullscreen: () => request('window.toggleFullscreen'),
821
+ startDrag: () => request('window.startDrag'),
822
+ },
823
+
824
+ // System Tray/Menubar API
825
+ tray: {
826
+ setTitle: (title) => request('tray.setTitle', { title }),
827
+ setTooltip: (tooltip) => request('tray.setTooltip', { tooltip }),
828
+ setIcon: (icon) => request('tray.setIcon', { icon }),
829
+ setMenu: (menu) => request('tray.setMenu', { menu }),
830
+ show: () => request('tray.show'),
831
+ hide: () => request('tray.hide'),
832
+ onClick: (callback) => on('tray.click', callback),
833
+ onDoubleClick: (callback) => on('tray.doubleClick', callback),
834
+ onRightClick: (callback) => on('tray.rightClick', callback),
835
+ },
836
+
837
+ // App API
838
+ app: {
839
+ quit: () => request('app.quit'),
840
+ hide: () => request('app.hide'),
841
+ show: () => request('app.show'),
842
+ focus: () => request('app.focus'),
843
+ getInfo: () => request('app.getInfo'),
844
+ getVersion: () => request('app.getVersion'),
845
+ getName: () => request('app.getName'),
846
+ getPath: (name) => request('app.getPath', { name }),
847
+ isDarkMode: () => request('app.isDarkMode'),
848
+ getLocale: () => request('app.getLocale'),
849
+ setBadge: (badge) => request('app.setBadge', { badge }),
850
+ hideDockIcon: () => request('app.hideDockIcon'),
851
+ showDockIcon: () => request('app.showDockIcon'),
852
+ notify: (options) => request('app.notify', options),
853
+ registerShortcut: (accelerator, callback) => {
854
+ const id = generateId();
855
+ on('shortcut.' + id, callback);
856
+ return request('app.registerShortcut', { accelerator, id });
857
+ },
858
+ unregisterShortcut: (accelerator) => request('app.unregisterShortcut', { accelerator }),
859
+ },
860
+
861
+ // Dialog API
862
+ dialog: {
863
+ openFile: (options) => request('dialog.openFile', options),
864
+ openFolder: (options) => request('dialog.openFolder', options),
865
+ saveFile: (options) => request('dialog.saveFile', options),
866
+ showAlert: (options) => request('dialog.showAlert', options),
867
+ showConfirm: (options) => request('dialog.showConfirm', options),
868
+ showPrompt: (options) => request('dialog.showPrompt', options),
869
+ showColorPicker: (options) => request('dialog.showColorPicker', options),
870
+ },
871
+
872
+ // Clipboard API
873
+ clipboard: {
874
+ writeText: (text) => request('clipboard.writeText', { text }),
875
+ readText: () => request('clipboard.readText'),
876
+ writeHTML: (html) => request('clipboard.writeHTML', { html }),
877
+ readHTML: () => request('clipboard.readHTML'),
878
+ clear: () => request('clipboard.clear'),
879
+ },
880
+
881
+ // File System API (limited for security)
882
+ fs: {
883
+ readFile: (path, encoding) => request('fs.readFile', { path, encoding }),
884
+ writeFile: (path, content, encoding) => request('fs.writeFile', { path, content, encoding }),
885
+ exists: (path) => request('fs.exists', { path }),
886
+ stat: (path) => request('fs.stat', { path }),
887
+ readDir: (path) => request('fs.readDir', { path }),
888
+ createDir: (path, recursive) => request('fs.createDir', { path, recursive }),
889
+ remove: (path, recursive) => request('fs.remove', { path, recursive }),
890
+ },
891
+
892
+ // Process/Shell API (limited for security)
893
+ process: {
894
+ exec: (command, options) => request('process.exec', { command, ...options }),
895
+ spawn: (command, args, options) => request('process.spawn', { command, args, ...options }),
896
+ env: () => request('process.env'),
897
+ cwd: () => request('process.cwd'),
898
+ platform: () => request('process.platform'),
899
+ },
900
+
901
+ // Gesture stream
902
+ //
903
+ // A webview's wheel events carry no phase information, so a page can only
904
+ // guess where a trackpad swipe begins and ends \u2014 typically with an idle
905
+ // timeout, which mistimes the release and cannot see momentum at all. The
906
+ // host holds the real NSEvent, so it forwards the phases instead:
907
+ //
908
+ // { axis: 'horizontal' | 'vertical',
909
+ // phase: 'begin' | 'change' | 'end',
910
+ // deltaX, deltaY, // points since the last event
911
+ // velocityX, velocityY, // points per second, at 'end'
912
+ // momentum: boolean } // the OS is coasting, not the finger
913
+ //
914
+ // Consumers must stay correct when nothing ever arrives: a host without
915
+ // gesture support simply never emits, so keep the wheel path bound and let
916
+ // a begin phase take over from it.
917
+ gestures: {
918
+ onSwipe: (callback) => on('gesture.swipe', callback),
919
+ },
920
+
921
+ // Native component helpers
922
+ nativeUI,
923
+ components: componentAPI
924
+ });
925
+
926
+ // Dispatch ready event
927
+ window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
928
+
929
+ if (config.debug) {
930
+ console.log('[Craft Bridge] Initialized, isCraft:', isCraft());
931
+ }
932
+ })();
933
+ </script>
934
+ `.replace("debug: false,",`debug: ${U},`).replace("timeout: 30000",`timeout: ${$}`)}function Cq(){return!1}function yq(q,U={}){let $=/@craft(?:\(([\s\S]*?)\))?/g;return q.replace($,(J,W)=>{let K={};if(W)try{K=JSON.parse(W.replace(/'/g,'"'))}catch{try{K=Function(`return ${W}`)()}catch{console.warn(`[stx] Invalid @craft config: ${W}`)}}return D(K)})}function N(q,U={}){if(q.includes("__craftBridgeInitialized"))return q;let $=D(U);if(q.includes("</head>"))return q.replace("</head>",`${$}
935
+ </head>`);if(q.includes("<body"))return q.replace(/(<body[^>]*>)/,`$1
936
+ ${$}`);return $+q}var b={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(q,U)=>{let $=q.checked?"checked":"",J=q.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
937
+ <input type="checkbox" class="craft-checkbox" ${$} ${J}>
938
+ <span class="craft-checkbox-label">${U||q.label||""}</span>
939
+ </label>`}},radio:{nativeType:"craft-radio",fallbackTag:"input",fallbackClasses:"craft-radio",nativeProps:["checked","disabled","name","value","label"]},select:{nativeType:"craft-select",fallbackTag:"select",fallbackClasses:"craft-select",nativeProps:["value","disabled","options","placeholder"]},slider:{nativeType:"craft-slider",fallbackTag:"input",fallbackClasses:"craft-slider",nativeProps:["value","min","max","step","disabled"],render:(q,U)=>{let $=q.min??0,J=q.max??100,W=q.step??1,K=q.value??50,Y=q.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${$}" max="${J}" step="${W}" value="${K}" ${Y}>`}},label:{nativeType:"craft-label",fallbackTag:"span",fallbackClasses:"craft-label",nativeProps:["text","for"]},badge:{nativeType:"craft-badge",fallbackTag:"span",fallbackClasses:"craft-badge",nativeProps:["variant","size"]},avatar:{nativeType:"craft-avatar",fallbackTag:"div",fallbackClasses:"craft-avatar",nativeProps:["src","alt","size","fallback"],render:(q,U)=>{let $=q.size||40,J=q.src,W=String(q.alt||""),K=q.fallback||(W?W.charAt(0).toUpperCase():"?");if(J)return`<img class="craft-avatar" src="${J}" alt="${W}" style="width:${$}px;height:${$}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${$}px;height:${$}px;border-radius:50%;display:flex;align-items:center;justify-content:center">${K}</div>`}},progress:{nativeType:"craft-progress",fallbackTag:"div",fallbackClasses:"craft-progress",nativeProps:["value","max","variant"],render:(q,U)=>{let $=Number(q.value)||0,J=Number(q.max)||100;return`<div class="craft-progress"><div class="craft-progress-bar" style="width:${Math.min(100,Math.max(0,$/J*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:(q,U)=>{let $=q.size||24;return`<div class="craft-spinner" style="width:${$}px;height:${$}px"></div>`}},card:{nativeType:"craft-card",fallbackTag:"div",fallbackClasses:"craft-card",nativeProps:["title","subtitle","variant"]},modal:{nativeType:"craft-modal",fallbackTag:"dialog",fallbackClasses:"craft-modal",nativeProps:["open","title","closable","size"],render:(q,U)=>{let $=q.open?"open":"",J=q.title||"";return`<dialog class="craft-modal" ${$}>
940
+ <div class="craft-modal-content">
941
+ ${J?`<div class="craft-modal-header"><h2>${J}</h2></div>`:""}
942
+ <div class="craft-modal-body">${U}</div>
943
+ </div>
944
+ </dialog>`}},tabs:{nativeType:"craft-tabs",fallbackTag:"div",fallbackClasses:"craft-tabs",nativeProps:["activeTab","tabs"]},accordion:{nativeType:"craft-accordion",fallbackTag:"details",fallbackClasses:"craft-accordion",nativeProps:["open","title"],render:(q,U)=>{let $=q.open?"open":"",J=q.title||"Details";return`<details class="craft-accordion" ${$}>
945
+ <summary class="craft-accordion-header">${J}</summary>
946
+ <div class="craft-accordion-content">${U}</div>
947
+ </details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:(q,U)=>{let $=q.variant||"info",J=q.title||"";return`<div class="craft-alert craft-alert-${$}" role="alert">
948
+ ${J?`<div class="craft-alert-title">${J}</div>`:""}
949
+ <div class="craft-alert-content">${U}</div>
950
+ </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(q,U)=>{let $=q.content||"",J=q.position||"top";return`<span class="craft-tooltip" data-tooltip="${$}" data-position="${J}">${U}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:r},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:a},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:t},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:o},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(q,U)=>{return`<input type="color" class="craft-color-picker" value="${q.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(q,U)=>{let $=q.value||"",J=q.min||"",W=q.max||"";return`<input type="date" class="craft-date-picker" value="${$}" min="${J}" max="${W}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(q,U)=>{return`<input type="time" class="craft-time-picker" value="${q.value||""}">`}}},h=`
951
+ <style id="craft-component-styles">
952
+ /* Craft Component Base Styles */
953
+ .craft-button {
954
+ display: inline-flex;
955
+ align-items: center;
956
+ justify-content: center;
957
+ padding: 8px 16px;
958
+ border: none;
959
+ border-radius: 6px;
960
+ font-family: inherit;
961
+ font-size: 14px;
962
+ font-weight: 500;
963
+ cursor: pointer;
964
+ transition: all 0.2s ease;
965
+ background: var(--craft-primary, #3b82f6);
966
+ color: white;
967
+ }
968
+ .craft-button:hover { opacity: 0.9; }
969
+ .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
970
+ .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
971
+ .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
972
+
973
+ .craft-text-input, .craft-textarea, .craft-select {
974
+ padding: 8px 12px;
975
+ border: 1px solid var(--craft-border, #d1d5db);
976
+ border-radius: 6px;
977
+ font-family: inherit;
978
+ font-size: 14px;
979
+ background: var(--craft-bg, #fff);
980
+ color: var(--craft-text, #1f2937);
981
+ transition: border-color 0.2s ease;
982
+ }
983
+ .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
984
+ outline: none;
985
+ border-color: var(--craft-primary, #3b82f6);
986
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
987
+ }
988
+
989
+ .craft-checkbox-wrapper {
990
+ display: inline-flex;
991
+ align-items: center;
992
+ gap: 8px;
993
+ cursor: pointer;
994
+ }
995
+ .craft-checkbox {
996
+ width: 18px;
997
+ height: 18px;
998
+ cursor: pointer;
999
+ }
1000
+
1001
+ .craft-slider {
1002
+ width: 100%;
1003
+ height: 6px;
1004
+ border-radius: 3px;
1005
+ cursor: pointer;
1006
+ }
1007
+
1008
+ .craft-badge {
1009
+ display: inline-flex;
1010
+ align-items: center;
1011
+ padding: 2px 8px;
1012
+ border-radius: 9999px;
1013
+ font-size: 12px;
1014
+ font-weight: 500;
1015
+ background: var(--craft-primary, #3b82f6);
1016
+ color: white;
1017
+ }
1018
+
1019
+ .craft-avatar {
1020
+ display: inline-flex;
1021
+ align-items: center;
1022
+ justify-content: center;
1023
+ background: var(--craft-secondary, #6b7280);
1024
+ color: white;
1025
+ font-weight: 600;
1026
+ overflow: hidden;
1027
+ }
1028
+ .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
1029
+
1030
+ .craft-progress {
1031
+ width: 100%;
1032
+ height: 8px;
1033
+ background: var(--craft-border, #e5e7eb);
1034
+ border-radius: 4px;
1035
+ overflow: hidden;
1036
+ }
1037
+ .craft-progress-bar {
1038
+ height: 100%;
1039
+ background: var(--craft-primary, #3b82f6);
1040
+ transition: width 0.3s ease;
1041
+ }
1042
+
1043
+ .craft-spinner {
1044
+ border: 2px solid var(--craft-border, #e5e7eb);
1045
+ border-top-color: var(--craft-primary, #3b82f6);
1046
+ border-radius: 50%;
1047
+ animation: craft-spin 0.8s linear infinite;
1048
+ }
1049
+ @keyframes craft-spin { to { transform: rotate(360deg); } }
1050
+
1051
+ .craft-card {
1052
+ background: var(--craft-bg, #fff);
1053
+ border: 1px solid var(--craft-border, #e5e7eb);
1054
+ border-radius: 8px;
1055
+ padding: 16px;
1056
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
1057
+ }
1058
+
1059
+ .craft-modal {
1060
+ border: none;
1061
+ border-radius: 12px;
1062
+ padding: 0;
1063
+ max-width: 90vw;
1064
+ max-height: 90vh;
1065
+ box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
1066
+ }
1067
+ .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
1068
+ .craft-modal-header {
1069
+ padding: 16px 20px;
1070
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
1071
+ }
1072
+ .craft-modal-header h2 { margin: 0; font-size: 18px; }
1073
+ .craft-modal-body { padding: 20px; }
1074
+
1075
+ .craft-accordion {
1076
+ border: 1px solid var(--craft-border, #e5e7eb);
1077
+ border-radius: 6px;
1078
+ overflow: hidden;
1079
+ }
1080
+ .craft-accordion-header {
1081
+ padding: 12px 16px;
1082
+ cursor: pointer;
1083
+ font-weight: 500;
1084
+ background: var(--craft-bg-secondary, #f9fafb);
1085
+ }
1086
+ .craft-accordion-content { padding: 16px; }
1087
+
1088
+ .craft-divider {
1089
+ border: none;
1090
+ border-top: 1px solid var(--craft-border, #e5e7eb);
1091
+ margin: 16px 0;
1092
+ }
1093
+
1094
+ .craft-alert {
1095
+ padding: 12px 16px;
1096
+ border-radius: 6px;
1097
+ border-left: 4px solid;
1098
+ }
1099
+ .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
1100
+ .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
1101
+ .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
1102
+ .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
1103
+ .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
1104
+
1105
+ .craft-tooltip {
1106
+ position: relative;
1107
+ cursor: help;
1108
+ }
1109
+ .craft-tooltip::after {
1110
+ content: attr(data-tooltip);
1111
+ position: absolute;
1112
+ bottom: 100%;
1113
+ left: 50%;
1114
+ transform: translateX(-50%);
1115
+ padding: 4px 8px;
1116
+ background: #1f2937;
1117
+ color: white;
1118
+ font-size: 12px;
1119
+ border-radius: 4px;
1120
+ white-space: nowrap;
1121
+ opacity: 0;
1122
+ pointer-events: none;
1123
+ transition: opacity 0.2s;
1124
+ }
1125
+ .craft-tooltip:hover::after { opacity: 1; }
1126
+
1127
+ .craft-table {
1128
+ width: 100%;
1129
+ border-collapse: collapse;
1130
+ }
1131
+ .craft-table th, .craft-table td {
1132
+ padding: 12px;
1133
+ text-align: left;
1134
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
1135
+ }
1136
+ .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
1137
+
1138
+ .craft-list {
1139
+ list-style: none;
1140
+ padding: 0;
1141
+ margin: 0;
1142
+ }
1143
+ .craft-list li {
1144
+ padding: 12px;
1145
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
1146
+ }
1147
+ .craft-list li:last-child { border-bottom: none; }
1148
+
1149
+ .craft-sidebar {
1150
+ --craft-sidebar-width: 286px;
1151
+ --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
1152
+ --craft-sidebar-border: rgba(255, 255, 255, 0.62);
1153
+ --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
1154
+ --craft-sidebar-text: rgba(24, 24, 27, 0.86);
1155
+ --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
1156
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
1157
+ --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
1158
+ position: relative;
1159
+ display: flex;
1160
+ flex-direction: column;
1161
+ width: var(--craft-sidebar-width);
1162
+ min-width: var(--craft-sidebar-width);
1163
+ height: 100vh;
1164
+ padding: 58px 10px 12px;
1165
+ color: var(--craft-sidebar-text);
1166
+ background:
1167
+ linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
1168
+ var(--craft-sidebar-bg);
1169
+ border: 1px solid var(--craft-sidebar-border);
1170
+ border-radius: 18px;
1171
+ box-shadow: var(--craft-sidebar-shadow);
1172
+ backdrop-filter: blur(34px) saturate(180%);
1173
+ -webkit-backdrop-filter: blur(34px) saturate(180%);
1174
+ overflow: hidden;
1175
+ user-select: none;
1176
+ }
1177
+ .craft-sidebar::before {
1178
+ content: "";
1179
+ position: absolute;
1180
+ inset: 0;
1181
+ pointer-events: none;
1182
+ background:
1183
+ radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
1184
+ linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
1185
+ mix-blend-mode: screen;
1186
+ opacity: 0.72;
1187
+ }
1188
+ .craft-sidebar[data-native-active="true"] { display: none; }
1189
+ .craft-sidebar-search {
1190
+ position: relative;
1191
+ z-index: 1;
1192
+ margin: 0 0 12px;
1193
+ }
1194
+ .craft-sidebar-search input {
1195
+ width: 100%;
1196
+ min-height: 28px;
1197
+ padding: 5px 10px;
1198
+ border: 1px solid rgba(0, 0, 0, 0.05);
1199
+ border-radius: 8px;
1200
+ background: rgba(255, 255, 255, 0.34);
1201
+ color: inherit;
1202
+ font: inherit;
1203
+ font-size: 13px;
1204
+ outline: none;
1205
+ }
1206
+ .craft-sidebar-section {
1207
+ position: relative;
1208
+ z-index: 1;
1209
+ margin: 0 0 14px;
1210
+ }
1211
+ .craft-sidebar-section-title {
1212
+ padding: 0 8px 5px;
1213
+ color: var(--craft-sidebar-muted);
1214
+ font-size: 11px;
1215
+ font-weight: 700;
1216
+ letter-spacing: 0;
1217
+ text-transform: uppercase;
1218
+ }
1219
+ .craft-sidebar-item {
1220
+ width: calc(100% - 4px);
1221
+ min-height: 28px;
1222
+ margin: 1px 2px;
1223
+ padding: 5px 8px;
1224
+ display: flex;
1225
+ align-items: center;
1226
+ gap: 8px;
1227
+ border: 0;
1228
+ border-radius: 8px;
1229
+ background: transparent;
1230
+ color: inherit;
1231
+ font: inherit;
1232
+ font-size: 13px;
1233
+ text-align: left;
1234
+ cursor: default;
1235
+ }
1236
+ .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
1237
+ .craft-sidebar-item[data-selected="true"] {
1238
+ color: white;
1239
+ background: var(--craft-sidebar-selected);
1240
+ box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
1241
+ }
1242
+ .craft-sidebar-item-icon {
1243
+ position: relative;
1244
+ display: inline-block;
1245
+ width: 16px;
1246
+ height: 16px;
1247
+ min-width: 16px;
1248
+ opacity: 0.82;
1249
+ overflow: hidden;
1250
+ color: transparent;
1251
+ }
1252
+ .craft-sidebar-item-icon::before {
1253
+ content: "";
1254
+ position: absolute;
1255
+ inset: 2px;
1256
+ border-radius: 4px;
1257
+ background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
1258
+ box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
1259
+ }
1260
+ .craft-sidebar-item-icon[data-icon*="circle"]::before {
1261
+ inset: 4px;
1262
+ border-radius: 999px;
1263
+ }
1264
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
1265
+ background: rgba(255, 255, 255, 0.9);
1266
+ }
1267
+ .craft-sidebar-item-label {
1268
+ flex: 1;
1269
+ overflow: hidden;
1270
+ white-space: nowrap;
1271
+ text-overflow: ellipsis;
1272
+ }
1273
+ .craft-sidebar-item-badge {
1274
+ min-width: 18px;
1275
+ padding: 1px 6px;
1276
+ border-radius: 999px;
1277
+ background: rgba(0, 0, 0, 0.08);
1278
+ color: var(--craft-sidebar-muted);
1279
+ font-size: 10px;
1280
+ font-weight: 700;
1281
+ text-align: center;
1282
+ }
1283
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
1284
+ color: white;
1285
+ background: rgba(255, 255, 255, 0.24);
1286
+ }
1287
+
1288
+ /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
1289
+ a native host, and deliberately not a second swipe implementation. */
1290
+ .craft-sidebar-spaces {
1291
+ position: relative;
1292
+ z-index: 1;
1293
+ flex: 1;
1294
+ min-height: 0;
1295
+ overflow-y: auto;
1296
+ }
1297
+ .craft-sidebar-space-title {
1298
+ padding: 10px 8px 4px;
1299
+ font-size: 13px;
1300
+ font-weight: 600;
1301
+ }
1302
+ .craft-sidebar-space-switcher {
1303
+ position: relative;
1304
+ z-index: 1;
1305
+ display: flex;
1306
+ align-items: center;
1307
+ gap: 1px;
1308
+ padding-top: 6px;
1309
+ }
1310
+ .craft-sidebar-space-tab {
1311
+ display: grid;
1312
+ place-items: center;
1313
+ width: 28px;
1314
+ height: 26px;
1315
+ border: 0;
1316
+ border-radius: 7px;
1317
+ background: transparent;
1318
+ color: inherit;
1319
+ font: inherit;
1320
+ font-size: 11px;
1321
+ font-weight: 700;
1322
+ opacity: 0.4;
1323
+ cursor: default;
1324
+ }
1325
+ .craft-sidebar-space-tab[data-selected="true"] {
1326
+ opacity: 1;
1327
+ background: rgba(255, 255, 255, 0.55);
1328
+ }
1329
+
1330
+ .craft-code-editor {
1331
+ font-family: 'SF Mono', 'Fira Code', monospace;
1332
+ font-size: 13px;
1333
+ line-height: 1.5;
1334
+ padding: 12px;
1335
+ background: #1e1e1e;
1336
+ color: #d4d4d4;
1337
+ border-radius: 6px;
1338
+ resize: vertical;
1339
+ }
1340
+
1341
+ /* Dark mode support */
1342
+ @media (prefers-color-scheme: dark) {
1343
+ .craft-text-input, .craft-textarea, .craft-select, .craft-card {
1344
+ background: #1f2937;
1345
+ color: #f3f4f6;
1346
+ border-color: #374151;
1347
+ }
1348
+ .craft-modal {
1349
+ background: #1f2937;
1350
+ color: #f3f4f6;
1351
+ }
1352
+ .craft-accordion-header { background: #374151; }
1353
+ .craft-table th { background: #374151; }
1354
+ .craft-sidebar {
1355
+ --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
1356
+ --craft-sidebar-border: rgba(255, 255, 255, 0.12);
1357
+ --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
1358
+ --craft-sidebar-text: rgba(244, 244, 245, 0.92);
1359
+ --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
1360
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
1361
+ }
1362
+ .craft-sidebar-search input {
1363
+ border-color: rgba(255,255,255,0.08);
1364
+ background: rgba(255,255,255,0.08);
1365
+ }
1366
+ }
1367
+ </style>
1368
+ `,bq=`
1369
+ <script id="craft-component-runtime">
1370
+ (function() {
1371
+ if (window.__stxCraftComponentRuntime) return;
1372
+ window.__stxCraftComponentRuntime = true;
1373
+
1374
+ function parseConfig(sidebar) {
1375
+ var id = sidebar.getAttribute('data-craft-sidebar-id');
1376
+ var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
1377
+ if (!script) return null;
1378
+ try {
1379
+ return JSON.parse(script.textContent || '{}');
1380
+ } catch (error) {
1381
+ console.warn('[stx] Invalid Craft sidebar config', error);
1382
+ return null;
1383
+ }
1384
+ }
1385
+
1386
+ function getNativeUI() {
1387
+ if (!window.craft) return null;
1388
+ var hasNativeHost = window.craft.isCraft?.() ||
1389
+ !!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
1390
+ if (!hasNativeHost) return null;
1391
+ return window.craft.nativeUI || window.craft.components;
1392
+ }
1393
+
1394
+ function initializeSidebar(sidebar) {
1395
+ if (sidebar.dataset.craftInitialized === 'true') return;
1396
+ if (sidebar.dataset.native === 'false') return;
1397
+
1398
+ var nativeUI = getNativeUI();
1399
+ if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
1400
+
1401
+ var config = parseConfig(sidebar);
1402
+ if (!config) return;
1403
+
1404
+ var hasSpaces = !!(config.spaces && config.spaces.length);
1405
+ // Spaces need a host that can swipe between whole scenes. Falling back to
1406
+ // createSidebar would flatten every space into one list, which is worse
1407
+ // than the web rendering already on the page \u2014 so leave that in place.
1408
+ if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
1409
+
1410
+ try {
1411
+ var nativeConfig = Object.assign({}, config);
1412
+ delete nativeConfig.sections;
1413
+ delete nativeConfig.spaces;
1414
+
1415
+ var nativeSidebar = hasSpaces
1416
+ ? nativeUI.createSpacesSidebar(nativeConfig)
1417
+ : nativeUI.createSidebar(nativeConfig);
1418
+
1419
+ if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
1420
+ nativeSidebar.setSpaces(config.spaces);
1421
+ }
1422
+ if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
1423
+ nativeSidebar.setActiveSpace(config.selectedSpace);
1424
+ }
1425
+ if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
1426
+ nativeSidebar.onSpaceChange(function(spaceId) {
1427
+ sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
1428
+ bubbles: true,
1429
+ detail: { spaceId: spaceId, sidebarId: config.id }
1430
+ }));
1431
+ });
1432
+ }
1433
+ if (nativeSidebar && !hasSpaces && config.sections) {
1434
+ config.sections.forEach(function(section) {
1435
+ if (nativeSidebar.addSection) nativeSidebar.addSection(section);
1436
+ });
1437
+ }
1438
+ if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
1439
+ nativeSidebar.setSelectedItem(config.selectedItem);
1440
+ }
1441
+ if (nativeSidebar && nativeSidebar.onSelect) {
1442
+ nativeSidebar.onSelect(function(itemId) {
1443
+ sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
1444
+ bubbles: true,
1445
+ detail: { itemId: itemId, sidebarId: config.id }
1446
+ }));
1447
+ });
1448
+ }
1449
+ sidebar.dataset.craftInitialized = 'true';
1450
+ sidebar.dataset.nativeActive = 'true';
1451
+ window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
1452
+ window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
1453
+ } catch (error) {
1454
+ sidebar.dataset.nativeError = error.message || 'unknown';
1455
+ console.warn('[stx] Failed to create native Craft sidebar', error);
1456
+ }
1457
+ }
1458
+
1459
+ function initializeCraftComponents() {
1460
+ document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
1461
+ }
1462
+
1463
+ if (document.readyState === 'loading') {
1464
+ document.addEventListener('DOMContentLoaded', initializeCraftComponents);
1465
+ } else {
1466
+ initializeCraftComponents();
1467
+ }
1468
+ window.addEventListener('craft:ready', initializeCraftComponents);
1469
+ document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
1470
+ })();
1471
+ </script>
1472
+ `;function u(q,U={}){let{classPrefix:$="craft"}=U;if(!q.includes("craft-component-styles"))if(q.includes("</head>"))q=q.replace("</head>",`${`
1473
+ <style id="craft-component-styles">
1474
+ /* Craft Component Base Styles */
1475
+ .craft-button {
1476
+ display: inline-flex;
1477
+ align-items: center;
1478
+ justify-content: center;
1479
+ padding: 8px 16px;
1480
+ border: none;
1481
+ border-radius: 6px;
1482
+ font-family: inherit;
1483
+ font-size: 14px;
1484
+ font-weight: 500;
1485
+ cursor: pointer;
1486
+ transition: all 0.2s ease;
1487
+ background: var(--craft-primary, #3b82f6);
1488
+ color: white;
1489
+ }
1490
+ .craft-button:hover { opacity: 0.9; }
1491
+ .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
1492
+ .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
1493
+ .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
1494
+
1495
+ .craft-text-input, .craft-textarea, .craft-select {
1496
+ padding: 8px 12px;
1497
+ border: 1px solid var(--craft-border, #d1d5db);
1498
+ border-radius: 6px;
1499
+ font-family: inherit;
1500
+ font-size: 14px;
1501
+ background: var(--craft-bg, #fff);
1502
+ color: var(--craft-text, #1f2937);
1503
+ transition: border-color 0.2s ease;
1504
+ }
1505
+ .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
1506
+ outline: none;
1507
+ border-color: var(--craft-primary, #3b82f6);
1508
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
1509
+ }
1510
+
1511
+ .craft-checkbox-wrapper {
1512
+ display: inline-flex;
1513
+ align-items: center;
1514
+ gap: 8px;
1515
+ cursor: pointer;
1516
+ }
1517
+ .craft-checkbox {
1518
+ width: 18px;
1519
+ height: 18px;
1520
+ cursor: pointer;
1521
+ }
1522
+
1523
+ .craft-slider {
1524
+ width: 100%;
1525
+ height: 6px;
1526
+ border-radius: 3px;
1527
+ cursor: pointer;
1528
+ }
1529
+
1530
+ .craft-badge {
1531
+ display: inline-flex;
1532
+ align-items: center;
1533
+ padding: 2px 8px;
1534
+ border-radius: 9999px;
1535
+ font-size: 12px;
1536
+ font-weight: 500;
1537
+ background: var(--craft-primary, #3b82f6);
1538
+ color: white;
1539
+ }
1540
+
1541
+ .craft-avatar {
1542
+ display: inline-flex;
1543
+ align-items: center;
1544
+ justify-content: center;
1545
+ background: var(--craft-secondary, #6b7280);
1546
+ color: white;
1547
+ font-weight: 600;
1548
+ overflow: hidden;
1549
+ }
1550
+ .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
1551
+
1552
+ .craft-progress {
1553
+ width: 100%;
1554
+ height: 8px;
1555
+ background: var(--craft-border, #e5e7eb);
1556
+ border-radius: 4px;
1557
+ overflow: hidden;
1558
+ }
1559
+ .craft-progress-bar {
1560
+ height: 100%;
1561
+ background: var(--craft-primary, #3b82f6);
1562
+ transition: width 0.3s ease;
1563
+ }
1564
+
1565
+ .craft-spinner {
1566
+ border: 2px solid var(--craft-border, #e5e7eb);
1567
+ border-top-color: var(--craft-primary, #3b82f6);
1568
+ border-radius: 50%;
1569
+ animation: craft-spin 0.8s linear infinite;
1570
+ }
1571
+ @keyframes craft-spin { to { transform: rotate(360deg); } }
1572
+
1573
+ .craft-card {
1574
+ background: var(--craft-bg, #fff);
1575
+ border: 1px solid var(--craft-border, #e5e7eb);
1576
+ border-radius: 8px;
1577
+ padding: 16px;
1578
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
1579
+ }
1580
+
1581
+ .craft-modal {
1582
+ border: none;
1583
+ border-radius: 12px;
1584
+ padding: 0;
1585
+ max-width: 90vw;
1586
+ max-height: 90vh;
1587
+ box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
1588
+ }
1589
+ .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
1590
+ .craft-modal-header {
1591
+ padding: 16px 20px;
1592
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
1593
+ }
1594
+ .craft-modal-header h2 { margin: 0; font-size: 18px; }
1595
+ .craft-modal-body { padding: 20px; }
1596
+
1597
+ .craft-accordion {
1598
+ border: 1px solid var(--craft-border, #e5e7eb);
1599
+ border-radius: 6px;
1600
+ overflow: hidden;
1601
+ }
1602
+ .craft-accordion-header {
1603
+ padding: 12px 16px;
1604
+ cursor: pointer;
1605
+ font-weight: 500;
1606
+ background: var(--craft-bg-secondary, #f9fafb);
1607
+ }
1608
+ .craft-accordion-content { padding: 16px; }
1609
+
1610
+ .craft-divider {
1611
+ border: none;
1612
+ border-top: 1px solid var(--craft-border, #e5e7eb);
1613
+ margin: 16px 0;
1614
+ }
1615
+
1616
+ .craft-alert {
1617
+ padding: 12px 16px;
1618
+ border-radius: 6px;
1619
+ border-left: 4px solid;
1620
+ }
1621
+ .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
1622
+ .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
1623
+ .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
1624
+ .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
1625
+ .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
1626
+
1627
+ .craft-tooltip {
1628
+ position: relative;
1629
+ cursor: help;
1630
+ }
1631
+ .craft-tooltip::after {
1632
+ content: attr(data-tooltip);
1633
+ position: absolute;
1634
+ bottom: 100%;
1635
+ left: 50%;
1636
+ transform: translateX(-50%);
1637
+ padding: 4px 8px;
1638
+ background: #1f2937;
1639
+ color: white;
1640
+ font-size: 12px;
1641
+ border-radius: 4px;
1642
+ white-space: nowrap;
1643
+ opacity: 0;
1644
+ pointer-events: none;
1645
+ transition: opacity 0.2s;
1646
+ }
1647
+ .craft-tooltip:hover::after { opacity: 1; }
1648
+
1649
+ .craft-table {
1650
+ width: 100%;
1651
+ border-collapse: collapse;
1652
+ }
1653
+ .craft-table th, .craft-table td {
1654
+ padding: 12px;
1655
+ text-align: left;
1656
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
1657
+ }
1658
+ .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
1659
+
1660
+ .craft-list {
1661
+ list-style: none;
1662
+ padding: 0;
1663
+ margin: 0;
1664
+ }
1665
+ .craft-list li {
1666
+ padding: 12px;
1667
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
1668
+ }
1669
+ .craft-list li:last-child { border-bottom: none; }
1670
+
1671
+ .craft-sidebar {
1672
+ --craft-sidebar-width: 286px;
1673
+ --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
1674
+ --craft-sidebar-border: rgba(255, 255, 255, 0.62);
1675
+ --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
1676
+ --craft-sidebar-text: rgba(24, 24, 27, 0.86);
1677
+ --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
1678
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
1679
+ --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
1680
+ position: relative;
1681
+ display: flex;
1682
+ flex-direction: column;
1683
+ width: var(--craft-sidebar-width);
1684
+ min-width: var(--craft-sidebar-width);
1685
+ height: 100vh;
1686
+ padding: 58px 10px 12px;
1687
+ color: var(--craft-sidebar-text);
1688
+ background:
1689
+ linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
1690
+ var(--craft-sidebar-bg);
1691
+ border: 1px solid var(--craft-sidebar-border);
1692
+ border-radius: 18px;
1693
+ box-shadow: var(--craft-sidebar-shadow);
1694
+ backdrop-filter: blur(34px) saturate(180%);
1695
+ -webkit-backdrop-filter: blur(34px) saturate(180%);
1696
+ overflow: hidden;
1697
+ user-select: none;
1698
+ }
1699
+ .craft-sidebar::before {
1700
+ content: "";
1701
+ position: absolute;
1702
+ inset: 0;
1703
+ pointer-events: none;
1704
+ background:
1705
+ radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
1706
+ linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
1707
+ mix-blend-mode: screen;
1708
+ opacity: 0.72;
1709
+ }
1710
+ .craft-sidebar[data-native-active="true"] { display: none; }
1711
+ .craft-sidebar-search {
1712
+ position: relative;
1713
+ z-index: 1;
1714
+ margin: 0 0 12px;
1715
+ }
1716
+ .craft-sidebar-search input {
1717
+ width: 100%;
1718
+ min-height: 28px;
1719
+ padding: 5px 10px;
1720
+ border: 1px solid rgba(0, 0, 0, 0.05);
1721
+ border-radius: 8px;
1722
+ background: rgba(255, 255, 255, 0.34);
1723
+ color: inherit;
1724
+ font: inherit;
1725
+ font-size: 13px;
1726
+ outline: none;
1727
+ }
1728
+ .craft-sidebar-section {
1729
+ position: relative;
1730
+ z-index: 1;
1731
+ margin: 0 0 14px;
1732
+ }
1733
+ .craft-sidebar-section-title {
1734
+ padding: 0 8px 5px;
1735
+ color: var(--craft-sidebar-muted);
1736
+ font-size: 11px;
1737
+ font-weight: 700;
1738
+ letter-spacing: 0;
1739
+ text-transform: uppercase;
1740
+ }
1741
+ .craft-sidebar-item {
1742
+ width: calc(100% - 4px);
1743
+ min-height: 28px;
1744
+ margin: 1px 2px;
1745
+ padding: 5px 8px;
1746
+ display: flex;
1747
+ align-items: center;
1748
+ gap: 8px;
1749
+ border: 0;
1750
+ border-radius: 8px;
1751
+ background: transparent;
1752
+ color: inherit;
1753
+ font: inherit;
1754
+ font-size: 13px;
1755
+ text-align: left;
1756
+ cursor: default;
1757
+ }
1758
+ .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
1759
+ .craft-sidebar-item[data-selected="true"] {
1760
+ color: white;
1761
+ background: var(--craft-sidebar-selected);
1762
+ box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
1763
+ }
1764
+ .craft-sidebar-item-icon {
1765
+ position: relative;
1766
+ display: inline-block;
1767
+ width: 16px;
1768
+ height: 16px;
1769
+ min-width: 16px;
1770
+ opacity: 0.82;
1771
+ overflow: hidden;
1772
+ color: transparent;
1773
+ }
1774
+ .craft-sidebar-item-icon::before {
1775
+ content: "";
1776
+ position: absolute;
1777
+ inset: 2px;
1778
+ border-radius: 4px;
1779
+ background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
1780
+ box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
1781
+ }
1782
+ .craft-sidebar-item-icon[data-icon*="circle"]::before {
1783
+ inset: 4px;
1784
+ border-radius: 999px;
1785
+ }
1786
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
1787
+ background: rgba(255, 255, 255, 0.9);
1788
+ }
1789
+ .craft-sidebar-item-label {
1790
+ flex: 1;
1791
+ overflow: hidden;
1792
+ white-space: nowrap;
1793
+ text-overflow: ellipsis;
1794
+ }
1795
+ .craft-sidebar-item-badge {
1796
+ min-width: 18px;
1797
+ padding: 1px 6px;
1798
+ border-radius: 999px;
1799
+ background: rgba(0, 0, 0, 0.08);
1800
+ color: var(--craft-sidebar-muted);
1801
+ font-size: 10px;
1802
+ font-weight: 700;
1803
+ text-align: center;
1804
+ }
1805
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
1806
+ color: white;
1807
+ background: rgba(255, 255, 255, 0.24);
1808
+ }
1809
+
1810
+ /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
1811
+ a native host, and deliberately not a second swipe implementation. */
1812
+ .craft-sidebar-spaces {
1813
+ position: relative;
1814
+ z-index: 1;
1815
+ flex: 1;
1816
+ min-height: 0;
1817
+ overflow-y: auto;
1818
+ }
1819
+ .craft-sidebar-space-title {
1820
+ padding: 10px 8px 4px;
1821
+ font-size: 13px;
1822
+ font-weight: 600;
1823
+ }
1824
+ .craft-sidebar-space-switcher {
1825
+ position: relative;
1826
+ z-index: 1;
1827
+ display: flex;
1828
+ align-items: center;
1829
+ gap: 1px;
1830
+ padding-top: 6px;
1831
+ }
1832
+ .craft-sidebar-space-tab {
1833
+ display: grid;
1834
+ place-items: center;
1835
+ width: 28px;
1836
+ height: 26px;
1837
+ border: 0;
1838
+ border-radius: 7px;
1839
+ background: transparent;
1840
+ color: inherit;
1841
+ font: inherit;
1842
+ font-size: 11px;
1843
+ font-weight: 700;
1844
+ opacity: 0.4;
1845
+ cursor: default;
1846
+ }
1847
+ .craft-sidebar-space-tab[data-selected="true"] {
1848
+ opacity: 1;
1849
+ background: rgba(255, 255, 255, 0.55);
1850
+ }
1851
+
1852
+ .craft-code-editor {
1853
+ font-family: 'SF Mono', 'Fira Code', monospace;
1854
+ font-size: 13px;
1855
+ line-height: 1.5;
1856
+ padding: 12px;
1857
+ background: #1e1e1e;
1858
+ color: #d4d4d4;
1859
+ border-radius: 6px;
1860
+ resize: vertical;
1861
+ }
1862
+
1863
+ /* Dark mode support */
1864
+ @media (prefers-color-scheme: dark) {
1865
+ .craft-text-input, .craft-textarea, .craft-select, .craft-card {
1866
+ background: #1f2937;
1867
+ color: #f3f4f6;
1868
+ border-color: #374151;
1869
+ }
1870
+ .craft-modal {
1871
+ background: #1f2937;
1872
+ color: #f3f4f6;
1873
+ }
1874
+ .craft-accordion-header { background: #374151; }
1875
+ .craft-table th { background: #374151; }
1876
+ .craft-sidebar {
1877
+ --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
1878
+ --craft-sidebar-border: rgba(255, 255, 255, 0.12);
1879
+ --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
1880
+ --craft-sidebar-text: rgba(244, 244, 245, 0.92);
1881
+ --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
1882
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
1883
+ }
1884
+ .craft-sidebar-search input {
1885
+ border-color: rgba(255,255,255,0.08);
1886
+ background: rgba(255,255,255,0.08);
1887
+ }
1888
+ }
1889
+ </style>
1890
+ `}
1891
+ </head>`);else if(q.includes("<style>"))q=q.replace("<style>",`${`
1892
+ <style id="craft-component-styles">
1893
+ /* Craft Component Base Styles */
1894
+ .craft-button {
1895
+ display: inline-flex;
1896
+ align-items: center;
1897
+ justify-content: center;
1898
+ padding: 8px 16px;
1899
+ border: none;
1900
+ border-radius: 6px;
1901
+ font-family: inherit;
1902
+ font-size: 14px;
1903
+ font-weight: 500;
1904
+ cursor: pointer;
1905
+ transition: all 0.2s ease;
1906
+ background: var(--craft-primary, #3b82f6);
1907
+ color: white;
1908
+ }
1909
+ .craft-button:hover { opacity: 0.9; }
1910
+ .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
1911
+ .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
1912
+ .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
1913
+
1914
+ .craft-text-input, .craft-textarea, .craft-select {
1915
+ padding: 8px 12px;
1916
+ border: 1px solid var(--craft-border, #d1d5db);
1917
+ border-radius: 6px;
1918
+ font-family: inherit;
1919
+ font-size: 14px;
1920
+ background: var(--craft-bg, #fff);
1921
+ color: var(--craft-text, #1f2937);
1922
+ transition: border-color 0.2s ease;
1923
+ }
1924
+ .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
1925
+ outline: none;
1926
+ border-color: var(--craft-primary, #3b82f6);
1927
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
1928
+ }
1929
+
1930
+ .craft-checkbox-wrapper {
1931
+ display: inline-flex;
1932
+ align-items: center;
1933
+ gap: 8px;
1934
+ cursor: pointer;
1935
+ }
1936
+ .craft-checkbox {
1937
+ width: 18px;
1938
+ height: 18px;
1939
+ cursor: pointer;
1940
+ }
1941
+
1942
+ .craft-slider {
1943
+ width: 100%;
1944
+ height: 6px;
1945
+ border-radius: 3px;
1946
+ cursor: pointer;
1947
+ }
1948
+
1949
+ .craft-badge {
1950
+ display: inline-flex;
1951
+ align-items: center;
1952
+ padding: 2px 8px;
1953
+ border-radius: 9999px;
1954
+ font-size: 12px;
1955
+ font-weight: 500;
1956
+ background: var(--craft-primary, #3b82f6);
1957
+ color: white;
1958
+ }
1959
+
1960
+ .craft-avatar {
1961
+ display: inline-flex;
1962
+ align-items: center;
1963
+ justify-content: center;
1964
+ background: var(--craft-secondary, #6b7280);
1965
+ color: white;
1966
+ font-weight: 600;
1967
+ overflow: hidden;
1968
+ }
1969
+ .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
1970
+
1971
+ .craft-progress {
1972
+ width: 100%;
1973
+ height: 8px;
1974
+ background: var(--craft-border, #e5e7eb);
1975
+ border-radius: 4px;
1976
+ overflow: hidden;
1977
+ }
1978
+ .craft-progress-bar {
1979
+ height: 100%;
1980
+ background: var(--craft-primary, #3b82f6);
1981
+ transition: width 0.3s ease;
1982
+ }
1983
+
1984
+ .craft-spinner {
1985
+ border: 2px solid var(--craft-border, #e5e7eb);
1986
+ border-top-color: var(--craft-primary, #3b82f6);
1987
+ border-radius: 50%;
1988
+ animation: craft-spin 0.8s linear infinite;
1989
+ }
1990
+ @keyframes craft-spin { to { transform: rotate(360deg); } }
1991
+
1992
+ .craft-card {
1993
+ background: var(--craft-bg, #fff);
1994
+ border: 1px solid var(--craft-border, #e5e7eb);
1995
+ border-radius: 8px;
1996
+ padding: 16px;
1997
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
1998
+ }
1999
+
2000
+ .craft-modal {
2001
+ border: none;
2002
+ border-radius: 12px;
2003
+ padding: 0;
2004
+ max-width: 90vw;
2005
+ max-height: 90vh;
2006
+ box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
2007
+ }
2008
+ .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
2009
+ .craft-modal-header {
2010
+ padding: 16px 20px;
2011
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
2012
+ }
2013
+ .craft-modal-header h2 { margin: 0; font-size: 18px; }
2014
+ .craft-modal-body { padding: 20px; }
2015
+
2016
+ .craft-accordion {
2017
+ border: 1px solid var(--craft-border, #e5e7eb);
2018
+ border-radius: 6px;
2019
+ overflow: hidden;
2020
+ }
2021
+ .craft-accordion-header {
2022
+ padding: 12px 16px;
2023
+ cursor: pointer;
2024
+ font-weight: 500;
2025
+ background: var(--craft-bg-secondary, #f9fafb);
2026
+ }
2027
+ .craft-accordion-content { padding: 16px; }
2028
+
2029
+ .craft-divider {
2030
+ border: none;
2031
+ border-top: 1px solid var(--craft-border, #e5e7eb);
2032
+ margin: 16px 0;
2033
+ }
2034
+
2035
+ .craft-alert {
2036
+ padding: 12px 16px;
2037
+ border-radius: 6px;
2038
+ border-left: 4px solid;
2039
+ }
2040
+ .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
2041
+ .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
2042
+ .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
2043
+ .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
2044
+ .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
2045
+
2046
+ .craft-tooltip {
2047
+ position: relative;
2048
+ cursor: help;
2049
+ }
2050
+ .craft-tooltip::after {
2051
+ content: attr(data-tooltip);
2052
+ position: absolute;
2053
+ bottom: 100%;
2054
+ left: 50%;
2055
+ transform: translateX(-50%);
2056
+ padding: 4px 8px;
2057
+ background: #1f2937;
2058
+ color: white;
2059
+ font-size: 12px;
2060
+ border-radius: 4px;
2061
+ white-space: nowrap;
2062
+ opacity: 0;
2063
+ pointer-events: none;
2064
+ transition: opacity 0.2s;
2065
+ }
2066
+ .craft-tooltip:hover::after { opacity: 1; }
2067
+
2068
+ .craft-table {
2069
+ width: 100%;
2070
+ border-collapse: collapse;
2071
+ }
2072
+ .craft-table th, .craft-table td {
2073
+ padding: 12px;
2074
+ text-align: left;
2075
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
2076
+ }
2077
+ .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
2078
+
2079
+ .craft-list {
2080
+ list-style: none;
2081
+ padding: 0;
2082
+ margin: 0;
2083
+ }
2084
+ .craft-list li {
2085
+ padding: 12px;
2086
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
2087
+ }
2088
+ .craft-list li:last-child { border-bottom: none; }
2089
+
2090
+ .craft-sidebar {
2091
+ --craft-sidebar-width: 286px;
2092
+ --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
2093
+ --craft-sidebar-border: rgba(255, 255, 255, 0.62);
2094
+ --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
2095
+ --craft-sidebar-text: rgba(24, 24, 27, 0.86);
2096
+ --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
2097
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
2098
+ --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
2099
+ position: relative;
2100
+ display: flex;
2101
+ flex-direction: column;
2102
+ width: var(--craft-sidebar-width);
2103
+ min-width: var(--craft-sidebar-width);
2104
+ height: 100vh;
2105
+ padding: 58px 10px 12px;
2106
+ color: var(--craft-sidebar-text);
2107
+ background:
2108
+ linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
2109
+ var(--craft-sidebar-bg);
2110
+ border: 1px solid var(--craft-sidebar-border);
2111
+ border-radius: 18px;
2112
+ box-shadow: var(--craft-sidebar-shadow);
2113
+ backdrop-filter: blur(34px) saturate(180%);
2114
+ -webkit-backdrop-filter: blur(34px) saturate(180%);
2115
+ overflow: hidden;
2116
+ user-select: none;
2117
+ }
2118
+ .craft-sidebar::before {
2119
+ content: "";
2120
+ position: absolute;
2121
+ inset: 0;
2122
+ pointer-events: none;
2123
+ background:
2124
+ radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
2125
+ linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
2126
+ mix-blend-mode: screen;
2127
+ opacity: 0.72;
2128
+ }
2129
+ .craft-sidebar[data-native-active="true"] { display: none; }
2130
+ .craft-sidebar-search {
2131
+ position: relative;
2132
+ z-index: 1;
2133
+ margin: 0 0 12px;
2134
+ }
2135
+ .craft-sidebar-search input {
2136
+ width: 100%;
2137
+ min-height: 28px;
2138
+ padding: 5px 10px;
2139
+ border: 1px solid rgba(0, 0, 0, 0.05);
2140
+ border-radius: 8px;
2141
+ background: rgba(255, 255, 255, 0.34);
2142
+ color: inherit;
2143
+ font: inherit;
2144
+ font-size: 13px;
2145
+ outline: none;
2146
+ }
2147
+ .craft-sidebar-section {
2148
+ position: relative;
2149
+ z-index: 1;
2150
+ margin: 0 0 14px;
2151
+ }
2152
+ .craft-sidebar-section-title {
2153
+ padding: 0 8px 5px;
2154
+ color: var(--craft-sidebar-muted);
2155
+ font-size: 11px;
2156
+ font-weight: 700;
2157
+ letter-spacing: 0;
2158
+ text-transform: uppercase;
2159
+ }
2160
+ .craft-sidebar-item {
2161
+ width: calc(100% - 4px);
2162
+ min-height: 28px;
2163
+ margin: 1px 2px;
2164
+ padding: 5px 8px;
2165
+ display: flex;
2166
+ align-items: center;
2167
+ gap: 8px;
2168
+ border: 0;
2169
+ border-radius: 8px;
2170
+ background: transparent;
2171
+ color: inherit;
2172
+ font: inherit;
2173
+ font-size: 13px;
2174
+ text-align: left;
2175
+ cursor: default;
2176
+ }
2177
+ .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
2178
+ .craft-sidebar-item[data-selected="true"] {
2179
+ color: white;
2180
+ background: var(--craft-sidebar-selected);
2181
+ box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
2182
+ }
2183
+ .craft-sidebar-item-icon {
2184
+ position: relative;
2185
+ display: inline-block;
2186
+ width: 16px;
2187
+ height: 16px;
2188
+ min-width: 16px;
2189
+ opacity: 0.82;
2190
+ overflow: hidden;
2191
+ color: transparent;
2192
+ }
2193
+ .craft-sidebar-item-icon::before {
2194
+ content: "";
2195
+ position: absolute;
2196
+ inset: 2px;
2197
+ border-radius: 4px;
2198
+ background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
2199
+ box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
2200
+ }
2201
+ .craft-sidebar-item-icon[data-icon*="circle"]::before {
2202
+ inset: 4px;
2203
+ border-radius: 999px;
2204
+ }
2205
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
2206
+ background: rgba(255, 255, 255, 0.9);
2207
+ }
2208
+ .craft-sidebar-item-label {
2209
+ flex: 1;
2210
+ overflow: hidden;
2211
+ white-space: nowrap;
2212
+ text-overflow: ellipsis;
2213
+ }
2214
+ .craft-sidebar-item-badge {
2215
+ min-width: 18px;
2216
+ padding: 1px 6px;
2217
+ border-radius: 999px;
2218
+ background: rgba(0, 0, 0, 0.08);
2219
+ color: var(--craft-sidebar-muted);
2220
+ font-size: 10px;
2221
+ font-weight: 700;
2222
+ text-align: center;
2223
+ }
2224
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
2225
+ color: white;
2226
+ background: rgba(255, 255, 255, 0.24);
2227
+ }
2228
+
2229
+ /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
2230
+ a native host, and deliberately not a second swipe implementation. */
2231
+ .craft-sidebar-spaces {
2232
+ position: relative;
2233
+ z-index: 1;
2234
+ flex: 1;
2235
+ min-height: 0;
2236
+ overflow-y: auto;
2237
+ }
2238
+ .craft-sidebar-space-title {
2239
+ padding: 10px 8px 4px;
2240
+ font-size: 13px;
2241
+ font-weight: 600;
2242
+ }
2243
+ .craft-sidebar-space-switcher {
2244
+ position: relative;
2245
+ z-index: 1;
2246
+ display: flex;
2247
+ align-items: center;
2248
+ gap: 1px;
2249
+ padding-top: 6px;
2250
+ }
2251
+ .craft-sidebar-space-tab {
2252
+ display: grid;
2253
+ place-items: center;
2254
+ width: 28px;
2255
+ height: 26px;
2256
+ border: 0;
2257
+ border-radius: 7px;
2258
+ background: transparent;
2259
+ color: inherit;
2260
+ font: inherit;
2261
+ font-size: 11px;
2262
+ font-weight: 700;
2263
+ opacity: 0.4;
2264
+ cursor: default;
2265
+ }
2266
+ .craft-sidebar-space-tab[data-selected="true"] {
2267
+ opacity: 1;
2268
+ background: rgba(255, 255, 255, 0.55);
2269
+ }
2270
+
2271
+ .craft-code-editor {
2272
+ font-family: 'SF Mono', 'Fira Code', monospace;
2273
+ font-size: 13px;
2274
+ line-height: 1.5;
2275
+ padding: 12px;
2276
+ background: #1e1e1e;
2277
+ color: #d4d4d4;
2278
+ border-radius: 6px;
2279
+ resize: vertical;
2280
+ }
2281
+
2282
+ /* Dark mode support */
2283
+ @media (prefers-color-scheme: dark) {
2284
+ .craft-text-input, .craft-textarea, .craft-select, .craft-card {
2285
+ background: #1f2937;
2286
+ color: #f3f4f6;
2287
+ border-color: #374151;
2288
+ }
2289
+ .craft-modal {
2290
+ background: #1f2937;
2291
+ color: #f3f4f6;
2292
+ }
2293
+ .craft-accordion-header { background: #374151; }
2294
+ .craft-table th { background: #374151; }
2295
+ .craft-sidebar {
2296
+ --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
2297
+ --craft-sidebar-border: rgba(255, 255, 255, 0.12);
2298
+ --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
2299
+ --craft-sidebar-text: rgba(244, 244, 245, 0.92);
2300
+ --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
2301
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
2302
+ }
2303
+ .craft-sidebar-search input {
2304
+ border-color: rgba(255,255,255,0.08);
2305
+ background: rgba(255,255,255,0.08);
2306
+ }
2307
+ }
2308
+ </style>
2309
+ `}
2310
+ <style>`);else q=`
2311
+ <style id="craft-component-styles">
2312
+ /* Craft Component Base Styles */
2313
+ .craft-button {
2314
+ display: inline-flex;
2315
+ align-items: center;
2316
+ justify-content: center;
2317
+ padding: 8px 16px;
2318
+ border: none;
2319
+ border-radius: 6px;
2320
+ font-family: inherit;
2321
+ font-size: 14px;
2322
+ font-weight: 500;
2323
+ cursor: pointer;
2324
+ transition: all 0.2s ease;
2325
+ background: var(--craft-primary, #3b82f6);
2326
+ color: white;
2327
+ }
2328
+ .craft-button:hover { opacity: 0.9; }
2329
+ .craft-button:disabled { opacity: 0.5; cursor: not-allowed; }
2330
+ .craft-button-secondary { background: var(--craft-secondary, #6b7280); }
2331
+ .craft-button-outline { background: transparent; border: 1px solid currentColor; color: var(--craft-primary, #3b82f6); }
2332
+
2333
+ .craft-text-input, .craft-textarea, .craft-select {
2334
+ padding: 8px 12px;
2335
+ border: 1px solid var(--craft-border, #d1d5db);
2336
+ border-radius: 6px;
2337
+ font-family: inherit;
2338
+ font-size: 14px;
2339
+ background: var(--craft-bg, #fff);
2340
+ color: var(--craft-text, #1f2937);
2341
+ transition: border-color 0.2s ease;
2342
+ }
2343
+ .craft-text-input:focus, .craft-textarea:focus, .craft-select:focus {
2344
+ outline: none;
2345
+ border-color: var(--craft-primary, #3b82f6);
2346
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
2347
+ }
2348
+
2349
+ .craft-checkbox-wrapper {
2350
+ display: inline-flex;
2351
+ align-items: center;
2352
+ gap: 8px;
2353
+ cursor: pointer;
2354
+ }
2355
+ .craft-checkbox {
2356
+ width: 18px;
2357
+ height: 18px;
2358
+ cursor: pointer;
2359
+ }
2360
+
2361
+ .craft-slider {
2362
+ width: 100%;
2363
+ height: 6px;
2364
+ border-radius: 3px;
2365
+ cursor: pointer;
2366
+ }
2367
+
2368
+ .craft-badge {
2369
+ display: inline-flex;
2370
+ align-items: center;
2371
+ padding: 2px 8px;
2372
+ border-radius: 9999px;
2373
+ font-size: 12px;
2374
+ font-weight: 500;
2375
+ background: var(--craft-primary, #3b82f6);
2376
+ color: white;
2377
+ }
2378
+
2379
+ .craft-avatar {
2380
+ display: inline-flex;
2381
+ align-items: center;
2382
+ justify-content: center;
2383
+ background: var(--craft-secondary, #6b7280);
2384
+ color: white;
2385
+ font-weight: 600;
2386
+ overflow: hidden;
2387
+ }
2388
+ .craft-avatar img { width: 100%; height: 100%; object-fit: cover; }
2389
+
2390
+ .craft-progress {
2391
+ width: 100%;
2392
+ height: 8px;
2393
+ background: var(--craft-border, #e5e7eb);
2394
+ border-radius: 4px;
2395
+ overflow: hidden;
2396
+ }
2397
+ .craft-progress-bar {
2398
+ height: 100%;
2399
+ background: var(--craft-primary, #3b82f6);
2400
+ transition: width 0.3s ease;
2401
+ }
2402
+
2403
+ .craft-spinner {
2404
+ border: 2px solid var(--craft-border, #e5e7eb);
2405
+ border-top-color: var(--craft-primary, #3b82f6);
2406
+ border-radius: 50%;
2407
+ animation: craft-spin 0.8s linear infinite;
2408
+ }
2409
+ @keyframes craft-spin { to { transform: rotate(360deg); } }
2410
+
2411
+ .craft-card {
2412
+ background: var(--craft-bg, #fff);
2413
+ border: 1px solid var(--craft-border, #e5e7eb);
2414
+ border-radius: 8px;
2415
+ padding: 16px;
2416
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
2417
+ }
2418
+
2419
+ .craft-modal {
2420
+ border: none;
2421
+ border-radius: 12px;
2422
+ padding: 0;
2423
+ max-width: 90vw;
2424
+ max-height: 90vh;
2425
+ box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
2426
+ }
2427
+ .craft-modal::backdrop { background: rgba(0,0,0,0.5); }
2428
+ .craft-modal-header {
2429
+ padding: 16px 20px;
2430
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
2431
+ }
2432
+ .craft-modal-header h2 { margin: 0; font-size: 18px; }
2433
+ .craft-modal-body { padding: 20px; }
2434
+
2435
+ .craft-accordion {
2436
+ border: 1px solid var(--craft-border, #e5e7eb);
2437
+ border-radius: 6px;
2438
+ overflow: hidden;
2439
+ }
2440
+ .craft-accordion-header {
2441
+ padding: 12px 16px;
2442
+ cursor: pointer;
2443
+ font-weight: 500;
2444
+ background: var(--craft-bg-secondary, #f9fafb);
2445
+ }
2446
+ .craft-accordion-content { padding: 16px; }
2447
+
2448
+ .craft-divider {
2449
+ border: none;
2450
+ border-top: 1px solid var(--craft-border, #e5e7eb);
2451
+ margin: 16px 0;
2452
+ }
2453
+
2454
+ .craft-alert {
2455
+ padding: 12px 16px;
2456
+ border-radius: 6px;
2457
+ border-left: 4px solid;
2458
+ }
2459
+ .craft-alert-info { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
2460
+ .craft-alert-success { background: #f0fdf4; border-color: #22c55e; color: #166534; }
2461
+ .craft-alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
2462
+ .craft-alert-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
2463
+ .craft-alert-title { font-weight: 600; margin-bottom: 4px; }
2464
+
2465
+ .craft-tooltip {
2466
+ position: relative;
2467
+ cursor: help;
2468
+ }
2469
+ .craft-tooltip::after {
2470
+ content: attr(data-tooltip);
2471
+ position: absolute;
2472
+ bottom: 100%;
2473
+ left: 50%;
2474
+ transform: translateX(-50%);
2475
+ padding: 4px 8px;
2476
+ background: #1f2937;
2477
+ color: white;
2478
+ font-size: 12px;
2479
+ border-radius: 4px;
2480
+ white-space: nowrap;
2481
+ opacity: 0;
2482
+ pointer-events: none;
2483
+ transition: opacity 0.2s;
2484
+ }
2485
+ .craft-tooltip:hover::after { opacity: 1; }
2486
+
2487
+ .craft-table {
2488
+ width: 100%;
2489
+ border-collapse: collapse;
2490
+ }
2491
+ .craft-table th, .craft-table td {
2492
+ padding: 12px;
2493
+ text-align: left;
2494
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
2495
+ }
2496
+ .craft-table th { font-weight: 600; background: var(--craft-bg-secondary, #f9fafb); }
2497
+
2498
+ .craft-list {
2499
+ list-style: none;
2500
+ padding: 0;
2501
+ margin: 0;
2502
+ }
2503
+ .craft-list li {
2504
+ padding: 12px;
2505
+ border-bottom: 1px solid var(--craft-border, #e5e7eb);
2506
+ }
2507
+ .craft-list li:last-child { border-bottom: none; }
2508
+
2509
+ .craft-sidebar {
2510
+ --craft-sidebar-width: 286px;
2511
+ --craft-sidebar-bg: rgba(255, 255, 255, 0.68);
2512
+ --craft-sidebar-border: rgba(255, 255, 255, 0.62);
2513
+ --craft-sidebar-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
2514
+ --craft-sidebar-text: rgba(24, 24, 27, 0.86);
2515
+ --craft-sidebar-muted: rgba(63, 63, 70, 0.62);
2516
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.42);
2517
+ --craft-sidebar-selected: rgba(10, 132, 255, 0.86);
2518
+ position: relative;
2519
+ display: flex;
2520
+ flex-direction: column;
2521
+ width: var(--craft-sidebar-width);
2522
+ min-width: var(--craft-sidebar-width);
2523
+ height: 100vh;
2524
+ padding: 58px 10px 12px;
2525
+ color: var(--craft-sidebar-text);
2526
+ background:
2527
+ linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)),
2528
+ var(--craft-sidebar-bg);
2529
+ border: 1px solid var(--craft-sidebar-border);
2530
+ border-radius: 18px;
2531
+ box-shadow: var(--craft-sidebar-shadow);
2532
+ backdrop-filter: blur(34px) saturate(180%);
2533
+ -webkit-backdrop-filter: blur(34px) saturate(180%);
2534
+ overflow: hidden;
2535
+ user-select: none;
2536
+ }
2537
+ .craft-sidebar::before {
2538
+ content: "";
2539
+ position: absolute;
2540
+ inset: 0;
2541
+ pointer-events: none;
2542
+ background:
2543
+ radial-gradient(circle at 18% 0%, rgba(255,255,255,0.68), transparent 32%),
2544
+ linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.30) 42%, transparent 58%);
2545
+ mix-blend-mode: screen;
2546
+ opacity: 0.72;
2547
+ }
2548
+ .craft-sidebar[data-native-active="true"] { display: none; }
2549
+ .craft-sidebar-search {
2550
+ position: relative;
2551
+ z-index: 1;
2552
+ margin: 0 0 12px;
2553
+ }
2554
+ .craft-sidebar-search input {
2555
+ width: 100%;
2556
+ min-height: 28px;
2557
+ padding: 5px 10px;
2558
+ border: 1px solid rgba(0, 0, 0, 0.05);
2559
+ border-radius: 8px;
2560
+ background: rgba(255, 255, 255, 0.34);
2561
+ color: inherit;
2562
+ font: inherit;
2563
+ font-size: 13px;
2564
+ outline: none;
2565
+ }
2566
+ .craft-sidebar-section {
2567
+ position: relative;
2568
+ z-index: 1;
2569
+ margin: 0 0 14px;
2570
+ }
2571
+ .craft-sidebar-section-title {
2572
+ padding: 0 8px 5px;
2573
+ color: var(--craft-sidebar-muted);
2574
+ font-size: 11px;
2575
+ font-weight: 700;
2576
+ letter-spacing: 0;
2577
+ text-transform: uppercase;
2578
+ }
2579
+ .craft-sidebar-item {
2580
+ width: calc(100% - 4px);
2581
+ min-height: 28px;
2582
+ margin: 1px 2px;
2583
+ padding: 5px 8px;
2584
+ display: flex;
2585
+ align-items: center;
2586
+ gap: 8px;
2587
+ border: 0;
2588
+ border-radius: 8px;
2589
+ background: transparent;
2590
+ color: inherit;
2591
+ font: inherit;
2592
+ font-size: 13px;
2593
+ text-align: left;
2594
+ cursor: default;
2595
+ }
2596
+ .craft-sidebar-item:hover { background: var(--craft-sidebar-hover); }
2597
+ .craft-sidebar-item[data-selected="true"] {
2598
+ color: white;
2599
+ background: var(--craft-sidebar-selected);
2600
+ box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 8px 18px rgba(10, 132, 255, 0.22);
2601
+ }
2602
+ .craft-sidebar-item-icon {
2603
+ position: relative;
2604
+ display: inline-block;
2605
+ width: 16px;
2606
+ height: 16px;
2607
+ min-width: 16px;
2608
+ opacity: 0.82;
2609
+ overflow: hidden;
2610
+ color: transparent;
2611
+ }
2612
+ .craft-sidebar-item-icon::before {
2613
+ content: "";
2614
+ position: absolute;
2615
+ inset: 2px;
2616
+ border-radius: 4px;
2617
+ background: var(--craft-sidebar-icon-color, rgba(63, 63, 70, 0.62));
2618
+ box-shadow: 0 1px 0 rgba(255,255,255,0.24) inset;
2619
+ }
2620
+ .craft-sidebar-item-icon[data-icon*="circle"]::before {
2621
+ inset: 4px;
2622
+ border-radius: 999px;
2623
+ }
2624
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-icon::before {
2625
+ background: rgba(255, 255, 255, 0.9);
2626
+ }
2627
+ .craft-sidebar-item-label {
2628
+ flex: 1;
2629
+ overflow: hidden;
2630
+ white-space: nowrap;
2631
+ text-overflow: ellipsis;
2632
+ }
2633
+ .craft-sidebar-item-badge {
2634
+ min-width: 18px;
2635
+ padding: 1px 6px;
2636
+ border-radius: 999px;
2637
+ background: rgba(0, 0, 0, 0.08);
2638
+ color: var(--craft-sidebar-muted);
2639
+ font-size: 10px;
2640
+ font-weight: 700;
2641
+ text-align: center;
2642
+ }
2643
+ .craft-sidebar-item[data-selected="true"] .craft-sidebar-item-badge {
2644
+ color: white;
2645
+ background: rgba(255, 255, 255, 0.24);
2646
+ }
2647
+
2648
+ /* Spaces fallback. Stacked in document order behind a rail \u2014 legible without
2649
+ a native host, and deliberately not a second swipe implementation. */
2650
+ .craft-sidebar-spaces {
2651
+ position: relative;
2652
+ z-index: 1;
2653
+ flex: 1;
2654
+ min-height: 0;
2655
+ overflow-y: auto;
2656
+ }
2657
+ .craft-sidebar-space-title {
2658
+ padding: 10px 8px 4px;
2659
+ font-size: 13px;
2660
+ font-weight: 600;
2661
+ }
2662
+ .craft-sidebar-space-switcher {
2663
+ position: relative;
2664
+ z-index: 1;
2665
+ display: flex;
2666
+ align-items: center;
2667
+ gap: 1px;
2668
+ padding-top: 6px;
2669
+ }
2670
+ .craft-sidebar-space-tab {
2671
+ display: grid;
2672
+ place-items: center;
2673
+ width: 28px;
2674
+ height: 26px;
2675
+ border: 0;
2676
+ border-radius: 7px;
2677
+ background: transparent;
2678
+ color: inherit;
2679
+ font: inherit;
2680
+ font-size: 11px;
2681
+ font-weight: 700;
2682
+ opacity: 0.4;
2683
+ cursor: default;
2684
+ }
2685
+ .craft-sidebar-space-tab[data-selected="true"] {
2686
+ opacity: 1;
2687
+ background: rgba(255, 255, 255, 0.55);
2688
+ }
2689
+
2690
+ .craft-code-editor {
2691
+ font-family: 'SF Mono', 'Fira Code', monospace;
2692
+ font-size: 13px;
2693
+ line-height: 1.5;
2694
+ padding: 12px;
2695
+ background: #1e1e1e;
2696
+ color: #d4d4d4;
2697
+ border-radius: 6px;
2698
+ resize: vertical;
2699
+ }
2700
+
2701
+ /* Dark mode support */
2702
+ @media (prefers-color-scheme: dark) {
2703
+ .craft-text-input, .craft-textarea, .craft-select, .craft-card {
2704
+ background: #1f2937;
2705
+ color: #f3f4f6;
2706
+ border-color: #374151;
2707
+ }
2708
+ .craft-modal {
2709
+ background: #1f2937;
2710
+ color: #f3f4f6;
2711
+ }
2712
+ .craft-accordion-header { background: #374151; }
2713
+ .craft-table th { background: #374151; }
2714
+ .craft-sidebar {
2715
+ --craft-sidebar-bg: rgba(24, 24, 27, 0.58);
2716
+ --craft-sidebar-border: rgba(255, 255, 255, 0.12);
2717
+ --craft-sidebar-shadow: 0 26px 74px rgba(0, 0, 0, 0.44), 0 1px 0 rgba(255, 255, 255, 0.11) inset;
2718
+ --craft-sidebar-text: rgba(244, 244, 245, 0.92);
2719
+ --craft-sidebar-muted: rgba(212, 212, 216, 0.58);
2720
+ --craft-sidebar-hover: rgba(255, 255, 255, 0.10);
2721
+ }
2722
+ .craft-sidebar-search input {
2723
+ border-color: rgba(255,255,255,0.08);
2724
+ background: rgba(255,255,255,0.08);
2725
+ }
2726
+ }
2727
+ </style>
2728
+ `+q;if(!q.includes("craft-component-runtime"))if(q.includes("</body>"))q=q.replace("</body>",`${`
2729
+ <script id="craft-component-runtime">
2730
+ (function() {
2731
+ if (window.__stxCraftComponentRuntime) return;
2732
+ window.__stxCraftComponentRuntime = true;
2733
+
2734
+ function parseConfig(sidebar) {
2735
+ var id = sidebar.getAttribute('data-craft-sidebar-id');
2736
+ var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
2737
+ if (!script) return null;
2738
+ try {
2739
+ return JSON.parse(script.textContent || '{}');
2740
+ } catch (error) {
2741
+ console.warn('[stx] Invalid Craft sidebar config', error);
2742
+ return null;
2743
+ }
2744
+ }
2745
+
2746
+ function getNativeUI() {
2747
+ if (!window.craft) return null;
2748
+ var hasNativeHost = window.craft.isCraft?.() ||
2749
+ !!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
2750
+ if (!hasNativeHost) return null;
2751
+ return window.craft.nativeUI || window.craft.components;
2752
+ }
2753
+
2754
+ function initializeSidebar(sidebar) {
2755
+ if (sidebar.dataset.craftInitialized === 'true') return;
2756
+ if (sidebar.dataset.native === 'false') return;
2757
+
2758
+ var nativeUI = getNativeUI();
2759
+ if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
2760
+
2761
+ var config = parseConfig(sidebar);
2762
+ if (!config) return;
2763
+
2764
+ var hasSpaces = !!(config.spaces && config.spaces.length);
2765
+ // Spaces need a host that can swipe between whole scenes. Falling back to
2766
+ // createSidebar would flatten every space into one list, which is worse
2767
+ // than the web rendering already on the page \u2014 so leave that in place.
2768
+ if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
2769
+
2770
+ try {
2771
+ var nativeConfig = Object.assign({}, config);
2772
+ delete nativeConfig.sections;
2773
+ delete nativeConfig.spaces;
2774
+
2775
+ var nativeSidebar = hasSpaces
2776
+ ? nativeUI.createSpacesSidebar(nativeConfig)
2777
+ : nativeUI.createSidebar(nativeConfig);
2778
+
2779
+ if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
2780
+ nativeSidebar.setSpaces(config.spaces);
2781
+ }
2782
+ if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
2783
+ nativeSidebar.setActiveSpace(config.selectedSpace);
2784
+ }
2785
+ if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
2786
+ nativeSidebar.onSpaceChange(function(spaceId) {
2787
+ sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
2788
+ bubbles: true,
2789
+ detail: { spaceId: spaceId, sidebarId: config.id }
2790
+ }));
2791
+ });
2792
+ }
2793
+ if (nativeSidebar && !hasSpaces && config.sections) {
2794
+ config.sections.forEach(function(section) {
2795
+ if (nativeSidebar.addSection) nativeSidebar.addSection(section);
2796
+ });
2797
+ }
2798
+ if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
2799
+ nativeSidebar.setSelectedItem(config.selectedItem);
2800
+ }
2801
+ if (nativeSidebar && nativeSidebar.onSelect) {
2802
+ nativeSidebar.onSelect(function(itemId) {
2803
+ sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
2804
+ bubbles: true,
2805
+ detail: { itemId: itemId, sidebarId: config.id }
2806
+ }));
2807
+ });
2808
+ }
2809
+ sidebar.dataset.craftInitialized = 'true';
2810
+ sidebar.dataset.nativeActive = 'true';
2811
+ window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
2812
+ window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
2813
+ } catch (error) {
2814
+ sidebar.dataset.nativeError = error.message || 'unknown';
2815
+ console.warn('[stx] Failed to create native Craft sidebar', error);
2816
+ }
2817
+ }
2818
+
2819
+ function initializeCraftComponents() {
2820
+ document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
2821
+ }
2822
+
2823
+ if (document.readyState === 'loading') {
2824
+ document.addEventListener('DOMContentLoaded', initializeCraftComponents);
2825
+ } else {
2826
+ initializeCraftComponents();
2827
+ }
2828
+ window.addEventListener('craft:ready', initializeCraftComponents);
2829
+ document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
2830
+ })();
2831
+ </script>
2832
+ `}
2833
+ </body>`);else q+=`
2834
+ <script id="craft-component-runtime">
2835
+ (function() {
2836
+ if (window.__stxCraftComponentRuntime) return;
2837
+ window.__stxCraftComponentRuntime = true;
2838
+
2839
+ function parseConfig(sidebar) {
2840
+ var id = sidebar.getAttribute('data-craft-sidebar-id');
2841
+ var script = id && document.querySelector('script[data-craft-sidebar-config="' + id + '"]');
2842
+ if (!script) return null;
2843
+ try {
2844
+ return JSON.parse(script.textContent || '{}');
2845
+ } catch (error) {
2846
+ console.warn('[stx] Invalid Craft sidebar config', error);
2847
+ return null;
2848
+ }
2849
+ }
2850
+
2851
+ function getNativeUI() {
2852
+ if (!window.craft) return null;
2853
+ var hasNativeHost = window.craft.isCraft?.() ||
2854
+ !!(window.webkit?.messageHandlers?.craft || window.CraftBridge || window.craftIPC);
2855
+ if (!hasNativeHost) return null;
2856
+ return window.craft.nativeUI || window.craft.components;
2857
+ }
2858
+
2859
+ function initializeSidebar(sidebar) {
2860
+ if (sidebar.dataset.craftInitialized === 'true') return;
2861
+ if (sidebar.dataset.native === 'false') return;
2862
+
2863
+ var nativeUI = getNativeUI();
2864
+ if (!nativeUI || typeof nativeUI.createSidebar !== 'function') return;
2865
+
2866
+ var config = parseConfig(sidebar);
2867
+ if (!config) return;
2868
+
2869
+ var hasSpaces = !!(config.spaces && config.spaces.length);
2870
+ // Spaces need a host that can swipe between whole scenes. Falling back to
2871
+ // createSidebar would flatten every space into one list, which is worse
2872
+ // than the web rendering already on the page \u2014 so leave that in place.
2873
+ if (hasSpaces && typeof nativeUI.createSpacesSidebar !== 'function') return;
2874
+
2875
+ try {
2876
+ var nativeConfig = Object.assign({}, config);
2877
+ delete nativeConfig.sections;
2878
+ delete nativeConfig.spaces;
2879
+
2880
+ var nativeSidebar = hasSpaces
2881
+ ? nativeUI.createSpacesSidebar(nativeConfig)
2882
+ : nativeUI.createSidebar(nativeConfig);
2883
+
2884
+ if (nativeSidebar && hasSpaces && nativeSidebar.setSpaces) {
2885
+ nativeSidebar.setSpaces(config.spaces);
2886
+ }
2887
+ if (nativeSidebar && hasSpaces && config.selectedSpace && nativeSidebar.setActiveSpace) {
2888
+ nativeSidebar.setActiveSpace(config.selectedSpace);
2889
+ }
2890
+ if (nativeSidebar && hasSpaces && nativeSidebar.onSpaceChange) {
2891
+ nativeSidebar.onSpaceChange(function(spaceId) {
2892
+ sidebar.dispatchEvent(new CustomEvent('craft-sidebar:space', {
2893
+ bubbles: true,
2894
+ detail: { spaceId: spaceId, sidebarId: config.id }
2895
+ }));
2896
+ });
2897
+ }
2898
+ if (nativeSidebar && !hasSpaces && config.sections) {
2899
+ config.sections.forEach(function(section) {
2900
+ if (nativeSidebar.addSection) nativeSidebar.addSection(section);
2901
+ });
2902
+ }
2903
+ if (nativeSidebar && config.selectedItem && nativeSidebar.setSelectedItem) {
2904
+ nativeSidebar.setSelectedItem(config.selectedItem);
2905
+ }
2906
+ if (nativeSidebar && nativeSidebar.onSelect) {
2907
+ nativeSidebar.onSelect(function(itemId) {
2908
+ sidebar.dispatchEvent(new CustomEvent('craft-sidebar:select', {
2909
+ bubbles: true,
2910
+ detail: { itemId: itemId, sidebarId: config.id }
2911
+ }));
2912
+ });
2913
+ }
2914
+ sidebar.dataset.craftInitialized = 'true';
2915
+ sidebar.dataset.nativeActive = 'true';
2916
+ window.__stxCraftNativeSidebars = window.__stxCraftNativeSidebars || {};
2917
+ window.__stxCraftNativeSidebars[config.id] = nativeSidebar;
2918
+ } catch (error) {
2919
+ sidebar.dataset.nativeError = error.message || 'unknown';
2920
+ console.warn('[stx] Failed to create native Craft sidebar', error);
2921
+ }
2922
+ }
2923
+
2924
+ function initializeCraftComponents() {
2925
+ document.querySelectorAll('[data-craft-native-sidebar]').forEach(initializeSidebar);
2926
+ }
2927
+
2928
+ if (document.readyState === 'loading') {
2929
+ document.addEventListener('DOMContentLoaded', initializeCraftComponents);
2930
+ } else {
2931
+ initializeCraftComponents();
2932
+ }
2933
+ window.addEventListener('craft:ready', initializeCraftComponents);
2934
+ document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
2935
+ })();
2936
+ </script>
2937
+ `;return q=q.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(J,W,K)=>{return C("sidebar",W,K.trim(),U,$)}),q=q.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(J,W)=>{return C("sidebar",W,"",U,$)}),q=q.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(J,W,K)=>{return C(W,K,"",U,$)}),q=q.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(J,W,K,Y)=>{return C(W,K,Y.trim(),U,$)}),q}function C(q,U,$,J,W){let K=J.components?.[q]||b[q];if(!K)return console.warn(`[stx] Unknown Craft component: @craft-${q}`),`<div class="${W}-unknown" data-component="${q}">${$}</div>`;let Y=y(U),L=[K.fallbackClasses||`${W}-${q}`];if(Y.class)L.push(Y.class),delete Y.class;if(K.render)return Y.__fallbackClasses=L.join(" "),K.render(Y,$);let Q=Wq(Y,K,L);if(["input","hr","br","img"].includes(K.fallbackTag))return`<${K.fallbackTag} ${Q}>`;return`<${K.fallbackTag} ${Q}>${$}</${K.fallbackTag}>`}function y(q){let U={},$=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,J;while((J=$.exec(q))!==null){let[W,K,Y,L]=J,Q=Y??L;if(W.startsWith(":"))U[K]=Q;else if(W.startsWith("@"))U[`on${K.charAt(0).toUpperCase()}${K.slice(1)}`]=Q;else if(Q===void 0)U[K]=!0;else U[K]=Q}return U}function r(q,U){let $=k(String(q.id||`craft-sidebar-${$q(U||JSON.stringify(q))}`)),J=qq(q.spaces)||e(U),W=J.length?[]:Uq(q.sections)||d(U),K=String(q.selectedSpace||J[0]?.id||""),Y=J.find((E)=>E.id===K)||J[0],L=String(q.selectedItem||q.selected||(J.length?Y?.sections[0]?.items[0]?.id:W[0]?.items[0]?.id)||""),Q={id:$,variant:String(q.variant||"desktop"),material:String(q.material||"sidebar"),backgroundEffect:String(q.backgroundEffect||"shimmer"),allowsVibrancy:q.allowsVibrancy!==!1&&q.allowsVibrancy!=="false",materialOpacity:Number(q.materialOpacity??0.68),materialDarkOpacity:q.materialDarkOpacity===void 0?void 0:Number(q.materialDarkOpacity),minWidth:q.minWidth===void 0?240:Number(q.minWidth),maxWidth:q.maxWidth===void 0?340:Number(q.maxWidth),canCollapse:q.canCollapse!==!1&&q.canCollapse!=="false",searchPlaceholder:q.searchPlaceholder?String(q.searchPlaceholder):void 0,selectedItem:L,sections:W,spaces:J,selectedSpace:K||void 0},X=String(q.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),w=Number(q.width||q.sidebarWidth||286),G=q.native===!1||q.native==="false"?"false":"true",B=Q.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${O(Q.searchPlaceholder)}"></div>`:"",_;if(J.length)_=Kq(J,K,L);else if(W.length)_=W.map((E)=>g(E,L)).join("");else _=U;return`<aside class="${R(X)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${R($)}" data-native="${G}" style="--craft-sidebar-width:${w}px">
2938
+ ${B}
2939
+ ${_}
2940
+ </aside>
2941
+ <script type="application/json" data-craft-sidebar-config="${R($)}">${Jq(Q)}</script>`}function a(q,U){let $=k(String(q.id||q.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${R($)}">
2942
+ ${q.label?`<div class="craft-sidebar-space-title">${O(String(q.label))}</div>`:""}
2943
+ ${U}
2944
+ </section>`}function t(q,U){let $=String(q.header||q.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${R(String(q.id||"section"))}">
2945
+ ${$?`<div class="craft-sidebar-section-title">${O($)}</div>`:""}
2946
+ ${U}
2947
+ </section>`}function o(q,U){let $={id:String(q.id||k(String(q.label||U||"item"))),label:String(q.label||U||""),icon:q.icon?String(q.icon):void 0,badge:q.badge?String(q.badge):void 0,tintColor:q.tintColor?String(q.tintColor):void 0};return f($,String(q.selected||"")==="true")}function d(q){let U=[],$=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,J;while((J=$.exec(q))!==null){let W=y(J[1]||""),K=J[2]||"",Y=String(W.id||k(String(W.header||W.title||`section-${U.length+1}`))),L=String(W.header||W.title||Y),Q=p(K);U.push({id:Y,header:L,title:L,items:Q})}return U}function p(q){let U=[],$=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,J;while((J=$.exec(q))!==null){let W=y(J[1]||""),K=String(W.label||(J[2]||"").replace(/<[^>]*>/g,"").trim()),Y=String(W.id||k(K||`item-${U.length+1}`));U.push({id:Y,label:K,icon:W.icon?String(W.icon):void 0,badge:W.badge?String(W.badge):void 0,tintColor:W.tintColor?String(W.tintColor):void 0})}return U}function e(q){let U=[],$=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,J;while((J=$.exec(q))!==null){let W=y(J[1]||""),K=J[2]||"",Y=String(W.label||W.title||`Space ${U.length+1}`);U.push({id:String(W.id||k(Y)),label:Y,icon:W.icon?String(W.icon):void 0,tint:W.tint?String(W.tint):void 0,sections:d(K)})}return U}function qq(q){if(!q)return;if(Array.isArray(q))return q;if(typeof q!=="string")return;try{let U=JSON.parse(q);return Array.isArray(U)?U:void 0}catch{return}}function Kq(q,U,$){let J=q.map((K)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${R(K.id)}" data-selected="${K.id===U?"true":"false"}" title="${R(K.label||K.id)}">${K.icon?`<span class="craft-sidebar-item-icon" data-icon="${R(K.icon)}"></span>`:O((K.label||K.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${q.map((K)=>`<section class="craft-sidebar-space" data-space-id="${R(K.id)}" data-selected="${K.id===U?"true":"false"}">
2948
+ ${K.label?`<div class="craft-sidebar-space-title">${O(K.label)}</div>`:""}
2949
+ ${K.sections.map((Y)=>g(Y,$)).join("")}
2950
+ </section>`).join("")}</div>
2951
+ <div class="craft-sidebar-space-switcher">${J}</div>`}function Uq(q){if(!q)return;if(Array.isArray(q))return q;if(typeof q!=="string")return;try{let U=JSON.parse(q);return Array.isArray(U)?U:void 0}catch{return}}function g(q,U){let $=q.header||q.title||q.id;return`<section class="craft-sidebar-section" data-section-id="${R(q.id)}">
2952
+ <div class="craft-sidebar-section-title">${O($)}</div>
2953
+ ${q.items.map((J)=>f(J,J.id===U)).join("")}
2954
+ </section>`}function f(q,U){let $=q.tintColor?` style="--craft-sidebar-icon-color:${R(q.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${R(q.id)}" data-selected="${U?"true":"false"}">
2955
+ ${q.icon?`<span class="craft-sidebar-item-icon" data-icon="${R(q.icon)}"${$}></span>`:""}
2956
+ <span class="craft-sidebar-item-label">${O(q.label)}</span>
2957
+ ${q.badge?`<span class="craft-sidebar-item-badge">${O(q.badge)}</span>`:""}
2958
+ </button>`}function k(q){return q.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function $q(q){let U=5381;for(let $=0;$<q.length;$++)U=U*33^q.charCodeAt($);return(U>>>0).toString(36)}function O(q){return q.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function R(q){return O(q).replace(/`/g,"&#96;")}function Jq(q){return JSON.stringify(q).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function Wq(q,U,$){let J=[];J.push(`class="${$.join(" ")}"`),J.push(`data-craft="${U.nativeType}"`);for(let[W,K]of Object.entries(q))if(K===!0)J.push(W);else if(K!==!1&&K!==void 0&&K!==null){let Y=String(K).replace(/"/g,"&quot;");J.push(`${W}="${Y}"`)}return J.join(" ")}function Pq(q,U){b[q]=U}function vq(){return{...b}}async function Qq(q){let U=Date.now();try{if(!await Bun.file(q.input).exists())return{success:!1,target:q.target||I(),format:q.format||"app",error:`Input file not found: ${q.input}`};let $=q.target||I(),J=q.format||Tq($),W=q.output||Z(process.cwd(),"dist","native");if(!s(W))T(W,{recursive:!0});let K=await m(q.input,{context:q.context,options:{isDev:!1}});if(K=N(K,{debug:q.verbose}),K=u(K),!K.includes("craft-component-styles")){if(K.includes("</head>"))K=K.replace("</head>",`${h}
2959
+ </head>`)}let Y=q.name||Yq(q.input,".stx"),L=q.version||"1.0.0",Q=q.craftPath||await Mq();if(!Q)return{success:!1,target:$,format:J,error:"Craft binary not found. Please install Craft or specify craftPath."};if(q.verbose)console.log(`\uD83D\uDCE6 Building native app for ${$}...`),console.log(` Input: ${q.input}`),console.log(` Output: ${W}`),console.log(` Craft: ${Q}`);let X;switch($){case"macos":X=await Xq(K,Y,L,W,J,q,Q);break;case"windows":X=await _q(K,Y,L,W,J,q,Q);break;case"linux":X=await Eq(K,Y,L,W,J,q,Q);break;case"ios":X=await Hq(K,Y,L,W,q,Q);break;case"android":X=await Rq(K,Y,L,W,q,Q);break;default:X={success:!1,target:$,format:J,error:`Unsupported target: ${$}`}}return X.duration=Date.now()-U,X}catch($){return{success:!1,target:q.target||I(),format:q.format||"app",error:$.message,duration:Date.now()-U}}}async function Xq(q,U,$,J,W,K,Y){let L=K.bundleId||`com.stx.${U.toLowerCase().replace(/[^a-z0-9]/g,"")}`,Q=Z(J,`${U}.app`),X=Z(Q,"Contents"),w=Z(X,"MacOS"),G=Z(X,"Resources");T(w,{recursive:!0}),T(G,{recursive:!0});let B=Z(G,"index.html");await Bun.write(B,q);let _="";if(K.sidebar?.enabled&&K.sidebar?.config)_=Z(G,"sidebar-config.json"),await Bun.write(_,JSON.stringify(K.sidebar.config));let E=K.sidebar?.enabled?`--native-sidebar --sidebar-width ${K.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",H=K.menubarOnly??K.systemTray;if((K.bundleStyle||(await Gq(Y)?"executable":"launcher"))==="executable"){let V=Z(w,U);F(Y,V),A(V,493);let M={html:"index.html",title:K.window?.title||U,width:K.window?.width||1200,height:K.window?.height||800,devTools:Boolean(K.devTools)};if(H)M.menubarOnly=!0;else if(K.systemTray)M.systemTray=!0;if(K.window?.frameless)M.frameless=!0;if(K.window?.transparent)M.transparent=!0;if(K.window?.alwaysOnTop)M.alwaysOnTop=!0;if(K.window?.resizable===!1)M.resizable=!1;await Bun.write(Z(G,"craft.json"),`${JSON.stringify(M,null,2)}
2960
+ `)}else{let V=Z(w,"craft");F(Y,V),A(V,493);let M=K.sidebar?.enabled?`--native-sidebar --sidebar-width ${K.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",n=`#!/bin/bash
2961
+ set -euo pipefail
2962
+ DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
2963
+ RESOURCES="$DIR/../Resources"
2964
+ exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
2965
+ ${[`--title "${K.window?.title||U}"`,`--width ${K.window?.width||1200}`,`--height ${K.window?.height||800}`,H?"--menubar-only":K.systemTray?"--system-tray":"",K.devTools?"":"--no-devtools",K.window?.frameless?"--frameless":"",K.window?.transparent?"--transparent":"",K.window?.alwaysOnTop?"--always-on-top":"",K.window?.resizable===!1?"--no-resize":"",M].filter(Boolean).join(" \\\n ")}
2966
+ `,S=Z(w,U);await Bun.write(S,n),A(S,493)}let v=Boolean(K.icon&&await Bun.file(K.icon).exists());if(v)F(K.icon,Z(G,"AppIcon.icns"));let i={CFBundleExecutable:U,CFBundleIdentifier:L,CFBundleName:U,CFBundleDisplayName:U,CFBundleShortVersionString:$,CFBundleVersion:$,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:K.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:K.menubarOnly??Boolean(K.systemTray),...v?{CFBundleIconFile:"AppIcon"}:{},...K.category?{LSApplicationCategoryType:K.category}:{},...K.copyright?{NSHumanReadableCopyright:K.copyright}:{},...K.infoPlist||{}};if(await Bun.write(Z(X,"Info.plist"),wq(i)),W==="dmg"){let V=Z(J,`${U}-${$}.dmg`),M=await zq(Q,V,U);if(!M.success)return{success:!1,target:"macos",format:"dmg",error:M.error};return{success:!0,target:"macos",format:"dmg",outputPath:V}}return{success:!0,target:"macos",format:"app",outputPath:Q}}async function Gq(q){try{let U=Bun.spawn([q,"--version"],{stdout:"pipe",stderr:"pipe"}),[$,J]=await Promise.all([new Response(U.stdout).text(),new Response(U.stderr).text()]);await U.exited;let K=`${$}
2967
+ ${J}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!K)return!1;let[Y,L,Q]=K.slice(1).map(Number);if(Y>0||L>0)return!0;return Q>=57}catch{return!1}}function l(q){return q.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wq(q){return`<?xml version="1.0" encoding="UTF-8"?>
2968
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2969
+ <plist version="1.0">
2970
+ <dict>
2971
+ ${Object.entries(q).map(([$,J])=>{let W=typeof J==="boolean"?`<${J}/>`:typeof J==="number"?`<integer>${J}</integer>`:`<string>${l(String(J))}</string>`;return` <key>${l($)}</key>
2972
+ ${W}`}).join(`
2973
+ `)}
2974
+ </dict>
2975
+ </plist>
2976
+ `}async function _q(q,U,$,J,W,K,Y){let L=Z(J,U);T(L,{recursive:!0});let Q=Z(L,"index.html");await Bun.write(Q,q),F(Y,Z(L,"craft.exe"));let X=`@echo off
2977
+ set DIR=%~dp0
2978
+ "%DIR%craft.exe" --html-file "%DIR%index.html" ^
2979
+ --title "${K.window?.title||U}" ^
2980
+ --width ${K.window?.width||1200} ^
2981
+ --height ${K.window?.height||800} ^
2982
+ ${K.systemTray?"--system-tray":""} ^
2983
+ ${K.devTools?"":"--no-devtools"}
2984
+ `;if(await Bun.write(Z(L,`${U}.bat`),X),W==="zip"){let w=Z(J,`${U}-${$}-windows.zip`),G=await Bq(L,w);if(!G.success)return{success:!1,target:"windows",format:"zip",error:G.error};return{success:!0,target:"windows",format:"zip",outputPath:w}}return{success:!0,target:"windows",format:"app",outputPath:L}}async function Eq(q,U,$,J,W,K,Y){let L=Z(J,U);T(L,{recursive:!0});let Q=Z(L,"index.html");await Bun.write(Q,q);let X=Z(L,"craft");F(Y,X),A(X,493);let w=`#!/bin/bash
2985
+ set -euo pipefail
2986
+ DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
2987
+ exec "$DIR/craft" --html-file "$DIR/index.html" \\
2988
+ --title "${K.window?.title||U}" \\
2989
+ --width ${K.window?.width||1200} \\
2990
+ --height ${K.window?.height||800} \\
2991
+ ${K.systemTray?"--system-tray":""} \\
2992
+ ${K.devTools?"":"--no-devtools"}
2993
+ `,G=Z(L,U.toLowerCase());await Bun.write(G,w),A(G,493);let B=`[Desktop Entry]
2994
+ Type=Application
2995
+ Name=${U}
2996
+ Exec=${G}
2997
+ Terminal=false
2998
+ Categories=Utility;
2999
+ `;if(await Bun.write(Z(L,`${U.toLowerCase()}.desktop`),B),W==="deb"){let _=Z(J,`${U.toLowerCase()}_${$}_amd64.deb`),E=await Oq(L,_,U,$,K);if(!E.success)return{success:!1,target:"linux",format:"deb",error:E.error};return{success:!0,target:"linux",format:"deb",outputPath:_}}if(W==="appimage"){let _=Z(J,`${U}-${$}-x86_64.AppImage`),E=await xq(L,_,U,K);if(!E.success)return{success:!1,target:"linux",format:"appimage",error:E.error};return{success:!0,target:"linux",format:"appimage",outputPath:_}}return{success:!0,target:"linux",format:"app",outputPath:L}}async function Hq(q,U,$,J,W,K){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${U}' to create an iOS project.`}}async function Rq(q,U,$,J,W,K){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${U}' to create an Android project.`}}async function Mq(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let q=[Z(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),Z(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),Z(P(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),Z(P(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",Z(P(),".local/bin/craft"),Z(process.env.LOCALAPPDATA||"","craft","craft.exe"),Z(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let U of q)if(await Bun.file(U).exists())return U;try{let $=Zq("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
3000
+ `)[0];if($&&await Bun.file($).exists())return $}catch{}return null}function I(){switch(Lq()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function Tq(q){switch(q){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function zq(q,U,$){return new Promise((J)=>{let W=j("hdiutil",["create","-volname",$,"-srcfolder",q,"-ov","-format","UDZO",U]);W.on("close",(K)=>{if(K===0)J({success:!0});else J({success:!1,error:`hdiutil exited with code ${K}`})}),W.on("error",(K)=>{J({success:!1,error:K.message})})})}async function Bq(q,U){return new Promise(($)=>{let J=j("zip",["-r",U,"."],{cwd:q});J.on("close",(W)=>{if(W===0)$({success:!0});else $({success:!1,error:`zip exited with code ${W}`})}),J.on("error",(W)=>{$({success:!1,error:W.message})})})}async function Oq(q,U,$,J,W){return new Promise((K)=>{try{let Y=Z(c(),`stx-deb-${Date.now()}`),L=Z(Y,"DEBIAN"),Q=Z(Y,"usr","bin"),X=Z(Y,"usr","share","applications"),w=Z(Y,"usr","share",$.toLowerCase());T(L,{recursive:!0}),T(Q,{recursive:!0}),T(X,{recursive:!0}),T(w,{recursive:!0});let G=z("fs").readdirSync(q);for(let H of G)F(Z(q,H),Z(w,H));let B=`#!/bin/bash
3001
+ exec /usr/share/${$.toLowerCase()}/${$.toLowerCase()} "$@"`;z("fs").writeFileSync(Z(Q,$.toLowerCase()),B),A(Z(Q,$.toLowerCase()),493);let _=`Package: ${$.toLowerCase()}
3002
+ Version: ${J}
3003
+ Section: utils
3004
+ Priority: optional
3005
+ Architecture: amd64
3006
+ Depends: libgtk-3-0, libwebkit2gtk-4.0-37
3007
+ Maintainer: ${W.author||"Unknown"}
3008
+ Description: ${W.description||$}
3009
+ `;z("fs").writeFileSync(Z(L,"control"),_);let E=j("dpkg-deb",["--build",Y,U]);E.on("close",(H)=>{if(z("fs").rmSync(Y,{recursive:!0,force:!0}),H===0)K({success:!0});else K({success:!1,error:`dpkg-deb exited with code ${H}`})}),E.on("error",(H)=>{z("fs").rmSync(Y,{recursive:!0,force:!0}),K({success:!1,error:H.message})})}catch(Y){K({success:!1,error:Y.message})}})}async function xq(q,U,$,J){return new Promise((W)=>{try{let K=Z(c(),`stx-appimage-${Date.now()}`),Y=Z(K,`${$}.AppDir`),L=Z(Y,"usr"),Q=Z(L,"bin"),X=Z(L,"share");T(Q,{recursive:!0}),T(X,{recursive:!0});let w=Z(X,$.toLowerCase());T(w,{recursive:!0});let G=z("fs").readdirSync(q);for(let x of G)F(Z(q,x),Z(w,x));let B=`#!/bin/bash
3010
+ SELF=$(readlink -f "$0")
3011
+ HERE=\${SELF%/*}
3012
+ export PATH="\${HERE}/usr/bin:\${PATH}"
3013
+ exec "\${HERE}/usr/share/${$.toLowerCase()}/${$.toLowerCase()}" "$@"
3014
+ `;z("fs").writeFileSync(Z(Y,"AppRun"),B),A(Z(Y,"AppRun"),493);let _=`[Desktop Entry]
3015
+ Type=Application
3016
+ Name=${$}
3017
+ Exec=${$.toLowerCase()}
3018
+ Terminal=false
3019
+ Categories=Utility;
3020
+ Icon=${$.toLowerCase()}
3021
+ `;z("fs").writeFileSync(Z(Y,`${$.toLowerCase()}.desktop`),_);let E=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]);if(z("fs").writeFileSync(Z(Y,`${$.toLowerCase()}.png`),E),J.icon&&s(J.icon))F(J.icon,Z(Y,`${$.toLowerCase()}.png`));let H=j("appimagetool",[Y,U],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(x)=>{if(z("fs").rmSync(K,{recursive:!0,force:!0}),x===0)A(U,493),W({success:!0});else W({success:!1,error:`appimagetool exited with code ${x}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(x)=>{z("fs").rmSync(K,{recursive:!0,force:!0}),W({success:!1,error:`appimagetool not found: ${x.message}`})})}catch(K){W({success:!1,error:K.message})}})}function Vq(){return[I()]}function Fq(q){switch(q){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var Aq={buildNative:Qq,getAvailableTargets:Vq,getAvailableFormats:Fq,detectPlatform:I},cq=Aq;
3022
+ export{Iq as Xj,D as Yj,Cq as Zj,yq as _j,N as $j,b as ak,h as bk,bq as ck,u as dk,Pq as ek,vq as fk,Qq as gk,Vq as hk,Fq as ik,cq as jk};