@stacksjs/desktop 0.2.198 → 0.2.200
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 -223
- package/dist/chunk-0954hbsb.js +315 -0
- package/dist/chunk-ts9f0mxv.js +3 -0
- package/dist/index.js +78 -2256
- package/dist/test-utils.js +1 -105
- package/package.json +1 -1
- package/dist/chunk-2mx7fq49.js +0 -4
- package/dist/chunk-ys4frvmj.js +0 -3960
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function HZ(){if(typeof Notification<"u"&&Notification.permission==="granted")return!0;return!1}function g(){return typeof window<"u"&&typeof document<"u"}async function P4(){if(typeof Notification>"u")return!1;if(Notification.permission==="granted")return!0;if(Notification.permission==="denied")return!1;return await Notification.requestPermission()==="granted"}var q=new Map;function qZ(){return`alert-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function UZ(Z){switch(Z){case"info":return"ℹ";case"success":return"✔";case"warning":return"⚠";case"error":return"✖";default:return"ℹ"}}function MZ(Z="top-right"){if(!g())throw Error("Toast container requires browser environment");try{let Y=document.querySelector(`.stx-toast-container[data-position="${Z}"]`);if(Y)return Y}catch{}let $=document.createElement("div");$.className=`stx-toast-container ${Z}`,$.dataset.position=Z;try{if(document.body)document.body.appendChild($)}catch{}return $}function TZ(Z){let{options:$}=Z,Y=UZ($.type),z=$.type||"info",G=$.duration!==0;return`
|
|
3
|
+
<div class="stx-toast ${z}" data-alert-id="${Z.id}" role="alert" aria-live="polite">
|
|
4
|
+
<div class="stx-toast-icon">${Y}</div>
|
|
5
|
+
<div class="stx-toast-content">
|
|
6
|
+
${$.title?`<div class="stx-toast-title">${t($.title)}</div>`:""}
|
|
7
|
+
<div class="stx-toast-message">${t($.message)}</div>
|
|
8
|
+
</div>
|
|
9
|
+
${G?'<button class="stx-toast-close" aria-label="Close">×</button>':""}
|
|
10
|
+
</div>
|
|
11
|
+
`}function t(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function E(Z){if(Z.timeout)clearTimeout(Z.timeout);if(q.delete(Z.id),Z.element&&g())Z.element.classList.add("dismissing"),setTimeout(()=>{Z.element?.remove()},200)}async function e(Z){let $=qZ(),Y=HZ(),z=Z.duration??5000,G={id:$,options:Z};if(q.set($,G),Y&&Z.type!=="error")try{let Q=new Notification(Z.title||"Notification",{body:Z.message,icon:Z.type==="success"?"\u2713":Z.type==="warning"?"\u26A0":"\u2139",tag:$});if(Q.onclick=()=>{if(Z.onClick)Z.onClick();Q.close()},z>0)G.timeout=setTimeout(()=>{Q.close(),q.delete($)},z);return}catch{}if(g())try{let Q=MZ(Z.position),P=document.createElement("div");P.innerHTML=TZ(G);let X=P.firstElementChild;if(!X){let F=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${F}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`);return}G.element=X;try{Q.appendChild(X)}catch{let F=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${F}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`);return}if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>{try{X.classList.add("visible")}catch{}});try{X.addEventListener("click",(F)=>{if(F.target.classList?.contains("stx-toast-close")){E(G);return}if(Z.onClick)Z.onClick()})}catch{}if(z>0)G.timeout=setTimeout(()=>{E(G)},z)}catch{let Q=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${Q}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`)}else{let Q=(Z.type||"info").toUpperCase();if(console.log(`[stx-alert] ${Q}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`),z>0)G.timeout=setTimeout(()=>{q.delete($)},z)}}async function C(Z){return e({...Z,position:Z.position||"top-right"})}async function V4(Z,$=3000){return C({message:Z,type:"info",duration:$})}async function F4(Z,$=3000){return C({message:Z,type:"success",duration:$})}async function j4(Z,$=3000){return C({message:Z,type:"warning",duration:$})}async function W4(Z,$=5000){return C({message:Z,type:"error",duration:$})}async function K4(Z,$,Y="info"){return e({title:Z,message:$,type:Y})}function N4(Z){let $=q.get(Z);if($)E($)}function R4(){for(let Z of q.values())E(Z)}function L4(){return q.size}var D4=`
|
|
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 SZ(){return!1}function u(){return typeof window<"u"&&typeof document<"u"}var U=[];function AZ(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function xZ(Z){switch(Z){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function I(Z){if(Z==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function _Z(Z){let{options:$}=Z,Y=xZ($.type),z=$.buttons||I($.type),G=$.type||"info",Q="";return z.forEach((P,X)=>{let F=P.style==="destructive"?"destructive":P.style==="primary"?"primary":"default",j=X===($.defaultButton??z.length-1)?"autofocus":"";Q+=`<button class="stx-modal-btn ${F}" data-index="${X}" ${j}>${P.label}</button>`}),`
|
|
114
|
+
<div class="stx-modal-overlay" data-modal-id="${Z.id}">
|
|
115
|
+
<div class="stx-modal ${G}" role="dialog" aria-modal="true" aria-labelledby="${Z.id}-title">
|
|
116
|
+
<div class="stx-modal-icon">${Y}</div>
|
|
117
|
+
<div class="stx-modal-content">
|
|
118
|
+
${$.title?`<h2 id="${Z.id}-title" class="stx-modal-title">${ZZ($.title)}</h2>`:""}
|
|
119
|
+
<p class="stx-modal-message">${ZZ($.message)}</p>
|
|
120
|
+
</div>
|
|
121
|
+
<div class="stx-modal-buttons">${Q}</div>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
`}function ZZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function L(Z,$,Y=!1){let z=U.indexOf(Z);if(z>-1)U.splice(z,1);if(Z.element&&u())Z.element.remove();let Q=(Z.options.buttons||I(Z.options.type))[$];if(Q?.action)Q.action();Z.resolve({buttonIndex:$,cancelled:Y})}async function T(Z){let $=SZ(),Y=AZ();return new Promise((z)=>{let G={id:Y,options:Z,resolve:z};if(U.push(G),$)console.log(`[stx-modal] Showing native modal: ${Z.title||"Modal"}`),setTimeout(()=>{L(G,Z.defaultButton??0,!1)},0);else if(u())try{let Q=document.createElement("div");Q.innerHTML=_Z(G);let P=Q.firstElementChild;if(!P){console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`),setTimeout(()=>{L(G,Z.defaultButton??0,!1)},0);return}G.element=P;try{document.body.appendChild(P)}catch{console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`),setTimeout(()=>{L(G,Z.defaultButton??0,!1)},0);return}try{P.querySelectorAll(".stx-modal-btn").forEach((X)=>{X.addEventListener("click",()=>{let F=Number.parseInt(X.dataset.index||"0",10);L(G,F,!1)})})}catch{}try{P.addEventListener("click",(X)=>{if(X.target===P){let F=Z.cancelButton??0;L(G,F,!0)}})}catch{}try{let X=(F)=>{if(F.key==="Escape"){let j=Z.cancelButton??0;L(G,j,!0),document.removeEventListener("keydown",X)}else if(F.key==="Enter"){let j=Z.defaultButton??(Z.buttons||I(Z.type)).length-1;L(G,j,!1),document.removeEventListener("keydown",X)}};document.addEventListener("keydown",X)}catch{}try{let X=P.querySelector(".stx-modal-btn[autofocus]");if(X)X.focus()}catch{}if(typeof process<"u"&&process.env.BUN_TEST)setTimeout(()=>{L(G,Z.defaultButton??0,!1)},0)}catch{console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`),setTimeout(()=>{L(G,Z.defaultButton??0,!1)},0)}else{console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`);let Q=Z.buttons||I(Z.type);console.log(`[stx-modal] Buttons: ${Q.map((P)=>P.label).join(", ")}`),setTimeout(()=>{L(G,Z.defaultButton??0,!1)},0)}})}async function EZ(Z,$){return T({title:Z,message:$,type:"info"})}async function H4(Z,$){return T({title:Z,message:$,type:"warning"})}async function q4(Z,$){return T({title:Z,message:$,type:"error"})}async function U4(Z,$){return T({title:Z,message:$,type:"success"})}async function CZ(Z,$){return T({title:Z,message:$,type:"question",buttons:[{label:"No",style:"default"},{label:"Yes",style:"primary"}],defaultButton:1,cancelButton:0})}async function M4(Z,$="Confirm"){return(await CZ($,Z)).buttonIndex===1}async function T4(Z,$="Alert"){await EZ($,Z)}async function S4(Z,$="",Y="Input"){if(u()&&typeof window.prompt==="function")return window.prompt(Z,$);return console.log(`[stx-modal] PROMPT: ${Y}`),console.log(`[stx-modal] ${Z}`),console.log(`[stx-modal] Default: ${$}`),$}function A4(){return U.length}function x4(){while(U.length>0){let Z=U[U.length-1];L(Z,0,!0)}}var _4=`
|
|
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 w(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function C4(Z={}){if(w()){let $=window;try{return await $.craft.dialog.showOpenDialog(Z)}catch(Y){console.warn("[stx-dialog] Failed to show native open dialog:",Y)}}return new Promise(($)=>{if(typeof document>"u"){$({canceled:!0,filePaths:[]});return}let Y=document.createElement("input");if(Y.type="file",Y.multiple=Z.multiSelections??!1,Z.filters?.length){let z=Z.filters.flatMap((G)=>G.extensions.map((Q)=>`.${Q}`));Y.accept=z.join(",")}if(Z.canChooseDirectories&&!Z.canChooseFiles)Y.webkitdirectory=!0;Y.onchange=()=>{let z=Array.from(Y.files||[]);if(z.length===0)$({canceled:!0,filePaths:[]});else{let G=z.map((Q)=>Q.name);$({canceled:!1,filePaths:G})}},Y.oncancel=()=>{$({canceled:!0,filePaths:[]})},Y.click()})}async function I4(Z={}){if(w()){let Y=window;try{return await Y.craft.dialog.showSaveDialog(Z)}catch(z){console.warn("[stx-dialog] Failed to show native save dialog:",z)}}if(typeof window<"u"&&"showSaveFilePicker"in window)try{let Y=Z.filters?.map((G)=>({description:G.name,accept:{"*/*":G.extensions.map((Q)=>`.${Q}`)}}));return{canceled:!1,filePath:(await window.showSaveFilePicker({suggestedName:Z.defaultPath,types:Y})).name}}catch(Y){return{canceled:!0}}console.warn("[stx-dialog] Save dialog not available, using prompt fallback");let $=prompt("Enter filename:",Z.defaultPath||"file.txt");if($)return{canceled:!1,filePath:$};return{canceled:!0}}async function y(Z){if(w()){let z=window;try{return await z.craft.dialog.showMessageBox(Z)}catch(G){console.warn("[stx-dialog] Failed to show native message box:",G)}}let $=Z.buttons||["OK"];if($.length===1)return alert(Z.message),{response:0};if($.length===2&&Z.type==="question")return{response:confirm(Z.message)?1:0};return console.warn("[stx-dialog] Complex message box not fully supported in browser, using confirm"),{response:confirm(`${Z.message}
|
|
257
|
+
|
|
258
|
+
${$.join(" / ")}`)?$.length-1:0}}async function w4(Z={}){if(w()){let $=window;try{return await $.craft.dialog.showColorPicker(Z)}catch(Y){console.warn("[stx-dialog] Failed to show native color picker:",Y)}}return new Promise(($)=>{if(typeof document>"u"){$({canceled:!0});return}let Y=document.createElement("input");Y.type="color",Y.value=Z.color||"#000000",Y.onchange=()=>{$({canceled:!1,color:Y.value})},Y.oncancel=()=>{$({canceled:!0})},Y.click()})}async function y4(Z,$){await y({type:"info",title:$||"Alert",message:Z,buttons:["OK"]})}async function f4(Z,$){return(await y({type:"question",title:$||"Confirm",message:Z,buttons:["Cancel","OK"],defaultButton:1,cancelButton:0})).response===1}async function m4(Z,$){await y({type:"error",title:$||"Error",message:Z,buttons:["OK"]})}async function B4(Z,$){await y({type:"warning",title:$||"Warning",message:Z,buttons:["OK"]})}function v4(){return`
|
|
259
|
+
// STX Desktop Dialog Bridge
|
|
260
|
+
// Provides convenient wrappers around window.craft.dialog APIs
|
|
261
|
+
window.stxDialog = {
|
|
262
|
+
// File dialogs
|
|
263
|
+
showOpenDialog: (options) => window.craft?.dialog?.showOpenDialog(options),
|
|
264
|
+
showSaveDialog: (options) => window.craft?.dialog?.showSaveDialog(options),
|
|
265
|
+
|
|
266
|
+
// Message dialogs
|
|
267
|
+
showMessageBox: (options) => window.craft?.dialog?.showMessageBox(options),
|
|
268
|
+
|
|
269
|
+
// Color picker
|
|
270
|
+
showColorPicker: (options) => window.craft?.dialog?.showColorPicker(options),
|
|
271
|
+
|
|
272
|
+
// Font picker
|
|
273
|
+
showFontPicker: (options) => window.craft?.dialog?.showFontPicker(options),
|
|
274
|
+
|
|
275
|
+
// Convenience functions
|
|
276
|
+
alert: async (message, title) => {
|
|
277
|
+
return window.craft?.dialog?.showMessageBox({
|
|
278
|
+
type: 'info',
|
|
279
|
+
title: title || 'Alert',
|
|
280
|
+
message,
|
|
281
|
+
buttons: ['OK'],
|
|
282
|
+
});
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
confirm: async (message, title) => {
|
|
286
|
+
const result = await window.craft?.dialog?.showMessageBox({
|
|
287
|
+
type: 'question',
|
|
288
|
+
title: title || 'Confirm',
|
|
289
|
+
message,
|
|
290
|
+
buttons: ['Cancel', 'OK'],
|
|
291
|
+
});
|
|
292
|
+
return result?.response === 1;
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
error: async (message, title) => {
|
|
296
|
+
return window.craft?.dialog?.showMessageBox({
|
|
297
|
+
type: 'error',
|
|
298
|
+
title: title || 'Error',
|
|
299
|
+
message,
|
|
300
|
+
buttons: ['OK'],
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
// Check if dialog is available
|
|
305
|
+
isAvailable: () => typeof window.craft?.dialog !== 'undefined',
|
|
306
|
+
};
|
|
307
|
+
`}var h=null,W=null;class $Z{_process;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(Z,$){this._process=Z,this._options=$,this._startedAt=new Date;let Y=$.duration;if(Y&&Y>0){let z=Y*60*1000;this._endsAt=new Date(this._startedAt.getTime()+z),this._expireTimer=setTimeout(()=>{this._stopped=!0;for(let G of this._expireHandlers)try{G()}catch{}},z)}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 Z=this._endsAt.getTime()-Date.now();return Math.max(0,Z)}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(Z){this._expireHandlers.push(Z)}}function l4(Z={}){IZ();let{duration:$,preventDisplaySleep:Y=!0,preventIdleSleep:z=!0,preventSystemSleep:G=!0,preventDiskSleep:Q=!1,assertUserActivity:P=!0}=Z,X=[];if(Y)X.push("-d");if(z)X.push("-i");if(G)X.push("-s");if(Q)X.push("-m");if(P)X.push("-u");let F=[...X];if($&&$>0)F.push("-t",String($*60));let j=Bun.spawn(["/usr/bin/caffeinate",...F],{stdio:["ignore","ignore","ignore"]}),N=new $Z(j,Z);return h=j,W=N,N}function IZ(Z){if(Z){if(Z.stop(),W===Z)h=null,W=null;return}if(W)W.stop();h=null,W=null}function g4(){return W!==null&&W.isActive}function u4(){if(!W||!W.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let $=W.options.duration;return{active:!0,instance:W,startedAt:W.startedAt,endsAt:W.endsAt,durationMinutes:$&&$>0?$:-1}}function h4(Z){let $=Z||W;if(!$||!$.isActive)return"0:00";let Y=$.remainingMs;if(Y===null)return"\u221E";let z=Math.ceil(Y/1000),G=Math.floor(z/3600),Q=Math.floor(z%3600/60),P=z%60;if(G>0)return`${G}:${String(Q).padStart(2,"0")}:${String(P).padStart(2,"0")}`;return`${Q}:${String(P).padStart(2,"0")}`}function c4(Z){if(Z<=0||Z===-1)return"Indefinitely";if(Z<60)return`${Z} minutes`;if(Z===60)return"1 hour";if(Z%60===0)return`${Z/60} hours`;let $=Math.floor(Z/60),Y=Z%60;return`${$}h ${Y}m`}var D=new Map,wZ=0,f=!1;function yZ(Z){let $=Z.split("+").map((z)=>z.trim()),Y={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let z of $){let G=z.toLowerCase();switch(G){case"cmd":case"command":case"meta":case"\u2318":Y.meta=!0;break;case"ctrl":case"control":case"\u2303":Y.ctrl=!0;break;case"shift":case"\u21E7":Y.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":Y.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")Y.meta=!0;else Y.ctrl=!0;break;default:Y.key=G}}return Y}function d4(Z){let $=[];if(Z.ctrl)$.push("\u2303");if(Z.alt)$.push("\u2325");if(Z.shift)$.push("\u21E7");if(Z.meta)$.push("\u2318");return $.push(Z.key.toUpperCase()),$.join("")}function fZ(Z,$){if($.meta!==Z.metaKey)return!1;if($.ctrl!==Z.ctrlKey)return!1;if($.shift!==Z.shiftKey)return!1;if($.alt!==Z.altKey)return!1;return Z.key.toLowerCase()===$.key||Z.code.toLowerCase()===`key${$.key}`}function JZ(Z){for(let[,$]of D)if(fZ(Z,$.parsed)){Z.preventDefault(),Z.stopPropagation();try{$.handler()}catch{}break}}function mZ(){if(f)return;if(typeof document>"u")return;document.addEventListener("keydown",JZ,!0),f=!0}function c(){if(!f)return;if(typeof document>"u")return;document.removeEventListener("keydown",JZ,!0),f=!1}async function BZ(Z,$){if(typeof window>"u")return!1;let Y=window.craft;if(!Y?.hotkeys?.register)return!1;try{return await Y.hotkeys.register(Z,$),!0}catch{return!1}}async function p(Z){if(typeof window>"u")return;let $=window.craft;if(!$?.hotkeys?.unregister)return;try{await $.hotkeys.unregister(Z)}catch{}}function n4(Z,$){let Y=`hotkey_${++wZ}_${Date.now()}`,z=yZ(Z);D.set(Y,{shortcut:Z,handler:$,parsed:z}),BZ(Y,Z),mZ();let G={shortcut:Z,id:Y,unregister(){vZ(G)}};return G}function vZ(Z){if(D.delete(Z.id),p(Z.id),D.size===0)c()}function r4(){for(let[Z]of D)p(Z);D.clear(),c()}function o4(){return Array.from(D.entries()).map(([Z,$])=>({shortcut:$.shortcut,id:Z,unregister(){if(D.delete(Z),p(Z),D.size===0)c()}}))}class YZ{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(Z){if(this._duration=Z.duration,this._tickInterval=Z.tickInterval||1000,this._remaining=Z.duration,Z.onComplete)this._completionHandlers.add(Z.onComplete);if(Z.onTick)this._tickHandlers.add(Z.onTick);if(Z.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 Z=Date.now()-this._lastTick;return Math.max(0,this._remaining-Z)}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 Z=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-Z),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(Z){return this._completionHandlers.add(Z),()=>{this._completionHandlers.delete(Z)}}onTick(Z){return this._tickHandlers.add(Z),()=>{this._tickHandlers.delete(Z)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let Z=Date.now(),$=Z-this._lastTick;this._lastTick=Z,this._remaining=Math.max(0,this._remaining-$);for(let Y of this._tickHandlers)try{Y(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let Y of this._completionHandlers)try{Y()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class zZ{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(Z){if(this._interval=Z.interval,this._handler=Z.handler,this._immediate=Z.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 i4(Z){return new YZ(Z)}function s4(Z){return new zZ(Z)}function t4(Z){return new Promise(($)=>setTimeout($,Z))}function e4(Z){let $=Math.ceil(Z/1000),Y=Math.floor($/3600),z=Math.floor($%3600/60),G=$%60;if(Y>0)return`${Y}:${String(z).padStart(2,"0")}:${String(G).padStart(2,"0")}`;return`${z}:${String(G).padStart(2,"0")}`}function Z8(Z){let $=Math.ceil(Z/1000),Y=Math.floor($/3600),z=Math.floor($%3600/60),G=$%60;if(Y>0){if(z>0)return`${Y}h ${z}m`;return`${Y}h`}if(z>0){if(G>0)return`${z}m ${G}s`;return`${z}m`}return`${G}s`}function J(Z){if(typeof window>"u")return!1;let $=window.craft;return!!($&&$[Z])}function V(Z){if(!J(Z))throw Error(`craft.${Z} is not available \u2014 this API requires a Craft native window`);return window.craft[Z]}function O(Z,$){if(typeof window>"u")return()=>{};let Y=(z)=>$(z.detail??{});return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var z8={async writeText(Z){if(J("clipboard")){await window.craft.clipboard.writeText(Z);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(Z)},async readText(){if(J("clipboard")){let Z=await window.craft.clipboard.readText();return typeof Z==="string"?Z:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(Z){if(J("clipboard")){await window.craft.clipboard.writeHTML(Z);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let $=new window.ClipboardItem({"text/html":new Blob([Z],{type:"text/html"}),"text/plain":new Blob([bZ(Z)],{type:"text/plain"})});await navigator.clipboard.write([$])}catch{}},async readHTML(){if(J("clipboard")){let Z=await window.craft.clipboard.readHTML();return typeof Z==="string"?Z:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let Z=await navigator.clipboard.read();for(let $ of Z)if($.types.includes("text/html"))return await(await $.getType("text/html")).text()}catch{}return""},async clear(){if(J("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(J("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(J("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(J("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function bZ(Z){return Z.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
308
|
+
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
309
|
+
|
|
310
|
+
`).trim()}var Q8={async show(Z){if(!Z.title)throw Error("notification title is required");if(J("notifications")){await window.craft.notifications.show(Z);return}if(typeof window<"u"&&"Notification"in window){let $=window.Notification;if($.permission==="granted")new $(Z.title,{body:Z.body,icon:Z.icon});else if($.permission==="default"){if(await $.requestPermission()==="granted")new $(Z.title,{body:Z.body,icon:Z.icon})}}},async schedule(Z){if(J("notifications")){let z={...Z};if(z.triggerAt instanceof Date)z.triggerAt=z.triggerAt.toISOString();await window.craft.notifications.schedule(z);return}let $=lZ(Z.triggerAt),Y=Math.max(0,$-Date.now());setTimeout(()=>{this.show(Z).catch(()=>{})},Y)},async cancel(Z){if(J("notifications"))await window.craft.notifications.cancel(Z)},async cancelAll(){if(J("notifications"))await window.craft.notifications.cancelAll()},async setBadge(Z){let $=Math.max(0,Math.round(Number.isFinite(Z)?Z:0));if(J("notifications")){await window.craft.notifications.setBadge($);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge($)}catch{}},async clearBadge(){if(J("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(J("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let Z=window.Notification;if(Z.permission==="granted")return!0;if(Z.permission==="denied")return!1;return await Z.requestPermission()==="granted"}return!1},async registerCategories(Z){if(!Array.isArray(Z)||Z.length===0)return;if(J("notifications")){let $=window.craft.notifications.registerCategories;if(typeof $==="function")await $(Z)}},onActionClicked(Z){return O("craft:notification:actionClicked",Z)},onReply(Z){return O("craft:notification:reply",Z)}};function lZ(Z){if(Z==null)return Date.now();if(Z instanceof Date)return Z.getTime();if(typeof Z==="number")return Z;let $=Date.parse(Z);return Number.isNaN($)?Date.now():$}var V8={async readFile(Z){let $=await V("fs").readFile(Z);return $&&$.data||""},async readBuffer(Z){let $=await V("fs").readFile(Z),Y=$&&$.data||"";if($&&$.base64===!0)return uZ(Y);return new TextEncoder().encode(Y)},async writeFile(Z,$){await V("fs").writeFile(Z,$)},async writeBuffer(Z,$){let Y=gZ($),z=V("fs");if(typeof z.writeFileBytes==="function")await z.writeFileBytes(Z,Y);else await z.writeFile(Z,Y)},async copy(Z,$){if(Z===$)throw Error("fs.copy: source and destination must differ");await V("fs").copy(Z,$)},async move(Z,$){if(Z===$)throw Error("fs.move: source and destination must differ");await V("fs").move(Z,$)},async appendFile(Z,$){await V("fs").appendFile(Z,$)},async deleteFile(Z){await V("fs").deleteFile(Z)},async exists(Z){return await V("fs").exists(Z)},async stat(Z){return hZ(await V("fs").stat(Z))},async readDir(Z){let $=await V("fs").readDir(Z),Y=$&&$.entries||[],z=Z.endsWith("/")?Z.slice(0,-1):Z;return Y.map((G)=>({name:G.name,path:`${z}/${G.name}`,isDirectory:!!G.isDirectory}))},async mkdir(Z,$){await V("fs").mkdir(Z,$)},async rmdir(Z,$){await V("fs").rmdir(Z,$)},async watch(Z,$){await V("fs").watch(Z,$)},async unwatch(Z){await V("fs").unwatch(Z)},onChange(Z){return O("craft:fs:change",Z)},async watchTree(Z,$,Y){let z=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=V("fs");await G.watch(Z,z,{recursive:!!$.recursive});let Q=$.kinds&&$.kinds.length>0?new Set($.kinds):null,P=Math.max(0,Math.floor($.coalesceMs??0)),X=[],F=null,j=!1,N=()=>{if(F=null,X.length===0)return;let R=X;X=[];try{Y(R)}catch{}},k=O("craft:fs:change",(R)=>{if(j)return;if(R.id!==z)return;if(Q&&R.kind&&!Q.has(R.kind))return;if(X.push(R),P===0){N();return}if(F==null)F=setTimeout(N,P)});return{id:z,async stop(){if(j)return;if(j=!0,k(),F)clearTimeout(F),F=null;if(X.length>0)N();try{await G.unwatch(z)}catch{}}}},async homeDir(){return await V("fs").homeDir()},async tempDir(){return await V("fs").tempDir()},async appDataDir(){return await V("fs").appDataDir()}};function gZ(Z){let $="";for(let Y=0;Y<Z.length;Y++)$+=String.fromCharCode(Z[Y]);return typeof btoa==="function"?btoa($):Buffer.from(Z).toString("base64")}function uZ(Z){let $=typeof atob==="function"?atob(Z):Buffer.from(Z,"base64").toString("binary"),Y=new Uint8Array($.length);for(let z=0;z<$.length;z++)Y[z]=$.charCodeAt(z);return Y}function hZ(Z){return{isFile:!!Z.isFile,isDirectory:!!Z.isDirectory,isSymlink:!!Z.isSymlink,size:Number(Z.size)||0,modifiedAt:Z.modifiedAt!=null?Z.modifiedAt<1000000000000?Z.modifiedAt*1000:Z.modifiedAt:0}}var S=new Set,GZ=!1;function cZ(){if(GZ)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let $=Z.detail;if($?.id)S.delete($.id)}),GZ=!0}var pZ=new Set(["javascript:","data:","file:","vbscript:"]),W8={async openExternal(Z){let $=Z.trim().toLowerCase();for(let Y of pZ)if($.startsWith(Y))throw Error(`shell.openExternal: ${Y} URLs are blocked for safety`);if(J("shell")){await window.craft.shell.openExternal(Z);return}if(typeof window<"u"&&typeof window.open==="function")window.open(Z,"_blank","noopener,noreferrer")},async openPath(Z){await V("shell").openPath(Z)},async showInFinder(Z){await V("shell").showInFinder(Z)},async spawn(Z,$,Y=[],z={}){if(cZ(),!Z||typeof Z!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!$||typeof $!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(Y))throw Error("shell.spawn: args must be an array");for(let G of Y)if(typeof G!=="string")throw Error("shell.spawn: args entries must be strings");if(S.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);S.add(Z);try{await V("shell").spawn(Z,$,Y,z)}catch(G){throw S.delete(Z),G}},async kill(Z){await V("shell").kill(Z),S.delete(Z)},async getEnv(Z){if(J("shell")){let $=await window.craft.shell.getEnv(Z);return $==null?void 0:String($)}return},async setEnv(Z,$){await V("shell").setEnv(Z,$)},onStdout(Z){return O("craft:shell:stdout",Z)},onStderr(Z){return O("craft:shell:stderr",Z)},onExit(Z){return O("craft:shell:exit",Z)}};var R8={async register(Z,$,Y){if(!J("shortcuts"))return;await window.craft.shortcuts.register(Z,$,Y)},async unregister(Z){if(!J("shortcuts"))return;await window.craft.shortcuts.unregister(Z)},async unregisterAll(){if(!J("shortcuts"))return;await window.craft.shortcuts.unregisterAll()},async enable(Z){if(!J("shortcuts"))return;await window.craft.shortcuts.enable(Z)},async disable(Z){if(!J("shortcuts"))return;await window.craft.shortcuts.disable(Z)},async isRegistered(Z){if(!J("shortcuts"))return!1;return await window.craft.shortcuts.isRegistered(Z)},async list(){if(!J("shortcuts"))return[];return await window.craft.shortcuts.list()},on(Z){return O("craft:shortcut",Z)}};var k8={get(){if(J("theme"))try{return window.craft.theme.get()}catch{}return{appearance:dZ()}},onChange(Z){if(Z(this.get()),J("theme"))return O("craft:theme",Z);if(typeof window<"u"&&window.matchMedia){let $=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>Z({appearance:$.matches?"dark":"light"});return $.addEventListener("change",Y),()=>$.removeEventListener("change",Y)}return()=>{}},async current(){return this.get()}};function dZ(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function U8(Z,$={}){if(!J("dragOut"))throw Error("dragOut requires a Craft native window");let Y=Array.isArray(Z)?Z:[Z];if(Y.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(Y,$)}function M8(){return J("dragOut")}var A8={onUrl(Z){if(!J("deepLink"))return()=>{};return O("craft:deepLink",Z)},getInitialUrl(){if(typeof window>"u")return null;if(J("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let Z=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return Z},isAvailable(){return J("deepLink")}};var E8={async isCharging(){if(J("power"))return await window.craft.power.isCharging();let Z=await m();return Z?!!Z.charging:!1},async isPluggedIn(){if(J("power"))return await window.craft.power.isPluggedIn();let Z=await m();return Z?!!Z.charging||Z.level>=0.999:!1},async isLowPowerMode(){if(J("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(J("power")){let $=await window.craft.power.batteryLevel();return typeof $==="number"?$:null}let Z=await m();return Z?Z.level:null},async timeRemaining(){if(J("power")){let Y=await window.craft.power.timeRemaining();return typeof Y==="number"?Y:null}let Z=await m();if(!Z)return null;let $=Z.charging?Z.chargingTime:Z.dischargingTime;return Number.isFinite($)?Math.round($/60):null},async thermalState(){if(J("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(J("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(Z="app is busy"){if(J("power")){await window.craft.power.preventSleep(Z);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let $=window;if($.__craftWebWakeLock?.release){try{await $.__craftWebWakeLock.release()}catch{}$.__craftWebWakeLock=null}try{let Y=await navigator.wakeLock.request("screen");$.__craftWebWakeLock=Y}catch{}},async allowSleep(){if(J("power")){await window.craft.power.allowSleep();return}let Z=window.__craftWebWakeLock;if(Z&&typeof Z.release==="function"){try{await Z.release()}catch{}window.__craftWebWakeLock=null}},onSleep(Z){return O("craft:powerSleep",Z)},onWake(Z){return O("craft:powerWake",Z)}};async function m(){if(typeof navigator>"u")return null;let Z=navigator;if(typeof Z.getBattery!=="function")return null;try{return await Z.getBattery()}catch{return null}}var w8={async connectionType(){if(J("network"))return await window.craft.network.connectionType();return OZ()},async wifiSSID(){if(J("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(J("network")){let Z=await window.craft.network.wifiSignalStrength();return typeof Z==="number"?Z:void 0}return},async ipAddress(){if(J("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(J("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(J("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(J("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(J("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(J("network"))await window.craft.network.openPreferences()},onChange(Z){if(J("network"))return O("craft:networkChange",Z);if(typeof window>"u")return()=>{};let $=()=>Z({type:OZ(),online:!0}),Y=()=>Z({type:"none",online:!1});return window.addEventListener("online",$),window.addEventListener("offline",Y),()=>{window.removeEventListener("online",$),window.removeEventListener("offline",Y)}}};function OZ(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let Z=navigator.connection;if(!Z)return"unknown";let $=String(Z.type||Z.effectiveType||"unknown").toLowerCase();if($==="wifi"||$==="cellular"||$==="ethernet"||$==="bluetooth"||$==="none")return $;return"unknown"}var m8={async checkForUpdates(){if(!J("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!J("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(Z){if(!J("updater"))return;await window.craft.updater.setAutomaticChecks(Z)},async setCheckInterval(Z){if(!J("updater"))return;if(!Number.isFinite(Z))throw Error("setCheckInterval: must be a finite number");let $=Z<=0?0:Math.max(60,Math.round(Z));await window.craft.updater.setCheckInterval($)},async setFeedURL(Z){if(!J("updater"))return;await window.craft.updater.setFeedURL(Z)},async getLastUpdateCheckDate(){if(!J("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!J("updater"))return null;let Z=await window.craft.updater.getUpdateInfo();if(!Z||typeof Z.version!=="string"||Z.version.length===0)return null;return Z},onAvailable(Z){return O("craft:updateAvailable",Z)},onDownloaded(Z){return O("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:$,publicKeyB64:Y}){let z=QZ(Z),G;try{G=await crypto.subtle.importKey("raw",B(Y),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",G,B($),z)}catch{return!1}},async verifyDownload({url:Z,signatureB64:$,publicKeyB64:Y,fetchInit:z}){let G;try{G=await fetch(Z,z)}catch{return{ok:!1,reason:"fetch-failed"}}if(!G.ok)return{ok:!1,reason:"http-error",status:G.status};let Q=new Uint8Array(await G.arrayBuffer()),P;try{P=await crypto.subtle.importKey("raw",B(Y),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let X=!1;try{X=await crypto.subtle.verify("Ed25519",P,B($),QZ(Q))}catch{X=!1}if(!X)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:Q}}};function QZ(Z){if(Z instanceof ArrayBuffer)return new Uint8Array(Z);let $=new ArrayBuffer(Z.byteLength),Y=new Uint8Array($);return Y.set(Z),Y}function B(Z){if(typeof atob==="function"){let z=atob(Z),G=new ArrayBuffer(z.length),Q=new Uint8Array(G);for(let P=0;P<z.length;P++)Q[P]=z.charCodeAt(P);return Q}let $=Buffer.from(Z,"base64"),Y=new ArrayBuffer($.length);return new Uint8Array(Y).set($),new Uint8Array(Y)}var b8={onFocus(Z){if(J("window"))return O("craft:window:focus",()=>Z());return d("focus",Z)},onBlur(Z){if(J("window"))return O("craft:window:blur",()=>Z());return d("blur",Z)},onResize(Z){if(J("window"))return O("craft:window:resize",Z);if(typeof window>"u")return()=>{};let $=()=>Z({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},onMove(Z){if(J("window"))return O("craft:window:move",Z);return()=>{}},onClose(Z){if(J("window"))return O("craft:window:close",()=>Z());return d("beforeunload",Z)},onMinimize(Z){if(J("window"))return O("craft:window:minimize",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="hidden")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},onRestore(Z){if(J("window"))return O("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)}};function d(Z,$){if(typeof window>"u")return()=>{};let Y=()=>$();return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var XZ={name:"",version:"0.0.0"},u8={async hideDockIcon(){if(J("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(J("app"))await window.craft.app.showDockIcon()},async quit(){if(J("app"))await window.craft.app.quit()},async getInfo(){if(!J("app"))return XZ;let Z=await window.craft.app.getInfo();return{...XZ,...Z||{}}},async notify(Z){if(!Z.title)throw Error("notify: title is required");if(J("app"))await window.craft.app.notify(Z)},async setBadge(Z){if(J("app"))await window.craft.app.setBadge(Z)},async bounce(Z="informational"){if(J("app"))await window.craft.app.bounce(Z)}};var p8={async set(Z){if(J("menu"))await window.craft.menu.set(Z)},async setDock(Z){if(J("menu"))await window.craft.menu.setDock(Z)},async addItem(Z,$){if(J("menu"))await window.craft.menu.addItem(Z,$)},async removeItem(Z){if(J("menu"))await window.craft.menu.removeItem(Z)},async enableItem(Z){if(J("menu"))await window.craft.menu.enableItem(Z)},async disableItem(Z){if(J("menu"))await window.craft.menu.disableItem(Z)},async checkItem(Z){if(J("menu"))await window.craft.menu.checkItem(Z)},async uncheckItem(Z){if(J("menu"))await window.craft.menu.uncheckItem(Z)},async setItemLabel(Z,$){if(J("menu"))await window.craft.menu.setItemLabel(Z,$)},async clearDock(){if(J("menu"))await window.craft.menu.clearDock()},onAction(Z){return O("craft:menu:action",Z)}};var r8={async getDisplays(){if(J("screen"))return await window.craft.screen.getDisplays();return PZ()},async getPrimary(){if(J("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return PZ()[0]??null},onChange(Z){if(J("screen"))return O("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let $=()=>Z();return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}};function PZ(){if(typeof window>"u"||!window.screen)return[];let Z=window.screen;return[{id:0,x:Z.left??0,y:Z.top??0,width:Z.width||0,height:Z.height||0,workX:Z.availLeft??0,workY:Z.availTop??0,workWidth:Z.availWidth??Z.width??0,workHeight:Z.availHeight??Z.height??0,scaleFactor:window.devicePixelRatio||1}]}var i8={async set(Z,$,Y){if(!Z)throw Error("keychain.set: service is required");if(!$)throw Error("keychain.set: account is required");await V("keychain").set(Z,$,Y)},async get(Z,$){if(!Z)throw Error("keychain.get: service is required");if(!$)throw Error("keychain.get: account is required");let Y=await V("keychain").get(Z,$);return typeof Y==="string"?Y:null},async delete(Z,$){if(!Z)throw Error("keychain.delete: service is required");if(!$)throw Error("keychain.delete: account is required");await V("keychain").delete(Z,$)},async has(Z,$){if(!Z)throw Error("keychain.has: service is required");if(!$)throw Error("keychain.has: account is required");return await V("keychain").has(Z,$)}};var e8={async check(Z){if(J("permissions"))return await window.craft.permissions.check(Z);return await VZ(Z)},async request(Z){if(J("permissions"))return await window.craft.permissions.request(Z);return await nZ(Z)},async openSettings(Z){if(J("permissions"))await window.craft.permissions.openSettings(Z)}};async function VZ(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let $=await navigator.permissions.query({name:Z});return rZ($.state)}catch{return"not-supported"}}async function nZ(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let $=await window.Notification.requestPermission();return $==="granted"?"granted":$==="denied"?"denied":"undetermined"}return await VZ(Z)}function rZ(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var J$={async print(){if(J("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(Z){if(!Z)throw Error("printToPDF: path is required");let $=Z.startsWith("/"),Y=/^[a-zA-Z]:[\\/]/.test(Z)||Z.startsWith("\\\\");if(!$&&!Y)throw Error("printToPDF: path must be absolute");let z=await V("printing").printToPDF(Z);return{ok:!!(z&&z.ok),path:z?.path}}};var G$={async enable(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};var X$={async addItem(Z){if(J("touchbar"))await window.craft.touchbar.addItem(Z)},async removeItem(Z){if(J("touchbar"))await window.craft.touchbar.removeItem(Z)},async updateItem(Z,$){if(J("touchbar"))await window.craft.touchbar.updateItem(Z,$)},async setLabel(Z,$){if(J("touchbar"))await window.craft.touchbar.setLabel(Z,$)},async setIcon(Z,$){if(J("touchbar"))await window.craft.touchbar.setIcon(Z,$)},async setEnabled(Z,$){if(J("touchbar"))await window.craft.touchbar.setEnabled(Z,$)},async setSliderValue(Z,$){if(J("touchbar"))await window.craft.touchbar.setSliderValue(Z,$)},async clear(){if(J("touchbar"))await window.craft.touchbar.clear()},async show(){if(J("touchbar"))await window.craft.touchbar.show()},async hide(){if(J("touchbar"))await window.craft.touchbar.hide()},onAction(Z){return O("craft:touchbar:action",Z)}};var oZ=/^[\da-f]*$/i;function aZ(Z,$){if(typeof $!=="string"||!oZ.test($)||$.length%2!==0)throw Error(`${Z}: must be a hex string with even length, got ${JSON.stringify($)}`)}var F$={async isEnabled(){return J("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return J("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return J("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return J("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(J("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(J("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return J("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(Z){if(J("bluetooth"))await window.craft.bluetooth.connect(Z)},async disconnect(Z){if(J("bluetooth"))await window.craft.bluetooth.disconnect(Z)},async openPreferences(){if(J("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(Z){if(!Z)throw Error("bluetooth.discoverServices: deviceId is required");if(!J("bluetooth"))return[];let $=await window.craft.bluetooth.discoverServices(Z);return Array.isArray($)?$:[]},async discoverCharacteristics(Z,$){if(!Z||!$)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!J("bluetooth"))return[];let Y=await window.craft.bluetooth.discoverCharacteristics(Z,$);return Array.isArray(Y)?Y:[]},async readCharacteristic(Z,$,Y){if(!Z||!$||!Y)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(Z,$,Y)},async writeCharacteristic(Z,$,Y,z,G="with-response"){if(!Z||!$||!Y)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(aZ("bluetooth.writeCharacteristic.valueHex",z),!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(Z,$,Y,z,G)},async setCharacteristicNotify(Z,$,Y,z){if(!Z||!$||!Y)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(Z,$,Y,z)},onDeviceFound(Z){return O("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return O("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return O("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return O("craft:bluetooth:characteristicValue",Z)}};var K$={async speak(Z,$){if(!Z)throw Error("speech.speak: text is required");if(J("speech")){await window.craft.speech.speak(Z,$);return}if(typeof window<"u"&&window.speechSynthesis){let Y=new window.SpeechSynthesisUtterance(Z);if($){if($.rate!=null)Y.rate=$.rate;if($.pitch!=null)Y.pitch=$.pitch;if($.volume!=null)Y.volume=$.volume;if($.voice){let G=window.speechSynthesis.getVoices().find((Q)=>Q.voiceURI===$.voice||Q.name===$.voice||Q.lang===$.voice);if(G)Y.voice=G}}window.speechSynthesis.speak(Y)}},async stop(){if(J("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(J("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(J("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(J("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(J("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map(($)=>({id:$.voiceURI||$.name,name:$.name,language:$.lang||"",quality:"default"}));return[]}};var A=[],n=!0,r,o,v={async report(Z){if(J("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!n)return;let $=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:r,appVersion:o}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:r,appVersion:o};if(A.length>=64)A.shift();A.push($)},async flush(){if(J("crashReporter"))return await window.craft.crashReporter.flush();return[...A]},async clear(){if(J("crashReporter")){await window.craft.crashReporter.clear();return}A.length=0},async setEnabled(Z){if(J("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}n=Z},async isEnabled(){if(J("crashReporter"))return await window.craft.crashReporter.isEnabled();return n},async setUser(Z){if(J("crashReporter")){await window.craft.crashReporter.setUser(Z);return}r=Z||void 0},async setAppVersion(Z){if(J("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}o=Z||void 0},attachGlobalHandlers(){if(J("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=(Y)=>{v.report({severity:"error",message:Y.message,source:"js",stack:Y.error?.stack||`${Y.message}
|
|
311
|
+
at ${Y.filename}:${Y.lineno}:${Y.colno}`}).catch(()=>{})},$=(Y)=>{let z=Y.reason;v.report({severity:"error",message:z?.message||String(z),source:"js",stack:z?.stack||""}).catch(()=>{})};return window.addEventListener("error",Z),window.addEventListener("unhandledrejection",$),()=>{window.removeEventListener("error",Z),window.removeEventListener("unhandledrejection",$)}},forwardTo(Z){return Y4(Z)}},iZ="craft:crashReporter:pending",sZ=/[\w.+-]+@[\w-]+\.[\w.-]+/g,tZ=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,eZ=/\/(?:Users|home)\/[^\s/'"`]+/g;function Z4(Z){let $=(Y)=>Y.replace(sZ,"<email>").replace(tZ,"<ip>").replace(eZ,"/<home>");return{...Z,message:$(Z.message),stack:$(Z.stack)}}async function $4(Z,$){let Y=new TextEncoder,z=await crypto.subtle.importKey("raw",Y.encode(Z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),G=await crypto.subtle.sign("HMAC",z,Y.encode($));return[...new Uint8Array(G)].map((Q)=>Q.toString(16).padStart(2,"0")).join("")}function J4(Z){if(!Z||typeof localStorage>"u")return[];try{let $=localStorage.getItem(Z);if(!$)return[];let Y=JSON.parse($);return Array.isArray(Y)?Y:[]}catch{return[]}}function FZ(Z,$){if(!Z||typeof localStorage>"u")return;try{if($.length===0)localStorage.removeItem(Z);else localStorage.setItem(Z,JSON.stringify($))}catch{}}function Y4(Z){let{endpoint:$,intervalMs:Y=60000,signingSecret:z,redact:G=!0,headers:Q={},maxRetries:P=5,persistKey:X}=Z,F=X===null?null:X??iZ,j=J4(F),N=!1,k=null,R=null,LZ=typeof G==="function"?G:G===!1?(H)=>H:Z4;async function DZ(H){let x=JSON.stringify({entries:H}),_={"Content-Type":"application/json",...Q};if(z)_["X-Craft-Signature"]=await $4(z,x);let s=0,l=1000;while(!N)try{let M=await fetch($,{method:"POST",headers:_,body:x});if(M.ok)return;if(M.status>=400&&M.status<500)return;throw Error(`HTTP ${M.status}`)}catch(M){if(s+=1,s>P)throw j=[...H,...j],FZ(F,j),M;await new Promise((kZ)=>{setTimeout(kZ,l)}),l=Math.min(l*2,60000)}}async function i(){if(N||R)return R??void 0;let H=await v.flush();if(H.length>0)await v.clear();if(j=[...j,...H.map((_)=>LZ(_))],j.length===0)return;let x=j;return j=[],FZ(F,j),R=DZ(x).catch(()=>{}).finally(()=>{R=null}),R}if(Y>0)k=setInterval(()=>{i().catch(()=>{})},Y);return{async flushNow(){await i()},stop(){if(N=!0,k)clearInterval(k);k=null},pending(){return[...j]}}}var H$={async isAvailable(){if(!J("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(Z){if(!J("iap"))return[];let $=Array.isArray(Z)?Z:[String(Z)];return await window.craft.iap.getProducts($)},async purchase(Z){if(!J("iap"))return{queued:!1,productId:Z,reason:"IAP bridge not available"};let $=await window.craft.iap.purchase(Z);return{queued:!!($&&$.queued),productId:$?.productId,reason:$?.reason}},async restorePurchases(){if(!J("iap"))return{ok:!1};let Z=await window.craft.iap.restorePurchases();return{ok:!!(Z&&Z.ok)}},async finishTransaction(Z){if(!J("iap"))return;await window.craft.iap.finishTransaction(Z)},async getReceiptData(){if(!J("iap"))return null;let Z=await window.craft.iap.getReceiptData();return Z?String(Z):null},onPurchased(Z){return O("craft:iap:purchased",Z)},onFailed(Z){return O("craft:iap:failed",Z)},onRestored(Z){return O("craft:iap:restored",Z)},onProductsLoaded(Z){return O("craft:iap:productsLoaded",($)=>Z($.products||[]))},onRefunded(Z){return O("craft:iap:refunded",Z)},onSubscriptionStatusChanged(Z){return O("craft:iap:subscriptionStatusChanged",Z)},async getActiveSubscriptions(){if(!J("iap"))return[];let Z=window.craft.iap.getActiveSubscriptions;if(typeof Z!=="function")return[];let $=await Z();return Array.isArray($)?$:[]},async isEligibleForIntroOffer(Z){if(!J("iap"))return!1;let $=window.craft.iap.isEligibleForIntroOffer;if(typeof $!=="function")return!1;return!!await $(Z)}};var b={async startActivity(Z,$){if(!Z)throw Error("handoff.startActivity: type is required");if(!J("handoff"))return!1;let Y=await window.craft.handoff.startActivity(Z,$);return typeof Y==="boolean"?Y:!!(Y&&Y.ok)},async updateActivity(Z){if(!J("handoff"))return!1;let $=await window.craft.handoff.updateActivity(Z);return typeof $==="boolean"?$:!!($&&$.ok)},async stopActivity(){if(!J("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!J("handoff"))return null;let Z=await window.craft.handoff.getCurrentActivity();return Z&&typeof Z.type==="string"?Z:null},onIncoming(Z){return O("craft:handoff:incoming",Z)}};var S$={async start(Z,$){return b.startActivity(Z,{title:$?.title,webpageURL:$?.webpageURL,userInfo:$?.state})},async update(Z){return b.updateActivity({title:Z.title,webpageURL:Z.webpageURL,userInfo:Z.state})},async stop(){await b.stopActivity()}};var _$={async requestPermission(Z="whenInUse"){if(J("location"))return await window.craft.location.requestPermission(Z);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(J("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(J("location"))return await window.craft.location.getCurrentLocation();if(typeof navigator<"u"&&navigator.geolocation)return navigator.geolocation.getCurrentPosition((Z)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:Z.coords.latitude,longitude:Z.coords.longitude,altitude:Z.coords.altitude,horizontalAccuracy:Z.coords.accuracy,verticalAccuracy:Z.coords.altitudeAccuracy,speed:Z.coords.speed}}))},(Z)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:Z.message||String(Z)}}))}),{requested:!0};return{requested:!1}},async startWatching(Z){if(J("location"))return await window.craft.location.startWatching(Z);if(typeof navigator<"u"&&navigator.geolocation){let $=navigator.geolocation.watchPosition((Y)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:Y.coords.latitude,longitude:Y.coords.longitude,altitude:Y.coords.altitude,horizontalAccuracy:Y.coords.accuracy,verticalAccuracy:Y.coords.altitudeAccuracy,speed:Y.coords.speed}}))});return window.__craftWebLocationWatchId=$,!0}return!1},async stopWatching(){if(J("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let Z=window.__craftWebLocationWatchId;if(Z!=null)navigator.geolocation.clearWatch(Z),window.__craftWebLocationWatchId=null}},onUpdate(Z){return O("craft:location:update",Z)},onError(Z){return O("craft:location:error",Z)},onAuthChanged(Z){return O("craft:location:authChanged",Z)}};var I$={async captureScreen(){if(!J("screenCapture"))return null;let Z=await window.craft.screenCapture.captureScreen();return Z?String(Z):null},async captureWindow(Z){if(!J("screenCapture"))return null;if(!Number.isFinite(Z)||Z<=0)throw Error("captureWindow: id must be a positive number");let $=await window.craft.screenCapture.captureWindow(Z);return $?String($):null},async listWindows(){if(!J("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var z4=250,G4=60000,WZ=2000,jZ={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function O4(){return{...jZ,signals:{...jZ.signals},sources:[]}}var a={async getState(){if(!J("screenSharing"))return O4();return await window.craft.screenSharing.getState()},async watch(Z=WZ){let $=Math.min(G4,Math.max(z4,Math.round(Z)));if(!J("screenSharing"))return $;let Y=await window.craft.screenSharing.watch($);return Y&&Y.intervalMs||$},async stop(){if(!J("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(Z){return O("craft:screenSharing:change",Z)}};async function f$(Z,$=WZ){let Y=a.onChange(Z);return await a.watch($),()=>{Y(),a.stop()}}var Q4={supported:!1,isFocused:null,authorization:"unsupported"};function KZ(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var NZ={async getStatus(){if(!J("focus"))return{...Q4};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!J("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(Z,$={}){if(!J("focus"))return KZ();if(!(Z?$.onShortcut:$.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${Z?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(Z,$)},async runShortcut(Z){if(!J("focus"))return KZ();if(!Z)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(Z)},async listShortcuts(){if(!J("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!J("focus"))return{canList:!1,shortcuts:[]};let Z=await window.craft.focus.listShortcutsResult();return{canList:Boolean(Z?.canList),shortcuts:Z?.shortcuts||[]}}};async function v$(...Z){if(Z.length===0)return!1;let $=new Set(await NZ.listShortcuts());return Z.every((Y)=>$.has(Y))}async function b$(...Z){if(Z.length===0)return!1;let{canList:$,shortcuts:Y}=await NZ.listShortcutsResult();if(!$)return"unknown";let z=new Set(Y);return Z.every((G)=>z.has(G))}var u$={async start(Z=0,$="127.0.0.1"){if(!J("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(Z,$)},async stop(){if(!J("localServer"))return;await window.craft.localServer.stop()},async respond(Z){if(!J("localServer"))return;await window.craft.localServer.respond(Z||{status:200,body:"OK"})},onRequest(Z){return O("craft:localServer:request",Z)},async awaitOAuthCallback(Z={}){V("localServer");let{port:$=0,host:Y="127.0.0.1",timeoutMs:z=300000,successHTML:G}=Z,Q=await this.start($,Y);if(!Q.started)throw Error(`localServer: start failed${Q.reason?` \u2014 ${Q.reason}`:""}`);return new Promise((P,X)=>{let F=setTimeout(()=>{j(),this.stop().catch(()=>{}),X(Error("localServer: OAuth callback timed out"))},z),j=this.onRequest(({url:N})=>{clearTimeout(F),j();let k=G??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
312
|
+
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
313
|
+
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
|
314
|
+
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:k,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),P({url:N,port:Q.port})})})}};var p$={async isAvailable(){if(!J("biometric"))return!1;return await window.craft.biometric.isAvailable()},async getBiometryType(){if(!J("biometric"))return"none";return await window.craft.biometric.getBiometryType()},async evaluate(Z,$){if(!Z)throw Error("biometric.evaluate: reason is required");if(!J("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(Z,$)}};var K=null,r$={async play(Z,$){if(J("audio"))return await window.craft.audio.play(Z,$);if(typeof window>"u"||typeof Audio>"u")return!1;if(K)K.pause(),K=null;if(K=new Audio(Z),$?.volume!=null)K.volume=$.volume;if($?.loops)K.loop=!0;try{return await K.play(),!0}catch{return!1}},async playSystemSound(Z){if(J("audio"))return await window.craft.audio.playSystemSound(Z);if(typeof window>"u"||typeof Audio>"u")return!1;try{return K=new Audio(`/System/Library/Sounds/${Z}.aiff`),await K.play(),!0}catch{return!1}},async stop(){if(J("audio")){await window.craft.audio.stop();return}if(K)K.pause(),K.currentTime=0,K=null},async isPlaying(){if(J("audio"))return await window.craft.audio.isPlaying();return!!(K&&!K.paused)},async startRecording(Z,$){if(J("audio"))return await window.craft.audio.startRecording(Z,$);return!1},async stopRecording(){if(J("audio"))await window.craft.audio.stopRecording()},async isRecording(){if(J("audio"))return await window.craft.audio.isRecording();return!1}};var i$={async execute(Z){if(!Z)throw Error("appleScript.execute: source is required");if(!J("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(Z)}};var e$={async getDefault(Z){if(!Z)throw Error("fileAssociations.getDefault: uti is required");if(!J("fileAssociations"))return null;let $=await window.craft.fileAssociations.getDefault(Z);return $?String($):null},async setDefault(Z,$){if(!Z||!$)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!J("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(Z,$)}};var JJ={async get(Z){if(!Z)throw Error("tags.get: path is required");if(!J("tags"))return[];return await window.craft.tags.get(Z)},async set(Z,$){if(!Z)throw Error("tags.set: path is required");if(!J("tags"))return!1;let Y=Array.isArray($)?$:[String($)];return await window.craft.tags.set(Z,Y)},async clear(Z){if(!Z)throw Error("tags.clear: path is required");if(!J("tags"))return!1;return await window.craft.tags.clear(Z)}};var GJ={async countPages(Z){if(!Z)throw Error("pdf.countPages: path is required");if(!J("pdf"))return 0;return await window.craft.pdf.countPages(Z)},async extractText(Z){if(!Z)throw Error("pdf.extractText: path is required");if(!J("pdf"))return"";return await window.craft.pdf.extractText(Z)}};var XJ={async debug(Z){if(J("log"))await window.craft.log.debug(Z);else console.debug(Z)},async info(Z){if(J("log"))await window.craft.log.info(Z);else console.info(Z)},async warn(Z){if(J("log"))await window.craft.log.warn(Z);else console.warn(Z)},async error(Z){if(J("log"))await window.craft.log.error(Z);else console.error(Z)}};var FJ={async browse(Z){if(!J("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(Z)},async stop(){if(J("bonjour"))await window.craft.bonjour.stop()},onFound(Z){return O("craft:bonjour:found",Z)},onLost(Z){return O("craft:bonjour:lost",Z)}};var KJ={async index(Z){if(!J("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(Z)},async remove(Z){if(!J("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(Z)},async removeAll(){if(!J("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var LJ={async isAvailable(){if(!J("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(Z){if(!J("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(Z)},async stop(){if(J("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(Z){return O("craft:speechRecognition:partial",Z)},onFinal(Z){return O("craft:speechRecognition:final",Z)}};var HJ={async recognizeText(Z){if(!Z)throw Error("vision.recognizeText: path is required");if(!J("vision"))return[];return await window.craft.vision.recognizeText(Z)},async detectFaces(Z){if(!Z)throw Error("vision.detectFaces: path is required");if(!J("vision"))return[];return await window.craft.vision.detectFaces(Z)},async detectBarcodes(Z){if(!Z)throw Error("vision.detectBarcodes: path is required");if(!J("vision"))return[];return await window.craft.vision.detectBarcodes(Z)}};var MJ={async listSources(){if(!J("midi"))return[];return await window.craft.midi.listSources()},async listDestinations(){if(!J("midi"))return[];return await window.craft.midi.listDestinations()},async send(Z,$){if(!J("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(Z,$)},async subscribe(Z){if(!J("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(Z)},async unsubscribe(Z){if(!J("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(Z)},onMessage(Z){return O("craft:midi:message",Z)}};var AJ={async loadModel(Z,$){if(!Z||!$)throw Error("coreml.loadModel: id and path are required");if(!J("coreml"))return!1;return await window.craft.coreml.loadModel(Z,$)},async unloadModel(Z){if(!J("coreml"))return;await window.craft.coreml.unloadModel(Z)},async predict(Z,$){if(!Z)throw Error("coreml.predict: id is required");if(!J("coreml"))return null;return await window.craft.coreml.predict(Z,$)}};var EJ={async listCameras(){if(!J("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var wJ={async register(Z){if(!Z)throw Error("serviceMenu.register: name is required");if(!J("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(Z)},async unregister(Z){if(!Z)throw Error("serviceMenu.unregister: name is required");if(!J("serviceMenu"))return;await window.craft.serviceMenu.unregister(Z)},onInvoked(Z){return O("craft:serviceMenu:invoked",Z)}};var mJ={async list(){if(!J("serial"))return[];return await window.craft.serial.list()},async open(Z,$=9600){if(!Z)throw Error("serial.open: path is required");if(!J("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(Z,$)},async write(Z,$){if(!Z)throw Error("serial.write: id is required");if(!J("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(Z,$)},async close(Z){if(!J("serial"))return;await window.craft.serial.close(Z)},onData(Z){return O("craft:serial:data",Z)}};var RZ=[{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 bJ(){return RZ.map(({name:Z,support:$})=>({name:Z,support:$,available:J(Z)}))}function X4(Z){let $=RZ.find((Y)=>Y.name===Z);if(!$)return;return{...$,available:J(Z)}}function lJ(Z){let $=X4(Z);return!!$&&$.available}
|
|
315
|
+
export{P4 as a,e as b,C as c,V4 as d,F4 as e,j4 as f,W4 as g,K4 as h,N4 as i,R4 as j,L4 as k,D4 as l,T as m,EZ as n,H4 as o,q4 as p,U4 as q,CZ as r,M4 as s,T4 as t,S4 as u,A4 as v,x4 as w,_4 as x,C4 as y,I4 as z,y as A,w4 as B,y4 as C,f4 as D,m4 as E,B4 as F,v4 as G,l4 as H,IZ as I,g4 as J,u4 as K,h4 as L,c4 as M,yZ as N,d4 as O,n4 as P,vZ as Q,r4 as R,o4 as S,i4 as T,s4 as U,t4 as V,e4 as W,Z8 as X,J as Y,z8 as Z,Q8 as _,V8 as $,W8 as aa,R8 as ba,k8 as ca,U8 as da,M8 as ea,A8 as fa,E8 as ga,w8 as ha,m8 as ia,b8 as ja,u8 as ka,p8 as la,r8 as ma,i8 as na,e8 as oa,J$ as pa,G$ as qa,X$ as ra,F$ as sa,K$ as ta,v as ua,Z4 as va,$4 as wa,H$ as xa,b as ya,S$ as za,_$ as Aa,I$ as Ba,z4 as Ca,G4 as Da,WZ as Ea,a as Fa,f$ as Ga,NZ as Ha,v$ as Ia,b$ as Ja,u$ as Ka,p$ as La,r$ as Ma,i$ as Na,e$ as Oa,JJ as Pa,GJ as Qa,XJ as Ra,FJ as Sa,KJ as Ta,LJ as Ua,HJ as Va,MJ as Wa,AJ as Xa,EJ as Ya,wJ as Za,mJ as _a,bJ as $a,X4 as ab,lJ as bb};
|