@stacksjs/desktop 0.2.412 → 0.2.414
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.js +1 -1
- package/dist/chunk-aa3mwv0w.js +347 -0
- package/dist/index.js +76 -76
- package/dist/test-utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-er7zj094.js +0 -347
- package/dist/chunk-gzgq8v6d.js +0 -3
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{v,s,r,P,S,k,A,C,I,T,E,M,t,d,D,B,O,u,L,R,_,N,F,z,W,H,n,U,q,V,j,K,G,Y,p,X,J,Q,Z,f,ee,te,m,re,ne,oe,ie,ae,se,ce,le,de,ue,pe,fe,me,ge,he,we,be,xe,ye,ve,Pe,Se,ke,Ae,g,Ce,Ie,$e,Te,Ee,Me,De,Be,Oe,o,h,w,Le,i,Re,_e,Ne,b,x,c,a,Fe,l,ze,We,He,Ue,qe,Ve,je,Ke,Ge,Ye,Xe,Je,Qe,Ze,et,tt,rt,nt,ot,it,y,at}from"./chunk-aa3mwv0w.js";export{c as DEFAULT_WATCH_INTERVAL_MS,x as MAX_WATCH_INTERVAL_MS,b as MIN_WATCH_INTERVAL_MS,z as MODAL_STYLES,M as TOAST_STYLES,R as alert,Pe as app,Ve as appleScript,qe as audio,be as battery,Ue as biometric,Be as bluetooth,Xe as bonjour,Y as caffeinate,le as clipboard,F as closeAllModals,L as confirm,Ae as contextMenu,rt as continuityCamera,tt as coreml,o as crashReporter,ie as createInterval,oe as createTimer,p as decaffeinate,we as deepLinks,ae as delay,I as dismissAlertById,T as dismissAllAlerts,ge as dragOut,je as fileAssociations,l as focus,We as focusShortcutsReady,ce as formatCompact,Z as formatDuration,Q as formatRemainingTime,ee as formatShortcut,se as formatTime,ue as fs,E as getActiveAlertCount,N as getActiveModalCount,J as getCaffeinateStatus,it as getCapabilities,y as getCapability,G as getDialogBridgeScript,ne as getRegisteredHotkeys,fe as globalShortcuts,i as handoff,ze as hasFocusShortcuts,Le as iap,at as isAvailable,X as isCaffeinated,he as isDragOutAvailable,Ie as keychain,Re as liveActivities,He as localServer,_e as location,Ye as log,ke as menu,et as midi,Ee as nativeAutoLaunch,Me as nativeWindow,xe as network,de as notifications,C as notify,f as parseShortcut,Ge as pdf,$e as permissions,Te as printing,_ as prompt,h as redactPII,te as registerHotkey,v as requestNotificationPermission,Ce as screen,Ne as screenCapture,a as screenSharing,ot as serial,nt as serviceMenu,pe as shell,s as showAlert,q as showAlertDialog,U as showColorPicker,V as showConfirmDialog,j as showErrorDialog,B as showErrorModal,A as showErrorToast,d as showInfoModal,P as showInfoToast,n as showMessageBox,t as showModal,W as showOpenDialog,u as showQuestionModal,H as showSaveDialog,O as showSuccessModal,S as showSuccessToast,r as showToast,K as showWarningDialog,D as showWarningModal,k as showWarningToast,g as sidebar,w as signPayload,Oe as speech,Qe as speechRecognition,Je as spotlight,Se as standardMenus,Ke as tags,me as theme,De as touchbar,re as unregisterAllHotkeys,m as unregisterHotkey,ye as updater,Ze as vision,Fe as watchScreenSharing,ve as windowEvents};
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function Mr(){if(typeof Notification<"u"&&Notification.permission==="granted")return!0;return!1}function $t(){return typeof window<"u"&&typeof document<"u"}async function v(){if(typeof Notification>"u")return!1;if(Notification.permission==="granted")return!0;if(Notification.permission==="denied")return!1;return await Notification.requestPermission()==="granted"}var Ct=new Map;function Dr(){return`alert-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function Br(st){switch(st){case"info":return"ℹ";case"success":return"✔";case"warning":return"⚠";case"error":return"✖";default:return"ℹ"}}function Tr(st="top-right"){if(!$t())throw Error("Toast container requires browser environment");try{let dt=document.querySelector(`.stx-toast-container[data-position="${st}"]`);if(dt)return dt}catch{}let ct=document.createElement("div");ct.className=`stx-toast-container ${st}`,ct.dataset.position=st;try{if(document.body)document.body.appendChild(ct)}catch{}return ct}function Rr(st){let{options:ct}=st,dt=Br(ct.type),lt=ct.type||"info",ut=ct.duration!==0;return`
|
|
3
|
+
<div class="stx-toast ${lt}" data-alert-id="${st.id}" role="alert" aria-live="polite">
|
|
4
|
+
<div class="stx-toast-icon">${dt}</div>
|
|
5
|
+
<div class="stx-toast-content">
|
|
6
|
+
${ct.title?`<div class="stx-toast-title">${nr(ct.title)}</div>`:""}
|
|
7
|
+
<div class="stx-toast-message">${nr(ct.message)}</div>
|
|
8
|
+
</div>
|
|
9
|
+
${ut?'<button class="stx-toast-close" aria-label="Close">×</button>':""}
|
|
10
|
+
</div>
|
|
11
|
+
`}function nr(st){return st.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ot(st){if(st.timeout)clearTimeout(st.timeout);if(Ct.delete(st.id),st.element&&$t())st.element.classList.add("dismissing"),setTimeout(()=>{st.element?.remove()},200)}async function s(st){let ct=Dr(),dt=Mr(),lt=st.duration??5000,ut={id:ct,options:st};if(Ct.set(ct,ut),dt&&st.type!=="error")try{let ft=new Notification(st.title||"Notification",{body:st.message,icon:st.type==="success"?"\u2713":st.type==="warning"?"\u26A0":"\u2139",tag:ct});if(ft.onclick=()=>{if(st.onClick)st.onClick();ft.close()},lt>0)ut.timeout=setTimeout(()=>{ft.close(),Ct.delete(ct)},lt);return}catch{}if($t())try{let ft=Tr(st.position),mt=document.createElement("div");mt.innerHTML=Rr(ut);let gt=mt.firstElementChild;if(!gt){let wt=(st.type||"info").toUpperCase();console.log(`[stx-alert] ${wt}: ${st.title||""}`),console.log(`[stx-alert] ${st.message}`);return}ut.element=gt;try{ft.appendChild(gt)}catch{let wt=(st.type||"info").toUpperCase();console.log(`[stx-alert] ${wt}: ${st.title||""}`),console.log(`[stx-alert] ${st.message}`);return}if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>{try{gt.classList.add("visible")}catch{}});try{gt.addEventListener("click",(wt)=>{if(wt.target.classList?.contains("stx-toast-close")){Ot(ut);return}if(st.onClick)st.onClick()})}catch{}if(lt>0)ut.timeout=setTimeout(()=>{Ot(ut)},lt)}catch{let ft=(st.type||"info").toUpperCase();console.log(`[stx-alert] ${ft}: ${st.title||""}`),console.log(`[stx-alert] ${st.message}`)}else{let ft=(st.type||"info").toUpperCase();if(console.log(`[stx-alert] ${ft}: ${st.title||""}`),console.log(`[stx-alert] ${st.message}`),lt>0)ut.timeout=setTimeout(()=>{Ct.delete(ct)},lt)}}async function r(st){return s({...st,position:st.position||"top-right"})}async function P(st,ct=3000){return r({message:st,type:"info",duration:ct})}async function S(st,ct=3000){return r({message:st,type:"success",duration:ct})}async function k(st,ct=3000){return r({message:st,type:"warning",duration:ct})}async function A(st,ct=5000){return r({message:st,type:"error",duration:ct})}async function C(st,ct,dt="info"){return s({title:st,message:ct,type:dt})}function I(st){let ct=Ct.get(st);if(ct)Ot(ct)}function T(){for(let st of Ct.values())Ot(st)}function E(){return Ct.size}var M=`
|
|
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 Lr(){return!1}function Wt(){return typeof window<"u"&&typeof document<"u"}var Mt=[];function _r(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function Or(st){switch(st){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function Ft(st){if(st==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function Fr(st){let{options:ct}=st,dt=Or(ct.type),lt=ct.buttons||Ft(ct.type),ut=ct.type||"info",ft="";return lt.forEach((mt,gt)=>{let wt=mt.style==="destructive"?"destructive":mt.style==="primary"?"primary":"default",vt=gt===(ct.defaultButton??lt.length-1)?"autofocus":"";ft+=`<button class="stx-modal-btn ${wt}" data-index="${gt}" ${vt}>${mt.label}</button>`}),`
|
|
114
|
+
<div class="stx-modal-overlay" data-modal-id="${st.id}">
|
|
115
|
+
<div class="stx-modal ${ut}" role="dialog" aria-modal="true" aria-labelledby="${st.id}-title">
|
|
116
|
+
<div class="stx-modal-icon">${dt}</div>
|
|
117
|
+
<div class="stx-modal-content">
|
|
118
|
+
${ct.title?`<h2 id="${st.id}-title" class="stx-modal-title">${ir(ct.title)}</h2>`:""}
|
|
119
|
+
<p class="stx-modal-message">${ir(ct.message)}</p>
|
|
120
|
+
</div>
|
|
121
|
+
<div class="stx-modal-buttons">${ft}</div>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
`}function ir(st){return st.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function St(st,ct,dt=!1){let lt=Mt.indexOf(st);if(lt>-1)Mt.splice(lt,1);if(st.element&&Wt())st.element.remove();let ft=(st.options.buttons||Ft(st.options.type))[ct];if(ft?.action)ft.action();st.resolve({buttonIndex:ct,cancelled:dt})}async function t(st){let ct=Lr(),dt=_r();return new Promise((lt)=>{let ut={id:dt,options:st,resolve:lt};if(Mt.push(ut),ct)console.log(`[stx-modal] Showing native modal: ${st.title||"Modal"}`),setTimeout(()=>{St(ut,st.defaultButton??0,!1)},0);else if(Wt())try{let ft=document.createElement("div");ft.innerHTML=Fr(ut);let mt=ft.firstElementChild;if(!mt){console.log(`[stx-modal] ${st.type?.toUpperCase()||"INFO"}: ${st.title||"Modal"}`),console.log(`[stx-modal] ${st.message}`),setTimeout(()=>{St(ut,st.defaultButton??0,!1)},0);return}ut.element=mt;try{document.body.appendChild(mt)}catch{console.log(`[stx-modal] ${st.type?.toUpperCase()||"INFO"}: ${st.title||"Modal"}`),console.log(`[stx-modal] ${st.message}`),setTimeout(()=>{St(ut,st.defaultButton??0,!1)},0);return}try{mt.querySelectorAll(".stx-modal-btn").forEach((gt)=>{gt.addEventListener("click",()=>{let wt=Number.parseInt(gt.dataset.index||"0",10);St(ut,wt,!1)})})}catch{}try{mt.addEventListener("click",(gt)=>{if(gt.target===mt){let wt=st.cancelButton??0;St(ut,wt,!0)}})}catch{}try{let gt=(wt)=>{if(wt.key==="Escape"){let vt=st.cancelButton??0;St(ut,vt,!0),document.removeEventListener("keydown",gt)}else if(wt.key==="Enter"){let vt=st.defaultButton??(st.buttons||Ft(st.type)).length-1;St(ut,vt,!1),document.removeEventListener("keydown",gt)}};document.addEventListener("keydown",gt)}catch{}try{let gt=mt.querySelector(".stx-modal-btn[autofocus]");if(gt)gt.focus()}catch{}if(typeof process<"u"&&process.env.BUN_TEST)setTimeout(()=>{St(ut,st.defaultButton??0,!1)},0)}catch{console.log(`[stx-modal] ${st.type?.toUpperCase()||"INFO"}: ${st.title||"Modal"}`),console.log(`[stx-modal] ${st.message}`),setTimeout(()=>{St(ut,st.defaultButton??0,!1)},0)}else{console.log(`[stx-modal] ${st.type?.toUpperCase()||"INFO"}: ${st.title||"Modal"}`),console.log(`[stx-modal] ${st.message}`);let ft=st.buttons||Ft(st.type);console.log(`[stx-modal] Buttons: ${ft.map((mt)=>mt.label).join(", ")}`),setTimeout(()=>{St(ut,st.defaultButton??0,!1)},0)}})}async function d(st,ct){return t({title:st,message:ct,type:"info"})}async function D(st,ct){return t({title:st,message:ct,type:"warning"})}async function B(st,ct){return t({title:st,message:ct,type:"error"})}async function O(st,ct){return t({title:st,message:ct,type:"success"})}async function u(st,ct){return t({title:st,message:ct,type:"question",buttons:[{label:"No",style:"default"},{label:"Yes",style:"primary"}],defaultButton:1,cancelButton:0})}async function L(st,ct="Confirm"){return(await u(ct,st)).buttonIndex===1}async function R(st,ct="Alert"){await d(ct,st)}async function _(st,ct="",dt="Input"){if(Wt()&&typeof window.prompt==="function")return window.prompt(st,ct);return console.log(`[stx-modal] PROMPT: ${dt}`),console.log(`[stx-modal] ${st}`),console.log(`[stx-modal] Default: ${ct}`),ct}function N(){return Mt.length}function F(){while(Mt.length>0){let st=Mt[Mt.length-1];St(st,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 or(st){let ct=new Set(st.properties??[]);if(st.canChooseDirectories)ct.add("openDirectory");if(st.canChooseFiles)ct.add("openFile");if(st.multiSelections)ct.add("multiSelections");if(st.showHiddenFiles)ct.add("showHiddenFiles");if(st.canCreateDirectories)ct.add("createDirectory");return{...st,properties:[...ct]}}function Nr(){if(typeof window>"u")return;return window.craft?.dialog}var qr={error:"critical",warning:"warning",question:"info",info:"info",none:"info"};function Ur(st){let ct=[st.title?st.message:"",st.detail??""].filter(Boolean).join(`
|
|
257
|
+
|
|
258
|
+
`);return{title:st.title||st.message,message:ct||void 0,style:qr[st.type??"none"]??"info",buttons:st.buttons}}function ar(st,ct){if(typeof st==="number"&&Number.isFinite(st))return{response:st};if(st&&typeof st==="object"){let lt=st;if(typeof lt.response==="number")return{response:lt.response};if(typeof lt.buttonIndex==="number")return{response:lt.buttonIndex}}let dt=ct.buttons??["OK"];return{response:ct.cancelButton??Math.max(0,dt.length-1)}}function zt(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function W(st={}){if(zt()){let ct=window;try{return await ct.craft.dialog.showOpenDialog(or(st))}catch(dt){console.warn("[stx-dialog] Failed to show native open dialog:",dt)}}return new Promise((ct)=>{if(typeof document>"u"){ct({canceled:!0,filePaths:[]});return}let dt=new Set(or(st).properties),lt=document.createElement("input");if(lt.type="file",lt.multiple=dt.has("multiSelections"),st.filters?.length){let ut=st.filters.flatMap((ft)=>ft.extensions.map((mt)=>`.${mt}`));lt.accept=ut.join(",")}if(dt.has("openDirectory")&&!dt.has("openFile"))lt.webkitdirectory=!0;lt.onchange=()=>{let ut=Array.from(lt.files||[]);if(ut.length===0)ct({canceled:!0,filePaths:[]});else{let ft=ut.map((mt)=>mt.name);ct({canceled:!1,filePaths:ft})}},lt.oncancel=()=>{ct({canceled:!0,filePaths:[]})},lt.click()})}async function H(st={}){if(zt()){let dt=window;try{return await dt.craft.dialog.showSaveDialog(st)}catch(lt){console.warn("[stx-dialog] Failed to show native save dialog:",lt)}}if(typeof window<"u"&&"showSaveFilePicker"in window)try{let dt=st.filters?.map((ut)=>({description:ut.name,accept:{"*/*":ut.extensions.map((ft)=>`.${ft}`)}}));return{canceled:!1,filePath:(await window.showSaveFilePicker({suggestedName:st.defaultPath,types:dt})).name}}catch(dt){return{canceled:!0}}console.warn("[stx-dialog] Save dialog not available, using prompt fallback");let ct=prompt("Enter filename:",st.defaultPath||"file.txt");if(ct)return{canceled:!1,filePath:ct};return{canceled:!0}}async function n(st){let ct=Nr();if(typeof ct?.showMessageBox==="function")try{return ar(await ct.showMessageBox(st),st)}catch(gt){console.warn("[stx-dialog] Failed to show native message box:",gt)}else if(typeof ct?.showAlert==="function")try{return ar(await ct.showAlert(Ur(st)),st)}catch(gt){console.warn("[stx-dialog] Failed to show native alert:",gt)}let dt=st.buttons||["OK"],lt=st.detail?`
|
|
259
|
+
|
|
260
|
+
${st.detail}`:"",ut=`${st.message}${lt}`;if(dt.length===1)return alert(ut),{response:0};let ft=st.cancelButton??dt.length-1,mt=st.defaultButton!==void 0&&st.defaultButton!==ft?st.defaultButton:dt.findIndex((gt,wt)=>wt!==ft);if(dt.length>2)console.warn(`[stx-dialog] ${dt.length} buttons requested; a browser confirm offers two. Reachable: "${dt[mt]}" and "${dt[ft]}".`);return{response:confirm(ut)?mt:ft}}async function U(st={}){if(zt()){let ct=window;try{return await ct.craft.dialog.showColorPicker(st)}catch(dt){console.warn("[stx-dialog] Failed to show native color picker:",dt)}}return new Promise((ct)=>{if(typeof document>"u"){ct({canceled:!0});return}let dt=document.createElement("input");dt.type="color",dt.value=st.color||"#000000",dt.onchange=()=>{ct({canceled:!1,color:dt.value})},dt.oncancel=()=>{ct({canceled:!0})},dt.click()})}async function q(st,ct){await n({type:"info",title:ct||"Alert",message:st,buttons:["OK"]})}async function V(st,ct){return(await n({type:"question",title:ct||"Confirm",message:st,buttons:["OK","Cancel"],defaultButton:0,cancelButton:1})).response===0}async function j(st,ct){await n({type:"error",title:ct||"Error",message:st,buttons:["OK"]})}async function K(st,ct){await n({type:"warning",title:ct||"Warning",message:st,buttons:["OK"]})}function G(){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
|
+
`}var Kt=null,yt=null;class sr{_process;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(st,ct){this._process=st,this._options=ct,this._startedAt=new Date;let dt=ct.duration;if(dt&&dt>0){let lt=dt*60*1000;this._endsAt=new Date(this._startedAt.getTime()+lt),this._expireTimer=setTimeout(()=>{this._stopped=!0;for(let ut of this._expireHandlers)try{ut()}catch{}},lt)}else this._endsAt=null}get pid(){return this._process.pid}get startedAt(){return this._startedAt}get endsAt(){return this._endsAt}get options(){return{...this._options}}get isActive(){if(this._stopped)return!1;return this._process.exitCode===null}get remainingMs(){if(!this._endsAt)return null;let st=this._endsAt.getTime()-Date.now();return Math.max(0,st)}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;try{this._process.kill()}catch{}}onExpire(st){this._expireHandlers.push(st)}}function Y(st={}){p();let{duration:ct,preventDisplaySleep:dt=!0,preventIdleSleep:lt=!0,preventSystemSleep:ut=!0,preventDiskSleep:ft=!1,assertUserActivity:mt=!0}=st,gt=[];if(dt)gt.push("-d");if(lt)gt.push("-i");if(ut)gt.push("-s");if(ft)gt.push("-m");if(mt)gt.push("-u");let wt=[...gt];if(ct&&ct>0)wt.push("-t",String(ct*60));let vt=Bun.spawn(["/usr/bin/caffeinate",...wt],{stdio:["ignore","ignore","ignore"]}),xt=new sr(vt,st);return Kt=vt,yt=xt,xt}function p(st){if(st){if(st.stop(),yt===st)Kt=null,yt=null;return}if(yt)yt.stop();Kt=null,yt=null}function X(){return yt!==null&&yt.isActive}function J(){if(!yt||!yt.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let ct=yt.options.duration;return{active:!0,instance:yt,startedAt:yt.startedAt,endsAt:yt.endsAt,durationMinutes:ct&&ct>0?ct:-1}}function Q(st){let ct=st||yt;if(!ct||!ct.isActive)return"0:00";let dt=ct.remainingMs;if(dt===null)return"\u221E";let lt=Math.ceil(dt/1000),ut=Math.floor(lt/3600),ft=Math.floor(lt%3600/60),mt=lt%60;if(ut>0)return`${ut}:${String(ft).padStart(2,"0")}:${String(mt).padStart(2,"0")}`;return`${ft}:${String(mt).padStart(2,"0")}`}function Z(st){if(st<=0||st===-1)return"Indefinitely";if(st<60)return`${st} minutes`;if(st===60)return"1 hour";if(st%60===0)return`${st/60} hours`;let ct=Math.floor(st/60),dt=st%60;return`${ct}h ${dt}m`}var At=new Map,Hr=0,Nt=!1;function f(st){let ct=st.split("+").map((lt)=>lt.trim()),dt={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let lt of ct){let ut=lt.toLowerCase();switch(ut){case"cmd":case"command":case"meta":case"\u2318":dt.meta=!0;break;case"ctrl":case"control":case"\u2303":dt.ctrl=!0;break;case"shift":case"\u21E7":dt.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":dt.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")dt.meta=!0;else dt.ctrl=!0;break;default:dt.key=ut}}return dt}function ee(st){let ct=[];if(st.ctrl)ct.push("\u2303");if(st.alt)ct.push("\u2325");if(st.shift)ct.push("\u21E7");if(st.meta)ct.push("\u2318");return ct.push(st.key.toUpperCase()),ct.join("")}function $r(st,ct){if(ct.meta!==st.metaKey)return!1;if(ct.ctrl!==st.ctrlKey)return!1;if(ct.shift!==st.shiftKey)return!1;if(ct.alt!==st.altKey)return!1;return st.key.toLowerCase()===ct.key||st.code.toLowerCase()===`key${ct.key}`}function cr(st){for(let[,ct]of At)if($r(st,ct.parsed)){st.preventDefault(),st.stopPropagation();try{ct.handler()}catch{}break}}function Wr(){if(Nt)return;if(typeof document>"u")return;document.addEventListener("keydown",cr,!0),Nt=!0}function jt(){if(!Nt)return;if(typeof document>"u")return;document.removeEventListener("keydown",cr,!0),Nt=!1}async function zr(st,ct){if(typeof window>"u")return!1;let dt=window.craft;if(!dt?.hotkeys?.register)return!1;try{return await dt.hotkeys.register(st,ct),!0}catch{return!1}}async function Vt(st){if(typeof window>"u")return;let ct=window.craft;if(!ct?.hotkeys?.unregister)return;try{await ct.hotkeys.unregister(st)}catch{}}function te(st,ct){let dt=`hotkey_${++Hr}_${Date.now()}`,lt=f(st);At.set(dt,{shortcut:st,handler:ct,parsed:lt}),zr(dt,st),Wr();let ut={shortcut:st,id:dt,unregister(){m(ut)}};return ut}function m(st){if(At.delete(st.id),Vt(st.id),At.size===0)jt()}function re(){for(let[st]of At)Vt(st);At.clear(),jt()}function ne(){return Array.from(At.entries()).map(([st,ct])=>({shortcut:ct.shortcut,id:st,unregister(){if(At.delete(st),Vt(st),At.size===0)jt()}}))}class dr{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(st){if(this._duration=st.duration,this._tickInterval=st.tickInterval||1000,this._remaining=st.duration,st.onComplete)this._completionHandlers.add(st.onComplete);if(st.onTick)this._tickHandlers.add(st.onTick);if(st.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 st=Date.now()-this._lastTick;return Math.max(0,this._remaining-st)}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 st=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-st),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(st){return this._completionHandlers.add(st),()=>{this._completionHandlers.delete(st)}}onTick(st){return this._tickHandlers.add(st),()=>{this._tickHandlers.delete(st)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let st=Date.now(),ct=st-this._lastTick;this._lastTick=st,this._remaining=Math.max(0,this._remaining-ct);for(let dt of this._tickHandlers)try{dt(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let dt of this._completionHandlers)try{dt()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class lr{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(st){if(this._interval=st.interval,this._handler=st.handler,this._immediate=st.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 oe(st){return new dr(st)}function ie(st){return new lr(st)}function ae(st){return new Promise((ct)=>setTimeout(ct,st))}function se(st){let ct=Math.ceil(st/1000),dt=Math.floor(ct/3600),lt=Math.floor(ct%3600/60),ut=ct%60;if(dt>0)return`${dt}:${String(lt).padStart(2,"0")}:${String(ut).padStart(2,"0")}`;return`${lt}:${String(ut).padStart(2,"0")}`}function ce(st){let ct=Math.ceil(st/1000),dt=Math.floor(ct/3600),lt=Math.floor(ct%3600/60),ut=ct%60;if(dt>0){if(lt>0)return`${dt}h ${lt}m`;return`${dt}h`}if(lt>0){if(ut>0)return`${lt}m ${ut}s`;return`${lt}m`}return`${ut}s`}function e(st){if(typeof window>"u")return!1;let ct=window.craft;return!!(ct&&ct[st])}function ht(st){if(!e(st))throw Error(`craft.${st} is not available \u2014 this API requires a Craft native window`);return window.craft[st]}function pt(st,ct){if(typeof window>"u")return()=>{};let dt=(lt)=>ct(lt.detail??{});return window.addEventListener(st,dt),()=>window.removeEventListener(st,dt)}var le={async writeText(st){if(e("clipboard")){await window.craft.clipboard.writeText(st);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(st)},async readText(){if(e("clipboard")){let st=await window.craft.clipboard.readText();return typeof st==="string"?st:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(st){if(e("clipboard")){await window.craft.clipboard.writeHTML(st);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let ct=new window.ClipboardItem({"text/html":new Blob([st],{type:"text/html"}),"text/plain":new Blob([Kr(st)],{type:"text/plain"})});await navigator.clipboard.write([ct])}catch{}},async readHTML(){if(e("clipboard")){let st=await window.craft.clipboard.readHTML();return typeof st==="string"?st:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let st=await navigator.clipboard.read();for(let ct of st)if(ct.types.includes("text/html"))return await(await ct.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 Kr(st){return st.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 de={async show(st){if(!st.title)throw Error("notification title is required");if(e("notifications")){await window.craft.notifications.show(st);return}if(typeof window<"u"&&"Notification"in window){let ct=window.Notification;if(ct.permission==="granted")new ct(st.title,{body:st.body,icon:st.icon});else if(ct.permission==="default"){if(await ct.requestPermission()==="granted")new ct(st.title,{body:st.body,icon:st.icon})}}},async schedule(st){if(e("notifications")){let lt={...st};if(lt.triggerAt instanceof Date)lt.triggerAt=lt.triggerAt.toISOString();await window.craft.notifications.schedule(lt);return}let ct=jr(st.triggerAt),dt=Math.max(0,ct-Date.now());setTimeout(()=>{this.show(st).catch(()=>{})},dt)},async cancel(st){if(e("notifications"))await window.craft.notifications.cancel(st)},async cancelAll(){if(e("notifications"))await window.craft.notifications.cancelAll()},async setBadge(st){let ct=Math.max(0,Math.round(Number.isFinite(st)?st:0));if(e("notifications")){await window.craft.notifications.setBadge(ct);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(ct)}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 st=window.Notification;if(st.permission==="granted")return!0;if(st.permission==="denied")return!1;return await st.requestPermission()==="granted"}return!1},async registerCategories(st){if(!Array.isArray(st)||st.length===0)return;if(e("notifications")){let ct=window.craft.notifications.registerCategories;if(typeof ct==="function")await ct(st)}},onActionClicked(st){return pt("craft:notification:actionClicked",st)},onReply(st){return pt("craft:notification:reply",st)}};function jr(st){if(st==null)return Date.now();if(st instanceof Date)return st.getTime();if(typeof st==="number")return st;let ct=Date.parse(st);return Number.isNaN(ct)?Date.now():ct}var ue={async readFile(st){let ct=await ht("fs").readFile(st);return ct&&ct.data||""},async readBuffer(st){let ct=await ht("fs").readFile(st),dt=ct&&ct.data||"";if(ct&&ct.base64===!0)return Yr(dt);return new TextEncoder().encode(dt)},async writeFile(st,ct){await ht("fs").writeFile(st,ct)},async writeBuffer(st,ct){let dt=Vr(ct),lt=ht("fs");if(typeof lt.writeFileBytes==="function")await lt.writeFileBytes(st,dt);else await lt.writeFile(st,dt)},async copy(st,ct){if(st===ct)throw Error("fs.copy: source and destination must differ");await ht("fs").copy(st,ct)},async move(st,ct){if(st===ct)throw Error("fs.move: source and destination must differ");await ht("fs").move(st,ct)},async appendFile(st,ct){await ht("fs").appendFile(st,ct)},async deleteFile(st){await ht("fs").deleteFile(st)},async exists(st){return await ht("fs").exists(st)},async stat(st){return Gr(await ht("fs").stat(st))},async readDir(st){let ct=await ht("fs").readDir(st),dt=ct&&ct.entries||[],lt=st.endsWith("/")?st.slice(0,-1):st;return dt.map((ut)=>({name:ut.name,path:`${lt}/${ut.name}`,isDirectory:!!ut.isDirectory}))},async mkdir(st,ct){await ht("fs").mkdir(st,ct)},async rmdir(st,ct){await ht("fs").rmdir(st,ct)},async watch(st,ct){await ht("fs").watch(st,ct)},async unwatch(st){await ht("fs").unwatch(st)},onChange(st){return pt("craft:fs:change",st)},async watchTree(st,ct,dt){let lt=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,ut=ht("fs");await ut.watch(st,lt,{recursive:!!ct.recursive});let ft=ct.kinds&&ct.kinds.length>0?new Set(ct.kinds):null,mt=Math.max(0,Math.floor(ct.coalesceMs??0)),gt=[],wt=null,vt=!1,xt=()=>{if(wt=null,gt.length===0)return;let Pt=gt;gt=[];try{dt(Pt)}catch{}},kt=pt("craft:fs:change",(Pt)=>{if(vt)return;if(Pt.id!==lt)return;if(ft&&Pt.kind&&!ft.has(Pt.kind))return;if(gt.push(Pt),mt===0){xt();return}if(wt==null)wt=setTimeout(xt,mt)});return{id:lt,async stop(){if(vt)return;if(vt=!0,kt(),wt)clearTimeout(wt),wt=null;if(gt.length>0)xt();try{await ut.unwatch(lt)}catch{}}}},async homeDir(){return await ht("fs").homeDir()},async tempDir(){return await ht("fs").tempDir()},async appDataDir(){return await ht("fs").appDataDir()}};function Vr(st){let ct="";for(let dt=0;dt<st.length;dt++)ct+=String.fromCharCode(st[dt]);return typeof btoa==="function"?btoa(ct):Buffer.from(st).toString("base64")}function Yr(st){let ct=typeof atob==="function"?atob(st):Buffer.from(st,"base64").toString("binary"),dt=new Uint8Array(ct.length);for(let lt=0;lt<ct.length;lt++)dt[lt]=ct.charCodeAt(lt);return dt}function Gr(st){return{isFile:!!st.isFile,isDirectory:!!st.isDirectory,isSymlink:!!st.isSymlink,size:Number(st.size)||0,modifiedAt:st.modifiedAt!=null?st.modifiedAt<1000000000000?st.modifiedAt*1000:st.modifiedAt:0}}var Tt=new Set,ur=!1;function Xr(){if(ur)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(st)=>{let ct=st.detail;if(ct?.id)Tt.delete(ct.id)}),ur=!0}var Jr=new Set(["javascript:","data:","file:","vbscript:"]),pe={async openExternal(st){let ct=st.trim().toLowerCase();for(let dt of Jr)if(ct.startsWith(dt))throw Error(`shell.openExternal: ${dt} URLs are blocked for safety`);if(e("shell")){await window.craft.shell.openExternal(st);return}if(typeof window<"u"&&typeof window.open==="function")window.open(st,"_blank","noopener,noreferrer")},async openPath(st){await ht("shell").openPath(st)},async showInFinder(st){await ht("shell").showInFinder(st)},async spawn(st,ct,dt=[],lt={}){if(Xr(),!st||typeof st!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!ct||typeof ct!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(dt))throw Error("shell.spawn: args must be an array");for(let ut of dt)if(typeof ut!=="string")throw Error("shell.spawn: args entries must be strings");if(Tt.has(st))throw Error(`shell.spawn: id "${st}" is already in use \u2014 call kill(id) first or pick a different id`);Tt.add(st);try{await ht("shell").spawn(st,ct,dt,lt)}catch(ut){throw Tt.delete(st),ut}},async kill(st){await ht("shell").kill(st),Tt.delete(st)},async getEnv(st){if(e("shell")){let ct=await window.craft.shell.getEnv(st);return ct==null?void 0:String(ct)}return},async setEnv(st,ct){await ht("shell").setEnv(st,ct)},onStdout(st){return pt("craft:shell:stdout",st)},onStderr(st){return pt("craft:shell:stderr",st)},onExit(st){return pt("craft:shell:exit",st)}};function Dt(){return window.craft.shortcuts}var fe={async register(st,ct,dt){if(!e("shortcuts"))return;await Dt().register(st,ct,dt)},async unregister(st){if(!e("shortcuts"))return;await Dt().unregister(st)},async unregisterAll(){if(!e("shortcuts"))return;await Dt().unregisterAll()},async enable(st){if(!e("shortcuts"))return;await Dt().enable(st)},async disable(st){if(!e("shortcuts"))return;await Dt().disable(st)},async isRegistered(st){if(!e("shortcuts"))return!1;return await Dt().isRegistered(st)},async list(){if(!e("shortcuts"))return[];return await Dt().list()},on(st){return pt("craft:shortcut",st)}};var me={get(){if(e("theme"))try{return window.craft.theme.get()}catch{}return{appearance:Qr()}},onChange(st){if(st(this.get()),e("theme"))return pt("craft:theme",st);if(typeof window<"u"&&window.matchMedia){let ct=window.matchMedia("(prefers-color-scheme: dark)"),dt=()=>st({appearance:ct.matches?"dark":"light"});return ct.addEventListener("change",dt),()=>ct.removeEventListener("change",dt)}return()=>{}},async current(){return this.get()}};function Qr(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function ge(st,ct={}){if(!e("dragOut"))throw Error("dragOut requires a Craft native window");let dt=Array.isArray(st)?st:[st];if(dt.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(dt,ct)}function he(){return e("dragOut")}var we={onUrl(st){if(!e("deepLink"))return()=>{};return pt("craft:deepLink",st)},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 st=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return st},isAvailable(){return e("deepLink")}};var be={async isCharging(){if(e("power"))return await window.craft.power.isCharging();let st=await qt();return st?!!st.charging:!1},async isPluggedIn(){if(e("power"))return await window.craft.power.isPluggedIn();let st=await qt();return st?!!st.charging||st.level>=0.999:!1},async isLowPowerMode(){if(e("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(e("power")){let ct=await window.craft.power.batteryLevel();return typeof ct==="number"?ct:null}let st=await qt();return st?st.level:null},async timeRemaining(){if(e("power")){let dt=await window.craft.power.timeRemaining();return typeof dt==="number"?dt:null}let st=await qt();if(!st)return null;let ct=st.charging?st.chargingTime:st.dischargingTime;return Number.isFinite(ct)?Math.round(ct/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(st="app is busy"){if(e("power")){await window.craft.power.preventSleep(st);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let ct=window;if(ct.__craftWebWakeLock?.release){try{await ct.__craftWebWakeLock.release()}catch{}ct.__craftWebWakeLock=null}try{let dt=await navigator.wakeLock.request("screen");ct.__craftWebWakeLock=dt}catch{}},async allowSleep(){if(e("power")){await window.craft.power.allowSleep();return}let st=window.__craftWebWakeLock;if(st&&typeof st.release==="function"){try{await st.release()}catch{}window.__craftWebWakeLock=null}},onSleep(st){return pt("craft:powerSleep",st)},onWake(st){return pt("craft:powerWake",st)}};async function qt(){if(typeof navigator>"u")return null;let st=navigator;if(typeof st.getBattery!=="function")return null;try{return await st.getBattery()}catch{return null}}var xe={async connectionType(){if(e("network"))return await window.craft.network.connectionType();return fr()},async wifiSSID(){if(e("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(e("network")){let st=await window.craft.network.wifiSignalStrength();return typeof st==="number"?st: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(st){if(e("network"))return pt("craft:networkChange",st);if(typeof window>"u")return()=>{};let ct=()=>st({type:fr(),online:!0}),dt=()=>st({type:"none",online:!1});return window.addEventListener("online",ct),window.addEventListener("offline",dt),()=>{window.removeEventListener("online",ct),window.removeEventListener("offline",dt)}}};function fr(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let st=navigator.connection;if(!st)return"unknown";let ct=String(st.type||st.effectiveType||"unknown").toLowerCase();if(ct==="wifi"||ct==="cellular"||ct==="ethernet"||ct==="bluetooth"||ct==="none")return ct;return"unknown"}var ye={async checkForUpdates(){if(!e("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!e("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(st){if(!e("updater"))return;await window.craft.updater.setAutomaticChecks(st)},async setCheckInterval(st){if(!e("updater"))return;if(!Number.isFinite(st))throw Error("setCheckInterval: must be a finite number");let ct=st<=0?0:Math.max(60,Math.round(st));await window.craft.updater.setCheckInterval(ct)},async setFeedURL(st){if(!e("updater"))return;await window.craft.updater.setFeedURL(st)},async getLastUpdateCheckDate(){if(!e("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!e("updater"))return null;let st=await window.craft.updater.getUpdateInfo();if(!st||typeof st.version!=="string"||st.version.length===0)return null;return st},onAvailable(st){return pt("craft:updateAvailable",st)},onDownloaded(st){return pt("craft:updateDownloaded",st)},async verifySignature({payload:st,signatureB64:ct,publicKeyB64:dt}){let lt=pr(st),ut;try{ut=await crypto.subtle.importKey("raw",Ut(dt),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",ut,Ut(ct),lt)}catch{return!1}},async verifyDownload({url:st,signatureB64:ct,publicKeyB64:dt,fetchInit:lt}){let ut;try{ut=await fetch(st,lt)}catch{return{ok:!1,reason:"fetch-failed"}}if(!ut.ok)return{ok:!1,reason:"http-error",status:ut.status};let ft=new Uint8Array(await ut.arrayBuffer()),mt;try{mt=await crypto.subtle.importKey("raw",Ut(dt),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let gt=!1;try{gt=await crypto.subtle.verify("Ed25519",mt,Ut(ct),pr(ft))}catch{gt=!1}if(!gt)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:ft}}};function pr(st){if(st instanceof ArrayBuffer)return new Uint8Array(st);let ct=new ArrayBuffer(st.byteLength),dt=new Uint8Array(ct);return dt.set(st),dt}function Ut(st){if(typeof atob==="function"){let lt=atob(st),ut=new ArrayBuffer(lt.length),ft=new Uint8Array(ut);for(let mt=0;mt<lt.length;mt++)ft[mt]=lt.charCodeAt(mt);return ft}let ct=Buffer.from(st,"base64"),dt=new ArrayBuffer(ct.length);return new Uint8Array(dt).set(ct),new Uint8Array(dt)}var ve={onFocus(st){if(e("window"))return pt("craft:window:focus",()=>st());return Yt("focus",st)},onBlur(st){if(e("window"))return pt("craft:window:blur",()=>st());return Yt("blur",st)},onResize(st){if(e("window"))return pt("craft:window:resize",st);if(typeof window>"u")return()=>{};let ct=()=>st({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",ct),()=>window.removeEventListener("resize",ct)},onMove(st){if(e("window"))return pt("craft:window:move",st);return()=>{}},onClose(st){if(e("window"))return pt("craft:window:close",()=>st());return Yt("beforeunload",st)},onMinimize(st){if(e("window"))return pt("craft:window:minimize",()=>st());if(typeof document>"u")return()=>{};let ct=()=>{if(document.visibilityState==="hidden")st()};return document.addEventListener("visibilitychange",ct),()=>document.removeEventListener("visibilitychange",ct)},onRestore(st){if(e("window"))return pt("craft:window:restore",()=>st());if(typeof document>"u")return()=>{};let ct=()=>{if(document.visibilityState==="visible")st()};return document.addEventListener("visibilitychange",ct),()=>document.removeEventListener("visibilitychange",ct)}};function Yt(st,ct){if(typeof window>"u")return()=>{};let dt=()=>ct();return window.addEventListener(st,dt),()=>window.removeEventListener(st,dt)}var mr={name:"",version:"0.0.0"},Pe={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 mr;let st=await window.craft.app.getInfo();return{...mr,...st||{}}},async notify(st){if(!st.title)throw Error("notify: title is required");if(e("app"))await window.craft.app.notify(st)},async setBadge(st){if(e("app"))await window.craft.app.setBadge(st)},async bounce(st="informational"){if(e("app"))await window.craft.app.bounce(st)}};var Se={app(st,ct={}){return{label:st,items:[{label:`About ${st}`,role:"about"},{separator:!0},...ct.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:ct.settings},{separator:!0}]:[],{label:`Hide ${st}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${st}`,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(st,ct={}){return[this.app(st,ct),this.edit()]}},Zr=0;function en(st){let ct=new Map;return{payload:{menus:st.menus.map((lt)=>({label:lt.label,items:lt.items.map((ut)=>{let{onClick:ft,...mt}=ut;if(mt.separator)return mt;let gt=mt.id??`stx.menu.${Zr++}`;if(ft)ct.set(gt,ft);return{...mt,id:gt}})}))},handlers:ct}}var Gt=null,ke={async set(st){if(!e("menu"))return!1;let{payload:ct,handlers:dt}=en(st);if(Gt?.(),Gt=null,dt.size>0)Gt=pt("craft:menu:action",(lt)=>{dt.get(lt.id)?.()});return await window.craft.menu.set(ct),!0},async setDock(st){if(e("menu"))await window.craft.menu.setDock(st)},async addItem(st,ct){if(e("menu"))await window.craft.menu.addItem(st,ct)},async removeItem(st){if(e("menu"))await window.craft.menu.removeItem(st)},async enableItem(st){if(e("menu"))await window.craft.menu.enableItem(st)},async disableItem(st){if(e("menu"))await window.craft.menu.disableItem(st)},async checkItem(st){if(e("menu"))await window.craft.menu.checkItem(st)},async uncheckItem(st){if(e("menu"))await window.craft.menu.uncheckItem(st)},async setItemLabel(st,ct){if(e("menu"))await window.craft.menu.setItemLabel(st,ct)},async clearDock(){if(e("menu"))await window.craft.menu.clearDock()},onAction(st){return pt("craft:menu:action",st)}};function wr(st){if(st.separator)return{id:st.id||"",title:"",type:"separator"};return{id:st.id||"",title:st.title||"",icon:st.icon,shortcut:st.shortcut,enabled:st.disabled?!1:void 0,checked:st.checked?!0:void 0,type:st.submenu?"submenu":void 0,submenu:st.submenu?.map(wr)}}async function gr(st){if(!st.items||st.items.length===0)throw Error("contextMenu.show requires at least one item");if(!e("nativeUI"))return null;let ct=window.craft?.nativeUI;if(!ct)return null;let dt=await ct.showContextMenu({targetId:st.targetId||"",targetType:"general",x:Math.round(st.x),y:Math.round(st.y),items:st.items.map(wr)});return{id:typeof dt?.id==="string"?dt.id:null,targetId:dt?.targetId}}var Ae={available(){return e("nativeUI")},async show(st){return await gr(st)!==null},async pick(st){return(await gr(st))?.id??null},onAction(st){return pt("craft:contextmenu:action",(ct)=>{if(typeof ct.id==="string")st({id:ct.id,targetId:ct.targetId??""})})}};function Xt(st){if(st===null||st===void 0||st===0)return"";return String(st)}function hr(st){return st.map((ct)=>({id:ct.id,header:ct.header,items:ct.items.map((dt)=>({id:dt.id,label:dt.label,icon:dt.icon,badge:Xt(dt.badge)||void 0}))}))}function vr(st){return JSON.stringify(st.map((ct)=>[ct.id,ct.header??"",ct.items.map((dt)=>[dt.id,dt.label,dt.icon??""])]))}function yr(st){return new Map(st.flatMap((ct)=>ct.items.map((dt)=>[dt.id,Xt(dt.badge)])))}var g={available(){return e("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(st){if(!g.available())return null;let ct=window.craft?.nativeUI;if(!ct)return null;let dt=ct.createSidebar({id:st.id,sections:hr(st.sections),selected:st.selected}),lt=st.sections,ut=new Set;return dt.onSelect((ft)=>{for(let mt of[...ut])mt(ft)}),{id:dt.id,update(ft){if(vr(ft)===vr(lt)){let mt=yr(lt);for(let[gt,wt]of yr(ft))if(mt.get(gt)!==wt)dt.updateItem(gt,{badge:wt})}else dt.setSections(hr(ft));lt=ft},updateItem(ft,mt){dt.updateItem(ft,{...mt.label!==void 0?{label:mt.label}:{},...mt.icon!==void 0?{icon:mt.icon}:{},..."badge"in mt?{badge:Xt(mt.badge)}:{}}),lt=lt.map((gt)=>({...gt,items:gt.items.map((wt)=>wt.id===ft?{...wt,...mt}:wt)}))},select(ft){dt.setSelectedItem(ft)},onSelect(ft){return ut.add(ft),()=>ut.delete(ft)},destroy(){ut.clear(),dt.destroy()}}}};var Ce={async getDisplays(){if(e("screen"))return await window.craft.screen.getDisplays();return br()},async getPrimary(){if(e("screen")){let st=await window.craft.screen.getPrimary();return st&&typeof st.width==="number"?st:null}return br()[0]??null},onChange(st){if(e("screen"))return pt("craft:screen:change",()=>st());if(typeof window>"u")return()=>{};let ct=()=>st();return window.addEventListener("resize",ct),()=>window.removeEventListener("resize",ct)}};function br(){if(typeof window>"u"||!window.screen)return[];let st=window.screen;return[{id:0,x:st.left??0,y:st.top??0,width:st.width||0,height:st.height||0,workX:st.availLeft??0,workY:st.availTop??0,workWidth:st.availWidth??st.width??0,workHeight:st.availHeight??st.height??0,scaleFactor:window.devicePixelRatio||1}]}var Ie={async set(st,ct,dt){if(!st)throw Error("keychain.set: service is required");if(!ct)throw Error("keychain.set: account is required");await ht("keychain").set(st,ct,dt)},async get(st,ct){if(!st)throw Error("keychain.get: service is required");if(!ct)throw Error("keychain.get: account is required");let dt=await ht("keychain").get(st,ct);return typeof dt==="string"?dt:null},async delete(st,ct){if(!st)throw Error("keychain.delete: service is required");if(!ct)throw Error("keychain.delete: account is required");await ht("keychain").delete(st,ct)},async has(st,ct){if(!st)throw Error("keychain.has: service is required");if(!ct)throw Error("keychain.has: account is required");return await ht("keychain").has(st,ct)}};var $e={async check(st){if(e("permissions"))return await window.craft.permissions.check(st);return await xr(st)},async request(st){if(e("permissions"))return await window.craft.permissions.request(st);return await tn(st)},async openSettings(st){if(e("permissions"))await window.craft.permissions.openSettings(st)}};async function xr(st){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let ct=await navigator.permissions.query({name:st});return rn(ct.state)}catch{return"not-supported"}}async function tn(st){if(st==="notifications"&&typeof window<"u"&&"Notification"in window){let ct=await window.Notification.requestPermission();return ct==="granted"?"granted":ct==="denied"?"denied":"undetermined"}return await xr(st)}function rn(st){if(st==="granted")return"granted";if(st==="denied")return"denied";if(st==="prompt")return"undetermined";return"undetermined"}var Te={async print(){if(e("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(st){if(!st)throw Error("printToPDF: path is required");let ct=st.startsWith("/"),dt=/^[a-zA-Z]:[\\/]/.test(st)||st.startsWith("\\\\");if(!ct&&!dt)throw Error("printToPDF: path must be absolute");let lt=await ht("printing").printToPDF(st);return{ok:!!(lt&<.ok),path:lt?.path}}};var Ee={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 Jt(){if(!e("window"))return null;return window.craft.window}function It(st){let ct=Jt();if(!ct)return Promise.resolve();try{return Promise.resolve(st(ct)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var Me={get available(){return Jt()!==null},open(st){let ct=()=>{if(typeof window<"u"&&st.url)window.open(st.url,st.name);return{name:st.name}},dt=Jt();if(!dt?.open)return Promise.resolve(ct());return dt.open(st).then((lt)=>({name:lt?.name||st.name})).catch(ct)},close:()=>It((st)=>st.close?.()),focus:()=>It((st)=>st.focus?.()),minimize:()=>It((st)=>st.minimize?.()),maximize:()=>It((st)=>st.maximize?.()),center:()=>It((st)=>st.center?.()),startDrag:()=>It((st)=>st.startDrag?.()),setTitle:(st)=>It((ct)=>ct.setTitle?.(st)),setSize:(st,ct)=>It((dt)=>dt.setSize?.(st,ct)),setAppearance:(st)=>It((ct)=>ct.setAppearance?.(st))};var De={async addItem(st){if(e("touchbar"))await window.craft.touchbar.addItem(st)},async removeItem(st){if(e("touchbar"))await window.craft.touchbar.removeItem(st)},async updateItem(st,ct){if(e("touchbar"))await window.craft.touchbar.updateItem(st,ct)},async setLabel(st,ct){if(e("touchbar"))await window.craft.touchbar.setLabel(st,ct)},async setIcon(st,ct){if(e("touchbar"))await window.craft.touchbar.setIcon(st,ct)},async setEnabled(st,ct){if(e("touchbar"))await window.craft.touchbar.setEnabled(st,ct)},async setSliderValue(st,ct){if(e("touchbar"))await window.craft.touchbar.setSliderValue(st,ct)},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(st){return pt("craft:touchbar:action",st)}};var nn=/^[\da-f]*$/i;function on(st,ct){if(typeof ct!=="string"||!nn.test(ct)||ct.length%2!==0)throw Error(`${st}: must be a hex string with even length, got ${JSON.stringify(ct)}`)}var Be={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(st){if(e("bluetooth"))await window.craft.bluetooth.connect(st)},async disconnect(st){if(e("bluetooth"))await window.craft.bluetooth.disconnect(st)},async openPreferences(){if(e("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(st){if(!st)throw Error("bluetooth.discoverServices: deviceId is required");if(!e("bluetooth"))return[];let ct=await window.craft.bluetooth.discoverServices(st);return Array.isArray(ct)?ct:[]},async discoverCharacteristics(st,ct){if(!st||!ct)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!e("bluetooth"))return[];let dt=await window.craft.bluetooth.discoverCharacteristics(st,ct);return Array.isArray(dt)?dt:[]},async readCharacteristic(st,ct,dt){if(!st||!ct||!dt)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!e("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(st,ct,dt)},async writeCharacteristic(st,ct,dt,lt,ut="with-response"){if(!st||!ct||!dt)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(on("bluetooth.writeCharacteristic.valueHex",lt),!e("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(st,ct,dt,lt,ut)},async setCharacteristicNotify(st,ct,dt,lt){if(!st||!ct||!dt)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!e("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(st,ct,dt,lt)},onDeviceFound(st){return pt("craft:bluetooth:deviceFound",st)},onDeviceConnected(st){return pt("craft:bluetooth:deviceConnected",st)},onDeviceDisconnected(st){return pt("craft:bluetooth:deviceDisconnected",st)},onCharacteristicValue(st){return pt("craft:bluetooth:characteristicValue",st)}};var Oe={async speak(st,ct){if(!st)throw Error("speech.speak: text is required");if(e("speech")){await window.craft.speech.speak(st,ct);return}if(typeof window<"u"&&window.speechSynthesis){let dt=new window.SpeechSynthesisUtterance(st);if(ct){if(ct.rate!=null)dt.rate=ct.rate;if(ct.pitch!=null)dt.pitch=ct.pitch;if(ct.volume!=null)dt.volume=ct.volume;if(ct.voice){let ut=window.speechSynthesis.getVoices().find((ft)=>ft.voiceURI===ct.voice||ft.name===ct.voice||ft.lang===ct.voice);if(ut)dt.voice=ut}}window.speechSynthesis.speak(dt)}},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((ct)=>({id:ct.voiceURI||ct.name,name:ct.name,language:ct.lang||"",quality:"default"}));return[]}};var Rt=[],Qt=!0,Zt,er,o={async report(st){if(e("crashReporter")){await window.craft.crashReporter.report(st);return}if(!Qt)return;let ct=st instanceof Error?{timestamp:Date.now(),severity:"error",message:st.message,source:"js",stack:st.stack||"",userId:Zt,appVersion:er}:{timestamp:Date.now(),severity:st.severity||"error",message:st.message||"",source:st.source||"js",stack:st.stack||"",userId:Zt,appVersion:er};if(Rt.length>=64)Rt.shift();Rt.push(ct)},async flush(){if(e("crashReporter"))return await window.craft.crashReporter.flush();return[...Rt]},async clear(){if(e("crashReporter")){await window.craft.crashReporter.clear();return}Rt.length=0},async setEnabled(st){if(e("crashReporter")){await window.craft.crashReporter.setEnabled(st);return}Qt=st},async isEnabled(){if(e("crashReporter"))return await window.craft.crashReporter.isEnabled();return Qt},async setUser(st){if(e("crashReporter")){await window.craft.crashReporter.setUser(st);return}Zt=st||void 0},async setAppVersion(st){if(e("crashReporter")){await window.craft.crashReporter.setAppVersion(st);return}er=st||void 0},attachGlobalHandlers(){if(e("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let st=(dt)=>{o.report({severity:"error",message:dt.message,source:"js",stack:dt.error?.stack||`${dt.message}
|
|
343
|
+
at ${dt.filename}:${dt.lineno}:${dt.colno}`}).catch(()=>{})},ct=(dt)=>{let lt=dt.reason;o.report({severity:"error",message:lt?.message||String(lt),source:"js",stack:lt?.stack||""}).catch(()=>{})};return window.addEventListener("error",st),window.addEventListener("unhandledrejection",ct),()=>{window.removeEventListener("error",st),window.removeEventListener("unhandledrejection",ct)}},forwardTo(st){return un(st)}},an="craft:crashReporter:pending",sn=/[\w.+-]+@[\w-]+\.[\w.-]+/g,cn=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,dn=/\/(?:Users|home)\/[^\s/'"`]+/g;function h(st){let ct=(dt)=>dt.replace(sn,"<email>").replace(cn,"<ip>").replace(dn,"/<home>");return{...st,message:ct(st.message),stack:ct(st.stack)}}async function w(st,ct){let dt=new TextEncoder,lt=await crypto.subtle.importKey("raw",dt.encode(st),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),ut=await crypto.subtle.sign("HMAC",lt,dt.encode(ct));return[...new Uint8Array(ut)].map((ft)=>ft.toString(16).padStart(2,"0")).join("")}function ln(st){if(!st||typeof localStorage>"u")return[];try{let ct=localStorage.getItem(st);if(!ct)return[];let dt=JSON.parse(ct);return Array.isArray(dt)?dt:[]}catch{return[]}}function Pr(st,ct){if(!st||typeof localStorage>"u")return;try{if(ct.length===0)localStorage.removeItem(st);else localStorage.setItem(st,JSON.stringify(ct))}catch{}}function un(st){let{endpoint:ct,intervalMs:dt=60000,signingSecret:lt,redact:ut=!0,headers:ft={},maxRetries:mt=5,persistKey:gt}=st,wt=gt===null?null:gt??an,vt=ln(wt),xt=!1,kt=null,Pt=null,kr=typeof ut==="function"?ut:ut===!1?(Et)=>Et:h;async function Er(Et){let Lt=JSON.stringify({entries:Et}),_t={"Content-Type":"application/json",...ft};if(lt)_t["X-Craft-Signature"]=await w(lt,Lt);let rr=0,Ht=1000;while(!xt)try{let Bt=await fetch(ct,{method:"POST",headers:_t,body:Lt});if(Bt.ok)return;if(Bt.status>=400&&Bt.status<500)return;throw Error(`HTTP ${Bt.status}`)}catch(Bt){if(rr+=1,rr>mt)throw vt=[...Et,...vt],Pr(wt,vt),Bt;await new Promise((Cr)=>{setTimeout(Cr,Ht)}),Ht=Math.min(Ht*2,60000)}}async function tr(){if(xt||Pt)return Pt??void 0;let Et=await o.flush();if(Et.length>0)await o.clear();if(vt=[...vt,...Et.map((_t)=>kr(_t))],vt.length===0)return;let Lt=vt;return vt=[],Pr(wt,vt),Pt=Er(Lt).catch(()=>{}).finally(()=>{Pt=null}),Pt}if(dt>0)kt=setInterval(()=>{tr().catch(()=>{})},dt);return{async flushNow(){await tr()},stop(){if(xt=!0,kt)clearInterval(kt);kt=null},pending(){return[...vt]}}}var Le={async isAvailable(){if(!e("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(st){if(!e("iap"))return[];let ct=Array.isArray(st)?st:[String(st)];return await window.craft.iap.getProducts(ct)},async purchase(st){if(!e("iap"))return{queued:!1,productId:st,reason:"IAP bridge not available"};let ct=await window.craft.iap.purchase(st);return{queued:!!(ct&&ct.queued),productId:ct?.productId,reason:ct?.reason}},async restorePurchases(){if(!e("iap"))return{ok:!1};let st=await window.craft.iap.restorePurchases();return{ok:!!(st&&st.ok)}},async finishTransaction(st){if(!e("iap"))return;await window.craft.iap.finishTransaction(st)},async getReceiptData(){if(!e("iap"))return null;let st=await window.craft.iap.getReceiptData();return st?String(st):null},onPurchased(st){return pt("craft:iap:purchased",st)},onFailed(st){return pt("craft:iap:failed",st)},onRestored(st){return pt("craft:iap:restored",st)},onProductsLoaded(st){return pt("craft:iap:productsLoaded",(ct)=>st(ct.products||[]))},onRefunded(st){return pt("craft:iap:refunded",st)},onSubscriptionStatusChanged(st){return pt("craft:iap:subscriptionStatusChanged",st)},async getActiveSubscriptions(){if(!e("iap"))return[];let st=window.craft.iap.getActiveSubscriptions;if(typeof st!=="function")return[];let ct=await st();return Array.isArray(ct)?ct:[]},async isEligibleForIntroOffer(st){if(!e("iap"))return!1;let ct=window.craft.iap.isEligibleForIntroOffer;if(typeof ct!=="function")return!1;return!!await ct(st)}};var i={async startActivity(st,ct){if(!st)throw Error("handoff.startActivity: type is required");if(!e("handoff"))return!1;let dt=await window.craft.handoff.startActivity(st,ct);return typeof dt==="boolean"?dt:!!(dt&&dt.ok)},async updateActivity(st){if(!e("handoff"))return!1;let ct=await window.craft.handoff.updateActivity(st);return typeof ct==="boolean"?ct:!!(ct&&ct.ok)},async stopActivity(){if(!e("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!e("handoff"))return null;let st=await window.craft.handoff.getCurrentActivity();return st&&typeof st.type==="string"?st:null},onIncoming(st){return pt("craft:handoff:incoming",st)}};var Re={async start(st,ct){return i.startActivity(st,{title:ct?.title,webpageURL:ct?.webpageURL,userInfo:ct?.state})},async update(st){return i.updateActivity({title:st.title,webpageURL:st.webpageURL,userInfo:st.state})},async stop(){await i.stopActivity()}};var _e={async requestPermission(st="whenInUse"){if(e("location"))return await window.craft.location.requestPermission(st);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((st)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:st.coords.latitude,longitude:st.coords.longitude,altitude:st.coords.altitude,horizontalAccuracy:st.coords.accuracy,verticalAccuracy:st.coords.altitudeAccuracy,speed:st.coords.speed}}))},(st)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:st.message||String(st)}}))}),{requested:!0};return{requested:!1}},async startWatching(st){if(e("location"))return await window.craft.location.startWatching(st);if(typeof navigator<"u"&&navigator.geolocation){let ct=navigator.geolocation.watchPosition((dt)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:dt.coords.latitude,longitude:dt.coords.longitude,altitude:dt.coords.altitude,horizontalAccuracy:dt.coords.accuracy,verticalAccuracy:dt.coords.altitudeAccuracy,speed:dt.coords.speed}}))});return window.__craftWebLocationWatchId=ct,!0}return!1},async stopWatching(){if(e("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let st=window.__craftWebLocationWatchId;if(st!=null)navigator.geolocation.clearWatch(st),window.__craftWebLocationWatchId=null}},onUpdate(st){return pt("craft:location:update",st)},onError(st){return pt("craft:location:error",st)},onAuthChanged(st){return pt("craft:location:authChanged",st)}};var Ne={async captureScreen(){if(!e("screenCapture"))return null;let st=await window.craft.screenCapture.captureScreen();return st?String(st):null},async captureWindow(st){if(!e("screenCapture"))return null;if(!Number.isFinite(st)||st<=0)throw Error("captureWindow: id must be a positive number");let ct=await window.craft.screenCapture.captureWindow(st);return ct?String(ct):null},async listWindows(){if(!e("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var b=250,x=60000,c=2000,Sr={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function fn(){return{...Sr,signals:{...Sr.signals},sources:[]}}var a={async getState(){if(!e("screenSharing"))return fn();return await window.craft.screenSharing.getState()},async watch(st=c){let ct=Math.min(x,Math.max(b,Math.round(st)));if(!e("screenSharing"))return ct;let dt=await window.craft.screenSharing.watch(ct);return dt&&dt.intervalMs||ct},async stop(){if(!e("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(st){return pt("craft:screenSharing:change",st)}};async function Fe(st,ct=c){let dt=a.onChange(st);return await a.watch(ct),()=>{dt(),a.stop()}}var pn={supported:!1,isFocused:null,authorization:"unsupported"};function Ar(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var l={async getStatus(){if(!e("focus"))return{...pn};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!e("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(st,ct={}){if(!e("focus"))return Ar();if(!(st?ct.onShortcut:ct.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${st?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(st,ct)},async runShortcut(st){if(!e("focus"))return Ar();if(!st)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(st)},async listShortcuts(){if(!e("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!e("focus"))return{canList:!1,shortcuts:[]};let ct=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean(ct?.canList),shortcuts:ct?.shortcuts??[]}}};async function ze(...st){if(st.length===0)return!1;let ct=new Set(await l.listShortcuts());return st.every((dt)=>ct.has(dt))}async function We(...st){if(st.length===0)return!1;let{canList:ct,shortcuts:dt}=await l.listShortcutsResult();if(!ct)return"unknown";let lt=new Set(dt);return st.every((ut)=>lt.has(ut))}var He={async start(st=0,ct="127.0.0.1"){if(!e("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(st,ct)},async stop(){if(!e("localServer"))return;await window.craft.localServer.stop()},async respond(st){if(!e("localServer"))return;await window.craft.localServer.respond(st||{status:200,body:"OK"})},onRequest(st){return pt("craft:localServer:request",st)},async awaitOAuthCallback(st={}){ht("localServer");let{port:ct=0,host:dt="127.0.0.1",timeoutMs:lt=300000,successHTML:ut}=st,ft=await this.start(ct,dt);if(!ft.started)throw Error(`localServer: start failed${ft.reason?` \u2014 ${ft.reason}`:""}`);return new Promise((mt,gt)=>{let wt=setTimeout(()=>{vt(),this.stop().catch(()=>{}),gt(Error("localServer: OAuth callback timed out"))},lt),vt=this.onRequest(({url:xt})=>{clearTimeout(wt),vt();let kt=ut??`<!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:kt,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),mt({url:xt,port:ft.port})})})}};var Ue={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(st,ct){if(!st)throw Error("biometric.evaluate: reason is required");if(!e("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(st,ct)}};var bt=null,qe={async play(st,ct){if(e("audio"))return await window.craft.audio.play(st,ct);if(typeof window>"u"||typeof Audio>"u")return!1;if(bt)bt.pause(),bt=null;if(bt=new Audio(st),ct?.volume!=null)bt.volume=ct.volume;if(ct?.loops)bt.loop=!0;try{return await bt.play(),!0}catch{return!1}},async playSystemSound(st){if(e("audio"))return await window.craft.audio.playSystemSound(st);if(typeof window>"u"||typeof Audio>"u")return!1;try{return bt=new Audio(`/System/Library/Sounds/${st}.aiff`),await bt.play(),!0}catch{return!1}},async stop(){if(e("audio")){await window.craft.audio.stop();return}if(bt)bt.pause(),bt.currentTime=0,bt=null},async isPlaying(){if(e("audio"))return await window.craft.audio.isPlaying();return!!(bt&&!bt.paused)},async startRecording(st,ct){if(e("audio"))return await window.craft.audio.startRecording(st,ct);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 Ve={async execute(st){if(!st)throw Error("appleScript.execute: source is required");if(!e("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(st)}};var je={async getDefault(st){if(!st)throw Error("fileAssociations.getDefault: uti is required");if(!e("fileAssociations"))return null;let ct=await window.craft.fileAssociations.getDefault(st);return ct?String(ct):null},async setDefault(st,ct){if(!st||!ct)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!e("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(st,ct)}};var Ke={async get(st){if(!st)throw Error("tags.get: path is required");if(!e("tags"))return[];return await window.craft.tags.get(st)},async set(st,ct){if(!st)throw Error("tags.set: path is required");if(!e("tags"))return!1;let dt=Array.isArray(ct)?ct:[String(ct)];return await window.craft.tags.set(st,dt)},async clear(st){if(!st)throw Error("tags.clear: path is required");if(!e("tags"))return!1;return await window.craft.tags.clear(st)}};var Ge={async countPages(st){if(!st)throw Error("pdf.countPages: path is required");if(!e("pdf"))return 0;return await window.craft.pdf.countPages(st)},async extractText(st){if(!st)throw Error("pdf.extractText: path is required");if(!e("pdf"))return"";return await window.craft.pdf.extractText(st)}};var Ye={async debug(st){if(e("log"))await window.craft.log.debug(st);else console.debug(st)},async info(st){if(e("log"))await window.craft.log.info(st);else console.info(st)},async warn(st){if(e("log"))await window.craft.log.warn(st);else console.warn(st)},async error(st){if(e("log"))await window.craft.log.error(st);else console.error(st)}};var Xe={async browse(st){if(!e("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(st)},async stop(){if(e("bonjour"))await window.craft.bonjour.stop()},onFound(st){return pt("craft:bonjour:found",st)},onLost(st){return pt("craft:bonjour:lost",st)}};var Je={async index(st){if(!e("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(st)},async remove(st){if(!e("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(st)},async removeAll(){if(!e("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var Qe={async isAvailable(){if(!e("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(st){if(!e("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(st)},async stop(){if(e("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(st){return pt("craft:speechRecognition:partial",st)},onFinal(st){return pt("craft:speechRecognition:final",st)}};var Ze={async recognizeText(st){if(!st)throw Error("vision.recognizeText: path is required");if(!e("vision"))return[];return await window.craft.vision.recognizeText(st)},async detectFaces(st){if(!st)throw Error("vision.detectFaces: path is required");if(!e("vision"))return[];return await window.craft.vision.detectFaces(st)},async detectBarcodes(st){if(!st)throw Error("vision.detectBarcodes: path is required");if(!e("vision"))return[];return await window.craft.vision.detectBarcodes(st)}};var et={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(st,ct){if(!e("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(st,ct)},async subscribe(st){if(!e("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(st)},async unsubscribe(st){if(!e("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(st)},onMessage(st){return pt("craft:midi:message",st)}};var tt={async loadModel(st,ct){if(!st||!ct)throw Error("coreml.loadModel: id and path are required");if(!e("coreml"))return!1;return await window.craft.coreml.loadModel(st,ct)},async unloadModel(st){if(!e("coreml"))return;await window.craft.coreml.unloadModel(st)},async predict(st,ct){if(!st)throw Error("coreml.predict: id is required");if(!e("coreml"))return null;return await window.craft.coreml.predict(st,ct)}};var rt={async listCameras(){if(!e("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var nt={async register(st){if(!st)throw Error("serviceMenu.register: name is required");if(!e("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(st)},async unregister(st){if(!st)throw Error("serviceMenu.unregister: name is required");if(!e("serviceMenu"))return;await window.craft.serviceMenu.unregister(st)},onInvoked(st){return pt("craft:serviceMenu:invoked",st)}};var ot={async list(){if(!e("serial"))return[];return await window.craft.serial.list()},async open(st,ct=9600){if(!st)throw Error("serial.open: path is required");if(!e("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(st,ct)},async write(st,ct){if(!st)throw Error("serial.write: id is required");if(!e("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(st,ct)},async close(st){if(!e("serial"))return;await window.craft.serial.close(st)},onData(st){return pt("craft:serial:data",st)}};var Ir=[{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 it(){return Ir.map(({name:st,support:ct})=>({name:st,support:ct,available:e(st)}))}function y(st){let ct=Ir.find((dt)=>dt.name===st);if(!ct)return;return{...ct,available:e(st)}}function at(st){let ct=y(st);return!!ct&&ct.available}
|
|
347
|
+
export{v,s,r,P,S,k,A,C,I,T,E,M,t,d,D,B,O,u,L,R,_,N,F,z,W,H,n,U,q,V,j,K,G,Y,p,X,J,Q,Z,f,ee,te,m,re,ne,oe,ie,ae,se,ce,e,le,de,ue,pe,fe,me,ge,he,we,be,xe,ye,ve,Pe,Se,ke,Ae,g,Ce,Ie,$e,Te,Ee,Me,De,Be,Oe,o,h,w,Le,i,Re,_e,Ne,b,x,c,a,Fe,l,ze,We,He,Ue,qe,Ve,je,Ke,Ge,Ye,Xe,Je,Qe,Ze,et,tt,rt,nt,ot,it,y,at};
|