2025-03-13 18:00:03 +00:00

7 lines
43 KiB
JavaScript

var H$=Object.defineProperty;var sF=(F,Q)=>{for(var $ in Q)H$(F,$,{get:Q[$],enumerable:!0,configurable:!0,set:(H)=>Q[$]=()=>H})};var CF="__DESTROY__";var qF=class{name="worker-child-io";messageQueue=[];resolveRead=null;constructor(){self.onmessage=this.handleMessage}handleMessage=(F)=>{let Q=F.data;if(Q===CF){this.destroy();return}if(this.resolveRead)this.resolveRead(Q),this.resolveRead=null;else this.messageQueue.push(Q)};async read(){if(this.messageQueue.length>0)return this.messageQueue.shift()??null;return new Promise((F)=>{this.resolveRead=F})}async write(F){self.postMessage(F)}destroy(){self.postMessage(CF),self.close()}signalDestroy(){self.postMessage(CF)}};function Y$(F,Q){if(Q instanceof Uint8Array)return{type:"Uint8Array",data:Array.from(Q)};return Q}function J$(F,Q){if(Q&&Q.type==="Uint8Array"&&Array.isArray(Q.data))return new Uint8Array(Q.data);return Q}function a(F){return JSON.stringify(F,Y$)+`
`}function tF(F){return new Promise((Q,$)=>{try{let H=JSON.parse(F,J$);Q(H)}catch(H){console.error("failed to parse message",typeof F,F,H),$(H)}})}function MF(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var h=class{constructor(F,Q){this.io=F,this.apiImplementation=Q?.expose,this.listen()}pendingRequests={};callbacks={};callbackCache=new Map;count=0;messageStr="";apiImplementation;expose(F){this.apiImplementation=F}getIO(){return this.io}async listen(){while(!0){let F=await this.io.read();if(!F)continue;let Q=F.toString("utf-8");if(Q.trim().length===0)continue;this.messageStr+=Q;let $=this.messageStr[this.messageStr.length-1],H=this.messageStr.split(`
`),M=$===`
`?H:H.slice(0,-1);this.messageStr=$===`
`?"":H.at(-1)??"";for(let w of M.map((O)=>O.trim()).filter(Boolean))if(w.startsWith("{"))this.handleMessageStr(w);else console.log("(kkrpc stdout passthrough):",w)}}async handleMessageStr(F){return this.count++,tF(F).then((Q)=>{if(Q.type==="response")this.handleResponse(Q);else if(Q.type==="request")this.handleRequest(Q);else if(Q.type==="callback")this.handleCallback(Q);else console.error("received unknown message type",Q,typeof Q)}).catch((Q)=>{console.log("(kkrpc stdout passthrough):",F)})}callMethod(F,Q){return new Promise(($,H)=>{let M=MF();this.pendingRequests[M]={resolve:$,reject:H};let w=[],O=Q.map((z)=>{if(typeof z==="function"){let T=this.callbackCache.get(z);if(!T)T=MF(),this.callbacks[T]=z,this.callbackCache.set(z,T);return w.push(T),`__callback__${T}`}return z}),X={id:M,method:F,args:O,type:"request",callbackIds:w.length>0?w:void 0};this.io.write(a(X))})}handleResponse(F){let{id:Q}=F,{result:$,error:H}=F.args;if(this.pendingRequests[Q]){if(H)this.pendingRequests[Q].reject(new Error(H));else this.pendingRequests[Q].resolve($);delete this.pendingRequests[Q]}}handleRequest(F){let{id:Q,method:$,args:H}=F,M=$.split(".");if(!this.apiImplementation)return;let w=this.apiImplementation;for(let T=0;T<M.length-1;T++)if(w=w[M[T]],!w){this.sendError(Q,`Method path ${$} not found at ${M[T]}`);return}let O=M[M.length-1],X=w[O];if(typeof X!=="function"){this.sendError(Q,`Method ${$} is not a function`);return}let z=H.map((T)=>{if(typeof T==="string"&&T.startsWith("__callback__")){let A=T.slice(12);return(...b)=>{this.invokeCallback(A,b)}}return T});try{let T=X.apply(w,z);Promise.resolve(T).then((A)=>{return this.sendResponse(Q,A)}).catch((A)=>this.sendError(Q,A.message))}catch(T){this.sendError(Q,T.message??T.toString())}}invokeCallback(F,Q){let $={id:MF(),method:F,args:Q,type:"callback"};this.io.write(a($))}handleCallback(F){let{method:Q,args:$}=F,H=this.callbacks[Q];if(H)H(...$);else console.error(`Callback with id ${Q} not found`)}sendResponse(F,Q){let $={id:F,method:"",args:{result:Q},type:"response"};this.io.write(a($))}sendError(F,Q){let $={id:F,method:"",args:{error:Q},type:"response"};this.io.write(a($))}createNestedProxy(F=[]){return new Proxy(()=>{},{get:(Q,$)=>{if(typeof $==="string"&&$!=="then")return this.createNestedProxy([...F,$]);return},apply:(Q,$,H)=>{let M=F.join(".");return this.callMethod(M,H)}})}getAPI(){return this.createNestedProxy()}freeCallbacks(){this.callbacks={},this.callbackCache.clear()}};function P(F,Q,$,H){if($==="a"&&!H)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?F!==Q||!H:!Q.has(F))throw new TypeError("Cannot read private member from an object whose class did not declare it");return $==="m"?H:$==="a"?H.call(F):H?H.value:Q.get(F)}function wF(F,Q,$,H,M){if(H==="m")throw new TypeError("Private method is not writable");if(H==="a"&&!M)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?F!==Q||!M:!Q.has(F))throw new TypeError("Cannot write private member to an object whose class did not declare it");return H==="a"?M.call(F,$):M?M.value=$:Q.set(F,$),$}var r,I,o,U$,eF="__TAURI_TO_IPC_KEY__";function aF(F,Q=!1){return window.__TAURI_INTERNALS__.transformCallback(F,Q)}class SF{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,()=>{}),I.set(this,0),o.set(this,[]),this.id=aF(({message:F,id:Q})=>{if(Q==P(this,I,"f")){P(this,r,"f").call(this,F),wF(this,I,P(this,I,"f")+1,"f");while(P(this,I,"f")in P(this,o,"f")){let $=P(this,o,"f")[P(this,I,"f")];P(this,r,"f").call(this,$),delete P(this,o,"f")[P(this,I,"f")],wF(this,I,P(this,I,"f")+1,"f")}}else P(this,o,"f")[Q]=F})}set onmessage(F){wF(this,r,F,"f")}get onmessage(){return P(this,r,"f")}[(r=new WeakMap,I=new WeakMap,o=new WeakMap,eF)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[eF]()}}U$=new WeakMap;var FQ;(function(F){F.WINDOW_RESIZED="tauri://resize",F.WINDOW_MOVED="tauri://move",F.WINDOW_CLOSE_REQUESTED="tauri://close-requested",F.WINDOW_DESTROYED="tauri://destroyed",F.WINDOW_FOCUS="tauri://focus",F.WINDOW_BLUR="tauri://blur",F.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",F.WINDOW_THEME_CHANGED="tauri://theme-changed",F.WINDOW_CREATED="tauri://window-created",F.WEBVIEW_CREATED="tauri://webview-created",F.DRAG_ENTER="tauri://drag-enter",F.DRAG_OVER="tauri://drag-over",F.DRAG_DROP="tauri://drag-drop",F.DRAG_LEAVE="tauri://drag-leave"})(FQ||(FQ={}));var QF;(function(F){F[F.Audio=1]="Audio",F[F.Cache=2]="Cache",F[F.Config=3]="Config",F[F.Data=4]="Data",F[F.LocalData=5]="LocalData",F[F.Document=6]="Document",F[F.Download=7]="Download",F[F.Picture=8]="Picture",F[F.Public=9]="Public",F[F.Video=10]="Video",F[F.Resource=11]="Resource",F[F.Temp=12]="Temp",F[F.AppConfig=13]="AppConfig",F[F.AppData=14]="AppData",F[F.AppLocalData=15]="AppLocalData",F[F.AppCache=16]="AppCache",F[F.AppLog=17]="AppLog",F[F.Desktop=18]="Desktop",F[F.Executable=19]="Executable",F[F.Font=20]="Font",F[F.Home=21]="Home",F[F.Runtime=22]="Runtime",F[F.Template=23]="Template"})(QF||(QF={}));var QQ;(function(F){F[F.Trace=1]="Trace",F[F.Debug=2]="Debug",F[F.Info=3]="Info",F[F.Warn=4]="Warn",F[F.Error=5]="Error"})(QQ||(QQ={}));function EF(F){return async function Q($,H){console.log("fetch",$,H);let M=H?.maxRedirections,w=H?.connectTimeout,O=H?.proxy;if(H!=null)delete H.maxRedirections,delete H.connectTimeout,delete H.proxy;let X=H?.signal,T=(H?.headers==null?[]:H.headers instanceof Headers?Array.from(H.headers.entries()):Array.isArray(H.headers)?H.headers:Object.entries(H.headers)).map(([G,c])=>[G,typeof c==="string"?c:c.toString()]),A=new Request($,H),b=await A.arrayBuffer(),e=b.byteLength!==0?Array.from(new Uint8Array(b)):null,y=await F.rawFetch({clientConfig:{method:A.method,url:A.url,headers:T,data:e,maxRedirections:M,connectTimeout:w,proxy:O}});X?.addEventListener("abort",()=>{F.fetchCancel(y)});let{status:BF,statusText:bF,url:PF,headers:j,rid:v}=await F.fetchSend(y),S=await F.fetchReadBody(v),ZF=new Response(S instanceof ArrayBuffer&&S.byteLength!==0?S:S instanceof Array&&S.length>0?new Uint8Array(S):null,{headers:j,status:BF,statusText:bF});return Object.defineProperty(ZF,"url",{value:PF}),ZF}}class $F{constructor(){this.eventListeners=Object.create(null)}addListener(F,Q){return this.on(F,Q)}removeListener(F,Q){return this.off(F,Q)}on(F,Q){if(F in this.eventListeners)this.eventListeners[F].push(Q);else this.eventListeners[F]=[Q];return this}once(F,Q){let $=(H)=>{this.removeListener(F,$),Q(H)};return this.addListener(F,$)}off(F,Q){if(F in this.eventListeners)this.eventListeners[F]=this.eventListeners[F].filter(($)=>$!==Q);return this}removeAllListeners(F){if(F)delete this.eventListeners[F];else this.eventListeners=Object.create(null);return this}emit(F,Q){if(F in this.eventListeners){let $=this.eventListeners[F];for(let H of $)H(Q);return!0}return!1}listenerCount(F){if(F in this.eventListeners)return this.eventListeners[F].length;return 0}prependListener(F,Q){if(F in this.eventListeners)this.eventListeners[F].unshift(Q);else this.eventListeners[F]=[Q];return this}prependOnceListener(F,Q){let $=(H)=>{this.removeListener(F,$),Q(H)};return this.prependListener(F,$)}}function IF(F){return{upload:(Q,$,H,M)=>F.upload(Q,$,H?H:void 0,M),download:(Q,$,H,M)=>F.download(Q,$,H?H:void 0,M)}}function $Q(F){return{onDragDrop:(Q)=>F.onDragDrop(Q),onDragEnter:(Q)=>F.onDragEnter(Q),onDragLeave:(Q)=>F.onDragLeave(Q),onDragOver:(Q)=>F.onDragOver(Q),onWindowBlur:(Q)=>F.onWindowBlur(Q),onWindowCloseRequested:(Q)=>F.onWindowCloseRequested(Q),onWindowFocus:(Q)=>F.onWindowFocus(Q)}}function HQ(F){return{BaseDirectory:QF,appCacheDir:F.appCacheDir,appConfigDir:F.appConfigDir,appDataDir:F.appDataDir,appLocalDataDir:F.appLocalDataDir,appLogDir:F.appLogDir,audioDir:F.audioDir,basename:F.basename,cacheDir:F.cacheDir,configDir:F.configDir,dataDir:F.dataDir,delimiter:F.delimiter,desktopDir:F.desktopDir,dirname:F.dirname,documentDir:F.documentDir,downloadDir:F.downloadDir,executableDir:F.executableDir,extname:F.extname,fontDir:F.fontDir,homeDir:F.homeDir,isAbsolute:F.isAbsolute,join:F.join,localDataDir:F.localDataDir,normalize:F.normalize,pictureDir:F.pictureDir,publicDir:F.publicDir,resolve:F.resolve,resolveResource:F.resolveResource,resourceDir:F.resourceDir,runtimeDir:F.runtimeDir,sep:F.sep,tempDir:F.tempDir,templateDir:F.templateDir,videoDir:F.videoDir,extensionDir:F.extensionDir,extensionSupportDir:F.extensionSupportDir}}class HF{pid;api;constructor(F,Q){this.pid=F,this.api=Q}async write(F){this.api.stdinWrite(F.toString(),this.pid)}kill(){return this.api.kill(this.pid)}}class kF extends $F{program;args;options;stdout=new $F;stderr=new $F;constructor(F,Q=[],$){super();this.program=F,this.args=typeof Q==="string"?[Q]:Q,this.options=$??{}}}class hF extends kF{api;constructor(F,Q=[],$,H){super(F,Q,H);this.api=$}async spawn(){let F=this.args;if(typeof F==="object")Object.freeze(F);return this.api.rawSpawn(this.program,F,this.options,(Q)=>{switch(Q.event){case"Error":this.emit("error",Q.payload);break;case"Terminated":this.emit("close",Q.payload);break;case"Stdout":this.stdout.emit("data",Q.payload);break;case"Stderr":this.stderr.emit("data",Q.payload);break}}).then(async(Q)=>{return await this.api.recordSpawnedProcess(Q),new HF(Q,this.api)})}async execute(){let F=this.args;if(typeof F==="object")Object.freeze(F);return this.api.execute(this.program,this.args,this.options)}}class _F extends kF{config;scriptPath;api;constructor(F,Q,$,H){super("deno",Q);this.config=$,this.scriptPath=F,this.api=H}execute(){return this.api.denoExecute(this.scriptPath,this.config,this.args)}spawn(){return this.api.denoRawSpawn(this.scriptPath,this.config,this.args,(F)=>{switch(F.event){case"Error":this.emit("error",F.payload);break;case"Terminated":this.emit("close",F.payload);break;case"Stdout":this.stdout.emit("data",F.payload);break;case"Stderr":this.stderr.emit("data",F.payload);break}}).then(async(F)=>{return console.log("spawned deno process",F),await this.api.recordSpawnedProcess(F),new HF(F,this.api)})}}class DF{readStream;childProcess;name="tauri-shell-stdio";constructor(F,Q){this.readStream=F;this.childProcess=Q}read(){return new Promise((F,Q)=>{this.readStream.on("data",($)=>{F($)})})}async write(F){return this.childProcess.write(F+`
`)}}function YQ(F){function Q(j,v=[],S){return new hF(j,v,F,S)}function $(j,v,S){return new _F(j,v,S,F)}async function H(j,v,S,ZF){let G=$(j,v,S),c=await G.spawn(),$$=new DF(G.stdout,c);return{rpcChannel:new h($$,{expose:ZF}),process:c,command:G}}function M(j){return Q("bash",["-c",j])}function w(j){return Q("powershell",["-Command",j])}function O(j){return Q("osascript",["-e",j])}function X(j){return Q("python",["-c",j])}function z(j){return Q("zsh",["-c",j])}function T(j){return Q("node",["-e",j])}async function A(j){return M(j).execute()}async function b(j){return w(j).execute()}async function e(j){return O(j).execute()}async function y(j){return X(j).execute()}async function BF(j){return z(j).execute()}async function bF(j){return T(j).execute()}function PF(){return F.likelyOnWindows()}return{open:F.open,killPid:F.killPid,makeBashScript:M,makePowershellScript:w,makeAppleScript:O,makePythonScript:X,makeZshScript:z,makeNodeScript:T,executeBashScript:A,executePowershellScript:b,executeAppleScript:e,executePythonScript:y,executeZshScript:BF,executeNodeScript:bF,hasCommand:F.hasCommand,likelyOnWindows:PF,createCommand:Q,createDenoCommand:$,Child:HF,TauriShellStdio:DF,createDenoRpcChannel:H,RPCChannel:h,whereIsCommand:F.whereIsCommand}}function JQ(F){return{message:(Q,$,H)=>F.message(Q,$,H?H:void 0),info:(Q,$,H)=>F.info(Q,$,H?H:void 0),success:(Q,$,H)=>F.success(Q,$,H?H:void 0),warning:(Q,$,H)=>F.warning(Q,$,H?H:void 0),error:(Q,$,H)=>F.error(Q,$,H?H:void 0)}}class zF{searchTerm="";highlightedListItemValue;onSearchTermChange(F){return this.searchTerm=F,Promise.resolve()}onActionSelected(F){return Promise.resolve()}onEnterPressedOnSearchBar(){return Promise.resolve()}onFilesDropped(F){return Promise.resolve()}onBeforeGoBack(){return Promise.resolve()}onListItemSelected(F){return Promise.resolve()}onListScrolledToBottom(){return Promise.resolve()}onHighlightedListItemChanged(F){return this.highlightedListItemValue=F,Promise.resolve()}onFormSubmit(F){return Promise.resolve()}}var fF;function Z$(F){return{lang:F?.lang??fF?.lang,message:F?.message,abortEarly:F?.abortEarly??fF?.abortEarly,abortPipeEarly:F?.abortPipeEarly??fF?.abortPipeEarly}}var M$;function w$(F){return M$?.get(F)}var z$;function x$(F){return z$?.get(F)}var O$;function W$(F,Q){return O$?.get(F)?.get(Q)}function l(F){let Q=typeof F;if(Q==="string")return`"${F}"`;if(Q==="number"||Q==="bigint"||Q==="boolean")return`${F}`;if(Q==="object"||Q==="function")return(F&&Object.getPrototypeOf(F)?.constructor?.name)??"null";return Q}function L(F,Q,$,H,M){let w=M&&"input"in M?M.input:$.value,O=M?.expected??F.expects??null,X=M?.received??l(w),z={kind:F.kind,type:F.type,input:w,expected:O,received:X,message:`Invalid ${Q}: ${O?`Expected ${O} but r`:"R"}eceived ${X}`,requirement:F.requirement,path:M?.path,issues:M?.issues,lang:H.lang,abortEarly:H.abortEarly,abortPipeEarly:H.abortPipeEarly},T=F.kind==="schema",A=M?.message??F.message??W$(F.reference,z.lang)??(T?x$(z.lang):null)??H.message??w$(z.lang);if(A!==void 0)z.message=typeof A==="function"?A(z):A;if(T)$.typed=!1;if($.issues)$.issues.push(z);else $.issues=[z]}function N(F){return{version:1,vendor:"valibot",validate(Q){return F["~run"]({value:Q},Z$())}}}function R$(F,Q){return Object.hasOwn(F,Q)&&Q!=="__proto__"&&Q!=="prototype"&&Q!=="constructor"}function ZQ(F,Q){let $=[...new Set(F)];if($.length>1)return`(${$.join(` ${Q} `)})`;return $[0]??"never"}var T$=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function yF(F){return{kind:"validation",type:"hex_color",reference:yF,async:!1,expects:null,requirement:T$,message:F,"~run"(Q,$){if(Q.typed&&!this.requirement.test(Q.value))L(this,"hex color",Q,$);return Q}}}function vF(F,Q){return{kind:"validation",type:"max_value",reference:vF,async:!1,expects:`<=${F instanceof Date?F.toJSON():l(F)}`,requirement:F,message:Q,"~run"($,H){if($.typed&&!($.value<=this.requirement))L(this,"value",$,H,{received:$.value instanceof Date?$.value.toJSON():l($.value)});return $}}}function lF(F,Q){return{kind:"validation",type:"min_value",reference:lF,async:!1,expects:`>=${F instanceof Date?F.toJSON():l(F)}`,requirement:F,message:Q,"~run"($,H){if($.typed&&!($.value>=this.requirement))L(this,"value",$,H,{received:$.value instanceof Date?$.value.toJSON():l($.value)});return $}}}function X$(F,Q,$){return typeof F.fallback==="function"?F.fallback(Q,$):F.fallback}function pF(F,Q,$){return typeof F.default==="function"?F.default(Q,$):F.default}function YF(){return{kind:"schema",type:"any",reference:YF,expects:"any",async:!1,get "~standard"(){return N(this)},"~run"(F){return F.typed=!0,F}}}function W(F,Q){return{kind:"schema",type:"array",reference:W,expects:"Array",async:!1,item:F,message:Q,get "~standard"(){return N(this)},"~run"($,H){let M=$.value;if(Array.isArray(M)){$.typed=!0,$.value=[];for(let w=0;w<M.length;w++){let O=M[w],X=this.item["~run"]({value:O},H);if(X.issues){let z={type:"array",origin:"value",input:M,key:w,value:O};for(let T of X.issues){if(T.path)T.path.unshift(z);else T.path=[z];$.issues?.push(T)}if(!$.issues)$.issues=X.issues;if(H.abortEarly){$.typed=!1;break}}if(!X.typed)$.typed=!1;$.value.push(X.value)}}else L(this,"type",$,H);return $}}}function K(F){return{kind:"schema",type:"boolean",reference:K,expects:"boolean",async:!1,message:F,get "~standard"(){return N(this)},"~run"(Q,$){if(typeof Q.value==="boolean")Q.typed=!0;else L(this,"type",Q,$);return Q}}}function p(F){return{kind:"schema",type:"date",reference:p,expects:"Date",async:!1,message:F,get "~standard"(){return N(this)},"~run"(Q,$){if(Q.value instanceof Date)if(!isNaN(Q.value))Q.typed=!0;else L(this,"type",Q,$,{received:'"Invalid Date"'});else L(this,"type",Q,$);return Q}}}function C(F,Q){let $=[];for(let H in F)if(`${+H}`!==H||typeof F[H]!=="string"||!Object.is(F[F[H]],+H))$.push(F[H]);return{kind:"schema",type:"enum",reference:C,expects:ZQ($.map(l),"|"),async:!1,enum:F,options:$,message:Q,get "~standard"(){return N(this)},"~run"(H,M){if(this.options.includes(H.value))H.typed=!0;else L(this,"type",H,M);return H}}}function gF(F){return{kind:"schema",type:"function",reference:gF,expects:"Function",async:!1,message:F,get "~standard"(){return N(this)},"~run"(Q,$){if(typeof Q.value==="function")Q.typed=!0;else L(this,"type",Q,$);return Q}}}function k(F){return{kind:"schema",type:"lazy",reference:k,expects:"unknown",async:!1,getter:F,get "~standard"(){return N(this)},"~run"(Q,$){return this.getter(Q.value)["~run"](Q,$)}}}function Y(F,Q){return{kind:"schema",type:"literal",reference:Y,expects:l(F),async:!1,literal:F,message:Q,get "~standard"(){return N(this)},"~run"($,H){if($.value===this.literal)$.typed=!0;else L(this,"type",$,H);return $}}}function R(F,Q){return{kind:"schema",type:"nullable",reference:R,expects:`(${F.expects} | null)`,async:!1,wrapped:F,default:Q,get "~standard"(){return N(this)},"~run"($,H){if($.value===null){if(this.default!==void 0)$.value=pF(this,$,H);if($.value===null)return $.typed=!0,$}return this.wrapped["~run"]($,H)}}}function V(F){return{kind:"schema",type:"number",reference:V,expects:"number",async:!1,message:F,get "~standard"(){return N(this)},"~run"(Q,$){if(typeof Q.value==="number"&&!isNaN(Q.value))Q.typed=!0;else L(this,"type",Q,$);return Q}}}function Z(F,Q){return{kind:"schema",type:"object",reference:Z,expects:"Object",async:!1,entries:F,message:Q,get "~standard"(){return N(this)},"~run"($,H){let M=$.value;if(M&&typeof M==="object"){$.typed=!0,$.value={};for(let w in this.entries){let O=this.entries[w];if(w in M||(O.type==="exact_optional"||O.type==="optional"||O.type==="nullish")&&O.default!==void 0){let X=w in M?M[w]:pF(O),z=O["~run"]({value:X},H);if(z.issues){let T={type:"object",origin:"value",input:M,key:w,value:X};for(let A of z.issues){if(A.path)A.path.unshift(T);else A.path=[T];$.issues?.push(A)}if(!$.issues)$.issues=z.issues;if(H.abortEarly){$.typed=!1;break}}if(!z.typed)$.typed=!1;$.value[w]=z.value}else if(O.fallback!==void 0)$.value[w]=X$(O);else if(O.type!=="exact_optional"&&O.type!=="optional"&&O.type!=="nullish"){if(L(this,"key",$,H,{input:void 0,expected:`"${w}"`,path:[{type:"object",origin:"key",input:M,key:w,value:M[w]}]}),H.abortEarly)break}}}else L(this,"type",$,H);return $}}}function U(F,Q){return{kind:"schema",type:"optional",reference:U,expects:`(${F.expects} | undefined)`,async:!1,wrapped:F,default:Q,get "~standard"(){return N(this)},"~run"($,H){if($.value===void 0){if(this.default!==void 0)$.value=pF(this,$,H);if($.value===void 0)return $.typed=!0,$}return this.wrapped["~run"]($,H)}}}function D(F,Q,$){return{kind:"schema",type:"record",reference:D,expects:"Object",async:!1,key:F,value:Q,message:$,get "~standard"(){return N(this)},"~run"(H,M){let w=H.value;if(w&&typeof w==="object"){H.typed=!0,H.value={};for(let O in w)if(R$(w,O)){let X=w[O],z=this.key["~run"]({value:O},M);if(z.issues){let A={type:"object",origin:"key",input:w,key:O,value:X};for(let b of z.issues)b.path=[A],H.issues?.push(b);if(!H.issues)H.issues=z.issues;if(M.abortEarly){H.typed=!1;break}}let T=this.value["~run"]({value:X},M);if(T.issues){let A={type:"object",origin:"value",input:w,key:O,value:X};for(let b of T.issues){if(b.path)b.path.unshift(A);else b.path=[A];H.issues?.push(b)}if(!H.issues)H.issues=T.issues;if(M.abortEarly){H.typed=!1;break}}if(!z.typed||!T.typed)H.typed=!1;if(z.typed)H.value[z.value]=T.value}}else L(this,"type",H,M);return H}}}function J(F){return{kind:"schema",type:"string",reference:J,expects:"string",async:!1,message:F,get "~standard"(){return N(this)},"~run"(Q,$){if(typeof Q.value==="string")Q.typed=!0;else L(this,"type",Q,$);return Q}}}function UQ(F){let Q;if(F)for(let $ of F)if(Q)Q.push(...$.issues);else Q=$.issues;return Q}function x(F,Q){return{kind:"schema",type:"union",reference:x,expects:ZQ(F.map(($)=>$.expects),"|"),async:!1,options:F,message:Q,get "~standard"(){return N(this)},"~run"($,H){let M,w,O;for(let X of this.options){let z=X["~run"]({value:$.value},H);if(z.typed)if(z.issues)if(w)w.push(z);else w=[z];else{M=z;break}else if(O)O.push(z);else O=[z]}if(M)return M;if(w){if(w.length===1)return w[0];L(this,"type",$,H,{issues:UQ(w)}),$.typed=!0}else if(O?.length===1)return O[0];else L(this,"type",$,H,{issues:UQ(O)});return $}}}function mF(...F){return{...F[0],pipe:F,get "~standard"(){return N(this)},"~run"(Q,$){for(let H of F)if(H.kind!=="metadata"){if(Q.issues&&(H.kind==="schema"||H.kind==="transformation")){Q.typed=!1;break}if(!Q.issues||!$.abortEarly&&!$.abortPipeEarly)Q=H["~run"](Q,$)}return Q}}}var _;((G)=>{G.List="List";G.ListItem="ListItem";G.ListItemDetail="ListItemDetail";G.ListItemAccessory="ListItemAccessory";G.ListSection="ListSection";G.ListItemDetailMetadata="ListItemDetailMetadata";G.ListItemDetailMetadataLabel="ListItemDetailMetadataLabel";G.ListItemDetailMetadataLink="ListItemDetailMetadataLink";G.ListItemDetailMetadataTagList="ListItemDetailMetadataTagList";G.ListItemDetailMetadataTagListItem="ListItemDetailMetadataTagListItem";G.ListItemDetailMetadataSeparator="ListItemDetailMetadataSeparator";G.Icon="Icon";G.EmptyView="EmptyView";G.Dropdown="Dropdown";G.DropdownSection="DropdownSection";G.DropdownItem="DropdownItem";G.ActionPanel="ActionPanel";G.Action="Action";G.ActionPanelSection="ActionPanelSection";G.ActionPanelSubmenu="ActionPanelSubmenu";G.Markdown="Markdown"})(_||={});var q=C(_),OF;((z)=>{z.Base="Base";z.Number="Number";z.Select="Select";z.Boolean="Boolean";z.Input="Input";z.Date="Date";z.Array="Array";z.Form="Form"})(OF||={});var JF=C(OF);var WF;((w)=>{w.Iconify="iconify";w.RemoteUrl="remote-url";w.Svg="svg";w.Base64PNG="base64-png";w.Text="text"})(WF||={});var MQ=C(WF),wQ=Z({type:MQ,value:J(),invert:U(K()),darkInvert:U(K()),hexColor:U(J()),bgColor:U(J())}),B=Z({...wQ.entries,fallback:U(k(()=>B))}),V$=Z({...wQ.entries,nodeName:q,fallback:U(k(()=>B))});var n=mF(J(),yF()),v1=Z({top:U(V()),right:U(V()),bottom:U(V()),left:U(V())}),l1=x([Y("light"),Y("dark"),Y("auto")]),p1=x([Y("zinc"),Y("slate"),Y("stone"),Y("gray"),Y("neutral"),Y("red"),Y("rose"),Y("orange"),Y("green"),Y("blue"),Y("yellow"),Y("violet")]),g1=mF(V(),lF(0),vF(1));var K$=Z({nodeName:q,icon:U(B),title:J(),value:J()}),uF=Z({nodeName:q,title:U(J()),items:W(x([K$]))});var RF=Z({nodeName:q,content:J()});var RY=Z({nodeName:q,title:U(J()),description:U(J()),icon:U(B)}),j$=Z({nodeName:q,title:J(),value:J(),icon:U(B),keywords:U(W(J()))}),A$=Z({nodeName:q,title:J(),items:W(j$)}),TY=Z({nodeName:q,tooltip:J(),sections:W(A$),defaultValue:J()}),G$=Z({nodeName:q,tag:U(x([J(),Z({color:n,text:J()})])),text:U(x([J(),Z({color:n,text:J()})])),date:U(x([p(),Z({color:n,text:p()})])),icon:U(B),tooltip:U(J())}),L$=Z({nodeName:Y("ListItemDetailMetadataLabel"),title:J(),icon:U(B),text:U(x([J(),Z({color:n,text:J()})]))}),N$=Z({nodeName:Y("ListItemDetailMetadataLink"),title:J(),text:J(),url:J()}),B$=Z({nodeName:Y("ListItemDetailMetadataTagListItem"),text:U(J()),color:U(n)}),b$=Z({nodeName:Y("ListItemDetailMetadataTagList"),title:J(),tags:W(B$)}),P$=Z({nodeName:Y("ListItemDetailMetadataSeparator")}),C$=x([L$,N$,b$,P$]),q$=Z({nodeName:Y("ListItemDetailMetadata"),items:W(C$)}),S$=Z({nodeName:Y("ListItemDetail"),children:W(x([RF,q$])),width:U(V())}),xQ=Z({nodeName:Y("ListItem"),title:J(),subTitle:U(J()),accessories:U(W(G$)),value:J(),defaultAction:U(J()),actions:U(uF),icon:U(B),keywords:U(W(J()))}),E$=Z({nodeName:Y("ListSection"),title:U(J()),subtitle:U(J()),items:W(xQ)}),I$=x([Y("items"),Y("detail"),Y("filter"),Y("sections"),Y("actions"),Y("defaultAction")]),XY=Z({nodeName:Y("List"),sections:U(W(E$)),items:U(W(xQ)),filter:x([Y("none"),Y("default")]),detail:U(S$),actions:U(uF),defaultAction:U(J()),inherits:U(W(I$))});var D$=x([Y("color"),Y("date"),Y("datetime-local"),Y("month"),Y("number"),Y("password"),Y("text"),Y("url"),Y("week"),Y("time"),Y("search")]),i=Z({nodeName:JF,key:J(),label:U(J()),hideLabel:U(K()),placeholder:U(J()),optional:U(K()),description:U(J()),default:U(YF())}),OQ=Z({...i.entries,type:U(D$),component:U(x([Y("textarea"),Y("default")])),default:U(J())}),WQ=Z({...i.entries,nodeName:JF,default:U(V())}),RQ=Z({...i.entries,options:W(J()),default:U(J())}),TQ=Z({...i.entries,component:U(x([Y("checkbox"),Y("switch")]))}),XQ=Z({...i.entries,default:U(J())}),k$=x([OQ,WQ,RQ,TQ,XQ]),h$=Z({...i.entries,content:k$}),_$=x([h$,RQ,OQ,WQ,TQ,XQ]),f$=Z({nodeName:JF,key:J(),showFormDataDebug:U(K()),fields:W(x([k(()=>f$),_$])),title:U(J()),description:U(J()),submitBtnText:U(J())});class d{nodeName="Icon";type;value;invert;darkInvert;hexColor;bgColor;constructor(F){this.type=F.type,this.value=F.value,this.invert=F.invert,this.darkInvert=F.darkInvert,this.hexColor=F.hexColor,this.bgColor=F.bgColor}toModel(){return{nodeName:this.nodeName,type:this.type,value:this.value,invert:this.invert,darkInvert:this.darkInvert,hexColor:this.hexColor,bgColor:this.bgColor}}}var E={};sF(E,{Section:()=>IQ,List:()=>DQ,ItemDetailMetadataTagListItem:()=>bQ,ItemDetailMetadataTagList:()=>PQ,ItemDetailMetadataSeparator:()=>CQ,ItemDetailMetadataLink:()=>BQ,ItemDetailMetadataLabel:()=>NQ,ItemDetailMetadata:()=>qQ,ItemDetail:()=>SQ,ItemAccessory:()=>LQ,Item:()=>EQ,EmptyView:()=>KQ,DropdownSection:()=>AQ,DropdownItem:()=>jQ,Dropdown:()=>GQ});class KQ{nodeName="EmptyView";title;description;icon;constructor(F){this.title=F.title,this.description=F.description,this.icon=F.icon}toModel(){return{nodeName:this.nodeName,title:this.title,description:this.description,icon:this.icon?.toModel()}}}class jQ{nodeName="DropdownItem";title;value;icon;keywords;constructor(F){this.title=F.title,this.value=F.value,this.icon=F.icon,this.keywords=F.keywords}toModel(){return{nodeName:this.nodeName,title:this.title,value:this.value,icon:this.icon?.toModel(),keywords:this.keywords}}}class AQ{nodeName="DropdownSection";title;items;constructor(F){this.title=F.title,this.items=F.items}toModel(){return{nodeName:this.nodeName,title:this.title,items:this.items.map((F)=>F.toModel())}}}class GQ{nodeName="Dropdown";tooltip;sections;defaultValue;constructor(F){this.tooltip=F.tooltip,this.sections=F.sections,this.defaultValue=F.defaultValue}toModel(){return{nodeName:this.nodeName,tooltip:this.tooltip,sections:this.sections.map((F)=>F.toModel()),defaultValue:this.defaultValue}}}class LQ{nodeName="ListItemAccessory";tag;text;date;icon;tooltip;constructor(F){this.tag=F.tag,this.text=F.text,this.date=F.date,this.icon=F.icon,this.tooltip=F.tooltip}toModel(){return{nodeName:this.nodeName,tag:this.tag,text:this.text,date:this.date,icon:this.icon?.toModel(),tooltip:this.tooltip}}}class NQ{nodeName="ListItemDetailMetadataLabel";title;icon;text;constructor(F){this.title=F.title,this.icon=F.icon,this.text=F.text}toModel(){return{nodeName:this.nodeName,title:this.title,icon:this.icon?.toModel(),text:this.text}}}class BQ{nodeName="ListItemDetailMetadataLink";title;text;url;constructor(F){this.title=F.title,this.text=F.text,this.url=F.url}toModel(){return{nodeName:this.nodeName,title:this.title,text:this.text,url:this.url}}}class bQ{nodeName="ListItemDetailMetadataTagListItem";text;color;icon;constructor(F){this.text=F.text,this.color=F.color,this.icon=F.icon}toModel(){return{nodeName:this.nodeName,text:this.text,color:this.color}}}class PQ{nodeName="ListItemDetailMetadataTagList";title;tags;constructor(F){this.title=F.title,this.tags=F.tags}toModel(){return{nodeName:this.nodeName,title:this.title,tags:this.tags.map((F)=>F.toModel())}}}class CQ{nodeName="ListItemDetailMetadataSeparator";toModel(){return{nodeName:this.nodeName}}}class qQ{nodeName="ListItemDetailMetadata";items;constructor(F){this.items=F}toModel(){return{nodeName:this.nodeName,items:this.items.map((F)=>F.toModel())}}}class SQ{nodeName="ListItemDetail";children;width;constructor(F){this.children=F.children,this.width=F.width}toModel(){return{nodeName:this.nodeName,children:this.children.map((F)=>F.toModel()),width:this.width}}}class EQ{nodeName="ListItem";title;value;subTitle;accessories;icon;keywords;defaultAction;actions;constructor(F){this.title=F.title,this.value=F.value,this.actions=F.actions,this.defaultAction=F.defaultAction,this.subTitle=F.subTitle,this.accessories=F.accessories,this.icon=F.icon,this.keywords=F.keywords}toModel(){return{nodeName:this.nodeName,title:this.title,value:this.value,defaultAction:this.defaultAction,actions:this.actions?.toModel(),subTitle:this.subTitle,accessories:this.accessories?.map((F)=>F.toModel()),icon:this.icon?.toModel(),keywords:this.keywords}}}class IQ{nodeName="ListSection";title;items;constructor(F){this.title=F.title,this.items=F.items}toModel(){return{nodeName:this.nodeName,title:this.title,items:this.items.map((F)=>F.toModel())}}}class DQ{nodeName="List";sections;items;detail;filter;inherits;actions;defaultAction;constructor(F){this.sections=F.sections,this.items=F.items,this.detail=F.detail,this.filter=F.filter??"default",this.inherits=F.inherits??[],this.actions=F.actions,this.defaultAction=F.defaultAction}toModel(){return{nodeName:this.nodeName,sections:this.sections?.map((F)=>F.toModel()),items:this.items?.map((F)=>F.toModel()),filter:this.filter,detail:this.detail?.toModel(),inherits:this.inherits,actions:this.actions?.toModel(),defaultAction:this.defaultAction}}}var g={};sF(g,{ActionPanel:()=>hQ,Action:()=>kQ});class kQ{nodeName="Action";icon;title;value;constructor(F){this.icon=F.icon,this.title=F.title,this.value=F.value}toModel(){return{nodeName:this.nodeName,title:this.title,value:this.value,icon:this.icon}}}class hQ{nodeName="ActionPanel";title;items;constructor(F){this.title=F.title,this.items=F.items}toModel(){return{nodeName:this.nodeName,title:this.title,items:this.items.map((F)=>F.toModel())}}}var EY=Z({name:J(),icon_path:R(J()),app_path_exe:R(J()),app_desktop_path:J()});var hY=D(J("Window label"),Z({path:J("Path to the extension"),processes:W(V()),dist:U(R(J()))})),_Y=Z({extId:V(),identifier:J(),version:J(),enabled:K(),installed_at:J(),path:R(J()),data:R(YF())}),_Q;((X)=>{X.HeadlessWorker="headless_worker";X.Builtin="builtin";X.System="system";X.UiWorker="ui_worker";X.UiIframe="ui_iframe";X.QuickLink="quick_link";X.Remote="remote"})(_Q||={});var f=C(_Q),y$=Z({cmdId:V(),extId:V(),name:J(),type:f,data:J(),alias:R(U(J())),hotkey:R(U(J())),enabled:K()}),fY=Z({...y$.entries,data:Z({link:J(),icon:B})}),yY=Z({dataId:V(),extId:V(),dataType:J(),data:U(J()),searchText:U(J()),createdAt:p(),updatedAt:p()}),vY=Z({name:J(),value:J(),icon:R(B),keywords:R(W(J())),function:gF(),confirmRequired:K()});var fQ;(($)=>{$.Asc="ASC";$.Desc="DESC"})(fQ||={});var gY=C(fQ),yQ;((H)=>{H.ExactMatch="exact_match";H.Like="like";H.FTS="fts"})(yQ||={});var mY=C(yQ);var TF=x([Y("clipboard:read-all"),Y("clipboard:write-all"),Y("clipboard:read-text"),Y("clipboard:write-text"),Y("clipboard:read-image"),Y("clipboard:write-image"),Y("clipboard:read-files"),Y("clipboard:write-files")]),XF=x([Y("dialog:all")]),VF=x([Y("notification:all")]),KF=x([Y("fs:read"),Y("fs:write"),Y("fs:exists")]),jF=Y("os:all"),vQ=x([Y("shell:open"),Y("shell:execute"),Y("shell:kill-any")]),AF=Y("fetch:all"),GF=x([Y("system-info:all"),Y("system-info:memory"),Y("system-info:cpu"),Y("system-info:os"),Y("system-info:disk"),Y("system-info:network"),Y("system-info:battery"),Y("system-info:process"),Y("system-info:components")]),LF=x([Y("network:interface"),Y("network:port")]),NF=x([Y("updownload:download"),Y("updownload:upload")]),v$=x([TF,XF,VF,KF,jF,vQ,AF,GF,LF,NF]);var rF={readText:["clipboard:read-text","clipboard:read-all"],writeText:["clipboard:write-text","clipboard:write-all"],readImageBase64:["clipboard:read-all","clipboard:read-image"],readImageBinary:["clipboard:read-all","clipboard:read-image"],writeImageBase64:["clipboard:write-all","clipboard:write-image"],writeImageBinary:["clipboard:write-all","clipboard:write-image"],readFiles:["clipboard:read-all","clipboard:read-files"],writeFiles:["clipboard:write-all","clipboard:write-files"],readRtf:["clipboard:read-all","clipboard:read-text"],writeRtf:["clipboard:write-all","clipboard:write-text"],readHtml:["clipboard:read-all","clipboard:read-text"],writeHtml:["clipboard:write-all","clipboard:write-text"],writeHtmlAndText:["clipboard:write-all","clipboard:write-text"],hasText:[],hasRTF:[],hasHTML:[],hasImage:[],hasFiles:[]};var r$=x([TF,Y("clipboard:paste")]),lQ=x([Y("system:volumn"),Y("system:boot"),Y("system:disk"),Y("system:apps"),Y("system:fs"),Y("system:ui")]),pQ=x([KF,Y("fs:read-dir"),Y("fs:stat"),Y("fs:search")]),o$=x([Y("event:drag-drop"),Y("event:drag-enter"),Y("event:drag-leave"),Y("event:drag-over"),Y("event:window-blur"),Y("event:window-close-requested"),Y("event:window-focus")]),n$=x([Y("security:mac:reveal-security-pane"),Y("security:mac:verify-fingerprint"),Y("security:mac:reset-screencapture-permission"),Y("security:mac:request-permission"),Y("security:mac:check-permission"),Y("security:mac:all")]),i$=x([Y("hostname"),Y("osRelease"),Y("osUptime"),Y("loadavg"),Y("networkInterfaces"),Y("systemMemoryInfo"),Y("uid"),Y("gid"),Y("cpus"),J()]),d$=Z({net:U(x([Y("*"),W(J())])),env:U(x([Y("*"),W(J())])),read:U(x([Y("*"),W(J())])),write:U(x([Y("*"),W(J())])),run:U(x([Y("*"),W(J())])),ffi:U(x([Y("*"),W(J())])),sys:U(x([Y("*"),W(i$)]))}),s=Z({path:U(J()),url:U(J()),cmd:U(Z({program:J(),args:W(J())})),...d$.entries}),gQ=Z({permission:pQ,allow:U(W(s)),deny:U(W(s))}),mQ=x([Y("open:url"),Y("open:file"),Y("open:folder")]),uQ=Z({permission:mQ,allow:U(W(s)),deny:U(W(s))}),cQ=x([Y("shell:execute"),Y("shell:deno:execute"),Y("shell:spawn"),Y("shell:deno:spawn"),Y("shell:open"),Y("shell:kill"),Y("shell:kill-any"),Y("shell:all"),Y("shell:stdin-write")]),rQ=Z({permission:cQ,allow:U(W(s)),deny:U(W(s))}),oF=x([r$,o$,XF,VF,jF,cQ,AF,GF,LF,NF,lQ,n$]),s$=x([oF,pQ,mQ]);var U8={...rF,paste:["clipboard:paste"]};var nF;((H)=>{H.linux="linux";H.macos="macos";H.windows="windows"})(nF||={});var t$=C(nF),oQ=Object.values(nF),e$=Z({type:x([Y("text"),Y("regex")]),value:J()}),iQ;((H)=>{H.visible="visible";H.transparent="transparent";H.overlay="overlay"})(iQ||={});var a$=C(iQ),dQ=Z({center:U(R(K())),x:U(R(V())),y:U(R(V())),width:U(R(V())),height:U(R(V())),minWidth:U(R(V())),minHeight:U(R(V())),maxWidth:U(R(V())),maxHeight:U(R(V())),resizable:U(R(K())),title:U(R(J())),fullscreen:U(R(K())),focus:U(R(K())),transparent:U(R(K())),maximized:U(R(K())),visible:U(R(K())),decorations:U(R(K())),alwaysOnTop:U(R(K())),alwaysOnBottom:U(R(K())),contentProtected:U(R(K())),skipTaskbar:U(R(K())),shadow:U(R(K())),titleBarStyle:U(R(a$)),hiddenTitle:U(R(K())),tabbingIdentifier:U(R(J())),maximizable:U(R(K())),minimizable:U(R(K())),closable:U(R(K())),parent:U(R(J())),visibleOnAllWorkspaces:U(R(K()))}),iF=Z({main:J("HTML file to load, e.g. dist/index.html"),description:U(R(J("Description of the Command"),""),""),name:J("Name of the command"),cmds:W(e$,"Commands to trigger the UI"),icon:U(B),platforms:U(R(W(t$,"Platforms available on. Leave empty for all platforms."),oQ),oQ)}),FH=Z({...iF.entries,type:U(f,f.enum.UiIframe),dist:J("Dist folder to load, e.g. dist, build, out"),devMain:J("URL to load in development to support live reload, e.g. http://localhost:5173/"),window:U(R(dQ))}),QH=Z({...iF.entries,type:U(f,f.enum.UiWorker),window:U(R(dQ))}),$H=Z({...iF.entries,type:U(f,f.enum.HeadlessWorker)}),HH=x([oF,gQ,uQ,rQ]),YH=Z({name:J("Name of the extension (Human Readable)"),shortDescription:J("Description of the extension (Will be displayed in store)"),longDescription:J("Long description of the extension (Will be displayed in store)"),identifier:J("Unique identifier for the extension, must be the same as extension folder name"),icon:B,permissions:W(HH,"Permissions Declared by the extension. e.g. clipboard-all. Not declared APIs will be blocked."),demoImages:W(J("Demo images for the extension")),customUiCmds:U(W(FH,"Custom UI Commands")),templateUiCmds:U(W(QH,"Template UI Commands")),headlessCmds:U(W($H,"Headless Commands"))}),nQ=x([Z({name:J("GitHub Username"),email:U(R(J("Email of the person"))),url:U(R(J("URL of the person")))}),J("GitHub Username")]),JH=x([Y("AGPL-3.0-only"),Y("Apache-2.0"),Y("BSD-2-Clause"),Y("BSD-3-Clause"),Y("BSL-1.0"),Y("CC0-1.0"),Y("CDDL-1.0"),Y("CDDL-1.1"),Y("EPL-1.0"),Y("EPL-2.0"),Y("GPL-2.0-only"),Y("GPL-3.0-only"),Y("ISC"),Y("LGPL-2.0-only"),Y("LGPL-2.1-only"),Y("LGPL-2.1-or-later"),Y("LGPL-3.0-only"),Y("LGPL-3.0-or-later"),Y("MIT"),Y("MPL-2.0"),Y("MS-PL"),Y("UNLICENSED")]),UH=Z({name:J("Package name for the extension (just a regular npm package name)"),version:J("Version of the extension"),readme:U(J("Custom README.md path of the extension")),license:JH,author:U(nQ),draft:U(K("Whether the extension is a draft, draft will not be published")),contributors:U(W(nQ,"Contributors of the extension")),repository:U(x([J("URL of the repository"),Z({type:J("Type of the repository"),url:J("URL of the repository"),directory:U(J("Directory of the repository"))})])),dependencies:U(D(J(),J())),kunkun:YH,files:U(W(J("Files to include in the extension. e.g. ['dist']")))}),K8=Z({...UH.entries,...{extPath:J(),extFolderName:J()}});var ZH=Z({addresses:W(J()),fullname:J(),hostname:J(),port:V(),service_type:J(),subType:U(J()),properties:U(D(J(),J())),publicKey:J(),sslCert:J()}),G8=D(J(),ZH);var sQ=Z({filename:J(),fileSize:V(),id:J(),type:V(),children:W(k(()=>sQ))}),N8=Z({port:J(),code:J(),totalBytes:V(),totalFiles:V(),sslCert:J(),root:k(()=>sQ),ip:J()}),B8=Z({code:J(),idPathMap:D(J(),J())});class m{nodeName="Base";key;label;hideLabel;placeholder;optional;description;default;constructor(F){this.key=F.key,this.key=F.key,this.label=F.label,this.hideLabel=F.hideLabel,this.placeholder=F.placeholder,this.optional=F.optional,this.description=F.description,this.default=F.default}toModel(){return{nodeName:this.nodeName,key:this.key,label:this.label,hideLabel:this.hideLabel,placeholder:this.placeholder,optional:this.optional,description:this.description,default:this.default}}}class MH extends m{nodeName="Input";component;constructor(F){super(F);this.component=F.component}toModel(){return{...super.toModel(),component:this.component}}}class wH extends m{nodeName="Number"}class zH extends m{nodeName="Select";options;constructor(F){super(F);this.options=F.options}toModel(){return{...super.toModel(),options:this.options}}}class xH extends m{nodeName="Boolean";component;constructor(F){super(F);this.component=F.component??"checkbox"}toModel(){return{...super.toModel(),component:this.component}}}class OH extends m{nodeName="Date"}class WH extends m{nodeName="Array";content;constructor(F){super(F);this.content=F.content}toModel(){return{...super.toModel(),content:this.content.toModel()}}}class RH{nodeName="Form";fields;showFormDataDebug;key;title;description;submitBtnText;constructor(F){this.fields=F.fields,this.key=F.key,this.title=F.title,this.description=F.description,this.submitBtnText=F.submitBtnText,this.showFormDataDebug=F.showFormDataDebug}toModel(){return{nodeName:this.nodeName,key:this.key,title:this.title,description:this.description,submitBtnText:this.submitBtnText,fields:this.fields.map((F)=>F.toModel())}}}class dF{nodeName="Markdown";content;constructor(F){this.content=F}toModel(){return{nodeName:this.nodeName,content:this.content}}}var XH=new qF,eQ=new h(XH,{}),u=eQ.getAPI();function aQ(F){eQ.expose(F)}var F6=$Q(u.event),Q6=EF(u.fetch),$6=HQ(u.path),H6=YQ(u.shell),Y6=JQ(u.toast),J6=IF(u.updownload),{db:t,kv:U6,os:Z6,clipboard:M6,dialog:w6,fs:z6,log:x6,notification:O6,sysInfo:W6,network:R6,system:T6,open:F$,utils:X6,app:V6,security:K6,helper:j6,workerUi:UF}=u;class Q$ extends zF{nips=[];preferences="";loading=!1;searchQuery="";async load(){this.loading=!0,this.updateUI();try{this.nips=await this.fetchNostrNips()}catch(F){console.error("Failed to load NIPs:",F)}finally{this.loading=!1,this.updateUI()}try{let F=await t.retrieveAll({fields:["data","search_text"]});if(F.length>0&&F[0].data)this.preferences=JSON.parse(F[0].data)?JSON.parse(F[0].data):"nostr",this.updateUI();else this.preferences="nostr",this.updateUI()}catch(F){console.error("Failed to load preferences:",F)}}async fetchNostrNips(){try{let Q=await(await fetch("https://api.github.com/repos/nostr-protocol/nips/contents/README.md")).json(),$=atob(Q.content),H=/\- \[NIP-([0-9A-Za-z]+)\: (.*?)\]\(([0-9A-Za-z]+\.md)\)/g,M=[],w;while((w=H.exec($))!==null){let O=w[1],X=w[2],T=`https://github.com/nostr-protocol/nips/blob/master/${w[3]}`,A=/^\d+$/.test(O),e=`https://nips.nostr.com/${A?parseInt(O):O}`,y=A?O.padStart(2,"0"):O;M.push({nip:y,title:X,rawTitle:X,urlGithub:T,urlNostrCom:e,content:`NIP-${y}: ${X}`})}return M.sort((O,X)=>{let z=/^\d+$/.test(O.nip.replace(/^0+/,"")),T=/^\d+$/.test(X.nip.replace(/^0+/,""));if(z&&T)return parseInt(O.nip)-parseInt(X.nip);if(z)return-1;if(T)return 1;return O.nip.localeCompare(X.nip)})}catch(F){return console.error("Error fetching NIPs:",F),[]}}getFilteredNips(){if(!this.searchQuery)return this.nips;let F=this.searchQuery.toLowerCase();return this.nips.filter((Q)=>Q.rawTitle.toLowerCase().includes(F)||Q.nip.toLowerCase().includes(F)||Q.content.toLowerCase().includes(F))}async onSearchTermChange(F){this.searchQuery=F,this.updateUI()}getFooterActions(){let F=[new g.Action({title:"Always open on nips.nostr.com",value:"open-nostr",icon:new d({type:"iconify",value:"game-icons:ostrich"})}),new g.Action({title:"Always open on GitHub",value:"open-github",icon:new d({type:"iconify",value:"mdi:github"})})];if(this.preferences==="github")F.reverse();return F}async updateUI(){return console.log("updateUI",this.preferences),UF.setSearchBarPlaceholder("Number, Title, k[X], t[X]…").then(()=>{let F=this.getFilteredNips();if(this.loading)return UF.render(new E.List({sections:[new E.Section({title:"Loading...",items:[]})]}));if(F.length===0)return UF.render(new E.List({sections:[new E.Section({title:"No NIPs found",items:[]})]}));return UF.render(new E.List({sections:[new E.Section({title:"Nostr Implementation Possibilities",items:F.map((Q)=>new E.Item({title:`NIP-${Q.nip}: ${Q.title}`,value:this.preferences==="nostr"?Q.urlNostrCom:Q.urlGithub,icon:new d({type:"iconify",value:"majesticons:open"})}))})],actions:new g.ActionPanel({items:this.getFooterActions()})}))})}onListItemSelected(F){return F$.url(F)}async onActionSelected(F){if(F==="open-nostr")await t.deleteAll(),await t.add({data:JSON.stringify("nostr"),dataType:"preference",searchText:"open_with"}),this.preferences="nostr",this.updateUI();if(F==="open-github")await t.deleteAll(),await t.add({data:JSON.stringify("github"),dataType:"preference",searchText:"open_with"}),this.preferences="github",this.updateUI();return Promise.resolve()}}aQ(new Q$);