@stacksjs/desktop 0.2.639 → 0.2.641
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.
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +345 -2
- package/dist/index.js +420 -76
- package/package.json +1 -1
- package/dist/chunk-tyk2bp3f.js +0 -347
package/package.json
CHANGED
package/dist/chunk-tyk2bp3f.js
DELETED
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var u=import.meta.require;function Dr(){if(typeof Notification<"u"&&Notification.permission==="granted")return!0;return!1}function jt(){return typeof window<"u"&&typeof document<"u"}async function P(){if(typeof Notification>"u")return!1;if(Notification.permission==="granted")return!0;if(Notification.permission==="denied")return!1;return await Notification.requestPermission()==="granted"}var Mt=new Map;function Tr(){return`alert-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function Br(ct){switch(ct){case"info":return"ℹ";case"success":return"✔";case"warning":return"⚠";case"error":return"✖";default:return"ℹ"}}function Rr(ct="top-right"){if(!jt())throw Error("Toast container requires browser environment");try{let lt=document.querySelector(`.stx-toast-container[data-position="${ct}"]`);if(lt)return lt}catch{}let dt=document.createElement("div");dt.className=`stx-toast-container ${ct}`,dt.dataset.position=ct;try{if(document.body)document.body.appendChild(dt)}catch{}return dt}function Lr(ct){let{options:dt}=ct,lt=Br(dt.type),ut=dt.type||"info",ft=dt.duration!==0;return`
|
|
3
|
-
<div class="stx-toast ${ut}" data-alert-id="${ct.id}" role="alert" aria-live="polite">
|
|
4
|
-
<div class="stx-toast-icon">${lt}</div>
|
|
5
|
-
<div class="stx-toast-content">
|
|
6
|
-
${dt.title?`<div class="stx-toast-title">${or(dt.title)}</div>`:""}
|
|
7
|
-
<div class="stx-toast-message">${or(dt.message)}</div>
|
|
8
|
-
</div>
|
|
9
|
-
${ft?'<button class="stx-toast-close" aria-label="Close">×</button>':""}
|
|
10
|
-
</div>
|
|
11
|
-
`}function or(ct){return ct.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qt(ct){if(ct.timeout)clearTimeout(ct.timeout);if(Mt.delete(ct.id),ct.element&&jt())ct.element.classList.add("dismissing"),setTimeout(()=>{ct.element?.remove()},200)}async function c(ct){let dt=Tr(),lt=Dr(),ut=ct.duration??5000,ft={id:dt,options:ct};if(Mt.set(dt,ft),lt&&ct.type!=="error")try{let pt=new Notification(ct.title||"Notification",{body:ct.message,icon:ct.type==="success"?"\u2713":ct.type==="warning"?"\u26A0":"\u2139",tag:dt});if(pt.onclick=()=>{if(ct.onClick)ct.onClick();pt.close()},ut>0)ft.timeout=setTimeout(()=>{pt.close(),Mt.delete(dt)},ut);return}catch{}if(jt())try{let pt=Rr(ct.position),gt=document.createElement("div");gt.innerHTML=Lr(ft);let wt=gt.firstElementChild;if(!wt){let ht=(ct.type||"info").toUpperCase();console.log(`[stx-alert] ${ht}: ${ct.title||""}`),console.log(`[stx-alert] ${ct.message}`);return}ft.element=wt;try{pt.appendChild(wt)}catch{let ht=(ct.type||"info").toUpperCase();console.log(`[stx-alert] ${ht}: ${ct.title||""}`),console.log(`[stx-alert] ${ct.message}`);return}if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>{try{wt.classList.add("visible")}catch{}});try{wt.addEventListener("click",(ht)=>{if(ht.target.classList?.contains("stx-toast-close")){qt(ft);return}if(ct.onClick)ct.onClick()})}catch{}if(ut>0)ft.timeout=setTimeout(()=>{qt(ft)},ut)}catch{let pt=(ct.type||"info").toUpperCase();console.log(`[stx-alert] ${pt}: ${ct.title||""}`),console.log(`[stx-alert] ${ct.message}`)}else{let pt=(ct.type||"info").toUpperCase();if(console.log(`[stx-alert] ${pt}: ${ct.title||""}`),console.log(`[stx-alert] ${ct.message}`),ut>0)ft.timeout=setTimeout(()=>{Mt.delete(dt)},ut)}}async function r(ct){return c({...ct,position:ct.position||"top-right"})}async function S(ct,dt=3000){return r({message:ct,type:"info",duration:dt})}async function k(ct,dt=3000){return r({message:ct,type:"success",duration:dt})}async function A(ct,dt=3000){return r({message:ct,type:"warning",duration:dt})}async function C(ct,dt=5000){return r({message:ct,type:"error",duration:dt})}async function I(ct,dt,lt="info"){return c({title:ct,message:dt,type:lt})}function T(ct){let dt=Mt.get(ct);if(dt)qt(dt)}function E(){for(let ct of Mt.values())qt(ct)}function M(){return Mt.size}var D=`
|
|
12
|
-
.stx-toast-container {
|
|
13
|
-
position: fixed;
|
|
14
|
-
z-index: 10001;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
gap: 8px;
|
|
18
|
-
max-width: 400px;
|
|
19
|
-
pointer-events: none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.stx-toast-container.top-left { top: 16px; left: 16px; }
|
|
23
|
-
.stx-toast-container.top-center { top: 16px; left: 50%; transform: translateX(-50%); }
|
|
24
|
-
.stx-toast-container.top-right { top: 16px; right: 16px; }
|
|
25
|
-
.stx-toast-container.bottom-left { bottom: 16px; left: 16px; }
|
|
26
|
-
.stx-toast-container.bottom-center { bottom: 16px; left: 50%; transform: translateX(-50%); }
|
|
27
|
-
.stx-toast-container.bottom-right { bottom: 16px; right: 16px; }
|
|
28
|
-
|
|
29
|
-
.stx-toast {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: flex-start;
|
|
32
|
-
gap: 12px;
|
|
33
|
-
padding: 12px 16px;
|
|
34
|
-
background: #fff;
|
|
35
|
-
border-radius: 8px;
|
|
36
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
37
|
-
pointer-events: auto;
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
opacity: 0;
|
|
40
|
-
transform: translateY(-10px);
|
|
41
|
-
transition: opacity 0.2s, transform 0.2s;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.stx-toast.visible {
|
|
45
|
-
opacity: 1;
|
|
46
|
-
transform: translateY(0);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.stx-toast.dismissing {
|
|
50
|
-
opacity: 0;
|
|
51
|
-
transform: translateX(100%);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@media (prefers-color-scheme: dark) {
|
|
55
|
-
.stx-toast {
|
|
56
|
-
background: #2d2d2d;
|
|
57
|
-
color: #fff;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.stx-toast-icon {
|
|
62
|
-
font-size: 20px;
|
|
63
|
-
flex-shrink: 0;
|
|
64
|
-
margin-top: 2px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.stx-toast.info .stx-toast-icon { color: #3498db; }
|
|
68
|
-
.stx-toast.success .stx-toast-icon { color: #27ae60; }
|
|
69
|
-
.stx-toast.warning .stx-toast-icon { color: #f39c12; }
|
|
70
|
-
.stx-toast.error .stx-toast-icon { color: #e74c3c; }
|
|
71
|
-
|
|
72
|
-
.stx-toast-content {
|
|
73
|
-
flex: 1;
|
|
74
|
-
min-width: 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.stx-toast-title {
|
|
78
|
-
font-weight: 600;
|
|
79
|
-
margin-bottom: 4px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.stx-toast-message {
|
|
83
|
-
color: #666;
|
|
84
|
-
font-size: 14px;
|
|
85
|
-
line-height: 1.4;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@media (prefers-color-scheme: dark) {
|
|
89
|
-
.stx-toast-message { color: #aaa; }
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.stx-toast-close {
|
|
93
|
-
background: none;
|
|
94
|
-
border: none;
|
|
95
|
-
font-size: 20px;
|
|
96
|
-
cursor: pointer;
|
|
97
|
-
opacity: 0.5;
|
|
98
|
-
padding: 0;
|
|
99
|
-
line-height: 1;
|
|
100
|
-
color: inherit;
|
|
101
|
-
transition: opacity 0.15s;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.stx-toast-close:hover {
|
|
105
|
-
opacity: 1;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* Border accent for different types */
|
|
109
|
-
.stx-toast.info { border-left: 4px solid #3498db; }
|
|
110
|
-
.stx-toast.success { border-left: 4px solid #27ae60; }
|
|
111
|
-
.stx-toast.warning { border-left: 4px solid #f39c12; }
|
|
112
|
-
.stx-toast.error { border-left: 4px solid #e74c3c; }
|
|
113
|
-
`;function Or(){return!1}function Vt(){return typeof window<"u"&&typeof document<"u"}var Dt=[];function _r(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function Fr(ct){switch(ct){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function $t(ct){if(ct==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function Nr(ct){let{options:dt}=ct,lt=Fr(dt.type),ut=dt.buttons||$t(dt.type),ft=dt.type||"info",pt="";return ut.forEach((gt,wt)=>{let ht=gt.style==="destructive"?"destructive":gt.style==="primary"?"primary":"default",yt=wt===(dt.defaultButton??ut.length-1)?"autofocus":"";pt+=`<button class="stx-modal-btn ${ht}" data-index="${wt}" ${yt}>${gt.label}</button>`}),`
|
|
114
|
-
<div class="stx-modal-overlay" data-modal-id="${ct.id}">
|
|
115
|
-
<div class="stx-modal ${ft}" role="dialog" aria-modal="true" aria-labelledby="${ct.id}-title">
|
|
116
|
-
<div class="stx-modal-icon">${lt}</div>
|
|
117
|
-
<div class="stx-modal-content">
|
|
118
|
-
${dt.title?`<h2 id="${ct.id}-title" class="stx-modal-title">${ar(dt.title)}</h2>`:""}
|
|
119
|
-
<p class="stx-modal-message">${ar(dt.message)}</p>
|
|
120
|
-
</div>
|
|
121
|
-
<div class="stx-modal-buttons">${pt}</div>
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
`}function ar(ct){return ct.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function It(ct,dt,lt=!1){let ut=Dt.indexOf(ct);if(ut>-1)Dt.splice(ut,1);if(ct.element&&Vt())ct.element.remove();let pt=(ct.options.buttons||$t(ct.options.type))[dt];if(pt?.action)pt.action();ct.resolve({buttonIndex:dt,cancelled:lt})}async function t(ct){let dt=Or(),lt=_r();return new Promise((ut)=>{let ft={id:lt,options:ct,resolve:ut};if(Dt.push(ft),dt)console.log(`[stx-modal] Showing native modal: ${ct.title||"Modal"}`),setTimeout(()=>{It(ft,ct.defaultButton??0,!1)},0);else if(Vt())try{let pt=document.createElement("div");pt.innerHTML=Nr(ft);let gt=pt.firstElementChild;if(!gt){console.log(`[stx-modal] ${ct.type?.toUpperCase()||"INFO"}: ${ct.title||"Modal"}`),console.log(`[stx-modal] ${ct.message}`),setTimeout(()=>{It(ft,ct.defaultButton??0,!1)},0);return}ft.element=gt;try{document.body.appendChild(gt)}catch{console.log(`[stx-modal] ${ct.type?.toUpperCase()||"INFO"}: ${ct.title||"Modal"}`),console.log(`[stx-modal] ${ct.message}`),setTimeout(()=>{It(ft,ct.defaultButton??0,!1)},0);return}try{gt.querySelectorAll(".stx-modal-btn").forEach((wt)=>{wt.addEventListener("click",()=>{let ht=Number.parseInt(wt.dataset.index||"0",10);It(ft,ht,!1)})})}catch{}try{gt.addEventListener("click",(wt)=>{if(wt.target===gt){let ht=ct.cancelButton??0;It(ft,ht,!0)}})}catch{}try{let wt=(ht)=>{if(ht.key==="Escape"){let yt=ct.cancelButton??0;It(ft,yt,!0),document.removeEventListener("keydown",wt)}else if(ht.key==="Enter"){let yt=ct.defaultButton??(ct.buttons||$t(ct.type)).length-1;It(ft,yt,!1),document.removeEventListener("keydown",wt)}};document.addEventListener("keydown",wt)}catch{}try{let wt=gt.querySelector(".stx-modal-btn[autofocus]");if(wt)wt.focus()}catch{}if(typeof process<"u"&&process.env.BUN_TEST)setTimeout(()=>{It(ft,ct.defaultButton??0,!1)},0)}catch{console.log(`[stx-modal] ${ct.type?.toUpperCase()||"INFO"}: ${ct.title||"Modal"}`),console.log(`[stx-modal] ${ct.message}`),setTimeout(()=>{It(ft,ct.defaultButton??0,!1)},0)}else{console.log(`[stx-modal] ${ct.type?.toUpperCase()||"INFO"}: ${ct.title||"Modal"}`),console.log(`[stx-modal] ${ct.message}`);let pt=ct.buttons||$t(ct.type);console.log(`[stx-modal] Buttons: ${pt.map((gt)=>gt.label).join(", ")}`),setTimeout(()=>{It(ft,ct.defaultButton??0,!1)},0)}})}async function p(ct,dt){return t({title:ct,message:dt,type:"info"})}async function B(ct,dt){return t({title:ct,message:dt,type:"warning"})}async function O(ct,dt){return t({title:ct,message:dt,type:"error"})}async function R(ct,dt){return t({title:ct,message:dt,type:"success"})}async function f(ct,dt){return t({title:ct,message:dt,type:"question",buttons:[{label:"No",style:"default"},{label:"Yes",style:"primary"}],defaultButton:1,cancelButton:0})}async function L(ct,dt="Confirm"){return(await f(dt,ct)).buttonIndex===1}async function _(ct,dt="Alert"){await p(dt,ct)}async function N(ct,dt="",lt="Input"){if(Vt()&&typeof window.prompt==="function")return window.prompt(ct,dt);return console.log(`[stx-modal] PROMPT: ${lt}`),console.log(`[stx-modal] ${ct}`),console.log(`[stx-modal] Default: ${dt}`),dt}function F(){return Dt.length}function W(){while(Dt.length>0){let ct=Dt[Dt.length-1];It(ct,0,!0)}}var z=`
|
|
125
|
-
.stx-modal-overlay {
|
|
126
|
-
position: fixed;
|
|
127
|
-
inset: 0;
|
|
128
|
-
background: rgba(0, 0, 0, 0.5);
|
|
129
|
-
display: flex;
|
|
130
|
-
align-items: center;
|
|
131
|
-
justify-content: center;
|
|
132
|
-
z-index: 10000;
|
|
133
|
-
animation: stx-modal-fade-in 0.15s ease-out;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@keyframes stx-modal-fade-in {
|
|
137
|
-
from { opacity: 0; }
|
|
138
|
-
to { opacity: 1; }
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.stx-modal {
|
|
142
|
-
background: #fff;
|
|
143
|
-
border-radius: 12px;
|
|
144
|
-
padding: 24px;
|
|
145
|
-
max-width: 400px;
|
|
146
|
-
width: 90%;
|
|
147
|
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
|
|
148
|
-
animation: stx-modal-slide-up 0.2s ease-out;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@keyframes stx-modal-slide-up {
|
|
152
|
-
from { transform: translateY(20px); opacity: 0; }
|
|
153
|
-
to { transform: translateY(0); opacity: 1; }
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
@media (prefers-color-scheme: dark) {
|
|
157
|
-
.stx-modal {
|
|
158
|
-
background: #2d2d2d;
|
|
159
|
-
color: #fff;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.stx-modal-icon {
|
|
164
|
-
font-size: 48px;
|
|
165
|
-
text-align: center;
|
|
166
|
-
margin-bottom: 16px;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.stx-modal.info .stx-modal-icon { color: #3498db; }
|
|
170
|
-
.stx-modal.warning .stx-modal-icon { color: #f39c12; }
|
|
171
|
-
.stx-modal.error .stx-modal-icon { color: #e74c3c; }
|
|
172
|
-
.stx-modal.success .stx-modal-icon { color: #27ae60; }
|
|
173
|
-
.stx-modal.question .stx-modal-icon { color: #9b59b6; }
|
|
174
|
-
|
|
175
|
-
.stx-modal-content {
|
|
176
|
-
text-align: center;
|
|
177
|
-
margin-bottom: 24px;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.stx-modal-title {
|
|
181
|
-
margin: 0 0 8px;
|
|
182
|
-
font-size: 20px;
|
|
183
|
-
font-weight: 600;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.stx-modal-message {
|
|
187
|
-
margin: 0;
|
|
188
|
-
color: #666;
|
|
189
|
-
line-height: 1.5;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@media (prefers-color-scheme: dark) {
|
|
193
|
-
.stx-modal-message { color: #aaa; }
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.stx-modal-buttons {
|
|
197
|
-
display: flex;
|
|
198
|
-
gap: 8px;
|
|
199
|
-
justify-content: center;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.stx-modal-btn {
|
|
203
|
-
padding: 10px 24px;
|
|
204
|
-
border-radius: 6px;
|
|
205
|
-
font-size: 14px;
|
|
206
|
-
font-weight: 500;
|
|
207
|
-
cursor: pointer;
|
|
208
|
-
border: none;
|
|
209
|
-
transition: background 0.15s, transform 0.1s;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.stx-modal-btn:hover {
|
|
213
|
-
transform: translateY(-1px);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.stx-modal-btn:active {
|
|
217
|
-
transform: translateY(0);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.stx-modal-btn.default {
|
|
221
|
-
background: #e0e0e0;
|
|
222
|
-
color: #333;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.stx-modal-btn.default:hover {
|
|
226
|
-
background: #d0d0d0;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.stx-modal-btn.primary {
|
|
230
|
-
background: #3498db;
|
|
231
|
-
color: #fff;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.stx-modal-btn.primary:hover {
|
|
235
|
-
background: #2980b9;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.stx-modal-btn.destructive {
|
|
239
|
-
background: #e74c3c;
|
|
240
|
-
color: #fff;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.stx-modal-btn.destructive:hover {
|
|
244
|
-
background: #c0392b;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@media (prefers-color-scheme: dark) {
|
|
248
|
-
.stx-modal-btn.default {
|
|
249
|
-
background: #444;
|
|
250
|
-
color: #fff;
|
|
251
|
-
}
|
|
252
|
-
.stx-modal-btn.default:hover {
|
|
253
|
-
background: #555;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
`;function sr(ct){let dt=new Set(ct.properties??[]);if(ct.canChooseDirectories)dt.add("openDirectory");if(ct.canChooseFiles)dt.add("openFile");if(ct.multiSelections)dt.add("multiSelections");if(ct.showHiddenFiles)dt.add("showHiddenFiles");if(ct.canCreateDirectories)dt.add("createDirectory");return{...ct,properties:[...dt]}}function Ur(){if(typeof window>"u")return;return window.craft?.dialog}var qr={error:"critical",warning:"warning",question:"info",info:"info",none:"info"};function $r(ct){let dt=[ct.title?ct.message:"",ct.detail??""].filter(Boolean).join(`
|
|
257
|
-
|
|
258
|
-
`);return{title:ct.title||ct.message,message:dt||void 0,style:qr[ct.type??"none"]??"info",buttons:ct.buttons}}function cr(ct,dt){if(typeof ct==="number"&&Number.isFinite(ct))return{response:ct};if(ct&&typeof ct==="object"){let ut=ct;if(typeof ut.response==="number")return{response:ut.response};if(typeof ut.buttonIndex==="number")return{response:ut.buttonIndex}}let lt=dt.buttons??["OK"];return{response:dt.cancelButton??Math.max(0,lt.length-1)}}function Yt(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function H(ct={}){if(Yt())return await window.craft.dialog.showOpenDialog(sr(ct));return new Promise((dt)=>{if(typeof document>"u"){dt({canceled:!0,filePaths:[]});return}let lt=new Set(sr(ct).properties),ut=document.createElement("input");if(ut.type="file",ut.multiple=lt.has("multiSelections"),ct.filters?.length){let ft=ct.filters.flatMap((pt)=>pt.extensions.map((gt)=>`.${gt}`));ut.accept=ft.join(",")}if(lt.has("openDirectory")&&!lt.has("openFile"))ut.webkitdirectory=!0;ut.onchange=()=>{let ft=Array.from(ut.files||[]);if(ft.length===0)dt({canceled:!0,filePaths:[]});else{let pt=ft.map((gt)=>gt.name);dt({canceled:!1,filePaths:pt})}},ut.oncancel=()=>{dt({canceled:!0,filePaths:[]})},ut.click()})}async function U(ct={}){if(Yt()){let lt=window;try{return await lt.craft.dialog.showSaveDialog(ct)}catch(ut){console.warn("[stx-dialog] Failed to show native save dialog:",ut)}}if(typeof window<"u"&&"showSaveFilePicker"in window)try{let lt=ct.filters?.map((ft)=>({description:ft.name,accept:{"*/*":ft.extensions.map((pt)=>`.${pt}`)}}));return{canceled:!1,filePath:(await window.showSaveFilePicker({suggestedName:ct.defaultPath,types:lt})).name}}catch(lt){return{canceled:!0}}console.warn("[stx-dialog] Save dialog not available, using prompt fallback");let dt=prompt("Enter filename:",ct.defaultPath||"file.txt");if(dt)return{canceled:!1,filePath:dt};return{canceled:!0}}async function n(ct){let dt=Ur();if(typeof dt?.showMessageBox==="function")try{return cr(await dt.showMessageBox(ct),ct)}catch(wt){console.warn("[stx-dialog] Failed to show native message box:",wt)}else if(typeof dt?.showAlert==="function")try{return cr(await dt.showAlert($r(ct)),ct)}catch(wt){console.warn("[stx-dialog] Failed to show native alert:",wt)}let lt=ct.buttons||["OK"],ut=ct.detail?`
|
|
259
|
-
|
|
260
|
-
${ct.detail}`:"",ft=`${ct.message}${ut}`;if(lt.length===1)return alert(ft),{response:0};let pt=ct.cancelButton??lt.length-1,gt=ct.defaultButton!==void 0&&ct.defaultButton!==pt?ct.defaultButton:lt.findIndex((wt,ht)=>ht!==pt);if(lt.length>2)console.warn(`[stx-dialog] ${lt.length} buttons requested; a browser confirm offers two. Reachable: "${lt[gt]}" and "${lt[pt]}".`);return{response:confirm(ft)?gt:pt}}async function q(ct={}){if(Yt()){let dt=window;try{return await dt.craft.dialog.showColorPicker(ct)}catch(lt){console.warn("[stx-dialog] Failed to show native color picker:",lt)}}return new Promise((dt)=>{if(typeof document>"u"){dt({canceled:!0});return}let lt=document.createElement("input");lt.type="color",lt.value=ct.color||"#000000",lt.onchange=()=>{dt({canceled:!1,color:lt.value})},lt.oncancel=()=>{dt({canceled:!0})},lt.click()})}async function V(ct,dt){await n({type:"info",title:dt||"Alert",message:ct,buttons:["OK"]})}async function j(ct,dt){return(await n({type:"question",title:dt||"Confirm",message:ct,buttons:["OK","Cancel"],defaultButton:0,cancelButton:1})).response===0}async function K(ct,dt){await n({type:"error",title:dt||"Error",message:ct,buttons:["OK"]})}async function G(ct,dt){await n({type:"warning",title:dt||"Warning",message:ct,buttons:["OK"]})}function Y(){return`
|
|
261
|
-
// STX Desktop Dialog Bridge
|
|
262
|
-
// Provides convenient wrappers around window.craft.dialog APIs
|
|
263
|
-
window.stxDialog = {
|
|
264
|
-
// File dialogs
|
|
265
|
-
showOpenDialog: (options) => window.craft?.dialog?.showOpenDialog(options),
|
|
266
|
-
showSaveDialog: (options) => window.craft?.dialog?.showSaveDialog(options),
|
|
267
|
-
|
|
268
|
-
// Message dialogs.
|
|
269
|
-
//
|
|
270
|
-
// The bridge's dialog namespace has no showMessageBox -- showAlert is the
|
|
271
|
-
// method it actually implements, and it answers with the button index. So
|
|
272
|
-
// this prefers showMessageBox when a host provides one and uses showAlert
|
|
273
|
-
// otherwise, instead of calling a method that is not there (stacksjs/stx#2040).
|
|
274
|
-
showMessageBox: async (options) => {
|
|
275
|
-
const api = window.craft?.dialog;
|
|
276
|
-
if (typeof api?.showMessageBox === 'function') {
|
|
277
|
-
const raw = await api.showMessageBox(options);
|
|
278
|
-
if (typeof raw === 'number') return { response: raw };
|
|
279
|
-
if (raw && typeof raw.response === 'number') return { response: raw.response };
|
|
280
|
-
if (raw && typeof raw.buttonIndex === 'number') return { response: raw.buttonIndex };
|
|
281
|
-
}
|
|
282
|
-
else if (typeof api?.showAlert === 'function') {
|
|
283
|
-
const index = await api.showAlert({
|
|
284
|
-
title: options.title || options.message,
|
|
285
|
-
message: options.title ? options.message : options.detail,
|
|
286
|
-
buttons: options.buttons,
|
|
287
|
-
});
|
|
288
|
-
if (typeof index === 'number') return { response: index };
|
|
289
|
-
}
|
|
290
|
-
// Unreadable: answer with cancel, never with the action button.
|
|
291
|
-
const buttons = options.buttons || ['OK'];
|
|
292
|
-
return { response: options.cancelButton ?? Math.max(0, buttons.length - 1) };
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
// Color picker
|
|
296
|
-
showColorPicker: (options) => window.craft?.dialog?.showColorPicker(options),
|
|
297
|
-
|
|
298
|
-
// Font picker
|
|
299
|
-
showFontPicker: (options) => window.craft?.dialog?.showFontPicker(options),
|
|
300
|
-
|
|
301
|
-
// Convenience functions
|
|
302
|
-
alert: async (message, title) => {
|
|
303
|
-
return window.stxDialog.showMessageBox({
|
|
304
|
-
type: 'info',
|
|
305
|
-
title: title || 'Alert',
|
|
306
|
-
message,
|
|
307
|
-
buttons: ['OK'],
|
|
308
|
-
});
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
// OK first, matching showConfirmDialog: NSAlert adds buttons right-to-left
|
|
312
|
-
// and makes the first one the default, so ['Cancel', 'OK'] built a confirm
|
|
313
|
-
// that defaulted to Cancel and put OK on the left. This wrapper still had
|
|
314
|
-
// the old order after the typed path was corrected.
|
|
315
|
-
confirm: async (message, title) => {
|
|
316
|
-
const result = await window.stxDialog.showMessageBox({
|
|
317
|
-
type: 'question',
|
|
318
|
-
title: title || 'Confirm',
|
|
319
|
-
message,
|
|
320
|
-
buttons: ['OK', 'Cancel'],
|
|
321
|
-
defaultButton: 0,
|
|
322
|
-
cancelButton: 1,
|
|
323
|
-
});
|
|
324
|
-
return result?.response === 0;
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
error: async (message, title) => {
|
|
328
|
-
return window.stxDialog.showMessageBox({
|
|
329
|
-
type: 'error',
|
|
330
|
-
title: title || 'Error',
|
|
331
|
-
message,
|
|
332
|
-
buttons: ['OK'],
|
|
333
|
-
});
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
// Check if dialog is available
|
|
337
|
-
isAvailable: () => typeof window.craft?.dialog !== 'undefined',
|
|
338
|
-
};
|
|
339
|
-
`}function dr(ct){if(typeof process>"u"||process.platform!=="darwin")throw Error("Caffeinate requires macOS");let{dlopen:dt,ptr:lt}=u("bun:ffi"),ut=dt("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation",{CFStringCreateWithCString:{args:["ptr","ptr","u32"],returns:"ptr"},CFRelease:{args:["ptr"],returns:"void"}}),ft=dt("/System/Library/Frameworks/IOKit.framework/IOKit",{IOPMAssertionCreateWithName:{args:["ptr","u32","ptr","ptr"],returns:"i32"},IOPMAssertionRelease:{args:["u32"],returns:"i32"},IOPMAssertionDeclareUserActivity:{args:["ptr","u32","ptr"],returns:"i32"}}),pt=[],gt=!1;function wt(){if(gt)return;gt=!0;for(let yt of pt)ft.symbols.IOPMAssertionRelease(yt);ft.close(),ut.close()}function ht(yt){let Pt=Buffer.from(`${yt}\x00`),xt=ut.symbols.CFStringCreateWithCString(null,lt(Pt),134217984);if(!xt)throw Error("Could not create power assertion name");return xt}try{let yt=[[ct.preventDisplaySleep??!0,"PreventUserIdleDisplaySleep"],[ct.preventIdleSleep??!0,"PreventUserIdleSystemSleep"],[ct.preventSystemSleep??!0,"PreventSystemSleep"],[ct.preventDiskSleep??!1,"PreventDiskIdle"]];for(let[Pt,xt]of yt){if(!Pt)continue;let bt=ht(ct.reason||"stx: keeping your Mac awake"),_t=ht(xt),Ft=new Uint32Array(1);try{let Rt=ft.symbols.IOPMAssertionCreateWithName(_t,255,bt,lt(Ft));if(Rt!==0)throw Error(`Could not acquire ${xt} (${Rt})`);pt.push(Ft[0])}finally{ut.symbols.CFRelease(bt),ut.symbols.CFRelease(_t)}}if(!pt.length)throw Error("At least one sleep prevention option must be enabled");if(ct.assertUserActivity??!0){let Pt=ht("stx: user activity"),xt=new Uint32Array(1);try{let bt=ft.symbols.IOPMAssertionDeclareUserActivity(Pt,0,lt(xt));if(bt!==0)throw Error(`Could not declare user activity (${bt})`);pt.push(xt[0])}finally{ut.symbols.CFRelease(Pt)}}return wt}catch(yt){throw wt(),yt}}var St=null;class lr{_release;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(ct,dt){this._release=ct,this._options={...dt},this._startedAt=new Date;let lt=dt.duration;if(lt&<>0){let ut=lt*60*1000;this._endsAt=new Date(this._startedAt.getTime()+ut),this._expireTimer=setTimeout(()=>{this.stop();for(let ft of this._expireHandlers)try{ft()}catch{}},ut)}else this._endsAt=null}get pid(){return process.pid}get startedAt(){return this._startedAt}get endsAt(){return this._endsAt}get options(){return{...this._options}}get isActive(){return!this._stopped}get remainingMs(){if(!this._endsAt)return null;let ct=this._endsAt.getTime()-Date.now();return Math.max(0,ct)}get elapsedMs(){return Date.now()-this._startedAt.getTime()}stop(){if(this._stopped)return;if(this._stopped=!0,this._expireTimer)clearTimeout(this._expireTimer),this._expireTimer=null;this._release()}onExpire(ct){this._expireHandlers.push(ct)}}function X(ct={}){if(ct.duration!==void 0&&ct.duration!==-1&&(!Number.isFinite(ct.duration)||ct.duration<=0))throw RangeError("duration must be positive minutes or -1 for indefinitely");let dt=dr(ct),lt=new lr(dt,ct);return l(),St=lt,lt}function l(ct){if(ct){if(ct.stop(),St===ct)St=null;return}if(St)St.stop();St=null}function J(){return St!==null&&St.isActive}function Q(){if(!St||!St.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let dt=St.options.duration;return{active:!0,instance:St,startedAt:St.startedAt,endsAt:St.endsAt,durationMinutes:dt&&dt>0?dt:-1}}function Z(ct){let dt=ct||St;if(!dt||!dt.isActive)return"0:00";let lt=dt.remainingMs;if(lt===null)return"\u221E";let ut=Math.ceil(lt/1000),ft=Math.floor(ut/3600),pt=Math.floor(ut%3600/60),gt=ut%60;if(ft>0)return`${ft}:${String(pt).padStart(2,"0")}:${String(gt).padStart(2,"0")}`;return`${pt}:${String(gt).padStart(2,"0")}`}function ee(ct){if(ct<=0||ct===-1)return"Indefinitely";if(ct<60)return`${ct} minutes`;if(ct===60)return"1 hour";if(ct%60===0)return`${ct/60} hours`;let dt=Math.floor(ct/60),lt=ct%60;return`${dt}h ${lt}m`}if(typeof process<"u")process.once("exit",()=>l());var kt=new Map,Hr=0,Ht=!1;function m(ct){let dt=ct.split("+").map((ut)=>ut.trim()),lt={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let ut of dt){let ft=ut.toLowerCase();switch(ft){case"cmd":case"command":case"meta":case"\u2318":lt.meta=!0;break;case"ctrl":case"control":case"\u2303":lt.ctrl=!0;break;case"shift":case"\u21E7":lt.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":lt.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")lt.meta=!0;else lt.ctrl=!0;break;default:lt.key=ft}}return lt}function te(ct){let dt=[];if(ct.ctrl)dt.push("\u2303");if(ct.alt)dt.push("\u2325");if(ct.shift)dt.push("\u21E7");if(ct.meta)dt.push("\u2318");return dt.push(ct.key.toUpperCase()),dt.join("")}function Wr(ct,dt){if(dt.meta!==ct.metaKey)return!1;if(dt.ctrl!==ct.ctrlKey)return!1;if(dt.shift!==ct.shiftKey)return!1;if(dt.alt!==ct.altKey)return!1;return ct.key.toLowerCase()===dt.key||ct.code.toLowerCase()===`key${dt.key}`}function ur(ct){for(let[,dt]of kt)if(Wr(ct,dt.parsed)){ct.preventDefault(),ct.stopPropagation();try{dt.handler()}catch{}break}}function zr(){if(Ht)return;if(typeof document>"u")return;document.addEventListener("keydown",ur,!0),Ht=!0}function Gt(){if(!Ht)return;if(typeof document>"u")return;document.removeEventListener("keydown",ur,!0),Ht=!1}async function Kr(ct,dt){if(typeof window>"u")return!1;let lt=window.craft;if(!lt?.hotkeys?.register)return!1;try{return await lt.hotkeys.register(ct,dt),!0}catch{return!1}}async function Xt(ct){if(typeof window>"u")return;let dt=window.craft;if(!dt?.hotkeys?.unregister)return;try{await dt.hotkeys.unregister(ct)}catch{}}function re(ct,dt){let lt=`hotkey_${++Hr}_${Date.now()}`,ut=m(ct);kt.set(lt,{shortcut:ct,handler:dt,parsed:ut}),Kr(lt,ct),zr();let ft={shortcut:ct,id:lt,unregister(){g(ft)}};return ft}function g(ct){if(kt.delete(ct.id),Xt(ct.id),kt.size===0)Gt()}function ne(){for(let[ct]of kt)Xt(ct);kt.clear(),Gt()}function oe(){return Array.from(kt.entries()).map(([ct,dt])=>({shortcut:dt.shortcut,id:ct,unregister(){if(kt.delete(ct),Xt(ct),kt.size===0)Gt()}}))}class fr{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(ct){if(this._duration=ct.duration,this._tickInterval=ct.tickInterval||1000,this._remaining=ct.duration,ct.onComplete)this._completionHandlers.add(ct.onComplete);if(ct.onTick)this._tickHandlers.add(ct.onTick);if(ct.autoStart)this.start()}get isRunning(){return this._running&&!this._paused}get isPaused(){return this._paused}get isComplete(){return this._complete}get remaining(){if(this._running&&!this._paused){let ct=Date.now()-this._lastTick;return Math.max(0,this._remaining-ct)}return Math.max(0,this._remaining)}get elapsed(){return this._duration-this.remaining}get duration(){return this._duration}get progress(){if(this._duration===0)return 1;return Math.min(1,this.elapsed/this._duration)}start(){if(this._running)return;this._running=!0,this._paused=!1,this._complete=!1,this._lastTick=Date.now(),this._startInterval()}stop(){this._clearInterval(),this._running=!1,this._paused=!1,this._remaining=this._duration}pause(){if(!this._running||this._paused)return;let ct=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-ct),this._clearInterval(),this._paused=!0}resume(){if(!this._paused)return;this._paused=!1,this._lastTick=Date.now(),this._startInterval()}reset(){this._clearInterval(),this._running=!1,this._paused=!1,this._complete=!1,this._remaining=this._duration}onComplete(ct){return this._completionHandlers.add(ct),()=>{this._completionHandlers.delete(ct)}}onTick(ct){return this._tickHandlers.add(ct),()=>{this._tickHandlers.delete(ct)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let ct=Date.now(),dt=ct-this._lastTick;this._lastTick=ct,this._remaining=Math.max(0,this._remaining-dt);for(let lt of this._tickHandlers)try{lt(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let lt of this._completionHandlers)try{lt()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class pr{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(ct){if(this._interval=ct.interval,this._handler=ct.handler,this._immediate=ct.immediate!==!1,this._immediate)this.start()}get isRunning(){return this._running}start(){if(this._running)return;this._running=!0,this._intervalId=setInterval(()=>{try{this._handler()}catch{}},this._interval)}stop(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null;this._running=!1}}function ie(ct){return new fr(ct)}function ae(ct){return new pr(ct)}function se(ct){return new Promise((dt)=>setTimeout(dt,ct))}function ce(ct){let dt=Math.ceil(ct/1000),lt=Math.floor(dt/3600),ut=Math.floor(dt%3600/60),ft=dt%60;if(lt>0)return`${lt}:${String(ut).padStart(2,"0")}:${String(ft).padStart(2,"0")}`;return`${ut}:${String(ft).padStart(2,"0")}`}function le(ct){let dt=Math.ceil(ct/1000),lt=Math.floor(dt/3600),ut=Math.floor(dt%3600/60),ft=dt%60;if(lt>0){if(ut>0)return`${lt}h ${ut}m`;return`${lt}h`}if(ut>0){if(ft>0)return`${ut}m ${ft}s`;return`${ut}m`}return`${ft}s`}function e(ct){if(typeof window>"u")return!1;let dt=window.craft;return!!(dt&&dt[ct])}function vt(ct){if(!e(ct))throw Error(`craft.${ct} is not available \u2014 this API requires a Craft native window`);return window.craft[ct]}function mt(ct,dt){if(typeof window>"u")return()=>{};let lt=(ut)=>dt(ut.detail??{});return window.addEventListener(ct,lt),()=>window.removeEventListener(ct,lt)}var de={async writeText(ct){if(e("clipboard")){await window.craft.clipboard.writeText(ct);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(ct)},async readText(){if(e("clipboard")){let ct=await window.craft.clipboard.readText();return typeof ct==="string"?ct:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(ct){if(e("clipboard")){await window.craft.clipboard.writeHTML(ct);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let dt=new window.ClipboardItem({"text/html":new Blob([ct],{type:"text/html"}),"text/plain":new Blob([jr(ct)],{type:"text/plain"})});await navigator.clipboard.write([dt])}catch{}},async readHTML(){if(e("clipboard")){let ct=await window.craft.clipboard.readHTML();return typeof ct==="string"?ct:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let ct=await navigator.clipboard.read();for(let dt of ct)if(dt.types.includes("text/html"))return await(await dt.getType("text/html")).text()}catch{}return""},async clear(){if(e("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(e("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(e("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(e("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function jr(ct){return ct.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
340
|
-
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
341
|
-
|
|
342
|
-
`).trim()}var ue={async show(ct){if(!ct.title)throw Error("notification title is required");if(e("notifications")){await window.craft.notifications.show(ct);return}if(typeof window<"u"&&"Notification"in window){let dt=window.Notification;if(dt.permission==="granted")new dt(ct.title,{body:ct.body,icon:ct.icon});else if(dt.permission==="default"){if(await dt.requestPermission()==="granted")new dt(ct.title,{body:ct.body,icon:ct.icon})}}},async schedule(ct){if(e("notifications")){let ut={...ct};if(ut.triggerAt instanceof Date)ut.triggerAt=ut.triggerAt.toISOString();await window.craft.notifications.schedule(ut);return}let dt=Vr(ct.triggerAt),lt=Math.max(0,dt-Date.now());setTimeout(()=>{this.show(ct).catch(()=>{})},lt)},async cancel(ct){if(e("notifications"))await window.craft.notifications.cancel(ct)},async cancelAll(){if(e("notifications"))await window.craft.notifications.cancelAll()},async setBadge(ct){let dt=Math.max(0,Math.round(Number.isFinite(ct)?ct:0));if(e("notifications")){await window.craft.notifications.setBadge(dt);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(dt)}catch{}},async clearBadge(){if(e("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(e("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let ct=window.Notification;if(ct.permission==="granted")return!0;if(ct.permission==="denied")return!1;return await ct.requestPermission()==="granted"}return!1},async registerCategories(ct){if(!Array.isArray(ct)||ct.length===0)return;if(e("notifications")){let dt=window.craft.notifications.registerCategories;if(typeof dt==="function")await dt(ct)}},onActionClicked(ct){return mt("craft:notification:actionClicked",ct)},onReply(ct){return mt("craft:notification:reply",ct)}};function Vr(ct){if(ct==null)return Date.now();if(ct instanceof Date)return ct.getTime();if(typeof ct==="number")return ct;let dt=Date.parse(ct);return Number.isNaN(dt)?Date.now():dt}var pe={async readFile(ct){let dt=await vt("fs").readFile(ct);return dt&&dt.data||""},async readBuffer(ct){let dt=await vt("fs").readFile(ct),lt=dt&&dt.data||"";if(dt&&dt.base64===!0)return Gr(lt);return new TextEncoder().encode(lt)},async writeFile(ct,dt){await vt("fs").writeFile(ct,dt)},async writeBuffer(ct,dt){let lt=Yr(dt),ut=vt("fs");if(typeof ut.writeFileBytes==="function")await ut.writeFileBytes(ct,lt);else await ut.writeFile(ct,lt)},async copy(ct,dt){if(ct===dt)throw Error("fs.copy: source and destination must differ");await vt("fs").copy(ct,dt)},async move(ct,dt){if(ct===dt)throw Error("fs.move: source and destination must differ");await vt("fs").move(ct,dt)},async appendFile(ct,dt){await vt("fs").appendFile(ct,dt)},async deleteFile(ct){await vt("fs").deleteFile(ct)},async exists(ct){return await vt("fs").exists(ct)},async stat(ct){return Xr(await vt("fs").stat(ct))},async readDir(ct){let dt=await vt("fs").readDir(ct),lt=dt&&dt.entries||[],ut=ct.endsWith("/")?ct.slice(0,-1):ct;return lt.map((ft)=>({name:ft.name,path:`${ut}/${ft.name}`,isDirectory:!!ft.isDirectory}))},async mkdir(ct,dt){await vt("fs").mkdir(ct,dt)},async rmdir(ct,dt){await vt("fs").rmdir(ct,dt)},async watch(ct,dt){await vt("fs").watch(ct,dt)},async unwatch(ct){await vt("fs").unwatch(ct)},onChange(ct){return mt("craft:fs:change",ct)},async watchTree(ct,dt,lt){let ut=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,ft=vt("fs");await ft.watch(ct,ut,{recursive:!!dt.recursive});let pt=dt.kinds&&dt.kinds.length>0?new Set(dt.kinds):null,gt=Math.max(0,Math.floor(dt.coalesceMs??0)),wt=[],ht=null,yt=!1,Pt=()=>{if(ht=null,wt.length===0)return;let bt=wt;wt=[];try{lt(bt)}catch{}},xt=mt("craft:fs:change",(bt)=>{if(yt)return;if(bt.id!==ut)return;if(pt&&bt.kind&&!pt.has(bt.kind))return;if(wt.push(bt),gt===0){Pt();return}if(ht==null)ht=setTimeout(Pt,gt)});return{id:ut,async stop(){if(yt)return;if(yt=!0,xt(),ht)clearTimeout(ht),ht=null;if(wt.length>0)Pt();try{await ft.unwatch(ut)}catch{}}}},async homeDir(){return await vt("fs").homeDir()},async tempDir(){return await vt("fs").tempDir()},async appDataDir(){return await vt("fs").appDataDir()}};function Yr(ct){let dt="";for(let lt=0;lt<ct.length;lt++)dt+=String.fromCharCode(ct[lt]);return typeof btoa==="function"?btoa(dt):Buffer.from(ct).toString("base64")}function Gr(ct){let dt=typeof atob==="function"?atob(ct):Buffer.from(ct,"base64").toString("binary"),lt=new Uint8Array(dt.length);for(let ut=0;ut<dt.length;ut++)lt[ut]=dt.charCodeAt(ut);return lt}function Xr(ct){return{isFile:!!ct.isFile,isDirectory:!!ct.isDirectory,isSymlink:!!ct.isSymlink,size:Number(ct.size)||0,modifiedAt:ct.modifiedAt!=null?ct.modifiedAt<1000000000000?ct.modifiedAt*1000:ct.modifiedAt:0}}var Lt=new Set,mr=!1;function Jr(){if(mr)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(ct)=>{let dt=ct.detail;if(dt?.id)Lt.delete(dt.id)}),mr=!0}var Qr=new Set(["javascript:","data:","file:","vbscript:"]),fe={async openExternal(ct){let dt=ct.trim().toLowerCase();for(let lt of Qr)if(dt.startsWith(lt))throw Error(`shell.openExternal: ${lt} URLs are blocked for safety`);if(e("shell")){await window.craft.shell.openExternal(ct);return}if(typeof window<"u"&&typeof window.open==="function")window.open(ct,"_blank","noopener,noreferrer")},async openPath(ct){await vt("shell").openPath(ct)},async showInFinder(ct){await vt("shell").showInFinder(ct)},async spawn(ct,dt,lt=[],ut={}){if(Jr(),!ct||typeof ct!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!dt||typeof dt!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(lt))throw Error("shell.spawn: args must be an array");for(let ft of lt)if(typeof ft!=="string")throw Error("shell.spawn: args entries must be strings");if(Lt.has(ct))throw Error(`shell.spawn: id "${ct}" is already in use \u2014 call kill(id) first or pick a different id`);Lt.add(ct);try{await vt("shell").spawn(ct,dt,lt,ut)}catch(ft){throw Lt.delete(ct),ft}},async kill(ct){await vt("shell").kill(ct),Lt.delete(ct)},async getEnv(ct){if(e("shell")){let dt=await window.craft.shell.getEnv(ct);return dt==null?void 0:String(dt)}return},async setEnv(ct,dt){await vt("shell").setEnv(ct,dt)},onStdout(ct){return mt("craft:shell:stdout",ct)},onStderr(ct){return mt("craft:shell:stderr",ct)},onExit(ct){return mt("craft:shell:exit",ct)}};function Tt(){return window.craft.shortcuts}var me={async register(ct,dt,lt){if(!e("shortcuts"))return;await Tt().register(ct,dt,lt)},async unregister(ct){if(!e("shortcuts"))return;await Tt().unregister(ct)},async unregisterAll(){if(!e("shortcuts"))return;await Tt().unregisterAll()},async enable(ct){if(!e("shortcuts"))return;await Tt().enable(ct)},async disable(ct){if(!e("shortcuts"))return;await Tt().disable(ct)},async isRegistered(ct){if(!e("shortcuts"))return!1;return await Tt().isRegistered(ct)},async list(){if(!e("shortcuts"))return[];return await Tt().list()},on(ct){return mt("craft:shortcut",ct)}};var ge={get(){if(e("theme"))try{return window.craft.theme.get()}catch{}return{appearance:Zr()}},onChange(ct){if(ct(this.get()),e("theme"))return mt("craft:theme",ct);if(typeof window<"u"&&window.matchMedia){let dt=window.matchMedia("(prefers-color-scheme: dark)"),lt=()=>ct({appearance:dt.matches?"dark":"light"});return dt.addEventListener("change",lt),()=>dt.removeEventListener("change",lt)}return()=>{}},async current(){return this.get()}};function Zr(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function he(ct,dt={}){if(!e("dragOut"))throw Error("dragOut requires a Craft native window");let lt=Array.isArray(ct)?ct:[ct];if(lt.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(lt,dt)}function we(){return e("dragOut")}var be={onUrl(ct){if(!e("deepLink"))return()=>{};return mt("craft:deepLink",ct)},getInitialUrl(){if(typeof window>"u")return null;if(e("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let ct=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return ct},isAvailable(){return e("deepLink")}};var xe={async isCharging(){if(e("power"))return await window.craft.power.isCharging();let ct=await Wt();return ct?!!ct.charging:!1},async isPluggedIn(){if(e("power"))return await window.craft.power.isPluggedIn();let ct=await Wt();return ct?!!ct.charging||ct.level>=0.999:!1},async isLowPowerMode(){if(e("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(e("power")){let dt=await window.craft.power.batteryLevel();return typeof dt==="number"?dt:null}let ct=await Wt();return ct?ct.level:null},async timeRemaining(){if(e("power")){let lt=await window.craft.power.timeRemaining();return typeof lt==="number"?lt:null}let ct=await Wt();if(!ct)return null;let dt=ct.charging?ct.chargingTime:ct.dischargingTime;return Number.isFinite(dt)?Math.round(dt/60):null},async thermalState(){if(e("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(e("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(ct="app is busy"){if(e("power")){await window.craft.power.preventSleep(ct);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let dt=window;if(dt.__craftWebWakeLock?.release){try{await dt.__craftWebWakeLock.release()}catch{}dt.__craftWebWakeLock=null}try{let lt=await navigator.wakeLock.request("screen");dt.__craftWebWakeLock=lt}catch{}},async allowSleep(){if(e("power")){await window.craft.power.allowSleep();return}let ct=window.__craftWebWakeLock;if(ct&&typeof ct.release==="function"){try{await ct.release()}catch{}window.__craftWebWakeLock=null}},onSleep(ct){return mt("craft:powerSleep",ct)},onWake(ct){return mt("craft:powerWake",ct)}};async function Wt(){if(typeof navigator>"u")return null;let ct=navigator;if(typeof ct.getBattery!=="function")return null;try{return await ct.getBattery()}catch{return null}}var ye={async connectionType(){if(e("network"))return await window.craft.network.connectionType();return gr()},async wifiSSID(){if(e("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(e("network")){let ct=await window.craft.network.wifiSignalStrength();return typeof ct==="number"?ct:void 0}return},async ipAddress(){if(e("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(e("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(e("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(e("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(e("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(e("network"))await window.craft.network.openPreferences()},onChange(ct){if(e("network"))return mt("craft:networkChange",ct);if(typeof window>"u")return()=>{};let dt=()=>ct({type:gr(),online:!0}),lt=()=>ct({type:"none",online:!1});return window.addEventListener("online",dt),window.addEventListener("offline",lt),()=>{window.removeEventListener("online",dt),window.removeEventListener("offline",lt)}}};function gr(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let ct=navigator.connection;if(!ct)return"unknown";let dt=String(ct.type||ct.effectiveType||"unknown").toLowerCase();if(dt==="wifi"||dt==="cellular"||dt==="ethernet"||dt==="bluetooth"||dt==="none")return dt;return"unknown"}var ve={async checkForUpdates(){if(!e("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!e("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(ct){if(!e("updater"))return;await window.craft.updater.setAutomaticChecks(ct)},async setCheckInterval(ct){if(!e("updater"))return;if(!Number.isFinite(ct))throw Error("setCheckInterval: must be a finite number");let dt=ct<=0?0:Math.max(60,Math.round(ct));await window.craft.updater.setCheckInterval(dt)},async setFeedURL(ct){if(!e("updater"))return;await window.craft.updater.setFeedURL(ct)},async getLastUpdateCheckDate(){if(!e("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!e("updater"))return null;let ct=await window.craft.updater.getUpdateInfo();if(!ct||typeof ct.version!=="string"||ct.version.length===0)return null;return ct},onAvailable(ct){return mt("craft:updateAvailable",ct)},onDownloaded(ct){return mt("craft:updateDownloaded",ct)},async verifySignature({payload:ct,signatureB64:dt,publicKeyB64:lt}){let ut=wr(ct),ft;try{ft=await crypto.subtle.importKey("raw",zt(lt),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",ft,zt(dt),ut)}catch{return!1}},async verifyDownload({url:ct,signatureB64:dt,publicKeyB64:lt,fetchInit:ut}){let ft;try{ft=await fetch(ct,ut)}catch{return{ok:!1,reason:"fetch-failed"}}if(!ft.ok)return{ok:!1,reason:"http-error",status:ft.status};let pt=new Uint8Array(await ft.arrayBuffer()),gt;try{gt=await crypto.subtle.importKey("raw",zt(lt),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let wt=!1;try{wt=await crypto.subtle.verify("Ed25519",gt,zt(dt),wr(pt))}catch{wt=!1}if(!wt)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:pt}}};function wr(ct){if(ct instanceof ArrayBuffer)return new Uint8Array(ct);let dt=new ArrayBuffer(ct.byteLength),lt=new Uint8Array(dt);return lt.set(ct),lt}function zt(ct){if(typeof atob==="function"){let ut=atob(ct),ft=new ArrayBuffer(ut.length),pt=new Uint8Array(ft);for(let gt=0;gt<ut.length;gt++)pt[gt]=ut.charCodeAt(gt);return pt}let dt=Buffer.from(ct,"base64"),lt=new ArrayBuffer(dt.length);return new Uint8Array(lt).set(dt),new Uint8Array(lt)}var Pe={onFocus(ct){if(e("window"))return mt("craft:window:focus",()=>ct());return Jt("focus",ct)},onBlur(ct){if(e("window"))return mt("craft:window:blur",()=>ct());return Jt("blur",ct)},onResize(ct){if(e("window"))return mt("craft:window:resize",ct);if(typeof window>"u")return()=>{};let dt=()=>ct({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",dt),()=>window.removeEventListener("resize",dt)},onMove(ct){if(e("window"))return mt("craft:window:move",ct);return()=>{}},onClose(ct){if(e("window"))return mt("craft:window:close",()=>ct());return Jt("beforeunload",ct)},onMinimize(ct){if(e("window"))return mt("craft:window:minimize",()=>ct());if(typeof document>"u")return()=>{};let dt=()=>{if(document.visibilityState==="hidden")ct()};return document.addEventListener("visibilitychange",dt),()=>document.removeEventListener("visibilitychange",dt)},onRestore(ct){if(e("window"))return mt("craft:window:restore",()=>ct());if(typeof document>"u")return()=>{};let dt=()=>{if(document.visibilityState==="visible")ct()};return document.addEventListener("visibilitychange",dt),()=>document.removeEventListener("visibilitychange",dt)}};function Jt(ct,dt){if(typeof window>"u")return()=>{};let lt=()=>dt();return window.addEventListener(ct,lt),()=>window.removeEventListener(ct,lt)}var hr={name:"",version:"0.0.0"},Se={async hideDockIcon(){if(e("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(e("app"))await window.craft.app.showDockIcon()},async quit(){if(e("app"))await window.craft.app.quit()},async getInfo(){if(!e("app"))return hr;let ct=await window.craft.app.getInfo();return{...hr,...ct||{}}},async notify(ct){if(!ct.title)throw Error("notify: title is required");if(e("app"))await window.craft.app.notify(ct)},async setBadge(ct){if(e("app"))await window.craft.app.setBadge(ct)},async bounce(ct="informational"){if(e("app"))await window.craft.app.bounce(ct)}};var ke={app(ct,dt={}){return{label:ct,items:[{label:`About ${ct}`,role:"about"},{separator:!0},...dt.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:dt.settings},{separator:!0}]:[],{label:`Hide ${ct}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${ct}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(ct,dt={}){return[this.app(ct,dt),this.edit()]}},en=0;function tn(ct){let dt=new Map;return{payload:{menus:ct.menus.map((ut)=>({label:ut.label,items:ut.items.map((ft)=>{let{onClick:pt,...gt}=ft;if(gt.separator)return gt;let wt=gt.id??`stx.menu.${en++}`;if(pt)dt.set(wt,pt);return{...gt,id:wt}})}))},handlers:dt}}var Qt=null,Ae={async set(ct){if(!e("menu"))return!1;let{payload:dt,handlers:lt}=tn(ct);if(Qt?.(),Qt=null,lt.size>0)Qt=mt("craft:menu:action",(ut)=>{lt.get(ut.id)?.()});return await window.craft.menu.set(dt),!0},async setDock(ct){if(e("menu"))await window.craft.menu.setDock(ct)},async addItem(ct,dt){if(e("menu"))await window.craft.menu.addItem(ct,dt)},async removeItem(ct){if(e("menu"))await window.craft.menu.removeItem(ct)},async enableItem(ct){if(e("menu"))await window.craft.menu.enableItem(ct)},async disableItem(ct){if(e("menu"))await window.craft.menu.disableItem(ct)},async checkItem(ct){if(e("menu"))await window.craft.menu.checkItem(ct)},async uncheckItem(ct){if(e("menu"))await window.craft.menu.uncheckItem(ct)},async setItemLabel(ct,dt){if(e("menu"))await window.craft.menu.setItemLabel(ct,dt)},async clearDock(){if(e("menu"))await window.craft.menu.clearDock()},onAction(ct){return mt("craft:menu:action",ct)}};function yr(ct){if(ct.separator)return{id:ct.id||"",title:"",type:"separator"};return{id:ct.id||"",title:ct.title||"",icon:ct.icon,shortcut:ct.shortcut,enabled:ct.disabled?!1:void 0,checked:ct.checked?!0:void 0,type:ct.submenu?"submenu":void 0,submenu:ct.submenu?.map(yr)}}async function vr(ct){if(!ct.items||ct.items.length===0)throw Error("contextMenu.show requires at least one item");if(!e("nativeUI"))return null;let dt=window.craft?.nativeUI;if(!dt)return null;let lt=await dt.showContextMenu({targetId:ct.targetId||"",targetType:"general",x:Math.round(ct.x),y:Math.round(ct.y),items:ct.items.map(yr)});return{id:typeof lt?.id==="string"?lt.id:null,targetId:lt?.targetId}}var Ce={available(){return e("nativeUI")},async show(ct){return await vr(ct)!==null},async pick(ct){return(await vr(ct))?.id??null},onAction(ct){return mt("craft:contextmenu:action",(dt)=>{if(typeof dt.id==="string")ct({id:dt.id,targetId:dt.targetId??""})})}};function Zt(ct){if(ct===null||ct===void 0||ct===0)return"";return String(ct)}function br(ct){return ct.map((dt)=>({id:dt.id,header:dt.header,items:dt.items.map((lt)=>({id:lt.id,label:lt.label,icon:lt.icon,badge:Zt(lt.badge)||void 0}))}))}function xr(ct){return JSON.stringify(ct.map((dt)=>[dt.id,dt.header??"",dt.items.map((lt)=>[lt.id,lt.label,lt.icon??""])]))}function Pr(ct){return new Map(ct.flatMap((dt)=>dt.items.map((lt)=>[lt.id,Zt(lt.badge)])))}var h={available(){return e("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(ct){if(!h.available())return null;let dt=window.craft?.nativeUI;if(!dt)return null;let lt=dt.createSidebar({id:ct.id,sections:br(ct.sections),selected:ct.selected}),ut=ct.sections,ft=new Set;return lt.onSelect((pt)=>{for(let gt of[...ft])gt(pt)}),{id:lt.id,update(pt){if(xr(pt)===xr(ut)){let gt=Pr(ut);for(let[wt,ht]of Pr(pt))if(gt.get(wt)!==ht)lt.updateItem(wt,{badge:ht})}else lt.setSections(br(pt));ut=pt},updateItem(pt,gt){lt.updateItem(pt,{...gt.label!==void 0?{label:gt.label}:{},...gt.icon!==void 0?{icon:gt.icon}:{},..."badge"in gt?{badge:Zt(gt.badge)}:{}}),ut=ut.map((wt)=>({...wt,items:wt.items.map((ht)=>ht.id===pt?{...ht,...gt}:ht)}))},select(pt){lt.setSelectedItem(pt)},onSelect(pt){return ft.add(pt),()=>ft.delete(pt)},destroy(){ft.clear(),lt.destroy()}}}};var Ie={async getDisplays(){if(e("screen"))return await window.craft.screen.getDisplays();return Sr()},async getPrimary(){if(e("screen")){let ct=await window.craft.screen.getPrimary();return ct&&typeof ct.width==="number"?ct:null}return Sr()[0]??null},onChange(ct){if(e("screen"))return mt("craft:screen:change",()=>ct());if(typeof window>"u")return()=>{};let dt=()=>ct();return window.addEventListener("resize",dt),()=>window.removeEventListener("resize",dt)}};function Sr(){if(typeof window>"u"||!window.screen)return[];let ct=window.screen;return[{id:0,x:ct.left??0,y:ct.top??0,width:ct.width||0,height:ct.height||0,workX:ct.availLeft??0,workY:ct.availTop??0,workWidth:ct.availWidth??ct.width??0,workHeight:ct.availHeight??ct.height??0,scaleFactor:window.devicePixelRatio||1}]}var $e={async set(ct,dt,lt){if(!ct)throw Error("keychain.set: service is required");if(!dt)throw Error("keychain.set: account is required");await vt("keychain").set(ct,dt,lt)},async get(ct,dt){if(!ct)throw Error("keychain.get: service is required");if(!dt)throw Error("keychain.get: account is required");let lt=await vt("keychain").get(ct,dt);return typeof lt==="string"?lt:null},async delete(ct,dt){if(!ct)throw Error("keychain.delete: service is required");if(!dt)throw Error("keychain.delete: account is required");await vt("keychain").delete(ct,dt)},async has(ct,dt){if(!ct)throw Error("keychain.has: service is required");if(!dt)throw Error("keychain.has: account is required");return await vt("keychain").has(ct,dt)}};var Te={async check(ct){if(e("permissions"))return await window.craft.permissions.check(ct);return await Ar(ct)},async request(ct){if(e("permissions"))return await window.craft.permissions.request(ct);return await rn(ct)},async openSettings(ct){if(e("permissions"))await window.craft.permissions.openSettings(ct)}};async function Ar(ct){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let dt=await navigator.permissions.query({name:ct});return nn(dt.state)}catch{return"not-supported"}}async function rn(ct){if(ct==="notifications"&&typeof window<"u"&&"Notification"in window){let dt=await window.Notification.requestPermission();return dt==="granted"?"granted":dt==="denied"?"denied":"undetermined"}return await Ar(ct)}function nn(ct){if(ct==="granted")return"granted";if(ct==="denied")return"denied";if(ct==="prompt")return"undetermined";return"undetermined"}var Ee={async print(){if(e("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(ct){if(!ct)throw Error("printToPDF: path is required");let dt=ct.startsWith("/"),lt=/^[a-zA-Z]:[\\/]/.test(ct)||ct.startsWith("\\\\");if(!dt&&!lt)throw Error("printToPDF: path must be absolute");let ut=await vt("printing").printToPDF(ct);return{ok:!!(ut&&ut.ok),path:ut?.path}}};var Me={async enable(){if(!e("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!e("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!e("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};function er(){if(!e("window"))return null;return window.craft.window}function Et(ct){let dt=er();if(!dt)return Promise.resolve();try{return Promise.resolve(ct(dt)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var De={get available(){return er()!==null},open(ct){let dt=()=>{if(typeof window<"u"&&ct.url)window.open(ct.url,ct.name);return{name:ct.name}},lt=er();if(!lt?.open)return Promise.resolve(dt());return lt.open(ct).then((ut)=>({name:ut?.name||ct.name})).catch(dt)},close:()=>Et((ct)=>ct.close?.()),focus:()=>Et((ct)=>ct.focus?.()),minimize:()=>Et((ct)=>ct.minimize?.()),maximize:()=>Et((ct)=>ct.maximize?.()),center:()=>Et((ct)=>ct.center?.()),startDrag:()=>Et((ct)=>ct.startDrag?.()),setTitle:(ct)=>Et((dt)=>dt.setTitle?.(ct)),setSize:(ct,dt)=>Et((lt)=>lt.setSize?.(ct,dt)),setAppearance:(ct)=>Et((dt)=>dt.setAppearance?.(ct))};var Be={async addItem(ct){if(e("touchbar"))await window.craft.touchbar.addItem(ct)},async removeItem(ct){if(e("touchbar"))await window.craft.touchbar.removeItem(ct)},async updateItem(ct,dt){if(e("touchbar"))await window.craft.touchbar.updateItem(ct,dt)},async setLabel(ct,dt){if(e("touchbar"))await window.craft.touchbar.setLabel(ct,dt)},async setIcon(ct,dt){if(e("touchbar"))await window.craft.touchbar.setIcon(ct,dt)},async setEnabled(ct,dt){if(e("touchbar"))await window.craft.touchbar.setEnabled(ct,dt)},async setSliderValue(ct,dt){if(e("touchbar"))await window.craft.touchbar.setSliderValue(ct,dt)},async clear(){if(e("touchbar"))await window.craft.touchbar.clear()},async show(){if(e("touchbar"))await window.craft.touchbar.show()},async hide(){if(e("touchbar"))await window.craft.touchbar.hide()},onAction(ct){return mt("craft:touchbar:action",ct)}};var on=/^[\da-f]*$/i;function an(ct,dt){if(typeof dt!=="string"||!on.test(dt)||dt.length%2!==0)throw Error(`${ct}: must be a hex string with even length, got ${JSON.stringify(dt)}`)}var Oe={async isEnabled(){return e("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return e("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return e("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return e("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(e("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(e("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return e("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(ct){if(e("bluetooth"))await window.craft.bluetooth.connect(ct)},async disconnect(ct){if(e("bluetooth"))await window.craft.bluetooth.disconnect(ct)},async openPreferences(){if(e("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(ct){if(!ct)throw Error("bluetooth.discoverServices: deviceId is required");if(!e("bluetooth"))return[];let dt=await window.craft.bluetooth.discoverServices(ct);return Array.isArray(dt)?dt:[]},async discoverCharacteristics(ct,dt){if(!ct||!dt)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!e("bluetooth"))return[];let lt=await window.craft.bluetooth.discoverCharacteristics(ct,dt);return Array.isArray(lt)?lt:[]},async readCharacteristic(ct,dt,lt){if(!ct||!dt||!lt)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!e("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(ct,dt,lt)},async writeCharacteristic(ct,dt,lt,ut,ft="with-response"){if(!ct||!dt||!lt)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(an("bluetooth.writeCharacteristic.valueHex",ut),!e("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(ct,dt,lt,ut,ft)},async setCharacteristicNotify(ct,dt,lt,ut){if(!ct||!dt||!lt)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!e("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(ct,dt,lt,ut)},onDeviceFound(ct){return mt("craft:bluetooth:deviceFound",ct)},onDeviceConnected(ct){return mt("craft:bluetooth:deviceConnected",ct)},onDeviceDisconnected(ct){return mt("craft:bluetooth:deviceDisconnected",ct)},onCharacteristicValue(ct){return mt("craft:bluetooth:characteristicValue",ct)}};var Re={async speak(ct,dt){if(!ct)throw Error("speech.speak: text is required");if(e("speech")){await window.craft.speech.speak(ct,dt);return}if(typeof window<"u"&&window.speechSynthesis){let lt=new window.SpeechSynthesisUtterance(ct);if(dt){if(dt.rate!=null)lt.rate=dt.rate;if(dt.pitch!=null)lt.pitch=dt.pitch;if(dt.volume!=null)lt.volume=dt.volume;if(dt.voice){let ft=window.speechSynthesis.getVoices().find((pt)=>pt.voiceURI===dt.voice||pt.name===dt.voice||pt.lang===dt.voice);if(ft)lt.voice=ft}}window.speechSynthesis.speak(lt)}},async stop(){if(e("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(e("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(e("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(e("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(e("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((dt)=>({id:dt.voiceURI||dt.name,name:dt.name,language:dt.lang||"",quality:"default"}));return[]}};var Ot=[],tr=!0,rr,nr,o={async report(ct){if(e("crashReporter")){await window.craft.crashReporter.report(ct);return}if(!tr)return;let dt=ct instanceof Error?{timestamp:Date.now(),severity:"error",message:ct.message,source:"js",stack:ct.stack||"",userId:rr,appVersion:nr}:{timestamp:Date.now(),severity:ct.severity||"error",message:ct.message||"",source:ct.source||"js",stack:ct.stack||"",userId:rr,appVersion:nr};if(Ot.length>=64)Ot.shift();Ot.push(dt)},async flush(){if(e("crashReporter"))return await window.craft.crashReporter.flush();return[...Ot]},async clear(){if(e("crashReporter")){await window.craft.crashReporter.clear();return}Ot.length=0},async setEnabled(ct){if(e("crashReporter")){await window.craft.crashReporter.setEnabled(ct);return}tr=ct},async isEnabled(){if(e("crashReporter"))return await window.craft.crashReporter.isEnabled();return tr},async setUser(ct){if(e("crashReporter")){await window.craft.crashReporter.setUser(ct);return}rr=ct||void 0},async setAppVersion(ct){if(e("crashReporter")){await window.craft.crashReporter.setAppVersion(ct);return}nr=ct||void 0},attachGlobalHandlers(){if(e("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let ct=(lt)=>{o.report({severity:"error",message:lt.message,source:"js",stack:lt.error?.stack||`${lt.message}
|
|
343
|
-
at ${lt.filename}:${lt.lineno}:${lt.colno}`}).catch(()=>{})},dt=(lt)=>{let ut=lt.reason;o.report({severity:"error",message:ut?.message||String(ut),source:"js",stack:ut?.stack||""}).catch(()=>{})};return window.addEventListener("error",ct),window.addEventListener("unhandledrejection",dt),()=>{window.removeEventListener("error",ct),window.removeEventListener("unhandledrejection",dt)}},forwardTo(ct){return fn(ct)}},sn="craft:crashReporter:pending",cn=/[\w.+-]+@[\w-]+\.[\w.-]+/g,dn=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,ln=/\/(?:Users|home)\/[^\s/'"`]+/g;function w(ct){let dt=(lt)=>lt.replace(cn,"<email>").replace(dn,"<ip>").replace(ln,"/<home>");return{...ct,message:dt(ct.message),stack:dt(ct.stack)}}async function b(ct,dt){let lt=new TextEncoder,ut=await crypto.subtle.importKey("raw",lt.encode(ct),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),ft=await crypto.subtle.sign("HMAC",ut,lt.encode(dt));return[...new Uint8Array(ft)].map((pt)=>pt.toString(16).padStart(2,"0")).join("")}function un(ct){if(!ct||typeof localStorage>"u")return[];try{let dt=localStorage.getItem(ct);if(!dt)return[];let lt=JSON.parse(dt);return Array.isArray(lt)?lt:[]}catch{return[]}}function Ir(ct,dt){if(!ct||typeof localStorage>"u")return;try{if(dt.length===0)localStorage.removeItem(ct);else localStorage.setItem(ct,JSON.stringify(dt))}catch{}}function fn(ct){let{endpoint:dt,intervalMs:lt=60000,signingSecret:ut,redact:ft=!0,headers:pt={},maxRetries:gt=5,persistKey:wt}=ct,ht=wt===null?null:wt??sn,yt=un(ht),Pt=!1,xt=null,bt=null,_t=typeof ft==="function"?ft:ft===!1?(Ct)=>Ct:w;async function Ft(Ct){let Nt=JSON.stringify({entries:Ct}),Ut={"Content-Type":"application/json",...pt};if(ut)Ut["X-Craft-Signature"]=await b(ut,Nt);let ir=0,Kt=1000;while(!Pt)try{let Bt=await fetch(dt,{method:"POST",headers:Ut,body:Nt});if(Bt.ok)return;if(Bt.status>=400&&Bt.status<500)return;throw Error(`HTTP ${Bt.status}`)}catch(Bt){if(ir+=1,ir>gt)throw yt=[...Ct,...yt],Ir(ht,yt),Bt;await new Promise((Mr)=>{setTimeout(Mr,Kt)}),Kt=Math.min(Kt*2,60000)}}async function Rt(){if(Pt||bt)return bt??void 0;let Ct=await o.flush();if(Ct.length>0)await o.clear();if(yt=[...yt,...Ct.map((Ut)=>_t(Ut))],yt.length===0)return;let Nt=yt;return yt=[],Ir(ht,yt),bt=Ft(Nt).catch(()=>{}).finally(()=>{bt=null}),bt}if(lt>0)xt=setInterval(()=>{Rt().catch(()=>{})},lt);return{async flushNow(){await Rt()},stop(){if(Pt=!0,xt)clearInterval(xt);xt=null},pending(){return[...yt]}}}var Le={async isAvailable(){if(!e("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(ct){if(!e("iap"))return[];let dt=Array.isArray(ct)?ct:[String(ct)];return await window.craft.iap.getProducts(dt)},async purchase(ct){if(!e("iap"))return{queued:!1,productId:ct,reason:"IAP bridge not available"};let dt=await window.craft.iap.purchase(ct);return{queued:!!(dt&&dt.queued),productId:dt?.productId,reason:dt?.reason}},async restorePurchases(){if(!e("iap"))return{ok:!1};let ct=await window.craft.iap.restorePurchases();return{ok:!!(ct&&ct.ok)}},async finishTransaction(ct){if(!e("iap"))return;await window.craft.iap.finishTransaction(ct)},async getReceiptData(){if(!e("iap"))return null;let ct=await window.craft.iap.getReceiptData();return ct?String(ct):null},onPurchased(ct){return mt("craft:iap:purchased",ct)},onFailed(ct){return mt("craft:iap:failed",ct)},onRestored(ct){return mt("craft:iap:restored",ct)},onProductsLoaded(ct){return mt("craft:iap:productsLoaded",(dt)=>ct(dt.products||[]))},onRefunded(ct){return mt("craft:iap:refunded",ct)},onSubscriptionStatusChanged(ct){return mt("craft:iap:subscriptionStatusChanged",ct)},async getActiveSubscriptions(){if(!e("iap"))return[];let ct=window.craft.iap.getActiveSubscriptions;if(typeof ct!=="function")return[];let dt=await ct();return Array.isArray(dt)?dt:[]},async isEligibleForIntroOffer(ct){if(!e("iap"))return!1;let dt=window.craft.iap.isEligibleForIntroOffer;if(typeof dt!=="function")return!1;return!!await dt(ct)}};var i={async startActivity(ct,dt){if(!ct)throw Error("handoff.startActivity: type is required");if(!e("handoff"))return!1;let lt=await window.craft.handoff.startActivity(ct,dt);return typeof lt==="boolean"?lt:!!(lt&<.ok)},async updateActivity(ct){if(!e("handoff"))return!1;let dt=await window.craft.handoff.updateActivity(ct);return typeof dt==="boolean"?dt:!!(dt&&dt.ok)},async stopActivity(){if(!e("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!e("handoff"))return null;let ct=await window.craft.handoff.getCurrentActivity();return ct&&typeof ct.type==="string"?ct:null},onIncoming(ct){return mt("craft:handoff:incoming",ct)}};var _e={async start(ct,dt){return i.startActivity(ct,{title:dt?.title,webpageURL:dt?.webpageURL,userInfo:dt?.state})},async update(ct){return i.updateActivity({title:ct.title,webpageURL:ct.webpageURL,userInfo:ct.state})},async stop(){await i.stopActivity()}};var Ne={async requestPermission(ct="whenInUse"){if(e("location"))return await window.craft.location.requestPermission(ct);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(e("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(e("location"))return await window.craft.location.getCurrentLocation();if(typeof navigator<"u"&&navigator.geolocation)return navigator.geolocation.getCurrentPosition((ct)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:ct.coords.latitude,longitude:ct.coords.longitude,altitude:ct.coords.altitude,horizontalAccuracy:ct.coords.accuracy,verticalAccuracy:ct.coords.altitudeAccuracy,speed:ct.coords.speed}}))},(ct)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:ct.message||String(ct)}}))}),{requested:!0};return{requested:!1}},async startWatching(ct){if(e("location"))return await window.craft.location.startWatching(ct);if(typeof navigator<"u"&&navigator.geolocation){let dt=navigator.geolocation.watchPosition((lt)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:lt.coords.latitude,longitude:lt.coords.longitude,altitude:lt.coords.altitude,horizontalAccuracy:lt.coords.accuracy,verticalAccuracy:lt.coords.altitudeAccuracy,speed:lt.coords.speed}}))});return window.__craftWebLocationWatchId=dt,!0}return!1},async stopWatching(){if(e("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let ct=window.__craftWebLocationWatchId;if(ct!=null)navigator.geolocation.clearWatch(ct),window.__craftWebLocationWatchId=null}},onUpdate(ct){return mt("craft:location:update",ct)},onError(ct){return mt("craft:location:error",ct)},onAuthChanged(ct){return mt("craft:location:authChanged",ct)}};var Fe={async captureScreen(){if(!e("screenCapture"))return null;let ct=await window.craft.screenCapture.captureScreen();return ct?String(ct):null},async captureWindow(ct){if(!e("screenCapture"))return null;if(!Number.isFinite(ct)||ct<=0)throw Error("captureWindow: id must be a positive number");let dt=await window.craft.screenCapture.captureWindow(ct);return dt?String(dt):null},async listWindows(){if(!e("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var x=250,y=60000,a=2000,kr={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function pn(){return{...kr,signals:{...kr.signals},sources:[]}}var s={async getState(){if(!e("screenSharing"))return pn();return await window.craft.screenSharing.getState()},async watch(ct=a){let dt=Number.isFinite(ct)?Math.min(y,Math.max(x,Math.round(ct))):a;if(!e("screenSharing"))return dt;let lt=await window.craft.screenSharing.watch(dt);return lt&<.intervalMs||dt},async stop(){if(!e("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(ct){return mt("craft:screenSharing:change",ct)}};async function We(ct,dt=a){let lt=s.onChange(ct);try{await s.watch(dt)}catch(ft){throw lt(),ft}let ut;return()=>{if(!ut)lt(),ut=s.stop();return ut}}var mn={supported:!1,isFocused:null,authorization:"unsupported"};function Er(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var d={async getStatus(){if(!e("focus"))return{...mn};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!e("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(ct,dt={}){if(!e("focus"))return Er();if(!(ct?dt.onShortcut:dt.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${ct?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(ct,dt)},async runShortcut(ct){if(!e("focus"))return Er();if(!ct)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(ct)},async listShortcuts(){if(!e("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!e("focus"))return{canList:!1,shortcuts:[]};let dt=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean(dt?.canList),shortcuts:dt?.shortcuts??[]}}};async function ze(...ct){if(ct.length===0)return!1;let dt=new Set(await d.listShortcuts());return ct.every((lt)=>dt.has(lt))}async function He(...ct){if(ct.length===0)return!1;let{canList:dt,shortcuts:lt}=await d.listShortcutsResult();if(!dt)return"unknown";let ut=new Set(lt);return ct.every((ft)=>ut.has(ft))}var Ue={async start(ct=0,dt="127.0.0.1"){if(!e("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(ct,dt)},async stop(){if(!e("localServer"))return;await window.craft.localServer.stop()},async respond(ct){if(!e("localServer"))return;await window.craft.localServer.respond(ct||{status:200,body:"OK"})},onRequest(ct){return mt("craft:localServer:request",ct)},async awaitOAuthCallback(ct={}){vt("localServer");let{port:dt=0,host:lt="127.0.0.1",timeoutMs:ut=300000,successHTML:ft}=ct,pt=await this.start(dt,lt);if(!pt.started)throw Error(`localServer: start failed${pt.reason?` \u2014 ${pt.reason}`:""}`);return new Promise((gt,wt)=>{let ht=setTimeout(()=>{yt(),this.stop().catch(()=>{}),wt(Error("localServer: OAuth callback timed out"))},ut),yt=this.onRequest(({url:Pt})=>{clearTimeout(ht),yt();let xt=ft??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
344
|
-
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
345
|
-
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
|
346
|
-
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:xt,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),gt({url:Pt,port:pt.port})})})}};var qe={async isAvailable(){if(!e("biometric"))return!1;return await window.craft.biometric.isAvailable()},async getBiometryType(){if(!e("biometric"))return"none";return await window.craft.biometric.getBiometryType()},async evaluate(ct,dt){if(!ct)throw Error("biometric.evaluate: reason is required");if(!e("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(ct,dt)}};var At=null,Ve={async play(ct,dt){if(e("audio"))return await window.craft.audio.play(ct,dt);if(typeof window>"u"||typeof Audio>"u")return!1;if(At)At.pause(),At=null;if(At=new Audio(ct),dt?.volume!=null)At.volume=dt.volume;if(dt?.loops)At.loop=!0;try{return await At.play(),!0}catch{return!1}},async playSystemSound(ct){if(e("audio"))return await window.craft.audio.playSystemSound(ct);if(typeof window>"u"||typeof Audio>"u")return!1;try{return At=new Audio(`/System/Library/Sounds/${ct}.aiff`),await At.play(),!0}catch{return!1}},async stop(){if(e("audio")){await window.craft.audio.stop();return}if(At)At.pause(),At.currentTime=0,At=null},async isPlaying(){if(e("audio"))return await window.craft.audio.isPlaying();return!!(At&&!At.paused)},async startRecording(ct,dt){if(e("audio"))return await window.craft.audio.startRecording(ct,dt);return!1},async stopRecording(){if(e("audio"))await window.craft.audio.stopRecording()},async isRecording(){if(e("audio"))return await window.craft.audio.isRecording();return!1}};var je={async execute(ct){if(!ct)throw Error("appleScript.execute: source is required");if(!e("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(ct)}};var Ke={async getDefault(ct){if(!ct)throw Error("fileAssociations.getDefault: uti is required");if(!e("fileAssociations"))return null;let dt=await window.craft.fileAssociations.getDefault(ct);return dt?String(dt):null},async setDefault(ct,dt){if(!ct||!dt)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!e("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(ct,dt)}};var Ge={async get(ct){if(!ct)throw Error("tags.get: path is required");if(!e("tags"))return[];return await window.craft.tags.get(ct)},async set(ct,dt){if(!ct)throw Error("tags.set: path is required");if(!e("tags"))return!1;let lt=Array.isArray(dt)?dt:[String(dt)];return await window.craft.tags.set(ct,lt)},async clear(ct){if(!ct)throw Error("tags.clear: path is required");if(!e("tags"))return!1;return await window.craft.tags.clear(ct)}};var Ye={async countPages(ct){if(!ct)throw Error("pdf.countPages: path is required");if(!e("pdf"))return 0;return await window.craft.pdf.countPages(ct)},async extractText(ct){if(!ct)throw Error("pdf.extractText: path is required");if(!e("pdf"))return"";return await window.craft.pdf.extractText(ct)}};var Xe={async debug(ct){if(e("log"))await window.craft.log.debug(ct);else console.debug(ct)},async info(ct){if(e("log"))await window.craft.log.info(ct);else console.info(ct)},async warn(ct){if(e("log"))await window.craft.log.warn(ct);else console.warn(ct)},async error(ct){if(e("log"))await window.craft.log.error(ct);else console.error(ct)}};var Je={async browse(ct){if(!e("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(ct)},async stop(){if(e("bonjour"))await window.craft.bonjour.stop()},onFound(ct){return mt("craft:bonjour:found",ct)},onLost(ct){return mt("craft:bonjour:lost",ct)}};var Qe={async index(ct){if(!e("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(ct)},async remove(ct){if(!e("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(ct)},async removeAll(){if(!e("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var Ze={async isAvailable(){if(!e("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(ct){if(!e("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(ct)},async stop(){if(e("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(ct){return mt("craft:speechRecognition:partial",ct)},onFinal(ct){return mt("craft:speechRecognition:final",ct)}};var et={async recognizeText(ct){if(!ct)throw Error("vision.recognizeText: path is required");if(!e("vision"))return[];return await window.craft.vision.recognizeText(ct)},async detectFaces(ct){if(!ct)throw Error("vision.detectFaces: path is required");if(!e("vision"))return[];return await window.craft.vision.detectFaces(ct)},async detectBarcodes(ct){if(!ct)throw Error("vision.detectBarcodes: path is required");if(!e("vision"))return[];return await window.craft.vision.detectBarcodes(ct)}};var tt={async listSources(){if(!e("midi"))return[];return await window.craft.midi.listSources()},async listDestinations(){if(!e("midi"))return[];return await window.craft.midi.listDestinations()},async send(ct,dt){if(!e("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(ct,dt)},async subscribe(ct){if(!e("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(ct)},async unsubscribe(ct){if(!e("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(ct)},onMessage(ct){return mt("craft:midi:message",ct)}};var rt={async loadModel(ct,dt){if(!ct||!dt)throw Error("coreml.loadModel: id and path are required");if(!e("coreml"))return!1;return await window.craft.coreml.loadModel(ct,dt)},async unloadModel(ct){if(!e("coreml"))return;await window.craft.coreml.unloadModel(ct)},async predict(ct,dt){if(!ct)throw Error("coreml.predict: id is required");if(!e("coreml"))return null;return await window.craft.coreml.predict(ct,dt)}};var nt={async listCameras(){if(!e("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var ot={async register(ct){if(!ct)throw Error("serviceMenu.register: name is required");if(!e("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(ct)},async unregister(ct){if(!ct)throw Error("serviceMenu.unregister: name is required");if(!e("serviceMenu"))return;await window.craft.serviceMenu.unregister(ct)},onInvoked(ct){return mt("craft:serviceMenu:invoked",ct)}};var it={async list(){if(!e("serial"))return[];return await window.craft.serial.list()},async open(ct,dt=9600){if(!ct)throw Error("serial.open: path is required");if(!e("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(ct,dt)},async write(ct,dt){if(!ct)throw Error("serial.write: id is required");if(!e("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(ct,dt)},async close(ct){if(!e("serial"))return;await window.craft.serial.close(ct)},onData(ct){return mt("craft:serial:data",ct)}};var Cr=[{name:"fs",support:"native"},{name:"shell",support:"native"},{name:"system",support:"all"},{name:"clipboard",support:"all"},{name:"dialog",support:"all"},{name:"window",support:"native"},{name:"tray",support:"native"},{name:"menu",support:"native"},{name:"theme",support:"all"},{name:"screen",support:"all"},{name:"network",support:"all"},{name:"power",support:"all"},{name:"battery",support:"all"},{name:"notifications",support:"all"},{name:"globalShortcuts",support:"native"},{name:"autolaunch",support:"native"},{name:"appInfo",support:"all"},{name:"localServer",support:"native"},{name:"bluetooth",support:"native"},{name:"crashReporter",support:"all"},{name:"updater",support:"native"},{name:"iap",support:"macos"},{name:"keychain",support:"native"},{name:"log",support:"all"},{name:"biometric",support:"macos"},{name:"location",support:"macos"},{name:"audio",support:"macos"},{name:"deepLink",support:"native"},{name:"handoff",support:"macos"},{name:"liveActivities",support:"macos"},{name:"touchbar",support:"macos"},{name:"dragOut",support:"macos"},{name:"appleScript",support:"macos"},{name:"fileAssociations",support:"native"},{name:"tags",support:"macos"},{name:"pdf",support:"macos"},{name:"bonjour",support:"macos"},{name:"spotlight",support:"macos"},{name:"speechRecognition",support:"macos"},{name:"vision",support:"macos"},{name:"midi",support:"macos"},{name:"coreml",support:"macos"},{name:"continuityCamera",support:"macos"},{name:"serviceMenu",support:"macos"},{name:"serial",support:"native"}];function at(){return Cr.map(({name:ct,support:dt})=>({name:ct,support:dt,available:e(ct)}))}function v(ct){let dt=Cr.find((lt)=>lt.name===ct);if(!dt)return;return{...dt,available:e(ct)}}function st(ct){let dt=v(ct);return!!dt&&dt.available}
|
|
347
|
-
export{u,P,c,r,S,k,A,C,I,T,E,M,D,t,p,B,O,R,f,L,_,N,F,W,z,H,U,n,q,V,j,K,G,Y,X,l,J,Q,Z,ee,m,te,re,g,ne,oe,ie,ae,se,ce,le,e,de,ue,pe,fe,me,ge,he,we,be,xe,ye,ve,Pe,Se,ke,Ae,Ce,h,Ie,$e,Te,Ee,Me,De,Be,Oe,Re,o,w,b,Le,i,_e,Ne,Fe,x,y,a,s,We,d,ze,He,Ue,qe,Ve,je,Ke,Ge,Ye,Xe,Je,Qe,Ze,et,tt,rt,nt,ot,it,at,v,st};
|