mirror of
https://github.com/joel-st/kunkun-nostr-goto-repo.git
synced 2025-04-20 05:29:15 +00:00
8 lines
44 KiB
JavaScript
8 lines
44 KiB
JavaScript
var U$=Object.defineProperty;var FQ=(F,Q)=>{for(var $ in Q)U$(F,$,{get:Q[$],enumerable:!0,configurable:!0,set:(H)=>Q[$]=()=>H})};var EF="__DESTROY__";var IF=class{name="worker-child-io";messageQueue=[];resolveRead=null;constructor(){self.onmessage=this.handleMessage}handleMessage=(F)=>{let Q=F.data;if(Q===EF){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(EF),self.close()}signalDestroy(){self.postMessage(EF)}};function Z$(F,Q){if(Q instanceof Uint8Array)return{type:"Uint8Array",data:Array.from(Q)};return Q}function w$(F,Q){if(Q&&Q.type==="Uint8Array"&&Array.isArray(Q.data))return new Uint8Array(Q.data);return Q}function JF(F){return JSON.stringify(F,Z$)+`
|
|
`}function QQ(F){return new Promise((Q,$)=>{try{let H=JSON.parse(F,w$);Q(H)}catch(H){console.error("failed to parse message",typeof F,F,H),$(H)}})}function xF(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var l=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(`
|
|
`),w=$===`
|
|
`?H:H.slice(0,-1);this.messageStr=$===`
|
|
`?"":H.at(-1)??"";for(let z of w.map((T)=>T.trim()).filter(Boolean))if(z.startsWith("{"))this.handleMessageStr(z);else console.log("(kkrpc stdout passthrough):",z)}}async handleMessageStr(F){return this.count++,QQ(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 w=xF();this.pendingRequests[w]={resolve:$,reject:H};let z=[],T=Q.map((M)=>{if(typeof M==="function"){let R=this.callbackCache.get(M);if(!R)R=xF(),this.callbacks[R]=M,this.callbackCache.set(M,R);return z.push(R),`__callback__${R}`}return M}),X={id:w,method:F,args:T,type:"request",callbackIds:z.length>0?z:void 0};this.io.write(JF(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,w=$.split(".");if(!this.apiImplementation)return;let z=this.apiImplementation;for(let R=0;R<w.length-1;R++)if(z=z[w[R]],!z){this.sendError(Q,`Method path ${$} not found at ${w[R]}`);return}let T=w[w.length-1],X=z[T];if(typeof X!=="function"){this.sendError(Q,`Method ${$} is not a function`);return}let M=H.map((R)=>{if(typeof R==="string"&&R.startsWith("__callback__")){let V=R.slice(12);return(...G)=>{this.invokeCallback(V,G)}}return R});try{let R=X.apply(z,M);Promise.resolve(R).then((V)=>{return this.sendResponse(Q,V)}).catch((V)=>this.sendError(Q,V.message))}catch(R){this.sendError(Q,R.message??R.toString())}}invokeCallback(F,Q){let $={id:xF(),method:F,args:Q,type:"callback"};this.io.write(JF($))}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(JF($))}sendError(F,Q){let $={id:F,method:"",args:{error:Q},type:"response"};this.io.write(JF($))}createNestedProxy(F=[]){return new Proxy(()=>{},{get:(Q,$)=>{if(typeof $==="string"&&$!=="then")return this.createNestedProxy([...F,$]);return},apply:(Q,$,H)=>{let w=F.join(".");return this.callMethod(w,H)}})}getAPI(){return this.createNestedProxy()}freeCallbacks(){this.callbacks={},this.callbackCache.clear()}};function S(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 RF(F,Q,$,H,w){if(H==="m")throw new TypeError("Private method is not writable");if(H==="a"&&!w)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?F!==Q||!w:!Q.has(F))throw new TypeError("Cannot write private member to an object whose class did not declare it");return H==="a"?w.call(F,$):w?w.value=$:Q.set(F,$),$}var s,_,t,z$,$Q="__TAURI_TO_IPC_KEY__";function HQ(F,Q=!1){return window.__TAURI_INTERNALS__.transformCallback(F,Q)}class DF{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,s.set(this,()=>{}),_.set(this,0),t.set(this,[]),this.id=HQ(({message:F,id:Q})=>{if(Q==S(this,_,"f")){S(this,s,"f").call(this,F),RF(this,_,S(this,_,"f")+1,"f");while(S(this,_,"f")in S(this,t,"f")){let $=S(this,t,"f")[S(this,_,"f")];S(this,s,"f").call(this,$),delete S(this,t,"f")[S(this,_,"f")],RF(this,_,S(this,_,"f")+1,"f")}}else S(this,t,"f")[Q]=F})}set onmessage(F){RF(this,s,F,"f")}get onmessage(){return S(this,s,"f")}[(s=new WeakMap,_=new WeakMap,t=new WeakMap,$Q)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[$Q]()}}z$=new WeakMap;var YQ;(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"})(YQ||(YQ={}));var ZF;(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"})(ZF||(ZF={}));var JQ;(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"})(JQ||(JQ={}));function kF(F){return async function Q($,H){console.log("fetch",$,H);let w=H?.maxRedirections,z=H?.connectTimeout,T=H?.proxy;if(H!=null)delete H.maxRedirections,delete H.connectTimeout,delete H.proxy;let X=H?.signal,R=(H?.headers==null?[]:H.headers instanceof Headers?Array.from(H.headers.entries()):Array.isArray(H.headers)?H.headers:Object.entries(H.headers)).map(([L,v])=>[L,typeof v==="string"?v:v.toString()]),V=new Request($,H),G=await V.arrayBuffer(),k=G.byteLength!==0?Array.from(new Uint8Array(G)):null,N=await F.rawFetch({clientConfig:{method:V.method,url:V.url,headers:R,data:k,maxRedirections:w,connectTimeout:z,proxy:T}});X?.addEventListener("abort",()=>{F.fetchCancel(N)});let{status:q,statusText:D,url:i,headers:K,rid:h}=await F.fetchSend(N),B=await F.fetchReadBody(h),d=new Response(B instanceof ArrayBuffer&&B.byteLength!==0?B:B instanceof Array&&B.length>0?new Uint8Array(B):null,{headers:K,status:q,statusText:D});return Object.defineProperty(d,"url",{value:i}),d}}class wF{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 hF(F){return{upload:(Q,$,H,w)=>F.upload(Q,$,H?H:void 0,w),download:(Q,$,H,w)=>F.download(Q,$,H?H:void 0,w)}}function UQ(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 ZQ(F){return{BaseDirectory:ZF,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 zF{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 fF extends wF{program;args;options;stdout=new wF;stderr=new wF;constructor(F,Q=[],$){super();this.program=F,this.args=typeof Q==="string"?[Q]:Q,this.options=$??{}}}class yF extends fF{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 zF(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 vF extends fF{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 zF(F,this.api)})}}class _F{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 wQ(F){function Q(K,h=[],B){return new yF(K,h,F,B)}function $(K,h,B){return new vF(K,h,B,F)}async function H(K,h,B,d){let L=$(K,h,B),v=await L.spawn(),WF=new _F(L.stdout,v);return{rpcChannel:new l(WF,{expose:d}),process:v,command:L}}function w(K){return Q("bash",["-c",K])}function z(K){return Q("powershell",["-Command",K])}function T(K){return Q("osascript",["-e",K])}function X(K){return Q("python",["-c",K])}function M(K){return Q("zsh",["-c",K])}function R(K){return Q("node",["-e",K])}async function V(K){return w(K).execute()}async function G(K){return z(K).execute()}async function k(K){return T(K).execute()}async function N(K){return X(K).execute()}async function q(K){return M(K).execute()}async function D(K){return R(K).execute()}function i(){return F.likelyOnWindows()}return{open:F.open,killPid:F.killPid,makeBashScript:w,makePowershellScript:z,makeAppleScript:T,makePythonScript:X,makeZshScript:M,makeNodeScript:R,executeBashScript:V,executePowershellScript:G,executeAppleScript:k,executePythonScript:N,executeZshScript:q,executeNodeScript:D,hasCommand:F.hasCommand,likelyOnWindows:i,createCommand:Q,createDenoCommand:$,Child:zF,TauriShellStdio:_F,createDenoRpcChannel:H,RPCChannel:l,whereIsCommand:F.whereIsCommand}}function zQ(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 TF{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 lF;function M$(F){return{lang:F?.lang??lF?.lang,message:F?.message,abortEarly:F?.abortEarly??lF?.abortEarly,abortPipeEarly:F?.abortPipeEarly??lF?.abortPipeEarly}}var O$;function W$(F){return O$?.get(F)}var x$;function R$(F){return x$?.get(F)}var T$;function X$(F,Q){return T$?.get(F)?.get(Q)}function m(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 P(F,Q,$,H,w){let z=w&&"input"in w?w.input:$.value,T=w?.expected??F.expects??null,X=w?.received??m(z),M={kind:F.kind,type:F.type,input:z,expected:T,received:X,message:`Invalid ${Q}: ${T?`Expected ${T} but r`:"R"}eceived ${X}`,requirement:F.requirement,path:w?.path,issues:w?.issues,lang:H.lang,abortEarly:H.abortEarly,abortPipeEarly:H.abortPipeEarly},R=F.kind==="schema",V=w?.message??F.message??X$(F.reference,M.lang)??(R?R$(M.lang):null)??H.message??W$(M.lang);if(V!==void 0)M.message=typeof V==="function"?V(M):V;if(R)$.typed=!1;if($.issues)$.issues.push(M);else $.issues=[M]}function b(F){return{version:1,vendor:"valibot",validate(Q){return F["~run"]({value:Q},M$())}}}function V$(F,Q){return Object.hasOwn(F,Q)&&Q!=="__proto__"&&Q!=="prototype"&&Q!=="constructor"}function OQ(F,Q){let $=[...new Set(F)];if($.length>1)return`(${$.join(` ${Q} `)})`;return $[0]??"never"}var K$=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function pF(F){return{kind:"validation",type:"hex_color",reference:pF,async:!1,expects:null,requirement:K$,message:F,"~run"(Q,$){if(Q.typed&&!this.requirement.test(Q.value))P(this,"hex color",Q,$);return Q}}}function gF(F,Q){return{kind:"validation",type:"max_value",reference:gF,async:!1,expects:`<=${F instanceof Date?F.toJSON():m(F)}`,requirement:F,message:Q,"~run"($,H){if($.typed&&!($.value<=this.requirement))P(this,"value",$,H,{received:$.value instanceof Date?$.value.toJSON():m($.value)});return $}}}function mF(F,Q){return{kind:"validation",type:"min_value",reference:mF,async:!1,expects:`>=${F instanceof Date?F.toJSON():m(F)}`,requirement:F,message:Q,"~run"($,H){if($.typed&&!($.value>=this.requirement))P(this,"value",$,H,{received:$.value instanceof Date?$.value.toJSON():m($.value)});return $}}}function j$(F,Q,$){return typeof F.fallback==="function"?F.fallback(Q,$):F.fallback}function uF(F,Q,$){return typeof F.default==="function"?F.default(Q,$):F.default}function MF(){return{kind:"schema",type:"any",reference:MF,expects:"any",async:!1,get "~standard"(){return b(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 b(this)},"~run"($,H){let w=$.value;if(Array.isArray(w)){$.typed=!0,$.value=[];for(let z=0;z<w.length;z++){let T=w[z],X=this.item["~run"]({value:T},H);if(X.issues){let M={type:"array",origin:"value",input:w,key:z,value:T};for(let R of X.issues){if(R.path)R.path.unshift(M);else R.path=[M];$.issues?.push(R)}if(!$.issues)$.issues=X.issues;if(H.abortEarly){$.typed=!1;break}}if(!X.typed)$.typed=!1;$.value.push(X.value)}}else P(this,"type",$,H);return $}}}function A(F){return{kind:"schema",type:"boolean",reference:A,expects:"boolean",async:!1,message:F,get "~standard"(){return b(this)},"~run"(Q,$){if(typeof Q.value==="boolean")Q.typed=!0;else P(this,"type",Q,$);return Q}}}function u(F){return{kind:"schema",type:"date",reference:u,expects:"Date",async:!1,message:F,get "~standard"(){return b(this)},"~run"(Q,$){if(Q.value instanceof Date)if(!isNaN(Q.value))Q.typed=!0;else P(this,"type",Q,$,{received:'"Invalid Date"'});else P(this,"type",Q,$);return Q}}}function E(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:E,expects:OQ($.map(m),"|"),async:!1,enum:F,options:$,message:Q,get "~standard"(){return b(this)},"~run"(H,w){if(this.options.includes(H.value))H.typed=!0;else P(this,"type",H,w);return H}}}function rF(F){return{kind:"schema",type:"function",reference:rF,expects:"Function",async:!1,message:F,get "~standard"(){return b(this)},"~run"(Q,$){if(typeof Q.value==="function")Q.typed=!0;else P(this,"type",Q,$);return Q}}}function y(F){return{kind:"schema",type:"lazy",reference:y,expects:"unknown",async:!1,getter:F,get "~standard"(){return b(this)},"~run"(Q,$){return this.getter(Q.value)["~run"](Q,$)}}}function Y(F,Q){return{kind:"schema",type:"literal",reference:Y,expects:m(F),async:!1,literal:F,message:Q,get "~standard"(){return b(this)},"~run"($,H){if($.value===this.literal)$.typed=!0;else P(this,"type",$,H);return $}}}function x(F,Q){return{kind:"schema",type:"nullable",reference:x,expects:`(${F.expects} | null)`,async:!1,wrapped:F,default:Q,get "~standard"(){return b(this)},"~run"($,H){if($.value===null){if(this.default!==void 0)$.value=uF(this,$,H);if($.value===null)return $.typed=!0,$}return this.wrapped["~run"]($,H)}}}function j(F){return{kind:"schema",type:"number",reference:j,expects:"number",async:!1,message:F,get "~standard"(){return b(this)},"~run"(Q,$){if(typeof Q.value==="number"&&!isNaN(Q.value))Q.typed=!0;else P(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 b(this)},"~run"($,H){let w=$.value;if(w&&typeof w==="object"){$.typed=!0,$.value={};for(let z in this.entries){let T=this.entries[z];if(z in w||(T.type==="exact_optional"||T.type==="optional"||T.type==="nullish")&&T.default!==void 0){let X=z in w?w[z]:uF(T),M=T["~run"]({value:X},H);if(M.issues){let R={type:"object",origin:"value",input:w,key:z,value:X};for(let V of M.issues){if(V.path)V.path.unshift(R);else V.path=[R];$.issues?.push(V)}if(!$.issues)$.issues=M.issues;if(H.abortEarly){$.typed=!1;break}}if(!M.typed)$.typed=!1;$.value[z]=M.value}else if(T.fallback!==void 0)$.value[z]=j$(T);else if(T.type!=="exact_optional"&&T.type!=="optional"&&T.type!=="nullish"){if(P(this,"key",$,H,{input:void 0,expected:`"${z}"`,path:[{type:"object",origin:"key",input:w,key:z,value:w[z]}]}),H.abortEarly)break}}}else P(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 b(this)},"~run"($,H){if($.value===void 0){if(this.default!==void 0)$.value=uF(this,$,H);if($.value===void 0)return $.typed=!0,$}return this.wrapped["~run"]($,H)}}}function f(F,Q,$){return{kind:"schema",type:"record",reference:f,expects:"Object",async:!1,key:F,value:Q,message:$,get "~standard"(){return b(this)},"~run"(H,w){let z=H.value;if(z&&typeof z==="object"){H.typed=!0,H.value={};for(let T in z)if(V$(z,T)){let X=z[T],M=this.key["~run"]({value:T},w);if(M.issues){let V={type:"object",origin:"key",input:z,key:T,value:X};for(let G of M.issues)G.path=[V],H.issues?.push(G);if(!H.issues)H.issues=M.issues;if(w.abortEarly){H.typed=!1;break}}let R=this.value["~run"]({value:X},w);if(R.issues){let V={type:"object",origin:"value",input:z,key:T,value:X};for(let G of R.issues){if(G.path)G.path.unshift(V);else G.path=[V];H.issues?.push(G)}if(!H.issues)H.issues=R.issues;if(w.abortEarly){H.typed=!1;break}}if(!M.typed||!R.typed)H.typed=!1;if(M.typed)H.value[M.value]=R.value}}else P(this,"type",H,w);return H}}}function J(F){return{kind:"schema",type:"string",reference:J,expects:"string",async:!1,message:F,get "~standard"(){return b(this)},"~run"(Q,$){if(typeof Q.value==="string")Q.typed=!0;else P(this,"type",Q,$);return Q}}}function MQ(F){let Q;if(F)for(let $ of F)if(Q)Q.push(...$.issues);else Q=$.issues;return Q}function O(F,Q){return{kind:"schema",type:"union",reference:O,expects:OQ(F.map(($)=>$.expects),"|"),async:!1,options:F,message:Q,get "~standard"(){return b(this)},"~run"($,H){let w,z,T;for(let X of this.options){let M=X["~run"]({value:$.value},H);if(M.typed)if(M.issues)if(z)z.push(M);else z=[M];else{w=M;break}else if(T)T.push(M);else T=[M]}if(w)return w;if(z){if(z.length===1)return z[0];P(this,"type",$,H,{issues:MQ(z)}),$.typed=!0}else if(T?.length===1)return T[0];else P(this,"type",$,H,{issues:MQ(T)});return $}}}function cF(...F){return{...F[0],pipe:F,get "~standard"(){return b(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 p;((L)=>{L.List="List";L.ListItem="ListItem";L.ListItemDetail="ListItemDetail";L.ListItemAccessory="ListItemAccessory";L.ListSection="ListSection";L.ListItemDetailMetadata="ListItemDetailMetadata";L.ListItemDetailMetadataLabel="ListItemDetailMetadataLabel";L.ListItemDetailMetadataLink="ListItemDetailMetadataLink";L.ListItemDetailMetadataTagList="ListItemDetailMetadataTagList";L.ListItemDetailMetadataTagListItem="ListItemDetailMetadataTagListItem";L.ListItemDetailMetadataSeparator="ListItemDetailMetadataSeparator";L.Icon="Icon";L.EmptyView="EmptyView";L.Dropdown="Dropdown";L.DropdownSection="DropdownSection";L.DropdownItem="DropdownItem";L.ActionPanel="ActionPanel";L.Action="Action";L.ActionPanelSection="ActionPanelSection";L.ActionPanelSubmenu="ActionPanelSubmenu";L.Markdown="Markdown"})(p||={});var I=E(p),VF;((M)=>{M.Base="Base";M.Number="Number";M.Select="Select";M.Boolean="Boolean";M.Input="Input";M.Date="Date";M.Array="Array";M.Form="Form"})(VF||={});var OF=E(VF);var KF;((z)=>{z.Iconify="iconify";z.RemoteUrl="remote-url";z.Svg="svg";z.Base64PNG="base64-png";z.Text="text"})(KF||={});var WQ=E(KF),xQ=Z({type:WQ,value:J(),invert:U(A()),darkInvert:U(A()),hexColor:U(J()),bgColor:U(J())}),C=Z({...xQ.entries,fallback:U(y(()=>C))}),A$=Z({...xQ.entries,nodeName:I,fallback:U(y(()=>C))});var e=cF(J(),pF()),p1=Z({top:U(j()),right:U(j()),bottom:U(j()),left:U(j())}),g1=O([Y("light"),Y("dark"),Y("auto")]),m1=O([Y("zinc"),Y("slate"),Y("stone"),Y("gray"),Y("neutral"),Y("red"),Y("rose"),Y("orange"),Y("green"),Y("blue"),Y("yellow"),Y("violet")]),u1=cF(j(),mF(0),gF(1));var L$=Z({nodeName:I,icon:U(C),title:J(),value:J()}),oF=Z({nodeName:I,title:U(J()),items:W(O([L$]))});var jF=Z({nodeName:I,content:J()});var XY=Z({nodeName:I,title:U(J()),description:U(J()),icon:U(C)}),G$=Z({nodeName:I,title:J(),value:J(),icon:U(C),keywords:U(W(J()))}),N$=Z({nodeName:I,title:J(),items:W(G$)}),VY=Z({nodeName:I,tooltip:J(),sections:W(N$),defaultValue:J()}),B$=Z({nodeName:I,tag:U(O([J(),Z({color:e,text:J()})])),text:U(O([J(),Z({color:e,text:J()})])),date:U(O([u(),Z({color:e,text:u()})])),icon:U(C),tooltip:U(J())}),P$=Z({nodeName:Y("ListItemDetailMetadataLabel"),title:J(),icon:U(C),text:U(O([J(),Z({color:e,text:J()})]))}),b$=Z({nodeName:Y("ListItemDetailMetadataLink"),title:J(),text:J(),url:J()}),C$=Z({nodeName:Y("ListItemDetailMetadataTagListItem"),text:U(J()),color:U(e)}),q$=Z({nodeName:Y("ListItemDetailMetadataTagList"),title:J(),tags:W(C$)}),S$=Z({nodeName:Y("ListItemDetailMetadataSeparator")}),E$=O([P$,b$,q$,S$]),I$=Z({nodeName:Y("ListItemDetailMetadata"),items:W(E$)}),D$=Z({nodeName:Y("ListItemDetail"),children:W(O([jF,I$])),width:U(j())}),TQ=Z({nodeName:Y("ListItem"),title:J(),subTitle:U(J()),accessories:U(W(B$)),value:J(),defaultAction:U(J()),actions:U(oF),icon:U(C),keywords:U(W(J()))}),k$=Z({nodeName:Y("ListSection"),title:U(J()),subtitle:U(J()),items:W(TQ)}),h$=O([Y("items"),Y("detail"),Y("filter"),Y("sections"),Y("actions"),Y("defaultAction")]),KY=Z({nodeName:Y("List"),sections:U(W(k$)),items:U(W(TQ)),filter:O([Y("none"),Y("default")]),detail:U(D$),actions:U(oF),defaultAction:U(J()),inherits:U(W(h$))});var _$=O([Y("color"),Y("date"),Y("datetime-local"),Y("month"),Y("number"),Y("password"),Y("text"),Y("url"),Y("week"),Y("time"),Y("search")]),a=Z({nodeName:OF,key:J(),label:U(J()),hideLabel:U(A()),placeholder:U(J()),optional:U(A()),description:U(J()),default:U(MF())}),XQ=Z({...a.entries,type:U(_$),component:U(O([Y("textarea"),Y("default")])),default:U(J())}),VQ=Z({...a.entries,nodeName:OF,default:U(j())}),KQ=Z({...a.entries,options:W(J()),default:U(J())}),jQ=Z({...a.entries,component:U(O([Y("checkbox"),Y("switch")]))}),AQ=Z({...a.entries,default:U(J())}),f$=O([XQ,VQ,KQ,jQ,AQ]),y$=Z({...a.entries,content:f$}),v$=O([y$,KQ,XQ,VQ,jQ,AQ]),l$=Z({nodeName:OF,key:J(),showFormDataDebug:U(A()),fields:W(O([y(()=>l$),v$])),title:U(J()),description:U(J()),submitBtnText:U(J())});class FF{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 r={};FQ(r,{Section:()=>_Q,List:()=>fQ,ItemDetailMetadataTagListItem:()=>SQ,ItemDetailMetadataTagList:()=>EQ,ItemDetailMetadataSeparator:()=>IQ,ItemDetailMetadataLink:()=>qQ,ItemDetailMetadataLabel:()=>CQ,ItemDetailMetadata:()=>DQ,ItemDetail:()=>kQ,ItemAccessory:()=>bQ,Item:()=>hQ,EmptyView:()=>GQ,DropdownSection:()=>BQ,DropdownItem:()=>NQ,Dropdown:()=>PQ});class GQ{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 NQ{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 BQ{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 PQ{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 bQ{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 CQ{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 qQ{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 SQ{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 EQ{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 IQ{nodeName="ListItemDetailMetadataSeparator";toModel(){return{nodeName:this.nodeName}}}class DQ{nodeName="ListItemDetailMetadata";items;constructor(F){this.items=F}toModel(){return{nodeName:this.nodeName,items:this.items.map((F)=>F.toModel())}}}class kQ{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 hQ{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 _Q{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 fQ{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 c={};FQ(c,{ActionPanel:()=>vQ,Action:()=>yQ});class yQ{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 vQ{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 DY=Z({name:J(),icon_path:x(J()),app_path_exe:x(J()),app_desktop_path:J()});var fY=f(J("Window label"),Z({path:J("Path to the extension"),processes:W(j()),dist:U(x(J()))})),yY=Z({extId:j(),identifier:J(),version:J(),enabled:A(),installed_at:J(),path:x(J()),data:x(MF())}),lQ;((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"})(lQ||={});var g=E(lQ),p$=Z({cmdId:j(),extId:j(),name:J(),type:g,data:J(),alias:x(U(J())),hotkey:x(U(J())),enabled:A()}),vY=Z({...p$.entries,data:Z({link:J(),icon:C})}),lY=Z({dataId:j(),extId:j(),dataType:J(),data:U(J()),searchText:U(J()),createdAt:u(),updatedAt:u()}),pY=Z({name:J(),value:J(),icon:x(C),keywords:x(W(J())),function:rF(),confirmRequired:A()});var pQ;(($)=>{$.Asc="ASC";$.Desc="DESC"})(pQ||={});var uY=E(pQ),gQ;((H)=>{H.ExactMatch="exact_match";H.Like="like";H.FTS="fts"})(gQ||={});var rY=E(gQ);var AF=O([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")]),LF=O([Y("dialog:all")]),GF=O([Y("notification:all")]),NF=O([Y("fs:read"),Y("fs:write"),Y("fs:exists")]),BF=Y("os:all"),mQ=O([Y("shell:open"),Y("shell:execute"),Y("shell:kill-any")]),PF=Y("fetch:all"),bF=O([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")]),CF=O([Y("network:interface"),Y("network:port")]),qF=O([Y("updownload:download"),Y("updownload:upload")]),g$=O([AF,LF,GF,NF,BF,mQ,PF,bF,CF,qF]);var iF={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 i$=O([AF,Y("clipboard:paste")]),uQ=O([Y("system:volumn"),Y("system:boot"),Y("system:disk"),Y("system:apps"),Y("system:fs"),Y("system:ui")]),rQ=O([NF,Y("fs:read-dir"),Y("fs:stat"),Y("fs:search")]),d$=O([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")]),s$=O([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")]),t$=O([Y("hostname"),Y("osRelease"),Y("osUptime"),Y("loadavg"),Y("networkInterfaces"),Y("systemMemoryInfo"),Y("uid"),Y("gid"),Y("cpus"),J()]),e$=Z({net:U(O([Y("*"),W(J())])),env:U(O([Y("*"),W(J())])),read:U(O([Y("*"),W(J())])),write:U(O([Y("*"),W(J())])),run:U(O([Y("*"),W(J())])),ffi:U(O([Y("*"),W(J())])),sys:U(O([Y("*"),W(t$)]))}),QF=Z({path:U(J()),url:U(J()),cmd:U(Z({program:J(),args:W(J())})),...e$.entries}),cQ=Z({permission:rQ,allow:U(W(QF)),deny:U(W(QF))}),oQ=O([Y("open:url"),Y("open:file"),Y("open:folder")]),nQ=Z({permission:oQ,allow:U(W(QF)),deny:U(W(QF))}),iQ=O([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")]),dQ=Z({permission:iQ,allow:U(W(QF)),deny:U(W(QF))}),dF=O([i$,d$,LF,GF,BF,iQ,PF,bF,CF,qF,uQ,s$]),a$=O([dF,rQ,oQ]);var w8={...iF,paste:["clipboard:paste"]};var sF;((H)=>{H.linux="linux";H.macos="macos";H.windows="windows"})(sF||={});var FH=E(sF),sQ=Object.values(sF),QH=Z({type:O([Y("text"),Y("regex")]),value:J()}),eQ;((H)=>{H.visible="visible";H.transparent="transparent";H.overlay="overlay"})(eQ||={});var $H=E(eQ),aQ=Z({center:U(x(A())),x:U(x(j())),y:U(x(j())),width:U(x(j())),height:U(x(j())),minWidth:U(x(j())),minHeight:U(x(j())),maxWidth:U(x(j())),maxHeight:U(x(j())),resizable:U(x(A())),title:U(x(J())),fullscreen:U(x(A())),focus:U(x(A())),transparent:U(x(A())),maximized:U(x(A())),visible:U(x(A())),decorations:U(x(A())),alwaysOnTop:U(x(A())),alwaysOnBottom:U(x(A())),contentProtected:U(x(A())),skipTaskbar:U(x(A())),shadow:U(x(A())),titleBarStyle:U(x($H)),hiddenTitle:U(x(A())),tabbingIdentifier:U(x(J())),maximizable:U(x(A())),minimizable:U(x(A())),closable:U(x(A())),parent:U(x(J())),visibleOnAllWorkspaces:U(x(A()))}),tF=Z({main:J("HTML file to load, e.g. dist/index.html"),description:U(x(J("Description of the Command"),""),""),name:J("Name of the command"),cmds:W(QH,"Commands to trigger the UI"),icon:U(C),platforms:U(x(W(FH,"Platforms available on. Leave empty for all platforms."),sQ),sQ)}),HH=Z({...tF.entries,type:U(g,g.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(x(aQ))}),YH=Z({...tF.entries,type:U(g,g.enum.UiWorker),window:U(x(aQ))}),JH=Z({...tF.entries,type:U(g,g.enum.HeadlessWorker)}),UH=O([dF,cQ,nQ,dQ]),ZH=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:C,permissions:W(UH,"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(HH,"Custom UI Commands")),templateUiCmds:U(W(YH,"Template UI Commands")),headlessCmds:U(W(JH,"Headless Commands"))}),tQ=O([Z({name:J("GitHub Username"),email:U(x(J("Email of the person"))),url:U(x(J("URL of the person")))}),J("GitHub Username")]),wH=O([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")]),zH=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:wH,author:U(tQ),draft:U(A("Whether the extension is a draft, draft will not be published")),contributors:U(W(tQ,"Contributors of the extension")),repository:U(O([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(f(J(),J())),kunkun:ZH,files:U(W(J("Files to include in the extension. e.g. ['dist']")))}),A8=Z({...zH.entries,...{extPath:J(),extFolderName:J()}});var MH=Z({addresses:W(J()),fullname:J(),hostname:J(),port:j(),service_type:J(),subType:U(J()),properties:U(f(J(),J())),publicKey:J(),sslCert:J()}),N8=f(J(),MH);var F$=Z({filename:J(),fileSize:j(),id:J(),type:j(),children:W(y(()=>F$))}),P8=Z({port:J(),code:J(),totalBytes:j(),totalFiles:j(),sslCert:J(),root:y(()=>F$),ip:J()}),b8=Z({code:J(),idPathMap:f(J(),J())});class o{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 OH extends o{nodeName="Input";component;constructor(F){super(F);this.component=F.component}toModel(){return{...super.toModel(),component:this.component}}}class WH extends o{nodeName="Number"}class xH extends o{nodeName="Select";options;constructor(F){super(F);this.options=F.options}toModel(){return{...super.toModel(),options:this.options}}}class RH extends o{nodeName="Boolean";component;constructor(F){super(F);this.component=F.component??"checkbox"}toModel(){return{...super.toModel(),component:this.component}}}class TH extends o{nodeName="Date"}class XH extends o{nodeName="Array";content;constructor(F){super(F);this.content=F.content}toModel(){return{...super.toModel(),content:this.content.toModel()}}}class VH{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 eF{nodeName="Markdown";content;constructor(F){this.content=F}toModel(){return{nodeName:this.nodeName,content:this.content}}}var jH=new IF,$$=new l(jH,{}),n=$$.getAPI();function H$(F){$$.expose(F)}var $6=UQ(n.event),H6=kF(n.fetch),Y6=ZQ(n.path),J6=wQ(n.shell),U6=zQ(n.toast),Z6=hF(n.updownload),{db:$F,kv:w6,os:z6,clipboard:M6,dialog:O6,fs:W6,log:x6,notification:R6,sysInfo:T6,network:X6,system:V6,open:Y$,utils:K6,app:j6,security:A6,helper:L6,workerUi:aF}=n;class J$ extends TF{nips=[];preferences="";loading=!1;searchQuery="";filteredNips=[];async load(){this.loading=!0,this.updateUI();try{this.nips=await this.fetchNostrNips(),this.filteredNips=this.nips}catch(F){console.error("Failed to load NIPs:",F)}finally{this.loading=!1,this.updateUI()}try{let F=await $F.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)}}sortNips(F){return F.sort((Q,$)=>{let H=/^\d+$/.test(Q.nip.replace(/^0+/,"")),w=/^\d+$/.test($.nip.replace(/^0+/,""));if(H&&w)return parseInt(Q.nip)-parseInt($.nip);if(H)return-1;if(w)return 1;return Q.nip.localeCompare($.nip)})}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,w=[],z;while((z=H.exec($))!==null){let X=z[1],M=z[2],V=`https://github.com/nostr-protocol/nips/blob/master/${z[3]}`,G=/^\d+$/.test(X),N=`https://nips.nostr.com/${G?parseInt(X):X}`,q=G?X.padStart(2,"0"):X;w.push({nip:q,title:M,rawTitle:M,urlGithub:V,urlNostrCom:N,content:`NIP-${q}: ${M}`,kinds:[]})}let T=$.match(/## Event Kinds\s+([\s\S]+?)(?=##|$)/);if(T&&T[1]){let X=[],R=T[1].trim().split(`
|
|
`).filter((V)=>V.trim()!=="");for(let V=2;V<R.length;V++){let k=R[V].split("|").map((N)=>N.trim()).filter((N)=>N!=="");if(k.length>=3){let N=k[0],q=k[1],D=[],i=N.match(/`(\d+)`/g);if(i)i.forEach((HF)=>{let YF=parseInt(HF.replace(/`/g,""));if(!isNaN(YF))D.push(YF)});let K=N.match(/`(\d+)`\s*-\s*`(\d+)`/);if(K&&K[1]&&K[2]){let HF=parseInt(K[1]),YF=parseInt(K[2]);if(!isNaN(HF)&&!isNaN(YF))for(let SF=HF;SF<=YF;SF++)D.push(SF)}let h=k[2],B=[],d=/\[([0-9A-Za-z]+)\]\([0-9A-Za-z]+\.md\)/g,L;while((L=d.exec(h))!==null)B.push(L[1]);let v=/([0-9A-Za-z]+)\s+\(deprecated\)/g,WF;while((WF=v.exec(h))!==null)B.push(WF[1]);if(D.length>0&&B.length>0)X.push([D,q,B])}}X.forEach((V)=>{let G=V[0];V[2].forEach((N)=>{let q=w.find((D)=>D.nip===N||N.startsWith("0")&&D.nip===N.replace(/^0+/,""));if(q)q.kinds=[...q.kinds,...G],q.kinds=[...new Set(q.kinds)]})})}return this.sortNips(w)}catch(F){return console.error("Error fetching NIPs:",F),[]}}async setFilteredNips(){if(!this.searchQuery)this.filteredNips=this.nips;let F=this.searchQuery.toLowerCase(),Q=F.match(/k(\d+)/),$=this.nips.filter((H)=>{if(Q&&H.kinds.includes(parseInt(Q[1])))console.log("kindMatch",Q,H);return H.rawTitle.toLowerCase().includes(F)||H.nip.toLowerCase().includes(F)||H.content.toLowerCase().includes(F)||Q&&H.kinds.includes(parseInt(Q[1]))});this.filteredNips=this.sortNips($),this.updateUI()}async onSearchTermChange(F){this.searchQuery=F,await this.setFilteredNips()}getFooterActions(){let F=[new c.Action({title:"Always open on nips.nostr.com",value:"open-nostr",icon:new FF({type:"iconify",value:"game-icons:ostrich"})}),new c.Action({title:"Always open on GitHub",value:"open-github",icon:new FF({type:"iconify",value:"mdi:github"})})];if(this.preferences==="github")F.reverse();return F}async updateUI(){return aF.setSearchBarPlaceholder("Number, Title, k[X], t[X]…").then(()=>{return aF.render(new r.List({sections:[new r.Section({title:"Nostr Implementation Possibilities",items:this.filteredNips.map((F)=>new r.Item({title:`NIP-${F.nip}: ${F.title}`,value:this.preferences==="nostr"?F.urlNostrCom:F.urlGithub,icon:new FF({type:"iconify",value:"majesticons:open"})}))})],actions:new c.ActionPanel({items:this.getFooterActions()})}))})}onListItemSelected(F){return Y$.url(F)}async onActionSelected(F){if(F==="open-nostr")await $F.deleteAll(),await $F.add({data:JSON.stringify("nostr"),dataType:"preference",searchText:"open_with"}),this.preferences="nostr",this.updateUI();if(F==="open-github")await $F.deleteAll(),await $F.add({data:JSON.stringify("github"),dataType:"preference",searchText:"open_with"}),this.preferences="github",this.updateUI();return Promise.resolve()}}H$(new J$);
|