@stacksjs/stx 0.2.200 → 0.2.202
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/{chunk-2f80w68h.js → chunk-5d664wp1.js} +1 -1
- package/dist/{chunk-k03b9z9e.js → chunk-5hpp0vzz.js} +54 -54
- package/dist/{chunk-hryeb88f.js → chunk-as6mtt14.js} +1 -1
- package/dist/{chunk-wjqswn35.js → chunk-h5rx09a5.js} +4 -4
- package/dist/{chunk-vx8cht59.js → chunk-m3qtqheb.js} +1 -1
- package/dist/{chunk-eqq7k4g0.js → chunk-njvb5hn8.js} +1 -1
- package/dist/{chunk-pa6gyr8e.js → chunk-q7tx4b74.js} +1 -1
- package/dist/{chunk-b5nws5vh.js → chunk-r65jaef6.js} +1 -1
- package/dist/{chunk-v9yzmqsh.js → chunk-te0r2g0x.js} +1 -1
- package/dist/{chunk-macr4195.js → chunk-xdxhz4h3.js} +1 -1
- package/dist/cli.js +3 -3
- package/package.json +5 -5
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{hu as v}from"./chunk-pw0rzgpv.js";function
|
|
2
|
+
import{hu as v}from"./chunk-pw0rzgpv.js";function D4(){if(typeof Notification<"u"&&Notification.permission==="granted")return!0;return!1}function zZ(){return typeof window<"u"&&typeof document<"u"}async function M4(){if(typeof Notification>"u")return!1;if(Notification.permission==="granted")return!0;if(Notification.permission==="denied")return!1;return await Notification.requestPermission()==="granted"}var y=new Map;function T4(){return`alert-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function _4(Z){switch(Z){case"info":return"ℹ";case"success":return"✔";case"warning":return"⚠";case"error":return"✖";default:return"ℹ"}}function N4(Z="top-right"){if(!zZ())throw Error("Toast container requires browser environment");try{let $=document.querySelector(`.stx-toast-container[data-position="${Z}"]`);if($)return $}catch{}let Y=document.createElement("div");Y.className=`stx-toast-container ${Z}`,Y.dataset.position=Z;try{if(document.body)document.body.appendChild(Y)}catch{}return Y}function E4(Z){let{options:Y}=Z,$=_4(Y.type),J=Y.type||"info",G=Y.duration!==0;return`
|
|
3
3
|
<div class="stx-toast ${J}" data-alert-id="${Z.id}" role="alert" aria-live="polite">
|
|
4
4
|
<div class="stx-toast-icon">${$}</div>
|
|
5
5
|
<div class="stx-toast-content">
|
|
6
|
-
${Y.title?`<div class="stx-toast-title">${
|
|
7
|
-
<div class="stx-toast-message">${
|
|
6
|
+
${Y.title?`<div class="stx-toast-title">${kZ(Y.title)}</div>`:""}
|
|
7
|
+
<div class="stx-toast-message">${kZ(Y.message)}</div>
|
|
8
8
|
</div>
|
|
9
|
-
${
|
|
9
|
+
${G?'<button class="stx-toast-close" aria-label="Close">×</button>':""}
|
|
10
10
|
</div>
|
|
11
|
-
`}function
|
|
11
|
+
`}function kZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function s(Z){if(Z.timeout)clearTimeout(Z.timeout);if(y.delete(Z.id),Z.element&&zZ())Z.element.classList.add("dismissing"),setTimeout(()=>{Z.element?.remove()},200)}async function FZ(Z){let Y=T4(),$=D4(),J=Z.duration??5000,G={id:Y,options:Z};if(y.set(Y,G),$&&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:Y});if(X.onclick=()=>{if(Z.onClick)Z.onClick();X.close()},J>0)G.timeout=setTimeout(()=>{X.close(),y.delete(Y)},J);return}catch{}if(zZ())try{let X=N4(Z.position),O=document.createElement("div");O.innerHTML=E4(G);let z=O.firstElementChild;if(!z){let F=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${F}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`);return}G.element=z;try{X.appendChild(z)}catch{let F=(Z.type||"info").toUpperCase();console.log(`[stx-alert] ${F}: ${Z.title||""}`),console.log(`[stx-alert] ${Z.message}`);return}if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>{try{z.classList.add("visible")}catch{}});try{z.addEventListener("click",(F)=>{if(F.target.classList?.contains("stx-toast-close")){s(G);return}if(Z.onClick)Z.onClick()})}catch{}if(J>0)G.timeout=setTimeout(()=>{s(G)},J)}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}`),J>0)G.timeout=setTimeout(()=>{y.delete(Y)},J)}}async function p(Z){return FZ({...Z,position:Z.position||"top-right"})}async function A4(Z,Y=3000){return p({message:Z,type:"info",duration:Y})}async function k4(Z,Y=3000){return p({message:Z,type:"success",duration:Y})}async function H4(Z,Y=3000){return p({message:Z,type:"warning",duration:Y})}async function x4(Z,Y=5000){return p({message:Z,type:"error",duration:Y})}async function C4(Z,Y,$="info"){return FZ({title:Z,message:Y,type:$})}function I4(Z){let Y=y.get(Z);if(Y)s(Y)}function S4(){for(let Z of y.values())s(Z)}function w4(){return y.size}var B4=`
|
|
12
12
|
.stx-toast-container {
|
|
13
13
|
position: fixed;
|
|
14
14
|
z-index: 10001;
|
|
@@ -110,44 +110,44 @@ import{hu as v}from"./chunk-pw0rzgpv.js";function W4(){if(typeof Notification<"u
|
|
|
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
|
|
114
|
-
<label class="${
|
|
113
|
+
`;function T(Z="stx"){return`${Z}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function q(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(...Z){return Z.filter(Boolean).join(" ")}function W(Z){if(!Z)return"";return Object.entries(Z).map(([Y,$])=>`${Y.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${$}`).join("; ")}function f4(Z){let{text:Y,variant:$="primary",size:J="medium",disabled:G=!1,loading:X=!1,icon:O,iconPosition:z="left",id:F=T("btn"),className:R,style:j}=Z,V=D("stx-button",`stx-button--${$}`,`stx-button--${J}`,G&&"stx-button--disabled",X&&"stx-button--loading",R),K=W(j),U=O?`<span class="stx-button-icon">${O}</span>`:"",L=X?'<span class="stx-button-spinner"></span>':"",_=z==="left"?`${U}${L}<span class="stx-button-text">${q(Y)}</span>`:`<span class="stx-button-text">${q(Y)}</span>${U}${L}`;return`<button id="${F}" class="${V}" ${G||X?"disabled":""} ${K?`style='${K}'`:""}>${_}</button>`}function v4(Z){let{value:Y="",placeholder:$="",type:J="text",disabled:G=!1,readonly:X=!1,maxLength:O,minLength:z,pattern:F,required:R=!1,autocomplete:j,label:V,error:K,hint:U,id:L=T("input"),className:_,style:N}=Z,E=D("stx-input",K&&"stx-input--error",G&&"stx-input--disabled",_),S=W(N),i=[`type="${J}"`,`id="${L}"`,`class="${E}"`,Y&&`value="${q(Y)}"`,$&&`placeholder="${q($)}"`,G&&"disabled",X&&"readonly",R&&"required",O&&`maxlength="${O}"`,z&&`minlength="${z}"`,F&&`pattern="${q(F)}"`,j&&`autocomplete="${j}"`,S&&`style="${S}"`].filter(Boolean).join(" "),w="";if(V)w+=`<label class="stx-input-label" for="${L}">${q(V)}</label>`;if(w+=`<input ${i} />`,K)w+=`<div class="stx-input-error">${q(K)}</div>`;else if(U)w+=`<div class="stx-input-hint">${q(U)}</div>`;return`<div class="stx-input-wrapper">${w}</div>`}function y4(Z){let{checked:Y=!1,label:$,disabled:J=!1,indeterminate:G=!1,id:X=T("checkbox"),className:O,style:z}=Z,F=D("stx-checkbox",J&&"stx-checkbox--disabled",O),R=W(z),j=['type="checkbox"',`id="${X}"`,Y&&"checked",J&&"disabled",G&&'data-indeterminate="true"'].filter(Boolean).join(" ");return`
|
|
114
|
+
<label class="${F}" ${R?`style="${R}"`:""}>
|
|
115
115
|
<input ${j} />
|
|
116
116
|
<span class="stx-checkbox-box"></span>
|
|
117
117
|
${$?`<span class="stx-checkbox-label">${q($)}</span>`:""}
|
|
118
118
|
</label>
|
|
119
|
-
`}function
|
|
119
|
+
`}function g4(Z){let{value:Y=50,min:$=0,max:J=100,step:G=1,disabled:X=!1,label:O,showValue:z=!0,id:F=T("slider"),className:R,style:j}=Z,V=D("stx-slider",X&&"stx-slider--disabled",R),K=W(j),U=['type="range"',`id="${F}"`,`value="${Y}"`,`min="${$}"`,`max="${J}"`,`step="${G}"`,X&&"disabled"].filter(Boolean).join(" "),L="";if(O)L+=`<label class="stx-slider-label" for="${F}">${q(O)}</label>`;if(L+=`<div class="stx-slider-track"><input ${U} /></div>`,z)L+=`<span class="stx-slider-value">${Y}</span>`;return`<div class="${V}" ${K?`style='${K}'`:""}>${L}</div>`}function b4(Z){let{value:Y,max:$=100,variant:J="default",size:G="medium",showLabel:X=!1,indeterminate:O=!1,id:z=T("progress"),className:F,style:R}=Z,j=Math.min(100,Math.max(0,Y/$*100)),V=D("stx-progress",`stx-progress--${J}`,`stx-progress--${G}`,O&&"stx-progress--indeterminate",F),K=W(R);return`
|
|
120
120
|
<div id="${z}" class="${V}" role="progressbar" aria-valuenow="${Y}" aria-valuemin="0" aria-valuemax="${$}" ${K?`style="${K}"`:""}>
|
|
121
|
-
<div class="stx-progress-bar" style="width: ${
|
|
121
|
+
<div class="stx-progress-bar" style="width: ${O?"100%":`${j}%`}"></div>
|
|
122
122
|
${X?`<span class="stx-progress-label">${Math.round(j)}%</span>`:""}
|
|
123
123
|
</div>
|
|
124
|
-
`}function
|
|
124
|
+
`}function u4(Z){let{text:Y,variant:$="default",size:J="medium",id:G=T("badge"),className:X,style:O}=Z,z=D("stx-badge",`stx-badge--${$}`,`stx-badge--${J}`,X),F=W(O);return`<span id="${G}" class="${z}" ${F?`style='${F}'`:""}>${q(Y)}</span>`}function m4(Z){let{src:Y,alt:$="",name:J,size:G="medium",shape:X="circle",id:O=T("avatar"),className:z,style:F}=Z,R=typeof G==="number"?"":`stx-avatar--${G}`,j=typeof G==="number"?`width: ${G}px; height: ${G}px;`:"",V=D("stx-avatar",R,`stx-avatar--${X}`,z),K=[j,W(F)].filter(Boolean).join(" "),U=J?J.split(" ").map((L)=>L[0]).join("").toUpperCase().slice(0,2):"";if(Y)return`<div id="${O}" class="${V}" ${K?`style="${K}"`:""}>
|
|
125
125
|
<img src="${q(Y)}" alt="${q($)}" class="stx-avatar-img" />
|
|
126
|
-
</div>`;return`<div id="${
|
|
126
|
+
</div>`;return`<div id="${O}" class="${V}" ${K?`style="${K}"`:""}>
|
|
127
127
|
<span class="stx-avatar-initials">${U}</span>
|
|
128
|
-
</div>`}function
|
|
129
|
-
<label class="${
|
|
128
|
+
</div>`}function h4(Z){let{title:Y,subtitle:$,content:J,image:G,footer:X,variant:O="default",id:z=T("card"),className:F,style:R}=Z,j=D("stx-card",`stx-card--${O}`,F),V=W(R),K="";if(G)K+=`<div class="stx-card-image"><img src="${q(G)}" alt="" /></div>`;if(K+='<div class="stx-card-body">',Y)K+=`<h3 class="stx-card-title">${q(Y)}</h3>`;if($)K+=`<p class="stx-card-subtitle">${q($)}</p>`;if(J)K+=`<div class="stx-card-content">${q(J)}</div>`;if(K+="</div>",X)K+=`<div class="stx-card-footer">${q(X)}</div>`;return`<div id="${z}" class="${j}" ${V?`style='${V}'`:""}>${K}</div>`}function c4(Z){let{tabs:Y,activeTab:$,variant:J="default",id:G=T("tabs"),className:X,style:O}=Z,z=D("stx-tabs",`stx-tabs--${J}`,X),F=W(O),R=Y.map((j,V)=>{let K=$?j.value===$:V===0;return`<button class="${D("stx-tab",K&&"stx-tab--active",j.disabled&&"stx-tab--disabled")}" data-value="${q(j.value)}" ${j.disabled?"disabled":""} role="tab" aria-selected="${K}">${q(j.label)}</button>`}).join("");return`<div id="${G}" class="${z}" role="tablist" ${F?`style='${F}'`:""}>${R}</div>`}function p4(Z){let{options:Y,value:$,placeholder:J="Select...",disabled:G=!1,id:X=T("dropdown"),className:O,style:z}=Z,F=D("stx-dropdown",G&&"stx-dropdown--disabled",O),R=W(z),j=Y.map((K)=>{let U=K.value===$?"selected":"",L=K.disabled?"disabled":"";return`<option value="${q(K.value)}" ${U} ${L}>${q(K.label)}</option>`}).join(""),V=$?"":`<option value="" disabled selected>${q(J)}</option>`;return`<select id="${X}" class="${F}" ${G?"disabled":""} ${R?`style='${R}'`:""}>${V}${j}</select>`}function l4(Z){let{value:Y=0,max:$=5,readonly:J=!1,size:G="medium",allowHalf:X=!1,id:O=T("rating"),className:z,style:F}=Z,R=D("stx-rating",`stx-rating--${G}`,J&&"stx-rating--readonly",z),j=W(F),V="";for(let K=1;K<=$;K++){let U=K<=Y,L=X&&K-0.5===Y;V+=`<span class="stx-star ${U?"stx-star--filled":L?"stx-star--half":""}" data-value="${K}">\u2605</span>`}return`<div id="${O}" class="${R}" role="slider" aria-valuenow="${Y}" aria-valuemin="0" aria-valuemax="${$}" ${j?`style='${j}'`:""}>${V}</div>`}function d4(Z){let{value:Y,name:$,checked:J=!1,label:G,disabled:X=!1,id:O=T("radio"),className:z,style:F}=Z,R=D("stx-radio",X&&"stx-radio--disabled",z),j=W(F),V=['type="radio"',`id="${O}"`,`name="${q($)}"`,`value="${q(Y)}"`,J&&"checked",X&&"disabled"].filter(Boolean).join(" ");return`
|
|
129
|
+
<label class="${R}" ${j?`style="${j}"`:""}>
|
|
130
130
|
<input ${V} />
|
|
131
131
|
<span class="stx-radio-circle"></span>
|
|
132
|
-
${
|
|
132
|
+
${G?`<span class="stx-radio-label">${q(G)}</span>`:""}
|
|
133
133
|
</label>
|
|
134
|
-
`}function
|
|
134
|
+
`}function r4(Z){let{value:Y="#3498db",disabled:$=!1,label:J,presetColors:G=["#e74c3c","#f39c12","#27ae60","#3498db","#9b59b6","#1abc9c","#34495e","#000000"],id:X=T("color"),className:O,style:z}=Z,F=D("stx-color-picker",$&&"stx-color-picker--disabled",O),R=W(z),j="";if(J)j+=`<label class="stx-color-picker-label" for="${X}">${q(J)}</label>`;if(j+=`<div class="stx-color-picker-input">
|
|
135
135
|
<input type="color" id="${X}" value="${q(Y)}" ${$?"disabled":""} />
|
|
136
136
|
<span class="stx-color-picker-value">${q(Y)}</span>
|
|
137
|
-
</div>`,
|
|
137
|
+
</div>`,G.length>0){j+='<div class="stx-color-picker-presets">';for(let V of G)j+=`<button class="stx-color-preset" style="background: ${q(V)}" data-color="${q(V)}" ${$?"disabled":""}></button>`;j+="</div>"}return`<div class="${F}" ${R?`style='${R}'`:""}>${j}</div>`}function n4(Z){let{value:Y,min:$,max:J,disabled:G=!1,label:X,placeholder:O="Select date",showClear:z=!0,id:F=T("date"),className:R,style:j}=Z,V=D("stx-date-picker",G&&"stx-date-picker--disabled",R),K=W(j),U=Y instanceof Date?Y.toISOString().split("T")[0]:Y||"",L=$ instanceof Date?$.toISOString().split("T")[0]:$,_=J instanceof Date?J.toISOString().split("T")[0]:J,N=['type="date"',`id="${F}"`,U&&`value="${U}"`,L&&`min="${L}"`,_&&`max="${_}"`,G&&"disabled",`placeholder="${q(O)}"`].filter(Boolean).join(" "),E="";if(X)E+=`<label class="stx-date-picker-label" for="${F}">${q(X)}</label>`;return E+=`<div class="stx-date-picker-input">
|
|
138
138
|
<input ${N} />
|
|
139
139
|
${z&&U?'<button class="stx-date-picker-clear" type="button">×</button>':""}
|
|
140
|
-
</div>`,`<div class="${V}" ${K?`style='${K}'`:""}>${E}</div>`}function
|
|
141
|
-
<input type="text" id="${z}" value="${q(U)}" placeholder="${q(J)}" ${
|
|
142
|
-
${
|
|
143
|
-
</div>`,
|
|
144
|
-
${
|
|
140
|
+
</div>`,`<div class="${V}" ${K?`style='${K}'`:""}>${E}</div>`}function o4(Z){let{value:Y="",disabled:$=!1,label:J,step:G=60,min:X,max:O,id:z=T("time"),className:F,style:R}=Z,j=D("stx-time-picker",$&&"stx-time-picker--disabled",F),V=W(R),K=['type="time"',`id="${z}"`,Y&&`value="${q(Y)}"`,`step="${G}"`,X&&`min="${q(X)}"`,O&&`max="${q(O)}"`,$&&"disabled"].filter(Boolean).join(" "),U="";if(J)U+=`<label class="stx-time-picker-label" for="${z}">${q(J)}</label>`;return U+=`<input ${K} class="stx-time-picker-input" />`,`<div class="${j}" ${V?`style='${V}'`:""}>${U}</div>`}function a4(Z){let{options:Y,value:$="",placeholder:J="Search...",disabled:G=!1,label:X,loading:O=!1,id:z=T("autocomplete"),className:F,style:R}=Z,j=D("stx-autocomplete",G&&"stx-autocomplete--disabled",F),V=W(R),K=Y.find((_)=>_.value===$),U=K?K.label:$,L="";if(X)L+=`<label class="stx-autocomplete-label" for="${z}">${q(X)}</label>`;L+=`<div class="stx-autocomplete-input-wrapper">
|
|
141
|
+
<input type="text" id="${z}" value="${q(U)}" placeholder="${q(J)}" ${G?"disabled":""} autocomplete="off" class="stx-autocomplete-input" />
|
|
142
|
+
${O?'<span class="stx-autocomplete-spinner"></span>':""}
|
|
143
|
+
</div>`,L+='<ul class="stx-autocomplete-list">';for(let _ of Y)L+=`<li class="stx-autocomplete-item ${_.value===$?"stx-autocomplete-item--selected":""}" data-value="${q(_.value)}">${q(_.label)}</li>`;return L+="</ul>",`<div class="${j}" ${V?`style='${V}'`:""}>${L}</div>`}function i4(Z){let{text:Y,htmlFor:$,required:J=!1,size:G="medium",id:X=T("label"),className:O,style:z}=Z,F=D("stx-label",`stx-label--${G}`,O),R=W(z);return`<label id="${X}" class="${F}" ${$?`for='${q($)}'`:""} ${R?`style='${R}'`:""}>${q(Y)}${J?'<span class="stx-label-required">*</span>':""}</label>`}function s4(Z){let{src:Y,alt:$="",width:J,height:G,objectFit:X="cover",fallback:O,loading:z="lazy",id:F=T("image"),className:R,style:j}=Z,V=D("stx-image",R),K={objectFit:X};if(J)K.width=typeof J==="number"?`${J}px`:J;if(G)K.height=typeof G==="number"?`${G}px`:G;let U=[W(K),W(j)].filter(Boolean).join("; "),L=O?`onerror="this.src='${q(O)}'"`:"";return`<img id="${F}" class="${V}" src="${q(Y)}" alt="${q($)}" loading="${z}" ${U?`style='${U}'`:""} ${L} />`}function t4(Z){let{text:Y,variant:$="default",size:J="medium",removable:G=!1,icon:X,id:O=T("chip"),className:z,style:F}=Z,R=D("stx-chip",`stx-chip--${$}`,`stx-chip--${J}`,z),j=W(F),V="";if(X)V+=`<span class="stx-chip-icon">${X}</span>`;if(V+=`<span class="stx-chip-text">${q(Y)}</span>`,G)V+='<button class="stx-chip-remove" type="button">×</button>';return`<span id="${O}" class="${R}" ${j?`style='${j}'`:""}>${V}</span>`}function e4(Z){let{text:Y,position:$="top",delay:J=200,children:G,id:X=T("tooltip"),className:O,style:z}=Z,F=D("stx-tooltip-wrapper",O),R=W(z);return`<div id="${X}" class="${F}" ${R?`style="${R}"`:""} data-tooltip="${q(Y)}" data-position="${$}" data-delay="${J}">
|
|
144
|
+
${G}
|
|
145
145
|
<span class="stx-tooltip stx-tooltip--${$}">${q(Y)}</span>
|
|
146
|
-
</div>`}function
|
|
147
|
-
<div class="stx-split-pane" style="${j}: ${$[0]}%">${
|
|
146
|
+
</div>`}function ZY(Z){let{direction:Y="vertical",showScrollbar:$=!0,smooth:J=!0,height:G,width:X,children:O,id:z=T("scroll"),className:F,style:R}=Z,j=D("stx-scroll-view",`stx-scroll-view--${Y}`,!$&&"stx-scroll-view--hide-scrollbar",J&&"stx-scroll-view--smooth",F),V={};if(G)V.height=typeof G==="number"?`${G}px`:G;if(X)V.width=typeof X==="number"?`${X}px`:X;let K=[W(V),W(R)].filter(Boolean).join("; ");return`<div id="${z}" class="${j}" ${K?`style='${K}'`:""}>${O}</div>`}function YY(Z){let{direction:Y="horizontal",sizes:$=[50,50],resizable:J=!0,children:G,id:X=T("split"),className:O,style:z}=Z,F=D("stx-split-view",`stx-split-view--${Y}`,J&&"stx-split-view--resizable",O),R=W(z),j=Y==="horizontal"?"width":"height";return`<div id="${X}" class="${F}" ${R?`style="${R}"`:""}>
|
|
147
|
+
<div class="stx-split-pane" style="${j}: ${$[0]}%">${G[0]}</div>
|
|
148
148
|
${J?'<div class="stx-split-divider"></div>':""}
|
|
149
|
-
<div class="stx-split-pane" style="${j}: ${$[1]}%">${
|
|
150
|
-
</div>`}function
|
|
149
|
+
<div class="stx-split-pane" style="${j}: ${$[1]}%">${G[1]}</div>
|
|
150
|
+
</div>`}function $Y(Z){let{items:Y,multiple:$=!1,defaultOpen:J=[],id:G=T("accordion"),className:X,style:O}=Z,z=D("stx-accordion",X),F=W(O),R="";return Y.forEach((j,V)=>{let K=J.includes(V),U=D("stx-accordion-item",K&&"stx-accordion-item--open",j.disabled&&"stx-accordion-item--disabled");R+=`<div class="${U}" data-index="${V}">
|
|
151
151
|
<button class="stx-accordion-header" ${j.disabled?"disabled":""} aria-expanded="${K}" data-multiple="${$}">
|
|
152
152
|
<span class="stx-accordion-title">${q(j.title)}</span>
|
|
153
153
|
<span class="stx-accordion-icon">\u25BC</span>
|
|
@@ -155,7 +155,7 @@ import{hu as v}from"./chunk-pw0rzgpv.js";function W4(){if(typeof Notification<"u
|
|
|
155
155
|
<div class="stx-accordion-content" ${K?"":"hidden"}>
|
|
156
156
|
${q(j.content)}
|
|
157
157
|
</div>
|
|
158
|
-
</div>`}),`<div id="${
|
|
158
|
+
</div>`}),`<div id="${G}" class="${z}" ${F?`style='${F}'`:""}>${R}</div>`}function JY(Z){let{steps:Y,currentStep:$,orientation:J="horizontal",id:G=T("stepper"),className:X,style:O}=Z,z=D("stx-stepper",`stx-stepper--${J}`,X),F=W(O),R="";return Y.forEach((j,V)=>{let K=D("stx-step",V<$&&"stx-step--completed",V===$&&"stx-step--active");if(R+=`<div class="${K}" data-step="${V}">
|
|
159
159
|
<div class="stx-step-indicator">
|
|
160
160
|
${V<$?"\u2713":V+1}
|
|
161
161
|
</div>
|
|
@@ -163,35 +163,35 @@ import{hu as v}from"./chunk-pw0rzgpv.js";function W4(){if(typeof Notification<"u
|
|
|
163
163
|
<div class="stx-step-label">${q(j.label)}</div>
|
|
164
164
|
${j.description?`<div class="stx-step-description">${q(j.description)}</div>`:""}
|
|
165
165
|
</div>
|
|
166
|
-
</div>`,V<Y.length-1)
|
|
167
|
-
<div class="stx-list-view-empty">${q(
|
|
168
|
-
</div>`;let j='<ul class="stx-list-view-items">';for(let V of Y){let K=
|
|
166
|
+
</div>`,V<Y.length-1)R+='<div class="stx-step-connector"></div>'}),`<div id="${G}" class="${z}" ${F?`style='${F}'`:""}>${R}</div>`}function QY(Z){let{open:Y=!1,title:$,size:J="medium",closable:G=!0,children:X,footer:O,id:z=T("modal"),className:F,style:R}=Z,j=D("stx-modal-component",`stx-modal-component--${J}`,F),V=W(R);if(!Y)return`<div id="${z}" class="${j} stx-modal-component--hidden" ${V?`style='${V}'`:""}></div>`;let K='<div class="stx-modal-component-overlay">';if(K+='<div class="stx-modal-component-dialog">',$||G){if(K+='<div class="stx-modal-component-header">',$)K+=`<h3 class="stx-modal-component-title">${q($)}</h3>`;if(G)K+='<button class="stx-modal-component-close">×</button>';K+="</div>"}if(K+=`<div class="stx-modal-component-body">${X}</div>`,O)K+=`<div class="stx-modal-component-footer">${O}</div>`;return K+="</div></div>",`<div id="${z}" class="${j}" ${V?`style='${V}'`:""}>${K}</div>`}function GY(Z){let{items:Y,selectable:$=!1,multiSelect:J=!1,emptyMessage:G="No items",id:X=T("list"),className:O,style:z}=Z,F=D("stx-list-view",$&&"stx-list-view--selectable",J&&"stx-list-view--multi",O),R=W(z);if(Y.length===0)return`<div id="${X}" class="${F}" ${R?`style="${R}"`:""}>
|
|
167
|
+
<div class="stx-list-view-empty">${q(G)}</div>
|
|
168
|
+
</div>`;let j='<ul class="stx-list-view-items">';for(let V of Y){let K=D("stx-list-view-item",V.selected&&"stx-list-view-item--selected");j+=`<li class="${K}" data-id="${q(V.id)}" ${$?'tabindex="0"':""}>${V.content}</li>`}return j+="</ul>",`<div id="${X}" class="${F}" ${R?`style='${R}'`:""}>${j}</div>`}function XY(Z){let{columns:Y,data:$,striped:J=!1,bordered:G=!1,hoverable:X=!0,sortBy:O,sortOrder:z,id:F=T("table"),className:R,style:j}=Z,V=D("stx-table",J&&"stx-table--striped",G&&"stx-table--bordered",X&&"stx-table--hoverable",R),K=W(j),U="<table>";U+="<thead><tr>";for(let L of Y){let N=L.key===O?`stx-table-sorted stx-table-sorted--${z}`:"",E=L.sortable?'data-sortable="true"':"",S=L.width?`style="width: ${L.width}"`:"";U+=`<th class="${N}" ${E} ${S} data-key="${q(L.key)}">${q(L.label)}${L.sortable?'<span class="stx-table-sort-icon"></span>':""}</th>`}U+="</tr></thead>",U+="<tbody>";for(let L of $){U+="<tr>";for(let _ of Y){let N=L[_.key];U+=`<td>${N!=null?q(String(N)):""}</td>`}U+="</tr>"}return U+="</tbody></table>",`<div id="${F}" class="${V}" ${K?`style='${K}'`:""}>${U}</div>`}function HZ(Z,Y,$,J){let G=Y.includes(Z.key),X=$.includes(Z.key),O=Z.children&&Z.children.length>0,F=`<div class="${D("stx-tree-node",X&&"stx-tree-node--selected",Z.disabled&&"stx-tree-node--disabled")}" data-key="${q(Z.key)}">`;if(F+='<div class="stx-tree-node-content">',O)F+=`<span class="stx-tree-toggle ${G?"stx-tree-toggle--expanded":""}">\u25B6</span>`;else F+='<span class="stx-tree-toggle-placeholder"></span>';if(J)F+=`<input type="checkbox" class="stx-tree-checkbox" ${X?"checked":""} ${Z.disabled?"disabled":""} />`;if(Z.icon)F+=`<span class="stx-tree-icon">${Z.icon}</span>`;if(F+=`<span class="stx-tree-label">${q(Z.label)}</span>`,F+="</div>",O&&G){F+='<div class="stx-tree-children">';for(let R of Z.children)F+=HZ(R,Y,$,J);F+="</div>"}return F+="</div>",F}function zY(Z){let{nodes:Y,expandedKeys:$=[],selectedKeys:J=[],checkable:G=!1,id:X=T("tree"),className:O,style:z}=Z,F=D("stx-tree-view",G&&"stx-tree-view--checkable",O),R=W(z),j="";for(let V of Y)j+=HZ(V,$,J,G);return`<div id="${X}" class="${F}" role="tree" ${R?`style='${R}'`:""}>${j}</div>`}function FY(Z){let{columns:Y,data:$,pagination:J,selectable:G=!1,id:X=T("datagrid"),className:O,style:z}=Z,F=D("stx-data-grid",G&&"stx-data-grid--selectable",O),R=W(z),j='<div class="stx-data-grid-table-wrapper">';if(j+='<table class="stx-data-grid-table">',j+="<thead><tr>",G)j+='<th class="stx-data-grid-select-all"><input type="checkbox" /></th>';for(let V of Y){let K=V.width?`style="width: ${V.width}"`:"";j+=`<th ${K}>
|
|
169
169
|
<div class="stx-data-grid-header-cell">
|
|
170
170
|
<span>${q(V.label)}</span>
|
|
171
171
|
${V.sortable?'<button class="stx-data-grid-sort">\u21C5</button>':""}
|
|
172
172
|
${V.filterable?'<button class="stx-data-grid-filter">\u22BB</button>':""}
|
|
173
173
|
</div>
|
|
174
|
-
</th>`}j+="</tr></thead>",j+="<tbody>";for(let V of $){if(j+="<tr>",
|
|
174
|
+
</th>`}j+="</tr></thead>",j+="<tbody>";for(let V of $){if(j+="<tr>",G)j+='<td class="stx-data-grid-select"><input type="checkbox" /></td>';for(let K of Y){let U=V[K.key];j+=`<td>${U!=null?q(String(U)):""}</td>`}j+="</tr>"}if(j+="</tbody></table></div>",J){let V=Math.ceil(J.total/J.pageSize);j+=`<div class="stx-data-grid-pagination">
|
|
175
175
|
<span class="stx-data-grid-page-info">Page ${J.page} of ${V} (${J.total} items)</span>
|
|
176
176
|
<div class="stx-data-grid-page-buttons">
|
|
177
177
|
<button class="stx-data-grid-page-btn" ${J.page<=1?"disabled":""}>\u25C0</button>
|
|
178
178
|
<button class="stx-data-grid-page-btn" ${J.page>=V?"disabled":""}>\u25B6</button>
|
|
179
179
|
</div>
|
|
180
|
-
</div>`}return`<div id="${X}" class="${
|
|
180
|
+
</div>`}return`<div id="${X}" class="${F}" ${R?`style='${R}'`:""}>${j}</div>`}function OY(Z){let{type:Y,data:$,options:J={},width:G="100%",height:X=300,id:O=T("chart"),className:z,style:F}=Z,R=D("stx-chart",`stx-chart--${Y}`,z),j={width:typeof G==="number"?`${G}px`:G,height:typeof X==="number"?`${X}px`:X},V=[W(j),W(F)].filter(Boolean).join("; "),K=JSON.stringify({type:Y,data:$,options:J});return`<div id="${O}" class="${R}" style="${V}" data-chart='${q(K)}'>
|
|
181
181
|
<div class="stx-chart-placeholder">
|
|
182
182
|
${J.title?`<div class="stx-chart-title">${q(J.title)}</div>`:""}
|
|
183
183
|
<div class="stx-chart-type">${Y.charAt(0).toUpperCase()+Y.slice(1)} Chart</div>
|
|
184
184
|
<div class="stx-chart-info">${$.datasets.length} dataset(s), ${$.labels.length} labels</div>
|
|
185
185
|
</div>
|
|
186
|
-
</div>`}function RY(Z){let{value:Y="",language:$="plaintext",theme:J="dark",lineNumbers:
|
|
187
|
-
`),N="";if(
|
|
186
|
+
</div>`}function RY(Z){let{value:Y="",language:$="plaintext",theme:J="dark",lineNumbers:G=!0,readOnly:X=!1,height:O=300,tabSize:z=2,wordWrap:F=!1,id:R=T("code"),className:j,style:V}=Z,K=D("stx-code-editor",`stx-code-editor--${J}`,G&&"stx-code-editor--line-numbers",X&&"stx-code-editor--readonly",F&&"stx-code-editor--wrap",j),U={height:typeof O==="number"?`${O}px`:O},L=[W(U),W(V)].filter(Boolean).join("; "),_=Y.split(`
|
|
187
|
+
`),N="";if(G){N+='<div class="stx-code-editor-gutter">';for(let E=1;E<=_.length;E++)N+=`<div class="stx-code-editor-line-number">${E}</div>`;N+="</div>"}return N+=`<pre class="stx-code-editor-content"><code class="language-${q($)}">${q(Y)}</code></pre>`,`<div id="${R}" class="${K}" style="${L}" data-language="${q($)}" data-tab-size="${z}">${N}</div>`}function KY(Z){let{src:Y,type:$="video",poster:J,autoplay:G=!1,loop:X=!1,muted:O=!1,controls:z=!0,width:F,height:R,id:j=T("media"),className:V,style:K}=Z,U=D("stx-media-player",`stx-media-player--${$}`,V),L={};if(F)L.width=typeof F==="number"?`${F}px`:F;if(R)L.height=typeof R==="number"?`${R}px`:R;let _=[W(L),W(K)].filter(Boolean).join("; "),N=[`id="${j}-media"`,`src="${q(Y)}"`,z&&"controls",G&&"autoplay",X&&"loop",O&&"muted",$==="video"&&J&&`poster="${q(J)}"`].filter(Boolean).join(" "),E=$==="video"?`<video ${N}>Your browser does not support the video tag.</video>`:`<audio ${N}>Your browser does not support the audio tag.</audio>`;return`<div id="${j}" class="${U}" ${_?`style='${_}'`:""}>${E}</div>`}function jY(Z){if(Z===void 0)return"";let Y=["B","KB","MB","GB"],$=Z,J=0;while($>=1024&&J<Y.length-1)$/=1024,J++;return`${$.toFixed(1)} ${Y[J]}`}function VY(Z){let{files:Y,viewMode:$="list",showHidden:J=!1,selectable:G=!0,id:X=T("files"),className:O,style:z}=Z,F=D("stx-file-explorer",`stx-file-explorer--${$}`,O),R=W(z),j=J?Y:Y.filter((K)=>!K.name.startsWith(".")),V="";if($==="list"){V='<table class="stx-file-explorer-list"><thead><tr><th>Name</th><th>Size</th><th>Modified</th></tr></thead><tbody>';for(let K of j){let U=K.icon||(K.type==="folder"?"\uD83D\uDCC1":"\uD83D\uDCC4"),L=K.type==="file"?jY(K.size):"",_=K.modified?K.modified.toLocaleDateString():"";V+=`<tr class="stx-file-explorer-item ${G?"stx-file-explorer-item--selectable":""}" data-path="${q(K.path)}" data-type="${K.type}">
|
|
188
188
|
<td><span class="stx-file-explorer-icon">${U}</span>${q(K.name)}</td>
|
|
189
|
-
<td>${
|
|
190
|
-
<td>${
|
|
191
|
-
</tr>`}V+="</tbody></table>"}else{V='<div class="stx-file-explorer-grid">';for(let K of j){let U=K.icon||(K.type==="folder"?"\uD83D\uDCC1":"\uD83D\uDCC4");V+=`<div class="stx-file-explorer-item ${
|
|
189
|
+
<td>${L}</td>
|
|
190
|
+
<td>${_}</td>
|
|
191
|
+
</tr>`}V+="</tbody></table>"}else{V='<div class="stx-file-explorer-grid">';for(let K of j){let U=K.icon||(K.type==="folder"?"\uD83D\uDCC1":"\uD83D\uDCC4");V+=`<div class="stx-file-explorer-item ${G?"stx-file-explorer-item--selectable":""}" data-path="${q(K.path)}" data-type="${K.type}">
|
|
192
192
|
<div class="stx-file-explorer-icon">${U}</div>
|
|
193
193
|
<div class="stx-file-explorer-name">${q(K.name)}</div>
|
|
194
|
-
</div>`}V+="</div>"}return`<div id="${X}" class="${
|
|
194
|
+
</div>`}V+="</div>"}return`<div id="${X}" class="${F}" ${R?`style='${R}'`:""}>${V}</div>`}function qY(Z){let{url:Y,width:$="100%",height:J=400,sandbox:G=!0,allowScripts:X=!0,id:O=T("webview"),className:z,style:F}=Z,R=D("stx-webview",z),j={width:typeof $==="number"?`${$}px`:$,height:typeof J==="number"?`${J}px`:J},V=[W(j),W(F)].filter(Boolean).join("; "),K=[];if(G){if(K.push("allow-same-origin"),X)K.push("allow-scripts")}let U=G?`sandbox="${K.join(" ")}"`:"";return`<iframe id="${O}" class="${R}" src="${q(Y)}" style="${V}" ${U} loading="lazy" frameborder="0"></iframe>`}var PY=["Button","TextInput","Checkbox","RadioButton","Slider","ColorPicker","DatePicker","TimePicker","Autocomplete","Label","ImageView","ProgressBar","Avatar","Badge","Chip","Card","Tooltip","Toast","ScrollView","SplitView","Accordion","Stepper","Modal","Tabs","Dropdown","ListView","Table","TreeView","DataGrid","Chart","Rating","CodeEditor","MediaPlayer","FileExplorer","WebView"],UY=`
|
|
195
195
|
/* Button */
|
|
196
196
|
.stx-button {
|
|
197
197
|
display: inline-flex;
|
|
@@ -548,18 +548,18 @@ import{hu as v}from"./chunk-pw0rzgpv.js";function W4(){if(typeof Notification<"u
|
|
|
548
548
|
.stx-chip--warning { background: #3a2a1a; }
|
|
549
549
|
.stx-chip--error { background: #3a1a1a; }
|
|
550
550
|
}
|
|
551
|
-
`;function
|
|
551
|
+
`;function LY(){return!1}function OZ(){return typeof window<"u"&&typeof document<"u"}var g=[];function WY(){return`modal-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function DY(Z){switch(Z){case"info":return"ℹ";case"warning":return"⚠";case"error":return"✖";case"success":return"✔";case"question":return"❓";default:return"ℹ"}}function t(Z){if(Z==="question")return[{label:"No",style:"default"},{label:"Yes",style:"primary"}];return[{label:"OK",style:"primary"}]}function MY(Z){let{options:Y}=Z,$=DY(Y.type),J=Y.buttons||t(Y.type),G=Y.type||"info",X="";return J.forEach((O,z)=>{let F=O.style==="destructive"?"destructive":O.style==="primary"?"primary":"default",R=z===(Y.defaultButton??J.length-1)?"autofocus":"";X+=`<button class="stx-modal-btn ${F}" data-index="${z}" ${R}>${O.label}</button>`}),`
|
|
552
552
|
<div class="stx-modal-overlay" data-modal-id="${Z.id}">
|
|
553
|
-
<div class="stx-modal ${
|
|
553
|
+
<div class="stx-modal ${G}" role="dialog" aria-modal="true" aria-labelledby="${Z.id}-title">
|
|
554
554
|
<div class="stx-modal-icon">${$}</div>
|
|
555
555
|
<div class="stx-modal-content">
|
|
556
|
-
${Y.title?`<h2 id="${Z.id}-title" class="stx-modal-title">${
|
|
557
|
-
<p class="stx-modal-message">${
|
|
556
|
+
${Y.title?`<h2 id="${Z.id}-title" class="stx-modal-title">${xZ(Y.title)}</h2>`:""}
|
|
557
|
+
<p class="stx-modal-message">${xZ(Y.message)}</p>
|
|
558
558
|
</div>
|
|
559
559
|
<div class="stx-modal-buttons">${X}</div>
|
|
560
560
|
</div>
|
|
561
561
|
</div>
|
|
562
|
-
`}function
|
|
562
|
+
`}function xZ(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function C(Z,Y,$=!1){let J=g.indexOf(Z);if(J>-1)g.splice(J,1);if(Z.element&&OZ())Z.element.remove();let X=(Z.options.buttons||t(Z.options.type))[Y];if(X?.action)X.action();Z.resolve({buttonIndex:Y,cancelled:$})}async function u(Z){let Y=LY(),$=WY();return new Promise((J)=>{let G={id:$,options:Z,resolve:J};if(g.push(G),Y)console.log(`[stx-modal] Showing native modal: ${Z.title||"Modal"}`),setTimeout(()=>{C(G,Z.defaultButton??0,!1)},0);else if(OZ())try{let X=document.createElement("div");X.innerHTML=MY(G);let O=X.firstElementChild;if(!O){console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`),setTimeout(()=>{C(G,Z.defaultButton??0,!1)},0);return}G.element=O;try{document.body.appendChild(O)}catch{console.log(`[stx-modal] ${Z.type?.toUpperCase()||"INFO"}: ${Z.title||"Modal"}`),console.log(`[stx-modal] ${Z.message}`),setTimeout(()=>{C(G,Z.defaultButton??0,!1)},0);return}try{O.querySelectorAll(".stx-modal-btn").forEach((z)=>{z.addEventListener("click",()=>{let F=Number.parseInt(z.dataset.index||"0",10);C(G,F,!1)})})}catch{}try{O.addEventListener("click",(z)=>{if(z.target===O){let F=Z.cancelButton??0;C(G,F,!0)}})}catch{}try{let z=(F)=>{if(F.key==="Escape"){let R=Z.cancelButton??0;C(G,R,!0),document.removeEventListener("keydown",z)}else if(F.key==="Enter"){let R=Z.defaultButton??(Z.buttons||t(Z.type)).length-1;C(G,R,!1),document.removeEventListener("keydown",z)}};document.addEventListener("keydown",z)}catch{}try{let z=O.querySelector(".stx-modal-btn[autofocus]");if(z)z.focus()}catch{}if(typeof process<"u"&&process.env.BUN_TEST)setTimeout(()=>{C(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(()=>{C(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||t(Z.type);console.log(`[stx-modal] Buttons: ${X.map((O)=>O.label).join(", ")}`),setTimeout(()=>{C(G,Z.defaultButton??0,!1)},0)}})}async function CZ(Z,Y){return u({title:Z,message:Y,type:"info"})}async function TY(Z,Y){return u({title:Z,message:Y,type:"warning"})}async function _Y(Z,Y){return u({title:Z,message:Y,type:"error"})}async function NY(Z,Y){return u({title:Z,message:Y,type:"success"})}async function IZ(Z,Y){return u({title:Z,message:Y,type:"question",buttons:[{label:"No",style:"default"},{label:"Yes",style:"primary"}],defaultButton:1,cancelButton:0})}async function EY(Z,Y="Confirm"){return(await IZ(Y,Z)).buttonIndex===1}async function AY(Z,Y="Alert"){await CZ(Y,Z)}async function kY(Z,Y="",$="Input"){if(OZ()&&typeof window.prompt==="function")return window.prompt(Z,Y);return console.log(`[stx-modal] PROMPT: ${$}`),console.log(`[stx-modal] ${Z}`),console.log(`[stx-modal] Default: ${Y}`),Y}function HY(){return g.length}function xY(){while(g.length>0){let Z=g[g.length-1];C(Z,0,!0)}}var CY=`
|
|
563
563
|
.stx-modal-overlay {
|
|
564
564
|
position: fixed;
|
|
565
565
|
inset: 0;
|
|
@@ -691,7 +691,7 @@ import{hu as v}from"./chunk-pw0rzgpv.js";function W4(){if(typeof Notification<"u
|
|
|
691
691
|
background: #555;
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
-
`;import
|
|
694
|
+
`;import SZ from"process";function IY(){if(SZ.platform)return SZ.platform;return"unknown"}function BZ(){if(typeof window<"u"&&window.craft?.tray)return!0;return!1}function fZ(Z,Y){if(Z.type==="separator")return{id:`sep-${Y}`,label:"",type:"separator"};let $={id:`item-${Y}-${Z.label.replace(/\s+/g,"-").toLowerCase()}`,label:Z.label,type:Z.type||"normal",enabled:Z.enabled!==!1};if(Z.accelerator)$.shortcut=Z.accelerator;if(Z.type==="checkbox")$.checked=Z.checked||!1;if(Z.type==="submenu"&&Z.submenu)$.submenu=Z.submenu.map((J,G)=>fZ(J,G));return $}function RZ(Z){return Z.map((Y,$)=>fZ(Y,$))}function vZ(Z,Y=0){if(Z.type==="separator")return'<hr class="stx-tray-separator" />';let $=" ".repeat(Y),J=Z.enabled===!1?"disabled":"",G=Z.checked?"\u2713 ":"",X=Z.accelerator?`<span class="accelerator">${Z.accelerator}</span>`:"",O=`${$}<div class="stx-tray-item ${J}" data-action="${Z.label}">`;if(O+=`<span class="label">${G}${Z.label}</span>${X}`,Z.type==="submenu"&&Z.submenu){O+='<span class="arrow">\u25B8</span>',O+='<div class="stx-tray-submenu">';for(let z of Z.submenu)O+=vZ(z,Y+1);O+="</div>"}return O+="</div>",O}function SY(Z){let Y='<div class="stx-tray-menu">';for(let $ of Z)Y+=vZ($);return Y+="</div>",Y}var f=new Map;function wY(){return`tray-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var wZ=!1;function BY(){if(wZ||typeof window>"u")return;window.addEventListener("craft:tray:menu",(Z)=>{let{action:Y}=Z.detail;for(let $ of f.values()){let J=$.handlers.get(Y);if(J){J();break}}}),wZ=!0}async function yZ(Z={}){let Y=wY(),$=IY(),J=BZ(),G={icon:Z.icon||"",tooltip:Z.tooltip||"stx Application",menu:Z.menu||[],visible:!0},X=new Map;for(let z of Z.menu||[]){if(z.type!=="separator"&&z.onClick)X.set(z.label,z.onClick);if(z.type==="submenu"&&z.submenu){for(let F of z.submenu)if(F.type!=="separator"&&F.onClick)X.set(F.label,F.onClick)}}if(f.set(Y,{state:G,handlers:X}),J){BY();let z=window;try{if(G.tooltip)await z.craft.tray.setTitle({title:G.tooltip}),await z.craft.tray.setTooltip({tooltip:G.tooltip});if(G.icon)await z.craft.tray.setIcon({icon:G.icon});let F=RZ(G.menu);await z.craft.tray.setMenu({items:F}),console.log(`[stx-tray] Native tray created for ${$}`)}catch(F){console.warn("[stx-tray] Failed to create native tray:",F)}}else console.log("[stx-tray] Created simulated tray (not in Craft window)"),console.log(`[stx-tray] ID: ${Y}`),console.log(`[stx-tray] Tooltip: ${G.tooltip}`),console.log(`[stx-tray] Menu items: ${G.menu.length}`);return{id:Y,setIcon:(z)=>{if(G.icon=z,J)window.craft.tray.setIcon({icon:z}).catch((R)=>{console.warn("[stx-tray] Failed to set icon:",R)});console.log(`[stx-tray:${Y}] Icon updated`)},setTooltip:(z)=>{if(G.tooltip=z,J)window.craft.tray.setTooltip({tooltip:z}).catch((R)=>{console.warn("[stx-tray] Failed to set tooltip:",R)});console.log(`[stx-tray:${Y}] Tooltip: ${z}`)},setMenu:(z)=>{G.menu=z,X.clear();for(let F of z){if(F.type!=="separator"&&F.onClick)X.set(F.label,F.onClick);if(F.type==="submenu"&&F.submenu){for(let R of F.submenu)if(R.type!=="separator"&&R.onClick)X.set(R.label,R.onClick)}}if(J){let F=window,R=RZ(z);F.craft.tray.setMenu({items:R}).catch((j)=>{console.warn("[stx-tray] Failed to set menu:",j)})}console.log(`[stx-tray:${Y}] Menu updated (${z.length} items)`)},destroy:()=>{if(G.visible=!1,f.delete(Y),J)window.craft.tray.destroy?.().catch((F)=>{console.warn("[stx-tray] Failed to destroy tray:",F)});console.log(`[stx-tray:${Y}] Destroyed`)}}}var fY=yZ;function vY(){return Array.from(f.keys())}function yY(Z){let Y=f.get(Z);if(!Y)return null;let $=BZ();return{id:Z,setIcon:(J)=>{if(Y.state.icon=J,$)window.craft.tray.setIcon({icon:J}).catch(()=>{})},setTooltip:(J)=>{if(Y.state.tooltip=J,$)window.craft.tray.setTooltip({tooltip:J}).catch(()=>{})},setMenu:(J)=>{if(Y.state.menu=J,$){let G=window,X=RZ(J);G.craft.tray.setMenu({items:X}).catch(()=>{})}},destroy:()=>{if(f.delete(Z),$)window.craft.tray.destroy?.().catch(()=>{})}}}function gY(Z,Y){let $=f.get(Z);if(!$)return!1;let J=$.handlers.get(Y);if(J)return J(),!0;return!1}function bY(Z){let Y=f.get(Z);if(!Y)return null;return SY(Y.state.menu)}function uY(){return`
|
|
695
695
|
// STX Desktop Tray Bridge
|
|
696
696
|
// Provides convenient wrappers around window.craft.tray APIs
|
|
697
697
|
window.stxTray = {
|
|
@@ -704,7 +704,7 @@ window.stxTray = {
|
|
|
704
704
|
// Check if tray is available
|
|
705
705
|
isAvailable: () => typeof window.craft?.tray !== 'undefined',
|
|
706
706
|
};
|
|
707
|
-
`}var
|
|
707
|
+
`}var mY=`
|
|
708
708
|
.stx-tray-menu {
|
|
709
709
|
background: #2d2d2d;
|
|
710
710
|
border-radius: 8px;
|
|
@@ -770,9 +770,9 @@ window.stxTray = {
|
|
|
770
770
|
.stx-tray-item:hover > .stx-tray-submenu {
|
|
771
771
|
display: block;
|
|
772
772
|
}
|
|
773
|
-
`;function e(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function
|
|
773
|
+
`;function e(){if(typeof window<"u"&&window.craft?.dialog)return!0;return!1}async function hY(Z={}){if(e()){let Y=window;try{return await Y.craft.dialog.showOpenDialog(Z)}catch($){console.warn("[stx-dialog] Failed to show native open dialog:",$)}}return new Promise((Y)=>{if(typeof document>"u"){Y({canceled:!0,filePaths:[]});return}let $=document.createElement("input");if($.type="file",$.multiple=Z.multiSelections??!1,Z.filters?.length){let J=Z.filters.flatMap((G)=>G.extensions.map((X)=>`.${X}`));$.accept=J.join(",")}if(Z.canChooseDirectories&&!Z.canChooseFiles)$.webkitdirectory=!0;$.onchange=()=>{let J=Array.from($.files||[]);if(J.length===0)Y({canceled:!0,filePaths:[]});else{let G=J.map((X)=>X.name);Y({canceled:!1,filePaths:G})}},$.oncancel=()=>{Y({canceled:!0,filePaths:[]})},$.click()})}async function cY(Z={}){if(e()){let $=window;try{return await $.craft.dialog.showSaveDialog(Z)}catch(J){console.warn("[stx-dialog] Failed to show native save dialog:",J)}}if(typeof window<"u"&&"showSaveFilePicker"in window)try{let $=Z.filters?.map((G)=>({description:G.name,accept:{"*/*":G.extensions.map((X)=>`.${X}`)}}));return{canceled:!1,filePath:(await window.showSaveFilePicker({suggestedName:Z.defaultPath,types:$})).name}}catch($){return{canceled:!0}}console.warn("[stx-dialog] Save dialog not available, using prompt fallback");let Y=prompt("Enter filename:",Z.defaultPath||"file.txt");if(Y)return{canceled:!1,filePath:Y};return{canceled:!0}}async function l(Z){if(e()){let J=window;try{return await J.craft.dialog.showMessageBox(Z)}catch(G){console.warn("[stx-dialog] Failed to show native message box:",G)}}let Y=Z.buttons||["OK"];if(Y.length===1)return alert(Z.message),{response:0};if(Y.length===2&&Z.type==="question")return{response:confirm(Z.message)?1:0};return console.warn("[stx-dialog] Complex message box not fully supported in browser, using confirm"),{response:confirm(`${Z.message}
|
|
774
774
|
|
|
775
|
-
${Y.join(" / ")}`)?Y.length-1:0}}async function
|
|
775
|
+
${Y.join(" / ")}`)?Y.length-1:0}}async function pY(Z={}){if(e()){let Y=window;try{return await Y.craft.dialog.showColorPicker(Z)}catch($){console.warn("[stx-dialog] Failed to show native color picker:",$)}}return new Promise((Y)=>{if(typeof document>"u"){Y({canceled:!0});return}let $=document.createElement("input");$.type="color",$.value=Z.color||"#000000",$.onchange=()=>{Y({canceled:!1,color:$.value})},$.oncancel=()=>{Y({canceled:!0})},$.click()})}async function lY(Z,Y){await l({type:"info",title:Y||"Alert",message:Z,buttons:["OK"]})}async function dY(Z,Y){return(await l({type:"question",title:Y||"Confirm",message:Z,buttons:["Cancel","OK"],defaultButton:1,cancelButton:0})).response===1}async function rY(Z,Y){await l({type:"error",title:Y||"Error",message:Z,buttons:["OK"]})}async function nY(Z,Y){await l({type:"warning",title:Y||"Warning",message:Z,buttons:["OK"]})}function oY(){return`
|
|
776
776
|
// STX Desktop Dialog Bridge
|
|
777
777
|
// Provides convenient wrappers around window.craft.dialog APIs
|
|
778
778
|
window.stxDialog = {
|
|
@@ -821,7 +821,7 @@ window.stxDialog = {
|
|
|
821
821
|
// Check if dialog is available
|
|
822
822
|
isAvailable: () => typeof window.craft?.dialog !== 'undefined',
|
|
823
823
|
};
|
|
824
|
-
`}import I from"process";import{existsSync as
|
|
824
|
+
`}import I from"process";import{existsSync as aY}from"fs";import{dirname as iY,join as sY}from"path";import{craftBinaryNotFoundMessage as gZ,resolveCraftBinary as tY}from"craft-native";var m={};function eY(Z){m={...m,...Z}}function Z6(){return{...m}}function Y6(){m={}}function KZ(Z){if(!Z.sidebarConfig)return;let Y={...Z.sidebarConfig};if(Y.variant==="desktop")Y.material=Y.material??"sidebar",Y.backgroundEffect=Y.backgroundEffect??"shimmer",Y.allowsVibrancy=Y.allowsVibrancy??!0;return Y}function ZZ(){let Z=[I.env.CRAFT_BINARY_PATH,m.craftBinaryPath,...m.additionalSearchPaths||[],sY(iY(I.execPath),"craft")];for(let Y of Z)if(Y&&aY(Y))return Y;return tY()}var H=new Map;function jZ(Z){let Y=H.get(Z);if(!Y||Y.closed)return;Y.closed=!0;for(let $ of Y.closeListeners??[])try{$()}catch(J){console.warn(`[stx/desktop] window ${Z} close listener threw:`,J)}Y.closeListeners?.clear()}var $6=50;async function VZ(Z,Y){let $=Y.show().then(()=>({failed:!1}),(G)=>({failed:!0,error:G})),J=await Promise.race([$,new Promise((G)=>setTimeout(()=>G(null),$6))]);if(J?.failed)throw J.error;$.then(()=>jZ(Z))}function J6(){return Array.from(H.keys())}function Q6(Z){let Y=H.get(Z);if(!Y)return null;return YZ(Z,Y.app)}function G6(){for(let[Z,Y]of H)try{Y.app?.close?.()}catch($){console.warn(`Failed to close window ${Z}:`,$)}H.clear()}function YZ(Z,Y){return{id:Z,show:()=>{console.log(`[stx/desktop] Window ${Z} shown`)},hide:()=>{console.log("[stx/desktop] To hide window, use window.craft.window.hide() from inside the webview")},close:()=>{let $=H.get(Z);if($?.app)$.app.close(),jZ(Z),H.delete(Z),console.log(`[stx/desktop] Window ${Z} closed`)},onClosed:($)=>{let J=H.get(Z);if(!J||J.closed)return queueMicrotask($),()=>{};return J.closeListeners??=new Set,J.closeListeners.add($),()=>J.closeListeners?.delete($)},focus:()=>{console.log("[stx/desktop] To focus window, use window.craft.window.focus() from inside the webview")},minimize:()=>{console.log("[stx/desktop] To minimize window, use window.craft.window.minimize() from inside the webview")},maximize:()=>{console.log("[stx/desktop] To maximize window, use window.craft.window.maximize() from inside the webview")},restore:()=>{console.log("[stx/desktop] To restore window, use window.craft.window.show() from inside the webview")},setTitle:($)=>{console.log(`[stx/desktop] To set title, use window.craft.window.setTitle({ title: "${$}" }) from inside the webview`)},loadURL:($)=>{console.log(`[stx/desktop] To navigate, use window.location.href = "${$}" from inside the webview`)},reload:()=>{console.log("[stx/desktop] To reload, use window.craft.window.reload() from inside the webview")}}}function qZ(Z,Y={}){let $=["--url",Z,"--title",Y.title||"stx Desktop","--width",String(Y.width??1200),"--height",String(Y.height??800)];if(Y.darkMode)$.push("--dark");if(Y.hotReload)$.push("--hot-reload");if(Y.resizable===!1)$.push("--no-resize");if(Y.frameless)$.push("--frameless");if(Y.alwaysOnTop)$.push("--always-on-top");if(Y.titlebarHidden)$.push("--titlebar-hidden");if(Y.systemTray)$.push("--system-tray");if(Y.hideDockIcon)$.push("--hide-dock-icon");if(Y.devTools===!1)$.push("--no-devtools");if(Y.nativeSidebar)$.push("--native-sidebar");if(Y.sidebarWidth!==void 0)$.push("--sidebar-width",String(Y.sidebarWidth));let J=KZ(Y);if(J)$.push("--sidebar-config",JSON.stringify(J));return $}async function X6(Z,Y={}){let $=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,J=ZZ();try{let{createApp:G}=await import("craft-native"),X=G({url:Z,craftPath:J,window:{title:Y.title||"stx Desktop",width:Y.width??1200,height:Y.height??800,darkMode:Y.darkMode??!1,hotReload:Y.hotReload??!1,resizable:Y.resizable??!0,frameless:Y.frameless??!1,alwaysOnTop:Y.alwaysOnTop??!1,titlebarHidden:Y.titlebarHidden??!1,systemTray:Y.systemTray??!1,hideDockIcon:Y.hideDockIcon??!1,devTools:Y.devTools??!1,nativeSidebar:Y.nativeSidebar??!1,sidebarWidth:Y.sidebarWidth,sidebarConfig:KZ(Y)}});return H.set($,{app:X,url:Z,options:Y}),await VZ($,X),YZ($,X)}catch{try{let{spawn:G}=await import("child_process"),X=G(J,qZ(Z,Y),{stdio:"inherit"});X.on("error",(z)=>{console.error(z.code==="ENOENT"?gZ(J):`craft child error: ${z.message}`)});let O={close:()=>X.kill()};return H.set($,{app:O,url:Z,options:Y}),X.on("exit",()=>jZ($)),YZ($,O)}catch(G){return console.error("Failed to spawn craft binary:",G.message),null}}}async function z6(Z,Y={}){let $=`http://localhost:${Z}/`;if(I.env.NODE_ENV==="test"||I.env.BUN_TEST)return console.warn("\u26A0 Skipping native window in test environment"),console.log("(Skipping browser fallback in test environment)"),!1;try{let{createApp:G}=await import("craft-native");console.log("\u26A1 Opening native window via craft-native\u2026");let X=!Y.nativeSidebar,O=KZ(Y),z=G({url:$,craftPath:ZZ(),window:{title:Y.title||"stx Development",width:Y.width||1400,height:Y.height||900,resizable:!0,systemTray:X,darkMode:Y.darkMode??!0,hotReload:Y.hotReload??!0,devTools:!0,titlebarHidden:Y.titlebarHidden??!1,nativeSidebar:Y.nativeSidebar??!1,sidebarWidth:Y.sidebarWidth??260,sidebarConfig:O}}),F=`dev-window-${Z}`;return H.set(F,{app:z,url:$,options:Y}),await VZ(F,z),console.log(`\u2713 Native window opened at ${$}`),!0}catch{let G=ZZ();try{console.log(`\u26A1 Opening native window via craft binary (${G})\u2026`);let{spawn:X}=await import("child_process"),O=X(G,qZ($,{title:"stx Development",width:1400,height:900,hotReload:!0,...Y}),{stdio:"inherit"});O.on("exit",()=>I.exit(0)),O.on("error",(F)=>{console.warn(F.code==="ENOENT"?gZ(G):`craft child error: ${F.message}`)});let z=`dev-window-${Z}`;return H.set(z,{app:{close:()=>O.kill()},url:$,options:Y}),console.log(`\u2713 Native window opened at ${$}`),!0}catch(X){console.warn("\u26A0 Could not spawn craft binary:",X.message)}if(I.env.NODE_ENV==="test"||I.env.BUN_TEST)return console.log("(Skipping browser fallback in test environment)"),!1;console.log("\uD83D\uDCF1 Opening in browser instead\u2026");try{let{spawn:X}=await import("child_process"),O=I.platform;return X(O==="darwin"?"open":O==="win32"?"cmd":"xdg-open",O==="win32"?["/c","start",$]:[$],{detached:!0,stdio:"ignore"}).unref(),console.log(`\u2713 Browser opened at ${$}`),!0}catch(X){return console.error("Could not open browser:",X),console.log(`Please open manually: ${$}`),!1}}}async function F6(Z,Y={}){let{title:$="stx Desktop",width:J=1200,height:G=800,darkMode:X=!1,hotReload:O=!1,resizable:z=!0,frameless:F=!1,alwaysOnTop:R=!1}=Y;try{let{createApp:j}=await import("craft-native"),V=ZZ(),K=j({html:Z,craftPath:V,window:{title:$,width:J,height:G,darkMode:X,hotReload:O,resizable:z,frameless:F,alwaysOnTop:R}}),U=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return H.set(U,{app:K,url:"html-content",options:Y}),await VZ(U,K),YZ(U,K)}catch(j){return console.error("Failed to create window with HTML:",j),null}}function O6(){try{return v.resolve("craft-native"),!0}catch{return!1}}function R6(){return`
|
|
825
825
|
// STX Desktop Window Bridge
|
|
826
826
|
// Provides convenient wrappers around window.craft APIs
|
|
827
827
|
window.stxWindow = {
|
|
@@ -862,7 +862,7 @@ window.stxWindow = {
|
|
|
862
862
|
|
|
863
863
|
// Expose as global for backwards compatibility
|
|
864
864
|
window.desktop = window.stxWindow;
|
|
865
|
-
`}import{pack as
|
|
865
|
+
`}import{pack as K6,packageApp as j6}from"craft-native";import{craftBinaryNotFoundMessage as V6,resolveCraftBinary as q6}from"craft-native";import{AutoUpdater as bZ,generateUpdateManifest as uZ}from"craft-native";var mZ="update.json";function hZ(Z,Y){return`https://github.com/${Z}/releases/latest/download/${Y}`}function cZ(Z,Y,$){return`https://github.com/${Z}/releases/download/${Y}/${$}`}function P6(Z){let{repository:Y,manifestAsset:$=mZ,...J}=Z;return new bZ({...J,updateUrl:hZ(Y,$)})}function U6(Z){let Y=Z.tag??`v${Z.version}`,$={};for(let[J,G]of Object.entries(Z.artifacts)){if(!G)continue;$[J]={path:G,url:cZ(Z.repository,Y,G.split("/").pop())}}return uZ({version:Z.version,releaseNotes:Z.releaseNotes,platforms:$})}var PZ=null,A=null;class pZ{_process;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(Z,Y){this._process=Z,this._options=Y,this._startedAt=new Date;let $=Y.duration;if($&&$>0){let J=$*60*1000;this._endsAt=new Date(this._startedAt.getTime()+J),this._expireTimer=setTimeout(()=>{this._stopped=!0;for(let G of this._expireHandlers)try{G()}catch{}},J)}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 L6(Z={}){lZ();let{duration:Y,preventDisplaySleep:$=!0,preventIdleSleep:J=!0,preventSystemSleep:G=!0,preventDiskSleep:X=!1,assertUserActivity:O=!0}=Z,z=[];if($)z.push("-d");if(J)z.push("-i");if(G)z.push("-s");if(X)z.push("-m");if(O)z.push("-u");let F=[...z];if(Y&&Y>0)F.push("-t",String(Y*60));let R=Bun.spawn(["/usr/bin/caffeinate",...F],{stdio:["ignore","ignore","ignore"]}),j=new pZ(R,Z);return PZ=R,A=j,j}function lZ(Z){if(Z){if(Z.stop(),A===Z)PZ=null,A=null;return}if(A)A.stop();PZ=null,A=null}function W6(){return A!==null&&A.isActive}function D6(){if(!A||!A.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let Y=A.options.duration;return{active:!0,instance:A,startedAt:A.startedAt,endsAt:A.endsAt,durationMinutes:Y&&Y>0?Y:-1}}function M6(Z){let Y=Z||A;if(!Y||!Y.isActive)return"0:00";let $=Y.remainingMs;if($===null)return"\u221E";let J=Math.ceil($/1000),G=Math.floor(J/3600),X=Math.floor(J%3600/60),O=J%60;if(G>0)return`${G}:${String(X).padStart(2,"0")}:${String(O).padStart(2,"0")}`;return`${X}:${String(O).padStart(2,"0")}`}function T6(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 Y=Math.floor(Z/60),$=Z%60;return`${Y}h ${$}m`}import{existsSync as UZ,mkdirSync as _6,readFileSync as N6,watch as E6,writeFileSync as A6}from"fs";import{homedir as k6,platform as H6}from"os";import{dirname as x6,join as d}from"path";function C6(Z){let Y=H6(),$=k6();switch(Y){case"darwin":return d($,"Library","Application Support",Z);case"win32":return d(process.env.APPDATA||d($,"AppData","Roaming"),Z);default:return d($,".config",Z)}}class dZ{_defaults;_data;_path;_changeHandlers=new Map;_anyChangeHandlers=new Set;_watcher=null;_writeTimer=null;_writing=!1;constructor(Z){this._defaults={...Z.defaults};let Y=Z.path?x6(Z.path):C6(Z.name);if(this._path=Z.path||d(Y,"preferences.json"),!UZ(Y))_6(Y,{recursive:!0});if(this._data=this._load(),Z.watch!==!1)this._setupWatcher()}get path(){return this._path}get(Z){if(Z in this._data)return this._data[Z];return this._defaults[Z]}set(Z,Y){let $=this.get(Z);if(JSON.stringify($)===JSON.stringify(Y))return;this._data[Z]=Y,this._scheduleSave(),this._notifyChange(Z,Y,$)}getAll(){return{...this._defaults,...this._data}}has(Z){return Z in this._data}delete(Z){if(!(Z in this._data))return;let Y=this._data[Z];delete this._data[Z],this._scheduleSave(),this._notifyChange(Z,this._defaults[Z],Y)}reset(){let Z={...this._data};this._data={},this._save();for(let Y of Object.keys(Z)){let $=this._defaults[Y];this._notifyChange(Y,$,Z[Y])}}onChange(Z,Y){let $=Z;if(!this._changeHandlers.has($))this._changeHandlers.set($,new Set);return this._changeHandlers.get($).add(Y),()=>{this._changeHandlers.get($)?.delete(Y)}}onAnyChange(Z){return this._anyChangeHandlers.add(Z),()=>{this._anyChangeHandlers.delete(Z)}}close(){if(this._watcher)this._watcher.close(),this._watcher=null;if(this._writeTimer)clearTimeout(this._writeTimer),this._writeTimer=null,this._save()}_load(){try{if(UZ(this._path)){let Z=N6(this._path,"utf-8");return JSON.parse(Z)}}catch{}return{}}_save(){this._writing=!0;try{let Z=JSON.stringify({...this._defaults,...this._data},null,2);A6(this._path,Z,"utf-8")}catch(Z){console.error(`Failed to save preferences to ${this._path}:`,Z)}finally{setTimeout(()=>{this._writing=!1},100)}}_scheduleSave(){if(this._writeTimer)clearTimeout(this._writeTimer);this._writeTimer=setTimeout(()=>{this._writeTimer=null,this._save()},50)}_setupWatcher(){try{if(!UZ(this._path))this._save();this._watcher=E6(this._path,()=>{if(this._writing)return;let Z=this._load(),Y={...this._data};this._data=Z;let $=new Set([...Object.keys(Y),...Object.keys(Z)]);for(let J of $){let G=J in Y?Y[J]:this._defaults[J],X=J in Z?Z[J]:this._defaults[J];if(JSON.stringify(G)!==JSON.stringify(X))this._notifyChange(J,X,G)}})}catch{}}_notifyChange(Z,Y,$){let J=this._changeHandlers.get(Z);if(J)for(let G of J)try{G(Y,$)}catch{}for(let G of this._anyChangeHandlers)try{G(Z,Y,$)}catch{}}}function I6(Z){return new dZ(Z)}import{existsSync as h,mkdirSync as rZ,readFileSync as S6,unlinkSync as nZ,writeFileSync as oZ}from"fs";import{homedir as $Z,platform as aZ}from"os";import{join as c}from"path";function iZ(Z){let Y=Z.toLowerCase().replace(/[^a-z0-9]/g,"-");return c($Z(),"Library","LaunchAgents",`com.${Y}.plist`)}function sZ(Z){let Y=process.env.XDG_CONFIG_HOME||c($Z(),".config");return c(Y,"autostart",`${Z.toLowerCase()}.desktop`)}async function w6(Z,Y){let $=Y.appName||"StxApp",J=iZ($),G=c($Z(),"Library","LaunchAgents");if(Z){let X=Y.appPath||process.execPath,O=Y.args||[],z=[X,...O],F=`<?xml version="1.0" encoding="UTF-8"?>
|
|
866
866
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
867
867
|
<plist version="1.0">
|
|
868
868
|
<dict>
|
|
@@ -870,7 +870,7 @@ window.desktop = window.stxWindow;
|
|
|
870
870
|
<string>com.${$.toLowerCase().replace(/[^a-z0-9]/g,"-")}</string>
|
|
871
871
|
<key>ProgramArguments</key>
|
|
872
872
|
<array>
|
|
873
|
-
${z.map((
|
|
873
|
+
${z.map((R)=>` <string>${y6(R)}</string>`).join(`
|
|
874
874
|
`)}
|
|
875
875
|
</array>
|
|
876
876
|
<key>RunAtLoad</key>
|
|
@@ -880,7 +880,7 @@ ${z.map((O)=>` <string>${B6(O)}</string>`).join(`
|
|
|
880
880
|
${Y.isHidden?` <key>ProcessType</key>
|
|
881
881
|
<string>Background</string>`:""}
|
|
882
882
|
</dict>
|
|
883
|
-
</plist>`;if(!h(
|
|
883
|
+
</plist>`;if(!h(G))rZ(G,{recursive:!0});oZ(J,F,"utf-8")}else if(h(J))nZ(J)}async function B6(Z,Y){let $=Y.appName||"StxApp",J=sZ($),G=c(process.env.XDG_CONFIG_HOME||c($Z(),".config"),"autostart");if(Z){let X=Y.appPath||process.execPath,O=Y.args||[],z=[X,...O].join(" "),F=`[Desktop Entry]
|
|
884
884
|
Type=Application
|
|
885
885
|
Name=${$}
|
|
886
886
|
Exec=${z}
|
|
@@ -888,11 +888,11 @@ Terminal=false
|
|
|
888
888
|
StartupNotify=false
|
|
889
889
|
${Y.isHidden?`X-GNOME-Autostart-enabled=true
|
|
890
890
|
NoDisplay=true`:""}
|
|
891
|
-
`;if(!h(
|
|
891
|
+
`;if(!h(G))rZ(G,{recursive:!0});oZ(J,F,"utf-8")}else if(h(J))nZ(J)}async function f6(Z){return h(iZ(Z))}async function v6(Z){let Y=sZ(Z);if(!h(Y))return!1;try{let $=S6(Y,"utf-8");if($.includes("X-GNOME-Autostart-enabled=false"))return!1;if($.includes("Hidden=true"))return!1;return!0}catch{return!1}}function y6(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function g6(Z,Y={}){let $=aZ();switch($){case"darwin":return w6(Z,Y);case"linux":return B6(Z,Y);default:throw Error(`Auto-launch is not yet supported on ${$}`)}}async function b6(Z){let Y=Z||"StxApp";switch(aZ()){case"darwin":return f6(Y);case"linux":return v6(Y);default:return!1}}var B=new Map,u6=0,JZ=!1;function tZ(Z){let Y=Z.split("+").map((J)=>J.trim()),$={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let J of Y){let G=J.toLowerCase();switch(G){case"cmd":case"command":case"meta":case"\u2318":$.meta=!0;break;case"ctrl":case"control":case"\u2303":$.ctrl=!0;break;case"shift":case"\u21E7":$.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":$.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")$.meta=!0;else $.ctrl=!0;break;default:$.key=G}}return $}function m6(Z){let Y=[];if(Z.ctrl)Y.push("\u2303");if(Z.alt)Y.push("\u2325");if(Z.shift)Y.push("\u21E7");if(Z.meta)Y.push("\u2318");return Y.push(Z.key.toUpperCase()),Y.join("")}function h6(Z,Y){if(Y.meta!==Z.metaKey)return!1;if(Y.ctrl!==Z.ctrlKey)return!1;if(Y.shift!==Z.shiftKey)return!1;if(Y.alt!==Z.altKey)return!1;return Z.key.toLowerCase()===Y.key||Z.code.toLowerCase()===`key${Y.key}`}function eZ(Z){for(let[,Y]of B)if(h6(Z,Y.parsed)){Z.preventDefault(),Z.stopPropagation();try{Y.handler()}catch{}break}}function c6(){if(JZ)return;if(typeof document>"u")return;document.addEventListener("keydown",eZ,!0),JZ=!0}function LZ(){if(!JZ)return;if(typeof document>"u")return;document.removeEventListener("keydown",eZ,!0),JZ=!1}async function p6(Z,Y){if(typeof window>"u")return!1;let $=window.craft;if(!$?.hotkeys?.register)return!1;try{return await $.hotkeys.register(Z,Y),!0}catch{return!1}}async function WZ(Z){if(typeof window>"u")return;let Y=window.craft;if(!Y?.hotkeys?.unregister)return;try{await Y.hotkeys.unregister(Z)}catch{}}function l6(Z,Y){let $=`hotkey_${++u6}_${Date.now()}`,J=tZ(Z);B.set($,{shortcut:Z,handler:Y,parsed:J}),p6($,Z),c6();let G={shortcut:Z,id:$,unregister(){Z4(G)}};return G}function Z4(Z){if(B.delete(Z.id),WZ(Z.id),B.size===0)LZ()}function d6(){for(let[Z]of B)WZ(Z);B.clear(),LZ()}function r6(){return Array.from(B.entries()).map(([Z,Y])=>({shortcut:Y.shortcut,id:Z,unregister(){if(B.delete(Z),WZ(Z),B.size===0)LZ()}}))}class Y4{_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(),Y=Z-this._lastTick;this._lastTick=Z,this._remaining=Math.max(0,this._remaining-Y);for(let $ of this._tickHandlers)try{$(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let $ of this._completionHandlers)try{$()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class $4{_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 n6(Z){return new Y4(Z)}function o6(Z){return new $4(Z)}function a6(Z){return new Promise((Y)=>setTimeout(Y,Z))}function i6(Z){let Y=Math.ceil(Z/1000),$=Math.floor(Y/3600),J=Math.floor(Y%3600/60),G=Y%60;if($>0)return`${$}:${String(J).padStart(2,"0")}:${String(G).padStart(2,"0")}`;return`${J}:${String(G).padStart(2,"0")}`}function s6(Z){let Y=Math.ceil(Z/1000),$=Math.floor(Y/3600),J=Math.floor(Y%3600/60),G=Y%60;if($>0){if(J>0)return`${$}h ${J}m`;return`${$}h`}if(J>0){if(G>0)return`${J}m ${G}s`;return`${J}m`}return`${G}s`}function Q(Z){if(typeof window>"u")return!1;let Y=window.craft;return!!(Y&&Y[Z])}function M(Z){if(!Q(Z))throw Error(`craft.${Z} is not available \u2014 this API requires a Craft native window`);return window.craft[Z]}function P(Z,Y){if(typeof window>"u")return()=>{};let $=(J)=>Y(J.detail??{});return window.addEventListener(Z,$),()=>window.removeEventListener(Z,$)}var t6={async writeText(Z){if(Q("clipboard")){await window.craft.clipboard.writeText(Z);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(Z)},async readText(){if(Q("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(Q("clipboard")){await window.craft.clipboard.writeHTML(Z);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let Y=new window.ClipboardItem({"text/html":new Blob([Z],{type:"text/html"}),"text/plain":new Blob([e6(Z)],{type:"text/plain"})});await navigator.clipboard.write([Y])}catch{}},async readHTML(){if(Q("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 Y of Z)if(Y.types.includes("text/html"))return await(await Y.getType("text/html")).text()}catch{}return""},async clear(){if(Q("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(Q("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(Q("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(Q("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function e6(Z){return Z.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
892
892
|
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
893
893
|
|
|
894
|
-
`).trim()}var s6={async show(Z){if(!Z.title)throw Error("notification title is required");if(G("notifications")){await window.craft.notifications.show(Z);return}if(typeof window<"u"&&"Notification"in window){let Y=window.Notification;if(Y.permission==="granted")new Y(Z.title,{body:Z.body,icon:Z.icon});else if(Y.permission==="default"){if(await Y.requestPermission()==="granted")new Y(Z.title,{body:Z.body,icon:Z.icon})}}},async schedule(Z){if(G("notifications")){let J={...Z};if(J.triggerAt instanceof Date)J.triggerAt=J.triggerAt.toISOString();await window.craft.notifications.schedule(J);return}let Y=t6(Z.triggerAt),$=Math.max(0,Y-Date.now());setTimeout(()=>{this.show(Z).catch(()=>{})},$)},async cancel(Z){if(G("notifications"))await window.craft.notifications.cancel(Z)},async cancelAll(){if(G("notifications"))await window.craft.notifications.cancelAll()},async setBadge(Z){let Y=Math.max(0,Math.round(Number.isFinite(Z)?Z:0));if(G("notifications")){await window.craft.notifications.setBadge(Y);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(Y)}catch{}},async clearBadge(){if(G("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(G("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(G("notifications")){let Y=window.craft.notifications.registerCategories;if(typeof Y==="function")await Y(Z)}},onActionClicked(Z){return P("craft:notification:actionClicked",Z)},onReply(Z){return P("craft:notification:reply",Z)}};function t6(Z){if(Z==null)return Date.now();if(Z instanceof Date)return Z.getTime();if(typeof Z==="number")return Z;let Y=Date.parse(Z);return Number.isNaN(Y)?Date.now():Y}var e6={async readFile(Z){let Y=await M("fs").readFile(Z);return Y&&Y.data||""},async readBuffer(Z){let Y=await M("fs").readFile(Z),$=Y&&Y.data||"";if(Y&&Y.base64===!0)return Y8($);return new TextEncoder().encode($)},async writeFile(Z,Y){await M("fs").writeFile(Z,Y)},async writeBuffer(Z,Y){let $=Z8(Y),J=M("fs");if(typeof J.writeFileBytes==="function")await J.writeFileBytes(Z,$);else await J.writeFile(Z,$)},async copy(Z,Y){if(Z===Y)throw Error("fs.copy: source and destination must differ");await M("fs").copy(Z,Y)},async move(Z,Y){if(Z===Y)throw Error("fs.move: source and destination must differ");await M("fs").move(Z,Y)},async appendFile(Z,Y){await M("fs").appendFile(Z,Y)},async deleteFile(Z){await M("fs").deleteFile(Z)},async exists(Z){return await M("fs").exists(Z)},async stat(Z){return $8(await M("fs").stat(Z))},async readDir(Z){let Y=await M("fs").readDir(Z),$=Y&&Y.entries||[],J=Z.endsWith("/")?Z.slice(0,-1):Z;return $.map((Q)=>({name:Q.name,path:`${J}/${Q.name}`,isDirectory:!!Q.isDirectory}))},async mkdir(Z,Y){await M("fs").mkdir(Z,Y)},async rmdir(Z,Y){await M("fs").rmdir(Z,Y)},async watch(Z,Y){await M("fs").watch(Z,Y)},async unwatch(Z){await M("fs").unwatch(Z)},onChange(Z){return P("craft:fs:change",Z)},async watchTree(Z,Y,$){let J=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,Q=M("fs");await Q.watch(Z,J,{recursive:!!Y.recursive});let X=Y.kinds&&Y.kinds.length>0?new Set(Y.kinds):null,F=Math.max(0,Math.floor(Y.coalesceMs??0)),z=[],R=null,O=!1,j=()=>{if(R=null,z.length===0)return;let K=z;z=[];try{$(K)}catch{}},V=P("craft:fs:change",(K)=>{if(O)return;if(K.id!==J)return;if(X&&K.kind&&!X.has(K.kind))return;if(z.push(K),F===0){j();return}if(R==null)R=setTimeout(j,F)});return{id:J,async stop(){if(O)return;if(O=!0,V(),R)clearTimeout(R),R=null;if(z.length>0)j();try{await Q.unwatch(J)}catch{}}}},async homeDir(){return await M("fs").homeDir()},async tempDir(){return await M("fs").tempDir()},async appDataDir(){return await M("fs").appDataDir()}};function Z8(Z){let Y="";for(let $=0;$<Z.length;$++)Y+=String.fromCharCode(Z[$]);return typeof btoa==="function"?btoa(Y):Buffer.from(Z).toString("base64")}function Y8(Z){let Y=typeof atob==="function"?atob(Z):Buffer.from(Z,"base64").toString("binary"),$=new Uint8Array(Y.length);for(let J=0;J<Y.length;J++)$[J]=Y.charCodeAt(J);return $}function $8(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 r=new Set,Y4=!1;function J8(){if(Y4)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let Y=Z.detail;if(Y?.id)r.delete(Y.id)}),Y4=!0}var G8=new Set(["javascript:","data:","file:","vbscript:"]),Q8={async openExternal(Z){let Y=Z.trim().toLowerCase();for(let $ of G8)if(Y.startsWith($))throw Error(`shell.openExternal: ${$} URLs are blocked for safety`);if(G("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 M("shell").openPath(Z)},async showInFinder(Z){await M("shell").showInFinder(Z)},async spawn(Z,Y,$=[],J={}){if(J8(),!Z||typeof Z!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!Y||typeof Y!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray($))throw Error("shell.spawn: args must be an array");for(let Q of $)if(typeof Q!=="string")throw Error("shell.spawn: args entries must be strings");if(r.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);r.add(Z);try{await M("shell").spawn(Z,Y,$,J)}catch(Q){throw r.delete(Z),Q}},async kill(Z){await M("shell").kill(Z),r.delete(Z)},async getEnv(Z){if(G("shell")){let Y=await window.craft.shell.getEnv(Z);return Y==null?void 0:String(Y)}return},async setEnv(Z,Y){await M("shell").setEnv(Z,Y)},onStdout(Z){return P("craft:shell:stdout",Z)},onStderr(Z){return P("craft:shell:stderr",Z)},onExit(Z){return P("craft:shell:exit",Z)}};var X8={async register(Z,Y,$){if(!G("shortcuts"))return;await window.craft.shortcuts.register(Z,Y,$)},async unregister(Z){if(!G("shortcuts"))return;await window.craft.shortcuts.unregister(Z)},async unregisterAll(){if(!G("shortcuts"))return;await window.craft.shortcuts.unregisterAll()},async enable(Z){if(!G("shortcuts"))return;await window.craft.shortcuts.enable(Z)},async disable(Z){if(!G("shortcuts"))return;await window.craft.shortcuts.disable(Z)},async isRegistered(Z){if(!G("shortcuts"))return!1;return await window.craft.shortcuts.isRegistered(Z)},async list(){if(!G("shortcuts"))return[];return await window.craft.shortcuts.list()},on(Z){return P("craft:shortcut",Z)}};var z8={get(){if(G("theme"))try{return window.craft.theme.get()}catch{}return{appearance:R8()}},onChange(Z){if(Z(this.get()),G("theme"))return P("craft:theme",Z);if(typeof window<"u"&&window.matchMedia){let Y=window.matchMedia("(prefers-color-scheme: dark)"),$=()=>Z({appearance:Y.matches?"dark":"light"});return Y.addEventListener("change",$),()=>Y.removeEventListener("change",$)}return()=>{}},async current(){return this.get()}};function R8(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function F8(Z,Y={}){if(!G("dragOut"))throw Error("dragOut requires a Craft native window");let $=Array.isArray(Z)?Z:[Z];if($.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start($,Y)}function O8(){return G("dragOut")}var K8={onUrl(Z){if(!G("deepLink"))return()=>{};return P("craft:deepLink",Z)},getInitialUrl(){if(typeof window>"u")return null;if(G("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 G("deepLink")}};var j8={async isCharging(){if(G("power"))return await window.craft.power.isCharging();let Z=await GZ();return Z?!!Z.charging:!1},async isPluggedIn(){if(G("power"))return await window.craft.power.isPluggedIn();let Z=await GZ();return Z?!!Z.charging||Z.level>=0.999:!1},async isLowPowerMode(){if(G("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(G("power")){let Y=await window.craft.power.batteryLevel();return typeof Y==="number"?Y:null}let Z=await GZ();return Z?Z.level:null},async timeRemaining(){if(G("power")){let $=await window.craft.power.timeRemaining();return typeof $==="number"?$:null}let Z=await GZ();if(!Z)return null;let Y=Z.charging?Z.chargingTime:Z.dischargingTime;return Number.isFinite(Y)?Math.round(Y/60):null},async thermalState(){if(G("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(G("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(G("power")){await window.craft.power.preventSleep(Z);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let Y=window;if(Y.__craftWebWakeLock?.release){try{await Y.__craftWebWakeLock.release()}catch{}Y.__craftWebWakeLock=null}try{let $=await navigator.wakeLock.request("screen");Y.__craftWebWakeLock=$}catch{}},async allowSleep(){if(G("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 P("craft:powerSleep",Z)},onWake(Z){return P("craft:powerWake",Z)}};async function GZ(){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 V8={async connectionType(){if(G("network"))return await window.craft.network.connectionType();return $4()},async wifiSSID(){if(G("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(G("network")){let Z=await window.craft.network.wifiSignalStrength();return typeof Z==="number"?Z:void 0}return},async ipAddress(){if(G("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(G("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(G("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(G("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(G("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(G("network"))await window.craft.network.openPreferences()},onChange(Z){if(G("network"))return P("craft:networkChange",Z);if(typeof window>"u")return()=>{};let Y=()=>Z({type:$4(),online:!0}),$=()=>Z({type:"none",online:!1});return window.addEventListener("online",Y),window.addEventListener("offline",$),()=>{window.removeEventListener("online",Y),window.removeEventListener("offline",$)}}};function $4(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let Z=navigator.connection;if(!Z)return"unknown";let Y=String(Z.type||Z.effectiveType||"unknown").toLowerCase();if(Y==="wifi"||Y==="cellular"||Y==="ethernet"||Y==="bluetooth"||Y==="none")return Y;return"unknown"}var q8={async checkForUpdates(){if(!G("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!G("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(Z){if(!G("updater"))return;await window.craft.updater.setAutomaticChecks(Z)},async setCheckInterval(Z){if(!G("updater"))return;if(!Number.isFinite(Z))throw Error("setCheckInterval: must be a finite number");let Y=Z<=0?0:Math.max(60,Math.round(Z));await window.craft.updater.setCheckInterval(Y)},async setFeedURL(Z){if(!G("updater"))return;await window.craft.updater.setFeedURL(Z)},async getLastUpdateCheckDate(){if(!G("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!G("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 P("craft:updateAvailable",Z)},onDownloaded(Z){return P("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:Y,publicKeyB64:$}){let J=J4(Z),Q;try{Q=await crypto.subtle.importKey("raw",QZ($),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",Q,QZ(Y),J)}catch{return!1}},async verifyDownload({url:Z,signatureB64:Y,publicKeyB64:$,fetchInit:J}){let Q;try{Q=await fetch(Z,J)}catch{return{ok:!1,reason:"fetch-failed"}}if(!Q.ok)return{ok:!1,reason:"http-error",status:Q.status};let X=new Uint8Array(await Q.arrayBuffer()),F;try{F=await crypto.subtle.importKey("raw",QZ($),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let z=!1;try{z=await crypto.subtle.verify("Ed25519",F,QZ(Y),J4(X))}catch{z=!1}if(!z)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:X}}};function J4(Z){if(Z instanceof ArrayBuffer)return new Uint8Array(Z);let Y=new ArrayBuffer(Z.byteLength),$=new Uint8Array(Y);return $.set(Z),$}function QZ(Z){if(typeof atob==="function"){let J=atob(Z),Q=new ArrayBuffer(J.length),X=new Uint8Array(Q);for(let F=0;F<J.length;F++)X[F]=J.charCodeAt(F);return X}let Y=Buffer.from(Z,"base64"),$=new ArrayBuffer(Y.length);return new Uint8Array($).set(Y),new Uint8Array($)}var P8={onFocus(Z){if(G("window"))return P("craft:window:focus",()=>Z());return WZ("focus",Z)},onBlur(Z){if(G("window"))return P("craft:window:blur",()=>Z());return WZ("blur",Z)},onResize(Z){if(G("window"))return P("craft:window:resize",Z);if(typeof window>"u")return()=>{};let Y=()=>Z({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},onMove(Z){if(G("window"))return P("craft:window:move",Z);return()=>{}},onClose(Z){if(G("window"))return P("craft:window:close",()=>Z());return WZ("beforeunload",Z)},onMinimize(Z){if(G("window"))return P("craft:window:minimize",()=>Z());if(typeof document>"u")return()=>{};let Y=()=>{if(document.visibilityState==="hidden")Z()};return document.addEventListener("visibilitychange",Y),()=>document.removeEventListener("visibilitychange",Y)},onRestore(Z){if(G("window"))return P("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let Y=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",Y),()=>document.removeEventListener("visibilitychange",Y)}};function WZ(Z,Y){if(typeof window>"u")return()=>{};let $=()=>Y();return window.addEventListener(Z,$),()=>window.removeEventListener(Z,$)}var G4={name:"",version:"0.0.0"},U8={async hideDockIcon(){if(G("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(G("app"))await window.craft.app.showDockIcon()},async quit(){if(G("app"))await window.craft.app.quit()},async getInfo(){if(!G("app"))return G4;let Z=await window.craft.app.getInfo();return{...G4,...Z||{}}},async notify(Z){if(!Z.title)throw Error("notify: title is required");if(G("app"))await window.craft.app.notify(Z)},async setBadge(Z){if(G("app"))await window.craft.app.setBadge(Z)},async bounce(Z="informational"){if(G("app"))await window.craft.app.bounce(Z)}};var W8={async set(Z){if(G("menu"))await window.craft.menu.set(Z)},async setDock(Z){if(G("menu"))await window.craft.menu.setDock(Z)},async addItem(Z,Y){if(G("menu"))await window.craft.menu.addItem(Z,Y)},async removeItem(Z){if(G("menu"))await window.craft.menu.removeItem(Z)},async enableItem(Z){if(G("menu"))await window.craft.menu.enableItem(Z)},async disableItem(Z){if(G("menu"))await window.craft.menu.disableItem(Z)},async checkItem(Z){if(G("menu"))await window.craft.menu.checkItem(Z)},async uncheckItem(Z){if(G("menu"))await window.craft.menu.uncheckItem(Z)},async setItemLabel(Z,Y){if(G("menu"))await window.craft.menu.setItemLabel(Z,Y)},async clearDock(){if(G("menu"))await window.craft.menu.clearDock()},onAction(Z){return P("craft:menu:action",Z)}};var D8={accentColor:()=>H("system","accentColor",()=>""),highlightColor:()=>H("system","highlightColor",()=>""),language:()=>H("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>H("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>H("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>H("system","is24HourTime",()=>{try{let Z=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return Z.hourCycle==="h23"||Z.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>H("system","reduceMotion",()=>DZ("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>H("system","reduceTransparency",()=>DZ("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>H("system","increaseContrast",()=>DZ("(prefers-contrast: more)")),systemVersion:()=>H("system","systemVersion",()=>""),hostname:()=>H("system","hostname",()=>""),username:()=>H("system","username",()=>""),async openPreferences(){if(G("system"))await window.craft.system.openPreferences()}};async function H(Z,Y,$){if(G(Z))return await window.craft[Z][Y]();return await $()}function DZ(Z){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(Z).matches}var L8={async getDisplays(){if(G("screen"))return await window.craft.screen.getDisplays();return Q4()},async getPrimary(){if(G("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return Q4()[0]??null},onChange(Z){if(G("screen"))return P("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let Y=()=>Z();return window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)}};function Q4(){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 M8={async set(Z,Y,$){if(!Z)throw Error("keychain.set: service is required");if(!Y)throw Error("keychain.set: account is required");await M("keychain").set(Z,Y,$)},async get(Z,Y){if(!Z)throw Error("keychain.get: service is required");if(!Y)throw Error("keychain.get: account is required");let $=await M("keychain").get(Z,Y);return typeof $==="string"?$:null},async delete(Z,Y){if(!Z)throw Error("keychain.delete: service is required");if(!Y)throw Error("keychain.delete: account is required");await M("keychain").delete(Z,Y)},async has(Z,Y){if(!Z)throw Error("keychain.has: service is required");if(!Y)throw Error("keychain.has: account is required");return await M("keychain").has(Z,Y)}};var _8={async check(Z){if(G("permissions"))return await window.craft.permissions.check(Z);return await X4(Z)},async request(Z){if(G("permissions"))return await window.craft.permissions.request(Z);return await T8(Z)},async openSettings(Z){if(G("permissions"))await window.craft.permissions.openSettings(Z)}};async function X4(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let Y=await navigator.permissions.query({name:Z});return N8(Y.state)}catch{return"not-supported"}}async function T8(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let Y=await window.Notification.requestPermission();return Y==="granted"?"granted":Y==="denied"?"denied":"undetermined"}return await X4(Z)}function N8(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var E8={async print(){if(G("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 Y=Z.startsWith("/"),$=/^[a-zA-Z]:[\\/]/.test(Z)||Z.startsWith("\\\\");if(!Y&&!$)throw Error("printToPDF: path must be absolute");let J=await M("printing").printToPDF(Z);return{ok:!!(J&&J.ok),path:J?.path}}};var A8={async enable(){if(!G("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!G("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!G("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};var k8={async addItem(Z){if(G("touchbar"))await window.craft.touchbar.addItem(Z)},async removeItem(Z){if(G("touchbar"))await window.craft.touchbar.removeItem(Z)},async updateItem(Z,Y){if(G("touchbar"))await window.craft.touchbar.updateItem(Z,Y)},async setLabel(Z,Y){if(G("touchbar"))await window.craft.touchbar.setLabel(Z,Y)},async setIcon(Z,Y){if(G("touchbar"))await window.craft.touchbar.setIcon(Z,Y)},async setEnabled(Z,Y){if(G("touchbar"))await window.craft.touchbar.setEnabled(Z,Y)},async setSliderValue(Z,Y){if(G("touchbar"))await window.craft.touchbar.setSliderValue(Z,Y)},async clear(){if(G("touchbar"))await window.craft.touchbar.clear()},async show(){if(G("touchbar"))await window.craft.touchbar.show()},async hide(){if(G("touchbar"))await window.craft.touchbar.hide()},onAction(Z){return P("craft:touchbar:action",Z)}};var H8=/^[\da-f]*$/i;function x8(Z,Y){if(typeof Y!=="string"||!H8.test(Y)||Y.length%2!==0)throw Error(`${Z}: must be a hex string with even length, got ${JSON.stringify(Y)}`)}var C8={async isEnabled(){return G("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return G("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return G("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return G("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(G("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(G("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return G("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(Z){if(G("bluetooth"))await window.craft.bluetooth.connect(Z)},async disconnect(Z){if(G("bluetooth"))await window.craft.bluetooth.disconnect(Z)},async openPreferences(){if(G("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(Z){if(!Z)throw Error("bluetooth.discoverServices: deviceId is required");if(!G("bluetooth"))return[];let Y=await window.craft.bluetooth.discoverServices(Z);return Array.isArray(Y)?Y:[]},async discoverCharacteristics(Z,Y){if(!Z||!Y)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!G("bluetooth"))return[];let $=await window.craft.bluetooth.discoverCharacteristics(Z,Y);return Array.isArray($)?$:[]},async readCharacteristic(Z,Y,$){if(!Z||!Y||!$)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!G("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(Z,Y,$)},async writeCharacteristic(Z,Y,$,J,Q="with-response"){if(!Z||!Y||!$)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(x8("bluetooth.writeCharacteristic.valueHex",J),!G("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(Z,Y,$,J,Q)},async setCharacteristicNotify(Z,Y,$,J){if(!Z||!Y||!$)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!G("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(Z,Y,$,J)},onDeviceFound(Z){return P("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return P("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return P("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return P("craft:bluetooth:characteristicValue",Z)}};var I8={async speak(Z,Y){if(!Z)throw Error("speech.speak: text is required");if(G("speech")){await window.craft.speech.speak(Z,Y);return}if(typeof window<"u"&&window.speechSynthesis){let $=new window.SpeechSynthesisUtterance(Z);if(Y){if(Y.rate!=null)$.rate=Y.rate;if(Y.pitch!=null)$.pitch=Y.pitch;if(Y.volume!=null)$.volume=Y.volume;if(Y.voice){let Q=window.speechSynthesis.getVoices().find((X)=>X.voiceURI===Y.voice||X.name===Y.voice||X.lang===Y.voice);if(Q)$.voice=Q}}window.speechSynthesis.speak($)}},async stop(){if(G("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(G("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(G("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(G("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(G("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((Y)=>({id:Y.voiceURI||Y.name,name:Y.name,language:Y.lang||"",quality:"default"}));return[]}};var n=[],LZ=!0,MZ,_Z,o={async report(Z){if(G("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!LZ)return;let Y=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:MZ,appVersion:_Z}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:MZ,appVersion:_Z};if(n.length>=64)n.shift();n.push(Y)},async flush(){if(G("crashReporter"))return await window.craft.crashReporter.flush();return[...n]},async clear(){if(G("crashReporter")){await window.craft.crashReporter.clear();return}n.length=0},async setEnabled(Z){if(G("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}LZ=Z},async isEnabled(){if(G("crashReporter"))return await window.craft.crashReporter.isEnabled();return LZ},async setUser(Z){if(G("crashReporter")){await window.craft.crashReporter.setUser(Z);return}MZ=Z||void 0},async setAppVersion(Z){if(G("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}_Z=Z||void 0},attachGlobalHandlers(){if(G("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=($)=>{o.report({severity:"error",message:$.message,source:"js",stack:$.error?.stack||`${$.message}
|
|
895
|
-
at ${$.filename}:${$.lineno}:${$.colno}`}).catch(()=>{})},Y=($)=>{let J=$.reason;o.report({severity:"error",message:J?.message||String(J),source:"js",stack:J?.stack||""}).catch(()=>{})};return window.addEventListener("error",Z),window.addEventListener("unhandledrejection",Y),()=>{window.removeEventListener("error",Z),window.removeEventListener("unhandledrejection",Y)}},forwardTo(Z){return
|
|
894
|
+
`).trim()}var Z8={async show(Z){if(!Z.title)throw Error("notification title is required");if(Q("notifications")){await window.craft.notifications.show(Z);return}if(typeof window<"u"&&"Notification"in window){let Y=window.Notification;if(Y.permission==="granted")new Y(Z.title,{body:Z.body,icon:Z.icon});else if(Y.permission==="default"){if(await Y.requestPermission()==="granted")new Y(Z.title,{body:Z.body,icon:Z.icon})}}},async schedule(Z){if(Q("notifications")){let J={...Z};if(J.triggerAt instanceof Date)J.triggerAt=J.triggerAt.toISOString();await window.craft.notifications.schedule(J);return}let Y=Y8(Z.triggerAt),$=Math.max(0,Y-Date.now());setTimeout(()=>{this.show(Z).catch(()=>{})},$)},async cancel(Z){if(Q("notifications"))await window.craft.notifications.cancel(Z)},async cancelAll(){if(Q("notifications"))await window.craft.notifications.cancelAll()},async setBadge(Z){let Y=Math.max(0,Math.round(Number.isFinite(Z)?Z:0));if(Q("notifications")){await window.craft.notifications.setBadge(Y);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(Y)}catch{}},async clearBadge(){if(Q("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(Q("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(Q("notifications")){let Y=window.craft.notifications.registerCategories;if(typeof Y==="function")await Y(Z)}},onActionClicked(Z){return P("craft:notification:actionClicked",Z)},onReply(Z){return P("craft:notification:reply",Z)}};function Y8(Z){if(Z==null)return Date.now();if(Z instanceof Date)return Z.getTime();if(typeof Z==="number")return Z;let Y=Date.parse(Z);return Number.isNaN(Y)?Date.now():Y}var $8={async readFile(Z){let Y=await M("fs").readFile(Z);return Y&&Y.data||""},async readBuffer(Z){let Y=await M("fs").readFile(Z),$=Y&&Y.data||"";if(Y&&Y.base64===!0)return Q8($);return new TextEncoder().encode($)},async writeFile(Z,Y){await M("fs").writeFile(Z,Y)},async writeBuffer(Z,Y){let $=J8(Y),J=M("fs");if(typeof J.writeFileBytes==="function")await J.writeFileBytes(Z,$);else await J.writeFile(Z,$)},async copy(Z,Y){if(Z===Y)throw Error("fs.copy: source and destination must differ");await M("fs").copy(Z,Y)},async move(Z,Y){if(Z===Y)throw Error("fs.move: source and destination must differ");await M("fs").move(Z,Y)},async appendFile(Z,Y){await M("fs").appendFile(Z,Y)},async deleteFile(Z){await M("fs").deleteFile(Z)},async exists(Z){return await M("fs").exists(Z)},async stat(Z){return G8(await M("fs").stat(Z))},async readDir(Z){let Y=await M("fs").readDir(Z),$=Y&&Y.entries||[],J=Z.endsWith("/")?Z.slice(0,-1):Z;return $.map((G)=>({name:G.name,path:`${J}/${G.name}`,isDirectory:!!G.isDirectory}))},async mkdir(Z,Y){await M("fs").mkdir(Z,Y)},async rmdir(Z,Y){await M("fs").rmdir(Z,Y)},async watch(Z,Y){await M("fs").watch(Z,Y)},async unwatch(Z){await M("fs").unwatch(Z)},onChange(Z){return P("craft:fs:change",Z)},async watchTree(Z,Y,$){let J=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=M("fs");await G.watch(Z,J,{recursive:!!Y.recursive});let X=Y.kinds&&Y.kinds.length>0?new Set(Y.kinds):null,O=Math.max(0,Math.floor(Y.coalesceMs??0)),z=[],F=null,R=!1,j=()=>{if(F=null,z.length===0)return;let K=z;z=[];try{$(K)}catch{}},V=P("craft:fs:change",(K)=>{if(R)return;if(K.id!==J)return;if(X&&K.kind&&!X.has(K.kind))return;if(z.push(K),O===0){j();return}if(F==null)F=setTimeout(j,O)});return{id:J,async stop(){if(R)return;if(R=!0,V(),F)clearTimeout(F),F=null;if(z.length>0)j();try{await G.unwatch(J)}catch{}}}},async homeDir(){return await M("fs").homeDir()},async tempDir(){return await M("fs").tempDir()},async appDataDir(){return await M("fs").appDataDir()}};function J8(Z){let Y="";for(let $=0;$<Z.length;$++)Y+=String.fromCharCode(Z[$]);return typeof btoa==="function"?btoa(Y):Buffer.from(Z).toString("base64")}function Q8(Z){let Y=typeof atob==="function"?atob(Z):Buffer.from(Z,"base64").toString("binary"),$=new Uint8Array(Y.length);for(let J=0;J<Y.length;J++)$[J]=Y.charCodeAt(J);return $}function G8(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 r=new Set,J4=!1;function X8(){if(J4)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let Y=Z.detail;if(Y?.id)r.delete(Y.id)}),J4=!0}var z8=new Set(["javascript:","data:","file:","vbscript:"]),F8={async openExternal(Z){let Y=Z.trim().toLowerCase();for(let $ of z8)if(Y.startsWith($))throw Error(`shell.openExternal: ${$} URLs are blocked for safety`);if(Q("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 M("shell").openPath(Z)},async showInFinder(Z){await M("shell").showInFinder(Z)},async spawn(Z,Y,$=[],J={}){if(X8(),!Z||typeof Z!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!Y||typeof Y!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray($))throw Error("shell.spawn: args must be an array");for(let G of $)if(typeof G!=="string")throw Error("shell.spawn: args entries must be strings");if(r.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);r.add(Z);try{await M("shell").spawn(Z,Y,$,J)}catch(G){throw r.delete(Z),G}},async kill(Z){await M("shell").kill(Z),r.delete(Z)},async getEnv(Z){if(Q("shell")){let Y=await window.craft.shell.getEnv(Z);return Y==null?void 0:String(Y)}return},async setEnv(Z,Y){await M("shell").setEnv(Z,Y)},onStdout(Z){return P("craft:shell:stdout",Z)},onStderr(Z){return P("craft:shell:stderr",Z)},onExit(Z){return P("craft:shell:exit",Z)}};var O8={async register(Z,Y,$){if(!Q("shortcuts"))return;await window.craft.shortcuts.register(Z,Y,$)},async unregister(Z){if(!Q("shortcuts"))return;await window.craft.shortcuts.unregister(Z)},async unregisterAll(){if(!Q("shortcuts"))return;await window.craft.shortcuts.unregisterAll()},async enable(Z){if(!Q("shortcuts"))return;await window.craft.shortcuts.enable(Z)},async disable(Z){if(!Q("shortcuts"))return;await window.craft.shortcuts.disable(Z)},async isRegistered(Z){if(!Q("shortcuts"))return!1;return await window.craft.shortcuts.isRegistered(Z)},async list(){if(!Q("shortcuts"))return[];return await window.craft.shortcuts.list()},on(Z){return P("craft:shortcut",Z)}};var R8={get(){if(Q("theme"))try{return window.craft.theme.get()}catch{}return{appearance:K8()}},onChange(Z){if(Z(this.get()),Q("theme"))return P("craft:theme",Z);if(typeof window<"u"&&window.matchMedia){let Y=window.matchMedia("(prefers-color-scheme: dark)"),$=()=>Z({appearance:Y.matches?"dark":"light"});return Y.addEventListener("change",$),()=>Y.removeEventListener("change",$)}return()=>{}},async current(){return this.get()}};function K8(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function j8(Z,Y={}){if(!Q("dragOut"))throw Error("dragOut requires a Craft native window");let $=Array.isArray(Z)?Z:[Z];if($.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start($,Y)}function V8(){return Q("dragOut")}var q8={onUrl(Z){if(!Q("deepLink"))return()=>{};return P("craft:deepLink",Z)},getInitialUrl(){if(typeof window>"u")return null;if(Q("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 Q("deepLink")}};var P8={async isCharging(){if(Q("power"))return await window.craft.power.isCharging();let Z=await QZ();return Z?!!Z.charging:!1},async isPluggedIn(){if(Q("power"))return await window.craft.power.isPluggedIn();let Z=await QZ();return Z?!!Z.charging||Z.level>=0.999:!1},async isLowPowerMode(){if(Q("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(Q("power")){let Y=await window.craft.power.batteryLevel();return typeof Y==="number"?Y:null}let Z=await QZ();return Z?Z.level:null},async timeRemaining(){if(Q("power")){let $=await window.craft.power.timeRemaining();return typeof $==="number"?$:null}let Z=await QZ();if(!Z)return null;let Y=Z.charging?Z.chargingTime:Z.dischargingTime;return Number.isFinite(Y)?Math.round(Y/60):null},async thermalState(){if(Q("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(Q("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(Q("power")){await window.craft.power.preventSleep(Z);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let Y=window;if(Y.__craftWebWakeLock?.release){try{await Y.__craftWebWakeLock.release()}catch{}Y.__craftWebWakeLock=null}try{let $=await navigator.wakeLock.request("screen");Y.__craftWebWakeLock=$}catch{}},async allowSleep(){if(Q("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 P("craft:powerSleep",Z)},onWake(Z){return P("craft:powerWake",Z)}};async function QZ(){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 U8={async connectionType(){if(Q("network"))return await window.craft.network.connectionType();return Q4()},async wifiSSID(){if(Q("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(Q("network")){let Z=await window.craft.network.wifiSignalStrength();return typeof Z==="number"?Z:void 0}return},async ipAddress(){if(Q("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(Q("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(Q("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(Q("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(Q("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(Q("network"))await window.craft.network.openPreferences()},onChange(Z){if(Q("network"))return P("craft:networkChange",Z);if(typeof window>"u")return()=>{};let Y=()=>Z({type:Q4(),online:!0}),$=()=>Z({type:"none",online:!1});return window.addEventListener("online",Y),window.addEventListener("offline",$),()=>{window.removeEventListener("online",Y),window.removeEventListener("offline",$)}}};function Q4(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let Z=navigator.connection;if(!Z)return"unknown";let Y=String(Z.type||Z.effectiveType||"unknown").toLowerCase();if(Y==="wifi"||Y==="cellular"||Y==="ethernet"||Y==="bluetooth"||Y==="none")return Y;return"unknown"}var L8={async checkForUpdates(){if(!Q("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!Q("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(Z){if(!Q("updater"))return;await window.craft.updater.setAutomaticChecks(Z)},async setCheckInterval(Z){if(!Q("updater"))return;if(!Number.isFinite(Z))throw Error("setCheckInterval: must be a finite number");let Y=Z<=0?0:Math.max(60,Math.round(Z));await window.craft.updater.setCheckInterval(Y)},async setFeedURL(Z){if(!Q("updater"))return;await window.craft.updater.setFeedURL(Z)},async getLastUpdateCheckDate(){if(!Q("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!Q("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 P("craft:updateAvailable",Z)},onDownloaded(Z){return P("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:Y,publicKeyB64:$}){let J=G4(Z),G;try{G=await crypto.subtle.importKey("raw",GZ($),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",G,GZ(Y),J)}catch{return!1}},async verifyDownload({url:Z,signatureB64:Y,publicKeyB64:$,fetchInit:J}){let G;try{G=await fetch(Z,J)}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",GZ($),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let z=!1;try{z=await crypto.subtle.verify("Ed25519",O,GZ(Y),G4(X))}catch{z=!1}if(!z)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:X}}};function G4(Z){if(Z instanceof ArrayBuffer)return new Uint8Array(Z);let Y=new ArrayBuffer(Z.byteLength),$=new Uint8Array(Y);return $.set(Z),$}function GZ(Z){if(typeof atob==="function"){let J=atob(Z),G=new ArrayBuffer(J.length),X=new Uint8Array(G);for(let O=0;O<J.length;O++)X[O]=J.charCodeAt(O);return X}let Y=Buffer.from(Z,"base64"),$=new ArrayBuffer(Y.length);return new Uint8Array($).set(Y),new Uint8Array($)}var W8={onFocus(Z){if(Q("window"))return P("craft:window:focus",()=>Z());return DZ("focus",Z)},onBlur(Z){if(Q("window"))return P("craft:window:blur",()=>Z());return DZ("blur",Z)},onResize(Z){if(Q("window"))return P("craft:window:resize",Z);if(typeof window>"u")return()=>{};let Y=()=>Z({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},onMove(Z){if(Q("window"))return P("craft:window:move",Z);return()=>{}},onClose(Z){if(Q("window"))return P("craft:window:close",()=>Z());return DZ("beforeunload",Z)},onMinimize(Z){if(Q("window"))return P("craft:window:minimize",()=>Z());if(typeof document>"u")return()=>{};let Y=()=>{if(document.visibilityState==="hidden")Z()};return document.addEventListener("visibilitychange",Y),()=>document.removeEventListener("visibilitychange",Y)},onRestore(Z){if(Q("window"))return P("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let Y=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",Y),()=>document.removeEventListener("visibilitychange",Y)}};function DZ(Z,Y){if(typeof window>"u")return()=>{};let $=()=>Y();return window.addEventListener(Z,$),()=>window.removeEventListener(Z,$)}var X4={name:"",version:"0.0.0"},D8={async hideDockIcon(){if(Q("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(Q("app"))await window.craft.app.showDockIcon()},async quit(){if(Q("app"))await window.craft.app.quit()},async getInfo(){if(!Q("app"))return X4;let Z=await window.craft.app.getInfo();return{...X4,...Z||{}}},async notify(Z){if(!Z.title)throw Error("notify: title is required");if(Q("app"))await window.craft.app.notify(Z)},async setBadge(Z){if(Q("app"))await window.craft.app.setBadge(Z)},async bounce(Z="informational"){if(Q("app"))await window.craft.app.bounce(Z)}};var M8={async set(Z){if(Q("menu"))await window.craft.menu.set(Z)},async setDock(Z){if(Q("menu"))await window.craft.menu.setDock(Z)},async addItem(Z,Y){if(Q("menu"))await window.craft.menu.addItem(Z,Y)},async removeItem(Z){if(Q("menu"))await window.craft.menu.removeItem(Z)},async enableItem(Z){if(Q("menu"))await window.craft.menu.enableItem(Z)},async disableItem(Z){if(Q("menu"))await window.craft.menu.disableItem(Z)},async checkItem(Z){if(Q("menu"))await window.craft.menu.checkItem(Z)},async uncheckItem(Z){if(Q("menu"))await window.craft.menu.uncheckItem(Z)},async setItemLabel(Z,Y){if(Q("menu"))await window.craft.menu.setItemLabel(Z,Y)},async clearDock(){if(Q("menu"))await window.craft.menu.clearDock()},onAction(Z){return P("craft:menu:action",Z)}};var T8={accentColor:()=>x("system","accentColor",()=>""),highlightColor:()=>x("system","highlightColor",()=>""),language:()=>x("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>x("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>x("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>x("system","is24HourTime",()=>{try{let Z=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return Z.hourCycle==="h23"||Z.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>x("system","reduceMotion",()=>MZ("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>x("system","reduceTransparency",()=>MZ("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>x("system","increaseContrast",()=>MZ("(prefers-contrast: more)")),systemVersion:()=>x("system","systemVersion",()=>""),hostname:()=>x("system","hostname",()=>""),username:()=>x("system","username",()=>""),async openPreferences(){if(Q("system"))await window.craft.system.openPreferences()}};async function x(Z,Y,$){if(Q(Z))return await window.craft[Z][Y]();return await $()}function MZ(Z){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(Z).matches}var _8={async getDisplays(){if(Q("screen"))return await window.craft.screen.getDisplays();return z4()},async getPrimary(){if(Q("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return z4()[0]??null},onChange(Z){if(Q("screen"))return P("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let Y=()=>Z();return window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)}};function z4(){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 N8={async set(Z,Y,$){if(!Z)throw Error("keychain.set: service is required");if(!Y)throw Error("keychain.set: account is required");await M("keychain").set(Z,Y,$)},async get(Z,Y){if(!Z)throw Error("keychain.get: service is required");if(!Y)throw Error("keychain.get: account is required");let $=await M("keychain").get(Z,Y);return typeof $==="string"?$:null},async delete(Z,Y){if(!Z)throw Error("keychain.delete: service is required");if(!Y)throw Error("keychain.delete: account is required");await M("keychain").delete(Z,Y)},async has(Z,Y){if(!Z)throw Error("keychain.has: service is required");if(!Y)throw Error("keychain.has: account is required");return await M("keychain").has(Z,Y)}};var E8={async check(Z){if(Q("permissions"))return await window.craft.permissions.check(Z);return await F4(Z)},async request(Z){if(Q("permissions"))return await window.craft.permissions.request(Z);return await A8(Z)},async openSettings(Z){if(Q("permissions"))await window.craft.permissions.openSettings(Z)}};async function F4(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let Y=await navigator.permissions.query({name:Z});return k8(Y.state)}catch{return"not-supported"}}async function A8(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let Y=await window.Notification.requestPermission();return Y==="granted"?"granted":Y==="denied"?"denied":"undetermined"}return await F4(Z)}function k8(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var H8={async print(){if(Q("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 Y=Z.startsWith("/"),$=/^[a-zA-Z]:[\\/]/.test(Z)||Z.startsWith("\\\\");if(!Y&&!$)throw Error("printToPDF: path must be absolute");let J=await M("printing").printToPDF(Z);return{ok:!!(J&&J.ok),path:J?.path}}};var x8={async enable(){if(!Q("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!Q("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!Q("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};var C8={async addItem(Z){if(Q("touchbar"))await window.craft.touchbar.addItem(Z)},async removeItem(Z){if(Q("touchbar"))await window.craft.touchbar.removeItem(Z)},async updateItem(Z,Y){if(Q("touchbar"))await window.craft.touchbar.updateItem(Z,Y)},async setLabel(Z,Y){if(Q("touchbar"))await window.craft.touchbar.setLabel(Z,Y)},async setIcon(Z,Y){if(Q("touchbar"))await window.craft.touchbar.setIcon(Z,Y)},async setEnabled(Z,Y){if(Q("touchbar"))await window.craft.touchbar.setEnabled(Z,Y)},async setSliderValue(Z,Y){if(Q("touchbar"))await window.craft.touchbar.setSliderValue(Z,Y)},async clear(){if(Q("touchbar"))await window.craft.touchbar.clear()},async show(){if(Q("touchbar"))await window.craft.touchbar.show()},async hide(){if(Q("touchbar"))await window.craft.touchbar.hide()},onAction(Z){return P("craft:touchbar:action",Z)}};var I8=/^[\da-f]*$/i;function S8(Z,Y){if(typeof Y!=="string"||!I8.test(Y)||Y.length%2!==0)throw Error(`${Z}: must be a hex string with even length, got ${JSON.stringify(Y)}`)}var w8={async isEnabled(){return Q("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return Q("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return Q("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return Q("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(Q("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(Q("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return Q("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(Z){if(Q("bluetooth"))await window.craft.bluetooth.connect(Z)},async disconnect(Z){if(Q("bluetooth"))await window.craft.bluetooth.disconnect(Z)},async openPreferences(){if(Q("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(Z){if(!Z)throw Error("bluetooth.discoverServices: deviceId is required");if(!Q("bluetooth"))return[];let Y=await window.craft.bluetooth.discoverServices(Z);return Array.isArray(Y)?Y:[]},async discoverCharacteristics(Z,Y){if(!Z||!Y)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!Q("bluetooth"))return[];let $=await window.craft.bluetooth.discoverCharacteristics(Z,Y);return Array.isArray($)?$:[]},async readCharacteristic(Z,Y,$){if(!Z||!Y||!$)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!Q("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(Z,Y,$)},async writeCharacteristic(Z,Y,$,J,G="with-response"){if(!Z||!Y||!$)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(S8("bluetooth.writeCharacteristic.valueHex",J),!Q("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(Z,Y,$,J,G)},async setCharacteristicNotify(Z,Y,$,J){if(!Z||!Y||!$)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!Q("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(Z,Y,$,J)},onDeviceFound(Z){return P("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return P("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return P("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return P("craft:bluetooth:characteristicValue",Z)}};var B8={async speak(Z,Y){if(!Z)throw Error("speech.speak: text is required");if(Q("speech")){await window.craft.speech.speak(Z,Y);return}if(typeof window<"u"&&window.speechSynthesis){let $=new window.SpeechSynthesisUtterance(Z);if(Y){if(Y.rate!=null)$.rate=Y.rate;if(Y.pitch!=null)$.pitch=Y.pitch;if(Y.volume!=null)$.volume=Y.volume;if(Y.voice){let G=window.speechSynthesis.getVoices().find((X)=>X.voiceURI===Y.voice||X.name===Y.voice||X.lang===Y.voice);if(G)$.voice=G}}window.speechSynthesis.speak($)}},async stop(){if(Q("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(Q("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(Q("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(Q("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(Q("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((Y)=>({id:Y.voiceURI||Y.name,name:Y.name,language:Y.lang||"",quality:"default"}));return[]}};var n=[],TZ=!0,_Z,NZ,o={async report(Z){if(Q("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!TZ)return;let Y=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:_Z,appVersion:NZ}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:_Z,appVersion:NZ};if(n.length>=64)n.shift();n.push(Y)},async flush(){if(Q("crashReporter"))return await window.craft.crashReporter.flush();return[...n]},async clear(){if(Q("crashReporter")){await window.craft.crashReporter.clear();return}n.length=0},async setEnabled(Z){if(Q("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}TZ=Z},async isEnabled(){if(Q("crashReporter"))return await window.craft.crashReporter.isEnabled();return TZ},async setUser(Z){if(Q("crashReporter")){await window.craft.crashReporter.setUser(Z);return}_Z=Z||void 0},async setAppVersion(Z){if(Q("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}NZ=Z||void 0},attachGlobalHandlers(){if(Q("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=($)=>{o.report({severity:"error",message:$.message,source:"js",stack:$.error?.stack||`${$.message}
|
|
895
|
+
at ${$.filename}:${$.lineno}:${$.colno}`}).catch(()=>{})},Y=($)=>{let J=$.reason;o.report({severity:"error",message:J?.message||String(J),source:"js",stack:J?.stack||""}).catch(()=>{})};return window.addEventListener("error",Z),window.addEventListener("unhandledrejection",Y),()=>{window.removeEventListener("error",Z),window.removeEventListener("unhandledrejection",Y)}},forwardTo(Z){return u8(Z)}},f8="craft:crashReporter:pending",v8=/[\w.+-]+@[\w-]+\.[\w.-]+/g,y8=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,g8=/\/(?:Users|home)\/[^\s/'"`]+/g;function R4(Z){let Y=($)=>$.replace(v8,"<email>").replace(y8,"<ip>").replace(g8,"/<home>");return{...Z,message:Y(Z.message),stack:Y(Z.stack)}}async function K4(Z,Y){let $=new TextEncoder,J=await crypto.subtle.importKey("raw",$.encode(Z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),G=await crypto.subtle.sign("HMAC",J,$.encode(Y));return[...new Uint8Array(G)].map((X)=>X.toString(16).padStart(2,"0")).join("")}function b8(Z){if(!Z||typeof localStorage>"u")return[];try{let Y=localStorage.getItem(Z);if(!Y)return[];let $=JSON.parse(Y);return Array.isArray($)?$:[]}catch{return[]}}function O4(Z,Y){if(!Z||typeof localStorage>"u")return;try{if(Y.length===0)localStorage.removeItem(Z);else localStorage.setItem(Z,JSON.stringify(Y))}catch{}}function u8(Z){let{endpoint:Y,intervalMs:$=60000,signingSecret:J,redact:G=!0,headers:X={},maxRetries:O=5,persistKey:z}=Z,F=z===null?null:z??f8,R=b8(F),j=!1,V=null,K=null,U=typeof G==="function"?G:G===!1?(N)=>N:R4;async function L(N){let E=JSON.stringify({entries:N}),S={"Content-Type":"application/json",...X};if(J)S["X-Craft-Signature"]=await K4(J,E);let i=0,w=1000;while(!j)try{let b=await fetch(Y,{method:"POST",headers:S,body:E});if(b.ok)return;if(b.status>=400&&b.status<500)return;throw Error(`HTTP ${b.status}`)}catch(b){if(i+=1,i>O)throw R=[...N,...R],O4(F,R),b;await new Promise((W4)=>{setTimeout(W4,w)}),w=Math.min(w*2,60000)}}async function _(){if(j||K)return K??void 0;let N=await o.flush();if(N.length>0)await o.clear();if(R=[...R,...N.map((S)=>U(S))],R.length===0)return;let E=R;return R=[],O4(F,R),K=L(E).catch(()=>{}).finally(()=>{K=null}),K}if($>0)V=setInterval(()=>{_().catch(()=>{})},$);return{async flushNow(){await _()},stop(){if(j=!0,V)clearInterval(V);V=null},pending(){return[...R]}}}var m8={async isAvailable(){if(!Q("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(Z){if(!Q("iap"))return[];let Y=Array.isArray(Z)?Z:[String(Z)];return await window.craft.iap.getProducts(Y)},async purchase(Z){if(!Q("iap"))return{queued:!1,productId:Z,reason:"IAP bridge not available"};let Y=await window.craft.iap.purchase(Z);return{queued:!!(Y&&Y.queued),productId:Y?.productId,reason:Y?.reason}},async restorePurchases(){if(!Q("iap"))return{ok:!1};let Z=await window.craft.iap.restorePurchases();return{ok:!!(Z&&Z.ok)}},async finishTransaction(Z){if(!Q("iap"))return;await window.craft.iap.finishTransaction(Z)},async getReceiptData(){if(!Q("iap"))return null;let Z=await window.craft.iap.getReceiptData();return Z?String(Z):null},onPurchased(Z){return P("craft:iap:purchased",Z)},onFailed(Z){return P("craft:iap:failed",Z)},onRestored(Z){return P("craft:iap:restored",Z)},onProductsLoaded(Z){return P("craft:iap:productsLoaded",(Y)=>Z(Y.products||[]))},onRefunded(Z){return P("craft:iap:refunded",Z)},onSubscriptionStatusChanged(Z){return P("craft:iap:subscriptionStatusChanged",Z)},async getActiveSubscriptions(){if(!Q("iap"))return[];let Z=window.craft.iap.getActiveSubscriptions;if(typeof Z!=="function")return[];let Y=await Z();return Array.isArray(Y)?Y:[]},async isEligibleForIntroOffer(Z){if(!Q("iap"))return!1;let Y=window.craft.iap.isEligibleForIntroOffer;if(typeof Y!=="function")return!1;return!!await Y(Z)}};var a={async startActivity(Z,Y){if(!Z)throw Error("handoff.startActivity: type is required");if(!Q("handoff"))return!1;let $=await window.craft.handoff.startActivity(Z,Y);return typeof $==="boolean"?$:!!($&&$.ok)},async updateActivity(Z){if(!Q("handoff"))return!1;let Y=await window.craft.handoff.updateActivity(Z);return typeof Y==="boolean"?Y:!!(Y&&Y.ok)},async stopActivity(){if(!Q("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!Q("handoff"))return null;let Z=await window.craft.handoff.getCurrentActivity();return Z&&typeof Z.type==="string"?Z:null},onIncoming(Z){return P("craft:handoff:incoming",Z)}};var h8={async start(Z,Y){return a.startActivity(Z,{title:Y?.title,webpageURL:Y?.webpageURL,userInfo:Y?.state})},async update(Z){return a.updateActivity({title:Z.title,webpageURL:Z.webpageURL,userInfo:Z.state})},async stop(){await a.stopActivity()}};var c8={async requestPermission(Z="whenInUse"){if(Q("location"))return await window.craft.location.requestPermission(Z);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(Q("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(Q("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(Q("location"))return await window.craft.location.startWatching(Z);if(typeof navigator<"u"&&navigator.geolocation){let Y=navigator.geolocation.watchPosition(($)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:$.coords.latitude,longitude:$.coords.longitude,altitude:$.coords.altitude,horizontalAccuracy:$.coords.accuracy,verticalAccuracy:$.coords.altitudeAccuracy,speed:$.coords.speed}}))});return window.__craftWebLocationWatchId=Y,!0}return!1},async stopWatching(){if(Q("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 P("craft:location:update",Z)},onError(Z){return P("craft:location:error",Z)},onAuthChanged(Z){return P("craft:location:authChanged",Z)}};var p8={async captureScreen(){if(!Q("screenCapture"))return null;let Z=await window.craft.screenCapture.captureScreen();return Z?String(Z):null},async captureWindow(Z){if(!Q("screenCapture"))return null;if(!Number.isFinite(Z)||Z<=0)throw Error("captureWindow: id must be a positive number");let Y=await window.craft.screenCapture.captureWindow(Z);return Y?String(Y):null},async listWindows(){if(!Q("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var V4=250,q4=60000,EZ=2000,j4={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function l8(){return{...j4,signals:{...j4.signals},sources:[]}}var XZ={async getState(){if(!Q("screenSharing"))return l8();return await window.craft.screenSharing.getState()},async watch(Z=EZ){let Y=Math.min(q4,Math.max(V4,Math.round(Z)));if(!Q("screenSharing"))return Y;let $=await window.craft.screenSharing.watch(Y);return $&&$.intervalMs||Y},async stop(){if(!Q("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(Z){return P("craft:screenSharing:change",Z)}};async function d8(Z,Y=EZ){let $=XZ.onChange(Z);return await XZ.watch(Y),()=>{$(),XZ.stop()}}var r8={supported:!1,isFocused:null,authorization:"unsupported"};function P4(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var AZ={async getStatus(){if(!Q("focus"))return{...r8};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!Q("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(Z,Y={}){if(!Q("focus"))return P4();if(!(Z?Y.onShortcut:Y.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${Z?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(Z,Y)},async runShortcut(Z){if(!Q("focus"))return P4();if(!Z)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(Z)},async listShortcuts(){if(!Q("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!Q("focus"))return{canList:!1,shortcuts:[]};let Z=await window.craft.focus.listShortcutsResult();return{canList:Boolean(Z?.canList),shortcuts:Z?.shortcuts||[]}}};async function n8(...Z){if(Z.length===0)return!1;let Y=new Set(await AZ.listShortcuts());return Z.every(($)=>Y.has($))}async function o8(...Z){if(Z.length===0)return!1;let{canList:Y,shortcuts:$}=await AZ.listShortcutsResult();if(!Y)return"unknown";let J=new Set($);return Z.every((G)=>J.has(G))}var a8={async start(Z=0,Y="127.0.0.1"){if(!Q("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(Z,Y)},async stop(){if(!Q("localServer"))return;await window.craft.localServer.stop()},async respond(Z){if(!Q("localServer"))return;await window.craft.localServer.respond(Z||{status:200,body:"OK"})},onRequest(Z){return P("craft:localServer:request",Z)},async awaitOAuthCallback(Z={}){M("localServer");let{port:Y=0,host:$="127.0.0.1",timeoutMs:J=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((O,z)=>{let F=setTimeout(()=>{R(),this.stop().catch(()=>{}),z(Error("localServer: OAuth callback timed out"))},J),R=this.onRequest(({url:j})=>{clearTimeout(F),R();let V=G??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
896
896
|
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
897
897
|
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
|
898
|
-
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:V,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),F({url:j,port:X.port})})})}};var n8={async isAvailable(){if(!G("biometric"))return!1;return await window.craft.biometric.isAvailable()},async getBiometryType(){if(!G("biometric"))return"none";return await window.craft.biometric.getBiometryType()},async evaluate(Z,Y){if(!Z)throw Error("biometric.evaluate: reason is required");if(!G("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(Z,Y)}};var k=null,o8={async play(Z,Y){if(G("audio"))return await window.craft.audio.play(Z,Y);if(typeof window>"u"||typeof Audio>"u")return!1;if(k)k.pause(),k=null;if(k=new Audio(Z),Y?.volume!=null)k.volume=Y.volume;if(Y?.loops)k.loop=!0;try{return await k.play(),!0}catch{return!1}},async playSystemSound(Z){if(G("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(G("audio")){await window.craft.audio.stop();return}if(k)k.pause(),k.currentTime=0,k=null},async isPlaying(){if(G("audio"))return await window.craft.audio.isPlaying();return!!(k&&!k.paused)},async startRecording(Z,Y){if(G("audio"))return await window.craft.audio.startRecording(Z,Y);return!1},async stopRecording(){if(G("audio"))await window.craft.audio.stopRecording()},async isRecording(){if(G("audio"))return await window.craft.audio.isRecording();return!1}};var a8={async execute(Z){if(!Z)throw Error("appleScript.execute: source is required");if(!G("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(Z)}};var i8={async getDefault(Z){if(!Z)throw Error("fileAssociations.getDefault: uti is required");if(!G("fileAssociations"))return null;let Y=await window.craft.fileAssociations.getDefault(Z);return Y?String(Y):null},async setDefault(Z,Y){if(!Z||!Y)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!G("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(Z,Y)}};var s8={async get(Z){if(!Z)throw Error("tags.get: path is required");if(!G("tags"))return[];return await window.craft.tags.get(Z)},async set(Z,Y){if(!Z)throw Error("tags.set: path is required");if(!G("tags"))return!1;let $=Array.isArray(Y)?Y:[String(Y)];return await window.craft.tags.set(Z,$)},async clear(Z){if(!Z)throw Error("tags.clear: path is required");if(!G("tags"))return!1;return await window.craft.tags.clear(Z)}};var t8={async countPages(Z){if(!Z)throw Error("pdf.countPages: path is required");if(!G("pdf"))return 0;return await window.craft.pdf.countPages(Z)},async extractText(Z){if(!Z)throw Error("pdf.extractText: path is required");if(!G("pdf"))return"";return await window.craft.pdf.extractText(Z)}};var e8={async debug(Z){if(G("log"))await window.craft.log.debug(Z);else console.debug(Z)},async info(Z){if(G("log"))await window.craft.log.info(Z);else console.info(Z)},async warn(Z){if(G("log"))await window.craft.log.warn(Z);else console.warn(Z)},async error(Z){if(G("log"))await window.craft.log.error(Z);else console.error(Z)}};var Z9={async browse(Z){if(!G("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(Z)},async stop(){if(G("bonjour"))await window.craft.bonjour.stop()},onFound(Z){return P("craft:bonjour:found",Z)},onLost(Z){return P("craft:bonjour:lost",Z)}};var Y9={async index(Z){if(!G("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(Z)},async remove(Z){if(!G("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(Z)},async removeAll(){if(!G("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var $9={async isAvailable(){if(!G("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(Z){if(!G("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(Z)},async stop(){if(G("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(Z){return P("craft:speechRecognition:partial",Z)},onFinal(Z){return P("craft:speechRecognition:final",Z)}};var J9={async recognizeText(Z){if(!Z)throw Error("vision.recognizeText: path is required");if(!G("vision"))return[];return await window.craft.vision.recognizeText(Z)},async detectFaces(Z){if(!Z)throw Error("vision.detectFaces: path is required");if(!G("vision"))return[];return await window.craft.vision.detectFaces(Z)},async detectBarcodes(Z){if(!Z)throw Error("vision.detectBarcodes: path is required");if(!G("vision"))return[];return await window.craft.vision.detectBarcodes(Z)}};var G9={async listSources(){if(!G("midi"))return[];return await window.craft.midi.listSources()},async listDestinations(){if(!G("midi"))return[];return await window.craft.midi.listDestinations()},async send(Z,Y){if(!G("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(Z,Y)},async subscribe(Z){if(!G("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(Z)},async unsubscribe(Z){if(!G("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(Z)},onMessage(Z){return P("craft:midi:message",Z)}};var Q9={async loadModel(Z,Y){if(!Z||!Y)throw Error("coreml.loadModel: id and path are required");if(!G("coreml"))return!1;return await window.craft.coreml.loadModel(Z,Y)},async unloadModel(Z){if(!G("coreml"))return;await window.craft.coreml.unloadModel(Z)},async predict(Z,Y){if(!Z)throw Error("coreml.predict: id is required");if(!G("coreml"))return null;return await window.craft.coreml.predict(Z,Y)}};var X9={async listCameras(){if(!G("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var z9={async register(Z){if(!Z)throw Error("serviceMenu.register: name is required");if(!G("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(!G("serviceMenu"))return;await window.craft.serviceMenu.unregister(Z)},onInvoked(Z){return P("craft:serviceMenu:invoked",Z)}};var R9={async list(){if(!G("serial"))return[];return await window.craft.serial.list()},async open(Z,Y=9600){if(!Z)throw Error("serial.open: path is required");if(!G("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(Z,Y)},async write(Z,Y){if(!Z)throw Error("serial.write: id is required");if(!G("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(Z,Y)},async close(Z){if(!G("serial"))return;await window.craft.serial.close(Z)},onData(Z){return P("craft:serial:data",Z)}};var q4=[{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 F9(){return q4.map(({name:Z,support:Y})=>({name:Z,support:Y,available:G(Z)}))}function P4(Z){let Y=q4.find(($)=>$.name===Z);if(!Y)return;return{...Y,available:G(Z)}}function O9(Z){let Y=P4(Z);return!!Y&&Y.available}export{P8 as windowEvents,c8 as watchScreenSharing,J9 as vision,q8 as updater,tZ as unregisterHotkey,c6 as unregisterAllHotkeys,vY as triggerTrayAction,k8 as touchbar,z8 as theme,s8 as tags,D8 as system,Y9 as spotlight,$9 as speechRecognition,I8 as speech,F4 as signPayload,A4 as showWarningToast,LY as showWarningModal,dY as showWarningDialog,p as showToast,E4 as showSuccessToast,_Y as showSuccessModal,mY as showSaveDialog,xZ as showQuestionModal,uY as showOpenDialog,u as showModal,l as showMessageBox,N4 as showInfoToast,HZ as showInfoModal,k4 as showErrorToast,MY as showErrorModal,lY as showErrorDialog,pY as showConfirmDialog,hY as showColorPicker,cY as showAlertDialog,RZ as showAlert,Q8 as shell,sY as setDesktopConfig,f6 as setAutoLaunch,z9 as serviceMenu,R9 as serial,XZ as screenSharing,m8 as screenCapture,L8 as screen,K6 as resolveCraftBinary,eY as resetDesktopConfig,D4 as requestNotificationPermission,h6 as registerHotkey,R4 as redactPII,EY as prompt,E8 as printing,_8 as permissions,t8 as pdf,iZ as parseShortcut,F6 as packageApp,R6 as pack,G6 as openDevWindow,H4 as notify,s6 as notifications,V8 as network,A8 as nativeAutoLaunch,G9 as midi,W8 as menu,e8 as log,u8 as location,r8 as localServer,b8 as liveActivities,M8 as keychain,X6 as isWebviewAvailable,O8 as isDragOutAvailable,P6 as isCaffeinated,O9 as isAvailable,v6 as isAutoLaunchEnabled,g8 as iap,l8 as hasFocusShortcuts,a as handoff,X8 as globalShortcuts,mZ as githubReleaseAssetUrl,uZ as githubLatestAssetUrl,z6 as getWindowBridgeScript,Y6 as getWindow,fY as getTrayInstance,gY as getTrayBridgeScript,yY as getSimulatedTrayHTML,p6 as getRegisteredHotkeys,rY as getDialogBridgeScript,tY as getDesktopConfig,P4 as getCapability,F9 as getCapabilities,U6 as getCaffeinateStatus,Z6 as getActiveWindowIds,BY as getActiveTrayInstances,AY as getActiveModalCount,I4 as getActiveAlertCount,gZ as generateUpdateManifest,e6 as fs,n6 as formatTime,g6 as formatShortcut,W6 as formatRemainingTime,D6 as formatDuration,o6 as formatCompact,d8 as focusShortcutsReady,NZ as focus,i8 as fileAssociations,F8 as dragOut,C4 as dismissAllAlerts,x4 as dismissAlertById,r6 as delay,K8 as deepLinks,cZ as decaffeinate,Q6 as createWindowWithHTML,J6 as createWindow,jY as createWebView,QY as createTreeView,s4 as createTooltip,l6 as createTimer,r4 as createTimePicker,B4 as createTextInput,m4 as createTabs,GY as createTable,fZ as createSystemTray,YY as createStepper,e4 as createSplitView,v4 as createSlider,t4 as createScrollView,c4 as createRating,p4 as createRadioButton,y4 as createProgressBar,H6 as createPreferences,$Y as createModalComponent,SY as createMenubar,FY as createMediaPlayer,JY as createListView,o4 as createLabel,d6 as createInterval,a4 as createImageView,j6 as createGitHubUpdater,V6 as createGitHubUpdateManifest,KY as createFileExplorer,h4 as createDropdown,d4 as createDatePicker,XY as createDataGrid,l4 as createColorPicker,RY as createCodeEditor,i4 as createChip,f4 as createCheckbox,zY as createChart,u4 as createCard,S4 as createButton,g4 as createBadge,b4 as createAvatar,n4 as createAutocomplete,ZY as createAccordion,o as crashReporter,jZ as craftWindowArguments,O6 as craftBinaryNotFoundMessage,Q9 as coreml,X9 as continuityCamera,TY as confirm,$6 as closeAllWindows,kY as closeAllModals,a6 as clipboard,q6 as caffeinate,Z9 as bonjour,C8 as bluetooth,n8 as biometric,j8 as battery,o8 as audio,a8 as appleScript,U8 as appInfo,NY as alert,bZ as UPDATE_MANIFEST_ASSET,bY as TRAY_MENU_STYLES,w4 as TOAST_STYLES,HY as MODAL_STYLES,K4 as MIN_WATCH_INTERVAL_MS,j4 as MAX_WATCH_INTERVAL_MS,TZ as DEFAULT_WATCH_INTERVAL_MS,qY as COMPONENT_STYLES,yZ as AutoUpdater,VY as AVAILABLE_COMPONENTS};
|
|
898
|
+
<script>setTimeout(()=>window.close(),1500)</script>`;this.respond({status:200,body:V,contentType:"text/html; charset=utf-8"}).catch(()=>{}).finally(()=>this.stop().catch(()=>{})),O({url:j,port:X.port})})})}};var i8={async isAvailable(){if(!Q("biometric"))return!1;return await window.craft.biometric.isAvailable()},async getBiometryType(){if(!Q("biometric"))return"none";return await window.craft.biometric.getBiometryType()},async evaluate(Z,Y){if(!Z)throw Error("biometric.evaluate: reason is required");if(!Q("biometric"))return{success:!1,errorCode:-1};return await window.craft.biometric.evaluate(Z,Y)}};var k=null,s8={async play(Z,Y){if(Q("audio"))return await window.craft.audio.play(Z,Y);if(typeof window>"u"||typeof Audio>"u")return!1;if(k)k.pause(),k=null;if(k=new Audio(Z),Y?.volume!=null)k.volume=Y.volume;if(Y?.loops)k.loop=!0;try{return await k.play(),!0}catch{return!1}},async playSystemSound(Z){if(Q("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(Q("audio")){await window.craft.audio.stop();return}if(k)k.pause(),k.currentTime=0,k=null},async isPlaying(){if(Q("audio"))return await window.craft.audio.isPlaying();return!!(k&&!k.paused)},async startRecording(Z,Y){if(Q("audio"))return await window.craft.audio.startRecording(Z,Y);return!1},async stopRecording(){if(Q("audio"))await window.craft.audio.stopRecording()},async isRecording(){if(Q("audio"))return await window.craft.audio.isRecording();return!1}};var t8={async execute(Z){if(!Z)throw Error("appleScript.execute: source is required");if(!Q("appleScript"))return{ok:!1};return await window.craft.appleScript.execute(Z)}};var e8={async getDefault(Z){if(!Z)throw Error("fileAssociations.getDefault: uti is required");if(!Q("fileAssociations"))return null;let Y=await window.craft.fileAssociations.getDefault(Z);return Y?String(Y):null},async setDefault(Z,Y){if(!Z||!Y)throw Error("fileAssociations.setDefault: uti and bundleId are required");if(!Q("fileAssociations"))return!1;return await window.craft.fileAssociations.setDefault(Z,Y)}};var Z9={async get(Z){if(!Z)throw Error("tags.get: path is required");if(!Q("tags"))return[];return await window.craft.tags.get(Z)},async set(Z,Y){if(!Z)throw Error("tags.set: path is required");if(!Q("tags"))return!1;let $=Array.isArray(Y)?Y:[String(Y)];return await window.craft.tags.set(Z,$)},async clear(Z){if(!Z)throw Error("tags.clear: path is required");if(!Q("tags"))return!1;return await window.craft.tags.clear(Z)}};var Y9={async countPages(Z){if(!Z)throw Error("pdf.countPages: path is required");if(!Q("pdf"))return 0;return await window.craft.pdf.countPages(Z)},async extractText(Z){if(!Z)throw Error("pdf.extractText: path is required");if(!Q("pdf"))return"";return await window.craft.pdf.extractText(Z)}};var $9={async debug(Z){if(Q("log"))await window.craft.log.debug(Z);else console.debug(Z)},async info(Z){if(Q("log"))await window.craft.log.info(Z);else console.info(Z)},async warn(Z){if(Q("log"))await window.craft.log.warn(Z);else console.warn(Z)},async error(Z){if(Q("log"))await window.craft.log.error(Z);else console.error(Z)}};var J9={async browse(Z){if(!Q("bonjour"))return{started:!1,reason:"bridge unavailable"};return await window.craft.bonjour.browse(Z)},async stop(){if(Q("bonjour"))await window.craft.bonjour.stop()},onFound(Z){return P("craft:bonjour:found",Z)},onLost(Z){return P("craft:bonjour:lost",Z)}};var Q9={async index(Z){if(!Q("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(Z)},async remove(Z){if(!Q("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(Z)},async removeAll(){if(!Q("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var G9={async isAvailable(){if(!Q("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(Z){if(!Q("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(Z)},async stop(){if(Q("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(Z){return P("craft:speechRecognition:partial",Z)},onFinal(Z){return P("craft:speechRecognition:final",Z)}};var X9={async recognizeText(Z){if(!Z)throw Error("vision.recognizeText: path is required");if(!Q("vision"))return[];return await window.craft.vision.recognizeText(Z)},async detectFaces(Z){if(!Z)throw Error("vision.detectFaces: path is required");if(!Q("vision"))return[];return await window.craft.vision.detectFaces(Z)},async detectBarcodes(Z){if(!Z)throw Error("vision.detectBarcodes: path is required");if(!Q("vision"))return[];return await window.craft.vision.detectBarcodes(Z)}};var z9={async listSources(){if(!Q("midi"))return[];return await window.craft.midi.listSources()},async listDestinations(){if(!Q("midi"))return[];return await window.craft.midi.listDestinations()},async send(Z,Y){if(!Q("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.send(Z,Y)},async subscribe(Z){if(!Q("midi"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.midi.subscribe(Z)},async unsubscribe(Z){if(!Q("midi"))return{ok:!1};return await window.craft.midi.unsubscribe(Z)},onMessage(Z){return P("craft:midi:message",Z)}};var F9={async loadModel(Z,Y){if(!Z||!Y)throw Error("coreml.loadModel: id and path are required");if(!Q("coreml"))return!1;return await window.craft.coreml.loadModel(Z,Y)},async unloadModel(Z){if(!Q("coreml"))return;await window.craft.coreml.unloadModel(Z)},async predict(Z,Y){if(!Z)throw Error("coreml.predict: id is required");if(!Q("coreml"))return null;return await window.craft.coreml.predict(Z,Y)}};var O9={async listCameras(){if(!Q("continuityCamera"))return[];return await window.craft.continuityCamera.listCameras()}};var R9={async register(Z){if(!Z)throw Error("serviceMenu.register: name is required");if(!Q("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(!Q("serviceMenu"))return;await window.craft.serviceMenu.unregister(Z)},onInvoked(Z){return P("craft:serviceMenu:invoked",Z)}};var K9={async list(){if(!Q("serial"))return[];return await window.craft.serial.list()},async open(Z,Y=9600){if(!Z)throw Error("serial.open: path is required");if(!Q("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(Z,Y)},async write(Z,Y){if(!Z)throw Error("serial.write: id is required");if(!Q("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(Z,Y)},async close(Z){if(!Q("serial"))return;await window.craft.serial.close(Z)},onData(Z){return P("craft:serial:data",Z)}};var U4=[{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 j9(){return U4.map(({name:Z,support:Y})=>({name:Z,support:Y,available:Q(Z)}))}function L4(Z){let Y=U4.find(($)=>$.name===Z);if(!Y)return;return{...Y,available:Q(Z)}}function V9(Z){let Y=L4(Z);return!!Y&&Y.available}export{W8 as windowEvents,d8 as watchScreenSharing,X9 as vision,L8 as updater,Z4 as unregisterHotkey,d6 as unregisterAllHotkeys,gY as triggerTrayAction,C8 as touchbar,R8 as theme,Z9 as tags,T8 as system,Q9 as spotlight,G9 as speechRecognition,B8 as speech,K4 as signPayload,H4 as showWarningToast,TY as showWarningModal,nY as showWarningDialog,p as showToast,k4 as showSuccessToast,NY as showSuccessModal,cY as showSaveDialog,IZ as showQuestionModal,hY as showOpenDialog,u as showModal,l as showMessageBox,A4 as showInfoToast,CZ as showInfoModal,x4 as showErrorToast,_Y as showErrorModal,rY as showErrorDialog,dY as showConfirmDialog,pY as showColorPicker,lY as showAlertDialog,FZ as showAlert,F8 as shell,eY as setDesktopConfig,g6 as setAutoLaunch,R9 as serviceMenu,K9 as serial,XZ as screenSharing,p8 as screenCapture,_8 as screen,q6 as resolveCraftBinary,Y6 as resetDesktopConfig,M4 as requestNotificationPermission,l6 as registerHotkey,R4 as redactPII,kY as prompt,H8 as printing,E8 as permissions,Y9 as pdf,tZ as parseShortcut,j6 as packageApp,K6 as pack,z6 as openDevWindow,C4 as notify,Z8 as notifications,U8 as network,x8 as nativeAutoLaunch,z9 as midi,M8 as menu,$9 as log,c8 as location,a8 as localServer,h8 as liveActivities,N8 as keychain,O6 as isWebviewAvailable,V8 as isDragOutAvailable,W6 as isCaffeinated,V9 as isAvailable,b6 as isAutoLaunchEnabled,m8 as iap,n8 as hasFocusShortcuts,a as handoff,O8 as globalShortcuts,cZ as githubReleaseAssetUrl,hZ as githubLatestAssetUrl,R6 as getWindowBridgeScript,Q6 as getWindow,yY as getTrayInstance,uY as getTrayBridgeScript,bY as getSimulatedTrayHTML,r6 as getRegisteredHotkeys,oY as getDialogBridgeScript,Z6 as getDesktopConfig,L4 as getCapability,j9 as getCapabilities,D6 as getCaffeinateStatus,J6 as getActiveWindowIds,vY as getActiveTrayInstances,HY as getActiveModalCount,w4 as getActiveAlertCount,uZ as generateUpdateManifest,$8 as fs,i6 as formatTime,m6 as formatShortcut,M6 as formatRemainingTime,T6 as formatDuration,s6 as formatCompact,o8 as focusShortcutsReady,AZ as focus,e8 as fileAssociations,j8 as dragOut,S4 as dismissAllAlerts,I4 as dismissAlertById,a6 as delay,q8 as deepLinks,lZ as decaffeinate,F6 as createWindowWithHTML,X6 as createWindow,qY as createWebView,zY as createTreeView,e4 as createTooltip,n6 as createTimer,o4 as createTimePicker,v4 as createTextInput,c4 as createTabs,XY as createTable,yZ as createSystemTray,JY as createStepper,YY as createSplitView,g4 as createSlider,ZY as createScrollView,l4 as createRating,d4 as createRadioButton,b4 as createProgressBar,I6 as createPreferences,QY as createModalComponent,fY as createMenubar,KY as createMediaPlayer,GY as createListView,i4 as createLabel,o6 as createInterval,s4 as createImageView,P6 as createGitHubUpdater,U6 as createGitHubUpdateManifest,VY as createFileExplorer,p4 as createDropdown,n4 as createDatePicker,FY as createDataGrid,r4 as createColorPicker,RY as createCodeEditor,t4 as createChip,y4 as createCheckbox,OY as createChart,h4 as createCard,f4 as createButton,u4 as createBadge,m4 as createAvatar,a4 as createAutocomplete,$Y as createAccordion,o as crashReporter,qZ as craftWindowArguments,V6 as craftBinaryNotFoundMessage,F9 as coreml,O9 as continuityCamera,EY as confirm,G6 as closeAllWindows,xY as closeAllModals,t6 as clipboard,L6 as caffeinate,J9 as bonjour,w8 as bluetooth,i8 as biometric,P8 as battery,s8 as audio,t8 as appleScript,D8 as appInfo,AY as alert,mZ as UPDATE_MANIFEST_ASSET,mY as TRAY_MENU_STYLES,B4 as TOAST_STYLES,CY as MODAL_STYLES,V4 as MIN_WATCH_INTERVAL_MS,q4 as MAX_WATCH_INTERVAL_MS,EZ as DEFAULT_WATCH_INTERVAL_MS,UY as COMPONENT_STYLES,bZ as AutoUpdater,PY as AVAILABLE_COMPONENTS};
|