@stacksjs/desktop 0.2.377 → 0.2.379
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/_bridge.d.ts
CHANGED
|
@@ -114,6 +114,9 @@ declare module 'craft-native' {
|
|
|
114
114
|
interface CraftAppAPI {
|
|
115
115
|
setBadge: (count: number) => Promise<void>
|
|
116
116
|
bounce: (type?: 'critical' | 'informational') => Promise<void>
|
|
117
|
+
}
|
|
118
|
+
interface CraftNativeUIAPI {
|
|
119
|
+
_emitSidebarSelect?: (itemId: string) => void
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
declare global {
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$ as Az,$a as AA,A as jq,Aa as $z,B as xq,Ba as jz,C as kq,Ca as xz,D as yq,Da as kz,E as wq,Ea as yz,F as fq,Fa as wz,G as gq,Ga as fz,H as vq,Ha as gz,I as bq,Ia as vz,J as mq,Ja as bz,K as dq,Ka as mz,L as hq,La as dz,M as uq,Ma as hz,N as pq,Na as uz,O as lq,Oa as pz,P as cq,Pa as lz,Q as nq,Qa as cz,R as rq,Ra as nz,S as aq,Sa as rz,T as sq,Ta as az,U as oq,Ua as sz,V as tq,Va as oz,W as iq,Wa as tz,X as eq,Xa as iz,Ya as ez,Z as qz,Za as qA,_ as zz,_a as zA,a as Cq,aa as Bz,ab as BA,b as Dq,ba as Cz,bb as CA,c as Eq,ca as Dz,cb as DA,d as Fq,da as Ez,db as EA,e as Gq,ea as Fz,eb as FA,f as Hq,fa as Gz,fb as GA,g as Iq,ga as Hz,h as Jq,ha as Iz,i as Kq,ia as Jz,j as Lq,ja as Kz,k as Mq,ka as Lz,l as Nq,la as Mz,m as Oq,ma as Nz,n as Pq,na as Oz,o as Qq,oa as Pz,p as Rq,pa as Qz,q as Sq,qa as Rz,r as Tq,ra as Sz,s as Uq,sa as Tz,t as Vq,ta as Uz,u as Wq,ua as Vz,v as Xq,va as Wz,w as Yq,wa as Xz,x as Zq,xa as Yz,y as _q,ya as Zz,z as $q,za as _z}from"./chunk-
|
|
2
|
+
import{$ as Az,$a as AA,A as jq,Aa as $z,B as xq,Ba as jz,C as kq,Ca as xz,D as yq,Da as kz,E as wq,Ea as yz,F as fq,Fa as wz,G as gq,Ga as fz,H as vq,Ha as gz,I as bq,Ia as vz,J as mq,Ja as bz,K as dq,Ka as mz,L as hq,La as dz,M as uq,Ma as hz,N as pq,Na as uz,O as lq,Oa as pz,P as cq,Pa as lz,Q as nq,Qa as cz,R as rq,Ra as nz,S as aq,Sa as rz,T as sq,Ta as az,U as oq,Ua as sz,V as tq,Va as oz,W as iq,Wa as tz,X as eq,Xa as iz,Ya as ez,Z as qz,Za as qA,_ as zz,_a as zA,a as Cq,aa as Bz,ab as BA,b as Dq,ba as Cz,bb as CA,c as Eq,ca as Dz,cb as DA,d as Fq,da as Ez,db as EA,e as Gq,ea as Fz,eb as FA,f as Hq,fa as Gz,fb as GA,g as Iq,ga as Hz,h as Jq,ha as Iz,i as Kq,ia as Jz,j as Lq,ja as Kz,k as Mq,ka as Lz,l as Nq,la as Mz,m as Oq,ma as Nz,n as Pq,na as Oz,o as Qq,oa as Pz,p as Rq,pa as Qz,q as Sq,qa as Rz,r as Tq,ra as Sz,s as Uq,sa as Tz,t as Vq,ta as Uz,u as Wq,ua as Vz,v as Xq,va as Wz,w as Yq,wa as Xz,x as Zq,xa as Yz,y as _q,ya as Zz,z as $q,za as _z}from"./chunk-r6jrvhhq.js";import"./chunk-gzgq8v6d.js";export{Kz as windowEvents,mz as watchScreenSharing,qA as vision,Jz as updater,nq as unregisterHotkey,rq as unregisterAllHotkeys,Wz as touchbar,Dz as theme,az as tags,Mz as standardMenus,iz as spotlight,ez as speechRecognition,Yz as speech,$z as signPayload,Pz as sidebar,Hq as showWarningToast,Qq as showWarningModal,fq as showWarningDialog,Eq as showToast,Gq as showSuccessToast,Sq as showSuccessModal,$q as showSaveDialog,Tq as showQuestionModal,_q as showOpenDialog,Oq as showModal,jq as showMessageBox,Fq as showInfoToast,Pq as showInfoModal,Iq as showErrorToast,Rq as showErrorModal,wq as showErrorDialog,yq as showConfirmDialog,xq as showColorPicker,kq as showAlertDialog,Dq as showAlert,Bz as shell,CA as serviceMenu,DA as serial,bz as screenSharing,wz as screenCapture,Qz as screen,Cq as requestNotificationPermission,cq as registerHotkey,_z as redactPII,Wq as prompt,Tz as printing,Sz as permissions,sz as pdf,pq as parseShortcut,Jq as notify,zz as notifications,Iz as network,Vz as nativeWindow,Uz as nativeAutoLaunch,zA as midi,Nz as menu,oz as log,yz as location,pz as localServer,kz as liveActivities,Rz as keychain,Fz as isDragOutAvailable,mq as isCaffeinated,GA as isAvailable,jz as iap,hz as hasFocusShortcuts,xz as handoff,Cz as globalShortcuts,aq as getRegisteredHotkeys,gq as getDialogBridgeScript,FA as getCapability,EA as getCapabilities,dq as getCaffeinateStatus,Xq as getActiveModalCount,Mq as getActiveAlertCount,Az as fs,iq as formatTime,lq as formatShortcut,hq as formatRemainingTime,uq as formatDuration,eq as formatCompact,uz as focusShortcutsReady,dz as focus,rz as fileAssociations,Ez as dragOut,Lq as dismissAllAlerts,Kq as dismissAlertById,tq as delay,Gz as deepLinks,bq as decaffeinate,sq as createTimer,oq as createInterval,Zz as crashReporter,AA as coreml,BA as continuityCamera,Oz as contextMenu,Uq as confirm,Yq as closeAllModals,qz as clipboard,vq as caffeinate,tz as bonjour,Xz as bluetooth,lz as biometric,Hz as battery,cz as audio,nz as appleScript,Lz as app,Vq as alert,Nq as TOAST_STYLES,Zq as MODAL_STYLES,fz as MIN_WATCH_INTERVAL_MS,gz as MAX_WATCH_INTERVAL_MS,vz as DEFAULT_WATCH_INTERVAL_MS};
|
|
@@ -8,7 +8,7 @@ function wZ(){if(typeof Notification<"u"&&Notification.permission==="granted")re
|
|
|
8
8
|
</div>
|
|
9
9
|
${G?'<button class="stx-toast-close" aria-label="Close">×</button>':""}
|
|
10
10
|
</div>
|
|
11
|
-
`}function YZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(Z){if(Z.timeout)clearTimeout(Z.timeout);if(U.delete(Z.id),Z.element&&h())Z.element.classList.add("dismissing"),setTimeout(()=>{Z.element?.remove()},200)}async function zZ(Z){let $=IZ(),Y=wZ(),z=Z.duration??5000,G={id:$,options:Z};if(U.set($,G),Y&&Z.type!=="error")try{let X=new Notification(Z.title||"Notification",{body:Z.message,icon:Z.type==="success"?"\u2713":Z.type==="warning"?"\u26A0":"\u2139",tag:$});if(X.onclick=()=>{if(Z.onClick)Z.onClick();X.close()},z>0)G.timeout=setTimeout(()=>{X.close(),U.delete($)},z);return}catch{}if(h())try{let X=fZ(Z.position),
|
|
11
|
+
`}function YZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(Z){if(Z.timeout)clearTimeout(Z.timeout);if(U.delete(Z.id),Z.element&&h())Z.element.classList.add("dismissing"),setTimeout(()=>{Z.element?.remove()},200)}async function zZ(Z){let $=IZ(),Y=wZ(),z=Z.duration??5000,G={id:$,options:Z};if(U.set($,G),Y&&Z.type!=="error")try{let X=new Notification(Z.title||"Notification",{body:Z.message,icon:Z.type==="success"?"\u2713":Z.type==="warning"?"\u26A0":"\u2139",tag:$});if(X.onclick=()=>{if(Z.onClick)Z.onClick();X.close()},z>0)G.timeout=setTimeout(()=>{X.close(),U.delete($)},z);return}catch{}if(h())try{let X=fZ(Z.position),P=document.createElement("div");P.innerHTML=BZ(G);let O=P.firstElementChild;if(!O){let V=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${V}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`);return}G.element=O;try{X.appendChild(O)}catch{let V=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${V}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`);return}if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>{try{O.classList.add("visible")}catch{}});try{O.addEventListener("click",(V)=>{if(V.target.classList?.contains("stx-toast-close")){w(G);return}if(Z.onClick)Z.onClick()})}catch{}if(z>0)G.timeout=setTimeout(()=>{w(G)},z)}catch{let X=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${X}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`)}else{let X=(Z.type||"info").toUpperCase();if(console.log(`[stx-alert] ${X}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`),z>0)G.timeout=setTimeout(()=>{U.delete($)},z)}}async function I(Z){return zZ({...Z,position:Z.position||"top-right"})}async function S4(Z,$=3000){return I({message:Z,type:"info",duration:$})}async function A4(Z,$=3000){return I({message:Z,type:"success",duration:$})}async function T4(Z,$=3000){return I({message:Z,type:"warning",duration:$})}async function _4(Z,$=5000){return I({message:Z,type:"error",duration:$})}async function x4(Z,$,Y="info"){return zZ({title:Z,message:$,type:Y})}function E4(Z){let $=U.get(Z);if($)w($)}function C4(){for(let Z of U.values())w(Z)}function w4(){return U.size}var I4=`
|
|
12
12
|
.stx-toast-container {
|
|
13
13
|
position: fixed;
|
|
14
14
|
z-index: 10001;
|
|
@@ -110,7 +110,7 @@ function wZ(){if(typeof Notification<"u"&&Notification.permission==="granted")re
|
|
|
110
110
|
.stx-toast.success { border-left: 4px solid #27ae60; }
|
|
111
111
|
.stx-toast.warning { border-left: 4px solid #f39c12; }
|
|
112
112
|
.stx-toast.error { border-left: 4px solid #e74c3c; }
|
|
113
|
-
`;function vZ(){return!1}function c(){return typeof window<"u"&&typeof document<"u"}var M=[];function mZ(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function bZ(Z){switch(Z){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function y(Z){if(Z==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function uZ(Z){let{options:$}=Z,Y=bZ($.type),z=$.buttons||y($.type),G=$.type||"info",X="";return z.forEach((O
|
|
113
|
+
`;function vZ(){return!1}function c(){return typeof window<"u"&&typeof document<"u"}var M=[];function mZ(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function bZ(Z){switch(Z){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function y(Z){if(Z==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function uZ(Z){let{options:$}=Z,Y=bZ($.type),z=$.buttons||y($.type),G=$.type||"info",X="";return z.forEach((P,O)=>{let V=P.style==="destructive"?"destructive":P.style==="primary"?"primary":"default",j=O===($.defaultButton??z.length-1)?"autofocus":"";X+=`<button class="stx-modal-btn ${V}" data-index="${O}" ${j}>${P.label}</button>`}),`
|
|
114
114
|
<div class="stx-modal-overlay" data-modal-id="${Z.id}">
|
|
115
115
|
<div class="stx-modal ${G}" role="dialog" aria-modal="true" aria-labelledby="${Z.id}-title">
|
|
116
116
|
<div class="stx-modal-icon">${Y}</div>
|
|
@@ -121,7 +121,7 @@ function wZ(){if(typeof Notification<"u"&&Notification.permission==="granted")re
|
|
|
121
121
|
<div class="stx-modal-buttons">${X}</div>
|
|
122
122
|
</div>
|
|
123
123
|
</div>
|
|
124
|
-
`}function GZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(Z,$,Y=!1){let z=M.indexOf(Z);if(z>-1)M.splice(z,1);if(Z.element&&c())Z.element.remove();let X=(Z.options.buttons||y(Z.options.type))[$];if(X?.action)X.action();Z.resolve({buttonIndex:$,cancelled:Y})}async function T(Z){let $=vZ(),Y=mZ();return new Promise((z)=>{let G={id:Y,options:Z,resolve:z};if(M.push(G),$)console.log(`[stx-modal] Showing native modal: ${Z.title||"Modal"}`),setTimeout(()=>{D(G,Z.defaultButton??0,!1)},0);else if(c())try{let X=document.createElement("div");X.innerHTML=uZ(G);let
|
|
124
|
+
`}function GZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(Z,$,Y=!1){let z=M.indexOf(Z);if(z>-1)M.splice(z,1);if(Z.element&&c())Z.element.remove();let X=(Z.options.buttons||y(Z.options.type))[$];if(X?.action)X.action();Z.resolve({buttonIndex:$,cancelled:Y})}async function T(Z){let $=vZ(),Y=mZ();return new Promise((z)=>{let G={id:Y,options:Z,resolve:z};if(M.push(G),$)console.log(`[stx-modal] Showing native modal: ${Z.title||"Modal"}`),setTimeout(()=>{D(G,Z.defaultButton??0,!1)},0);else if(c())try{let X=document.createElement("div");X.innerHTML=uZ(G);let P=X.firstElementChild;if(!P){console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`),setTimeout(()=>{D(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(()=>{D(G,Z.defaultButton??0,!1)},0);return}try{P.querySelectorAll(".stx-modal-btn").forEach((O)=>{O.addEventListener("click",()=>{let V=Number.parseInt(O.dataset.index||"0",10);D(G,V,!1)})})}catch{}try{P.addEventListener("click",(O)=>{if(O.target===P){let V=Z.cancelButton??0;D(G,V,!0)}})}catch{}try{let O=(V)=>{if(V.key==="Escape"){let j=Z.cancelButton??0;D(G,j,!0),document.removeEventListener("keydown",O)}else if(V.key==="Enter"){let j=Z.defaultButton??(Z.buttons||y(Z.type)).length-1;D(G,j,!1),document.removeEventListener("keydown",O)}};document.addEventListener("keydown",O)}catch{}try{let O=P.querySelector(".stx-modal-btn[autofocus]");if(O)O.focus()}catch{}if(typeof process<"u"&&process.env.BUN_TEST)setTimeout(()=>{D(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(()=>{D(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 X=Z.buttons||y(Z.type);console.log(`[stx-modal] Buttons: ${X.map((P)=>P.label).join(", ")}`),setTimeout(()=>{D(G,Z.defaultButton??0,!1)},0)}})}async function lZ(Z,$){return T({title:Z,message:$,type:"info"})}async function f4(Z,$){return T({title:Z,message:$,type:"warning"})}async function B4(Z,$){return T({title:Z,message:$,type:"error"})}async function v4(Z,$){return T({title:Z,message:$,type:"success"})}async function gZ(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 gZ($,Z)).buttonIndex===1}async function b4(Z,$="Alert"){await lZ($,Z)}async function u4(Z,$="",Y="Input"){if(c()&&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 l4(){return M.length}function g4(){while(M.length>0){let Z=M[M.length-1];D(Z,0,!0)}}var h4=`
|
|
125
125
|
.stx-modal-overlay {
|
|
126
126
|
position: fixed;
|
|
127
127
|
inset: 0;
|
|
@@ -253,9 +253,9 @@ function wZ(){if(typeof Notification<"u"&&Notification.permission==="granted")re
|
|
|
253
253
|
background: #555;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
`;function QZ(Z){let $=new Set(Z.properties??[]);if(Z.canChooseDirectories)$.add("openDirectory");if(Z.canChooseFiles)$.add("openFile");if(Z.multiSelections)$.add("multiSelections");if(Z.showHiddenFiles)$.add("showHiddenFiles");if(Z.canCreateDirectories)$.add("createDirectory");return{...Z,properties:[...$]}}function f(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function p4(Z={}){if(f()){let $=window;try{return await $.craft.dialog.showOpenDialog(QZ(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=new Set(QZ(Z).properties),z=document.createElement("input");if(z.type="file",z.multiple=Y.has("multiSelections"),Z.filters?.length){let G=Z.filters.flatMap((X)=>X.extensions.map((
|
|
256
|
+
`;function QZ(Z){let $=new Set(Z.properties??[]);if(Z.canChooseDirectories)$.add("openDirectory");if(Z.canChooseFiles)$.add("openFile");if(Z.multiSelections)$.add("multiSelections");if(Z.showHiddenFiles)$.add("showHiddenFiles");if(Z.canCreateDirectories)$.add("createDirectory");return{...Z,properties:[...$]}}function f(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function p4(Z={}){if(f()){let $=window;try{return await $.craft.dialog.showOpenDialog(QZ(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=new Set(QZ(Z).properties),z=document.createElement("input");if(z.type="file",z.multiple=Y.has("multiSelections"),Z.filters?.length){let G=Z.filters.flatMap((X)=>X.extensions.map((P)=>`.${P}`));z.accept=G.join(",")}if(Y.has("openDirectory")&&!Y.has("openFile"))z.webkitdirectory=!0;z.onchange=()=>{let G=Array.from(z.files||[]);if(G.length===0)$({canceled:!0,filePaths:[]});else{let X=G.map((P)=>P.name);$({canceled:!1,filePaths:X})}},z.oncancel=()=>{$({canceled:!0,filePaths:[]})},z.click()})}async function d4(Z={}){if(f()){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((X)=>`.${X}`)}}));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 B(Z){if(f()){let P=window;try{return await P.craft.dialog.showMessageBox(Z)}catch(O){console.warn("[stx-dialog] Failed to show native message box:",O)}}let $=Z.buttons||["OK"],Y=Z.detail?`
|
|
257
257
|
|
|
258
|
-
${Z.detail}`:"",z=`${Z.message}${Y}`;if($.length===1)return alert(z),{response:0};let G=Z.cancelButton??$.length-1,X=Z.defaultButton!==void 0&&Z.defaultButton!==G?Z.defaultButton:$.findIndex((O
|
|
258
|
+
${Z.detail}`:"",z=`${Z.message}${Y}`;if($.length===1)return alert(z),{response:0};let G=Z.cancelButton??$.length-1,X=Z.defaultButton!==void 0&&Z.defaultButton!==G?Z.defaultButton:$.findIndex((P,O)=>O!==G);if($.length>2)console.warn(`[stx-dialog] ${$.length} buttons requested; a browser confirm offers two. Reachable: "${$[X]}" and "${$[G]}".`);return{response:confirm(z)?X:G}}async function r4(Z={}){if(f()){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 n4(Z,$){await B({type:"info",title:$||"Alert",message:Z,buttons:["OK"]})}async function o4(Z,$){return(await B({type:"question",title:$||"Confirm",message:Z,buttons:["OK","Cancel"],defaultButton:0,cancelButton:1})).response===0}async function a4(Z,$){await B({type:"error",title:$||"Error",message:Z,buttons:["OK"]})}async function i4(Z,$){await B({type:"warning",title:$||"Warning",message:Z,buttons:["OK"]})}function s4(){return`
|
|
259
259
|
// STX Desktop Dialog Bridge
|
|
260
260
|
// Provides convenient wrappers around window.craft.dialog APIs
|
|
261
261
|
window.stxDialog = {
|
|
@@ -304,12 +304,12 @@ window.stxDialog = {
|
|
|
304
304
|
// Check if dialog is available
|
|
305
305
|
isAvailable: () => typeof window.craft?.dialog !== 'undefined',
|
|
306
306
|
};
|
|
307
|
-
`}var p=null,W=null;class XZ{_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 e4(Z={}){hZ();let{duration:$,preventDisplaySleep:Y=!0,preventIdleSleep:z=!0,preventSystemSleep:G=!0,preventDiskSleep:X=!1,assertUserActivity:
|
|
307
|
+
`}var p=null,W=null;class XZ{_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 e4(Z={}){hZ();let{duration:$,preventDisplaySleep:Y=!0,preventIdleSleep:z=!0,preventSystemSleep:G=!0,preventDiskSleep:X=!1,assertUserActivity:P=!0}=Z,O=[];if(Y)O.push("-d");if(z)O.push("-i");if(G)O.push("-s");if(X)O.push("-m");if(P)O.push("-u");let V=[...O];if($&&$>0)V.push("-t",String($*60));let j=Bun.spawn(["/usr/bin/caffeinate",...V],{stdio:["ignore","ignore","ignore"]}),R=new XZ(j,Z);return p=j,W=R,R}function hZ(Z){if(Z){if(Z.stop(),W===Z)p=null,W=null;return}if(W)W.stop();p=null,W=null}function Z8(){return W!==null&&W.isActive}function $8(){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 J8(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),X=Math.floor(z%3600/60),P=z%60;if(G>0)return`${G}:${String(X).padStart(2,"0")}:${String(P).padStart(2,"0")}`;return`${X}:${String(P).padStart(2,"0")}`}function Y8(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 N=new Map,cZ=0,v=!1;function pZ(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 G8(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 dZ(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 PZ(Z){for(let[,$]of N)if(dZ(Z,$.parsed)){Z.preventDefault(),Z.stopPropagation();try{$.handler()}catch{}break}}function rZ(){if(v)return;if(typeof document>"u")return;document.addEventListener("keydown",PZ,!0),v=!0}function d(){if(!v)return;if(typeof document>"u")return;document.removeEventListener("keydown",PZ,!0),v=!1}async function nZ(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 r(Z){if(typeof window>"u")return;let $=window.craft;if(!$?.hotkeys?.unregister)return;try{await $.hotkeys.unregister(Z)}catch{}}function Q8(Z,$){let Y=`hotkey_${++cZ}_${Date.now()}`,z=pZ(Z);N.set(Y,{shortcut:Z,handler:$,parsed:z}),nZ(Y,Z),rZ();let G={shortcut:Z,id:Y,unregister(){oZ(G)}};return G}function oZ(Z){if(N.delete(Z.id),r(Z.id),N.size===0)d()}function X8(){for(let[Z]of N)r(Z);N.clear(),d()}function P8(){return Array.from(N.entries()).map(([Z,$])=>({shortcut:$.shortcut,id:Z,unregister(){if(N.delete(Z),r(Z),N.size===0)d()}}))}class OZ{_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 VZ{_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 V8(Z){return new OZ(Z)}function F8(Z){return new VZ(Z)}function j8(Z){return new Promise(($)=>setTimeout($,Z))}function W8(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 K8(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 F(Z){if(!J(Z))throw Error(`craft.${Z} is not available \u2014 this API requires a Craft native window`);return window.craft[Z]}function Q(Z,$){if(typeof window>"u")return()=>{};let Y=(z)=>$(z.detail??{});return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var N8={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([aZ(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 aZ(Z){return Z.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
308
308
|
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
309
309
|
|
|
310
|
-
`).trim()}var H8={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 $=iZ(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 Q("craft:notification:actionClicked",Z)},onReply(Z){return Q("craft:notification:reply",Z)}};function iZ(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 S8={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 tZ(Y);return new TextEncoder().encode(Y)},async writeFile(Z,$){await V("fs").writeFile(Z,$)},async writeBuffer(Z,$){let Y=sZ($),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 eZ(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 Q("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 X=$.kinds&&$.kinds.length>0?new Set($.kinds):null,O=Math.max(0,Math.floor($.coalesceMs??0)),P=[],F=null,j=!1,R=()=>{if(F=null,P.length===0)return;let L=P;P=[];try{Y(L)}catch{}},q=Q("craft:fs:change",(L)=>{if(j)return;if(L.id!==z)return;if(X&&L.kind&&!X.has(L.kind))return;if(P.push(L),O===0){R();return}if(F==null)F=setTimeout(R,O)});return{id:z,async stop(){if(j)return;if(j=!0,q(),F)clearTimeout(F),F=null;if(P.length>0)R();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 sZ(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 tZ(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 eZ(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 _=new Set,FZ=!1;function Z4(){if(FZ)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let $=Z.detail;if($?.id)_.delete($.id)}),FZ=!0}var $4=new Set(["javascript:","data:","file:","vbscript:"]),_8={async openExternal(Z){let $=Z.trim().toLowerCase();for(let Y of $4)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(Z4(),!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(_.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);_.add(Z);try{await V("shell").spawn(Z,$,Y,z)}catch(G){throw _.delete(Z),G}},async kill(Z){await V("shell").kill(Z),_.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 Q("craft:shell:stdout",Z)},onStderr(Z){return Q("craft:shell:stderr",Z)},onExit(Z){return Q("craft:shell:exit",Z)}};function S(){return window.craft.shortcuts}var C8={async register(Z,$,Y){if(!J("shortcuts"))return;await S().register(Z,$,Y)},async unregister(Z){if(!J("shortcuts"))return;await S().unregister(Z)},async unregisterAll(){if(!J("shortcuts"))return;await S().unregisterAll()},async enable(Z){if(!J("shortcuts"))return;await S().enable(Z)},async disable(Z){if(!J("shortcuts"))return;await S().disable(Z)},async isRegistered(Z){if(!J("shortcuts"))return!1;return await S().isRegistered(Z)},async list(){if(!J("shortcuts"))return[];return await S().list()},on(Z){return Q("craft:shortcut",Z)}};var y8={get(){if(J("theme"))try{return window.craft.theme.get()}catch{}return{appearance:J4()}},onChange(Z){if(Z(this.get()),J("theme"))return Q("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 J4(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function v8(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 l8={onUrl(Z){if(!J("deepLink"))return()=>{};return Q("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 c8={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 Q("craft:powerSleep",Z)},onWake(Z){return Q("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 r8={async connectionType(){if(J("network"))return await window.craft.network.connectionType();return jZ()},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 Q("craft:networkChange",Z);if(typeof window>"u")return()=>{};let $=()=>Z({type:jZ(),online:!0}),Y=()=>Z({type:"none",online:!1});return window.addEventListener("online",$),window.addEventListener("offline",Y),()=>{window.removeEventListener("online",$),window.removeEventListener("offline",Y)}}};function jZ(){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 a8={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 Q("craft:updateAvailable",Z)},onDownloaded(Z){return Q("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:$,publicKeyB64:Y}){let z=WZ(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 X=new Uint8Array(await G.arrayBuffer()),O;try{O=await crypto.subtle.importKey("raw",b(Y),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let P=!1;try{P=await crypto.subtle.verify("Ed25519",O,b($),WZ(X))}catch{P=!1}if(!P)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:X}}};function WZ(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),X=new Uint8Array(G);for(let O=0;O<z.length;O++)X[O]=z.charCodeAt(O);return X}let $=Buffer.from(Z,"base64"),Y=new ArrayBuffer($.length);return new Uint8Array(Y).set($),new Uint8Array(Y)}var t8={onFocus(Z){if(J("window"))return Q("craft:window:focus",()=>Z());return n("focus",Z)},onBlur(Z){if(J("window"))return Q("craft:window:blur",()=>Z());return n("blur",Z)},onResize(Z){if(J("window"))return Q("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 Q("craft:window:move",Z);return()=>{}},onClose(Z){if(J("window"))return Q("craft:window:close",()=>Z());return n("beforeunload",Z)},onMinimize(Z){if(J("window"))return Q("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 Q("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)}};function n(Z,$){if(typeof window>"u")return()=>{};let Y=()=>$();return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var KZ={name:"",version:"0.0.0"},$$={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 KZ;let Z=await window.craft.app.getInfo();return{...KZ,...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 z$={app(Z,$={}){return{label:Z,items:[{label:`About ${Z}`,role:"about"},{separator:!0},...$.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:$.settings},{separator:!0}]:[],{label:`Hide ${Z}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${Z}`,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(Z,$={}){return[this.app(Z,$),this.edit()]}},Y4=0;function z4(Z){let $=new Map;return{payload:{menus:Z.menus.map((z)=>({label:z.label,items:z.items.map((G)=>{let{onClick:X,...O}=G;if(O.separator)return O;let P=O.id??`stx.menu.${Y4++}`;if(X)$.set(P,X);return{...O,id:P}})}))},handlers:$}}var o=null,G$={async set(Z){if(!J("menu"))return!1;let{payload:$,handlers:Y}=z4(Z);if(o?.(),o=null,Y.size>0)o=Q("craft:menu:action",(z)=>{Y.get(z.id)?.()});return await window.craft.menu.set($),!0},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 Q("craft:menu:action",Z)}};function LZ(Z){if(Z.separator)return{id:Z.id||"",title:"",type:"separator"};return{id:Z.id||"",title:Z.title||"",icon:Z.icon,shortcut:Z.shortcut,enabled:Z.disabled?!1:void 0,checked:Z.checked?!0:void 0,type:Z.submenu?"submenu":void 0,submenu:Z.submenu?.map(LZ)}}async function RZ(Z){if(!Z.items||Z.items.length===0)throw Error("contextMenu.show requires at least one item");if(!J("nativeUI"))return null;let $=await window.craft.nativeUI.showContextMenu({targetId:Z.targetId||"",targetType:"general",x:Math.round(Z.x),y:Math.round(Z.y),items:Z.items.map(LZ)});return{id:typeof $?.id==="string"?$.id:null,targetId:$?.targetId}}var P$={available(){return J("nativeUI")},async show(Z){return await RZ(Z)!==null},async pick(Z){return(await RZ(Z))?.id??null},onAction(Z){return Q("craft:contextmenu:action",($)=>{if(typeof $.id==="string")Z({id:$.id,targetId:$.targetId??""})})}};function a(Z){if(Z===null||Z===void 0||Z===0)return"";return String(Z)}function DZ(Z){return Z.map(($)=>({id:$.id,header:$.header,items:$.items.map((Y)=>({id:Y.id,label:Y.label,icon:Y.icon,badge:a(Y.badge)||void 0}))}))}function NZ(Z){return JSON.stringify(Z.map(($)=>[$.id,$.header??"",$.items.map((Y)=>[Y.id,Y.label,Y.icon??""])]))}function kZ(Z){return new Map(Z.flatMap(($)=>$.items.map((Y)=>[Y.id,a(Y.badge)])))}var G4={available(){return J("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(Z){if(!G4.available())return null;let $=window.craft.nativeUI.createSidebar({id:Z.id,sections:DZ(Z.sections),selected:Z.selected}),Y=Z.sections,z=new Set;return $.onSelect((G)=>{for(let X of[...z])X(G)}),{id:$.id,update(G){if(NZ(G)===NZ(Y)){let X=kZ(Y);for(let[O,P]of kZ(G))if(X.get(O)!==P)$.updateItem(O,{badge:P})}else $.setSections(DZ(G));Y=G},updateItem(G,X){$.updateItem(G,{...X.label!==void 0?{label:X.label}:{},...X.icon!==void 0?{icon:X.icon}:{},..."badge"in X?{badge:a(X.badge)}:{}}),Y=Y.map((O)=>({...O,items:O.items.map((P)=>P.id===G?{...P,...X}:P)}))},select(G){$.setSelectedItem(G)},onSelect(G){return z.add(G),()=>z.delete(G)},destroy(){z.clear(),$.destroy()}}}};var W$={async getDisplays(){if(J("screen"))return await window.craft.screen.getDisplays();return qZ()},async getPrimary(){if(J("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return qZ()[0]??null},onChange(Z){if(J("screen"))return Q("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let $=()=>Z();return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}};function qZ(){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 L$={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 k$={async check(Z){if(J("permissions"))return await window.craft.permissions.check(Z);return await HZ(Z)},async request(Z){if(J("permissions"))return await window.craft.permissions.request(Z);return await Q4(Z)},async openSettings(Z){if(J("permissions"))await window.craft.permissions.openSettings(Z)}};async function HZ(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let $=await navigator.permissions.query({name:Z});return X4($.state)}catch{return"not-supported"}}async function Q4(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let $=await window.Notification.requestPermission();return $==="granted"?"granted":$==="denied"?"denied":"undetermined"}return await HZ(Z)}function X4(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var U$={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 A$={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()}};function i(){if(!J("window"))return null;return window.craft.window}function k(Z){let $=i();if(!$)return Promise.resolve();try{return Promise.resolve(Z($)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var x$={get available(){return i()!==null},open(Z){let $=()=>{if(typeof window<"u"&&Z.url)window.open(Z.url,Z.name);return{name:Z.name}},Y=i();if(!Y?.open)return Promise.resolve($());return Y.open(Z).then((z)=>({name:z?.name||Z.name})).catch($)},close:()=>k((Z)=>Z.close?.()),focus:()=>k((Z)=>Z.focus?.()),minimize:()=>k((Z)=>Z.minimize?.()),maximize:()=>k((Z)=>Z.maximize?.()),center:()=>k((Z)=>Z.center?.()),startDrag:()=>k((Z)=>Z.startDrag?.()),setTitle:(Z)=>k(($)=>$.setTitle?.(Z)),setSize:(Z,$)=>k((Y)=>Y.setSize?.(Z,$)),setAppearance:(Z)=>k(($)=>$.setAppearance?.(Z))};var w$={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 Q("craft:touchbar:action",Z)}};var P4=/^[\da-f]*$/i;function O4(Z,$){if(typeof $!=="string"||!P4.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(O4("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 Q("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return Q("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return Q("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return Q("craft:bluetooth:characteristicValue",Z)}};var m$={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((X)=>X.voiceURI===$.voice||X.name===$.voice||X.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 x=[],s=!0,t,e,u={async report(Z){if(J("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!s)return;let $=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:t,appVersion:e}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:t,appVersion:e};if(x.length>=64)x.shift();x.push($)},async flush(){if(J("crashReporter"))return await window.craft.crashReporter.flush();return[...x]},async clear(){if(J("crashReporter")){await window.craft.crashReporter.clear();return}x.length=0},async setEnabled(Z){if(J("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}s=Z},async isEnabled(){if(J("crashReporter"))return await window.craft.crashReporter.isEnabled();return s},async setUser(Z){if(J("crashReporter")){await window.craft.crashReporter.setUser(Z);return}t=Z||void 0},async setAppVersion(Z){if(J("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}e=Z||void 0},attachGlobalHandlers(){if(J("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=(Y)=>{u.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;u.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 D4(Z)}},V4="craft:crashReporter:pending",F4=/[\w.+-]+@[\w-]+\.[\w.-]+/g,j4=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,W4=/\/(?:Users|home)\/[^\s/'"`]+/g;function K4(Z){let $=(Y)=>Y.replace(F4,"<email>").replace(j4,"<ip>").replace(W4,"/<home>");return{...Z,message:$(Z.message),stack:$(Z.stack)}}async function R4(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((X)=>X.toString(16).padStart(2,"0")).join("")}function L4(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 UZ(Z,$){if(!Z||typeof localStorage>"u")return;try{if($.length===0)localStorage.removeItem(Z);else localStorage.setItem(Z,JSON.stringify($))}catch{}}function D4(Z){let{endpoint:$,intervalMs:Y=60000,signingSecret:z,redact:G=!0,headers:X={},maxRetries:
|
|
310
|
+
`).trim()}var H8={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 $=iZ(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 Q("craft:notification:actionClicked",Z)},onReply(Z){return Q("craft:notification:reply",Z)}};function iZ(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 S8={async readFile(Z){let $=await F("fs").readFile(Z);return $&&$.data||""},async readBuffer(Z){let $=await F("fs").readFile(Z),Y=$&&$.data||"";if($&&$.base64===!0)return tZ(Y);return new TextEncoder().encode(Y)},async writeFile(Z,$){await F("fs").writeFile(Z,$)},async writeBuffer(Z,$){let Y=sZ($),z=F("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 F("fs").copy(Z,$)},async move(Z,$){if(Z===$)throw Error("fs.move: source and destination must differ");await F("fs").move(Z,$)},async appendFile(Z,$){await F("fs").appendFile(Z,$)},async deleteFile(Z){await F("fs").deleteFile(Z)},async exists(Z){return await F("fs").exists(Z)},async stat(Z){return eZ(await F("fs").stat(Z))},async readDir(Z){let $=await F("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 F("fs").mkdir(Z,$)},async rmdir(Z,$){await F("fs").rmdir(Z,$)},async watch(Z,$){await F("fs").watch(Z,$)},async unwatch(Z){await F("fs").unwatch(Z)},onChange(Z){return Q("craft:fs:change",Z)},async watchTree(Z,$,Y){let z=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=F("fs");await G.watch(Z,z,{recursive:!!$.recursive});let X=$.kinds&&$.kinds.length>0?new Set($.kinds):null,P=Math.max(0,Math.floor($.coalesceMs??0)),O=[],V=null,j=!1,R=()=>{if(V=null,O.length===0)return;let L=O;O=[];try{Y(L)}catch{}},q=Q("craft:fs:change",(L)=>{if(j)return;if(L.id!==z)return;if(X&&L.kind&&!X.has(L.kind))return;if(O.push(L),P===0){R();return}if(V==null)V=setTimeout(R,P)});return{id:z,async stop(){if(j)return;if(j=!0,q(),V)clearTimeout(V),V=null;if(O.length>0)R();try{await G.unwatch(z)}catch{}}}},async homeDir(){return await F("fs").homeDir()},async tempDir(){return await F("fs").tempDir()},async appDataDir(){return await F("fs").appDataDir()}};function sZ(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 tZ(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 eZ(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 _=new Set,FZ=!1;function Z4(){if(FZ)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let $=Z.detail;if($?.id)_.delete($.id)}),FZ=!0}var $4=new Set(["javascript:","data:","file:","vbscript:"]),_8={async openExternal(Z){let $=Z.trim().toLowerCase();for(let Y of $4)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 F("shell").openPath(Z)},async showInFinder(Z){await F("shell").showInFinder(Z)},async spawn(Z,$,Y=[],z={}){if(Z4(),!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(_.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);_.add(Z);try{await F("shell").spawn(Z,$,Y,z)}catch(G){throw _.delete(Z),G}},async kill(Z){await F("shell").kill(Z),_.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 F("shell").setEnv(Z,$)},onStdout(Z){return Q("craft:shell:stdout",Z)},onStderr(Z){return Q("craft:shell:stderr",Z)},onExit(Z){return Q("craft:shell:exit",Z)}};function S(){return window.craft.shortcuts}var C8={async register(Z,$,Y){if(!J("shortcuts"))return;await S().register(Z,$,Y)},async unregister(Z){if(!J("shortcuts"))return;await S().unregister(Z)},async unregisterAll(){if(!J("shortcuts"))return;await S().unregisterAll()},async enable(Z){if(!J("shortcuts"))return;await S().enable(Z)},async disable(Z){if(!J("shortcuts"))return;await S().disable(Z)},async isRegistered(Z){if(!J("shortcuts"))return!1;return await S().isRegistered(Z)},async list(){if(!J("shortcuts"))return[];return await S().list()},on(Z){return Q("craft:shortcut",Z)}};var y8={get(){if(J("theme"))try{return window.craft.theme.get()}catch{}return{appearance:J4()}},onChange(Z){if(Z(this.get()),J("theme"))return Q("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 J4(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function v8(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 l8={onUrl(Z){if(!J("deepLink"))return()=>{};return Q("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 c8={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 Q("craft:powerSleep",Z)},onWake(Z){return Q("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 r8={async connectionType(){if(J("network"))return await window.craft.network.connectionType();return jZ()},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 Q("craft:networkChange",Z);if(typeof window>"u")return()=>{};let $=()=>Z({type:jZ(),online:!0}),Y=()=>Z({type:"none",online:!1});return window.addEventListener("online",$),window.addEventListener("offline",Y),()=>{window.removeEventListener("online",$),window.removeEventListener("offline",Y)}}};function jZ(){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 a8={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 Q("craft:updateAvailable",Z)},onDownloaded(Z){return Q("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:$,publicKeyB64:Y}){let z=WZ(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 X=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 O=!1;try{O=await crypto.subtle.verify("Ed25519",P,b($),WZ(X))}catch{O=!1}if(!O)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:X}}};function WZ(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),X=new Uint8Array(G);for(let P=0;P<z.length;P++)X[P]=z.charCodeAt(P);return X}let $=Buffer.from(Z,"base64"),Y=new ArrayBuffer($.length);return new Uint8Array(Y).set($),new Uint8Array(Y)}var t8={onFocus(Z){if(J("window"))return Q("craft:window:focus",()=>Z());return n("focus",Z)},onBlur(Z){if(J("window"))return Q("craft:window:blur",()=>Z());return n("blur",Z)},onResize(Z){if(J("window"))return Q("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 Q("craft:window:move",Z);return()=>{}},onClose(Z){if(J("window"))return Q("craft:window:close",()=>Z());return n("beforeunload",Z)},onMinimize(Z){if(J("window"))return Q("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 Q("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)}};function n(Z,$){if(typeof window>"u")return()=>{};let Y=()=>$();return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var KZ={name:"",version:"0.0.0"},$$={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 KZ;let Z=await window.craft.app.getInfo();return{...KZ,...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 z$={app(Z,$={}){return{label:Z,items:[{label:`About ${Z}`,role:"about"},{separator:!0},...$.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:$.settings},{separator:!0}]:[],{label:`Hide ${Z}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${Z}`,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(Z,$={}){return[this.app(Z,$),this.edit()]}},Y4=0;function z4(Z){let $=new Map;return{payload:{menus:Z.menus.map((z)=>({label:z.label,items:z.items.map((G)=>{let{onClick:X,...P}=G;if(P.separator)return P;let O=P.id??`stx.menu.${Y4++}`;if(X)$.set(O,X);return{...P,id:O}})}))},handlers:$}}var o=null,G$={async set(Z){if(!J("menu"))return!1;let{payload:$,handlers:Y}=z4(Z);if(o?.(),o=null,Y.size>0)o=Q("craft:menu:action",(z)=>{Y.get(z.id)?.()});return await window.craft.menu.set($),!0},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 Q("craft:menu:action",Z)}};function LZ(Z){if(Z.separator)return{id:Z.id||"",title:"",type:"separator"};return{id:Z.id||"",title:Z.title||"",icon:Z.icon,shortcut:Z.shortcut,enabled:Z.disabled?!1:void 0,checked:Z.checked?!0:void 0,type:Z.submenu?"submenu":void 0,submenu:Z.submenu?.map(LZ)}}async function RZ(Z){if(!Z.items||Z.items.length===0)throw Error("contextMenu.show requires at least one item");if(!J("nativeUI"))return null;let $=window.craft?.nativeUI;if(!$)return null;let Y=await $.showContextMenu({targetId:Z.targetId||"",targetType:"general",x:Math.round(Z.x),y:Math.round(Z.y),items:Z.items.map(LZ)});return{id:typeof Y?.id==="string"?Y.id:null,targetId:Y?.targetId}}var P$={available(){return J("nativeUI")},async show(Z){return await RZ(Z)!==null},async pick(Z){return(await RZ(Z))?.id??null},onAction(Z){return Q("craft:contextmenu:action",($)=>{if(typeof $.id==="string")Z({id:$.id,targetId:$.targetId??""})})}};function a(Z){if(Z===null||Z===void 0||Z===0)return"";return String(Z)}function DZ(Z){return Z.map(($)=>({id:$.id,header:$.header,items:$.items.map((Y)=>({id:Y.id,label:Y.label,icon:Y.icon,badge:a(Y.badge)||void 0}))}))}function NZ(Z){return JSON.stringify(Z.map(($)=>[$.id,$.header??"",$.items.map((Y)=>[Y.id,Y.label,Y.icon??""])]))}function kZ(Z){return new Map(Z.flatMap(($)=>$.items.map((Y)=>[Y.id,a(Y.badge)])))}var G4={available(){return J("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(Z){if(!G4.available())return null;let $=window.craft?.nativeUI;if(!$)return null;let Y=$.createSidebar({id:Z.id,sections:DZ(Z.sections),selected:Z.selected}),z=Z.sections,G=new Set;return Y.onSelect((X)=>{for(let P of[...G])P(X)}),{id:Y.id,update(X){if(NZ(X)===NZ(z)){let P=kZ(z);for(let[O,V]of kZ(X))if(P.get(O)!==V)Y.updateItem(O,{badge:V})}else Y.setSections(DZ(X));z=X},updateItem(X,P){Y.updateItem(X,{...P.label!==void 0?{label:P.label}:{},...P.icon!==void 0?{icon:P.icon}:{},..."badge"in P?{badge:a(P.badge)}:{}}),z=z.map((O)=>({...O,items:O.items.map((V)=>V.id===X?{...V,...P}:V)}))},select(X){Y.setSelectedItem(X)},onSelect(X){return G.add(X),()=>G.delete(X)},destroy(){G.clear(),Y.destroy()}}}};var W$={async getDisplays(){if(J("screen"))return await window.craft.screen.getDisplays();return qZ()},async getPrimary(){if(J("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return qZ()[0]??null},onChange(Z){if(J("screen"))return Q("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let $=()=>Z();return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}};function qZ(){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 L$={async set(Z,$,Y){if(!Z)throw Error("keychain.set: service is required");if(!$)throw Error("keychain.set: account is required");await F("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 F("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 F("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 F("keychain").has(Z,$)}};var k$={async check(Z){if(J("permissions"))return await window.craft.permissions.check(Z);return await HZ(Z)},async request(Z){if(J("permissions"))return await window.craft.permissions.request(Z);return await Q4(Z)},async openSettings(Z){if(J("permissions"))await window.craft.permissions.openSettings(Z)}};async function HZ(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let $=await navigator.permissions.query({name:Z});return X4($.state)}catch{return"not-supported"}}async function Q4(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let $=await window.Notification.requestPermission();return $==="granted"?"granted":$==="denied"?"denied":"undetermined"}return await HZ(Z)}function X4(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var U$={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 F("printing").printToPDF(Z);return{ok:!!(z&&z.ok),path:z?.path}}};var A$={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()}};function i(){if(!J("window"))return null;return window.craft.window}function k(Z){let $=i();if(!$)return Promise.resolve();try{return Promise.resolve(Z($)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var x$={get available(){return i()!==null},open(Z){let $=()=>{if(typeof window<"u"&&Z.url)window.open(Z.url,Z.name);return{name:Z.name}},Y=i();if(!Y?.open)return Promise.resolve($());return Y.open(Z).then((z)=>({name:z?.name||Z.name})).catch($)},close:()=>k((Z)=>Z.close?.()),focus:()=>k((Z)=>Z.focus?.()),minimize:()=>k((Z)=>Z.minimize?.()),maximize:()=>k((Z)=>Z.maximize?.()),center:()=>k((Z)=>Z.center?.()),startDrag:()=>k((Z)=>Z.startDrag?.()),setTitle:(Z)=>k(($)=>$.setTitle?.(Z)),setSize:(Z,$)=>k((Y)=>Y.setSize?.(Z,$)),setAppearance:(Z)=>k(($)=>$.setAppearance?.(Z))};var w$={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 Q("craft:touchbar:action",Z)}};var P4=/^[\da-f]*$/i;function O4(Z,$){if(typeof $!=="string"||!P4.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(O4("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 Q("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return Q("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return Q("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return Q("craft:bluetooth:characteristicValue",Z)}};var m$={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((X)=>X.voiceURI===$.voice||X.name===$.voice||X.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 x=[],s=!0,t,e,u={async report(Z){if(J("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!s)return;let $=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:t,appVersion:e}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:t,appVersion:e};if(x.length>=64)x.shift();x.push($)},async flush(){if(J("crashReporter"))return await window.craft.crashReporter.flush();return[...x]},async clear(){if(J("crashReporter")){await window.craft.crashReporter.clear();return}x.length=0},async setEnabled(Z){if(J("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}s=Z},async isEnabled(){if(J("crashReporter"))return await window.craft.crashReporter.isEnabled();return s},async setUser(Z){if(J("crashReporter")){await window.craft.crashReporter.setUser(Z);return}t=Z||void 0},async setAppVersion(Z){if(J("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}e=Z||void 0},attachGlobalHandlers(){if(J("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=(Y)=>{u.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;u.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 D4(Z)}},V4="craft:crashReporter:pending",F4=/[\w.+-]+@[\w-]+\.[\w.-]+/g,j4=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,W4=/\/(?:Users|home)\/[^\s/'"`]+/g;function K4(Z){let $=(Y)=>Y.replace(F4,"<email>").replace(j4,"<ip>").replace(W4,"/<home>");return{...Z,message:$(Z.message),stack:$(Z.stack)}}async function R4(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((X)=>X.toString(16).padStart(2,"0")).join("")}function L4(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 UZ(Z,$){if(!Z||typeof localStorage>"u")return;try{if($.length===0)localStorage.removeItem(Z);else localStorage.setItem(Z,JSON.stringify($))}catch{}}function D4(Z){let{endpoint:$,intervalMs:Y=60000,signingSecret:z,redact:G=!0,headers:X={},maxRetries:P=5,persistKey:O}=Z,V=O===null?null:O??V4,j=L4(V),R=!1,q=null,L=null,xZ=typeof G==="function"?G:G===!1?(H)=>H:K4;async function EZ(H){let E=JSON.stringify({entries:H}),C={"Content-Type":"application/json",...X};if(z)C["X-Craft-Signature"]=await R4(z,E);let JZ=0,g=1000;while(!R)try{let A=await fetch($,{method:"POST",headers:C,body:E});if(A.ok)return;if(A.status>=400&&A.status<500)return;throw Error(`HTTP ${A.status}`)}catch(A){if(JZ+=1,JZ>P)throw j=[...H,...j],UZ(V,j),A;await new Promise((CZ)=>{setTimeout(CZ,g)}),g=Math.min(g*2,60000)}}async function $Z(){if(R||L)return L??void 0;let H=await u.flush();if(H.length>0)await u.clear();if(j=[...j,...H.map((C)=>xZ(C))],j.length===0)return;let E=j;return j=[],UZ(V,j),L=EZ(E).catch(()=>{}).finally(()=>{L=null}),L}if(Y>0)q=setInterval(()=>{$Z().catch(()=>{})},Y);return{async flushNow(){await $Z()},stop(){if(R=!0,q)clearInterval(q);q=null},pending(){return[...j]}}}var c$={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 Q("craft:iap:purchased",Z)},onFailed(Z){return Q("craft:iap:failed",Z)},onRestored(Z){return Q("craft:iap:restored",Z)},onProductsLoaded(Z){return Q("craft:iap:productsLoaded",($)=>Z($.products||[]))},onRefunded(Z){return Q("craft:iap:refunded",Z)},onSubscriptionStatusChanged(Z){return Q("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 l={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 Q("craft:handoff:incoming",Z)}};var o$={async start(Z,$){return l.startActivity(Z,{title:$?.title,webpageURL:$?.webpageURL,userInfo:$?.state})},async update(Z){return l.updateActivity({title:Z.title,webpageURL:Z.webpageURL,userInfo:Z.state})},async stop(){await l.stopActivity()}};var s$={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 Q("craft:location:update",Z)},onError(Z){return Q("craft:location:error",Z)},onAuthChanged(Z){return Q("craft:location:authChanged",Z)}};var ZJ={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 N4=250,k4=60000,SZ=2000,MZ={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function q4(){return{...MZ,signals:{...MZ.signals},sources:[]}}var ZZ={async getState(){if(!J("screenSharing"))return q4();return await window.craft.screenSharing.getState()},async watch(Z=SZ){let $=Math.min(k4,Math.max(N4,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 Q("craft:screenSharing:change",Z)}};async function YJ(Z,$=SZ){let Y=ZZ.onChange(Z);return await ZZ.watch($),()=>{Y(),ZZ.stop()}}var H4={supported:!1,isFocused:null,authorization:"unsupported"};function AZ(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var TZ={async getStatus(){if(!J("focus"))return{...H4};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 AZ();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 AZ();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 $=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean($?.canList),shortcuts:$?.shortcuts??[]}}};async function QJ(...Z){if(Z.length===0)return!1;let $=new Set(await TZ.listShortcuts());return Z.every((Y)=>$.has(Y))}async function XJ(...Z){if(Z.length===0)return!1;let{canList:$,shortcuts:Y}=await TZ.listShortcutsResult();if(!$)return"unknown";let z=new Set(Y);return Z.every((G)=>z.has(G))}var VJ={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 Q("craft:localServer:request",Z)},async awaitOAuthCallback(Z={}){F("localServer");let{port:$=0,host:Y="127.0.0.1",timeoutMs:z=300000,successHTML:G}=Z,X=await this.start($,Y);if(!X.started)throw Error(`localServer: start failed${X.reason?` \u2014 ${X.reason}`:""}`);return new Promise((P,O)=>{let V=setTimeout(()=>{j(),this.stop().catch(()=>{}),O(Error("localServer: OAuth callback timed out"))},z),j=this.onRequest(({url:R})=>{clearTimeout(V),j();let q=G??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
312
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
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:q,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),
|
|
314
|
+
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:q,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),P({url:R,port:X.port})})})}};var WJ={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,LJ={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 kJ={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 UJ={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 AJ={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 xJ={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 wJ={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 Q("craft:bonjour:found",Z)},onLost(Z){return Q("craft:bonjour:lost",Z)}};var mJ={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 Q("craft:speechRecognition:partial",Z)},onFinal(Z){return Q("craft:speechRecognition:final",Z)}};var cJ={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 rJ={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 Q("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 tJ={async listCameras(){if(!J("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var $Y={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 Q("craft:serviceMenu:invoked",Z)}};var zY={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 Q("craft:serial:data",Z)}};var _Z=[{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 XY(){return _Z.map(({name:Z,support:$})=>({name:Z,support:$,available:J(Z)}))}function U4(Z){let $=_Z.find((Y)=>Y.name===Z);if(!$)return;return{...$,available:J(Z)}}function PY(Z){let $=U4(Z);return!!$&&$.available}
|
|
315
315
|
export{M4 as a,zZ as b,I as c,S4 as d,A4 as e,T4 as f,_4 as g,x4 as h,E4 as i,C4 as j,w4 as k,I4 as l,T as m,lZ as n,f4 as o,B4 as p,v4 as q,gZ as r,m4 as s,b4 as t,u4 as u,l4 as v,g4 as w,h4 as x,p4 as y,d4 as z,B as A,r4 as B,n4 as C,o4 as D,a4 as E,i4 as F,s4 as G,e4 as H,hZ as I,Z8 as J,$8 as K,J8 as L,Y8 as M,pZ as N,G8 as O,Q8 as P,oZ as Q,X8 as R,P8 as S,V8 as T,F8 as U,j8 as V,W8 as W,K8 as X,J as Y,N8 as Z,H8 as _,S8 as $,_8 as aa,C8 as ba,y8 as ca,v8 as da,m8 as ea,l8 as fa,c8 as ga,r8 as ha,a8 as ia,t8 as ja,$$ as ka,z$ as la,G$ as ma,P$ as na,G4 as oa,W$ as pa,L$ as qa,k$ as ra,U$ as sa,A$ as ta,x$ as ua,w$ as va,f$ as wa,m$ as xa,u as ya,K4 as za,R4 as Aa,c$ as Ba,l as Ca,o$ as Da,s$ as Ea,ZJ as Fa,N4 as Ga,k4 as Ha,SZ as Ia,ZZ as Ja,YJ as Ka,TZ as La,QJ as Ma,XJ as Na,VJ as Oa,WJ as Pa,LJ as Qa,kJ as Ra,UJ as Sa,AJ as Ta,xJ as Ua,wJ as Va,fJ as Wa,mJ as Xa,lJ as Ya,cJ as Za,rJ as _a,aJ as $a,tJ as ab,$Y as bb,zY as cb,XY as db,U4 as eb,PY as fb};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$ as Q1,$a as Q2,A as x0,Aa as C1,B as H0,Ba as x1,C as v0,Ca as H1,D as w0,Da as v1,E as f0,Ea as w1,F as S0,Fa as f1,G as g0,Ga as S1,H as b0,Ha as g1,I as y0,Ia as b1,J as u0,Ja as y1,K as h0,Ka as u1,L as m0,La as h1,M as c0,Ma as m1,N as d0,Na as c1,O as p0,Oa as d1,P as r0,Pa as p1,Q as n0,Qa as r1,R as o0,Ra as n1,S as l0,Sa as o1,T as a0,Ta as l1,U as i0,Ua as a1,V as s0,Va as i1,W as t0,Wa as s1,X as e0,Xa as t1,Y as n,Ya as e1,Z as Y1,Za as Y2,_ as Z1,_a as Z2,a as $0,aa as X1,ab as X2,b as J0,ba as $1,bb as $2,c as G0,ca as J1,cb as J2,d as R0,da as G1,db as G2,e as q0,ea as R1,eb as R2,f as K0,fa as q1,fb as q2,g as U0,ga as K1,h as _0,ha as U1,i as E0,ia as _1,j as F0,ja as E1,k as j0,ka as F1,l as B0,la as j1,m as V0,ma as B1,n as O0,na as V1,o as z0,oa as O1,p as M0,pa as z1,q as L0,qa as M1,r as T0,ra as L1,s as D0,sa as T1,t as W0,ta as D1,u as P0,ua as W1,v as A0,va as P1,w as N0,wa as A1,x as I0,xa as N1,y as k0,ya as I1,z as C0,za as k1}from"./chunk-
|
|
2
|
+
import{$ as Q1,$a as Q2,A as x0,Aa as C1,B as H0,Ba as x1,C as v0,Ca as H1,D as w0,Da as v1,E as f0,Ea as w1,F as S0,Fa as f1,G as g0,Ga as S1,H as b0,Ha as g1,I as y0,Ia as b1,J as u0,Ja as y1,K as h0,Ka as u1,L as m0,La as h1,M as c0,Ma as m1,N as d0,Na as c1,O as p0,Oa as d1,P as r0,Pa as p1,Q as n0,Qa as r1,R as o0,Ra as n1,S as l0,Sa as o1,T as a0,Ta as l1,U as i0,Ua as a1,V as s0,Va as i1,W as t0,Wa as s1,X as e0,Xa as t1,Y as n,Ya as e1,Z as Y1,Za as Y2,_ as Z1,_a as Z2,a as $0,aa as X1,ab as X2,b as J0,ba as $1,bb as $2,c as G0,ca as J1,cb as J2,d as R0,da as G1,db as G2,e as q0,ea as R1,eb as R2,f as K0,fa as q1,fb as q2,g as U0,ga as K1,h as _0,ha as U1,i as E0,ia as _1,j as F0,ja as E1,k as j0,ka as F1,l as B0,la as j1,m as V0,ma as B1,n as O0,na as V1,o as z0,oa as O1,p as M0,pa as z1,q as L0,qa as M1,r as T0,ra as L1,s as D0,sa as T1,t as W0,ta as D1,u as P0,ua as W1,v as A0,va as P1,w as N0,wa as A1,x as I0,xa as N1,y as k0,ya as I1,z as C0,za as k1}from"./chunk-r6jrvhhq.js";import{gb as N}from"./chunk-gzgq8v6d.js";function z(Y="stx"){return`${Y}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function F(Y){return Y.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function O(...Y){return Y.filter(Boolean).join(" ")}function V(Y){if(!Y)return"";return Object.entries(Y).map(([Z,Q])=>`${Z.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${Q}`).join("; ")}function OY(Y){let{text:Z,variant:Q="primary",size:X="medium",disabled:$=!1,loading:J=!1,icon:K,iconPosition:R="left",id:G=z("btn"),className:_,style:U}=Y,E=O("stx-button",`stx-button--${Q}`,`stx-button--${X}`,$&&"stx-button--disabled",J&&"stx-button--loading",_),q=V(U),j=K?`<span class="stx-button-icon">${K}</span>`:"",B=J?'<span class="stx-button-spinner"></span>':"",M=R==="left"?`${j}${B}<span class="stx-button-text">${F(Z)}</span>`:`<span class="stx-button-text">${F(Z)}</span>${j}${B}`;return`<button id="${G}" class="${E}" ${$||J?"disabled":""} ${q?`style='${q}'`:""}>${M}</button>`}function zY(Y){let{value:Z="",placeholder:Q="",type:X="text",disabled:$=!1,readonly:J=!1,maxLength:K,minLength:R,pattern:G,required:_=!1,autocomplete:U,label:E,error:q,hint:j,id:B=z("input"),className:M,style:L}=Y,T=O("stx-input",q&&"stx-input--error",$&&"stx-input--disabled",M),w=V(L),VY=[`type="${X}"`,`id="${B}"`,`class="${T}"`,Z&&`value="${F(Z)}"`,Q&&`placeholder="${F(Q)}"`,$&&"disabled",J&&"readonly",_&&"required",K&&`maxlength="${K}"`,R&&`minlength="${R}"`,G&&`pattern="${F(G)}"`,U&&`autocomplete="${U}"`,w&&`style="${w}"`].filter(Boolean).join(" "),x="";if(E)x+=`<label class="stx-input-label" for="${B}">${F(E)}</label>`;if(x+=`<input ${VY} />`,q)x+=`<div class="stx-input-error">${F(q)}</div>`;else if(j)x+=`<div class="stx-input-hint">${F(j)}</div>`;return`<div class="stx-input-wrapper">${x}</div>`}function MY(Y){let{checked:Z=!1,label:Q,disabled:X=!1,indeterminate:$=!1,id:J=z("checkbox"),className:K,style:R}=Y,G=O("stx-checkbox",X&&"stx-checkbox--disabled",K),_=V(R),U=['type="checkbox"',`id="${J}"`,Z&&"checked",X&&"disabled",$&&'data-indeterminate="true"'].filter(Boolean).join(" ");return`
|
|
3
3
|
<label class="${G}" ${_?`style="${_}"`:""}>
|
|
4
4
|
<input ${U} />
|
|
5
5
|
<span class="stx-checkbox-box"></span>
|
package/package.json
CHANGED