needle-cloud 2.10.0 → 2.11.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"node-fetch";import{File as t}from"@web-std/file";import n,{createHash as o,randomUUID as i}from"node:crypto";import{Command as a,Option as r}from"commander";import s,{existsSync as c,statSync as l,readFileSync as p,readdirSync as u,appendFileSync as d,mkdirSync as m,writeFileSync as f,realpathSync as h,lstatSync as g,readFile as v}from"fs";import{execFileSync as b}from"child_process";import x from"open";import y,{resolve as w,join as _,relative as j,isAbsolute as k,sep as S,dirname as E}from"path";import $ from"ora";import{existsSync as T,mkdirSync as I,renameSync as O,realpathSync as A,statSync as C,rename as R,appendFileSync as N,openSync as P,readSync as U,closeSync as L,createReadStream as z,constants as F,fstatSync as D,readdirSync as q,lstatSync as B,readFileSync as M,rmSync as W,writeFileSync as H,watch as G}from"node:fs";import{writeFile as J,readlink as V,readFile as K,readdir as Y,mkdir as Z,open as X,stat as Q,unlink as ee}from"node:fs/promises";import te,{homedir as ne,tmpdir as oe}from"node:os";import ie,{resolve as ae,relative as re,dirname as se,isAbsolute as ce,sep as le,join as pe,win32 as ue,posix as de,extname as me,basename as fe}from"node:path";import he from"util";import ge,{Readable as ve}from"stream";import be from"http";import xe from"https";import ye from"url";import we,{randomUUID as _e}from"crypto";import je from"net";import ke from"tls";import Se from"assert";import Ee from"tty";import $e,{homedir as Te,tmpdir as Ie}from"os";import Oe,{EventEmitter as Ae}from"events";import Ce from"http2";import Re from"zlib";import{Console as Ne}from"node:console";import{createInterface as Pe}from"node:readline/promises";import Ue from"dotenv";import Le from"@logto/node";import{createInterface as ze}from"node:readline";import{Readable as Fe}from"node:stream";import{createGzip as De}from"node:zlib";import{Router as qe}from"express";import Be,{WebSocketServer as Me}from"ws";import{execFileSync as We,execFile as He,spawnSync as Ge,spawn as Je}from"node:child_process";import{minimatch as Ve}from"minimatch";import{fileURLToPath as Ke}from"node:url";import{promisify as Ye}from"node:util";import Ze from"body-parser";import{setTimeout as Xe}from"node:timers/promises";const Qe="STRING",et="BOOLEAN",tt="NUMBER",nt="ARRAY";function ot(e){return e.replace(/[-_](\w)/g,(e,t)=>t.toUpperCase())}function it(e){const t=e.match(/--[\w-]+/g);return t?t[t.length-1]:e.split(/[\s,]+/)[0]}function at(e){return ot(it(e).replace(/^--/,""))}function rt(e){return ot(e.replace(/[[\]<>]/g,"").replace(/\.\.\.$/,"").trim())}function st(e,t){if(null==e)return e;switch(t){case et:{if("boolean"==typeof e)return e;const t=String(e).toLowerCase();return""===t||!["false","0","no","off"].includes(t)&&(!!["true","1","yes","on"].includes(t)||Boolean(e))}case tt:{const t=Number(e);return Number.isNaN(t)?e:t}case nt:return Array.isArray(e)?e:String(e).split(",");case Qe:return Array.isArray(e)?e:String(e);default:return e}}const ct={error:(...e)=>console.error(...e),warn:(...e)=>console.warn(...e),info:(...e)=>console.log(...e),debug:(...e)=>console.debug(...e),log:(...e)=>console.log(...e)};class lt{constructor(e,t){this.name=e,this.description=null!=t?t:"",this.visible=!0,this.strictOptions=!0,this._aliases=[],this._helpTexts=[],this._action=void 0,this.options=[],this.args=[]}alias(e){return this._aliases.push(e),this}getAliases(){return[...this._aliases]}configure(e={}){return void 0!==e.visible&&(this.visible=!1!==e.visible),void 0!==e.strictOptions&&(this.strictOptions=!1!==e.strictOptions),this}hide(){return this.visible=!1,this}help(e){return e&&this._helpTexts.push(e),this}option(e,t,n={}){return this.options.push({synopsis:e,description:null!=t?t:"",name:at(e),validator:n.validator,default:n.default,required:!0===n.required,hidden:!0===n.hidden}),this}argument(e,t,n={}){return this.args.push({synopsis:e,description:null!=t?t:"",name:rt(e),validator:n.validator,default:n.default}),this}action(e){return this._action=e,this}isHelpCommand(){return!1}}class pt{constructor(){this.STRING=Qe,this.BOOLEAN=et,this.NUMBER=tt,this.ARRAY=nt,this._version=void 0,this._description=void 0,this._name="needle-cloud",this._commands=[],this._exitOverride=!1,this._testHooks=null}version(e){return this._version=e,this}description(e){return this._description=e,this}name(e){return this._name=e,this}command(e,t){const n=new lt(e,t);return this._commands.push(n),n}getCommands(){return[...this._commands]}exitOverride(){return this._exitOverride=!0,this}async run(e){const t=this._build();try{return await t.parseAsync(null!=e?e:process.argv.slice(2),{from:"user"})}catch(t){var n,o,i;if(this._exitOverride)throw t;const a=null!=(n=null==(o=this._testHooks)?void 0:o.error)?n:e=>console.error(e);return a(`error: ${t instanceof Error&&t.message||String(t)}`),(null!=e?e:process.argv).includes("--verbose")&&t instanceof Error&&t.stack&&a(t.stack),null!=(i=this._testHooks)&&i.exit?this._testHooks.exit(1):process.exit(1)}}_build(){const e=new a(this._name);this._version&&e.version(this._version),this._description&&e.description(this._description),this._exitOverride&&e.exitOverride();const t=new Map,n=o=>{if(1===o.length)return e;const i=o.slice(0,-1).join(" ");let r=t.get(i);return r||(r=new a(o[o.length-2]),this._exitOverride&&r.exitOverride(),t.set(i,r),n(o.slice(0,-1)).addCommand(r)),r};for(const e of this._commands){const o=e.name.split(/\s+/),i=t.get(e.name),s=null!=i?i:new a(o[o.length-1]);t.set(e.name,s),s.description(e.description);for(const t of e._aliases)s.alias(t);for(const t of e._helpTexts)s.addHelpText("after","\n"+t);this._exitOverride&&s.exitOverride(),e.strictOptions||(s.allowUnknownOption(!0),s.allowExcessArguments(!0));for(const t of e.args)s.argument(t.synopsis,t.description);for(const t of e.options){let e=t.synopsis;t.validator&&!it(e).startsWith("--no-")&&(e=/[<[]/.test(e)?e.replace(/<([\w-]+)>/,"[$1]"):`${e} [value]`);const n=new r(e,t.description);t.hidden&&n.hideHelp(),t.required&&n.makeOptionMandatory(),s.addOption(n)}e._action&&s.action(async(...t)=>{var n;const o=null!=(n=t[e.args.length])?n:{},i={};e.args.forEach((e,n)=>{const o=t[n];i[e.name]=st(void 0===o?e.default:o,e.validator)});const a={};for(const t of e.options){if(it(t.synopsis).startsWith("--no-")){const e=ot(it(t.synopsis).replace(/^--no-/,""));a[t.name]=!1===o[e];continue}const e=o[t.name];a[t.name]=st(void 0===e?t.default:e,t.validator)}for(const[e,t]of Object.entries(o))e in a||(a[e]=t);await e._action({args:i,options:a,logger:ct,command:s})}),i||n(o).addCommand(s,{hidden:!e.visible})}return e}}function ut(){return new pt}var dt={program:ut(),createProgram:ut,STRING:Qe,BOOLEAN:et,NUMBER:tt,ARRAY:nt};class mt extends Error{constructor(e,t,n){super(n),this.name="ApiError",this.status=e,this.body=t}}const ft={status:"/v1/status",version:"/v1/version",api:"/v1/api",runtime_snapshots:{release_get:"/v1/runtime-releases",get:"/v1/runtime-snapshots/:hash",file:"/v1/runtime-snapshots/:hash/files/*"},usage:{get:"/v1/usage"},affiliate:{get:"/v1/affiliate/get",link_clicked:"/v1/affiliate/link_clicked"},account:{public_key:"/v1/account/public_key",post_machine:"/v1/account/machine",connect:"/v1/account/connect",get_licenses:"/v1/account/get/licenses",set_license_active:"/v1/account/set_license_active",set_licenses_active:"/v1/account/set_licenses_active",buy_licenses:"/v1/account/buy_licenses",update_licenses:"/v1/account/update_licenses",preview_invitation:"/v1/account/preview_invitation",update_payment_method:"/v1/account/update_payment_method",get_billing:"/v1/account/get_billing",generate_invoice:"/v1/account/generate_invoice",resume_subscription:"/v1/account/resume_subscription",cancel_subscription:"/v1/account/cancel_subscription",start_billingportal_session:"/v1/account/start_billingportal_session",post_preferences:"/v1/account/preferences",get_preferences:"/v1/account/preferences"},payment:{info:"/v1/payment/info",create:"/v1/payment/create"},ai:{llmstxt:"/v1/ai/llmstxt",chat:"/v1/ai/chat",chat_personal:"/v1/ai/chat/personal",list_chats:"/v1/ai/chat/list",chat_image:"/v1/ai/chat/image",chat_tool_result:"/v1/ai/chat/tool-result",chat_stop:"/v1/ai/chat/stop",chat_file_edits:"/v1/ai/file-edits",chat_file_edit_undo:"/v1/ai/file-edits/undo",chat_enqueue:"/v1/ai/chat/enqueue",chat_enqueue_cancel:"/v1/ai/chat/enqueue/cancel",ask:"/v1/ai/ask",completions:"/v1/ai/completions",evaluate:"/v1/ai/evaluate",post_settings:"/v1/ai/chat/settings",ws:"/v1/ws",cli_ws:"/v1/cli/ws"},organizations:{get:"/v1/organizations/get",orgs_details:"/v1/organizations/details",licenses:"/v1/organizations/licenses",get_invitations:"/v1/organizations/get_invitations"},events:{get:"/v1/events/get",post:"/v1/events/post",list:"/v1/events/list"},reports:{get:"/v1/reports/get",post:"/v1/reports/post"},diagnostics:{download_failed:"/v1/diagnostics/download-failed"},questionnaire:{get:"/v1/questionnaires/get",post:"/v1/questionnaires/post"},roadmap:{get:"/v1/roadmap/get",post_vote:"/v1/roadmap/post"},tokens:{create:"/v1/tokens/create",delete:"/v1/tokens/delete",list:"/v1/tokens/list"},get:{stats:"/v1/get/stats",jobs:"/v1/list/jobs",deployments:"/v1/list/deployments",discounts:"/v1/get/discounts"},files:{entry:"/v1/files/:identifier/:version/",file:"/v1/files/:identifier/:version/*"},view:{get_analytics:"/v1/view/analytics",get_public_info:"/v1/view/public/info",post_version:"/v1/view/post_version"},content:{root:"/v1/content",download:"/v1/content/download",detail:"/v1/content/:identifier",update:"/v1/content/:identifier",delete:"/v1/content/:identifier",restore:"/v1/content/:identifier/restore",visits:"/v1/content/:identifier/visits",domains:"/v1/content/:identifier/domains",domain_item:"/v1/content/:identifier/domains/:hostname",domain_verify:"/v1/content/:identifier/domains/:hostname/verify"},analytics:{content_list:"/v1/analytics/content-list"},public:{content_list:"/v1/public/content",content_detail:"/v1/public/content/:identifier"},collections:{list:"/v1/collections/list",get:"/v1/collections/get",create:"/v1/collections/create",update:"/v1/collections/update",delete:"/v1/collections/delete",add_item:"/v1/collections/add-item",remove_item:"/v1/collections/remove-item",reorder_items:"/v1/collections/reorder-items"},projects:{create:"/v1/projects/create",list:"/v1/projects/list",head:"/v1/projects/head",push:"/v1/projects/push",pull:"/v1/projects/pull",delete:"/v1/projects/delete",restore:"/v1/projects/restore",archive:"/v1/projects/archive",unarchive:"/v1/projects/unarchive",clone:"/v1/projects/clone",update:"/v1/projects/update",blobs_check:"/v1/projects/blobs/check",blobs_upload:"/v1/projects/blobs/upload",blobs_complete:"/v1/projects/blobs/complete",blobs_download:"/v1/projects/blobs/download",revisions:"/v1/projects/revisions",revisions_update:"/v1/projects/revisions/update",deployments:"/v1/projects/deployments",promote:"/v1/projects/promote",promotions:"/v1/projects/promotions"},upload:{request:"/v1/upload/request",request_put_url:"/v1/upload/put",update_results:"/v1/upload/results",done:"/v1/upload/done",cancel:"/v1/upload/cancel",multipart_create:"/v1/upload/multipart/create",multipart_part_urls:"/v1/upload/multipart/part-urls",multipart_complete:"/v1/upload/multipart/complete",multipart_abort:"/v1/upload/multipart/abort"},jobs:{create:"/v1/jobs/create",get_id:"/v1/jobs/get_id",presigned_url:"/v1/jobs/presigned-url",presigned_urls:"/v1/jobs/presigned-urls",download_urls:"/v1/jobs/download-urls",request_restart:"/v1/jobs/restart",delete:"/v1/jobs/delete",post_update:"/v1/jobs/update",post_results_stats:"/v1/jobs/results_stats",post_usage:"/v1/jobs/post_usage",get_status:"/v1/jobs/status",get_org:"/v1/jobs/org",query:"/v1/jobs/query",request_job_that_needs_stats:"/v1/jobs/job_needs_stats"},worker:{get_available_count:"/v1/worker/get_available_count"},local_projects:{get:{user:"/v1/local_projects/user",by_id:"/v1/local_projects/"},post:"/v1/local_projects"}};function ht(e){const t={authorization:"Bearer "+e.authToken};return e.org&&(t["x-needle-cloud-org"]=e.org),e.roles&&(t.roles=e.roles.join(",")),e.roles_org&&(t.roles_org=e.roles_org.join(",")),t}const gt={credentials:"omit"};async function vt(e,t){const n=e.baseUrl+ft.account.get_licenses,o={...{...t},...ht(e)},i=await fetch(n,{...gt,method:"GET",headers:o}).catch(e=>(console.error(e),null));return i?i.ok?(await i.json()).licenses:(console.error(i.statusText,await i.text()),[]):[]}function bt(e,t=void 0){let n=e.baseUrl+`/v1/files/${e.content_id}`;if(n+=e.job_id&&!0!==(null==t?void 0:t.latest)?"/"+e.job_id:"/latest",n+="/",e.filename){const t=e.filename.split("/");for(let e=0;e<t.length;e++){const o=t[e].trim();0!==o.length&&(n+=encodeURIComponent(o),e<t.length-1&&(n+="/"))}}return!0===(null==t?void 0:t.progressive)?n+="?progressive=1":!1===(null==t?void 0:t.progressive)&&(n+="?progressive=0"),n}function xt(e,t){return function(){return e.apply(t,arguments)}}const{toString:yt}=Object.prototype,{getPrototypeOf:wt}=Object,{iterator:_t,toStringTag:jt}=Symbol,kt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),St=(e,t)=>{let n=e;const o=[];for(;null!=n&&n!==Object.prototype;){if(-1!==o.indexOf(n))return!1;if(o.push(n),kt(n,t))return!0;n=wt(n)}return!1},Et=($t=Object.create(null),e=>{const t=yt.call(e);return $t[t]||($t[t]=t.slice(8,-1).toLowerCase())});var $t;const Tt=e=>(e=e.toLowerCase(),t=>Et(t)===e),It=e=>t=>typeof t===e,{isArray:Ot}=Array,At=It("undefined");function Ct(e){return null!==e&&!At(e)&&null!==e.constructor&&!At(e.constructor)&&Pt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Rt=Tt("ArrayBuffer"),Nt=It("string"),Pt=It("function"),Ut=It("number"),Lt=e=>null!==e&&"object"==typeof e,zt=e=>{if(!Lt(e))return!1;const t=wt(e);return!(null!==t&&t!==Object.prototype&&null!==wt(t)||St(e,jt)||St(e,_t))},Ft=Tt("Date"),Dt=Tt("File"),qt=Tt("Blob"),Bt=Tt("FileList"),Mt=Tt("Set"),Wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Ht=void 0!==Wt.FormData?Wt.FormData:void 0,Gt=Tt("URLSearchParams"),[Jt,Vt,Kt,Yt]=["ReadableStream","Request","Response","Headers"].map(Tt);function Zt(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let o,i;if("object"!=typeof e&&(e=[e]),Ot(e))for(o=0,i=e.length;o<i;o++)t.call(null,e[o],o,e);else{if(Ct(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let r;for(o=0;o<a;o++)r=i[o],t.call(null,e[r],r,e)}}function Xt(e,t){if(Ct(e))return null;t=t.toLowerCase();const n=Object.keys(e);let o,i=n.length;for(;i-- >0;)if(o=n[i],t===o.toLowerCase())return o;return null}const Qt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,en=e=>!At(e)&&e!==Qt,tn=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&wt(Uint8Array)),nn=Tt("HTMLFormElement"),{propertyIsEnumerable:on}=Object.prototype,an=Tt("RegExp"),rn=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};Zt(n,(n,i)=>{let a;!1!==(a=t(n,i,e))&&(o[i]=a||n)}),Object.defineProperties(e,o)},sn=Tt("AsyncFunction"),cn=(ln="function"==typeof setImmediate,pn=Pt(Qt.postMessage),ln?setImmediate:pn?(un=`axios@${Math.random()}`,dn=[],Qt.addEventListener("message",({source:e,data:t})=>{e===Qt&&t===un&&dn.length&&dn.shift()()},!1),e=>{dn.push(e),Qt.postMessage(un,"*")}):e=>setTimeout(e));var ln,pn,un,dn;const mn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Qt):"undefined"!=typeof process&&process.nextTick||cn,fn=e=>null!=e&&Pt(e[_t]);var hn={isArray:Ot,isArrayBuffer:Rt,isBuffer:Ct,isFormData:e=>{if(!e)return!1;if(Ht&&e instanceof Ht)return!0;const t=wt(e);if(!t||t===Object.prototype)return!1;if(!Pt(e.append))return!1;const n=Et(e);return"formdata"===n||"object"===n&&Pt(e.toString)&&"[object FormData]"===e.toString()},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Rt(e.buffer),t},isString:Nt,isNumber:Ut,isBoolean:e=>!0===e||!1===e,isObject:Lt,isPlainObject:zt,isEmptyObject:e=>{if(!Lt(e)||Ct(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Jt,isRequest:Vt,isResponse:Kt,isHeaders:Yt,isUndefined:At,isDate:Ft,isFile:Dt,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:qt,isRegExp:an,isFunction:Pt,isStream:e=>Lt(e)&&Pt(e.pipe),isURLSearchParams:Gt,isTypedArray:tn,isFileList:Bt,forEach:Zt,merge:function e(...t){const{caseless:n,skipUndefined:o}=en(this)&&this||{},i={},a=(t,a)=>{if("__proto__"===a||"constructor"===a||"prototype"===a)return;const r=n&&"string"==typeof a&&Xt(i,a)||a,s=kt(i,r)?i[r]:void 0;zt(s)&&zt(t)?i[r]=e(s,t):zt(t)?i[r]=e({},t):Ot(t)?i[r]=t.slice():o&&At(t)||(i[r]=t)};for(let e=0,n=t.length;e<n;e++){const n=t[e];if(!n||Ct(n))continue;if(Zt(n,a),"object"!=typeof n||Ot(n))continue;const o=Object.getOwnPropertySymbols(n);for(let e=0;e<o.length;e++){const t=o[e];on.call(n,t)&&a(n[t],t)}}return i},extend:(e,t,n,{allOwnKeys:o}={})=>(Zt(t,(t,o)=>{n&&Pt(t)?Object.defineProperty(e,o,{__proto__:null,value:xt(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,o)=>{e.prototype=Object.create(t.prototype,o),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,o)=>{let i,a,r;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)r=i[a],o&&!o(r,e,t)||s[r]||(t[r]=e[r],s[r]=!0);e=!1!==n&&wt(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Et,kindOfTest:Tt,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length);const o=e.indexOf(t,n-=t.length);return-1!==o&&o===n},toArray:e=>{if(!e)return null;if(Ot(e))return e;let t=e.length;if(!Ut(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[_t]).call(e);let o;for(;(o=n.next())&&!o.done;){const n=o.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const o=[];for(;null!==(n=e.exec(t));)o.push(n);return o},isHTMLForm:nn,hasOwnProperty:kt,hasOwnProp:kt,hasOwnInPrototypeChain:St,getSafeProp:(e,t)=>null!=e&&St(e,t)?e[t]:void 0,reduceDescriptors:rn,freezeMethods:e=>{rn(e,(t,n)=>{if(Pt(e)&&["arguments","caller","callee"].includes(n))return!1;Pt(e[n])&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},o=e=>{e.forEach(e=>{n[e]=!0})};return Ot(e)?o(e):o(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Xt,global:Qt,isContextDefined:en,isSpecCompliantForm:function(e){return!!(e&&Pt(e.append)&&"FormData"===e[jt]&&e[_t])},toJSONObject:e=>{const t=new WeakSet,n=e=>{if(Lt(e)){if(t.has(e))return;if(Ct(e))return e;if(!("toJSON"in e)){let o;if(t.add(e),Mt(e)){o=[];for(const t of e){const e=n(t);!At(e)&&o.push(e)}}else o=Ot(e)?[]:{},Zt(e,(e,t)=>{const i=n(e);!At(i)&&(o[t]=i)});return t.delete(e),o}}return e};return n(e)},isAsyncFn:sn,isThenable:e=>e&&(Lt(e)||Pt(e))&&Pt(e.then)&&Pt(e.catch),setImmediate:cn,asap:mn,isIterable:fn,isSafeIterable:e=>null!=e&&St(e,_t)&&fn(e)};const gn=hn.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),vn=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),bn=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function xn(e,t){return hn.isArray(e)?e.map(e=>xn(e,t)):function(e){let t=0,n=e.length;for(;t<n;){const n=e.charCodeAt(t);if(9!==n&&32!==n)break;t+=1}for(;n>t;){const t=e.charCodeAt(n-1);if(9!==t&&32!==t)break;n-=1}return 0===t&&n===e.length?e:e.slice(t,n)}(String(e).replace(t,""))}function yn(e){const t=Object.create(null);return hn.forEach(e.toJSON(),(e,n)=>{t[n]=(e=>xn(e,bn))(e)}),t}const wn=Symbol("internals");function _n(e){return e&&String(e).trim().toLowerCase()}function jn(e){return!1===e||null==e?e:hn.isArray(e)?e.map(jn):(e=>xn(e,vn))(String(e))}const kn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Sn(e){let t=0,n=e.length;for(;t<n;){const n=e.charCodeAt(t);if(9!==n&&32!==n)break;t+=1}for(;n>t;){const t=e.charCodeAt(n-1);if(9!==t&&32!==t)break;n-=1}return 0===t&&n===e.length?e:e.slice(t,n)}function En(e,t,n,o,i){return hn.isFunction(o)?o.call(this,t,n):(i&&(t=n),hn.isString(t)?hn.isString(o)?-1!==t.indexOf(o):hn.isRegExp(o)?o.test(t):void 0:void 0)}class $n{constructor(e){e&&this.set(e)}set(e,t,n){const o=this;function i(e,t,n){const i=_n(t);if(!i)return;const a=hn.findKey(o,i);(!a||void 0===o[a]||!0===n||void 0===n&&!1!==o[a])&&(o[a||t]=jn(e))}const a=(e,t)=>hn.forEach(e,(e,n)=>i(e,n,t));if(hn.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(hn.isString(e)&&(e=e.trim())&&!(e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))(e))a((e=>{const t={};let n,o,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),o=e.substring(i+1).trim();const a=hn.hasOwnProp(t,n);!n||a&&hn.hasOwnProp(gn,n)||("set-cookie"===n?a?t[n].push(o):t[n]=[o]:t[n]=a?t[n]+", "+o:o)}),t})(e),t);else if(hn.isObject(e)&&hn.isSafeIterable(e)){let n,o,i=Object.create(null);for(const t of e){if(!hn.isArray(t))throw new TypeError("Object iterator must return a key-value pair");o=t[0],hn.hasOwnProp(i,o)?(n=i[o],i[o]=hn.isArray(n)?[...n,t[1]]:[n,t[1]]):i[o]=t[1]}a(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=_n(e)){const n=hn.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(e);)t[o[1]]=o[2];return t}(e);if(hn.isFunction(t))return t.call(this,e,n);if(hn.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=_n(e)){const n=hn.findKey(this,e);return!(!n||void 0===this[n]||t&&!En(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function i(e){if(e=_n(e)){const i=hn.findKey(n,e);!i||t&&!En(0,n[i],i,t)||(delete n[i],o=!0)}}return hn.isArray(e)?e.forEach(i):i(e),o}clear(e){const t=Object.keys(this);let n=t.length,o=!1;for(;n--;){const i=t[n];e&&!En(0,this[i],i,e,!0)||(delete this[i],o=!0)}return o}normalize(e){const t=this,n={};return hn.forEach(this,(o,i)=>{const a=hn.findKey(n,i);if(a)return t[a]=jn(o),void delete t[i];const r=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();r!==i&&delete t[i],t[r]=jn(o),n[r]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return hn.forEach(this,(n,o)=>{null!=n&&!1!==n&&(t[o]=e&&hn.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){const e=this.get("set-cookie");return hn.isArray(e)?e:null==e||!1===e?[]:[e]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static parseParameters(e){return function(e){const t=Object.create(null),n=String(e);let o=0,i=!1,a=!1;function r(e){const i=Sn(n.slice(o,e)),a=i.indexOf("=");if(a<1)return;const r=Sn(i.slice(0,a));if(!kn.test(r))return;const s=r.toLowerCase();if("__proto__"===s||"constructor"===s||"prototype"===s)return;const c=Sn(i.slice(a+1));t[s]=function(e){const t=e.length-1;if(t<1||34!==e.charCodeAt(0)||34!==e.charCodeAt(t))return e;let n="";for(let o=1;o<t;o++){const i=e.charCodeAt(o);if(34===i)return e;if(92===i&&(o+=1,o>=t))return e;n+=e[o]}return n}(c)}for(let e=0;e<n.length;e++){const t=n.charCodeAt(e);i?a?a=!1:92===t?a=!0:34===t&&(i=!1):34===t?i=!0:44!==t&&59!==t||(r(e),o=e+1)}return r(n.length),t}(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[wn]=this[wn]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=_n(e);t[o]||(function(e,t){const n=hn.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+n,{__proto__:null,value:function(e,n,i){return this[o].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[o]=!0)}return hn.isArray(e)?e.forEach(o):o(e),this}}$n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),hn.reduceDescriptors($n.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),hn.freezeMethods($n);var Tn=$n;const In="[REDACTED ****]";class On extends Error{static from(e,t,n,o,i,a){let r=e.message;!r&&hn.isArray(e.errors)&&e.errors.length&&(r=function(e){return e.errors.map(e=>{try{return function(e){try{return String(e)}catch(e){return""}}(e&&e.message?e.message:e)}catch(e){return""}}).filter(Boolean).join("; ")||e.name||"AggregateError"}(e));const s=new On(r,t||e.code,n,o,i);return Object.defineProperty(s,"cause",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),s.name=e.name,null!=e.status&&null==s.status&&(s.status=e.status),a&&Object.assign(s,a),s}constructor(e,t,n,o,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){const e=this.config,t=e&&hn.hasOwnProp(e,"redact")?e.redact:void 0,n=hn.isArray(t)&&t.length>0?function(e,t){const n=new Set(t.map(e=>String(e).toLowerCase())),o=[],i=e=>{if(null===e||"object"!=typeof e)return e;if(hn.isBuffer(e))return e;if(-1!==o.indexOf(e))return;let t;if(e instanceof Tn&&(e=e.toJSON()),o.push(e),hn.isArray(e))t=[],e.forEach((e,n)=>{const o=i(e);hn.isUndefined(o)||(t[n]=o)});else{if(!hn.isPlainObject(e)&&function(e){if(hn.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(hn.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}(e))return o.pop(),e;t=Object.create(null);for(const[o,a]of Object.entries(e)){const e=n.has(o.toLowerCase())?In:i(a);hn.isUndefined(e)||(t[o]=e)}}return o.pop(),t};return i(e)}(e,t):hn.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}}On.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",On.ERR_BAD_OPTION="ERR_BAD_OPTION",On.ECONNABORTED="ECONNABORTED",On.ETIMEDOUT="ETIMEDOUT",On.ECONNREFUSED="ECONNREFUSED",On.ERR_NETWORK="ERR_NETWORK",On.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",On.ERR_DEPRECATED="ERR_DEPRECATED",On.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",On.ERR_BAD_REQUEST="ERR_BAD_REQUEST",On.ERR_CANCELED="ERR_CANCELED",On.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",On.ERR_INVALID_URL="ERR_INVALID_URL",On.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var An=On,Cn=ge.Stream,Rn=Nn;function Nn(){this.source=null,this.dataSize=0,this.maxDataSize=1048576,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}he.inherits(Nn,Cn),Nn.create=function(e,t){var n=new this;for(var o in t=t||{})n[o]=t[o];n.source=e;var i=e.emit;return e.emit=function(){return n._handleEmit(arguments),i.apply(e,arguments)},e.on("error",function(){}),n.pauseStream&&e.pause(),n},Object.defineProperty(Nn.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}}),Nn.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)},Nn.prototype.resume=function(){this._released||this.release(),this.source.resume()},Nn.prototype.pause=function(){this.source.pause()},Nn.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(e){this.emit.apply(this,e)}.bind(this)),this._bufferedEvents=[]},Nn.prototype.pipe=function(){var e=Cn.prototype.pipe.apply(this,arguments);return this.resume(),e},Nn.prototype._handleEmit=function(e){this._released?this.emit.apply(this,e):("data"===e[0]&&(this.dataSize+=e[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(e))},Nn.prototype._checkIfMaxDataSizeExceeded=function(){this._maxDataSizeExceeded||this.dataSize<=this.maxDataSize||(this._maxDataSizeExceeded=!0,this.emit("error",new Error("DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.")))};var Pn=ge.Stream,Un=Ln;function Ln(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2097152,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}he.inherits(Ln,Pn),Ln.create=function(e){var t=new this;for(var n in e=e||{})t[n]=e[n];return t},Ln.isStreamLike=function(e){return"function"!=typeof e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Buffer.isBuffer(e)},Ln.prototype.append=function(e){if(Ln.isStreamLike(e)){if(!(e instanceof Rn)){var t=Rn.create(e,{maxDataSize:Infinity,pauseStream:this.pauseStreams});e.on("data",this._checkDataSize.bind(this)),e=t}this._handleErrors(e),this.pauseStreams&&e.pause()}return this._streams.push(e),this},Ln.prototype.pipe=function(e,t){return Pn.prototype.pipe.call(this,e,t),this.resume(),e},Ln.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop)this._pendingNext=!0;else{this._insideLoop=!0;try{do{this._pendingNext=!1,this._realGetNext()}while(this._pendingNext)}finally{this._insideLoop=!1}}},Ln.prototype._realGetNext=function(){var e=this._streams.shift();void 0!==e?"function"==typeof e?e(function(e){Ln.isStreamLike(e)&&(e.on("data",this._checkDataSize.bind(this)),this._handleErrors(e)),this._pipeNext(e)}.bind(this)):this._pipeNext(e):this.end()},Ln.prototype._pipeNext=function(e){if(this._currentStream=e,Ln.isStreamLike(e))return e.on("end",this._getNext.bind(this)),void e.pipe(this,{end:!1});this.write(e),this._getNext()},Ln.prototype._handleErrors=function(e){var t=this;e.on("error",function(e){t._emitError(e)})},Ln.prototype.write=function(e){this.emit("data",e)},Ln.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.pause&&this._currentStream.pause(),this.emit("pause"))},Ln.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.resume&&this._currentStream.resume(),this.emit("resume")},Ln.prototype.end=function(){this._reset(),this.emit("end")},Ln.prototype.destroy=function(){this._reset(),this.emit("close")},Ln.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null},Ln.prototype._checkDataSize=function(){this._updateDataSize(),this.dataSize<=this.maxDataSize||this._emitError(new Error("DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded."))},Ln.prototype._updateDataSize=function(){this.dataSize=0;var e=this;this._streams.forEach(function(t){t.dataSize&&(e.dataSize+=t.dataSize)}),this._currentStream&&this._currentStream.dataSize&&(this.dataSize+=this._currentStream.dataSize)},Ln.prototype._emitError=function(e){this._reset(),this.emit("error",e)};var zn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Fn(e){var t={exports:{}};return e(t,t.exports),t.exports}var Dn={"application/1d-interleaved-parityfec":{source:"iana"},"application/3gpdash-qoe-report+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/3gpp-ims+xml":{source:"iana",compressible:!0},"application/3gpphal+json":{source:"iana",compressible:!0},"application/3gpphalforms+json":{source:"iana",compressible:!0},"application/a2l":{source:"iana"},"application/ace+cbor":{source:"iana"},"application/activemessage":{source:"iana"},"application/activity+json":{source:"iana",compressible:!0},"application/alto-costmap+json":{source:"iana",compressible:!0},"application/alto-costmapfilter+json":{source:"iana",compressible:!0},"application/alto-directory+json":{source:"iana",compressible:!0},"application/alto-endpointcost+json":{source:"iana",compressible:!0},"application/alto-endpointcostparams+json":{source:"iana",compressible:!0},"application/alto-endpointprop+json":{source:"iana",compressible:!0},"application/alto-endpointpropparams+json":{source:"iana",compressible:!0},"application/alto-error+json":{source:"iana",compressible:!0},"application/alto-networkmap+json":{source:"iana",compressible:!0},"application/alto-networkmapfilter+json":{source:"iana",compressible:!0},"application/alto-updatestreamcontrol+json":{source:"iana",compressible:!0},"application/alto-updatestreamparams+json":{source:"iana",compressible:!0},"application/aml":{source:"iana"},"application/andrew-inset":{source:"iana",extensions:["ez"]},"application/applefile":{source:"iana"},"application/applixware":{source:"apache",extensions:["aw"]},"application/at+jwt":{source:"iana"},"application/atf":{source:"iana"},"application/atfx":{source:"iana"},"application/atom+xml":{source:"iana",compressible:!0,extensions:["atom"]},"application/atomcat+xml":{source:"iana",compressible:!0,extensions:["atomcat"]},"application/atomdeleted+xml":{source:"iana",compressible:!0,extensions:["atomdeleted"]},"application/atomicmail":{source:"iana"},"application/atomsvc+xml":{source:"iana",compressible:!0,extensions:["atomsvc"]},"application/atsc-dwd+xml":{source:"iana",compressible:!0,extensions:["dwd"]},"application/atsc-dynamic-event-message":{source:"iana"},"application/atsc-held+xml":{source:"iana",compressible:!0,extensions:["held"]},"application/atsc-rdt+json":{source:"iana",compressible:!0},"application/atsc-rsat+xml":{source:"iana",compressible:!0,extensions:["rsat"]},"application/atxml":{source:"iana"},"application/auth-policy+xml":{source:"iana",compressible:!0},"application/bacnet-xdd+zip":{source:"iana",compressible:!1},"application/batch-smtp":{source:"iana"},"application/bdoc":{compressible:!1,extensions:["bdoc"]},"application/beep+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/calendar+json":{source:"iana",compressible:!0},"application/calendar+xml":{source:"iana",compressible:!0,extensions:["xcs"]},"application/call-completion":{source:"iana"},"application/cals-1840":{source:"iana"},"application/captive+json":{source:"iana",compressible:!0},"application/cbor":{source:"iana"},"application/cbor-seq":{source:"iana"},"application/cccex":{source:"iana"},"application/ccmp+xml":{source:"iana",compressible:!0},"application/ccxml+xml":{source:"iana",compressible:!0,extensions:["ccxml"]},"application/cdfx+xml":{source:"iana",compressible:!0,extensions:["cdfx"]},"application/cdmi-capability":{source:"iana",extensions:["cdmia"]},"application/cdmi-container":{source:"iana",extensions:["cdmic"]},"application/cdmi-domain":{source:"iana",extensions:["cdmid"]},"application/cdmi-object":{source:"iana",extensions:["cdmio"]},"application/cdmi-queue":{source:"iana",extensions:["cdmiq"]},"application/cdni":{source:"iana"},"application/cea":{source:"iana"},"application/cea-2018+xml":{source:"iana",compressible:!0},"application/cellml+xml":{source:"iana",compressible:!0},"application/cfw":{source:"iana"},"application/city+json":{source:"iana",compressible:!0},"application/clr":{source:"iana"},"application/clue+xml":{source:"iana",compressible:!0},"application/clue_info+xml":{source:"iana",compressible:!0},"application/cms":{source:"iana"},"application/cnrp+xml":{source:"iana",compressible:!0},"application/coap-group+json":{source:"iana",compressible:!0},"application/coap-payload":{source:"iana"},"application/commonground":{source:"iana"},"application/conference-info+xml":{source:"iana",compressible:!0},"application/cose":{source:"iana"},"application/cose-key":{source:"iana"},"application/cose-key-set":{source:"iana"},"application/cpl+xml":{source:"iana",compressible:!0,extensions:["cpl"]},"application/csrattrs":{source:"iana"},"application/csta+xml":{source:"iana",compressible:!0},"application/cstadata+xml":{source:"iana",compressible:!0},"application/csvm+json":{source:"iana",compressible:!0},"application/cu-seeme":{source:"apache",extensions:["cu"]},"application/cwt":{source:"iana"},"application/cybercash":{source:"iana"},"application/dart":{compressible:!0},"application/dash+xml":{source:"iana",compressible:!0,extensions:["mpd"]},"application/dash-patch+xml":{source:"iana",compressible:!0,extensions:["mpp"]},"application/dashdelta":{source:"iana"},"application/davmount+xml":{source:"iana",compressible:!0,extensions:["davmount"]},"application/dca-rft":{source:"iana"},"application/dcd":{source:"iana"},"application/dec-dx":{source:"iana"},"application/dialog-info+xml":{source:"iana",compressible:!0},"application/dicom":{source:"iana"},"application/dicom+json":{source:"iana",compressible:!0},"application/dicom+xml":{source:"iana",compressible:!0},"application/dii":{source:"iana"},"application/dit":{source:"iana"},"application/dns":{source:"iana"},"application/dns+json":{source:"iana",compressible:!0},"application/dns-message":{source:"iana"},"application/docbook+xml":{source:"apache",compressible:!0,extensions:["dbk"]},"application/dots+cbor":{source:"iana"},"application/dskpp+xml":{source:"iana",compressible:!0},"application/dssc+der":{source:"iana",extensions:["dssc"]},"application/dssc+xml":{source:"iana",compressible:!0,extensions:["xdssc"]},"application/dvcs":{source:"iana"},"application/ecmascript":{source:"iana",compressible:!0,extensions:["es","ecma"]},"application/edi-consent":{source:"iana"},"application/edi-x12":{source:"iana",compressible:!1},"application/edifact":{source:"iana",compressible:!1},"application/efi":{source:"iana"},"application/elm+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/elm+xml":{source:"iana",compressible:!0},"application/emergencycalldata.cap+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/emergencycalldata.comment+xml":{source:"iana",compressible:!0},"application/emergencycalldata.control+xml":{source:"iana",compressible:!0},"application/emergencycalldata.deviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.ecall.msd":{source:"iana"},"application/emergencycalldata.providerinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.serviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.subscriberinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.veds+xml":{source:"iana",compressible:!0},"application/emma+xml":{source:"iana",compressible:!0,extensions:["emma"]},"application/emotionml+xml":{source:"iana",compressible:!0,extensions:["emotionml"]},"application/encaprtp":{source:"iana"},"application/epp+xml":{source:"iana",compressible:!0},"application/epub+zip":{source:"iana",compressible:!1,extensions:["epub"]},"application/eshop":{source:"iana"},"application/exi":{source:"iana",extensions:["exi"]},"application/expect-ct-report+json":{source:"iana",compressible:!0},"application/express":{source:"iana",extensions:["exp"]},"application/fastinfoset":{source:"iana"},"application/fastsoap":{source:"iana"},"application/fdt+xml":{source:"iana",compressible:!0,extensions:["fdt"]},"application/fhir+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/fhir+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/fido.trusted-apps+json":{compressible:!0},"application/fits":{source:"iana"},"application/flexfec":{source:"iana"},"application/font-sfnt":{source:"iana"},"application/font-tdpfr":{source:"iana",extensions:["pfr"]},"application/font-woff":{source:"iana",compressible:!1},"application/framework-attributes+xml":{source:"iana",compressible:!0},"application/geo+json":{source:"iana",compressible:!0,extensions:["geojson"]},"application/geo+json-seq":{source:"iana"},"application/geopackage+sqlite3":{source:"iana"},"application/geoxacml+xml":{source:"iana",compressible:!0},"application/gltf-buffer":{source:"iana"},"application/gml+xml":{source:"iana",compressible:!0,extensions:["gml"]},"application/gpx+xml":{source:"apache",compressible:!0,extensions:["gpx"]},"application/gxf":{source:"apache",extensions:["gxf"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/h224":{source:"iana"},"application/held+xml":{source:"iana",compressible:!0},"application/hjson":{extensions:["hjson"]},"application/http":{source:"iana"},"application/hyperstudio":{source:"iana",extensions:["stk"]},"application/ibe-key-request+xml":{source:"iana",compressible:!0},"application/ibe-pkg-reply+xml":{source:"iana",compressible:!0},"application/ibe-pp-data":{source:"iana"},"application/iges":{source:"iana"},"application/im-iscomposing+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/index":{source:"iana"},"application/index.cmd":{source:"iana"},"application/index.obj":{source:"iana"},"application/index.response":{source:"iana"},"application/index.vnd":{source:"iana"},"application/inkml+xml":{source:"iana",compressible:!0,extensions:["ink","inkml"]},"application/iotp":{source:"iana"},"application/ipfix":{source:"iana",extensions:["ipfix"]},"application/ipp":{source:"iana"},"application/isup":{source:"iana"},"application/its+xml":{source:"iana",compressible:!0,extensions:["its"]},"application/java-archive":{source:"apache",compressible:!1,extensions:["jar","war","ear"]},"application/java-serialized-object":{source:"apache",compressible:!1,extensions:["ser"]},"application/java-vm":{source:"apache",compressible:!1,extensions:["class"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/jf2feed+json":{source:"iana",compressible:!0},"application/jose":{source:"iana"},"application/jose+json":{source:"iana",compressible:!0},"application/jrd+json":{source:"iana",compressible:!0},"application/jscalendar+json":{source:"iana",compressible:!0},"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/json-patch+json":{source:"iana",compressible:!0},"application/json-seq":{source:"iana"},"application/json5":{extensions:["json5"]},"application/jsonml+json":{source:"apache",compressible:!0,extensions:["jsonml"]},"application/jwk+json":{source:"iana",compressible:!0},"application/jwk-set+json":{source:"iana",compressible:!0},"application/jwt":{source:"iana"},"application/kpml-request+xml":{source:"iana",compressible:!0},"application/kpml-response+xml":{source:"iana",compressible:!0},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/lgr+xml":{source:"iana",compressible:!0,extensions:["lgr"]},"application/link-format":{source:"iana"},"application/load-control+xml":{source:"iana",compressible:!0},"application/lost+xml":{source:"iana",compressible:!0,extensions:["lostxml"]},"application/lostsync+xml":{source:"iana",compressible:!0},"application/lpf+zip":{source:"iana",compressible:!1},"application/lxf":{source:"iana"},"application/mac-binhex40":{source:"iana",extensions:["hqx"]},"application/mac-compactpro":{source:"apache",extensions:["cpt"]},"application/macwriteii":{source:"iana"},"application/mads+xml":{source:"iana",compressible:!0,extensions:["mads"]},"application/manifest+json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/marc":{source:"iana",extensions:["mrc"]},"application/marcxml+xml":{source:"iana",compressible:!0,extensions:["mrcx"]},"application/mathematica":{source:"iana",extensions:["ma","nb","mb"]},"application/mathml+xml":{source:"iana",compressible:!0,extensions:["mathml"]},"application/mathml-content+xml":{source:"iana",compressible:!0},"application/mathml-presentation+xml":{source:"iana",compressible:!0},"application/mbms-associated-procedure-description+xml":{source:"iana",compressible:!0},"application/mbms-deregister+xml":{source:"iana",compressible:!0},"application/mbms-envelope+xml":{source:"iana",compressible:!0},"application/mbms-msk+xml":{source:"iana",compressible:!0},"application/mbms-msk-response+xml":{source:"iana",compressible:!0},"application/mbms-protection-description+xml":{source:"iana",compressible:!0},"application/mbms-reception-report+xml":{source:"iana",compressible:!0},"application/mbms-register+xml":{source:"iana",compressible:!0},"application/mbms-register-response+xml":{source:"iana",compressible:!0},"application/mbms-schedule+xml":{source:"iana",compressible:!0},"application/mbms-user-service-description+xml":{source:"iana",compressible:!0},"application/mbox":{source:"iana",extensions:["mbox"]},"application/media-policy-dataset+xml":{source:"iana",compressible:!0,extensions:["mpf"]},"application/media_control+xml":{source:"iana",compressible:!0},"application/mediaservercontrol+xml":{source:"iana",compressible:!0,extensions:["mscml"]},"application/merge-patch+json":{source:"iana",compressible:!0},"application/metalink+xml":{source:"apache",compressible:!0,extensions:["metalink"]},"application/metalink4+xml":{source:"iana",compressible:!0,extensions:["meta4"]},"application/mets+xml":{source:"iana",compressible:!0,extensions:["mets"]},"application/mf4":{source:"iana"},"application/mikey":{source:"iana"},"application/mipc":{source:"iana"},"application/missing-blocks+cbor-seq":{source:"iana"},"application/mmt-aei+xml":{source:"iana",compressible:!0,extensions:["maei"]},"application/mmt-usd+xml":{source:"iana",compressible:!0,extensions:["musd"]},"application/mods+xml":{source:"iana",compressible:!0,extensions:["mods"]},"application/moss-keys":{source:"iana"},"application/moss-signature":{source:"iana"},"application/mosskey-data":{source:"iana"},"application/mosskey-request":{source:"iana"},"application/mp21":{source:"iana",extensions:["m21","mp21"]},"application/mp4":{source:"iana",extensions:["mp4s","m4p"]},"application/mpeg4-generic":{source:"iana"},"application/mpeg4-iod":{source:"iana"},"application/mpeg4-iod-xmt":{source:"iana"},"application/mrb-consumer+xml":{source:"iana",compressible:!0},"application/mrb-publish+xml":{source:"iana",compressible:!0},"application/msc-ivr+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msc-mixer+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msword":{source:"iana",compressible:!1,extensions:["doc","dot"]},"application/mud+json":{source:"iana",compressible:!0},"application/multipart-core":{source:"iana"},"application/mxf":{source:"iana",extensions:["mxf"]},"application/n-quads":{source:"iana",extensions:["nq"]},"application/n-triples":{source:"iana",extensions:["nt"]},"application/nasdata":{source:"iana"},"application/news-checkgroups":{source:"iana",charset:"US-ASCII"},"application/news-groupinfo":{source:"iana",charset:"US-ASCII"},"application/news-transmission":{source:"iana"},"application/nlsml+xml":{source:"iana",compressible:!0},"application/node":{source:"iana",extensions:["cjs"]},"application/nss":{source:"iana"},"application/oauth-authz-req+jwt":{source:"iana"},"application/oblivious-dns-message":{source:"iana"},"application/ocsp-request":{source:"iana"},"application/ocsp-response":{source:"iana"},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{source:"iana",extensions:["oda"]},"application/odm+xml":{source:"iana",compressible:!0},"application/odx":{source:"iana"},"application/oebps-package+xml":{source:"iana",compressible:!0,extensions:["opf"]},"application/ogg":{source:"iana",compressible:!1,extensions:["ogx"]},"application/omdoc+xml":{source:"apache",compressible:!0,extensions:["omdoc"]},"application/onenote":{source:"apache",extensions:["onetoc","onetoc2","onetmp","onepkg"]},"application/opc-nodeset+xml":{source:"iana",compressible:!0},"application/oscore":{source:"iana"},"application/oxps":{source:"iana",extensions:["oxps"]},"application/p21":{source:"iana"},"application/p21+zip":{source:"iana",compressible:!1},"application/p2p-overlay+xml":{source:"iana",compressible:!0,extensions:["relo"]},"application/parityfec":{source:"iana"},"application/passport":{source:"iana"},"application/patch-ops-error+xml":{source:"iana",compressible:!0,extensions:["xer"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/pdx":{source:"iana"},"application/pem-certificate-chain":{source:"iana"},"application/pgp-encrypted":{source:"iana",compressible:!1,extensions:["pgp"]},"application/pgp-keys":{source:"iana",extensions:["asc"]},"application/pgp-signature":{source:"iana",extensions:["asc","sig"]},"application/pics-rules":{source:"apache",extensions:["prf"]},"application/pidf+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pidf-diff+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pkcs10":{source:"iana",extensions:["p10"]},"application/pkcs12":{source:"iana"},"application/pkcs7-mime":{source:"iana",extensions:["p7m","p7c"]},"application/pkcs7-signature":{source:"iana",extensions:["p7s"]},"application/pkcs8":{source:"iana",extensions:["p8"]},"application/pkcs8-encrypted":{source:"iana"},"application/pkix-attr-cert":{source:"iana",extensions:["ac"]},"application/pkix-cert":{source:"iana",extensions:["cer"]},"application/pkix-crl":{source:"iana",extensions:["crl"]},"application/pkix-pkipath":{source:"iana",extensions:["pkipath"]},"application/pkixcmp":{source:"iana",extensions:["pki"]},"application/pls+xml":{source:"iana",compressible:!0,extensions:["pls"]},"application/poc-settings+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/postscript":{source:"iana",compressible:!0,extensions:["ai","eps","ps"]},"application/ppsp-tracker+json":{source:"iana",compressible:!0},"application/problem+json":{source:"iana",compressible:!0},"application/problem+xml":{source:"iana",compressible:!0},"application/provenance+xml":{source:"iana",compressible:!0,extensions:["provx"]},"application/prs.alvestrand.titrax-sheet":{source:"iana"},"application/prs.cww":{source:"iana",extensions:["cww"]},"application/prs.cyn":{source:"iana",charset:"7-BIT"},"application/prs.hpub+zip":{source:"iana",compressible:!1},"application/prs.nprend":{source:"iana"},"application/prs.plucker":{source:"iana"},"application/prs.rdf-xml-crypt":{source:"iana"},"application/prs.xsf+xml":{source:"iana",compressible:!0},"application/pskc+xml":{source:"iana",compressible:!0,extensions:["pskcxml"]},"application/pvd+json":{source:"iana",compressible:!0},"application/qsig":{source:"iana"},"application/raml+yaml":{compressible:!0,extensions:["raml"]},"application/raptorfec":{source:"iana"},"application/rdap+json":{source:"iana",compressible:!0},"application/rdf+xml":{source:"iana",compressible:!0,extensions:["rdf","owl"]},"application/reginfo+xml":{source:"iana",compressible:!0,extensions:["rif"]},"application/relax-ng-compact-syntax":{source:"iana",extensions:["rnc"]},"application/remote-printing":{source:"iana"},"application/reputon+json":{source:"iana",compressible:!0},"application/resource-lists+xml":{source:"iana",compressible:!0,extensions:["rl"]},"application/resource-lists-diff+xml":{source:"iana",compressible:!0,extensions:["rld"]},"application/rfc+xml":{source:"iana",compressible:!0},"application/riscos":{source:"iana"},"application/rlmi+xml":{source:"iana",compressible:!0},"application/rls-services+xml":{source:"iana",compressible:!0,extensions:["rs"]},"application/route-apd+xml":{source:"iana",compressible:!0,extensions:["rapd"]},"application/route-s-tsid+xml":{source:"iana",compressible:!0,extensions:["sls"]},"application/route-usd+xml":{source:"iana",compressible:!0,extensions:["rusd"]},"application/rpki-ghostbusters":{source:"iana",extensions:["gbr"]},"application/rpki-manifest":{source:"iana",extensions:["mft"]},"application/rpki-publication":{source:"iana"},"application/rpki-roa":{source:"iana",extensions:["roa"]},"application/rpki-updown":{source:"iana"},"application/rsd+xml":{source:"apache",compressible:!0,extensions:["rsd"]},"application/rss+xml":{source:"apache",compressible:!0,extensions:["rss"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/rtploopback":{source:"iana"},"application/rtx":{source:"iana"},"application/samlassertion+xml":{source:"iana",compressible:!0},"application/samlmetadata+xml":{source:"iana",compressible:!0},"application/sarif+json":{source:"iana",compressible:!0},"application/sarif-external-properties+json":{source:"iana",compressible:!0},"application/sbe":{source:"iana"},"application/sbml+xml":{source:"iana",compressible:!0,extensions:["sbml"]},"application/scaip+xml":{source:"iana",compressible:!0},"application/scim+json":{source:"iana",compressible:!0},"application/scvp-cv-request":{source:"iana",extensions:["scq"]},"application/scvp-cv-response":{source:"iana",extensions:["scs"]},"application/scvp-vp-request":{source:"iana",extensions:["spq"]},"application/scvp-vp-response":{source:"iana",extensions:["spp"]},"application/sdp":{source:"iana",extensions:["sdp"]},"application/secevent+jwt":{source:"iana"},"application/senml+cbor":{source:"iana"},"application/senml+json":{source:"iana",compressible:!0},"application/senml+xml":{source:"iana",compressible:!0,extensions:["senmlx"]},"application/senml-etch+cbor":{source:"iana"},"application/senml-etch+json":{source:"iana",compressible:!0},"application/senml-exi":{source:"iana"},"application/sensml+cbor":{source:"iana"},"application/sensml+json":{source:"iana",compressible:!0},"application/sensml+xml":{source:"iana",compressible:!0,extensions:["sensmlx"]},"application/sensml-exi":{source:"iana"},"application/sep+xml":{source:"iana",compressible:!0},"application/sep-exi":{source:"iana"},"application/session-info":{source:"iana"},"application/set-payment":{source:"iana"},"application/set-payment-initiation":{source:"iana",extensions:["setpay"]},"application/set-registration":{source:"iana"},"application/set-registration-initiation":{source:"iana",extensions:["setreg"]},"application/sgml":{source:"iana"},"application/sgml-open-catalog":{source:"iana"},"application/shf+xml":{source:"iana",compressible:!0,extensions:["shf"]},"application/sieve":{source:"iana",extensions:["siv","sieve"]},"application/simple-filter+xml":{source:"iana",compressible:!0},"application/simple-message-summary":{source:"iana"},"application/simplesymbolcontainer":{source:"iana"},"application/sipc":{source:"iana"},"application/slate":{source:"iana"},"application/smil":{source:"iana"},"application/smil+xml":{source:"iana",compressible:!0,extensions:["smi","smil"]},"application/smpte336m":{source:"iana"},"application/soap+fastinfoset":{source:"iana"},"application/soap+xml":{source:"iana",compressible:!0},"application/sparql-query":{source:"iana",extensions:["rq"]},"application/sparql-results+xml":{source:"iana",compressible:!0,extensions:["srx"]},"application/spdx+json":{source:"iana",compressible:!0},"application/spirits-event+xml":{source:"iana",compressible:!0},"application/sql":{source:"iana"},"application/srgs":{source:"iana",extensions:["gram"]},"application/srgs+xml":{source:"iana",compressible:!0,extensions:["grxml"]},"application/sru+xml":{source:"iana",compressible:!0,extensions:["sru"]},"application/ssdl+xml":{source:"apache",compressible:!0,extensions:["ssdl"]},"application/ssml+xml":{source:"iana",compressible:!0,extensions:["ssml"]},"application/stix+json":{source:"iana",compressible:!0},"application/swid+xml":{source:"iana",compressible:!0,extensions:["swidtag"]},"application/tamp-apex-update":{source:"iana"},"application/tamp-apex-update-confirm":{source:"iana"},"application/tamp-community-update":{source:"iana"},"application/tamp-community-update-confirm":{source:"iana"},"application/tamp-error":{source:"iana"},"application/tamp-sequence-adjust":{source:"iana"},"application/tamp-sequence-adjust-confirm":{source:"iana"},"application/tamp-status-query":{source:"iana"},"application/tamp-status-response":{source:"iana"},"application/tamp-update":{source:"iana"},"application/tamp-update-confirm":{source:"iana"},"application/tar":{compressible:!0},"application/taxii+json":{source:"iana",compressible:!0},"application/td+json":{source:"iana",compressible:!0},"application/tei+xml":{source:"iana",compressible:!0,extensions:["tei","teicorpus"]},"application/tetra_isi":{source:"iana"},"application/thraud+xml":{source:"iana",compressible:!0,extensions:["tfi"]},"application/timestamp-query":{source:"iana"},"application/timestamp-reply":{source:"iana"},"application/timestamped-data":{source:"iana",extensions:["tsd"]},"application/tlsrpt+gzip":{source:"iana"},"application/tlsrpt+json":{source:"iana",compressible:!0},"application/tnauthlist":{source:"iana"},"application/token-introspection+jwt":{source:"iana"},"application/toml":{compressible:!0,extensions:["toml"]},"application/trickle-ice-sdpfrag":{source:"iana"},"application/trig":{source:"iana",extensions:["trig"]},"application/ttml+xml":{source:"iana",compressible:!0,extensions:["ttml"]},"application/tve-trigger":{source:"iana"},"application/tzif":{source:"iana"},"application/tzif-leap":{source:"iana"},"application/ubjson":{compressible:!1,extensions:["ubj"]},"application/ulpfec":{source:"iana"},"application/urc-grpsheet+xml":{source:"iana",compressible:!0},"application/urc-ressheet+xml":{source:"iana",compressible:!0,extensions:["rsheet"]},"application/urc-targetdesc+xml":{source:"iana",compressible:!0,extensions:["td"]},"application/urc-uisocketdesc+xml":{source:"iana",compressible:!0},"application/vcard+json":{source:"iana",compressible:!0},"application/vcard+xml":{source:"iana",compressible:!0},"application/vemmi":{source:"iana"},"application/vividence.scriptfile":{source:"apache"},"application/vnd.1000minds.decision-model+xml":{source:"iana",compressible:!0,extensions:["1km"]},"application/vnd.3gpp-prose+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-prose-pc3ch+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-v2x-local-service-information":{source:"iana"},"application/vnd.3gpp.5gnas":{source:"iana"},"application/vnd.3gpp.access-transfer-events+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.bsf+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gmop+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gtpc":{source:"iana"},"application/vnd.3gpp.interworking-data":{source:"iana"},"application/vnd.3gpp.lpp":{source:"iana"},"application/vnd.3gpp.mc-signalling-ear":{source:"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-payload":{source:"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-signalling":{source:"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-floor-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-signed+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-init-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-transmission-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mid-call+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ngap":{source:"iana"},"application/vnd.3gpp.pfcp":{source:"iana"},"application/vnd.3gpp.pic-bw-large":{source:"iana",extensions:["plb"]},"application/vnd.3gpp.pic-bw-small":{source:"iana",extensions:["psb"]},"application/vnd.3gpp.pic-bw-var":{source:"iana",extensions:["pvb"]},"application/vnd.3gpp.s1ap":{source:"iana"},"application/vnd.3gpp.sms":{source:"iana"},"application/vnd.3gpp.sms+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-ext+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.state-and-event-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ussd+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.bcmcsinfo+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.sms":{source:"iana"},"application/vnd.3gpp2.tcap":{source:"iana",extensions:["tcap"]},"application/vnd.3lightssoftware.imagescal":{source:"iana"},"application/vnd.3m.post-it-notes":{source:"iana",extensions:["pwn"]},"application/vnd.accpac.simply.aso":{source:"iana",extensions:["aso"]},"application/vnd.accpac.simply.imp":{source:"iana",extensions:["imp"]},"application/vnd.acucobol":{source:"iana",extensions:["acu"]},"application/vnd.acucorp":{source:"iana",extensions:["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{source:"apache",compressible:!1,extensions:["air"]},"application/vnd.adobe.flash.movie":{source:"iana"},"application/vnd.adobe.formscentral.fcdt":{source:"iana",extensions:["fcdt"]},"application/vnd.adobe.fxp":{source:"iana",extensions:["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{source:"iana"},"application/vnd.adobe.xdp+xml":{source:"iana",compressible:!0,extensions:["xdp"]},"application/vnd.adobe.xfdf":{source:"iana",extensions:["xfdf"]},"application/vnd.aether.imp":{source:"iana"},"application/vnd.afpc.afplinedata":{source:"iana"},"application/vnd.afpc.afplinedata-pagedef":{source:"iana"},"application/vnd.afpc.cmoca-cmresource":{source:"iana"},"application/vnd.afpc.foca-charset":{source:"iana"},"application/vnd.afpc.foca-codedfont":{source:"iana"},"application/vnd.afpc.foca-codepage":{source:"iana"},"application/vnd.afpc.modca":{source:"iana"},"application/vnd.afpc.modca-cmtable":{source:"iana"},"application/vnd.afpc.modca-formdef":{source:"iana"},"application/vnd.afpc.modca-mediummap":{source:"iana"},"application/vnd.afpc.modca-objectcontainer":{source:"iana"},"application/vnd.afpc.modca-overlay":{source:"iana"},"application/vnd.afpc.modca-pagesegment":{source:"iana"},"application/vnd.age":{source:"iana",extensions:["age"]},"application/vnd.ah-barcode":{source:"iana"},"application/vnd.ahead.space":{source:"iana",extensions:["ahead"]},"application/vnd.airzip.filesecure.azf":{source:"iana",extensions:["azf"]},"application/vnd.airzip.filesecure.azs":{source:"iana",extensions:["azs"]},"application/vnd.amadeus+json":{source:"iana",compressible:!0},"application/vnd.amazon.ebook":{source:"apache",extensions:["azw"]},"application/vnd.amazon.mobi8-ebook":{source:"iana"},"application/vnd.americandynamics.acc":{source:"iana",extensions:["acc"]},"application/vnd.amiga.ami":{source:"iana",extensions:["ami"]},"application/vnd.amundsen.maze+xml":{source:"iana",compressible:!0},"application/vnd.android.ota":{source:"iana"},"application/vnd.android.package-archive":{source:"apache",compressible:!1,extensions:["apk"]},"application/vnd.anki":{source:"iana"},"application/vnd.anser-web-certificate-issue-initiation":{source:"iana",extensions:["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{source:"apache",extensions:["fti"]},"application/vnd.antix.game-component":{source:"iana",extensions:["atx"]},"application/vnd.apache.arrow.file":{source:"iana"},"application/vnd.apache.arrow.stream":{source:"iana"},"application/vnd.apache.thrift.binary":{source:"iana"},"application/vnd.apache.thrift.compact":{source:"iana"},"application/vnd.apache.thrift.json":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/vnd.aplextor.warrp+json":{source:"iana",compressible:!0},"application/vnd.apothekende.reservation+json":{source:"iana",compressible:!0},"application/vnd.apple.installer+xml":{source:"iana",compressible:!0,extensions:["mpkg"]},"application/vnd.apple.keynote":{source:"iana",extensions:["key"]},"application/vnd.apple.mpegurl":{source:"iana",extensions:["m3u8"]},"application/vnd.apple.numbers":{source:"iana",extensions:["numbers"]},"application/vnd.apple.pages":{source:"iana",extensions:["pages"]},"application/vnd.apple.pkpass":{compressible:!1,extensions:["pkpass"]},"application/vnd.arastra.swi":{source:"iana"},"application/vnd.aristanetworks.swi":{source:"iana",extensions:["swi"]},"application/vnd.artisan+json":{source:"iana",compressible:!0},"application/vnd.artsquare":{source:"iana"},"application/vnd.astraea-software.iota":{source:"iana",extensions:["iota"]},"application/vnd.audiograph":{source:"iana",extensions:["aep"]},"application/vnd.autopackage":{source:"iana"},"application/vnd.avalon+json":{source:"iana",compressible:!0},"application/vnd.avistar+xml":{source:"iana",compressible:!0},"application/vnd.balsamiq.bmml+xml":{source:"iana",compressible:!0,extensions:["bmml"]},"application/vnd.balsamiq.bmpr":{source:"iana"},"application/vnd.banana-accounting":{source:"iana"},"application/vnd.bbf.usp.error":{source:"iana"},"application/vnd.bbf.usp.msg":{source:"iana"},"application/vnd.bbf.usp.msg+json":{source:"iana",compressible:!0},"application/vnd.bekitzur-stech+json":{source:"iana",compressible:!0},"application/vnd.bint.med-content":{source:"iana"},"application/vnd.biopax.rdf+xml":{source:"iana",compressible:!0},"application/vnd.blink-idb-value-wrapper":{source:"iana"},"application/vnd.blueice.multipass":{source:"iana",extensions:["mpm"]},"application/vnd.bluetooth.ep.oob":{source:"iana"},"application/vnd.bluetooth.le.oob":{source:"iana"},"application/vnd.bmi":{source:"iana",extensions:["bmi"]},"application/vnd.bpf":{source:"iana"},"application/vnd.bpf3":{source:"iana"},"application/vnd.businessobjects":{source:"iana",extensions:["rep"]},"application/vnd.byu.uapi+json":{source:"iana",compressible:!0},"application/vnd.cab-jscript":{source:"iana"},"application/vnd.canon-cpdl":{source:"iana"},"application/vnd.canon-lips":{source:"iana"},"application/vnd.capasystems-pg+json":{source:"iana",compressible:!0},"application/vnd.cendio.thinlinc.clientconf":{source:"iana"},"application/vnd.century-systems.tcp_stream":{source:"iana"},"application/vnd.chemdraw+xml":{source:"iana",compressible:!0,extensions:["cdxml"]},"application/vnd.chess-pgn":{source:"iana"},"application/vnd.chipnuts.karaoke-mmd":{source:"iana",extensions:["mmd"]},"application/vnd.ciedi":{source:"iana"},"application/vnd.cinderella":{source:"iana",extensions:["cdy"]},"application/vnd.cirpack.isdn-ext":{source:"iana"},"application/vnd.citationstyles.style+xml":{source:"iana",compressible:!0,extensions:["csl"]},"application/vnd.claymore":{source:"iana",extensions:["cla"]},"application/vnd.cloanto.rp9":{source:"iana",extensions:["rp9"]},"application/vnd.clonk.c4group":{source:"iana",extensions:["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{source:"iana",extensions:["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{source:"iana",extensions:["c11amz"]},"application/vnd.coffeescript":{source:"iana"},"application/vnd.collabio.xodocuments.document":{source:"iana"},"application/vnd.collabio.xodocuments.document-template":{source:"iana"},"application/vnd.collabio.xodocuments.presentation":{source:"iana"},"application/vnd.collabio.xodocuments.presentation-template":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{source:"iana"},"application/vnd.collection+json":{source:"iana",compressible:!0},"application/vnd.collection.doc+json":{source:"iana",compressible:!0},"application/vnd.collection.next+json":{source:"iana",compressible:!0},"application/vnd.comicbook+zip":{source:"iana",compressible:!1},"application/vnd.comicbook-rar":{source:"iana"},"application/vnd.commerce-battelle":{source:"iana"},"application/vnd.commonspace":{source:"iana",extensions:["csp"]},"application/vnd.contact.cmsg":{source:"iana",extensions:["cdbcmsg"]},"application/vnd.coreos.ignition+json":{source:"iana",compressible:!0},"application/vnd.cosmocaller":{source:"iana",extensions:["cmc"]},"application/vnd.crick.clicker":{source:"iana",extensions:["clkx"]},"application/vnd.crick.clicker.keyboard":{source:"iana",extensions:["clkk"]},"application/vnd.crick.clicker.palette":{source:"iana",extensions:["clkp"]},"application/vnd.crick.clicker.template":{source:"iana",extensions:["clkt"]},"application/vnd.crick.clicker.wordbank":{source:"iana",extensions:["clkw"]},"application/vnd.criticaltools.wbs+xml":{source:"iana",compressible:!0,extensions:["wbs"]},"application/vnd.cryptii.pipe+json":{source:"iana",compressible:!0},"application/vnd.crypto-shade-file":{source:"iana"},"application/vnd.cryptomator.encrypted":{source:"iana"},"application/vnd.cryptomator.vault":{source:"iana"},"application/vnd.ctc-posml":{source:"iana",extensions:["pml"]},"application/vnd.ctct.ws+xml":{source:"iana",compressible:!0},"application/vnd.cups-pdf":{source:"iana"},"application/vnd.cups-postscript":{source:"iana"},"application/vnd.cups-ppd":{source:"iana",extensions:["ppd"]},"application/vnd.cups-raster":{source:"iana"},"application/vnd.cups-raw":{source:"iana"},"application/vnd.curl":{source:"iana"},"application/vnd.curl.car":{source:"apache",extensions:["car"]},"application/vnd.curl.pcurl":{source:"apache",extensions:["pcurl"]},"application/vnd.cyan.dean.root+xml":{source:"iana",compressible:!0},"application/vnd.cybank":{source:"iana"},"application/vnd.cyclonedx+json":{source:"iana",compressible:!0},"application/vnd.cyclonedx+xml":{source:"iana",compressible:!0},"application/vnd.d2l.coursepackage1p0+zip":{source:"iana",compressible:!1},"application/vnd.d3m-dataset":{source:"iana"},"application/vnd.d3m-problem":{source:"iana"},"application/vnd.dart":{source:"iana",compressible:!0,extensions:["dart"]},"application/vnd.data-vision.rdz":{source:"iana",extensions:["rdz"]},"application/vnd.datapackage+json":{source:"iana",compressible:!0},"application/vnd.dataresource+json":{source:"iana",compressible:!0},"application/vnd.dbf":{source:"iana",extensions:["dbf"]},"application/vnd.debian.binary-package":{source:"iana"},"application/vnd.dece.data":{source:"iana",extensions:["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{source:"iana",compressible:!0,extensions:["uvt","uvvt"]},"application/vnd.dece.unspecified":{source:"iana",extensions:["uvx","uvvx"]},"application/vnd.dece.zip":{source:"iana",extensions:["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{source:"iana",extensions:["fe_launch"]},"application/vnd.desmume.movie":{source:"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{source:"iana"},"application/vnd.dm.delegation+xml":{source:"iana",compressible:!0},"application/vnd.dna":{source:"iana",extensions:["dna"]},"application/vnd.document+json":{source:"iana",compressible:!0},"application/vnd.dolby.mlp":{source:"apache",extensions:["mlp"]},"application/vnd.dolby.mobile.1":{source:"iana"},"application/vnd.dolby.mobile.2":{source:"iana"},"application/vnd.doremir.scorecloud-binary-document":{source:"iana"},"application/vnd.dpgraph":{source:"iana",extensions:["dpg"]},"application/vnd.dreamfactory":{source:"iana",extensions:["dfac"]},"application/vnd.drive+json":{source:"iana",compressible:!0},"application/vnd.ds-keypoint":{source:"apache",extensions:["kpxx"]},"application/vnd.dtg.local":{source:"iana"},"application/vnd.dtg.local.flash":{source:"iana"},"application/vnd.dtg.local.html":{source:"iana"},"application/vnd.dvb.ait":{source:"iana",extensions:["ait"]},"application/vnd.dvb.dvbisl+xml":{source:"iana",compressible:!0},"application/vnd.dvb.dvbj":{source:"iana"},"application/vnd.dvb.esgcontainer":{source:"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess2":{source:"iana"},"application/vnd.dvb.ipdcesgpdd":{source:"iana"},"application/vnd.dvb.ipdcroaming":{source:"iana"},"application/vnd.dvb.iptv.alfec-base":{source:"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{source:"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-container+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-generic+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-msglist+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-request+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-response+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-init+xml":{source:"iana",compressible:!0},"application/vnd.dvb.pfr":{source:"iana"},"application/vnd.dvb.service":{source:"iana",extensions:["svc"]},"application/vnd.dxr":{source:"iana"},"application/vnd.dynageo":{source:"iana",extensions:["geo"]},"application/vnd.dzr":{source:"iana"},"application/vnd.easykaraoke.cdgdownload":{source:"iana"},"application/vnd.ecdis-update":{source:"iana"},"application/vnd.ecip.rlp":{source:"iana"},"application/vnd.eclipse.ditto+json":{source:"iana",compressible:!0},"application/vnd.ecowin.chart":{source:"iana",extensions:["mag"]},"application/vnd.ecowin.filerequest":{source:"iana"},"application/vnd.ecowin.fileupdate":{source:"iana"},"application/vnd.ecowin.series":{source:"iana"},"application/vnd.ecowin.seriesrequest":{source:"iana"},"application/vnd.ecowin.seriesupdate":{source:"iana"},"application/vnd.efi.img":{source:"iana"},"application/vnd.efi.iso":{source:"iana"},"application/vnd.emclient.accessrequest+xml":{source:"iana",compressible:!0},"application/vnd.enliven":{source:"iana",extensions:["nml"]},"application/vnd.enphase.envoy":{source:"iana"},"application/vnd.eprints.data+xml":{source:"iana",compressible:!0},"application/vnd.epson.esf":{source:"iana",extensions:["esf"]},"application/vnd.epson.msf":{source:"iana",extensions:["msf"]},"application/vnd.epson.quickanime":{source:"iana",extensions:["qam"]},"application/vnd.epson.salt":{source:"iana",extensions:["slt"]},"application/vnd.epson.ssf":{source:"iana",extensions:["ssf"]},"application/vnd.ericsson.quickcall":{source:"iana"},"application/vnd.espass-espass+zip":{source:"iana",compressible:!1},"application/vnd.eszigno3+xml":{source:"iana",compressible:!0,extensions:["es3","et3"]},"application/vnd.etsi.aoc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.asic-e+zip":{source:"iana",compressible:!1},"application/vnd.etsi.asic-s+zip":{source:"iana",compressible:!1},"application/vnd.etsi.cug+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvcommand+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-bc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-cod+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-npvr+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvservice+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsync+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvueprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mcid+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mheg5":{source:"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{source:"iana",compressible:!0},"application/vnd.etsi.pstn+xml":{source:"iana",compressible:!0},"application/vnd.etsi.sci+xml":{source:"iana",compressible:!0},"application/vnd.etsi.simservs+xml":{source:"iana",compressible:!0},"application/vnd.etsi.timestamp-token":{source:"iana"},"application/vnd.etsi.tsl+xml":{source:"iana",compressible:!0},"application/vnd.etsi.tsl.der":{source:"iana"},"application/vnd.eu.kasparian.car+json":{source:"iana",compressible:!0},"application/vnd.eudora.data":{source:"iana"},"application/vnd.evolv.ecig.profile":{source:"iana"},"application/vnd.evolv.ecig.settings":{source:"iana"},"application/vnd.evolv.ecig.theme":{source:"iana"},"application/vnd.exstream-empower+zip":{source:"iana",compressible:!1},"application/vnd.exstream-package":{source:"iana"},"application/vnd.ezpix-album":{source:"iana",extensions:["ez2"]},"application/vnd.ezpix-package":{source:"iana",extensions:["ez3"]},"application/vnd.f-secure.mobile":{source:"iana"},"application/vnd.familysearch.gedcom+zip":{source:"iana",compressible:!1},"application/vnd.fastcopy-disk-image":{source:"iana"},"application/vnd.fdf":{source:"iana",extensions:["fdf"]},"application/vnd.fdsn.mseed":{source:"iana",extensions:["mseed"]},"application/vnd.fdsn.seed":{source:"iana",extensions:["seed","dataless"]},"application/vnd.ffsns":{source:"iana"},"application/vnd.ficlab.flb+zip":{source:"iana",compressible:!1},"application/vnd.filmit.zfc":{source:"iana"},"application/vnd.fints":{source:"iana"},"application/vnd.firemonkeys.cloudcell":{source:"iana"},"application/vnd.flographit":{source:"iana",extensions:["gph"]},"application/vnd.fluxtime.clip":{source:"iana",extensions:["ftc"]},"application/vnd.font-fontforge-sfd":{source:"iana"},"application/vnd.framemaker":{source:"iana",extensions:["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{source:"iana",extensions:["fnc"]},"application/vnd.frogans.ltf":{source:"iana",extensions:["ltf"]},"application/vnd.fsc.weblaunch":{source:"iana",extensions:["fsc"]},"application/vnd.fujifilm.fb.docuworks":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.binder":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.container":{source:"iana"},"application/vnd.fujifilm.fb.jfi+xml":{source:"iana",compressible:!0},"application/vnd.fujitsu.oasys":{source:"iana",extensions:["oas"]},"application/vnd.fujitsu.oasys2":{source:"iana",extensions:["oa2"]},"application/vnd.fujitsu.oasys3":{source:"iana",extensions:["oa3"]},"application/vnd.fujitsu.oasysgp":{source:"iana",extensions:["fg5"]},"application/vnd.fujitsu.oasysprs":{source:"iana",extensions:["bh2"]},"application/vnd.fujixerox.art-ex":{source:"iana"},"application/vnd.fujixerox.art4":{source:"iana"},"application/vnd.fujixerox.ddd":{source:"iana",extensions:["ddd"]},"application/vnd.fujixerox.docuworks":{source:"iana",extensions:["xdw"]},"application/vnd.fujixerox.docuworks.binder":{source:"iana",extensions:["xbd"]},"application/vnd.fujixerox.docuworks.container":{source:"iana"},"application/vnd.fujixerox.hbpl":{source:"iana"},"application/vnd.fut-misnet":{source:"iana"},"application/vnd.futoin+cbor":{source:"iana"},"application/vnd.futoin+json":{source:"iana",compressible:!0},"application/vnd.fuzzysheet":{source:"iana",extensions:["fzs"]},"application/vnd.genomatix.tuxedo":{source:"iana",extensions:["txd"]},"application/vnd.gentics.grd+json":{source:"iana",compressible:!0},"application/vnd.geo+json":{source:"iana",compressible:!0},"application/vnd.geocube+xml":{source:"iana",compressible:!0},"application/vnd.geogebra.file":{source:"iana",extensions:["ggb"]},"application/vnd.geogebra.slides":{source:"iana"},"application/vnd.geogebra.tool":{source:"iana",extensions:["ggt"]},"application/vnd.geometry-explorer":{source:"iana",extensions:["gex","gre"]},"application/vnd.geonext":{source:"iana",extensions:["gxt"]},"application/vnd.geoplan":{source:"iana",extensions:["g2w"]},"application/vnd.geospace":{source:"iana",extensions:["g3w"]},"application/vnd.gerber":{source:"iana"},"application/vnd.globalplatform.card-content-mgt":{source:"iana"},"application/vnd.globalplatform.card-content-mgt-response":{source:"iana"},"application/vnd.gmx":{source:"iana",extensions:["gmx"]},"application/vnd.google-apps.document":{compressible:!1,extensions:["gdoc"]},"application/vnd.google-apps.presentation":{compressible:!1,extensions:["gslides"]},"application/vnd.google-apps.spreadsheet":{compressible:!1,extensions:["gsheet"]},"application/vnd.google-earth.kml+xml":{source:"iana",compressible:!0,extensions:["kml"]},"application/vnd.google-earth.kmz":{source:"iana",compressible:!1,extensions:["kmz"]},"application/vnd.gov.sk.e-form+xml":{source:"iana",compressible:!0},"application/vnd.gov.sk.e-form+zip":{source:"iana",compressible:!1},"application/vnd.gov.sk.xmldatacontainer+xml":{source:"iana",compressible:!0},"application/vnd.grafeq":{source:"iana",extensions:["gqf","gqs"]},"application/vnd.gridmp":{source:"iana"},"application/vnd.groove-account":{source:"iana",extensions:["gac"]},"application/vnd.groove-help":{source:"iana",extensions:["ghf"]},"application/vnd.groove-identity-message":{source:"iana",extensions:["gim"]},"application/vnd.groove-injector":{source:"iana",extensions:["grv"]},"application/vnd.groove-tool-message":{source:"iana",extensions:["gtm"]},"application/vnd.groove-tool-template":{source:"iana",extensions:["tpl"]},"application/vnd.groove-vcard":{source:"iana",extensions:["vcg"]},"application/vnd.hal+json":{source:"iana",compressible:!0},"application/vnd.hal+xml":{source:"iana",compressible:!0,extensions:["hal"]},"application/vnd.handheld-entertainment+xml":{source:"iana",compressible:!0,extensions:["zmm"]},"application/vnd.hbci":{source:"iana",extensions:["hbci"]},"application/vnd.hc+json":{source:"iana",compressible:!0},"application/vnd.hcl-bireports":{source:"iana"},"application/vnd.hdt":{source:"iana"},"application/vnd.heroku+json":{source:"iana",compressible:!0},"application/vnd.hhe.lesson-player":{source:"iana",extensions:["les"]},"application/vnd.hl7cda+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hl7v2+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hp-hpgl":{source:"iana",extensions:["hpgl"]},"application/vnd.hp-hpid":{source:"iana",extensions:["hpid"]},"application/vnd.hp-hps":{source:"iana",extensions:["hps"]},"application/vnd.hp-jlyt":{source:"iana",extensions:["jlt"]},"application/vnd.hp-pcl":{source:"iana",extensions:["pcl"]},"application/vnd.hp-pclxl":{source:"iana",extensions:["pclxl"]},"application/vnd.httphone":{source:"iana"},"application/vnd.hydrostatix.sof-data":{source:"iana",extensions:["sfd-hdstx"]},"application/vnd.hyper+json":{source:"iana",compressible:!0},"application/vnd.hyper-item+json":{source:"iana",compressible:!0},"application/vnd.hyperdrive+json":{source:"iana",compressible:!0},"application/vnd.hzn-3d-crossword":{source:"iana"},"application/vnd.ibm.afplinedata":{source:"iana"},"application/vnd.ibm.electronic-media":{source:"iana"},"application/vnd.ibm.minipay":{source:"iana",extensions:["mpy"]},"application/vnd.ibm.modcap":{source:"iana",extensions:["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{source:"iana",extensions:["irm"]},"application/vnd.ibm.secure-container":{source:"iana",extensions:["sc"]},"application/vnd.iccprofile":{source:"iana",extensions:["icc","icm"]},"application/vnd.ieee.1905":{source:"iana"},"application/vnd.igloader":{source:"iana",extensions:["igl"]},"application/vnd.imagemeter.folder+zip":{source:"iana",compressible:!1},"application/vnd.imagemeter.image+zip":{source:"iana",compressible:!1},"application/vnd.immervision-ivp":{source:"iana",extensions:["ivp"]},"application/vnd.immervision-ivu":{source:"iana",extensions:["ivu"]},"application/vnd.ims.imsccv1p1":{source:"iana"},"application/vnd.ims.imsccv1p2":{source:"iana"},"application/vnd.ims.imsccv1p3":{source:"iana"},"application/vnd.ims.lis.v2.result+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy.id+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings.simple+json":{source:"iana",compressible:!0},"application/vnd.informedcontrol.rms+xml":{source:"iana",compressible:!0},"application/vnd.informix-visionary":{source:"iana"},"application/vnd.infotech.project":{source:"iana"},"application/vnd.infotech.project+xml":{source:"iana",compressible:!0},"application/vnd.innopath.wamp.notification":{source:"iana"},"application/vnd.insors.igm":{source:"iana",extensions:["igm"]},"application/vnd.intercon.formnet":{source:"iana",extensions:["xpw","xpx"]},"application/vnd.intergeo":{source:"iana",extensions:["i2g"]},"application/vnd.intertrust.digibox":{source:"iana"},"application/vnd.intertrust.nncp":{source:"iana"},"application/vnd.intu.qbo":{source:"iana",extensions:["qbo"]},"application/vnd.intu.qfx":{source:"iana",extensions:["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.conceptitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.knowledgeitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsmessage+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.packageitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.planningitem+xml":{source:"iana",compressible:!0},"application/vnd.ipunplugged.rcprofile":{source:"iana",extensions:["rcprofile"]},"application/vnd.irepository.package+xml":{source:"iana",compressible:!0,extensions:["irp"]},"application/vnd.is-xpr":{source:"iana",extensions:["xpr"]},"application/vnd.isac.fcs":{source:"iana",extensions:["fcs"]},"application/vnd.iso11783-10+zip":{source:"iana",compressible:!1},"application/vnd.jam":{source:"iana",extensions:["jam"]},"application/vnd.japannet-directory-service":{source:"iana"},"application/vnd.japannet-jpnstore-wakeup":{source:"iana"},"application/vnd.japannet-payment-wakeup":{source:"iana"},"application/vnd.japannet-registration":{source:"iana"},"application/vnd.japannet-registration-wakeup":{source:"iana"},"application/vnd.japannet-setstore-wakeup":{source:"iana"},"application/vnd.japannet-verification":{source:"iana"},"application/vnd.japannet-verification-wakeup":{source:"iana"},"application/vnd.jcp.javame.midlet-rms":{source:"iana",extensions:["rms"]},"application/vnd.jisp":{source:"iana",extensions:["jisp"]},"application/vnd.joost.joda-archive":{source:"iana",extensions:["joda"]},"application/vnd.jsk.isdn-ngn":{source:"iana"},"application/vnd.kahootz":{source:"iana",extensions:["ktz","ktr"]},"application/vnd.kde.karbon":{source:"iana",extensions:["karbon"]},"application/vnd.kde.kchart":{source:"iana",extensions:["chrt"]},"application/vnd.kde.kformula":{source:"iana",extensions:["kfo"]},"application/vnd.kde.kivio":{source:"iana",extensions:["flw"]},"application/vnd.kde.kontour":{source:"iana",extensions:["kon"]},"application/vnd.kde.kpresenter":{source:"iana",extensions:["kpr","kpt"]},"application/vnd.kde.kspread":{source:"iana",extensions:["ksp"]},"application/vnd.kde.kword":{source:"iana",extensions:["kwd","kwt"]},"application/vnd.kenameaapp":{source:"iana",extensions:["htke"]},"application/vnd.kidspiration":{source:"iana",extensions:["kia"]},"application/vnd.kinar":{source:"iana",extensions:["kne","knp"]},"application/vnd.koan":{source:"iana",extensions:["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{source:"iana",extensions:["sse"]},"application/vnd.las":{source:"iana"},"application/vnd.las.las+json":{source:"iana",compressible:!0},"application/vnd.las.las+xml":{source:"iana",compressible:!0,extensions:["lasxml"]},"application/vnd.laszip":{source:"iana"},"application/vnd.leap+json":{source:"iana",compressible:!0},"application/vnd.liberty-request+xml":{source:"iana",compressible:!0},"application/vnd.llamagraphics.life-balance.desktop":{source:"iana",extensions:["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{source:"iana",compressible:!0,extensions:["lbe"]},"application/vnd.logipipe.circuit+zip":{source:"iana",compressible:!1},"application/vnd.loom":{source:"iana"},"application/vnd.lotus-1-2-3":{source:"iana",extensions:["123"]},"application/vnd.lotus-approach":{source:"iana",extensions:["apr"]},"application/vnd.lotus-freelance":{source:"iana",extensions:["pre"]},"application/vnd.lotus-notes":{source:"iana",extensions:["nsf"]},"application/vnd.lotus-organizer":{source:"iana",extensions:["org"]},"application/vnd.lotus-screencam":{source:"iana",extensions:["scm"]},"application/vnd.lotus-wordpro":{source:"iana",extensions:["lwp"]},"application/vnd.macports.portpkg":{source:"iana",extensions:["portpkg"]},"application/vnd.mapbox-vector-tile":{source:"iana",extensions:["mvt"]},"application/vnd.marlin.drm.actiontoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.conftoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.license+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.mdcf":{source:"iana"},"application/vnd.mason+json":{source:"iana",compressible:!0},"application/vnd.maxar.archive.3tz+zip":{source:"iana",compressible:!1},"application/vnd.maxmind.maxmind-db":{source:"iana"},"application/vnd.mcd":{source:"iana",extensions:["mcd"]},"application/vnd.medcalcdata":{source:"iana",extensions:["mc1"]},"application/vnd.mediastation.cdkey":{source:"iana",extensions:["cdkey"]},"application/vnd.meridian-slingshot":{source:"iana"},"application/vnd.mfer":{source:"iana",extensions:["mwf"]},"application/vnd.mfmp":{source:"iana",extensions:["mfm"]},"application/vnd.micro+json":{source:"iana",compressible:!0},"application/vnd.micrografx.flo":{source:"iana",extensions:["flo"]},"application/vnd.micrografx.igx":{source:"iana",extensions:["igx"]},"application/vnd.microsoft.portable-executable":{source:"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{source:"iana"},"application/vnd.miele+json":{source:"iana",compressible:!0},"application/vnd.mif":{source:"iana",extensions:["mif"]},"application/vnd.minisoft-hp3000-save":{source:"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{source:"iana"},"application/vnd.mobius.daf":{source:"iana",extensions:["daf"]},"application/vnd.mobius.dis":{source:"iana",extensions:["dis"]},"application/vnd.mobius.mbk":{source:"iana",extensions:["mbk"]},"application/vnd.mobius.mqy":{source:"iana",extensions:["mqy"]},"application/vnd.mobius.msl":{source:"iana",extensions:["msl"]},"application/vnd.mobius.plc":{source:"iana",extensions:["plc"]},"application/vnd.mobius.txf":{source:"iana",extensions:["txf"]},"application/vnd.mophun.application":{source:"iana",extensions:["mpn"]},"application/vnd.mophun.certificate":{source:"iana",extensions:["mpc"]},"application/vnd.motorola.flexsuite":{source:"iana"},"application/vnd.motorola.flexsuite.adsi":{source:"iana"},"application/vnd.motorola.flexsuite.fis":{source:"iana"},"application/vnd.motorola.flexsuite.gotap":{source:"iana"},"application/vnd.motorola.flexsuite.kmr":{source:"iana"},"application/vnd.motorola.flexsuite.ttc":{source:"iana"},"application/vnd.motorola.flexsuite.wem":{source:"iana"},"application/vnd.motorola.iprm":{source:"iana"},"application/vnd.mozilla.xul+xml":{source:"iana",compressible:!0,extensions:["xul"]},"application/vnd.ms-3mfdocument":{source:"iana"},"application/vnd.ms-artgalry":{source:"iana",extensions:["cil"]},"application/vnd.ms-asf":{source:"iana"},"application/vnd.ms-cab-compressed":{source:"iana",extensions:["cab"]},"application/vnd.ms-color.iccprofile":{source:"apache"},"application/vnd.ms-excel":{source:"iana",compressible:!1,extensions:["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{source:"iana",extensions:["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{source:"iana",extensions:["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{source:"iana",extensions:["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{source:"iana",extensions:["xltm"]},"application/vnd.ms-fontobject":{source:"iana",compressible:!0,extensions:["eot"]},"application/vnd.ms-htmlhelp":{source:"iana",extensions:["chm"]},"application/vnd.ms-ims":{source:"iana",extensions:["ims"]},"application/vnd.ms-lrm":{source:"iana",extensions:["lrm"]},"application/vnd.ms-office.activex+xml":{source:"iana",compressible:!0},"application/vnd.ms-officetheme":{source:"iana",extensions:["thmx"]},"application/vnd.ms-opentype":{source:"apache",compressible:!0},"application/vnd.ms-outlook":{compressible:!1,extensions:["msg"]},"application/vnd.ms-package.obfuscated-opentype":{source:"apache"},"application/vnd.ms-pki.seccat":{source:"apache",extensions:["cat"]},"application/vnd.ms-pki.stl":{source:"apache",extensions:["stl"]},"application/vnd.ms-playready.initiator+xml":{source:"iana",compressible:!0},"application/vnd.ms-powerpoint":{source:"iana",compressible:!1,extensions:["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{source:"iana",extensions:["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{source:"iana",extensions:["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{source:"iana",extensions:["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{source:"iana",extensions:["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{source:"iana",extensions:["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{source:"iana",compressible:!0},"application/vnd.ms-printing.printticket+xml":{source:"apache",compressible:!0},"application/vnd.ms-printschematicket+xml":{source:"iana",compressible:!0},"application/vnd.ms-project":{source:"iana",extensions:["mpp","mpt"]},"application/vnd.ms-tnef":{source:"iana"},"application/vnd.ms-windows.devicepairing":{source:"iana"},"application/vnd.ms-windows.nwprinting.oob":{source:"iana"},"application/vnd.ms-windows.printerpairing":{source:"iana"},"application/vnd.ms-windows.wsd.oob":{source:"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.lic-resp":{source:"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.meter-resp":{source:"iana"},"application/vnd.ms-word.document.macroenabled.12":{source:"iana",extensions:["docm"]},"application/vnd.ms-word.template.macroenabled.12":{source:"iana",extensions:["dotm"]},"application/vnd.ms-works":{source:"iana",extensions:["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{source:"iana",extensions:["wpl"]},"application/vnd.ms-xpsdocument":{source:"iana",compressible:!1,extensions:["xps"]},"application/vnd.msa-disk-image":{source:"iana"},"application/vnd.mseq":{source:"iana",extensions:["mseq"]},"application/vnd.msign":{source:"iana"},"application/vnd.multiad.creator":{source:"iana"},"application/vnd.multiad.creator.cif":{source:"iana"},"application/vnd.music-niff":{source:"iana"},"application/vnd.musician":{source:"iana",extensions:["mus"]},"application/vnd.muvee.style":{source:"iana",extensions:["msty"]},"application/vnd.mynfc":{source:"iana",extensions:["taglet"]},"application/vnd.nacamar.ybrid+json":{source:"iana",compressible:!0},"application/vnd.ncd.control":{source:"iana"},"application/vnd.ncd.reference":{source:"iana"},"application/vnd.nearst.inv+json":{source:"iana",compressible:!0},"application/vnd.nebumind.line":{source:"iana"},"application/vnd.nervana":{source:"iana"},"application/vnd.netfpx":{source:"iana"},"application/vnd.neurolanguage.nlu":{source:"iana",extensions:["nlu"]},"application/vnd.nimn":{source:"iana"},"application/vnd.nintendo.nitro.rom":{source:"iana"},"application/vnd.nintendo.snes.rom":{source:"iana"},"application/vnd.nitf":{source:"iana",extensions:["ntf","nitf"]},"application/vnd.noblenet-directory":{source:"iana",extensions:["nnd"]},"application/vnd.noblenet-sealer":{source:"iana",extensions:["nns"]},"application/vnd.noblenet-web":{source:"iana",extensions:["nnw"]},"application/vnd.nokia.catalogs":{source:"iana"},"application/vnd.nokia.conml+wbxml":{source:"iana"},"application/vnd.nokia.conml+xml":{source:"iana",compressible:!0},"application/vnd.nokia.iptv.config+xml":{source:"iana",compressible:!0},"application/vnd.nokia.isds-radio-presets":{source:"iana"},"application/vnd.nokia.landmark+wbxml":{source:"iana"},"application/vnd.nokia.landmark+xml":{source:"iana",compressible:!0},"application/vnd.nokia.landmarkcollection+xml":{source:"iana",compressible:!0},"application/vnd.nokia.n-gage.ac+xml":{source:"iana",compressible:!0,extensions:["ac"]},"application/vnd.nokia.n-gage.data":{source:"iana",extensions:["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{source:"iana",extensions:["n-gage"]},"application/vnd.nokia.ncd":{source:"iana"},"application/vnd.nokia.pcd+wbxml":{source:"iana"},"application/vnd.nokia.pcd+xml":{source:"iana",compressible:!0},"application/vnd.nokia.radio-preset":{source:"iana",extensions:["rpst"]},"application/vnd.nokia.radio-presets":{source:"iana",extensions:["rpss"]},"application/vnd.novadigm.edm":{source:"iana",extensions:["edm"]},"application/vnd.novadigm.edx":{source:"iana",extensions:["edx"]},"application/vnd.novadigm.ext":{source:"iana",extensions:["ext"]},"application/vnd.ntt-local.content-share":{source:"iana"},"application/vnd.ntt-local.file-transfer":{source:"iana"},"application/vnd.ntt-local.ogw_remote-access":{source:"iana"},"application/vnd.ntt-local.sip-ta_remote":{source:"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{source:"iana"},"application/vnd.oasis.opendocument.chart":{source:"iana",extensions:["odc"]},"application/vnd.oasis.opendocument.chart-template":{source:"iana",extensions:["otc"]},"application/vnd.oasis.opendocument.database":{source:"iana",extensions:["odb"]},"application/vnd.oasis.opendocument.formula":{source:"iana",extensions:["odf"]},"application/vnd.oasis.opendocument.formula-template":{source:"iana",extensions:["odft"]},"application/vnd.oasis.opendocument.graphics":{source:"iana",compressible:!1,extensions:["odg"]},"application/vnd.oasis.opendocument.graphics-template":{source:"iana",extensions:["otg"]},"application/vnd.oasis.opendocument.image":{source:"iana",extensions:["odi"]},"application/vnd.oasis.opendocument.image-template":{source:"iana",extensions:["oti"]},"application/vnd.oasis.opendocument.presentation":{source:"iana",compressible:!1,extensions:["odp"]},"application/vnd.oasis.opendocument.presentation-template":{source:"iana",extensions:["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{source:"iana",compressible:!1,extensions:["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{source:"iana",extensions:["ots"]},"application/vnd.oasis.opendocument.text":{source:"iana",compressible:!1,extensions:["odt"]},"application/vnd.oasis.opendocument.text-master":{source:"iana",extensions:["odm"]},"application/vnd.oasis.opendocument.text-template":{source:"iana",extensions:["ott"]},"application/vnd.oasis.opendocument.text-web":{source:"iana",extensions:["oth"]},"application/vnd.obn":{source:"iana"},"application/vnd.ocf+cbor":{source:"iana"},"application/vnd.oci.image.manifest.v1+json":{source:"iana",compressible:!0},"application/vnd.oftn.l10n+json":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessdownload+xml":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessstreaming+xml":{source:"iana",compressible:!0},"application/vnd.oipf.cspg-hexbinary":{source:"iana"},"application/vnd.oipf.dae.svg+xml":{source:"iana",compressible:!0},"application/vnd.oipf.dae.xhtml+xml":{source:"iana",compressible:!0},"application/vnd.oipf.mippvcontrolmessage+xml":{source:"iana",compressible:!0},"application/vnd.oipf.pae.gem":{source:"iana"},"application/vnd.oipf.spdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.oipf.spdlist+xml":{source:"iana",compressible:!0},"application/vnd.oipf.ueprofile+xml":{source:"iana",compressible:!0},"application/vnd.oipf.userprofile+xml":{source:"iana",compressible:!0},"application/vnd.olpc-sugar":{source:"iana",extensions:["xo"]},"application/vnd.oma-scws-config":{source:"iana"},"application/vnd.oma-scws-http-request":{source:"iana"},"application/vnd.oma-scws-http-response":{source:"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.drm-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.imd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.ltkm":{source:"iana"},"application/vnd.oma.bcast.notification+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.provisioningtrigger":{source:"iana"},"application/vnd.oma.bcast.sgboot":{source:"iana"},"application/vnd.oma.bcast.sgdd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sgdu":{source:"iana"},"application/vnd.oma.bcast.simple-symbol-container":{source:"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sprov+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.stkm":{source:"iana"},"application/vnd.oma.cab-address-book+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-feature-handler+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-pcc+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-subs-invite+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-user-prefs+xml":{source:"iana",compressible:!0},"application/vnd.oma.dcd":{source:"iana"},"application/vnd.oma.dcdc":{source:"iana"},"application/vnd.oma.dd2+xml":{source:"iana",compressible:!0,extensions:["dd2"]},"application/vnd.oma.drm.risd+xml":{source:"iana",compressible:!0},"application/vnd.oma.group-usage-list+xml":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+cbor":{source:"iana"},"application/vnd.oma.lwm2m+json":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+tlv":{source:"iana"},"application/vnd.oma.pal+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.detailed-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.final-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.groups+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.invocation-descriptor+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.optimized-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.push":{source:"iana"},"application/vnd.oma.scidm.messages+xml":{source:"iana",compressible:!0},"application/vnd.oma.xcap-directory+xml":{source:"iana",compressible:!0},"application/vnd.omads-email+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-file+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-folder+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omaloc-supl-init":{source:"iana"},"application/vnd.onepager":{source:"iana"},"application/vnd.onepagertamp":{source:"iana"},"application/vnd.onepagertamx":{source:"iana"},"application/vnd.onepagertat":{source:"iana"},"application/vnd.onepagertatp":{source:"iana"},"application/vnd.onepagertatx":{source:"iana"},"application/vnd.openblox.game+xml":{source:"iana",compressible:!0,extensions:["obgx"]},"application/vnd.openblox.game-binary":{source:"iana"},"application/vnd.openeye.oeb":{source:"iana"},"application/vnd.openofficeorg.extension":{source:"apache",extensions:["oxt"]},"application/vnd.openstreetmap.data+xml":{source:"iana",compressible:!0,extensions:["osm"]},"application/vnd.opentimestamps.ots":{source:"iana"},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawing+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",compressible:!1,extensions:["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slide":{source:"iana",extensions:["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{source:"iana",extensions:["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.template":{source:"iana",extensions:["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",compressible:!1,extensions:["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{source:"iana",extensions:["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.theme+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.vmldrawing":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",compressible:!1,extensions:["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{source:"iana",extensions:["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.core-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.relationships+xml":{source:"iana",compressible:!0},"application/vnd.oracle.resource+json":{source:"iana",compressible:!0},"application/vnd.orange.indata":{source:"iana"},"application/vnd.osa.netdeploy":{source:"iana"},"application/vnd.osgeo.mapguide.package":{source:"iana",extensions:["mgp"]},"application/vnd.osgi.bundle":{source:"iana"},"application/vnd.osgi.dp":{source:"iana",extensions:["dp"]},"application/vnd.osgi.subsystem":{source:"iana",extensions:["esa"]},"application/vnd.otps.ct-kip+xml":{source:"iana",compressible:!0},"application/vnd.oxli.countgraph":{source:"iana"},"application/vnd.pagerduty+json":{source:"iana",compressible:!0},"application/vnd.palm":{source:"iana",extensions:["pdb","pqa","oprc"]},"application/vnd.panoply":{source:"iana"},"application/vnd.paos.xml":{source:"iana"},"application/vnd.patentdive":{source:"iana"},"application/vnd.patientecommsdoc":{source:"iana"},"application/vnd.pawaafile":{source:"iana",extensions:["paw"]},"application/vnd.pcos":{source:"iana"},"application/vnd.pg.format":{source:"iana",extensions:["str"]},"application/vnd.pg.osasli":{source:"iana",extensions:["ei6"]},"application/vnd.piaccess.application-licence":{source:"iana"},"application/vnd.picsel":{source:"iana",extensions:["efif"]},"application/vnd.pmi.widget":{source:"iana",extensions:["wg"]},"application/vnd.poc.group-advertisement+xml":{source:"iana",compressible:!0},"application/vnd.pocketlearn":{source:"iana",extensions:["plf"]},"application/vnd.powerbuilder6":{source:"iana",extensions:["pbd"]},"application/vnd.powerbuilder6-s":{source:"iana"},"application/vnd.powerbuilder7":{source:"iana"},"application/vnd.powerbuilder7-s":{source:"iana"},"application/vnd.powerbuilder75":{source:"iana"},"application/vnd.powerbuilder75-s":{source:"iana"},"application/vnd.preminet":{source:"iana"},"application/vnd.previewsystems.box":{source:"iana",extensions:["box"]},"application/vnd.proteus.magazine":{source:"iana",extensions:["mgz"]},"application/vnd.psfs":{source:"iana"},"application/vnd.publishare-delta-tree":{source:"iana",extensions:["qps"]},"application/vnd.pvi.ptid1":{source:"iana",extensions:["ptid"]},"application/vnd.pwg-multiplexed":{source:"iana"},"application/vnd.pwg-xhtml-print+xml":{source:"iana",compressible:!0},"application/vnd.qualcomm.brew-app-res":{source:"iana"},"application/vnd.quarantainenet":{source:"iana"},"application/vnd.quark.quarkxpress":{source:"iana",extensions:["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{source:"iana"},"application/vnd.radisys.moml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conn+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-stream+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-base+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-detect+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-group+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-speech+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-transform+xml":{source:"iana",compressible:!0},"application/vnd.rainstor.data":{source:"iana"},"application/vnd.rapid":{source:"iana"},"application/vnd.rar":{source:"iana",extensions:["rar"]},"application/vnd.realvnc.bed":{source:"iana",extensions:["bed"]},"application/vnd.recordare.musicxml":{source:"iana",extensions:["mxl"]},"application/vnd.recordare.musicxml+xml":{source:"iana",compressible:!0,extensions:["musicxml"]},"application/vnd.renlearn.rlprint":{source:"iana"},"application/vnd.resilient.logic":{source:"iana"},"application/vnd.restful+json":{source:"iana",compressible:!0},"application/vnd.rig.cryptonote":{source:"iana",extensions:["cryptonote"]},"application/vnd.rim.cod":{source:"apache",extensions:["cod"]},"application/vnd.rn-realmedia":{source:"apache",extensions:["rm"]},"application/vnd.rn-realmedia-vbr":{source:"apache",extensions:["rmvb"]},"application/vnd.route66.link66+xml":{source:"iana",compressible:!0,extensions:["link66"]},"application/vnd.rs-274x":{source:"iana"},"application/vnd.ruckus.download":{source:"iana"},"application/vnd.s3sms":{source:"iana"},"application/vnd.sailingtracker.track":{source:"iana",extensions:["st"]},"application/vnd.sar":{source:"iana"},"application/vnd.sbm.cid":{source:"iana"},"application/vnd.sbm.mid2":{source:"iana"},"application/vnd.scribus":{source:"iana"},"application/vnd.sealed.3df":{source:"iana"},"application/vnd.sealed.csf":{source:"iana"},"application/vnd.sealed.doc":{source:"iana"},"application/vnd.sealed.eml":{source:"iana"},"application/vnd.sealed.mht":{source:"iana"},"application/vnd.sealed.net":{source:"iana"},"application/vnd.sealed.ppt":{source:"iana"},"application/vnd.sealed.tiff":{source:"iana"},"application/vnd.sealed.xls":{source:"iana"},"application/vnd.sealedmedia.softseal.html":{source:"iana"},"application/vnd.sealedmedia.softseal.pdf":{source:"iana"},"application/vnd.seemail":{source:"iana",extensions:["see"]},"application/vnd.seis+json":{source:"iana",compressible:!0},"application/vnd.sema":{source:"iana",extensions:["sema"]},"application/vnd.semd":{source:"iana",extensions:["semd"]},"application/vnd.semf":{source:"iana",extensions:["semf"]},"application/vnd.shade-save-file":{source:"iana"},"application/vnd.shana.informed.formdata":{source:"iana",extensions:["ifm"]},"application/vnd.shana.informed.formtemplate":{source:"iana",extensions:["itp"]},"application/vnd.shana.informed.interchange":{source:"iana",extensions:["iif"]},"application/vnd.shana.informed.package":{source:"iana",extensions:["ipk"]},"application/vnd.shootproof+json":{source:"iana",compressible:!0},"application/vnd.shopkick+json":{source:"iana",compressible:!0},"application/vnd.shp":{source:"iana"},"application/vnd.shx":{source:"iana"},"application/vnd.sigrok.session":{source:"iana"},"application/vnd.simtech-mindmapper":{source:"iana",extensions:["twd","twds"]},"application/vnd.siren+json":{source:"iana",compressible:!0},"application/vnd.smaf":{source:"iana",extensions:["mmf"]},"application/vnd.smart.notebook":{source:"iana"},"application/vnd.smart.teacher":{source:"iana",extensions:["teacher"]},"application/vnd.snesdev-page-table":{source:"iana"},"application/vnd.software602.filler.form+xml":{source:"iana",compressible:!0,extensions:["fo"]},"application/vnd.software602.filler.form-xml-zip":{source:"iana"},"application/vnd.solent.sdkm+xml":{source:"iana",compressible:!0,extensions:["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{source:"iana",extensions:["dxp"]},"application/vnd.spotfire.sfs":{source:"iana",extensions:["sfs"]},"application/vnd.sqlite3":{source:"iana"},"application/vnd.sss-cod":{source:"iana"},"application/vnd.sss-dtf":{source:"iana"},"application/vnd.sss-ntf":{source:"iana"},"application/vnd.stardivision.calc":{source:"apache",extensions:["sdc"]},"application/vnd.stardivision.draw":{source:"apache",extensions:["sda"]},"application/vnd.stardivision.impress":{source:"apache",extensions:["sdd"]},"application/vnd.stardivision.math":{source:"apache",extensions:["smf"]},"application/vnd.stardivision.writer":{source:"apache",extensions:["sdw","vor"]},"application/vnd.stardivision.writer-global":{source:"apache",extensions:["sgl"]},"application/vnd.stepmania.package":{source:"iana",extensions:["smzip"]},"application/vnd.stepmania.stepchart":{source:"iana",extensions:["sm"]},"application/vnd.street-stream":{source:"iana"},"application/vnd.sun.wadl+xml":{source:"iana",compressible:!0,extensions:["wadl"]},"application/vnd.sun.xml.calc":{source:"apache",extensions:["sxc"]},"application/vnd.sun.xml.calc.template":{source:"apache",extensions:["stc"]},"application/vnd.sun.xml.draw":{source:"apache",extensions:["sxd"]},"application/vnd.sun.xml.draw.template":{source:"apache",extensions:["std"]},"application/vnd.sun.xml.impress":{source:"apache",extensions:["sxi"]},"application/vnd.sun.xml.impress.template":{source:"apache",extensions:["sti"]},"application/vnd.sun.xml.math":{source:"apache",extensions:["sxm"]},"application/vnd.sun.xml.writer":{source:"apache",extensions:["sxw"]},"application/vnd.sun.xml.writer.global":{source:"apache",extensions:["sxg"]},"application/vnd.sun.xml.writer.template":{source:"apache",extensions:["stw"]},"application/vnd.sus-calendar":{source:"iana",extensions:["sus","susp"]},"application/vnd.svd":{source:"iana",extensions:["svd"]},"application/vnd.swiftview-ics":{source:"iana"},"application/vnd.sycle+xml":{source:"iana",compressible:!0},"application/vnd.syft+json":{source:"iana",compressible:!0},"application/vnd.symbian.install":{source:"apache",extensions:["sis","sisx"]},"application/vnd.syncml+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xsm"]},"application/vnd.syncml.dm+wbxml":{source:"iana",charset:"UTF-8",extensions:["bdm"]},"application/vnd.syncml.dm+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xdm"]},"application/vnd.syncml.dm.notification":{source:"iana"},"application/vnd.syncml.dmddf+wbxml":{source:"iana"},"application/vnd.syncml.dmddf+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{source:"iana"},"application/vnd.syncml.dmtnds+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.syncml.ds.notification":{source:"iana"},"application/vnd.tableschema+json":{source:"iana",compressible:!0},"application/vnd.tao.intent-module-archive":{source:"iana",extensions:["tao"]},"application/vnd.tcpdump.pcap":{source:"iana",extensions:["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{source:"iana",compressible:!0},"application/vnd.tmd.mediaflex.api+xml":{source:"iana",compressible:!0},"application/vnd.tml":{source:"iana"},"application/vnd.tmobile-livetv":{source:"iana",extensions:["tmo"]},"application/vnd.tri.onesource":{source:"iana"},"application/vnd.trid.tpt":{source:"iana",extensions:["tpt"]},"application/vnd.triscape.mxs":{source:"iana",extensions:["mxs"]},"application/vnd.trueapp":{source:"iana",extensions:["tra"]},"application/vnd.truedoc":{source:"iana"},"application/vnd.ubisoft.webplayer":{source:"iana"},"application/vnd.ufdl":{source:"iana",extensions:["ufd","ufdl"]},"application/vnd.uiq.theme":{source:"iana",extensions:["utz"]},"application/vnd.umajin":{source:"iana",extensions:["umj"]},"application/vnd.unity":{source:"iana",extensions:["unityweb"]},"application/vnd.uoml+xml":{source:"iana",compressible:!0,extensions:["uoml"]},"application/vnd.uplanet.alert":{source:"iana"},"application/vnd.uplanet.alert-wbxml":{source:"iana"},"application/vnd.uplanet.bearer-choice":{source:"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{source:"iana"},"application/vnd.uplanet.cacheop":{source:"iana"},"application/vnd.uplanet.cacheop-wbxml":{source:"iana"},"application/vnd.uplanet.channel":{source:"iana"},"application/vnd.uplanet.channel-wbxml":{source:"iana"},"application/vnd.uplanet.list":{source:"iana"},"application/vnd.uplanet.list-wbxml":{source:"iana"},"application/vnd.uplanet.listcmd":{source:"iana"},"application/vnd.uplanet.listcmd-wbxml":{source:"iana"},"application/vnd.uplanet.signal":{source:"iana"},"application/vnd.uri-map":{source:"iana"},"application/vnd.valve.source.material":{source:"iana"},"application/vnd.vcx":{source:"iana",extensions:["vcx"]},"application/vnd.vd-study":{source:"iana"},"application/vnd.vectorworks":{source:"iana"},"application/vnd.vel+json":{source:"iana",compressible:!0},"application/vnd.verimatrix.vcas":{source:"iana"},"application/vnd.veritone.aion+json":{source:"iana",compressible:!0},"application/vnd.veryant.thin":{source:"iana"},"application/vnd.ves.encrypted":{source:"iana"},"application/vnd.vidsoft.vidconference":{source:"iana"},"application/vnd.visio":{source:"iana",extensions:["vsd","vst","vss","vsw"]},"application/vnd.visionary":{source:"iana",extensions:["vis"]},"application/vnd.vividence.scriptfile":{source:"iana"},"application/vnd.vsf":{source:"iana",extensions:["vsf"]},"application/vnd.wap.sic":{source:"iana"},"application/vnd.wap.slc":{source:"iana"},"application/vnd.wap.wbxml":{source:"iana",charset:"UTF-8",extensions:["wbxml"]},"application/vnd.wap.wmlc":{source:"iana",extensions:["wmlc"]},"application/vnd.wap.wmlscriptc":{source:"iana",extensions:["wmlsc"]},"application/vnd.webturbo":{source:"iana",extensions:["wtb"]},"application/vnd.wfa.dpp":{source:"iana"},"application/vnd.wfa.p2p":{source:"iana"},"application/vnd.wfa.wsc":{source:"iana"},"application/vnd.windows.devicepairing":{source:"iana"},"application/vnd.wmc":{source:"iana"},"application/vnd.wmf.bootstrap":{source:"iana"},"application/vnd.wolfram.mathematica":{source:"iana"},"application/vnd.wolfram.mathematica.package":{source:"iana"},"application/vnd.wolfram.player":{source:"iana",extensions:["nbp"]},"application/vnd.wordperfect":{source:"iana",extensions:["wpd"]},"application/vnd.wqd":{source:"iana",extensions:["wqd"]},"application/vnd.wrq-hp3000-labelled":{source:"iana"},"application/vnd.wt.stf":{source:"iana",extensions:["stf"]},"application/vnd.wv.csp+wbxml":{source:"iana"},"application/vnd.wv.csp+xml":{source:"iana",compressible:!0},"application/vnd.wv.ssp+xml":{source:"iana",compressible:!0},"application/vnd.xacml+json":{source:"iana",compressible:!0},"application/vnd.xara":{source:"iana",extensions:["xar"]},"application/vnd.xfdl":{source:"iana",extensions:["xfdl"]},"application/vnd.xfdl.webform":{source:"iana"},"application/vnd.xmi+xml":{source:"iana",compressible:!0},"application/vnd.xmpie.cpkg":{source:"iana"},"application/vnd.xmpie.dpkg":{source:"iana"},"application/vnd.xmpie.plan":{source:"iana"},"application/vnd.xmpie.ppkg":{source:"iana"},"application/vnd.xmpie.xlim":{source:"iana"},"application/vnd.yamaha.hv-dic":{source:"iana",extensions:["hvd"]},"application/vnd.yamaha.hv-script":{source:"iana",extensions:["hvs"]},"application/vnd.yamaha.hv-voice":{source:"iana",extensions:["hvp"]},"application/vnd.yamaha.openscoreformat":{source:"iana",extensions:["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{source:"iana",compressible:!0,extensions:["osfpvg"]},"application/vnd.yamaha.remote-setup":{source:"iana"},"application/vnd.yamaha.smaf-audio":{source:"iana",extensions:["saf"]},"application/vnd.yamaha.smaf-phrase":{source:"iana",extensions:["spf"]},"application/vnd.yamaha.through-ngn":{source:"iana"},"application/vnd.yamaha.tunnel-udpencap":{source:"iana"},"application/vnd.yaoweme":{source:"iana"},"application/vnd.yellowriver-custom-menu":{source:"iana",extensions:["cmp"]},"application/vnd.youtube.yt":{source:"iana"},"application/vnd.zul":{source:"iana",extensions:["zir","zirz"]},"application/vnd.zzazz.deck+xml":{source:"iana",compressible:!0,extensions:["zaz"]},"application/voicexml+xml":{source:"iana",compressible:!0,extensions:["vxml"]},"application/voucher-cms+json":{source:"iana",compressible:!0},"application/vq-rtcpxr":{source:"iana"},"application/wasm":{source:"iana",compressible:!0,extensions:["wasm"]},"application/watcherinfo+xml":{source:"iana",compressible:!0,extensions:["wif"]},"application/webpush-options+json":{source:"iana",compressible:!0},"application/whoispp-query":{source:"iana"},"application/whoispp-response":{source:"iana"},"application/widget":{source:"iana",extensions:["wgt"]},"application/winhlp":{source:"apache",extensions:["hlp"]},"application/wita":{source:"iana"},"application/wordperfect5.1":{source:"iana"},"application/wsdl+xml":{source:"iana",compressible:!0,extensions:["wsdl"]},"application/wspolicy+xml":{source:"iana",compressible:!0,extensions:["wspolicy"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/x-abiword":{source:"apache",extensions:["abw"]},"application/x-ace-compressed":{source:"apache",extensions:["ace"]},"application/x-amf":{source:"apache"},"application/x-apple-diskimage":{source:"apache",extensions:["dmg"]},"application/x-arj":{compressible:!1,extensions:["arj"]},"application/x-authorware-bin":{source:"apache",extensions:["aab","x32","u32","vox"]},"application/x-authorware-map":{source:"apache",extensions:["aam"]},"application/x-authorware-seg":{source:"apache",extensions:["aas"]},"application/x-bcpio":{source:"apache",extensions:["bcpio"]},"application/x-bdoc":{compressible:!1,extensions:["bdoc"]},"application/x-bittorrent":{source:"apache",extensions:["torrent"]},"application/x-blorb":{source:"apache",extensions:["blb","blorb"]},"application/x-bzip":{source:"apache",compressible:!1,extensions:["bz"]},"application/x-bzip2":{source:"apache",compressible:!1,extensions:["bz2","boz"]},"application/x-cbr":{source:"apache",extensions:["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{source:"apache",extensions:["vcd"]},"application/x-cfs-compressed":{source:"apache",extensions:["cfs"]},"application/x-chat":{source:"apache",extensions:["chat"]},"application/x-chess-pgn":{source:"apache",extensions:["pgn"]},"application/x-chrome-extension":{extensions:["crx"]},"application/x-cocoa":{source:"nginx",extensions:["cco"]},"application/x-compress":{source:"apache"},"application/x-conference":{source:"apache",extensions:["nsc"]},"application/x-cpio":{source:"apache",extensions:["cpio"]},"application/x-csh":{source:"apache",extensions:["csh"]},"application/x-deb":{compressible:!1},"application/x-debian-package":{source:"apache",extensions:["deb","udeb"]},"application/x-dgc-compressed":{source:"apache",extensions:["dgc"]},"application/x-director":{source:"apache",extensions:["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{source:"apache",extensions:["wad"]},"application/x-dtbncx+xml":{source:"apache",compressible:!0,extensions:["ncx"]},"application/x-dtbook+xml":{source:"apache",compressible:!0,extensions:["dtb"]},"application/x-dtbresource+xml":{source:"apache",compressible:!0,extensions:["res"]},"application/x-dvi":{source:"apache",compressible:!1,extensions:["dvi"]},"application/x-envoy":{source:"apache",extensions:["evy"]},"application/x-eva":{source:"apache",extensions:["eva"]},"application/x-font-bdf":{source:"apache",extensions:["bdf"]},"application/x-font-dos":{source:"apache"},"application/x-font-framemaker":{source:"apache"},"application/x-font-ghostscript":{source:"apache",extensions:["gsf"]},"application/x-font-libgrx":{source:"apache"},"application/x-font-linux-psf":{source:"apache",extensions:["psf"]},"application/x-font-pcf":{source:"apache",extensions:["pcf"]},"application/x-font-snf":{source:"apache",extensions:["snf"]},"application/x-font-speedo":{source:"apache"},"application/x-font-sunos-news":{source:"apache"},"application/x-font-type1":{source:"apache",extensions:["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{source:"apache"},"application/x-freearc":{source:"apache",extensions:["arc"]},"application/x-futuresplash":{source:"apache",extensions:["spl"]},"application/x-gca-compressed":{source:"apache",extensions:["gca"]},"application/x-glulx":{source:"apache",extensions:["ulx"]},"application/x-gnumeric":{source:"apache",extensions:["gnumeric"]},"application/x-gramps-xml":{source:"apache",extensions:["gramps"]},"application/x-gtar":{source:"apache",extensions:["gtar"]},"application/x-gzip":{source:"apache"},"application/x-hdf":{source:"apache",extensions:["hdf"]},"application/x-httpd-php":{compressible:!0,extensions:["php"]},"application/x-install-instructions":{source:"apache",extensions:["install"]},"application/x-iso9660-image":{source:"apache",extensions:["iso"]},"application/x-iwork-keynote-sffkey":{extensions:["key"]},"application/x-iwork-numbers-sffnumbers":{extensions:["numbers"]},"application/x-iwork-pages-sffpages":{extensions:["pages"]},"application/x-java-archive-diff":{source:"nginx",extensions:["jardiff"]},"application/x-java-jnlp-file":{source:"apache",compressible:!1,extensions:["jnlp"]},"application/x-javascript":{compressible:!0},"application/x-keepass2":{extensions:["kdbx"]},"application/x-latex":{source:"apache",compressible:!1,extensions:["latex"]},"application/x-lua-bytecode":{extensions:["luac"]},"application/x-lzh-compressed":{source:"apache",extensions:["lzh","lha"]},"application/x-makeself":{source:"nginx",extensions:["run"]},"application/x-mie":{source:"apache",extensions:["mie"]},"application/x-mobipocket-ebook":{source:"apache",extensions:["prc","mobi"]},"application/x-mpegurl":{compressible:!1},"application/x-ms-application":{source:"apache",extensions:["application"]},"application/x-ms-shortcut":{source:"apache",extensions:["lnk"]},"application/x-ms-wmd":{source:"apache",extensions:["wmd"]},"application/x-ms-wmz":{source:"apache",extensions:["wmz"]},"application/x-ms-xbap":{source:"apache",extensions:["xbap"]},"application/x-msaccess":{source:"apache",extensions:["mdb"]},"application/x-msbinder":{source:"apache",extensions:["obd"]},"application/x-mscardfile":{source:"apache",extensions:["crd"]},"application/x-msclip":{source:"apache",extensions:["clp"]},"application/x-msdos-program":{extensions:["exe"]},"application/x-msdownload":{source:"apache",extensions:["exe","dll","com","bat","msi"]},"application/x-msmediaview":{source:"apache",extensions:["mvb","m13","m14"]},"application/x-msmetafile":{source:"apache",extensions:["wmf","wmz","emf","emz"]},"application/x-msmoney":{source:"apache",extensions:["mny"]},"application/x-mspublisher":{source:"apache",extensions:["pub"]},"application/x-msschedule":{source:"apache",extensions:["scd"]},"application/x-msterminal":{source:"apache",extensions:["trm"]},"application/x-mswrite":{source:"apache",extensions:["wri"]},"application/x-netcdf":{source:"apache",extensions:["nc","cdf"]},"application/x-ns-proxy-autoconfig":{compressible:!0,extensions:["pac"]},"application/x-nzb":{source:"apache",extensions:["nzb"]},"application/x-perl":{source:"nginx",extensions:["pl","pm"]},"application/x-pilot":{source:"nginx",extensions:["prc","pdb"]},"application/x-pkcs12":{source:"apache",compressible:!1,extensions:["p12","pfx"]},"application/x-pkcs7-certificates":{source:"apache",extensions:["p7b","spc"]},"application/x-pkcs7-certreqresp":{source:"apache",extensions:["p7r"]},"application/x-pki-message":{source:"iana"},"application/x-rar-compressed":{source:"apache",compressible:!1,extensions:["rar"]},"application/x-redhat-package-manager":{source:"nginx",extensions:["rpm"]},"application/x-research-info-systems":{source:"apache",extensions:["ris"]},"application/x-sea":{source:"nginx",extensions:["sea"]},"application/x-sh":{source:"apache",compressible:!0,extensions:["sh"]},"application/x-shar":{source:"apache",extensions:["shar"]},"application/x-shockwave-flash":{source:"apache",compressible:!1,extensions:["swf"]},"application/x-silverlight-app":{source:"apache",extensions:["xap"]},"application/x-sql":{source:"apache",extensions:["sql"]},"application/x-stuffit":{source:"apache",compressible:!1,extensions:["sit"]},"application/x-stuffitx":{source:"apache",extensions:["sitx"]},"application/x-subrip":{source:"apache",extensions:["srt"]},"application/x-sv4cpio":{source:"apache",extensions:["sv4cpio"]},"application/x-sv4crc":{source:"apache",extensions:["sv4crc"]},"application/x-t3vm-image":{source:"apache",extensions:["t3"]},"application/x-tads":{source:"apache",extensions:["gam"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-tcl":{source:"apache",extensions:["tcl","tk"]},"application/x-tex":{source:"apache",extensions:["tex"]},"application/x-tex-tfm":{source:"apache",extensions:["tfm"]},"application/x-texinfo":{source:"apache",extensions:["texinfo","texi"]},"application/x-tgif":{source:"apache",extensions:["obj"]},"application/x-ustar":{source:"apache",extensions:["ustar"]},"application/x-virtualbox-hdd":{compressible:!0,extensions:["hdd"]},"application/x-virtualbox-ova":{compressible:!0,extensions:["ova"]},"application/x-virtualbox-ovf":{compressible:!0,extensions:["ovf"]},"application/x-virtualbox-vbox":{compressible:!0,extensions:["vbox"]},"application/x-virtualbox-vbox-extpack":{compressible:!1,extensions:["vbox-extpack"]},"application/x-virtualbox-vdi":{compressible:!0,extensions:["vdi"]},"application/x-virtualbox-vhd":{compressible:!0,extensions:["vhd"]},"application/x-virtualbox-vmdk":{compressible:!0,extensions:["vmdk"]},"application/x-wais-source":{source:"apache",extensions:["src"]},"application/x-web-app-manifest+json":{compressible:!0,extensions:["webapp"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"application/x-x509-ca-cert":{source:"iana",extensions:["der","crt","pem"]},"application/x-x509-ca-ra-cert":{source:"iana"},"application/x-x509-next-ca-cert":{source:"iana"},"application/x-xfig":{source:"apache",extensions:["fig"]},"application/x-xliff+xml":{source:"apache",compressible:!0,extensions:["xlf"]},"application/x-xpinstall":{source:"apache",compressible:!1,extensions:["xpi"]},"application/x-xz":{source:"apache",extensions:["xz"]},"application/x-zmachine":{source:"apache",extensions:["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{source:"iana"},"application/xacml+xml":{source:"iana",compressible:!0},"application/xaml+xml":{source:"apache",compressible:!0,extensions:["xaml"]},"application/xcap-att+xml":{source:"iana",compressible:!0,extensions:["xav"]},"application/xcap-caps+xml":{source:"iana",compressible:!0,extensions:["xca"]},"application/xcap-diff+xml":{source:"iana",compressible:!0,extensions:["xdf"]},"application/xcap-el+xml":{source:"iana",compressible:!0,extensions:["xel"]},"application/xcap-error+xml":{source:"iana",compressible:!0},"application/xcap-ns+xml":{source:"iana",compressible:!0,extensions:["xns"]},"application/xcon-conference-info+xml":{source:"iana",compressible:!0},"application/xcon-conference-info-diff+xml":{source:"iana",compressible:!0},"application/xenc+xml":{source:"iana",compressible:!0,extensions:["xenc"]},"application/xhtml+xml":{source:"iana",compressible:!0,extensions:["xhtml","xht"]},"application/xhtml-voice+xml":{source:"apache",compressible:!0},"application/xliff+xml":{source:"iana",compressible:!0,extensions:["xlf"]},"application/xml":{source:"iana",compressible:!0,extensions:["xml","xsl","xsd","rng"]},"application/xml-dtd":{source:"iana",compressible:!0,extensions:["dtd"]},"application/xml-external-parsed-entity":{source:"iana"},"application/xml-patch+xml":{source:"iana",compressible:!0},"application/xmpp+xml":{source:"iana",compressible:!0},"application/xop+xml":{source:"iana",compressible:!0,extensions:["xop"]},"application/xproc+xml":{source:"apache",compressible:!0,extensions:["xpl"]},"application/xslt+xml":{source:"iana",compressible:!0,extensions:["xsl","xslt"]},"application/xspf+xml":{source:"apache",compressible:!0,extensions:["xspf"]},"application/xv+xml":{source:"iana",compressible:!0,extensions:["mxml","xhvml","xvml","xvm"]},"application/yang":{source:"iana",extensions:["yang"]},"application/yang-data+json":{source:"iana",compressible:!0},"application/yang-data+xml":{source:"iana",compressible:!0},"application/yang-patch+json":{source:"iana",compressible:!0},"application/yang-patch+xml":{source:"iana",compressible:!0},"application/yin+xml":{source:"iana",compressible:!0,extensions:["yin"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/zlib":{source:"iana"},"application/zstd":{source:"iana"},"audio/1d-interleaved-parityfec":{source:"iana"},"audio/32kadpcm":{source:"iana"},"audio/3gpp":{source:"iana",compressible:!1,extensions:["3gpp"]},"audio/3gpp2":{source:"iana"},"audio/aac":{source:"iana"},"audio/ac3":{source:"iana"},"audio/adpcm":{source:"apache",extensions:["adp"]},"audio/amr":{source:"iana",extensions:["amr"]},"audio/amr-wb":{source:"iana"},"audio/amr-wb+":{source:"iana"},"audio/aptx":{source:"iana"},"audio/asc":{source:"iana"},"audio/atrac-advanced-lossless":{source:"iana"},"audio/atrac-x":{source:"iana"},"audio/atrac3":{source:"iana"},"audio/basic":{source:"iana",compressible:!1,extensions:["au","snd"]},"audio/bv16":{source:"iana"},"audio/bv32":{source:"iana"},"audio/clearmode":{source:"iana"},"audio/cn":{source:"iana"},"audio/dat12":{source:"iana"},"audio/dls":{source:"iana"},"audio/dsr-es201108":{source:"iana"},"audio/dsr-es202050":{source:"iana"},"audio/dsr-es202211":{source:"iana"},"audio/dsr-es202212":{source:"iana"},"audio/dv":{source:"iana"},"audio/dvi4":{source:"iana"},"audio/eac3":{source:"iana"},"audio/encaprtp":{source:"iana"},"audio/evrc":{source:"iana"},"audio/evrc-qcp":{source:"iana"},"audio/evrc0":{source:"iana"},"audio/evrc1":{source:"iana"},"audio/evrcb":{source:"iana"},"audio/evrcb0":{source:"iana"},"audio/evrcb1":{source:"iana"},"audio/evrcnw":{source:"iana"},"audio/evrcnw0":{source:"iana"},"audio/evrcnw1":{source:"iana"},"audio/evrcwb":{source:"iana"},"audio/evrcwb0":{source:"iana"},"audio/evrcwb1":{source:"iana"},"audio/evs":{source:"iana"},"audio/flexfec":{source:"iana"},"audio/fwdred":{source:"iana"},"audio/g711-0":{source:"iana"},"audio/g719":{source:"iana"},"audio/g722":{source:"iana"},"audio/g7221":{source:"iana"},"audio/g723":{source:"iana"},"audio/g726-16":{source:"iana"},"audio/g726-24":{source:"iana"},"audio/g726-32":{source:"iana"},"audio/g726-40":{source:"iana"},"audio/g728":{source:"iana"},"audio/g729":{source:"iana"},"audio/g7291":{source:"iana"},"audio/g729d":{source:"iana"},"audio/g729e":{source:"iana"},"audio/gsm":{source:"iana"},"audio/gsm-efr":{source:"iana"},"audio/gsm-hr-08":{source:"iana"},"audio/ilbc":{source:"iana"},"audio/ip-mr_v2.5":{source:"iana"},"audio/isac":{source:"apache"},"audio/l16":{source:"iana"},"audio/l20":{source:"iana"},"audio/l24":{source:"iana",compressible:!1},"audio/l8":{source:"iana"},"audio/lpc":{source:"iana"},"audio/melp":{source:"iana"},"audio/melp1200":{source:"iana"},"audio/melp2400":{source:"iana"},"audio/melp600":{source:"iana"},"audio/mhas":{source:"iana"},"audio/midi":{source:"apache",extensions:["mid","midi","kar","rmi"]},"audio/mobile-xmf":{source:"iana",extensions:["mxmf"]},"audio/mp3":{compressible:!1,extensions:["mp3"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a","mp4a"]},"audio/mp4a-latm":{source:"iana"},"audio/mpa":{source:"iana"},"audio/mpa-robust":{source:"iana"},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{source:"iana"},"audio/musepack":{source:"apache"},"audio/ogg":{source:"iana",compressible:!1,extensions:["oga","ogg","spx","opus"]},"audio/opus":{source:"iana"},"audio/parityfec":{source:"iana"},"audio/pcma":{source:"iana"},"audio/pcma-wb":{source:"iana"},"audio/pcmu":{source:"iana"},"audio/pcmu-wb":{source:"iana"},"audio/prs.sid":{source:"iana"},"audio/qcelp":{source:"iana"},"audio/raptorfec":{source:"iana"},"audio/red":{source:"iana"},"audio/rtp-enc-aescm128":{source:"iana"},"audio/rtp-midi":{source:"iana"},"audio/rtploopback":{source:"iana"},"audio/rtx":{source:"iana"},"audio/s3m":{source:"apache",extensions:["s3m"]},"audio/scip":{source:"iana"},"audio/silk":{source:"apache",extensions:["sil"]},"audio/smv":{source:"iana"},"audio/smv-qcp":{source:"iana"},"audio/smv0":{source:"iana"},"audio/sofa":{source:"iana"},"audio/sp-midi":{source:"iana"},"audio/speex":{source:"iana"},"audio/t140c":{source:"iana"},"audio/t38":{source:"iana"},"audio/telephone-event":{source:"iana"},"audio/tetra_acelp":{source:"iana"},"audio/tetra_acelp_bb":{source:"iana"},"audio/tone":{source:"iana"},"audio/tsvcis":{source:"iana"},"audio/uemclip":{source:"iana"},"audio/ulpfec":{source:"iana"},"audio/usac":{source:"iana"},"audio/vdvi":{source:"iana"},"audio/vmr-wb":{source:"iana"},"audio/vnd.3gpp.iufp":{source:"iana"},"audio/vnd.4sb":{source:"iana"},"audio/vnd.audiokoz":{source:"iana"},"audio/vnd.celp":{source:"iana"},"audio/vnd.cisco.nse":{source:"iana"},"audio/vnd.cmles.radio-events":{source:"iana"},"audio/vnd.cns.anp1":{source:"iana"},"audio/vnd.cns.inf1":{source:"iana"},"audio/vnd.dece.audio":{source:"iana",extensions:["uva","uvva"]},"audio/vnd.digital-winds":{source:"iana",extensions:["eol"]},"audio/vnd.dlna.adts":{source:"iana"},"audio/vnd.dolby.heaac.1":{source:"iana"},"audio/vnd.dolby.heaac.2":{source:"iana"},"audio/vnd.dolby.mlp":{source:"iana"},"audio/vnd.dolby.mps":{source:"iana"},"audio/vnd.dolby.pl2":{source:"iana"},"audio/vnd.dolby.pl2x":{source:"iana"},"audio/vnd.dolby.pl2z":{source:"iana"},"audio/vnd.dolby.pulse.1":{source:"iana"},"audio/vnd.dra":{source:"iana",extensions:["dra"]},"audio/vnd.dts":{source:"iana",extensions:["dts"]},"audio/vnd.dts.hd":{source:"iana",extensions:["dtshd"]},"audio/vnd.dts.uhd":{source:"iana"},"audio/vnd.dvb.file":{source:"iana"},"audio/vnd.everad.plj":{source:"iana"},"audio/vnd.hns.audio":{source:"iana"},"audio/vnd.lucent.voice":{source:"iana",extensions:["lvp"]},"audio/vnd.ms-playready.media.pya":{source:"iana",extensions:["pya"]},"audio/vnd.nokia.mobile-xmf":{source:"iana"},"audio/vnd.nortel.vbk":{source:"iana"},"audio/vnd.nuera.ecelp4800":{source:"iana",extensions:["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{source:"iana",extensions:["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{source:"iana",extensions:["ecelp9600"]},"audio/vnd.octel.sbc":{source:"iana"},"audio/vnd.presonus.multitrack":{source:"iana"},"audio/vnd.qcelp":{source:"iana"},"audio/vnd.rhetorex.32kadpcm":{source:"iana"},"audio/vnd.rip":{source:"iana",extensions:["rip"]},"audio/vnd.rn-realaudio":{compressible:!1},"audio/vnd.sealedmedia.softseal.mpeg":{source:"iana"},"audio/vnd.vmx.cvsd":{source:"iana"},"audio/vnd.wave":{compressible:!1},"audio/vorbis":{source:"iana",compressible:!1},"audio/vorbis-config":{source:"iana"},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/wave":{compressible:!1,extensions:["wav"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/x-aac":{source:"apache",compressible:!1,extensions:["aac"]},"audio/x-aiff":{source:"apache",extensions:["aif","aiff","aifc"]},"audio/x-caf":{source:"apache",compressible:!1,extensions:["caf"]},"audio/x-flac":{source:"apache",extensions:["flac"]},"audio/x-m4a":{source:"nginx",extensions:["m4a"]},"audio/x-matroska":{source:"apache",extensions:["mka"]},"audio/x-mpegurl":{source:"apache",extensions:["m3u"]},"audio/x-ms-wax":{source:"apache",extensions:["wax"]},"audio/x-ms-wma":{source:"apache",extensions:["wma"]},"audio/x-pn-realaudio":{source:"apache",extensions:["ram","ra"]},"audio/x-pn-realaudio-plugin":{source:"apache",extensions:["rmp"]},"audio/x-realaudio":{source:"nginx",extensions:["ra"]},"audio/x-tta":{source:"apache"},"audio/x-wav":{source:"apache",extensions:["wav"]},"audio/xm":{source:"apache",extensions:["xm"]},"chemical/x-cdx":{source:"apache",extensions:["cdx"]},"chemical/x-cif":{source:"apache",extensions:["cif"]},"chemical/x-cmdf":{source:"apache",extensions:["cmdf"]},"chemical/x-cml":{source:"apache",extensions:["cml"]},"chemical/x-csml":{source:"apache",extensions:["csml"]},"chemical/x-pdb":{source:"apache"},"chemical/x-xyz":{source:"apache",extensions:["xyz"]},"font/collection":{source:"iana",extensions:["ttc"]},"font/otf":{source:"iana",compressible:!0,extensions:["otf"]},"font/sfnt":{source:"iana"},"font/ttf":{source:"iana",compressible:!0,extensions:["ttf"]},"font/woff":{source:"iana",extensions:["woff"]},"font/woff2":{source:"iana",extensions:["woff2"]},"image/aces":{source:"iana",extensions:["exr"]},"image/apng":{compressible:!1,extensions:["apng"]},"image/avci":{source:"iana",extensions:["avci"]},"image/avcs":{source:"iana",extensions:["avcs"]},"image/avif":{source:"iana",compressible:!1,extensions:["avif"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/cgm":{source:"iana",extensions:["cgm"]},"image/dicom-rle":{source:"iana",extensions:["drle"]},"image/emf":{source:"iana",extensions:["emf"]},"image/fits":{source:"iana",extensions:["fits"]},"image/g3fax":{source:"iana",extensions:["g3"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/heic":{source:"iana",extensions:["heic"]},"image/heic-sequence":{source:"iana",extensions:["heics"]},"image/heif":{source:"iana",extensions:["heif"]},"image/heif-sequence":{source:"iana",extensions:["heifs"]},"image/hej2k":{source:"iana",extensions:["hej2"]},"image/hsj2":{source:"iana",extensions:["hsj2"]},"image/ief":{source:"iana",extensions:["ief"]},"image/jls":{source:"iana",extensions:["jls"]},"image/jp2":{source:"iana",compressible:!1,extensions:["jp2","jpg2"]},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/jph":{source:"iana",extensions:["jph"]},"image/jphc":{source:"iana",extensions:["jhc"]},"image/jpm":{source:"iana",compressible:!1,extensions:["jpm"]},"image/jpx":{source:"iana",compressible:!1,extensions:["jpx","jpf"]},"image/jxr":{source:"iana",extensions:["jxr"]},"image/jxra":{source:"iana",extensions:["jxra"]},"image/jxrs":{source:"iana",extensions:["jxrs"]},"image/jxs":{source:"iana",extensions:["jxs"]},"image/jxsc":{source:"iana",extensions:["jxsc"]},"image/jxsi":{source:"iana",extensions:["jxsi"]},"image/jxss":{source:"iana",extensions:["jxss"]},"image/ktx":{source:"iana",extensions:["ktx"]},"image/ktx2":{source:"iana",extensions:["ktx2"]},"image/naplps":{source:"iana"},"image/pjpeg":{compressible:!1},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/prs.btif":{source:"iana",extensions:["btif"]},"image/prs.pti":{source:"iana",extensions:["pti"]},"image/pwg-raster":{source:"iana"},"image/sgi":{source:"apache",extensions:["sgi"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/t38":{source:"iana",extensions:["t38"]},"image/tiff":{source:"iana",compressible:!1,extensions:["tif","tiff"]},"image/tiff-fx":{source:"iana",extensions:["tfx"]},"image/vnd.adobe.photoshop":{source:"iana",compressible:!0,extensions:["psd"]},"image/vnd.airzip.accelerator.azv":{source:"iana",extensions:["azv"]},"image/vnd.cns.inf2":{source:"iana"},"image/vnd.dece.graphic":{source:"iana",extensions:["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{source:"iana",extensions:["djvu","djv"]},"image/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"image/vnd.dwg":{source:"iana",extensions:["dwg"]},"image/vnd.dxf":{source:"iana",extensions:["dxf"]},"image/vnd.fastbidsheet":{source:"iana",extensions:["fbs"]},"image/vnd.fpx":{source:"iana",extensions:["fpx"]},"image/vnd.fst":{source:"iana",extensions:["fst"]},"image/vnd.fujixerox.edmics-mmr":{source:"iana",extensions:["mmr"]},"image/vnd.fujixerox.edmics-rlc":{source:"iana",extensions:["rlc"]},"image/vnd.globalgraphics.pgb":{source:"iana"},"image/vnd.microsoft.icon":{source:"iana",compressible:!0,extensions:["ico"]},"image/vnd.mix":{source:"iana"},"image/vnd.mozilla.apng":{source:"iana"},"image/vnd.ms-dds":{compressible:!0,extensions:["dds"]},"image/vnd.ms-modi":{source:"iana",extensions:["mdi"]},"image/vnd.ms-photo":{source:"apache",extensions:["wdp"]},"image/vnd.net-fpx":{source:"iana",extensions:["npx"]},"image/vnd.pco.b16":{source:"iana",extensions:["b16"]},"image/vnd.radiance":{source:"iana"},"image/vnd.sealed.png":{source:"iana"},"image/vnd.sealedmedia.softseal.gif":{source:"iana"},"image/vnd.sealedmedia.softseal.jpg":{source:"iana"},"image/vnd.svf":{source:"iana"},"image/vnd.tencent.tap":{source:"iana",extensions:["tap"]},"image/vnd.valve.source.texture":{source:"iana",extensions:["vtf"]},"image/vnd.wap.wbmp":{source:"iana",extensions:["wbmp"]},"image/vnd.xiff":{source:"iana",extensions:["xif"]},"image/vnd.zbrush.pcx":{source:"iana",extensions:["pcx"]},"image/webp":{source:"apache",extensions:["webp"]},"image/wmf":{source:"iana",extensions:["wmf"]},"image/x-3ds":{source:"apache",extensions:["3ds"]},"image/x-cmu-raster":{source:"apache",extensions:["ras"]},"image/x-cmx":{source:"apache",extensions:["cmx"]},"image/x-freehand":{source:"apache",extensions:["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/x-jng":{source:"nginx",extensions:["jng"]},"image/x-mrsid-image":{source:"apache",extensions:["sid"]},"image/x-ms-bmp":{source:"nginx",compressible:!0,extensions:["bmp"]},"image/x-pcx":{source:"apache",extensions:["pcx"]},"image/x-pict":{source:"apache",extensions:["pic","pct"]},"image/x-portable-anymap":{source:"apache",extensions:["pnm"]},"image/x-portable-bitmap":{source:"apache",extensions:["pbm"]},"image/x-portable-graymap":{source:"apache",extensions:["pgm"]},"image/x-portable-pixmap":{source:"apache",extensions:["ppm"]},"image/x-rgb":{source:"apache",extensions:["rgb"]},"image/x-tga":{source:"apache",extensions:["tga"]},"image/x-xbitmap":{source:"apache",extensions:["xbm"]},"image/x-xcf":{compressible:!1},"image/x-xpixmap":{source:"apache",extensions:["xpm"]},"image/x-xwindowdump":{source:"apache",extensions:["xwd"]},"message/cpim":{source:"iana"},"message/delivery-status":{source:"iana"},"message/disposition-notification":{source:"iana",extensions:["disposition-notification"]},"message/external-body":{source:"iana"},"message/feedback-report":{source:"iana"},"message/global":{source:"iana",extensions:["u8msg"]},"message/global-delivery-status":{source:"iana",extensions:["u8dsn"]},"message/global-disposition-notification":{source:"iana",extensions:["u8mdn"]},"message/global-headers":{source:"iana",extensions:["u8hdr"]},"message/http":{source:"iana",compressible:!1},"message/imdn+xml":{source:"iana",compressible:!0},"message/news":{source:"iana"},"message/partial":{source:"iana",compressible:!1},"message/rfc822":{source:"iana",compressible:!0,extensions:["eml","mime"]},"message/s-http":{source:"iana"},"message/sip":{source:"iana"},"message/sipfrag":{source:"iana"},"message/tracking-status":{source:"iana"},"message/vnd.si.simp":{source:"iana"},"message/vnd.wfa.wsc":{source:"iana",extensions:["wsc"]},"model/3mf":{source:"iana",extensions:["3mf"]},"model/e57":{source:"iana"},"model/gltf+json":{source:"iana",compressible:!0,extensions:["gltf"]},"model/gltf-binary":{source:"iana",compressible:!0,extensions:["glb"]},"model/iges":{source:"iana",compressible:!1,extensions:["igs","iges"]},"model/mesh":{source:"iana",compressible:!1,extensions:["msh","mesh","silo"]},"model/mtl":{source:"iana",extensions:["mtl"]},"model/obj":{source:"iana",extensions:["obj"]},"model/step":{source:"iana"},"model/step+xml":{source:"iana",compressible:!0,extensions:["stpx"]},"model/step+zip":{source:"iana",compressible:!1,extensions:["stpz"]},"model/step-xml+zip":{source:"iana",compressible:!1,extensions:["stpxz"]},"model/stl":{source:"iana",extensions:["stl"]},"model/vnd.collada+xml":{source:"iana",compressible:!0,extensions:["dae"]},"model/vnd.dwf":{source:"iana",extensions:["dwf"]},"model/vnd.flatland.3dml":{source:"iana"},"model/vnd.gdl":{source:"iana",extensions:["gdl"]},"model/vnd.gs-gdl":{source:"apache"},"model/vnd.gs.gdl":{source:"iana"},"model/vnd.gtw":{source:"iana",extensions:["gtw"]},"model/vnd.moml+xml":{source:"iana",compressible:!0},"model/vnd.mts":{source:"iana",extensions:["mts"]},"model/vnd.opengex":{source:"iana",extensions:["ogex"]},"model/vnd.parasolid.transmit.binary":{source:"iana",extensions:["x_b"]},"model/vnd.parasolid.transmit.text":{source:"iana",extensions:["x_t"]},"model/vnd.pytha.pyox":{source:"iana"},"model/vnd.rosette.annotated-data-model":{source:"iana"},"model/vnd.sap.vds":{source:"iana",extensions:["vds"]},"model/vnd.usdz+zip":{source:"iana",compressible:!1,extensions:["usdz"]},"model/vnd.valve.source.compiled-map":{source:"iana",extensions:["bsp"]},"model/vnd.vtu":{source:"iana",extensions:["vtu"]},"model/vrml":{source:"iana",compressible:!1,extensions:["wrl","vrml"]},"model/x3d+binary":{source:"apache",compressible:!1,extensions:["x3db","x3dbz"]},"model/x3d+fastinfoset":{source:"iana",extensions:["x3db"]},"model/x3d+vrml":{source:"apache",compressible:!1,extensions:["x3dv","x3dvz"]},"model/x3d+xml":{source:"iana",compressible:!0,extensions:["x3d","x3dz"]},"model/x3d-vrml":{source:"iana",extensions:["x3dv"]},"multipart/alternative":{source:"iana",compressible:!1},"multipart/appledouble":{source:"iana"},"multipart/byteranges":{source:"iana"},"multipart/digest":{source:"iana"},"multipart/encrypted":{source:"iana",compressible:!1},"multipart/form-data":{source:"iana",compressible:!1},"multipart/header-set":{source:"iana"},"multipart/mixed":{source:"iana"},"multipart/multilingual":{source:"iana"},"multipart/parallel":{source:"iana"},"multipart/related":{source:"iana",compressible:!1},"multipart/report":{source:"iana"},"multipart/signed":{source:"iana",compressible:!1},"multipart/vnd.bint.med-plus":{source:"iana"},"multipart/voice-message":{source:"iana"},"multipart/x-mixed-replace":{source:"iana"},"text/1d-interleaved-parityfec":{source:"iana"},"text/cache-manifest":{source:"iana",compressible:!0,extensions:["appcache","manifest"]},"text/calendar":{source:"iana",extensions:["ics","ifb"]},"text/calender":{compressible:!0},"text/cmd":{compressible:!0},"text/coffeescript":{extensions:["coffee","litcoffee"]},"text/cql":{source:"iana"},"text/cql-expression":{source:"iana"},"text/cql-identifier":{source:"iana"},"text/css":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["css"]},"text/csv":{source:"iana",compressible:!0,extensions:["csv"]},"text/csv-schema":{source:"iana"},"text/directory":{source:"iana"},"text/dns":{source:"iana"},"text/ecmascript":{source:"iana"},"text/encaprtp":{source:"iana"},"text/enriched":{source:"iana"},"text/fhirpath":{source:"iana"},"text/flexfec":{source:"iana"},"text/fwdred":{source:"iana"},"text/gff3":{source:"iana"},"text/grammar-ref-list":{source:"iana"},"text/html":{source:"iana",compressible:!0,extensions:["html","htm","shtml"]},"text/jade":{extensions:["jade"]},"text/javascript":{source:"iana",compressible:!0},"text/jcr-cnd":{source:"iana"},"text/jsx":{compressible:!0,extensions:["jsx"]},"text/less":{compressible:!0,extensions:["less"]},"text/markdown":{source:"iana",compressible:!0,extensions:["markdown","md"]},"text/mathml":{source:"nginx",extensions:["mml"]},"text/mdx":{compressible:!0,extensions:["mdx"]},"text/mizar":{source:"iana"},"text/n3":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["n3"]},"text/parameters":{source:"iana",charset:"UTF-8"},"text/parityfec":{source:"iana"},"text/plain":{source:"iana",compressible:!0,extensions:["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{source:"iana",charset:"UTF-8"},"text/prs.fallenstein.rst":{source:"iana"},"text/prs.lines.tag":{source:"iana",extensions:["dsc"]},"text/prs.prop.logic":{source:"iana"},"text/raptorfec":{source:"iana"},"text/red":{source:"iana"},"text/rfc822-headers":{source:"iana"},"text/richtext":{source:"iana",compressible:!0,extensions:["rtx"]},"text/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"text/rtp-enc-aescm128":{source:"iana"},"text/rtploopback":{source:"iana"},"text/rtx":{source:"iana"},"text/sgml":{source:"iana",extensions:["sgml","sgm"]},"text/shaclc":{source:"iana"},"text/shex":{source:"iana",extensions:["shex"]},"text/slim":{extensions:["slim","slm"]},"text/spdx":{source:"iana",extensions:["spdx"]},"text/strings":{source:"iana"},"text/stylus":{extensions:["stylus","styl"]},"text/t140":{source:"iana"},"text/tab-separated-values":{source:"iana",compressible:!0,extensions:["tsv"]},"text/troff":{source:"iana",extensions:["t","tr","roff","man","me","ms"]},"text/turtle":{source:"iana",charset:"UTF-8",extensions:["ttl"]},"text/ulpfec":{source:"iana"},"text/uri-list":{source:"iana",compressible:!0,extensions:["uri","uris","urls"]},"text/vcard":{source:"iana",compressible:!0,extensions:["vcard"]},"text/vnd.a":{source:"iana"},"text/vnd.abc":{source:"iana"},"text/vnd.ascii-art":{source:"iana"},"text/vnd.curl":{source:"iana",extensions:["curl"]},"text/vnd.curl.dcurl":{source:"apache",extensions:["dcurl"]},"text/vnd.curl.mcurl":{source:"apache",extensions:["mcurl"]},"text/vnd.curl.scurl":{source:"apache",extensions:["scurl"]},"text/vnd.debian.copyright":{source:"iana",charset:"UTF-8"},"text/vnd.dmclientscript":{source:"iana"},"text/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"text/vnd.esmertec.theme-descriptor":{source:"iana",charset:"UTF-8"},"text/vnd.familysearch.gedcom":{source:"iana",extensions:["ged"]},"text/vnd.ficlab.flt":{source:"iana"},"text/vnd.fly":{source:"iana",extensions:["fly"]},"text/vnd.fmi.flexstor":{source:"iana",extensions:["flx"]},"text/vnd.gml":{source:"iana"},"text/vnd.graphviz":{source:"iana",extensions:["gv"]},"text/vnd.hans":{source:"iana"},"text/vnd.hgl":{source:"iana"},"text/vnd.in3d.3dml":{source:"iana",extensions:["3dml"]},"text/vnd.in3d.spot":{source:"iana",extensions:["spot"]},"text/vnd.iptc.newsml":{source:"iana"},"text/vnd.iptc.nitf":{source:"iana"},"text/vnd.latex-z":{source:"iana"},"text/vnd.motorola.reflex":{source:"iana"},"text/vnd.ms-mediapackage":{source:"iana"},"text/vnd.net2phone.commcenter.command":{source:"iana"},"text/vnd.radisys.msml-basic-layout":{source:"iana"},"text/vnd.senx.warpscript":{source:"iana"},"text/vnd.si.uricatalogue":{source:"iana"},"text/vnd.sosi":{source:"iana"},"text/vnd.sun.j2me.app-descriptor":{source:"iana",charset:"UTF-8",extensions:["jad"]},"text/vnd.trolltech.linguist":{source:"iana",charset:"UTF-8"},"text/vnd.wap.si":{source:"iana"},"text/vnd.wap.sl":{source:"iana"},"text/vnd.wap.wml":{source:"iana",extensions:["wml"]},"text/vnd.wap.wmlscript":{source:"iana",extensions:["wmls"]},"text/vtt":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["vtt"]},"text/x-asm":{source:"apache",extensions:["s","asm"]},"text/x-c":{source:"apache",extensions:["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{source:"nginx",extensions:["htc"]},"text/x-fortran":{source:"apache",extensions:["f","for","f77","f90"]},"text/x-gwt-rpc":{compressible:!0},"text/x-handlebars-template":{extensions:["hbs"]},"text/x-java-source":{source:"apache",extensions:["java"]},"text/x-jquery-tmpl":{compressible:!0},"text/x-lua":{extensions:["lua"]},"text/x-markdown":{compressible:!0,extensions:["mkd"]},"text/x-nfo":{source:"apache",extensions:["nfo"]},"text/x-opml":{source:"apache",extensions:["opml"]},"text/x-org":{compressible:!0,extensions:["org"]},"text/x-pascal":{source:"apache",extensions:["p","pas"]},"text/x-processing":{compressible:!0,extensions:["pde"]},"text/x-sass":{extensions:["sass"]},"text/x-scss":{extensions:["scss"]},"text/x-setext":{source:"apache",extensions:["etx"]},"text/x-sfv":{source:"apache",extensions:["sfv"]},"text/x-suse-ymp":{compressible:!0,extensions:["ymp"]},"text/x-uuencode":{source:"apache",extensions:["uu"]},"text/x-vcalendar":{source:"apache",extensions:["vcs"]},"text/x-vcard":{source:"apache",extensions:["vcf"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/xml-external-parsed-entity":{source:"iana"},"text/yaml":{compressible:!0,extensions:["yaml","yml"]},"video/1d-interleaved-parityfec":{source:"iana"},"video/3gpp":{source:"iana",extensions:["3gp","3gpp"]},"video/3gpp-tt":{source:"iana"},"video/3gpp2":{source:"iana",extensions:["3g2"]},"video/av1":{source:"iana"},"video/bmpeg":{source:"iana"},"video/bt656":{source:"iana"},"video/celb":{source:"iana"},"video/dv":{source:"iana"},"video/encaprtp":{source:"iana"},"video/ffv1":{source:"iana"},"video/flexfec":{source:"iana"},"video/h261":{source:"iana",extensions:["h261"]},"video/h263":{source:"iana",extensions:["h263"]},"video/h263-1998":{source:"iana"},"video/h263-2000":{source:"iana"},"video/h264":{source:"iana",extensions:["h264"]},"video/h264-rcdo":{source:"iana"},"video/h264-svc":{source:"iana"},"video/h265":{source:"iana"},"video/iso.segment":{source:"iana",extensions:["m4s"]},"video/jpeg":{source:"iana",extensions:["jpgv"]},"video/jpeg2000":{source:"iana"},"video/jpm":{source:"apache",extensions:["jpm","jpgm"]},"video/jxsv":{source:"iana"},"video/mj2":{source:"iana",extensions:["mj2","mjp2"]},"video/mp1s":{source:"iana"},"video/mp2p":{source:"iana"},"video/mp2t":{source:"iana",extensions:["ts"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","mp4v","mpg4"]},"video/mp4v-es":{source:"iana"},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{source:"iana"},"video/mpv":{source:"iana"},"video/nv":{source:"iana"},"video/ogg":{source:"iana",compressible:!1,extensions:["ogv"]},"video/parityfec":{source:"iana"},"video/pointer":{source:"iana"},"video/quicktime":{source:"iana",compressible:!1,extensions:["qt","mov"]},"video/raptorfec":{source:"iana"},"video/raw":{source:"iana"},"video/rtp-enc-aescm128":{source:"iana"},"video/rtploopback":{source:"iana"},"video/rtx":{source:"iana"},"video/scip":{source:"iana"},"video/smpte291":{source:"iana"},"video/smpte292m":{source:"iana"},"video/ulpfec":{source:"iana"},"video/vc1":{source:"iana"},"video/vc2":{source:"iana"},"video/vnd.cctv":{source:"iana"},"video/vnd.dece.hd":{source:"iana",extensions:["uvh","uvvh"]},"video/vnd.dece.mobile":{source:"iana",extensions:["uvm","uvvm"]},"video/vnd.dece.mp4":{source:"iana"},"video/vnd.dece.pd":{source:"iana",extensions:["uvp","uvvp"]},"video/vnd.dece.sd":{source:"iana",extensions:["uvs","uvvs"]},"video/vnd.dece.video":{source:"iana",extensions:["uvv","uvvv"]},"video/vnd.directv.mpeg":{source:"iana"},"video/vnd.directv.mpeg-tts":{source:"iana"},"video/vnd.dlna.mpeg-tts":{source:"iana"},"video/vnd.dvb.file":{source:"iana",extensions:["dvb"]},"video/vnd.fvt":{source:"iana",extensions:["fvt"]},"video/vnd.hns.video":{source:"iana"},"video/vnd.iptvforum.1dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.1dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.2dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.2dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.ttsavc":{source:"iana"},"video/vnd.iptvforum.ttsmpeg2":{source:"iana"},"video/vnd.motorola.video":{source:"iana"},"video/vnd.motorola.videop":{source:"iana"},"video/vnd.mpegurl":{source:"iana",extensions:["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{source:"iana",extensions:["pyv"]},"video/vnd.nokia.interleaved-multimedia":{source:"iana"},"video/vnd.nokia.mp4vr":{source:"iana"},"video/vnd.nokia.videovoip":{source:"iana"},"video/vnd.objectvideo":{source:"iana"},"video/vnd.radgamettools.bink":{source:"iana"},"video/vnd.radgamettools.smacker":{source:"iana"},"video/vnd.sealed.mpeg1":{source:"iana"},"video/vnd.sealed.mpeg4":{source:"iana"},"video/vnd.sealed.swf":{source:"iana"},"video/vnd.sealedmedia.softseal.mov":{source:"iana"},"video/vnd.uvvu.mp4":{source:"iana",extensions:["uvu","uvvu"]},"video/vnd.vivo":{source:"iana",extensions:["viv"]},"video/vnd.youtube.yt":{source:"iana"},"video/vp8":{source:"iana"},"video/vp9":{source:"iana"},"video/webm":{source:"apache",compressible:!1,extensions:["webm"]},"video/x-f4v":{source:"apache",extensions:["f4v"]},"video/x-fli":{source:"apache",extensions:["fli"]},"video/x-flv":{source:"apache",compressible:!1,extensions:["flv"]},"video/x-m4v":{source:"apache",extensions:["m4v"]},"video/x-matroska":{source:"apache",compressible:!1,extensions:["mkv","mk3d","mks"]},"video/x-mng":{source:"apache",extensions:["mng"]},"video/x-ms-asf":{source:"apache",extensions:["asf","asx"]},"video/x-ms-vob":{source:"apache",extensions:["vob"]},"video/x-ms-wm":{source:"apache",extensions:["wm"]},"video/x-ms-wmv":{source:"apache",compressible:!1,extensions:["wmv"]},"video/x-ms-wmx":{source:"apache",extensions:["wmx"]},"video/x-ms-wvx":{source:"apache",extensions:["wvx"]},"video/x-msvideo":{source:"apache",extensions:["avi"]},"video/x-sgi-movie":{source:"apache",extensions:["movie"]},"video/x-smv":{source:"apache",extensions:["smv"]},"x-conference/x-cooltalk":{source:"apache",extensions:["ice"]},"x-shader/x-fragment":{compressible:!0},"x-shader/x-vertex":{compressible:!0}},qn=Fn(function(e,t){var n,o,i,a=y.extname,r=/^\s*([^;\s]*)(?:;|\s|$)/,s=/^text\//i;function c(e){if(!e||"string"!=typeof e)return!1;var t=r.exec(e),n=t&&Dn[t[1].toLowerCase()];return n&&n.charset?n.charset:!(!t||!s.test(t[1]))&&"UTF-8"}t.charset=c,t.charsets={lookup:c},t.contentType=function(e){if(!e||"string"!=typeof e)return!1;var n=-1===e.indexOf("/")?t.lookup(e):e;if(!n)return!1;if(-1===n.indexOf("charset")){var o=t.charset(n);o&&(n+="; charset="+o.toLowerCase())}return n},t.extension=function(e){if(!e||"string"!=typeof e)return!1;var n=r.exec(e),o=n&&t.extensions[n[1].toLowerCase()];return!(!o||!o.length)&&o[0]},t.extensions=Object.create(null),t.lookup=function(e){if(!e||"string"!=typeof e)return!1;var n=a("x."+e).toLowerCase().substr(1);return n&&t.types[n]||!1},t.types=Object.create(null),n=t.extensions,o=t.types,i=["nginx","apache",void 0,"iana"],Object.keys(Dn).forEach(function(e){var t=Dn[e],a=t.extensions;if(a&&a.length){n[e]=a;for(var r=0;r<a.length;r++){var s=a[r];if(o[s]){var c=i.indexOf(Dn[o[s]].source),l=i.indexOf(t.source);if("application/octet-stream"!==o[s]&&(c>l||c===l&&"application/"===o[s].substr(0,12)))continue}o[s]=e}}})}),Bn=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)},Mn=function(e){var t=!1;return Bn(function(){t=!0}),function(n,o){t?e(n,o):Bn(function(){e(n,o)})}},Wn=function(e){Object.keys(e.jobs).forEach(Hn.bind(e)),e.jobs={}};function Hn(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}var Gn=function(e,t,n,o){var i=n.keyedList?n.keyedList[n.index]:n.index;n.jobs[i]=function(e,t,n,o){return 2==e.length?e(n,Mn(o)):e(n,t,Mn(o))}(t,i,e[i],function(e,t){i in n.jobs&&(delete n.jobs[i],e?Wn(n):n.results[i]=t,o(e,n.results))})},Jn=function(e,t){var n=!Array.isArray(e),o={index:0,keyedList:n||t?Object.keys(e):null,jobs:{},results:n?{}:[],size:n?Object.keys(e).length:e.length};return t&&o.keyedList.sort(n?t:function(n,o){return t(e[n],e[o])}),o},Vn=function(e){Object.keys(this.jobs).length&&(this.index=this.size,Wn(this),Mn(e)(null,this.results))},Kn=function(e,t,n,o){var i=Jn(e,n);return Gn(e,t,i,function n(a,r){a?o(a,r):(i.index++,i.index<(i.keyedList||e).length?Gn(e,t,i,n):o(null,i.results))}),Vn.bind(i,o)};function Yn(e,t){return e<t?-1:e>t?1:0}Kn.ascending=Yn,Kn.descending=function(e,t){return-1*Yn(e,t)};var Zn=Object,Xn=Error,Qn=EvalError,eo=RangeError,to=ReferenceError,no=SyntaxError,oo=TypeError,io=URIError,ao=Math.abs,ro=Math.floor,so=Math.max,co=Math.min,lo=Math.pow,po=Math.round,uo=Number.isNaN||function(e){return e!=e},mo=Object.getOwnPropertyDescriptor;if(mo)try{mo([],"length")}catch(e){mo=null}var fo=mo,ho=Object.defineProperty||!1;if(ho)try{ho({},"a",{value:1})}catch(e){ho=!1}var go,vo=ho,bo=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(var o in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var i=Object.getOwnPropertySymbols(e);if(1!==i.length||i[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var a=Object.getOwnPropertyDescriptor(e,t);if(42!==a.value||!0!==a.enumerable)return!1}return!0},xo="undefined"!=typeof Symbol&&Symbol,yo="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null,wo=Zn,_o=wo.getPrototypeOf||null,jo=Object.prototype.toString,ko=Math.max,So=function(e,t){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},Eo=Function.prototype.bind||function(e){var t=this;if("function"!=typeof t||"[object Function]"!==jo.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var n,o=function(e,t){for(var n=[],o=1,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n}(arguments),i=ko(0,t.length-o.length),a=[],r=0;r<i;r++)a[r]="$"+r;if(n=Function("binder","return function ("+function(e,t){for(var n="",o=0;o<e.length;o+=1)n+=e[o],o+1<e.length&&(n+=",");return n}(a)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof n){var i=t.apply(this,So(o,arguments));return Object(i)===i?i:this}return t.apply(e,So(o,arguments))}),t.prototype){var s=function(){};s.prototype=t.prototype,n.prototype=new s,s.prototype=null}return n},$o=Function.prototype.call,To=Function.prototype.apply,Io="undefined"!=typeof Reflect&&Reflect&&Reflect.apply||Eo.call($o,To),Oo=oo,Ao=fo;try{go=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var Co,Ro=!!go&&Ao&&Ao(Object.prototype,"__proto__"),No=Object,Po=No.getPrototypeOf,Uo=Ro&&"function"==typeof Ro.get?function(e){if(e.length<1||"function"!=typeof e[0])throw new Oo("a function is required");return Io(Eo,$o,e)}([Ro.get]):"function"==typeof Po&&function(e){return Po(null==e?e:No(e))},Lo=yo?function(e){return yo(e)}:_o?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return _o(e)}:Uo?function(e){return Uo(e)}:null,zo=Eo.call(Function.prototype.call,Object.prototype.hasOwnProperty),Fo=Xn,Do=Qn,qo=eo,Bo=to,Mo=no,Wo=io,Ho=ao,Go=ro,Jo=so,Vo=co,Ko=lo,Yo=po,Zo=vo,Xo=zo,Qo=Function,ei=function(e){try{return Qo('"use strict"; return ('+e+").constructor;")()}catch(e){}},ti=function(){throw new Oo},ni=Ao?function(){try{return ti}catch(e){try{return Ao(arguments,"callee").get}catch(e){return ti}}}():ti,oi="function"==typeof xo&&"function"==typeof Symbol&&"symbol"==typeof xo("foo")&&"symbol"==typeof Symbol("bar")&&bo(),ii={},ai="undefined"!=typeof Uint8Array&&Lo?Lo(Uint8Array):Co,ri={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?Co:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?Co:ArrayBuffer,"%ArrayIteratorPrototype%":oi&&Lo?Lo([][Symbol.iterator]()):Co,"%AsyncFromSyncIteratorPrototype%":Co,"%AsyncFunction%":ii,"%AsyncGenerator%":ii,"%AsyncGeneratorFunction%":ii,"%AsyncIteratorPrototype%":ii,"%Atomics%":"undefined"==typeof Atomics?Co:Atomics,"%BigInt%":"undefined"==typeof BigInt?Co:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?Co:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?Co:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?Co:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Fo,"%eval%":eval,"%EvalError%":Do,"%Float16Array%":"undefined"==typeof Float16Array?Co:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?Co:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?Co:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?Co:FinalizationRegistry,"%Function%":Qo,"%GeneratorFunction%":ii,"%Int8Array%":"undefined"==typeof Int8Array?Co:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?Co:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?Co:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":oi&&Lo?Lo(Lo([][Symbol.iterator]())):Co,"%JSON%":"object"==typeof JSON?JSON:Co,"%Map%":"undefined"==typeof Map?Co:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&oi&&Lo?Lo((new Map)[Symbol.iterator]()):Co,"%Math%":Math,"%Number%":Number,"%Object%":wo,"%Object.getOwnPropertyDescriptor%":Ao,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?Co:Promise,"%Proxy%":"undefined"==typeof Proxy?Co:Proxy,"%RangeError%":qo,"%ReferenceError%":Bo,"%Reflect%":"undefined"==typeof Reflect?Co:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?Co:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&oi&&Lo?Lo((new Set)[Symbol.iterator]()):Co,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?Co:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":oi&&Lo?Lo(""[Symbol.iterator]()):Co,"%Symbol%":oi?Symbol:Co,"%SyntaxError%":Mo,"%ThrowTypeError%":ni,"%TypedArray%":ai,"%TypeError%":Oo,"%Uint8Array%":"undefined"==typeof Uint8Array?Co:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?Co:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?Co:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?Co:Uint32Array,"%URIError%":Wo,"%WeakMap%":"undefined"==typeof WeakMap?Co:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?Co:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?Co:WeakSet,"%Function.prototype.call%":$o,"%Function.prototype.apply%":To,"%Object.defineProperty%":Zo,"%Object.getPrototypeOf%":_o,"%Math.abs%":Ho,"%Math.floor%":Go,"%Math.max%":Jo,"%Math.min%":Vo,"%Math.pow%":Ko,"%Math.round%":Yo,"%Math.sign%":function(e){return uo(e)||0===e?e:e<0?-1:1},"%Reflect.getPrototypeOf%":yo};if(Lo)try{null.error}catch(e){var si=Lo(Lo(e));ri["%Error.prototype%"]=si}var ci=function e(t){var n;if("%AsyncFunction%"===t)n=ei("async function () {}");else if("%GeneratorFunction%"===t)n=ei("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=ei("async function* () {}");else if("%AsyncGenerator%"===t){var o=e("%AsyncGeneratorFunction%");o&&(n=o.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&Lo&&(n=Lo(i.prototype))}return ri[t]=n,n},li={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},pi=Eo.call($o,Array.prototype.concat),ui=Eo.call(To,Array.prototype.splice),di=Eo.call($o,String.prototype.replace),mi=Eo.call($o,String.prototype.slice),fi=Eo.call($o,RegExp.prototype.exec),hi=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,gi=/\\(\\)?/g,vi=function(e,t){var n,o=e;if(Xo(li,o)&&(o="%"+(n=li[o])[0]+"%"),Xo(ri,o)){var i=ri[o];if(i===ii&&(i=ci(o)),void 0===i&&!t)throw new Oo("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:o,value:i}}throw new Mo("intrinsic "+e+" does not exist!")},bi=function(e,t){if("string"!=typeof e||0===e.length)throw new Oo("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new Oo('"allowMissing" argument must be a boolean');if(null===fi(/^%?[^%]*%?$/,e))throw new Mo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=mi(e,0,1),n=mi(e,-1);if("%"===t&&"%"!==n)throw new Mo("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new Mo("invalid intrinsic syntax, expected opening `%`");var o=[];return di(e,hi,function(e,t,n,i){o[o.length]=n?di(i,gi,"$1"):t||e}),o}(e),o=n.length>0?n[0]:"",i=vi("%"+o+"%",t),a=i.name,r=i.value,s=!1,c=i.alias;c&&(o=c[0],ui(n,pi([0,1],c)));for(var l=1,p=!0;l<n.length;l+=1){var u=n[l],d=mi(u,0,1),m=mi(u,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new Mo("property names with quotes must have matching quotes");if("constructor"!==u&&p||(s=!0),Xo(ri,a="%"+(o+="."+u)+"%"))r=ri[a];else if(null!=r){if(!(u in r)){if(!t)throw new Oo("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ao&&l+1>=n.length){var f=Ao(r,u);r=(p=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:r[u]}else p=Xo(r,u),r=r[u];p&&!s&&(ri[a]=r)}}return r}("%Object.defineProperty%",!0),xi=bo()&&Symbol.toStringTag?Symbol.toStringTag:null,yi=function(e,t){return Object.keys(t).forEach(function(n){e[n]=e[n]||t[n]}),e},wi=ye.parse,_i=ge.Stream;function ji(e){return String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22")}function ki(e){if(!(this instanceof ki))return new ki(e);for(var t in this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],Un.call(this),e=e||{})this[t]=e[t]}he.inherits(ki,Un),ki.LINE_BREAK="\r\n",ki.DEFAULT_CONTENT_TYPE="application/octet-stream",ki.prototype.append=function(e,t,n){"string"==typeof(n=n||{})&&(n={filename:n});var o=Un.prototype.append.bind(this);if("number"!=typeof t&&null!=t||(t=String(t)),Array.isArray(t))this._error(new Error("Arrays are not supported."));else{var i=this._multiPartHeader(e,t,n),a=this._multiPartFooter();o(i),o(t),o(a),this._trackLength(i,t,n)}},ki.prototype._trackLength=function(e,t,n){var o=0;null!=n.knownLength?o+=Number(n.knownLength):Buffer.isBuffer(t)?o=t.length:"string"==typeof t&&(o=Buffer.byteLength(t)),this._valueLength+=o,this._overheadLength+=Buffer.byteLength(e)+ki.LINE_BREAK.length,t&&(t.path||t.readable&&Xo(t,"httpVersion")||t instanceof _i)&&(n.knownLength||this._valuesToMeasure.push(t))},ki.prototype._lengthRetriever=function(e,t){Xo(e,"fd")?null!=e.end&&Infinity!=e.end&&null!=e.start?t(null,e.end+1-(e.start?e.start:0)):s.stat(e.path,function(n,o){n?t(n):t(null,o.size-(e.start?e.start:0))}):Xo(e,"httpVersion")?t(null,Number(e.headers["content-length"])):Xo(e,"httpModule")?(e.on("response",function(n){e.pause(),t(null,Number(n.headers["content-length"]))}),e.resume()):t("Unknown stream")},ki.prototype._multiPartHeader=function(e,t,n){if("string"==typeof n.header)return n.header;var o,i=this._getContentDisposition(t,n),a=this._getContentType(t,n),r="",s={"Content-Disposition":["form-data",'name="'+ji(e)+'"'].concat(i||[]),"Content-Type":[].concat(a||[])};for(var c in"object"==typeof n.header&&yi(s,n.header),s)if(Xo(s,c)){if(null==(o=s[c]))continue;Array.isArray(o)||(o=[o]),o.length&&(r+=c+": "+o.join("; ")+ki.LINE_BREAK)}return"--"+this.getBoundary()+ki.LINE_BREAK+r+ki.LINE_BREAK},ki.prototype._getContentDisposition=function(e,t){var n;if("string"==typeof t.filepath?n=y.normalize(t.filepath).replace(/\\/g,"/"):t.filename||e&&(e.name||e.path)?n=y.basename(t.filename||e&&(e.name||e.path)):e&&e.readable&&Xo(e,"httpVersion")&&(n=y.basename(e.client._httpMessage.path||"")),n)return'filename="'+ji(n)+'"'},ki.prototype._getContentType=function(e,t){var n=t.contentType;return!n&&e&&e.name&&(n=qn.lookup(e.name)),!n&&e&&e.path&&(n=qn.lookup(e.path)),!n&&e&&e.readable&&Xo(e,"httpVersion")&&(n=e.headers["content-type"]),n||!t.filepath&&!t.filename||(n=qn.lookup(t.filepath||t.filename)),!n&&e&&"object"==typeof e&&(n=ki.DEFAULT_CONTENT_TYPE),n},ki.prototype._multiPartFooter=function(){return function(e){var t=ki.LINE_BREAK;0===this._streams.length&&(t+=this._lastBoundary()),e(t)}.bind(this)},ki.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+ki.LINE_BREAK},ki.prototype.getHeaders=function(e){var t,n={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(t in e)Xo(e,t)&&(n[t.toLowerCase()]=e[t]);return n},ki.prototype.setBoundary=function(e){if("string"!=typeof e)throw new TypeError("FormData boundary must be a string");this._boundary=e},ki.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary},ki.prototype.getBuffer=function(){for(var e=new Buffer.alloc(0),t=this.getBoundary(),n=0,o=this._streams.length;n<o;n++)"function"!=typeof this._streams[n]&&(e=Buffer.isBuffer(this._streams[n])?Buffer.concat([e,this._streams[n]]):Buffer.concat([e,Buffer.from(this._streams[n])]),"string"==typeof this._streams[n]&&this._streams[n].substring(2,t.length+2)===t||(e=Buffer.concat([e,Buffer.from(ki.LINE_BREAK)])));return Buffer.concat([e,Buffer.from(this._lastBoundary())])},ki.prototype._generateBoundary=function(){this._boundary="--------------------------"+we.randomBytes(12).toString("hex")},ki.prototype.getLengthSync=function(){var e=this._overheadLength+this._valueLength;return this._streams.length&&(e+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),e},ki.prototype.hasKnownLength=function(){var e=!0;return this._valuesToMeasure.length&&(e=!1),e},ki.prototype.getLength=function(e){var t=this._overheadLength+this._valueLength;this._streams.length&&(t+=this._lastBoundary().length),this._valuesToMeasure.length?function(e,t,n){for(var o=Jn(e);o.index<(o.keyedList||e).length;)Gn(e,t,o,function(e,t){e?n(e,t):0!==Object.keys(o.jobs).length||n(null,o.results)}),o.index++;Vn.bind(o,n)}(this._valuesToMeasure,this._lengthRetriever,function(n,o){n?e(n):(o.forEach(function(e){t+=e}),e(null,t))}):process.nextTick(e.bind(this,null,t))},ki.prototype.submit=function(e,t){var n,o,i={method:"post"};return"string"==typeof e?(e=wi(e),o=yi({port:e.port,path:e.pathname,host:e.hostname,protocol:e.protocol},i)):(o=yi(e,i)).port||(o.port="https:"===o.protocol?443:80),o.headers=this.getHeaders(e.headers),n="https:"===o.protocol?xe.request(o):be.request(o),this.getLength(function(e,o){if(e&&"Unknown stream"!==e)this._error(e);else if(o&&n.setHeader("Content-Length",o),this.pipe(n),t){var i,a=function(e,o){return n.removeListener("error",a),n.removeListener("response",i),t.call(this,e,o)};i=a.bind(this,null),n.on("error",a),n.on("response",i)}}.bind(this)),n},ki.prototype._error=function(e){this.error||(this.error=e,this.pause(),this.emit("error",e))},ki.prototype.toString=function(){return"[object FormData]"},function(e,t){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,o=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(void 0!==n&&"boolean"!=typeof n||void 0!==o&&"boolean"!=typeof o)throw new Oo("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");!xi||!n&&Xo(e,xi)||(bi?bi(e,xi,{configurable:!o,enumerable:!1,value:t,writable:!1}):e[xi]=t)}(ki.prototype,"FormData");var Si=ki,Ei={isBufferAvailable:()=>"undefined"!=typeof Buffer,from:e=>Buffer.from(e)};const $i=100;function Ti(e){return hn.isPlainObject(e)||hn.isArray(e)}function Ii(e){return hn.endsWith(e,"[]")?e.slice(0,-2):e}function Oi(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ii(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Ai=hn.toFlatObject(hn,{},null,function(e){return/^is[A-Z]/.test(e)});function Ci(e,t,n){if(!hn.isObject(e))throw new TypeError("target must be an object");t=t||new(Si||FormData);const o=(n=hn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!hn.isUndefined(t[e])})).metaTokens,i=n.visitor||m,a=n.dots,r=n.indexes,s=n.Blob||"undefined"!=typeof Blob&&Blob,c=void 0===n.maxDepth?$i:n.maxDepth,l=s&&hn.isSpecCompliantForm(t),p=[];if(!hn.isFunction(i))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(hn.isDate(e))return e.toISOString();if(hn.isBoolean(e))return e.toString();if(!l&&hn.isBlob(e))throw new An("Blob is not supported. Use a Buffer instead.");if(hn.isArrayBuffer(e)||hn.isTypedArray(e)){if(l&&"function"==typeof s)return new s([e]);if(Ei&&Ei.isBufferAvailable())return Ei.from(e);throw new An("Blob is not supported. Use a Buffer instead.",An.ERR_NOT_SUPPORT)}return e}function d(e){if(e>c)throw new An("Object is too deeply nested ("+e+" levels). Max depth: "+c,An.ERR_FORM_DATA_DEPTH_EXCEEDED)}function m(e,n,i){let s=e;if(hn.isReactNative(t)&&hn.isReactNativeBlob(e))return t.append(Oi(i,n,a),u(e)),!1;if(e&&!i&&"object"==typeof e)if(hn.endsWith(n,"{}"))n=o?n:n.slice(0,-2),e=function(e,t){if(Infinity===c)return JSON.stringify(e);const n=[];return JSON.stringify(e,function(e,t){if(!hn.isObject(t))return t;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(t),d(1+n.length-1),t})}(e);else if(hn.isArray(e)&&function(e){return hn.isArray(e)&&!e.some(Ti)}(e)||(hn.isFileList(e)||hn.endsWith(n,"[]"))&&(s=hn.toArray(e)))return n=Ii(n),s.forEach(function(e,o){!hn.isUndefined(e)&&null!==e&&t.append(!0===r?Oi([n],o,a):null===r?n:n+"[]",u(e))}),!1;return!!Ti(e)||(t.append(Oi(i,n,a),u(e)),!1)}const f=Object.assign(Ai,{defaultVisitor:m,convertValue:u,isVisitable:Ti});if(!hn.isObject(e))throw new TypeError("data must be an object");return function e(n,o,a=0){if(!hn.isUndefined(n)){if(d(a),-1!==p.indexOf(n))throw new Error("Circular reference detected in "+o.join("."));p.push(n),hn.forEach(n,function(n,r){!0===(!(hn.isUndefined(n)||null===n)&&i.call(t,n,hn.isString(r)?r.trim():r,o,f))&&e(n,o?o.concat(r):[r],a+1)}),p.pop()}}(e),t}function Ri(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function Ni(e,t){this._pairs=[],e&&Ci(e,this,t)}const Pi=Ni.prototype;function Ui(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Li(e,t,n){if(!t)return e;e=e||"";const o=hn.isFunction(n)?{serialize:n}:n,i=hn.getSafeProp(o,"encode")||Ui,a=hn.getSafeProp(o,"serialize");let r;if(r=a?a(t,o):hn.isURLSearchParams(t)?t.toString():new Ni(t,o).toString(i),r){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}Pi.append=function(e,t){this._pairs.push([e,t])},Pi.toString=function(e){const t=e?t=>e.call(this,t,Ri):Ri;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var zi=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){hn.forEach(this.handlers,function(t){null!==t&&e(t)})}},Fi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},Di=ye.URLSearchParams;const qi="abcdefghijklmnopqrstuvwxyz",Bi="0123456789",Mi={DIGIT:Bi,ALPHA:qi,ALPHA_DIGIT:qi+qi.toUpperCase()+Bi};var Wi={isNode:!0,classes:{URLSearchParams:Di,FormData:Si,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:Mi,generateString:(e=16,t=Mi.ALPHA_DIGIT)=>{let n="";const{length:o}=t,i=new Uint32Array(e);we.randomFillSync(i);for(let a=0;a<e;a++)n+=t[i[a]%o];return n},protocols:["http","https","file","data"]};const Hi="undefined"!=typeof window&&"undefined"!=typeof document,Gi="object"==typeof navigator&&navigator||void 0,Ji=Hi&&(!Gi||["ReactNative","NativeScript","NS"].indexOf(Gi.product)<0);var Vi={__proto__:null,hasBrowserEnv:Hi,hasStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,hasStandardBrowserEnv:Ji,navigator:Gi,origin:Hi&&window.location.href||"http://localhost",...Wi};const Ki=$i;function Yi(e){if(e>Ki)throw new An("FormData field is too deeply nested ("+e+" levels). Max depth: "+Ki,An.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Zi(e){function t(e,n,o,i){Yi(i);let a=e[i++];if("__proto__"===a)return!0;const r=Number.isFinite(+a),s=i>=e.length;return a=!a&&hn.isArray(o)?o.length:a,s?(o[a]=hn.hasOwnProp(o,a)?hn.isArray(o[a])?o[a].concat(n):[o[a],n]:n,!r):(hn.hasOwnProp(o,a)&&hn.isObject(o[a])||(o[a]=[]),t(e,n,o[a],i)&&hn.isArray(o[a])&&(o[a]=function(e){const t={},n=Object.keys(e);let o;const i=n.length;let a;for(o=0;o<i;o++)a=n[o],t[a]=e[a];return t}(o[a])),!r)}if(hn.isFormData(e)&&hn.isFunction(e.entries)){const n={};return hn.forEachEntry(e,(e,o)=>{t(function(e){const t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g;let o;for(;null!==(o=n.exec(e));)Yi(t.length),t.push("[]"===o[0]?"":o[1]||o[0]);return t}(e),o,n,0)}),n}return null}const Xi=(e,t)=>null!=e&&hn.hasOwnProp(e,t)?e[t]:void 0,Qi={transitional:Fi,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,i=hn.isObject(e);if(i&&hn.isHTMLForm(e)&&(e=new FormData(e)),hn.isFormData(e))return o?JSON.stringify(Zi(e)):e;if(hn.isArrayBuffer(e)||hn.isBuffer(e)||hn.isStream(e)||hn.isFile(e)||hn.isBlob(e)||hn.isReadableStream(e))return e;if(hn.isArrayBufferView(e))return e.buffer;if(hn.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){const t=Xi(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ci(e,new Vi.classes.URLSearchParams,{visitor:function(e,t,n,o){return Vi.isNode&&hn.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}(e,t).toString();if((a=hn.isFileList(e))||n.indexOf("multipart/form-data")>-1){const n=Xi(this,"env"),o=n&&n.FormData;return Ci(a?{"files[]":e}:e,o&&new o,t)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(hn.isString(e))try{return(0,JSON.parse)(e),hn.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=Xi(this,"transitional")||Qi.transitional,n=t&&t.forcedJSONParsing,o=Xi(this,"responseType"),i="json"===o;if(hn.isResponse(e)||hn.isReadableStream(e))return e;if(e&&hn.isString(e)&&(n&&!o||i)){const n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Xi(this,"parseReviver"))}catch(e){if(n){if("SyntaxError"===e.name)throw An.from(e,An.ERR_BAD_RESPONSE,this,null,Xi(this,"response"));throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Vi.classes.FormData,Blob:Vi.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};hn.forEach(["delete","get","head","post","put","patch","query"],e=>{Qi.headers[e]={}});var ea=Qi;function ta(e,t){const n=this||ea,o=t||n,i=Tn.from(o.headers);let a=o.data;return hn.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function na(e){return!(!e||!e.__CANCEL__)}var oa=class extends An{constructor(e,t,n){super(null==e?"canceled":e,An.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function ia(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new An("Request failed with status code "+n.status,n.status>=400&&n.status<500?An.ERR_BAD_REQUEST:An.ERR_BAD_RESPONSE,n.config,n.request,n)):e(n)}const aa=/^https?:(?!\/\/)/i,ra=/[\t\n\r]/g;function sa(e,t){if("string"==typeof e){const n=function(e){return function(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}(e).replace(ra,"")}(e);if(aa.test(n))throw new An(`Invalid URL ${JSON.stringify(function(e){const t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${In}@`),n=t.indexOf("#"),o=(-1===n?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${In}`);return-1===n?o:`${o}#${i=t.slice(n+1),i?i.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,t,n="")=>`${t}${n}${In}`):i}`;var i}(n))}: missing "//" after protocol`,An.ERR_INVALID_URL,t)}}function ca(e,t,n,o){sa(t,o);let i=!function(e){return"string"==typeof e&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(i||!1===n)?(sa(e,o),function(e,t){if(!t)return e;let n=e.length;for(;n>0&&47===e.charCodeAt(n-1);)n--;return e.slice(0,n)+"/"+t.replace(/^\/+/,"")}(e,t)):t}var la={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function pa(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}var ua=1e3,da=60*ua,ma=60*da,fa=24*ma,ha=7*fa,ga=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return n*ha;case"days":case"day":case"d":return n*fa;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ma;case"minutes":case"minute":case"mins":case"min":case"m":return n*da;case"seconds":case"second":case"secs":case"sec":case"s":return n*ua;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=fa?va(e,t,fa,"day"):t>=ma?va(e,t,ma,"hour"):t>=da?va(e,t,da,"minute"):t>=ua?va(e,t,ua,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=fa?Math.round(e/fa)+"d":t>=ma?Math.round(e/ma)+"h":t>=da?Math.round(e/da)+"m":t>=ua?Math.round(e/ua)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function va(e,t,n,o){var i=t>=1.5*n;return Math.round(e/n)+" "+o+(i?"s":"")}var ba=function(e){function t(e){let o,i,a,r=null;function s(...e){if(!s.enabled)return;const n=s,i=Number(new Date);n.diff=i-(o||i),n.prev=o,n.curr=i,o=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(o,i)=>{if("%%"===o)return"%";a++;const r=t.formatters[i];return"function"==typeof r&&(o=r.call(n,e[a]),e.splice(a,1),a--),o}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==r?r:(i!==t.namespaces&&(i=t.namespaces,a=t.enabled(e)),a),set:e=>{r=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const o=t(this.namespace+(void 0===n?":":n)+e);return o.log=this.log,o}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const o=("string"==typeof e?e:"").split(/[\s,]+/),i=o.length;for(n=0;n<i;n++)o[n]&&("-"===(e=o[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,o;for(n=0,o=t.skips.length;n<o;n++)if(t.skips[n].test(e))return!1;for(n=0,o=t.names.length;n<o;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=ga,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t},xa=Fn(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(o++,"%c"===e&&(i=o))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ba(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}),ya=(e,t=process.argv)=>{const n=e.startsWith("-")?"":1===e.length?"-":"--",o=t.indexOf(n+e),i=t.indexOf("--");return-1!==o&&(-1===i||o<i)};const{env:wa}=process;let _a;function ja(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ka(e,t){if(0===_a)return 0;if(ya("color=16m")||ya("color=full")||ya("color=truecolor"))return 3;if(ya("color=256"))return 2;if(e&&!t&&void 0===_a)return 0;const n=_a||0;if("dumb"===wa.TERM)return n;if("win32"===process.platform){const e=$e.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in wa)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in wa)||"codeship"===wa.CI_NAME?1:n;if("TEAMCITY_VERSION"in wa)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(wa.TEAMCITY_VERSION)?1:0;if("truecolor"===wa.COLORTERM)return 3;if("TERM_PROGRAM"in wa){const e=parseInt((wa.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(wa.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(wa.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(wa.TERM)||"COLORTERM"in wa?1:n}ya("no-color")||ya("no-colors")||ya("color=false")||ya("color=never")?_a=0:(ya("color")||ya("colors")||ya("color=true")||ya("color=always"))&&(_a=1),"FORCE_COLOR"in wa&&(_a="true"===wa.FORCE_COLOR?1:"false"===wa.FORCE_COLOR?0:0===wa.FORCE_COLOR.length?1:Math.min(parseInt(wa.FORCE_COLOR,10),3));var Sa={supportsColor:function(e){return ja(ka(e,e&&e.isTTY))},stdout:ja(ka(!0,Ee.isatty(1))),stderr:ja(ka(!0,Ee.isatty(2)))},Ea=Fn(function(e,t){t.init=function(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let o=0;o<n.length;o++)e.inspectOpts[n[o]]=t.inspectOpts[n[o]]},t.log=function(...e){return process.stderr.write(he.format(...e)+"\n")},t.formatArgs=function(n){const{namespace:o,useColors:i}=this;if(i){const t=this.color,i="[3"+(t<8?t:"8;5;"+t),a=` ${i};1m${o} [0m`;n[0]=a+n[0].split("\n").join("\n"+a),n.push(i+"m+"+e.exports.humanize(this.diff)+"[0m")}else n[0]=(t.inspectOpts.hideDate?"":(new Date).toISOString()+" ")+o+" "+n[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):Ee.isatty(process.stderr.fd)},t.destroy=he.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{Sa&&(Sa.stderr||Sa).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let o=process.env[t];return o=!!/^(yes|on|true|enabled)$/i.test(o)||!/^(no|off|false|disabled)$/i.test(o)&&("null"===o?null:Number(o)),e[n]=o,e},{}),e.exports=ba(t);const{formatters:n}=e.exports;n.o=function(e){return this.inspectOpts.colors=this.useColors,he.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},n.O=function(e){return this.inspectOpts.colors=this.useColors,he.inspect(e,this.inspectOpts)}}),$a=Fn(function(e){e.exports="undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?xa:Ea}),Ta=/*#__PURE__*/Object.defineProperty({default:function(e){return function(t,n){return new Promise((o,i)=>{e.call(this,t,n,(e,t)=>{e?i(e):o(t)})})}}},"__esModule",{value:!0}),Ia=zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Oa=Ia($a),Aa=Ia(Ta),Ca=Oa.default("agent-base");function Ra(){const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some(e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:"))}function Na(e,t){return new Na.Agent(e,t)}!function(e){e.Agent=class extends Oe.EventEmitter{constructor(e,t){super();let n=t;"function"==typeof e?this.callback=e:e&&(n=e),this.timeout=null,n&&"number"==typeof n.timeout&&(this.timeout=n.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=Infinity,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return"number"==typeof this.explicitDefaultPort?this.explicitDefaultPort:Ra()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return"string"==typeof this.explicitProtocol?this.explicitProtocol:Ra()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,t,n){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,t){const n=Object.assign({},t);"boolean"!=typeof n.secureEndpoint&&(n.secureEndpoint=Ra()),null==n.host&&(n.host="localhost"),null==n.port&&(n.port=n.secureEndpoint?443:80),null==n.protocol&&(n.protocol=n.secureEndpoint?"https:":"http:"),n.host&&n.path&&delete n.path,delete n.agent,delete n.hostname,delete n._defaultAgent,delete n.defaultPort,delete n.createConnection,e._last=!0,e.shouldKeepAlive=!1;let o=!1,i=null;const a=n.timeout||this.timeout,r=t=>{e._hadError||(e.emit("error",t),e._hadError=!0)},s=()=>{i=null,o=!0;const e=new Error(`A "socket" was not created for HTTP request before ${a}ms`);e.code="ETIMEOUT",r(e)},c=e=>{o||(null!==i&&(clearTimeout(i),i=null),r(e))},l=t=>{if(o)return;if(null!=i&&(clearTimeout(i),i=null),a=t,Boolean(a)&&"function"==typeof a.addRequest)return Ca("Callback returned another Agent instance %o",t.constructor.name),void t.addRequest(e,n);var a;if(t)return t.once("free",()=>{this.freeSocket(t,n)}),void e.onSocket(t);const s=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);r(s)};if("function"==typeof this.callback){this.promisifiedCallback||(this.callback.length>=3?(Ca("Converting legacy callback function to promise"),this.promisifiedCallback=Aa.default(this.callback)):this.promisifiedCallback=this.callback),"number"==typeof a&&a>0&&(i=setTimeout(s,a)),"port"in n&&"number"!=typeof n.port&&(n.port=Number(n.port));try{Ca("Resolving socket for %o request: %o",n.protocol,`${e.method} ${e.path}`),Promise.resolve(this.promisifiedCallback(e,n)).then(l,c)}catch(e){Promise.reject(e).catch(c)}}else r(new Error("`callback` is not defined"))}freeSocket(e,t){Ca("Freeing socket %o %o",e.constructor.name,t),e.destroy()}destroy(){Ca("Destroying agent %o",this.constructor.name)}},e.prototype=e.Agent.prototype}(Na||(Na={}));var Pa=Na;const Ua=(zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})($a).default("https-proxy-agent:parse-proxy-response");var La=/*#__PURE__*/Object.defineProperty({default:function(e){return new Promise((t,n)=>{let o=0;const i=[];function a(){const n=e.read();n?function(e){i.push(e),o+=e.length;const n=Buffer.concat(i,o);if(-1===n.indexOf("\r\n\r\n"))return Ua("have not received end of HTTP headers yet..."),void a();const r=n.toString("ascii",0,n.indexOf("\r\n")),s=+r.split(" ")[1];Ua("got proxy server response: %o",r),t({statusCode:s,buffered:n})}(n):e.once("readable",a)}function r(e){Ua("onclose had error %o",e)}function s(){Ua("onend")}e.on("error",function t(o){e.removeListener("end",s),e.removeListener("error",t),e.removeListener("close",r),e.removeListener("readable",a),Ua("onerror %o",o),n(o)}),e.on("close",r),e.on("end",s),a()})}},"__esModule",{value:!0}),za=zn&&zn.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,a){function r(e){try{c(o.next(e))}catch(e){a(e)}}function s(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((o=o.apply(e,t||[])).next())})},Fa=zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Da=Fa(je),qa=Fa(ke),Ba=Fa(ye),Ma=Fa(Se),Wa=Fa($a),Ha=Fa(La),Ga=Wa.default("https-proxy-agent:agent");function Ja(e){e.resume()}const Va=(zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:class extends Pa.Agent{constructor(e){let t;if(t="string"==typeof e?Ba.default.parse(e):e,!t)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ga("creating new HttpsProxyAgent instance: %o",t),super(t);const n=Object.assign({},t);var o;this.secureProxy=t.secureProxy||"string"==typeof(o=n.protocol)&&/^https:?$/i.test(o),n.host=n.hostname||n.host,"string"==typeof n.port&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(e,t){return za(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let i;o?(Ga("Creating `tls.Socket`: %o",n),i=qa.default.connect(n)):(Ga("Creating `net.Socket`: %o",n),i=Da.default.connect(n));const a=Object.assign({},n.headers);let r=`CONNECT ${t.host}:${t.port} HTTP/1.1\r\n`;n.auth&&(a["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:s,port:c,secureEndpoint:l}=t;(function(e,t){return Boolean(!t&&80===e||t&&443===e)})(c,l)||(s+=`:${c}`),a.Host=s,a.Connection="close";for(const e of Object.keys(a))r+=`${e}: ${a[e]}\r\n`;const p=Ha.default(i);i.write(`${r}\r\n`);const{statusCode:u,buffered:d}=yield p;if(200===u){if(e.once("socket",Ja),t.secureEndpoint){Ga("Upgrading socket connection to TLS");const e=t.servername||t.host;return qa.default.connect(Object.assign(Object.assign({},function(e,...t){const n={};let o;for(o in e)t.includes(o)||(n[o]=e[o]);return n}(t,"host","hostname","path","port")),{socket:i,servername:e}))}return i}i.destroy();const m=new Da.default.Socket({writable:!1});return m.readable=!0,e.once("socket",e=>{Ga("replaying proxy buffer for failed request"),Ma.default(e.listenerCount("data")>0),e.push(d),e.push(null)}),m})}}},"__esModule",{value:!0}));function Ka(e){return new Va.default(e)}!function(e){e.HttpsProxyAgent=Va.default,e.prototype=Va.default.prototype}(Ka||(Ka={}));var Ya,Za,Xa,Qa,er=Ka,tr=function(){if(!Ya){try{Ya=$a("follow-redirects")}catch(e){}"function"!=typeof Ya&&(Ya=function(){})}Ya.apply(null,arguments)},nr=ye.URL,or=ge.Writable;Za="undefined"!=typeof process,Xa="undefined"!=typeof window&&"undefined"!=typeof document,Qa=Sr(Error.captureStackTrace),Za||!Xa&&Qa||console.warn("The follow-redirects package should be excluded from browser builds.");var ir=!1;try{Se(new nr(""))}catch(e){ir="ERR_INVALID_URL"===e.code}var ar=["Authorization","Proxy-Authorization","Cookie"],rr=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],sr=["abort","aborted","connect","error","socket","timeout"],cr=Object.create(null);sr.forEach(function(e){cr[e]=function(t,n,o){this._redirectable.emit(e,t,n,o)}});var lr=_r("ERR_INVALID_URL","Invalid URL",TypeError),pr=_r("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),ur=_r("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",pr),dr=_r("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),mr=_r("ERR_STREAM_WRITE_AFTER_END","write after end"),fr=or.prototype.destroy||vr;function hr(e,t){or.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var n=this;this._onNativeResponse=function(e){try{n._processResponse(e)}catch(e){n.emit("error",e instanceof pr?e:new pr({cause:e}))}},this._headerFilter=new RegExp("^(?:"+ar.concat(e.sensitiveHeaders).map(Er).join("|")+")$","i"),this._performRequest()}function gr(e){var t={maxRedirects:21,maxBodyLength:10485760},n={};return Object.keys(e).forEach(function(o){var i=o+":",a=n[i]=e[o],r=t[o]=Object.create(a);Object.defineProperties(r,{request:{value:function(e,o,a){return nr&&e instanceof nr?e=yr(e):kr(e)?e=yr(br(e)):(a=o,o=xr(e),e={protocol:i}),Sr(o)&&(a=o,o=null),(o=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,o)).nativeProtocols=n,kr(o.host)||kr(o.hostname)||(o.hostname="::1"),Se.equal(o.protocol,i,"protocol mismatch"),tr("options",o),new hr(o,a)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,n){var o=r.request(e,t,n);return o.end(),o},configurable:!0,enumerable:!0,writable:!0}})}),t}function vr(){}function br(e){var t;if(ir)t=new nr(e);else if(!kr((t=xr(ye.parse(e))).protocol))throw new lr({input:e});return t}function xr(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new lr({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new lr({input:e.href||e});return e}function yr(e,t){var n=t||{};for(var o of rr)n[o]=e[o];return n.hostname.startsWith("[")&&(n.hostname=n.hostname.slice(1,-1)),""!==n.port&&(n.port=Number(n.port)),n.path=n.search?n.pathname+n.search:n.pathname,n}function wr(e,t){var n;for(var o in t)e.test(o)&&(n=t[o],delete t[o]);return null==n?void 0:String(n).trim()}function _r(e,t,n){function o(n){Sr(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,n||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return o.prototype=new(n||Error),Object.defineProperties(o.prototype,{constructor:{value:o,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),o}function jr(e,t){for(var n of sr)e.removeListener(n,cr[n]);e.on("error",vr),e.destroy(t)}function kr(e){return"string"==typeof e||e instanceof String}function Sr(e){return"function"==typeof e}function Er(e){return e.replace(/[\]\\/()*+?.$]/g,"\\$&")}(hr.prototype=Object.create(or.prototype)).abort=function(){jr(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},hr.prototype.destroy=function(e){return jr(this._currentRequest,e),fr.call(this,e),this},hr.prototype.write=function(e,t,n){if(this._ending)throw new mr;if(!(kr(e)||"object"==typeof(o=e)&&"length"in o))throw new TypeError("data should be a string, Buffer or Uint8Array");var o;Sr(t)&&(n=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,n)):(this.emit("error",new dr),this.abort()):n&&n()},hr.prototype.end=function(e,t,n){if(Sr(e)?(n=e,e=t=null):Sr(t)&&(n=t,t=null),e){var o=this,i=this._currentRequest;this.write(e,t,function(){o._ended=!0,i.end(null,null,n)}),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,n)},hr.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},hr.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},hr.prototype.setTimeout=function(e,t){var n=this;function o(t){t.setTimeout(e),t.removeListener("timeout",t.destroy),t.addListener("timeout",t.destroy)}function i(t){n._timeout&&clearTimeout(n._timeout),n._timeout=setTimeout(function(){n.emit("timeout"),a()},e),o(t)}function a(){n._timeout&&(clearTimeout(n._timeout),n._timeout=null),n.removeListener("abort",a),n.removeListener("error",a),n.removeListener("response",a),n.removeListener("close",a),t&&n.removeListener("timeout",t),n.socket||n._currentRequest.removeListener("socket",i)}return t&&this.on("timeout",t),this.socket?i(this.socket):this._currentRequest.once("socket",i),this.on("socket",o),this.on("abort",a),this.on("error",a),this.on("response",a),this.on("close",a),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){hr.prototype[e]=function(t,n){return this._currentRequest[e](t,n)}}),["aborted","connection","socket"].forEach(function(e){Object.defineProperty(hr.prototype,e,{get:function(){return this._currentRequest[e]}})}),hr.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.sensitiveHeaders instanceof Array||(e.sensitiveHeaders=[]),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}},hr.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var n=e.slice(0,-1);this._options.agent=this._options.agents[n]}var o=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var i of(o._redirectable=this,sr))o.on(i,cr[i]);if(this._currentUrl=/^\//.test(this._options.path)?ye.format(this._options):this._options.path,this._isRedirect){var a=0,r=this,s=this._requestBodyBuffers;!function e(t){if(o===r._currentRequest)if(t)r.emit("error",t);else if(a<s.length){var n=s[a++];o.finished||o.write(n.data,n.encoding,e)}else r._ended&&o.end()}()}},hr.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var n,o=e.headers.location;if(!o||!1===this._options.followRedirects||t<300||t>=400)return e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),void(this._requestBodyBuffers=[]);if(jr(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new ur;var i=this._options.beforeRedirect;i&&(n=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var a=this._options.method;((301===t||302===t)&&"POST"===this._options.method||303===t&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],wr(/^content-/i,this._options.headers));var r=wr(/^host$/i,this._options.headers),s=br(this._currentUrl),c=r||s.host,l=/^\w+:/.test(o)?this._currentUrl:ye.format(Object.assign(s,{host:c})),p=function(e,t){return ir?new nr(e,t):br(ye.resolve(t,e))}(o,l);tr("redirecting to",p.href),this._isRedirect=!0,yr(p,this._options),(p.protocol!==s.protocol&&"https:"!==p.protocol||p.host!==c&&!function(e,t){Se(kr(e)&&kr(t));var n=e.length-t.length-1;return n>0&&"."===e[n]&&e.endsWith(t)}(p.host,c))&&wr(this._headerFilter,this._options.headers),Sr(i)&&(i(this._options,{headers:e.headers,statusCode:t},{url:l,method:a,headers:n}),this._sanitizeOptions(this._options)),this._performRequest()};var $r=gr({http:be,https:xe});$r.wrap=gr;const Tr="1.19.0";function Ir(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}const Or=/^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/,Ar=["content-type","content-length"];function Cr(e,t,n){"content-only"===n?Object.entries(t||{}).forEach(([t,n])=>{Ar.includes(t.toLowerCase())&&e.set(t,n)}):e.set(t)}const Rr=Symbol("internals");var Nr=class extends ge.Transform{constructor(e){super({readableHighWaterMark:(e=hn.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!hn.isUndefined(t[e]))).chunkSize});const t=this[Rr]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",e=>{"progress"===e&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){const t=this[Rr];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){const o=this[Rr],i=o.maxRate,a=this.readableHighWaterMark,r=o.timeWindow,s=i/(1e3/r),c=!1!==o.minChunkSize?Math.max(o.minChunkSize,.01*s):0,l=(e,t)=>{const n=Buffer.byteLength(e);o.bytesSeen+=n,o.bytes+=n,o.isCaptured&&this.emit("progress",o.bytesSeen),this.push(e)?process.nextTick(t):o.onReadCallback=()=>{o.onReadCallback=null,process.nextTick(t)}},p=(e,t)=>{const n=Buffer.byteLength(e);let p,u=null,d=a,m=0;if(i){const e=Date.now();(!o.ts||(m=e-o.ts)>=r)&&(o.ts=e,p=s-o.bytes,o.bytes=p<0?-p:0,m=0),p=s-o.bytes}if(i){if(p<=0)return setTimeout(()=>{t(null,e)},r-m);p<d&&(d=p)}d&&n>d&&n-d>c&&(u=e.subarray(d),e=e.subarray(0,d)),l(e,u?()=>{process.nextTick(t,null,u)}:t)};p(e,function e(t,o){if(t)return n(t);o?p(o,e):n(null)})}};const{asyncIterator:Pr}=Symbol;var Ur=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Pr]?yield*e[Pr]():yield e};const Lr=Vi.ALPHABET.ALPHA_DIGIT+"-_",zr="function"==typeof TextEncoder?new TextEncoder:new he.TextEncoder,Fr="\r\n",Dr=zr.encode(Fr);class qr{constructor(e,t){const{escapeName:n}=this.constructor,o=hn.isString(t);let i=`Content-Disposition: form-data; name="${n(e)}"${!o&&t.name?`; filename="${n(t.name)}"`:""}${Fr}`;o?t=zr.encode(String(t).replace(/\r?\n|\r\n?/g,Fr)):i+=`Content-Type: ${String(t.type||"application/octet-stream").replace(/[\r\n]/g,"")}${Fr}`,this.headers=zr.encode(i+Fr),this.contentLength=o?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+2,this.name=e,this.value=t}async*encode(){yield this.headers;const{value:e}=this;hn.isTypedArray(e)?yield e:yield*Ur(e),yield Dr}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}var Br=class extends ge.Transform{__transform(e,t,n){this.push(e),n()}_transform(e,t,n){if(0!==e.length&&(this._transform=this.__transform,120!==e[0])){const e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,n)}},Mr=(e,t)=>hn.isAsyncFn(e)?function(...n){const o=n.pop();e.apply(this,n).then(e=>{try{t?o(null,...t(e)):o(null,e)}catch(e){o(e)}},o)}:e;const Wr=new Set(["localhost","0.0.0.0"]),Hr=e=>{const t=e.split(".");return 4===t.length&&"127"===t[0]&&t.every(e=>/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255)},Gr=e=>{if(/^0[xX][0-9a-fA-F]+$/.test(e)){const t=parseInt(e.slice(2),16);return Number.isFinite(t)?t:null}if(e.length>1&&/^0[0-7]+$/.test(e)){const t=parseInt(e,8);return Number.isFinite(t)?t:null}if(e.length>1&&/^0[0-9]+$/.test(e))return null;if(/^[0-9]+$/.test(e)){const t=parseInt(e,10);return Number.isFinite(t)?t:null}return null},Jr=e=>/^0{1,4}$/.test(e),Vr=e=>!!e&&(!!Wr.has(e)||!!Hr(e)||!!(e=>{if("::"===e)return!0;const t=e.indexOf("::");if(-1!==t){if(t!==e.lastIndexOf("::"))return!1;const n=e.slice(0,t),o=e.slice(t+2),i=n?n.split(":"):[],a=o?o.split(":"):[];return i.length+a.length<8&&i.every(Jr)&&a.every(Jr)}const n=e.split(":");return 8===n.length&&n.every(Jr)})(e)||(e=>{if("::1"===e)return!0;const t=e.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);if(t)return Hr(t[1]);const n=e.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);if(n){const e=parseInt(n[1],16);return e>=32512&&e<=32767}const o=e.split(":");if(8===o.length){for(let e=0;e<7;e++)if(!/^0+$/.test(o[e]))return!1;return/^0*1$/.test(o[7])}return!1})(e)),Kr={http:80,https:443,ws:80,wss:443,ftp:21},Yr=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i,Zr=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i,Xr=e=>{if(!e)return e;"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.slice(1,-1));const t=e.replace(/\.+$/,""),n=(e=>{if("string"!=typeof e||!e||-1!==e.indexOf(":"))return e;let t=e;if("["===t.charAt(0)&&"]"===t.charAt(t.length-1)&&(t=t.slice(1,-1)),t=t.replace(/\.+$/,""),!/^[0-9.xXa-fA-F]+$/.test(t))return e;const n=t.split(".");if(n.some(e=>""===e))return e;if(4===n.length){const t=n.map(Gr);return t.some(e=>null===e||e<0||e>255)?e:t.join(".")}if(n.length>4)return e;if(1===n.length)return e;const o=n.slice(0,-1),i=4-o.length,a=Gr(n[n.length-1]);if(null===a)return e;if(a<0||a>(1<<8*i)-1)return e;const r=new Array(i).fill(0);for(let e=i-1,t=a;e>=0;e--,t>>=8)r[e]=255&t;const s=o.map(Gr);return s.some(e=>null===e||e<0||e>255)?e:[...s,...r].join(".")})(t);return n!==t?n:(e=>{if("string"!=typeof e||-1===e.indexOf(":"))return e;const t=e.match(Yr);if(t)return t[1];const n=e.match(Zr);if(n){const e=parseInt(n[1],16),t=parseInt(n[2],16);return`${e>>8}.${255&e}.${t>>8}.${255&t}`}return e})(t)},Qr=(e,t,n=3)=>{let o=0;const i=function(e,t){e=e||10;const n=new Array(e),o=new Array(e);let i,a=0,r=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),l=o[r];i||(i=c),n[a]=s,o[a]=c;let p=r,u=0;for(;p!==a;)u+=n[p++],p%=e;if(a=(a+1)%e,a===r&&(r=(r+1)%e),c-i<t)return;const d=l&&c-l;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(n,a){let r,s,c=0,l=1e3/a;const p=(n,a=Date.now())=>{c=a,r=null,s&&(clearTimeout(s),s=null),(n=>{if(!n||"number"!=typeof n.loaded)return;const a=n.loaded,r=n.lengthComputable?n.total:void 0,s=Math.max(0,null!=r?Math.min(a,r):a),c=Math.max(0,s-o),l=i(c);o=Math.max(o,s),e({loaded:s,total:r,progress:r?s/r:void 0,bytes:c,rate:l||void 0,estimated:l&&r?(r-s)/l:void 0,event:n,lengthComputable:null!=r,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-c;n>=l?p(e,t):(r=e,s||(s=setTimeout(()=>{s=null,p(r)},l-n)))},()=>r&&p(r)]}(0,n)},es=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},ts=(e,t=hn.asap)=>(...n)=>t(()=>e(...n)),ns=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,os=(e,t,n)=>t+2<n&&ns(e.charCodeAt(t+1))&&ns(e.charCodeAt(t+2)),is=e=>e<=57?e-48:(223&e)-55,as=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||43===e||47===e||45===e||95===e,rs=e=>{const t=e.length;let n=0;return t>0&&61===e.charCodeAt(t-1)&&(n++,t>1&&61===e.charCodeAt(t-2)&&n++),Math.floor(3*(t-n)/4)},ss=e=>{const t=e.length;let n=0,o=0,i=!1;for(let r=0;r<t;r++){let s=e.charCodeAt(r);37===s&&os(e,r,t)&&(s=16*is(e.charCodeAt(r+1))+is(e.charCodeAt(r+2)),r+=2),9!==(a=s)&&10!==a&&12!==a&&13!==a&&32!==a&&(61!==s?!as(s)||o>0?i=!0:n++:o++)}var a;return i||o>2||o>0&&(n+o)%4!=0||n%4==1?rs(e):(e=>{const t=e%4;return 3*Math.floor(e/4)+(2===t?1:3===t?2:0)})(n)},cs=(e,t)=>{if(!e||"string"!=typeof e)return 0;if(!e.startsWith("data:"))return 0;const n=e.indexOf(",");if(n<0)return 0;const o=e.slice(5,n),i=e.slice(n+1);if(/;base64/i.test(o))return t(i);let a=0;for(let e=0,t=i.length;e<t;e++){const n=i.charCodeAt(e);if(37===n&&os(i,e,t))a+=1,e+=2;else if(n<128)a+=1;else if(n<2048)a+=2;else if(n>=55296&&n<=56319&&e+1<t){const t=i.charCodeAt(e+1);t>=56320&&t<=57343?(a+=4,e++):a+=3}else a+=3}return a},ls={flush:Re.constants.Z_SYNC_FLUSH,finishFlush:Re.constants.Z_SYNC_FLUSH},ps={flush:Re.constants.BROTLI_OPERATION_FLUSH,finishFlush:Re.constants.BROTLI_OPERATION_FLUSH},us={flush:Re.constants.ZSTD_e_flush,finishFlush:Re.constants.ZSTD_e_flush},ds=hn.isFunction(Re.createBrotliDecompress),ms=hn.isFunction(Re.createZstdDecompress),fs="gzip, compress, deflate"+(ds?", br":""),hs=fs+(ms?", zstd":""),gs="undefined"!=typeof process&&process.nextTick?process.nextTick.bind(process):hn.asap,{http:vs,https:bs}=$r,xs=/https:?/,ys=Symbol("axios.http.socketListener"),ws=Symbol("axios.http.currentReq"),_s=Symbol("axios.http.installedTunnel"),js=new Map,ks=new WeakMap,Ss={22:21,24:5},Es=Vi.protocols.map(e=>e+":"),$s=e=>{if(!hn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Ts=(e,[t,n])=>(e.on("end",n).on("error",n),t),Is=new class{constructor(){this.sessions=Object.create(null)}getSession(e,t){t=Object.assign({sessionTimeout:1e3},t);let n=this.sessions[e];if(n){let e=n.length;for(let o=0;o<e;o++){const[e,i]=n[o];if(!e.destroyed&&!e.closed&&he.isDeepStrictEqual(i,t))return e}}const o=Ce.connect(e,t);let i,a;const r=()=>{if(i)return;i=!0,a&&(clearTimeout(a),a=null);let t=n,r=t.length,s=r;for(;s--;)if(t[s][0]===o)return 1===r?delete this.sessions[e]:t.splice(s,1),void(o.closed||o.close())},s=o.request,{sessionTimeout:c}=t;if(null!=c){let e=0;o.request=function(){const t=s.apply(this,arguments);return e++,a&&(clearTimeout(a),a=null),t.once("close",()=>{--e||(a=setTimeout(()=>{a=null,r()},c))}),t}}o.once("close",r);let l=[o,t];return n?n.push(l):n=this.sessions[e]=[l],o}};function Os(e,t,n){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.auth&&e.beforeRedirects.auth(e),e.beforeRedirects.sensitiveHeaders&&e.beforeRedirects.sensitiveHeaders(e,n),e.beforeRedirects.config&&e.beforeRedirects.config(e,t,n)}function As(e,t,n,o,i,a){let r=t;const s=function(e,t,n){return xs.test(e.protocol)?n||xe.globalAgent:t||be.globalAgent}(e,a,i);if(!r&&!1!==r&&!function(e,t=process.versions&&process.versions.node){if(!function(e=process.versions&&process.versions.node){if(!e)return!1;const[t,n]=e.split(".").map(e=>Number(e));return!(!Number.isInteger(t)||!Number.isInteger(n))&&(t>24||null!=Ss[t]&&n>=Ss[t])}(t))return!1;const n=e&&e.options;return Boolean(n&&hn.hasOwnProp(n,"proxyEnv")&&null!=n.proxyEnv)}(s)){const e=function(e){var t=("string"==typeof e?function(e){try{return new URL(e)}catch{return null}}(e):e)||{},n=t.protocol,o=t.host,i=t.port;if("string"!=typeof o||!o||"string"!=typeof n)return"";if(n=n.split(":",1)[0],!function(e,t){var n=pa("no_proxy").toLowerCase();return!n||"*"!==n&&n.split(/[,\s]/).every(function(n){if(!n)return!0;var o=n.match(/^(.+):(\d+)$/),i=o?o[1]:n,a=o?parseInt(o[2]):0;return!(!a||a===t)||(/^[.*]/.test(i)?("*"===i.charAt(0)&&(i=i.slice(1)),!e.endsWith(i)):e!==i)})}(o=o.replace(/:\d*$/,""),i=parseInt(i)||la[n]||0))return"";var a=pa(n+"_proxy")||pa("all_proxy");return a&&-1===a.indexOf("://")&&(a=n+"://"+a),a}(n);e&&(function(e){let t;try{t=new URL(e)}catch(e){return!1}const n=(process.env.no_proxy||process.env.NO_PROXY||"").toLowerCase();if(!n)return!1;if("*"===n)return!0;const o=Number.parseInt(t.port,10)||Kr[t.protocol.split(":",1)[0]]||0,i=Xr(t.hostname.toLowerCase());return n.split(/[\s,]+/).some(e=>{if(!e)return!1;if("*"===e)return!0;let[t,n]=(e=>{let t=e,n=0;if("["===t.charAt(0)){const e=t.indexOf("]");if(-1!==e){const o=t.slice(1,e),i=t.slice(e+1);return":"===i.charAt(0)&&/^\d+$/.test(i.slice(1))&&(n=Number.parseInt(i.slice(1),10)),[o,n]}}const o=t.indexOf(":"),i=t.lastIndexOf(":");return-1!==o&&o===i&&/^\d+$/.test(t.slice(i+1))&&(n=Number.parseInt(t.slice(i+1),10),t=t.slice(0,i)),[t,n]})(e);return t=Xr(t),!!t&&(!n||n===o)&&("*"===t.charAt(0)&&(t=t.slice(1)),"."===t.charAt(0)?i.endsWith(t):i===t||Vr(i)&&Vr(t))})}(n)||(r=new URL(e)))}if(o&&e.headers)for(const t of Object.keys(e.headers))"proxy-authorization"===t.toLowerCase()&&delete e.headers[t];if(o&&e.agent&&e.agent[_s]&&(e.agent=void 0),r){const t=r instanceof URL,o=e=>t||hn.hasOwnProp(r,e)?r[e]:void 0,a=o("username"),s=o("password");let c=hn.hasOwnProp(r,"auth")?r.auth:void 0;if(a&&(c=(a||"")+":"+(s||"")),c){const e="object"==typeof c,t=e&&hn.hasOwnProp(c,"username")?c.username:void 0,n=e&&hn.hasOwnProp(c,"password")?c.password:void 0;if(Boolean(t||n))c=(t||"")+":"+(n||"");else if(e)throw new An("Invalid proxy authorization",An.ERR_BAD_OPTION,{proxy:r})}if(xs.test(e.protocol)){if(!(i instanceof er)){const t=o("hostname")||o("host"),n=o("port"),a=o("protocol"),r=a?a.includes(":")?a:`${a}:`:"http:",s=t&&t.includes(":")&&!t.startsWith("[")?`[${t}]`:t,l=new URL(`${r}//${s}${n?":"+n:""}`),p={protocol:l.protocol,hostname:l.hostname.replace(/^\[|\]$/g,""),port:l.port,auth:c&&"string"==typeof c?c:void 0};"https:"===l.protocol&&(p.ALPNProtocols=["http/1.1"]);const u=function(e,t){const n=e.protocol+"//"+e.hostname+":"+(e.port||"")+"#"+(e.auth||""),o=t?ks.get(t)||ks.set(t,new Map).get(t):js;let i=o.get(n);if(i)return i;const a=t&&t.options?{...t.options,...e}:e;if(i=new er(a),t&&t.options){const e={...t.options},n=i.callback;i.callback=function(t,o){return n.call(this,t,{...e,...o})}}return i[_s]=!0,o.set(n,i),i}(p,i);e.agent=u,e.agents&&(e.agents.https=u)}}else{if(c){const t=Buffer.from(c,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+t}let t=!1;for(const n of Object.keys(e.headers))if("host"===n.toLowerCase()){t=!0;break}t||(e.headers.host=e.hostname+(e.port?":"+e.port:""));const i=o("hostname")||o("host");e.hostname=i,e.host=i,e.port=o("port"),e.path=n;const a=o("protocol");a&&(e.protocol=a.includes(":")?a:`${a}:`)}}e.beforeRedirects.proxy=function(e){As(e,t,e.href,!0,i,a)}}const Cs="undefined"!=typeof process&&"process"===hn.kindOf(process),Rs=(e,t)=>(({address:e,family:t})=>{if(!hn.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(hn.isObject(e)?e:{address:e,family:t}),Ns={request(e,t){const n=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:o,headers:i}=e,a=Is.getSession(n,o),{HTTP2_HEADER_SCHEME:r,HTTP2_HEADER_METHOD:s,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:l}=Ce.constants,p={[r]:e.protocol.replace(":",""),[s]:e.method,[c]:e.path};hn.forEach(i,(e,t)=>{":"!==t.charAt(0)&&(p[t]=e)});const u=a.request(p);return u.once("response",e=>{const n=u,o=(e=Object.assign({},e))[l];delete e[l],n.headers=e,n.statusCode=+o,t(n)}),u}};var Ps,Us,Ls=Cs&&function(e){return t=async function(t,n,o){const i=t=>hn.getSafeProp(e,t),a=i("transitional")||Fi;let r=i("data"),s=i("lookup"),c=i("family"),l=i("httpVersion");void 0===l&&(l=1);let p=i("http2Options");const u=i("httpAgent"),d=i("httpsAgent"),m=i("proxy"),f=i("responseType"),h=i("responseEncoding"),g=i("socketPath"),v=i("method").toUpperCase(),b=i("maxRedirects"),x=i("maxBodyLength"),y=i("maxContentLength"),_=i("decompress");let j,k,S,E=!1;if(l=+l,Number.isNaN(l))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(1!==l&&2!==l)throw TypeError(`Unsupported protocol version '${l}'`);const $=2===l;if(s){const e=Mr(s,e=>hn.isArray(e)?e:[e]);s=(t,n,o)=>{e(t,n,(e,t,i)=>{if(e)return o(e);const a=hn.isArray(t)?t.map(e=>Rs(e)):[Rs(t,i)];n.all?o(e,a):o(e,a[0].address,a[0].family)})}}const T=new Ae;function I(t){try{T.emit("abort",!t||t.type?new oa(null,e,k):t)}catch(e){}}function O(){S&&(clearTimeout(S),S=null)}T.once("abort",n);const A=()=>{O(),e.cancelToken&&e.cancelToken.unsubscribe(I),e.signal&&e.signal.removeEventListener("abort",I),T.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(I),e.signal&&(e.signal.aborted?I():e.signal.addEventListener("abort",I))),o((e,t)=>{if(j=!0,O(),t)return E=!0,void A();const{data:n}=e;if(n instanceof ge.Readable||n instanceof ge.Duplex){const e=ge.finished(n,()=>{e(),A()})}else A()});const C=ca(i("baseURL"),i("url"),i("allowAbsoluteUrls"),e),R=new URL(C,g?"http://localhost":Vi.hasBrowserEnv?Vi.origin:void 0),N=R.protocol||Es[0];if("data:"===N){if(y>-1){const t=function(e){return cs(e,rs)}(String(i("url")||C||""));if(t>y)return n(new An("maxContentLength size of "+y+" exceeded",An.ERR_BAD_RESPONSE,e))}let o;if("GET"!==v)return ia(t,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{o=function(e,t,n){const o=n&&n.Blob||Vi.classes.Blob,i=Ir(e);if(void 0===t&&o&&(t=!0),"data"===i){e=i.length?e.slice(i.length+1):e;const n=Or.exec(e);if(!n)throw new An("Invalid URL",An.ERR_INVALID_URL);const a=n[1],r=n[2],s=n[3]?"base64":"utf8",c=n[4];let l="";a?l=r?a+r:a:r&&(l="text/plain"+r);const p="base64"===s?Buffer.from(c,"base64"):Buffer.from(decodeURIComponent(c),s);if(t){if(!o)throw new An("Blob is not supported",An.ERR_NOT_SUPPORT);return new o([p],{type:l})}return p}throw new An("Unsupported protocol "+i,An.ERR_NOT_SUPPORT)}(i("url"),"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw An.from(t,An.ERR_BAD_REQUEST,e)}return"text"===f?(o=o.toString(h),h&&"utf8"!==h||(o=hn.stripBOM(o))):"stream"===f&&(o=ge.Readable.from(o)),ia(t,n,{data:o,status:200,statusText:"OK",headers:new Tn,config:e})}if(-1===Es.indexOf(N))return n(new An("Unsupported protocol "+N,An.ERR_BAD_REQUEST,e));const P=Tn.from(e.headers).normalize();P.set("User-Agent","axios/"+Tr,!1);const{onUploadProgress:U,onDownloadProgress:L}=e,z=e.maxRate;let F,D;if(hn.isSpecCompliantForm(r)){const e=P.getContentType(/boundary=([-_\w\d]{10,70})/i);r=((e,t,n)=>{const{tag:o="form-data-boundary",size:i=25,boundary:a=o+"-"+Vi.generateString(i,Lr)}=n||{};if(!hn.isFormData(e))throw new TypeError("FormData instance required");if(a.length<1||a.length>70)throw new Error("boundary must be 1-70 characters long");const r=zr.encode("--"+a+Fr),s=zr.encode("--"+a+"--"+Fr);let c=s.byteLength;const l=Array.from(e.entries()).map(([e,t])=>{const n=new qr(e,t);return c+=n.size,n});c+=r.byteLength*l.length,c=hn.toFiniteNumber(c);const p={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(c)&&(p["Content-Length"]=c),t&&t(p),ve.from(async function*(){for(const e of l)yield r,yield*e.encode();yield s}())})(r,e=>{P.set(e)},{tag:`axios-${Tr}-boundary`,boundary:e&&e[1]||void 0})}else if(hn.isFormData(r)&&hn.isFunction(r.getHeaders)&&r.getHeaders!==Object.prototype.getHeaders){if(Cr(P,r.getHeaders(),i("formDataHeaderPolicy")),!P.hasContentLength())try{const e=await he.promisify(r.getLength).call(r);Number.isFinite(e)&&e>=0&&P.setContentLength(e)}catch(e){}}else if(hn.isBlob(r)||hn.isFile(r))r.size&&P.setContentType(r.type||"application/octet-stream"),P.setContentLength(r.size||0),r=ge.Readable.from(Ur(r));else if(r&&!hn.isStream(r)){if(Buffer.isBuffer(r));else if(hn.isArrayBuffer(r))r=Buffer.from(new Uint8Array(r));else{if(!hn.isString(r))return n(new An("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",An.ERR_BAD_REQUEST,e));r=Buffer.from(r,"utf-8")}if(P.setContentLength(r.length,!1),x>-1&&r.length>x)return n(new An("Request body larger than maxBodyLength limit",An.ERR_BAD_REQUEST,e))}const q=hn.toFiniteNumber(P.getContentLength());let B;hn.isArray(z)?(F=z[0],D=z[1]):F=D=z,r&&(U||F)&&(hn.isStream(r)||(r=ge.Readable.from(r,{objectMode:!1})),r=ge.pipeline([r,new Nr({maxRate:hn.toFiniteNumber(F)})],hn.noop),U&&r.on("progress",Ts(r,es(q,Qr(ts(U,gs),!1,3)))));const M=i("auth");let W;M&&(B=(hn.getSafeProp(M,"username")||"")+":"+(hn.getSafeProp(M,"password")||"")),B||!R.username&&!R.password||(B=$s(R.username)+":"+$s(R.password)),B&&P.delete("authorization");try{W=Li(R.pathname+R.search,i("params"),i("paramsSerializer")).replace(/^\?/,"")}catch(t){return n(An.from(t,An.ERR_BAD_REQUEST,e,null,null,{url:i("url"),exists:!0}))}P.set("Accept-Encoding",hn.hasOwnProp(a,"advertiseZstdAcceptEncoding")&&!0===a.advertiseZstdAcceptEncoding?hs:fs,!1);const H=Object.assign(Object.create(null),{path:W,method:v,headers:yn(P),agents:{http:u,https:d},auth:B,protocol:N,family:c,beforeRedirect:Os,beforeRedirects:Object.create(null),http2Options:p});if(!hn.isUndefined(s)&&(H.lookup=s),g){if("string"!=typeof g)return n(new An("socketPath must be a string",An.ERR_BAD_OPTION_VALUE,e));const t=i("allowedSocketPaths");if(null!=t){const o=Array.isArray(t)?t:[t],i=w(g);if(!o.some(e=>"string"==typeof e&&w(e)===i))return n(new An(`socketPath "${g}" is not permitted by allowedSocketPaths`,An.ERR_BAD_OPTION_VALUE,e))}H.socketPath=g}else H.hostname=R.hostname.startsWith("[")?R.hostname.slice(1,-1):R.hostname,H.port=R.port,As(H,m,N+"//"+R.hostname+(R.port?":"+R.port:"")+H.path,!1,d,u);let G,J=!1,V=!1;const K=xs.test(H.protocol);if(null==H.agent&&(H.agent=K?d:u),$)G=Ns;else{const t=i("transport");if(t)G=t;else if(0===b)G=K?xe:be,J=!0;else{V=!0,H.sensitiveHeaders=[],b&&(H.maxRedirects=b);const t=i("beforeRedirect");if(t&&(H.beforeRedirects.config=t),B){const e=R.origin,t=B;H.beforeRedirects.auth=function(n){try{new URL(n.href).origin===e&&(n.auth=t)}catch(e){}}}const o=i("sensitiveHeaders");if(null!=o){if(!hn.isArray(o))return n(new An("sensitiveHeaders must be an array of strings",An.ERR_BAD_OPTION_VALUE,e));const t=new Set;for(const i of o){if(!hn.isString(i))return n(new An("sensitiveHeaders must be an array of strings",An.ERR_BAD_OPTION_VALUE,e));t.add(i.toLowerCase())}t.size&&(H.sensitiveHeaders=Array.from(t),H.beforeRedirects.sensitiveHeaders=function(e,n){(function(e,t){if(!t)return!1;try{return new URL(t.url).origin===new URL(e.href).origin}catch(e){return!1}})(e,n)||function(e,t){e&&Object.keys(e).forEach(n=>{t.has(n.toLowerCase())&&delete e[n]})}(e.headers,t)})}G=K?bs:vs}}H.maxBodyLength=x>-1?x:Infinity,H.insecureHTTPParser=Boolean(i("insecureHTTPParser")),k=G.request(H,function(o){if(O(),k.destroyed)return;const i=[o],a=hn.toFiniteNumber(o.headers["content-length"]);if(L||D){const e=new Nr({maxRate:hn.toFiniteNumber(D)});L&&e.on("progress",Ts(e,es(a,Qr(ts(L,gs),!0,3)))),i.push(e)}let r=o;const s=o.req||k;if(!1!==_&&o.headers["content-encoding"])switch("HEAD"!==v&&204!==o.statusCode||delete o.headers["content-encoding"],(o.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":i.push(Re.createUnzip(ls)),delete o.headers["content-encoding"];break;case"deflate":i.push(new Br),i.push(Re.createUnzip(ls)),delete o.headers["content-encoding"];break;case"br":ds&&(i.push(Re.createBrotliDecompress(ps)),delete o.headers["content-encoding"]);break;case"zstd":ms&&(i.push(Re.createZstdDecompress(us)),delete o.headers["content-encoding"])}r=i.length>1?ge.pipeline(i,hn.noop):i[0];const c={status:o.statusCode,statusText:o.statusMessage,headers:new Tn(o.headers),config:e,request:s};if("stream"===f){if(y>-1){const t=y,n=r;r=ge.Readable.from(async function*(){let o=0;for await(const i of n){if(o+=i.length,o>t)throw new An("maxContentLength size of "+t+" exceeded",An.ERR_BAD_RESPONSE,e,s);yield i}}(),{objectMode:!1})}c.data=r,ia(t,n,c)}else{const o=[];let i=0;r.on("data",function(t){o.push(t),i+=t.length,y>-1&&i>y&&(E=!0,r.destroy(),I(new An("maxContentLength size of "+y+" exceeded",An.ERR_BAD_RESPONSE,e,s)))}),r.on("aborted",function(){if(E)return;const t=new An("stream has been aborted",An.ERR_BAD_RESPONSE,e,s,c);r.destroy(t),n(t)}),r.on("error",function(t){E||n(An.from(t,null,e,s,c))}),r.on("end",function(){try{let e=1===o.length?o[0]:Buffer.concat(o);"arraybuffer"!==f&&(e=e.toString(h),h&&"utf8"!==h||(e=hn.stripBOM(e))),c.data=e}catch(t){return n(An.from(t,null,e,c.request,c))}ia(t,n,c)})}T.once("abort",e=>{r.destroyed||(r.emit("error",e),r.destroy())})}),T.once("abort",e=>{k.close?k.close():k.destroy(e)}),k.on("error",function(t){n(An.from(t,null,e,k))});const Y=new Set;if(k.on("socket",function(e){"function"==typeof e.setKeepAlive&&e.setKeepAlive(!0,6e4),e[ys]||(e.on("error",function(t){const n=e[ws];n&&!n.destroyed&&n.destroy(t)}),e[ys]=!0),e[ws]=k,Y.add(e)}),k.once("close",function(){O();for(const e of Y)e[ws]===k&&(e[ws]=null);Y.clear()}),i("timeout")){const t=parseInt(i("timeout"),10);if(Number.isNaN(t))return void I(new An("error trying to parse `config.timeout` to int",An.ERR_BAD_OPTION_VALUE,e,k));const n=function(){j||I(function(){const t=i("timeout");let n=t?"timeout of "+t+"ms exceeded":"timeout exceeded";const o=i("timeoutErrorMessage");return o&&(n=o),new An(n,a.clarifyTimeoutError?An.ETIMEDOUT:An.ECONNABORTED,e,k)}())};J&&t>0&&(S=setTimeout(n,t)),k.setTimeout(t,n)}else k.setTimeout(0);if(hn.isStream(r)){let t=!1,n=!1;r.on("end",()=>{t=!0}),r.once("error",e=>{n=!0,k.destroy(e)}),r.on("close",()=>{t||n||I(new oa("Request stream has been aborted",e,k))});let o=r;if(x>-1&&!V){const t=x;let n=0;o=ge.pipeline([r,new ge.Transform({transform(o,i,a){if(n+=o.length,n>t)return a(new An("Request body larger than maxBodyLength limit",An.ERR_BAD_REQUEST,e,k));a(null,o)}})],hn.noop),o.on("error",e=>{k.destroyed||k.destroy(e)})}o.pipe(k)}else r&&k.write(r),k.end()},new Promise((e,n)=>{let o,i;const a=(e,t)=>{i||(i=!0,o&&o(e,t))},r=e=>{a(e,!0),n(e)};t(t=>{a(t),e(t)},r,e=>o=e).catch(r)});var t},zs=Vi.hasStandardBrowserEnv?(Ps=new URL(Vi.origin),Us=Vi.navigator&&/(msie|trident)/i.test(Vi.navigator.userAgent),e=>(e=new URL(e,Vi.origin),Ps.protocol===e.protocol&&Ps.host===e.host&&(Us||Ps.port===e.port))):()=>!0,Fs=Vi.hasStandardBrowserEnv?{write(e,t,n,o,i,a,r){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];hn.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),hn.isString(o)&&s.push(`path=${o}`),hn.isString(i)&&s.push(`domain=${i}`),!0===a&&s.push("secure"),hn.isString(r)&&s.push(`SameSite=${r}`),document.cookie=s.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const o=t[n].replace(/^\s+/,""),i=o.indexOf("=");if(-1!==i&&o.slice(0,i)===e)try{return decodeURIComponent(o.slice(i+1))}catch(e){return o.slice(i+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};const Ds=e=>e instanceof Tn?{...e}:e,qs=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Bs(e,t){e=e||{},t=t||{};const n=Object.create(null);function o(e,t,n,o){return hn.isPlainObject(e)&&hn.isPlainObject(t)?hn.merge.call({caseless:o},e,t):hn.isPlainObject(t)?hn.merge({},t):hn.isArray(t)?t.slice():t}function i(e,t,n,i){return hn.isUndefined(t)?hn.isUndefined(e)?void 0:o(void 0,e,0,i):o(e,t,0,i)}function a(e,t){if(!hn.isUndefined(t))return o(void 0,t)}function r(e,t){return hn.isUndefined(t)?hn.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function s(n,i,a){return hn.hasOwnProp(t,a)?o(n,i):hn.hasOwnProp(e,a)?o(void 0,n):void 0}Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});const c={url:a,method:a,data:a,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,allowedSocketPaths:r,responseEncoding:r,validateStatus:s,headers:(e,t,n)=>i(Ds(e),Ds(t),0,!0)};return hn.forEach(qs({...e,...t}),function(o){if("__proto__"===o||"constructor"===o||"prototype"===o)return;const a=hn.hasOwnProp(c,o)?c[o]:i,r=a(hn.hasOwnProp(e,o)?e[o]:void 0,hn.hasOwnProp(t,o)?t[o]:void 0,o);hn.isUndefined(r)&&a!==s||(n[o]=r)}),hn.hasOwnProp(t,"validateStatus")&&hn.isUndefined(t.validateStatus)&&!1===function(n){const o=hn.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!hn.isUndefined(o)){if(!hn.isPlainObject(o))return;if(hn.hasOwnProp(o,n))return o[n]}const i=hn.hasOwnProp(e,"transitional")?e.transitional:void 0;if(hn.isPlainObject(i)&&hn.hasOwnProp(i,n))return i[n]}("validateStatusUndefinedResolves")&&(hn.hasOwnProp(e,"validateStatus")?n.validateStatus=o(void 0,e.validateStatus):delete n.validateStatus),n}function Ms(e){const t=Bs({},e),n=e=>hn.hasOwnProp(t,e)?t[e]:void 0,o=n("data");let i=n("withXSRFToken");const a=n("xsrfHeaderName"),r=n("xsrfCookieName");let s=n("headers");const c=n("auth"),l=n("baseURL"),p=n("allowAbsoluteUrls"),u=n("url");if(t.headers=s=Tn.from(s),t.url=Li(ca(l,u,p,t),n("params"),n("paramsSerializer")),c){const t=hn.getSafeProp(c,"username")||"",n=hn.getSafeProp(c,"password")||"";try{s.set("Authorization","Basic "+btoa(t+":"+(n?(e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))(n):"")))}catch(t){throw An.from(t,An.ERR_BAD_OPTION_VALUE,e)}}if(hn.isFormData(o)&&(Vi.hasStandardBrowserEnv||Vi.hasStandardBrowserWebWorkerEnv||hn.isReactNative(o)?s.setContentType(void 0):hn.isFunction(o.getHeaders)&&Cr(s,o.getHeaders(),n("formDataHeaderPolicy"))),Vi.hasStandardBrowserEnv&&(hn.isFunction(i)&&(i=i(t)),!0===i||null==i&&zs(t.url))){const e=a&&r&&Fs.read(r);e&&s.set(a,e)}return t}var Ws="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const o=Ms(e);let i=o.data;const a=Tn.from(o.headers).normalize();let r,s,c,l,p,{responseType:u,onUploadProgress:d,onDownloadProgress:m}=o;function f(){l&&l(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(r),o.signal&&o.signal.removeEventListener("abort",r)}let h=new XMLHttpRequest;function g(){if(!h)return;const o=Tn.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());ia(function(e){t(e),f()},function(e){n(e),f()},{data:u&&"text"!==u&&"json"!==u?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:o,config:e,request:h}),h=null}h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout,"onloadend"in h?h.onloadend=g:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&h.responseURL.startsWith("file:"))&&setTimeout(g)},h.onabort=function(){h&&(n(new An("Request aborted",An.ECONNABORTED,e,h)),f(),h=null)},h.onerror=function(t){const o=new An(t&&t.message?t.message:"Network Error",An.ERR_NETWORK,e,h);o.event=t||null,n(o),f(),h=null},h.ontimeout=function(){let t=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";o.timeoutErrorMessage&&(t=o.timeoutErrorMessage),n(new An(t,(o.transitional||Fi).clarifyTimeoutError?An.ETIMEDOUT:An.ECONNABORTED,e,h)),f(),h=null},void 0===i&&a.setContentType(null),"setRequestHeader"in h&&hn.forEach(yn(a),function(e,t){h.setRequestHeader(t,e)}),hn.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),u&&"json"!==u&&(h.responseType=o.responseType),m&&([c,p]=Qr(m,!0),h.addEventListener("progress",c)),d&&h.upload&&([s,l]=Qr(d),h.upload.addEventListener("progress",s),h.upload.addEventListener("loadend",l)),(o.cancelToken||o.signal)&&(r=t=>{h&&(n(!t||t.type?new oa(null,e,h):t),h.abort(),f(),h=null)},o.cancelToken&&o.cancelToken.subscribe(r),o.signal&&(o.signal.aborted?r():o.signal.addEventListener("abort",r)));const v=Ir(o.url);if(v&&!Vi.protocols.includes(v))return n(new An("Unsupported protocol "+v+":",An.ERR_BAD_REQUEST,e)),void f();h.send(i||null)})},Hs=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let o=!1;const i=function(e){if(!o){o=!0,r();const t=e instanceof Error?e:this.reason;n.abort(t instanceof An?t:new oa(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,i(new An(`timeout of ${t}ms exceeded`,An.ETIMEDOUT))},t);const r=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>{o||(e.aborted?i.call(e):e.addEventListener("abort",i,{once:!0}))});const{signal:s}=n;return s.unsubscribe=()=>hn.asap(r),s};const Gs=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let o,i=0;for(;i<n;)o=i+t,yield e.slice(i,o),i=o},Js=(e,t,n,o)=>{const i=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Gs(n,t)}(e,t);let a,r=0,s=e=>{a||(a=!0,o&&o(e))};return new ReadableStream({async pull(e){try{const{done:t,value:o}=await i.next();if(t)return s(),void e.close();if(n){let e=r+=o.byteLength;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},{isFunction:Vs}=hn,Ks=e=>{if(!hn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Ys=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Zs=e=>{const t=null!=hn.global?hn.global:globalThis,{ReadableStream:n,TextEncoder:o}=t;e=hn.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:i,Request:a,Response:r}=e,s=i?Vs(i):"function"==typeof fetch,c=Vs(a),l=Vs(r);if(!s)return!1;const p=s&&Vs(n),u=s&&("function"==typeof o?(d=new o,e=>d.encode(e)):async e=>new Uint8Array(await new a(e).arrayBuffer()));var d;const m=c&&p&&Ys(()=>{let e=!1;const t=new a(Vi.origin,{body:new n,method:"POST",get duplex(){return e=!0,"half"}}),o=t.headers.has("Content-Type");return null!=t.body&&t.body.cancel(),e&&!o}),f=l&&p&&Ys(()=>hn.isReadableStream(new r("").body)),h={stream:f&&(e=>e.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!h[e]&&(h[e]=(t,n)=>{let o=t&&t[e];if(o)return o.call(t);throw new An(`Response type '${e}' is not supported`,An.ERR_NOT_SUPPORT,n)})});const g=async e=>{if(null==e)return 0;if(hn.isBlob(e))return e.size;if(hn.isSpecCompliantForm(e)){const t=new a(Vi.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return hn.isArrayBufferView(e)||hn.isArrayBuffer(e)?e.byteLength:(hn.isURLSearchParams(e)&&(e+=""),hn.isString(e)?(await u(e)).byteLength:void 0)};return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:u,timeout:d,onDownloadProgress:v,onUploadProgress:b,responseType:x,headers:y,withCredentials:w="same-origin",fetchOptions:_,maxContentLength:j,maxBodyLength:k}=Ms(e);const S=hn.isNumber(j)&&j>-1,E=hn.isNumber(k)&&k>-1;let $=i||fetch;x=x?(x+"").toLowerCase():"text";let T=Hs([l,u&&u.toAbortSignal()],d),I=null;const O=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let A,C=null;const R=()=>new An("Request body larger than maxBodyLength limit",An.ERR_BAD_REQUEST,e,I);try{let i;const l=hn.hasOwnProp(e,"auth")?e.auth:void 0;if(l&&(i={username:hn.getSafeProp(l,"username")||"",password:hn.getSafeProp(l,"password")||""}),(e=>{const t=e.indexOf("://");let n=e;return-1!==t&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")})(t)){const e=new URL(t,Vi.origin);i||!e.username&&!e.password||(i={username:Ks(e.username),password:Ks(e.password)}),(e.username||e.password)&&(e.username="",e.password="",t=e.href)}if(i&&(y.delete("authorization"),y.set("Authorization","Basic "+btoa((e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))((i.username||"")+":"+(i.password||""))))),S&&"string"==typeof t&&t.startsWith("data:")){const n=function(e){const t="string"==typeof e?e.indexOf("#"):-1;return cs(-1===t?e:e.slice(0,t),ss)}(t);if(n>j)throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I)}if(E&&"get"!==n&&"head"!==n){const e=await g(s);if("number"==typeof e&&isFinite(e)&&(A=e,e>k))throw R()}const u=E&&(hn.isReadableStream(s)||hn.isStream(s)),d=(e,t,n)=>Js(e,65536,e=>{if(E&&e>k)throw C=R();t&&t(e)},n);if(m&&"get"!==n&&"head"!==n&&(b||u)){if(A=null==A?await(async(e,t)=>{const n=hn.toFiniteNumber(e.getContentLength());return null==n?g(t):n})(y,s):A,0!==A||u){let e,n=new a(t,{method:"POST",body:s,duplex:"half"});if(hn.isFormData(s)&&(e=n.headers.get("content-type"))&&y.setContentType(e),n.body){const[e,t]=b&&es(A,Qr(ts(b)))||[];s=d(n.body,e,t)}}}else if(u&&!c&&p&&"get"!==n&&"head"!==n)s=d(s);else if(u&&c&&!m&&"get"!==n&&"head"!==n)throw new An("Stream request bodies are not supported by the current fetch implementation",An.ERR_NOT_SUPPORT,e,I);hn.isString(w)||(w=w?"include":"omit");const N=c&&"credentials"in a.prototype;if(hn.isFormData(s)){const e=y.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&y.delete("content-type")}y.set("User-Agent","axios/"+Tr,!1);const P={..._,signal:T,method:n.toUpperCase(),headers:yn(y.normalize()),body:s,duplex:"half",credentials:N?w:void 0};I=c&&new a(t,P);let U=await(c?$(I,_):$(t,P));const L=Tn.from(U.headers);if(S){const t=hn.toFiniteNumber(L.getContentLength());if(null!=t&&t>j)throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I)}const z=f&&("stream"===x||"response"===x);if(f&&U.body&&(v||S||z&&O)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=U[e]});const n=hn.toFiniteNumber(L.getContentLength()),[o,i]=v&&es(n,Qr(ts(v),!0))||[];let a=0;U=new r(Js(U.body,65536,t=>{if(S&&(a=t,a>j))throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I);o&&o(t)},()=>{i&&i(),O&&O()}),t)}x=x||"text";let F=await h[hn.findKey(h,x)||"text"](U,e);if(S&&!f&&!z){let t;if(null!=F&&("number"==typeof F.byteLength?t=F.byteLength:"number"==typeof F.size?t=F.size:"string"==typeof F&&(t="function"==typeof o?(new o).encode(F).byteLength:F.length)),"number"==typeof t&&t>j)throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I)}return!z&&O&&O(),await new Promise((t,n)=>{ia(t,n,{data:F,headers:Tn.from(U.headers),status:U.status,statusText:U.statusText,config:e,request:I})})}catch(t){if(O&&O(),T&&T.aborted&&T.reason instanceof An){const n=T.reason;throw n.config=e,I&&(n.request=I),t!==n&&Object.defineProperty(n,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),n}if(C)throw I&&!C.request&&(C.request=I),C;if(t instanceof An)throw I&&!t.request&&(t.request=I),t;if(t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message)){const n=new An("Network Error",An.ERR_NETWORK,e,I,t&&t.response);throw Object.defineProperty(n,"cause",{__proto__:null,value:t.cause||t,writable:!0,enumerable:!1,configurable:!0}),n}throw An.from(t,t&&t.code,e,I,t&&t.response)}}},Xs=new Map,Qs=e=>{let t=e&&e.env||{};const{fetch:n,Request:o,Response:i}=t,a=[o,i,n];let r,s,c=a.length,l=Xs;for(;c--;)r=a[c],s=l.get(r),void 0===s&&l.set(r,s=c?new Map:Zs(t)),l=s;return s};Qs();const ec={http:Ls,xhr:Ws,fetch:{get:Qs}};hn.forEach(ec,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch(e){}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const tc=e=>`- ${e}`,nc=e=>hn.isFunction(e)||null===e||!1===e;var oc=function(e,t){e=hn.isArray(e)?e:[e];const{length:n}=e;let o,i;const a={};for(let r=0;r<n;r++){let n;if(o=e[r],i=o,!nc(o)&&(i=ec[(n=String(o)).toLowerCase()],void 0===i))throw new An(`Unknown adapter '${n}'`);if(i&&(hn.isFunction(i)||(i=i.get(t))))break;a[n||"#"+r]=i}if(!i){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=n?e.length>1?"since :\n"+e.map(tc).join("\n"):" "+tc(e[0]):"as no adapter specified";throw new An("There is no suitable adapter to dispatch the request "+t,An.ERR_NOT_SUPPORT)}return i};function ic(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new oa(null,e)}function ac(e){return ic(e),e.headers=Tn.from(e.headers),e.data=ta.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),oc(e.adapter||ea.adapter,e)(e).then(function(t){ic(e),e.response=t;try{t.data=ta.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=Tn.from(t.headers),t},function(t){if(!na(t)&&(ic(e),t&&t.response)){e.response=t.response;try{t.response.data=ta.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=Tn.from(t.response.headers)}return Promise.reject(t)})}const rc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{rc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const sc={};rc.transitional=function(e,t,n){function o(e,t){return"[Axios v"+Tr+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,a)=>{if(!1===e)throw new An(o(i," has been removed"+(t?" in "+t:"")),An.ERR_DEPRECATED);return t&&!sc[i]&&(sc[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,a)}},rc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var cc={assertOptions:function(e,t,n){if("object"!=typeof e||null===e)throw new An("options must be an object",An.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let i=o.length;for(;i-- >0;){const a=o[i],r=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(r){const t=e[a],n=void 0===t||r(t,a,e);if(!0!==n)throw new An("option "+a+" must be "+n,An.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new An("Unknown option "+a,An.ERR_BAD_OPTION)}},validators:rc};const lc=cc.validators;class pc{constructor(e){this.defaults=e||{},this.interceptors={request:new zi,response:new zi}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=(()=>{if(!t.stack)return"";const e=t.stack.indexOf("\n");return-1===e?"":t.stack.slice(e+1)})();try{if(e.stack){if(n){const t=n.indexOf("\n"),o=-1===t?-1:n.indexOf("\n",t+1),i=-1===o?"":n.slice(o+1);String(e.stack).endsWith(i)||(e.stack+="\n"+n)}}else e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Bs(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:i}=t;void 0!==n&&cc.assertOptions(n,{silentJSONParsing:lc.transitional(lc.boolean),forcedJSONParsing:lc.transitional(lc.boolean),clarifyTimeoutError:lc.transitional(lc.boolean),legacyInterceptorReqResOrdering:lc.transitional(lc.boolean),advertiseZstdAcceptEncoding:lc.transitional(lc.boolean),validateStatusUndefinedResolves:lc.transitional(lc.boolean)},!1),null!=o&&(hn.isFunction(o)?t.paramsSerializer={serialize:o}:cc.assertOptions(o,{encode:lc.function,serialize:lc.function},!0)),void 0!==t.allowAbsoluteUrls||(t.allowAbsoluteUrls=void 0===this.defaults.allowAbsoluteUrls||this.defaults.allowAbsoluteUrls),cc.assertOptions(t,{baseUrl:lc.spelling("baseURL"),withXsrfToken:lc.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&hn.merge(i.common,i[t.method]);i&&hn.forEach(["delete","get","head","post","put","patch","query","common"],e=>{delete i[e]}),t.headers=Tn.concat(a,i);const r=[];let s=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;s=s&&e.synchronous;const n=t.transitional||Fi;n&&n.legacyInterceptorReqResOrdering?r.unshift(e.fulfilled,e.rejected):r.push(e.fulfilled,e.rejected)});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let p,u=0;if(!s){const e=[ac.bind(this),void 0];for(e.unshift(...r),e.push(...c),p=e.length,l=Promise.resolve(t);u<p;)l=l.then(e[u++],e[u++]);return l}p=r.length;let d=t;for(;u<p;){const e=r[u++],t=r[u++];try{d=e?e(d):d}catch(e){if(!t){l=Promise.reject(e);break}try{const n=t.call(this,e);hn.isThenable(n)&&(l=Promise.resolve(n).then(()=>ac.call(this,d)))}catch(e){l=Promise.reject(e)}break}}if(!l)try{l=ac.call(this,d)}catch(e){l=Promise.reject(e)}for(u=0,p=c.length;u<p;)l=l.then(c[u++],c[u++]);return l}getUri(e){return Li(ca((e=Bs(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}}hn.forEach(["delete","get","head","options"],function(e){pc.prototype[e]=function(t,n){return this.request(Bs(n||{},{method:e,url:t,data:n&&hn.hasOwnProp(n,"data")?n.data:void 0}))}}),hn.forEach(["post","put","patch","query"],function(e){function t(t){return function(n,o,i){return this.request(Bs(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}pc.prototype[e]=t(),"query"!==e&&(pc.prototype[e+"Form"]=t(!0))});var uc=pc;class dc{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const o=new Promise(e=>{n.subscribe(e),t=e}).then(e);return o.cancel=function(){n.unsubscribe(t)},o},e(function(e,o,i){n.reason||(n.reason=new oa(e,o,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new dc(function(t){e=t}),cancel:e}}}var mc=dc;const fc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(fc).forEach(([e,t])=>{fc[t]=e});var hc=fc;const gc=function e(t){const n=new uc(t),o=xt(uc.prototype.request,n);return hn.extend(o,uc.prototype,n,{allOwnKeys:!0}),hn.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return e(Bs(t,n))},o}(ea);gc.Axios=uc,gc.CanceledError=oa,gc.CancelToken=mc,gc.isCancel=na,gc.VERSION=Tr,gc.toFormData=Ci,gc.AxiosError=An,gc.Cancel=gc.CanceledError,gc.all=function(e){return Promise.all(e)},gc.spread=function(e){return function(t){return e.apply(null,t)}},gc.isAxiosError=function(e){return hn.isObject(e)&&!0===e.isAxiosError},gc.mergeConfig=Bs,gc.AxiosHeaders=Tn,gc.formToJSON=e=>Zi(hn.isHTMLForm(e)?new FormData(e):e),gc.getAdapter=oc,gc.HttpStatusCode=hc,gc.default=gc;var vc=gc;const{CanceledError:bc}=vc,xc="screenshot.needle.webp",yc=/screenshot(\-\d+?)?\.needle\.(webp|png|jpg|jpeg)/;async function wc(e,t){const n=t.baseUrl+ft.jobs.post_update,o={...ht(t),job_id:e.identifier,status:e.status},i={status_message:e.status_message,error:e.error,progress:e.progress},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)}).catch(e=>(console.error(e),null));return!!a&&a.ok}async function _c(e,t){const n=t.baseUrl+ft.jobs.get_status,o={...ht(t),job_id:e,org:t.org},i=await fetch(n,{...gt,method:"GET",headers:o}).catch(e=>(t.verbose?console.error("Failed to get job status",e):console.error("Failed to get job status",e.message),null));return i?i.ok?await i.json():(console.error("Failed to get status",i.status,await i.text()),{failed:!0,httpStatus:i.status}):{failed:!0}}function jc(e={}){var t,n;const o=null!=(t=e.maxAuthFailures)?t:2,i=null!=(n=e.maxTransientFailures)?n:10;let a=0,r=0;return{record(e){if(e&&!0!==e.failed)return a=0,r=0,null;const t=null==e?void 0:e.httpStatus;return 401===t||403===t?(a++,a>=o?{abort:!0,reason:`Not authorized to read the job status (HTTP ${t}). Your access token is invalid or expired — run \`needle-cloud login\` or pass a fresh --token.`}:null):(r++,r>=i?{abort:!0,reason:`Could not read the job status after ${r} attempts${t?` (last: HTTP ${t})`:""}. The job may still be running — check it in the Needle Cloud dashboard.`}:null)}}}const kc=6,Sc=1e3,Ec=15e3,$c=9e4,Tc=new Set(["CERT_HAS_EXPIRED","UNABLE_TO_VERIFY_LEAF_SIGNATURE","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","ERR_TLS_CERT_ALTNAME_INVALID"]),Ic=new Set([408,429]);function Oc(e){var t;if(function(e){const t=null==e?void 0:e.name,n=null==e?void 0:e.code;return"CanceledError"===t||"AbortError"===t||"ERR_CANCELED"===n||"ABORT_ERR"===n}(e))return!1;const n=null==e||null==(t=e.response)?void 0:t.status;if("number"==typeof n&&n>0)return!!Ic.has(n)||!(n>=400&&n<500);const o=function(e){var t,n;const o=null!=(t=null==e?void 0:e.code)?t:null==e||null==(n=e.cause)?void 0:n.code;return"string"==typeof o&&o.length?o:null}(e);return!o||!Tc.has(o)}function Ac(e,t={}){const{baseMs:n=Sc,maxMs:o=Ec,random:i=Math.random}=t,a=Math.max(1,Math.floor(e)),r=Math.min(o,n*2**(a-1))/2;return Math.max(1,Math.round(r+i()*r))}async function Cc(e,t={}){const{maxAttempts:n=kc,budgetMs:o=$c,baseMs:i=Sc,maxMs:a=Ec,isRetryable:r=Oc,sleep:s=Rc,now:c=Date.now,random:l=Math.random,onRetry:p}=t,u=c();let d,m=0;for(;m<n;){m++;try{return{ok:!0,value:await e(m),attempts:m}}catch(e){if(d=e,!r(e))return{ok:!1,error:e,attempts:m,reason:"permanent"};if(m>=n)return{ok:!1,error:e,attempts:m,reason:"attempts-exhausted"};const t=Ac(m,{baseMs:i,maxMs:a,random:l});if(c()-u+t>=o)return{ok:!1,error:e,attempts:m,reason:"budget-exhausted"};null==p||p({attempt:m,waitMs:t,error:e}),await s(t)}}return{ok:!1,error:d,attempts:m,reason:"attempts-exhausted"}}function Rc(e){return new Promise(t=>setTimeout(t,e))}const Nc=5242880,Pc=1e4,Uc=16777216,Lc=67108864;var zc=Fn(function(e,t){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],o=e[1],i=e[2],a=e[3];o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[0]-680876936|0)<<7|n>>>25)+o|0)&o|~n&i)+t[1]-389564586|0)<<12|a>>>20)+n|0)&n|~a&o)+t[2]+606105819|0)<<17|i>>>15)+a|0)&a|~i&n)+t[3]-1044525330|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[4]-176418897|0)<<7|n>>>25)+o|0)&o|~n&i)+t[5]+1200080426|0)<<12|a>>>20)+n|0)&n|~a&o)+t[6]-1473231341|0)<<17|i>>>15)+a|0)&a|~i&n)+t[7]-45705983|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[8]+1770035416|0)<<7|n>>>25)+o|0)&o|~n&i)+t[9]-1958414417|0)<<12|a>>>20)+n|0)&n|~a&o)+t[10]-42063|0)<<17|i>>>15)+a|0)&a|~i&n)+t[11]-1990404162|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[12]+1804603682|0)<<7|n>>>25)+o|0)&o|~n&i)+t[13]-40341101|0)<<12|a>>>20)+n|0)&n|~a&o)+t[14]-1502002290|0)<<17|i>>>15)+a|0)&a|~i&n)+t[15]+1236535329|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[1]-165796510|0)<<5|n>>>27)+o|0)&i|o&~i)+t[6]-1069501632|0)<<9|a>>>23)+n|0)&o|n&~o)+t[11]+643717713|0)<<14|i>>>18)+a|0)&n|a&~n)+t[0]-373897302|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[5]-701558691|0)<<5|n>>>27)+o|0)&i|o&~i)+t[10]+38016083|0)<<9|a>>>23)+n|0)&o|n&~o)+t[15]-660478335|0)<<14|i>>>18)+a|0)&n|a&~n)+t[4]-405537848|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[9]+568446438|0)<<5|n>>>27)+o|0)&i|o&~i)+t[14]-1019803690|0)<<9|a>>>23)+n|0)&o|n&~o)+t[3]-187363961|0)<<14|i>>>18)+a|0)&n|a&~n)+t[8]+1163531501|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[13]-1444681467|0)<<5|n>>>27)+o|0)&i|o&~i)+t[2]-51403784|0)<<9|a>>>23)+n|0)&o|n&~o)+t[7]+1735328473|0)<<14|i>>>18)+a|0)&n|a&~n)+t[12]-1926607734|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[5]-378558|0)<<4|n>>>28)+o|0)^o^i)+t[8]-2022574463|0)<<11|a>>>21)+n|0)^n^o)+t[11]+1839030562|0)<<16|i>>>16)+a|0)^a^n)+t[14]-35309556|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[1]-1530992060|0)<<4|n>>>28)+o|0)^o^i)+t[4]+1272893353|0)<<11|a>>>21)+n|0)^n^o)+t[7]-155497632|0)<<16|i>>>16)+a|0)^a^n)+t[10]-1094730640|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[13]+681279174|0)<<4|n>>>28)+o|0)^o^i)+t[0]-358537222|0)<<11|a>>>21)+n|0)^n^o)+t[3]-722521979|0)<<16|i>>>16)+a|0)^a^n)+t[6]+76029189|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[9]-640364487|0)<<4|n>>>28)+o|0)^o^i)+t[12]-421815835|0)<<11|a>>>21)+n|0)^n^o)+t[15]+530742520|0)<<16|i>>>16)+a|0)^a^n)+t[2]-995338651|0)<<23|o>>>9)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[0]-198630844|0)<<6|n>>>26)+o|0)|~i))+t[7]+1126891415|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[14]-1416354905|0)<<15|i>>>17)+a|0)|~n))+t[5]-57434055|0)<<21|o>>>11)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[12]+1700485571|0)<<6|n>>>26)+o|0)|~i))+t[3]-1894986606|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[10]-1051523|0)<<15|i>>>17)+a|0)|~n))+t[1]-2054922799|0)<<21|o>>>11)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[8]+1873313359|0)<<6|n>>>26)+o|0)|~i))+t[15]-30611744|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[6]-1560198380|0)<<15|i>>>17)+a|0)|~n))+t[13]+1309151649|0)<<21|o>>>11)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[4]-145523070|0)<<6|n>>>26)+o|0)|~i))+t[11]-1120210379|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[2]+718787259|0)<<15|i>>>17)+a|0)|~n))+t[9]-343485551|0)<<21|o>>>11)+i|0,e[0]=n+e[0]|0,e[1]=o+e[1]|0,e[2]=i+e[2]|0,e[3]=a+e[3]|0}function o(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function a(e){var t,i,a,r,s,c,l=e.length,p=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=l;t+=64)n(p,o(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)a[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55)for(n(p,a),t=0;t<16;t+=1)a[t]=0;return r=(r=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),c=parseInt(r[1],16)||0,a[14]=s,a[15]=c,n(p,a),p}function r(e){var n,o="";for(n=0;n<4;n+=1)o+=t[e>>8*n+4&15]+t[e>>8*n&15];return o}function s(e){var t;for(t=0;t<e.length;t+=1)e[t]=r(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function l(e){var t,n=[],o=e.length;for(t=0;t<o-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function p(){this.reset()}return s(a("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(t,n){var o,i,a,r,s=this.byteLength,c=e(t,s),l=s;return void 0!==n&&(l=e(n,s)),c>l?new ArrayBuffer(0):(o=l-c,i=new ArrayBuffer(o),a=new Uint8Array(i),r=new Uint8Array(this,c,o),a.set(r),i)}}(),p.prototype.append=function(e){return this.appendBinary(c(e)),this},p.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,o(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},p.prototype.end=function(e){var t,n,o=this._buff,i=o.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)a[t>>2]|=o.charCodeAt(t)<<(t%4<<3);return this._finish(a,i),n=s(this._hash),e&&(n=l(n)),this.reset(),n},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(e,t){var o,i,a,r=t;if(e[r>>2]|=128<<(r%4<<3),r>55)for(n(this._hash,e),r=0;r<16;r+=1)e[r]=0;o=(o=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),a=parseInt(o[1],16)||0,e[14]=i,e[15]=a,n(this._hash,e)},p.hash=function(e,t){return p.hashBinary(c(e),t)},p.hashBinary=function(e,t){var n=s(a(e));return t?l(n):n},(p.ArrayBuffer=function(){this.reset()}).prototype.append=function(e){var t,o,a,r,s=(o=this._buff.buffer,a=e,(r=new Uint8Array(o.byteLength+a.byteLength)).set(new Uint8Array(o)),r.set(new Uint8Array(a),o.byteLength),r),c=s.length;for(this._length+=e.byteLength,t=64;t<=c;t+=64)n(this._hash,i(s.subarray(t-64,t)));return this._buff=t-64<c?new Uint8Array(s.buffer.slice(t-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(e){var t,n,o=this._buff,i=o.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)a[t>>2]|=o[t]<<(t%4<<3);return this._finish(a,i),n=s(this._hash),e&&(n=l(n)),this.reset(),n},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var e=p.prototype.getState.call(this);return e.buff=String.fromCharCode.apply(null,new Uint8Array(e.buff)),e},p.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,o=e.length,i=new ArrayBuffer(o),a=new Uint8Array(i);for(n=0;n<o;n+=1)a[n]=e.charCodeAt(n);return a}(e.buff),p.prototype.setState.call(this,e)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(e,t){var o=s(function(e){var t,o,a,r,s,c,l=e.length,p=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=l;t+=64)n(p,i(e.subarray(t-64,t)));for(o=(e=t-64<l?e.subarray(t-64):new Uint8Array(0)).length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)a[t>>2]|=e[t]<<(t%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55)for(n(p,a),t=0;t<16;t+=1)a[t]=0;return r=(r=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),c=parseInt(r[1],16)||0,a[14]=s,a[15]=c,n(p,a),p}(new Uint8Array(e)));return t?l(o):o},p}()}),Fc=zc;function Dc(e,t=0){return Wc(e,t,2).getUint16(0,!0)}function qc(e,t=0){return Wc(e,t,4).getUint32(0,!0)}function Bc(e,t=0,n=e.byteLength){const o=e.slice(t,t+n);return Hc.decode(new Uint8Array(o))}function Mc(e,t,n=0){if(e.length<t.length+n)return!1;for(const[o,i]of t.entries())if(null!==i&&i!==e[o+n])return!1;return!0}function Wc(e,t,n){const o=e.slice(t,t+n);return new DataView(new Uint8Array(o).buffer)}const Hc=new TextDecoder("utf8"),Gc=[["db","application/vnd.sqlite3",[83,81,76,105,116,101,32,102,111,114,109,97,116,32,51,0]],["woff","font/woff",[119,79,70,70]],["woff2","font/woff2",[119,79,70,50]],["bmp","image/bmp",[66,77]],["gif","image/gif",[71,73,70,56,55,97]],["gif","image/gif",[71,73,70,56,57,97]],["heic","image/heic",[102,116,121,112,104,101,105],{offset:4}],["heic","image/heic",[102,116,121,112,109],{offset:4}],["ico","image/x-icon",[0,0,1,0]],["jpg","image/jpeg",[255,216,255]],["pdf","application/pdf",[37,80,68,70,45]],["png","image/png",[137,80,78,71,13,10,26,10]],["7z","application/x-7z-compressed",[55,122,188,175,39,28]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,0]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,1,0]],["rtf","application/rtf",[123,92,114,116,102,49]],["bz2","application/x-bzip2",[66,90,104]],["gz","application/gzip",[31,139]],["tar","application/x-tar",[117,115,116,97,114,0,48,48],{offset:257}],["tar","application/x-tar",[117,115,116,97,114,32,32,0],{offset:257}],["tif","image/tiff",[73,73,42,0]],["tiff","image/tiff",[77,77,0,42]],["zip","application/zip",[80,75,3,4],{exact:!1}],["zip","application/zip",[80,75,5,6]],["mp3","audio/mp3",[255,251]],["mp3","audio/mp3",[255,243]],["mp3","audio/mp3",[255,242]],["mp3","audio/mp3",[73,68,51]],["mp4","video/mp4",[102,116,121,112,105,115,111,109],{offset:4}],["avi","video/x-msvideo",[82,73,70,70,null,null,null,null,65,86,73,32]],["wav","audio/wav",[82,73,70,70,null,null,null,null,87,65,86,69]],["ogx","application/ogg",[79,103,103,83],{exact:!1},[["oga","audio/ogg",[127,70,76,65,67],{offset:28}],["ogg","audio/ogg",[1,118,111,114,98,105,115],{offset:28}],["ogm","video/ogg",[1,118,105,100,101,111,0],{offset:28}],["ogv","video/ogg",[128,116,104,101,111,114,97],{offset:28}]]],["webp","image/webp",[82,73,70,70,null,null,null,null,87,69,66,80]],["psd","image/vnd.adobe.photoshop",[56,66,80,83]],["flac","audio/x-flac",[102,76,97,67]],["wasm","application/wasm",[0,97,115,109]],["deb","application/x-deb",[33,60,97,114,99,104,62,10]],["exe","application/x-msdownload",[77,90]],["exe","application/x-msdownload",[90,77]],["class","application/java-vm",[202,254,186,190]]];function Jc(e){return e.flatMap(([e,t,n,o={},i=[]])=>[[e,t,n,o],...i])}function Vc(e,t){const n=Dc(e,26),o=Bc(e,30,n),[i]=o.split("/"),a=o.endsWith(".xml");return"META-INF"===i?{ext:"jar",mime:"application/java-archive"}:"ppt"===i&&a?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:"word"===i&&a?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:"xl"===i&&a?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:"mimetype"===i?function(e,t){const n=qc(e,18),o=qc(e,22),i=Dc(e,28);if(n===o){const o=Bc(e,30+t+i,n);if("application/vnd.oasis.opendocument.presentation"===o)return{ext:"odp",mime:o};if("application/vnd.oasis.opendocument.spreadsheet"===o)return{ext:"ods",mime:o};if("application/vnd.oasis.opendocument.text"===o)return{ext:"odt",mime:o};if("application/epub+zip"===o)return{ext:"epub",mime:o}}}(e,n)??t:t}const Kc=function(e){return Jc(e).map(([e,t,n,{offset:o=0}={}])=>n.length+o).reduce((e,t)=>t>e?t:e,0)}(Gc);function Yc(e,t){for(const[n,o,i,{exact:a=!0,offset:r=0}={},s=[]]of t)if(Mc(e,i,r)){if("zip"===n&&!a)return Vc(e.buffer,{ext:n,mime:o});if(!a&&s.length)for(const[t,n,o,{offset:i=0}={}]of s)if(Mc(e,o,i))return{ext:t,mime:n};return{ext:n,mime:o}}}function Zc(e,t,n=void 0){const o=function(e,t,n){let o=0;for(;;){let t=e.indexOf("\\",o);if(-1===t)break;o=t+1,e=e.replace("\\","/")}return e}(e).split("/").pop()||e,i=(null==n?void 0:n.type)||Qc(t,e),a=new File([t],o,{type:i});return a.path=e,a}const Xc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Qc(e,t=void 0){const n=function(e,{extra:t=!1,hint:n}={}){const o=new Uint8Array(e.slice(0,Kc));if(n){const e=function(e,{ext:t,mime:n}){return t||n?Jc(e).filter(e=>e[0]===t||e[1]===n):[]}(Gc,n);if(e.length>0){const t=Yc(o,e);if(void 0!==t)return t}}return Yc(o,Gc)||(t?function(e){return function(e){try{const t=Bc(e);if(!function(e){for(let t=0;t<e.length;t++)try{const n=e.charCodeAt(t);if(65533===n||n<=8)return!1}catch{return!1}return!0}(t))return;try{return JSON.parse(t),{ext:"json",mime:"application/json"}}catch{return{ext:"txt",mime:"text/plain"}}}catch{return}}(e)}(e):void 0)}(e);if(n)return n.mime;const o=new Uint8Array(e).subarray(0,4);let i="";for(var a=0;a<o.length;a++)i+=o[a].toString(16);let r="unknown";switch(i){case"676c5446":r="model/gltf-binary";break;case"89504e47":r="image/png";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":r="image/jpeg";break;default:r="unknown"}return"unknown"===r&&"string"==typeof t&&(r=function(e){const t=e.toLowerCase();let n="";return t.endsWith(".html")||t.endsWith(".html.gz")||t.endsWith(".html.br")?n="text/html":t.endsWith(".js")||t.endsWith(".js.gz")||t.endsWith(".js.br")||t.endsWith(".mjs")||t.endsWith(".mjs.gz")||t.endsWith(".mjs.br")||t.endsWith(".cjs")||t.endsWith(".cjs.gz")||t.endsWith(".cjs.br")?n="application/javascript":t.endsWith(".wasm")?n="application/wasm":t.endsWith(".css")||t.endsWith(".css.gz")||t.endsWith(".css.br")?n="text/css":t.endsWith(".json")?n="application/json":t.endsWith(".txt")?n="text/plain":t.endsWith(".md")?n="text/markdown":t.endsWith(".yaml")||t.endsWith(".yml")?n="application/yaml":t.endsWith(".bin")?n="application/octet-stream":t.endsWith(".png")?n="image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?n="image/jpeg":t.endsWith(".gif")?n="image/gif":t.endsWith(".webp")?n="image/webp":t.endsWith(".avif")?n="image/avif":t.endsWith(".bmp")?n="image/bmp":t.endsWith(".tiff")||t.endsWith(".tif")?n="image/tiff":t.endsWith(".ico")?n="image/x-icon":t.endsWith(".svg")?n="image/svg+xml":t.endsWith(".xml")?n="application/xml":t.endsWith(".hdr")?n="image/vnd.radiance":t.endsWith(".exr")?n="image/x-exr":t.endsWith(".ktx2")?n="image/ktx2":t.endsWith(".ktx")?n="image/ktx":t.endsWith(".dds")?n="image/vnd-ms.dds":t.endsWith(".ogg")?n="audio/ogg":t.endsWith(".mp3")?n="audio/mpeg":t.endsWith(".wav")?n="audio/wave":t.endsWith(".flac")?n="audio/flac":t.endsWith(".m4a")?n="audio/mp4":t.endsWith(".aac")?n="audio/aac":t.endsWith(".mp4")?n="video/mp4":t.endsWith(".webm")?n="video/webm":t.endsWith(".mov")?n="video/quicktime":t.endsWith(".woff2")?n="font/woff2":t.endsWith(".woff")?n="font/woff":t.endsWith(".ttf")?n="font/ttf":t.endsWith(".otf")?n="font/otf":t.endsWith(".zip")?n="application/zip":t.endsWith(".glb")?n="model/gltf-binary":t.endsWith(".gltf")?n="model/gltf+json":t.endsWith(".vrm")?n="model/gltf-binary":t.endsWith(".usdz")?n="model/vnd.usdz+zip":t.endsWith(".usda")?n="model/vnd.usd-usda":t.endsWith(".usdc")?n="model/vnd.usd-usdc":t.endsWith(".usd")?n="model/vnd.usd-usd":t.endsWith(".mtl")?n="model/mtl":t.endsWith(".obj")?n="model/obj":t.endsWith(".fbx")?n="model/vnd.autodesk.fbx":t.endsWith(".stl")?n="model/stl":t.endsWith(".mtlx")?n="application/materialx+xml":t.endsWith(".ply")?n="model/ply":t.endsWith(".dae")?n="model/vnd.collada+xml":t.endsWith(".3mf")?n="model/3mf":(t.endsWith(".splat")||t.endsWith(".spz")||t.endsWith(".ksplat")||t.endsWith(".sog")||t.endsWith(".sogs"))&&(n="application/octet-stream"),n}(t)),r}function el(e){return"string"==typeof e&&0!==e.length&&e.toLowerCase().endsWith(".exr")}function tl(e){if("string"!=typeof e||0===e.length)return!1;const t=e.toLowerCase();return t.endsWith(".hdr")||t.endsWith(".hdri")}function nl(e){return"string"==typeof e&&0!==e.length&&/\.pmrem(\d+x\d+)?\.ktx2$/i.test(e)}function ol(e,t){const n=e.toLowerCase();return"application/gzip"===t||"application/brotli"===t?(n.endsWith(".html.gz")||n.endsWith(".html.br")?(t="text/html",e=e.substring(0,e.length-3)):n.endsWith(".js.gz")||n.endsWith(".js.br")||n.endsWith(".mjs.gz")||n.endsWith(".mjs.br")||n.endsWith(".cjs.gz")||n.endsWith(".cjs.br")?(t="application/javascript",e=e.substring(0,e.length-3)):n.endsWith(".css.gz")||n.endsWith(".css.br")?(t="text/css",e=e.substring(0,e.length-3)):n.endsWith(".json.gz")||n.endsWith(".json.br")?(t="text/json",e=e.substring(0,e.length-3)):n.endsWith(".txt.gz")||n.endsWith(".txt.br")?(t="text/plain",e=e.substring(0,e.length-3)):n.endsWith(".wasm.gz")||n.endsWith(".wasm.br")?(t="application/wasm",e=e.substring(0,e.length-3)):n.endsWith(".bin.gz")||n.endsWith(".bin.br")?(t="application/octet-stream",e=e.substring(0,e.length-3)):n.endsWith(".png.gz")||n.endsWith(".png.br")?(t="image/png",e=e.substring(0,e.length-3)):n.endsWith(".jpg.gz")||n.endsWith(".jpg.br")||n.endsWith(".jpeg.gz")||n.endsWith(".jpeg.br")?(t="image/jpeg",e=e.substring(0,e.length-3)):n.endsWith(".gif.gz")||n.endsWith(".gif.br")?(t="image/gif",e=e.substring(0,e.length-3)):n.endsWith(".webp.gz")||n.endsWith(".webp.br")?(t="image/webp",e=e.substring(0,e.length-3)):n.endsWith(".svg.gz")||n.endsWith(".svg.br")?(t="image/svg+xml",e=e.substring(0,e.length-3)):n.endsWith(".xml.gz")||n.endsWith(".xml.br")?(t="application/xml",e=e.substring(0,e.length-3)):n.endsWith(".ico.gz")||n.endsWith(".ico.br")?(t="image/x-icon",e=e.substring(0,e.length-3)):n.endsWith(".avif.gz")||n.endsWith(".avif.br")?(t="image/avif",e=e.substring(0,e.length-3)):n.endsWith(".bmp.gz")||n.endsWith(".bmp.br")?(t="image/bmp",e=e.substring(0,e.length-3)):n.endsWith(".tiff.gz")||n.endsWith(".tiff.br")||n.endsWith(".tif.gz")||n.endsWith(".tif.br")?(t="image/tiff",e=e.substring(0,e.length-3)):n.endsWith(".hdr.gz")||n.endsWith(".hdr.br")?(t="image/vnd.radiance",e=e.substring(0,e.length-3)):n.endsWith(".exr.gz")||n.endsWith(".exr.br")?(t="image/x-exr",e=e.substring(0,e.length-3)):n.endsWith(".ktx2.gz")||n.endsWith(".ktx2.br")?(t="image/ktx2",e=e.substring(0,e.length-3)):n.endsWith(".ktx.gz")||n.endsWith(".ktx.br")?(t="image/ktx",e=e.substring(0,e.length-3)):n.endsWith(".dds.gz")||n.endsWith(".dds.br")?(t="image/vnd-ms.dds",e=e.substring(0,e.length-3)):n.endsWith(".webm.gz")||n.endsWith(".webm.br")?(t="video/webm",e=e.substring(0,e.length-3)):n.endsWith(".mp4.gz")||n.endsWith(".mp4.br")?(t="video/mp4",e=e.substring(0,e.length-3)):n.endsWith(".mov.gz")||n.endsWith(".mov.br")?(t="video/quicktime",e=e.substring(0,e.length-3)):n.endsWith(".mp3.gz")||n.endsWith(".mp3.br")?(t="audio/mpeg",e=e.substring(0,e.length-3)):n.endsWith(".wav.gz")||n.endsWith(".wav.br")?(t="audio/wave",e=e.substring(0,e.length-3)):n.endsWith(".ogg.gz")||n.endsWith(".ogg.br")?(t="audio/ogg",e=e.substring(0,e.length-3)):n.endsWith(".flac.gz")||n.endsWith(".flac.br")?(t="audio/flac",e=e.substring(0,e.length-3)):n.endsWith(".m4a.gz")||n.endsWith(".m4a.br")?(t="audio/mp4",e=e.substring(0,e.length-3)):n.endsWith(".aac.gz")||n.endsWith(".aac.br")?(t="audio/aac",e=e.substring(0,e.length-3)):n.endsWith(".woff2.gz")||n.endsWith(".woff2.br")?(t="font/woff2",e=e.substring(0,e.length-3)):n.endsWith(".woff.gz")||n.endsWith(".woff.br")?(t="font/woff",e=e.substring(0,e.length-3)):n.endsWith(".ttf.gz")||n.endsWith(".ttf.br")?(t="font/ttf",e=e.substring(0,e.length-3)):n.endsWith(".otf.gz")||n.endsWith(".otf.br")?(t="font/otf",e=e.substring(0,e.length-3)):n.endsWith(".md.gz")||n.endsWith(".md.br")?(t="text/markdown",e=e.substring(0,e.length-3)):n.endsWith(".yaml.gz")||n.endsWith(".yaml.br")||n.endsWith(".yml.gz")||n.endsWith(".yml.br")?(t="application/yaml",e=e.substring(0,e.length-3)):n.endsWith(".zip.gz")||n.endsWith(".zip.br")?(t="application/zip",e=e.substring(0,e.length-3)):n.endsWith(".glb.gz")||n.endsWith(".glb.br")?(t="model/gltf-binary",e=e.substring(0,e.length-3)):n.endsWith(".gltf.gz")||n.endsWith(".gltf.br")?(t="model/gltf+json",e=e.substring(0,e.length-3)):n.endsWith(".vrm.gz")||n.endsWith(".vrm.br")?(t="model/gltf-binary",e=e.substring(0,e.length-3)):n.endsWith(".usdz.gz")||n.endsWith(".usdz.br")?(t="model/vnd.usdz+zip",e=e.substring(0,e.length-3)):n.endsWith(".usda.gz")||n.endsWith(".usda.br")?(t="model/vnd.usd-usda",e=e.substring(0,e.length-3)):n.endsWith(".usdc.gz")||n.endsWith(".usdc.br")?(t="model/vnd.usd-usdc",e=e.substring(0,e.length-3)):n.endsWith(".usd.gz")||n.endsWith(".usd.br")?(t="model/vnd.usd-usd",e=e.substring(0,e.length-3)):n.endsWith(".obj.gz")||n.endsWith(".obj.br")?(t="model/obj",e=e.substring(0,e.length-3)):n.endsWith(".mtl.gz")||n.endsWith(".mtl.br")?(t="model/mtl",e=e.substring(0,e.length-3)):n.endsWith(".stl.gz")||n.endsWith(".stl.br")?(t="model/stl",e=e.substring(0,e.length-3)):n.endsWith(".mtlx.gz")||n.endsWith(".mtlx.br")?(t="application/materialx+xml",e=e.substring(0,e.length-3)):n.endsWith(".ply.gz")||n.endsWith(".ply.br")?(t="model/ply",e=e.substring(0,e.length-3)):n.endsWith(".dae.gz")||n.endsWith(".dae.br")?(t="model/vnd.collada+xml",e=e.substring(0,e.length-3)):n.endsWith(".3mf.gz")||n.endsWith(".3mf.br")?(t="model/3mf",e=e.substring(0,e.length-3)):(n.endsWith(".splat.gz")||n.endsWith(".splat.br")||n.endsWith(".spz.gz")||n.endsWith(".spz.br")||n.endsWith(".ksplat.gz")||n.endsWith(".ksplat.br")||n.endsWith(".sog.gz")||n.endsWith(".sog.br")||n.endsWith(".sogs.gz")||n.endsWith(".sogs.br"))&&(t="application/octet-stream",e=e.substring(0,e.length-3)),{filename:e,mimetype:t}):null}function il(e,t=void 0,n=!0){const o=Math.abs(e);if(o>=1099511627776){let o=n?" TB":"";return(e/1099511627776).toFixed(void 0===t?2:t)+o}if(o>=1073741824){let o=n?" GB":"";return(e/1073741824).toFixed(void 0===t?2:t)+o}if(o>=1048576){let o=n?" MB":"";return(e/1048576).toFixed(void 0===t?1:t)+o}if(o>=1024){let o=n?" KB":"";return(e/1024).toFixed(void 0===t?0:t)+o}let i=n?" B":"";return e.toFixed(0)+i}function al(e){return e.split("/").reduce((e,t)=>("."===t||(".."===t?e.pop():null!=t&&t.length&&e.push(t)),e),[]).join("/")}const rl=1179937895,sl=1313821514,cl=12,ll=8;function pl(e,t){let n=t;for(;n<e.length&&0!==e[n];)n++;return n>=e.length?null:new TextDecoder("latin1").decode(e.subarray(t,n))}async function ul(e){return new Promise(t=>setTimeout(t,e))}function dl(e,t,n=void 0){e instanceof Date&&(e=e.getTime()),t instanceof Date&&(t=t.getTime());let o=t-e,i=o>0;const a=!1!==(null==n?void 0:n.prefix),r=!1!==(null==n?void 0:n.suffix);let s="",c="";o<0&&(o=-o);const l=Math.floor(o/1e3),p=Math.floor(l/60),u=Math.floor(p/60),d=Math.floor(u/24);if(null!=(null==n?void 0:n.limitInDays)&&d>=n.limitInDays)return a&&(s="on "),`${s}${new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}${c}`;s=a?i?"":"in ":"",c=r&&i?" ago":"";const m=Math.floor(d/30),f=Math.floor(m/12);return 1===f?`${s}1 year${c}`:f>1?`${s}${Math.floor(f)} years${c}`:1===m?`${s}1 month${c}`:m>1?`${s}${Math.floor(m)} months${c}`:1===d?i&&null!=n&&n.allowSimple?"yesterday":`${s}1 day${c}`:d>1?`${s}${Math.floor(d)} days${c}`:1===u?`${s}1 hour${c}`:u>1?`${s}${Math.floor(u)} hours${c}`:1===p?`${s}1 minute${c}`:p>1?`${s}${Math.floor(p)} minutes${c}`:null!=n&&n.allowSimple&&l<10?"just now":`${s}${l.toFixed(0)} seconds${c}`}const ml=/^image_(?<image_lod>\d+)_|^mesh_lod_(?<mesh_lod>\d+)_/;function fl(e){return e.includes("\\u")?JSON.parse(`"${e}"`):decodeURIComponent(e)}function hl(e){let t=null,n="";const o=e.filter(e=>"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase());if(1===o.length)return t=o[0],t;const i=e.filter(e=>e.name.toLowerCase().endsWith(".html")||e.name.toLowerCase().endsWith(".htm")||e.name.toLowerCase().endsWith(".html.gz")||e.name.toLowerCase().endsWith(".html.br"));if(1===i.length)return i[0];if(i.length>1){const e=new Map;for(const t of i){const n=t.path.split("/");let o=e.get(n.length);o||(o=[],e.set(n.length,o)),o.push(t)}const o=Array.from(e.keys()).sort((e,t)=>e-t);if(o.length>0)for(const n of o){const o=e.get(n);if(!o)continue;const i=o.find(e=>"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase());return i?(t=i,t):(t=o[0],t)}return n="Invalid upload: Multiple HTML files found but could not determine root.",console.error(n,i.map(e=>e.path||e.name)),{error:n}}const a=e.filter(e=>e.name.toLowerCase().endsWith(".glb")||e.name.toLowerCase().endsWith(".gltf")||e.name.toLowerCase().endsWith(".vrm"));if(a.length>1){const e=function(e){const t=new Array,n=/(mesh_lod|image)_\d_(.{1,50})/;for(const o of e){if(n.test(o.name))continue;const e=o.name.toLowerCase();(e.endsWith(".gltf")||e.endsWith(".vrm")||e.endsWith(".glb"))&&t.push(o)}return 1==t.length?t[0]:null!=(o=bl(t)[0])?o:null;var o}(a);return e?(t=e,t):(n="Invalid upload: Multiple glb/glTF/vrm files found. This is currently not supported.",console.error(n,a.map(e=>e.path||e.name)),{error:n})}if(1===a.length)return t=a[0],t;const r=e.filter(e=>e.name.toLowerCase().endsWith(".usdz")||e.name.toLowerCase().endsWith(".usd")||e.name.toLowerCase().endsWith(".usda")||e.name.toLowerCase().endsWith(".usdc"));if(r.length>=1)return t=function(e){var t;const n=bl(e),o=["usda","usdz","usd","usdc"];for(const e of o){const t=n.find(t=>t.name.toLowerCase().endsWith(`.${e}`));if(t)return t}return null!=(t=n[0])?t:null}(r),t;const s=e.filter(e=>e.name.toLowerCase().endsWith(".fbx"));if(s.length>1)return n="Invalid upload: Multiple fbx files found. This is currently not supported.",console.error(n,s),{error:n};if(1===s.length)return t=s[0],t;const c=e.filter(e=>e.name.toLowerCase().endsWith(".obj"));if(c.length>1)return n="Invalid upload: Multiple obj files found. This is currently not supported.",console.error(n,c),{error:n};if(1===c.length)return t=c[0],t;const l=e.filter(e=>e.name.toLowerCase().endsWith(".stl"));if(l.length>1)return n="Invalid upload: Multiple stl files found. This is currently not supported.",console.error(n,l),{error:n};if(1===l.length)return t=l[0],t;const p=e.filter(e=>{const t=e.name.toLowerCase();return t.endsWith(".ply")||t.endsWith(".splat")||t.endsWith(".spz")||t.endsWith(".ksplat")||t.endsWith(".sog")||t.endsWith(".sogs")});if(p.length>1)return n="Invalid upload: Multiple splat files found. Upload them as separate content items.",console.error(n,p.map(e=>e.path||e.name)),{error:n};if(1===p.length)return t=p[0],t;if(1===e.length&&!e[0].arrayBuffer&&e[0].path.toLowerCase().startsWith("http"))return t=e[0],t;const u=e.filter(e=>e.name.toLowerCase().endsWith("package.json"));if(1===u.length)return t=u[0],t;if(u.length>1)return n="Invalid upload: Multiple package.json files found. This is currently not supported.",console.error(n,u),{error:n};const d=e.filter(e=>e.name.toLowerCase().endsWith(".mtlx"));if(d.length>1)return n="Invalid upload: Multiple mtlx files found. This is currently not supported.",console.error(n,d),{error:n};if(1===d.length)return t=d[0],t;const m=e.filter(e=>{const t=e.name.toLowerCase();return el(t)||tl(t)||nl(t)});return m.length>1?(n="Invalid upload: Multiple HDRI files found. Upload them as separate content items.",console.error(n,m.map(e=>e.path||e.name)),{error:n}):1===m.length?(t=m[0],t):t||{error:"No supported file to upload found..."}}const gl=new Set(["glb","gltf","vrm"]),vl=new Set(["fbx","obj","stl","usd","usda","usdz"]);function bl(e){let t=Infinity,n=[];for(const o of e){const e=o.path.split("/").length;e<t?(t=e,n=[o]):e===t&&n.push(o)}return n}class xl{constructor(e,t){this.totalFiles=e,this.estimatedTotalSize=t,this.uploadedSize=0,this.startTime=Date.now(),this.lastUpdateTime=this.startTime,this.lastUploadedSize=0,this.speedEMA=null,this.emaFactor=.1,this.smoothedRemainingTime=null,this.recentSpeeds=new Array,this.maxRecentSpeeds=20,this.initialEstimateThreshold=.05}updateProgress(e){const t=Date.now(),n=(t-this.lastUpdateTime)/1e3,o=e-this.lastUploadedSize;if(this.uploadedSize=e,n>0&&o>0){this.recentSpeeds.push(o/n),this.recentSpeeds.length>this.maxRecentSpeeds&&this.recentSpeeds.shift();const e=this.recentSpeeds.reduce((e,t)=>e+t,0)/this.recentSpeeds.length;this.speedEMA=null===this.speedEMA?e:this.emaFactor*e+(1-this.emaFactor)*this.speedEMA}this.lastUpdateTime=t,this.lastUploadedSize=e;const i=this.uploadedSize/this.estimatedTotalSize,a=(t-this.startTime)/1e3,r=this.speedEMA&&this.speedEMA>0?this.speedEMA:this.uploadedSize/a;let s;if(s=r>0?(this.estimatedTotalSize-this.uploadedSize)/r:Infinity,i>=this.initialEstimateThreshold)if(null===this.smoothedRemainingTime)this.smoothedRemainingTime=s;else{const e=.1;this.smoothedRemainingTime=(1-e)*this.smoothedRemainingTime+e*s}else this.smoothedRemainingTime=a/i-a;return this.smoothedRemainingTime=Math.max(this.smoothedRemainingTime,(this.estimatedTotalSize-this.uploadedSize)/r),{progress:100*i,estimatedTimeRemaining:Math.round(this.smoothedRemainingTime),estimatedTimeRemainingString:this.smoothedRemainingTime>3?this.__formatTime(this.smoothedRemainingTime):"few seconds"}}__formatTime(e){if(!isFinite(e))return"Calculating...";if(e<60)return`${Math.round(e)}sec`;const t=Math.floor(e/60);if(t<60)return`${t}min`;const n=Math.floor(t/60);if(n<24)return`${n}h ${t%60}min`;const o=Math.floor(n/24);return o<=10?`${o}d`:"Calculating..."}}const yl=15e3;function wl(e,t,n={setTimeout:setTimeout,clearTimeout:clearTimeout}){return function(o,i){const a=e.call(this,o,i);if(!a||"function"!=typeof a.once)return a;const r=n.setTimeout(()=>{const e=new Error(`connect timeout: no connection within ${t/1e3}s`);e.code="ETIMEDOUT",a.destroy(e)},t),s=()=>n.clearTimeout(r);return a.once("connect",s),a.once("secureConnect",s),a.once("error",s),a.once("close",s),a}}let _l;async function jl(e={}){var t,n;if(!(null!=(t=e.isNode)?t:"undefined"!=typeof process&&null!=(n=process.versions)&&n.node))return{};if(_l)return _l;const[{default:o},{default:i}]=await Promise.all([import("node:http"),import("node:https")]),a=new o.Agent({keepAlive:!0}),r=new i.Agent({keepAlive:!0});for(const e of[a,r])e.createConnection=wl(e.createConnection,yl);return _l={httpAgent:a,httpsAgent:r},_l}async function kl(e){const t=await import("./pako.esm-01431bd2.js"),n=await e.arrayBuffer(),o=t.gzip(new Uint8Array(n)).buffer.slice(0);if(o.byteLength>51200&&o.byteLength>=n.byteLength){if(n.byteLength>0)return null}else if(!(o instanceof ArrayBuffer))return console.error("gzipCompress: Invalid ArrayBuffer"),{error:`Gzip compressing failed for "${e.name}" (unexpected result)`};return Zc(`${"path"in e?e.path:e.name}.gz`,o,{type:"application/gzip"})}const Sl=16777216;async function El(e,t,n=void 0){const o=async function(e,t,n){var o,i,a,r,s,c,l,p,u,d,m,f,h,g,v,b,x,y,w,_;let{files:j,skipped:k}=function(e){const t=[];return{files:e.filter(e=>{const n=e.name||"";return!(!n||n.endsWith("/"))||(t.push({name:n,reason:"directory-entry"}),!1)}),skipped:t}}(t.files);for(const e of k)console.warn(`[upload] Skipping directory entry: "${e.name}"`);t.files=j;const S=(null==(o=n)?void 0:o.loglevel)||"none";if(!j.length)return"none"!=S&&console.error("No files to upload"),{success:!1,error:"No files to upload"};if(!t.entrypoint){const e=hl(j);if(null==e)return{success:!1,error:"No entrypoint file found"};if("object"==typeof e&&"error"in e)return{success:!1,error:e.error};"info"===S&&console.log("Entrypoint: "+e.name),t.entrypoint=e}t.entrypoint&&!j.includes(t.entrypoint)&&j.push(t.entrypoint);const E=await async function(e){if(e.length>5e3)return{success:!1,error:"Too many files. Maximum filecount is 5000"};let t=0,n=0,o=0,i=0;for(let c=e.length-1;c>=0;c--){const l=e[c];if(t+=l.size,t>1073741824)return{success:!1,error:`Total file size exceeds limit of ${1024..toFixed(0)} MB. Please reduce the size of your upload.`};const p=l.name.toLocaleLowerCase();if(".ds_store"!==p){if(p.endsWith(".gltf")?o++:p.endsWith(".glb")?(s=p)&&ml.test(s)||i++:p.endsWith(".vrm")&&n++,p.endsWith(".gltf")){var a;o+=1,console.log(`Found glTF file ${l.name}. Will check if all dependencies are available\n`,e);const t=await l.text(),n=t.matchAll(/"uri"\s*:\s*"(?<value>.*?)"/g);if(!n)continue;const i=JSON.parse(t);if("2.0"!==i.asset.version)return console.warn("⚠ glTF version is not 2.0. This is currently not supported."),{success:!1,error:`glTF version ${i.asset.version} is unsupported.Please use glTF 2.0.`};const s=null==(a=l.path)?void 0:a.split("/"),c=s.splice(0,s.length-1).join("/");for(const t of n){var r;const n=null==(r=t.groups)?void 0:r.value;if(n){let t=!1;if(n.startsWith("http://")||n.startsWith("https://")||n.startsWith("www.")){console.log(`✅ Found remote dependency ${n} `);break}if(n.startsWith("data:")){console.log(`✅ Found embedded dependency ${n} `);break}{const o=al(`${c}/${fl(n)}`);console.log('❓ Check if local dependency exists "'+o+'"');for(const n of e){if(n.webkitRelativePath===o||n.name==o){t=!0,console.log(`✅ Found dependency in name or webkit: ${n.name} || ${n.webkitRelativePath} `);break}if(n.path===o){t=!0,console.log(`✅ Found dependency in path: ${n.path} `);break}}}if(!t)return console.warn("⚠ Missing dependency "+n,c),{success:!1,error:"Missing resource: "+n}}}}}else e.splice(c,1)}var s;return{success:!0,vrm_count:n,gltf_count:o,glb_count:i}}(j);if("error"in E)return{success:!1,error:E.error||"Failed to validate files"};if(null!=(i=t.entrypoint)&&i.name.endsWith(".htm")||null!=(a=t.entrypoint)&&a.name.endsWith(".html")||null!=(r=t.entrypoint)&&r.name.endsWith(".html.gz")||null!=(s=t.entrypoint)&&s.name.endsWith(".html.br"))n||(n={}),n.type="deployment";else if(E.vrm_count>10)return{success:!1,error:"Multiple model files found - this is not supported for asset uploads. Please upload a single model file only."};const $=await async function(e,t={}){const{raw:n=!1,loglevel:o="none",entrypoint:i=null}=t,a=(...e)=>{"none"!==o&&console.log(...e)};if(n)return"none"!==o&&console.warn("Raw upload - skipping gzip compression of files"),{files:e,entrypoint:i};const r=new Set(e.map(Il)),s=[];let c=i;for(const t of e){const n=Il(t),p=t.name.toLowerCase();if(!$l.some(e=>p.endsWith(e))){s.push(t);continue}const u=Tl.find(e=>r.has(`${n}${e}`));if(u){var l;a(`Skipping gzip compression, using pre-compressed file: ${n}${u}`),i===t&&(c=null!=(l=e.find(e=>Il(e)===`${n}${u}`))?l:c);continue}a(`gZip compressing file: ${t.name}`);const d=await kl(t).catch(e=>({error:`Error compressing ${t.name}: ${e.message}`}));if(null===d){"none"!==o&&console.error(`Did not compress file: ${t.name}`),s.push(t);continue}if("error"in d)return{files:e,entrypoint:i,error:d.error};if(!d)return{files:e,entrypoint:i,error:`Failed to compress ${t.name}`};const m=i===t;s.push(d),m&&(c=d),a(`gZip compressed file: ${t.name} ${m?"(entrypoint)":""}`)}return{files:s,entrypoint:c}}(j,{raw:t.raw,loglevel:null!=(c=null==(l=n)?void 0:l.loglevel)?c:S,entrypoint:t.entrypoint});if($.error)return{success:!1,error:$.error,status:500};j=$.files,t.files=j,t.entrypoint=$.entrypoint,j.sort((e,t)=>e.name.includes(".needle")&&!t.name.includes(".needle")?-1:!e.name.includes(".needle")&&t.name.includes(".needle")?1:0);const{baseUrl:T,authToken:I}=e,O="Bearer "+I,A={...ht(e),triggered_by:t.triggered_by,filename:`${encodeURIComponent(t.entrypoint.name)}`,"total-files":j.length.toString(),"total-files-size":j.reduce((e,t)=>e+t.size,0).toString()};null!=(p=n)&&p.content_id&&(A.content_id=n.content_id),null!=(u=n)&&u.type&&(A.type=n.type),null!=(d=n)&&d.name&&(A.name=encodeURIComponent(n.name)),null!=(m=n)&&m.parent_job_id&&(A.parent_job_id=n.parent_job_id);const C={entrypoint:(null==(f=t.entrypoint)?void 0:f.path)||(null==(h=t.entrypoint)?void 0:h.name),files:[]};null!=(g=n)&&g.content_type&&(C.content_type=n.content_type);const R={outputs:[C],...t.metadata?{metadata:t.metadata}:{},...!1===(null==(v=n)?void 0:v.optimizations)?{optimizations:!1}:{},...!0===(null==(b=n)?void 0:b.verify)?{verify:!0}:{}},N=[];for(let e=0;e<j.length;e++){var P,U,L;const t=j[e];let o=t.path||t.webkitRelativePath||t.name;if(null!=(P=o)&&P.includes(":"))throw new Error(`Invalid filename: ${o}`);let i=await t.arrayBuffer();const a=t.size;let r=t.type;if(null!=(U=r)&&U.length&&"unknown"!==r.toLowerCase()||(r=Qc(i,o)),"deployment"===(null==(L=n)?void 0:L.type)){const e=ol(o,r);e&&(o=e.filename,r=e.mimetype)}const s=function(e){let t="";for(let n=0;n<e.length;n+=3){const o=e.charCodeAt(n),i=n+1<e.length?e.charCodeAt(n+1):0,a=n+2<e.length?e.charCodeAt(n+2):0;t+=Xc[o>>2]+Xc[(3&o)<<4|i>>4]+(n+1<e.length?Xc[(15&i)<<2|a>>6]:"=")+(n+2<e.length?Xc[63&a]:"=")}return t}(Fc.ArrayBuffer.hash(i,!0));N[e]=i,C.files[e]={filename:o,content_type:r,content_length:a,content_md5:s}}if("deployment"!==(null==(x=n)?void 0:x.type)){const e=t.entrypoint.name.toLowerCase();let o;if(e.endsWith(".glb")||e.endsWith(".gltf"))try{const n=N[j.indexOf(t.entrypoint)];o=function(e){return function(e){if(!e)return!1;const t=!e.nodes||0===e.nodes.length,n=!e.meshes||0===e.meshes.length,o=Array.isArray(e.materials)&&1===e.materials.length;return t&&n&&o}(e)?"material":"3d-asset"}(e.endsWith(".glb")?function(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<cl+ll)throw new Error("Buffer too small to be a GLB");const n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==rl)throw new Error("Not a GLB (magic mismatch)");const o=n.getUint32(cl,!0);if(n.getUint32(cl+4,!0)!==sl)throw new Error("First chunk is not JSON");const i=cl+ll,a=i+o;if(a>t.byteLength)throw new Error("JSON chunk exceeds buffer length");const r=t.subarray(i,a),s=(new TextDecoder).decode(r);return JSON.parse(s)}(n):JSON.parse((new TextDecoder).decode(n)))}catch(e){return{success:!1,error:`Failed to inspect "${t.entrypoint.name}": ${e.message}`}}else e.endsWith(".mtlx")?o="material":(el(e)||tl(e)||nl(e))&&(o="hdri");if(o){var z;if(null!=(z=n)&&z.content_type&&n.content_type!==o)return{success:!1,error:`Content type mismatch: "${t.entrypoint.name}" contains "${o}" but "${n.content_type}" was requested.`};C.content_type=o}}try{const e=await async function(e){var t,n,o,i,a;if(!e||"function"!=typeof e.slice||"number"!=typeof e.size)return null;const r=Math.min(e.size,65536);if(r<=0)return null;let s;try{const t=await e.slice(0,r).arrayBuffer();s=new Uint8Array(t)}catch{return null}return null!=(t=null!=(n=null!=(o=null!=(i=null!=(a=function(e){if(e.length<24)return null;if(137!==e[0]||80!==e[1]||78!==e[2]||71!==e[3])return null;if(13!==e[4]||10!==e[5]||26!==e[6]||10!==e[7])return null;const t=new DataView(e.buffer,e.byteOffset),n=t.getUint32(16,!1),o=t.getUint32(20,!1);return n&&o?{width:n,height:o}:null}(s))?a:function(e){if(e.length<28)return null;const t=[171,75,84,88,32,50,48,187,13,10,26,10];for(let n=0;n<t.length;n++)if(e[n]!==t[n])return null;const n=new DataView(e.buffer,e.byteOffset),o=n.getUint32(20,!0),i=n.getUint32(24,!0);return o&&i?{width:o,height:i}:null}(s))?i:function(e){if(e.length<16)return null;if(118!==e[0]||47!==e[1]||49!==e[2]||1!==e[3])return null;const t=new DataView(e.buffer,e.byteOffset);let n=8;for(;n<e.length;){const o=pl(e,n);if(null===o)return null;if(0===o.length)return null;n+=o.length+1;const i=pl(e,n);if(null===i)return null;if(n+=i.length+1,n+4>e.length)return null;const a=t.getInt32(n,!0);if(n+=4,a<0||n+a>e.length)return null;if("dataWindow"===o&&"box2i"===i&&16===a){const e=t.getInt32(n,!0),o=t.getInt32(n+4,!0),i=t.getInt32(n+8,!0)-e+1,a=t.getInt32(n+12,!0)-o+1;return i<=0||a<=0?null:{width:i,height:a}}n+=a}return null}(s))?o:function(e){if(e.length<30)return null;if(82!==e[0]||73!==e[1]||70!==e[2]||70!==e[3])return null;if(87!==e[8]||69!==e[9]||66!==e[10]||80!==e[11])return null;const t=String.fromCharCode(e[12],e[13],e[14],e[15]);if("VP8 "===t){const t=16383&(e[26]|e[27]<<8),n=16383&(e[28]|e[29]<<8);return t&&n?{width:t,height:n}:null}return"VP8L"===t?47!==e[20]?null:{width:1+(16383&(e[21]|e[22]<<8)),height:1+(16383&(e[22]>>6|e[23]<<2|(15&e[24])<<10))}:"VP8X"===t?{width:1+(e[24]|e[25]<<8|e[26]<<16),height:1+(e[27]|e[28]<<8|e[29]<<16)}:null}(s))?n:function(e){if(e.length<4)return null;if(255!==e[0]||216!==e[1])return null;let t=2;for(;t<e.length-8;){for(;t<e.length&&255===e[t];)t++;if(t>=e.length)return null;const n=e[t++];if(1===n||n>=208&&n<=217)continue;if(t+2>e.length)return null;const o=e[t]<<8|e[t+1];if(o<2||t+o>e.length)return null;if(n>=192&&n<=207&&196!==n&&200!==n&&204!==n){if(t+7>e.length)return null;const n=e[t+3]<<8|e[t+4],o=e[t+5]<<8|e[t+6];return o&&n?{width:o,height:n}:null}t+=o}return null}(s))?t:function(e){if(e.length<10)return null;if(35!==e[0]||63!==e[1])return null;const t=new TextDecoder("latin1").decode(e.subarray(0,Math.min(e.length,4096))).match(/[+-]Y\s+(\d+)\s+[+-]X\s+(\d+)/);if(!t)return null;const n=parseInt(t[1],10),o=parseInt(t[2],10);return o&&n?{width:o,height:n}:null}(s)}(t.entrypoint);e&&(C.width=e.width,C.height=e.height)}catch(e){"debug"===S&&console.warn("readImageResolution failed; uploading without dimensions",e)}const F=await fetch(T+ft.upload.request,{...gt,method:"POST",headers:A,body:JSON.stringify(R)}).catch(e=>"fetch failed"==e.message||"Failed to fetch"==e.message?`Network error. Make sure you are connected to the internet and ${T} is reachable.`:(console.error("Failed to begin upload\n",e),null));if(null===F||"string"==typeof F)return{success:!1,error:F||"Failed to begin upload"};if(!F.ok){const e=await F.text();if(e.startsWith("{")){const t=JSON.parse(e);if("error"in t)return{success:!1,status:F.status,error:t.error}}return"none"!=S&&console.error("Failed to begin upload\n",F.status,e),{success:!1,status:F.status,error:`${e}`}}const D=await F.json();"debug"===S&&console.debug("BeginResponse",D);const q=j.reduce((e,t)=>e+t.size,0);var B;if("exists"===D.type)return"none"!=S&&console.log("Upload already exists",D.id),null!=(B=n)&&B.onStart&&n.onStart(D.id,D.content_id),{success:!0,uploadSkipped:!0,id:D.id,type:D.job_type,content_id:D.content_id,filesUploaded:j.length,totalSize:q,url:D.url,edit_url:D.edit_url};const M=t.entrypoint.webkitRelativePath||t.entrypoint.name;let W=0;null==(y=n)||null==(y=y.abort)||y.addEventListener("abort",async()=>{console.log("Upload aborted: Cancelling upload"),await fetch(T+ft.upload.cancel,{...gt,method:"POST",headers:{authorization:O,id:D.id}})});let H=!1,G=Date.now();function J(t,n,o=!1){if(!o&&Date.now()-G<1e3)return!1;if(H&&"completed"!==n)return void("none"!=S&&console.warn("Invalid status update..."));G=Date.now();const i=Math.floor(W/q*100);return"debug"===S&&console.log("SET STATUS: "+n,t,i),wc({identifier:D.id,status:n,status_message:t,progress:i},e),!0}null!=(w=n)&&w.onStart&&n.onStart(D.id,D.content_id);const V=Date.now(),K=new xl(j.length,q/1024/1024),Y=new Array,Z=function(e){let t=0;for(const n of e)Number.isFinite(n)&&n>=0&&(t=Math.max(t,n));return t>=Lc?2:t>=Sl?4:10}(C.files.map(e=>e.content_length));"debug"===S&&console.debug(`Upload file concurrency: ${Z}`);let X=!1;const Q=[...j],ee=j.length,te=function(e,t=25e3){let n=!1;const o=setInterval(()=>{if(!n)try{const t=e();t&&"function"==typeof t.then&&t.catch(e=>{console.warn("[upload] heartbeat tick failed:",e)})}catch(e){console.warn("[upload] heartbeat tick threw:",e)}},t);return o&&"function"==typeof o.unref&&o.unref(),function(){n||(n=!0,clearInterval(o))}}(()=>J("Upload in progress","running",!0));try{var ne;for(let o=0;o<Q.length;o++){var oe;if(!(X||null!=(oe=n)&&null!=(oe=oe.abort)&&oe.aborted)){if(Y.length<Z){console.debug(`Uploading file ${o}/${j.length}: ${j[o].name}`);let i=0,a=0;const r=C.files[o],s=r.filename,c=N[o],l=r.content_length,p=r.content_type,u=j[o],d=u.name.endsWith(".gz")?"gzip":u.name.endsWith(".br")?"br":void 0,m=zl({uploadId:D.id,uploadRequestPUTUrl:D.request_put_url,entrypointPath:M,file:j[o],fileName:s,fileMd5:r.content_md5,fileBuffer:c,fileType:p,content_encoding:d,fileSize:l,fileIndex:o,fileNumber:o+1,fileCount:ee,loglevel:S,experimental:t.experimental,args:e,options:n,onProgress:e=>{var t;const r=e.progress||0;i=j[o].size*r;const c=i-a;if(a=i,W+=c,null!=(t=n)&&t.progress){const e=W/q,t=j.length,i=j[o].size,a=(Date.now()-V)/1e3,c=K.updateProgress(W/1024/1024);n.progress({uploadedBytes:W,totalBytes:q,progress01:e,fileName:j[o].name,fileSize:i,fileProgress01:r,fileIndex:o,totalFiles:t,estimatedTimeLeftDisplay:c.estimatedTimeRemainingString,estimatedTimeLeft:c.estimatedTimeRemaining,elapsedTime:a}),J(`Uploading file ${o+1}/${t} (${s}): ${(100*r).toFixed(0)}% of ${il(q)}. Finished in approx. ${c.estimatedTimeRemainingString}`,"running",!1)}}}).then(e=>{if(!0!==e)return e;for(let e=Y.length-1;e>=0;e--)Y[e]===m&&Y.splice(e,1);J(`Uploaded ${il(W)+" of "+il(q)} for ${j[o].name}`,"running")}).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),X=!0)});Y.push(m)}Y.length>=Z&&await Promise.race(Y)}}null!=(ne=n)&&null!=(ne=ne.abort)&&ne.aborted?console.debug("Upload aborted"):X&&console.debug("Upload failed"),await Promise.all(Y).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),X=!0)})}finally{te()}if(X)return await wc({identifier:D.id,status:"failed",error:"Failed to upload files"},e),{success:!1,error:"Failed to upload files"};if(null!=(_=n)&&null!=(_=_.abort)&&_.aborted)return await wc({identifier:D.id,status:"canceled",status_message:"Upload aborted",error:"Upload aborted"},e),{success:!1,error:"Upload aborted"};H=!0,console.log(`Upload Done: All files uploaded to ${D.id}`);const ie={...ht(e),id:D.id};"none"!=S&&console.log("Completing upload - notify server");let ae=null;for(let e=0;e<5;e++){var re;await ul(1e3*e);const t=AbortSignal.timeout(6e4+5e3*e);if(ae=await fetch(T+ft.upload.done,{...gt,method:"POST",headers:ie,signal:t}).catch(t=>(console.error(`Failed to complete upload (${e+1} / 5)`,t.message),null)),!0===(null==(re=ae)?void 0:re.ok))break;if(ae&&ae.status>=400&&ae.status<500)break;var se;"none"!=S&&e<4&&console.warn(`Failed to complete upload (${(null==(se=ae)?void 0:se.status)||"no status"}): will retry in 1 second`)}if(!ae)return console.error("Failed to complete upload"),{success:!1,error:"Failed to complete upload"};if(!ae.ok){if(524===ae.status)return console.error("Failed to complete upload: Gateway Timeout"),{success:!1,error:"Failed to complete upload: Gateway Timeout"};{const e=await ae.text().catch(()=>"");return console.error(`Failed to complete upload (${ae.status}): ${e}`),{success:!1,error:`Failed to complete upload: ${e?e.substring(0,300):`status ${ae.status}`}`}}}"none"!=S&&console.log("Upload complete");const ce=await ae.json();return{success:!0,type:ce.type,uploadSkipped:!1,id:ce.id,content_id:ce.content_id,url:ce.url,edit_url:ce.edit_url,filesUploaded:j.length,totalSize:q}}(e,t,n);return await o.finally(()=>{})}const $l=[".html",".js",".css"],Tl=[".gz",".br"];function Il(e){return"path"in e&&e.path?e.path:e.name}function Ol(e){var t;const n=null==e||null==(t=e.config)?void 0:t.url;if(!n)return null;try{return new URL(n).host}catch{return null}}const Al=400,Cl=255;function Rl(e){const t="string"==typeof e?e:String(null!=e?e:"");return t.length<=Cl?t:t.slice(0,Cl-1)+"…"}const Nl={ECONNRESET:"connection reset before the upload completed",ECONNREFUSED:"connection refused by the storage host",ECONNABORTED:"connection aborted — timed out or closed mid-request",ENOTFOUND:"DNS lookup failed for the storage host",EAI_AGAIN:"DNS lookup failed temporarily — resolver unavailable",ETIMEDOUT:"connection timed out",EPIPE:"connection closed while sending the file",EHOSTUNREACH:"storage host unreachable from this network",ENETUNREACH:"network unreachable",EPROTO:"TLS or protocol error",ERR_NETWORK:"network error — the request never reached the storage host",CERT_HAS_EXPIRED:"the TLS certificate for the storage host has expired",UNABLE_TO_VERIFY_LEAF_SIGNATURE:"the TLS certificate for the storage host could not be verified",DEPTH_ZERO_SELF_SIGNED_CERT:"a self-signed TLS certificate was presented for the storage host",SELF_SIGNED_CERT_IN_CHAIN:"a self-signed TLS certificate was presented for the storage host"};function Pl(e){if(!e)return"unknown upload error";const t=[];try{const i=e.response,a=null==i?void 0:i.status,r=null==i?void 0:i.statusText;a&&t.push(`HTTP ${a}${r?" "+r:""}`);const s=null==i?void 0:i.data;if(null!=s){var n,o;let i;if("string"==typeof s)i=s;else try{i=JSON.stringify(s)}catch{i=String(s)}const a=null==(n=i.match(/<Code>([^<]+)<\/Code>/))?void 0:n[1],r=null==(o=i.match(/<Message>([^<]+)<\/Message>/))?void 0:o[1];if(a)t.push(`S3 ${a}${r?": "+r:""}`);else if(function(e){return/^\s*(<!DOCTYPE\s+html|<html[\s>])/i.test(e)}(i)){const n=Ol(e);t.push("blocked by a network filter or proxy"+(n?` before it reached ${n}`:"")+" — ask your network administrator to allow this host")}else i&&t.push(i.slice(0,200))}let c=null;if(!i&&(c=function(e){var t,n;const o=null!=(t=null==e?void 0:e.code)?t:null==e||null==(n=e.cause)?void 0:n.code;return"string"==typeof o&&o.length?o:null}(e),c)){const n=Nl[c];t.push(n?`${c} (${n})`:c);const o=Ol(e);o&&t.push(`while uploading to ${o}`)}const l=e.message?String(e.message):"",p=a&&/^Request failed with status code \d+$/.test(l)||null!==c&&l.includes(c);l&&!p&&t.push(l)}catch{}return 0===t.length&&e.message&&t.push(String(e.message)),t.length?t.join(" — "):"unknown upload error"}const Ul=12e4;function Ll(e,t){let n=null,o=!1;const i=()=>{n&&(clearTimeout(n),n=null)};return{reset:()=>{o||(i(),n=setTimeout(()=>{o=!0,n=null,t()},e))},cancel:i}}async function zl(e){if(e.fileSize>=Lc)return async function(e){const{uploadId:t,entrypointPath:n,file:o,fileName:i,fileMd5:a,fileType:r,content_encoding:s,fileSize:c,args:l,options:p,onProgress:u,partSize:d,concurrency:m,maxRetries:f,retryDelayMs:h,putPart:g}=e,{baseUrl:v}=l,b=()=>({...ht(l),"Content-Type":"application/json",org:l.org,job_id:t}),x={...b(),filesize:c.toString()},y=JSON.stringify({filename:i,entrypoint:n,"content-type":r,"content-md5":a,"content-encoding":s,output_index:0});async function w(e,t,n){const o=await fetch(e,{...gt,method:"POST",headers:t,body:JSON.stringify(n)});if(!o.ok)throw new Error(`${e} ${o.status}: ${await o.text().catch(()=>"")}`);return o.json()}return await async function(e){const{size:t,slice:n,partSize:o=Uc,concurrency:i=4,maxRetries:a=5,retryDelayMs:r=1e3,createUpload:s,getPartUrls:c,putPart:l,completeUpload:p,abortUpload:u,onProgress:d,signal:m,checkCancelled:f}=e,h=async()=>{if(m&&m.aborted)return!0;if(f)try{return!!await f()}catch{return!1}return!1};if(await h())throw new Error("Upload aborted");const g=function(e,t=Uc){if(!Number.isFinite(e)||e<=0)return[];let n=Math.max(t,Nc,Math.ceil(e/Pc));const o=[];let i=0,a=1;for(;i<e;){const t=Math.min(i+n,e);o.push({partNumber:a,start:i,end:t,size:t-i}),i=t,a++}return o}(t,o);if(0===g.length)throw new Error("Nothing to upload (size <= 0)");const{upload_id:v,key:b}=await s(),x=await c(v,b,g.map(e=>e.partNumber)),y=new Map(x.map(e=>[e.part_number,e.url])),w=[];let _=0,j=null;const k=async e=>{const t=y.get(e.partNumber);if(!t)throw new Error(`Missing presigned url for part ${e.partNumber}`);let o=!1;const i=await Cc(async()=>{if(await h())throw o=!0,new Error("Upload aborted");try{const o=n(e.start,e.end),i=await l({url:t,payload:o,partNumber:e.partNumber,size:e.size,signal:m});if(!i)throw new Error(`No ETag returned for part ${e.partNumber}`);return i}catch(e){throw await h()&&(o=!0),e}},{maxAttempts:a+1,baseMs:r,isRetryable:e=>!o&&Oc(e),...r>0?{}:{sleep:async()=>{}}});if(!i.ok)throw i.error||new Error(`Failed to upload part ${e.partNumber}`);w.push({part_number:e.partNumber,etag:i.value}),_+=e.size,d&&d(_)},S=[...g],E=Math.max(1,Math.min(i,g.length));if(await Promise.all(Array.from({length:E},()=>(async()=>{for(;S.length>0;){if(j||await h())return;const e=S.shift();if(!e)return;try{await k(e)}catch(e){return void(j=j||e)}}})())),j||await h())throw await u(v,b).catch(()=>{}),j||new Error("Upload aborted");return w.sort((e,t)=>e.part_number-t.part_number),await p(v,b,w),{ok:!0,key:b,upload_id:v,parts:g.length}}({size:c,partSize:d,concurrency:m,maxRetries:f,retryDelayMs:h,slice:(e,t)=>o.slice(e,t),signal:null==p?void 0:p.abort,onProgress:e=>{u&&u({loaded:e,total:c,progress:c?e/c:0})},createUpload:async()=>{const e=await fetch(v+ft.upload.multipart_create,{...gt,method:"POST",headers:x,body:y});if(!e.ok)throw new Error(`multipart/create ${e.status}: ${await e.text().catch(()=>"")}`);const t=await e.json();return{upload_id:t.upload_id,key:t.key}},getPartUrls:async(e,t,n)=>(await w(v+ft.upload.multipart_part_urls,b(),{key:t,upload_id:e,part_numbers:n})).urls,putPart:g||(({url:e,payload:t,partNumber:n,signal:o})=>async function({url:e,payload:t,partNumber:n,contentType:o,signal:i}){const a=i,r=new AbortController;let s=!1;const c=()=>r.abort();a&&(a.aborted?r.abort():a.addEventListener("abort",c,{once:!0}));const l=Ll(Ul,()=>{s=!0,r.abort()});l.reset();try{var p,u;const n=await vc.put(e,t,{...gt,...await jl(),withCredentials:!1,signal:r.signal,headers:{"Content-Type":o},onUploadProgress:()=>l.reset()});if(200!==n.status)throw new Error(Pl({response:n}));const i=(null==(p=n.headers)?void 0:p.etag)||(null==(u=n.headers)?void 0:u.ETag);if(!i)throw new Error("part PUT returned no ETag (is the bucket's CORS exposeHeaders:etag set?)");return i}catch(e){if(null!=a&&a.aborted)throw e;if(s)throw new Error(`Part ${n} stalled: no progress for ${Ul/1e3}s`);throw new Error(Pl(e))}finally{l.cancel(),a&&a.removeEventListener("abort",c)}}({url:e,payload:t,partNumber:n,signal:o,contentType:r})),completeUpload:async(e,t,n)=>w(v+ft.upload.multipart_complete,b(),{key:t,upload_id:e,parts:n}),abortUpload:async(e,t)=>{await fetch(v+ft.upload.multipart_abort,{...gt,method:"POST",headers:b(),body:JSON.stringify({key:t,upload_id:e})}).catch(()=>{})}}),!0}(e);const{uploadId:t,uploadRequestPUTUrl:n,entrypointPath:o,file:i,fileName:a,fileBuffer:r,fileMd5:s,fileSize:c,fileType:l,content_encoding:p,fileIndex:u,fileNumber:d,fileCount:m,loglevel:f,args:h,options:g,experimental:v}=e;"info"===f&&console.log(`Uploading file "${i.name}" type=${l} (${c}) ${i.type} with hash ${s}`);const b={...ht(h),"Content-Type":"application/json",org:h.org,job_id:t,filesize:c.toString(),progress:(u/m*100).toFixed(0)},x={filename:a,entrypoint:o,"content-type":l,"content-md5":s,"content-encoding":p,output_index:0};"debug"===f&&console.debug("Requesting presigned URL with headers",b);const y=JSON.stringify(x);let w=null,_="";const j=await Cc(async()=>{var e;if(null!=g&&null!=(e=g.abort)&&e.aborted)throw new bc("Upload aborted");const t=await fetch(n,{...gt,method:"POST",headers:b,body:y});if(!t.ok){const e=await t.text().catch(()=>"");throw _=e,{response:{status:t.status,statusText:t.statusText,data:e}}}return await t.json()},{baseMs:500,onRetry:({attempt:e,waitMs:t,error:n})=>{console.warn(`Failed to get presigned url for "${a}" "${l}": ${Pl(n)}\n→ Retry #${e} in ${t}ms`)}});if(j.ok)w=j.value;else if(j.error instanceof bc)throw j.error;if(null==w){const e=_||Pl(j.error);throw new Error(`Failed to get presigned url for "${a}" "${l}" \n${e}`)}const k=w.presigned_url;var S=!1;let E=null;const $=[];let T=0;const I=await Cc(async t=>{var n;if(null!=g&&null!=(n=g.abort)&&n.aborted)throw new bc("Upload aborted");const o={"Content-Type":l,"Content-MD5":s};v&&(o["Content-Length"]=c.toString()),p&&(o["Content-Encoding"]=p),1===t&&"none"!=f&&console.log(`Uploading file ${d}/${m}: ${a}`),"debug"===f&&console.debug("PUT with headers",o);const i=new AbortController;let u=!1;const h=()=>i.abort();null!=g&&g.abort&&(g.abort.aborted?i.abort():g.abort.addEventListener("abort",h,{once:!0}));const b=Ll(Ul,()=>{u=!0,i.abort()});b.reset();try{const t=await vc.put(k,r,{...gt,...await jl(),withCredentials:!1,signal:i.signal,headers:o,onUploadProgress:t=>{b.reset(),e.onProgress(t)}});if(200!==t.status)throw{response:t};return t}catch(e){var x;if(null!=g&&null!=(x=g.abort)&&x.aborted)throw new bc("Upload aborted");if(u)throw E=`stalled: no upload progress for ${Ul/1e3}s`,$.push(E),"none"!==f&&console.error(`Upload stalled (PUT) (${d}, ${a}) after ${Ul/1e3}s with no progress`),new Error(E);throw E=Pl(e),$.push(E),e instanceof bc||("none"!==f&&console.error(`Failed to upload file (PUT) (${d}, ${a}) "${E}"`),"debug"===f&&(console.log(o,{fileSize:c}),e.response?console.debug(e.response):console.debug(e))),e}finally{b.cancel(),null!=g&&g.abort&&g.abort.removeEventListener("abort",h)}},{onRetry:({attempt:e,waitMs:t})=>{"none"!==f&&console.log(`Retry PUT #${e} for file ${a} in ${t}ms`)}});if(T=I.attempts,I.ok)S=!0,"info"===f&&console.log(`Uploaded file ${d}/${m} "${a}" (${l}, ${il(c)})`);else if(I.error instanceof bc)throw I.error;if(!S){var O;const e=null!=(O=function(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if("string"!=typeof n)continue;const e=n.trim();e&&!t.includes(e)&&t.push(e)}return t.length?t.join("; "):null}($))?O:E,n=function(e,t,n){const o="string"==typeof t?t.trim():"",i="number"==typeof n&&n>1?` after ${n} attempts`:"";return o?`Failed to upload file ${e}${i}: ${o.length>Al?o.slice(0,Al)+"…":o}`:`Failed to upload file ${e}${i}`}(a,e,T);throw console.error(n),await wc({identifier:t,status:"failed",status_message:Rl(n),error:"Failed to upload file "+a},h),new Error(n)}return!0}async function Fl(e,t,n){const o=e.baseUrl+ft.jobs.presigned_url,i=await fetch(o,{...gt,method:"POST",headers:{...ht(e),job_id:t},body:JSON.stringify(n)}).catch(e=>(console.error(e),null));return i&&i.ok?await i.text():(console.error("Failed to get presigned download URL",null==i?void 0:i.status),null)}async function Dl(e,t){const n=e.baseUrl+ft.jobs.create,o={...ht(e),"content-type":"application/json"},i={type:"ai-material",triggered_by:e.trigger_type,parameters:{...t}},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();return console.error(`Failed to request texture generation (${a.status}): ${e}`),{error:e||`Request failed (${a.status})`}}return await a.json().catch(e=>(console.error(e),null))}async function ql(e,t={}){const n=new URL(e.baseUrl+ft.content.root);t.content_type&&n.searchParams.set("content_type",t.content_type),t.content_format&&n.searchParams.set("content_format",t.content_format),t.search&&n.searchParams.set("search",t.search),t.tags&&n.searchParams.set("tags",t.tags),t.types&&n.searchParams.set("types",t.types),t.trash&&n.searchParams.set("trash","true"),t.is_public&&n.searchParams.set("is_public","true"),t.page&&n.searchParams.set("page",String(t.page)),t.limit&&n.searchParams.set("limit",String(t.limit)),t.collection_id&&n.searchParams.set("collection_id",t.collection_id),t.offset&&n.searchParams.set("offset",String(t.offset));const o=ht(e),i=await fetch(n,{...gt,method:"GET",headers:o});if(!i.ok){const e=await i.text();throw new Error(`Failed to list content (${i.status}): ${e}`)}return await i.json()}async function Bl(e,t){const n=`${e.baseUrl}${ft.content.root}/${t}`,o=ht(e),i=await fetch(n,{...gt,method:"GET",headers:o});if(!i.ok){const e=await i.text();throw new Error(`Failed to get content (${i.status}): ${e}`)}return await i.json()}async function Ml(e,t){const n=`${e.baseUrl}${ft.content.root}/${t}`,o=ht(e),i=await fetch(n,{...gt,method:"DELETE",headers:o});if(!i.ok){const e=await i.text();throw new Error(`Failed to delete content (${i.status}): ${e}`)}return await i.json()}const Wl={schema:{name:"load_needle_engine_skill",description:'Load the Needle Engine skill: authoritative coding guidelines, component patterns, the Unity/Blender-to-web export workflow, and reference docs. Load this BEFORE answering ANY Needle Engine coding or workflow question — do NOT answer from prior knowledge, which is frequently wrong about how Needle actually works (for example: the relationship between Unity C# scripts and TypeScript components, and what the editor export does — Needle does NOT auto-convert C# logic to TypeScript). ALWAYS load first when the user: shares or asks about Unity C# code (a MonoBehaviour, the Needle.Engine.* namespace) or Blender scripts in a Needle context; asks how a Unity or Blender component maps to, converts to, ports to, or works in Needle Engine or TypeScript; asks about components, lifecycle, serialization, XR, networking, deployment, or the export/codegen pipeline; or reports a Needle Engine bug or error. Do NOT load for greetings or small talk that contains no technical question — wait for the actual question first. Without arguments loads the main skill file. Use the "file" parameter to load specific reference files (e.g. "references/api.md", "references/components.md"). Call without arguments first to discover available references.',inputSchema:{type:"object",properties:{file:{type:"string",description:'File to load relative to the skill root, e.g. "references/api.md". Defaults to the main skill file.'}},additionalProperties:!1,required:[]}},async execute(e){const t=(null==e?void 0:e.file)||"SKILL.md";if(t.includes("..")||t.startsWith("/"))return{error:"Invalid file path."};try{const e="https://raw.githubusercontent.com/needle-tools/ai/main/providers/claude/plugin/skills/needle-engine/"+encodeURI(t),n=new AbortController,o=setTimeout(()=>n.abort(),5e3),i=await fetch(e,{signal:n.signal,redirect:"follow"});return clearTimeout(o),i.ok?{content:await i.text()}:{error:`Could not fetch '${t}' (HTTP ${i.status})`}}catch(e){return{error:`Error fetching skill: ${e.message}`}}}};function Hl(e){let t,n=null,o="";for(const i of e.split("\n"))i.startsWith("event: ")?n=i.slice(7).trim():i.startsWith("data: ")?o=i.slice(6):i.startsWith("id: ")&&(t=parseInt(i.slice(4).trim(),10));if(!n)return null;let i=null;switch(n){case"delta":i={type:"delta",content:decodeURIComponent(o)};break;case"message":i={type:"message",content:decodeURIComponent(o)};break;case"status":i={type:"status",message:decodeURIComponent(o)};break;case"error":i={type:"error",message:decodeURIComponent(o)};break;case"notice":i={type:"notice",message:decodeURIComponent(o)};break;case"stopped":i={type:"stopped"};break;case"tool_call":i={type:"tool_call",...JSON.parse(o)};break;case"tool_result":i={type:"tool_result",...JSON.parse(o)};break;case"file_change":i={type:"file_change",...JSON.parse(o)};break;case"local_preview":i={type:"local_preview",...JSON.parse(o)};break;case"message_inserted":i={type:"message_inserted",...JSON.parse(o)};break;case"elicitation":i={type:"elicitation",...JSON.parse(o)};break;case"done":{const e=JSON.parse(o),{chat_url:t,...n}=e;i={type:"done",token_usage:n},t&&(i.chat_url=t);break}case"message_id":i={type:"message_id",message_id:decodeURIComponent(o)};break;case"chat_id":i={type:"chat_id",chat_id:decodeURIComponent(o)}}return i&&void 0!==t&&(i.id=t),i}function Gl(e,t){const n=ht(e);return null!=t&&t.personal&&(n["x-needle-ai-chat"]="personal"),null!=t&&t.instanceId&&(n["x-needle-instance-id"]=t.instanceId),n}function Jl(e,t){return t.stream?async function*(e,t){const n=new URL(e.baseUrl+ft.ai.chat),o=Gl(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!0,source:t.source,allow_file_edits:!0===t.allowFileEdits,file_edit_session_id:!0===t.allowFileEdits?t.fileEditSessionId:void 0,allow_local_commands:!0===t.allowLocalCommands,local_command_session_id:!0===t.allowLocalCommands?t.localCommandSessionId:void 0,full_url:t.full_url,pathname:t.pathname,context:t.context,disabled_tools:t.disabled_tools},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();throw new Error(`Failed to stream chat message (${a.status}): ${e}`)}if(!a.body)throw new Error("Response body is null — streaming not supported in this environment");yield*async function*(e){const t=e.getReader(),n=new TextDecoder;let o="";try{for(;;){const{done:e,value:i}=await t.read();if(e)break;o+=n.decode(i,{stream:!0});const a=o.split("\n\n");o=a.pop()||"";for(const e of a){const t=Hl(e);t&&(yield t)}}if(o.trim()){const e=Hl(o);e&&(yield e)}}finally{t.releaseLock()}}(a.body)}(e,t):async function(e,t){const n=new URL(e.baseUrl+ft.ai.chat),o=Gl(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!1,source:t.source,allow_file_edits:!0===t.allowFileEdits,file_edit_session_id:!0===t.allowFileEdits?t.fileEditSessionId:void 0,allow_local_commands:!0===t.allowLocalCommands,local_command_session_id:!0===t.allowLocalCommands?t.localCommandSessionId:void 0,full_url:t.full_url,pathname:t.pathname,context:t.context,disabled_tools:t.disabled_tools},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();throw new Error(`Failed to send chat message (${a.status}): ${e}`)}return await a.json()}(e,t)}const Vl=200,Kl=["github.com","gitlab.com","bitbucket.org"],Yl=/[\w.+-]+@[\w-]+\.[\w.]+/;function Zl(e){if(e)return Yl.test(e)?void 0:e}function Xl(e,t){return String(b("git",e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],...t?{cwd:t}:{}})||"").trim()}function Ql(e,t){try{return Xl(e,t)}catch{return""}}function ep(e){try{const t=Xl(["rev-parse","HEAD"],e);if(!t)return null;const n=Ql(["rev-parse","--abbrev-ref","HEAD"],e),o=Ql(["log","-1","--pretty=%s"],e),i=Zl(Ql(["log","-1","--pretty=%an"],e)),a=Ql(["status","--porcelain"],e).length>0,r=Ql(["remote","get-url","origin"],e),s=t.slice(0,7),{repository:c,url:l}=function(e,t){if(!e)return{};const n=/^(?:https?:\/\/(?:[^@/]+@)?([^/]+)\/|git@([^:]+):)(.+?)(?:\.git)?$/.exec(e.trim());if(!n)return{};const o=(n[1]||n[2]||"").toLowerCase(),i=n[3];return i?Kl.includes(o)?{repository:i,url:`https://${o}/${i}/${"bitbucket.org"===o?"commits":"commit"}/${t}`}:{repository:i}:{}}(r,t),p={type:"git",id:t,label:`${n||s}@${s}${a?" (dirty)":""}`};return n&&(p.branch=n),i&&(p.author=i),o&&(p.message=o.slice(0,Vl)),a&&(p.dirty=!0),c&&(p.repository=c),l&&(p.url=l),p}catch{return null}}function tp(e){if("string"==typeof e)return e.trim()||void 0}const np="https://cloud.needle.tools/api",op=()=>"https://cloud.needle.tools/account",ip=()=>"https://cloud.needle.tools/edit";function ap(e){return x(e)}const rp=["node_modules",".git",".vscode",".vercel",".github",".idea"];function sp(e,t,n=null,o="",i=0){if(null===n){if(i>0)throw new Error("result must be provided if level > 0. Did you forget to pass it?");n={files:[],total_size:0}}if(0===i){if(!c(t))throw new Error(`Directory or file "${t}" does not exist.`);if(l(t).isFile()){const e=Zc(t,p(t));return e.path=e.name,n.files.push(e),n.entrypoint=e,n}}else if(i>20)throw new Error("Recursion depth too high. Are you sure you are providing the correct directory?");const a=u(t,{withFileTypes:!0});for(const i of a)if(0==i.isDirectory()){if("optimization"===e&&0==((r=(r=i.name).toLowerCase()).endsWith(".glb")||r.endsWith(".gltf")||r.endsWith(".vrm")||r.endsWith(".usdz")||r.endsWith(".usd")||r.endsWith(".fbx")))continue;const a=Zc(o+i.name,p(t+"/"+i.name));if(n.files.push(a),n.total_size+=a.size,n.total_size>1073741824)throw new Error(`Collected filesize exceeds ${1024..toFixed(0)} MB. Are you sure you are providing the correct directory?`);if(n.files.length>1e4)throw new Error(`Too many files (${n.files.length}): The maximum filecount is 10,000.`)}var r;for(const r of a)if(r.isDirectory()){if(rp.includes(r.name))continue;sp(e,t+"/"+r.name,n,o+r.name+"/",i+1)}return n}const cp=new RegExp("\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g"),lp=new RegExp("\\b[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\\b","gi"),pp=new RegExp("(Authorization:\\s*)([^\\s,;\"']+(?:\\s+[^\\s,;\"']+)?)","gi"),up=new RegExp("\\bBearer\\s+([A-Za-z0-9._\\-=]+)","g"),dp=new RegExp("([?&]token=)([^&\\s\"'<>]+)","g"),mp=new RegExp("<redacted:\\d+ch>","g");function fp(e){if("string"!=typeof e)return e;if(0===e.length)return e;if(mp.test(e)&&(mp.lastIndex=0,!function(e){cp.lastIndex=0,lp.lastIndex=0,pp.lastIndex=0,up.lastIndex=0,dp.lastIndex=0;const t=cp.test(e)||lp.test(e)||pp.test(e)||up.test(e)||dp.test(e);return cp.lastIndex=0,lp.lastIndex=0,pp.lastIndex=0,up.lastIndex=0,dp.lastIndex=0,t}(e.replace(mp,""))))return e;mp.lastIndex=0;let t=e;return t=t.replace(pp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(dp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(up,(e,t)=>`<redacted:${("Bearer "+t).length}ch>`),t=t.replace(cp,e=>`<redacted:${e.length}ch>`),t=t.replace(lp,e=>`<redacted:${e.length}ch>`),t}const hp=["cli.log","cli.prev.log"],gp=ie.join(te.homedir(),".needle","cli","logs");I(gp,{recursive:!0});try{!function(e,t){const n={migrated:[],skipped:[]};if(!e||!t)return n;if(ie.resolve(e)===ie.resolve(t))return n;if(!T(e))return n;for(const o of hp){const i=ie.join(e,o);if(T(i))try{I(t,{recursive:!0});const e=ie.join(t,o);if(T(e)){const e=ie.join(t,o.replace(/\.log$/,"")+".legacy.log");O(i,e),n.skipped.push(o)}else O(i,e),n.migrated.push(o)}catch(e){console.error(`[needle-cloud] Failed to migrate legacy log ${o}: ${e instanceof Error?e.message:e}`)}}}(ie.join(A(te.tmpdir()),"Needle","Cloud","logs"),gp)}catch(e){console.error(`[needle-cloud] legacy log migration check failed: ${e instanceof Error?e.message:e}`)}const vp=ie.resolve(gp,"cli.log");if(T(vp)){const e=C(vp),t=e.mtimeMs;if(Date.now()-t>432e5||e.size>52428800){const e=xp();R(vp,e,t=>{t?console.error(`Failed to rename log file: ${t.message}`):console.log(`Log file renamed to ${e}`)})}}function bp(){return vp}function xp(){return ie.resolve(gp,"cli.prev.log")}function yp(e,t){try{let n=fp(String(null!=e?e:""));return n=`[${(new Date).toISOString()}] ${n}`,null!=t&&t.emptyLineBefore&&(n="\n"+n),N(vp,n+"\n"),!0}catch(e){return console.error(`Failed to write to log file: ${e instanceof Error?e.message:e}`),!1}}async function wp(e,t){return e=fp(e),e=`[${(new Date).toISOString()}] ${e}`,null!=t&&t.emptyLineBefore&&(e="\n"+e),J(vp,e+"\n",{flag:"a"}).then(()=>!0).catch(e=>(console.error(`Failed to write to log file: ${e.message}`),!1))}var _p={__proto__:null,getLogFilePath:bp,getPrevLogsFilePath:xp,getPipelineLogFilePath:function(){return ie.join(te.homedir(),".needle","optimization-pipeline","logs","pipeline.log")},writeToLogFileSync:yp,writeToLogFile:wp};function jp(e,t,n){process.env.GITHUB_ACTIONS&&(process.env.GITHUB_OUTPUT?d(process.env.GITHUB_OUTPUT,`${e}=${t}\n`):null==n||n.logger.warn("GITHUB_OUTPUT environment variable is not set. Cannot set output variables."))}async function kp(e){var t;e.directory=y.resolve(e.directory);let{files:n,entrypoint:o}=sp("deployment",e.directory);if(e.entrypoint&&(o=n.find(t=>t.path===e.entrypoint),!o))return process.exitCode=1,void $().fail(`Entrypoint "${e.entrypoint}" not found. Please make sure you provide a valid entrypoint.`);if(!o){const e=hl(n);if("error"in e)return process.exitCode=1,wp(`[Deployment] Error determining entrypoint: ${e.error}`),void $().fail(`Error: ${e.error}`);o=e}if(!(n.length>0&&o&&(o.name.toLowerCase().endsWith(".html")||o.name.toLowerCase().endsWith(".html.gz")||o.name.toLowerCase().endsWith(".html.br"))))return process.exitCode=1,wp("[Deployment] Deployment is not valid: No .html file found."),void $().fail("Deployment is not valid: No .html file found.");if(!o)return process.exitCode=1,wp("[Deployment] No entrypoint found. Please provide an index.html file in your project."),void $().fail("No entrypoint found. Please provide an index.html file in your project.");const i=null!=(t=e.endpoint)&&t.length?e.endpoint:"https://cloud.needle.tools/api";let a=e.name;a||(a=Sp(e.directory)||void 0);let r=null==i?void 0:i.includes("localhost");const s=a?` of "${a}"`:"",c=$().start(`Begin deployment${s} ${r?"(local)":""} of ${n.length} files...`);c.spinner="earth",await ul(50);let l=-1,p=null;const u=e.noProvenance?null:function(e=process.env,t,n){try{return function(e=process.env,t){try{if(tp(e.NEEDLE_CLOUD_NO_PROVENANCE))return null;let n=ep(t);tp(e.GITHUB_ACTIONS)&&(n=function(e,t){var n,o;const i=tp(t.GITHUB_SHA),a=tp(t.GITHUB_REF_NAME),r=tp(t.GITHUB_REPOSITORY),s=null!=(n=tp(t.GITHUB_SERVER_URL))?n:"https://github.com";if(!i&&!a)return e;const c={type:"git",...null!=e?e:{}};i&&(c.id=i),a&&(c.branch=a),r&&(c.repository=r),r&&i&&(c.url=`${s}/${r}/commit/${i}`);const l=String(null!=(o=c.id)?o:"").slice(0,7);return l&&(c.label=`${a||l}@${l}${c.dirty?" (dirty)":""}`),c}(n,e));const o=function(e=process.env){var t;if(!tp(e.CI))return{type:"local"};if(!tp(e.GITHUB_ACTIONS))return{type:"ci"};const n={type:"github-actions"},o=tp(e.GITHUB_RUN_ID),i=tp(e.GITHUB_REPOSITORY),a=null!=(t=tp(e.GITHUB_SERVER_URL))?t:"https://github.com";o&&(n.id=o);const r=Zl(tp(e.GITHUB_ACTOR));return r&&(n.actor=r),tp(e.GITHUB_EVENT_NAME)&&(n.event=tp(e.GITHUB_EVENT_NAME)),o&&i&&(n.url=`${a}/${i}/actions/runs/${o}`),n}(e);return n||"local"!==o.type?{...n?{source:n}:{},runner:o,client:{name:"needle-cloud-cli"}}:null}catch(e){var n;return console.warn(`[provenance] Could not determine provenance: ${null!=(n=null==e?void 0:e.message)?n:e}`),null}}(e,t&&ep(t)?t:n)}catch(e){var o;return console.warn(`[provenance] Could not determine provenance: ${null!=(o=null==e?void 0:e.message)?o:e}`),null}}(process.env,e.directory);if(null!=u&&u.source){var d;const{label:e,author:t}=u.source;wp(`[provenance] ${e}${t?` by ${t}`:""} (${null==(d=u.runner)?void 0:d.type})`)}wp(`Deployment started${s} ${r?"(local)":""} of ${n.length} files...`);const m=await El({baseUrl:i,authToken:e.token,org:e.org_id},{triggered_by:"cli",files:n,entrypoint:o,experimental:e.experimental,raw:e.raw,...u?{metadata:u}:{}},{name:a,type:"deployment",loglevel:e.verbose?"debug":"none",progress:e=>{if(e.fileIndex!==l){l=e.fileIndex;const t=e.totalBytes/1024/1024;c.text=`Uploading file ${e.fileIndex+1} of ${e.totalFiles} files: ${(e.uploadedBytes/1024/1024).toFixed(1)} / ${t.toFixed(1)} MB. Total progress: ${(100*e.progress01).toFixed(1)} %. Time passed: ${e.elapsedTime.toFixed(0)}sec. About ${e.estimatedTimeLeftDisplay} until complete.`}}}).catch(e=>(p=e instanceof Error?e.message:String(e),null));if(null!=m&&!0===m.success){c.succeed(`🚀 Deployment${s} successful (${m.content_id}/${m.id})`);let t="";t=m.url?m.url:"https://cloud.needle.tools/view/"+m.content_id+"/"+m.id,console.log("🔗 View the deployment at: "+t),e.open&&ap(t);try{jp("deployment_url",t,{logger:e.logger}),jp("edit_id",m.content_id,{logger:e.logger})}catch(t){e.logger.error("Error writing output for CI: "+t)}}else{process.exitCode=1;const e=p||(null==m?void 0:m.error)||"Deployment failed";wp(`[Deployment] Failed: ${e}`),c.fail(e)}}function Sp(e,t=0){if(t>10)return null;const n=y.join(e,"needle.config.json");if(c(n)){const t=y.join(e,"package.json");if(c(t)){var o;const e=p(t,"utf8"),n=JSON.parse(e);if(null!=(o=n.name)&&o.length)return n.name}return y.basename(e)}const i=y.dirname(e);return i===e?null:Sp(i,t+1)}const Ep={getContent:Bl,updateContentLabel:async function(e,t={}){const n={...ht(e),content_id:e.content_id,job_id:e.job_id,type:e.type,action:e.action};try{const t=await fetch(`${e.baseUrl}${ft.view.post_version}`,{...gt,method:"POST",headers:n});if(!t.ok){const e=await t.text();throw new mt(t.status,e,`Failed to update label (${t.status}): ${e}`)}return console.log(`Updated ${e.job_id} to ${e.type}`),!0}catch(n){if(t.throwOnError)throw n;return console.error("Failed to update label",e.job_id,n),!1}}};function $p(e){if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new Error("Invalid content identifier; use the item ID shown by list or upload.")}function Tp(e){if($p(e.contentId),!/^[a-z0-9][a-z0-9_-]*$/.test(e.label))throw new Error("Label names must use lowercase letters, numbers, hyphens or underscores.");if("latest"===e.label)throw new Error("latest is managed automatically; choose another destination label.");if(void 0!==e.versionId==(void 0!==e.from))throw new Error("Provide exactly one of --version or --from.");if(""===e.versionId||""===e.from)throw new Error("--version and --from require a nonempty value.")}function Ip(e,t){if(e.identifier!==t)throw new Error("The returned content does not match the requested content item.")}function Op(e){const t=new Map;for(const n of e.versions)for(const e of[n,...n.variants])for(const o of e.labels){let i=t.get(o.label);i||(i={label:o.label,sourceVersionIds:[],targets:[]},t.set(o.label,i)),i.sourceVersionIds.includes(n.identifier)||i.sourceVersionIds.push(n.identifier),i.targets.push({...o,versionId:e.identifier,sourceVersionId:n.identifier})}return{contentId:e.identifier,labels:[...t.values()].sort((e,t)=>e.label.localeCompare(t.label))}}async function Ap(e,t,n=Ep){$p(t);const o=await n.getContent(e,t);return Ip(o,t),Op(o)}async function Cp(e,t,n=Ep){var o,i;Tp(t);const a=await n.getContent(e,t.contentId);Ip(a,t.contentId);const r=Op(a);let s=t.versionId;if(t.from){const e=r.labels.find(e=>e.label===t.from);if(!e)throw new Error(`Source label '${t.from}' was not found.`);if(1!==e.sourceVersionIds.length)throw new Error(`Source label '${t.from}' is ambiguous; use --version.`);s=e.sourceVersionIds[0]}const c=a.versions.find(e=>e.identifier===s||e.variants.some(e=>e.identifier===s)),l=(null==c?void 0:c.identifier)===s?c:null==c?void 0:c.variants.find(e=>e.identifier===s);if(!l)throw new Error(`Version '${s}' was not found in this content item.`);if("completed"!==l.status)throw new Error("The selected version must have completed processing before assigning a label.");if(!await n.updateContentLabel({...e,content_id:t.contentId,job_id:l.identifier,type:t.label,action:"add_label"},{throwOnError:!0}))throw new Error("Label update failed.");let p;try{p=await Ap(e,t.contentId,n)}catch(e){throw new Error(`Label update was accepted, but verification failed: ${e instanceof Error?e.message:String(e)}`,{cause:e})}const u=p.labels.find(e=>e.label===t.label);if(null==u||!u.targets.some(e=>e.versionId===s))throw new Error("Label update was accepted, but the selected target could not be confirmed. Check the current label before retrying.");return{contentId:t.contentId,label:t.label,versionId:l.identifier,previousVersionIds:null!=(o=null==(i=r.labels.find(e=>e.label===t.label))?void 0:i.sourceVersionIds)?o:[],targets:u.targets}}const Rp=/token|secret|password|authorization|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret/i;function Np(e,t){return async function(n){const o=function(e,t){const n=[];if(e&&Object.keys(e).length>0&&n.push(`args=${Pp(e)}`),t&&Object.keys(t).length>0){const e=Object.fromEntries(Object.entries(t).map(([e,t])=>Rp.test(e)?[e,"<redacted>"]:[e,t]));n.push(`options=${Pp(e)}`)}return n.join(" ")}(null==n?void 0:n.args,null==n?void 0:n.options);wp(`CLI action: ${e}${o?" "+o:""}`);const i=Date.now();try{const o=await t(n);return wp(`CLI action: ${e} succeeded in ${Date.now()-i}ms`),o}catch(t){const n=t instanceof Error?t.message:String(t);throw yp(`CLI action: ${e} failed in ${Date.now()-i}ms: ${n}`),t}}}function Pp(e){try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():"function"==typeof t?"<fn>":t)}catch{return"<unserializable>"}}function Up(e,t){for(const o of e){var n;t(` ${o.displayName} (${o.versionId===o.sourceVersionId?"source":"derived"}, ${o.versionId}): ${null!=(n=o.url)?n:"URL unavailable"}\n`)}}async function Lp(e){if(!e.outDir)throw new Error("Output directory is required");const t=$("Downloading results...").start(),n=await async function(e){const t=await async function(e){if(!e.identifier)return null;const t={...ht(e)},n={job_id:e.identifier,fields:e.fields,content_format:e.content_format},o=e.baseUrl+ft.jobs.query,i=await fetch(o,{...gt,method:"POST",headers:t,body:JSON.stringify(n)}).catch(e=>(console.error(e),null));if(null==i)return null;if(!i.ok)return console.error("Failed to get job",i.status,await i.text()),null;const a=await i.json().catch(e=>(console.error(e),null));return null==a?null:a.job}({baseUrl:e.baseUrl,authToken:e.authToken,org:e.org,identifier:e.identifier,fields:["results"],content_format:e.content_format});if(null==t||!t.results)return{error:`Job ${e.identifier} did not produce any result files`};const n=t.results;if(!n.bucket||!n.directory)return{error:`Job ${e.identifier} has incomplete result data`};const o=[];for(const t of n.files){if((i=t.filename).startsWith(".extras/")||i.startsWith(".extras\\")||i.endsWith(xc)||yc.test(i)||i.endsWith(".needle.log"))continue;const a=`${n.directory}/${t.filename}`,r=await Fl(e,e.identifier,{bucket:n.bucket,key:a});if(!r){console.error(`Failed to get presigned URL for: ${t.filename}`);continue}const s=await fetch(r).catch(e=>(console.error(e),null));if(!s||!s.ok){console.error(`Failed to download (${null==s?void 0:s.status} | ${null==s?void 0:s.statusText}): ${t.filename}`);continue}const c=await s.arrayBuffer().catch(e=>(console.error(e),null));if(!c)return{error:`Failed to read downloaded file: ${t.filename}`};o.push({filename:t.filename,data:c})}var i;return{files:o}}({baseUrl:e.baseUrl,authToken:e.authToken,org:e.org,identifier:e.identifier,content_format:e.content_format});if("error"in n)return t.fail(n.error),{error:n.error};const o=[];for(const i of n.files){t.text=`Downloading ${i.filename}`,c(e.outDir)||m(e.outDir,{recursive:!0});let a=i.filename;if(e.filename){const t=i.filename.substring(i.filename.lastIndexOf("."));if(1===n.files.length)a=e.filename.includes(".")?e.filename:e.filename+t;else{const t=i.filename.substring(i.filename.lastIndexOf(".")),n=i.filename.substring(0,i.filename.lastIndexOf("."));a=e.filename+"-"+n+t}}const r=e.outDir+"/"+a,s=r.split("/").slice(0,-1).join("/");c(s)||m(s,{recursive:!0}),e.verbose&&console.log(`Writing ${i.filename} (${(i.data.byteLength/1024).toFixed(2)} KB) to "${r}"`),f(r,Buffer.from(i.data)),o.push(r)}return t.succeed(`Downloaded ${o.length} ${1===o.length?"file":"files"}: ${o.join(", ")}`),e.verbose&&console.log("Downloaded files:\n",o),{success:!0,paths:o}}async function zp(e){var t;if(e.wait&&e.noOptimize)return{error:"--wait cannot be combined with --no-optimize."};if(e.outDir&&!e.wait)return{error:"--outdir requires --wait."};if(e.outDir&&c(e.outDir)&&l(e.outDir).isFile())return{error:"The output directory is a file - it must be a directory"};if(""===e.outDir)return{error:"Output Directory is invalid"};if(e.format&&!["cli","json","source-url","edit-url"].includes(e.format))return{error:"Invalid output format."};if(e.usecase&&!["product","world"].includes(e.usecase))return{error:"Use case must be product or world."};const n=await async function(e,t={}){const n=t.purposeLabel?` ${t.purposeLabel}`:"";if(!c(e.fileOrDirectory))return $().fail(`File not found: ${e.fileOrDirectory}`),{error:"File not found"};if(!e.token||e.token.length<=1||"string"!=typeof e.token||"true"===e.token)return{error:`Missing access token. Create a token at ${op()}`};if(void 0!==e.name&&e.name&&(e.name.length<=0||"true"===e.name||"false"===e.name))return{error:`Name is not valid: "${e.name}". Please provide a valid name`};e.fileOrDirectory=w(e.fileOrDirectory);const o=$(`Gathering files ${e.fileOrDirectory}`).start();let i=null;try{i=sp("optimization",e.fileOrDirectory)}catch(t){return $().fail(t instanceof Error?t.message:`Failed to collect files in ${e.fileOrDirectory}`),{error:"Failed to collect files"}}if(!i.files.length)return o.fail("No supported files found."),{error:"No supported files found."};if(t.singleFile&&1!==i.files.length)return o.fail("source-url requires one file; use --format json for multiple files."),{error:"source-url requires one file; use --format json for multiple files."};const a=i.files.map(e=>e.path||e.name);o.text=`Uploading ${i.files.length} files${n}:\n- ${i.files.map(e=>e.path||e.name).join("\n -")}`;const r="https://cloud.needle.tools/api";e.verbose&&console.log("Using endpoint:",r);const s=function(e){var t,n;if(function(e){return e.some(e=>{let t=e.name.toLowerCase();return!!(t.endsWith(".html")||t.endsWith(".htm")||t.endsWith(".html.gz")||t.endsWith(".html.br"))||"mimetype"in e&&"text/html"===e.mimetype})}(e))return{kind:"deployment",contentType:void 0,uploadType:"deployment",canOptimize:!1,canConvertToGLB:!1};if(function(e){if(null==e||!e.length)return!1;const t=e.filter(e=>el(e.name)||tl(e.name)||nl(e.name));return 1===t.length&&hl(e)===t[0]}(e))return{kind:"environment-texture",contentType:"hdri",uploadType:void 0,canOptimize:!1,canConvertToGLB:!1};const o=null!=(t=null==(n=e[0])||null==(n=n.name.split(".").pop())?void 0:n.toLowerCase())?t:"";return{kind:"asset",contentType:"3d-asset",uploadType:void 0,canOptimize:e.some(e=>{var t;const n=null==(t=e.name.split(".").pop())?void 0:t.toLowerCase();return null!=n&&gl.has(n)}),canConvertToGLB:vl.has(o)}}(i.files),l="asset"===s.kind||"deployment"===s.contentType?void 0:s.contentType,p=await El({baseUrl:r,authToken:e.token,org:e.org_id},{triggered_by:"cli",files:i.files,entrypoint:i.entrypoint},{type:s.uploadType||"upload",name:e.name,content_type:l,...!1===t.optimizations?{optimizations:!1}:{},loglevel:e.verbose?"debug":"none",progress:e=>{o.text=`Uploading ${e.fileName} - finished in approx. ${e.estimatedTimeLeftDisplay}, ${100*e.progress01}%`}});if(0==p.success){const e=`${p.error||"Unknown error: could not start upload"}`;return o.fail(e),{error:e,noprint:!0}}const u=p.edit_url||`${ip()}/${p.content_id}?select_team=1`;return o.succeed(p.uploadSkipped?`Files have already been uploaded to ${u}`:`Uploaded ${i.files.length} files${n} to ${u}`),{res:p,editUrl:u,paths:a}}(e,{optimizations:!e.noOptimize&&void 0,purposeLabel:e.wait?"for optimization":void 0,singleFile:"source-url"===e.format});if("error"in n)return n;const{res:o,editUrl:i,paths:a}=n,r=a.map(e=>({path:e,sourceUrl:bt({baseUrl:"https://cloud.needle.tools/api",content_id:o.content_id,job_id:o.id})+e.split("/").map(encodeURIComponent).join("/")})),s={success:!0,assetId:o.content_id,versionId:o.id,editUrl:i,sourceUrl:1===r.length?r[0].sourceUrl:null,files:r,optimizedUrl:null,processingStatus:e.noOptimize?"not_requested":"unknown"};if(e.noOptimize&&$().info("No processing jobs were scheduled by this command (--no-optimize)."),!e.wait)return s;const p=function(e){return e.progressive?{progressive:!0,usecase:e.usecase||"product"}:{progressive:!1}}({progressive:null==(t=e.progressive)||t,usecase:e.usecase}),u=await async function(e,t={progressive:!0}){const n=e.baseUrl+ft.jobs.create,o={...ht(e),"content-type":"application/json"},i={type:"optimization",job_id:e.id,triggered_by:e.trigger_type,parameters:{...t}},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();return console.error(`Failed to request optimization (${a.status}): ${e} `),null}return await a.json().catch(e=>(console.error(e),null))}({baseUrl:"https://cloud.needle.tools/api",authToken:e.token,org:e.org_id,id:o.id,trigger_type:"cli"},p);if(!u)return{error:"Failed to send optimization request"};if("error"in u)return{error:`Failed to optimize: ${u.error}`};const d=u.job,m=$(`Optimization requested for ${d.name||d.identifier}`).start(),f=jc();let h=d.status;for(;"completed"!==h;){if("failed"===h||"canceled"===h){const e=d.error||`Optimization ${h}`;return m.fail(e),{error:e}}const t=await _c(d.identifier,{baseUrl:"https://cloud.needle.tools/api",authToken:e.token,org:d.org}),n=f.record(t);if(n)return m.fail(n.reason),{error:n.reason};if("failed"in t)await ul(2e3);else{if(h=t.status,"failed"===h||"canceled"===h){const e=t.error||`Optimization ${h}`;return m.fail(e),{error:e}}"completed"!==h&&(m.text=t.status_message||("running"===h?"Your asset is being optimized":"Waiting for optimization"),await ul("running"===h?1e3:"stalled"===h?2500:2e3))}}if(m.succeed("Optimization completed"),s.processingStatus="completed",s.optimizedUrl=bt({baseUrl:"https://cloud.needle.tools/api",content_id:o.content_id,job_id:d.identifier}),s.optimization={versionId:d.identifier,progressive:p.progressive,...p.usecase?{usecase:p.usecase}:{}},e.outDir){const t=await Lp({baseUrl:"https://cloud.needle.tools/api",authToken:e.token,org:e.org_id,identifier:d.identifier,outDir:e.outDir,verbose:e.verbose});if("error"in t)return t}return s}function Fp(e,t,n){if("error"in e)throw new Error(e.error);if("source-url"===t){if(!e.sourceUrl)throw new Error("source-url requires one file; use --format json for multiple files.");n(e.sourceUrl+"\n")}else if("edit-url"===t)n(e.editUrl+"\n");else if("json"===t){const{success:t,...o}=e;n(JSON.stringify(o)+"\n")}else{var o;n(`Edit: ${e.editUrl}\n`);for(const t of e.files)n(`Source (${t.path}): ${t.sourceUrl}\n`);e.optimizedUrl&&n(`Optimized (${null!=(o=e.optimization)&&o.progressive?"progressive-"+e.optimization.usecase:"non-progressive"}): ${e.optimizedUrl}\n`)}}async function Dp(e){const{token:t,org_id:n,slug:o,message:i,stream:a}=e;if(a){const e=Jl({baseUrl:"https://cloud.needle.tools/api",authToken:t,org:n},{slug:o,message:i,stream:!0,source:"cli"});for await(const t of e)switch(t.type){case"delta":process.stdout.write(t.content);break;case"message":break;case"status":process.stdout.write(`[${t.message}]\n`);break;case"error":return void $().fail(t.message);case"tool_call":process.stdout.write(`[tool: ${t.name}]\n`);break;case"done":process.stdout.write("\n")}}else{const e=$("Thinking...").start(),a=await Jl({baseUrl:"https://cloud.needle.tools/api",authToken:t,org:n},{slug:o,message:i,stream:!1,source:"cli"});e.stop(),console.log(a.content)}}async function qp(e,t=Ml){if(!e.identifier)throw new Error("A content identifier is required");return t({baseUrl:e.endpoint,authToken:e.authToken,org:e.org},e.identifier)}async function Bp(e){const t=new URL((e.endpoint||"https://cloud.needle.tools/api")+ft.get.deployments);t.searchParams.append("offset",e.offset.toString()),t.searchParams.append("limit",e.limit.toString()),e.names&&t.searchParams.append("name",e.names.map(e=>e.trim()).join(","));const n=await fetch(t,{method:"GET",headers:{...ht({authToken:e.authToken,org:e.org})}});return n.ok?await n.json():{status:n.status,error:await n.text()}}const Mp=["#e06c75","#d19a66","#e5c07b","#98c379","#7ec8a4","#56b6c2","#61afef","#528bff","#c678dd","#e88de4","#be5046","#d4976c","#b5cea8","#4ec9b0","#9cdcfe","#c8ae9d"];function Wp(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;const[n,o,i]=function(e){const t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,255&t]}(Mp[Math.abs(t)%Mp.length]);return`[38;2;${n};${o};${i}m${e}[0m`}function Hp(e){return`[2m${e}[0m`}const Gp=8424,Jp="http://localhost:8424",Vp=/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]\s?(.*)$/,Kp=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}):\s*(.*)$/,Yp=[[/^\[MCP\]|^MCP (New session|websocket server|Request|SSE|Bridge)|^Unknown MCP/,"mcp"],[/^Needle Cloud connection:|^Cloud tool (request|result|error):/,"cloud"],[/^Denied:/,"denial"],[/^Local (server|token)|^Starting Needle CLI server|^Restarting auth server|^Server is running|^Running server uses different/,"server"],[/^OIDC:|^Sign in|^Sign out|^User logged in|^Logged in successfully|^Token refresh failed|^Failed to validate (login|logout)|^Getting access token|^No access token|^ERR: Missing NEEDLE_CLOUD_TOKEN|^Too many logins|^WARN: You do not have a default organization|^User signed in|^Error during sign in/,"auth"],[/^Settings(:| changed)/,"settings"],[/^\[Deployment\]|^Deployment started/,"deployment"],[/^\[generate-material\]/,"ai"],[/^Active project changed|^Error saving project info/,"project"]],Zp=[[/^ERR:|^ERROR:|^Error\b|^Failed\b/,"error"],[/\bconnection: error\b|\bFailed to\b|\b(Token refresh failed)\b|\b(rejected|terminating|pong timeout)\b/i,"error"],[/^WARN:|^WARNING:|^Warning\b/,"warn"]];function Xp(e){for(const[t,n]of Yp)if(t.test(e))return n;return"general"}function Qp(e){for(const[t,n]of Zp)if(t.test(e))return n;return"info"}const eu=new RegExp("\\b([A-Z][A-Z0-9_]*(?:_KEY|_TOKEN|_SECRET|_PASSWORD))=([^\\s,;\"']+)","g"),tu=new RegExp("\\b(User(?:name)?:\\s*)([A-Za-z0-9._\\-]{1,64})","g"),nu=new RegExp("\\b[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,}\\b","g"),ou=52428800;function iu(e,t){if(!T(e))return null;if(t<=0)return"";const{size:n}=C(e);if(0===n)return"";const o=n>t?n-t:0,i=n-o,a=Buffer.allocUnsafe(i),r=P(e,"r");try{let e=0;for(;e<i;){const t=U(r,a,e,i-e,o+e);if(0===t)break;e+=t}}finally{L(r)}if(o>0){const e=a.indexOf(10);return-1===e?"":a.slice(e+1).toString("utf8")}return a.toString("utf8")}async function*au(e){const t=ze({input:z(e,{encoding:"utf8"}),crlfDelay:Infinity});for await(const e of t)yield e}function ru(e,t,n,o){var i,a;if(0===e.length)return[];const r=function(e){if("string"!=typeof e)return{ts:null,level:"info",source:"general",message:""};let t=null,n=e,o=e.match(Vp);if(o)t=o[1],n=o[2];else if(o=e.match(Kp),o){const e=new Date(`${o[1]}T${o[2]}`);Number.isNaN(e.getTime())||(t=e.toISOString(),n=o[3])}return{ts:t,level:Qp(n),source:Xp(n),message:n}}(e),s=null!=(i=null!=(a=r.ts)?a:n)?i:null,c=r.level,l=null!=t?t:r.source;return function(e){if("string"!=typeof e)return[e];if(e.length<=16384)return[e];const t=e.length,n=Math.max(1,16344),o=Math.ceil(t/n),i=[];for(let a=0;a<o;a++){const r=a*n,s=e.slice(r,r+n);i.push(`${s} [chunk ${a+1}/${o} of ${t} bytes]`)}return i}(function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;let n=fp(e);return n=function(e,t){if(!t)return e;const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\\/g,"\\\\+"),o=new RegExp(n,"gi");return e.replace(o,"~")}(n,null==t?void 0:t.homeDir),n=function(e){return e.replace(eu,(e,t,n)=>`${t}=<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(tu,(e,t,n)=>`${t}<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(nu,e=>`<redacted:${e.length}ch>`)}(n),n}(r.message,o)).map(e=>({ts:s,level:c,source:l,message:e}))}const su="https://haystack.needle.tools/api/ingest/logs",cu="https://haystack.needle.tools";async function lu(e){try{return await e.json()}catch{return null}}async function pu(e){try{return await e.text()}catch{return""}}function uu(e){const t=e instanceof Error?e.message:String(e),n=e&&"object"==typeof e?e.cause:void 0;let o=t;if(n){const e=n instanceof Error?n.message:String(n),t="object"==typeof n&&null!==n?n.code:void 0;o=t?`${e} (${t})`:e}return`Network error reaching ${su}: ${o}`}var du,mu={__proto__:null,HAYSTACK_RESOURCE:cu,runSendLogs:async function(e,t){var n;let o=await t.getAccessToken();if(!o&&t.recoverAuth)try{t.stdout.write("Updating sign-in (your stored permissions need a one-time refresh)...\n"),o=await t.recoverAuth()}catch{o=null}if(!o)return{ok:!1,error:"Not signed in. Run `needle-cloud login` first, then retry."};const i={type:"meta",...t.meta,mode:e.mode,...e.note?{note:e.note}:{}},a=t.findActiveEditorLog(),r=function(e){const t=Fe.from(async function*(e){if(yield JSON.stringify(e.meta)+"\n",e.prevLogPath&&T(e.prevLogPath)){let t=null;for await(const n of au(e.prevLogPath)){const o=ru(n,null,t,e.redactOpts);for(const e of o)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}if(e.cliLogPath&&T(e.cliLogPath)){let t=null;for await(const n of au(e.cliLogPath)){const o=ru(n,null,t,e.redactOpts);for(const e of o)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}if(e.editor){var t,n;const o=null!=(t=e.editor.tailBytes)?t:ou,i=null!=(n=e.editor.paths)?n:e.editor.path?[e.editor.path]:[];for(const t of i){const n=iu(t,o);if(!n)continue;let i=null;try{i=C(t).mtime.toISOString()}catch{}for(const t of n.split("\n")){const n=ru(t,e.editor.editor,i,e.redactOpts);for(const e of n)e.ts&&(i=e.ts),yield JSON.stringify(e)+"\n"}}}if(e.pipelineLogPath&&T(e.pipelineLogPath)){var o;const t=null!=(o=e.pipelineTailBytes)?o:ou,n=iu(e.pipelineLogPath,t);if(n){let t=null;try{t=C(e.pipelineLogPath).mtime.toISOString()}catch{}for(const o of n.split("\n")){const n=ru(o,"gltf-build-pipeline",t,e.redactOpts);for(const e of n)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}}}(e),{objectMode:!1});return t.pipe(De())}({meta:i,cliLogPath:t.paths.cliLogPath,prevLogPath:t.paths.prevLogPath,editor:a,pipelineLogPath:null!=(n=t.paths.pipelineLogPath)?n:null,redactOpts:{homeDir:t.paths.homeDir}});if(e.dryRun){const{gunzipSync:e}=await import("node:zlib"),n=[];for await(const e of r)n.push(e);const o=e(Buffer.concat(n)).toString("utf8");return t.stdout.write(o),{ok:!0}}let s,c;try{const e=[];for await(const t of r)e.push(t);s=Buffer.concat(e)}catch(e){return{ok:!1,error:`Failed to build upload payload: ${e instanceof Error?e.message:String(e)}`}}try{c=await t.fetch(su,{method:"POST",body:s,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/x-ndjson","Content-Encoding":"gzip"}})}catch(e){return{ok:!1,error:uu(e)}}if(401===c.status){const e=await pu(c);return{ok:!1,error:`401 Unauthorized from ${su}: ${e&&e.length>0?e:"no reason given"} (try \`needle-cloud login\` if your sign-in expired; if you're already signed in, the server may not accept this token's issuer/audience)`}}if(429===c.status){const e=await pu(c);return{ok:!1,error:`429 Rate-limited: ${e&&e.length>0?e:"no reason given"}. You've hit the upload quota for this account; try again later.`}}if(413===c.status){const e=await lu(c);return{ok:!0,refId:null==e?void 0:e.ref_id,truncated:!0}}if(!c.ok){const e=await pu(c);return(400===(l=c.status)||l>=500)&&await async function({token:e,fetch:t,baseMeta:n,status:o,bodyText:i}){const{gzipSync:a}=await import("node:zlib"),r={type:"meta",...n,mode:"crash",note:"send-logs upload error follow-up"},s={ts:(new Date).toISOString(),level:"error",source:"send-logs",message:`Upload failed: status=${o} body=${(null!=i?i:"").slice(0,1024)}`},c=JSON.stringify(r)+"\n"+JSON.stringify(s)+"\n",l=a(Buffer.from(c,"utf8"));await t(su,{method:"POST",body:l,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/x-ndjson","Content-Encoding":"gzip"}})}({token:o,fetch:t.fetch,baseMeta:t.meta,status:c.status,bodyText:e}).catch(()=>{}),{ok:!1,error:`Server returned ${c.status}: ${e}`}}var l;const p=await lu(c);return{ok:!0,refId:null==p?void 0:p.ref_id,truncated:Boolean(null==p?void 0:p.truncated)}}};const fu={appId:"2stnsoa6a1b0gwc7lra55",appSecret:"seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",endpoint:"https://auth.needle.tools",resources:["https://cloud.needle.tools/api",cu],scopes:["openid","profile","email","roles","urn:logto:scope:organizations","urn:logto:scope:organization_roles","identities","custom_data","all","read","write","delete","upload","download","invite","editor","cli:logs:write"]},hu={getAccessToken:!0,fetchUserInfo:!0,resource:null==(du=fu.resources)?void 0:du[0],resources:fu.resources||[],scopes:fu.scopes||[]};function gu(e="default"){return null==e?`${Jp}/?signed-out=1`:"too-many-logins"===e?`${Jp}/?too-many-logins=1`:"error"===e?`${Jp}/?error=1`:`${Jp}/?signed-out=1`}var vu;function bu(){yu.clear(),s.existsSync(ju)&&s.rmSync(ju,{recursive:!0}),s.existsSync(ku)&&s.rmSync(ku,{recursive:!0})}const xu=process.argv.includes("--debug-auth"),yu=new Map;let wu=null==(vu=fu.resources)?void 0:vu[0];if(wu)try{wu=new URL(wu).hostname}catch(e){xu&&console.error("Invalid resource URL",wu)}let _u=wu||"-";_u=_u.replace(/[^a-zA-Z0-9\.\-]/g,"");const ju=y.join(Te(),".needle",".auth",_u),ku=`${Ie()}/Needle/Cloud/.auth/${_u}`;!function(){if(s.existsSync(ku)){xu&&console.debug("Migrating auth data from legacy location",ku,"→",ju);try{s.existsSync(ju)||s.mkdirSync(ju,{recursive:!0,mode:448});for(const e of s.readdirSync(ku)){const t=y.join(ku,e),n=y.join(ju,e);s.statSync(t).isFile()&&!s.existsSync(n)&&(s.copyFileSync(t,n),s.chmodSync(n,384))}s.rmSync(ku,{recursive:!0}),xu&&console.debug("Legacy auth data migrated successfully")}catch(e){xu&&console.error("Failed to migrate legacy auth data",e)}}}();const Su={accessToken:`${ju}/accessToken`,refreshToken:`${ju}/refreshToken`,idToken:`${ju}/idToken`,signInSession:`${ju}/signInSession`};function Eu(e){return Su[e]||`${ju}/${e}`}const $u=new class{constructor(){this.basePath=ju}async setItem(e,t){xu&&console.debug("\n- SET ITEM",e,t),s.existsSync(this.basePath)||s.mkdirSync(this.basePath,{recursive:!0,mode:448});const n=Eu(e);n&&s.writeFileSync(n,t,{mode:384}),yu.set(e,t)}async getItem(e){xu&&console.debug("\n- GET ITEM",e);const t=yu.get(e);if(void 0===t){const t=Eu(e);if(t){if(s.existsSync(t)){const n=s.readFileSync(t,"utf8");return yu.set(e,n),n}}else console.error(`Unknown token name: ${e}`);return null}return String(t)}async removeItem(e){xu&&console.debug("\n- REMOVE ITEM",e),yu.delete(e);const t=Eu(e);if(t&&s.existsSync(t)){try{const e=s.statSync(t).size;e>0&&s.writeFileSync(t,Buffer.alloc(e,0),{mode:384})}catch{}s.rmSync(t)}}};let Tu=null;function Iu(){return Tu||(Tu=new Le(fu,{storage:$u,navigate:()=>{}})),Tu}function Ou(){Tu=null}let Au=Promise.resolve();function Cu(e){const t=Au.then(e,e);return Au=t.then(()=>{},()=>{}),t}async function Ru(e){return Nu(Iu(),e)}async function Nu(e,t){try{const n=await Cu(()=>e.getAccessToken(t));return null!=n?n:null}catch(e){return function(e){return Boolean(e)&&"object"==typeof e&&"not_authenticated"===e.code}(e)||(wp(`Token refresh failed for resource ${t}: ${e instanceof Error?e.message:e}`),Pu(e)&&(wp(`Token refresh: clearing dead grant for resource ${t}`),bu(),Tu=null)),null}}function Pu(e){return function(e){var t,n;if(!e||"object"!=typeof e)return!1;const o=e,i=e=>{if("string"!=typeof e)return!1;const t=e.replace(/^oidc\./,"");return"invalid_grant"===t||"invalid_target"===t};return i(o.code)||i(null==(t=o.data)?void 0:t.error)||i(null==(n=o.data)?void 0:n.code)}(e)}async function Uu(){return Ru(hu.resource)}function Lu(){return Du(Iu())}async function zu(e){var t;if(!e)return{status:401,error:"Not authenticated"};const n=null==(t=e.userInfo)?void 0:t.custom_data;return n?n.default_org?n.default_org:(console.warn("WARN: You do not have a default organization set. Please visit your Needle Cloud account settings and then try again."),wp("WARN: You do not have a default organization set. Please visit your Needle Cloud account settings and then try again."),null):null}function Fu(e){return new Le(fu,{storage:$u,navigate:t=>{if(null==e.navigate)throw new Error("Can not navigate");e.navigate(t)}})}function Du(e){return function(e,t){return Cu(()=>e.getContext(t))}(e,hu).then(t=>{const n=t;return n.client=e,n}).catch(async e=>{const t=e instanceof Error?e.message:String(e);return"oidc.invalid_token"==e.code||"oidc.invalid_grant"==e.code?(wp(`OIDC: ${e.code} – token refresh failed, clearing stale tokens`),bu(),Tu=null,console.error("Session expired – please log in again: npx needle-cloud login")):e.code?(console.error(e.code),wp(`OIDC: ${e.code} – ${t}`)):wp(`OIDC: getContext failed – ${t}`),null})}var qu={__proto__:null,resetSharedClient:Ou,tryGetFreshAccessTokenForResource:Ru,acquireAccessToken:Nu,shouldClearAuthOnError:Pu,tryGetFreshAccessToken:Uu,tryGetUser:Lu,tryGetDefaultOrgId:zu,createNodeClient:Fu,getUserFromClient:Du};function Bu(e){var t,n,o,i;if(!e)return"";let a=(null==(t=e.claims)?void 0:t.name)||(null==(n=e.userInfo)?void 0:n.name)||(null==(o=e.claims)?void 0:o.username)||"";var r;return(!a||a.length<=0)&&null!=(i=e.claims)&&i.email?function(e){return e?(e=(e=(e=(e=e.split("@")[0]).replace(/[^a-zA-Z0-9]/g," ")).replace(/\s+/g," ")).split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),e):e}(null==(r=e.claims)?void 0:r.email):a}async function Mu(e,t=null){var n,o;if(!e)return{status:500,error:"User is not provided"};if(!e.isAuthenticated)return{status:403,error:"User is not authenticated"};const i=(null==(n=e.claims)?void 0:n.sub)||(null==(o=e.userInfo)?void 0:o.sub);t===i&&(t=null);let a=null;if(null==t)a=e.accessToken;else if(null!=t){var r;let n=null==e||null==(r=e.userInfo)||null==(r=r.organization_data)?void 0:r.find(e=>e.id===t);if(!n){var s;const o=t.toLowerCase();n=null==e||null==(s=e.userInfo)||null==(s=s.organization_data)?void 0:s.find(e=>e.name.toLowerCase()===o)}if(!n)return{status:403,error:`User is not part of team "${t}"`};t=n.id,a=await e.client.getOrganizationToken(n.id).catch(e=>{var o;return console.error(`Error getting organization token for "${null==(o=n)?void 0:o.name}" (${t}): ${e.message}`),null})}return a?{authToken:a,org:t}:{status:403,error:"No access token found"}}const Wu=function(){return async(e,t,n)=>{const o=await Lu();Object.defineProperty(e,"user",{enumerable:!0,get:()=>o}),n()}};let Hu=null;function Gu(e){var t;const n=null==(t=e.userInfo)?void 0:t.custom_data;if(!n)return[];const o=n.machines;return o?o.map(e=>e.name):[]}let Ju=Date.now();async function Vu(e){var t;const n=Date.now();n-Ju>3e4&&"client"in e&&(Ju=n,await e.client.fetchUserInfo().catch(console.error));const o=null==(t=e.userInfo)?void 0:t.custom_data;if(!o)return!1;if(Hu||await Ku(),!Hu)return console.error("Failed to get machine id"),!0;const i=o.machines;if(!i)return!1;const a=i.some(e=>e.id===Hu);return a}async function Ku(){return Hu||await import("node-machine-id").then(async e=>{const t=await e.default.machineId(!1);Hu=t}),Hu}function Yu(){return $e.userInfo().username+"@"+$e.hostname()}async function Zu(e,t={signout:!1}){if(e.accessToken){const o={machine_id:await Ku(),machine_name:Yu(),platform:$e.platform(),arch:$e.arch()},i=await fetch("https://cloud.needle.tools/api"+ft.account.post_machine,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify(o)}).catch(e=>{var t,n;const o=(null==e||null==(t=e.cause)?void 0:t.code)||(null==e||null==(n=e.cause)?void 0:n.message)||(null==e?void 0:e.message)||"connection refused";return console.error(`Failed to validate login: ${o} - Make sure https://cloud.needle.tools/api is reachable`),wp(`Failed to validate login: "${o}" - Make sure https://cloud.needle.tools/api is reachable.`),{status:502,error:`Failed to validate login at 'https://cloud.needle.tools/api' (${o}) - make sure this URL is reachable.`}});if(!i)return!1;if("error"in i)return i;let a=!0;if(403===i.status){const e=await i.text();if(e.trimStart().startsWith("{")){const t=JSON.parse(e);t.logins&&(a=!1,wp("Too many logins from different machines"),$().fail("You have reached the maximum number of allowed logins\n"),$().warn(`Please logout from one of the following machines:\n- ${t.logins.join("\n- ")}\n`))}}var n;return!!a||(t.signout&&(bu(),"client"in e&&(null==(n=e.client)||n.signOut(gu("too-many-logins")))),!1)}return!0}let Xu=null;function Qu(){if(Xu)return Xu;{const e=rd();return Xu=e,e}}const ed="projects.json";function td(e){e.entries.sort((e,t)=>t.last_accessed-e.last_accessed);let t=0;e.entries=e.entries.filter(e=>"cli"===e.source||++t<=30),f(ad(),JSON.stringify(e),"utf-8"),Xu=e}function nd(){var e;const t=Qu(),n=t.selected_web_project;if(n){const e=t.entries.find(e=>e.web_location&&w(e.web_location)===n);if(e)return e}return null!=(e=t.entries[0])?e:null}function od(e){const t=h.native(e);if(!l(t).isDirectory()||!c(_(t,"package.json")))throw new Error("The web project must be a directory with package.json.");const n=Qu(),o=n.entries.find(e=>e.web_location&&w(e.web_location)===t);if(o)return o.last_accessed=Date.now(),n.selected_web_project=t,td(n),o;const i={web_location:t,source:"cli",editor:"unknown",last_accessed:Date.now()};return n.entries.unshift(i),n.selected_web_project=t,td(n),i}function id(e){if("string"!=typeof e||!e)throw new Error("A registered project path is required.");const t=Qu(),n=w(e),o=t.entries.find(e=>e.web_location&&w(e.web_location)===n);if(null==o||!o.web_location)throw new Error("This web project is not registered with the local Needle CLI.");const i=h.native(o.web_location);if(!l(i).isDirectory()||!c(_(i,"package.json")))throw new Error("The registered web project is no longer available.");return o.last_accessed=Date.now(),t.selected_web_project=i,t.entries=[o,...t.entries.filter(e=>e!==o)],td(t),o}function ad(){const e=process.env.HOME||process.env.USERPROFILE||process.cwd(),t=_(e,".needle");return c(t)||m(t,{recursive:!0}),_(t,ed)}function rd(){const e=ad();if(!c(e))return{entries:[]};const t=p(e,"utf-8");try{const e=JSON.parse(t);return Xu=e,e}catch(e){return console.error("Failed to parse project info file:",e),{entries:[]}}}const sd=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8"));function cd(){return sd.version}const ld=process.env.NEEDLE_SEARCH_ENDPOINT||"https://search.needle.tools",pd=process.env.NEEDLE_SEARCH_API_KEY||"da5737c00d6822c32a1b9e3b5dab094bfc17e205aef2f7f3e1a0fd4ebc77b79f",ud=[{name:"needle_my_account",description:"Get current Needle Cloud user information",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},{name:"needle_search",description:"Search Needle Engine documentation, forum posts, and community discussions. Returns relevant content ranked by semantic similarity. Use this to find information about Needle Engine features, APIs, components, workflows, and troubleshooting.\n\nIMPORTANT: If search results seem irrelevant or low-quality (scores below 0.6, or results don't match the topic), retry with different search terms — up to 3 total attempts. Try varying your query: use specific class/method names, try shorter keyword-based queries, or rephrase the question. Do NOT guess or fabricate answers based on poor search results.",inputSchema:{type:"object",properties:{query:{type:"string",description:'What to search for, e.g. "how to add physics components" or "WebXR hand tracking" or "deploy to vercel"'},limit:{type:"number",description:"Maximum number of results to return (1-20, default 5)"}},additionalProperties:!1,required:["query"]}}],dd={needle_my_account:async function(e){try{const e=await Lu(),t=null==e?void 0:e.userInfo;return t?JSON.stringify({id:t.sub,name:t.name||t.preferred_username,email:t.email,profile_picture:t.picture}):"No user is currently logged in."}catch(e){return"Error retrieving user: "+(e instanceof Error?e.message:String(e))}},needle_search:async function(t){const n=t.query;if(!n||"string"!=typeof n)return{content:[{type:"text",text:"Error: query parameter is required."}]};const o=Math.min(Math.max(Number(t.limit)||5,1),20),i=`${ld}/api/semantic-search?q=${encodeURIComponent(n)}&limit=${o}`,a={Accept:"application/json"};pd&&(a.Authorization=`Bearer ${pd}`);try{const t=await e(i,{headers:a,signal:AbortSignal.timeout(15e3)});if(!t.ok){const e=await t.text().catch(()=>"");return{content:[{type:"text",text:`Search API error (${t.status}): ${e}`}]}}const o=await t.json();if(!o.results||0===o.results.length)return{content:[{type:"text",text:`No results found for: "${n}"`}]};const r=o.results.map((e,t)=>`## [${t+1}] ${e.title} (score: ${e.score})\nSource: ${e.source}${e.url?` — ${e.url}`:""}\n\n`+e.content+(e.truncated?`\n\n> Content truncated (${e.content.length} of ${e.contentLength} chars shown).${e.url?` Full content: ${e.url}`:""}`:"")).join("\n\n---\n\n");return{content:[{type:"text",text:`Found ${o.results.length} results for "${n}" (${o.durationMs}ms):\n\n${r}`}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e instanceof Error?e.message:String(e)}`}]}}}},md=new Map;function fd(e,t){const n=ud.findIndex(t=>t.name===e);if(-1!==n){ud.splice(n,1),delete dd[e];for(const t of md.values())t.delete(e);t()}}function hd(e,t,n,o){const i=ud.findIndex(t=>t.name===e.name);if(-1!==i){var a;const t=null==(a=[...md.entries()].find(([,t])=>t.has(e.name)))?void 0:a[0];if(!t||t!==(null==n?void 0:n.source))throw new Error(`Tool "${e.name}" is already registered by ${null!=t?t:"the CLI"}.`);ud.splice(i,1)}if(ud.push(e),dd[e.name]=t,gd.delete(e.name),null!=n&&n.source){const t=md.get(n.source)||new Set;t.add(e.name),md.set(n.source,t)}o()}const gd=new Map;async function vd(e,t,n={}){const o=dd[e];if(!o){const t=gd.get(e);if(t)return{isError:!0,content:[{type:"text",text:`This tool is currently unavailable because "${t}" disconnected. Please reconnect (e.g. reopen the browser tab) and try again. You should also call tools/list to refresh your available tools.`}]};throw new Error(`Tool "${e}" is not registered.`)}const i=await o(t,n);if("string"==typeof i)return{content:[{type:"text",text:i}]};if("object"==typeof i)return Array.isArray(i.content)?i:{content:[{type:"text",text:JSON.stringify(i)}]};throw new Error(`Invalid tool result type for tool "${e}".`)}const bd=200,xd=2e3,yd=new RegExp("^[A-Za-z0-9_./*?\\[\\]{},\\-]+$"),wd="[REDACTED]";function _d(e){return/(?:password|passwd|pwd|secret|token|apikey|privatekey|accesskey|connectionstring|databaseurl|authorization|credentials)$/.test(e.toLowerCase().replace(/[^a-z0-9]/g,""))}function jd(e){return"string"==typeof e?Sd(e):Array.isArray(e)?e.map(jd):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,_d(e)&&null!==t?wd:jd(t)])):e}function kd(e){var t;return wd+"\n".repeat((null!=(t=e.match(/\n/g))?t:[]).length)}function Sd(e){let t=e.replace(/-----BEGIN (?:[A-Z0-9 ]*PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g,kd);const n=t.split("\n");for(let e=0;e<n.length;e++){const t=/^([ \t]*)([\w.-]+)\s*:[ \t]*(?:[|>][^\n]*)?$/.exec(n[e]);if(!t||!_d(t[2]))continue;const a=t[1].length;for(n[e]=wd;e+1<n.length&&(!n[e+1].trim()||(null!=(o=null==(i=n[e+1].match(/^[ \t]*/))?void 0:i[0].length)?o:0)>a);){var o,i;n[++e]=wd}}return t=n.join("\n"),t=t.replace(/\b(?:Authorization\s*:\s*(?:Basic|Bearer)\s+|Bearer\s+)[^\s"',;]+/gi,e=>e.substring(0,e.lastIndexOf(" ")+1)+wd),t=t.replace(/(?<![\w.-])((?:["']?[\w.-]*(?:password|passwd|pwd|secret|token|api[_-]?key|private[_-]?key|access[_-]?key|connection[_-]?string|database[_-]?url|authorization|credentials)["']?)[ \t]*[:=][ \t]*)("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[^\s,;\]}]+)/gi,(e,t,n)=>{var o;if(!_d(t.split(/[:=]/)[0].replace(/["'\s]/g,""))||/^(?:process\.env\.|import\.meta\.env\.|\[REDACTED\])/.test(n))return e;const i=n.startsWith('"')?'"':n.startsWith("'")?"'":n.startsWith("`")?"`":"";return t+i+wd+i+"\n".repeat((null!=(o=n.match(/\n/g))?o:[]).length)}),t=t.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/@]+:[^\s/@]+@/gi,"$1"+wd+"@"),t=t.replace(/([?&])([\w%-]+)=([^&#\s"']*)/g,(e,t,n)=>_d(function(e){try{return decodeURIComponent(e)}catch{return e}}(n))?t+n+"="+wd:e),t.replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|sk-(?:proj-|live_|test_)?[A-Za-z0-9_-]{20,}|(?:AKIA|ASIA)[A-Z0-9]{16}|xox[baprs]-[A-Za-z0-9-]{15,}|AIza[A-Za-z0-9_-]{30,}|npm_[A-Za-z0-9]{20,}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)\b/g,wd)}function Ed(e){if(/^\s*[\[{]/.test(e)){try{JSON.parse(e)}catch{return Sd(e)}const o=/"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|[{}\[\]:,]|\s+/g;let i,a="",r=0;for(;null!==(i=o.exec(e));){var t;if(!i[0].startsWith('"'))continue;let s=i.index+i[0].length;for(;/[ \t\r\n]/.test(null!=(n=e[s])?n:"");){var n;s++}if(":"!==e[s])continue;const c=JSON.parse(i[0]);if("string"!=typeof c||!_d(c))continue;o.lastIndex=s+1;let l=o.exec(e);for(;l&&/^\s+$/.test(l[0]);)l=o.exec(e);if(!l)throw new Error("Invalid JSON credential value.");const p=l.index;let u=p+l[0].length;if("{"===l[0]||"["===l[0]){let t=1;for(;t;){const n=o.exec(e);if(!n)throw new Error("Invalid JSON credential value.");"{"!==n[0]&&"["!==n[0]||t++,"}"!==n[0]&&"]"!==n[0]||t--,u=n.index+n[0].length}}a+=e.slice(r,p)+JSON.stringify(wd)+"\n".repeat((null!=(t=e.slice(p,u).match(/\n/g))?t:[]).length),r=u}return a+=e.slice(r),a.replace(/"(?:\\.|[^"\\])*"/g,e=>JSON.stringify(Sd(JSON.parse(e))))}return Sd(e)}class $d extends Error{}function Td(e){return e.split(/[\\/]/).some(e=>{const t=e.toLowerCase().replace(/[ .]+$/,"");return/^(?:\.env(?:\..*)?|\.envrc|\.npmrc|\.pypirc|\.netrc|\.yarnrc(?:\.yml)?|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?|credentials(?:\.[\w.-]+)?|service[-_]?account(?:\.[\w.-]+)?|\.ssh|\.aws|\.docker|\.azure|\.kube|\.gnupg|\.needle|\.git)$/.test(t)||/(?:^|[._-])(?:credentials|secrets)(?:\.(?:json|ya?ml|toml|ini|txt))?$/.test(t)||/\.(?:env|pem|key|p12|pfx|jks|keystore|kdbx)$/.test(t)})}function Id(e,t){const n=re(e,t);return""===n||!ce(n)&&".."!==n&&!n.startsWith(".."+le)}function Od(e,t,n={}){if("string"!=typeof t||!t||t.includes("\0"))throw new $d("Invalid file path.");const o=A(e),i=ae(o,t);if(!Id(o,i))throw new $d("Path is outside the connected project.");const a=re(o,i);if(a.split(/[\\/]/).some(e=>e.includes(":")||/[ .]$/.test(e)))throw new $d("Invalid file path.");if(Td(e)||Td(o)||Td(a))throw new $d("Sensitive files cannot be accessed by local AI tools.");let r=i;for(;!T(r)&&r!==o&&n.allowMissing;)r=se(r);const s=A(r);if(!Id(o,s))throw new $d("Path is outside the connected project.");const c=ae(s,re(r,i));if(Td(c))throw new $d("Sensitive files cannot be accessed by local AI tools.");return{root:o,path:c}}function Ad(e,t,n={}){var o,i;const a=Od(e,t);if(!C(a.path).isFile())throw new $d("Path is not a regular file.");const r=P(a.path,F.O_RDONLY|(null!=(o=F.O_NOFOLLOW)?o:0)|(null!=(i=F.O_NONBLOCK)?i:0));try{var s;const o=D(r);if(!o.isFile())throw new $d("Path is not a regular file.");if(o.nlink>1)throw new $d("Hard-link aliases cannot be read by local AI tools.");const i=null!=(s=n.maxBytes)?s:8388608;if(!Number.isSafeInteger(i)||i<0||i>67108864)throw new $d("Invalid read size limit.");const l=n.range;if(l&&(!Number.isSafeInteger(l.offset)||!Number.isSafeInteger(l.length)||l.offset<0||l.length<0||l.offset+l.length>o.size))throw new $d("Invalid file byte range.");if((l?l.length:o.size)>i)throw new $d(`File exceeds the ${i} byte read limit.`);const p=Od(e,t),u=C(p.path);if(p.path!==a.path||o.ino!==u.ino||o.dev!==u.dev)throw new $d("File path changed while opening. Retry the request.");const d=Buffer.alloc(Math.min(i+1,65536)),m=[];let f,h=0;const g=l?l.length:i+1;for(;h<g&&(f=U(r,d,0,Math.min(d.length,g-h),(null!=(c=null==l?void 0:l.offset)?c:0)+h))>0;){var c;if(h+=f,h>i)throw new $d("File exceeds the read size limit.");m.push(Buffer.from(d.subarray(0,f)))}if(l&&h!==l.length)throw new $d("File byte range changed while reading.");const v=Od(e,t),b=C(v.path);if(v.path!==a.path||b.ino!==o.ino||b.dev!==o.dev)throw new $d("File path changed while reading. Retry the request.");return Buffer.concat(m,h)}finally{L(r)}}function Cd(e){if(/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(e.toString("utf8")))throw new $d("Files containing private-key material cannot be read.")}function Rd(e,t={}){const n=e.toString("utf8");if(n.includes("\0")||!Buffer.from(n,"utf8").equals(e))throw new $d("Only UTF-8 text files can be read.");return t.allowPrivateKeys||Cd(e),Ed(n)}function Nd(e,t,n={}){return{...Od(e,t),text:Rd(Ad(e,t,n),n)}}function Pd(e,t){try{return We("grep",e,{input:t,encoding:"utf8",timeout:1e4,maxBuffer:1048576})}catch(e){if(e&&"object"==typeof e&&"status"in e&&1===e.status)return"";throw e}}function Ud(e,t,n=Pd){!function({pattern:e,glob:t,root:n,maxResults:o}){if("string"!=typeof e)throw new Error("invalid pattern: must be a string");if(e.length>xd)throw new Error(`invalid pattern: exceeds ${xd} characters`);if(null!=t&&""!==t){if("string"!=typeof t)throw new Error("invalid glob: must be a string");if(t.length>bd)throw new Error(`invalid glob: exceeds ${bd} characters`);if(!yd.test(t))throw new Error("invalid glob: contains disallowed characters")}const i=["-rn"];t&&i.push(`--include=${t}`),i.push(`--max-count=${o}`,"-E",e,n)}({...t,root:"."});const o=[],i=[];let a=0,r=0,s=0,c=0,l=!1;const p=Date.now();return function n(u,d){if(d>20||s>=2e3||r>=33554432||Date.now()-p>1e4)l=!0;else for(const m of q(u,{withFileTypes:!0})){const f=pe(u,m.name),h=re(e,f).replace(/\\/g,"/");if(Td(h)||m.isSymbolicLink())c++;else{if(m.isDirectory()){if("node_modules"===m.name||m.name.startsWith(".")){c++;continue}n(f,d+1)}else{if(t.glob&&!Ve(h,t.glob,{matchBase:!0}))continue;try{Od(e,f);const t=Nd(e,f).text.replace(/\n$/,""),n=Buffer.byteLength(t);if(++s>2e3||r+n>33554432||Date.now()-p>1e4)return void(l=!0);const c=t.split("\n").length;i.push({start:a+1,end:a+c,path:h}),a+=c,r+=n,o.push(t+"\n")}catch(e){if(e instanceof $d){c++;continue}throw e}}if(l)return}}}(Od(e,".").path,0),{lines:n(["-n","-E",`--max-count=${t.maxResults}`,"-e",t.pattern,"--"],o.join("")).trimEnd().split("\n").filter(Boolean).map(e=>{const t=e.indexOf(":"),n=Number(e.slice(0,t)),o=i.find(e=>n>=e.start&&n<=e.end);if(!o||t<0)throw new Error("Unexpected grep output.");return`${o.path}:${n-o.start+1}:${e.slice(t+1)}`}),omitted:c,limited:l}}const Ld=new Set;async function zd(e,t=He){const n={check:"typescript",diagnostics:[]};if(!e)return{...n,status:"unavailable",message:"No connected web project. Open your project in the editor first."};const o=ae(e),i=pe(o,"tsconfig.json"),a=pe(o,"node_modules/typescript/lib/tsc.js");if(!T(i))return{...n,status:"unavailable",message:"The connected web project has no tsconfig.json."};if(!T(a))return{...n,status:"unavailable",message:"TypeScript is not installed in the connected web project. Install the project dependencies first."};if(Ld.has(o))return{...n,status:"error",message:"A check is already running for this project."};Ld.add(o);try{const e={...process.env};delete e.NODE_OPTIONS,delete e.NODE_PATH;const r=await new Promise(n=>{t(process.execPath,[a,"--project",i,"--noEmit","--incremental","false","--pretty","false"],{cwd:o,shell:!1,timeout:1e4,maxBuffer:262144,windowsHide:!0,encoding:"utf8",env:e},(e,t,o)=>n({error:e,stdout:t,stderr:o}))}),{error:s}=r,c=Ed(r.stdout),l=Ed(r.stderr);if(s&&(s.killed||"number"!=typeof s.code))return{...n,status:"error",message:s.killed?"Type checking exceeded the 10 second limit.":`Could not finish type checking: ${s.code||s.message}`,output:String(l||c).slice(0,4e3)};const p=[],u=[];for(const e of String(c).split(/\r?\n/)){const t=/^(?:(.+)\((\d+),(\d+)\): )?error (TS\d+): (.*)$/.exec(e);t?p.push({...t[1]?{file:t[1],line:Number(t[2]),column:Number(t[3])}:{},code:t[4],severity:"error",message:t[5]}):e.trim()&&(/^\s/.test(e)&&p.length?p[p.length-1].message+="\n"+e:u.push(e))}const d=Boolean(l||u.length||s&&!p.length);return{check:"typescript",project:o,status:d?"error":p.length?"failed":"passed",diagnostics:p.slice(0,100),totalDiagnostics:p.length,truncated:p.length>100,...d?{message:"The compiler did not return a complete diagnostic result.",output:[l,...u].join("\n").slice(0,4e3)}:{}}}finally{Ld.delete(o)}}const Fd=new Set([".git","node_modules"]);function Dd(e){if(!e)return null;try{const t=A(e),n=o("sha256"),i=[t];let a=0;for(;i.length;){const e=i.pop(),o=q(e,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name));for(const r of o){if(++a>2e4)return null;const o=pe(e,r.name),s=re(t,o).replaceAll("\\","/");if(r.isDirectory()&&Fd.has(r.name)){n.update(`${s}\0excluded\n`);continue}const c=B(o,{bigint:!0});n.update(`${s}\0${c.mode}\0${c.size}\0${c.mtimeNs}\0${c.ctimeNs}\n`),r.isDirectory()&&i.push(o)}}return n.digest("hex")}catch{return null}}const qd=(e,t)=>Ed(String(null!=e?e:"")).slice(0,t),Bd=1048576,Md=104857600,Wd=e=>o("sha256").update(e).digest("hex"),Hd=1048576,Gd=e=>o("sha256").update(e).digest("hex"),Jd=new Set([".app",".bat",".cmd",".com",".desktop",".exe",".hta",".jar",".lnk",".msi",".ps1",".scr",".sh",".url",".vbs",".wsf"]),Vd="settings.json";function Kd(){return pe(ne(),".needle")}function Yd(e){const t=pe(null!=e?e:Kd(),Vd);if(!T(t))return{};try{const e=JSON.parse(M(t,"utf-8"));return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}catch{return{}}}function Zd(e){return"disabled"===Yd(e).remote_ai_tools}function Xd(e){const t=pe(null!=e?e:Kd(),Vd);if(!T(t))return{};try{const e=JSON.parse(M(t,"utf-8"));return e&&"object"==typeof e&&!Array.isArray(e)?e:null}catch(e){return console.warn(`Needle CLI settings are unreadable; local AI mutations are disabled: ${e instanceof Error?e.message:String(e)}`),null}}function Qd(e){const t=Xd(e);return null===t||void 0!==t.local_file_edits&&"enabled"!==t.local_file_edits}function em(e){const t=Xd(e);return null===t||void 0!==t.local_project_commands&&"enabled"!==t.local_project_commands}function tm(e,t){if(!T(e))try{I(e,{recursive:!0})}catch{}let n=null,o=null;try{n=G(e,{persistent:!1},(e,n)=>{n&&n.toString()!==Vd||(o&&clearTimeout(o),o=setTimeout(()=>{o=null;try{t()}catch{}},50))}),null==n.on||n.on("error",()=>{})}catch{}return()=>{o&&(clearTimeout(o),o=null);try{var e;null==(e=n)||e.close()}catch{}n=null}}var nm={__proto__:null,KNOWN_SETTINGS:{remote_ai_tools:{displayName:"Remote AI tools",default:"enabled",description:"Allow Needle Cloud AI chat to dispatch tool calls (file reads, search, etc.) to this machine.",command:"needle-cloud settings remote-ai-tools <true|false>"},local_file_edits:{displayName:"Local AI file edits",default:"enabled",description:"Allow AI file mutations on this machine when the chat also has approval.",command:"needle-cloud settings local-file-edits <true|false>"},local_project_commands:{displayName:"Local AI project commands",default:"enabled",description:"Allow approved AI installs, project creation, builds, and deploys on this machine.",command:"needle-cloud settings local-project-commands <true|false>"}},defaultSettingsDir:Kd,readSettings:Yd,writeSetting:function(e,t,n){const o=Yd(e);null===n?delete o[t]:o[t]=n,I(e,{recursive:!0}),H(pe(e,Vd),JSON.stringify(o,null,2)+"\n","utf-8")},areRemoteAiToolsDisabled:Zd,areLocalFileEditsDisabled:Qd,areLocalProjectCommandsDisabled:em,watchSettings:tm};const om=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function im(e,t=process.platform,n=Ge){if(!Number.isSafeInteger(e)||e<1)return null;if("win32"===t){const t=n("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],{shell:!1,windowsHide:!0,timeout:5e3,encoding:"utf8"}),o=String(t.stdout||"").trim();return 0===t.status&&/^\d{12,}$/.test(o)?`win:${o}`:null}if("linux"===t)try{const t=M(`/proc/${e}/stat`,"utf8"),n=t.slice(t.lastIndexOf(")")+2).trim().split(/\s+/),o=M("/proc/sys/kernel/random/boot_id","utf8").trim();return/^\d+$/.test(n[19]||"")&&o?`linux:${o}:${n[19]}`:null}catch{return null}if("darwin"===t){const t=n("ps",["-p",String(e),"-o","lstart="],{shell:!1,windowsHide:!0,timeout:5e3,encoding:"utf8"}),o=String(t.stdout||"").trim();return 0===t.status&&/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+[A-Z][a-z]{2}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4}$/.test(o)?`darwin:${o}`:null}return null}const am=Object.freeze(["vite","react","react-three-fiber","svelte","sveltekit","vue","nextjs"]),rm=new Set(am),sm=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@(?:\d+(?:\.\d+){0,2}(?:-[a-z0-9.-]+)?|latest|next))?$/i,cm=/^[a-z0-9][a-z0-9._-]{0,79}$/i;function lm(e,t){if(!e||!T(e)||!C(e).isDirectory())throw new Error(`${t} does not exist.`);return A.native(e)}function pm(e,t,n){if(!e||"object"!=typeof e)throw new Error("A project operation is required.");if("create"===e.operation){if("project"in e)throw new Error("Create uses destination, not project.");if("string"!=typeof e.name||!cm.test(e.name))throw new Error("Use a short project name containing letters, numbers, dots, hyphens, or underscores.");if(!rm.has(e.template))throw new Error("Unsupported Needle project template.");if("location"in e)throw new Error("Use an explicit absolute destination instead of a location name.");if(void 0!==e.parent&&void 0!==e.destination)throw new Error("Use either parent or destination for a new project, not both.");const t=void 0!==e.parent||void 0!==e.destination;if(void 0!==e.parent&&("string"!=typeof e.parent||!ce(e.parent)))throw new Error("An explicit project parent must be an absolute existing directory.");if(void 0!==e.destination&&("string"!=typeof e.destination||!ce(e.destination)))throw new Error("An explicit project destination must be absolute.");const o=void 0!==e.parent?pe(lm(e.parent,"The project parent"),e.name):void 0!==e.destination?ae(e.destination):pe(n,".needle","ai-projects",e.name);if(fe(o)!==e.name)throw new Error("The destination folder must match the project name.");const i=t?pe(lm(se(o),"The destination parent"),e.name):o;if(T(i))throw new Error("The project destination already exists; refusing to overwrite it.");return{request:e,operation:"create",name:e.name,template:e.template,destination:i,customDestination:t,command:`npm --yes create needle ${e.name} -- --template ${e.template}`,args:["--yes","create","needle",e.name,"--","--template",e.template]}}if("directory"in e&&"deploy"!==e.operation)throw new Error("Use project to select a project directory; directory is only for deploy output.");const i="project"in e?e.project:void 0;if(void 0!==i&&("string"!=typeof i||!ce(i)))throw new Error("An explicit project path must be absolute.");const a=lm(i||t||"","The project"),r=a!==(t&&T(t)?A.native(t):null),s=function(e){const t=pe(e,"package.json");if(!T(t))throw new Error("The connected project has no package.json.");const n=M(t,"utf8"),o=JSON.parse(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new Error("The project package.json is invalid.");const i=o;return{scripts:i.scripts&&"object"==typeof i.scripts&&!Array.isArray(i.scripts)?i.scripts:void 0,packageManager:"string"==typeof i.packageManager?i.packageManager:void 0,raw:n}}(a);!function(e,t){if(t&&!/^npm@\d+(?:\.\d+){0,2}(?:-[a-z0-9.-]+)?$/i.test(t))throw new Error(`This project uses ${t}; npm-only AI commands cannot modify it.`);for(const t of["pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"])if(T(pe(e,t)))throw new Error(`This project uses ${t}; npm-only AI commands cannot modify it.`)}(a,s.packageManager);const c=function(e,t){const n=pe(e,"package-lock.json");return i=t+"\0"+(T(n)?M(n,"utf8"):""),o("sha256").update(i).digest("hex");var i}(a,s.raw);if("install"===e.operation){const t=T(pe(a,"package-lock.json"));return{request:e,operation:"install",project:a,customProject:r,inputsHash:c,command:t?"npm ci":"npm install",args:t?["ci"]:["install"]}}if("add_package"===e.operation){if(!Array.isArray(e.packages)||e.packages.length<1||e.packages.length>10||e.packages.some(e=>"string"!=typeof e||!sm.test(e)))throw new Error("Provide 1–10 npm registry package names with optional exact versions or tags.");const t=!0===e.dev;return{request:e,operation:"add_package",project:a,customProject:r,inputsHash:c,packages:[...e.packages],dev:t,command:`npm install ${e.packages.join(" ")} ${t?"--save-dev":"--save"}`,args:["install",...e.packages,t?"--save-dev":"--save"]}}if("build"===e.operation){var l;const t=null==(l=s.scripts)?void 0:l.build;if("string"!=typeof t||!t.trim())throw new Error("The connected project has no build script.");return{request:e,operation:"build",project:a,customProject:r,inputsHash:c,script:t,command:"npm run build",args:["run","build"]}}if("dev"===e.operation){var p;const t=null==(p=s.scripts)?void 0:p.dev;if("string"!=typeof t||!t.trim())throw new Error("The project has no dev script.");if(!T(pe(a,"node_modules")))throw new Error("Install project dependencies before starting the dev server.");return{request:e,operation:"dev",project:a,customProject:r,inputsHash:c,script:t,command:"npm run dev",args:["run","dev"]}}if("deploy"===e.operation){if(!e.team)throw new Error("An explicit Needle team ID is required for AI deployment.");let t=e.directory;if(void 0===t){const e=pe(a,"needle.config.json");if(T(e)){const n=JSON.parse(M(e,"utf8"));if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n.buildDirectory;"string"==typeof e&&(t=e)}}null!=t||(t="dist")}if("string"!=typeof t||!t||ce(t)||t.split(/[\\/]/).some(e=>".."===e||"."===e))throw new Error("Use a project-relative build directory.");const n=function(e,t){const n=A.native(t),o=re(e,n);if(".."===o||o.startsWith(`..${le}`)||ce(o))throw new Error("The build directory is outside the connected project.");return n}(a,lm(ae(a,t),"The build directory"));if(!T(pe(n,"index.html")))throw new Error("The build directory has no index HTML file.");if(void 0!==e.name&&!cm.test(e.name))throw new Error("Use a valid deployment name.");if(void 0!==e.team&&!/^org_[a-z0-9]+$/.test(e.team))throw new Error("Use a valid Needle team ID.");return{request:e,operation:"deploy",project:a,customProject:r,inputsHash:c,directory:n,...e.name?{name:e.name}:{},...e.team?{team:e.team}:{},command:`needle-cloud deploy ${n} --open false${e.name?` --name ${e.name}`:""} --team ${e.team}`}}throw new Error("Unsupported project operation.")}function um(e,t=process.platform,n=Ge,o=process.kill){if(!e||!Number.isSafeInteger(e)||e<1)return!1;if("win32"===t){const t=n("taskkill",["/PID",String(e),"/T","/F"],{shell:!1,windowsHide:!0,timeout:5e3,encoding:"utf8"});return t.error?console.warn(`Could not terminate local project command tree: ${t.error.message}`):0!==t.status&&console.warn(`Could not terminate local project command tree: ${String(t.stderr||"").trim()||`taskkill exited ${t.status}`}`),!t.error&&0===t.status}try{return o(-e,"SIGTERM"),!0}catch(e){return e instanceof Error&&"code"in e&&"ESRCH"===e.code||console.warn(`Could not terminate local project command tree: ${e instanceof Error?e.message:String(e)}`),!1}}async function dm(e,t,n=(()=>{}),o=x){let a,r,s=process.execPath,c=e.project||se(e.destination);if("deploy"===e.operation){const t=process.argv[1];if(!t||!T(t))throw new Error("Cannot locate the running Needle CLI entry point for deployment.");a=[ae(t),"deploy",e.directory,"--open","false",...e.name?["--name",e.name]:[],...e.team?["--team",e.team]:[]]}else{const t=[process.env.npm_execpath,pe(se(process.execPath),"node_modules","npm","bin","npm-cli.js"),pe(se(se(process.execPath)),"lib","node_modules","npm","bin","npm-cli.js")].find(e=>"string"==typeof e&&"npm-cli.js"===fe(e)&&T(e));if(!t)throw new Error("Could not locate npm-cli.js. Start Needle CLI through npm or install npm alongside Node.js.");a=[t,...e.args],"create"===e.operation&&I(c,{recursive:!0})}if("dev"===e.operation){const t=[Ke(new URL("../../../bin/cli.project-dev-supervisor.cjs",import.meta.url)),Ke(new URL("../bin/cli.project-dev-supervisor.cjs",import.meta.url))].find(T);if(!t)throw new Error("The local dev supervisor is missing from the Needle CLI installation.");r=e.runtimeFile||pe(oe(),`needle-dev-${i()}.runtime.json`),a=[t,Buffer.from(JSON.stringify({executable:s,args:a,cwd:c,runtimeFile:r})).toString("base64url")]}return new Promise((i,l)=>{var p,u;if(t.aborted)return void l(new Error("Project command was canceled before it started."));const d=Je(s,a,{cwd:c,shell:!1,windowsHide:!0,detached:"dev"===e.operation||"win32"!==process.platform,stdio:["ignore","pipe","pipe"]});let m="";const f=function(e){let t,n="",o="",i=!1,a=!1;function r(e){var n,o;if(/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(e)&&(i=!0),i)return/-----END [A-Z0-9 ]*PRIVATE KEY-----/.test(e)&&(i=!1),wd;const a=null!=(n=null==(o=e.match(/^[ \t]*/))?void 0:o[0].length)?n:0;if(void 0!==t){if(!e.trim()||a>t)return wd;t=void 0}const r=/^([ \t]*)([\w.-]+)[ \t]*:[ \t]*(?:[|>][^\n]*)?$/.exec(e);return r&&_d(r[2])?(t=r[1].length,wd):Ed(e)}return{push(e,t=!1){let i;for(n+=e;(i=n.indexOf("\n"))>=0;){const e=n.slice(0,i);n=n.slice(i+1),o=(o+(a?wd:r(e))+"\n").slice(-8e3),a=!1}return n.length>65536&&(r(n),n="",a=!0),t&&(n||a)&&(o=(o+(a?wd:r(n))).slice(-8e3),n="",a=!1),o}}}();let h,g,v=!1,b=!1;const x=e=>{if(b)return!1;try{return n(e),!0}catch(e){return b=!0,g=e,_(),!1}},y=t=>{if(m=f.push(t.toString().replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,"")),"dev"!==e.operation)return;if(!x({output:Ed(m)}))return;if(v)return;const n=m.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\]):\d+\/?/i);if(!n)return;v=!0;const i=n[0];x({url:i})&&o(i).then(()=>{x({browserOpened:!0})}).catch(e=>{x({browserError:e instanceof Error?e.message:String(e)})})};null==(p=d.stdout)||p.on("data",y),null==(u=d.stderr)||u.on("data",y);let w=!1;const _=()=>{if(r)return H(`${r}.cancel`,"",{flag:"w",mode:384}),void(null!=h||(h=setTimeout(()=>{um(d.pid),null!==d.exitCode||d.killed||d.kill("SIGTERM")},5e3)));um(d.pid),null!==d.exitCode||d.killed||d.kill("SIGTERM")};t.addEventListener("abort",_,{once:!0});const j="dev"===e.operation?null:setTimeout(()=>{w=!0,_()},9e5);if(d.once("error",e=>{j&&clearTimeout(j),t.removeEventListener("abort",_),l(e)}),d.once("close",e=>{if(h&&clearTimeout(h),r){const e=`${r}.cancel`;T(e)&&W(e)}j&&clearTimeout(j),t.removeEventListener("abort",_),b?l(g):(m=f.push("",!0),i({exitCode:w?124:null!=e?e:1,output:Ed(w?`${m}\nCommand timed out after 15 minutes.`:m)}))}),"dev"===e.operation&&d.pid){const e=im(d.pid);e?x({pid:d.pid,processIdentity:e,startedAt:Date.now()}):console.warn(`Could not record process identity for local dev job PID ${d.pid}; cancellation after CLI restart will be unavailable.`)}})}function mm(e){try{const t=new RegExp(e,"i");return{test:e=>t.test(e),mode:"regex"}}catch{const t=e.toLowerCase();return{test:e=>e.toLowerCase().includes(t),mode:"literal"}}}const fm=Ye(He),hm=String.raw`
|
|
1
|
+
import e from"node-fetch";import{File as t}from"@web-std/file";import n,{createHash as o,randomUUID as i}from"node:crypto";import{Command as a,Option as r}from"commander";import s,{existsSync as c,statSync as l,readFileSync as p,readdirSync as u,appendFileSync as d,mkdirSync as m,writeFileSync as f,realpathSync as h,lstatSync as g,readFile as v}from"fs";import{execFileSync as b}from"child_process";import x from"open";import y,{resolve as w,join as _,relative as j,isAbsolute as k,sep as S,dirname as E}from"path";import $ from"ora";import{existsSync as T,mkdirSync as I,renameSync as O,realpathSync as A,statSync as C,rename as R,appendFileSync as N,openSync as P,readSync as U,closeSync as L,createReadStream as z,constants as F,fstatSync as D,readdirSync as q,lstatSync as B,readFileSync as M,rmSync as W,writeFileSync as H,watch as G}from"node:fs";import{writeFile as J,readlink as V,readFile as K,readdir as Y,mkdir as Z,open as X,stat as Q,unlink as ee}from"node:fs/promises";import te,{homedir as ne,tmpdir as oe}from"node:os";import ie,{resolve as ae,relative as re,dirname as se,isAbsolute as ce,sep as le,join as pe,win32 as ue,posix as de,extname as me,basename as fe}from"node:path";import he from"util";import ge,{Readable as ve}from"stream";import be from"http";import xe from"https";import ye from"url";import we,{randomUUID as _e}from"crypto";import je from"net";import ke from"tls";import Se from"assert";import Ee from"tty";import $e,{homedir as Te,tmpdir as Ie}from"os";import Oe,{EventEmitter as Ae}from"events";import Ce from"http2";import Re from"zlib";import{Console as Ne}from"node:console";import{createInterface as Pe}from"node:readline/promises";import Ue from"dotenv";import Le from"@logto/node";import{createInterface as ze}from"node:readline";import{Readable as Fe}from"node:stream";import{createGzip as De}from"node:zlib";import{Router as qe}from"express";import Be,{WebSocketServer as Me}from"ws";import{execFileSync as We,execFile as He,spawnSync as Ge,spawn as Je}from"node:child_process";import{minimatch as Ve}from"minimatch";import{fileURLToPath as Ke}from"node:url";import{promisify as Ye}from"node:util";import Ze from"body-parser";import{setTimeout as Xe}from"node:timers/promises";const Qe="STRING",et="BOOLEAN",tt="NUMBER",nt="ARRAY";function ot(e){return e.replace(/[-_](\w)/g,(e,t)=>t.toUpperCase())}function it(e){const t=e.match(/--[\w-]+/g);return t?t[t.length-1]:e.split(/[\s,]+/)[0]}function at(e){return ot(it(e).replace(/^--/,""))}function rt(e){return ot(e.replace(/[[\]<>]/g,"").replace(/\.\.\.$/,"").trim())}function st(e,t){if(null==e)return e;switch(t){case et:{if("boolean"==typeof e)return e;const t=String(e).toLowerCase();return""===t||!["false","0","no","off"].includes(t)&&(!!["true","1","yes","on"].includes(t)||Boolean(e))}case tt:{const t=Number(e);return Number.isNaN(t)?e:t}case nt:return Array.isArray(e)?e:String(e).split(",");case Qe:return Array.isArray(e)?e:String(e);default:return e}}const ct={error:(...e)=>console.error(...e),warn:(...e)=>console.warn(...e),info:(...e)=>console.log(...e),debug:(...e)=>console.debug(...e),log:(...e)=>console.log(...e)};class lt{constructor(e,t){this.name=e,this.description=null!=t?t:"",this.visible=!0,this.strictOptions=!0,this._aliases=[],this._helpTexts=[],this._action=void 0,this.options=[],this.args=[]}alias(e){return this._aliases.push(e),this}getAliases(){return[...this._aliases]}configure(e={}){return void 0!==e.visible&&(this.visible=!1!==e.visible),void 0!==e.strictOptions&&(this.strictOptions=!1!==e.strictOptions),this}hide(){return this.visible=!1,this}help(e){return e&&this._helpTexts.push(e),this}option(e,t,n={}){return this.options.push({synopsis:e,description:null!=t?t:"",name:at(e),validator:n.validator,default:n.default,required:!0===n.required,hidden:!0===n.hidden}),this}argument(e,t,n={}){return this.args.push({synopsis:e,description:null!=t?t:"",name:rt(e),validator:n.validator,default:n.default}),this}action(e){return this._action=e,this}isHelpCommand(){return!1}}class pt{constructor(){this.STRING=Qe,this.BOOLEAN=et,this.NUMBER=tt,this.ARRAY=nt,this._version=void 0,this._description=void 0,this._name="needle-cloud",this._commands=[],this._exitOverride=!1,this._testHooks=null}version(e){return this._version=e,this}description(e){return this._description=e,this}name(e){return this._name=e,this}command(e,t){const n=new lt(e,t);return this._commands.push(n),n}getCommands(){return[...this._commands]}exitOverride(){return this._exitOverride=!0,this}async run(e){const t=this._build();try{return await t.parseAsync(null!=e?e:process.argv.slice(2),{from:"user"})}catch(t){var n,o,i;if(this._exitOverride)throw t;const a=null!=(n=null==(o=this._testHooks)?void 0:o.error)?n:e=>console.error(e);return a(`error: ${t instanceof Error&&t.message||String(t)}`),(null!=e?e:process.argv).includes("--verbose")&&t instanceof Error&&t.stack&&a(t.stack),null!=(i=this._testHooks)&&i.exit?this._testHooks.exit(1):process.exit(1)}}_build(){const e=new a(this._name);this._version&&e.version(this._version),this._description&&e.description(this._description),this._exitOverride&&e.exitOverride();const t=new Map,n=o=>{if(1===o.length)return e;const i=o.slice(0,-1).join(" ");let r=t.get(i);return r||(r=new a(o[o.length-2]),this._exitOverride&&r.exitOverride(),t.set(i,r),n(o.slice(0,-1)).addCommand(r)),r};for(const e of this._commands){const o=e.name.split(/\s+/),i=t.get(e.name),s=null!=i?i:new a(o[o.length-1]);t.set(e.name,s),s.description(e.description);for(const t of e._aliases)s.alias(t);for(const t of e._helpTexts)s.addHelpText("after","\n"+t);this._exitOverride&&s.exitOverride(),e.strictOptions||(s.allowUnknownOption(!0),s.allowExcessArguments(!0));for(const t of e.args)s.argument(t.synopsis,t.description);for(const t of e.options){let e=t.synopsis;t.validator&&!it(e).startsWith("--no-")&&(e=/[<[]/.test(e)?e.replace(/<([\w-]+)>/,"[$1]"):`${e} [value]`);const n=new r(e,t.description);t.hidden&&n.hideHelp(),t.required&&n.makeOptionMandatory(),s.addOption(n)}e._action&&s.action(async(...t)=>{var n;const o=null!=(n=t[e.args.length])?n:{},i={};e.args.forEach((e,n)=>{const o=t[n];i[e.name]=st(void 0===o?e.default:o,e.validator)});const a={};for(const t of e.options){if(it(t.synopsis).startsWith("--no-")){const e=ot(it(t.synopsis).replace(/^--no-/,""));a[t.name]=!1===o[e];continue}const e=o[t.name];a[t.name]=st(void 0===e?t.default:e,t.validator)}for(const[e,t]of Object.entries(o))e in a||(a[e]=t);await e._action({args:i,options:a,logger:ct,command:s})}),i||n(o).addCommand(s,{hidden:!e.visible})}return e}}function ut(){return new pt}var dt={program:ut(),createProgram:ut,STRING:Qe,BOOLEAN:et,NUMBER:tt,ARRAY:nt};class mt extends Error{constructor(e,t,n){super(n),this.name="ApiError",this.status=e,this.body=t}}const ft={status:"/v1/status",version:"/v1/version",api:"/v1/api",runtime_snapshots:{release_get:"/v1/runtime-releases",get:"/v1/runtime-snapshots/:hash",file:"/v1/runtime-snapshots/:hash/files/*"},usage:{get:"/v1/usage"},affiliate:{get:"/v1/affiliate/get",link_clicked:"/v1/affiliate/link_clicked"},account:{public_key:"/v1/account/public_key",post_machine:"/v1/account/machine",connect:"/v1/account/connect",get_licenses:"/v1/account/get/licenses",set_license_active:"/v1/account/set_license_active",set_licenses_active:"/v1/account/set_licenses_active",buy_licenses:"/v1/account/buy_licenses",update_licenses:"/v1/account/update_licenses",preview_invitation:"/v1/account/preview_invitation",update_payment_method:"/v1/account/update_payment_method",get_billing:"/v1/account/get_billing",generate_invoice:"/v1/account/generate_invoice",resume_subscription:"/v1/account/resume_subscription",cancel_subscription:"/v1/account/cancel_subscription",start_billingportal_session:"/v1/account/start_billingportal_session",post_preferences:"/v1/account/preferences",get_preferences:"/v1/account/preferences"},payment:{info:"/v1/payment/info",create:"/v1/payment/create"},ai:{llmstxt:"/v1/ai/llmstxt",chat:"/v1/ai/chat",chat_personal:"/v1/ai/chat/personal",list_chats:"/v1/ai/chat/list",chat_image:"/v1/ai/chat/image",chat_tool_result:"/v1/ai/chat/tool-result",chat_stop:"/v1/ai/chat/stop",chat_file_edits:"/v1/ai/file-edits",chat_file_edit_undo:"/v1/ai/file-edits/undo",chat_enqueue:"/v1/ai/chat/enqueue",chat_enqueue_cancel:"/v1/ai/chat/enqueue/cancel",ask:"/v1/ai/ask",completions:"/v1/ai/completions",evaluate:"/v1/ai/evaluate",post_settings:"/v1/ai/chat/settings",ws:"/v1/ws",cli_ws:"/v1/cli/ws"},organizations:{get:"/v1/organizations/get",orgs_details:"/v1/organizations/details",licenses:"/v1/organizations/licenses",get_invitations:"/v1/organizations/get_invitations"},events:{get:"/v1/events/get",post:"/v1/events/post",list:"/v1/events/list"},reports:{get:"/v1/reports/get",post:"/v1/reports/post"},diagnostics:{download_failed:"/v1/diagnostics/download-failed"},questionnaire:{get:"/v1/questionnaires/get",post:"/v1/questionnaires/post"},roadmap:{get:"/v1/roadmap/get",post_vote:"/v1/roadmap/post"},tokens:{create:"/v1/tokens/create",delete:"/v1/tokens/delete",list:"/v1/tokens/list"},get:{stats:"/v1/get/stats",jobs:"/v1/list/jobs",deployments:"/v1/list/deployments",discounts:"/v1/get/discounts"},files:{entry:"/v1/files/:identifier/:version/",file:"/v1/files/:identifier/:version/*"},view:{get_analytics:"/v1/view/analytics",get_public_info:"/v1/view/public/info",post_version:"/v1/view/post_version"},content:{root:"/v1/content",download:"/v1/content/download",detail:"/v1/content/:identifier",update:"/v1/content/:identifier",delete:"/v1/content/:identifier",restore:"/v1/content/:identifier/restore",visits:"/v1/content/:identifier/visits",domains:"/v1/content/:identifier/domains",domain_item:"/v1/content/:identifier/domains/:hostname",domain_verify:"/v1/content/:identifier/domains/:hostname/verify"},analytics:{content_list:"/v1/analytics/content-list"},public:{content_list:"/v1/public/content",content_detail:"/v1/public/content/:identifier"},collections:{list:"/v1/collections/list",get:"/v1/collections/get",create:"/v1/collections/create",update:"/v1/collections/update",delete:"/v1/collections/delete",add_item:"/v1/collections/add-item",remove_item:"/v1/collections/remove-item",reorder_items:"/v1/collections/reorder-items"},projects:{create:"/v1/projects/create",list:"/v1/projects/list",head:"/v1/projects/head",push:"/v1/projects/push",pull:"/v1/projects/pull",delete:"/v1/projects/delete",restore:"/v1/projects/restore",archive:"/v1/projects/archive",unarchive:"/v1/projects/unarchive",clone:"/v1/projects/clone",update:"/v1/projects/update",blobs_check:"/v1/projects/blobs/check",blobs_upload:"/v1/projects/blobs/upload",blobs_complete:"/v1/projects/blobs/complete",blobs_download:"/v1/projects/blobs/download",revisions:"/v1/projects/revisions",revisions_update:"/v1/projects/revisions/update",deployments:"/v1/projects/deployments",promote:"/v1/projects/promote",promotions:"/v1/projects/promotions"},upload:{request:"/v1/upload/request",request_put_url:"/v1/upload/put",update_results:"/v1/upload/results",done:"/v1/upload/done",cancel:"/v1/upload/cancel",multipart_create:"/v1/upload/multipart/create",multipart_part_urls:"/v1/upload/multipart/part-urls",multipart_complete:"/v1/upload/multipart/complete",multipart_abort:"/v1/upload/multipart/abort"},jobs:{create:"/v1/jobs/create",get_id:"/v1/jobs/get_id",presigned_url:"/v1/jobs/presigned-url",presigned_urls:"/v1/jobs/presigned-urls",download_urls:"/v1/jobs/download-urls",request_restart:"/v1/jobs/restart",delete:"/v1/jobs/delete",post_update:"/v1/jobs/update",post_results_stats:"/v1/jobs/results_stats",post_usage:"/v1/jobs/post_usage",get_status:"/v1/jobs/status",get_org:"/v1/jobs/org",query:"/v1/jobs/query",request_job_that_needs_stats:"/v1/jobs/job_needs_stats"},worker:{get_available_count:"/v1/worker/get_available_count"},local_projects:{get:{user:"/v1/local_projects/user",by_id:"/v1/local_projects/"},post:"/v1/local_projects"}};function ht(e){const t={authorization:"Bearer "+e.authToken};return e.org&&(t["x-needle-cloud-org"]=e.org),e.roles&&(t.roles=e.roles.join(",")),e.roles_org&&(t.roles_org=e.roles_org.join(",")),t}const gt={credentials:"omit"};async function vt(e,t){const n=e.baseUrl+ft.account.get_licenses,o={...{...t},...ht(e)},i=await fetch(n,{...gt,method:"GET",headers:o}).catch(e=>(console.error(e),null));return i?i.ok?(await i.json()).licenses:(console.error(i.statusText,await i.text()),[]):[]}function bt(e,t=void 0){let n=e.baseUrl+`/v1/files/${e.content_id}`;if(n+=e.job_id&&!0!==(null==t?void 0:t.latest)?"/"+e.job_id:"/latest",n+="/",e.filename){const t=e.filename.split("/");for(let e=0;e<t.length;e++){const o=t[e].trim();0!==o.length&&(n+=encodeURIComponent(o),e<t.length-1&&(n+="/"))}}return!0===(null==t?void 0:t.progressive)?n+="?progressive=1":!1===(null==t?void 0:t.progressive)&&(n+="?progressive=0"),n}function xt(e,t){return function(){return e.apply(t,arguments)}}const{toString:yt}=Object.prototype,{getPrototypeOf:wt}=Object,{iterator:_t,toStringTag:jt}=Symbol,kt=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),St=(e,t)=>{let n=e;const o=[];for(;null!=n&&n!==Object.prototype;){if(-1!==o.indexOf(n))return!1;if(o.push(n),kt(n,t))return!0;n=wt(n)}return!1},Et=($t=Object.create(null),e=>{const t=yt.call(e);return $t[t]||($t[t]=t.slice(8,-1).toLowerCase())});var $t;const Tt=e=>(e=e.toLowerCase(),t=>Et(t)===e),It=e=>t=>typeof t===e,{isArray:Ot}=Array,At=It("undefined");function Ct(e){return null!==e&&!At(e)&&null!==e.constructor&&!At(e.constructor)&&Pt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Rt=Tt("ArrayBuffer"),Nt=It("string"),Pt=It("function"),Ut=It("number"),Lt=e=>null!==e&&"object"==typeof e,zt=e=>{if(!Lt(e))return!1;const t=wt(e);return!(null!==t&&t!==Object.prototype&&null!==wt(t)||St(e,jt)||St(e,_t))},Ft=Tt("Date"),Dt=Tt("File"),qt=Tt("Blob"),Bt=Tt("FileList"),Mt=Tt("Set"),Wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Ht=void 0!==Wt.FormData?Wt.FormData:void 0,Gt=Tt("URLSearchParams"),[Jt,Vt,Kt,Yt]=["ReadableStream","Request","Response","Headers"].map(Tt);function Zt(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let o,i;if("object"!=typeof e&&(e=[e]),Ot(e))for(o=0,i=e.length;o<i;o++)t.call(null,e[o],o,e);else{if(Ct(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let r;for(o=0;o<a;o++)r=i[o],t.call(null,e[r],r,e)}}function Xt(e,t){if(Ct(e))return null;t=t.toLowerCase();const n=Object.keys(e);let o,i=n.length;for(;i-- >0;)if(o=n[i],t===o.toLowerCase())return o;return null}const Qt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,en=e=>!At(e)&&e!==Qt,tn=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&wt(Uint8Array)),nn=Tt("HTMLFormElement"),{propertyIsEnumerable:on}=Object.prototype,an=Tt("RegExp"),rn=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};Zt(n,(n,i)=>{let a;!1!==(a=t(n,i,e))&&(o[i]=a||n)}),Object.defineProperties(e,o)},sn=Tt("AsyncFunction"),cn=(ln="function"==typeof setImmediate,pn=Pt(Qt.postMessage),ln?setImmediate:pn?(un=`axios@${Math.random()}`,dn=[],Qt.addEventListener("message",({source:e,data:t})=>{e===Qt&&t===un&&dn.length&&dn.shift()()},!1),e=>{dn.push(e),Qt.postMessage(un,"*")}):e=>setTimeout(e));var ln,pn,un,dn;const mn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Qt):"undefined"!=typeof process&&process.nextTick||cn,fn=e=>null!=e&&Pt(e[_t]);var hn={isArray:Ot,isArrayBuffer:Rt,isBuffer:Ct,isFormData:e=>{if(!e)return!1;if(Ht&&e instanceof Ht)return!0;const t=wt(e);if(!t||t===Object.prototype)return!1;if(!Pt(e.append))return!1;const n=Et(e);return"formdata"===n||"object"===n&&Pt(e.toString)&&"[object FormData]"===e.toString()},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Rt(e.buffer),t},isString:Nt,isNumber:Ut,isBoolean:e=>!0===e||!1===e,isObject:Lt,isPlainObject:zt,isEmptyObject:e=>{if(!Lt(e)||Ct(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Jt,isRequest:Vt,isResponse:Kt,isHeaders:Yt,isUndefined:At,isDate:Ft,isFile:Dt,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:qt,isRegExp:an,isFunction:Pt,isStream:e=>Lt(e)&&Pt(e.pipe),isURLSearchParams:Gt,isTypedArray:tn,isFileList:Bt,forEach:Zt,merge:function e(...t){const{caseless:n,skipUndefined:o}=en(this)&&this||{},i={},a=(t,a)=>{if("__proto__"===a||"constructor"===a||"prototype"===a)return;const r=n&&"string"==typeof a&&Xt(i,a)||a,s=kt(i,r)?i[r]:void 0;zt(s)&&zt(t)?i[r]=e(s,t):zt(t)?i[r]=e({},t):Ot(t)?i[r]=t.slice():o&&At(t)||(i[r]=t)};for(let e=0,n=t.length;e<n;e++){const n=t[e];if(!n||Ct(n))continue;if(Zt(n,a),"object"!=typeof n||Ot(n))continue;const o=Object.getOwnPropertySymbols(n);for(let e=0;e<o.length;e++){const t=o[e];on.call(n,t)&&a(n[t],t)}}return i},extend:(e,t,n,{allOwnKeys:o}={})=>(Zt(t,(t,o)=>{n&&Pt(t)?Object.defineProperty(e,o,{__proto__:null,value:xt(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,o)=>{e.prototype=Object.create(t.prototype,o),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,o)=>{let i,a,r;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)r=i[a],o&&!o(r,e,t)||s[r]||(t[r]=e[r],s[r]=!0);e=!1!==n&&wt(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Et,kindOfTest:Tt,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length);const o=e.indexOf(t,n-=t.length);return-1!==o&&o===n},toArray:e=>{if(!e)return null;if(Ot(e))return e;let t=e.length;if(!Ut(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[_t]).call(e);let o;for(;(o=n.next())&&!o.done;){const n=o.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const o=[];for(;null!==(n=e.exec(t));)o.push(n);return o},isHTMLForm:nn,hasOwnProperty:kt,hasOwnProp:kt,hasOwnInPrototypeChain:St,getSafeProp:(e,t)=>null!=e&&St(e,t)?e[t]:void 0,reduceDescriptors:rn,freezeMethods:e=>{rn(e,(t,n)=>{if(Pt(e)&&["arguments","caller","callee"].includes(n))return!1;Pt(e[n])&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},o=e=>{e.forEach(e=>{n[e]=!0})};return Ot(e)?o(e):o(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Xt,global:Qt,isContextDefined:en,isSpecCompliantForm:function(e){return!!(e&&Pt(e.append)&&"FormData"===e[jt]&&e[_t])},toJSONObject:e=>{const t=new WeakSet,n=e=>{if(Lt(e)){if(t.has(e))return;if(Ct(e))return e;if(!("toJSON"in e)){let o;if(t.add(e),Mt(e)){o=[];for(const t of e){const e=n(t);!At(e)&&o.push(e)}}else o=Ot(e)?[]:{},Zt(e,(e,t)=>{const i=n(e);!At(i)&&(o[t]=i)});return t.delete(e),o}}return e};return n(e)},isAsyncFn:sn,isThenable:e=>e&&(Lt(e)||Pt(e))&&Pt(e.then)&&Pt(e.catch),setImmediate:cn,asap:mn,isIterable:fn,isSafeIterable:e=>null!=e&&St(e,_t)&&fn(e)};const gn=hn.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),vn=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),bn=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function xn(e,t){return hn.isArray(e)?e.map(e=>xn(e,t)):function(e){let t=0,n=e.length;for(;t<n;){const n=e.charCodeAt(t);if(9!==n&&32!==n)break;t+=1}for(;n>t;){const t=e.charCodeAt(n-1);if(9!==t&&32!==t)break;n-=1}return 0===t&&n===e.length?e:e.slice(t,n)}(String(e).replace(t,""))}function yn(e){const t=Object.create(null);return hn.forEach(e.toJSON(),(e,n)=>{t[n]=(e=>xn(e,bn))(e)}),t}const wn=Symbol("internals");function _n(e){return e&&String(e).trim().toLowerCase()}function jn(e){return!1===e||null==e?e:hn.isArray(e)?e.map(jn):(e=>xn(e,vn))(String(e))}const kn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Sn(e){let t=0,n=e.length;for(;t<n;){const n=e.charCodeAt(t);if(9!==n&&32!==n)break;t+=1}for(;n>t;){const t=e.charCodeAt(n-1);if(9!==t&&32!==t)break;n-=1}return 0===t&&n===e.length?e:e.slice(t,n)}function En(e,t,n,o,i){return hn.isFunction(o)?o.call(this,t,n):(i&&(t=n),hn.isString(t)?hn.isString(o)?-1!==t.indexOf(o):hn.isRegExp(o)?o.test(t):void 0:void 0)}class $n{constructor(e){e&&this.set(e)}set(e,t,n){const o=this;function i(e,t,n){const i=_n(t);if(!i)return;const a=hn.findKey(o,i);(!a||void 0===o[a]||!0===n||void 0===n&&!1!==o[a])&&(o[a||t]=jn(e))}const a=(e,t)=>hn.forEach(e,(e,n)=>i(e,n,t));if(hn.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(hn.isString(e)&&(e=e.trim())&&!(e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))(e))a((e=>{const t={};let n,o,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),o=e.substring(i+1).trim();const a=hn.hasOwnProp(t,n);!n||a&&hn.hasOwnProp(gn,n)||("set-cookie"===n?a?t[n].push(o):t[n]=[o]:t[n]=a?t[n]+", "+o:o)}),t})(e),t);else if(hn.isObject(e)&&hn.isSafeIterable(e)){let n,o,i=Object.create(null);for(const t of e){if(!hn.isArray(t))throw new TypeError("Object iterator must return a key-value pair");o=t[0],hn.hasOwnProp(i,o)?(n=i[o],i[o]=hn.isArray(n)?[...n,t[1]]:[n,t[1]]):i[o]=t[1]}a(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=_n(e)){const n=hn.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=n.exec(e);)t[o[1]]=o[2];return t}(e);if(hn.isFunction(t))return t.call(this,e,n);if(hn.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=_n(e)){const n=hn.findKey(this,e);return!(!n||void 0===this[n]||t&&!En(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function i(e){if(e=_n(e)){const i=hn.findKey(n,e);!i||t&&!En(0,n[i],i,t)||(delete n[i],o=!0)}}return hn.isArray(e)?e.forEach(i):i(e),o}clear(e){const t=Object.keys(this);let n=t.length,o=!1;for(;n--;){const i=t[n];e&&!En(0,this[i],i,e,!0)||(delete this[i],o=!0)}return o}normalize(e){const t=this,n={};return hn.forEach(this,(o,i)=>{const a=hn.findKey(n,i);if(a)return t[a]=jn(o),void delete t[i];const r=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();r!==i&&delete t[i],t[r]=jn(o),n[r]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return hn.forEach(this,(n,o)=>{null!=n&&!1!==n&&(t[o]=e&&hn.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){const e=this.get("set-cookie");return hn.isArray(e)?e:null==e||!1===e?[]:[e]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static parseParameters(e){return function(e){const t=Object.create(null),n=String(e);let o=0,i=!1,a=!1;function r(e){const i=Sn(n.slice(o,e)),a=i.indexOf("=");if(a<1)return;const r=Sn(i.slice(0,a));if(!kn.test(r))return;const s=r.toLowerCase();if("__proto__"===s||"constructor"===s||"prototype"===s)return;const c=Sn(i.slice(a+1));t[s]=function(e){const t=e.length-1;if(t<1||34!==e.charCodeAt(0)||34!==e.charCodeAt(t))return e;let n="";for(let o=1;o<t;o++){const i=e.charCodeAt(o);if(34===i)return e;if(92===i&&(o+=1,o>=t))return e;n+=e[o]}return n}(c)}for(let e=0;e<n.length;e++){const t=n.charCodeAt(e);i?a?a=!1:92===t?a=!0:34===t&&(i=!1):34===t?i=!0:44!==t&&59!==t||(r(e),o=e+1)}return r(n.length),t}(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[wn]=this[wn]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=_n(e);t[o]||(function(e,t){const n=hn.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+n,{__proto__:null,value:function(e,n,i){return this[o].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[o]=!0)}return hn.isArray(e)?e.forEach(o):o(e),this}}$n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),hn.reduceDescriptors($n.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),hn.freezeMethods($n);var Tn=$n;const In="[REDACTED ****]";class On extends Error{static from(e,t,n,o,i,a){let r=e.message;!r&&hn.isArray(e.errors)&&e.errors.length&&(r=function(e){return e.errors.map(e=>{try{return function(e){try{return String(e)}catch(e){return""}}(e&&e.message?e.message:e)}catch(e){return""}}).filter(Boolean).join("; ")||e.name||"AggregateError"}(e));const s=new On(r,t||e.code,n,o,i);return Object.defineProperty(s,"cause",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),s.name=e.name,null!=e.status&&null==s.status&&(s.status=e.status),a&&Object.assign(s,a),s}constructor(e,t,n,o,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){const e=this.config,t=e&&hn.hasOwnProp(e,"redact")?e.redact:void 0,n=hn.isArray(t)&&t.length>0?function(e,t){const n=new Set(t.map(e=>String(e).toLowerCase())),o=[],i=e=>{if(null===e||"object"!=typeof e)return e;if(hn.isBuffer(e))return e;if(-1!==o.indexOf(e))return;let t;if(e instanceof Tn&&(e=e.toJSON()),o.push(e),hn.isArray(e))t=[],e.forEach((e,n)=>{const o=i(e);hn.isUndefined(o)||(t[n]=o)});else{if(!hn.isPlainObject(e)&&function(e){if(hn.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(hn.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}(e))return o.pop(),e;t=Object.create(null);for(const[o,a]of Object.entries(e)){const e=n.has(o.toLowerCase())?In:i(a);hn.isUndefined(e)||(t[o]=e)}}return o.pop(),t};return i(e)}(e,t):hn.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}}On.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",On.ERR_BAD_OPTION="ERR_BAD_OPTION",On.ECONNABORTED="ECONNABORTED",On.ETIMEDOUT="ETIMEDOUT",On.ECONNREFUSED="ECONNREFUSED",On.ERR_NETWORK="ERR_NETWORK",On.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",On.ERR_DEPRECATED="ERR_DEPRECATED",On.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",On.ERR_BAD_REQUEST="ERR_BAD_REQUEST",On.ERR_CANCELED="ERR_CANCELED",On.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",On.ERR_INVALID_URL="ERR_INVALID_URL",On.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var An=On,Cn=ge.Stream,Rn=Nn;function Nn(){this.source=null,this.dataSize=0,this.maxDataSize=1048576,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}he.inherits(Nn,Cn),Nn.create=function(e,t){var n=new this;for(var o in t=t||{})n[o]=t[o];n.source=e;var i=e.emit;return e.emit=function(){return n._handleEmit(arguments),i.apply(e,arguments)},e.on("error",function(){}),n.pauseStream&&e.pause(),n},Object.defineProperty(Nn.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}}),Nn.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)},Nn.prototype.resume=function(){this._released||this.release(),this.source.resume()},Nn.prototype.pause=function(){this.source.pause()},Nn.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(e){this.emit.apply(this,e)}.bind(this)),this._bufferedEvents=[]},Nn.prototype.pipe=function(){var e=Cn.prototype.pipe.apply(this,arguments);return this.resume(),e},Nn.prototype._handleEmit=function(e){this._released?this.emit.apply(this,e):("data"===e[0]&&(this.dataSize+=e[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(e))},Nn.prototype._checkIfMaxDataSizeExceeded=function(){this._maxDataSizeExceeded||this.dataSize<=this.maxDataSize||(this._maxDataSizeExceeded=!0,this.emit("error",new Error("DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.")))};var Pn=ge.Stream,Un=Ln;function Ln(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2097152,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}he.inherits(Ln,Pn),Ln.create=function(e){var t=new this;for(var n in e=e||{})t[n]=e[n];return t},Ln.isStreamLike=function(e){return"function"!=typeof e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Buffer.isBuffer(e)},Ln.prototype.append=function(e){if(Ln.isStreamLike(e)){if(!(e instanceof Rn)){var t=Rn.create(e,{maxDataSize:Infinity,pauseStream:this.pauseStreams});e.on("data",this._checkDataSize.bind(this)),e=t}this._handleErrors(e),this.pauseStreams&&e.pause()}return this._streams.push(e),this},Ln.prototype.pipe=function(e,t){return Pn.prototype.pipe.call(this,e,t),this.resume(),e},Ln.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop)this._pendingNext=!0;else{this._insideLoop=!0;try{do{this._pendingNext=!1,this._realGetNext()}while(this._pendingNext)}finally{this._insideLoop=!1}}},Ln.prototype._realGetNext=function(){var e=this._streams.shift();void 0!==e?"function"==typeof e?e(function(e){Ln.isStreamLike(e)&&(e.on("data",this._checkDataSize.bind(this)),this._handleErrors(e)),this._pipeNext(e)}.bind(this)):this._pipeNext(e):this.end()},Ln.prototype._pipeNext=function(e){if(this._currentStream=e,Ln.isStreamLike(e))return e.on("end",this._getNext.bind(this)),void e.pipe(this,{end:!1});this.write(e),this._getNext()},Ln.prototype._handleErrors=function(e){var t=this;e.on("error",function(e){t._emitError(e)})},Ln.prototype.write=function(e){this.emit("data",e)},Ln.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.pause&&this._currentStream.pause(),this.emit("pause"))},Ln.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.resume&&this._currentStream.resume(),this.emit("resume")},Ln.prototype.end=function(){this._reset(),this.emit("end")},Ln.prototype.destroy=function(){this._reset(),this.emit("close")},Ln.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null},Ln.prototype._checkDataSize=function(){this._updateDataSize(),this.dataSize<=this.maxDataSize||this._emitError(new Error("DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded."))},Ln.prototype._updateDataSize=function(){this.dataSize=0;var e=this;this._streams.forEach(function(t){t.dataSize&&(e.dataSize+=t.dataSize)}),this._currentStream&&this._currentStream.dataSize&&(this.dataSize+=this._currentStream.dataSize)},Ln.prototype._emitError=function(e){this._reset(),this.emit("error",e)};var zn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Fn(e){var t={exports:{}};return e(t,t.exports),t.exports}var Dn={"application/1d-interleaved-parityfec":{source:"iana"},"application/3gpdash-qoe-report+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/3gpp-ims+xml":{source:"iana",compressible:!0},"application/3gpphal+json":{source:"iana",compressible:!0},"application/3gpphalforms+json":{source:"iana",compressible:!0},"application/a2l":{source:"iana"},"application/ace+cbor":{source:"iana"},"application/activemessage":{source:"iana"},"application/activity+json":{source:"iana",compressible:!0},"application/alto-costmap+json":{source:"iana",compressible:!0},"application/alto-costmapfilter+json":{source:"iana",compressible:!0},"application/alto-directory+json":{source:"iana",compressible:!0},"application/alto-endpointcost+json":{source:"iana",compressible:!0},"application/alto-endpointcostparams+json":{source:"iana",compressible:!0},"application/alto-endpointprop+json":{source:"iana",compressible:!0},"application/alto-endpointpropparams+json":{source:"iana",compressible:!0},"application/alto-error+json":{source:"iana",compressible:!0},"application/alto-networkmap+json":{source:"iana",compressible:!0},"application/alto-networkmapfilter+json":{source:"iana",compressible:!0},"application/alto-updatestreamcontrol+json":{source:"iana",compressible:!0},"application/alto-updatestreamparams+json":{source:"iana",compressible:!0},"application/aml":{source:"iana"},"application/andrew-inset":{source:"iana",extensions:["ez"]},"application/applefile":{source:"iana"},"application/applixware":{source:"apache",extensions:["aw"]},"application/at+jwt":{source:"iana"},"application/atf":{source:"iana"},"application/atfx":{source:"iana"},"application/atom+xml":{source:"iana",compressible:!0,extensions:["atom"]},"application/atomcat+xml":{source:"iana",compressible:!0,extensions:["atomcat"]},"application/atomdeleted+xml":{source:"iana",compressible:!0,extensions:["atomdeleted"]},"application/atomicmail":{source:"iana"},"application/atomsvc+xml":{source:"iana",compressible:!0,extensions:["atomsvc"]},"application/atsc-dwd+xml":{source:"iana",compressible:!0,extensions:["dwd"]},"application/atsc-dynamic-event-message":{source:"iana"},"application/atsc-held+xml":{source:"iana",compressible:!0,extensions:["held"]},"application/atsc-rdt+json":{source:"iana",compressible:!0},"application/atsc-rsat+xml":{source:"iana",compressible:!0,extensions:["rsat"]},"application/atxml":{source:"iana"},"application/auth-policy+xml":{source:"iana",compressible:!0},"application/bacnet-xdd+zip":{source:"iana",compressible:!1},"application/batch-smtp":{source:"iana"},"application/bdoc":{compressible:!1,extensions:["bdoc"]},"application/beep+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/calendar+json":{source:"iana",compressible:!0},"application/calendar+xml":{source:"iana",compressible:!0,extensions:["xcs"]},"application/call-completion":{source:"iana"},"application/cals-1840":{source:"iana"},"application/captive+json":{source:"iana",compressible:!0},"application/cbor":{source:"iana"},"application/cbor-seq":{source:"iana"},"application/cccex":{source:"iana"},"application/ccmp+xml":{source:"iana",compressible:!0},"application/ccxml+xml":{source:"iana",compressible:!0,extensions:["ccxml"]},"application/cdfx+xml":{source:"iana",compressible:!0,extensions:["cdfx"]},"application/cdmi-capability":{source:"iana",extensions:["cdmia"]},"application/cdmi-container":{source:"iana",extensions:["cdmic"]},"application/cdmi-domain":{source:"iana",extensions:["cdmid"]},"application/cdmi-object":{source:"iana",extensions:["cdmio"]},"application/cdmi-queue":{source:"iana",extensions:["cdmiq"]},"application/cdni":{source:"iana"},"application/cea":{source:"iana"},"application/cea-2018+xml":{source:"iana",compressible:!0},"application/cellml+xml":{source:"iana",compressible:!0},"application/cfw":{source:"iana"},"application/city+json":{source:"iana",compressible:!0},"application/clr":{source:"iana"},"application/clue+xml":{source:"iana",compressible:!0},"application/clue_info+xml":{source:"iana",compressible:!0},"application/cms":{source:"iana"},"application/cnrp+xml":{source:"iana",compressible:!0},"application/coap-group+json":{source:"iana",compressible:!0},"application/coap-payload":{source:"iana"},"application/commonground":{source:"iana"},"application/conference-info+xml":{source:"iana",compressible:!0},"application/cose":{source:"iana"},"application/cose-key":{source:"iana"},"application/cose-key-set":{source:"iana"},"application/cpl+xml":{source:"iana",compressible:!0,extensions:["cpl"]},"application/csrattrs":{source:"iana"},"application/csta+xml":{source:"iana",compressible:!0},"application/cstadata+xml":{source:"iana",compressible:!0},"application/csvm+json":{source:"iana",compressible:!0},"application/cu-seeme":{source:"apache",extensions:["cu"]},"application/cwt":{source:"iana"},"application/cybercash":{source:"iana"},"application/dart":{compressible:!0},"application/dash+xml":{source:"iana",compressible:!0,extensions:["mpd"]},"application/dash-patch+xml":{source:"iana",compressible:!0,extensions:["mpp"]},"application/dashdelta":{source:"iana"},"application/davmount+xml":{source:"iana",compressible:!0,extensions:["davmount"]},"application/dca-rft":{source:"iana"},"application/dcd":{source:"iana"},"application/dec-dx":{source:"iana"},"application/dialog-info+xml":{source:"iana",compressible:!0},"application/dicom":{source:"iana"},"application/dicom+json":{source:"iana",compressible:!0},"application/dicom+xml":{source:"iana",compressible:!0},"application/dii":{source:"iana"},"application/dit":{source:"iana"},"application/dns":{source:"iana"},"application/dns+json":{source:"iana",compressible:!0},"application/dns-message":{source:"iana"},"application/docbook+xml":{source:"apache",compressible:!0,extensions:["dbk"]},"application/dots+cbor":{source:"iana"},"application/dskpp+xml":{source:"iana",compressible:!0},"application/dssc+der":{source:"iana",extensions:["dssc"]},"application/dssc+xml":{source:"iana",compressible:!0,extensions:["xdssc"]},"application/dvcs":{source:"iana"},"application/ecmascript":{source:"iana",compressible:!0,extensions:["es","ecma"]},"application/edi-consent":{source:"iana"},"application/edi-x12":{source:"iana",compressible:!1},"application/edifact":{source:"iana",compressible:!1},"application/efi":{source:"iana"},"application/elm+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/elm+xml":{source:"iana",compressible:!0},"application/emergencycalldata.cap+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/emergencycalldata.comment+xml":{source:"iana",compressible:!0},"application/emergencycalldata.control+xml":{source:"iana",compressible:!0},"application/emergencycalldata.deviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.ecall.msd":{source:"iana"},"application/emergencycalldata.providerinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.serviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.subscriberinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.veds+xml":{source:"iana",compressible:!0},"application/emma+xml":{source:"iana",compressible:!0,extensions:["emma"]},"application/emotionml+xml":{source:"iana",compressible:!0,extensions:["emotionml"]},"application/encaprtp":{source:"iana"},"application/epp+xml":{source:"iana",compressible:!0},"application/epub+zip":{source:"iana",compressible:!1,extensions:["epub"]},"application/eshop":{source:"iana"},"application/exi":{source:"iana",extensions:["exi"]},"application/expect-ct-report+json":{source:"iana",compressible:!0},"application/express":{source:"iana",extensions:["exp"]},"application/fastinfoset":{source:"iana"},"application/fastsoap":{source:"iana"},"application/fdt+xml":{source:"iana",compressible:!0,extensions:["fdt"]},"application/fhir+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/fhir+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/fido.trusted-apps+json":{compressible:!0},"application/fits":{source:"iana"},"application/flexfec":{source:"iana"},"application/font-sfnt":{source:"iana"},"application/font-tdpfr":{source:"iana",extensions:["pfr"]},"application/font-woff":{source:"iana",compressible:!1},"application/framework-attributes+xml":{source:"iana",compressible:!0},"application/geo+json":{source:"iana",compressible:!0,extensions:["geojson"]},"application/geo+json-seq":{source:"iana"},"application/geopackage+sqlite3":{source:"iana"},"application/geoxacml+xml":{source:"iana",compressible:!0},"application/gltf-buffer":{source:"iana"},"application/gml+xml":{source:"iana",compressible:!0,extensions:["gml"]},"application/gpx+xml":{source:"apache",compressible:!0,extensions:["gpx"]},"application/gxf":{source:"apache",extensions:["gxf"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/h224":{source:"iana"},"application/held+xml":{source:"iana",compressible:!0},"application/hjson":{extensions:["hjson"]},"application/http":{source:"iana"},"application/hyperstudio":{source:"iana",extensions:["stk"]},"application/ibe-key-request+xml":{source:"iana",compressible:!0},"application/ibe-pkg-reply+xml":{source:"iana",compressible:!0},"application/ibe-pp-data":{source:"iana"},"application/iges":{source:"iana"},"application/im-iscomposing+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/index":{source:"iana"},"application/index.cmd":{source:"iana"},"application/index.obj":{source:"iana"},"application/index.response":{source:"iana"},"application/index.vnd":{source:"iana"},"application/inkml+xml":{source:"iana",compressible:!0,extensions:["ink","inkml"]},"application/iotp":{source:"iana"},"application/ipfix":{source:"iana",extensions:["ipfix"]},"application/ipp":{source:"iana"},"application/isup":{source:"iana"},"application/its+xml":{source:"iana",compressible:!0,extensions:["its"]},"application/java-archive":{source:"apache",compressible:!1,extensions:["jar","war","ear"]},"application/java-serialized-object":{source:"apache",compressible:!1,extensions:["ser"]},"application/java-vm":{source:"apache",compressible:!1,extensions:["class"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/jf2feed+json":{source:"iana",compressible:!0},"application/jose":{source:"iana"},"application/jose+json":{source:"iana",compressible:!0},"application/jrd+json":{source:"iana",compressible:!0},"application/jscalendar+json":{source:"iana",compressible:!0},"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/json-patch+json":{source:"iana",compressible:!0},"application/json-seq":{source:"iana"},"application/json5":{extensions:["json5"]},"application/jsonml+json":{source:"apache",compressible:!0,extensions:["jsonml"]},"application/jwk+json":{source:"iana",compressible:!0},"application/jwk-set+json":{source:"iana",compressible:!0},"application/jwt":{source:"iana"},"application/kpml-request+xml":{source:"iana",compressible:!0},"application/kpml-response+xml":{source:"iana",compressible:!0},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/lgr+xml":{source:"iana",compressible:!0,extensions:["lgr"]},"application/link-format":{source:"iana"},"application/load-control+xml":{source:"iana",compressible:!0},"application/lost+xml":{source:"iana",compressible:!0,extensions:["lostxml"]},"application/lostsync+xml":{source:"iana",compressible:!0},"application/lpf+zip":{source:"iana",compressible:!1},"application/lxf":{source:"iana"},"application/mac-binhex40":{source:"iana",extensions:["hqx"]},"application/mac-compactpro":{source:"apache",extensions:["cpt"]},"application/macwriteii":{source:"iana"},"application/mads+xml":{source:"iana",compressible:!0,extensions:["mads"]},"application/manifest+json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/marc":{source:"iana",extensions:["mrc"]},"application/marcxml+xml":{source:"iana",compressible:!0,extensions:["mrcx"]},"application/mathematica":{source:"iana",extensions:["ma","nb","mb"]},"application/mathml+xml":{source:"iana",compressible:!0,extensions:["mathml"]},"application/mathml-content+xml":{source:"iana",compressible:!0},"application/mathml-presentation+xml":{source:"iana",compressible:!0},"application/mbms-associated-procedure-description+xml":{source:"iana",compressible:!0},"application/mbms-deregister+xml":{source:"iana",compressible:!0},"application/mbms-envelope+xml":{source:"iana",compressible:!0},"application/mbms-msk+xml":{source:"iana",compressible:!0},"application/mbms-msk-response+xml":{source:"iana",compressible:!0},"application/mbms-protection-description+xml":{source:"iana",compressible:!0},"application/mbms-reception-report+xml":{source:"iana",compressible:!0},"application/mbms-register+xml":{source:"iana",compressible:!0},"application/mbms-register-response+xml":{source:"iana",compressible:!0},"application/mbms-schedule+xml":{source:"iana",compressible:!0},"application/mbms-user-service-description+xml":{source:"iana",compressible:!0},"application/mbox":{source:"iana",extensions:["mbox"]},"application/media-policy-dataset+xml":{source:"iana",compressible:!0,extensions:["mpf"]},"application/media_control+xml":{source:"iana",compressible:!0},"application/mediaservercontrol+xml":{source:"iana",compressible:!0,extensions:["mscml"]},"application/merge-patch+json":{source:"iana",compressible:!0},"application/metalink+xml":{source:"apache",compressible:!0,extensions:["metalink"]},"application/metalink4+xml":{source:"iana",compressible:!0,extensions:["meta4"]},"application/mets+xml":{source:"iana",compressible:!0,extensions:["mets"]},"application/mf4":{source:"iana"},"application/mikey":{source:"iana"},"application/mipc":{source:"iana"},"application/missing-blocks+cbor-seq":{source:"iana"},"application/mmt-aei+xml":{source:"iana",compressible:!0,extensions:["maei"]},"application/mmt-usd+xml":{source:"iana",compressible:!0,extensions:["musd"]},"application/mods+xml":{source:"iana",compressible:!0,extensions:["mods"]},"application/moss-keys":{source:"iana"},"application/moss-signature":{source:"iana"},"application/mosskey-data":{source:"iana"},"application/mosskey-request":{source:"iana"},"application/mp21":{source:"iana",extensions:["m21","mp21"]},"application/mp4":{source:"iana",extensions:["mp4s","m4p"]},"application/mpeg4-generic":{source:"iana"},"application/mpeg4-iod":{source:"iana"},"application/mpeg4-iod-xmt":{source:"iana"},"application/mrb-consumer+xml":{source:"iana",compressible:!0},"application/mrb-publish+xml":{source:"iana",compressible:!0},"application/msc-ivr+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msc-mixer+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msword":{source:"iana",compressible:!1,extensions:["doc","dot"]},"application/mud+json":{source:"iana",compressible:!0},"application/multipart-core":{source:"iana"},"application/mxf":{source:"iana",extensions:["mxf"]},"application/n-quads":{source:"iana",extensions:["nq"]},"application/n-triples":{source:"iana",extensions:["nt"]},"application/nasdata":{source:"iana"},"application/news-checkgroups":{source:"iana",charset:"US-ASCII"},"application/news-groupinfo":{source:"iana",charset:"US-ASCII"},"application/news-transmission":{source:"iana"},"application/nlsml+xml":{source:"iana",compressible:!0},"application/node":{source:"iana",extensions:["cjs"]},"application/nss":{source:"iana"},"application/oauth-authz-req+jwt":{source:"iana"},"application/oblivious-dns-message":{source:"iana"},"application/ocsp-request":{source:"iana"},"application/ocsp-response":{source:"iana"},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{source:"iana",extensions:["oda"]},"application/odm+xml":{source:"iana",compressible:!0},"application/odx":{source:"iana"},"application/oebps-package+xml":{source:"iana",compressible:!0,extensions:["opf"]},"application/ogg":{source:"iana",compressible:!1,extensions:["ogx"]},"application/omdoc+xml":{source:"apache",compressible:!0,extensions:["omdoc"]},"application/onenote":{source:"apache",extensions:["onetoc","onetoc2","onetmp","onepkg"]},"application/opc-nodeset+xml":{source:"iana",compressible:!0},"application/oscore":{source:"iana"},"application/oxps":{source:"iana",extensions:["oxps"]},"application/p21":{source:"iana"},"application/p21+zip":{source:"iana",compressible:!1},"application/p2p-overlay+xml":{source:"iana",compressible:!0,extensions:["relo"]},"application/parityfec":{source:"iana"},"application/passport":{source:"iana"},"application/patch-ops-error+xml":{source:"iana",compressible:!0,extensions:["xer"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/pdx":{source:"iana"},"application/pem-certificate-chain":{source:"iana"},"application/pgp-encrypted":{source:"iana",compressible:!1,extensions:["pgp"]},"application/pgp-keys":{source:"iana",extensions:["asc"]},"application/pgp-signature":{source:"iana",extensions:["asc","sig"]},"application/pics-rules":{source:"apache",extensions:["prf"]},"application/pidf+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pidf-diff+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pkcs10":{source:"iana",extensions:["p10"]},"application/pkcs12":{source:"iana"},"application/pkcs7-mime":{source:"iana",extensions:["p7m","p7c"]},"application/pkcs7-signature":{source:"iana",extensions:["p7s"]},"application/pkcs8":{source:"iana",extensions:["p8"]},"application/pkcs8-encrypted":{source:"iana"},"application/pkix-attr-cert":{source:"iana",extensions:["ac"]},"application/pkix-cert":{source:"iana",extensions:["cer"]},"application/pkix-crl":{source:"iana",extensions:["crl"]},"application/pkix-pkipath":{source:"iana",extensions:["pkipath"]},"application/pkixcmp":{source:"iana",extensions:["pki"]},"application/pls+xml":{source:"iana",compressible:!0,extensions:["pls"]},"application/poc-settings+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/postscript":{source:"iana",compressible:!0,extensions:["ai","eps","ps"]},"application/ppsp-tracker+json":{source:"iana",compressible:!0},"application/problem+json":{source:"iana",compressible:!0},"application/problem+xml":{source:"iana",compressible:!0},"application/provenance+xml":{source:"iana",compressible:!0,extensions:["provx"]},"application/prs.alvestrand.titrax-sheet":{source:"iana"},"application/prs.cww":{source:"iana",extensions:["cww"]},"application/prs.cyn":{source:"iana",charset:"7-BIT"},"application/prs.hpub+zip":{source:"iana",compressible:!1},"application/prs.nprend":{source:"iana"},"application/prs.plucker":{source:"iana"},"application/prs.rdf-xml-crypt":{source:"iana"},"application/prs.xsf+xml":{source:"iana",compressible:!0},"application/pskc+xml":{source:"iana",compressible:!0,extensions:["pskcxml"]},"application/pvd+json":{source:"iana",compressible:!0},"application/qsig":{source:"iana"},"application/raml+yaml":{compressible:!0,extensions:["raml"]},"application/raptorfec":{source:"iana"},"application/rdap+json":{source:"iana",compressible:!0},"application/rdf+xml":{source:"iana",compressible:!0,extensions:["rdf","owl"]},"application/reginfo+xml":{source:"iana",compressible:!0,extensions:["rif"]},"application/relax-ng-compact-syntax":{source:"iana",extensions:["rnc"]},"application/remote-printing":{source:"iana"},"application/reputon+json":{source:"iana",compressible:!0},"application/resource-lists+xml":{source:"iana",compressible:!0,extensions:["rl"]},"application/resource-lists-diff+xml":{source:"iana",compressible:!0,extensions:["rld"]},"application/rfc+xml":{source:"iana",compressible:!0},"application/riscos":{source:"iana"},"application/rlmi+xml":{source:"iana",compressible:!0},"application/rls-services+xml":{source:"iana",compressible:!0,extensions:["rs"]},"application/route-apd+xml":{source:"iana",compressible:!0,extensions:["rapd"]},"application/route-s-tsid+xml":{source:"iana",compressible:!0,extensions:["sls"]},"application/route-usd+xml":{source:"iana",compressible:!0,extensions:["rusd"]},"application/rpki-ghostbusters":{source:"iana",extensions:["gbr"]},"application/rpki-manifest":{source:"iana",extensions:["mft"]},"application/rpki-publication":{source:"iana"},"application/rpki-roa":{source:"iana",extensions:["roa"]},"application/rpki-updown":{source:"iana"},"application/rsd+xml":{source:"apache",compressible:!0,extensions:["rsd"]},"application/rss+xml":{source:"apache",compressible:!0,extensions:["rss"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/rtploopback":{source:"iana"},"application/rtx":{source:"iana"},"application/samlassertion+xml":{source:"iana",compressible:!0},"application/samlmetadata+xml":{source:"iana",compressible:!0},"application/sarif+json":{source:"iana",compressible:!0},"application/sarif-external-properties+json":{source:"iana",compressible:!0},"application/sbe":{source:"iana"},"application/sbml+xml":{source:"iana",compressible:!0,extensions:["sbml"]},"application/scaip+xml":{source:"iana",compressible:!0},"application/scim+json":{source:"iana",compressible:!0},"application/scvp-cv-request":{source:"iana",extensions:["scq"]},"application/scvp-cv-response":{source:"iana",extensions:["scs"]},"application/scvp-vp-request":{source:"iana",extensions:["spq"]},"application/scvp-vp-response":{source:"iana",extensions:["spp"]},"application/sdp":{source:"iana",extensions:["sdp"]},"application/secevent+jwt":{source:"iana"},"application/senml+cbor":{source:"iana"},"application/senml+json":{source:"iana",compressible:!0},"application/senml+xml":{source:"iana",compressible:!0,extensions:["senmlx"]},"application/senml-etch+cbor":{source:"iana"},"application/senml-etch+json":{source:"iana",compressible:!0},"application/senml-exi":{source:"iana"},"application/sensml+cbor":{source:"iana"},"application/sensml+json":{source:"iana",compressible:!0},"application/sensml+xml":{source:"iana",compressible:!0,extensions:["sensmlx"]},"application/sensml-exi":{source:"iana"},"application/sep+xml":{source:"iana",compressible:!0},"application/sep-exi":{source:"iana"},"application/session-info":{source:"iana"},"application/set-payment":{source:"iana"},"application/set-payment-initiation":{source:"iana",extensions:["setpay"]},"application/set-registration":{source:"iana"},"application/set-registration-initiation":{source:"iana",extensions:["setreg"]},"application/sgml":{source:"iana"},"application/sgml-open-catalog":{source:"iana"},"application/shf+xml":{source:"iana",compressible:!0,extensions:["shf"]},"application/sieve":{source:"iana",extensions:["siv","sieve"]},"application/simple-filter+xml":{source:"iana",compressible:!0},"application/simple-message-summary":{source:"iana"},"application/simplesymbolcontainer":{source:"iana"},"application/sipc":{source:"iana"},"application/slate":{source:"iana"},"application/smil":{source:"iana"},"application/smil+xml":{source:"iana",compressible:!0,extensions:["smi","smil"]},"application/smpte336m":{source:"iana"},"application/soap+fastinfoset":{source:"iana"},"application/soap+xml":{source:"iana",compressible:!0},"application/sparql-query":{source:"iana",extensions:["rq"]},"application/sparql-results+xml":{source:"iana",compressible:!0,extensions:["srx"]},"application/spdx+json":{source:"iana",compressible:!0},"application/spirits-event+xml":{source:"iana",compressible:!0},"application/sql":{source:"iana"},"application/srgs":{source:"iana",extensions:["gram"]},"application/srgs+xml":{source:"iana",compressible:!0,extensions:["grxml"]},"application/sru+xml":{source:"iana",compressible:!0,extensions:["sru"]},"application/ssdl+xml":{source:"apache",compressible:!0,extensions:["ssdl"]},"application/ssml+xml":{source:"iana",compressible:!0,extensions:["ssml"]},"application/stix+json":{source:"iana",compressible:!0},"application/swid+xml":{source:"iana",compressible:!0,extensions:["swidtag"]},"application/tamp-apex-update":{source:"iana"},"application/tamp-apex-update-confirm":{source:"iana"},"application/tamp-community-update":{source:"iana"},"application/tamp-community-update-confirm":{source:"iana"},"application/tamp-error":{source:"iana"},"application/tamp-sequence-adjust":{source:"iana"},"application/tamp-sequence-adjust-confirm":{source:"iana"},"application/tamp-status-query":{source:"iana"},"application/tamp-status-response":{source:"iana"},"application/tamp-update":{source:"iana"},"application/tamp-update-confirm":{source:"iana"},"application/tar":{compressible:!0},"application/taxii+json":{source:"iana",compressible:!0},"application/td+json":{source:"iana",compressible:!0},"application/tei+xml":{source:"iana",compressible:!0,extensions:["tei","teicorpus"]},"application/tetra_isi":{source:"iana"},"application/thraud+xml":{source:"iana",compressible:!0,extensions:["tfi"]},"application/timestamp-query":{source:"iana"},"application/timestamp-reply":{source:"iana"},"application/timestamped-data":{source:"iana",extensions:["tsd"]},"application/tlsrpt+gzip":{source:"iana"},"application/tlsrpt+json":{source:"iana",compressible:!0},"application/tnauthlist":{source:"iana"},"application/token-introspection+jwt":{source:"iana"},"application/toml":{compressible:!0,extensions:["toml"]},"application/trickle-ice-sdpfrag":{source:"iana"},"application/trig":{source:"iana",extensions:["trig"]},"application/ttml+xml":{source:"iana",compressible:!0,extensions:["ttml"]},"application/tve-trigger":{source:"iana"},"application/tzif":{source:"iana"},"application/tzif-leap":{source:"iana"},"application/ubjson":{compressible:!1,extensions:["ubj"]},"application/ulpfec":{source:"iana"},"application/urc-grpsheet+xml":{source:"iana",compressible:!0},"application/urc-ressheet+xml":{source:"iana",compressible:!0,extensions:["rsheet"]},"application/urc-targetdesc+xml":{source:"iana",compressible:!0,extensions:["td"]},"application/urc-uisocketdesc+xml":{source:"iana",compressible:!0},"application/vcard+json":{source:"iana",compressible:!0},"application/vcard+xml":{source:"iana",compressible:!0},"application/vemmi":{source:"iana"},"application/vividence.scriptfile":{source:"apache"},"application/vnd.1000minds.decision-model+xml":{source:"iana",compressible:!0,extensions:["1km"]},"application/vnd.3gpp-prose+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-prose-pc3ch+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-v2x-local-service-information":{source:"iana"},"application/vnd.3gpp.5gnas":{source:"iana"},"application/vnd.3gpp.access-transfer-events+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.bsf+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gmop+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gtpc":{source:"iana"},"application/vnd.3gpp.interworking-data":{source:"iana"},"application/vnd.3gpp.lpp":{source:"iana"},"application/vnd.3gpp.mc-signalling-ear":{source:"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-payload":{source:"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-signalling":{source:"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-floor-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-signed+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-init-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-transmission-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mid-call+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ngap":{source:"iana"},"application/vnd.3gpp.pfcp":{source:"iana"},"application/vnd.3gpp.pic-bw-large":{source:"iana",extensions:["plb"]},"application/vnd.3gpp.pic-bw-small":{source:"iana",extensions:["psb"]},"application/vnd.3gpp.pic-bw-var":{source:"iana",extensions:["pvb"]},"application/vnd.3gpp.s1ap":{source:"iana"},"application/vnd.3gpp.sms":{source:"iana"},"application/vnd.3gpp.sms+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-ext+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.state-and-event-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ussd+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.bcmcsinfo+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.sms":{source:"iana"},"application/vnd.3gpp2.tcap":{source:"iana",extensions:["tcap"]},"application/vnd.3lightssoftware.imagescal":{source:"iana"},"application/vnd.3m.post-it-notes":{source:"iana",extensions:["pwn"]},"application/vnd.accpac.simply.aso":{source:"iana",extensions:["aso"]},"application/vnd.accpac.simply.imp":{source:"iana",extensions:["imp"]},"application/vnd.acucobol":{source:"iana",extensions:["acu"]},"application/vnd.acucorp":{source:"iana",extensions:["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{source:"apache",compressible:!1,extensions:["air"]},"application/vnd.adobe.flash.movie":{source:"iana"},"application/vnd.adobe.formscentral.fcdt":{source:"iana",extensions:["fcdt"]},"application/vnd.adobe.fxp":{source:"iana",extensions:["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{source:"iana"},"application/vnd.adobe.xdp+xml":{source:"iana",compressible:!0,extensions:["xdp"]},"application/vnd.adobe.xfdf":{source:"iana",extensions:["xfdf"]},"application/vnd.aether.imp":{source:"iana"},"application/vnd.afpc.afplinedata":{source:"iana"},"application/vnd.afpc.afplinedata-pagedef":{source:"iana"},"application/vnd.afpc.cmoca-cmresource":{source:"iana"},"application/vnd.afpc.foca-charset":{source:"iana"},"application/vnd.afpc.foca-codedfont":{source:"iana"},"application/vnd.afpc.foca-codepage":{source:"iana"},"application/vnd.afpc.modca":{source:"iana"},"application/vnd.afpc.modca-cmtable":{source:"iana"},"application/vnd.afpc.modca-formdef":{source:"iana"},"application/vnd.afpc.modca-mediummap":{source:"iana"},"application/vnd.afpc.modca-objectcontainer":{source:"iana"},"application/vnd.afpc.modca-overlay":{source:"iana"},"application/vnd.afpc.modca-pagesegment":{source:"iana"},"application/vnd.age":{source:"iana",extensions:["age"]},"application/vnd.ah-barcode":{source:"iana"},"application/vnd.ahead.space":{source:"iana",extensions:["ahead"]},"application/vnd.airzip.filesecure.azf":{source:"iana",extensions:["azf"]},"application/vnd.airzip.filesecure.azs":{source:"iana",extensions:["azs"]},"application/vnd.amadeus+json":{source:"iana",compressible:!0},"application/vnd.amazon.ebook":{source:"apache",extensions:["azw"]},"application/vnd.amazon.mobi8-ebook":{source:"iana"},"application/vnd.americandynamics.acc":{source:"iana",extensions:["acc"]},"application/vnd.amiga.ami":{source:"iana",extensions:["ami"]},"application/vnd.amundsen.maze+xml":{source:"iana",compressible:!0},"application/vnd.android.ota":{source:"iana"},"application/vnd.android.package-archive":{source:"apache",compressible:!1,extensions:["apk"]},"application/vnd.anki":{source:"iana"},"application/vnd.anser-web-certificate-issue-initiation":{source:"iana",extensions:["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{source:"apache",extensions:["fti"]},"application/vnd.antix.game-component":{source:"iana",extensions:["atx"]},"application/vnd.apache.arrow.file":{source:"iana"},"application/vnd.apache.arrow.stream":{source:"iana"},"application/vnd.apache.thrift.binary":{source:"iana"},"application/vnd.apache.thrift.compact":{source:"iana"},"application/vnd.apache.thrift.json":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/vnd.aplextor.warrp+json":{source:"iana",compressible:!0},"application/vnd.apothekende.reservation+json":{source:"iana",compressible:!0},"application/vnd.apple.installer+xml":{source:"iana",compressible:!0,extensions:["mpkg"]},"application/vnd.apple.keynote":{source:"iana",extensions:["key"]},"application/vnd.apple.mpegurl":{source:"iana",extensions:["m3u8"]},"application/vnd.apple.numbers":{source:"iana",extensions:["numbers"]},"application/vnd.apple.pages":{source:"iana",extensions:["pages"]},"application/vnd.apple.pkpass":{compressible:!1,extensions:["pkpass"]},"application/vnd.arastra.swi":{source:"iana"},"application/vnd.aristanetworks.swi":{source:"iana",extensions:["swi"]},"application/vnd.artisan+json":{source:"iana",compressible:!0},"application/vnd.artsquare":{source:"iana"},"application/vnd.astraea-software.iota":{source:"iana",extensions:["iota"]},"application/vnd.audiograph":{source:"iana",extensions:["aep"]},"application/vnd.autopackage":{source:"iana"},"application/vnd.avalon+json":{source:"iana",compressible:!0},"application/vnd.avistar+xml":{source:"iana",compressible:!0},"application/vnd.balsamiq.bmml+xml":{source:"iana",compressible:!0,extensions:["bmml"]},"application/vnd.balsamiq.bmpr":{source:"iana"},"application/vnd.banana-accounting":{source:"iana"},"application/vnd.bbf.usp.error":{source:"iana"},"application/vnd.bbf.usp.msg":{source:"iana"},"application/vnd.bbf.usp.msg+json":{source:"iana",compressible:!0},"application/vnd.bekitzur-stech+json":{source:"iana",compressible:!0},"application/vnd.bint.med-content":{source:"iana"},"application/vnd.biopax.rdf+xml":{source:"iana",compressible:!0},"application/vnd.blink-idb-value-wrapper":{source:"iana"},"application/vnd.blueice.multipass":{source:"iana",extensions:["mpm"]},"application/vnd.bluetooth.ep.oob":{source:"iana"},"application/vnd.bluetooth.le.oob":{source:"iana"},"application/vnd.bmi":{source:"iana",extensions:["bmi"]},"application/vnd.bpf":{source:"iana"},"application/vnd.bpf3":{source:"iana"},"application/vnd.businessobjects":{source:"iana",extensions:["rep"]},"application/vnd.byu.uapi+json":{source:"iana",compressible:!0},"application/vnd.cab-jscript":{source:"iana"},"application/vnd.canon-cpdl":{source:"iana"},"application/vnd.canon-lips":{source:"iana"},"application/vnd.capasystems-pg+json":{source:"iana",compressible:!0},"application/vnd.cendio.thinlinc.clientconf":{source:"iana"},"application/vnd.century-systems.tcp_stream":{source:"iana"},"application/vnd.chemdraw+xml":{source:"iana",compressible:!0,extensions:["cdxml"]},"application/vnd.chess-pgn":{source:"iana"},"application/vnd.chipnuts.karaoke-mmd":{source:"iana",extensions:["mmd"]},"application/vnd.ciedi":{source:"iana"},"application/vnd.cinderella":{source:"iana",extensions:["cdy"]},"application/vnd.cirpack.isdn-ext":{source:"iana"},"application/vnd.citationstyles.style+xml":{source:"iana",compressible:!0,extensions:["csl"]},"application/vnd.claymore":{source:"iana",extensions:["cla"]},"application/vnd.cloanto.rp9":{source:"iana",extensions:["rp9"]},"application/vnd.clonk.c4group":{source:"iana",extensions:["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{source:"iana",extensions:["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{source:"iana",extensions:["c11amz"]},"application/vnd.coffeescript":{source:"iana"},"application/vnd.collabio.xodocuments.document":{source:"iana"},"application/vnd.collabio.xodocuments.document-template":{source:"iana"},"application/vnd.collabio.xodocuments.presentation":{source:"iana"},"application/vnd.collabio.xodocuments.presentation-template":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{source:"iana"},"application/vnd.collection+json":{source:"iana",compressible:!0},"application/vnd.collection.doc+json":{source:"iana",compressible:!0},"application/vnd.collection.next+json":{source:"iana",compressible:!0},"application/vnd.comicbook+zip":{source:"iana",compressible:!1},"application/vnd.comicbook-rar":{source:"iana"},"application/vnd.commerce-battelle":{source:"iana"},"application/vnd.commonspace":{source:"iana",extensions:["csp"]},"application/vnd.contact.cmsg":{source:"iana",extensions:["cdbcmsg"]},"application/vnd.coreos.ignition+json":{source:"iana",compressible:!0},"application/vnd.cosmocaller":{source:"iana",extensions:["cmc"]},"application/vnd.crick.clicker":{source:"iana",extensions:["clkx"]},"application/vnd.crick.clicker.keyboard":{source:"iana",extensions:["clkk"]},"application/vnd.crick.clicker.palette":{source:"iana",extensions:["clkp"]},"application/vnd.crick.clicker.template":{source:"iana",extensions:["clkt"]},"application/vnd.crick.clicker.wordbank":{source:"iana",extensions:["clkw"]},"application/vnd.criticaltools.wbs+xml":{source:"iana",compressible:!0,extensions:["wbs"]},"application/vnd.cryptii.pipe+json":{source:"iana",compressible:!0},"application/vnd.crypto-shade-file":{source:"iana"},"application/vnd.cryptomator.encrypted":{source:"iana"},"application/vnd.cryptomator.vault":{source:"iana"},"application/vnd.ctc-posml":{source:"iana",extensions:["pml"]},"application/vnd.ctct.ws+xml":{source:"iana",compressible:!0},"application/vnd.cups-pdf":{source:"iana"},"application/vnd.cups-postscript":{source:"iana"},"application/vnd.cups-ppd":{source:"iana",extensions:["ppd"]},"application/vnd.cups-raster":{source:"iana"},"application/vnd.cups-raw":{source:"iana"},"application/vnd.curl":{source:"iana"},"application/vnd.curl.car":{source:"apache",extensions:["car"]},"application/vnd.curl.pcurl":{source:"apache",extensions:["pcurl"]},"application/vnd.cyan.dean.root+xml":{source:"iana",compressible:!0},"application/vnd.cybank":{source:"iana"},"application/vnd.cyclonedx+json":{source:"iana",compressible:!0},"application/vnd.cyclonedx+xml":{source:"iana",compressible:!0},"application/vnd.d2l.coursepackage1p0+zip":{source:"iana",compressible:!1},"application/vnd.d3m-dataset":{source:"iana"},"application/vnd.d3m-problem":{source:"iana"},"application/vnd.dart":{source:"iana",compressible:!0,extensions:["dart"]},"application/vnd.data-vision.rdz":{source:"iana",extensions:["rdz"]},"application/vnd.datapackage+json":{source:"iana",compressible:!0},"application/vnd.dataresource+json":{source:"iana",compressible:!0},"application/vnd.dbf":{source:"iana",extensions:["dbf"]},"application/vnd.debian.binary-package":{source:"iana"},"application/vnd.dece.data":{source:"iana",extensions:["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{source:"iana",compressible:!0,extensions:["uvt","uvvt"]},"application/vnd.dece.unspecified":{source:"iana",extensions:["uvx","uvvx"]},"application/vnd.dece.zip":{source:"iana",extensions:["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{source:"iana",extensions:["fe_launch"]},"application/vnd.desmume.movie":{source:"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{source:"iana"},"application/vnd.dm.delegation+xml":{source:"iana",compressible:!0},"application/vnd.dna":{source:"iana",extensions:["dna"]},"application/vnd.document+json":{source:"iana",compressible:!0},"application/vnd.dolby.mlp":{source:"apache",extensions:["mlp"]},"application/vnd.dolby.mobile.1":{source:"iana"},"application/vnd.dolby.mobile.2":{source:"iana"},"application/vnd.doremir.scorecloud-binary-document":{source:"iana"},"application/vnd.dpgraph":{source:"iana",extensions:["dpg"]},"application/vnd.dreamfactory":{source:"iana",extensions:["dfac"]},"application/vnd.drive+json":{source:"iana",compressible:!0},"application/vnd.ds-keypoint":{source:"apache",extensions:["kpxx"]},"application/vnd.dtg.local":{source:"iana"},"application/vnd.dtg.local.flash":{source:"iana"},"application/vnd.dtg.local.html":{source:"iana"},"application/vnd.dvb.ait":{source:"iana",extensions:["ait"]},"application/vnd.dvb.dvbisl+xml":{source:"iana",compressible:!0},"application/vnd.dvb.dvbj":{source:"iana"},"application/vnd.dvb.esgcontainer":{source:"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess2":{source:"iana"},"application/vnd.dvb.ipdcesgpdd":{source:"iana"},"application/vnd.dvb.ipdcroaming":{source:"iana"},"application/vnd.dvb.iptv.alfec-base":{source:"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{source:"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-container+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-generic+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-msglist+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-request+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-response+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-init+xml":{source:"iana",compressible:!0},"application/vnd.dvb.pfr":{source:"iana"},"application/vnd.dvb.service":{source:"iana",extensions:["svc"]},"application/vnd.dxr":{source:"iana"},"application/vnd.dynageo":{source:"iana",extensions:["geo"]},"application/vnd.dzr":{source:"iana"},"application/vnd.easykaraoke.cdgdownload":{source:"iana"},"application/vnd.ecdis-update":{source:"iana"},"application/vnd.ecip.rlp":{source:"iana"},"application/vnd.eclipse.ditto+json":{source:"iana",compressible:!0},"application/vnd.ecowin.chart":{source:"iana",extensions:["mag"]},"application/vnd.ecowin.filerequest":{source:"iana"},"application/vnd.ecowin.fileupdate":{source:"iana"},"application/vnd.ecowin.series":{source:"iana"},"application/vnd.ecowin.seriesrequest":{source:"iana"},"application/vnd.ecowin.seriesupdate":{source:"iana"},"application/vnd.efi.img":{source:"iana"},"application/vnd.efi.iso":{source:"iana"},"application/vnd.emclient.accessrequest+xml":{source:"iana",compressible:!0},"application/vnd.enliven":{source:"iana",extensions:["nml"]},"application/vnd.enphase.envoy":{source:"iana"},"application/vnd.eprints.data+xml":{source:"iana",compressible:!0},"application/vnd.epson.esf":{source:"iana",extensions:["esf"]},"application/vnd.epson.msf":{source:"iana",extensions:["msf"]},"application/vnd.epson.quickanime":{source:"iana",extensions:["qam"]},"application/vnd.epson.salt":{source:"iana",extensions:["slt"]},"application/vnd.epson.ssf":{source:"iana",extensions:["ssf"]},"application/vnd.ericsson.quickcall":{source:"iana"},"application/vnd.espass-espass+zip":{source:"iana",compressible:!1},"application/vnd.eszigno3+xml":{source:"iana",compressible:!0,extensions:["es3","et3"]},"application/vnd.etsi.aoc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.asic-e+zip":{source:"iana",compressible:!1},"application/vnd.etsi.asic-s+zip":{source:"iana",compressible:!1},"application/vnd.etsi.cug+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvcommand+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-bc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-cod+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-npvr+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvservice+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsync+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvueprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mcid+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mheg5":{source:"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{source:"iana",compressible:!0},"application/vnd.etsi.pstn+xml":{source:"iana",compressible:!0},"application/vnd.etsi.sci+xml":{source:"iana",compressible:!0},"application/vnd.etsi.simservs+xml":{source:"iana",compressible:!0},"application/vnd.etsi.timestamp-token":{source:"iana"},"application/vnd.etsi.tsl+xml":{source:"iana",compressible:!0},"application/vnd.etsi.tsl.der":{source:"iana"},"application/vnd.eu.kasparian.car+json":{source:"iana",compressible:!0},"application/vnd.eudora.data":{source:"iana"},"application/vnd.evolv.ecig.profile":{source:"iana"},"application/vnd.evolv.ecig.settings":{source:"iana"},"application/vnd.evolv.ecig.theme":{source:"iana"},"application/vnd.exstream-empower+zip":{source:"iana",compressible:!1},"application/vnd.exstream-package":{source:"iana"},"application/vnd.ezpix-album":{source:"iana",extensions:["ez2"]},"application/vnd.ezpix-package":{source:"iana",extensions:["ez3"]},"application/vnd.f-secure.mobile":{source:"iana"},"application/vnd.familysearch.gedcom+zip":{source:"iana",compressible:!1},"application/vnd.fastcopy-disk-image":{source:"iana"},"application/vnd.fdf":{source:"iana",extensions:["fdf"]},"application/vnd.fdsn.mseed":{source:"iana",extensions:["mseed"]},"application/vnd.fdsn.seed":{source:"iana",extensions:["seed","dataless"]},"application/vnd.ffsns":{source:"iana"},"application/vnd.ficlab.flb+zip":{source:"iana",compressible:!1},"application/vnd.filmit.zfc":{source:"iana"},"application/vnd.fints":{source:"iana"},"application/vnd.firemonkeys.cloudcell":{source:"iana"},"application/vnd.flographit":{source:"iana",extensions:["gph"]},"application/vnd.fluxtime.clip":{source:"iana",extensions:["ftc"]},"application/vnd.font-fontforge-sfd":{source:"iana"},"application/vnd.framemaker":{source:"iana",extensions:["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{source:"iana",extensions:["fnc"]},"application/vnd.frogans.ltf":{source:"iana",extensions:["ltf"]},"application/vnd.fsc.weblaunch":{source:"iana",extensions:["fsc"]},"application/vnd.fujifilm.fb.docuworks":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.binder":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.container":{source:"iana"},"application/vnd.fujifilm.fb.jfi+xml":{source:"iana",compressible:!0},"application/vnd.fujitsu.oasys":{source:"iana",extensions:["oas"]},"application/vnd.fujitsu.oasys2":{source:"iana",extensions:["oa2"]},"application/vnd.fujitsu.oasys3":{source:"iana",extensions:["oa3"]},"application/vnd.fujitsu.oasysgp":{source:"iana",extensions:["fg5"]},"application/vnd.fujitsu.oasysprs":{source:"iana",extensions:["bh2"]},"application/vnd.fujixerox.art-ex":{source:"iana"},"application/vnd.fujixerox.art4":{source:"iana"},"application/vnd.fujixerox.ddd":{source:"iana",extensions:["ddd"]},"application/vnd.fujixerox.docuworks":{source:"iana",extensions:["xdw"]},"application/vnd.fujixerox.docuworks.binder":{source:"iana",extensions:["xbd"]},"application/vnd.fujixerox.docuworks.container":{source:"iana"},"application/vnd.fujixerox.hbpl":{source:"iana"},"application/vnd.fut-misnet":{source:"iana"},"application/vnd.futoin+cbor":{source:"iana"},"application/vnd.futoin+json":{source:"iana",compressible:!0},"application/vnd.fuzzysheet":{source:"iana",extensions:["fzs"]},"application/vnd.genomatix.tuxedo":{source:"iana",extensions:["txd"]},"application/vnd.gentics.grd+json":{source:"iana",compressible:!0},"application/vnd.geo+json":{source:"iana",compressible:!0},"application/vnd.geocube+xml":{source:"iana",compressible:!0},"application/vnd.geogebra.file":{source:"iana",extensions:["ggb"]},"application/vnd.geogebra.slides":{source:"iana"},"application/vnd.geogebra.tool":{source:"iana",extensions:["ggt"]},"application/vnd.geometry-explorer":{source:"iana",extensions:["gex","gre"]},"application/vnd.geonext":{source:"iana",extensions:["gxt"]},"application/vnd.geoplan":{source:"iana",extensions:["g2w"]},"application/vnd.geospace":{source:"iana",extensions:["g3w"]},"application/vnd.gerber":{source:"iana"},"application/vnd.globalplatform.card-content-mgt":{source:"iana"},"application/vnd.globalplatform.card-content-mgt-response":{source:"iana"},"application/vnd.gmx":{source:"iana",extensions:["gmx"]},"application/vnd.google-apps.document":{compressible:!1,extensions:["gdoc"]},"application/vnd.google-apps.presentation":{compressible:!1,extensions:["gslides"]},"application/vnd.google-apps.spreadsheet":{compressible:!1,extensions:["gsheet"]},"application/vnd.google-earth.kml+xml":{source:"iana",compressible:!0,extensions:["kml"]},"application/vnd.google-earth.kmz":{source:"iana",compressible:!1,extensions:["kmz"]},"application/vnd.gov.sk.e-form+xml":{source:"iana",compressible:!0},"application/vnd.gov.sk.e-form+zip":{source:"iana",compressible:!1},"application/vnd.gov.sk.xmldatacontainer+xml":{source:"iana",compressible:!0},"application/vnd.grafeq":{source:"iana",extensions:["gqf","gqs"]},"application/vnd.gridmp":{source:"iana"},"application/vnd.groove-account":{source:"iana",extensions:["gac"]},"application/vnd.groove-help":{source:"iana",extensions:["ghf"]},"application/vnd.groove-identity-message":{source:"iana",extensions:["gim"]},"application/vnd.groove-injector":{source:"iana",extensions:["grv"]},"application/vnd.groove-tool-message":{source:"iana",extensions:["gtm"]},"application/vnd.groove-tool-template":{source:"iana",extensions:["tpl"]},"application/vnd.groove-vcard":{source:"iana",extensions:["vcg"]},"application/vnd.hal+json":{source:"iana",compressible:!0},"application/vnd.hal+xml":{source:"iana",compressible:!0,extensions:["hal"]},"application/vnd.handheld-entertainment+xml":{source:"iana",compressible:!0,extensions:["zmm"]},"application/vnd.hbci":{source:"iana",extensions:["hbci"]},"application/vnd.hc+json":{source:"iana",compressible:!0},"application/vnd.hcl-bireports":{source:"iana"},"application/vnd.hdt":{source:"iana"},"application/vnd.heroku+json":{source:"iana",compressible:!0},"application/vnd.hhe.lesson-player":{source:"iana",extensions:["les"]},"application/vnd.hl7cda+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hl7v2+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hp-hpgl":{source:"iana",extensions:["hpgl"]},"application/vnd.hp-hpid":{source:"iana",extensions:["hpid"]},"application/vnd.hp-hps":{source:"iana",extensions:["hps"]},"application/vnd.hp-jlyt":{source:"iana",extensions:["jlt"]},"application/vnd.hp-pcl":{source:"iana",extensions:["pcl"]},"application/vnd.hp-pclxl":{source:"iana",extensions:["pclxl"]},"application/vnd.httphone":{source:"iana"},"application/vnd.hydrostatix.sof-data":{source:"iana",extensions:["sfd-hdstx"]},"application/vnd.hyper+json":{source:"iana",compressible:!0},"application/vnd.hyper-item+json":{source:"iana",compressible:!0},"application/vnd.hyperdrive+json":{source:"iana",compressible:!0},"application/vnd.hzn-3d-crossword":{source:"iana"},"application/vnd.ibm.afplinedata":{source:"iana"},"application/vnd.ibm.electronic-media":{source:"iana"},"application/vnd.ibm.minipay":{source:"iana",extensions:["mpy"]},"application/vnd.ibm.modcap":{source:"iana",extensions:["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{source:"iana",extensions:["irm"]},"application/vnd.ibm.secure-container":{source:"iana",extensions:["sc"]},"application/vnd.iccprofile":{source:"iana",extensions:["icc","icm"]},"application/vnd.ieee.1905":{source:"iana"},"application/vnd.igloader":{source:"iana",extensions:["igl"]},"application/vnd.imagemeter.folder+zip":{source:"iana",compressible:!1},"application/vnd.imagemeter.image+zip":{source:"iana",compressible:!1},"application/vnd.immervision-ivp":{source:"iana",extensions:["ivp"]},"application/vnd.immervision-ivu":{source:"iana",extensions:["ivu"]},"application/vnd.ims.imsccv1p1":{source:"iana"},"application/vnd.ims.imsccv1p2":{source:"iana"},"application/vnd.ims.imsccv1p3":{source:"iana"},"application/vnd.ims.lis.v2.result+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy.id+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings.simple+json":{source:"iana",compressible:!0},"application/vnd.informedcontrol.rms+xml":{source:"iana",compressible:!0},"application/vnd.informix-visionary":{source:"iana"},"application/vnd.infotech.project":{source:"iana"},"application/vnd.infotech.project+xml":{source:"iana",compressible:!0},"application/vnd.innopath.wamp.notification":{source:"iana"},"application/vnd.insors.igm":{source:"iana",extensions:["igm"]},"application/vnd.intercon.formnet":{source:"iana",extensions:["xpw","xpx"]},"application/vnd.intergeo":{source:"iana",extensions:["i2g"]},"application/vnd.intertrust.digibox":{source:"iana"},"application/vnd.intertrust.nncp":{source:"iana"},"application/vnd.intu.qbo":{source:"iana",extensions:["qbo"]},"application/vnd.intu.qfx":{source:"iana",extensions:["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.conceptitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.knowledgeitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsmessage+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.packageitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.planningitem+xml":{source:"iana",compressible:!0},"application/vnd.ipunplugged.rcprofile":{source:"iana",extensions:["rcprofile"]},"application/vnd.irepository.package+xml":{source:"iana",compressible:!0,extensions:["irp"]},"application/vnd.is-xpr":{source:"iana",extensions:["xpr"]},"application/vnd.isac.fcs":{source:"iana",extensions:["fcs"]},"application/vnd.iso11783-10+zip":{source:"iana",compressible:!1},"application/vnd.jam":{source:"iana",extensions:["jam"]},"application/vnd.japannet-directory-service":{source:"iana"},"application/vnd.japannet-jpnstore-wakeup":{source:"iana"},"application/vnd.japannet-payment-wakeup":{source:"iana"},"application/vnd.japannet-registration":{source:"iana"},"application/vnd.japannet-registration-wakeup":{source:"iana"},"application/vnd.japannet-setstore-wakeup":{source:"iana"},"application/vnd.japannet-verification":{source:"iana"},"application/vnd.japannet-verification-wakeup":{source:"iana"},"application/vnd.jcp.javame.midlet-rms":{source:"iana",extensions:["rms"]},"application/vnd.jisp":{source:"iana",extensions:["jisp"]},"application/vnd.joost.joda-archive":{source:"iana",extensions:["joda"]},"application/vnd.jsk.isdn-ngn":{source:"iana"},"application/vnd.kahootz":{source:"iana",extensions:["ktz","ktr"]},"application/vnd.kde.karbon":{source:"iana",extensions:["karbon"]},"application/vnd.kde.kchart":{source:"iana",extensions:["chrt"]},"application/vnd.kde.kformula":{source:"iana",extensions:["kfo"]},"application/vnd.kde.kivio":{source:"iana",extensions:["flw"]},"application/vnd.kde.kontour":{source:"iana",extensions:["kon"]},"application/vnd.kde.kpresenter":{source:"iana",extensions:["kpr","kpt"]},"application/vnd.kde.kspread":{source:"iana",extensions:["ksp"]},"application/vnd.kde.kword":{source:"iana",extensions:["kwd","kwt"]},"application/vnd.kenameaapp":{source:"iana",extensions:["htke"]},"application/vnd.kidspiration":{source:"iana",extensions:["kia"]},"application/vnd.kinar":{source:"iana",extensions:["kne","knp"]},"application/vnd.koan":{source:"iana",extensions:["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{source:"iana",extensions:["sse"]},"application/vnd.las":{source:"iana"},"application/vnd.las.las+json":{source:"iana",compressible:!0},"application/vnd.las.las+xml":{source:"iana",compressible:!0,extensions:["lasxml"]},"application/vnd.laszip":{source:"iana"},"application/vnd.leap+json":{source:"iana",compressible:!0},"application/vnd.liberty-request+xml":{source:"iana",compressible:!0},"application/vnd.llamagraphics.life-balance.desktop":{source:"iana",extensions:["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{source:"iana",compressible:!0,extensions:["lbe"]},"application/vnd.logipipe.circuit+zip":{source:"iana",compressible:!1},"application/vnd.loom":{source:"iana"},"application/vnd.lotus-1-2-3":{source:"iana",extensions:["123"]},"application/vnd.lotus-approach":{source:"iana",extensions:["apr"]},"application/vnd.lotus-freelance":{source:"iana",extensions:["pre"]},"application/vnd.lotus-notes":{source:"iana",extensions:["nsf"]},"application/vnd.lotus-organizer":{source:"iana",extensions:["org"]},"application/vnd.lotus-screencam":{source:"iana",extensions:["scm"]},"application/vnd.lotus-wordpro":{source:"iana",extensions:["lwp"]},"application/vnd.macports.portpkg":{source:"iana",extensions:["portpkg"]},"application/vnd.mapbox-vector-tile":{source:"iana",extensions:["mvt"]},"application/vnd.marlin.drm.actiontoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.conftoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.license+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.mdcf":{source:"iana"},"application/vnd.mason+json":{source:"iana",compressible:!0},"application/vnd.maxar.archive.3tz+zip":{source:"iana",compressible:!1},"application/vnd.maxmind.maxmind-db":{source:"iana"},"application/vnd.mcd":{source:"iana",extensions:["mcd"]},"application/vnd.medcalcdata":{source:"iana",extensions:["mc1"]},"application/vnd.mediastation.cdkey":{source:"iana",extensions:["cdkey"]},"application/vnd.meridian-slingshot":{source:"iana"},"application/vnd.mfer":{source:"iana",extensions:["mwf"]},"application/vnd.mfmp":{source:"iana",extensions:["mfm"]},"application/vnd.micro+json":{source:"iana",compressible:!0},"application/vnd.micrografx.flo":{source:"iana",extensions:["flo"]},"application/vnd.micrografx.igx":{source:"iana",extensions:["igx"]},"application/vnd.microsoft.portable-executable":{source:"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{source:"iana"},"application/vnd.miele+json":{source:"iana",compressible:!0},"application/vnd.mif":{source:"iana",extensions:["mif"]},"application/vnd.minisoft-hp3000-save":{source:"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{source:"iana"},"application/vnd.mobius.daf":{source:"iana",extensions:["daf"]},"application/vnd.mobius.dis":{source:"iana",extensions:["dis"]},"application/vnd.mobius.mbk":{source:"iana",extensions:["mbk"]},"application/vnd.mobius.mqy":{source:"iana",extensions:["mqy"]},"application/vnd.mobius.msl":{source:"iana",extensions:["msl"]},"application/vnd.mobius.plc":{source:"iana",extensions:["plc"]},"application/vnd.mobius.txf":{source:"iana",extensions:["txf"]},"application/vnd.mophun.application":{source:"iana",extensions:["mpn"]},"application/vnd.mophun.certificate":{source:"iana",extensions:["mpc"]},"application/vnd.motorola.flexsuite":{source:"iana"},"application/vnd.motorola.flexsuite.adsi":{source:"iana"},"application/vnd.motorola.flexsuite.fis":{source:"iana"},"application/vnd.motorola.flexsuite.gotap":{source:"iana"},"application/vnd.motorola.flexsuite.kmr":{source:"iana"},"application/vnd.motorola.flexsuite.ttc":{source:"iana"},"application/vnd.motorola.flexsuite.wem":{source:"iana"},"application/vnd.motorola.iprm":{source:"iana"},"application/vnd.mozilla.xul+xml":{source:"iana",compressible:!0,extensions:["xul"]},"application/vnd.ms-3mfdocument":{source:"iana"},"application/vnd.ms-artgalry":{source:"iana",extensions:["cil"]},"application/vnd.ms-asf":{source:"iana"},"application/vnd.ms-cab-compressed":{source:"iana",extensions:["cab"]},"application/vnd.ms-color.iccprofile":{source:"apache"},"application/vnd.ms-excel":{source:"iana",compressible:!1,extensions:["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{source:"iana",extensions:["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{source:"iana",extensions:["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{source:"iana",extensions:["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{source:"iana",extensions:["xltm"]},"application/vnd.ms-fontobject":{source:"iana",compressible:!0,extensions:["eot"]},"application/vnd.ms-htmlhelp":{source:"iana",extensions:["chm"]},"application/vnd.ms-ims":{source:"iana",extensions:["ims"]},"application/vnd.ms-lrm":{source:"iana",extensions:["lrm"]},"application/vnd.ms-office.activex+xml":{source:"iana",compressible:!0},"application/vnd.ms-officetheme":{source:"iana",extensions:["thmx"]},"application/vnd.ms-opentype":{source:"apache",compressible:!0},"application/vnd.ms-outlook":{compressible:!1,extensions:["msg"]},"application/vnd.ms-package.obfuscated-opentype":{source:"apache"},"application/vnd.ms-pki.seccat":{source:"apache",extensions:["cat"]},"application/vnd.ms-pki.stl":{source:"apache",extensions:["stl"]},"application/vnd.ms-playready.initiator+xml":{source:"iana",compressible:!0},"application/vnd.ms-powerpoint":{source:"iana",compressible:!1,extensions:["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{source:"iana",extensions:["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{source:"iana",extensions:["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{source:"iana",extensions:["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{source:"iana",extensions:["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{source:"iana",extensions:["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{source:"iana",compressible:!0},"application/vnd.ms-printing.printticket+xml":{source:"apache",compressible:!0},"application/vnd.ms-printschematicket+xml":{source:"iana",compressible:!0},"application/vnd.ms-project":{source:"iana",extensions:["mpp","mpt"]},"application/vnd.ms-tnef":{source:"iana"},"application/vnd.ms-windows.devicepairing":{source:"iana"},"application/vnd.ms-windows.nwprinting.oob":{source:"iana"},"application/vnd.ms-windows.printerpairing":{source:"iana"},"application/vnd.ms-windows.wsd.oob":{source:"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.lic-resp":{source:"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.meter-resp":{source:"iana"},"application/vnd.ms-word.document.macroenabled.12":{source:"iana",extensions:["docm"]},"application/vnd.ms-word.template.macroenabled.12":{source:"iana",extensions:["dotm"]},"application/vnd.ms-works":{source:"iana",extensions:["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{source:"iana",extensions:["wpl"]},"application/vnd.ms-xpsdocument":{source:"iana",compressible:!1,extensions:["xps"]},"application/vnd.msa-disk-image":{source:"iana"},"application/vnd.mseq":{source:"iana",extensions:["mseq"]},"application/vnd.msign":{source:"iana"},"application/vnd.multiad.creator":{source:"iana"},"application/vnd.multiad.creator.cif":{source:"iana"},"application/vnd.music-niff":{source:"iana"},"application/vnd.musician":{source:"iana",extensions:["mus"]},"application/vnd.muvee.style":{source:"iana",extensions:["msty"]},"application/vnd.mynfc":{source:"iana",extensions:["taglet"]},"application/vnd.nacamar.ybrid+json":{source:"iana",compressible:!0},"application/vnd.ncd.control":{source:"iana"},"application/vnd.ncd.reference":{source:"iana"},"application/vnd.nearst.inv+json":{source:"iana",compressible:!0},"application/vnd.nebumind.line":{source:"iana"},"application/vnd.nervana":{source:"iana"},"application/vnd.netfpx":{source:"iana"},"application/vnd.neurolanguage.nlu":{source:"iana",extensions:["nlu"]},"application/vnd.nimn":{source:"iana"},"application/vnd.nintendo.nitro.rom":{source:"iana"},"application/vnd.nintendo.snes.rom":{source:"iana"},"application/vnd.nitf":{source:"iana",extensions:["ntf","nitf"]},"application/vnd.noblenet-directory":{source:"iana",extensions:["nnd"]},"application/vnd.noblenet-sealer":{source:"iana",extensions:["nns"]},"application/vnd.noblenet-web":{source:"iana",extensions:["nnw"]},"application/vnd.nokia.catalogs":{source:"iana"},"application/vnd.nokia.conml+wbxml":{source:"iana"},"application/vnd.nokia.conml+xml":{source:"iana",compressible:!0},"application/vnd.nokia.iptv.config+xml":{source:"iana",compressible:!0},"application/vnd.nokia.isds-radio-presets":{source:"iana"},"application/vnd.nokia.landmark+wbxml":{source:"iana"},"application/vnd.nokia.landmark+xml":{source:"iana",compressible:!0},"application/vnd.nokia.landmarkcollection+xml":{source:"iana",compressible:!0},"application/vnd.nokia.n-gage.ac+xml":{source:"iana",compressible:!0,extensions:["ac"]},"application/vnd.nokia.n-gage.data":{source:"iana",extensions:["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{source:"iana",extensions:["n-gage"]},"application/vnd.nokia.ncd":{source:"iana"},"application/vnd.nokia.pcd+wbxml":{source:"iana"},"application/vnd.nokia.pcd+xml":{source:"iana",compressible:!0},"application/vnd.nokia.radio-preset":{source:"iana",extensions:["rpst"]},"application/vnd.nokia.radio-presets":{source:"iana",extensions:["rpss"]},"application/vnd.novadigm.edm":{source:"iana",extensions:["edm"]},"application/vnd.novadigm.edx":{source:"iana",extensions:["edx"]},"application/vnd.novadigm.ext":{source:"iana",extensions:["ext"]},"application/vnd.ntt-local.content-share":{source:"iana"},"application/vnd.ntt-local.file-transfer":{source:"iana"},"application/vnd.ntt-local.ogw_remote-access":{source:"iana"},"application/vnd.ntt-local.sip-ta_remote":{source:"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{source:"iana"},"application/vnd.oasis.opendocument.chart":{source:"iana",extensions:["odc"]},"application/vnd.oasis.opendocument.chart-template":{source:"iana",extensions:["otc"]},"application/vnd.oasis.opendocument.database":{source:"iana",extensions:["odb"]},"application/vnd.oasis.opendocument.formula":{source:"iana",extensions:["odf"]},"application/vnd.oasis.opendocument.formula-template":{source:"iana",extensions:["odft"]},"application/vnd.oasis.opendocument.graphics":{source:"iana",compressible:!1,extensions:["odg"]},"application/vnd.oasis.opendocument.graphics-template":{source:"iana",extensions:["otg"]},"application/vnd.oasis.opendocument.image":{source:"iana",extensions:["odi"]},"application/vnd.oasis.opendocument.image-template":{source:"iana",extensions:["oti"]},"application/vnd.oasis.opendocument.presentation":{source:"iana",compressible:!1,extensions:["odp"]},"application/vnd.oasis.opendocument.presentation-template":{source:"iana",extensions:["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{source:"iana",compressible:!1,extensions:["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{source:"iana",extensions:["ots"]},"application/vnd.oasis.opendocument.text":{source:"iana",compressible:!1,extensions:["odt"]},"application/vnd.oasis.opendocument.text-master":{source:"iana",extensions:["odm"]},"application/vnd.oasis.opendocument.text-template":{source:"iana",extensions:["ott"]},"application/vnd.oasis.opendocument.text-web":{source:"iana",extensions:["oth"]},"application/vnd.obn":{source:"iana"},"application/vnd.ocf+cbor":{source:"iana"},"application/vnd.oci.image.manifest.v1+json":{source:"iana",compressible:!0},"application/vnd.oftn.l10n+json":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessdownload+xml":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessstreaming+xml":{source:"iana",compressible:!0},"application/vnd.oipf.cspg-hexbinary":{source:"iana"},"application/vnd.oipf.dae.svg+xml":{source:"iana",compressible:!0},"application/vnd.oipf.dae.xhtml+xml":{source:"iana",compressible:!0},"application/vnd.oipf.mippvcontrolmessage+xml":{source:"iana",compressible:!0},"application/vnd.oipf.pae.gem":{source:"iana"},"application/vnd.oipf.spdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.oipf.spdlist+xml":{source:"iana",compressible:!0},"application/vnd.oipf.ueprofile+xml":{source:"iana",compressible:!0},"application/vnd.oipf.userprofile+xml":{source:"iana",compressible:!0},"application/vnd.olpc-sugar":{source:"iana",extensions:["xo"]},"application/vnd.oma-scws-config":{source:"iana"},"application/vnd.oma-scws-http-request":{source:"iana"},"application/vnd.oma-scws-http-response":{source:"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.drm-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.imd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.ltkm":{source:"iana"},"application/vnd.oma.bcast.notification+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.provisioningtrigger":{source:"iana"},"application/vnd.oma.bcast.sgboot":{source:"iana"},"application/vnd.oma.bcast.sgdd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sgdu":{source:"iana"},"application/vnd.oma.bcast.simple-symbol-container":{source:"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sprov+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.stkm":{source:"iana"},"application/vnd.oma.cab-address-book+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-feature-handler+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-pcc+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-subs-invite+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-user-prefs+xml":{source:"iana",compressible:!0},"application/vnd.oma.dcd":{source:"iana"},"application/vnd.oma.dcdc":{source:"iana"},"application/vnd.oma.dd2+xml":{source:"iana",compressible:!0,extensions:["dd2"]},"application/vnd.oma.drm.risd+xml":{source:"iana",compressible:!0},"application/vnd.oma.group-usage-list+xml":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+cbor":{source:"iana"},"application/vnd.oma.lwm2m+json":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+tlv":{source:"iana"},"application/vnd.oma.pal+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.detailed-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.final-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.groups+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.invocation-descriptor+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.optimized-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.push":{source:"iana"},"application/vnd.oma.scidm.messages+xml":{source:"iana",compressible:!0},"application/vnd.oma.xcap-directory+xml":{source:"iana",compressible:!0},"application/vnd.omads-email+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-file+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-folder+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omaloc-supl-init":{source:"iana"},"application/vnd.onepager":{source:"iana"},"application/vnd.onepagertamp":{source:"iana"},"application/vnd.onepagertamx":{source:"iana"},"application/vnd.onepagertat":{source:"iana"},"application/vnd.onepagertatp":{source:"iana"},"application/vnd.onepagertatx":{source:"iana"},"application/vnd.openblox.game+xml":{source:"iana",compressible:!0,extensions:["obgx"]},"application/vnd.openblox.game-binary":{source:"iana"},"application/vnd.openeye.oeb":{source:"iana"},"application/vnd.openofficeorg.extension":{source:"apache",extensions:["oxt"]},"application/vnd.openstreetmap.data+xml":{source:"iana",compressible:!0,extensions:["osm"]},"application/vnd.opentimestamps.ots":{source:"iana"},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawing+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",compressible:!1,extensions:["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slide":{source:"iana",extensions:["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{source:"iana",extensions:["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.template":{source:"iana",extensions:["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",compressible:!1,extensions:["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{source:"iana",extensions:["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.theme+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.vmldrawing":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",compressible:!1,extensions:["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{source:"iana",extensions:["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.core-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.relationships+xml":{source:"iana",compressible:!0},"application/vnd.oracle.resource+json":{source:"iana",compressible:!0},"application/vnd.orange.indata":{source:"iana"},"application/vnd.osa.netdeploy":{source:"iana"},"application/vnd.osgeo.mapguide.package":{source:"iana",extensions:["mgp"]},"application/vnd.osgi.bundle":{source:"iana"},"application/vnd.osgi.dp":{source:"iana",extensions:["dp"]},"application/vnd.osgi.subsystem":{source:"iana",extensions:["esa"]},"application/vnd.otps.ct-kip+xml":{source:"iana",compressible:!0},"application/vnd.oxli.countgraph":{source:"iana"},"application/vnd.pagerduty+json":{source:"iana",compressible:!0},"application/vnd.palm":{source:"iana",extensions:["pdb","pqa","oprc"]},"application/vnd.panoply":{source:"iana"},"application/vnd.paos.xml":{source:"iana"},"application/vnd.patentdive":{source:"iana"},"application/vnd.patientecommsdoc":{source:"iana"},"application/vnd.pawaafile":{source:"iana",extensions:["paw"]},"application/vnd.pcos":{source:"iana"},"application/vnd.pg.format":{source:"iana",extensions:["str"]},"application/vnd.pg.osasli":{source:"iana",extensions:["ei6"]},"application/vnd.piaccess.application-licence":{source:"iana"},"application/vnd.picsel":{source:"iana",extensions:["efif"]},"application/vnd.pmi.widget":{source:"iana",extensions:["wg"]},"application/vnd.poc.group-advertisement+xml":{source:"iana",compressible:!0},"application/vnd.pocketlearn":{source:"iana",extensions:["plf"]},"application/vnd.powerbuilder6":{source:"iana",extensions:["pbd"]},"application/vnd.powerbuilder6-s":{source:"iana"},"application/vnd.powerbuilder7":{source:"iana"},"application/vnd.powerbuilder7-s":{source:"iana"},"application/vnd.powerbuilder75":{source:"iana"},"application/vnd.powerbuilder75-s":{source:"iana"},"application/vnd.preminet":{source:"iana"},"application/vnd.previewsystems.box":{source:"iana",extensions:["box"]},"application/vnd.proteus.magazine":{source:"iana",extensions:["mgz"]},"application/vnd.psfs":{source:"iana"},"application/vnd.publishare-delta-tree":{source:"iana",extensions:["qps"]},"application/vnd.pvi.ptid1":{source:"iana",extensions:["ptid"]},"application/vnd.pwg-multiplexed":{source:"iana"},"application/vnd.pwg-xhtml-print+xml":{source:"iana",compressible:!0},"application/vnd.qualcomm.brew-app-res":{source:"iana"},"application/vnd.quarantainenet":{source:"iana"},"application/vnd.quark.quarkxpress":{source:"iana",extensions:["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{source:"iana"},"application/vnd.radisys.moml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conn+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-stream+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-base+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-detect+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-group+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-speech+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-transform+xml":{source:"iana",compressible:!0},"application/vnd.rainstor.data":{source:"iana"},"application/vnd.rapid":{source:"iana"},"application/vnd.rar":{source:"iana",extensions:["rar"]},"application/vnd.realvnc.bed":{source:"iana",extensions:["bed"]},"application/vnd.recordare.musicxml":{source:"iana",extensions:["mxl"]},"application/vnd.recordare.musicxml+xml":{source:"iana",compressible:!0,extensions:["musicxml"]},"application/vnd.renlearn.rlprint":{source:"iana"},"application/vnd.resilient.logic":{source:"iana"},"application/vnd.restful+json":{source:"iana",compressible:!0},"application/vnd.rig.cryptonote":{source:"iana",extensions:["cryptonote"]},"application/vnd.rim.cod":{source:"apache",extensions:["cod"]},"application/vnd.rn-realmedia":{source:"apache",extensions:["rm"]},"application/vnd.rn-realmedia-vbr":{source:"apache",extensions:["rmvb"]},"application/vnd.route66.link66+xml":{source:"iana",compressible:!0,extensions:["link66"]},"application/vnd.rs-274x":{source:"iana"},"application/vnd.ruckus.download":{source:"iana"},"application/vnd.s3sms":{source:"iana"},"application/vnd.sailingtracker.track":{source:"iana",extensions:["st"]},"application/vnd.sar":{source:"iana"},"application/vnd.sbm.cid":{source:"iana"},"application/vnd.sbm.mid2":{source:"iana"},"application/vnd.scribus":{source:"iana"},"application/vnd.sealed.3df":{source:"iana"},"application/vnd.sealed.csf":{source:"iana"},"application/vnd.sealed.doc":{source:"iana"},"application/vnd.sealed.eml":{source:"iana"},"application/vnd.sealed.mht":{source:"iana"},"application/vnd.sealed.net":{source:"iana"},"application/vnd.sealed.ppt":{source:"iana"},"application/vnd.sealed.tiff":{source:"iana"},"application/vnd.sealed.xls":{source:"iana"},"application/vnd.sealedmedia.softseal.html":{source:"iana"},"application/vnd.sealedmedia.softseal.pdf":{source:"iana"},"application/vnd.seemail":{source:"iana",extensions:["see"]},"application/vnd.seis+json":{source:"iana",compressible:!0},"application/vnd.sema":{source:"iana",extensions:["sema"]},"application/vnd.semd":{source:"iana",extensions:["semd"]},"application/vnd.semf":{source:"iana",extensions:["semf"]},"application/vnd.shade-save-file":{source:"iana"},"application/vnd.shana.informed.formdata":{source:"iana",extensions:["ifm"]},"application/vnd.shana.informed.formtemplate":{source:"iana",extensions:["itp"]},"application/vnd.shana.informed.interchange":{source:"iana",extensions:["iif"]},"application/vnd.shana.informed.package":{source:"iana",extensions:["ipk"]},"application/vnd.shootproof+json":{source:"iana",compressible:!0},"application/vnd.shopkick+json":{source:"iana",compressible:!0},"application/vnd.shp":{source:"iana"},"application/vnd.shx":{source:"iana"},"application/vnd.sigrok.session":{source:"iana"},"application/vnd.simtech-mindmapper":{source:"iana",extensions:["twd","twds"]},"application/vnd.siren+json":{source:"iana",compressible:!0},"application/vnd.smaf":{source:"iana",extensions:["mmf"]},"application/vnd.smart.notebook":{source:"iana"},"application/vnd.smart.teacher":{source:"iana",extensions:["teacher"]},"application/vnd.snesdev-page-table":{source:"iana"},"application/vnd.software602.filler.form+xml":{source:"iana",compressible:!0,extensions:["fo"]},"application/vnd.software602.filler.form-xml-zip":{source:"iana"},"application/vnd.solent.sdkm+xml":{source:"iana",compressible:!0,extensions:["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{source:"iana",extensions:["dxp"]},"application/vnd.spotfire.sfs":{source:"iana",extensions:["sfs"]},"application/vnd.sqlite3":{source:"iana"},"application/vnd.sss-cod":{source:"iana"},"application/vnd.sss-dtf":{source:"iana"},"application/vnd.sss-ntf":{source:"iana"},"application/vnd.stardivision.calc":{source:"apache",extensions:["sdc"]},"application/vnd.stardivision.draw":{source:"apache",extensions:["sda"]},"application/vnd.stardivision.impress":{source:"apache",extensions:["sdd"]},"application/vnd.stardivision.math":{source:"apache",extensions:["smf"]},"application/vnd.stardivision.writer":{source:"apache",extensions:["sdw","vor"]},"application/vnd.stardivision.writer-global":{source:"apache",extensions:["sgl"]},"application/vnd.stepmania.package":{source:"iana",extensions:["smzip"]},"application/vnd.stepmania.stepchart":{source:"iana",extensions:["sm"]},"application/vnd.street-stream":{source:"iana"},"application/vnd.sun.wadl+xml":{source:"iana",compressible:!0,extensions:["wadl"]},"application/vnd.sun.xml.calc":{source:"apache",extensions:["sxc"]},"application/vnd.sun.xml.calc.template":{source:"apache",extensions:["stc"]},"application/vnd.sun.xml.draw":{source:"apache",extensions:["sxd"]},"application/vnd.sun.xml.draw.template":{source:"apache",extensions:["std"]},"application/vnd.sun.xml.impress":{source:"apache",extensions:["sxi"]},"application/vnd.sun.xml.impress.template":{source:"apache",extensions:["sti"]},"application/vnd.sun.xml.math":{source:"apache",extensions:["sxm"]},"application/vnd.sun.xml.writer":{source:"apache",extensions:["sxw"]},"application/vnd.sun.xml.writer.global":{source:"apache",extensions:["sxg"]},"application/vnd.sun.xml.writer.template":{source:"apache",extensions:["stw"]},"application/vnd.sus-calendar":{source:"iana",extensions:["sus","susp"]},"application/vnd.svd":{source:"iana",extensions:["svd"]},"application/vnd.swiftview-ics":{source:"iana"},"application/vnd.sycle+xml":{source:"iana",compressible:!0},"application/vnd.syft+json":{source:"iana",compressible:!0},"application/vnd.symbian.install":{source:"apache",extensions:["sis","sisx"]},"application/vnd.syncml+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xsm"]},"application/vnd.syncml.dm+wbxml":{source:"iana",charset:"UTF-8",extensions:["bdm"]},"application/vnd.syncml.dm+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xdm"]},"application/vnd.syncml.dm.notification":{source:"iana"},"application/vnd.syncml.dmddf+wbxml":{source:"iana"},"application/vnd.syncml.dmddf+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{source:"iana"},"application/vnd.syncml.dmtnds+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.syncml.ds.notification":{source:"iana"},"application/vnd.tableschema+json":{source:"iana",compressible:!0},"application/vnd.tao.intent-module-archive":{source:"iana",extensions:["tao"]},"application/vnd.tcpdump.pcap":{source:"iana",extensions:["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{source:"iana",compressible:!0},"application/vnd.tmd.mediaflex.api+xml":{source:"iana",compressible:!0},"application/vnd.tml":{source:"iana"},"application/vnd.tmobile-livetv":{source:"iana",extensions:["tmo"]},"application/vnd.tri.onesource":{source:"iana"},"application/vnd.trid.tpt":{source:"iana",extensions:["tpt"]},"application/vnd.triscape.mxs":{source:"iana",extensions:["mxs"]},"application/vnd.trueapp":{source:"iana",extensions:["tra"]},"application/vnd.truedoc":{source:"iana"},"application/vnd.ubisoft.webplayer":{source:"iana"},"application/vnd.ufdl":{source:"iana",extensions:["ufd","ufdl"]},"application/vnd.uiq.theme":{source:"iana",extensions:["utz"]},"application/vnd.umajin":{source:"iana",extensions:["umj"]},"application/vnd.unity":{source:"iana",extensions:["unityweb"]},"application/vnd.uoml+xml":{source:"iana",compressible:!0,extensions:["uoml"]},"application/vnd.uplanet.alert":{source:"iana"},"application/vnd.uplanet.alert-wbxml":{source:"iana"},"application/vnd.uplanet.bearer-choice":{source:"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{source:"iana"},"application/vnd.uplanet.cacheop":{source:"iana"},"application/vnd.uplanet.cacheop-wbxml":{source:"iana"},"application/vnd.uplanet.channel":{source:"iana"},"application/vnd.uplanet.channel-wbxml":{source:"iana"},"application/vnd.uplanet.list":{source:"iana"},"application/vnd.uplanet.list-wbxml":{source:"iana"},"application/vnd.uplanet.listcmd":{source:"iana"},"application/vnd.uplanet.listcmd-wbxml":{source:"iana"},"application/vnd.uplanet.signal":{source:"iana"},"application/vnd.uri-map":{source:"iana"},"application/vnd.valve.source.material":{source:"iana"},"application/vnd.vcx":{source:"iana",extensions:["vcx"]},"application/vnd.vd-study":{source:"iana"},"application/vnd.vectorworks":{source:"iana"},"application/vnd.vel+json":{source:"iana",compressible:!0},"application/vnd.verimatrix.vcas":{source:"iana"},"application/vnd.veritone.aion+json":{source:"iana",compressible:!0},"application/vnd.veryant.thin":{source:"iana"},"application/vnd.ves.encrypted":{source:"iana"},"application/vnd.vidsoft.vidconference":{source:"iana"},"application/vnd.visio":{source:"iana",extensions:["vsd","vst","vss","vsw"]},"application/vnd.visionary":{source:"iana",extensions:["vis"]},"application/vnd.vividence.scriptfile":{source:"iana"},"application/vnd.vsf":{source:"iana",extensions:["vsf"]},"application/vnd.wap.sic":{source:"iana"},"application/vnd.wap.slc":{source:"iana"},"application/vnd.wap.wbxml":{source:"iana",charset:"UTF-8",extensions:["wbxml"]},"application/vnd.wap.wmlc":{source:"iana",extensions:["wmlc"]},"application/vnd.wap.wmlscriptc":{source:"iana",extensions:["wmlsc"]},"application/vnd.webturbo":{source:"iana",extensions:["wtb"]},"application/vnd.wfa.dpp":{source:"iana"},"application/vnd.wfa.p2p":{source:"iana"},"application/vnd.wfa.wsc":{source:"iana"},"application/vnd.windows.devicepairing":{source:"iana"},"application/vnd.wmc":{source:"iana"},"application/vnd.wmf.bootstrap":{source:"iana"},"application/vnd.wolfram.mathematica":{source:"iana"},"application/vnd.wolfram.mathematica.package":{source:"iana"},"application/vnd.wolfram.player":{source:"iana",extensions:["nbp"]},"application/vnd.wordperfect":{source:"iana",extensions:["wpd"]},"application/vnd.wqd":{source:"iana",extensions:["wqd"]},"application/vnd.wrq-hp3000-labelled":{source:"iana"},"application/vnd.wt.stf":{source:"iana",extensions:["stf"]},"application/vnd.wv.csp+wbxml":{source:"iana"},"application/vnd.wv.csp+xml":{source:"iana",compressible:!0},"application/vnd.wv.ssp+xml":{source:"iana",compressible:!0},"application/vnd.xacml+json":{source:"iana",compressible:!0},"application/vnd.xara":{source:"iana",extensions:["xar"]},"application/vnd.xfdl":{source:"iana",extensions:["xfdl"]},"application/vnd.xfdl.webform":{source:"iana"},"application/vnd.xmi+xml":{source:"iana",compressible:!0},"application/vnd.xmpie.cpkg":{source:"iana"},"application/vnd.xmpie.dpkg":{source:"iana"},"application/vnd.xmpie.plan":{source:"iana"},"application/vnd.xmpie.ppkg":{source:"iana"},"application/vnd.xmpie.xlim":{source:"iana"},"application/vnd.yamaha.hv-dic":{source:"iana",extensions:["hvd"]},"application/vnd.yamaha.hv-script":{source:"iana",extensions:["hvs"]},"application/vnd.yamaha.hv-voice":{source:"iana",extensions:["hvp"]},"application/vnd.yamaha.openscoreformat":{source:"iana",extensions:["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{source:"iana",compressible:!0,extensions:["osfpvg"]},"application/vnd.yamaha.remote-setup":{source:"iana"},"application/vnd.yamaha.smaf-audio":{source:"iana",extensions:["saf"]},"application/vnd.yamaha.smaf-phrase":{source:"iana",extensions:["spf"]},"application/vnd.yamaha.through-ngn":{source:"iana"},"application/vnd.yamaha.tunnel-udpencap":{source:"iana"},"application/vnd.yaoweme":{source:"iana"},"application/vnd.yellowriver-custom-menu":{source:"iana",extensions:["cmp"]},"application/vnd.youtube.yt":{source:"iana"},"application/vnd.zul":{source:"iana",extensions:["zir","zirz"]},"application/vnd.zzazz.deck+xml":{source:"iana",compressible:!0,extensions:["zaz"]},"application/voicexml+xml":{source:"iana",compressible:!0,extensions:["vxml"]},"application/voucher-cms+json":{source:"iana",compressible:!0},"application/vq-rtcpxr":{source:"iana"},"application/wasm":{source:"iana",compressible:!0,extensions:["wasm"]},"application/watcherinfo+xml":{source:"iana",compressible:!0,extensions:["wif"]},"application/webpush-options+json":{source:"iana",compressible:!0},"application/whoispp-query":{source:"iana"},"application/whoispp-response":{source:"iana"},"application/widget":{source:"iana",extensions:["wgt"]},"application/winhlp":{source:"apache",extensions:["hlp"]},"application/wita":{source:"iana"},"application/wordperfect5.1":{source:"iana"},"application/wsdl+xml":{source:"iana",compressible:!0,extensions:["wsdl"]},"application/wspolicy+xml":{source:"iana",compressible:!0,extensions:["wspolicy"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/x-abiword":{source:"apache",extensions:["abw"]},"application/x-ace-compressed":{source:"apache",extensions:["ace"]},"application/x-amf":{source:"apache"},"application/x-apple-diskimage":{source:"apache",extensions:["dmg"]},"application/x-arj":{compressible:!1,extensions:["arj"]},"application/x-authorware-bin":{source:"apache",extensions:["aab","x32","u32","vox"]},"application/x-authorware-map":{source:"apache",extensions:["aam"]},"application/x-authorware-seg":{source:"apache",extensions:["aas"]},"application/x-bcpio":{source:"apache",extensions:["bcpio"]},"application/x-bdoc":{compressible:!1,extensions:["bdoc"]},"application/x-bittorrent":{source:"apache",extensions:["torrent"]},"application/x-blorb":{source:"apache",extensions:["blb","blorb"]},"application/x-bzip":{source:"apache",compressible:!1,extensions:["bz"]},"application/x-bzip2":{source:"apache",compressible:!1,extensions:["bz2","boz"]},"application/x-cbr":{source:"apache",extensions:["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{source:"apache",extensions:["vcd"]},"application/x-cfs-compressed":{source:"apache",extensions:["cfs"]},"application/x-chat":{source:"apache",extensions:["chat"]},"application/x-chess-pgn":{source:"apache",extensions:["pgn"]},"application/x-chrome-extension":{extensions:["crx"]},"application/x-cocoa":{source:"nginx",extensions:["cco"]},"application/x-compress":{source:"apache"},"application/x-conference":{source:"apache",extensions:["nsc"]},"application/x-cpio":{source:"apache",extensions:["cpio"]},"application/x-csh":{source:"apache",extensions:["csh"]},"application/x-deb":{compressible:!1},"application/x-debian-package":{source:"apache",extensions:["deb","udeb"]},"application/x-dgc-compressed":{source:"apache",extensions:["dgc"]},"application/x-director":{source:"apache",extensions:["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{source:"apache",extensions:["wad"]},"application/x-dtbncx+xml":{source:"apache",compressible:!0,extensions:["ncx"]},"application/x-dtbook+xml":{source:"apache",compressible:!0,extensions:["dtb"]},"application/x-dtbresource+xml":{source:"apache",compressible:!0,extensions:["res"]},"application/x-dvi":{source:"apache",compressible:!1,extensions:["dvi"]},"application/x-envoy":{source:"apache",extensions:["evy"]},"application/x-eva":{source:"apache",extensions:["eva"]},"application/x-font-bdf":{source:"apache",extensions:["bdf"]},"application/x-font-dos":{source:"apache"},"application/x-font-framemaker":{source:"apache"},"application/x-font-ghostscript":{source:"apache",extensions:["gsf"]},"application/x-font-libgrx":{source:"apache"},"application/x-font-linux-psf":{source:"apache",extensions:["psf"]},"application/x-font-pcf":{source:"apache",extensions:["pcf"]},"application/x-font-snf":{source:"apache",extensions:["snf"]},"application/x-font-speedo":{source:"apache"},"application/x-font-sunos-news":{source:"apache"},"application/x-font-type1":{source:"apache",extensions:["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{source:"apache"},"application/x-freearc":{source:"apache",extensions:["arc"]},"application/x-futuresplash":{source:"apache",extensions:["spl"]},"application/x-gca-compressed":{source:"apache",extensions:["gca"]},"application/x-glulx":{source:"apache",extensions:["ulx"]},"application/x-gnumeric":{source:"apache",extensions:["gnumeric"]},"application/x-gramps-xml":{source:"apache",extensions:["gramps"]},"application/x-gtar":{source:"apache",extensions:["gtar"]},"application/x-gzip":{source:"apache"},"application/x-hdf":{source:"apache",extensions:["hdf"]},"application/x-httpd-php":{compressible:!0,extensions:["php"]},"application/x-install-instructions":{source:"apache",extensions:["install"]},"application/x-iso9660-image":{source:"apache",extensions:["iso"]},"application/x-iwork-keynote-sffkey":{extensions:["key"]},"application/x-iwork-numbers-sffnumbers":{extensions:["numbers"]},"application/x-iwork-pages-sffpages":{extensions:["pages"]},"application/x-java-archive-diff":{source:"nginx",extensions:["jardiff"]},"application/x-java-jnlp-file":{source:"apache",compressible:!1,extensions:["jnlp"]},"application/x-javascript":{compressible:!0},"application/x-keepass2":{extensions:["kdbx"]},"application/x-latex":{source:"apache",compressible:!1,extensions:["latex"]},"application/x-lua-bytecode":{extensions:["luac"]},"application/x-lzh-compressed":{source:"apache",extensions:["lzh","lha"]},"application/x-makeself":{source:"nginx",extensions:["run"]},"application/x-mie":{source:"apache",extensions:["mie"]},"application/x-mobipocket-ebook":{source:"apache",extensions:["prc","mobi"]},"application/x-mpegurl":{compressible:!1},"application/x-ms-application":{source:"apache",extensions:["application"]},"application/x-ms-shortcut":{source:"apache",extensions:["lnk"]},"application/x-ms-wmd":{source:"apache",extensions:["wmd"]},"application/x-ms-wmz":{source:"apache",extensions:["wmz"]},"application/x-ms-xbap":{source:"apache",extensions:["xbap"]},"application/x-msaccess":{source:"apache",extensions:["mdb"]},"application/x-msbinder":{source:"apache",extensions:["obd"]},"application/x-mscardfile":{source:"apache",extensions:["crd"]},"application/x-msclip":{source:"apache",extensions:["clp"]},"application/x-msdos-program":{extensions:["exe"]},"application/x-msdownload":{source:"apache",extensions:["exe","dll","com","bat","msi"]},"application/x-msmediaview":{source:"apache",extensions:["mvb","m13","m14"]},"application/x-msmetafile":{source:"apache",extensions:["wmf","wmz","emf","emz"]},"application/x-msmoney":{source:"apache",extensions:["mny"]},"application/x-mspublisher":{source:"apache",extensions:["pub"]},"application/x-msschedule":{source:"apache",extensions:["scd"]},"application/x-msterminal":{source:"apache",extensions:["trm"]},"application/x-mswrite":{source:"apache",extensions:["wri"]},"application/x-netcdf":{source:"apache",extensions:["nc","cdf"]},"application/x-ns-proxy-autoconfig":{compressible:!0,extensions:["pac"]},"application/x-nzb":{source:"apache",extensions:["nzb"]},"application/x-perl":{source:"nginx",extensions:["pl","pm"]},"application/x-pilot":{source:"nginx",extensions:["prc","pdb"]},"application/x-pkcs12":{source:"apache",compressible:!1,extensions:["p12","pfx"]},"application/x-pkcs7-certificates":{source:"apache",extensions:["p7b","spc"]},"application/x-pkcs7-certreqresp":{source:"apache",extensions:["p7r"]},"application/x-pki-message":{source:"iana"},"application/x-rar-compressed":{source:"apache",compressible:!1,extensions:["rar"]},"application/x-redhat-package-manager":{source:"nginx",extensions:["rpm"]},"application/x-research-info-systems":{source:"apache",extensions:["ris"]},"application/x-sea":{source:"nginx",extensions:["sea"]},"application/x-sh":{source:"apache",compressible:!0,extensions:["sh"]},"application/x-shar":{source:"apache",extensions:["shar"]},"application/x-shockwave-flash":{source:"apache",compressible:!1,extensions:["swf"]},"application/x-silverlight-app":{source:"apache",extensions:["xap"]},"application/x-sql":{source:"apache",extensions:["sql"]},"application/x-stuffit":{source:"apache",compressible:!1,extensions:["sit"]},"application/x-stuffitx":{source:"apache",extensions:["sitx"]},"application/x-subrip":{source:"apache",extensions:["srt"]},"application/x-sv4cpio":{source:"apache",extensions:["sv4cpio"]},"application/x-sv4crc":{source:"apache",extensions:["sv4crc"]},"application/x-t3vm-image":{source:"apache",extensions:["t3"]},"application/x-tads":{source:"apache",extensions:["gam"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-tcl":{source:"apache",extensions:["tcl","tk"]},"application/x-tex":{source:"apache",extensions:["tex"]},"application/x-tex-tfm":{source:"apache",extensions:["tfm"]},"application/x-texinfo":{source:"apache",extensions:["texinfo","texi"]},"application/x-tgif":{source:"apache",extensions:["obj"]},"application/x-ustar":{source:"apache",extensions:["ustar"]},"application/x-virtualbox-hdd":{compressible:!0,extensions:["hdd"]},"application/x-virtualbox-ova":{compressible:!0,extensions:["ova"]},"application/x-virtualbox-ovf":{compressible:!0,extensions:["ovf"]},"application/x-virtualbox-vbox":{compressible:!0,extensions:["vbox"]},"application/x-virtualbox-vbox-extpack":{compressible:!1,extensions:["vbox-extpack"]},"application/x-virtualbox-vdi":{compressible:!0,extensions:["vdi"]},"application/x-virtualbox-vhd":{compressible:!0,extensions:["vhd"]},"application/x-virtualbox-vmdk":{compressible:!0,extensions:["vmdk"]},"application/x-wais-source":{source:"apache",extensions:["src"]},"application/x-web-app-manifest+json":{compressible:!0,extensions:["webapp"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"application/x-x509-ca-cert":{source:"iana",extensions:["der","crt","pem"]},"application/x-x509-ca-ra-cert":{source:"iana"},"application/x-x509-next-ca-cert":{source:"iana"},"application/x-xfig":{source:"apache",extensions:["fig"]},"application/x-xliff+xml":{source:"apache",compressible:!0,extensions:["xlf"]},"application/x-xpinstall":{source:"apache",compressible:!1,extensions:["xpi"]},"application/x-xz":{source:"apache",extensions:["xz"]},"application/x-zmachine":{source:"apache",extensions:["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{source:"iana"},"application/xacml+xml":{source:"iana",compressible:!0},"application/xaml+xml":{source:"apache",compressible:!0,extensions:["xaml"]},"application/xcap-att+xml":{source:"iana",compressible:!0,extensions:["xav"]},"application/xcap-caps+xml":{source:"iana",compressible:!0,extensions:["xca"]},"application/xcap-diff+xml":{source:"iana",compressible:!0,extensions:["xdf"]},"application/xcap-el+xml":{source:"iana",compressible:!0,extensions:["xel"]},"application/xcap-error+xml":{source:"iana",compressible:!0},"application/xcap-ns+xml":{source:"iana",compressible:!0,extensions:["xns"]},"application/xcon-conference-info+xml":{source:"iana",compressible:!0},"application/xcon-conference-info-diff+xml":{source:"iana",compressible:!0},"application/xenc+xml":{source:"iana",compressible:!0,extensions:["xenc"]},"application/xhtml+xml":{source:"iana",compressible:!0,extensions:["xhtml","xht"]},"application/xhtml-voice+xml":{source:"apache",compressible:!0},"application/xliff+xml":{source:"iana",compressible:!0,extensions:["xlf"]},"application/xml":{source:"iana",compressible:!0,extensions:["xml","xsl","xsd","rng"]},"application/xml-dtd":{source:"iana",compressible:!0,extensions:["dtd"]},"application/xml-external-parsed-entity":{source:"iana"},"application/xml-patch+xml":{source:"iana",compressible:!0},"application/xmpp+xml":{source:"iana",compressible:!0},"application/xop+xml":{source:"iana",compressible:!0,extensions:["xop"]},"application/xproc+xml":{source:"apache",compressible:!0,extensions:["xpl"]},"application/xslt+xml":{source:"iana",compressible:!0,extensions:["xsl","xslt"]},"application/xspf+xml":{source:"apache",compressible:!0,extensions:["xspf"]},"application/xv+xml":{source:"iana",compressible:!0,extensions:["mxml","xhvml","xvml","xvm"]},"application/yang":{source:"iana",extensions:["yang"]},"application/yang-data+json":{source:"iana",compressible:!0},"application/yang-data+xml":{source:"iana",compressible:!0},"application/yang-patch+json":{source:"iana",compressible:!0},"application/yang-patch+xml":{source:"iana",compressible:!0},"application/yin+xml":{source:"iana",compressible:!0,extensions:["yin"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/zlib":{source:"iana"},"application/zstd":{source:"iana"},"audio/1d-interleaved-parityfec":{source:"iana"},"audio/32kadpcm":{source:"iana"},"audio/3gpp":{source:"iana",compressible:!1,extensions:["3gpp"]},"audio/3gpp2":{source:"iana"},"audio/aac":{source:"iana"},"audio/ac3":{source:"iana"},"audio/adpcm":{source:"apache",extensions:["adp"]},"audio/amr":{source:"iana",extensions:["amr"]},"audio/amr-wb":{source:"iana"},"audio/amr-wb+":{source:"iana"},"audio/aptx":{source:"iana"},"audio/asc":{source:"iana"},"audio/atrac-advanced-lossless":{source:"iana"},"audio/atrac-x":{source:"iana"},"audio/atrac3":{source:"iana"},"audio/basic":{source:"iana",compressible:!1,extensions:["au","snd"]},"audio/bv16":{source:"iana"},"audio/bv32":{source:"iana"},"audio/clearmode":{source:"iana"},"audio/cn":{source:"iana"},"audio/dat12":{source:"iana"},"audio/dls":{source:"iana"},"audio/dsr-es201108":{source:"iana"},"audio/dsr-es202050":{source:"iana"},"audio/dsr-es202211":{source:"iana"},"audio/dsr-es202212":{source:"iana"},"audio/dv":{source:"iana"},"audio/dvi4":{source:"iana"},"audio/eac3":{source:"iana"},"audio/encaprtp":{source:"iana"},"audio/evrc":{source:"iana"},"audio/evrc-qcp":{source:"iana"},"audio/evrc0":{source:"iana"},"audio/evrc1":{source:"iana"},"audio/evrcb":{source:"iana"},"audio/evrcb0":{source:"iana"},"audio/evrcb1":{source:"iana"},"audio/evrcnw":{source:"iana"},"audio/evrcnw0":{source:"iana"},"audio/evrcnw1":{source:"iana"},"audio/evrcwb":{source:"iana"},"audio/evrcwb0":{source:"iana"},"audio/evrcwb1":{source:"iana"},"audio/evs":{source:"iana"},"audio/flexfec":{source:"iana"},"audio/fwdred":{source:"iana"},"audio/g711-0":{source:"iana"},"audio/g719":{source:"iana"},"audio/g722":{source:"iana"},"audio/g7221":{source:"iana"},"audio/g723":{source:"iana"},"audio/g726-16":{source:"iana"},"audio/g726-24":{source:"iana"},"audio/g726-32":{source:"iana"},"audio/g726-40":{source:"iana"},"audio/g728":{source:"iana"},"audio/g729":{source:"iana"},"audio/g7291":{source:"iana"},"audio/g729d":{source:"iana"},"audio/g729e":{source:"iana"},"audio/gsm":{source:"iana"},"audio/gsm-efr":{source:"iana"},"audio/gsm-hr-08":{source:"iana"},"audio/ilbc":{source:"iana"},"audio/ip-mr_v2.5":{source:"iana"},"audio/isac":{source:"apache"},"audio/l16":{source:"iana"},"audio/l20":{source:"iana"},"audio/l24":{source:"iana",compressible:!1},"audio/l8":{source:"iana"},"audio/lpc":{source:"iana"},"audio/melp":{source:"iana"},"audio/melp1200":{source:"iana"},"audio/melp2400":{source:"iana"},"audio/melp600":{source:"iana"},"audio/mhas":{source:"iana"},"audio/midi":{source:"apache",extensions:["mid","midi","kar","rmi"]},"audio/mobile-xmf":{source:"iana",extensions:["mxmf"]},"audio/mp3":{compressible:!1,extensions:["mp3"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a","mp4a"]},"audio/mp4a-latm":{source:"iana"},"audio/mpa":{source:"iana"},"audio/mpa-robust":{source:"iana"},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{source:"iana"},"audio/musepack":{source:"apache"},"audio/ogg":{source:"iana",compressible:!1,extensions:["oga","ogg","spx","opus"]},"audio/opus":{source:"iana"},"audio/parityfec":{source:"iana"},"audio/pcma":{source:"iana"},"audio/pcma-wb":{source:"iana"},"audio/pcmu":{source:"iana"},"audio/pcmu-wb":{source:"iana"},"audio/prs.sid":{source:"iana"},"audio/qcelp":{source:"iana"},"audio/raptorfec":{source:"iana"},"audio/red":{source:"iana"},"audio/rtp-enc-aescm128":{source:"iana"},"audio/rtp-midi":{source:"iana"},"audio/rtploopback":{source:"iana"},"audio/rtx":{source:"iana"},"audio/s3m":{source:"apache",extensions:["s3m"]},"audio/scip":{source:"iana"},"audio/silk":{source:"apache",extensions:["sil"]},"audio/smv":{source:"iana"},"audio/smv-qcp":{source:"iana"},"audio/smv0":{source:"iana"},"audio/sofa":{source:"iana"},"audio/sp-midi":{source:"iana"},"audio/speex":{source:"iana"},"audio/t140c":{source:"iana"},"audio/t38":{source:"iana"},"audio/telephone-event":{source:"iana"},"audio/tetra_acelp":{source:"iana"},"audio/tetra_acelp_bb":{source:"iana"},"audio/tone":{source:"iana"},"audio/tsvcis":{source:"iana"},"audio/uemclip":{source:"iana"},"audio/ulpfec":{source:"iana"},"audio/usac":{source:"iana"},"audio/vdvi":{source:"iana"},"audio/vmr-wb":{source:"iana"},"audio/vnd.3gpp.iufp":{source:"iana"},"audio/vnd.4sb":{source:"iana"},"audio/vnd.audiokoz":{source:"iana"},"audio/vnd.celp":{source:"iana"},"audio/vnd.cisco.nse":{source:"iana"},"audio/vnd.cmles.radio-events":{source:"iana"},"audio/vnd.cns.anp1":{source:"iana"},"audio/vnd.cns.inf1":{source:"iana"},"audio/vnd.dece.audio":{source:"iana",extensions:["uva","uvva"]},"audio/vnd.digital-winds":{source:"iana",extensions:["eol"]},"audio/vnd.dlna.adts":{source:"iana"},"audio/vnd.dolby.heaac.1":{source:"iana"},"audio/vnd.dolby.heaac.2":{source:"iana"},"audio/vnd.dolby.mlp":{source:"iana"},"audio/vnd.dolby.mps":{source:"iana"},"audio/vnd.dolby.pl2":{source:"iana"},"audio/vnd.dolby.pl2x":{source:"iana"},"audio/vnd.dolby.pl2z":{source:"iana"},"audio/vnd.dolby.pulse.1":{source:"iana"},"audio/vnd.dra":{source:"iana",extensions:["dra"]},"audio/vnd.dts":{source:"iana",extensions:["dts"]},"audio/vnd.dts.hd":{source:"iana",extensions:["dtshd"]},"audio/vnd.dts.uhd":{source:"iana"},"audio/vnd.dvb.file":{source:"iana"},"audio/vnd.everad.plj":{source:"iana"},"audio/vnd.hns.audio":{source:"iana"},"audio/vnd.lucent.voice":{source:"iana",extensions:["lvp"]},"audio/vnd.ms-playready.media.pya":{source:"iana",extensions:["pya"]},"audio/vnd.nokia.mobile-xmf":{source:"iana"},"audio/vnd.nortel.vbk":{source:"iana"},"audio/vnd.nuera.ecelp4800":{source:"iana",extensions:["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{source:"iana",extensions:["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{source:"iana",extensions:["ecelp9600"]},"audio/vnd.octel.sbc":{source:"iana"},"audio/vnd.presonus.multitrack":{source:"iana"},"audio/vnd.qcelp":{source:"iana"},"audio/vnd.rhetorex.32kadpcm":{source:"iana"},"audio/vnd.rip":{source:"iana",extensions:["rip"]},"audio/vnd.rn-realaudio":{compressible:!1},"audio/vnd.sealedmedia.softseal.mpeg":{source:"iana"},"audio/vnd.vmx.cvsd":{source:"iana"},"audio/vnd.wave":{compressible:!1},"audio/vorbis":{source:"iana",compressible:!1},"audio/vorbis-config":{source:"iana"},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/wave":{compressible:!1,extensions:["wav"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/x-aac":{source:"apache",compressible:!1,extensions:["aac"]},"audio/x-aiff":{source:"apache",extensions:["aif","aiff","aifc"]},"audio/x-caf":{source:"apache",compressible:!1,extensions:["caf"]},"audio/x-flac":{source:"apache",extensions:["flac"]},"audio/x-m4a":{source:"nginx",extensions:["m4a"]},"audio/x-matroska":{source:"apache",extensions:["mka"]},"audio/x-mpegurl":{source:"apache",extensions:["m3u"]},"audio/x-ms-wax":{source:"apache",extensions:["wax"]},"audio/x-ms-wma":{source:"apache",extensions:["wma"]},"audio/x-pn-realaudio":{source:"apache",extensions:["ram","ra"]},"audio/x-pn-realaudio-plugin":{source:"apache",extensions:["rmp"]},"audio/x-realaudio":{source:"nginx",extensions:["ra"]},"audio/x-tta":{source:"apache"},"audio/x-wav":{source:"apache",extensions:["wav"]},"audio/xm":{source:"apache",extensions:["xm"]},"chemical/x-cdx":{source:"apache",extensions:["cdx"]},"chemical/x-cif":{source:"apache",extensions:["cif"]},"chemical/x-cmdf":{source:"apache",extensions:["cmdf"]},"chemical/x-cml":{source:"apache",extensions:["cml"]},"chemical/x-csml":{source:"apache",extensions:["csml"]},"chemical/x-pdb":{source:"apache"},"chemical/x-xyz":{source:"apache",extensions:["xyz"]},"font/collection":{source:"iana",extensions:["ttc"]},"font/otf":{source:"iana",compressible:!0,extensions:["otf"]},"font/sfnt":{source:"iana"},"font/ttf":{source:"iana",compressible:!0,extensions:["ttf"]},"font/woff":{source:"iana",extensions:["woff"]},"font/woff2":{source:"iana",extensions:["woff2"]},"image/aces":{source:"iana",extensions:["exr"]},"image/apng":{compressible:!1,extensions:["apng"]},"image/avci":{source:"iana",extensions:["avci"]},"image/avcs":{source:"iana",extensions:["avcs"]},"image/avif":{source:"iana",compressible:!1,extensions:["avif"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/cgm":{source:"iana",extensions:["cgm"]},"image/dicom-rle":{source:"iana",extensions:["drle"]},"image/emf":{source:"iana",extensions:["emf"]},"image/fits":{source:"iana",extensions:["fits"]},"image/g3fax":{source:"iana",extensions:["g3"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/heic":{source:"iana",extensions:["heic"]},"image/heic-sequence":{source:"iana",extensions:["heics"]},"image/heif":{source:"iana",extensions:["heif"]},"image/heif-sequence":{source:"iana",extensions:["heifs"]},"image/hej2k":{source:"iana",extensions:["hej2"]},"image/hsj2":{source:"iana",extensions:["hsj2"]},"image/ief":{source:"iana",extensions:["ief"]},"image/jls":{source:"iana",extensions:["jls"]},"image/jp2":{source:"iana",compressible:!1,extensions:["jp2","jpg2"]},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/jph":{source:"iana",extensions:["jph"]},"image/jphc":{source:"iana",extensions:["jhc"]},"image/jpm":{source:"iana",compressible:!1,extensions:["jpm"]},"image/jpx":{source:"iana",compressible:!1,extensions:["jpx","jpf"]},"image/jxr":{source:"iana",extensions:["jxr"]},"image/jxra":{source:"iana",extensions:["jxra"]},"image/jxrs":{source:"iana",extensions:["jxrs"]},"image/jxs":{source:"iana",extensions:["jxs"]},"image/jxsc":{source:"iana",extensions:["jxsc"]},"image/jxsi":{source:"iana",extensions:["jxsi"]},"image/jxss":{source:"iana",extensions:["jxss"]},"image/ktx":{source:"iana",extensions:["ktx"]},"image/ktx2":{source:"iana",extensions:["ktx2"]},"image/naplps":{source:"iana"},"image/pjpeg":{compressible:!1},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/prs.btif":{source:"iana",extensions:["btif"]},"image/prs.pti":{source:"iana",extensions:["pti"]},"image/pwg-raster":{source:"iana"},"image/sgi":{source:"apache",extensions:["sgi"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/t38":{source:"iana",extensions:["t38"]},"image/tiff":{source:"iana",compressible:!1,extensions:["tif","tiff"]},"image/tiff-fx":{source:"iana",extensions:["tfx"]},"image/vnd.adobe.photoshop":{source:"iana",compressible:!0,extensions:["psd"]},"image/vnd.airzip.accelerator.azv":{source:"iana",extensions:["azv"]},"image/vnd.cns.inf2":{source:"iana"},"image/vnd.dece.graphic":{source:"iana",extensions:["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{source:"iana",extensions:["djvu","djv"]},"image/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"image/vnd.dwg":{source:"iana",extensions:["dwg"]},"image/vnd.dxf":{source:"iana",extensions:["dxf"]},"image/vnd.fastbidsheet":{source:"iana",extensions:["fbs"]},"image/vnd.fpx":{source:"iana",extensions:["fpx"]},"image/vnd.fst":{source:"iana",extensions:["fst"]},"image/vnd.fujixerox.edmics-mmr":{source:"iana",extensions:["mmr"]},"image/vnd.fujixerox.edmics-rlc":{source:"iana",extensions:["rlc"]},"image/vnd.globalgraphics.pgb":{source:"iana"},"image/vnd.microsoft.icon":{source:"iana",compressible:!0,extensions:["ico"]},"image/vnd.mix":{source:"iana"},"image/vnd.mozilla.apng":{source:"iana"},"image/vnd.ms-dds":{compressible:!0,extensions:["dds"]},"image/vnd.ms-modi":{source:"iana",extensions:["mdi"]},"image/vnd.ms-photo":{source:"apache",extensions:["wdp"]},"image/vnd.net-fpx":{source:"iana",extensions:["npx"]},"image/vnd.pco.b16":{source:"iana",extensions:["b16"]},"image/vnd.radiance":{source:"iana"},"image/vnd.sealed.png":{source:"iana"},"image/vnd.sealedmedia.softseal.gif":{source:"iana"},"image/vnd.sealedmedia.softseal.jpg":{source:"iana"},"image/vnd.svf":{source:"iana"},"image/vnd.tencent.tap":{source:"iana",extensions:["tap"]},"image/vnd.valve.source.texture":{source:"iana",extensions:["vtf"]},"image/vnd.wap.wbmp":{source:"iana",extensions:["wbmp"]},"image/vnd.xiff":{source:"iana",extensions:["xif"]},"image/vnd.zbrush.pcx":{source:"iana",extensions:["pcx"]},"image/webp":{source:"apache",extensions:["webp"]},"image/wmf":{source:"iana",extensions:["wmf"]},"image/x-3ds":{source:"apache",extensions:["3ds"]},"image/x-cmu-raster":{source:"apache",extensions:["ras"]},"image/x-cmx":{source:"apache",extensions:["cmx"]},"image/x-freehand":{source:"apache",extensions:["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/x-jng":{source:"nginx",extensions:["jng"]},"image/x-mrsid-image":{source:"apache",extensions:["sid"]},"image/x-ms-bmp":{source:"nginx",compressible:!0,extensions:["bmp"]},"image/x-pcx":{source:"apache",extensions:["pcx"]},"image/x-pict":{source:"apache",extensions:["pic","pct"]},"image/x-portable-anymap":{source:"apache",extensions:["pnm"]},"image/x-portable-bitmap":{source:"apache",extensions:["pbm"]},"image/x-portable-graymap":{source:"apache",extensions:["pgm"]},"image/x-portable-pixmap":{source:"apache",extensions:["ppm"]},"image/x-rgb":{source:"apache",extensions:["rgb"]},"image/x-tga":{source:"apache",extensions:["tga"]},"image/x-xbitmap":{source:"apache",extensions:["xbm"]},"image/x-xcf":{compressible:!1},"image/x-xpixmap":{source:"apache",extensions:["xpm"]},"image/x-xwindowdump":{source:"apache",extensions:["xwd"]},"message/cpim":{source:"iana"},"message/delivery-status":{source:"iana"},"message/disposition-notification":{source:"iana",extensions:["disposition-notification"]},"message/external-body":{source:"iana"},"message/feedback-report":{source:"iana"},"message/global":{source:"iana",extensions:["u8msg"]},"message/global-delivery-status":{source:"iana",extensions:["u8dsn"]},"message/global-disposition-notification":{source:"iana",extensions:["u8mdn"]},"message/global-headers":{source:"iana",extensions:["u8hdr"]},"message/http":{source:"iana",compressible:!1},"message/imdn+xml":{source:"iana",compressible:!0},"message/news":{source:"iana"},"message/partial":{source:"iana",compressible:!1},"message/rfc822":{source:"iana",compressible:!0,extensions:["eml","mime"]},"message/s-http":{source:"iana"},"message/sip":{source:"iana"},"message/sipfrag":{source:"iana"},"message/tracking-status":{source:"iana"},"message/vnd.si.simp":{source:"iana"},"message/vnd.wfa.wsc":{source:"iana",extensions:["wsc"]},"model/3mf":{source:"iana",extensions:["3mf"]},"model/e57":{source:"iana"},"model/gltf+json":{source:"iana",compressible:!0,extensions:["gltf"]},"model/gltf-binary":{source:"iana",compressible:!0,extensions:["glb"]},"model/iges":{source:"iana",compressible:!1,extensions:["igs","iges"]},"model/mesh":{source:"iana",compressible:!1,extensions:["msh","mesh","silo"]},"model/mtl":{source:"iana",extensions:["mtl"]},"model/obj":{source:"iana",extensions:["obj"]},"model/step":{source:"iana"},"model/step+xml":{source:"iana",compressible:!0,extensions:["stpx"]},"model/step+zip":{source:"iana",compressible:!1,extensions:["stpz"]},"model/step-xml+zip":{source:"iana",compressible:!1,extensions:["stpxz"]},"model/stl":{source:"iana",extensions:["stl"]},"model/vnd.collada+xml":{source:"iana",compressible:!0,extensions:["dae"]},"model/vnd.dwf":{source:"iana",extensions:["dwf"]},"model/vnd.flatland.3dml":{source:"iana"},"model/vnd.gdl":{source:"iana",extensions:["gdl"]},"model/vnd.gs-gdl":{source:"apache"},"model/vnd.gs.gdl":{source:"iana"},"model/vnd.gtw":{source:"iana",extensions:["gtw"]},"model/vnd.moml+xml":{source:"iana",compressible:!0},"model/vnd.mts":{source:"iana",extensions:["mts"]},"model/vnd.opengex":{source:"iana",extensions:["ogex"]},"model/vnd.parasolid.transmit.binary":{source:"iana",extensions:["x_b"]},"model/vnd.parasolid.transmit.text":{source:"iana",extensions:["x_t"]},"model/vnd.pytha.pyox":{source:"iana"},"model/vnd.rosette.annotated-data-model":{source:"iana"},"model/vnd.sap.vds":{source:"iana",extensions:["vds"]},"model/vnd.usdz+zip":{source:"iana",compressible:!1,extensions:["usdz"]},"model/vnd.valve.source.compiled-map":{source:"iana",extensions:["bsp"]},"model/vnd.vtu":{source:"iana",extensions:["vtu"]},"model/vrml":{source:"iana",compressible:!1,extensions:["wrl","vrml"]},"model/x3d+binary":{source:"apache",compressible:!1,extensions:["x3db","x3dbz"]},"model/x3d+fastinfoset":{source:"iana",extensions:["x3db"]},"model/x3d+vrml":{source:"apache",compressible:!1,extensions:["x3dv","x3dvz"]},"model/x3d+xml":{source:"iana",compressible:!0,extensions:["x3d","x3dz"]},"model/x3d-vrml":{source:"iana",extensions:["x3dv"]},"multipart/alternative":{source:"iana",compressible:!1},"multipart/appledouble":{source:"iana"},"multipart/byteranges":{source:"iana"},"multipart/digest":{source:"iana"},"multipart/encrypted":{source:"iana",compressible:!1},"multipart/form-data":{source:"iana",compressible:!1},"multipart/header-set":{source:"iana"},"multipart/mixed":{source:"iana"},"multipart/multilingual":{source:"iana"},"multipart/parallel":{source:"iana"},"multipart/related":{source:"iana",compressible:!1},"multipart/report":{source:"iana"},"multipart/signed":{source:"iana",compressible:!1},"multipart/vnd.bint.med-plus":{source:"iana"},"multipart/voice-message":{source:"iana"},"multipart/x-mixed-replace":{source:"iana"},"text/1d-interleaved-parityfec":{source:"iana"},"text/cache-manifest":{source:"iana",compressible:!0,extensions:["appcache","manifest"]},"text/calendar":{source:"iana",extensions:["ics","ifb"]},"text/calender":{compressible:!0},"text/cmd":{compressible:!0},"text/coffeescript":{extensions:["coffee","litcoffee"]},"text/cql":{source:"iana"},"text/cql-expression":{source:"iana"},"text/cql-identifier":{source:"iana"},"text/css":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["css"]},"text/csv":{source:"iana",compressible:!0,extensions:["csv"]},"text/csv-schema":{source:"iana"},"text/directory":{source:"iana"},"text/dns":{source:"iana"},"text/ecmascript":{source:"iana"},"text/encaprtp":{source:"iana"},"text/enriched":{source:"iana"},"text/fhirpath":{source:"iana"},"text/flexfec":{source:"iana"},"text/fwdred":{source:"iana"},"text/gff3":{source:"iana"},"text/grammar-ref-list":{source:"iana"},"text/html":{source:"iana",compressible:!0,extensions:["html","htm","shtml"]},"text/jade":{extensions:["jade"]},"text/javascript":{source:"iana",compressible:!0},"text/jcr-cnd":{source:"iana"},"text/jsx":{compressible:!0,extensions:["jsx"]},"text/less":{compressible:!0,extensions:["less"]},"text/markdown":{source:"iana",compressible:!0,extensions:["markdown","md"]},"text/mathml":{source:"nginx",extensions:["mml"]},"text/mdx":{compressible:!0,extensions:["mdx"]},"text/mizar":{source:"iana"},"text/n3":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["n3"]},"text/parameters":{source:"iana",charset:"UTF-8"},"text/parityfec":{source:"iana"},"text/plain":{source:"iana",compressible:!0,extensions:["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{source:"iana",charset:"UTF-8"},"text/prs.fallenstein.rst":{source:"iana"},"text/prs.lines.tag":{source:"iana",extensions:["dsc"]},"text/prs.prop.logic":{source:"iana"},"text/raptorfec":{source:"iana"},"text/red":{source:"iana"},"text/rfc822-headers":{source:"iana"},"text/richtext":{source:"iana",compressible:!0,extensions:["rtx"]},"text/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"text/rtp-enc-aescm128":{source:"iana"},"text/rtploopback":{source:"iana"},"text/rtx":{source:"iana"},"text/sgml":{source:"iana",extensions:["sgml","sgm"]},"text/shaclc":{source:"iana"},"text/shex":{source:"iana",extensions:["shex"]},"text/slim":{extensions:["slim","slm"]},"text/spdx":{source:"iana",extensions:["spdx"]},"text/strings":{source:"iana"},"text/stylus":{extensions:["stylus","styl"]},"text/t140":{source:"iana"},"text/tab-separated-values":{source:"iana",compressible:!0,extensions:["tsv"]},"text/troff":{source:"iana",extensions:["t","tr","roff","man","me","ms"]},"text/turtle":{source:"iana",charset:"UTF-8",extensions:["ttl"]},"text/ulpfec":{source:"iana"},"text/uri-list":{source:"iana",compressible:!0,extensions:["uri","uris","urls"]},"text/vcard":{source:"iana",compressible:!0,extensions:["vcard"]},"text/vnd.a":{source:"iana"},"text/vnd.abc":{source:"iana"},"text/vnd.ascii-art":{source:"iana"},"text/vnd.curl":{source:"iana",extensions:["curl"]},"text/vnd.curl.dcurl":{source:"apache",extensions:["dcurl"]},"text/vnd.curl.mcurl":{source:"apache",extensions:["mcurl"]},"text/vnd.curl.scurl":{source:"apache",extensions:["scurl"]},"text/vnd.debian.copyright":{source:"iana",charset:"UTF-8"},"text/vnd.dmclientscript":{source:"iana"},"text/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"text/vnd.esmertec.theme-descriptor":{source:"iana",charset:"UTF-8"},"text/vnd.familysearch.gedcom":{source:"iana",extensions:["ged"]},"text/vnd.ficlab.flt":{source:"iana"},"text/vnd.fly":{source:"iana",extensions:["fly"]},"text/vnd.fmi.flexstor":{source:"iana",extensions:["flx"]},"text/vnd.gml":{source:"iana"},"text/vnd.graphviz":{source:"iana",extensions:["gv"]},"text/vnd.hans":{source:"iana"},"text/vnd.hgl":{source:"iana"},"text/vnd.in3d.3dml":{source:"iana",extensions:["3dml"]},"text/vnd.in3d.spot":{source:"iana",extensions:["spot"]},"text/vnd.iptc.newsml":{source:"iana"},"text/vnd.iptc.nitf":{source:"iana"},"text/vnd.latex-z":{source:"iana"},"text/vnd.motorola.reflex":{source:"iana"},"text/vnd.ms-mediapackage":{source:"iana"},"text/vnd.net2phone.commcenter.command":{source:"iana"},"text/vnd.radisys.msml-basic-layout":{source:"iana"},"text/vnd.senx.warpscript":{source:"iana"},"text/vnd.si.uricatalogue":{source:"iana"},"text/vnd.sosi":{source:"iana"},"text/vnd.sun.j2me.app-descriptor":{source:"iana",charset:"UTF-8",extensions:["jad"]},"text/vnd.trolltech.linguist":{source:"iana",charset:"UTF-8"},"text/vnd.wap.si":{source:"iana"},"text/vnd.wap.sl":{source:"iana"},"text/vnd.wap.wml":{source:"iana",extensions:["wml"]},"text/vnd.wap.wmlscript":{source:"iana",extensions:["wmls"]},"text/vtt":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["vtt"]},"text/x-asm":{source:"apache",extensions:["s","asm"]},"text/x-c":{source:"apache",extensions:["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{source:"nginx",extensions:["htc"]},"text/x-fortran":{source:"apache",extensions:["f","for","f77","f90"]},"text/x-gwt-rpc":{compressible:!0},"text/x-handlebars-template":{extensions:["hbs"]},"text/x-java-source":{source:"apache",extensions:["java"]},"text/x-jquery-tmpl":{compressible:!0},"text/x-lua":{extensions:["lua"]},"text/x-markdown":{compressible:!0,extensions:["mkd"]},"text/x-nfo":{source:"apache",extensions:["nfo"]},"text/x-opml":{source:"apache",extensions:["opml"]},"text/x-org":{compressible:!0,extensions:["org"]},"text/x-pascal":{source:"apache",extensions:["p","pas"]},"text/x-processing":{compressible:!0,extensions:["pde"]},"text/x-sass":{extensions:["sass"]},"text/x-scss":{extensions:["scss"]},"text/x-setext":{source:"apache",extensions:["etx"]},"text/x-sfv":{source:"apache",extensions:["sfv"]},"text/x-suse-ymp":{compressible:!0,extensions:["ymp"]},"text/x-uuencode":{source:"apache",extensions:["uu"]},"text/x-vcalendar":{source:"apache",extensions:["vcs"]},"text/x-vcard":{source:"apache",extensions:["vcf"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/xml-external-parsed-entity":{source:"iana"},"text/yaml":{compressible:!0,extensions:["yaml","yml"]},"video/1d-interleaved-parityfec":{source:"iana"},"video/3gpp":{source:"iana",extensions:["3gp","3gpp"]},"video/3gpp-tt":{source:"iana"},"video/3gpp2":{source:"iana",extensions:["3g2"]},"video/av1":{source:"iana"},"video/bmpeg":{source:"iana"},"video/bt656":{source:"iana"},"video/celb":{source:"iana"},"video/dv":{source:"iana"},"video/encaprtp":{source:"iana"},"video/ffv1":{source:"iana"},"video/flexfec":{source:"iana"},"video/h261":{source:"iana",extensions:["h261"]},"video/h263":{source:"iana",extensions:["h263"]},"video/h263-1998":{source:"iana"},"video/h263-2000":{source:"iana"},"video/h264":{source:"iana",extensions:["h264"]},"video/h264-rcdo":{source:"iana"},"video/h264-svc":{source:"iana"},"video/h265":{source:"iana"},"video/iso.segment":{source:"iana",extensions:["m4s"]},"video/jpeg":{source:"iana",extensions:["jpgv"]},"video/jpeg2000":{source:"iana"},"video/jpm":{source:"apache",extensions:["jpm","jpgm"]},"video/jxsv":{source:"iana"},"video/mj2":{source:"iana",extensions:["mj2","mjp2"]},"video/mp1s":{source:"iana"},"video/mp2p":{source:"iana"},"video/mp2t":{source:"iana",extensions:["ts"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","mp4v","mpg4"]},"video/mp4v-es":{source:"iana"},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{source:"iana"},"video/mpv":{source:"iana"},"video/nv":{source:"iana"},"video/ogg":{source:"iana",compressible:!1,extensions:["ogv"]},"video/parityfec":{source:"iana"},"video/pointer":{source:"iana"},"video/quicktime":{source:"iana",compressible:!1,extensions:["qt","mov"]},"video/raptorfec":{source:"iana"},"video/raw":{source:"iana"},"video/rtp-enc-aescm128":{source:"iana"},"video/rtploopback":{source:"iana"},"video/rtx":{source:"iana"},"video/scip":{source:"iana"},"video/smpte291":{source:"iana"},"video/smpte292m":{source:"iana"},"video/ulpfec":{source:"iana"},"video/vc1":{source:"iana"},"video/vc2":{source:"iana"},"video/vnd.cctv":{source:"iana"},"video/vnd.dece.hd":{source:"iana",extensions:["uvh","uvvh"]},"video/vnd.dece.mobile":{source:"iana",extensions:["uvm","uvvm"]},"video/vnd.dece.mp4":{source:"iana"},"video/vnd.dece.pd":{source:"iana",extensions:["uvp","uvvp"]},"video/vnd.dece.sd":{source:"iana",extensions:["uvs","uvvs"]},"video/vnd.dece.video":{source:"iana",extensions:["uvv","uvvv"]},"video/vnd.directv.mpeg":{source:"iana"},"video/vnd.directv.mpeg-tts":{source:"iana"},"video/vnd.dlna.mpeg-tts":{source:"iana"},"video/vnd.dvb.file":{source:"iana",extensions:["dvb"]},"video/vnd.fvt":{source:"iana",extensions:["fvt"]},"video/vnd.hns.video":{source:"iana"},"video/vnd.iptvforum.1dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.1dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.2dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.2dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.ttsavc":{source:"iana"},"video/vnd.iptvforum.ttsmpeg2":{source:"iana"},"video/vnd.motorola.video":{source:"iana"},"video/vnd.motorola.videop":{source:"iana"},"video/vnd.mpegurl":{source:"iana",extensions:["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{source:"iana",extensions:["pyv"]},"video/vnd.nokia.interleaved-multimedia":{source:"iana"},"video/vnd.nokia.mp4vr":{source:"iana"},"video/vnd.nokia.videovoip":{source:"iana"},"video/vnd.objectvideo":{source:"iana"},"video/vnd.radgamettools.bink":{source:"iana"},"video/vnd.radgamettools.smacker":{source:"iana"},"video/vnd.sealed.mpeg1":{source:"iana"},"video/vnd.sealed.mpeg4":{source:"iana"},"video/vnd.sealed.swf":{source:"iana"},"video/vnd.sealedmedia.softseal.mov":{source:"iana"},"video/vnd.uvvu.mp4":{source:"iana",extensions:["uvu","uvvu"]},"video/vnd.vivo":{source:"iana",extensions:["viv"]},"video/vnd.youtube.yt":{source:"iana"},"video/vp8":{source:"iana"},"video/vp9":{source:"iana"},"video/webm":{source:"apache",compressible:!1,extensions:["webm"]},"video/x-f4v":{source:"apache",extensions:["f4v"]},"video/x-fli":{source:"apache",extensions:["fli"]},"video/x-flv":{source:"apache",compressible:!1,extensions:["flv"]},"video/x-m4v":{source:"apache",extensions:["m4v"]},"video/x-matroska":{source:"apache",compressible:!1,extensions:["mkv","mk3d","mks"]},"video/x-mng":{source:"apache",extensions:["mng"]},"video/x-ms-asf":{source:"apache",extensions:["asf","asx"]},"video/x-ms-vob":{source:"apache",extensions:["vob"]},"video/x-ms-wm":{source:"apache",extensions:["wm"]},"video/x-ms-wmv":{source:"apache",compressible:!1,extensions:["wmv"]},"video/x-ms-wmx":{source:"apache",extensions:["wmx"]},"video/x-ms-wvx":{source:"apache",extensions:["wvx"]},"video/x-msvideo":{source:"apache",extensions:["avi"]},"video/x-sgi-movie":{source:"apache",extensions:["movie"]},"video/x-smv":{source:"apache",extensions:["smv"]},"x-conference/x-cooltalk":{source:"apache",extensions:["ice"]},"x-shader/x-fragment":{compressible:!0},"x-shader/x-vertex":{compressible:!0}},qn=Fn(function(e,t){var n,o,i,a=y.extname,r=/^\s*([^;\s]*)(?:;|\s|$)/,s=/^text\//i;function c(e){if(!e||"string"!=typeof e)return!1;var t=r.exec(e),n=t&&Dn[t[1].toLowerCase()];return n&&n.charset?n.charset:!(!t||!s.test(t[1]))&&"UTF-8"}t.charset=c,t.charsets={lookup:c},t.contentType=function(e){if(!e||"string"!=typeof e)return!1;var n=-1===e.indexOf("/")?t.lookup(e):e;if(!n)return!1;if(-1===n.indexOf("charset")){var o=t.charset(n);o&&(n+="; charset="+o.toLowerCase())}return n},t.extension=function(e){if(!e||"string"!=typeof e)return!1;var n=r.exec(e),o=n&&t.extensions[n[1].toLowerCase()];return!(!o||!o.length)&&o[0]},t.extensions=Object.create(null),t.lookup=function(e){if(!e||"string"!=typeof e)return!1;var n=a("x."+e).toLowerCase().substr(1);return n&&t.types[n]||!1},t.types=Object.create(null),n=t.extensions,o=t.types,i=["nginx","apache",void 0,"iana"],Object.keys(Dn).forEach(function(e){var t=Dn[e],a=t.extensions;if(a&&a.length){n[e]=a;for(var r=0;r<a.length;r++){var s=a[r];if(o[s]){var c=i.indexOf(Dn[o[s]].source),l=i.indexOf(t.source);if("application/octet-stream"!==o[s]&&(c>l||c===l&&"application/"===o[s].substr(0,12)))continue}o[s]=e}}})}),Bn=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)},Mn=function(e){var t=!1;return Bn(function(){t=!0}),function(n,o){t?e(n,o):Bn(function(){e(n,o)})}},Wn=function(e){Object.keys(e.jobs).forEach(Hn.bind(e)),e.jobs={}};function Hn(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}var Gn=function(e,t,n,o){var i=n.keyedList?n.keyedList[n.index]:n.index;n.jobs[i]=function(e,t,n,o){return 2==e.length?e(n,Mn(o)):e(n,t,Mn(o))}(t,i,e[i],function(e,t){i in n.jobs&&(delete n.jobs[i],e?Wn(n):n.results[i]=t,o(e,n.results))})},Jn=function(e,t){var n=!Array.isArray(e),o={index:0,keyedList:n||t?Object.keys(e):null,jobs:{},results:n?{}:[],size:n?Object.keys(e).length:e.length};return t&&o.keyedList.sort(n?t:function(n,o){return t(e[n],e[o])}),o},Vn=function(e){Object.keys(this.jobs).length&&(this.index=this.size,Wn(this),Mn(e)(null,this.results))},Kn=function(e,t,n,o){var i=Jn(e,n);return Gn(e,t,i,function n(a,r){a?o(a,r):(i.index++,i.index<(i.keyedList||e).length?Gn(e,t,i,n):o(null,i.results))}),Vn.bind(i,o)};function Yn(e,t){return e<t?-1:e>t?1:0}Kn.ascending=Yn,Kn.descending=function(e,t){return-1*Yn(e,t)};var Zn=Object,Xn=Error,Qn=EvalError,eo=RangeError,to=ReferenceError,no=SyntaxError,oo=TypeError,io=URIError,ao=Math.abs,ro=Math.floor,so=Math.max,co=Math.min,lo=Math.pow,po=Math.round,uo=Number.isNaN||function(e){return e!=e},mo=Object.getOwnPropertyDescriptor;if(mo)try{mo([],"length")}catch(e){mo=null}var fo=mo,ho=Object.defineProperty||!1;if(ho)try{ho({},"a",{value:1})}catch(e){ho=!1}var go,vo=ho,bo=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(var o in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var i=Object.getOwnPropertySymbols(e);if(1!==i.length||i[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var a=Object.getOwnPropertyDescriptor(e,t);if(42!==a.value||!0!==a.enumerable)return!1}return!0},xo="undefined"!=typeof Symbol&&Symbol,yo="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null,wo=Zn,_o=wo.getPrototypeOf||null,jo=Object.prototype.toString,ko=Math.max,So=function(e,t){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},Eo=Function.prototype.bind||function(e){var t=this;if("function"!=typeof t||"[object Function]"!==jo.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var n,o=function(e,t){for(var n=[],o=1,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n}(arguments),i=ko(0,t.length-o.length),a=[],r=0;r<i;r++)a[r]="$"+r;if(n=Function("binder","return function ("+function(e,t){for(var n="",o=0;o<e.length;o+=1)n+=e[o],o+1<e.length&&(n+=",");return n}(a)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof n){var i=t.apply(this,So(o,arguments));return Object(i)===i?i:this}return t.apply(e,So(o,arguments))}),t.prototype){var s=function(){};s.prototype=t.prototype,n.prototype=new s,s.prototype=null}return n},$o=Function.prototype.call,To=Function.prototype.apply,Io="undefined"!=typeof Reflect&&Reflect&&Reflect.apply||Eo.call($o,To),Oo=oo,Ao=fo;try{go=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var Co,Ro=!!go&&Ao&&Ao(Object.prototype,"__proto__"),No=Object,Po=No.getPrototypeOf,Uo=Ro&&"function"==typeof Ro.get?function(e){if(e.length<1||"function"!=typeof e[0])throw new Oo("a function is required");return Io(Eo,$o,e)}([Ro.get]):"function"==typeof Po&&function(e){return Po(null==e?e:No(e))},Lo=yo?function(e){return yo(e)}:_o?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return _o(e)}:Uo?function(e){return Uo(e)}:null,zo=Eo.call(Function.prototype.call,Object.prototype.hasOwnProperty),Fo=Xn,Do=Qn,qo=eo,Bo=to,Mo=no,Wo=io,Ho=ao,Go=ro,Jo=so,Vo=co,Ko=lo,Yo=po,Zo=vo,Xo=zo,Qo=Function,ei=function(e){try{return Qo('"use strict"; return ('+e+").constructor;")()}catch(e){}},ti=function(){throw new Oo},ni=Ao?function(){try{return ti}catch(e){try{return Ao(arguments,"callee").get}catch(e){return ti}}}():ti,oi="function"==typeof xo&&"function"==typeof Symbol&&"symbol"==typeof xo("foo")&&"symbol"==typeof Symbol("bar")&&bo(),ii={},ai="undefined"!=typeof Uint8Array&&Lo?Lo(Uint8Array):Co,ri={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?Co:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?Co:ArrayBuffer,"%ArrayIteratorPrototype%":oi&&Lo?Lo([][Symbol.iterator]()):Co,"%AsyncFromSyncIteratorPrototype%":Co,"%AsyncFunction%":ii,"%AsyncGenerator%":ii,"%AsyncGeneratorFunction%":ii,"%AsyncIteratorPrototype%":ii,"%Atomics%":"undefined"==typeof Atomics?Co:Atomics,"%BigInt%":"undefined"==typeof BigInt?Co:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?Co:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?Co:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?Co:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Fo,"%eval%":eval,"%EvalError%":Do,"%Float16Array%":"undefined"==typeof Float16Array?Co:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?Co:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?Co:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?Co:FinalizationRegistry,"%Function%":Qo,"%GeneratorFunction%":ii,"%Int8Array%":"undefined"==typeof Int8Array?Co:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?Co:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?Co:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":oi&&Lo?Lo(Lo([][Symbol.iterator]())):Co,"%JSON%":"object"==typeof JSON?JSON:Co,"%Map%":"undefined"==typeof Map?Co:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&oi&&Lo?Lo((new Map)[Symbol.iterator]()):Co,"%Math%":Math,"%Number%":Number,"%Object%":wo,"%Object.getOwnPropertyDescriptor%":Ao,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?Co:Promise,"%Proxy%":"undefined"==typeof Proxy?Co:Proxy,"%RangeError%":qo,"%ReferenceError%":Bo,"%Reflect%":"undefined"==typeof Reflect?Co:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?Co:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&oi&&Lo?Lo((new Set)[Symbol.iterator]()):Co,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?Co:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":oi&&Lo?Lo(""[Symbol.iterator]()):Co,"%Symbol%":oi?Symbol:Co,"%SyntaxError%":Mo,"%ThrowTypeError%":ni,"%TypedArray%":ai,"%TypeError%":Oo,"%Uint8Array%":"undefined"==typeof Uint8Array?Co:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?Co:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?Co:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?Co:Uint32Array,"%URIError%":Wo,"%WeakMap%":"undefined"==typeof WeakMap?Co:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?Co:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?Co:WeakSet,"%Function.prototype.call%":$o,"%Function.prototype.apply%":To,"%Object.defineProperty%":Zo,"%Object.getPrototypeOf%":_o,"%Math.abs%":Ho,"%Math.floor%":Go,"%Math.max%":Jo,"%Math.min%":Vo,"%Math.pow%":Ko,"%Math.round%":Yo,"%Math.sign%":function(e){return uo(e)||0===e?e:e<0?-1:1},"%Reflect.getPrototypeOf%":yo};if(Lo)try{null.error}catch(e){var si=Lo(Lo(e));ri["%Error.prototype%"]=si}var ci=function e(t){var n;if("%AsyncFunction%"===t)n=ei("async function () {}");else if("%GeneratorFunction%"===t)n=ei("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=ei("async function* () {}");else if("%AsyncGenerator%"===t){var o=e("%AsyncGeneratorFunction%");o&&(n=o.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&Lo&&(n=Lo(i.prototype))}return ri[t]=n,n},li={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},pi=Eo.call($o,Array.prototype.concat),ui=Eo.call(To,Array.prototype.splice),di=Eo.call($o,String.prototype.replace),mi=Eo.call($o,String.prototype.slice),fi=Eo.call($o,RegExp.prototype.exec),hi=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,gi=/\\(\\)?/g,vi=function(e,t){var n,o=e;if(Xo(li,o)&&(o="%"+(n=li[o])[0]+"%"),Xo(ri,o)){var i=ri[o];if(i===ii&&(i=ci(o)),void 0===i&&!t)throw new Oo("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:o,value:i}}throw new Mo("intrinsic "+e+" does not exist!")},bi=function(e,t){if("string"!=typeof e||0===e.length)throw new Oo("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new Oo('"allowMissing" argument must be a boolean');if(null===fi(/^%?[^%]*%?$/,e))throw new Mo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=mi(e,0,1),n=mi(e,-1);if("%"===t&&"%"!==n)throw new Mo("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new Mo("invalid intrinsic syntax, expected opening `%`");var o=[];return di(e,hi,function(e,t,n,i){o[o.length]=n?di(i,gi,"$1"):t||e}),o}(e),o=n.length>0?n[0]:"",i=vi("%"+o+"%",t),a=i.name,r=i.value,s=!1,c=i.alias;c&&(o=c[0],ui(n,pi([0,1],c)));for(var l=1,p=!0;l<n.length;l+=1){var u=n[l],d=mi(u,0,1),m=mi(u,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new Mo("property names with quotes must have matching quotes");if("constructor"!==u&&p||(s=!0),Xo(ri,a="%"+(o+="."+u)+"%"))r=ri[a];else if(null!=r){if(!(u in r)){if(!t)throw new Oo("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ao&&l+1>=n.length){var f=Ao(r,u);r=(p=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:r[u]}else p=Xo(r,u),r=r[u];p&&!s&&(ri[a]=r)}}return r}("%Object.defineProperty%",!0),xi=bo()&&Symbol.toStringTag?Symbol.toStringTag:null,yi=function(e,t){return Object.keys(t).forEach(function(n){e[n]=e[n]||t[n]}),e},wi=ye.parse,_i=ge.Stream;function ji(e){return String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22")}function ki(e){if(!(this instanceof ki))return new ki(e);for(var t in this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],Un.call(this),e=e||{})this[t]=e[t]}he.inherits(ki,Un),ki.LINE_BREAK="\r\n",ki.DEFAULT_CONTENT_TYPE="application/octet-stream",ki.prototype.append=function(e,t,n){"string"==typeof(n=n||{})&&(n={filename:n});var o=Un.prototype.append.bind(this);if("number"!=typeof t&&null!=t||(t=String(t)),Array.isArray(t))this._error(new Error("Arrays are not supported."));else{var i=this._multiPartHeader(e,t,n),a=this._multiPartFooter();o(i),o(t),o(a),this._trackLength(i,t,n)}},ki.prototype._trackLength=function(e,t,n){var o=0;null!=n.knownLength?o+=Number(n.knownLength):Buffer.isBuffer(t)?o=t.length:"string"==typeof t&&(o=Buffer.byteLength(t)),this._valueLength+=o,this._overheadLength+=Buffer.byteLength(e)+ki.LINE_BREAK.length,t&&(t.path||t.readable&&Xo(t,"httpVersion")||t instanceof _i)&&(n.knownLength||this._valuesToMeasure.push(t))},ki.prototype._lengthRetriever=function(e,t){Xo(e,"fd")?null!=e.end&&Infinity!=e.end&&null!=e.start?t(null,e.end+1-(e.start?e.start:0)):s.stat(e.path,function(n,o){n?t(n):t(null,o.size-(e.start?e.start:0))}):Xo(e,"httpVersion")?t(null,Number(e.headers["content-length"])):Xo(e,"httpModule")?(e.on("response",function(n){e.pause(),t(null,Number(n.headers["content-length"]))}),e.resume()):t("Unknown stream")},ki.prototype._multiPartHeader=function(e,t,n){if("string"==typeof n.header)return n.header;var o,i=this._getContentDisposition(t,n),a=this._getContentType(t,n),r="",s={"Content-Disposition":["form-data",'name="'+ji(e)+'"'].concat(i||[]),"Content-Type":[].concat(a||[])};for(var c in"object"==typeof n.header&&yi(s,n.header),s)if(Xo(s,c)){if(null==(o=s[c]))continue;Array.isArray(o)||(o=[o]),o.length&&(r+=c+": "+o.join("; ")+ki.LINE_BREAK)}return"--"+this.getBoundary()+ki.LINE_BREAK+r+ki.LINE_BREAK},ki.prototype._getContentDisposition=function(e,t){var n;if("string"==typeof t.filepath?n=y.normalize(t.filepath).replace(/\\/g,"/"):t.filename||e&&(e.name||e.path)?n=y.basename(t.filename||e&&(e.name||e.path)):e&&e.readable&&Xo(e,"httpVersion")&&(n=y.basename(e.client._httpMessage.path||"")),n)return'filename="'+ji(n)+'"'},ki.prototype._getContentType=function(e,t){var n=t.contentType;return!n&&e&&e.name&&(n=qn.lookup(e.name)),!n&&e&&e.path&&(n=qn.lookup(e.path)),!n&&e&&e.readable&&Xo(e,"httpVersion")&&(n=e.headers["content-type"]),n||!t.filepath&&!t.filename||(n=qn.lookup(t.filepath||t.filename)),!n&&e&&"object"==typeof e&&(n=ki.DEFAULT_CONTENT_TYPE),n},ki.prototype._multiPartFooter=function(){return function(e){var t=ki.LINE_BREAK;0===this._streams.length&&(t+=this._lastBoundary()),e(t)}.bind(this)},ki.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+ki.LINE_BREAK},ki.prototype.getHeaders=function(e){var t,n={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(t in e)Xo(e,t)&&(n[t.toLowerCase()]=e[t]);return n},ki.prototype.setBoundary=function(e){if("string"!=typeof e)throw new TypeError("FormData boundary must be a string");this._boundary=e},ki.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary},ki.prototype.getBuffer=function(){for(var e=new Buffer.alloc(0),t=this.getBoundary(),n=0,o=this._streams.length;n<o;n++)"function"!=typeof this._streams[n]&&(e=Buffer.isBuffer(this._streams[n])?Buffer.concat([e,this._streams[n]]):Buffer.concat([e,Buffer.from(this._streams[n])]),"string"==typeof this._streams[n]&&this._streams[n].substring(2,t.length+2)===t||(e=Buffer.concat([e,Buffer.from(ki.LINE_BREAK)])));return Buffer.concat([e,Buffer.from(this._lastBoundary())])},ki.prototype._generateBoundary=function(){this._boundary="--------------------------"+we.randomBytes(12).toString("hex")},ki.prototype.getLengthSync=function(){var e=this._overheadLength+this._valueLength;return this._streams.length&&(e+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),e},ki.prototype.hasKnownLength=function(){var e=!0;return this._valuesToMeasure.length&&(e=!1),e},ki.prototype.getLength=function(e){var t=this._overheadLength+this._valueLength;this._streams.length&&(t+=this._lastBoundary().length),this._valuesToMeasure.length?function(e,t,n){for(var o=Jn(e);o.index<(o.keyedList||e).length;)Gn(e,t,o,function(e,t){e?n(e,t):0!==Object.keys(o.jobs).length||n(null,o.results)}),o.index++;Vn.bind(o,n)}(this._valuesToMeasure,this._lengthRetriever,function(n,o){n?e(n):(o.forEach(function(e){t+=e}),e(null,t))}):process.nextTick(e.bind(this,null,t))},ki.prototype.submit=function(e,t){var n,o,i={method:"post"};return"string"==typeof e?(e=wi(e),o=yi({port:e.port,path:e.pathname,host:e.hostname,protocol:e.protocol},i)):(o=yi(e,i)).port||(o.port="https:"===o.protocol?443:80),o.headers=this.getHeaders(e.headers),n="https:"===o.protocol?xe.request(o):be.request(o),this.getLength(function(e,o){if(e&&"Unknown stream"!==e)this._error(e);else if(o&&n.setHeader("Content-Length",o),this.pipe(n),t){var i,a=function(e,o){return n.removeListener("error",a),n.removeListener("response",i),t.call(this,e,o)};i=a.bind(this,null),n.on("error",a),n.on("response",i)}}.bind(this)),n},ki.prototype._error=function(e){this.error||(this.error=e,this.pause(),this.emit("error",e))},ki.prototype.toString=function(){return"[object FormData]"},function(e,t){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,o=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(void 0!==n&&"boolean"!=typeof n||void 0!==o&&"boolean"!=typeof o)throw new Oo("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");!xi||!n&&Xo(e,xi)||(bi?bi(e,xi,{configurable:!o,enumerable:!1,value:t,writable:!1}):e[xi]=t)}(ki.prototype,"FormData");var Si=ki,Ei={isBufferAvailable:()=>"undefined"!=typeof Buffer,from:e=>Buffer.from(e)};const $i=100;function Ti(e){return hn.isPlainObject(e)||hn.isArray(e)}function Ii(e){return hn.endsWith(e,"[]")?e.slice(0,-2):e}function Oi(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ii(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Ai=hn.toFlatObject(hn,{},null,function(e){return/^is[A-Z]/.test(e)});function Ci(e,t,n){if(!hn.isObject(e))throw new TypeError("target must be an object");t=t||new(Si||FormData);const o=(n=hn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!hn.isUndefined(t[e])})).metaTokens,i=n.visitor||m,a=n.dots,r=n.indexes,s=n.Blob||"undefined"!=typeof Blob&&Blob,c=void 0===n.maxDepth?$i:n.maxDepth,l=s&&hn.isSpecCompliantForm(t),p=[];if(!hn.isFunction(i))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(hn.isDate(e))return e.toISOString();if(hn.isBoolean(e))return e.toString();if(!l&&hn.isBlob(e))throw new An("Blob is not supported. Use a Buffer instead.");if(hn.isArrayBuffer(e)||hn.isTypedArray(e)){if(l&&"function"==typeof s)return new s([e]);if(Ei&&Ei.isBufferAvailable())return Ei.from(e);throw new An("Blob is not supported. Use a Buffer instead.",An.ERR_NOT_SUPPORT)}return e}function d(e){if(e>c)throw new An("Object is too deeply nested ("+e+" levels). Max depth: "+c,An.ERR_FORM_DATA_DEPTH_EXCEEDED)}function m(e,n,i){let s=e;if(hn.isReactNative(t)&&hn.isReactNativeBlob(e))return t.append(Oi(i,n,a),u(e)),!1;if(e&&!i&&"object"==typeof e)if(hn.endsWith(n,"{}"))n=o?n:n.slice(0,-2),e=function(e,t){if(Infinity===c)return JSON.stringify(e);const n=[];return JSON.stringify(e,function(e,t){if(!hn.isObject(t))return t;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(t),d(1+n.length-1),t})}(e);else if(hn.isArray(e)&&function(e){return hn.isArray(e)&&!e.some(Ti)}(e)||(hn.isFileList(e)||hn.endsWith(n,"[]"))&&(s=hn.toArray(e)))return n=Ii(n),s.forEach(function(e,o){!hn.isUndefined(e)&&null!==e&&t.append(!0===r?Oi([n],o,a):null===r?n:n+"[]",u(e))}),!1;return!!Ti(e)||(t.append(Oi(i,n,a),u(e)),!1)}const f=Object.assign(Ai,{defaultVisitor:m,convertValue:u,isVisitable:Ti});if(!hn.isObject(e))throw new TypeError("data must be an object");return function e(n,o,a=0){if(!hn.isUndefined(n)){if(d(a),-1!==p.indexOf(n))throw new Error("Circular reference detected in "+o.join("."));p.push(n),hn.forEach(n,function(n,r){!0===(!(hn.isUndefined(n)||null===n)&&i.call(t,n,hn.isString(r)?r.trim():r,o,f))&&e(n,o?o.concat(r):[r],a+1)}),p.pop()}}(e),t}function Ri(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function Ni(e,t){this._pairs=[],e&&Ci(e,this,t)}const Pi=Ni.prototype;function Ui(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Li(e,t,n){if(!t)return e;e=e||"";const o=hn.isFunction(n)?{serialize:n}:n,i=hn.getSafeProp(o,"encode")||Ui,a=hn.getSafeProp(o,"serialize");let r;if(r=a?a(t,o):hn.isURLSearchParams(t)?t.toString():new Ni(t,o).toString(i),r){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}Pi.append=function(e,t){this._pairs.push([e,t])},Pi.toString=function(e){const t=e?t=>e.call(this,t,Ri):Ri;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var zi=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){hn.forEach(this.handlers,function(t){null!==t&&e(t)})}},Fi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},Di=ye.URLSearchParams;const qi="abcdefghijklmnopqrstuvwxyz",Bi="0123456789",Mi={DIGIT:Bi,ALPHA:qi,ALPHA_DIGIT:qi+qi.toUpperCase()+Bi};var Wi={isNode:!0,classes:{URLSearchParams:Di,FormData:Si,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:Mi,generateString:(e=16,t=Mi.ALPHA_DIGIT)=>{let n="";const{length:o}=t,i=new Uint32Array(e);we.randomFillSync(i);for(let a=0;a<e;a++)n+=t[i[a]%o];return n},protocols:["http","https","file","data"]};const Hi="undefined"!=typeof window&&"undefined"!=typeof document,Gi="object"==typeof navigator&&navigator||void 0,Ji=Hi&&(!Gi||["ReactNative","NativeScript","NS"].indexOf(Gi.product)<0);var Vi={__proto__:null,hasBrowserEnv:Hi,hasStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,hasStandardBrowserEnv:Ji,navigator:Gi,origin:Hi&&window.location.href||"http://localhost",...Wi};const Ki=$i;function Yi(e){if(e>Ki)throw new An("FormData field is too deeply nested ("+e+" levels). Max depth: "+Ki,An.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Zi(e){function t(e,n,o,i){Yi(i);let a=e[i++];if("__proto__"===a)return!0;const r=Number.isFinite(+a),s=i>=e.length;return a=!a&&hn.isArray(o)?o.length:a,s?(o[a]=hn.hasOwnProp(o,a)?hn.isArray(o[a])?o[a].concat(n):[o[a],n]:n,!r):(hn.hasOwnProp(o,a)&&hn.isObject(o[a])||(o[a]=[]),t(e,n,o[a],i)&&hn.isArray(o[a])&&(o[a]=function(e){const t={},n=Object.keys(e);let o;const i=n.length;let a;for(o=0;o<i;o++)a=n[o],t[a]=e[a];return t}(o[a])),!r)}if(hn.isFormData(e)&&hn.isFunction(e.entries)){const n={};return hn.forEachEntry(e,(e,o)=>{t(function(e){const t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g;let o;for(;null!==(o=n.exec(e));)Yi(t.length),t.push("[]"===o[0]?"":o[1]||o[0]);return t}(e),o,n,0)}),n}return null}const Xi=(e,t)=>null!=e&&hn.hasOwnProp(e,t)?e[t]:void 0,Qi={transitional:Fi,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,i=hn.isObject(e);if(i&&hn.isHTMLForm(e)&&(e=new FormData(e)),hn.isFormData(e))return o?JSON.stringify(Zi(e)):e;if(hn.isArrayBuffer(e)||hn.isBuffer(e)||hn.isStream(e)||hn.isFile(e)||hn.isBlob(e)||hn.isReadableStream(e))return e;if(hn.isArrayBufferView(e))return e.buffer;if(hn.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){const t=Xi(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ci(e,new Vi.classes.URLSearchParams,{visitor:function(e,t,n,o){return Vi.isNode&&hn.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}(e,t).toString();if((a=hn.isFileList(e))||n.indexOf("multipart/form-data")>-1){const n=Xi(this,"env"),o=n&&n.FormData;return Ci(a?{"files[]":e}:e,o&&new o,t)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(hn.isString(e))try{return(0,JSON.parse)(e),hn.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=Xi(this,"transitional")||Qi.transitional,n=t&&t.forcedJSONParsing,o=Xi(this,"responseType"),i="json"===o;if(hn.isResponse(e)||hn.isReadableStream(e))return e;if(e&&hn.isString(e)&&(n&&!o||i)){const n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Xi(this,"parseReviver"))}catch(e){if(n){if("SyntaxError"===e.name)throw An.from(e,An.ERR_BAD_RESPONSE,this,null,Xi(this,"response"));throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Vi.classes.FormData,Blob:Vi.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};hn.forEach(["delete","get","head","post","put","patch","query"],e=>{Qi.headers[e]={}});var ea=Qi;function ta(e,t){const n=this||ea,o=t||n,i=Tn.from(o.headers);let a=o.data;return hn.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function na(e){return!(!e||!e.__CANCEL__)}var oa=class extends An{constructor(e,t,n){super(null==e?"canceled":e,An.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function ia(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new An("Request failed with status code "+n.status,n.status>=400&&n.status<500?An.ERR_BAD_REQUEST:An.ERR_BAD_RESPONSE,n.config,n.request,n)):e(n)}const aa=/^https?:(?!\/\/)/i,ra=/[\t\n\r]/g;function sa(e,t){if("string"==typeof e){const n=function(e){return function(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}(e).replace(ra,"")}(e);if(aa.test(n))throw new An(`Invalid URL ${JSON.stringify(function(e){const t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${In}@`),n=t.indexOf("#"),o=(-1===n?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${In}`);return-1===n?o:`${o}#${i=t.slice(n+1),i?i.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,t,n="")=>`${t}${n}${In}`):i}`;var i}(n))}: missing "//" after protocol`,An.ERR_INVALID_URL,t)}}function ca(e,t,n,o){sa(t,o);let i=!function(e){return"string"==typeof e&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(i||!1===n)?(sa(e,o),function(e,t){if(!t)return e;let n=e.length;for(;n>0&&47===e.charCodeAt(n-1);)n--;return e.slice(0,n)+"/"+t.replace(/^\/+/,"")}(e,t)):t}var la={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function pa(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}var ua=1e3,da=60*ua,ma=60*da,fa=24*ma,ha=7*fa,ga=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return n*ha;case"days":case"day":case"d":return n*fa;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ma;case"minutes":case"minute":case"mins":case"min":case"m":return n*da;case"seconds":case"second":case"secs":case"sec":case"s":return n*ua;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=fa?va(e,t,fa,"day"):t>=ma?va(e,t,ma,"hour"):t>=da?va(e,t,da,"minute"):t>=ua?va(e,t,ua,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=fa?Math.round(e/fa)+"d":t>=ma?Math.round(e/ma)+"h":t>=da?Math.round(e/da)+"m":t>=ua?Math.round(e/ua)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function va(e,t,n,o){var i=t>=1.5*n;return Math.round(e/n)+" "+o+(i?"s":"")}var ba=function(e){function t(e){let o,i,a,r=null;function s(...e){if(!s.enabled)return;const n=s,i=Number(new Date);n.diff=i-(o||i),n.prev=o,n.curr=i,o=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(o,i)=>{if("%%"===o)return"%";a++;const r=t.formatters[i];return"function"==typeof r&&(o=r.call(n,e[a]),e.splice(a,1),a--),o}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==r?r:(i!==t.namespaces&&(i=t.namespaces,a=t.enabled(e)),a),set:e=>{r=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const o=t(this.namespace+(void 0===n?":":n)+e);return o.log=this.log,o}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const o=("string"==typeof e?e:"").split(/[\s,]+/),i=o.length;for(n=0;n<i;n++)o[n]&&("-"===(e=o[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,o;for(n=0,o=t.skips.length;n<o;n++)if(t.skips[n].test(e))return!1;for(n=0,o=t.names.length;n<o;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=ga,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t},xa=Fn(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(o++,"%c"===e&&(i=o))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ba(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}),ya=(e,t=process.argv)=>{const n=e.startsWith("-")?"":1===e.length?"-":"--",o=t.indexOf(n+e),i=t.indexOf("--");return-1!==o&&(-1===i||o<i)};const{env:wa}=process;let _a;function ja(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ka(e,t){if(0===_a)return 0;if(ya("color=16m")||ya("color=full")||ya("color=truecolor"))return 3;if(ya("color=256"))return 2;if(e&&!t&&void 0===_a)return 0;const n=_a||0;if("dumb"===wa.TERM)return n;if("win32"===process.platform){const e=$e.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in wa)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in wa)||"codeship"===wa.CI_NAME?1:n;if("TEAMCITY_VERSION"in wa)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(wa.TEAMCITY_VERSION)?1:0;if("truecolor"===wa.COLORTERM)return 3;if("TERM_PROGRAM"in wa){const e=parseInt((wa.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(wa.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(wa.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(wa.TERM)||"COLORTERM"in wa?1:n}ya("no-color")||ya("no-colors")||ya("color=false")||ya("color=never")?_a=0:(ya("color")||ya("colors")||ya("color=true")||ya("color=always"))&&(_a=1),"FORCE_COLOR"in wa&&(_a="true"===wa.FORCE_COLOR?1:"false"===wa.FORCE_COLOR?0:0===wa.FORCE_COLOR.length?1:Math.min(parseInt(wa.FORCE_COLOR,10),3));var Sa={supportsColor:function(e){return ja(ka(e,e&&e.isTTY))},stdout:ja(ka(!0,Ee.isatty(1))),stderr:ja(ka(!0,Ee.isatty(2)))},Ea=Fn(function(e,t){t.init=function(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let o=0;o<n.length;o++)e.inspectOpts[n[o]]=t.inspectOpts[n[o]]},t.log=function(...e){return process.stderr.write(he.format(...e)+"\n")},t.formatArgs=function(n){const{namespace:o,useColors:i}=this;if(i){const t=this.color,i="[3"+(t<8?t:"8;5;"+t),a=` ${i};1m${o} [0m`;n[0]=a+n[0].split("\n").join("\n"+a),n.push(i+"m+"+e.exports.humanize(this.diff)+"[0m")}else n[0]=(t.inspectOpts.hideDate?"":(new Date).toISOString()+" ")+o+" "+n[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):Ee.isatty(process.stderr.fd)},t.destroy=he.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{Sa&&(Sa.stderr||Sa).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let o=process.env[t];return o=!!/^(yes|on|true|enabled)$/i.test(o)||!/^(no|off|false|disabled)$/i.test(o)&&("null"===o?null:Number(o)),e[n]=o,e},{}),e.exports=ba(t);const{formatters:n}=e.exports;n.o=function(e){return this.inspectOpts.colors=this.useColors,he.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},n.O=function(e){return this.inspectOpts.colors=this.useColors,he.inspect(e,this.inspectOpts)}}),$a=Fn(function(e){e.exports="undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?xa:Ea}),Ta=/*#__PURE__*/Object.defineProperty({default:function(e){return function(t,n){return new Promise((o,i)=>{e.call(this,t,n,(e,t)=>{e?i(e):o(t)})})}}},"__esModule",{value:!0}),Ia=zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Oa=Ia($a),Aa=Ia(Ta),Ca=Oa.default("agent-base");function Ra(){const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some(e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:"))}function Na(e,t){return new Na.Agent(e,t)}!function(e){e.Agent=class extends Oe.EventEmitter{constructor(e,t){super();let n=t;"function"==typeof e?this.callback=e:e&&(n=e),this.timeout=null,n&&"number"==typeof n.timeout&&(this.timeout=n.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=Infinity,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return"number"==typeof this.explicitDefaultPort?this.explicitDefaultPort:Ra()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return"string"==typeof this.explicitProtocol?this.explicitProtocol:Ra()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,t,n){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,t){const n=Object.assign({},t);"boolean"!=typeof n.secureEndpoint&&(n.secureEndpoint=Ra()),null==n.host&&(n.host="localhost"),null==n.port&&(n.port=n.secureEndpoint?443:80),null==n.protocol&&(n.protocol=n.secureEndpoint?"https:":"http:"),n.host&&n.path&&delete n.path,delete n.agent,delete n.hostname,delete n._defaultAgent,delete n.defaultPort,delete n.createConnection,e._last=!0,e.shouldKeepAlive=!1;let o=!1,i=null;const a=n.timeout||this.timeout,r=t=>{e._hadError||(e.emit("error",t),e._hadError=!0)},s=()=>{i=null,o=!0;const e=new Error(`A "socket" was not created for HTTP request before ${a}ms`);e.code="ETIMEOUT",r(e)},c=e=>{o||(null!==i&&(clearTimeout(i),i=null),r(e))},l=t=>{if(o)return;if(null!=i&&(clearTimeout(i),i=null),a=t,Boolean(a)&&"function"==typeof a.addRequest)return Ca("Callback returned another Agent instance %o",t.constructor.name),void t.addRequest(e,n);var a;if(t)return t.once("free",()=>{this.freeSocket(t,n)}),void e.onSocket(t);const s=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);r(s)};if("function"==typeof this.callback){this.promisifiedCallback||(this.callback.length>=3?(Ca("Converting legacy callback function to promise"),this.promisifiedCallback=Aa.default(this.callback)):this.promisifiedCallback=this.callback),"number"==typeof a&&a>0&&(i=setTimeout(s,a)),"port"in n&&"number"!=typeof n.port&&(n.port=Number(n.port));try{Ca("Resolving socket for %o request: %o",n.protocol,`${e.method} ${e.path}`),Promise.resolve(this.promisifiedCallback(e,n)).then(l,c)}catch(e){Promise.reject(e).catch(c)}}else r(new Error("`callback` is not defined"))}freeSocket(e,t){Ca("Freeing socket %o %o",e.constructor.name,t),e.destroy()}destroy(){Ca("Destroying agent %o",this.constructor.name)}},e.prototype=e.Agent.prototype}(Na||(Na={}));var Pa=Na;const Ua=(zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})($a).default("https-proxy-agent:parse-proxy-response");var La=/*#__PURE__*/Object.defineProperty({default:function(e){return new Promise((t,n)=>{let o=0;const i=[];function a(){const n=e.read();n?function(e){i.push(e),o+=e.length;const n=Buffer.concat(i,o);if(-1===n.indexOf("\r\n\r\n"))return Ua("have not received end of HTTP headers yet..."),void a();const r=n.toString("ascii",0,n.indexOf("\r\n")),s=+r.split(" ")[1];Ua("got proxy server response: %o",r),t({statusCode:s,buffered:n})}(n):e.once("readable",a)}function r(e){Ua("onclose had error %o",e)}function s(){Ua("onend")}e.on("error",function t(o){e.removeListener("end",s),e.removeListener("error",t),e.removeListener("close",r),e.removeListener("readable",a),Ua("onerror %o",o),n(o)}),e.on("close",r),e.on("end",s),a()})}},"__esModule",{value:!0}),za=zn&&zn.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,a){function r(e){try{c(o.next(e))}catch(e){a(e)}}function s(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((o=o.apply(e,t||[])).next())})},Fa=zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Da=Fa(je),qa=Fa(ke),Ba=Fa(ye),Ma=Fa(Se),Wa=Fa($a),Ha=Fa(La),Ga=Wa.default("https-proxy-agent:agent");function Ja(e){e.resume()}const Va=(zn&&zn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:class extends Pa.Agent{constructor(e){let t;if(t="string"==typeof e?Ba.default.parse(e):e,!t)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Ga("creating new HttpsProxyAgent instance: %o",t),super(t);const n=Object.assign({},t);var o;this.secureProxy=t.secureProxy||"string"==typeof(o=n.protocol)&&/^https:?$/i.test(o),n.host=n.hostname||n.host,"string"==typeof n.port&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(e,t){return za(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let i;o?(Ga("Creating `tls.Socket`: %o",n),i=qa.default.connect(n)):(Ga("Creating `net.Socket`: %o",n),i=Da.default.connect(n));const a=Object.assign({},n.headers);let r=`CONNECT ${t.host}:${t.port} HTTP/1.1\r\n`;n.auth&&(a["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:s,port:c,secureEndpoint:l}=t;(function(e,t){return Boolean(!t&&80===e||t&&443===e)})(c,l)||(s+=`:${c}`),a.Host=s,a.Connection="close";for(const e of Object.keys(a))r+=`${e}: ${a[e]}\r\n`;const p=Ha.default(i);i.write(`${r}\r\n`);const{statusCode:u,buffered:d}=yield p;if(200===u){if(e.once("socket",Ja),t.secureEndpoint){Ga("Upgrading socket connection to TLS");const e=t.servername||t.host;return qa.default.connect(Object.assign(Object.assign({},function(e,...t){const n={};let o;for(o in e)t.includes(o)||(n[o]=e[o]);return n}(t,"host","hostname","path","port")),{socket:i,servername:e}))}return i}i.destroy();const m=new Da.default.Socket({writable:!1});return m.readable=!0,e.once("socket",e=>{Ga("replaying proxy buffer for failed request"),Ma.default(e.listenerCount("data")>0),e.push(d),e.push(null)}),m})}}},"__esModule",{value:!0}));function Ka(e){return new Va.default(e)}!function(e){e.HttpsProxyAgent=Va.default,e.prototype=Va.default.prototype}(Ka||(Ka={}));var Ya,Za,Xa,Qa,er=Ka,tr=function(){if(!Ya){try{Ya=$a("follow-redirects")}catch(e){}"function"!=typeof Ya&&(Ya=function(){})}Ya.apply(null,arguments)},nr=ye.URL,or=ge.Writable;Za="undefined"!=typeof process,Xa="undefined"!=typeof window&&"undefined"!=typeof document,Qa=Sr(Error.captureStackTrace),Za||!Xa&&Qa||console.warn("The follow-redirects package should be excluded from browser builds.");var ir=!1;try{Se(new nr(""))}catch(e){ir="ERR_INVALID_URL"===e.code}var ar=["Authorization","Proxy-Authorization","Cookie"],rr=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],sr=["abort","aborted","connect","error","socket","timeout"],cr=Object.create(null);sr.forEach(function(e){cr[e]=function(t,n,o){this._redirectable.emit(e,t,n,o)}});var lr=_r("ERR_INVALID_URL","Invalid URL",TypeError),pr=_r("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),ur=_r("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",pr),dr=_r("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),mr=_r("ERR_STREAM_WRITE_AFTER_END","write after end"),fr=or.prototype.destroy||vr;function hr(e,t){or.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var n=this;this._onNativeResponse=function(e){try{n._processResponse(e)}catch(e){n.emit("error",e instanceof pr?e:new pr({cause:e}))}},this._headerFilter=new RegExp("^(?:"+ar.concat(e.sensitiveHeaders).map(Er).join("|")+")$","i"),this._performRequest()}function gr(e){var t={maxRedirects:21,maxBodyLength:10485760},n={};return Object.keys(e).forEach(function(o){var i=o+":",a=n[i]=e[o],r=t[o]=Object.create(a);Object.defineProperties(r,{request:{value:function(e,o,a){return nr&&e instanceof nr?e=yr(e):kr(e)?e=yr(br(e)):(a=o,o=xr(e),e={protocol:i}),Sr(o)&&(a=o,o=null),(o=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,o)).nativeProtocols=n,kr(o.host)||kr(o.hostname)||(o.hostname="::1"),Se.equal(o.protocol,i,"protocol mismatch"),tr("options",o),new hr(o,a)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,n){var o=r.request(e,t,n);return o.end(),o},configurable:!0,enumerable:!0,writable:!0}})}),t}function vr(){}function br(e){var t;if(ir)t=new nr(e);else if(!kr((t=xr(ye.parse(e))).protocol))throw new lr({input:e});return t}function xr(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new lr({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new lr({input:e.href||e});return e}function yr(e,t){var n=t||{};for(var o of rr)n[o]=e[o];return n.hostname.startsWith("[")&&(n.hostname=n.hostname.slice(1,-1)),""!==n.port&&(n.port=Number(n.port)),n.path=n.search?n.pathname+n.search:n.pathname,n}function wr(e,t){var n;for(var o in t)e.test(o)&&(n=t[o],delete t[o]);return null==n?void 0:String(n).trim()}function _r(e,t,n){function o(n){Sr(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,n||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return o.prototype=new(n||Error),Object.defineProperties(o.prototype,{constructor:{value:o,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),o}function jr(e,t){for(var n of sr)e.removeListener(n,cr[n]);e.on("error",vr),e.destroy(t)}function kr(e){return"string"==typeof e||e instanceof String}function Sr(e){return"function"==typeof e}function Er(e){return e.replace(/[\]\\/()*+?.$]/g,"\\$&")}(hr.prototype=Object.create(or.prototype)).abort=function(){jr(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},hr.prototype.destroy=function(e){return jr(this._currentRequest,e),fr.call(this,e),this},hr.prototype.write=function(e,t,n){if(this._ending)throw new mr;if(!(kr(e)||"object"==typeof(o=e)&&"length"in o))throw new TypeError("data should be a string, Buffer or Uint8Array");var o;Sr(t)&&(n=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,n)):(this.emit("error",new dr),this.abort()):n&&n()},hr.prototype.end=function(e,t,n){if(Sr(e)?(n=e,e=t=null):Sr(t)&&(n=t,t=null),e){var o=this,i=this._currentRequest;this.write(e,t,function(){o._ended=!0,i.end(null,null,n)}),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,n)},hr.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},hr.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},hr.prototype.setTimeout=function(e,t){var n=this;function o(t){t.setTimeout(e),t.removeListener("timeout",t.destroy),t.addListener("timeout",t.destroy)}function i(t){n._timeout&&clearTimeout(n._timeout),n._timeout=setTimeout(function(){n.emit("timeout"),a()},e),o(t)}function a(){n._timeout&&(clearTimeout(n._timeout),n._timeout=null),n.removeListener("abort",a),n.removeListener("error",a),n.removeListener("response",a),n.removeListener("close",a),t&&n.removeListener("timeout",t),n.socket||n._currentRequest.removeListener("socket",i)}return t&&this.on("timeout",t),this.socket?i(this.socket):this._currentRequest.once("socket",i),this.on("socket",o),this.on("abort",a),this.on("error",a),this.on("response",a),this.on("close",a),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){hr.prototype[e]=function(t,n){return this._currentRequest[e](t,n)}}),["aborted","connection","socket"].forEach(function(e){Object.defineProperty(hr.prototype,e,{get:function(){return this._currentRequest[e]}})}),hr.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.sensitiveHeaders instanceof Array||(e.sensitiveHeaders=[]),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}},hr.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var n=e.slice(0,-1);this._options.agent=this._options.agents[n]}var o=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var i of(o._redirectable=this,sr))o.on(i,cr[i]);if(this._currentUrl=/^\//.test(this._options.path)?ye.format(this._options):this._options.path,this._isRedirect){var a=0,r=this,s=this._requestBodyBuffers;!function e(t){if(o===r._currentRequest)if(t)r.emit("error",t);else if(a<s.length){var n=s[a++];o.finished||o.write(n.data,n.encoding,e)}else r._ended&&o.end()}()}},hr.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var n,o=e.headers.location;if(!o||!1===this._options.followRedirects||t<300||t>=400)return e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),void(this._requestBodyBuffers=[]);if(jr(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new ur;var i=this._options.beforeRedirect;i&&(n=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var a=this._options.method;((301===t||302===t)&&"POST"===this._options.method||303===t&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],wr(/^content-/i,this._options.headers));var r=wr(/^host$/i,this._options.headers),s=br(this._currentUrl),c=r||s.host,l=/^\w+:/.test(o)?this._currentUrl:ye.format(Object.assign(s,{host:c})),p=function(e,t){return ir?new nr(e,t):br(ye.resolve(t,e))}(o,l);tr("redirecting to",p.href),this._isRedirect=!0,yr(p,this._options),(p.protocol!==s.protocol&&"https:"!==p.protocol||p.host!==c&&!function(e,t){Se(kr(e)&&kr(t));var n=e.length-t.length-1;return n>0&&"."===e[n]&&e.endsWith(t)}(p.host,c))&&wr(this._headerFilter,this._options.headers),Sr(i)&&(i(this._options,{headers:e.headers,statusCode:t},{url:l,method:a,headers:n}),this._sanitizeOptions(this._options)),this._performRequest()};var $r=gr({http:be,https:xe});$r.wrap=gr;const Tr="1.19.0";function Ir(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}const Or=/^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/,Ar=["content-type","content-length"];function Cr(e,t,n){"content-only"===n?Object.entries(t||{}).forEach(([t,n])=>{Ar.includes(t.toLowerCase())&&e.set(t,n)}):e.set(t)}const Rr=Symbol("internals");var Nr=class extends ge.Transform{constructor(e){super({readableHighWaterMark:(e=hn.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!hn.isUndefined(t[e]))).chunkSize});const t=this[Rr]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",e=>{"progress"===e&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){const t=this[Rr];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){const o=this[Rr],i=o.maxRate,a=this.readableHighWaterMark,r=o.timeWindow,s=i/(1e3/r),c=!1!==o.minChunkSize?Math.max(o.minChunkSize,.01*s):0,l=(e,t)=>{const n=Buffer.byteLength(e);o.bytesSeen+=n,o.bytes+=n,o.isCaptured&&this.emit("progress",o.bytesSeen),this.push(e)?process.nextTick(t):o.onReadCallback=()=>{o.onReadCallback=null,process.nextTick(t)}},p=(e,t)=>{const n=Buffer.byteLength(e);let p,u=null,d=a,m=0;if(i){const e=Date.now();(!o.ts||(m=e-o.ts)>=r)&&(o.ts=e,p=s-o.bytes,o.bytes=p<0?-p:0,m=0),p=s-o.bytes}if(i){if(p<=0)return setTimeout(()=>{t(null,e)},r-m);p<d&&(d=p)}d&&n>d&&n-d>c&&(u=e.subarray(d),e=e.subarray(0,d)),l(e,u?()=>{process.nextTick(t,null,u)}:t)};p(e,function e(t,o){if(t)return n(t);o?p(o,e):n(null)})}};const{asyncIterator:Pr}=Symbol;var Ur=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Pr]?yield*e[Pr]():yield e};const Lr=Vi.ALPHABET.ALPHA_DIGIT+"-_",zr="function"==typeof TextEncoder?new TextEncoder:new he.TextEncoder,Fr="\r\n",Dr=zr.encode(Fr);class qr{constructor(e,t){const{escapeName:n}=this.constructor,o=hn.isString(t);let i=`Content-Disposition: form-data; name="${n(e)}"${!o&&t.name?`; filename="${n(t.name)}"`:""}${Fr}`;o?t=zr.encode(String(t).replace(/\r?\n|\r\n?/g,Fr)):i+=`Content-Type: ${String(t.type||"application/octet-stream").replace(/[\r\n]/g,"")}${Fr}`,this.headers=zr.encode(i+Fr),this.contentLength=o?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+2,this.name=e,this.value=t}async*encode(){yield this.headers;const{value:e}=this;hn.isTypedArray(e)?yield e:yield*Ur(e),yield Dr}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}var Br=class extends ge.Transform{__transform(e,t,n){this.push(e),n()}_transform(e,t,n){if(0!==e.length&&(this._transform=this.__transform,120!==e[0])){const e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,n)}},Mr=(e,t)=>hn.isAsyncFn(e)?function(...n){const o=n.pop();e.apply(this,n).then(e=>{try{t?o(null,...t(e)):o(null,e)}catch(e){o(e)}},o)}:e;const Wr=new Set(["localhost","0.0.0.0"]),Hr=e=>{const t=e.split(".");return 4===t.length&&"127"===t[0]&&t.every(e=>/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255)},Gr=e=>{if(/^0[xX][0-9a-fA-F]+$/.test(e)){const t=parseInt(e.slice(2),16);return Number.isFinite(t)?t:null}if(e.length>1&&/^0[0-7]+$/.test(e)){const t=parseInt(e,8);return Number.isFinite(t)?t:null}if(e.length>1&&/^0[0-9]+$/.test(e))return null;if(/^[0-9]+$/.test(e)){const t=parseInt(e,10);return Number.isFinite(t)?t:null}return null},Jr=e=>/^0{1,4}$/.test(e),Vr=e=>!!e&&(!!Wr.has(e)||!!Hr(e)||!!(e=>{if("::"===e)return!0;const t=e.indexOf("::");if(-1!==t){if(t!==e.lastIndexOf("::"))return!1;const n=e.slice(0,t),o=e.slice(t+2),i=n?n.split(":"):[],a=o?o.split(":"):[];return i.length+a.length<8&&i.every(Jr)&&a.every(Jr)}const n=e.split(":");return 8===n.length&&n.every(Jr)})(e)||(e=>{if("::1"===e)return!0;const t=e.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);if(t)return Hr(t[1]);const n=e.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);if(n){const e=parseInt(n[1],16);return e>=32512&&e<=32767}const o=e.split(":");if(8===o.length){for(let e=0;e<7;e++)if(!/^0+$/.test(o[e]))return!1;return/^0*1$/.test(o[7])}return!1})(e)),Kr={http:80,https:443,ws:80,wss:443,ftp:21},Yr=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i,Zr=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i,Xr=e=>{if(!e)return e;"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.slice(1,-1));const t=e.replace(/\.+$/,""),n=(e=>{if("string"!=typeof e||!e||-1!==e.indexOf(":"))return e;let t=e;if("["===t.charAt(0)&&"]"===t.charAt(t.length-1)&&(t=t.slice(1,-1)),t=t.replace(/\.+$/,""),!/^[0-9.xXa-fA-F]+$/.test(t))return e;const n=t.split(".");if(n.some(e=>""===e))return e;if(4===n.length){const t=n.map(Gr);return t.some(e=>null===e||e<0||e>255)?e:t.join(".")}if(n.length>4)return e;if(1===n.length)return e;const o=n.slice(0,-1),i=4-o.length,a=Gr(n[n.length-1]);if(null===a)return e;if(a<0||a>(1<<8*i)-1)return e;const r=new Array(i).fill(0);for(let e=i-1,t=a;e>=0;e--,t>>=8)r[e]=255&t;const s=o.map(Gr);return s.some(e=>null===e||e<0||e>255)?e:[...s,...r].join(".")})(t);return n!==t?n:(e=>{if("string"!=typeof e||-1===e.indexOf(":"))return e;const t=e.match(Yr);if(t)return t[1];const n=e.match(Zr);if(n){const e=parseInt(n[1],16),t=parseInt(n[2],16);return`${e>>8}.${255&e}.${t>>8}.${255&t}`}return e})(t)},Qr=(e,t,n=3)=>{let o=0;const i=function(e,t){e=e||10;const n=new Array(e),o=new Array(e);let i,a=0,r=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),l=o[r];i||(i=c),n[a]=s,o[a]=c;let p=r,u=0;for(;p!==a;)u+=n[p++],p%=e;if(a=(a+1)%e,a===r&&(r=(r+1)%e),c-i<t)return;const d=l&&c-l;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(n,a){let r,s,c=0,l=1e3/a;const p=(n,a=Date.now())=>{c=a,r=null,s&&(clearTimeout(s),s=null),(n=>{if(!n||"number"!=typeof n.loaded)return;const a=n.loaded,r=n.lengthComputable?n.total:void 0,s=Math.max(0,null!=r?Math.min(a,r):a),c=Math.max(0,s-o),l=i(c);o=Math.max(o,s),e({loaded:s,total:r,progress:r?s/r:void 0,bytes:c,rate:l||void 0,estimated:l&&r?(r-s)/l:void 0,event:n,lengthComputable:null!=r,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-c;n>=l?p(e,t):(r=e,s||(s=setTimeout(()=>{s=null,p(r)},l-n)))},()=>r&&p(r)]}(0,n)},es=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},ts=(e,t=hn.asap)=>(...n)=>t(()=>e(...n)),ns=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,os=(e,t,n)=>t+2<n&&ns(e.charCodeAt(t+1))&&ns(e.charCodeAt(t+2)),is=e=>e<=57?e-48:(223&e)-55,as=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||43===e||47===e||45===e||95===e,rs=e=>{const t=e.length;let n=0;return t>0&&61===e.charCodeAt(t-1)&&(n++,t>1&&61===e.charCodeAt(t-2)&&n++),Math.floor(3*(t-n)/4)},ss=e=>{const t=e.length;let n=0,o=0,i=!1;for(let r=0;r<t;r++){let s=e.charCodeAt(r);37===s&&os(e,r,t)&&(s=16*is(e.charCodeAt(r+1))+is(e.charCodeAt(r+2)),r+=2),9!==(a=s)&&10!==a&&12!==a&&13!==a&&32!==a&&(61!==s?!as(s)||o>0?i=!0:n++:o++)}var a;return i||o>2||o>0&&(n+o)%4!=0||n%4==1?rs(e):(e=>{const t=e%4;return 3*Math.floor(e/4)+(2===t?1:3===t?2:0)})(n)},cs=(e,t)=>{if(!e||"string"!=typeof e)return 0;if(!e.startsWith("data:"))return 0;const n=e.indexOf(",");if(n<0)return 0;const o=e.slice(5,n),i=e.slice(n+1);if(/;base64/i.test(o))return t(i);let a=0;for(let e=0,t=i.length;e<t;e++){const n=i.charCodeAt(e);if(37===n&&os(i,e,t))a+=1,e+=2;else if(n<128)a+=1;else if(n<2048)a+=2;else if(n>=55296&&n<=56319&&e+1<t){const t=i.charCodeAt(e+1);t>=56320&&t<=57343?(a+=4,e++):a+=3}else a+=3}return a},ls={flush:Re.constants.Z_SYNC_FLUSH,finishFlush:Re.constants.Z_SYNC_FLUSH},ps={flush:Re.constants.BROTLI_OPERATION_FLUSH,finishFlush:Re.constants.BROTLI_OPERATION_FLUSH},us={flush:Re.constants.ZSTD_e_flush,finishFlush:Re.constants.ZSTD_e_flush},ds=hn.isFunction(Re.createBrotliDecompress),ms=hn.isFunction(Re.createZstdDecompress),fs="gzip, compress, deflate"+(ds?", br":""),hs=fs+(ms?", zstd":""),gs="undefined"!=typeof process&&process.nextTick?process.nextTick.bind(process):hn.asap,{http:vs,https:bs}=$r,xs=/https:?/,ys=Symbol("axios.http.socketListener"),ws=Symbol("axios.http.currentReq"),_s=Symbol("axios.http.installedTunnel"),js=new Map,ks=new WeakMap,Ss={22:21,24:5},Es=Vi.protocols.map(e=>e+":"),$s=e=>{if(!hn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Ts=(e,[t,n])=>(e.on("end",n).on("error",n),t),Is=new class{constructor(){this.sessions=Object.create(null)}getSession(e,t){t=Object.assign({sessionTimeout:1e3},t);let n=this.sessions[e];if(n){let e=n.length;for(let o=0;o<e;o++){const[e,i]=n[o];if(!e.destroyed&&!e.closed&&he.isDeepStrictEqual(i,t))return e}}const o=Ce.connect(e,t);let i,a;const r=()=>{if(i)return;i=!0,a&&(clearTimeout(a),a=null);let t=n,r=t.length,s=r;for(;s--;)if(t[s][0]===o)return 1===r?delete this.sessions[e]:t.splice(s,1),void(o.closed||o.close())},s=o.request,{sessionTimeout:c}=t;if(null!=c){let e=0;o.request=function(){const t=s.apply(this,arguments);return e++,a&&(clearTimeout(a),a=null),t.once("close",()=>{--e||(a=setTimeout(()=>{a=null,r()},c))}),t}}o.once("close",r);let l=[o,t];return n?n.push(l):n=this.sessions[e]=[l],o}};function Os(e,t,n){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.auth&&e.beforeRedirects.auth(e),e.beforeRedirects.sensitiveHeaders&&e.beforeRedirects.sensitiveHeaders(e,n),e.beforeRedirects.config&&e.beforeRedirects.config(e,t,n)}function As(e,t,n,o,i,a){let r=t;const s=function(e,t,n){return xs.test(e.protocol)?n||xe.globalAgent:t||be.globalAgent}(e,a,i);if(!r&&!1!==r&&!function(e,t=process.versions&&process.versions.node){if(!function(e=process.versions&&process.versions.node){if(!e)return!1;const[t,n]=e.split(".").map(e=>Number(e));return!(!Number.isInteger(t)||!Number.isInteger(n))&&(t>24||null!=Ss[t]&&n>=Ss[t])}(t))return!1;const n=e&&e.options;return Boolean(n&&hn.hasOwnProp(n,"proxyEnv")&&null!=n.proxyEnv)}(s)){const e=function(e){var t=("string"==typeof e?function(e){try{return new URL(e)}catch{return null}}(e):e)||{},n=t.protocol,o=t.host,i=t.port;if("string"!=typeof o||!o||"string"!=typeof n)return"";if(n=n.split(":",1)[0],!function(e,t){var n=pa("no_proxy").toLowerCase();return!n||"*"!==n&&n.split(/[,\s]/).every(function(n){if(!n)return!0;var o=n.match(/^(.+):(\d+)$/),i=o?o[1]:n,a=o?parseInt(o[2]):0;return!(!a||a===t)||(/^[.*]/.test(i)?("*"===i.charAt(0)&&(i=i.slice(1)),!e.endsWith(i)):e!==i)})}(o=o.replace(/:\d*$/,""),i=parseInt(i)||la[n]||0))return"";var a=pa(n+"_proxy")||pa("all_proxy");return a&&-1===a.indexOf("://")&&(a=n+"://"+a),a}(n);e&&(function(e){let t;try{t=new URL(e)}catch(e){return!1}const n=(process.env.no_proxy||process.env.NO_PROXY||"").toLowerCase();if(!n)return!1;if("*"===n)return!0;const o=Number.parseInt(t.port,10)||Kr[t.protocol.split(":",1)[0]]||0,i=Xr(t.hostname.toLowerCase());return n.split(/[\s,]+/).some(e=>{if(!e)return!1;if("*"===e)return!0;let[t,n]=(e=>{let t=e,n=0;if("["===t.charAt(0)){const e=t.indexOf("]");if(-1!==e){const o=t.slice(1,e),i=t.slice(e+1);return":"===i.charAt(0)&&/^\d+$/.test(i.slice(1))&&(n=Number.parseInt(i.slice(1),10)),[o,n]}}const o=t.indexOf(":"),i=t.lastIndexOf(":");return-1!==o&&o===i&&/^\d+$/.test(t.slice(i+1))&&(n=Number.parseInt(t.slice(i+1),10),t=t.slice(0,i)),[t,n]})(e);return t=Xr(t),!!t&&(!n||n===o)&&("*"===t.charAt(0)&&(t=t.slice(1)),"."===t.charAt(0)?i.endsWith(t):i===t||Vr(i)&&Vr(t))})}(n)||(r=new URL(e)))}if(o&&e.headers)for(const t of Object.keys(e.headers))"proxy-authorization"===t.toLowerCase()&&delete e.headers[t];if(o&&e.agent&&e.agent[_s]&&(e.agent=void 0),r){const t=r instanceof URL,o=e=>t||hn.hasOwnProp(r,e)?r[e]:void 0,a=o("username"),s=o("password");let c=hn.hasOwnProp(r,"auth")?r.auth:void 0;if(a&&(c=(a||"")+":"+(s||"")),c){const e="object"==typeof c,t=e&&hn.hasOwnProp(c,"username")?c.username:void 0,n=e&&hn.hasOwnProp(c,"password")?c.password:void 0;if(Boolean(t||n))c=(t||"")+":"+(n||"");else if(e)throw new An("Invalid proxy authorization",An.ERR_BAD_OPTION,{proxy:r})}if(xs.test(e.protocol)){if(!(i instanceof er)){const t=o("hostname")||o("host"),n=o("port"),a=o("protocol"),r=a?a.includes(":")?a:`${a}:`:"http:",s=t&&t.includes(":")&&!t.startsWith("[")?`[${t}]`:t,l=new URL(`${r}//${s}${n?":"+n:""}`),p={protocol:l.protocol,hostname:l.hostname.replace(/^\[|\]$/g,""),port:l.port,auth:c&&"string"==typeof c?c:void 0};"https:"===l.protocol&&(p.ALPNProtocols=["http/1.1"]);const u=function(e,t){const n=e.protocol+"//"+e.hostname+":"+(e.port||"")+"#"+(e.auth||""),o=t?ks.get(t)||ks.set(t,new Map).get(t):js;let i=o.get(n);if(i)return i;const a=t&&t.options?{...t.options,...e}:e;if(i=new er(a),t&&t.options){const e={...t.options},n=i.callback;i.callback=function(t,o){return n.call(this,t,{...e,...o})}}return i[_s]=!0,o.set(n,i),i}(p,i);e.agent=u,e.agents&&(e.agents.https=u)}}else{if(c){const t=Buffer.from(c,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+t}let t=!1;for(const n of Object.keys(e.headers))if("host"===n.toLowerCase()){t=!0;break}t||(e.headers.host=e.hostname+(e.port?":"+e.port:""));const i=o("hostname")||o("host");e.hostname=i,e.host=i,e.port=o("port"),e.path=n;const a=o("protocol");a&&(e.protocol=a.includes(":")?a:`${a}:`)}}e.beforeRedirects.proxy=function(e){As(e,t,e.href,!0,i,a)}}const Cs="undefined"!=typeof process&&"process"===hn.kindOf(process),Rs=(e,t)=>(({address:e,family:t})=>{if(!hn.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(hn.isObject(e)?e:{address:e,family:t}),Ns={request(e,t){const n=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:o,headers:i}=e,a=Is.getSession(n,o),{HTTP2_HEADER_SCHEME:r,HTTP2_HEADER_METHOD:s,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:l}=Ce.constants,p={[r]:e.protocol.replace(":",""),[s]:e.method,[c]:e.path};hn.forEach(i,(e,t)=>{":"!==t.charAt(0)&&(p[t]=e)});const u=a.request(p);return u.once("response",e=>{const n=u,o=(e=Object.assign({},e))[l];delete e[l],n.headers=e,n.statusCode=+o,t(n)}),u}};var Ps,Us,Ls=Cs&&function(e){return t=async function(t,n,o){const i=t=>hn.getSafeProp(e,t),a=i("transitional")||Fi;let r=i("data"),s=i("lookup"),c=i("family"),l=i("httpVersion");void 0===l&&(l=1);let p=i("http2Options");const u=i("httpAgent"),d=i("httpsAgent"),m=i("proxy"),f=i("responseType"),h=i("responseEncoding"),g=i("socketPath"),v=i("method").toUpperCase(),b=i("maxRedirects"),x=i("maxBodyLength"),y=i("maxContentLength"),_=i("decompress");let j,k,S,E=!1;if(l=+l,Number.isNaN(l))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(1!==l&&2!==l)throw TypeError(`Unsupported protocol version '${l}'`);const $=2===l;if(s){const e=Mr(s,e=>hn.isArray(e)?e:[e]);s=(t,n,o)=>{e(t,n,(e,t,i)=>{if(e)return o(e);const a=hn.isArray(t)?t.map(e=>Rs(e)):[Rs(t,i)];n.all?o(e,a):o(e,a[0].address,a[0].family)})}}const T=new Ae;function I(t){try{T.emit("abort",!t||t.type?new oa(null,e,k):t)}catch(e){}}function O(){S&&(clearTimeout(S),S=null)}T.once("abort",n);const A=()=>{O(),e.cancelToken&&e.cancelToken.unsubscribe(I),e.signal&&e.signal.removeEventListener("abort",I),T.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(I),e.signal&&(e.signal.aborted?I():e.signal.addEventListener("abort",I))),o((e,t)=>{if(j=!0,O(),t)return E=!0,void A();const{data:n}=e;if(n instanceof ge.Readable||n instanceof ge.Duplex){const e=ge.finished(n,()=>{e(),A()})}else A()});const C=ca(i("baseURL"),i("url"),i("allowAbsoluteUrls"),e),R=new URL(C,g?"http://localhost":Vi.hasBrowserEnv?Vi.origin:void 0),N=R.protocol||Es[0];if("data:"===N){if(y>-1){const t=function(e){return cs(e,rs)}(String(i("url")||C||""));if(t>y)return n(new An("maxContentLength size of "+y+" exceeded",An.ERR_BAD_RESPONSE,e))}let o;if("GET"!==v)return ia(t,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{o=function(e,t,n){const o=n&&n.Blob||Vi.classes.Blob,i=Ir(e);if(void 0===t&&o&&(t=!0),"data"===i){e=i.length?e.slice(i.length+1):e;const n=Or.exec(e);if(!n)throw new An("Invalid URL",An.ERR_INVALID_URL);const a=n[1],r=n[2],s=n[3]?"base64":"utf8",c=n[4];let l="";a?l=r?a+r:a:r&&(l="text/plain"+r);const p="base64"===s?Buffer.from(c,"base64"):Buffer.from(decodeURIComponent(c),s);if(t){if(!o)throw new An("Blob is not supported",An.ERR_NOT_SUPPORT);return new o([p],{type:l})}return p}throw new An("Unsupported protocol "+i,An.ERR_NOT_SUPPORT)}(i("url"),"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw An.from(t,An.ERR_BAD_REQUEST,e)}return"text"===f?(o=o.toString(h),h&&"utf8"!==h||(o=hn.stripBOM(o))):"stream"===f&&(o=ge.Readable.from(o)),ia(t,n,{data:o,status:200,statusText:"OK",headers:new Tn,config:e})}if(-1===Es.indexOf(N))return n(new An("Unsupported protocol "+N,An.ERR_BAD_REQUEST,e));const P=Tn.from(e.headers).normalize();P.set("User-Agent","axios/"+Tr,!1);const{onUploadProgress:U,onDownloadProgress:L}=e,z=e.maxRate;let F,D;if(hn.isSpecCompliantForm(r)){const e=P.getContentType(/boundary=([-_\w\d]{10,70})/i);r=((e,t,n)=>{const{tag:o="form-data-boundary",size:i=25,boundary:a=o+"-"+Vi.generateString(i,Lr)}=n||{};if(!hn.isFormData(e))throw new TypeError("FormData instance required");if(a.length<1||a.length>70)throw new Error("boundary must be 1-70 characters long");const r=zr.encode("--"+a+Fr),s=zr.encode("--"+a+"--"+Fr);let c=s.byteLength;const l=Array.from(e.entries()).map(([e,t])=>{const n=new qr(e,t);return c+=n.size,n});c+=r.byteLength*l.length,c=hn.toFiniteNumber(c);const p={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(c)&&(p["Content-Length"]=c),t&&t(p),ve.from(async function*(){for(const e of l)yield r,yield*e.encode();yield s}())})(r,e=>{P.set(e)},{tag:`axios-${Tr}-boundary`,boundary:e&&e[1]||void 0})}else if(hn.isFormData(r)&&hn.isFunction(r.getHeaders)&&r.getHeaders!==Object.prototype.getHeaders){if(Cr(P,r.getHeaders(),i("formDataHeaderPolicy")),!P.hasContentLength())try{const e=await he.promisify(r.getLength).call(r);Number.isFinite(e)&&e>=0&&P.setContentLength(e)}catch(e){}}else if(hn.isBlob(r)||hn.isFile(r))r.size&&P.setContentType(r.type||"application/octet-stream"),P.setContentLength(r.size||0),r=ge.Readable.from(Ur(r));else if(r&&!hn.isStream(r)){if(Buffer.isBuffer(r));else if(hn.isArrayBuffer(r))r=Buffer.from(new Uint8Array(r));else{if(!hn.isString(r))return n(new An("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",An.ERR_BAD_REQUEST,e));r=Buffer.from(r,"utf-8")}if(P.setContentLength(r.length,!1),x>-1&&r.length>x)return n(new An("Request body larger than maxBodyLength limit",An.ERR_BAD_REQUEST,e))}const q=hn.toFiniteNumber(P.getContentLength());let B;hn.isArray(z)?(F=z[0],D=z[1]):F=D=z,r&&(U||F)&&(hn.isStream(r)||(r=ge.Readable.from(r,{objectMode:!1})),r=ge.pipeline([r,new Nr({maxRate:hn.toFiniteNumber(F)})],hn.noop),U&&r.on("progress",Ts(r,es(q,Qr(ts(U,gs),!1,3)))));const M=i("auth");let W;M&&(B=(hn.getSafeProp(M,"username")||"")+":"+(hn.getSafeProp(M,"password")||"")),B||!R.username&&!R.password||(B=$s(R.username)+":"+$s(R.password)),B&&P.delete("authorization");try{W=Li(R.pathname+R.search,i("params"),i("paramsSerializer")).replace(/^\?/,"")}catch(t){return n(An.from(t,An.ERR_BAD_REQUEST,e,null,null,{url:i("url"),exists:!0}))}P.set("Accept-Encoding",hn.hasOwnProp(a,"advertiseZstdAcceptEncoding")&&!0===a.advertiseZstdAcceptEncoding?hs:fs,!1);const H=Object.assign(Object.create(null),{path:W,method:v,headers:yn(P),agents:{http:u,https:d},auth:B,protocol:N,family:c,beforeRedirect:Os,beforeRedirects:Object.create(null),http2Options:p});if(!hn.isUndefined(s)&&(H.lookup=s),g){if("string"!=typeof g)return n(new An("socketPath must be a string",An.ERR_BAD_OPTION_VALUE,e));const t=i("allowedSocketPaths");if(null!=t){const o=Array.isArray(t)?t:[t],i=w(g);if(!o.some(e=>"string"==typeof e&&w(e)===i))return n(new An(`socketPath "${g}" is not permitted by allowedSocketPaths`,An.ERR_BAD_OPTION_VALUE,e))}H.socketPath=g}else H.hostname=R.hostname.startsWith("[")?R.hostname.slice(1,-1):R.hostname,H.port=R.port,As(H,m,N+"//"+R.hostname+(R.port?":"+R.port:"")+H.path,!1,d,u);let G,J=!1,V=!1;const K=xs.test(H.protocol);if(null==H.agent&&(H.agent=K?d:u),$)G=Ns;else{const t=i("transport");if(t)G=t;else if(0===b)G=K?xe:be,J=!0;else{V=!0,H.sensitiveHeaders=[],b&&(H.maxRedirects=b);const t=i("beforeRedirect");if(t&&(H.beforeRedirects.config=t),B){const e=R.origin,t=B;H.beforeRedirects.auth=function(n){try{new URL(n.href).origin===e&&(n.auth=t)}catch(e){}}}const o=i("sensitiveHeaders");if(null!=o){if(!hn.isArray(o))return n(new An("sensitiveHeaders must be an array of strings",An.ERR_BAD_OPTION_VALUE,e));const t=new Set;for(const i of o){if(!hn.isString(i))return n(new An("sensitiveHeaders must be an array of strings",An.ERR_BAD_OPTION_VALUE,e));t.add(i.toLowerCase())}t.size&&(H.sensitiveHeaders=Array.from(t),H.beforeRedirects.sensitiveHeaders=function(e,n){(function(e,t){if(!t)return!1;try{return new URL(t.url).origin===new URL(e.href).origin}catch(e){return!1}})(e,n)||function(e,t){e&&Object.keys(e).forEach(n=>{t.has(n.toLowerCase())&&delete e[n]})}(e.headers,t)})}G=K?bs:vs}}H.maxBodyLength=x>-1?x:Infinity,H.insecureHTTPParser=Boolean(i("insecureHTTPParser")),k=G.request(H,function(o){if(O(),k.destroyed)return;const i=[o],a=hn.toFiniteNumber(o.headers["content-length"]);if(L||D){const e=new Nr({maxRate:hn.toFiniteNumber(D)});L&&e.on("progress",Ts(e,es(a,Qr(ts(L,gs),!0,3)))),i.push(e)}let r=o;const s=o.req||k;if(!1!==_&&o.headers["content-encoding"])switch("HEAD"!==v&&204!==o.statusCode||delete o.headers["content-encoding"],(o.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":i.push(Re.createUnzip(ls)),delete o.headers["content-encoding"];break;case"deflate":i.push(new Br),i.push(Re.createUnzip(ls)),delete o.headers["content-encoding"];break;case"br":ds&&(i.push(Re.createBrotliDecompress(ps)),delete o.headers["content-encoding"]);break;case"zstd":ms&&(i.push(Re.createZstdDecompress(us)),delete o.headers["content-encoding"])}r=i.length>1?ge.pipeline(i,hn.noop):i[0];const c={status:o.statusCode,statusText:o.statusMessage,headers:new Tn(o.headers),config:e,request:s};if("stream"===f){if(y>-1){const t=y,n=r;r=ge.Readable.from(async function*(){let o=0;for await(const i of n){if(o+=i.length,o>t)throw new An("maxContentLength size of "+t+" exceeded",An.ERR_BAD_RESPONSE,e,s);yield i}}(),{objectMode:!1})}c.data=r,ia(t,n,c)}else{const o=[];let i=0;r.on("data",function(t){o.push(t),i+=t.length,y>-1&&i>y&&(E=!0,r.destroy(),I(new An("maxContentLength size of "+y+" exceeded",An.ERR_BAD_RESPONSE,e,s)))}),r.on("aborted",function(){if(E)return;const t=new An("stream has been aborted",An.ERR_BAD_RESPONSE,e,s,c);r.destroy(t),n(t)}),r.on("error",function(t){E||n(An.from(t,null,e,s,c))}),r.on("end",function(){try{let e=1===o.length?o[0]:Buffer.concat(o);"arraybuffer"!==f&&(e=e.toString(h),h&&"utf8"!==h||(e=hn.stripBOM(e))),c.data=e}catch(t){return n(An.from(t,null,e,c.request,c))}ia(t,n,c)})}T.once("abort",e=>{r.destroyed||(r.emit("error",e),r.destroy())})}),T.once("abort",e=>{k.close?k.close():k.destroy(e)}),k.on("error",function(t){n(An.from(t,null,e,k))});const Y=new Set;if(k.on("socket",function(e){"function"==typeof e.setKeepAlive&&e.setKeepAlive(!0,6e4),e[ys]||(e.on("error",function(t){const n=e[ws];n&&!n.destroyed&&n.destroy(t)}),e[ys]=!0),e[ws]=k,Y.add(e)}),k.once("close",function(){O();for(const e of Y)e[ws]===k&&(e[ws]=null);Y.clear()}),i("timeout")){const t=parseInt(i("timeout"),10);if(Number.isNaN(t))return void I(new An("error trying to parse `config.timeout` to int",An.ERR_BAD_OPTION_VALUE,e,k));const n=function(){j||I(function(){const t=i("timeout");let n=t?"timeout of "+t+"ms exceeded":"timeout exceeded";const o=i("timeoutErrorMessage");return o&&(n=o),new An(n,a.clarifyTimeoutError?An.ETIMEDOUT:An.ECONNABORTED,e,k)}())};J&&t>0&&(S=setTimeout(n,t)),k.setTimeout(t,n)}else k.setTimeout(0);if(hn.isStream(r)){let t=!1,n=!1;r.on("end",()=>{t=!0}),r.once("error",e=>{n=!0,k.destroy(e)}),r.on("close",()=>{t||n||I(new oa("Request stream has been aborted",e,k))});let o=r;if(x>-1&&!V){const t=x;let n=0;o=ge.pipeline([r,new ge.Transform({transform(o,i,a){if(n+=o.length,n>t)return a(new An("Request body larger than maxBodyLength limit",An.ERR_BAD_REQUEST,e,k));a(null,o)}})],hn.noop),o.on("error",e=>{k.destroyed||k.destroy(e)})}o.pipe(k)}else r&&k.write(r),k.end()},new Promise((e,n)=>{let o,i;const a=(e,t)=>{i||(i=!0,o&&o(e,t))},r=e=>{a(e,!0),n(e)};t(t=>{a(t),e(t)},r,e=>o=e).catch(r)});var t},zs=Vi.hasStandardBrowserEnv?(Ps=new URL(Vi.origin),Us=Vi.navigator&&/(msie|trident)/i.test(Vi.navigator.userAgent),e=>(e=new URL(e,Vi.origin),Ps.protocol===e.protocol&&Ps.host===e.host&&(Us||Ps.port===e.port))):()=>!0,Fs=Vi.hasStandardBrowserEnv?{write(e,t,n,o,i,a,r){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];hn.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),hn.isString(o)&&s.push(`path=${o}`),hn.isString(i)&&s.push(`domain=${i}`),!0===a&&s.push("secure"),hn.isString(r)&&s.push(`SameSite=${r}`),document.cookie=s.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const o=t[n].replace(/^\s+/,""),i=o.indexOf("=");if(-1!==i&&o.slice(0,i)===e)try{return decodeURIComponent(o.slice(i+1))}catch(e){return o.slice(i+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};const Ds=e=>e instanceof Tn?{...e}:e,qs=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Bs(e,t){e=e||{},t=t||{};const n=Object.create(null);function o(e,t,n,o){return hn.isPlainObject(e)&&hn.isPlainObject(t)?hn.merge.call({caseless:o},e,t):hn.isPlainObject(t)?hn.merge({},t):hn.isArray(t)?t.slice():t}function i(e,t,n,i){return hn.isUndefined(t)?hn.isUndefined(e)?void 0:o(void 0,e,0,i):o(e,t,0,i)}function a(e,t){if(!hn.isUndefined(t))return o(void 0,t)}function r(e,t){return hn.isUndefined(t)?hn.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function s(n,i,a){return hn.hasOwnProp(t,a)?o(n,i):hn.hasOwnProp(e,a)?o(void 0,n):void 0}Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});const c={url:a,method:a,data:a,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,allowedSocketPaths:r,responseEncoding:r,validateStatus:s,headers:(e,t,n)=>i(Ds(e),Ds(t),0,!0)};return hn.forEach(qs({...e,...t}),function(o){if("__proto__"===o||"constructor"===o||"prototype"===o)return;const a=hn.hasOwnProp(c,o)?c[o]:i,r=a(hn.hasOwnProp(e,o)?e[o]:void 0,hn.hasOwnProp(t,o)?t[o]:void 0,o);hn.isUndefined(r)&&a!==s||(n[o]=r)}),hn.hasOwnProp(t,"validateStatus")&&hn.isUndefined(t.validateStatus)&&!1===function(n){const o=hn.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!hn.isUndefined(o)){if(!hn.isPlainObject(o))return;if(hn.hasOwnProp(o,n))return o[n]}const i=hn.hasOwnProp(e,"transitional")?e.transitional:void 0;if(hn.isPlainObject(i)&&hn.hasOwnProp(i,n))return i[n]}("validateStatusUndefinedResolves")&&(hn.hasOwnProp(e,"validateStatus")?n.validateStatus=o(void 0,e.validateStatus):delete n.validateStatus),n}function Ms(e){const t=Bs({},e),n=e=>hn.hasOwnProp(t,e)?t[e]:void 0,o=n("data");let i=n("withXSRFToken");const a=n("xsrfHeaderName"),r=n("xsrfCookieName");let s=n("headers");const c=n("auth"),l=n("baseURL"),p=n("allowAbsoluteUrls"),u=n("url");if(t.headers=s=Tn.from(s),t.url=Li(ca(l,u,p,t),n("params"),n("paramsSerializer")),c){const t=hn.getSafeProp(c,"username")||"",n=hn.getSafeProp(c,"password")||"";try{s.set("Authorization","Basic "+btoa(t+":"+(n?(e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))(n):"")))}catch(t){throw An.from(t,An.ERR_BAD_OPTION_VALUE,e)}}if(hn.isFormData(o)&&(Vi.hasStandardBrowserEnv||Vi.hasStandardBrowserWebWorkerEnv||hn.isReactNative(o)?s.setContentType(void 0):hn.isFunction(o.getHeaders)&&Cr(s,o.getHeaders(),n("formDataHeaderPolicy"))),Vi.hasStandardBrowserEnv&&(hn.isFunction(i)&&(i=i(t)),!0===i||null==i&&zs(t.url))){const e=a&&r&&Fs.read(r);e&&s.set(a,e)}return t}var Ws="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const o=Ms(e);let i=o.data;const a=Tn.from(o.headers).normalize();let r,s,c,l,p,{responseType:u,onUploadProgress:d,onDownloadProgress:m}=o;function f(){l&&l(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(r),o.signal&&o.signal.removeEventListener("abort",r)}let h=new XMLHttpRequest;function g(){if(!h)return;const o=Tn.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());ia(function(e){t(e),f()},function(e){n(e),f()},{data:u&&"text"!==u&&"json"!==u?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:o,config:e,request:h}),h=null}h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout,"onloadend"in h?h.onloadend=g:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&h.responseURL.startsWith("file:"))&&setTimeout(g)},h.onabort=function(){h&&(n(new An("Request aborted",An.ECONNABORTED,e,h)),f(),h=null)},h.onerror=function(t){const o=new An(t&&t.message?t.message:"Network Error",An.ERR_NETWORK,e,h);o.event=t||null,n(o),f(),h=null},h.ontimeout=function(){let t=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";o.timeoutErrorMessage&&(t=o.timeoutErrorMessage),n(new An(t,(o.transitional||Fi).clarifyTimeoutError?An.ETIMEDOUT:An.ECONNABORTED,e,h)),f(),h=null},void 0===i&&a.setContentType(null),"setRequestHeader"in h&&hn.forEach(yn(a),function(e,t){h.setRequestHeader(t,e)}),hn.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),u&&"json"!==u&&(h.responseType=o.responseType),m&&([c,p]=Qr(m,!0),h.addEventListener("progress",c)),d&&h.upload&&([s,l]=Qr(d),h.upload.addEventListener("progress",s),h.upload.addEventListener("loadend",l)),(o.cancelToken||o.signal)&&(r=t=>{h&&(n(!t||t.type?new oa(null,e,h):t),h.abort(),f(),h=null)},o.cancelToken&&o.cancelToken.subscribe(r),o.signal&&(o.signal.aborted?r():o.signal.addEventListener("abort",r)));const v=Ir(o.url);if(v&&!Vi.protocols.includes(v))return n(new An("Unsupported protocol "+v+":",An.ERR_BAD_REQUEST,e)),void f();h.send(i||null)})},Hs=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let o=!1;const i=function(e){if(!o){o=!0,r();const t=e instanceof Error?e:this.reason;n.abort(t instanceof An?t:new oa(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,i(new An(`timeout of ${t}ms exceeded`,An.ETIMEDOUT))},t);const r=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>{o||(e.aborted?i.call(e):e.addEventListener("abort",i,{once:!0}))});const{signal:s}=n;return s.unsubscribe=()=>hn.asap(r),s};const Gs=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let o,i=0;for(;i<n;)o=i+t,yield e.slice(i,o),i=o},Js=(e,t,n,o)=>{const i=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Gs(n,t)}(e,t);let a,r=0,s=e=>{a||(a=!0,o&&o(e))};return new ReadableStream({async pull(e){try{const{done:t,value:o}=await i.next();if(t)return s(),void e.close();if(n){let e=r+=o.byteLength;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},{isFunction:Vs}=hn,Ks=e=>{if(!hn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Ys=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Zs=e=>{const t=null!=hn.global?hn.global:globalThis,{ReadableStream:n,TextEncoder:o}=t;e=hn.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:i,Request:a,Response:r}=e,s=i?Vs(i):"function"==typeof fetch,c=Vs(a),l=Vs(r);if(!s)return!1;const p=s&&Vs(n),u=s&&("function"==typeof o?(d=new o,e=>d.encode(e)):async e=>new Uint8Array(await new a(e).arrayBuffer()));var d;const m=c&&p&&Ys(()=>{let e=!1;const t=new a(Vi.origin,{body:new n,method:"POST",get duplex(){return e=!0,"half"}}),o=t.headers.has("Content-Type");return null!=t.body&&t.body.cancel(),e&&!o}),f=l&&p&&Ys(()=>hn.isReadableStream(new r("").body)),h={stream:f&&(e=>e.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!h[e]&&(h[e]=(t,n)=>{let o=t&&t[e];if(o)return o.call(t);throw new An(`Response type '${e}' is not supported`,An.ERR_NOT_SUPPORT,n)})});const g=async e=>{if(null==e)return 0;if(hn.isBlob(e))return e.size;if(hn.isSpecCompliantForm(e)){const t=new a(Vi.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return hn.isArrayBufferView(e)||hn.isArrayBuffer(e)?e.byteLength:(hn.isURLSearchParams(e)&&(e+=""),hn.isString(e)?(await u(e)).byteLength:void 0)};return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:u,timeout:d,onDownloadProgress:v,onUploadProgress:b,responseType:x,headers:y,withCredentials:w="same-origin",fetchOptions:_,maxContentLength:j,maxBodyLength:k}=Ms(e);const S=hn.isNumber(j)&&j>-1,E=hn.isNumber(k)&&k>-1;let $=i||fetch;x=x?(x+"").toLowerCase():"text";let T=Hs([l,u&&u.toAbortSignal()],d),I=null;const O=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let A,C=null;const R=()=>new An("Request body larger than maxBodyLength limit",An.ERR_BAD_REQUEST,e,I);try{let i;const l=hn.hasOwnProp(e,"auth")?e.auth:void 0;if(l&&(i={username:hn.getSafeProp(l,"username")||"",password:hn.getSafeProp(l,"password")||""}),(e=>{const t=e.indexOf("://");let n=e;return-1!==t&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")})(t)){const e=new URL(t,Vi.origin);i||!e.username&&!e.password||(i={username:Ks(e.username),password:Ks(e.password)}),(e.username||e.password)&&(e.username="",e.password="",t=e.href)}if(i&&(y.delete("authorization"),y.set("Authorization","Basic "+btoa((e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))((i.username||"")+":"+(i.password||""))))),S&&"string"==typeof t&&t.startsWith("data:")){const n=function(e){const t="string"==typeof e?e.indexOf("#"):-1;return cs(-1===t?e:e.slice(0,t),ss)}(t);if(n>j)throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I)}if(E&&"get"!==n&&"head"!==n){const e=await g(s);if("number"==typeof e&&isFinite(e)&&(A=e,e>k))throw R()}const u=E&&(hn.isReadableStream(s)||hn.isStream(s)),d=(e,t,n)=>Js(e,65536,e=>{if(E&&e>k)throw C=R();t&&t(e)},n);if(m&&"get"!==n&&"head"!==n&&(b||u)){if(A=null==A?await(async(e,t)=>{const n=hn.toFiniteNumber(e.getContentLength());return null==n?g(t):n})(y,s):A,0!==A||u){let e,n=new a(t,{method:"POST",body:s,duplex:"half"});if(hn.isFormData(s)&&(e=n.headers.get("content-type"))&&y.setContentType(e),n.body){const[e,t]=b&&es(A,Qr(ts(b)))||[];s=d(n.body,e,t)}}}else if(u&&!c&&p&&"get"!==n&&"head"!==n)s=d(s);else if(u&&c&&!m&&"get"!==n&&"head"!==n)throw new An("Stream request bodies are not supported by the current fetch implementation",An.ERR_NOT_SUPPORT,e,I);hn.isString(w)||(w=w?"include":"omit");const N=c&&"credentials"in a.prototype;if(hn.isFormData(s)){const e=y.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&y.delete("content-type")}y.set("User-Agent","axios/"+Tr,!1);const P={..._,signal:T,method:n.toUpperCase(),headers:yn(y.normalize()),body:s,duplex:"half",credentials:N?w:void 0};I=c&&new a(t,P);let U=await(c?$(I,_):$(t,P));const L=Tn.from(U.headers);if(S){const t=hn.toFiniteNumber(L.getContentLength());if(null!=t&&t>j)throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I)}const z=f&&("stream"===x||"response"===x);if(f&&U.body&&(v||S||z&&O)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=U[e]});const n=hn.toFiniteNumber(L.getContentLength()),[o,i]=v&&es(n,Qr(ts(v),!0))||[];let a=0;U=new r(Js(U.body,65536,t=>{if(S&&(a=t,a>j))throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I);o&&o(t)},()=>{i&&i(),O&&O()}),t)}x=x||"text";let F=await h[hn.findKey(h,x)||"text"](U,e);if(S&&!f&&!z){let t;if(null!=F&&("number"==typeof F.byteLength?t=F.byteLength:"number"==typeof F.size?t=F.size:"string"==typeof F&&(t="function"==typeof o?(new o).encode(F).byteLength:F.length)),"number"==typeof t&&t>j)throw new An("maxContentLength size of "+j+" exceeded",An.ERR_BAD_RESPONSE,e,I)}return!z&&O&&O(),await new Promise((t,n)=>{ia(t,n,{data:F,headers:Tn.from(U.headers),status:U.status,statusText:U.statusText,config:e,request:I})})}catch(t){if(O&&O(),T&&T.aborted&&T.reason instanceof An){const n=T.reason;throw n.config=e,I&&(n.request=I),t!==n&&Object.defineProperty(n,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),n}if(C)throw I&&!C.request&&(C.request=I),C;if(t instanceof An)throw I&&!t.request&&(t.request=I),t;if(t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message)){const n=new An("Network Error",An.ERR_NETWORK,e,I,t&&t.response);throw Object.defineProperty(n,"cause",{__proto__:null,value:t.cause||t,writable:!0,enumerable:!1,configurable:!0}),n}throw An.from(t,t&&t.code,e,I,t&&t.response)}}},Xs=new Map,Qs=e=>{let t=e&&e.env||{};const{fetch:n,Request:o,Response:i}=t,a=[o,i,n];let r,s,c=a.length,l=Xs;for(;c--;)r=a[c],s=l.get(r),void 0===s&&l.set(r,s=c?new Map:Zs(t)),l=s;return s};Qs();const ec={http:Ls,xhr:Ws,fetch:{get:Qs}};hn.forEach(ec,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch(e){}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const tc=e=>`- ${e}`,nc=e=>hn.isFunction(e)||null===e||!1===e;var oc=function(e,t){e=hn.isArray(e)?e:[e];const{length:n}=e;let o,i;const a={};for(let r=0;r<n;r++){let n;if(o=e[r],i=o,!nc(o)&&(i=ec[(n=String(o)).toLowerCase()],void 0===i))throw new An(`Unknown adapter '${n}'`);if(i&&(hn.isFunction(i)||(i=i.get(t))))break;a[n||"#"+r]=i}if(!i){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=n?e.length>1?"since :\n"+e.map(tc).join("\n"):" "+tc(e[0]):"as no adapter specified";throw new An("There is no suitable adapter to dispatch the request "+t,An.ERR_NOT_SUPPORT)}return i};function ic(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new oa(null,e)}function ac(e){return ic(e),e.headers=Tn.from(e.headers),e.data=ta.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),oc(e.adapter||ea.adapter,e)(e).then(function(t){ic(e),e.response=t;try{t.data=ta.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=Tn.from(t.headers),t},function(t){if(!na(t)&&(ic(e),t&&t.response)){e.response=t.response;try{t.response.data=ta.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=Tn.from(t.response.headers)}return Promise.reject(t)})}const rc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{rc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const sc={};rc.transitional=function(e,t,n){function o(e,t){return"[Axios v"+Tr+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,a)=>{if(!1===e)throw new An(o(i," has been removed"+(t?" in "+t:"")),An.ERR_DEPRECATED);return t&&!sc[i]&&(sc[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,a)}},rc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var cc={assertOptions:function(e,t,n){if("object"!=typeof e||null===e)throw new An("options must be an object",An.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let i=o.length;for(;i-- >0;){const a=o[i],r=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(r){const t=e[a],n=void 0===t||r(t,a,e);if(!0!==n)throw new An("option "+a+" must be "+n,An.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new An("Unknown option "+a,An.ERR_BAD_OPTION)}},validators:rc};const lc=cc.validators;class pc{constructor(e){this.defaults=e||{},this.interceptors={request:new zi,response:new zi}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=(()=>{if(!t.stack)return"";const e=t.stack.indexOf("\n");return-1===e?"":t.stack.slice(e+1)})();try{if(e.stack){if(n){const t=n.indexOf("\n"),o=-1===t?-1:n.indexOf("\n",t+1),i=-1===o?"":n.slice(o+1);String(e.stack).endsWith(i)||(e.stack+="\n"+n)}}else e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Bs(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:i}=t;void 0!==n&&cc.assertOptions(n,{silentJSONParsing:lc.transitional(lc.boolean),forcedJSONParsing:lc.transitional(lc.boolean),clarifyTimeoutError:lc.transitional(lc.boolean),legacyInterceptorReqResOrdering:lc.transitional(lc.boolean),advertiseZstdAcceptEncoding:lc.transitional(lc.boolean),validateStatusUndefinedResolves:lc.transitional(lc.boolean)},!1),null!=o&&(hn.isFunction(o)?t.paramsSerializer={serialize:o}:cc.assertOptions(o,{encode:lc.function,serialize:lc.function},!0)),void 0!==t.allowAbsoluteUrls||(t.allowAbsoluteUrls=void 0===this.defaults.allowAbsoluteUrls||this.defaults.allowAbsoluteUrls),cc.assertOptions(t,{baseUrl:lc.spelling("baseURL"),withXsrfToken:lc.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&hn.merge(i.common,i[t.method]);i&&hn.forEach(["delete","get","head","post","put","patch","query","common"],e=>{delete i[e]}),t.headers=Tn.concat(a,i);const r=[];let s=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;s=s&&e.synchronous;const n=t.transitional||Fi;n&&n.legacyInterceptorReqResOrdering?r.unshift(e.fulfilled,e.rejected):r.push(e.fulfilled,e.rejected)});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let p,u=0;if(!s){const e=[ac.bind(this),void 0];for(e.unshift(...r),e.push(...c),p=e.length,l=Promise.resolve(t);u<p;)l=l.then(e[u++],e[u++]);return l}p=r.length;let d=t;for(;u<p;){const e=r[u++],t=r[u++];try{d=e?e(d):d}catch(e){if(!t){l=Promise.reject(e);break}try{const n=t.call(this,e);hn.isThenable(n)&&(l=Promise.resolve(n).then(()=>ac.call(this,d)))}catch(e){l=Promise.reject(e)}break}}if(!l)try{l=ac.call(this,d)}catch(e){l=Promise.reject(e)}for(u=0,p=c.length;u<p;)l=l.then(c[u++],c[u++]);return l}getUri(e){return Li(ca((e=Bs(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}}hn.forEach(["delete","get","head","options"],function(e){pc.prototype[e]=function(t,n){return this.request(Bs(n||{},{method:e,url:t,data:n&&hn.hasOwnProp(n,"data")?n.data:void 0}))}}),hn.forEach(["post","put","patch","query"],function(e){function t(t){return function(n,o,i){return this.request(Bs(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}pc.prototype[e]=t(),"query"!==e&&(pc.prototype[e+"Form"]=t(!0))});var uc=pc;class dc{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const o=new Promise(e=>{n.subscribe(e),t=e}).then(e);return o.cancel=function(){n.unsubscribe(t)},o},e(function(e,o,i){n.reason||(n.reason=new oa(e,o,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new dc(function(t){e=t}),cancel:e}}}var mc=dc;const fc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(fc).forEach(([e,t])=>{fc[t]=e});var hc=fc;const gc=function e(t){const n=new uc(t),o=xt(uc.prototype.request,n);return hn.extend(o,uc.prototype,n,{allOwnKeys:!0}),hn.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return e(Bs(t,n))},o}(ea);gc.Axios=uc,gc.CanceledError=oa,gc.CancelToken=mc,gc.isCancel=na,gc.VERSION=Tr,gc.toFormData=Ci,gc.AxiosError=An,gc.Cancel=gc.CanceledError,gc.all=function(e){return Promise.all(e)},gc.spread=function(e){return function(t){return e.apply(null,t)}},gc.isAxiosError=function(e){return hn.isObject(e)&&!0===e.isAxiosError},gc.mergeConfig=Bs,gc.AxiosHeaders=Tn,gc.formToJSON=e=>Zi(hn.isHTMLForm(e)?new FormData(e):e),gc.getAdapter=oc,gc.HttpStatusCode=hc,gc.default=gc;var vc=gc;const{CanceledError:bc}=vc,xc="screenshot.needle.webp",yc=/screenshot(\-\d+?)?\.needle\.(webp|png|jpg|jpeg)/;async function wc(e,t){const n=t.baseUrl+ft.jobs.post_update,o={...ht(t),job_id:e.identifier,status:e.status},i={status_message:e.status_message,error:e.error,progress:e.progress},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)}).catch(e=>(console.error(e),null));return!!a&&a.ok}async function _c(e,t){const n=t.baseUrl+ft.jobs.get_status,o={...ht(t),job_id:e,org:t.org},i=await fetch(n,{...gt,method:"GET",headers:o}).catch(e=>(t.verbose?console.error("Failed to get job status",e):console.error("Failed to get job status",e.message),null));return i?i.ok?await i.json():(console.error("Failed to get status",i.status,await i.text()),{failed:!0,httpStatus:i.status}):{failed:!0}}function jc(e={}){var t,n;const o=null!=(t=e.maxAuthFailures)?t:2,i=null!=(n=e.maxTransientFailures)?n:10;let a=0,r=0;return{record(e){if(e&&!0!==e.failed)return a=0,r=0,null;const t=null==e?void 0:e.httpStatus;return 401===t||403===t?(a++,a>=o?{abort:!0,reason:`Not authorized to read the job status (HTTP ${t}). Your access token is invalid or expired — run \`needle-cloud login\` or pass a fresh --token.`}:null):(r++,r>=i?{abort:!0,reason:`Could not read the job status after ${r} attempts${t?` (last: HTTP ${t})`:""}. The job may still be running — check it in the Needle Cloud dashboard.`}:null)}}}const kc=6,Sc=1e3,Ec=15e3,$c=9e4,Tc=new Set(["CERT_HAS_EXPIRED","UNABLE_TO_VERIFY_LEAF_SIGNATURE","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","ERR_TLS_CERT_ALTNAME_INVALID"]),Ic=new Set([408,429]);function Oc(e){var t;if(function(e){const t=null==e?void 0:e.name,n=null==e?void 0:e.code;return"CanceledError"===t||"AbortError"===t||"ERR_CANCELED"===n||"ABORT_ERR"===n}(e))return!1;const n=null==e||null==(t=e.response)?void 0:t.status;if("number"==typeof n&&n>0)return!!Ic.has(n)||!(n>=400&&n<500);const o=function(e){var t,n;const o=null!=(t=null==e?void 0:e.code)?t:null==e||null==(n=e.cause)?void 0:n.code;return"string"==typeof o&&o.length?o:null}(e);return!o||!Tc.has(o)}function Ac(e,t={}){const{baseMs:n=Sc,maxMs:o=Ec,random:i=Math.random}=t,a=Math.max(1,Math.floor(e)),r=Math.min(o,n*2**(a-1))/2;return Math.max(1,Math.round(r+i()*r))}async function Cc(e,t={}){const{maxAttempts:n=kc,budgetMs:o=$c,baseMs:i=Sc,maxMs:a=Ec,isRetryable:r=Oc,sleep:s=Rc,now:c=Date.now,random:l=Math.random,onRetry:p}=t,u=c();let d,m=0;for(;m<n;){m++;try{return{ok:!0,value:await e(m),attempts:m}}catch(e){if(d=e,!r(e))return{ok:!1,error:e,attempts:m,reason:"permanent"};if(m>=n)return{ok:!1,error:e,attempts:m,reason:"attempts-exhausted"};const t=Ac(m,{baseMs:i,maxMs:a,random:l});if(c()-u+t>=o)return{ok:!1,error:e,attempts:m,reason:"budget-exhausted"};null==p||p({attempt:m,waitMs:t,error:e}),await s(t)}}return{ok:!1,error:d,attempts:m,reason:"attempts-exhausted"}}function Rc(e){return new Promise(t=>setTimeout(t,e))}const Nc=5242880,Pc=1e4,Uc=16777216,Lc=67108864;var zc=Fn(function(e,t){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],o=e[1],i=e[2],a=e[3];o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[0]-680876936|0)<<7|n>>>25)+o|0)&o|~n&i)+t[1]-389564586|0)<<12|a>>>20)+n|0)&n|~a&o)+t[2]+606105819|0)<<17|i>>>15)+a|0)&a|~i&n)+t[3]-1044525330|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[4]-176418897|0)<<7|n>>>25)+o|0)&o|~n&i)+t[5]+1200080426|0)<<12|a>>>20)+n|0)&n|~a&o)+t[6]-1473231341|0)<<17|i>>>15)+a|0)&a|~i&n)+t[7]-45705983|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[8]+1770035416|0)<<7|n>>>25)+o|0)&o|~n&i)+t[9]-1958414417|0)<<12|a>>>20)+n|0)&n|~a&o)+t[10]-42063|0)<<17|i>>>15)+a|0)&a|~i&n)+t[11]-1990404162|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&i|~o&a)+t[12]+1804603682|0)<<7|n>>>25)+o|0)&o|~n&i)+t[13]-40341101|0)<<12|a>>>20)+n|0)&n|~a&o)+t[14]-1502002290|0)<<17|i>>>15)+a|0)&a|~i&n)+t[15]+1236535329|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[1]-165796510|0)<<5|n>>>27)+o|0)&i|o&~i)+t[6]-1069501632|0)<<9|a>>>23)+n|0)&o|n&~o)+t[11]+643717713|0)<<14|i>>>18)+a|0)&n|a&~n)+t[0]-373897302|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[5]-701558691|0)<<5|n>>>27)+o|0)&i|o&~i)+t[10]+38016083|0)<<9|a>>>23)+n|0)&o|n&~o)+t[15]-660478335|0)<<14|i>>>18)+a|0)&n|a&~n)+t[4]-405537848|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[9]+568446438|0)<<5|n>>>27)+o|0)&i|o&~i)+t[14]-1019803690|0)<<9|a>>>23)+n|0)&o|n&~o)+t[3]-187363961|0)<<14|i>>>18)+a|0)&n|a&~n)+t[8]+1163531501|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o&a|i&~a)+t[13]-1444681467|0)<<5|n>>>27)+o|0)&i|o&~i)+t[2]-51403784|0)<<9|a>>>23)+n|0)&o|n&~o)+t[7]+1735328473|0)<<14|i>>>18)+a|0)&n|a&~n)+t[12]-1926607734|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[5]-378558|0)<<4|n>>>28)+o|0)^o^i)+t[8]-2022574463|0)<<11|a>>>21)+n|0)^n^o)+t[11]+1839030562|0)<<16|i>>>16)+a|0)^a^n)+t[14]-35309556|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[1]-1530992060|0)<<4|n>>>28)+o|0)^o^i)+t[4]+1272893353|0)<<11|a>>>21)+n|0)^n^o)+t[7]-155497632|0)<<16|i>>>16)+a|0)^a^n)+t[10]-1094730640|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[13]+681279174|0)<<4|n>>>28)+o|0)^o^i)+t[0]-358537222|0)<<11|a>>>21)+n|0)^n^o)+t[3]-722521979|0)<<16|i>>>16)+a|0)^a^n)+t[6]+76029189|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((a=((a+=((n=((n+=(o^i^a)+t[9]-640364487|0)<<4|n>>>28)+o|0)^o^i)+t[12]-421815835|0)<<11|a>>>21)+n|0)^n^o)+t[15]+530742520|0)<<16|i>>>16)+a|0)^a^n)+t[2]-995338651|0)<<23|o>>>9)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[0]-198630844|0)<<6|n>>>26)+o|0)|~i))+t[7]+1126891415|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[14]-1416354905|0)<<15|i>>>17)+a|0)|~n))+t[5]-57434055|0)<<21|o>>>11)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[12]+1700485571|0)<<6|n>>>26)+o|0)|~i))+t[3]-1894986606|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[10]-1051523|0)<<15|i>>>17)+a|0)|~n))+t[1]-2054922799|0)<<21|o>>>11)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[8]+1873313359|0)<<6|n>>>26)+o|0)|~i))+t[15]-30611744|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[6]-1560198380|0)<<15|i>>>17)+a|0)|~n))+t[13]+1309151649|0)<<21|o>>>11)+i|0,o=((o+=((a=((a+=(o^((n=((n+=(i^(o|~a))+t[4]-145523070|0)<<6|n>>>26)+o|0)|~i))+t[11]-1120210379|0)<<10|a>>>22)+n|0)^((i=((i+=(n^(a|~o))+t[2]+718787259|0)<<15|i>>>17)+a|0)|~n))+t[9]-343485551|0)<<21|o>>>11)+i|0,e[0]=n+e[0]|0,e[1]=o+e[1]|0,e[2]=i+e[2]|0,e[3]=a+e[3]|0}function o(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function a(e){var t,i,a,r,s,c,l=e.length,p=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=l;t+=64)n(p,o(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)a[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55)for(n(p,a),t=0;t<16;t+=1)a[t]=0;return r=(r=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),c=parseInt(r[1],16)||0,a[14]=s,a[15]=c,n(p,a),p}function r(e){var n,o="";for(n=0;n<4;n+=1)o+=t[e>>8*n+4&15]+t[e>>8*n&15];return o}function s(e){var t;for(t=0;t<e.length;t+=1)e[t]=r(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function l(e){var t,n=[],o=e.length;for(t=0;t<o-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function p(){this.reset()}return s(a("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(t,n){var o,i,a,r,s=this.byteLength,c=e(t,s),l=s;return void 0!==n&&(l=e(n,s)),c>l?new ArrayBuffer(0):(o=l-c,i=new ArrayBuffer(o),a=new Uint8Array(i),r=new Uint8Array(this,c,o),a.set(r),i)}}(),p.prototype.append=function(e){return this.appendBinary(c(e)),this},p.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,o(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},p.prototype.end=function(e){var t,n,o=this._buff,i=o.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)a[t>>2]|=o.charCodeAt(t)<<(t%4<<3);return this._finish(a,i),n=s(this._hash),e&&(n=l(n)),this.reset(),n},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(e,t){var o,i,a,r=t;if(e[r>>2]|=128<<(r%4<<3),r>55)for(n(this._hash,e),r=0;r<16;r+=1)e[r]=0;o=(o=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),a=parseInt(o[1],16)||0,e[14]=i,e[15]=a,n(this._hash,e)},p.hash=function(e,t){return p.hashBinary(c(e),t)},p.hashBinary=function(e,t){var n=s(a(e));return t?l(n):n},(p.ArrayBuffer=function(){this.reset()}).prototype.append=function(e){var t,o,a,r,s=(o=this._buff.buffer,a=e,(r=new Uint8Array(o.byteLength+a.byteLength)).set(new Uint8Array(o)),r.set(new Uint8Array(a),o.byteLength),r),c=s.length;for(this._length+=e.byteLength,t=64;t<=c;t+=64)n(this._hash,i(s.subarray(t-64,t)));return this._buff=t-64<c?new Uint8Array(s.buffer.slice(t-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(e){var t,n,o=this._buff,i=o.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)a[t>>2]|=o[t]<<(t%4<<3);return this._finish(a,i),n=s(this._hash),e&&(n=l(n)),this.reset(),n},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var e=p.prototype.getState.call(this);return e.buff=String.fromCharCode.apply(null,new Uint8Array(e.buff)),e},p.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,o=e.length,i=new ArrayBuffer(o),a=new Uint8Array(i);for(n=0;n<o;n+=1)a[n]=e.charCodeAt(n);return a}(e.buff),p.prototype.setState.call(this,e)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(e,t){var o=s(function(e){var t,o,a,r,s,c,l=e.length,p=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=l;t+=64)n(p,i(e.subarray(t-64,t)));for(o=(e=t-64<l?e.subarray(t-64):new Uint8Array(0)).length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)a[t>>2]|=e[t]<<(t%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55)for(n(p,a),t=0;t<16;t+=1)a[t]=0;return r=(r=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),c=parseInt(r[1],16)||0,a[14]=s,a[15]=c,n(p,a),p}(new Uint8Array(e)));return t?l(o):o},p}()}),Fc=zc;function Dc(e,t=0){return Wc(e,t,2).getUint16(0,!0)}function qc(e,t=0){return Wc(e,t,4).getUint32(0,!0)}function Bc(e,t=0,n=e.byteLength){const o=e.slice(t,t+n);return Hc.decode(new Uint8Array(o))}function Mc(e,t,n=0){if(e.length<t.length+n)return!1;for(const[o,i]of t.entries())if(null!==i&&i!==e[o+n])return!1;return!0}function Wc(e,t,n){const o=e.slice(t,t+n);return new DataView(new Uint8Array(o).buffer)}const Hc=new TextDecoder("utf8"),Gc=[["db","application/vnd.sqlite3",[83,81,76,105,116,101,32,102,111,114,109,97,116,32,51,0]],["woff","font/woff",[119,79,70,70]],["woff2","font/woff2",[119,79,70,50]],["bmp","image/bmp",[66,77]],["gif","image/gif",[71,73,70,56,55,97]],["gif","image/gif",[71,73,70,56,57,97]],["heic","image/heic",[102,116,121,112,104,101,105],{offset:4}],["heic","image/heic",[102,116,121,112,109],{offset:4}],["ico","image/x-icon",[0,0,1,0]],["jpg","image/jpeg",[255,216,255]],["pdf","application/pdf",[37,80,68,70,45]],["png","image/png",[137,80,78,71,13,10,26,10]],["7z","application/x-7z-compressed",[55,122,188,175,39,28]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,0]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,1,0]],["rtf","application/rtf",[123,92,114,116,102,49]],["bz2","application/x-bzip2",[66,90,104]],["gz","application/gzip",[31,139]],["tar","application/x-tar",[117,115,116,97,114,0,48,48],{offset:257}],["tar","application/x-tar",[117,115,116,97,114,32,32,0],{offset:257}],["tif","image/tiff",[73,73,42,0]],["tiff","image/tiff",[77,77,0,42]],["zip","application/zip",[80,75,3,4],{exact:!1}],["zip","application/zip",[80,75,5,6]],["mp3","audio/mp3",[255,251]],["mp3","audio/mp3",[255,243]],["mp3","audio/mp3",[255,242]],["mp3","audio/mp3",[73,68,51]],["mp4","video/mp4",[102,116,121,112,105,115,111,109],{offset:4}],["avi","video/x-msvideo",[82,73,70,70,null,null,null,null,65,86,73,32]],["wav","audio/wav",[82,73,70,70,null,null,null,null,87,65,86,69]],["ogx","application/ogg",[79,103,103,83],{exact:!1},[["oga","audio/ogg",[127,70,76,65,67],{offset:28}],["ogg","audio/ogg",[1,118,111,114,98,105,115],{offset:28}],["ogm","video/ogg",[1,118,105,100,101,111,0],{offset:28}],["ogv","video/ogg",[128,116,104,101,111,114,97],{offset:28}]]],["webp","image/webp",[82,73,70,70,null,null,null,null,87,69,66,80]],["psd","image/vnd.adobe.photoshop",[56,66,80,83]],["flac","audio/x-flac",[102,76,97,67]],["wasm","application/wasm",[0,97,115,109]],["deb","application/x-deb",[33,60,97,114,99,104,62,10]],["exe","application/x-msdownload",[77,90]],["exe","application/x-msdownload",[90,77]],["class","application/java-vm",[202,254,186,190]]];function Jc(e){return e.flatMap(([e,t,n,o={},i=[]])=>[[e,t,n,o],...i])}function Vc(e,t){const n=Dc(e,26),o=Bc(e,30,n),[i]=o.split("/"),a=o.endsWith(".xml");return"META-INF"===i?{ext:"jar",mime:"application/java-archive"}:"ppt"===i&&a?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:"word"===i&&a?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:"xl"===i&&a?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:"mimetype"===i?function(e,t){const n=qc(e,18),o=qc(e,22),i=Dc(e,28);if(n===o){const o=Bc(e,30+t+i,n);if("application/vnd.oasis.opendocument.presentation"===o)return{ext:"odp",mime:o};if("application/vnd.oasis.opendocument.spreadsheet"===o)return{ext:"ods",mime:o};if("application/vnd.oasis.opendocument.text"===o)return{ext:"odt",mime:o};if("application/epub+zip"===o)return{ext:"epub",mime:o}}}(e,n)??t:t}const Kc=function(e){return Jc(e).map(([e,t,n,{offset:o=0}={}])=>n.length+o).reduce((e,t)=>t>e?t:e,0)}(Gc);function Yc(e,t){for(const[n,o,i,{exact:a=!0,offset:r=0}={},s=[]]of t)if(Mc(e,i,r)){if("zip"===n&&!a)return Vc(e.buffer,{ext:n,mime:o});if(!a&&s.length)for(const[t,n,o,{offset:i=0}={}]of s)if(Mc(e,o,i))return{ext:t,mime:n};return{ext:n,mime:o}}}function Zc(e,t,n=void 0){const o=function(e,t,n){let o=0;for(;;){let t=e.indexOf("\\",o);if(-1===t)break;o=t+1,e=e.replace("\\","/")}return e}(e).split("/").pop()||e,i=(null==n?void 0:n.type)||Qc(t,e),a=new File([t],o,{type:i});return a.path=e,a}const Xc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Qc(e,t=void 0){const n=function(e,{extra:t=!1,hint:n}={}){const o=new Uint8Array(e.slice(0,Kc));if(n){const e=function(e,{ext:t,mime:n}){return t||n?Jc(e).filter(e=>e[0]===t||e[1]===n):[]}(Gc,n);if(e.length>0){const t=Yc(o,e);if(void 0!==t)return t}}return Yc(o,Gc)||(t?function(e){return function(e){try{const t=Bc(e);if(!function(e){for(let t=0;t<e.length;t++)try{const n=e.charCodeAt(t);if(65533===n||n<=8)return!1}catch{return!1}return!0}(t))return;try{return JSON.parse(t),{ext:"json",mime:"application/json"}}catch{return{ext:"txt",mime:"text/plain"}}}catch{return}}(e)}(e):void 0)}(e);if(n)return n.mime;const o=new Uint8Array(e).subarray(0,4);let i="";for(var a=0;a<o.length;a++)i+=o[a].toString(16);let r="unknown";switch(i){case"676c5446":r="model/gltf-binary";break;case"89504e47":r="image/png";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":r="image/jpeg";break;default:r="unknown"}return"unknown"===r&&"string"==typeof t&&(r=function(e){const t=e.toLowerCase();let n="";return t.endsWith(".html")||t.endsWith(".html.gz")||t.endsWith(".html.br")?n="text/html":t.endsWith(".js")||t.endsWith(".js.gz")||t.endsWith(".js.br")||t.endsWith(".mjs")||t.endsWith(".mjs.gz")||t.endsWith(".mjs.br")||t.endsWith(".cjs")||t.endsWith(".cjs.gz")||t.endsWith(".cjs.br")?n="application/javascript":t.endsWith(".wasm")?n="application/wasm":t.endsWith(".css")||t.endsWith(".css.gz")||t.endsWith(".css.br")?n="text/css":t.endsWith(".json")?n="application/json":t.endsWith(".txt")?n="text/plain":t.endsWith(".md")?n="text/markdown":t.endsWith(".yaml")||t.endsWith(".yml")?n="application/yaml":t.endsWith(".bin")?n="application/octet-stream":t.endsWith(".png")?n="image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?n="image/jpeg":t.endsWith(".gif")?n="image/gif":t.endsWith(".webp")?n="image/webp":t.endsWith(".avif")?n="image/avif":t.endsWith(".bmp")?n="image/bmp":t.endsWith(".tiff")||t.endsWith(".tif")?n="image/tiff":t.endsWith(".ico")?n="image/x-icon":t.endsWith(".svg")?n="image/svg+xml":t.endsWith(".xml")?n="application/xml":t.endsWith(".hdr")?n="image/vnd.radiance":t.endsWith(".exr")?n="image/x-exr":t.endsWith(".ktx2")?n="image/ktx2":t.endsWith(".ktx")?n="image/ktx":t.endsWith(".dds")?n="image/vnd-ms.dds":t.endsWith(".ogg")?n="audio/ogg":t.endsWith(".mp3")?n="audio/mpeg":t.endsWith(".wav")?n="audio/wave":t.endsWith(".flac")?n="audio/flac":t.endsWith(".m4a")?n="audio/mp4":t.endsWith(".aac")?n="audio/aac":t.endsWith(".mp4")?n="video/mp4":t.endsWith(".webm")?n="video/webm":t.endsWith(".mov")?n="video/quicktime":t.endsWith(".woff2")?n="font/woff2":t.endsWith(".woff")?n="font/woff":t.endsWith(".ttf")?n="font/ttf":t.endsWith(".otf")?n="font/otf":t.endsWith(".zip")?n="application/zip":t.endsWith(".glb")?n="model/gltf-binary":t.endsWith(".gltf")?n="model/gltf+json":t.endsWith(".vrm")?n="model/gltf-binary":t.endsWith(".usdz")?n="model/vnd.usdz+zip":t.endsWith(".usda")?n="model/vnd.usd-usda":t.endsWith(".usdc")?n="model/vnd.usd-usdc":t.endsWith(".usd")?n="model/vnd.usd-usd":t.endsWith(".mtl")?n="model/mtl":t.endsWith(".obj")?n="model/obj":t.endsWith(".fbx")?n="model/vnd.autodesk.fbx":t.endsWith(".stl")?n="model/stl":t.endsWith(".mtlx")?n="application/materialx+xml":t.endsWith(".ply")?n="model/ply":t.endsWith(".dae")?n="model/vnd.collada+xml":t.endsWith(".3mf")?n="model/3mf":(t.endsWith(".splat")||t.endsWith(".spz")||t.endsWith(".ksplat")||t.endsWith(".sog")||t.endsWith(".sogs"))&&(n="application/octet-stream"),n}(t)),r}function el(e){return"string"==typeof e&&0!==e.length&&e.toLowerCase().endsWith(".exr")}function tl(e){if("string"!=typeof e||0===e.length)return!1;const t=e.toLowerCase();return t.endsWith(".hdr")||t.endsWith(".hdri")}function nl(e){return"string"==typeof e&&0!==e.length&&/\.pmrem(\d+x\d+)?\.ktx2$/i.test(e)}function ol(e,t){const n=e.toLowerCase();return"application/gzip"===t||"application/brotli"===t?(n.endsWith(".html.gz")||n.endsWith(".html.br")?(t="text/html",e=e.substring(0,e.length-3)):n.endsWith(".js.gz")||n.endsWith(".js.br")||n.endsWith(".mjs.gz")||n.endsWith(".mjs.br")||n.endsWith(".cjs.gz")||n.endsWith(".cjs.br")?(t="application/javascript",e=e.substring(0,e.length-3)):n.endsWith(".css.gz")||n.endsWith(".css.br")?(t="text/css",e=e.substring(0,e.length-3)):n.endsWith(".json.gz")||n.endsWith(".json.br")?(t="text/json",e=e.substring(0,e.length-3)):n.endsWith(".txt.gz")||n.endsWith(".txt.br")?(t="text/plain",e=e.substring(0,e.length-3)):n.endsWith(".wasm.gz")||n.endsWith(".wasm.br")?(t="application/wasm",e=e.substring(0,e.length-3)):n.endsWith(".bin.gz")||n.endsWith(".bin.br")?(t="application/octet-stream",e=e.substring(0,e.length-3)):n.endsWith(".png.gz")||n.endsWith(".png.br")?(t="image/png",e=e.substring(0,e.length-3)):n.endsWith(".jpg.gz")||n.endsWith(".jpg.br")||n.endsWith(".jpeg.gz")||n.endsWith(".jpeg.br")?(t="image/jpeg",e=e.substring(0,e.length-3)):n.endsWith(".gif.gz")||n.endsWith(".gif.br")?(t="image/gif",e=e.substring(0,e.length-3)):n.endsWith(".webp.gz")||n.endsWith(".webp.br")?(t="image/webp",e=e.substring(0,e.length-3)):n.endsWith(".svg.gz")||n.endsWith(".svg.br")?(t="image/svg+xml",e=e.substring(0,e.length-3)):n.endsWith(".xml.gz")||n.endsWith(".xml.br")?(t="application/xml",e=e.substring(0,e.length-3)):n.endsWith(".ico.gz")||n.endsWith(".ico.br")?(t="image/x-icon",e=e.substring(0,e.length-3)):n.endsWith(".avif.gz")||n.endsWith(".avif.br")?(t="image/avif",e=e.substring(0,e.length-3)):n.endsWith(".bmp.gz")||n.endsWith(".bmp.br")?(t="image/bmp",e=e.substring(0,e.length-3)):n.endsWith(".tiff.gz")||n.endsWith(".tiff.br")||n.endsWith(".tif.gz")||n.endsWith(".tif.br")?(t="image/tiff",e=e.substring(0,e.length-3)):n.endsWith(".hdr.gz")||n.endsWith(".hdr.br")?(t="image/vnd.radiance",e=e.substring(0,e.length-3)):n.endsWith(".exr.gz")||n.endsWith(".exr.br")?(t="image/x-exr",e=e.substring(0,e.length-3)):n.endsWith(".ktx2.gz")||n.endsWith(".ktx2.br")?(t="image/ktx2",e=e.substring(0,e.length-3)):n.endsWith(".ktx.gz")||n.endsWith(".ktx.br")?(t="image/ktx",e=e.substring(0,e.length-3)):n.endsWith(".dds.gz")||n.endsWith(".dds.br")?(t="image/vnd-ms.dds",e=e.substring(0,e.length-3)):n.endsWith(".webm.gz")||n.endsWith(".webm.br")?(t="video/webm",e=e.substring(0,e.length-3)):n.endsWith(".mp4.gz")||n.endsWith(".mp4.br")?(t="video/mp4",e=e.substring(0,e.length-3)):n.endsWith(".mov.gz")||n.endsWith(".mov.br")?(t="video/quicktime",e=e.substring(0,e.length-3)):n.endsWith(".mp3.gz")||n.endsWith(".mp3.br")?(t="audio/mpeg",e=e.substring(0,e.length-3)):n.endsWith(".wav.gz")||n.endsWith(".wav.br")?(t="audio/wave",e=e.substring(0,e.length-3)):n.endsWith(".ogg.gz")||n.endsWith(".ogg.br")?(t="audio/ogg",e=e.substring(0,e.length-3)):n.endsWith(".flac.gz")||n.endsWith(".flac.br")?(t="audio/flac",e=e.substring(0,e.length-3)):n.endsWith(".m4a.gz")||n.endsWith(".m4a.br")?(t="audio/mp4",e=e.substring(0,e.length-3)):n.endsWith(".aac.gz")||n.endsWith(".aac.br")?(t="audio/aac",e=e.substring(0,e.length-3)):n.endsWith(".woff2.gz")||n.endsWith(".woff2.br")?(t="font/woff2",e=e.substring(0,e.length-3)):n.endsWith(".woff.gz")||n.endsWith(".woff.br")?(t="font/woff",e=e.substring(0,e.length-3)):n.endsWith(".ttf.gz")||n.endsWith(".ttf.br")?(t="font/ttf",e=e.substring(0,e.length-3)):n.endsWith(".otf.gz")||n.endsWith(".otf.br")?(t="font/otf",e=e.substring(0,e.length-3)):n.endsWith(".md.gz")||n.endsWith(".md.br")?(t="text/markdown",e=e.substring(0,e.length-3)):n.endsWith(".yaml.gz")||n.endsWith(".yaml.br")||n.endsWith(".yml.gz")||n.endsWith(".yml.br")?(t="application/yaml",e=e.substring(0,e.length-3)):n.endsWith(".zip.gz")||n.endsWith(".zip.br")?(t="application/zip",e=e.substring(0,e.length-3)):n.endsWith(".glb.gz")||n.endsWith(".glb.br")?(t="model/gltf-binary",e=e.substring(0,e.length-3)):n.endsWith(".gltf.gz")||n.endsWith(".gltf.br")?(t="model/gltf+json",e=e.substring(0,e.length-3)):n.endsWith(".vrm.gz")||n.endsWith(".vrm.br")?(t="model/gltf-binary",e=e.substring(0,e.length-3)):n.endsWith(".usdz.gz")||n.endsWith(".usdz.br")?(t="model/vnd.usdz+zip",e=e.substring(0,e.length-3)):n.endsWith(".usda.gz")||n.endsWith(".usda.br")?(t="model/vnd.usd-usda",e=e.substring(0,e.length-3)):n.endsWith(".usdc.gz")||n.endsWith(".usdc.br")?(t="model/vnd.usd-usdc",e=e.substring(0,e.length-3)):n.endsWith(".usd.gz")||n.endsWith(".usd.br")?(t="model/vnd.usd-usd",e=e.substring(0,e.length-3)):n.endsWith(".obj.gz")||n.endsWith(".obj.br")?(t="model/obj",e=e.substring(0,e.length-3)):n.endsWith(".mtl.gz")||n.endsWith(".mtl.br")?(t="model/mtl",e=e.substring(0,e.length-3)):n.endsWith(".stl.gz")||n.endsWith(".stl.br")?(t="model/stl",e=e.substring(0,e.length-3)):n.endsWith(".mtlx.gz")||n.endsWith(".mtlx.br")?(t="application/materialx+xml",e=e.substring(0,e.length-3)):n.endsWith(".ply.gz")||n.endsWith(".ply.br")?(t="model/ply",e=e.substring(0,e.length-3)):n.endsWith(".dae.gz")||n.endsWith(".dae.br")?(t="model/vnd.collada+xml",e=e.substring(0,e.length-3)):n.endsWith(".3mf.gz")||n.endsWith(".3mf.br")?(t="model/3mf",e=e.substring(0,e.length-3)):(n.endsWith(".splat.gz")||n.endsWith(".splat.br")||n.endsWith(".spz.gz")||n.endsWith(".spz.br")||n.endsWith(".ksplat.gz")||n.endsWith(".ksplat.br")||n.endsWith(".sog.gz")||n.endsWith(".sog.br")||n.endsWith(".sogs.gz")||n.endsWith(".sogs.br"))&&(t="application/octet-stream",e=e.substring(0,e.length-3)),{filename:e,mimetype:t}):null}function il(e,t=void 0,n=!0){const o=Math.abs(e);if(o>=1099511627776){let o=n?" TB":"";return(e/1099511627776).toFixed(void 0===t?2:t)+o}if(o>=1073741824){let o=n?" GB":"";return(e/1073741824).toFixed(void 0===t?2:t)+o}if(o>=1048576){let o=n?" MB":"";return(e/1048576).toFixed(void 0===t?1:t)+o}if(o>=1024){let o=n?" KB":"";return(e/1024).toFixed(void 0===t?0:t)+o}let i=n?" B":"";return e.toFixed(0)+i}function al(e){return e.split("/").reduce((e,t)=>("."===t||(".."===t?e.pop():null!=t&&t.length&&e.push(t)),e),[]).join("/")}const rl=1179937895,sl=1313821514,cl=12,ll=8;function pl(e,t){let n=t;for(;n<e.length&&0!==e[n];)n++;return n>=e.length?null:new TextDecoder("latin1").decode(e.subarray(t,n))}async function ul(e){return new Promise(t=>setTimeout(t,e))}function dl(e,t,n=void 0){e instanceof Date&&(e=e.getTime()),t instanceof Date&&(t=t.getTime());let o=t-e,i=o>0;const a=!1!==(null==n?void 0:n.prefix),r=!1!==(null==n?void 0:n.suffix);let s="",c="";o<0&&(o=-o);const l=Math.floor(o/1e3),p=Math.floor(l/60),u=Math.floor(p/60),d=Math.floor(u/24);if(null!=(null==n?void 0:n.limitInDays)&&d>=n.limitInDays)return a&&(s="on "),`${s}${new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}${c}`;s=a?i?"":"in ":"",c=r&&i?" ago":"";const m=Math.floor(d/30),f=Math.floor(m/12);return 1===f?`${s}1 year${c}`:f>1?`${s}${Math.floor(f)} years${c}`:1===m?`${s}1 month${c}`:m>1?`${s}${Math.floor(m)} months${c}`:1===d?i&&null!=n&&n.allowSimple?"yesterday":`${s}1 day${c}`:d>1?`${s}${Math.floor(d)} days${c}`:1===u?`${s}1 hour${c}`:u>1?`${s}${Math.floor(u)} hours${c}`:1===p?`${s}1 minute${c}`:p>1?`${s}${Math.floor(p)} minutes${c}`:null!=n&&n.allowSimple&&l<10?"just now":`${s}${l.toFixed(0)} seconds${c}`}const ml=/^image_(?<image_lod>\d+)_|^mesh_lod_(?<mesh_lod>\d+)_/;function fl(e){return e.includes("\\u")?JSON.parse(`"${e}"`):decodeURIComponent(e)}function hl(e){let t=null,n="";const o=e.filter(e=>"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase());if(1===o.length)return t=o[0],t;const i=e.filter(e=>e.name.toLowerCase().endsWith(".html")||e.name.toLowerCase().endsWith(".htm")||e.name.toLowerCase().endsWith(".html.gz")||e.name.toLowerCase().endsWith(".html.br"));if(1===i.length)return i[0];if(i.length>1){const e=new Map;for(const t of i){const n=t.path.split("/");let o=e.get(n.length);o||(o=[],e.set(n.length,o)),o.push(t)}const o=Array.from(e.keys()).sort((e,t)=>e-t);if(o.length>0)for(const n of o){const o=e.get(n);if(!o)continue;const i=o.find(e=>"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase());return i?(t=i,t):(t=o[0],t)}return n="Invalid upload: Multiple HTML files found but could not determine root.",console.error(n,i.map(e=>e.path||e.name)),{error:n}}const a=e.filter(e=>e.name.toLowerCase().endsWith(".glb")||e.name.toLowerCase().endsWith(".gltf")||e.name.toLowerCase().endsWith(".vrm"));if(a.length>1){const e=function(e){const t=new Array,n=/(mesh_lod|image)_\d_(.{1,50})/;for(const o of e){if(n.test(o.name))continue;const e=o.name.toLowerCase();(e.endsWith(".gltf")||e.endsWith(".vrm")||e.endsWith(".glb"))&&t.push(o)}return 1==t.length?t[0]:null!=(o=bl(t)[0])?o:null;var o}(a);return e?(t=e,t):(n="Invalid upload: Multiple glb/glTF/vrm files found. This is currently not supported.",console.error(n,a.map(e=>e.path||e.name)),{error:n})}if(1===a.length)return t=a[0],t;const r=e.filter(e=>e.name.toLowerCase().endsWith(".usdz")||e.name.toLowerCase().endsWith(".usd")||e.name.toLowerCase().endsWith(".usda")||e.name.toLowerCase().endsWith(".usdc"));if(r.length>=1)return t=function(e){var t;const n=bl(e),o=["usda","usdz","usd","usdc"];for(const e of o){const t=n.find(t=>t.name.toLowerCase().endsWith(`.${e}`));if(t)return t}return null!=(t=n[0])?t:null}(r),t;const s=e.filter(e=>e.name.toLowerCase().endsWith(".fbx"));if(s.length>1)return n="Invalid upload: Multiple fbx files found. This is currently not supported.",console.error(n,s),{error:n};if(1===s.length)return t=s[0],t;const c=e.filter(e=>e.name.toLowerCase().endsWith(".obj"));if(c.length>1)return n="Invalid upload: Multiple obj files found. This is currently not supported.",console.error(n,c),{error:n};if(1===c.length)return t=c[0],t;const l=e.filter(e=>e.name.toLowerCase().endsWith(".stl"));if(l.length>1)return n="Invalid upload: Multiple stl files found. This is currently not supported.",console.error(n,l),{error:n};if(1===l.length)return t=l[0],t;const p=e.filter(e=>{const t=e.name.toLowerCase();return t.endsWith(".ply")||t.endsWith(".splat")||t.endsWith(".spz")||t.endsWith(".ksplat")||t.endsWith(".sog")||t.endsWith(".sogs")});if(p.length>1)return n="Invalid upload: Multiple splat files found. Upload them as separate content items.",console.error(n,p.map(e=>e.path||e.name)),{error:n};if(1===p.length)return t=p[0],t;if(1===e.length&&!e[0].arrayBuffer&&e[0].path.toLowerCase().startsWith("http"))return t=e[0],t;const u=e.filter(e=>e.name.toLowerCase().endsWith("package.json"));if(1===u.length)return t=u[0],t;if(u.length>1)return n="Invalid upload: Multiple package.json files found. This is currently not supported.",console.error(n,u),{error:n};const d=e.filter(e=>e.name.toLowerCase().endsWith(".mtlx"));if(d.length>1)return n="Invalid upload: Multiple mtlx files found. This is currently not supported.",console.error(n,d),{error:n};if(1===d.length)return t=d[0],t;const m=e.filter(e=>{const t=e.name.toLowerCase();return el(t)||tl(t)||nl(t)});return m.length>1?(n="Invalid upload: Multiple HDRI files found. Upload them as separate content items.",console.error(n,m.map(e=>e.path||e.name)),{error:n}):1===m.length?(t=m[0],t):t||{error:"No supported file to upload found..."}}const gl=new Set(["glb","gltf","vrm"]),vl=new Set(["fbx","obj","stl","usd","usda","usdz"]);function bl(e){let t=Infinity,n=[];for(const o of e){const e=o.path.split("/").length;e<t?(t=e,n=[o]):e===t&&n.push(o)}return n}class xl{constructor(e,t){this.totalFiles=e,this.estimatedTotalSize=t,this.uploadedSize=0,this.startTime=Date.now(),this.lastUpdateTime=this.startTime,this.lastUploadedSize=0,this.speedEMA=null,this.emaFactor=.1,this.smoothedRemainingTime=null,this.recentSpeeds=new Array,this.maxRecentSpeeds=20,this.initialEstimateThreshold=.05}updateProgress(e){const t=Date.now(),n=(t-this.lastUpdateTime)/1e3,o=e-this.lastUploadedSize;if(this.uploadedSize=e,n>0&&o>0){this.recentSpeeds.push(o/n),this.recentSpeeds.length>this.maxRecentSpeeds&&this.recentSpeeds.shift();const e=this.recentSpeeds.reduce((e,t)=>e+t,0)/this.recentSpeeds.length;this.speedEMA=null===this.speedEMA?e:this.emaFactor*e+(1-this.emaFactor)*this.speedEMA}this.lastUpdateTime=t,this.lastUploadedSize=e;const i=this.uploadedSize/this.estimatedTotalSize,a=(t-this.startTime)/1e3,r=this.speedEMA&&this.speedEMA>0?this.speedEMA:this.uploadedSize/a;let s;if(s=r>0?(this.estimatedTotalSize-this.uploadedSize)/r:Infinity,i>=this.initialEstimateThreshold)if(null===this.smoothedRemainingTime)this.smoothedRemainingTime=s;else{const e=.1;this.smoothedRemainingTime=(1-e)*this.smoothedRemainingTime+e*s}else this.smoothedRemainingTime=a/i-a;return this.smoothedRemainingTime=Math.max(this.smoothedRemainingTime,(this.estimatedTotalSize-this.uploadedSize)/r),{progress:100*i,estimatedTimeRemaining:Math.round(this.smoothedRemainingTime),estimatedTimeRemainingString:this.smoothedRemainingTime>3?this.__formatTime(this.smoothedRemainingTime):"few seconds"}}__formatTime(e){if(!isFinite(e))return"Calculating...";if(e<60)return`${Math.round(e)}sec`;const t=Math.floor(e/60);if(t<60)return`${t}min`;const n=Math.floor(t/60);if(n<24)return`${n}h ${t%60}min`;const o=Math.floor(n/24);return o<=10?`${o}d`:"Calculating..."}}const yl=15e3;function wl(e,t,n={setTimeout:setTimeout,clearTimeout:clearTimeout}){return function(o,i){const a=e.call(this,o,i);if(!a||"function"!=typeof a.once)return a;const r=n.setTimeout(()=>{const e=new Error(`connect timeout: no connection within ${t/1e3}s`);e.code="ETIMEDOUT",a.destroy(e)},t),s=()=>n.clearTimeout(r);return a.once("connect",s),a.once("secureConnect",s),a.once("error",s),a.once("close",s),a}}let _l;async function jl(e={}){var t,n;if(!(null!=(t=e.isNode)?t:"undefined"!=typeof process&&null!=(n=process.versions)&&n.node))return{};if(_l)return _l;const[{default:o},{default:i}]=await Promise.all([import("node:http"),import("node:https")]),a=new o.Agent({keepAlive:!0}),r=new i.Agent({keepAlive:!0});for(const e of[a,r])e.createConnection=wl(e.createConnection,yl);return _l={httpAgent:a,httpsAgent:r},_l}async function kl(e){const t=await import("./pako.esm-01431bd2.js"),n=await e.arrayBuffer(),o=t.gzip(new Uint8Array(n)).buffer.slice(0);if(o.byteLength>51200&&o.byteLength>=n.byteLength){if(n.byteLength>0)return null}else if(!(o instanceof ArrayBuffer))return console.error("gzipCompress: Invalid ArrayBuffer"),{error:`Gzip compressing failed for "${e.name}" (unexpected result)`};return Zc(`${"path"in e?e.path:e.name}.gz`,o,{type:"application/gzip"})}const Sl=16777216;async function El(e,t,n=void 0){const o=async function(e,t,n){var o,i,a,r,s,c,l,p,u,d,m,f,h,g,v,b,x,y,w,_;let{files:j,skipped:k}=function(e){const t=[];return{files:e.filter(e=>{const n=e.name||"";return!(!n||n.endsWith("/"))||(t.push({name:n,reason:"directory-entry"}),!1)}),skipped:t}}(t.files);for(const e of k)console.warn(`[upload] Skipping directory entry: "${e.name}"`);t.files=j;const S=(null==(o=n)?void 0:o.loglevel)||"none";if(!j.length)return"none"!=S&&console.error("No files to upload"),{success:!1,error:"No files to upload"};if(!t.entrypoint){const e=hl(j);if(null==e)return{success:!1,error:"No entrypoint file found"};if("object"==typeof e&&"error"in e)return{success:!1,error:e.error};"info"===S&&console.log("Entrypoint: "+e.name),t.entrypoint=e}t.entrypoint&&!j.includes(t.entrypoint)&&j.push(t.entrypoint);const E=await async function(e){if(e.length>5e3)return{success:!1,error:"Too many files. Maximum filecount is 5000"};let t=0,n=0,o=0,i=0;for(let c=e.length-1;c>=0;c--){const l=e[c];if(t+=l.size,t>1073741824)return{success:!1,error:`Total file size exceeds limit of ${1024..toFixed(0)} MB. Please reduce the size of your upload.`};const p=l.name.toLocaleLowerCase();if(".ds_store"!==p){if(p.endsWith(".gltf")?o++:p.endsWith(".glb")?(s=p)&&ml.test(s)||i++:p.endsWith(".vrm")&&n++,p.endsWith(".gltf")){var a;o+=1,console.log(`Found glTF file ${l.name}. Will check if all dependencies are available\n`,e);const t=await l.text(),n=t.matchAll(/"uri"\s*:\s*"(?<value>.*?)"/g);if(!n)continue;const i=JSON.parse(t);if("2.0"!==i.asset.version)return console.warn("⚠ glTF version is not 2.0. This is currently not supported."),{success:!1,error:`glTF version ${i.asset.version} is unsupported.Please use glTF 2.0.`};const s=null==(a=l.path)?void 0:a.split("/"),c=s.splice(0,s.length-1).join("/");for(const t of n){var r;const n=null==(r=t.groups)?void 0:r.value;if(n){let t=!1;if(n.startsWith("http://")||n.startsWith("https://")||n.startsWith("www.")){console.log(`✅ Found remote dependency ${n} `);break}if(n.startsWith("data:")){console.log(`✅ Found embedded dependency ${n} `);break}{const o=al(`${c}/${fl(n)}`);console.log('❓ Check if local dependency exists "'+o+'"');for(const n of e){if(n.webkitRelativePath===o||n.name==o){t=!0,console.log(`✅ Found dependency in name or webkit: ${n.name} || ${n.webkitRelativePath} `);break}if(n.path===o){t=!0,console.log(`✅ Found dependency in path: ${n.path} `);break}}}if(!t)return console.warn("⚠ Missing dependency "+n,c),{success:!1,error:"Missing resource: "+n}}}}}else e.splice(c,1)}var s;return{success:!0,vrm_count:n,gltf_count:o,glb_count:i}}(j);if("error"in E)return{success:!1,error:E.error||"Failed to validate files"};if(null!=(i=t.entrypoint)&&i.name.endsWith(".htm")||null!=(a=t.entrypoint)&&a.name.endsWith(".html")||null!=(r=t.entrypoint)&&r.name.endsWith(".html.gz")||null!=(s=t.entrypoint)&&s.name.endsWith(".html.br"))n||(n={}),n.type="deployment";else if(E.vrm_count>10)return{success:!1,error:"Multiple model files found - this is not supported for asset uploads. Please upload a single model file only."};const $=await async function(e,t={}){const{raw:n=!1,loglevel:o="none",entrypoint:i=null}=t,a=(...e)=>{"none"!==o&&console.log(...e)};if(n)return"none"!==o&&console.warn("Raw upload - skipping gzip compression of files"),{files:e,entrypoint:i};const r=new Set(e.map(Il)),s=[];let c=i;for(const t of e){const n=Il(t),p=t.name.toLowerCase();if(!$l.some(e=>p.endsWith(e))){s.push(t);continue}const u=Tl.find(e=>r.has(`${n}${e}`));if(u){var l;a(`Skipping gzip compression, using pre-compressed file: ${n}${u}`),i===t&&(c=null!=(l=e.find(e=>Il(e)===`${n}${u}`))?l:c);continue}a(`gZip compressing file: ${t.name}`);const d=await kl(t).catch(e=>({error:`Error compressing ${t.name}: ${e.message}`}));if(null===d){"none"!==o&&console.error(`Did not compress file: ${t.name}`),s.push(t);continue}if("error"in d)return{files:e,entrypoint:i,error:d.error};if(!d)return{files:e,entrypoint:i,error:`Failed to compress ${t.name}`};const m=i===t;s.push(d),m&&(c=d),a(`gZip compressed file: ${t.name} ${m?"(entrypoint)":""}`)}return{files:s,entrypoint:c}}(j,{raw:t.raw,loglevel:null!=(c=null==(l=n)?void 0:l.loglevel)?c:S,entrypoint:t.entrypoint});if($.error)return{success:!1,error:$.error,status:500};j=$.files,t.files=j,t.entrypoint=$.entrypoint,j.sort((e,t)=>e.name.includes(".needle")&&!t.name.includes(".needle")?-1:!e.name.includes(".needle")&&t.name.includes(".needle")?1:0);const{baseUrl:T,authToken:I}=e,O="Bearer "+I,A={...ht(e),triggered_by:t.triggered_by,filename:`${encodeURIComponent(t.entrypoint.name)}`,"total-files":j.length.toString(),"total-files-size":j.reduce((e,t)=>e+t.size,0).toString()};null!=(p=n)&&p.content_id&&(A.content_id=n.content_id),null!=(u=n)&&u.type&&(A.type=n.type),null!=(d=n)&&d.name&&(A.name=encodeURIComponent(n.name)),null!=(m=n)&&m.parent_job_id&&(A.parent_job_id=n.parent_job_id);const C={entrypoint:(null==(f=t.entrypoint)?void 0:f.path)||(null==(h=t.entrypoint)?void 0:h.name),files:[]};null!=(g=n)&&g.content_type&&(C.content_type=n.content_type);const R={outputs:[C],...t.metadata?{metadata:t.metadata}:{},...!1===(null==(v=n)?void 0:v.optimizations)?{optimizations:!1}:{},...!0===(null==(b=n)?void 0:b.verify)?{verify:!0}:{}},N=[];for(let e=0;e<j.length;e++){var P,U,L;const t=j[e];let o=t.path||t.webkitRelativePath||t.name;if(null!=(P=o)&&P.includes(":"))throw new Error(`Invalid filename: ${o}`);let i=await t.arrayBuffer();const a=t.size;let r=t.type;if(null!=(U=r)&&U.length&&"unknown"!==r.toLowerCase()||(r=Qc(i,o)),"deployment"===(null==(L=n)?void 0:L.type)){const e=ol(o,r);e&&(o=e.filename,r=e.mimetype)}const s=function(e){let t="";for(let n=0;n<e.length;n+=3){const o=e.charCodeAt(n),i=n+1<e.length?e.charCodeAt(n+1):0,a=n+2<e.length?e.charCodeAt(n+2):0;t+=Xc[o>>2]+Xc[(3&o)<<4|i>>4]+(n+1<e.length?Xc[(15&i)<<2|a>>6]:"=")+(n+2<e.length?Xc[63&a]:"=")}return t}(Fc.ArrayBuffer.hash(i,!0));N[e]=i,C.files[e]={filename:o,content_type:r,content_length:a,content_md5:s}}if("deployment"!==(null==(x=n)?void 0:x.type)){const e=t.entrypoint.name.toLowerCase();let o;if(e.endsWith(".glb")||e.endsWith(".gltf"))try{const n=N[j.indexOf(t.entrypoint)];o=function(e){return function(e){if(!e)return!1;const t=!e.nodes||0===e.nodes.length,n=!e.meshes||0===e.meshes.length,o=Array.isArray(e.materials)&&1===e.materials.length;return t&&n&&o}(e)?"material":"3d-asset"}(e.endsWith(".glb")?function(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<cl+ll)throw new Error("Buffer too small to be a GLB");const n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==rl)throw new Error("Not a GLB (magic mismatch)");const o=n.getUint32(cl,!0);if(n.getUint32(cl+4,!0)!==sl)throw new Error("First chunk is not JSON");const i=cl+ll,a=i+o;if(a>t.byteLength)throw new Error("JSON chunk exceeds buffer length");const r=t.subarray(i,a),s=(new TextDecoder).decode(r);return JSON.parse(s)}(n):JSON.parse((new TextDecoder).decode(n)))}catch(e){return{success:!1,error:`Failed to inspect "${t.entrypoint.name}": ${e.message}`}}else e.endsWith(".mtlx")?o="material":(el(e)||tl(e)||nl(e))&&(o="hdri");if(o){var z;if(null!=(z=n)&&z.content_type&&n.content_type!==o)return{success:!1,error:`Content type mismatch: "${t.entrypoint.name}" contains "${o}" but "${n.content_type}" was requested.`};C.content_type=o}}try{const e=await async function(e){var t,n,o,i,a;if(!e||"function"!=typeof e.slice||"number"!=typeof e.size)return null;const r=Math.min(e.size,65536);if(r<=0)return null;let s;try{const t=await e.slice(0,r).arrayBuffer();s=new Uint8Array(t)}catch{return null}return null!=(t=null!=(n=null!=(o=null!=(i=null!=(a=function(e){if(e.length<24)return null;if(137!==e[0]||80!==e[1]||78!==e[2]||71!==e[3])return null;if(13!==e[4]||10!==e[5]||26!==e[6]||10!==e[7])return null;const t=new DataView(e.buffer,e.byteOffset),n=t.getUint32(16,!1),o=t.getUint32(20,!1);return n&&o?{width:n,height:o}:null}(s))?a:function(e){if(e.length<28)return null;const t=[171,75,84,88,32,50,48,187,13,10,26,10];for(let n=0;n<t.length;n++)if(e[n]!==t[n])return null;const n=new DataView(e.buffer,e.byteOffset),o=n.getUint32(20,!0),i=n.getUint32(24,!0);return o&&i?{width:o,height:i}:null}(s))?i:function(e){if(e.length<16)return null;if(118!==e[0]||47!==e[1]||49!==e[2]||1!==e[3])return null;const t=new DataView(e.buffer,e.byteOffset);let n=8;for(;n<e.length;){const o=pl(e,n);if(null===o)return null;if(0===o.length)return null;n+=o.length+1;const i=pl(e,n);if(null===i)return null;if(n+=i.length+1,n+4>e.length)return null;const a=t.getInt32(n,!0);if(n+=4,a<0||n+a>e.length)return null;if("dataWindow"===o&&"box2i"===i&&16===a){const e=t.getInt32(n,!0),o=t.getInt32(n+4,!0),i=t.getInt32(n+8,!0)-e+1,a=t.getInt32(n+12,!0)-o+1;return i<=0||a<=0?null:{width:i,height:a}}n+=a}return null}(s))?o:function(e){if(e.length<30)return null;if(82!==e[0]||73!==e[1]||70!==e[2]||70!==e[3])return null;if(87!==e[8]||69!==e[9]||66!==e[10]||80!==e[11])return null;const t=String.fromCharCode(e[12],e[13],e[14],e[15]);if("VP8 "===t){const t=16383&(e[26]|e[27]<<8),n=16383&(e[28]|e[29]<<8);return t&&n?{width:t,height:n}:null}return"VP8L"===t?47!==e[20]?null:{width:1+(16383&(e[21]|e[22]<<8)),height:1+(16383&(e[22]>>6|e[23]<<2|(15&e[24])<<10))}:"VP8X"===t?{width:1+(e[24]|e[25]<<8|e[26]<<16),height:1+(e[27]|e[28]<<8|e[29]<<16)}:null}(s))?n:function(e){if(e.length<4)return null;if(255!==e[0]||216!==e[1])return null;let t=2;for(;t<e.length-8;){for(;t<e.length&&255===e[t];)t++;if(t>=e.length)return null;const n=e[t++];if(1===n||n>=208&&n<=217)continue;if(t+2>e.length)return null;const o=e[t]<<8|e[t+1];if(o<2||t+o>e.length)return null;if(n>=192&&n<=207&&196!==n&&200!==n&&204!==n){if(t+7>e.length)return null;const n=e[t+3]<<8|e[t+4],o=e[t+5]<<8|e[t+6];return o&&n?{width:o,height:n}:null}t+=o}return null}(s))?t:function(e){if(e.length<10)return null;if(35!==e[0]||63!==e[1])return null;const t=new TextDecoder("latin1").decode(e.subarray(0,Math.min(e.length,4096))).match(/[+-]Y\s+(\d+)\s+[+-]X\s+(\d+)/);if(!t)return null;const n=parseInt(t[1],10),o=parseInt(t[2],10);return o&&n?{width:o,height:n}:null}(s)}(t.entrypoint);e&&(C.width=e.width,C.height=e.height)}catch(e){"debug"===S&&console.warn("readImageResolution failed; uploading without dimensions",e)}const F=await fetch(T+ft.upload.request,{...gt,method:"POST",headers:A,body:JSON.stringify(R)}).catch(e=>"fetch failed"==e.message||"Failed to fetch"==e.message?`Network error. Make sure you are connected to the internet and ${T} is reachable.`:(console.error("Failed to begin upload\n",e),null));if(null===F||"string"==typeof F)return{success:!1,error:F||"Failed to begin upload"};if(!F.ok){const e=await F.text();if(e.startsWith("{")){const t=JSON.parse(e);if("error"in t)return{success:!1,status:F.status,error:t.error}}return"none"!=S&&console.error("Failed to begin upload\n",F.status,e),{success:!1,status:F.status,error:`${e}`}}const D=await F.json();"debug"===S&&console.debug("BeginResponse",D);const q=j.reduce((e,t)=>e+t.size,0);var B;if("exists"===D.type)return"none"!=S&&console.log("Upload already exists",D.id),null!=(B=n)&&B.onStart&&n.onStart(D.id,D.content_id),{success:!0,uploadSkipped:!0,id:D.id,type:D.job_type,content_id:D.content_id,filesUploaded:j.length,totalSize:q,url:D.url,edit_url:D.edit_url};const M=t.entrypoint.webkitRelativePath||t.entrypoint.name;let W=0;null==(y=n)||null==(y=y.abort)||y.addEventListener("abort",async()=>{console.log("Upload aborted: Cancelling upload"),await fetch(T+ft.upload.cancel,{...gt,method:"POST",headers:{authorization:O,id:D.id}})});let H=!1,G=Date.now();function J(t,n,o=!1){if(!o&&Date.now()-G<1e3)return!1;if(H&&"completed"!==n)return void("none"!=S&&console.warn("Invalid status update..."));G=Date.now();const i=Math.floor(W/q*100);return"debug"===S&&console.log("SET STATUS: "+n,t,i),wc({identifier:D.id,status:n,status_message:t,progress:i},e),!0}null!=(w=n)&&w.onStart&&n.onStart(D.id,D.content_id);const V=Date.now(),K=new xl(j.length,q/1024/1024),Y=new Array,Z=function(e){let t=0;for(const n of e)Number.isFinite(n)&&n>=0&&(t=Math.max(t,n));return t>=Lc?2:t>=Sl?4:10}(C.files.map(e=>e.content_length));"debug"===S&&console.debug(`Upload file concurrency: ${Z}`);let X=!1;const Q=[...j],ee=j.length,te=function(e,t=25e3){let n=!1;const o=setInterval(()=>{if(!n)try{const t=e();t&&"function"==typeof t.then&&t.catch(e=>{console.warn("[upload] heartbeat tick failed:",e)})}catch(e){console.warn("[upload] heartbeat tick threw:",e)}},t);return o&&"function"==typeof o.unref&&o.unref(),function(){n||(n=!0,clearInterval(o))}}(()=>J("Upload in progress","running",!0));try{var ne;for(let o=0;o<Q.length;o++){var oe;if(!(X||null!=(oe=n)&&null!=(oe=oe.abort)&&oe.aborted)){if(Y.length<Z){console.debug(`Uploading file ${o}/${j.length}: ${j[o].name}`);let i=0,a=0;const r=C.files[o],s=r.filename,c=N[o],l=r.content_length,p=r.content_type,u=j[o],d=u.name.endsWith(".gz")?"gzip":u.name.endsWith(".br")?"br":void 0,m=zl({uploadId:D.id,uploadRequestPUTUrl:D.request_put_url,entrypointPath:M,file:j[o],fileName:s,fileMd5:r.content_md5,fileBuffer:c,fileType:p,content_encoding:d,fileSize:l,fileIndex:o,fileNumber:o+1,fileCount:ee,loglevel:S,experimental:t.experimental,args:e,options:n,onProgress:e=>{var t;const r=e.progress||0;i=j[o].size*r;const c=i-a;if(a=i,W+=c,null!=(t=n)&&t.progress){const e=W/q,t=j.length,i=j[o].size,a=(Date.now()-V)/1e3,c=K.updateProgress(W/1024/1024);n.progress({uploadedBytes:W,totalBytes:q,progress01:e,fileName:j[o].name,fileSize:i,fileProgress01:r,fileIndex:o,totalFiles:t,estimatedTimeLeftDisplay:c.estimatedTimeRemainingString,estimatedTimeLeft:c.estimatedTimeRemaining,elapsedTime:a}),J(`Uploading file ${o+1}/${t} (${s}): ${(100*r).toFixed(0)}% of ${il(q)}. Finished in approx. ${c.estimatedTimeRemainingString}`,"running",!1)}}}).then(e=>{if(!0!==e)return e;for(let e=Y.length-1;e>=0;e--)Y[e]===m&&Y.splice(e,1);J(`Uploaded ${il(W)+" of "+il(q)} for ${j[o].name}`,"running")}).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),X=!0)});Y.push(m)}Y.length>=Z&&await Promise.race(Y)}}null!=(ne=n)&&null!=(ne=ne.abort)&&ne.aborted?console.debug("Upload aborted"):X&&console.debug("Upload failed"),await Promise.all(Y).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),X=!0)})}finally{te()}if(X)return await wc({identifier:D.id,status:"failed",error:"Failed to upload files"},e),{success:!1,error:"Failed to upload files"};if(null!=(_=n)&&null!=(_=_.abort)&&_.aborted)return await wc({identifier:D.id,status:"canceled",status_message:"Upload aborted",error:"Upload aborted"},e),{success:!1,error:"Upload aborted"};H=!0,console.log(`Upload Done: All files uploaded to ${D.id}`);const ie={...ht(e),id:D.id};"none"!=S&&console.log("Completing upload - notify server");let ae=null;for(let e=0;e<5;e++){var re;await ul(1e3*e);const t=AbortSignal.timeout(6e4+5e3*e);if(ae=await fetch(T+ft.upload.done,{...gt,method:"POST",headers:ie,signal:t}).catch(t=>(console.error(`Failed to complete upload (${e+1} / 5)`,t.message),null)),!0===(null==(re=ae)?void 0:re.ok))break;if(ae&&ae.status>=400&&ae.status<500)break;var se;"none"!=S&&e<4&&console.warn(`Failed to complete upload (${(null==(se=ae)?void 0:se.status)||"no status"}): will retry in 1 second`)}if(!ae)return console.error("Failed to complete upload"),{success:!1,error:"Failed to complete upload"};if(!ae.ok){if(524===ae.status)return console.error("Failed to complete upload: Gateway Timeout"),{success:!1,error:"Failed to complete upload: Gateway Timeout"};{const e=await ae.text().catch(()=>"");return console.error(`Failed to complete upload (${ae.status}): ${e}`),{success:!1,error:`Failed to complete upload: ${e?e.substring(0,300):`status ${ae.status}`}`}}}"none"!=S&&console.log("Upload complete");const ce=await ae.json();return{success:!0,type:ce.type,uploadSkipped:!1,id:ce.id,content_id:ce.content_id,url:ce.url,edit_url:ce.edit_url,filesUploaded:j.length,totalSize:q}}(e,t,n);return await o.finally(()=>{})}const $l=[".html",".js",".css"],Tl=[".gz",".br"];function Il(e){return"path"in e&&e.path?e.path:e.name}function Ol(e){var t;const n=null==e||null==(t=e.config)?void 0:t.url;if(!n)return null;try{return new URL(n).host}catch{return null}}const Al=400,Cl=255;function Rl(e){const t="string"==typeof e?e:String(null!=e?e:"");return t.length<=Cl?t:t.slice(0,Cl-1)+"…"}const Nl={ECONNRESET:"connection reset before the upload completed",ECONNREFUSED:"connection refused by the storage host",ECONNABORTED:"connection aborted — timed out or closed mid-request",ENOTFOUND:"DNS lookup failed for the storage host",EAI_AGAIN:"DNS lookup failed temporarily — resolver unavailable",ETIMEDOUT:"connection timed out",EPIPE:"connection closed while sending the file",EHOSTUNREACH:"storage host unreachable from this network",ENETUNREACH:"network unreachable",EPROTO:"TLS or protocol error",ERR_NETWORK:"network error — the request never reached the storage host",CERT_HAS_EXPIRED:"the TLS certificate for the storage host has expired",UNABLE_TO_VERIFY_LEAF_SIGNATURE:"the TLS certificate for the storage host could not be verified",DEPTH_ZERO_SELF_SIGNED_CERT:"a self-signed TLS certificate was presented for the storage host",SELF_SIGNED_CERT_IN_CHAIN:"a self-signed TLS certificate was presented for the storage host"};function Pl(e){if(!e)return"unknown upload error";const t=[];try{const i=e.response,a=null==i?void 0:i.status,r=null==i?void 0:i.statusText;a&&t.push(`HTTP ${a}${r?" "+r:""}`);const s=null==i?void 0:i.data;if(null!=s){var n,o;let i;if("string"==typeof s)i=s;else try{i=JSON.stringify(s)}catch{i=String(s)}const a=null==(n=i.match(/<Code>([^<]+)<\/Code>/))?void 0:n[1],r=null==(o=i.match(/<Message>([^<]+)<\/Message>/))?void 0:o[1];if(a)t.push(`S3 ${a}${r?": "+r:""}`);else if(function(e){return/^\s*(<!DOCTYPE\s+html|<html[\s>])/i.test(e)}(i)){const n=Ol(e);t.push("blocked by a network filter or proxy"+(n?` before it reached ${n}`:"")+" — ask your network administrator to allow this host")}else i&&t.push(i.slice(0,200))}let c=null;if(!i&&(c=function(e){var t,n;const o=null!=(t=null==e?void 0:e.code)?t:null==e||null==(n=e.cause)?void 0:n.code;return"string"==typeof o&&o.length?o:null}(e),c)){const n=Nl[c];t.push(n?`${c} (${n})`:c);const o=Ol(e);o&&t.push(`while uploading to ${o}`)}const l=e.message?String(e.message):"",p=a&&/^Request failed with status code \d+$/.test(l)||null!==c&&l.includes(c);l&&!p&&t.push(l)}catch{}return 0===t.length&&e.message&&t.push(String(e.message)),t.length?t.join(" — "):"unknown upload error"}const Ul=12e4;function Ll(e,t){let n=null,o=!1;const i=()=>{n&&(clearTimeout(n),n=null)};return{reset:()=>{o||(i(),n=setTimeout(()=>{o=!0,n=null,t()},e))},cancel:i}}async function zl(e){if(e.fileSize>=Lc)return async function(e){const{uploadId:t,entrypointPath:n,file:o,fileName:i,fileMd5:a,fileType:r,content_encoding:s,fileSize:c,args:l,options:p,onProgress:u,partSize:d,concurrency:m,maxRetries:f,retryDelayMs:h,putPart:g}=e,{baseUrl:v}=l,b=()=>({...ht(l),"Content-Type":"application/json",org:l.org,job_id:t}),x={...b(),filesize:c.toString()},y=JSON.stringify({filename:i,entrypoint:n,"content-type":r,"content-md5":a,"content-encoding":s,output_index:0});async function w(e,t,n){const o=await fetch(e,{...gt,method:"POST",headers:t,body:JSON.stringify(n)});if(!o.ok)throw new Error(`${e} ${o.status}: ${await o.text().catch(()=>"")}`);return o.json()}return await async function(e){const{size:t,slice:n,partSize:o=Uc,concurrency:i=4,maxRetries:a=5,retryDelayMs:r=1e3,createUpload:s,getPartUrls:c,putPart:l,completeUpload:p,abortUpload:u,onProgress:d,signal:m,checkCancelled:f}=e,h=async()=>{if(m&&m.aborted)return!0;if(f)try{return!!await f()}catch{return!1}return!1};if(await h())throw new Error("Upload aborted");const g=function(e,t=Uc){if(!Number.isFinite(e)||e<=0)return[];let n=Math.max(t,Nc,Math.ceil(e/Pc));const o=[];let i=0,a=1;for(;i<e;){const t=Math.min(i+n,e);o.push({partNumber:a,start:i,end:t,size:t-i}),i=t,a++}return o}(t,o);if(0===g.length)throw new Error("Nothing to upload (size <= 0)");const{upload_id:v,key:b}=await s(),x=await c(v,b,g.map(e=>e.partNumber)),y=new Map(x.map(e=>[e.part_number,e.url])),w=[];let _=0,j=null;const k=async e=>{const t=y.get(e.partNumber);if(!t)throw new Error(`Missing presigned url for part ${e.partNumber}`);let o=!1;const i=await Cc(async()=>{if(await h())throw o=!0,new Error("Upload aborted");try{const o=n(e.start,e.end),i=await l({url:t,payload:o,partNumber:e.partNumber,size:e.size,signal:m});if(!i)throw new Error(`No ETag returned for part ${e.partNumber}`);return i}catch(e){throw await h()&&(o=!0),e}},{maxAttempts:a+1,baseMs:r,isRetryable:e=>!o&&Oc(e),...r>0?{}:{sleep:async()=>{}}});if(!i.ok)throw i.error||new Error(`Failed to upload part ${e.partNumber}`);w.push({part_number:e.partNumber,etag:i.value}),_+=e.size,d&&d(_)},S=[...g],E=Math.max(1,Math.min(i,g.length));if(await Promise.all(Array.from({length:E},()=>(async()=>{for(;S.length>0;){if(j||await h())return;const e=S.shift();if(!e)return;try{await k(e)}catch(e){return void(j=j||e)}}})())),j||await h())throw await u(v,b).catch(()=>{}),j||new Error("Upload aborted");return w.sort((e,t)=>e.part_number-t.part_number),await p(v,b,w),{ok:!0,key:b,upload_id:v,parts:g.length}}({size:c,partSize:d,concurrency:m,maxRetries:f,retryDelayMs:h,slice:(e,t)=>o.slice(e,t),signal:null==p?void 0:p.abort,onProgress:e=>{u&&u({loaded:e,total:c,progress:c?e/c:0})},createUpload:async()=>{const e=await fetch(v+ft.upload.multipart_create,{...gt,method:"POST",headers:x,body:y});if(!e.ok)throw new Error(`multipart/create ${e.status}: ${await e.text().catch(()=>"")}`);const t=await e.json();return{upload_id:t.upload_id,key:t.key}},getPartUrls:async(e,t,n)=>(await w(v+ft.upload.multipart_part_urls,b(),{key:t,upload_id:e,part_numbers:n})).urls,putPart:g||(({url:e,payload:t,partNumber:n,signal:o})=>async function({url:e,payload:t,partNumber:n,contentType:o,signal:i}){const a=i,r=new AbortController;let s=!1;const c=()=>r.abort();a&&(a.aborted?r.abort():a.addEventListener("abort",c,{once:!0}));const l=Ll(Ul,()=>{s=!0,r.abort()});l.reset();try{var p,u;const n=await vc.put(e,t,{...gt,...await jl(),withCredentials:!1,signal:r.signal,headers:{"Content-Type":o},onUploadProgress:()=>l.reset()});if(200!==n.status)throw new Error(Pl({response:n}));const i=(null==(p=n.headers)?void 0:p.etag)||(null==(u=n.headers)?void 0:u.ETag);if(!i)throw new Error("part PUT returned no ETag (is the bucket's CORS exposeHeaders:etag set?)");return i}catch(e){if(null!=a&&a.aborted)throw e;if(s)throw new Error(`Part ${n} stalled: no progress for ${Ul/1e3}s`);throw new Error(Pl(e))}finally{l.cancel(),a&&a.removeEventListener("abort",c)}}({url:e,payload:t,partNumber:n,signal:o,contentType:r})),completeUpload:async(e,t,n)=>w(v+ft.upload.multipart_complete,b(),{key:t,upload_id:e,parts:n}),abortUpload:async(e,t)=>{await fetch(v+ft.upload.multipart_abort,{...gt,method:"POST",headers:b(),body:JSON.stringify({key:t,upload_id:e})}).catch(()=>{})}}),!0}(e);const{uploadId:t,uploadRequestPUTUrl:n,entrypointPath:o,file:i,fileName:a,fileBuffer:r,fileMd5:s,fileSize:c,fileType:l,content_encoding:p,fileIndex:u,fileNumber:d,fileCount:m,loglevel:f,args:h,options:g,experimental:v}=e;"info"===f&&console.log(`Uploading file "${i.name}" type=${l} (${c}) ${i.type} with hash ${s}`);const b={...ht(h),"Content-Type":"application/json",org:h.org,job_id:t,filesize:c.toString(),progress:(u/m*100).toFixed(0)},x={filename:a,entrypoint:o,"content-type":l,"content-md5":s,"content-encoding":p,output_index:0};"debug"===f&&console.debug("Requesting presigned URL with headers",b);const y=JSON.stringify(x);let w=null,_="";const j=await Cc(async()=>{var e;if(null!=g&&null!=(e=g.abort)&&e.aborted)throw new bc("Upload aborted");const t=await fetch(n,{...gt,method:"POST",headers:b,body:y});if(!t.ok){const e=await t.text().catch(()=>"");throw _=e,{response:{status:t.status,statusText:t.statusText,data:e}}}return await t.json()},{baseMs:500,onRetry:({attempt:e,waitMs:t,error:n})=>{console.warn(`Failed to get presigned url for "${a}" "${l}": ${Pl(n)}\n→ Retry #${e} in ${t}ms`)}});if(j.ok)w=j.value;else if(j.error instanceof bc)throw j.error;if(null==w){const e=_||Pl(j.error);throw new Error(`Failed to get presigned url for "${a}" "${l}" \n${e}`)}const k=w.presigned_url;var S=!1;let E=null;const $=[];let T=0;const I=await Cc(async t=>{var n;if(null!=g&&null!=(n=g.abort)&&n.aborted)throw new bc("Upload aborted");const o={"Content-Type":l,"Content-MD5":s};v&&(o["Content-Length"]=c.toString()),p&&(o["Content-Encoding"]=p),1===t&&"none"!=f&&console.log(`Uploading file ${d}/${m}: ${a}`),"debug"===f&&console.debug("PUT with headers",o);const i=new AbortController;let u=!1;const h=()=>i.abort();null!=g&&g.abort&&(g.abort.aborted?i.abort():g.abort.addEventListener("abort",h,{once:!0}));const b=Ll(Ul,()=>{u=!0,i.abort()});b.reset();try{const t=await vc.put(k,r,{...gt,...await jl(),withCredentials:!1,signal:i.signal,headers:o,onUploadProgress:t=>{b.reset(),e.onProgress(t)}});if(200!==t.status)throw{response:t};return t}catch(e){var x;if(null!=g&&null!=(x=g.abort)&&x.aborted)throw new bc("Upload aborted");if(u)throw E=`stalled: no upload progress for ${Ul/1e3}s`,$.push(E),"none"!==f&&console.error(`Upload stalled (PUT) (${d}, ${a}) after ${Ul/1e3}s with no progress`),new Error(E);throw E=Pl(e),$.push(E),e instanceof bc||("none"!==f&&console.error(`Failed to upload file (PUT) (${d}, ${a}) "${E}"`),"debug"===f&&(console.log(o,{fileSize:c}),e.response?console.debug(e.response):console.debug(e))),e}finally{b.cancel(),null!=g&&g.abort&&g.abort.removeEventListener("abort",h)}},{onRetry:({attempt:e,waitMs:t})=>{"none"!==f&&console.log(`Retry PUT #${e} for file ${a} in ${t}ms`)}});if(T=I.attempts,I.ok)S=!0,"info"===f&&console.log(`Uploaded file ${d}/${m} "${a}" (${l}, ${il(c)})`);else if(I.error instanceof bc)throw I.error;if(!S){var O;const e=null!=(O=function(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if("string"!=typeof n)continue;const e=n.trim();e&&!t.includes(e)&&t.push(e)}return t.length?t.join("; "):null}($))?O:E,n=function(e,t,n){const o="string"==typeof t?t.trim():"",i="number"==typeof n&&n>1?` after ${n} attempts`:"";return o?`Failed to upload file ${e}${i}: ${o.length>Al?o.slice(0,Al)+"…":o}`:`Failed to upload file ${e}${i}`}(a,e,T);throw console.error(n),await wc({identifier:t,status:"failed",status_message:Rl(n),error:"Failed to upload file "+a},h),new Error(n)}return!0}async function Fl(e,t,n){const o=e.baseUrl+ft.jobs.presigned_url,i=await fetch(o,{...gt,method:"POST",headers:{...ht(e),job_id:t},body:JSON.stringify(n)}).catch(e=>(console.error(e),null));return i&&i.ok?await i.text():(console.error("Failed to get presigned download URL",null==i?void 0:i.status),null)}async function Dl(e,t){const n=e.baseUrl+ft.jobs.create,o={...ht(e),"content-type":"application/json"},i={type:"ai-material",triggered_by:e.trigger_type,parameters:{...t}},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();return console.error(`Failed to request texture generation (${a.status}): ${e}`),{error:e||`Request failed (${a.status})`}}return await a.json().catch(e=>(console.error(e),null))}async function ql(e,t={}){const n=new URL(e.baseUrl+ft.content.root);void 0!==t.include_projects&&n.searchParams.set("include_projects",String(t.include_projects)),t.content_type&&n.searchParams.set("content_type",t.content_type),t.content_format&&n.searchParams.set("content_format",t.content_format),t.search&&n.searchParams.set("search",t.search),t.tags&&n.searchParams.set("tags",t.tags),t.types&&n.searchParams.set("types",t.types),t.trash&&n.searchParams.set("trash","true"),t.is_public&&n.searchParams.set("is_public","true"),t.page&&n.searchParams.set("page",String(t.page)),t.limit&&n.searchParams.set("limit",String(t.limit)),t.collection_id&&n.searchParams.set("collection_id",t.collection_id),t.offset&&n.searchParams.set("offset",String(t.offset));const o=ht(e),i=await fetch(n,{...gt,method:"GET",headers:o});if(!i.ok){const e=await i.text();throw new Error(`Failed to list content (${i.status}): ${e}`)}return await i.json()}async function Bl(e,t,n={}){const o=new URL(`${e.baseUrl}${ft.content.root}/${encodeURIComponent(t)}`);n.item&&o.searchParams.set("item",n.item);const i=ht(e),a=await fetch(o.toString(),{...gt,method:"GET",headers:i});if(!a.ok){const e=await a.text();throw new Error(`Failed to get content (${a.status}): ${e}`)}return await a.json()}async function Ml(e,t){const n=`${e.baseUrl}${ft.content.root}/${t}`,o=ht(e),i=await fetch(n,{...gt,method:"DELETE",headers:o});if(!i.ok){const e=await i.text();throw new Error(`Failed to delete content (${i.status}): ${e}`)}return await i.json()}const Wl={schema:{name:"load_needle_engine_skill",description:'Load the Needle Engine skill: authoritative coding guidelines, component patterns, the Unity/Blender-to-web export workflow, and reference docs. Load this BEFORE answering ANY Needle Engine coding or workflow question — do NOT answer from prior knowledge, which is frequently wrong about how Needle actually works (for example: the relationship between Unity C# scripts and TypeScript components, and what the editor export does — Needle does NOT auto-convert C# logic to TypeScript). ALWAYS load first when the user: shares or asks about Unity C# code (a MonoBehaviour, the Needle.Engine.* namespace) or Blender scripts in a Needle context; asks how a Unity or Blender component maps to, converts to, ports to, or works in Needle Engine or TypeScript; asks about components, lifecycle, serialization, XR, networking, deployment, or the export/codegen pipeline; or reports a Needle Engine bug or error. Do NOT load for greetings or small talk that contains no technical question — wait for the actual question first. Without arguments loads the main skill file. Use the "file" parameter to load specific reference files (e.g. "references/api.md", "references/components.md"). Call without arguments first to discover available references.',inputSchema:{type:"object",properties:{file:{type:"string",description:'File to load relative to the skill root, e.g. "references/api.md". Defaults to the main skill file.'}},additionalProperties:!1,required:[]}},async execute(e){const t=(null==e?void 0:e.file)||"SKILL.md";if(t.includes("..")||t.startsWith("/"))return{error:"Invalid file path."};try{const e="https://raw.githubusercontent.com/needle-tools/ai/main/providers/claude/plugin/skills/needle-engine/"+encodeURI(t),n=new AbortController,o=setTimeout(()=>n.abort(),5e3),i=await fetch(e,{signal:n.signal,redirect:"follow"});return clearTimeout(o),i.ok?{content:await i.text()}:{error:`Could not fetch '${t}' (HTTP ${i.status})`}}catch(e){return{error:`Error fetching skill: ${e.message}`}}}};function Hl(e){let t,n=null,o="";for(const i of e.split("\n"))i.startsWith("event: ")?n=i.slice(7).trim():i.startsWith("data: ")?o=i.slice(6):i.startsWith("id: ")&&(t=parseInt(i.slice(4).trim(),10));if(!n)return null;let i=null;switch(n){case"delta":i={type:"delta",content:decodeURIComponent(o)};break;case"message":i={type:"message",content:decodeURIComponent(o)};break;case"status":i={type:"status",message:decodeURIComponent(o)};break;case"error":i={type:"error",message:decodeURIComponent(o)};break;case"notice":i={type:"notice",message:decodeURIComponent(o)};break;case"stopped":i={type:"stopped"};break;case"tool_call":i={type:"tool_call",...JSON.parse(o)};break;case"tool_result":i={type:"tool_result",...JSON.parse(o)};break;case"file_change":i={type:"file_change",...JSON.parse(o)};break;case"local_preview":i={type:"local_preview",...JSON.parse(o)};break;case"message_inserted":i={type:"message_inserted",...JSON.parse(o)};break;case"elicitation":i={type:"elicitation",...JSON.parse(o)};break;case"done":{const e=JSON.parse(o),{chat_url:t,...n}=e;i={type:"done",token_usage:n},t&&(i.chat_url=t);break}case"message_id":i={type:"message_id",message_id:decodeURIComponent(o)};break;case"chat_id":i={type:"chat_id",chat_id:decodeURIComponent(o)}}return i&&void 0!==t&&(i.id=t),i}function Gl(e,t){const n=ht(e);return null!=t&&t.personal&&(n["x-needle-ai-chat"]="personal"),null!=t&&t.instanceId&&(n["x-needle-instance-id"]=t.instanceId),n}function Jl(e,t){return t.stream?async function*(e,t){const n=new URL(e.baseUrl+ft.ai.chat),o=Gl(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!0,source:t.source,allow_file_edits:!0===t.allowFileEdits,file_edit_session_id:!0===t.allowFileEdits?t.fileEditSessionId:void 0,allow_local_commands:!0===t.allowLocalCommands,local_command_session_id:!0===t.allowLocalCommands?t.localCommandSessionId:void 0,full_url:t.full_url,pathname:t.pathname,context:t.context,disabled_tools:t.disabled_tools},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();throw new Error(`Failed to stream chat message (${a.status}): ${e}`)}if(!a.body)throw new Error("Response body is null — streaming not supported in this environment");yield*async function*(e){const t=e.getReader(),n=new TextDecoder;let o="";try{for(;;){const{done:e,value:i}=await t.read();if(e)break;o+=n.decode(i,{stream:!0});const a=o.split("\n\n");o=a.pop()||"";for(const e of a){const t=Hl(e);t&&(yield t)}}if(o.trim()){const e=Hl(o);e&&(yield e)}}finally{t.releaseLock()}}(a.body)}(e,t):async function(e,t){const n=new URL(e.baseUrl+ft.ai.chat),o=Gl(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!1,source:t.source,allow_file_edits:!0===t.allowFileEdits,file_edit_session_id:!0===t.allowFileEdits?t.fileEditSessionId:void 0,allow_local_commands:!0===t.allowLocalCommands,local_command_session_id:!0===t.allowLocalCommands?t.localCommandSessionId:void 0,full_url:t.full_url,pathname:t.pathname,context:t.context,disabled_tools:t.disabled_tools},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();throw new Error(`Failed to send chat message (${a.status}): ${e}`)}return await a.json()}(e,t)}const Vl=200,Kl=["github.com","gitlab.com","bitbucket.org"],Yl=/[\w.+-]+@[\w-]+\.[\w.]+/;function Zl(e){if(e)return Yl.test(e)?void 0:e}function Xl(e,t){return String(b("git",e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],...t?{cwd:t}:{}})||"").trim()}function Ql(e,t){try{return Xl(e,t)}catch{return""}}function ep(e){try{const t=Xl(["rev-parse","HEAD"],e);if(!t)return null;const n=Ql(["rev-parse","--abbrev-ref","HEAD"],e),o=Ql(["log","-1","--pretty=%s"],e),i=Zl(Ql(["log","-1","--pretty=%an"],e)),a=Ql(["status","--porcelain"],e).length>0,r=Ql(["remote","get-url","origin"],e),s=t.slice(0,7),{repository:c,url:l}=function(e,t){if(!e)return{};const n=/^(?:https?:\/\/(?:[^@/]+@)?([^/]+)\/|git@([^:]+):)(.+?)(?:\.git)?$/.exec(e.trim());if(!n)return{};const o=(n[1]||n[2]||"").toLowerCase(),i=n[3];return i?Kl.includes(o)?{repository:i,url:`https://${o}/${i}/${"bitbucket.org"===o?"commits":"commit"}/${t}`}:{repository:i}:{}}(r,t),p={type:"git",id:t,label:`${n||s}@${s}${a?" (dirty)":""}`};return n&&(p.branch=n),i&&(p.author=i),o&&(p.message=o.slice(0,Vl)),a&&(p.dirty=!0),c&&(p.repository=c),l&&(p.url=l),p}catch{return null}}function tp(e){if("string"==typeof e)return e.trim()||void 0}const np="https://cloud.needle.tools/api",op=()=>"https://cloud.needle.tools/account",ip=()=>"https://cloud.needle.tools/edit";function ap(e){return x(e)}const rp=["node_modules",".git",".vscode",".vercel",".github",".idea"];function sp(e,t,n=null,o="",i=0){if(null===n){if(i>0)throw new Error("result must be provided if level > 0. Did you forget to pass it?");n={files:[],total_size:0}}if(0===i){if(!c(t))throw new Error(`Directory or file "${t}" does not exist.`);if(l(t).isFile()){const e=Zc(t,p(t));return e.path=e.name,n.files.push(e),n.entrypoint=e,n}}else if(i>20)throw new Error("Recursion depth too high. Are you sure you are providing the correct directory?");const a=u(t,{withFileTypes:!0});for(const i of a)if(0==i.isDirectory()){if("optimization"===e&&0==((r=(r=i.name).toLowerCase()).endsWith(".glb")||r.endsWith(".gltf")||r.endsWith(".vrm")||r.endsWith(".usdz")||r.endsWith(".usd")||r.endsWith(".fbx")))continue;const a=Zc(o+i.name,p(t+"/"+i.name));if(n.files.push(a),n.total_size+=a.size,n.total_size>1073741824)throw new Error(`Collected filesize exceeds ${1024..toFixed(0)} MB. Are you sure you are providing the correct directory?`);if(n.files.length>1e4)throw new Error(`Too many files (${n.files.length}): The maximum filecount is 10,000.`)}var r;for(const r of a)if(r.isDirectory()){if(rp.includes(r.name))continue;sp(e,t+"/"+r.name,n,o+r.name+"/",i+1)}return n}const cp=new RegExp("\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g"),lp=new RegExp("\\b[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\\b","gi"),pp=new RegExp("(Authorization:\\s*)([^\\s,;\"']+(?:\\s+[^\\s,;\"']+)?)","gi"),up=new RegExp("\\bBearer\\s+([A-Za-z0-9._\\-=]+)","g"),dp=new RegExp("([?&]token=)([^&\\s\"'<>]+)","g"),mp=new RegExp("<redacted:\\d+ch>","g");function fp(e){if("string"!=typeof e)return e;if(0===e.length)return e;if(mp.test(e)&&(mp.lastIndex=0,!function(e){cp.lastIndex=0,lp.lastIndex=0,pp.lastIndex=0,up.lastIndex=0,dp.lastIndex=0;const t=cp.test(e)||lp.test(e)||pp.test(e)||up.test(e)||dp.test(e);return cp.lastIndex=0,lp.lastIndex=0,pp.lastIndex=0,up.lastIndex=0,dp.lastIndex=0,t}(e.replace(mp,""))))return e;mp.lastIndex=0;let t=e;return t=t.replace(pp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(dp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(up,(e,t)=>`<redacted:${("Bearer "+t).length}ch>`),t=t.replace(cp,e=>`<redacted:${e.length}ch>`),t=t.replace(lp,e=>`<redacted:${e.length}ch>`),t}const hp=["cli.log","cli.prev.log"],gp=ie.join(te.homedir(),".needle","cli","logs");I(gp,{recursive:!0});try{!function(e,t){const n={migrated:[],skipped:[]};if(!e||!t)return n;if(ie.resolve(e)===ie.resolve(t))return n;if(!T(e))return n;for(const o of hp){const i=ie.join(e,o);if(T(i))try{I(t,{recursive:!0});const e=ie.join(t,o);if(T(e)){const e=ie.join(t,o.replace(/\.log$/,"")+".legacy.log");O(i,e),n.skipped.push(o)}else O(i,e),n.migrated.push(o)}catch(e){console.error(`[needle-cloud] Failed to migrate legacy log ${o}: ${e instanceof Error?e.message:e}`)}}}(ie.join(A(te.tmpdir()),"Needle","Cloud","logs"),gp)}catch(e){console.error(`[needle-cloud] legacy log migration check failed: ${e instanceof Error?e.message:e}`)}const vp=ie.resolve(gp,"cli.log");if(T(vp)){const e=C(vp),t=e.mtimeMs;if(Date.now()-t>432e5||e.size>52428800){const e=xp();R(vp,e,t=>{t?console.error(`Failed to rename log file: ${t.message}`):console.log(`Log file renamed to ${e}`)})}}function bp(){return vp}function xp(){return ie.resolve(gp,"cli.prev.log")}function yp(e,t){try{let n=fp(String(null!=e?e:""));return n=`[${(new Date).toISOString()}] ${n}`,null!=t&&t.emptyLineBefore&&(n="\n"+n),N(vp,n+"\n"),!0}catch(e){return console.error(`Failed to write to log file: ${e instanceof Error?e.message:e}`),!1}}async function wp(e,t){return e=fp(e),e=`[${(new Date).toISOString()}] ${e}`,null!=t&&t.emptyLineBefore&&(e="\n"+e),J(vp,e+"\n",{flag:"a"}).then(()=>!0).catch(e=>(console.error(`Failed to write to log file: ${e.message}`),!1))}var _p={__proto__:null,getLogFilePath:bp,getPrevLogsFilePath:xp,getPipelineLogFilePath:function(){return ie.join(te.homedir(),".needle","optimization-pipeline","logs","pipeline.log")},writeToLogFileSync:yp,writeToLogFile:wp};function jp(e,t,n){process.env.GITHUB_ACTIONS&&(process.env.GITHUB_OUTPUT?d(process.env.GITHUB_OUTPUT,`${e}=${t}\n`):null==n||n.logger.warn("GITHUB_OUTPUT environment variable is not set. Cannot set output variables."))}async function kp(e){var t;e.directory=y.resolve(e.directory);let{files:n,entrypoint:o}=sp("deployment",e.directory);if(e.entrypoint&&(o=n.find(t=>t.path===e.entrypoint),!o))return process.exitCode=1,void $().fail(`Entrypoint "${e.entrypoint}" not found. Please make sure you provide a valid entrypoint.`);if(!o){const e=hl(n);if("error"in e)return process.exitCode=1,wp(`[Deployment] Error determining entrypoint: ${e.error}`),void $().fail(`Error: ${e.error}`);o=e}if(!(n.length>0&&o&&(o.name.toLowerCase().endsWith(".html")||o.name.toLowerCase().endsWith(".html.gz")||o.name.toLowerCase().endsWith(".html.br"))))return process.exitCode=1,wp("[Deployment] Deployment is not valid: No .html file found."),void $().fail("Deployment is not valid: No .html file found.");if(!o)return process.exitCode=1,wp("[Deployment] No entrypoint found. Please provide an index.html file in your project."),void $().fail("No entrypoint found. Please provide an index.html file in your project.");const i=null!=(t=e.endpoint)&&t.length?e.endpoint:"https://cloud.needle.tools/api";let a=e.name;a||(a=Sp(e.directory)||void 0);let r=null==i?void 0:i.includes("localhost");const s=a?` of "${a}"`:"",c=$().start(`Begin deployment${s} ${r?"(local)":""} of ${n.length} files...`);c.spinner="earth",await ul(50);let l=-1,p=null;const u=e.noProvenance?null:function(e=process.env,t,n){try{return function(e=process.env,t){try{if(tp(e.NEEDLE_CLOUD_NO_PROVENANCE))return null;let n=ep(t);tp(e.GITHUB_ACTIONS)&&(n=function(e,t){var n,o;const i=tp(t.GITHUB_SHA),a=tp(t.GITHUB_REF_NAME),r=tp(t.GITHUB_REPOSITORY),s=null!=(n=tp(t.GITHUB_SERVER_URL))?n:"https://github.com";if(!i&&!a)return e;const c={type:"git",...null!=e?e:{}};i&&(c.id=i),a&&(c.branch=a),r&&(c.repository=r),r&&i&&(c.url=`${s}/${r}/commit/${i}`);const l=String(null!=(o=c.id)?o:"").slice(0,7);return l&&(c.label=`${a||l}@${l}${c.dirty?" (dirty)":""}`),c}(n,e));const o=function(e=process.env){var t;if(!tp(e.CI))return{type:"local"};if(!tp(e.GITHUB_ACTIONS))return{type:"ci"};const n={type:"github-actions"},o=tp(e.GITHUB_RUN_ID),i=tp(e.GITHUB_REPOSITORY),a=null!=(t=tp(e.GITHUB_SERVER_URL))?t:"https://github.com";o&&(n.id=o);const r=Zl(tp(e.GITHUB_ACTOR));return r&&(n.actor=r),tp(e.GITHUB_EVENT_NAME)&&(n.event=tp(e.GITHUB_EVENT_NAME)),o&&i&&(n.url=`${a}/${i}/actions/runs/${o}`),n}(e);return n||"local"!==o.type?{...n?{source:n}:{},runner:o,client:{name:"needle-cloud-cli"}}:null}catch(e){var n;return console.warn(`[provenance] Could not determine provenance: ${null!=(n=null==e?void 0:e.message)?n:e}`),null}}(e,t&&ep(t)?t:n)}catch(e){var o;return console.warn(`[provenance] Could not determine provenance: ${null!=(o=null==e?void 0:e.message)?o:e}`),null}}(process.env,e.directory);if(null!=u&&u.source){var d;const{label:e,author:t}=u.source;wp(`[provenance] ${e}${t?` by ${t}`:""} (${null==(d=u.runner)?void 0:d.type})`)}wp(`Deployment started${s} ${r?"(local)":""} of ${n.length} files...`);const m=await El({baseUrl:i,authToken:e.token,org:e.org_id},{triggered_by:"cli",files:n,entrypoint:o,experimental:e.experimental,raw:e.raw,...u?{metadata:u}:{}},{name:a,type:"deployment",loglevel:e.verbose?"debug":"none",progress:e=>{if(e.fileIndex!==l){l=e.fileIndex;const t=e.totalBytes/1024/1024;c.text=`Uploading file ${e.fileIndex+1} of ${e.totalFiles} files: ${(e.uploadedBytes/1024/1024).toFixed(1)} / ${t.toFixed(1)} MB. Total progress: ${(100*e.progress01).toFixed(1)} %. Time passed: ${e.elapsedTime.toFixed(0)}sec. About ${e.estimatedTimeLeftDisplay} until complete.`}}}).catch(e=>(p=e instanceof Error?e.message:String(e),null));if(null!=m&&!0===m.success){c.succeed(`🚀 Deployment${s} successful (${m.content_id}/${m.id})`);let t="";t=m.url?m.url:"https://cloud.needle.tools/view/"+m.content_id+"/"+m.id,console.log("🔗 View the deployment at: "+t),e.open&&ap(t);try{jp("deployment_url",t,{logger:e.logger}),jp("edit_id",m.content_id,{logger:e.logger})}catch(t){e.logger.error("Error writing output for CI: "+t)}}else{process.exitCode=1;const e=p||(null==m?void 0:m.error)||"Deployment failed";wp(`[Deployment] Failed: ${e}`),c.fail(e)}}function Sp(e,t=0){if(t>10)return null;const n=y.join(e,"needle.config.json");if(c(n)){const t=y.join(e,"package.json");if(c(t)){var o;const e=p(t,"utf8"),n=JSON.parse(e);if(null!=(o=n.name)&&o.length)return n.name}return y.basename(e)}const i=y.dirname(e);return i===e?null:Sp(i,t+1)}const Ep={getContent:Bl,updateContentLabel:async function(e,t={}){const n={...ht(e),content_id:e.content_id,job_id:e.job_id,type:e.type,action:e.action};try{const t=await fetch(`${e.baseUrl}${ft.view.post_version}`,{...gt,method:"POST",headers:n});if(!t.ok){const e=await t.text();throw new mt(t.status,e,`Failed to update label (${t.status}): ${e}`)}return console.log(`Updated ${e.job_id} to ${e.type}`),!0}catch(n){if(t.throwOnError)throw n;return console.error("Failed to update label",e.job_id,n),!1}}};function $p(e){if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new Error("Invalid content identifier; use the item ID shown by list or upload.")}function Tp(e){if($p(e.contentId),!/^[a-z0-9][a-z0-9_-]*$/.test(e.label))throw new Error("Label names must use lowercase letters, numbers, hyphens or underscores.");if("latest"===e.label)throw new Error("latest is managed automatically; choose another destination label.");if(void 0!==e.versionId==(void 0!==e.from))throw new Error("Provide exactly one of --version or --from.");if(""===e.versionId||""===e.from)throw new Error("--version and --from require a nonempty value.")}function Ip(e,t){if(e.identifier!==t)throw new Error("The returned content does not match the requested content item.")}function Op(e){const t=new Map;for(const n of e.versions)for(const e of[n,...n.variants])for(const o of e.labels){let i=t.get(o.label);i||(i={label:o.label,sourceVersionIds:[],targets:[]},t.set(o.label,i)),i.sourceVersionIds.includes(n.identifier)||i.sourceVersionIds.push(n.identifier),i.targets.push({...o,versionId:e.identifier,sourceVersionId:n.identifier})}return{contentId:e.identifier,labels:[...t.values()].sort((e,t)=>e.label.localeCompare(t.label))}}async function Ap(e,t,n=Ep){$p(t);const o=await n.getContent(e,t);return Ip(o,t),Op(o)}async function Cp(e,t,n=Ep){var o,i;Tp(t);const a=await n.getContent(e,t.contentId);Ip(a,t.contentId);const r=Op(a);let s=t.versionId;if(t.from){const e=r.labels.find(e=>e.label===t.from);if(!e)throw new Error(`Source label '${t.from}' was not found.`);if(1!==e.sourceVersionIds.length)throw new Error(`Source label '${t.from}' is ambiguous; use --version.`);s=e.sourceVersionIds[0]}const c=a.versions.find(e=>e.identifier===s||e.variants.some(e=>e.identifier===s)),l=(null==c?void 0:c.identifier)===s?c:null==c?void 0:c.variants.find(e=>e.identifier===s);if(!l)throw new Error(`Version '${s}' was not found in this content item.`);if("completed"!==l.status)throw new Error("The selected version must have completed processing before assigning a label.");if(!await n.updateContentLabel({...e,content_id:t.contentId,job_id:l.identifier,type:t.label,action:"add_label"},{throwOnError:!0}))throw new Error("Label update failed.");let p;try{p=await Ap(e,t.contentId,n)}catch(e){throw new Error(`Label update was accepted, but verification failed: ${e instanceof Error?e.message:String(e)}`,{cause:e})}const u=p.labels.find(e=>e.label===t.label);if(null==u||!u.targets.some(e=>e.versionId===s))throw new Error("Label update was accepted, but the selected target could not be confirmed. Check the current label before retrying.");return{contentId:t.contentId,label:t.label,versionId:l.identifier,previousVersionIds:null!=(o=null==(i=r.labels.find(e=>e.label===t.label))?void 0:i.sourceVersionIds)?o:[],targets:u.targets}}const Rp=/token|secret|password|authorization|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret/i;function Np(e,t){return async function(n){const o=function(e,t){const n=[];if(e&&Object.keys(e).length>0&&n.push(`args=${Pp(e)}`),t&&Object.keys(t).length>0){const e=Object.fromEntries(Object.entries(t).map(([e,t])=>Rp.test(e)?[e,"<redacted>"]:[e,t]));n.push(`options=${Pp(e)}`)}return n.join(" ")}(null==n?void 0:n.args,null==n?void 0:n.options);wp(`CLI action: ${e}${o?" "+o:""}`);const i=Date.now();try{const o=await t(n);return wp(`CLI action: ${e} succeeded in ${Date.now()-i}ms`),o}catch(t){const n=t instanceof Error?t.message:String(t);throw yp(`CLI action: ${e} failed in ${Date.now()-i}ms: ${n}`),t}}}function Pp(e){try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():"function"==typeof t?"<fn>":t)}catch{return"<unserializable>"}}function Up(e,t){for(const o of e){var n;t(` ${o.displayName} (${o.versionId===o.sourceVersionId?"source":"derived"}, ${o.versionId}): ${null!=(n=o.url)?n:"URL unavailable"}\n`)}}async function Lp(e){if(!e.outDir)throw new Error("Output directory is required");const t=$("Downloading results...").start(),n=await async function(e){const t=await async function(e){if(!e.identifier)return null;const t={...ht(e)},n={job_id:e.identifier,fields:e.fields,content_format:e.content_format},o=e.baseUrl+ft.jobs.query,i=await fetch(o,{...gt,method:"POST",headers:t,body:JSON.stringify(n)}).catch(e=>(console.error(e),null));if(null==i)return null;if(!i.ok)return console.error("Failed to get job",i.status,await i.text()),null;const a=await i.json().catch(e=>(console.error(e),null));return null==a?null:a.job}({baseUrl:e.baseUrl,authToken:e.authToken,org:e.org,identifier:e.identifier,fields:["results"],content_format:e.content_format});if(null==t||!t.results)return{error:`Job ${e.identifier} did not produce any result files`};const n=t.results;if(!n.bucket||!n.directory)return{error:`Job ${e.identifier} has incomplete result data`};const o=[];for(const t of n.files){if((i=t.filename).startsWith(".extras/")||i.startsWith(".extras\\")||i.endsWith(xc)||yc.test(i)||i.endsWith(".needle.log"))continue;const a=`${n.directory}/${t.filename}`,r=await Fl(e,e.identifier,{bucket:n.bucket,key:a});if(!r){console.error(`Failed to get presigned URL for: ${t.filename}`);continue}const s=await fetch(r).catch(e=>(console.error(e),null));if(!s||!s.ok){console.error(`Failed to download (${null==s?void 0:s.status} | ${null==s?void 0:s.statusText}): ${t.filename}`);continue}const c=await s.arrayBuffer().catch(e=>(console.error(e),null));if(!c)return{error:`Failed to read downloaded file: ${t.filename}`};o.push({filename:t.filename,data:c})}var i;return{files:o}}({baseUrl:e.baseUrl,authToken:e.authToken,org:e.org,identifier:e.identifier,content_format:e.content_format});if("error"in n)return t.fail(n.error),{error:n.error};const o=[];for(const i of n.files){t.text=`Downloading ${i.filename}`,c(e.outDir)||m(e.outDir,{recursive:!0});let a=i.filename;if(e.filename){const t=i.filename.substring(i.filename.lastIndexOf("."));if(1===n.files.length)a=e.filename.includes(".")?e.filename:e.filename+t;else{const t=i.filename.substring(i.filename.lastIndexOf(".")),n=i.filename.substring(0,i.filename.lastIndexOf("."));a=e.filename+"-"+n+t}}const r=e.outDir+"/"+a,s=r.split("/").slice(0,-1).join("/");c(s)||m(s,{recursive:!0}),e.verbose&&console.log(`Writing ${i.filename} (${(i.data.byteLength/1024).toFixed(2)} KB) to "${r}"`),f(r,Buffer.from(i.data)),o.push(r)}return t.succeed(`Downloaded ${o.length} ${1===o.length?"file":"files"}: ${o.join(", ")}`),e.verbose&&console.log("Downloaded files:\n",o),{success:!0,paths:o}}async function zp(e){var t;if(e.wait&&e.noOptimize)return{error:"--wait cannot be combined with --no-optimize."};if(e.outDir&&!e.wait)return{error:"--outdir requires --wait."};if(e.outDir&&c(e.outDir)&&l(e.outDir).isFile())return{error:"The output directory is a file - it must be a directory"};if(""===e.outDir)return{error:"Output Directory is invalid"};if(e.format&&!["cli","json","source-url","edit-url"].includes(e.format))return{error:"Invalid output format."};if(e.usecase&&!["product","world"].includes(e.usecase))return{error:"Use case must be product or world."};const n=await async function(e,t={}){const n=t.purposeLabel?` ${t.purposeLabel}`:"";if(!c(e.fileOrDirectory))return $().fail(`File not found: ${e.fileOrDirectory}`),{error:"File not found"};if(!e.token||e.token.length<=1||"string"!=typeof e.token||"true"===e.token)return{error:`Missing access token. Create a token at ${op()}`};if(void 0!==e.name&&e.name&&(e.name.length<=0||"true"===e.name||"false"===e.name))return{error:`Name is not valid: "${e.name}". Please provide a valid name`};e.fileOrDirectory=w(e.fileOrDirectory);const o=$(`Gathering files ${e.fileOrDirectory}`).start();let i=null;try{i=sp("optimization",e.fileOrDirectory)}catch(t){return $().fail(t instanceof Error?t.message:`Failed to collect files in ${e.fileOrDirectory}`),{error:"Failed to collect files"}}if(!i.files.length)return o.fail("No supported files found."),{error:"No supported files found."};if(t.singleFile&&1!==i.files.length)return o.fail("source-url requires one file; use --format json for multiple files."),{error:"source-url requires one file; use --format json for multiple files."};const a=i.files.map(e=>e.path||e.name);o.text=`Uploading ${i.files.length} files${n}:\n- ${i.files.map(e=>e.path||e.name).join("\n -")}`;const r="https://cloud.needle.tools/api";e.verbose&&console.log("Using endpoint:",r);const s=function(e){var t,n;if(function(e){return e.some(e=>{let t=e.name.toLowerCase();return!!(t.endsWith(".html")||t.endsWith(".htm")||t.endsWith(".html.gz")||t.endsWith(".html.br"))||"mimetype"in e&&"text/html"===e.mimetype})}(e))return{kind:"deployment",contentType:void 0,uploadType:"deployment",canOptimize:!1,canConvertToGLB:!1};if(function(e){if(null==e||!e.length)return!1;const t=e.filter(e=>el(e.name)||tl(e.name)||nl(e.name));return 1===t.length&&hl(e)===t[0]}(e))return{kind:"environment-texture",contentType:"hdri",uploadType:void 0,canOptimize:!1,canConvertToGLB:!1};const o=null!=(t=null==(n=e[0])||null==(n=n.name.split(".").pop())?void 0:n.toLowerCase())?t:"";return{kind:"asset",contentType:"3d-asset",uploadType:void 0,canOptimize:e.some(e=>{var t;const n=null==(t=e.name.split(".").pop())?void 0:t.toLowerCase();return null!=n&&gl.has(n)}),canConvertToGLB:vl.has(o)}}(i.files),l="asset"===s.kind||"deployment"===s.contentType?void 0:s.contentType,p=await El({baseUrl:r,authToken:e.token,org:e.org_id},{triggered_by:"cli",files:i.files,entrypoint:i.entrypoint},{type:s.uploadType||"upload",name:e.name,content_type:l,...!1===t.optimizations?{optimizations:!1}:{},loglevel:e.verbose?"debug":"none",progress:e=>{o.text=`Uploading ${e.fileName} - finished in approx. ${e.estimatedTimeLeftDisplay}, ${100*e.progress01}%`}});if(0==p.success){const e=`${p.error||"Unknown error: could not start upload"}`;return o.fail(e),{error:e,noprint:!0}}const u=p.edit_url||`${ip()}/${p.content_id}?select_team=1`;return o.succeed(p.uploadSkipped?`Files have already been uploaded to ${u}`:`Uploaded ${i.files.length} files${n} to ${u}`),{res:p,editUrl:u,paths:a}}(e,{optimizations:!e.noOptimize&&void 0,purposeLabel:e.wait?"for optimization":void 0,singleFile:"source-url"===e.format});if("error"in n)return n;const{res:o,editUrl:i,paths:a}=n,r=a.map(e=>({path:e,sourceUrl:bt({baseUrl:"https://cloud.needle.tools/api",content_id:o.content_id,job_id:o.id})+e.split("/").map(encodeURIComponent).join("/")})),s={success:!0,assetId:o.content_id,versionId:o.id,editUrl:i,sourceUrl:1===r.length?r[0].sourceUrl:null,files:r,optimizedUrl:null,processingStatus:e.noOptimize?"not_requested":"unknown"};if(e.noOptimize&&$().info("No processing jobs were scheduled by this command (--no-optimize)."),!e.wait)return s;const p=function(e){return e.progressive?{progressive:!0,usecase:e.usecase||"product"}:{progressive:!1}}({progressive:null==(t=e.progressive)||t,usecase:e.usecase}),u=await async function(e,t={progressive:!0}){const n=e.baseUrl+ft.jobs.create,o={...ht(e),"content-type":"application/json"},i={type:"optimization",job_id:e.id,triggered_by:e.trigger_type,parameters:{...t}},a=await fetch(n,{...gt,method:"POST",headers:o,body:JSON.stringify(i)});if(!a.ok){const e=await a.text();return console.error(`Failed to request optimization (${a.status}): ${e} `),null}return await a.json().catch(e=>(console.error(e),null))}({baseUrl:"https://cloud.needle.tools/api",authToken:e.token,org:e.org_id,id:o.id,trigger_type:"cli"},p);if(!u)return{error:"Failed to send optimization request"};if("error"in u)return{error:`Failed to optimize: ${u.error}`};const d=u.job,m=$(`Optimization requested for ${d.name||d.identifier}`).start(),f=jc();let h=d.status;for(;"completed"!==h;){if("failed"===h||"canceled"===h){const e=d.error||`Optimization ${h}`;return m.fail(e),{error:e}}const t=await _c(d.identifier,{baseUrl:"https://cloud.needle.tools/api",authToken:e.token,org:d.org}),n=f.record(t);if(n)return m.fail(n.reason),{error:n.reason};if("failed"in t)await ul(2e3);else{if(h=t.status,"failed"===h||"canceled"===h){const e=t.error||`Optimization ${h}`;return m.fail(e),{error:e}}"completed"!==h&&(m.text=t.status_message||("running"===h?"Your asset is being optimized":"Waiting for optimization"),await ul("running"===h?1e3:"stalled"===h?2500:2e3))}}if(m.succeed("Optimization completed"),s.processingStatus="completed",s.optimizedUrl=bt({baseUrl:"https://cloud.needle.tools/api",content_id:o.content_id,job_id:d.identifier}),s.optimization={versionId:d.identifier,progressive:p.progressive,...p.usecase?{usecase:p.usecase}:{}},e.outDir){const t=await Lp({baseUrl:"https://cloud.needle.tools/api",authToken:e.token,org:e.org_id,identifier:d.identifier,outDir:e.outDir,verbose:e.verbose});if("error"in t)return t}return s}function Fp(e,t,n){if("error"in e)throw new Error(e.error);if("source-url"===t){if(!e.sourceUrl)throw new Error("source-url requires one file; use --format json for multiple files.");n(e.sourceUrl+"\n")}else if("edit-url"===t)n(e.editUrl+"\n");else if("json"===t){const{success:t,...o}=e;n(JSON.stringify(o)+"\n")}else{var o;n(`Edit: ${e.editUrl}\n`);for(const t of e.files)n(`Source (${t.path}): ${t.sourceUrl}\n`);e.optimizedUrl&&n(`Optimized (${null!=(o=e.optimization)&&o.progressive?"progressive-"+e.optimization.usecase:"non-progressive"}): ${e.optimizedUrl}\n`)}}async function Dp(e){const{token:t,org_id:n,slug:o,message:i,stream:a}=e;if(a){const e=Jl({baseUrl:"https://cloud.needle.tools/api",authToken:t,org:n},{slug:o,message:i,stream:!0,source:"cli"});for await(const t of e)switch(t.type){case"delta":process.stdout.write(t.content);break;case"message":break;case"status":process.stdout.write(`[${t.message}]\n`);break;case"error":return void $().fail(t.message);case"tool_call":process.stdout.write(`[tool: ${t.name}]\n`);break;case"done":process.stdout.write("\n")}}else{const e=$("Thinking...").start(),a=await Jl({baseUrl:"https://cloud.needle.tools/api",authToken:t,org:n},{slug:o,message:i,stream:!1,source:"cli"});e.stop(),console.log(a.content)}}async function qp(e,t=Ml){if(!e.identifier)throw new Error("A content identifier is required");return t({baseUrl:e.endpoint,authToken:e.authToken,org:e.org},e.identifier)}async function Bp(e){const t=new URL((e.endpoint||"https://cloud.needle.tools/api")+ft.get.deployments);t.searchParams.append("offset",e.offset.toString()),t.searchParams.append("limit",e.limit.toString()),e.names&&t.searchParams.append("name",e.names.map(e=>e.trim()).join(","));const n=await fetch(t,{method:"GET",headers:{...ht({authToken:e.authToken,org:e.org})}});return n.ok?await n.json():{status:n.status,error:await n.text()}}const Mp=["#e06c75","#d19a66","#e5c07b","#98c379","#7ec8a4","#56b6c2","#61afef","#528bff","#c678dd","#e88de4","#be5046","#d4976c","#b5cea8","#4ec9b0","#9cdcfe","#c8ae9d"];function Wp(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;const[n,o,i]=function(e){const t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,255&t]}(Mp[Math.abs(t)%Mp.length]);return`[38;2;${n};${o};${i}m${e}[0m`}function Hp(e){return`[2m${e}[0m`}const Gp=8424,Jp="http://localhost:8424",Vp=/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]\s?(.*)$/,Kp=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}):\s*(.*)$/,Yp=[[/^\[MCP\]|^MCP (New session|websocket server|Request|SSE|Bridge)|^Unknown MCP/,"mcp"],[/^Needle Cloud connection:|^Cloud tool (request|result|error):/,"cloud"],[/^Denied:/,"denial"],[/^Local (server|token)|^Starting Needle CLI server|^Restarting auth server|^Server is running|^Running server uses different/,"server"],[/^OIDC:|^Sign in|^Sign out|^User logged in|^Logged in successfully|^Token refresh failed|^Failed to validate (login|logout)|^Getting access token|^No access token|^ERR: Missing NEEDLE_CLOUD_TOKEN|^Too many logins|^WARN: You do not have a default organization|^User signed in|^Error during sign in/,"auth"],[/^Settings(:| changed)/,"settings"],[/^\[Deployment\]|^Deployment started/,"deployment"],[/^\[generate-material\]/,"ai"],[/^Active project changed|^Error saving project info/,"project"]],Zp=[[/^ERR:|^ERROR:|^Error\b|^Failed\b/,"error"],[/\bconnection: error\b|\bFailed to\b|\b(Token refresh failed)\b|\b(rejected|terminating|pong timeout)\b/i,"error"],[/^WARN:|^WARNING:|^Warning\b/,"warn"]];function Xp(e){for(const[t,n]of Yp)if(t.test(e))return n;return"general"}function Qp(e){for(const[t,n]of Zp)if(t.test(e))return n;return"info"}const eu=new RegExp("\\b([A-Z][A-Z0-9_]*(?:_KEY|_TOKEN|_SECRET|_PASSWORD))=([^\\s,;\"']+)","g"),tu=new RegExp("\\b(User(?:name)?:\\s*)([A-Za-z0-9._\\-]{1,64})","g"),nu=new RegExp("\\b[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,}\\b","g"),ou=52428800;function iu(e,t){if(!T(e))return null;if(t<=0)return"";const{size:n}=C(e);if(0===n)return"";const o=n>t?n-t:0,i=n-o,a=Buffer.allocUnsafe(i),r=P(e,"r");try{let e=0;for(;e<i;){const t=U(r,a,e,i-e,o+e);if(0===t)break;e+=t}}finally{L(r)}if(o>0){const e=a.indexOf(10);return-1===e?"":a.slice(e+1).toString("utf8")}return a.toString("utf8")}async function*au(e){const t=ze({input:z(e,{encoding:"utf8"}),crlfDelay:Infinity});for await(const e of t)yield e}function ru(e,t,n,o){var i,a;if(0===e.length)return[];const r=function(e){if("string"!=typeof e)return{ts:null,level:"info",source:"general",message:""};let t=null,n=e,o=e.match(Vp);if(o)t=o[1],n=o[2];else if(o=e.match(Kp),o){const e=new Date(`${o[1]}T${o[2]}`);Number.isNaN(e.getTime())||(t=e.toISOString(),n=o[3])}return{ts:t,level:Qp(n),source:Xp(n),message:n}}(e),s=null!=(i=null!=(a=r.ts)?a:n)?i:null,c=r.level,l=null!=t?t:r.source;return function(e){if("string"!=typeof e)return[e];if(e.length<=16384)return[e];const t=e.length,n=Math.max(1,16344),o=Math.ceil(t/n),i=[];for(let a=0;a<o;a++){const r=a*n,s=e.slice(r,r+n);i.push(`${s} [chunk ${a+1}/${o} of ${t} bytes]`)}return i}(function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;let n=fp(e);return n=function(e,t){if(!t)return e;const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\\/g,"\\\\+"),o=new RegExp(n,"gi");return e.replace(o,"~")}(n,null==t?void 0:t.homeDir),n=function(e){return e.replace(eu,(e,t,n)=>`${t}=<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(tu,(e,t,n)=>`${t}<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(nu,e=>`<redacted:${e.length}ch>`)}(n),n}(r.message,o)).map(e=>({ts:s,level:c,source:l,message:e}))}const su="https://haystack.needle.tools/api/ingest/logs",cu="https://haystack.needle.tools";async function lu(e){try{return await e.json()}catch{return null}}async function pu(e){try{return await e.text()}catch{return""}}function uu(e){const t=e instanceof Error?e.message:String(e),n=e&&"object"==typeof e?e.cause:void 0;let o=t;if(n){const e=n instanceof Error?n.message:String(n),t="object"==typeof n&&null!==n?n.code:void 0;o=t?`${e} (${t})`:e}return`Network error reaching ${su}: ${o}`}var du,mu={__proto__:null,HAYSTACK_RESOURCE:cu,runSendLogs:async function(e,t){var n;let o=await t.getAccessToken();if(!o&&t.recoverAuth)try{t.stdout.write("Updating sign-in (your stored permissions need a one-time refresh)...\n"),o=await t.recoverAuth()}catch{o=null}if(!o)return{ok:!1,error:"Not signed in. Run `needle-cloud login` first, then retry."};const i={type:"meta",...t.meta,mode:e.mode,...e.note?{note:e.note}:{}},a=t.findActiveEditorLog(),r=function(e){const t=Fe.from(async function*(e){if(yield JSON.stringify(e.meta)+"\n",e.prevLogPath&&T(e.prevLogPath)){let t=null;for await(const n of au(e.prevLogPath)){const o=ru(n,null,t,e.redactOpts);for(const e of o)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}if(e.cliLogPath&&T(e.cliLogPath)){let t=null;for await(const n of au(e.cliLogPath)){const o=ru(n,null,t,e.redactOpts);for(const e of o)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}if(e.editor){var t,n;const o=null!=(t=e.editor.tailBytes)?t:ou,i=null!=(n=e.editor.paths)?n:e.editor.path?[e.editor.path]:[];for(const t of i){const n=iu(t,o);if(!n)continue;let i=null;try{i=C(t).mtime.toISOString()}catch{}for(const t of n.split("\n")){const n=ru(t,e.editor.editor,i,e.redactOpts);for(const e of n)e.ts&&(i=e.ts),yield JSON.stringify(e)+"\n"}}}if(e.pipelineLogPath&&T(e.pipelineLogPath)){var o;const t=null!=(o=e.pipelineTailBytes)?o:ou,n=iu(e.pipelineLogPath,t);if(n){let t=null;try{t=C(e.pipelineLogPath).mtime.toISOString()}catch{}for(const o of n.split("\n")){const n=ru(o,"gltf-build-pipeline",t,e.redactOpts);for(const e of n)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}}}(e),{objectMode:!1});return t.pipe(De())}({meta:i,cliLogPath:t.paths.cliLogPath,prevLogPath:t.paths.prevLogPath,editor:a,pipelineLogPath:null!=(n=t.paths.pipelineLogPath)?n:null,redactOpts:{homeDir:t.paths.homeDir}});if(e.dryRun){const{gunzipSync:e}=await import("node:zlib"),n=[];for await(const e of r)n.push(e);const o=e(Buffer.concat(n)).toString("utf8");return t.stdout.write(o),{ok:!0}}let s,c;try{const e=[];for await(const t of r)e.push(t);s=Buffer.concat(e)}catch(e){return{ok:!1,error:`Failed to build upload payload: ${e instanceof Error?e.message:String(e)}`}}try{c=await t.fetch(su,{method:"POST",body:s,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/x-ndjson","Content-Encoding":"gzip"}})}catch(e){return{ok:!1,error:uu(e)}}if(401===c.status){const e=await pu(c);return{ok:!1,error:`401 Unauthorized from ${su}: ${e&&e.length>0?e:"no reason given"} (try \`needle-cloud login\` if your sign-in expired; if you're already signed in, the server may not accept this token's issuer/audience)`}}if(429===c.status){const e=await pu(c);return{ok:!1,error:`429 Rate-limited: ${e&&e.length>0?e:"no reason given"}. You've hit the upload quota for this account; try again later.`}}if(413===c.status){const e=await lu(c);return{ok:!0,refId:null==e?void 0:e.ref_id,truncated:!0}}if(!c.ok){const e=await pu(c);return(400===(l=c.status)||l>=500)&&await async function({token:e,fetch:t,baseMeta:n,status:o,bodyText:i}){const{gzipSync:a}=await import("node:zlib"),r={type:"meta",...n,mode:"crash",note:"send-logs upload error follow-up"},s={ts:(new Date).toISOString(),level:"error",source:"send-logs",message:`Upload failed: status=${o} body=${(null!=i?i:"").slice(0,1024)}`},c=JSON.stringify(r)+"\n"+JSON.stringify(s)+"\n",l=a(Buffer.from(c,"utf8"));await t(su,{method:"POST",body:l,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/x-ndjson","Content-Encoding":"gzip"}})}({token:o,fetch:t.fetch,baseMeta:t.meta,status:c.status,bodyText:e}).catch(()=>{}),{ok:!1,error:`Server returned ${c.status}: ${e}`}}var l;const p=await lu(c);return{ok:!0,refId:null==p?void 0:p.ref_id,truncated:Boolean(null==p?void 0:p.truncated)}}};const fu={appId:"2stnsoa6a1b0gwc7lra55",appSecret:"seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",endpoint:"https://auth.needle.tools",resources:["https://cloud.needle.tools/api",cu],scopes:["openid","profile","email","roles","urn:logto:scope:organizations","urn:logto:scope:organization_roles","identities","custom_data","all","read","write","delete","upload","download","invite","editor","cli:logs:write"]},hu={getAccessToken:!0,fetchUserInfo:!0,resource:null==(du=fu.resources)?void 0:du[0],resources:fu.resources||[],scopes:fu.scopes||[]};function gu(e="default"){return null==e?`${Jp}/?signed-out=1`:"too-many-logins"===e?`${Jp}/?too-many-logins=1`:"error"===e?`${Jp}/?error=1`:`${Jp}/?signed-out=1`}var vu;function bu(){yu.clear(),s.existsSync(ju)&&s.rmSync(ju,{recursive:!0}),s.existsSync(ku)&&s.rmSync(ku,{recursive:!0})}const xu=process.argv.includes("--debug-auth"),yu=new Map;let wu=null==(vu=fu.resources)?void 0:vu[0];if(wu)try{wu=new URL(wu).hostname}catch(e){xu&&console.error("Invalid resource URL",wu)}let _u=wu||"-";_u=_u.replace(/[^a-zA-Z0-9\.\-]/g,"");const ju=y.join(Te(),".needle",".auth",_u),ku=`${Ie()}/Needle/Cloud/.auth/${_u}`;!function(){if(s.existsSync(ku)){xu&&console.debug("Migrating auth data from legacy location",ku,"→",ju);try{s.existsSync(ju)||s.mkdirSync(ju,{recursive:!0,mode:448});for(const e of s.readdirSync(ku)){const t=y.join(ku,e),n=y.join(ju,e);s.statSync(t).isFile()&&!s.existsSync(n)&&(s.copyFileSync(t,n),s.chmodSync(n,384))}s.rmSync(ku,{recursive:!0}),xu&&console.debug("Legacy auth data migrated successfully")}catch(e){xu&&console.error("Failed to migrate legacy auth data",e)}}}();const Su={accessToken:`${ju}/accessToken`,refreshToken:`${ju}/refreshToken`,idToken:`${ju}/idToken`,signInSession:`${ju}/signInSession`};function Eu(e){return Su[e]||`${ju}/${e}`}const $u=new class{constructor(){this.basePath=ju}async setItem(e,t){xu&&console.debug("\n- SET ITEM",e,t),s.existsSync(this.basePath)||s.mkdirSync(this.basePath,{recursive:!0,mode:448});const n=Eu(e);n&&s.writeFileSync(n,t,{mode:384}),yu.set(e,t)}async getItem(e){xu&&console.debug("\n- GET ITEM",e);const t=yu.get(e);if(void 0===t){const t=Eu(e);if(t){if(s.existsSync(t)){const n=s.readFileSync(t,"utf8");return yu.set(e,n),n}}else console.error(`Unknown token name: ${e}`);return null}return String(t)}async removeItem(e){xu&&console.debug("\n- REMOVE ITEM",e),yu.delete(e);const t=Eu(e);if(t&&s.existsSync(t)){try{const e=s.statSync(t).size;e>0&&s.writeFileSync(t,Buffer.alloc(e,0),{mode:384})}catch{}s.rmSync(t)}}};let Tu=null;function Iu(){return Tu||(Tu=new Le(fu,{storage:$u,navigate:()=>{}})),Tu}function Ou(){Tu=null}let Au=Promise.resolve();function Cu(e){const t=Au.then(e,e);return Au=t.then(()=>{},()=>{}),t}async function Ru(e){return Nu(Iu(),e)}async function Nu(e,t){try{const n=await Cu(()=>e.getAccessToken(t));return null!=n?n:null}catch(e){return function(e){return Boolean(e)&&"object"==typeof e&&"not_authenticated"===e.code}(e)||(wp(`Token refresh failed for resource ${t}: ${e instanceof Error?e.message:e}`),Pu(e)&&(wp(`Token refresh: clearing dead grant for resource ${t}`),bu(),Tu=null)),null}}function Pu(e){return function(e){var t,n;if(!e||"object"!=typeof e)return!1;const o=e,i=e=>{if("string"!=typeof e)return!1;const t=e.replace(/^oidc\./,"");return"invalid_grant"===t||"invalid_target"===t};return i(o.code)||i(null==(t=o.data)?void 0:t.error)||i(null==(n=o.data)?void 0:n.code)}(e)}async function Uu(){return Ru(hu.resource)}function Lu(){return Du(Iu())}async function zu(e){var t;if(!e)return{status:401,error:"Not authenticated"};const n=null==(t=e.userInfo)?void 0:t.custom_data;return n?n.default_org?n.default_org:(console.warn("WARN: You do not have a default organization set. Please visit your Needle Cloud account settings and then try again."),wp("WARN: You do not have a default organization set. Please visit your Needle Cloud account settings and then try again."),null):null}function Fu(e){return new Le(fu,{storage:$u,navigate:t=>{if(null==e.navigate)throw new Error("Can not navigate");e.navigate(t)}})}function Du(e){return function(e,t){return Cu(()=>e.getContext(t))}(e,hu).then(t=>{const n=t;return n.client=e,n}).catch(async e=>{const t=e instanceof Error?e.message:String(e);return"oidc.invalid_token"==e.code||"oidc.invalid_grant"==e.code?(wp(`OIDC: ${e.code} – token refresh failed, clearing stale tokens`),bu(),Tu=null,console.error("Session expired – please log in again: npx needle-cloud login")):e.code?(console.error(e.code),wp(`OIDC: ${e.code} – ${t}`)):wp(`OIDC: getContext failed – ${t}`),null})}var qu={__proto__:null,resetSharedClient:Ou,tryGetFreshAccessTokenForResource:Ru,acquireAccessToken:Nu,shouldClearAuthOnError:Pu,tryGetFreshAccessToken:Uu,tryGetUser:Lu,tryGetDefaultOrgId:zu,createNodeClient:Fu,getUserFromClient:Du};function Bu(e){var t,n,o,i;if(!e)return"";let a=(null==(t=e.claims)?void 0:t.name)||(null==(n=e.userInfo)?void 0:n.name)||(null==(o=e.claims)?void 0:o.username)||"";var r;return(!a||a.length<=0)&&null!=(i=e.claims)&&i.email?function(e){return e?(e=(e=(e=(e=e.split("@")[0]).replace(/[^a-zA-Z0-9]/g," ")).replace(/\s+/g," ")).split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),e):e}(null==(r=e.claims)?void 0:r.email):a}async function Mu(e,t=null){var n,o;if(!e)return{status:500,error:"User is not provided"};if(!e.isAuthenticated)return{status:403,error:"User is not authenticated"};const i=(null==(n=e.claims)?void 0:n.sub)||(null==(o=e.userInfo)?void 0:o.sub);t===i&&(t=null);let a=null;if(null==t)a=e.accessToken;else if(null!=t){var r;let n=null==e||null==(r=e.userInfo)||null==(r=r.organization_data)?void 0:r.find(e=>e.id===t);if(!n){var s;const o=t.toLowerCase();n=null==e||null==(s=e.userInfo)||null==(s=s.organization_data)?void 0:s.find(e=>e.name.toLowerCase()===o)}if(!n)return{status:403,error:`User is not part of team "${t}"`};t=n.id,a=await e.client.getOrganizationToken(n.id).catch(e=>{var o;return console.error(`Error getting organization token for "${null==(o=n)?void 0:o.name}" (${t}): ${e.message}`),null})}return a?{authToken:a,org:t}:{status:403,error:"No access token found"}}const Wu=function(){return async(e,t,n)=>{const o=await Lu();Object.defineProperty(e,"user",{enumerable:!0,get:()=>o}),n()}};let Hu=null;function Gu(e){var t;const n=null==(t=e.userInfo)?void 0:t.custom_data;if(!n)return[];const o=n.machines;return o?o.map(e=>e.name):[]}let Ju=Date.now();async function Vu(e){var t;const n=Date.now();n-Ju>3e4&&"client"in e&&(Ju=n,await e.client.fetchUserInfo().catch(console.error));const o=null==(t=e.userInfo)?void 0:t.custom_data;if(!o)return!1;if(Hu||await Ku(),!Hu)return console.error("Failed to get machine id"),!0;const i=o.machines;if(!i)return!1;const a=i.some(e=>e.id===Hu);return a}async function Ku(){return Hu||await import("node-machine-id").then(async e=>{const t=await e.default.machineId(!1);Hu=t}),Hu}function Yu(){return $e.userInfo().username+"@"+$e.hostname()}async function Zu(e,t={signout:!1}){if(e.accessToken){const o={machine_id:await Ku(),machine_name:Yu(),platform:$e.platform(),arch:$e.arch()},i=await fetch("https://cloud.needle.tools/api"+ft.account.post_machine,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify(o)}).catch(e=>{var t,n;const o=(null==e||null==(t=e.cause)?void 0:t.code)||(null==e||null==(n=e.cause)?void 0:n.message)||(null==e?void 0:e.message)||"connection refused";return console.error(`Failed to validate login: ${o} - Make sure https://cloud.needle.tools/api is reachable`),wp(`Failed to validate login: "${o}" - Make sure https://cloud.needle.tools/api is reachable.`),{status:502,error:`Failed to validate login at 'https://cloud.needle.tools/api' (${o}) - make sure this URL is reachable.`}});if(!i)return!1;if("error"in i)return i;let a=!0;if(403===i.status){const e=await i.text();if(e.trimStart().startsWith("{")){const t=JSON.parse(e);t.logins&&(a=!1,wp("Too many logins from different machines"),$().fail("You have reached the maximum number of allowed logins\n"),$().warn(`Please logout from one of the following machines:\n- ${t.logins.join("\n- ")}\n`))}}var n;return!!a||(t.signout&&(bu(),"client"in e&&(null==(n=e.client)||n.signOut(gu("too-many-logins")))),!1)}return!0}let Xu=null;function Qu(){if(Xu)return Xu;{const e=rd();return Xu=e,e}}const ed="projects.json";function td(e){e.entries.sort((e,t)=>t.last_accessed-e.last_accessed);let t=0;e.entries=e.entries.filter(e=>"cli"===e.source||++t<=30),f(ad(),JSON.stringify(e),"utf-8"),Xu=e}function nd(){var e;const t=Qu(),n=t.selected_web_project;if(n){const e=t.entries.find(e=>e.web_location&&w(e.web_location)===n);if(e)return e}return null!=(e=t.entries[0])?e:null}function od(e){const t=h.native(e);if(!l(t).isDirectory()||!c(_(t,"package.json")))throw new Error("The web project must be a directory with package.json.");const n=Qu(),o=n.entries.find(e=>e.web_location&&w(e.web_location)===t);if(o)return o.last_accessed=Date.now(),n.selected_web_project=t,td(n),o;const i={web_location:t,source:"cli",editor:"unknown",last_accessed:Date.now()};return n.entries.unshift(i),n.selected_web_project=t,td(n),i}function id(e){if("string"!=typeof e||!e)throw new Error("A registered project path is required.");const t=Qu(),n=w(e),o=t.entries.find(e=>e.web_location&&w(e.web_location)===n);if(null==o||!o.web_location)throw new Error("This web project is not registered with the local Needle CLI.");const i=h.native(o.web_location);if(!l(i).isDirectory()||!c(_(i,"package.json")))throw new Error("The registered web project is no longer available.");return o.last_accessed=Date.now(),t.selected_web_project=i,t.entries=[o,...t.entries.filter(e=>e!==o)],td(t),o}function ad(){const e=process.env.HOME||process.env.USERPROFILE||process.cwd(),t=_(e,".needle");return c(t)||m(t,{recursive:!0}),_(t,ed)}function rd(){const e=ad();if(!c(e))return{entries:[]};const t=p(e,"utf-8");try{const e=JSON.parse(t);return Xu=e,e}catch(e){return console.error("Failed to parse project info file:",e),{entries:[]}}}const sd=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8"));function cd(){return sd.version}const ld=process.env.NEEDLE_SEARCH_ENDPOINT||"https://search.needle.tools",pd=process.env.NEEDLE_SEARCH_API_KEY||"da5737c00d6822c32a1b9e3b5dab094bfc17e205aef2f7f3e1a0fd4ebc77b79f",ud=[{name:"needle_my_account",description:"Get current Needle Cloud user information",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},{name:"needle_search",description:"Search Needle Engine documentation, forum posts, and community discussions. Returns relevant content ranked by semantic similarity. Use this to find information about Needle Engine features, APIs, components, workflows, and troubleshooting.\n\nIMPORTANT: If search results seem irrelevant or low-quality (scores below 0.6, or results don't match the topic), retry with different search terms — up to 3 total attempts. Try varying your query: use specific class/method names, try shorter keyword-based queries, or rephrase the question. Do NOT guess or fabricate answers based on poor search results.",inputSchema:{type:"object",properties:{query:{type:"string",description:'What to search for, e.g. "how to add physics components" or "WebXR hand tracking" or "deploy to vercel"'},limit:{type:"number",description:"Maximum number of results to return (1-20, default 5)"}},additionalProperties:!1,required:["query"]}}],dd={needle_my_account:async function(e){try{const e=await Lu(),t=null==e?void 0:e.userInfo;return t?JSON.stringify({id:t.sub,name:t.name||t.preferred_username,email:t.email,profile_picture:t.picture}):"No user is currently logged in."}catch(e){return"Error retrieving user: "+(e instanceof Error?e.message:String(e))}},needle_search:async function(t){const n=t.query;if(!n||"string"!=typeof n)return{content:[{type:"text",text:"Error: query parameter is required."}]};const o=Math.min(Math.max(Number(t.limit)||5,1),20),i=`${ld}/api/semantic-search?q=${encodeURIComponent(n)}&limit=${o}`,a={Accept:"application/json"};pd&&(a.Authorization=`Bearer ${pd}`);try{const t=await e(i,{headers:a,signal:AbortSignal.timeout(15e3)});if(!t.ok){const e=await t.text().catch(()=>"");return{content:[{type:"text",text:`Search API error (${t.status}): ${e}`}]}}const o=await t.json();if(!o.results||0===o.results.length)return{content:[{type:"text",text:`No results found for: "${n}"`}]};const r=o.results.map((e,t)=>`## [${t+1}] ${e.title} (score: ${e.score})\nSource: ${e.source}${e.url?` — ${e.url}`:""}\n\n`+e.content+(e.truncated?`\n\n> Content truncated (${e.content.length} of ${e.contentLength} chars shown).${e.url?` Full content: ${e.url}`:""}`:"")).join("\n\n---\n\n");return{content:[{type:"text",text:`Found ${o.results.length} results for "${n}" (${o.durationMs}ms):\n\n${r}`}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e instanceof Error?e.message:String(e)}`}]}}}},md=new Map;function fd(e,t){const n=ud.findIndex(t=>t.name===e);if(-1!==n){ud.splice(n,1),delete dd[e];for(const t of md.values())t.delete(e);t()}}function hd(e,t,n,o){const i=ud.findIndex(t=>t.name===e.name);if(-1!==i){var a;const t=null==(a=[...md.entries()].find(([,t])=>t.has(e.name)))?void 0:a[0];if(!t||t!==(null==n?void 0:n.source))throw new Error(`Tool "${e.name}" is already registered by ${null!=t?t:"the CLI"}.`);ud.splice(i,1)}if(ud.push(e),dd[e.name]=t,gd.delete(e.name),null!=n&&n.source){const t=md.get(n.source)||new Set;t.add(e.name),md.set(n.source,t)}o()}const gd=new Map;async function vd(e,t,n={}){const o=dd[e];if(!o){const t=gd.get(e);if(t)return{isError:!0,content:[{type:"text",text:`This tool is currently unavailable because "${t}" disconnected. Please reconnect (e.g. reopen the browser tab) and try again. You should also call tools/list to refresh your available tools.`}]};throw new Error(`Tool "${e}" is not registered.`)}const i=await o(t,n);if("string"==typeof i)return{content:[{type:"text",text:i}]};if("object"==typeof i)return Array.isArray(i.content)?i:{content:[{type:"text",text:JSON.stringify(i)}]};throw new Error(`Invalid tool result type for tool "${e}".`)}const bd=200,xd=2e3,yd=new RegExp("^[A-Za-z0-9_./*?\\[\\]{},\\-]+$"),wd="[REDACTED]";function _d(e){return/(?:password|passwd|pwd|secret|token|apikey|privatekey|accesskey|connectionstring|databaseurl|authorization|credentials)$/.test(e.toLowerCase().replace(/[^a-z0-9]/g,""))}function jd(e){return"string"==typeof e?Sd(e):Array.isArray(e)?e.map(jd):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,_d(e)&&null!==t?wd:jd(t)])):e}function kd(e){var t;return wd+"\n".repeat((null!=(t=e.match(/\n/g))?t:[]).length)}function Sd(e){let t=e.replace(/-----BEGIN (?:[A-Z0-9 ]*PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g,kd);const n=t.split("\n");for(let e=0;e<n.length;e++){const t=/^([ \t]*)([\w.-]+)\s*:[ \t]*(?:[|>][^\n]*)?$/.exec(n[e]);if(!t||!_d(t[2]))continue;const a=t[1].length;for(n[e]=wd;e+1<n.length&&(!n[e+1].trim()||(null!=(o=null==(i=n[e+1].match(/^[ \t]*/))?void 0:i[0].length)?o:0)>a);){var o,i;n[++e]=wd}}return t=n.join("\n"),t=t.replace(/\b(?:Authorization\s*:\s*(?:Basic|Bearer)\s+|Bearer\s+)[^\s"',;]+/gi,e=>e.substring(0,e.lastIndexOf(" ")+1)+wd),t=t.replace(/(?<![\w.-])((?:["']?[\w.-]*(?:password|passwd|pwd|secret|token|api[_-]?key|private[_-]?key|access[_-]?key|connection[_-]?string|database[_-]?url|authorization|credentials)["']?)[ \t]*[:=][ \t]*)("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[^\s,;\]}]+)/gi,(e,t,n)=>{var o;if(!_d(t.split(/[:=]/)[0].replace(/["'\s]/g,""))||/^(?:process\.env\.|import\.meta\.env\.|\[REDACTED\])/.test(n))return e;const i=n.startsWith('"')?'"':n.startsWith("'")?"'":n.startsWith("`")?"`":"";return t+i+wd+i+"\n".repeat((null!=(o=n.match(/\n/g))?o:[]).length)}),t=t.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/@]+:[^\s/@]+@/gi,"$1"+wd+"@"),t=t.replace(/([?&])([\w%-]+)=([^&#\s"']*)/g,(e,t,n)=>_d(function(e){try{return decodeURIComponent(e)}catch{return e}}(n))?t+n+"="+wd:e),t.replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|sk-(?:proj-|live_|test_)?[A-Za-z0-9_-]{20,}|(?:AKIA|ASIA)[A-Z0-9]{16}|xox[baprs]-[A-Za-z0-9-]{15,}|AIza[A-Za-z0-9_-]{30,}|npm_[A-Za-z0-9]{20,}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)\b/g,wd)}function Ed(e){if(/^\s*[\[{]/.test(e)){try{JSON.parse(e)}catch{return Sd(e)}const o=/"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|[{}\[\]:,]|\s+/g;let i,a="",r=0;for(;null!==(i=o.exec(e));){var t;if(!i[0].startsWith('"'))continue;let s=i.index+i[0].length;for(;/[ \t\r\n]/.test(null!=(n=e[s])?n:"");){var n;s++}if(":"!==e[s])continue;const c=JSON.parse(i[0]);if("string"!=typeof c||!_d(c))continue;o.lastIndex=s+1;let l=o.exec(e);for(;l&&/^\s+$/.test(l[0]);)l=o.exec(e);if(!l)throw new Error("Invalid JSON credential value.");const p=l.index;let u=p+l[0].length;if("{"===l[0]||"["===l[0]){let t=1;for(;t;){const n=o.exec(e);if(!n)throw new Error("Invalid JSON credential value.");"{"!==n[0]&&"["!==n[0]||t++,"}"!==n[0]&&"]"!==n[0]||t--,u=n.index+n[0].length}}a+=e.slice(r,p)+JSON.stringify(wd)+"\n".repeat((null!=(t=e.slice(p,u).match(/\n/g))?t:[]).length),r=u}return a+=e.slice(r),a.replace(/"(?:\\.|[^"\\])*"/g,e=>JSON.stringify(Sd(JSON.parse(e))))}return Sd(e)}class $d extends Error{}function Td(e){return e.split(/[\\/]/).some(e=>{const t=e.toLowerCase().replace(/[ .]+$/,"");return/^(?:\.env(?:\..*)?|\.envrc|\.npmrc|\.pypirc|\.netrc|\.yarnrc(?:\.yml)?|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?|credentials(?:\.[\w.-]+)?|service[-_]?account(?:\.[\w.-]+)?|\.ssh|\.aws|\.docker|\.azure|\.kube|\.gnupg|\.needle|\.git)$/.test(t)||/(?:^|[._-])(?:credentials|secrets)(?:\.(?:json|ya?ml|toml|ini|txt))?$/.test(t)||/\.(?:env|pem|key|p12|pfx|jks|keystore|kdbx)$/.test(t)})}function Id(e,t){const n=re(e,t);return""===n||!ce(n)&&".."!==n&&!n.startsWith(".."+le)}function Od(e,t,n={}){if("string"!=typeof t||!t||t.includes("\0"))throw new $d("Invalid file path.");const o=A(e),i=ae(o,t);if(!Id(o,i))throw new $d("Path is outside the connected project.");const a=re(o,i);if(a.split(/[\\/]/).some(e=>e.includes(":")||/[ .]$/.test(e)))throw new $d("Invalid file path.");if(Td(e)||Td(o)||Td(a))throw new $d("Sensitive files cannot be accessed by local AI tools.");let r=i;for(;!T(r)&&r!==o&&n.allowMissing;)r=se(r);const s=A(r);if(!Id(o,s))throw new $d("Path is outside the connected project.");const c=ae(s,re(r,i));if(Td(c))throw new $d("Sensitive files cannot be accessed by local AI tools.");return{root:o,path:c}}function Ad(e,t,n={}){var o,i;const a=Od(e,t);if(!C(a.path).isFile())throw new $d("Path is not a regular file.");const r=P(a.path,F.O_RDONLY|(null!=(o=F.O_NOFOLLOW)?o:0)|(null!=(i=F.O_NONBLOCK)?i:0));try{var s;const o=D(r);if(!o.isFile())throw new $d("Path is not a regular file.");if(o.nlink>1)throw new $d("Hard-link aliases cannot be read by local AI tools.");const i=null!=(s=n.maxBytes)?s:8388608;if(!Number.isSafeInteger(i)||i<0||i>67108864)throw new $d("Invalid read size limit.");const l=n.range;if(l&&(!Number.isSafeInteger(l.offset)||!Number.isSafeInteger(l.length)||l.offset<0||l.length<0||l.offset+l.length>o.size))throw new $d("Invalid file byte range.");if((l?l.length:o.size)>i)throw new $d(`File exceeds the ${i} byte read limit.`);const p=Od(e,t),u=C(p.path);if(p.path!==a.path||o.ino!==u.ino||o.dev!==u.dev)throw new $d("File path changed while opening. Retry the request.");const d=Buffer.alloc(Math.min(i+1,65536)),m=[];let f,h=0;const g=l?l.length:i+1;for(;h<g&&(f=U(r,d,0,Math.min(d.length,g-h),(null!=(c=null==l?void 0:l.offset)?c:0)+h))>0;){var c;if(h+=f,h>i)throw new $d("File exceeds the read size limit.");m.push(Buffer.from(d.subarray(0,f)))}if(l&&h!==l.length)throw new $d("File byte range changed while reading.");const v=Od(e,t),b=C(v.path);if(v.path!==a.path||b.ino!==o.ino||b.dev!==o.dev)throw new $d("File path changed while reading. Retry the request.");return Buffer.concat(m,h)}finally{L(r)}}function Cd(e){if(/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(e.toString("utf8")))throw new $d("Files containing private-key material cannot be read.")}function Rd(e,t={}){const n=e.toString("utf8");if(n.includes("\0")||!Buffer.from(n,"utf8").equals(e))throw new $d("Only UTF-8 text files can be read.");return t.allowPrivateKeys||Cd(e),Ed(n)}function Nd(e,t,n={}){return{...Od(e,t),text:Rd(Ad(e,t,n),n)}}function Pd(e,t){try{return We("grep",e,{input:t,encoding:"utf8",timeout:1e4,maxBuffer:1048576})}catch(e){if(e&&"object"==typeof e&&"status"in e&&1===e.status)return"";throw e}}function Ud(e,t,n=Pd){!function({pattern:e,glob:t,root:n,maxResults:o}){if("string"!=typeof e)throw new Error("invalid pattern: must be a string");if(e.length>xd)throw new Error(`invalid pattern: exceeds ${xd} characters`);if(null!=t&&""!==t){if("string"!=typeof t)throw new Error("invalid glob: must be a string");if(t.length>bd)throw new Error(`invalid glob: exceeds ${bd} characters`);if(!yd.test(t))throw new Error("invalid glob: contains disallowed characters")}const i=["-rn"];t&&i.push(`--include=${t}`),i.push(`--max-count=${o}`,"-E",e,n)}({...t,root:"."});const o=[],i=[];let a=0,r=0,s=0,c=0,l=!1;const p=Date.now();return function n(u,d){if(d>20||s>=2e3||r>=33554432||Date.now()-p>1e4)l=!0;else for(const m of q(u,{withFileTypes:!0})){const f=pe(u,m.name),h=re(e,f).replace(/\\/g,"/");if(Td(h)||m.isSymbolicLink())c++;else{if(m.isDirectory()){if("node_modules"===m.name||m.name.startsWith(".")){c++;continue}n(f,d+1)}else{if(t.glob&&!Ve(h,t.glob,{matchBase:!0}))continue;try{Od(e,f);const t=Nd(e,f).text.replace(/\n$/,""),n=Buffer.byteLength(t);if(++s>2e3||r+n>33554432||Date.now()-p>1e4)return void(l=!0);const c=t.split("\n").length;i.push({start:a+1,end:a+c,path:h}),a+=c,r+=n,o.push(t+"\n")}catch(e){if(e instanceof $d){c++;continue}throw e}}if(l)return}}}(Od(e,".").path,0),{lines:n(["-n","-E",`--max-count=${t.maxResults}`,"-e",t.pattern,"--"],o.join("")).trimEnd().split("\n").filter(Boolean).map(e=>{const t=e.indexOf(":"),n=Number(e.slice(0,t)),o=i.find(e=>n>=e.start&&n<=e.end);if(!o||t<0)throw new Error("Unexpected grep output.");return`${o.path}:${n-o.start+1}:${e.slice(t+1)}`}),omitted:c,limited:l}}const Ld=new Set;async function zd(e,t=He){const n={check:"typescript",diagnostics:[]};if(!e)return{...n,status:"unavailable",message:"No connected web project. Open your project in the editor first."};const o=ae(e),i=pe(o,"tsconfig.json"),a=pe(o,"node_modules/typescript/lib/tsc.js");if(!T(i))return{...n,status:"unavailable",message:"The connected web project has no tsconfig.json."};if(!T(a))return{...n,status:"unavailable",message:"TypeScript is not installed in the connected web project. Install the project dependencies first."};if(Ld.has(o))return{...n,status:"error",message:"A check is already running for this project."};Ld.add(o);try{const e={...process.env};delete e.NODE_OPTIONS,delete e.NODE_PATH;const r=await new Promise(n=>{t(process.execPath,[a,"--project",i,"--noEmit","--incremental","false","--pretty","false"],{cwd:o,shell:!1,timeout:1e4,maxBuffer:262144,windowsHide:!0,encoding:"utf8",env:e},(e,t,o)=>n({error:e,stdout:t,stderr:o}))}),{error:s}=r,c=Ed(r.stdout),l=Ed(r.stderr);if(s&&(s.killed||"number"!=typeof s.code))return{...n,status:"error",message:s.killed?"Type checking exceeded the 10 second limit.":`Could not finish type checking: ${s.code||s.message}`,output:String(l||c).slice(0,4e3)};const p=[],u=[];for(const e of String(c).split(/\r?\n/)){const t=/^(?:(.+)\((\d+),(\d+)\): )?error (TS\d+): (.*)$/.exec(e);t?p.push({...t[1]?{file:t[1],line:Number(t[2]),column:Number(t[3])}:{},code:t[4],severity:"error",message:t[5]}):e.trim()&&(/^\s/.test(e)&&p.length?p[p.length-1].message+="\n"+e:u.push(e))}const d=Boolean(l||u.length||s&&!p.length);return{check:"typescript",project:o,status:d?"error":p.length?"failed":"passed",diagnostics:p.slice(0,100),totalDiagnostics:p.length,truncated:p.length>100,...d?{message:"The compiler did not return a complete diagnostic result.",output:[l,...u].join("\n").slice(0,4e3)}:{}}}finally{Ld.delete(o)}}const Fd=new Set([".git","node_modules"]);function Dd(e){if(!e)return null;try{const t=A(e),n=o("sha256"),i=[t];let a=0;for(;i.length;){const e=i.pop(),o=q(e,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name));for(const r of o){if(++a>2e4)return null;const o=pe(e,r.name),s=re(t,o).replaceAll("\\","/");if(r.isDirectory()&&Fd.has(r.name)){n.update(`${s}\0excluded\n`);continue}const c=B(o,{bigint:!0});n.update(`${s}\0${c.mode}\0${c.size}\0${c.mtimeNs}\0${c.ctimeNs}\n`),r.isDirectory()&&i.push(o)}}return n.digest("hex")}catch{return null}}const qd=(e,t)=>Ed(String(null!=e?e:"")).slice(0,t),Bd=1048576,Md=104857600,Wd=e=>o("sha256").update(e).digest("hex"),Hd=1048576,Gd=e=>o("sha256").update(e).digest("hex"),Jd=new Set([".app",".bat",".cmd",".com",".desktop",".exe",".hta",".jar",".lnk",".msi",".ps1",".scr",".sh",".url",".vbs",".wsf"]),Vd="settings.json";function Kd(){return pe(ne(),".needle")}function Yd(e){const t=pe(null!=e?e:Kd(),Vd);if(!T(t))return{};try{const e=JSON.parse(M(t,"utf-8"));return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}catch{return{}}}function Zd(e){return"disabled"===Yd(e).remote_ai_tools}function Xd(e){const t=pe(null!=e?e:Kd(),Vd);if(!T(t))return{};try{const e=JSON.parse(M(t,"utf-8"));return e&&"object"==typeof e&&!Array.isArray(e)?e:null}catch(e){return console.warn(`Needle CLI settings are unreadable; local AI mutations are disabled: ${e instanceof Error?e.message:String(e)}`),null}}function Qd(e){const t=Xd(e);return null===t||void 0!==t.local_file_edits&&"enabled"!==t.local_file_edits}function em(e){const t=Xd(e);return null===t||void 0!==t.local_project_commands&&"enabled"!==t.local_project_commands}function tm(e,t){if(!T(e))try{I(e,{recursive:!0})}catch{}let n=null,o=null;try{n=G(e,{persistent:!1},(e,n)=>{n&&n.toString()!==Vd||(o&&clearTimeout(o),o=setTimeout(()=>{o=null;try{t()}catch{}},50))}),null==n.on||n.on("error",()=>{})}catch{}return()=>{o&&(clearTimeout(o),o=null);try{var e;null==(e=n)||e.close()}catch{}n=null}}var nm={__proto__:null,KNOWN_SETTINGS:{remote_ai_tools:{displayName:"Remote AI tools",default:"enabled",description:"Allow Needle Cloud AI chat to dispatch tool calls (file reads, search, etc.) to this machine.",command:"needle-cloud settings remote-ai-tools <true|false>"},local_file_edits:{displayName:"Local AI file edits",default:"enabled",description:"Allow AI file mutations on this machine when the chat also has approval.",command:"needle-cloud settings local-file-edits <true|false>"},local_project_commands:{displayName:"Local AI project commands",default:"enabled",description:"Allow approved AI installs, project creation, builds, and deploys on this machine.",command:"needle-cloud settings local-project-commands <true|false>"}},defaultSettingsDir:Kd,readSettings:Yd,writeSetting:function(e,t,n){const o=Yd(e);null===n?delete o[t]:o[t]=n,I(e,{recursive:!0}),H(pe(e,Vd),JSON.stringify(o,null,2)+"\n","utf-8")},areRemoteAiToolsDisabled:Zd,areLocalFileEditsDisabled:Qd,areLocalProjectCommandsDisabled:em,watchSettings:tm};const om=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function im(e,t=process.platform,n=Ge){if(!Number.isSafeInteger(e)||e<1)return null;if("win32"===t){const t=n("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],{shell:!1,windowsHide:!0,timeout:5e3,encoding:"utf8"}),o=String(t.stdout||"").trim();return 0===t.status&&/^\d{12,}$/.test(o)?`win:${o}`:null}if("linux"===t)try{const t=M(`/proc/${e}/stat`,"utf8"),n=t.slice(t.lastIndexOf(")")+2).trim().split(/\s+/),o=M("/proc/sys/kernel/random/boot_id","utf8").trim();return/^\d+$/.test(n[19]||"")&&o?`linux:${o}:${n[19]}`:null}catch{return null}if("darwin"===t){const t=n("ps",["-p",String(e),"-o","lstart="],{shell:!1,windowsHide:!0,timeout:5e3,encoding:"utf8"}),o=String(t.stdout||"").trim();return 0===t.status&&/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+[A-Z][a-z]{2}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4}$/.test(o)?`darwin:${o}`:null}return null}const am=Object.freeze(["vite","react","react-three-fiber","svelte","sveltekit","vue","nextjs"]),rm=new Set(am),sm=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@(?:\d+(?:\.\d+){0,2}(?:-[a-z0-9.-]+)?|latest|next))?$/i,cm=/^[a-z0-9][a-z0-9._-]{0,79}$/i;function lm(e,t){if(!e||!T(e)||!C(e).isDirectory())throw new Error(`${t} does not exist.`);return A.native(e)}function pm(e,t,n){if(!e||"object"!=typeof e)throw new Error("A project operation is required.");if("create"===e.operation){if("project"in e)throw new Error("Create uses destination, not project.");if("string"!=typeof e.name||!cm.test(e.name))throw new Error("Use a short project name containing letters, numbers, dots, hyphens, or underscores.");if(!rm.has(e.template))throw new Error("Unsupported Needle project template.");if("location"in e)throw new Error("Use an explicit absolute destination instead of a location name.");if(void 0!==e.parent&&void 0!==e.destination)throw new Error("Use either parent or destination for a new project, not both.");const t=void 0!==e.parent||void 0!==e.destination;if(void 0!==e.parent&&("string"!=typeof e.parent||!ce(e.parent)))throw new Error("An explicit project parent must be an absolute existing directory.");if(void 0!==e.destination&&("string"!=typeof e.destination||!ce(e.destination)))throw new Error("An explicit project destination must be absolute.");const o=void 0!==e.parent?pe(lm(e.parent,"The project parent"),e.name):void 0!==e.destination?ae(e.destination):pe(n,".needle","ai-projects",e.name);if(fe(o)!==e.name)throw new Error("The destination folder must match the project name.");const i=t?pe(lm(se(o),"The destination parent"),e.name):o;if(T(i))throw new Error("The project destination already exists; refusing to overwrite it.");return{request:e,operation:"create",name:e.name,template:e.template,destination:i,customDestination:t,command:`npm --yes create needle ${e.name} -- --template ${e.template}`,args:["--yes","create","needle",e.name,"--","--template",e.template]}}if("directory"in e&&"deploy"!==e.operation)throw new Error("Use project to select a project directory; directory is only for deploy output.");const i="project"in e?e.project:void 0;if(void 0!==i&&("string"!=typeof i||!ce(i)))throw new Error("An explicit project path must be absolute.");const a=lm(i||t||"","The project"),r=a!==(t&&T(t)?A.native(t):null),s=function(e){const t=pe(e,"package.json");if(!T(t))throw new Error("The connected project has no package.json.");const n=M(t,"utf8"),o=JSON.parse(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new Error("The project package.json is invalid.");const i=o;return{scripts:i.scripts&&"object"==typeof i.scripts&&!Array.isArray(i.scripts)?i.scripts:void 0,packageManager:"string"==typeof i.packageManager?i.packageManager:void 0,raw:n}}(a);!function(e,t){if(t&&!/^npm@\d+(?:\.\d+){0,2}(?:-[a-z0-9.-]+)?$/i.test(t))throw new Error(`This project uses ${t}; npm-only AI commands cannot modify it.`);for(const t of["pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"])if(T(pe(e,t)))throw new Error(`This project uses ${t}; npm-only AI commands cannot modify it.`)}(a,s.packageManager);const c=function(e,t){const n=pe(e,"package-lock.json");return i=t+"\0"+(T(n)?M(n,"utf8"):""),o("sha256").update(i).digest("hex");var i}(a,s.raw);if("install"===e.operation){const t=T(pe(a,"package-lock.json"));return{request:e,operation:"install",project:a,customProject:r,inputsHash:c,command:t?"npm ci":"npm install",args:t?["ci"]:["install"]}}if("add_package"===e.operation){if(!Array.isArray(e.packages)||e.packages.length<1||e.packages.length>10||e.packages.some(e=>"string"!=typeof e||!sm.test(e)))throw new Error("Provide 1–10 npm registry package names with optional exact versions or tags.");const t=!0===e.dev;return{request:e,operation:"add_package",project:a,customProject:r,inputsHash:c,packages:[...e.packages],dev:t,command:`npm install ${e.packages.join(" ")} ${t?"--save-dev":"--save"}`,args:["install",...e.packages,t?"--save-dev":"--save"]}}if("build"===e.operation){var l;const t=null==(l=s.scripts)?void 0:l.build;if("string"!=typeof t||!t.trim())throw new Error("The connected project has no build script.");return{request:e,operation:"build",project:a,customProject:r,inputsHash:c,script:t,command:"npm run build",args:["run","build"]}}if("dev"===e.operation){var p;const t=null==(p=s.scripts)?void 0:p.dev;if("string"!=typeof t||!t.trim())throw new Error("The project has no dev script.");if(!T(pe(a,"node_modules")))throw new Error("Install project dependencies before starting the dev server.");return{request:e,operation:"dev",project:a,customProject:r,inputsHash:c,script:t,command:"npm run dev",args:["run","dev"]}}if("deploy"===e.operation){if(!e.team)throw new Error("An explicit Needle team ID is required for AI deployment.");let t=e.directory;if(void 0===t){const e=pe(a,"needle.config.json");if(T(e)){const n=JSON.parse(M(e,"utf8"));if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n.buildDirectory;"string"==typeof e&&(t=e)}}null!=t||(t="dist")}if("string"!=typeof t||!t||ce(t)||t.split(/[\\/]/).some(e=>".."===e||"."===e))throw new Error("Use a project-relative build directory.");const n=function(e,t){const n=A.native(t),o=re(e,n);if(".."===o||o.startsWith(`..${le}`)||ce(o))throw new Error("The build directory is outside the connected project.");return n}(a,lm(ae(a,t),"The build directory"));if(!T(pe(n,"index.html")))throw new Error("The build directory has no index HTML file.");if(void 0!==e.name&&!cm.test(e.name))throw new Error("Use a valid deployment name.");if(void 0!==e.team&&!/^org_[a-z0-9]+$/.test(e.team))throw new Error("Use a valid Needle team ID.");return{request:e,operation:"deploy",project:a,customProject:r,inputsHash:c,directory:n,...e.name?{name:e.name}:{},...e.team?{team:e.team}:{},command:`needle-cloud deploy ${n} --open false${e.name?` --name ${e.name}`:""} --team ${e.team}`}}throw new Error("Unsupported project operation.")}function um(e,t=process.platform,n=Ge,o=process.kill){if(!e||!Number.isSafeInteger(e)||e<1)return!1;if("win32"===t){const t=n("taskkill",["/PID",String(e),"/T","/F"],{shell:!1,windowsHide:!0,timeout:5e3,encoding:"utf8"});return t.error?console.warn(`Could not terminate local project command tree: ${t.error.message}`):0!==t.status&&console.warn(`Could not terminate local project command tree: ${String(t.stderr||"").trim()||`taskkill exited ${t.status}`}`),!t.error&&0===t.status}try{return o(-e,"SIGTERM"),!0}catch(e){return e instanceof Error&&"code"in e&&"ESRCH"===e.code||console.warn(`Could not terminate local project command tree: ${e instanceof Error?e.message:String(e)}`),!1}}async function dm(e,t,n=(()=>{}),o=x){let a,r,s=process.execPath,c=e.project||se(e.destination);if("deploy"===e.operation){const t=process.argv[1];if(!t||!T(t))throw new Error("Cannot locate the running Needle CLI entry point for deployment.");a=[ae(t),"deploy",e.directory,"--open","false",...e.name?["--name",e.name]:[],...e.team?["--team",e.team]:[]]}else{const t=[process.env.npm_execpath,pe(se(process.execPath),"node_modules","npm","bin","npm-cli.js"),pe(se(se(process.execPath)),"lib","node_modules","npm","bin","npm-cli.js")].find(e=>"string"==typeof e&&"npm-cli.js"===fe(e)&&T(e));if(!t)throw new Error("Could not locate npm-cli.js. Start Needle CLI through npm or install npm alongside Node.js.");a=[t,...e.args],"create"===e.operation&&I(c,{recursive:!0})}if("dev"===e.operation){const t=[Ke(new URL("../../../bin/cli.project-dev-supervisor.cjs",import.meta.url)),Ke(new URL("../bin/cli.project-dev-supervisor.cjs",import.meta.url))].find(T);if(!t)throw new Error("The local dev supervisor is missing from the Needle CLI installation.");r=e.runtimeFile||pe(oe(),`needle-dev-${i()}.runtime.json`),a=[t,Buffer.from(JSON.stringify({executable:s,args:a,cwd:c,runtimeFile:r})).toString("base64url")]}return new Promise((i,l)=>{var p,u;if(t.aborted)return void l(new Error("Project command was canceled before it started."));const d=Je(s,a,{cwd:c,shell:!1,windowsHide:!0,detached:"dev"===e.operation||"win32"!==process.platform,stdio:["ignore","pipe","pipe"]});let m="";const f=function(e){let t,n="",o="",i=!1,a=!1;function r(e){var n,o;if(/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(e)&&(i=!0),i)return/-----END [A-Z0-9 ]*PRIVATE KEY-----/.test(e)&&(i=!1),wd;const a=null!=(n=null==(o=e.match(/^[ \t]*/))?void 0:o[0].length)?n:0;if(void 0!==t){if(!e.trim()||a>t)return wd;t=void 0}const r=/^([ \t]*)([\w.-]+)[ \t]*:[ \t]*(?:[|>][^\n]*)?$/.exec(e);return r&&_d(r[2])?(t=r[1].length,wd):Ed(e)}return{push(e,t=!1){let i;for(n+=e;(i=n.indexOf("\n"))>=0;){const e=n.slice(0,i);n=n.slice(i+1),o=(o+(a?wd:r(e))+"\n").slice(-8e3),a=!1}return n.length>65536&&(r(n),n="",a=!0),t&&(n||a)&&(o=(o+(a?wd:r(n))).slice(-8e3),n="",a=!1),o}}}();let h,g,v=!1,b=!1;const x=e=>{if(b)return!1;try{return n(e),!0}catch(e){return b=!0,g=e,_(),!1}},y=t=>{if(m=f.push(t.toString().replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,"")),"dev"!==e.operation)return;if(!x({output:Ed(m)}))return;if(v)return;const n=m.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\]):\d+\/?/i);if(!n)return;v=!0;const i=n[0];x({url:i})&&o(i).then(()=>{x({browserOpened:!0})}).catch(e=>{x({browserError:e instanceof Error?e.message:String(e)})})};null==(p=d.stdout)||p.on("data",y),null==(u=d.stderr)||u.on("data",y);let w=!1;const _=()=>{if(r)return H(`${r}.cancel`,"",{flag:"w",mode:384}),void(null!=h||(h=setTimeout(()=>{um(d.pid),null!==d.exitCode||d.killed||d.kill("SIGTERM")},5e3)));um(d.pid),null!==d.exitCode||d.killed||d.kill("SIGTERM")};t.addEventListener("abort",_,{once:!0});const j="dev"===e.operation?null:setTimeout(()=>{w=!0,_()},9e5);if(d.once("error",e=>{j&&clearTimeout(j),t.removeEventListener("abort",_),l(e)}),d.once("close",e=>{if(h&&clearTimeout(h),r){const e=`${r}.cancel`;T(e)&&W(e)}j&&clearTimeout(j),t.removeEventListener("abort",_),b?l(g):(m=f.push("",!0),i({exitCode:w?124:null!=e?e:1,output:Ed(w?`${m}\nCommand timed out after 15 minutes.`:m)}))}),"dev"===e.operation&&d.pid){const e=im(d.pid);e?x({pid:d.pid,processIdentity:e,startedAt:Date.now()}):console.warn(`Could not record process identity for local dev job PID ${d.pid}; cancellation after CLI restart will be unavailable.`)}})}function mm(e){try{const t=new RegExp(e,"i");return{test:e=>t.test(e),mode:"regex"}}catch{const t=e.toLowerCase();return{test:e=>e.toLowerCase().includes(t),mode:"literal"}}}const fm=Ye(He),hm=String.raw`
|
|
2
2
|
$Port = __PORT__
|
|
3
3
|
$TargetHost = '__HOST__'
|
|
4
4
|
$ErrorActionPreference = 'Stop'
|
|
@@ -60,4 +60,4 @@ try {
|
|
|
60
60
|
} catch {
|
|
61
61
|
@{status='unavailable'; pid=$ownerPid; reason=$_.Exception.Message} | ConvertTo-Json -Compress
|
|
62
62
|
}
|
|
63
|
-
`;function gm(e,t,n,o){hd(e,async(e,n)=>{try{const o=await t(e,n);return"string"==typeof o?Ed(o):{...o,content:o.content.map(e=>"text"===e.type?{...e,text:Ed(e.text)}:e)}}catch(e){throw new Error(Ed(e instanceof Error?e.message:String(e)))}},n,o)}const vm=function(e,t=zd,n=Date.now){let o,i=0;return Object.assign(async(a={})=>{var r,s,c,l;const p={status:"error",message:"Use mode check, results or error; file/code filters, nonnegative integer offset/index. No paths or commands can be selected."};if(!a||"object"!=typeof a||Array.isArray(a))return p;if(Object.keys(a).some(e=>!["mode","file","code","offset","index"].includes(e)))return p;const u=null!=(r=a.mode)?r:"check";if(!["check","results","error"].includes(u))return p;for(const e of[a.file,a.code])if(void 0!==e&&("string"!=typeof e||e.length>250))return p;for(const e of[a.offset,a.index])if(void 0!==e&&(!Number.isSafeInteger(e)||e<0))return p;const d=e();if(o&&o.project!==d&&(o=void 0),"check"===u){var m;const e=i,a=Dd(d),r=await t(d);o={project:d,result:{...r,...r.message?{message:Ed(r.message)}:{},...r.output?{output:Ed(r.output)}:{},diagnostics:(null!=(m=r.diagnostics)?m:[]).map(e=>({...e,message:Ed(e.message)}))},time:n(),revision:e,snapshot:a}}if(!o)return{status:"unavailable",message:"No saved check for this local project. Run local_files_check_project with mode check first."};const f=Dd(d),h=null===o.snapshot||null===f,g=o.result,v=null!=(s=g.diagnostics)?s:[],b=v.map((e,t)=>({...e,index:t})).filter(e=>{var t;return(!a.file||(null!=(t=e.file)?t:"").toLowerCase().includes(a.file.toLowerCase()))&&(!a.code||e.code===a.code)}),x=null!=(c=a.offset)?c:0,y="error"===u?b.filter(e=>{var t,n;return e.index===(null!=(t=a.index)?t:null==(n=b.at(-1))?void 0:n.index)}):b.slice(x,x+5);if("error"===u&&!y.length)return{status:"unavailable",message:"No matching error in the latest check. Use mode results to list available error indexes."};const w="error"===u?2e3:300;return{status:g.status,check:"typescript",checkedAt:new Date(o.time).toISOString(),cached:"check"!==u,stale:o.revision!==i||h||o.snapshot!==f,project:qd(d,300),totalDiagnostics:null!=(l=g.totalDiagnostics)?l:v.length,retainedDiagnostics:v.length,matchingDiagnostics:b.length,truncated:Boolean(g.truncated),diagnostics:y.map(e=>({...e,...e.file?{file:qd(e.file,300)}:{},message:qd(e.message,w),messageTruncated:e.message.length>w})),..."error"!==u&&x+y.length<b.length?{nextOffset:x+y.length}:{},...g.message||h?{message:qd([g.message,h?"Could not scan project files for changes; this check is marked stale.":null].filter(Boolean).join(" "),500)}:{},...g.output?{output:qd(g.output,"error"===u?2e3:500),outputTruncated:g.output.length>("error"===u?2e3:500)}:{}}},{markStale(){i++}})}(()=>{var e;return null==(e=km())?void 0:e.web_location}),bm=function(e,t=pe(ne(),".needle","cli","ai-checkpoints"),n=(()=>{})){let o=0n,a=!1;function r(t){if(!(t&&t.chatId&&t.sessionId&&t.turnId&&t.project))throw new Error("Local file edit approval is required.");const n=e();if(!n||ae(n)!==ae(t.project))throw new Error("The approved local project has changed.");return{root:A(n),grant:t}}function s(e,t,n){if("string"!=typeof t||!t||t.includes("\0")||ce(t)||ue.isAbsolute(t)||de.isAbsolute(t)||t.split(/[\\/]/).some(e=>!e||"."===e||".."===e||e.includes(":")))throw new Error("Path must be a file inside the selected local project.");if(Td(e)||Td(t))throw new Error("Sensitive files cannot be accessed by local AI tools.");if(t.split(/[\\/]/).some(e=>/[ .]$/.test(e)))throw new Error("Invalid file path.");const o=ae(e,t);if(!o.startsWith(e+le))throw new Error("Path escapes the selected local project.");let i=e;const a=re(e,o).split(le);for(let e=0;e<a.length;e++){if(i=pe(i,a[e]),!T(i)){if(e!==a.length-1||!n)throw new Error("The file or its parent directory does not exist.");continue}const t=B(i);if(t.isSymbolicLink()||t.nlink>1)throw new Error("Symbolic links and hard links cannot be edited.");if(e<a.length-1&&!t.isDirectory())throw new Error("Parent path is not a directory.");if(e===a.length-1&&!t.isFile())throw new Error("Target is not a regular file.")}return o}function c(e,t){const n=`${e}.needle-ai-${i()}.tmp`;try{H(n,t,{flag:"wx",mode:384}),O(n,e)}finally{T(n)&&W(n)}}function l(){return T(t)?q(t).filter(e=>e.endsWith(".json")).reduce((e,n)=>e+C(pe(t,n)).size,0):0}function p(e){if(!a){if(T(t))for(const e of q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e))){const n=JSON.parse(M(pe(t,e),"utf8"));if(n.order&&/^\d+$/.test(n.order)){const e=BigInt(n.order);e>o&&(o=e)}}a=!0}const n=1000000n*BigInt(Date.now());o=n>o?n:o+1n,e.order=o.toString();const r=JSON.stringify(e);if(l()+Buffer.byteLength(r)>Md)throw new Error("Checkpoint storage is full; no file was changed.");I(t,{recursive:!0,mode:448});const s=i(),c=pe(t,`${s}.json`);return H(c,r,{flag:"wx",mode:384}),{id:s,file:c}}function u(e,t){if(e.byteLength>Bd)throw new Error("File exceeds the 1 MiB edit limit.");if(!t||!/^[a-f0-9]{64}$/.test(t))throw new Error("Expected file SHA-256 hash is required before changing a file.");if(Wd(e)!==t)throw new Error("The supplied expectedSha256 does not match this file. The file may have changed, or the hash may be incorrect. Run local_files_stat again and use its sha256 value.")}function d(e,t){try{const n=t=>{const n=s(e,t,!0);return T(n)?M(n):null},o=n(t.path),i=null===t.before?null:Wd(Buffer.from(t.before,"base64"));if("rename"===t.operation){if(!t.newPath)return"conflicted";const e=n(t.newPath);if(null===o&&e&&Wd(e)===t.afterSha256)return"applied";if(null===e&&o&&Wd(o)===i)return"undone"}else if("delete"===t.operation){if(null===o)return"applied";if(o&&Wd(o)===i)return"undone"}else{if(o&&Wd(o)===t.afterSha256)return"applied";if(null===o&&null===t.before||o&&Wd(o)===i)return"undone"}return"conflicted"}catch{return"conflicted"}}return{list(e){const{root:n,grant:o}=r(e);if(!T(t))return{changes:[],total:0};const i=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({...JSON.parse(M(pe(t,e),"utf8")),checkpointId:e.slice(0,-5)})).filter(e=>e.project===n&&e.chatId===o.chatId).sort((e,t)=>e.order&&t.order?BigInt(t.order)>BigInt(e.order)?1:BigInt(t.order)<BigInt(e.order)?-1:0:t.createdAt.localeCompare(e.createdAt));return{changes:i.slice(0,100).map(({path:e,checkpointId:t,turnId:o,createdAt:i,operation:a,newPath:r,...s})=>({path:e,checkpointId:t,turnId:o,createdAt:i,operation:null!=a?a:"write",...r?{newPath:r}:{},state:d(n,{...s,path:e,turnId:o,createdAt:i,operation:a,newPath:r})})),total:i.length}},stat(t){const n=e();if(!n)throw new Error("No connected local web project.");const o=A(n),i=s(o,t,!0);if(!T(i))return{path:t,exists:!1};const a=C(i).size;if(a>Bd)throw new Error("File exceeds the 1 MiB edit limit.");const r=Ad(o,t,{maxBytes:Bd});return Cd(r),{path:t,exists:!0,sha256:Wd(r),size:a}},write(e,t){var o;const{root:i,grant:a}=r(t);if(!e||"string"!=typeof e.content)throw new Error("Text content is required.");const l=Buffer.from(e.content,"utf8");if(l.byteLength>Bd||e.content.includes("\0"))throw new Error("Text file exceeds the 1 MiB limit or contains NUL.");const d=s(i,e.path,!0===e.create),m=T(d);if(!0===e.create&&m)throw new Error("File already exists.");if(!0!==e.create&&!m)throw new Error("File does not exist; use create.");const f=m?M(d):null;if(f&&u(f,e.expectedSha256),f&&Wd(f)===Wd(l))throw new Error("File already has this content; no edit was saved.");const h={project:i,path:re(i,d),chatId:a.chatId,sessionId:a.sessionId,turnId:a.turnId,before:null!=(o=null==f?void 0:f.toString("base64"))?o:null,after:l.toString("base64"),afterSha256:Wd(l),createdAt:(new Date).toISOString(),operation:"write"},g=p(h);try{if(s(i,e.path,!0===e.create),!0===e.create){if(T(d))throw new Error("The file was created since it was checked; check it again.")}else if(!T(d)||Wd(M(d))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");c(d,l)}catch(e){throw W(g.file),e}return n(),{path:e.path,checkpointId:g.id,turnId:a.turnId,afterSha256:h.afterSha256}},delete(e,t){const{root:o,grant:i}=r(t),a=s(o,null==e?void 0:e.path,!1),c=M(a);u(c,e.expectedSha256);const l=p({project:o,path:re(o,a),chatId:i.chatId,sessionId:i.sessionId,turnId:i.turnId,before:c.toString("base64"),after:null,afterSha256:null,createdAt:(new Date).toISOString(),operation:"delete"});try{if(s(o,e.path,!1),Wd(M(a))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");W(a)}catch(e){throw W(l.file),e}return n(),{path:e.path,checkpointId:l.id,turnId:i.turnId,afterSha256:null}},rename(e,t){const{root:o,grant:i}=r(t),a=s(o,null==e?void 0:e.path,!1),c=s(o,null==e?void 0:e.newPath,!0);if(T(c))throw new Error("Destination file already exists.");const l=M(a);u(l,e.expectedSha256);const d={project:o,path:re(o,a),newPath:re(o,c),chatId:i.chatId,sessionId:i.sessionId,turnId:i.turnId,before:l.toString("base64"),after:l.toString("base64"),afterSha256:Wd(l),createdAt:(new Date).toISOString(),operation:"rename"},m=p(d);try{if(s(o,e.path,!1),s(o,e.newPath,!0),T(c))throw new Error("Destination file already exists.");if(Wd(M(a))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");O(a,c)}catch(e){throw W(m.file),e}return n(),{path:e.newPath,checkpointId:m.id,turnId:i.turnId,afterSha256:d.afterSha256}},undo(e,o){const{root:i,grant:a}=r(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const p=pe(t,`${e.checkpointId}.json`),u=JSON.parse(M(p,"utf8"));if(u.project!==i||u.chatId!==a.chatId)throw new Error("Checkpoint belongs to another project or chat.");const d=s(i,u.path,!0);if("delete"===u.operation){var m;if(T(d))throw new Error("File changed after the AI edit; Undo would overwrite later work.");c(d,Buffer.from(null!=(m=u.before)?m:"","base64"))}else if("rename"===u.operation){if(!u.newPath)throw new Error("Invalid rename checkpoint.");const e=s(i,u.newPath,!1);if(T(d)||Wd(M(e))!==u.afterSha256)throw new Error("File changed after the AI edit; Undo would overwrite later work.");O(e,d)}else{const e=M(d);if(Wd(e)!==u.afterSha256)throw new Error("File changed after the AI edit; Undo would overwrite later work.");void 0===u.after&&(u.after=e.toString("base64"),function(e,t){const n=JSON.stringify(t);if(l()-C(e).size+Buffer.byteLength(n)>Md)throw new Error("Checkpoint storage is full; no file was changed.");c(e,Buffer.from(n))}(p,u)),null===u.before?W(d):c(d,Buffer.from(u.before,"base64"))}return n(),{path:u.path,checkpointId:e.checkpointId,undone:!0}},redo(e,o){const{root:i,grant:a}=r(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const l=pe(t,`${e.checkpointId}.json`),p=JSON.parse(M(l,"utf8"));if(p.project!==i||p.chatId!==a.chatId)throw new Error("Checkpoint belongs to another project or chat.");const u=s(i,p.path,!0);if("delete"===p.operation){var d;if(!T(u)||Wd(M(u))!==Wd(Buffer.from(null!=(d=p.before)?d:"","base64")))throw new Error("File changed after Undo; Redo would overwrite later work.");s(i,p.path,!1),W(u)}else if("rename"===p.operation){var m;if(!p.newPath)throw new Error("Invalid rename checkpoint.");const e=s(i,p.newPath,!0);if(!T(u)||T(e)||Wd(M(u))!==Wd(Buffer.from(null!=(m=p.before)?m:"","base64")))throw new Error("File changed after Undo; Redo would overwrite later work.");s(i,p.path,!1),s(i,p.newPath,!0),O(u,e)}else{if("string"!=typeof p.after||null===p.afterSha256)throw new Error("This checkpoint cannot be redone.");const e=Buffer.from(p.after,"base64");if(Wd(e)!==p.afterSha256)throw new Error("Checkpoint content is damaged; Redo was refused.");if(null===p.before?T(u):!T(u)||Wd(M(u))!==Wd(Buffer.from(p.before,"base64")))throw new Error("File changed after Undo; Redo would overwrite later work.");s(i,p.path,null===p.before),c(u,e)}return n(),{path:"rename"===p.operation?p.newPath:p.path,checkpointId:e.checkpointId,redone:!0}},undoTurn(e,n){const{root:o,grant:i}=r(n);if(!e||"string"!=typeof e.turnId||!e.turnId||e.turnId.length>255)throw new Error("Valid turn ID is required.");if(!T(t))throw new Error("No checkpoints found for this turn.");const a=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({checkpoint:JSON.parse(M(pe(t,e),"utf8")),checkpointId:e.slice(0,-5)})).filter(t=>t.checkpoint.project===o&&t.checkpoint.chatId===i.chatId&&t.checkpoint.turnId===e.turnId);if(!a.length)throw new Error("No checkpoints found for this turn.");if(a.some(e=>!e.checkpoint.order||!/^\d+$/.test(e.checkpoint.order)))throw new Error("Older checkpoints cannot be undone as a turn; use local_files_undo for each file.");a.sort((e,t)=>{const n=BigInt(e.checkpoint.order),o=BigInt(t.checkpoint.order);return n<o?1:n>o?-1:0});const c=new Map,l=e=>{const t=s(o,e,!0);return"win32"===process.platform?t.toLowerCase():t},p=e=>{var t;const n=s(o,e,!0),i=l(e);if(c.has(i))return null!=(t=c.get(i))?t:null;const a=T(n)?M(n):null;return c.set(i,a),a};for(const{checkpoint:e}of a){const t=null===e.before?null:Buffer.from(e.before,"base64");if("rename"===e.operation){if(!e.newPath)throw new Error("Invalid rename checkpoint.");const n=p(e.path),o=p(e.newPath);if(null!==n||null===o||Wd(o)!==e.afterSha256)throw new Error("File changed after this turn; no file was undone.");c.set(l(e.path),t),c.set(l(e.newPath),null)}else if("delete"===e.operation){if(null!==p(e.path))throw new Error("File changed after this turn; no file was undone.");c.set(l(e.path),t)}else{const n=p(e.path);if(null===n||Wd(n)!==e.afterSha256)throw new Error("File changed after this turn; no file was undone.");c.set(l(e.path),t)}}const u=[];try{for(const{checkpointId:e}of a)this.undo({checkpointId:e},n),u.push(e)}catch(e){const t=[];for(const e of[...u].reverse())try{this.redo({checkpointId:e},n)}catch(e){t.push(e)}if(t.length)throw new AggregateError([e,...t],"Turn Undo stopped and rollback failed; inspect the listed checkpoints before editing again.");throw new Error("Turn Undo stopped; earlier changes were rolled back.",{cause:e})}return{turnId:e.turnId,checkpointIds:u,undone:!0}}}}(()=>{var e;return null==(e=km())?void 0:e.web_location},void 0,()=>vm.markStale()),xm=function(e=pe(ne(),".needle","cli","ai-observations")){function t(t){if(!t||"string"!=typeof t.root||!t.root||"string"!=typeof t.path||!t.path||"string"!=typeof t.chatId||!t.chatId||t.path.includes("\0")||ce(t.path)||ue.isAbsolute(t.path)||de.isAbsolute(t.path))throw new Error("A project-relative file path and chat are required.");const n=A(t.root),o=ae(n,t.path);if(Od(n,t.path,{allowMissing:!0}),!o.startsWith(n+le))throw new Error("File path escapes the project.");const i=re(n,o).split(le).join("/");return{project:n,target:o,path:i,file:pe(e,Gd(n),Gd(t.chatId),`${Gd(i)}.json`)}}function n(e){if(!T(e.target))return null;if(C(Od(e.project,e.target).path).size>Hd)return{unsupported:"File exceeds the 1 MiB observation limit."};const t=Ad(e.project,e.target,{maxBytes:Hd}),n=t.toString("utf8");if(n.includes("\0")||!Buffer.from(n,"utf8").every((e,n)=>t[n]===e)||Buffer.byteLength(n,"utf8")!==t.length)return{unsupported:"Only UTF-8 text files can be observed."};const o=n.split("\n");return o.length>5e3?{unsupported:"File exceeds the 5,000-line observation limit."}:{content:t,lines:Rd(t).split("\n"),hashes:o.map(Gd),fileSha256:Gd(t)}}function o(e){if(!T(e.file))return null;const t=JSON.parse(M(e.file,"utf8"));if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Stored file observation is damaged.");const n=t;if(1!==n.version||n.project!==e.project||n.path!==e.path||!Array.isArray(n.lineHashes)||!n.lineHashes.every(e=>"string"==typeof e&&/^[a-f0-9]{64}$/.test(e))||"string"!=typeof n.fileSha256||!/^[a-f0-9]{64}$/.test(n.fileSha256)||"string"!=typeof n.chatId||"string"!=typeof n.observedAt)throw new Error("Stored file observation is damaged.");return n}function a(t,n,o){if("unsupported"in n)return{status:"unsupported",reason:n.unsupported};const a={version:1,project:t.project,path:t.path,chatId:o,observedAt:(new Date).toISOString(),fileSha256:n.fileSha256,lineHashes:n.hashes};I(pe(e,Gd(t.project),Gd(o)),{recursive:!0,mode:448});const r=`${t.file}.${i()}.tmp`;try{H(r,JSON.stringify(a),{flag:"wx",mode:384}),O(r,t.file)}finally{T(r)&&W(r)}return{status:"saved",observedAt:a.observedAt,sha256:a.fileSha256}}return{observe(e){const i=t(e),r=n(i);if(!r)throw new Error("File does not exist.");if("unsupported"in r)return{status:"unsupported",reason:r.unsupported};const s=o(i);return s?{status:"existing",observedAt:s.observedAt,sha256:s.fileSha256}:a(i,r,e.chatId)},snapshot(e){const o=t(e),i=n(o);if(!i)throw new Error("File does not exist.");return a(o,i,e.chatId)},diff(e){const i=t(e),a=o(i);if(!a)return{status:"no_baseline",path:i.path};const r=n(i);if(!r)return{status:"deleted",path:i.path,observedAt:a.observedAt};if("unsupported"in r)return{status:"unsupported",path:i.path,reason:r.unsupported};if(a.fileSha256===r.fileSha256)return{status:"unchanged",path:i.path,observedAt:a.observedAt,sha256:r.fileSha256};const s=function(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let o=e.length,i=t.length;for(;o>n&&i>n&&e[o-1]===t[i-1];)o--,i--;if(n===o&&n===i)return[];const a=new Map;for(let t=n;t<o;t++){const n=a.get(e[t]);n?n.count++:a.set(e[t],{index:t,count:1})}const r=new Map;for(let e=n;e<i;e++){var s;r.set(t[e],(null!=(s=r.get(t[e]))?s:0)+1)}const c=[];for(let e=n;e<i;e++){const n=a.get(t[e]);1===(null==n?void 0:n.count)&&1===r.get(t[e])&&c.push({old:n.index,current:e})}const l=[],p=[];for(let e=0;e<c.length;e++){let t=0,n=l.length;for(;t<n;){const o=t+n>>1;c[l[o]].old<c[e].old?t=o+1:n=o}p[e]=t?l[t-1]:-1,l[t]=e}const u=[];for(let e=l.length?l[l.length-1]:-1;e>=0;e=p[e])u.push(c[e]);u.reverse();const d=[];let m=n,f=n;for(const n of[...u,{old:o,current:i}]){let o=n.old,i=n.current;for(;m<o&&f<i&&e[m]===t[f];)m++,f++;for(;o>m&&i>f&&e[o-1]===t[i-1];)o--,i--;m===o&&f===i||d.push({oldStart:m,oldEnd:o,newStart:f,newEnd:i}),m=n.old+1,f=n.current+1}return d}(a.lineHashes,r.hashes);let c=80;const l=s.slice(0,20).map(e=>{const t=Math.min(e.newEnd-e.newStart,c);return c-=t,{before:{start:e.oldStart+1,count:e.oldEnd-e.oldStart},after:{start:e.newStart+1,count:e.newEnd-e.newStart},lines:r.lines.slice(e.newStart,e.newStart+t).map(e=>e.slice(0,300)),omittedLines:e.newEnd-e.newStart-t}});return{status:"changed",path:i.path,observedAt:a.observedAt,beforeSha256:a.fileSha256,afterSha256:r.fileSha256,beforeLineCount:a.lineHashes.length,afterLineCount:r.hashes.length,hunks:l,totalHunks:s.length,truncated:s.length>l.length,detail:s.length?void 0:"File bytes changed without a text-line change (for example line endings)."}}}}(),ym=function(e,t=x){return async function(n){const o=e(),i="web"===n.project?null==o?void 0:o.web_location:"editor"===n.project?null==o?void 0:o.project_location:null;if(!i)throw new Error("The selected local project is unavailable.");if("string"!=typeof n.path||!n.path.trim()||ce(n.path)||n.path.includes("\0"))throw new Error("Use a nonempty project-relative path.");const a=A.native(i),r=ae(a,n.path),s=re(a,r);if(".."===s||s.startsWith(`..${le}`)||ce(s))throw new Error("File path is outside the selected project.");const c=A.native(r),l=re(a,c);if(".."===l||l.startsWith(`..${le}`)||ce(l))throw new Error("File path is outside the selected project.");const p=C(c);if(!p.isFile()&&!p.isDirectory())throw new Error("The selected path is not a file or directory.");if(Jd.has(me(c).toLowerCase()))throw new Error("Opening executable file types is not supported.");return await t(c),{opened:!0,project:n.project,path:re(a,c)||"."}}}(km),wm=function(e){const{getProject:t,getHome:n=ne,run:o=dm,commandsEnabled:a=(()=>!em()),onFailure:r,onCreated:s,onApprovedProject:c,now:l=Date.now,getProcessIdentity:p=im}=e,u=function(e=pe(ne(),".needle","cli","ai-jobs"),t=Date.now){const n=t=>{if(!om.test(t))throw new Error("Invalid project job ID.");return pe(e,`${t}.json`)};return{runtimeFile:t=>(n(t),pe(e,`${t}.runtime.json`)),runtime(e){const t=this.runtimeFile(e);if(!T(t))return;const n=JSON.parse(M(t,"utf8"));if(!n||"object"!=typeof n||Array.isArray(n))throw new Error("Invalid local dev runtime state.");const o=n;if(!["running","completed","failed","canceled"].includes(String(o.status))||void 0!==o.url&&"string"!=typeof o.url||void 0!==o.exitCode&&!Number.isSafeInteger(o.exitCode)||void 0!==o.error&&"string"!=typeof o.error)throw new Error("Invalid local dev runtime state.");return o},save(t){const o=n(t.jobId);I(e,{recursive:!0,mode:448});const a=pe(e,`${t.jobId}.${i()}.tmp`);try{H(a,JSON.stringify(t),{flag:"wx",mode:384}),O(a,o)}finally{T(a)&&W(a)}},get(e){const o=n(e);if(!T(o))return;const i=JSON.parse(M(o,"utf8"));if(!i||"object"!=typeof i||Array.isArray(i))throw new Error("Invalid stored project job.");const a=i;if(a.jobId!==e||"string"!=typeof a.chatId||"string"!=typeof a.operation||void 0!==a.project&&"string"!=typeof a.project||void 0!==a.workingDirectory&&"string"!=typeof a.workingDirectory||void 0!==a.startedAt&&!Number.isFinite(a.startedAt)||void 0!==a.pid&&(!Number.isSafeInteger(a.pid)||Number(a.pid)<1)||void 0!==a.processIdentity&&"string"!=typeof a.processIdentity||!Number.isFinite(a.createdAt)||!Number.isFinite(a.updatedAt)||"string"!=typeof a.output||a.output.length>8e3||!["running","completed","failed","canceled"].includes(String(a.status)))throw new Error("Invalid stored project job.");const r=a;if(!("running"!==r.status&&t()-r.updatedAt>1728e5))return r;{W(o);const t=this.runtimeFile(e);T(t)&&W(t)}},list(){return T(e)?q(e).filter(e=>om.test(e.slice(0,-5))&&e.endsWith(".json")).map(e=>{try{return this.get(e.slice(0,-5))}catch(t){return void console.warn(`Could not read local project job ${e}: ${t instanceof Error?t.message:String(t)}`)}}).filter(e=>!!e):[]},remove(e){const t=n(e);T(t)&&W(t);const o=this.runtimeFile(e);T(o)&&W(o)}}}(pe(n(),".needle","cli","ai-jobs"),l),d=new Map,m=new Map;function f(e){const{controller:t,...n}=e;u.save(n)}function h(e){if("failed"!==e.status||!r)return;const{controller:t,...n}=e;try{r(n)}catch(e){console.error(`Could not record local project job failure: ${e instanceof Error?e.message:String(e)}`)}}function g(){for(const[e,t]of d)l()-t.createdAt>3e5&&d.delete(e);for(const[e,t]of m)"running"!==t.status&&l()-t.updatedAt>36e5&&m.delete(e)}function v(e){const o=pm(e.request,t(),n());if(JSON.stringify({...o,request:null})!==JSON.stringify({...e,request:null,planId:void 0,chatId:void 0,createdAt:void 0}))throw new Error("The project command or its inputs changed since approval. Plan it again.")}function b(e){if("running"!==e.status)return e;const t="dev"===e.operation?u.runtime(e.jobId):void 0;return null!=t&&t.url&&(e.url=t.url),t&&"running"!==t.status?(e.status=t.status,e.exitCode=t.exitCode,t.error&&(e.output=Ed(t.error).slice(-8e3))):"dev"===e.operation&&e.pid&&e.processIdentity&&p(e.pid)===e.processIdentity||(e.status="failed",e.output=`${e.output}\nThe CLI restarted and the original project process is no longer running or cannot be verified.`.trim().slice(-8e3)),"running"!==e.status&&(e.updatedAt=l(),u.save(e)),e}function x(e){if(e)return[...m.values()].find(t=>"dev"===t.operation&&t.project===e&&"running"===t.status)||u.list().map(b).find(t=>"dev"===t.operation&&t.project===e&&"running"===t.status)}function y(){for(const e of u.list())b(e)}y();const w=setInterval(y,36e5);return w.unref(),{plan(e,o){if(g(),!o)throw new Error("A Cloud chat is required to plan an AI project command.");const a={...pm(e,t(),n()),planId:i(),chatId:o,createdAt:l()},r="dev"===a.operation?x(a.project):void 0;if(r)throw new Error(`A dev server for this project is already running (job ID ${r.jobId}). Check its status or cancel it before starting another.`);return d.set(a.planId,a),a},getPlan(e,t){g();const n=d.get(e);if(!n||n.chatId!==t)throw new Error("This project command plan does not belong to this chat or expired.");return v(n),n},async start(e,t){g();const n=d.get(e);if(!n)throw new Error("This project command plan expired or was already used.");if(!t||t.chatId!==n.chatId||t.planId!==e)throw new Error("Exact Cloud approval is required for this project command.");if(!a())throw new Error("AI project commands are disabled in local Needle CLI settings.");v(n);const r="dev"===n.operation?x(n.project):void 0;if(r)throw new Error(`A dev server for this project is already running (job ID ${r.jobId}). Check its status or cancel it before starting another.`);n.customProject&&n.project&&(null==c||c(n.project)),d.delete(e);const p={jobId:i(),chatId:n.chatId,operation:n.operation,project:n.project||n.destination,workingDirectory:n.project||se(n.destination),startedAt:l(),createdAt:l(),updatedAt:l(),status:"running",output:"",controller:new AbortController};return m.set(p.jobId,p),f(p),"dev"===n.operation&&(n.runtimeFile=u.runtimeFile(p.jobId)),Promise.resolve().then(()=>o(n,p.controller.signal,e=>{"running"===p.status&&(void 0!==e.output&&(p.output=Ed(e.output).slice(-8e3)),void 0!==e.url&&(p.url=e.url),void 0!==e.browserOpened&&(p.browserOpened=e.browserOpened),void 0!==e.browserError&&(p.browserError=e.browserError),"dev"===n.operation&&void 0!==e.pid&&e.processIdentity&&(p.pid=e.pid,p.processIdentity=e.processIdentity,void 0!==e.startedAt&&(p.startedAt=e.startedAt)),p.updatedAt=l(),f(p))})).then(e=>{p.exitCode=e.exitCode,p.output=Ed(String(e.output||"")).slice(-8e3),"canceled"!==p.status&&0===e.exitCode&&"create"===n.operation&&n.destination&&(null==s||s(n.destination)),"canceled"!==p.status&&(p.status=0===e.exitCode?"completed":"failed"),p.updatedAt=l(),f(p),h(p)}).catch(e=>{const t=p.controller.signal.aborted;p.controller.abort(),p.output=Ed(e instanceof Error?e.message:String(e)).slice(-8e3),p.status=t?"canceled":"failed",p.updatedAt=l(),f(p),h(p)}),{jobId:p.jobId,status:"running"}},status(e,t){g();const n=m.get(e)||u.get(e);if(!n||n.chatId!==t)throw new Error("This project job does not belong to this chat.");const o=m.get(e);if(o){const{controller:e,...t}=o;return t}return b(n)},async cancel(e,t){const n=m.get(e),o=n?void 0:u.get(e),i=n||o&&b(o);if(!i||i.chatId!==t)throw new Error("This project job does not belong to this chat.");if("running"!==i.status)return{jobId:e,canceled:!1};if(!n){if("dev"!==i.operation)throw new Error("Only supervised dev jobs can be stopped after a CLI restart.");H(`${u.runtimeFile(e)}.cancel`,"",{flag:"w",mode:384});const t=Date.now()+1e4;for(;Date.now()<t;){const t=b(i);if("running"!==t.status)return{jobId:e,canceled:"canceled"===t.status};await new Promise(e=>setTimeout(e,100))}throw new Error("The dev server stop was requested, but the supervisor did not confirm it within 10 seconds. Check the job status.")}return n.controller.abort(),i.status="canceled",i.updatedAt=l(),f(n),{jobId:e,canceled:!0}},dispose(){clearInterval(w);for(const e of m.values())"running"===e.status&&"dev"!==e.operation&&(e.controller.abort(),e.status="canceled",e.updatedAt=l(),f(e))}}}({getProject:()=>{var e;return null==(e=km())?void 0:e.web_location},onCreated:od,onApprovedProject:od,onFailure:e=>{var t;return yp(`[AI project] ${e.operation} failed job=${e.jobId} exit=${null!=(t=e.exitCode)?t:"error"} output=${e.output.replace(/\s+/g," ").slice(0,700)}`)}});function _m(e){if(null==e||!e.editGrant)throw new Error("Local file edit approval is required.");if(Qd())throw new Error("AI file edits are disabled in local Needle CLI settings.");return e.editGrant}function jm(e={}){gm({name:"local_files_editor_log_path",description:"Get the filepath to the editor log file on disk (this may be Unity or Blender)",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=Qu();if(n){const e=null==n?void 0:n.entries.sort((e,t)=>t.last_accessed-e.last_accessed)[0];if(null!=e&&e.log_location){const n=l(e.log_location).mtime;t.content.push({type:"text",text:`${e.log_location} (last modified: ${n.toLocaleString()})`})}else{let n="No recent project with known log location known.";e&&(n+=" Recent project is "+(null==e?void 0:e.project_location)),t.content.push({type:"text",text:n})}}return t},{source:"cli"},()=>{}),gm({name:"local_files_editor_project_path",description:"Get the filepath to the currently opened project in the editor (this may be Unity or Blender)",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=Qu();if(n){const e=null==n?void 0:n.entries.sort((e,t)=>t.last_accessed-e.last_accessed)[0];t.content.push(null!=e&&e.project_location?{type:"text",text:e.project_location}:{type:"text",text:"No recent project with known project location known."})}return t},{source:"cli"},()=>{}),gm({name:"local_files_editor_scene_path",description:"Get the filepath to the currently opened scene in the editor (Unity or Blender). Use this to find out which scene the user is working on.",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=Qu();if(n){const e=null==n?void 0:n.entries.sort((e,t)=>t.last_accessed-e.last_accessed)[0];t.content.push(null!=e&&e.scene_location?{type:"text",text:e.scene_location}:{type:"text",text:"No recent project with known scene location known."})}return t},{source:"cli"},()=>{}),gm({name:"local_files_web_project_path",description:"Get the filepath to the selected Needle Engine web project. Unity-generated web projects may validly live inside the Unity project's Library/Needle directory; do not treat that location alone as a misconfiguration. Use this directory as the web-project root.",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=km();return t.content.push(null!=n&&n.web_location?{type:"text",text:w(n.web_location)}:{type:"text",text:"No selected web project is known."}),t},{source:"cli"},()=>{}),gm({name:"local_files_diff",description:"Compare a local project text file with the first version observed by this chat. local_files_read saves a hash-only baseline on the first read; later reads do not replace it. Returns changed line ranges and bounded current lines, never removed text or who changed it. If no baseline exists, read the file first. Use mode=reset only after reviewing changes to start a new baseline. Works for web and editor project files.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path relative to the connected web or editor project, or an absolute path within it."},mode:{type:"string",enum:["compare","reset"],description:"Compare with the first observed version (default), or replace that version with the current file."}},required:["path"],additionalProperties:!1}},async(e,t)=>{var n;const o=$m(e.path);if(!o)throw new Error("Path is outside the connected project.");const i={root:o.root,path:j(o.root,o.resolved),chatId:null!=(n=null==t?void 0:t.chatId)?n:"local-mcp"},a="reset"===e.mode?xm.snapshot(i):xm.diff(i);return{content:[{type:"text",text:JSON.stringify(a)}]}},{source:"cli"},()=>{}),gm({name:"local_files_open",description:'Open an existing file or directory in the connected local web or editor project using the operating system default app. Directories open in the file manager; use path="." for the project root. Use a project-relative path and select project="web" or "editor". This affects the user desktop. It does not read or edit files. Executable file types and paths outside the selected project are refused.',inputSchema:{type:"object",properties:{project:{type:"string",enum:["web","editor"]},path:{type:"string"}},required:["project","path"],additionalProperties:!1}},async e=>({content:[{type:"text",text:JSON.stringify(await ym(e))}]}),{source:"cli"},()=>{}),gm({name:"local_files_read",description:"Read a file from the user's local project on disk (editor project or web project). The path must be relative to the project root or an absolute path inside the project. Sensitive files, including .env variants and private keys, are refused. Recognizable secrets are redacted before filtering or selecting lines. UTF-8 files are limited to 8 MiB. Returns the file contents (or a portion if offset/limit are specified). Use 'filter' to search for specific terms within the file.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path (relative to project root, or absolute within the project)"},offset:{type:"number",description:"Line number to start reading from (1-based, default: 1). In filter mode: number of matches to skip."},limit:{type:"number",description:"Maximum number of lines to return (default: 200, max: 1000). In filter mode: max matches to return."},filter:{type:"string",description:'Regex to search for in the file (case-insensitive, e.g. "error|warning"). Falls back to a literal substring match if the pattern isn\'t valid regex. Returns matching lines with line numbers instead of sequential content.'}},additionalProperties:!1,required:["path"]}},async(e,t)=>{const n=$m(e.path);if(!n)return{content:[{type:"text",text:"Error: path is outside the project directory."}]};try{const i=l(n.resolved).mtime.toISOString(),a=Nd(n.root,n.resolved).text.split("\n");let r="";try{var o;const e=xm.observe({root:n.root,path:j(n.root,n.resolved),chatId:null!=(o=null==t?void 0:t.chatId)?o:"local-mcp"});r="unsupported"===e.status?`\nChange baseline unavailable: ${e.reason}`:`\nChange baseline: ${"saved"===e.status?"saved":"kept from first read"}. Use local_files_diff to compare later changes.`}catch(e){console.error("[MCP] Could not observe local file changes",e),r=`\nChange baseline unavailable: ${e instanceof Error?e.message:"unknown error"}`}if(e.filter){const t=mm(e.filter),o=[];for(let e=0;e<a.length;e++)t.test(a[e])&&o.push(`${e+1}: ${a[e]}`);const s=o.length,c=Math.max(0,e.offset||0),l=Math.min(Math.max(e.limit||200,1),1e3),p=o.slice(c,c+l);return{content:[{type:"text",text:`File: ${n.resolved} (modified: ${i}) — filter="${e.filter}" (${t.mode}) → ${s} matches (showing ${c+1}-${c+p.length}) in ${a.length} lines`+r+"\n"+p.join("\n")}]}}const s=Math.max(1,e.offset||1),c=Math.min(e.limit||200,1e3),p=a.slice(s-1,s-1+c),u=p.map((e,t)=>`${s+t}: ${e}`).join("\n");return{content:[{type:"text",text:`File: ${n.resolved} (${a.length} lines, modified: ${i}, showing ${s}-${s+p.length-1})`+r+"\n"+u}]}}catch(e){return{content:[{type:"text",text:`Error reading file: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),gm({name:"local_files_grep",description:"Search for a pattern in the user's local project files on disk (editor project and web project) using grep. Searches sanitized UTF-8 text; sensitive files, links, hidden directories and node_modules are skipped. Reports omitted entries and search limits. Returns matching lines with file paths and line numbers. Note: runtime-only things (e.g. node-material shaders) have no source files — read those with the inspector_* tools instead.",inputSchema:{type:"object",properties:{pattern:{type:"string",description:"Search pattern (regular expression)"},glob:{type:"string",description:"File glob filter, e.g. '*.ts' or '*.cs' (optional)"},max_results:{type:"number",description:"Maximum number of matching lines to return (default: 50)"}},additionalProperties:!1,required:["pattern"]}},async e=>{const t=Em();if(0===t.length)return{content:[{type:"text",text:"Error: no active project found."}]};const n=Math.min(Math.max(Math.floor(e.max_results||50),1),200),o=t.map(t=>Ud(t,{pattern:e.pattern,glob:e.glob,maxResults:n})),i=o.flatMap(e=>e.lines),a=`\nOmitted ${o.reduce((e,t)=>e+t.omitted,0)} sensitive, unsupported or excluded entries.${o.some(e=>e.limited)?" Search stopped at the file, byte, depth or time limit.":""}`;return{content:[{type:"text",text:(i.length?`Found ${i.length} matches:\n`+i.slice(0,n).join("\n"):"No matches found.")+a}]}},{source:"cli"},()=>{}),gm({name:"local_files_list",description:"List files in the user's local project directories on disk matching an optional glob pattern. A list is shallow by default: files in subdirectories are NOT included. When checking whether a file exists anywhere below a folder, use recursive=true or provide its exact subdirectory in path. By default searches both the editor project (Unity/Blender) and the web project. Use the 'project' parameter to target a specific one. Results are prefixed with <web_project>/..., <unity>/..., or <blender>/... so you know which root each file belongs to. Do not conclude that a file is absent from a project based on a shallow listing.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Project-relative subdirectory to list (default: root). Absolute paths, including paths to a different project, are not accepted."},pattern:{type:"string",description:"Glob pattern to filter files, e.g. '*.ts' or '*.glb'. Supports multiple patterns separated by '|', e.g. '*.gltf|*.glb' (optional)"},recursive:{type:"boolean",description:"Set true to include files in all subdirectories. Default false lists only files directly in path; use true before claiming a nested file is absent."},project:{type:"string",enum:["web","editor"],description:"Which project root to search: 'web' for the Needle Engine web project (use this for exported assets, source files, node_modules), 'editor' for the Unity/Blender project. Omit to search both."}},additionalProperties:!1,required:[]}},async e=>{if(void 0!==e.path&&("string"!=typeof e.path||k(e.path)))return{content:[{type:"text",text:"Error: local_files_list requires a project-relative path. It cannot list an absolute path outside the connected project."}]};const t=km();if(!t)return{content:[{type:"text",text:"Error: no active project found."}]};const n="blender"===t.editor?"<blender>":"unity"===t.editor?"<unity>":"<editor_project>",o=[];if(e.project&&"editor"!==e.project||!t.project_location||o.push({root:w(t.project_location),label:n}),e.project&&"web"!==e.project||!t.web_location||o.push({root:w(t.web_location),label:"<web_project>"}),0===o.length)return{content:[{type:"text",text:"Error: no active project found."}]};const i=[],a=[];for(const{root:t,label:n}of o){const o=Sm(e.path||".",t);if(o)try{var r;e.recursive||a.push(...u(o,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(".")&&"node_modules"!==e.name).map(e=>`${n}/${j(t,_(o,e.name))}`));const s=Im(o,t,null!=(r=e.recursive)&&r,e.pattern,0);i.push(...s.map(e=>({file:e,root:t,label:n})))}catch(e){throw new Error(`Could not list project files: ${e instanceof Error?e.message:String(e)}`)}}const s=a.length>0?`\nShallow listing: subdirectories were not searched (${a.slice(0,12).join(", ")}${a.length>12?", ...":""}). To search nested files, call local_files_list with recursive=true or set path to the subdirectory.`:"";if(0===i.length)return{content:[{type:"text",text:`No files found directly in the selected path.${o.length>0?`\nSearched in:\n${o.map(e=>`${e.label} → ${e.root}`).join("\n")}`:"\nNo project directories available to search."}${s}`}]};const c=i.slice(0,500).map(e=>`${e.label}/${j(e.root,e.file)}`);return{content:[{type:"text",text:`Found ${i.length} files${i.length>500?" (showing first 500)":""}:\n`+c.join("\n")+s}]}},{source:"cli"},()=>{}),gm({name:"local_files_read_editor_log",description:"Read or search the Unity or Blender editor log file. By default reads the last N lines. Use the 'filter' parameter to search for specific terms (e.g. error messages, warnings, component names) across the entire log.",inputSchema:{type:"object",properties:{lines:{type:"number",description:"Number of lines to read from the end of the log (default: 100, max: 500). Ignored when filter is set."},filter:{type:"string",description:'Regex to search for in the log (case-insensitive, e.g. "error|exception|warning"). Falls back to a literal substring match if the pattern isn\'t valid regex. Returns all matching lines from the entire log instead of just the tail.'},offset:{type:"number",description:"Number of matching results to skip from the start (default: 0). Only used with filter."},limit:{type:"number",description:"Maximum number of matching results to return (default: 200, max: 500). Only used with filter."}},additionalProperties:!1,required:[]}},async e=>{const t=km();var n;if(null==t||!t.log_location)return wp(`read_editor_log: no editor log file known (project: ${null!=(n=null==t?void 0:t.project_location)?n:"none"})`),{content:[{type:"text",text:"Error: no editor log file known. Is a Unity or Blender project open?"}]};try{if(!t.log_location.toLowerCase().endsWith(".log"))throw new Error("Only the connected editor log can be read.");const n=Nd(se(t.log_location),fe(t.log_location),{maxBytes:67108864,allowPrivateKeys:!0}).text.split("\n");let o,i;if(e.filter){const t=mm(e.filter);o=[];for(let e=0;e<n.length;e++)t.test(n[e])&&o.push(`L${e+1}: ${n[e]}`);const a=o.length,r=Math.max(0,e.offset||0),s=Math.min(Math.max(e.limit||200,1),500);o=o.slice(r,r+s),i=`filter="${e.filter}" (${t.mode}) → ${a} matches (showing ${r+1}-${r+o.length}) in ${n.length} total lines`}else{const t=Math.min(Math.max(e.lines||100,1),500);o=n.slice(-t),i=`last ${t} of ${n.length} lines`}const a="unity"===t.editor?function(e){const t=[],n=new Map;let o=!1,i=0;for(const a of e){if(/^\s+at\s/.test(a)||/^\s*(UnityEngine\.|System\.|Unity\.)/.test(a)||/^\s+\w+[\w.<>]+\s*\(/.test(a)){o||(o=!0,i=0),i++,i<=3?t.push(a):4===i&&t.push(" ... (stack trace truncated)");continue}if(o=!1,i=0,!a.trim())continue;const e=n.get(a)||0;if(n.set(a,e+1),0===e)t.push(a);else if(1===e)t.push(` [repeated ${e+1}x] ${a}`);else{const n=t.length-1;n>=0&&t[n].startsWith(" [repeated")&&(t[n]=` [repeated ${e+1}x] ${a}`)}}return t}(o):o,r=5e4;let s=a.join("\n"),c="";if(s.length>r){s=s.substring(s.length-r);const e=s.indexOf("\n");e>0&&(s=s.substring(e+1)),c=" (output truncated to last ~50KB)"}return{content:[{type:"text",text:`Editor log: ${t.log_location} (${i}, ${a.length} after processing, editor: ${t.editor})${c}:\n`+s}]}}catch(e){return{content:[{type:"text",text:`Error reading log: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),gm({name:"local_files_read_gltf",description:"Read and summarize a glTF or GLB file from the user's local project on disk. Without a query, returns a structured summary including nodes, meshes, materials, animations, extensions, and compression/optimization hints. Use 'query' to drill into specific parts using JSON pointer paths. Use '*' as a wildcard for array indices or object keys. For GLB files, extracts the JSON chunk and skips binary data.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path to a .gltf or .glb file (relative to project root, or absolute path)"},query:{type:"string",description:"JSON pointer path to extract a specific part of the glTF, e.g. '/nodes/0', '/materials', '/extensions/NEEDLE_progressive', '/materials/*/extensions'. Use '*' as a wildcard for array indices or object keys."}},additionalProperties:!1,required:["path"]}},async e=>{let t=$m(e.path);if(!t)return{content:[{type:"text",text:"Error: path is outside the project directory."}]};if(!c(t.resolved))return{content:[{type:"text",text:`Error: file not found: ${t.resolved}`}]};try{const n=function(e,t){const n=e.toLowerCase();if(n.endsWith(".gltf")){const n=Nd(t,e).text;return JSON.parse(n)}if(n.endsWith(".glb")){const n=Ad(t,e,{maxBytes:20,range:{offset:0,length:20}});if(n.length<20)return null;if(1179937895!==n.readUInt32LE(0))return null;const o=n.readUInt32LE(12);if(1313821514!==n.readUInt32LE(16))return null;const i=Ad(t,e,{maxBytes:67108864,range:{offset:20,length:o}}).toString("utf-8"),a=jd(JSON.parse(i));if(!a||"object"!=typeof a||Array.isArray(a))throw new Error("glTF JSON must be an object.");return a}return null}(t.resolved,t.root);if(!n)return{content:[{type:"text",text:"Error: could not parse glTF/GLB file."}]};const o=5e4;if(e.query){const i=Tm(n,e.query.replace(/^\//,"").split("/"));if(void 0===i)return{content:[{type:"text",text:`No data found at pointer: ${e.query}`}]};let a=JSON.stringify(i),r=!1;return a.length>o&&(a=a.substring(0,o),r=!0),{content:[{type:"text",text:`${e.query} in ${t.resolved}`+(r?` (truncated to ${o} chars)`:"")+"\n"+a}]}}let i=function(e,t){var n,o,i,a,r,s,c,l,p,u,d,m,f;const h=[`glTF: ${t}`];if(e.asset){const t=[];e.asset.version&&t.push(`v${e.asset.version}`),e.asset.generator&&t.push(e.asset.generator),h.push(`Asset: ${t.join(", ")}`)}if(null!=(n=e.extensionsUsed)&&n.length&&h.push(`Extensions used: ${e.extensionsUsed.join(", ")}`),null!=(o=e.extensionsRequired)&&o.length&&h.push(`Extensions required: ${e.extensionsRequired.join(", ")}`),null!=(i=e.scenes)&&i.length&&h.push(`Scenes: ${e.scenes.length}${void 0!==e.scene?` (default: ${e.scene})`:""}`),null!=(a=e.nodes)&&a.length){var g,v,b;h.push(`\nNodes (${e.nodes.length}):`);const t=null!=(g=null==(v=e.scenes)||null==(v=v[null!=(b=e.scene)?b:0])?void 0:v.nodes)?g:[],n=new Set,o=(t,i)=>{if(i>6||n.has(t))return;n.add(t);const a=e.nodes[t];if(!a)return;const r=" ".repeat(i),s=[];if(void 0!==a.mesh&&s.push(`mesh:${a.mesh}`),void 0!==a.camera&&s.push(`camera:${a.camera}`),void 0!==a.skin&&s.push(`skin:${a.skin}`),a.extensions&&s.push(`ext:[${Object.keys(a.extensions).join(",")}]`),h.push(`${r}- ${a.name||`node_${t}`}${s.length?` (${s.join(", ")})`:""}`),a.children)for(const e of a.children)o(e,i+1)};for(const e of t)o(e,1);n.size<e.nodes.length&&n.size>0&&h.push(` ... and ${e.nodes.length-n.size} more nodes`)}if(null!=(r=e.meshes)&&r.length){h.push(`\nMeshes (${e.meshes.length}):`);for(const t of e.meshes.slice(0,30)){var x,y;const e=null!=(x=null==(y=t.primitives)?void 0:y.length)?x:0;h.push(` - ${t.name||"(unnamed)"} (${e} primitive${1!==e?"s":""})`)}e.meshes.length>30&&h.push(` ... and ${e.meshes.length-30} more`)}if(null!=(s=e.materials)&&s.length){h.push(`\nMaterials (${e.materials.length}):`);for(const t of e.materials.slice(0,30)){const e=t.name||"(unnamed)",n=[];t.pbrMetallicRoughness&&n.push("PBR"),t.alphaMode&&"OPAQUE"!==t.alphaMode&&n.push(t.alphaMode),t.doubleSided&&n.push("doubleSided"),t.extensions&&n.push(`ext:[${Object.keys(t.extensions).join(",")}]`),h.push(` - ${e}${n.length?` (${n.join(", ")})`:""}`)}e.materials.length>30&&h.push(` ... and ${e.materials.length-30} more`)}if(null!=(c=e.textures)&&c.length&&h.push(`Textures: ${e.textures.length}`),null!=(l=e.images)&&l.length&&h.push(`Images: ${e.images.length}`),null!=(p=e.animations)&&p.length){h.push(`\nAnimations (${e.animations.length}):`);for(const t of e.animations.slice(0,20)){var w,_;const e=null!=(w=null==(_=t.channels)?void 0:_.length)?w:0;h.push(` - ${t.name||"(unnamed)"} (${e} channel${1!==e?"s":""})`)}e.animations.length>20&&h.push(` ... and ${e.animations.length-20} more`)}if(null!=(u=e.skins)&&u.length){h.push(`\nSkins (${e.skins.length}):`);for(const t of e.skins.slice(0,10)){var j,k;h.push(` - ${t.name||"(unnamed)"} (${null!=(j=null==(k=t.joints)?void 0:k.length)?j:0} joints)`)}}if(null!=(d=e.cameras)&&d.length){h.push(`\nCameras (${e.cameras.length}):`);for(const t of e.cameras)h.push(` - ${t.name||"(unnamed)"} (${t.type})`)}if(null!=(m=e.buffers)&&m.length){const t=e.buffers.reduce((e,t)=>e+(t.byteLength||0),0);h.push(`\nBuffers: ${e.buffers.length} (${(t/1024/1024).toFixed(1)} MB total)`)}return null!=(f=e.accessors)&&f.length&&h.push(`Accessors: ${e.accessors.length}`),h.join("\n")}(n,t.resolved);return i.length>o&&(i=i.substring(0,o)+"\n... (truncated)"),{content:[{type:"text",text:i}]}}catch(e){return{content:[{type:"text",text:`Error reading glTF: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),function(){const e=e=>({content:[{type:"text",text:JSON.stringify(e)}]});gm({name:"local_files_resolve_url",description:"Find the working directory of the process serving a localhost URL, including a server started by another app or by the user. Returns the listening PID and working directory, or an explicit reason when unavailable. The URL path is not assumed to be a file path. Works only for a server running on the same machine as the Needle CLI.",inputSchema:{type:"object",properties:{url:{type:"string",description:"HTTP localhost URL or loopback host:port, for example http://127.0.0.1:8765/preview.html."}},required:["url"],additionalProperties:!1}},async t=>e(await async function(e){const t=function(e){if("string"!=typeof e||!e.trim())throw new Error("A localhost URL or host:port is required.");const t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`http://${t}`);if("http:"!==n.protocol&&"https:"!==n.protocol)throw new Error("Only HTTP and HTTPS localhost URLs are supported.");const o=n.hostname.toLowerCase();if(!["localhost","127.0.0.1","[::1]"].includes(o))throw new Error("Only localhost or loopback IP addresses are supported.");const i=n.port?Number(n.port):"https:"===n.protocol?443:80;if(!Number.isInteger(i)||i<1||i>65535)throw new Error("A valid TCP port is required.");return{host:o,port:i,path:n.pathname+n.search}}(e);if("win32"===process.platform){const e=await async function(e,t){const n=hm.replace("__PORT__",String(e)).replace("__HOST__",t),o=Buffer.from(n,"utf16le").toString("base64"),{stdout:i}=await fm("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",o],{timeout:1e4,maxBuffer:1048576});return JSON.parse(i.trim())}(t.port,t.host);return{...t,...e}}if("linux"===process.platform||"darwin"===process.platform){const e="linux"===process.platform?await async function(e){const t=new Set;for(const o of["/proc/net/tcp","/proc/net/tcp6"]){let i;try{i=await K(o,"utf8")}catch(e){if("ENOENT"===e.code)continue;throw e}for(const o of i.split("\n").slice(1)){var n;const i=o.trim().split(/\s+/);i.length<10||Number.parseInt(null!=(n=i[1].split(":").at(-1))?n:"",16)===e&&"0A"===i[3]&&t.add(i[9])}}if(!t.size)return null;const o=await Y("/proc",{withFileTypes:!0});for(const e of o){if(!e.isDirectory()||!/^\d+$/.test(e.name))continue;let n;try{n=await Y(`/proc/${e.name}/fd`)}catch{continue}for(const o of n)try{const n=await V(`/proc/${e.name}/fd/${o}`),i=/^socket:\[(\d+)\]$/.exec(n);if(i&&t.has(i[1]))return Number(e.name)}catch{}}throw new Error("A process is listening, but its PID is not visible to this CLI.")}(t.port):await async function(e){try{const{stdout:t}=await fm("lsof",["-nP","-t",`-iTCP:${e}`,"-sTCP:LISTEN"],{timeout:5e3}),n=Number(t.trim().split(/\s+/)[0]);return Number.isInteger(n)&&n>0?n:null}catch(e){if(1===e.code)return null;throw e}}(t.port);if(null===e)return{...t,status:"not-listening"};try{const n="linux"===process.platform?await V(`/proc/${e}/cwd`):await async function(e){const{stdout:t}=await fm("lsof",["-a","-p",String(e),"-d","cwd","-Fn"],{timeout:5e3}),n=t.split(/\r?\n/).find(e=>e.startsWith("n"));if(!n)throw new Error("The process working directory is not available.");return n.slice(1)}(e);return{...t,status:"found",pid:e,workingDirectory:n}}catch(n){return{...t,status:"unavailable",pid:e,reason:n instanceof Error?n.message:String(n)}}}return{...t,status:"unavailable",reason:`Unsupported platform: ${process.platform}`}}(null==t?void 0:t.url)),{source:"cli"},()=>{}),gm({name:"local_project_list",description:"List web projects registered with the local Needle CLI, including projects created by AI after a successful create job. Each path may be selected with local_project_select. File tools access only the currently selected project.",inputSchema:{type:"object",properties:{},required:[],additionalProperties:!1}},async()=>e(Qu().entries.filter(e=>e.web_location).map(e=>({path:e.web_location,selected:e===km(),editor:e.editor}))),{source:"cli"},()=>{}),gm({name:"local_project_select",description:"Select a registered local web project by its exact path from local_project_list. Subsequent local_files_* tools use this project. Selecting a project does not approve edits; Cloud chat must obtain a separate file-edit grant for the selected project.",inputSchema:{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:!1}},async t=>e({selected:id(t.path).web_location}),{source:"cli"},()=>{}),gm({name:"local_project_action",description:"Prepare a local Needle project action without executing it. Operations: create (name, template, optional absolute parent or destination), install, add_package (packages, optional dev), build, dev (start the dev server and open its local URL in the default browser), deploy (target team ID required; optional name and relative build directory). For dev, hot reload may be disabled in vite.config.js/ts by hmr: false or Needle allowHotReload: false; if edits do not appear, inspect the config and use the normal file-edit approval to enable it if appropriate. For create, parent is an existing folder to create the named project INSIDE, even if the parent has spaces or parentheses; destination is the full path of the new project and must end with name. If the user provides an existing folder path, use parent and do not treat its basename as the project name. If only the name is missing, ask only for a name. For install/add_package/build/dev/deploy, omit project to use the selected web project, or pass an explicit absolute path to another local project; that target needs fresh Cloud approval. An approved action for another project registers and selects it for local file tools, even if the command fails. A successful create job also registers and selects its new project. Use local_project_list and local_project_select to return to another registered project. Never put a project path in directory; that is only the deploy build output. Cloud chat fills the current team if omitted. For a prepared action, pass planId alone to retrieve its exact command and project. Then call request_local_project_command with planId for approval. Local CLI settings can still disable execution.",inputSchema:{type:"object",properties:{operation:{type:"string",enum:["create","install","add_package","build","dev","deploy"]},name:{type:"string"},template:{type:"string",enum:am},parent:{type:"string",description:"Existing absolute folder in which to create the new project. Its name may contain spaces or parentheses; the new child folder uses name."},destination:{type:"string",description:"Full absolute path to the new project folder; its last segment must equal name. Use parent instead when the user supplies an existing containing folder."},project:{type:"string",description:"Absolute local project path. Use the path returned by a completed create job for a new project; omit for the connected web project. A different path requires fresh approval."},packages:{type:"array",items:{type:"string"}},dev:{type:"boolean"},directory:{type:"string"},team:{type:"string",description:"Target Needle Cloud team ID for deploy. Use the org_... identifier, which Cloud data may call orgId. In Cloud chat, omit this to use the current team."},planId:{type:"string"}},required:[],additionalProperties:!1}},async(t,n)=>{if(null==n||!n.chatId)throw new Error("A Cloud chat is required to plan an AI project command.");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Project command arguments must be an object.");return e(t.planId?wm.getPlan(t.planId,n.chatId):wm.plan(t,n.chatId))},{source:"cli"},()=>{}),gm({name:"local_project_start",description:"Internal Cloud approval handoff for a previously planned project command. A model tool call cannot grant approval.",inputSchema:{type:"object",properties:{planId:{type:"string"}},required:["planId"],additionalProperties:!1}},async(t,n)=>{if(!t||"string"!=typeof t.planId)throw new Error("A project plan ID is required.");if(null==n||!n.commandGrant||n.chatId!==n.commandGrant.chatId||t.planId!==n.commandGrant.planId)throw new Error("Exact Cloud approval is required for this project command.");if(em())throw new Error("AI project commands are disabled in local Needle CLI settings.");return e(await wm.start(t.planId,n.commandGrant))},{source:"cli"},()=>{}),gm({name:"local_project_status",description:"Read the status and bounded output of a local project command job in this chat. Poll this after local_project_start; the job may take several minutes.",inputSchema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"],additionalProperties:!1}},async(t,n)=>{if(!t||"string"!=typeof t.jobId)throw new Error("A project job ID is required.");if(null==n||!n.chatId)throw new Error("A Cloud chat is required to inspect this project job.");return e(wm.status(t.jobId,n.chatId))},{source:"cli"},()=>{}),gm({name:"local_project_cancel",description:"Cancel a running local project command job in this chat.",inputSchema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"],additionalProperties:!1}},async(t,n)=>{if(!t||"string"!=typeof t.jobId)throw new Error("A project job ID is required.");if(null==n||!n.chatId)throw new Error("A Cloud chat is required to cancel this project job.");return e(await wm.cancel(t.jobId,n.chatId))},{source:"cli"},()=>{})}(),gm(Wl.schema,async e=>{const t=await Wl.execute(e);return"error"in t?{content:[{type:"text",text:t.error}]}:{content:[{type:"text",text:t.content}]}},{source:"cli"},()=>{}),gm({name:"local_files_stat",description:'Check one exact relative path in the connected local web project and read its SHA-256 hash and size. This does not search by basename or recurse: exists=false only means that exact path was not found. First locate a nested file with local_files_list(path="src", recursive=true), then pass the full relative path such as src/scripts/MyComponent.ts. Use the returned hash as expectedSha256 before replacing or deleting that file.',inputSchema:{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:!1}},async e=>({content:[{type:"text",text:JSON.stringify(bm.stat(e.path))}]}),{source:"cli"},()=>{}),gm({name:"local_files_write",description:"Create or replace a UTF-8 text file in the approved local web project. For an existing file, first call local_files_stat and pass its SHA-256 hash as expectedSha256. Creating a new file requires create=true. Automatically saves an undo checkpoint. Requires user approval for this project and chat session. A successful write only confirms that bytes were saved; run local_files_check_project with mode=check afterward before saying TypeScript errors are fixed.",inputSchema:{type:"object",properties:{path:{type:"string"},content:{type:"string"},create:{type:"boolean"},expectedSha256:{type:"string"}},required:["path","content"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.write(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_delete",description:"Delete a file in the approved local web project. First call local_files_stat and pass its SHA-256 hash as expectedSha256. Saves an undo checkpoint and refuses changed files.",inputSchema:{type:"object",properties:{path:{type:"string"},expectedSha256:{type:"string"}},required:["path","expectedSha256"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.delete(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_rename",description:"Rename a file within the approved local web project. First call local_files_stat and pass its SHA-256 hash as expectedSha256. The destination must not exist. Saves an undo checkpoint.",inputSchema:{type:"object",properties:{path:{type:"string"},newPath:{type:"string"},expectedSha256:{type:"string"}},required:["path","newPath","expectedSha256"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.rename(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_undo",description:"Undo one saved AI file edit in the approved local web project. Refuses to overwrite changes made after the edit. The checkpoint remains available for Redo.",inputSchema:{type:"object",properties:{checkpointId:{type:"string"}},required:["checkpointId"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.undo(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_redo",description:"Reapply one previously undone AI file edit from its checkpoint. Refuses to overwrite changes made after Undo. Requires active file-edit approval.",inputSchema:{type:"object",properties:{checkpointId:{type:"string"}},required:["checkpointId"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.redo(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_undo_turn",description:"Undo all AI file edits from one turn in reverse order. Use a turnId from local_files_list_changes. Checks every file for conflicts before changing anything; refuses changed files. Older checkpoints without turn ordering must be undone individually.",inputSchema:{type:"object",properties:{turnId:{type:"string"}},required:["turnId"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.undoTurn(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_list_changes",description:"List recent undo checkpoints for this chat and connected local web project. Requires active user approval. Returns filenames and checkpoint IDs, not file contents.",inputSchema:{type:"object",properties:{},required:[],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.list(_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_check_project",description:"Check the connected local web project for TypeScript errors without emitting files or applying fixes. Default mode check runs its installed compiler (10 second limit) and returns up to 5 short diagnostics. Use mode results with file/code filters and offset to browse the latest check without rerunning. Use mode error with an index for details; omit index for the last matching error. Results are timestamped snapshots, retained until another check or project change, or CLI exit. Local AI writes and changes to tracked local project files mark saved results stale; dependency files inside node_modules are excluded from the change scan. Retains at most 100 diagnostics. Reports current errors, not whether they predate edits. Not a linter or Unity/Blender compiler.",inputSchema:{type:"object",properties:{mode:{type:"string",enum:["check","results","error"],description:"Run a new check, browse cached results, or inspect one cached error."},file:{type:"string",maxLength:250,description:"Filter diagnostic filenames by case-insensitive substring; does not select a project or restrict compiler inputs."},code:{type:"string",maxLength:250,description:"Exact diagnostic code, e.g. TS2322."},offset:{type:"integer",minimum:0,description:"Offset within filtered results; 5 errors per page."},index:{type:"integer",minimum:0,description:"Diagnostic index from the latest check for mode error; defaults to the last matching error."}},additionalProperties:!1,required:[]}},async e=>{const t=await vm(e);return{content:[{type:"text",text:JSON.stringify(t)}],isError:"error"===t.status||"unavailable"===t.status}},{source:"cli"},()=>{}),null!=e&&e.logToolCount&&wp(`[MCP] registered ${ud.length} built-in tools: ${ud.map(e=>e.name).join(", ")}`)}function km(){return nd()}function Sm(e,t){const n=w(t,e),o=w(t),i=j(o,n);return k(i)||".."===i||i.startsWith(".."+S)?null:Od(o,n,{allowMissing:!0}).path}function Em(){const e=km();if(!e)return[];const t=[];return e.project_location&&t.push(w(e.project_location)),e.web_location&&t.push(w(e.web_location)),t}function $m(e){const t=Em();for(const n of t){const t=Sm(e,n);if(t&&c(t))return{resolved:t,root:n}}for(const n of t){const t=Sm(e,n);if(t)return{resolved:t,root:n}}const n=w(e);for(const e of t)if(n.startsWith(e+S)||n===e)return{resolved:n,root:e};return null}function Tm(e,t){if(0===t.length||null==e)return e;const[n,...o]=t;if("*"!==n)return Tm(e[/^\d+$/.test(n)?Number(n):n],o);if(Array.isArray(e)){const t=e.map(e=>Tm(e,o)).filter(e=>void 0!==e);return t.length>0?t:void 0}if("object"==typeof e){const t={};for(const n of Object.keys(e)){const i=Tm(e[n],o);void 0!==i&&(t[n]=i)}return Object.keys(t).length>0?t:void 0}}function Im(e,t,n,o,i){if(i>10)return[];const a=[],r=u(e,{withFileTypes:!0}),s="node_modules"===(e.split("/").pop()||e.split("\\").pop()||"");for(const c of r){if(s){if(".needle"!==c.name&&".vite"!==c.name)continue}else{if("Library"===c.name)continue;if(c.name.startsWith(".")||"node_modules"===c.name){if(!n)continue;if(c.name.startsWith("."))continue}}const r=_(e,c.name);if(!Td(j(t,r))&&!c.isSymbolicLink())if(Od(t,r),c.isDirectory())n&&a.push(...Im(r,t,!0,o,i+1));else{if(o&&!o.split("|").map(e=>(e=e.trim()).startsWith(".")&&!e.startsWith("*.")?"*"+e:e).filter(Boolean).some(e=>Ve(c.name,e,{nocase:!0})))continue;a.push(r)}}return a}process.once("exit",()=>wm.dispose());const Om="cli-installation-id",Am=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Cm=2e3,Rm=6e4,Nm=25e3,Pm=1e4,Um=i();let Lm=null,zm=null,Fm=null,Dm=null,qm=Cm,Bm=!1,Mm=!1;function Wm(){Lm||(Zd()?wp("Needle Cloud connection: skipped (remote_ai_tools disabled in settings)"):(Bm=!1,zm&&(clearTimeout(zm),zm=null),qm=Cm,Jm()))}function Hm(e){Bm=!0,Vm(),zm&&(clearTimeout(zm),zm=null),Lm?(wp(`Needle Cloud connection: closing (reason: ${null!=e?e:"shutdown"})`),Lm.close(1e3,null!=e?e:"shutdown"),Lm=null):e&&wp(`Needle Cloud connection: disconnect requested (reason: ${e}) — no active connection`)}function Gm(){if(!Lm||Lm.readyState!==Be.OPEN)return;try{jm()}catch(e){wp(`Needle Cloud connection: registerServerTools failed: ${e}`)}const e=ud.map(e=>e.name);var t;wp(`Needle Cloud connection: sending ${e.length} tools: ${e.join(", ")}`),Lm.send(JSON.stringify({type:"tools",tools:(t=ud,t.map(e=>{var t;return{name:e.name,description:e.description,inputSchema:e.inputSchema,capability:null!=(t=e.capability)?t:"local"}}))}))}async function Jm(){let e,t=await Uu();if(t||(t=function(){const e=Eu("accessToken");if(s.existsSync(e)){const t=s.readFileSync(e,"utf8");if(t){const e=JSON.parse(t),n=null==e?void 0:e["@https://cloud.needle.tools/api"];return null==n?void 0:n.token}}return null}(),t&&wp("Needle Cloud connection: using cached token (refresh failed)")),!t)return Mm||(wp("Needle Cloud connection: skipped (not logged in)"),Mm=!0),void Km(!0);Mm=!1;try{e=function(e=Kd()){I(e,{recursive:!0,mode:448});const t=pe(e,Om);try{H(t,i(),{flag:"wx",mode:384})}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"EEXIST"!==e.code)throw e}const n=M(t,"utf8").trim();if(!Am.test(n))throw new Error("Invalid local CLI installation ID.");return n}()}catch(e){return wp(`Needle Cloud connection: could not read local CLI installation identity: ${e instanceof Error?e.message:String(e)}`),void Km(!0)}const n="https://cloud.needle.tools/api".replace(/^http/,"ws")+"/v1/cli/ws?token="+encodeURIComponent(t)+"&instance="+encodeURIComponent(Um)+"&installation="+encodeURIComponent(e);wp("Needle Cloud connection: connecting...");const o=`needle-cloud/${cd()} Node/${process.versions.node}`;Lm=new Be(n,{headers:{"User-Agent":o,Origin:"cli://needle-cloud"}}),Lm.on("open",()=>{qm=Cm,wp("Needle Cloud connection: established"),Ym(),Gm(),Vm(),Fm=setInterval(()=>{Lm&&Lm.readyState===Be.OPEN&&(Lm.ping(),Dm=setTimeout(()=>{wp("Needle Cloud connection: pong timeout, terminating"),Lm&&Lm.terminate()},Pm))},Nm)}),Lm.on("pong",()=>{Dm&&(clearTimeout(Dm),Dm=null)}),Lm.on("message",e=>{try{const n=JSON.parse(e.toString());var t;"execute_tool"===n.type&&n.requestId&&n.toolName&&async function(e,t,n,o,i,a){wp(function(e,t,n){const o=Object.entries(t).slice(0,12).map(([e,t])=>`${e.slice(0,40)}:${"string"==typeof t?t.length+" chars":typeof t}`);return`Cloud tool request: ${e.slice(0,64)}(${o.join(", ")}) [${n.slice(0,64)}]`}(t,n,e));const r=Date.now();try{var s,c;"local_project_action"===t&&Ym();const l=await vd(t,n,{chatId:o,editGrant:i,commandGrant:a});"local_project_select"!==t&&"local_project_start"!==t&&"local_project_status"!==t||Ym(),wp(`Cloud tool result: ${t} → ${null!=(s=null==l||null==(c=l.content)?void 0:c.reduce((e,t)=>{var n;return e+((null==(n=t.text)?void 0:n.length)||0)},0))?s:0} chars in ${Date.now()-r}ms [${e}]`),Lm&&Lm.readyState===Be.OPEN&&Lm.send(JSON.stringify({type:"tool_result",requestId:e,result:l}))}catch(n){const o=n instanceof Error?n.message:String(n);wp(`Cloud tool error: ${t} → ${o} in ${Date.now()-r}ms [${e}]`),Lm&&Lm.readyState===Be.OPEN&&Lm.send(JSON.stringify({type:"tool_result",requestId:e,error:o}))}}(n.requestId,n.toolName,null!=(t=n.args)?t:{},n.chatId,n.editGrant,n.commandGrant)}catch{}}),Lm.on("close",(e,t)=>{const n=(null==t?void 0:t.toString())||"";wp(`Needle Cloud connection: closed (code=${e}${n?" "+n:""})`),Vm(),Lm=null,Bm||Km()}),Lm.on("error",e=>{wp(`Needle Cloud connection: error - ${e.message||"connection refused"} (is https://cloud.needle.tools/api reachable?)`)})}function Vm(){Fm&&(clearInterval(Fm),Fm=null),Dm&&(clearTimeout(Dm),Dm=null)}function Km(e=!1){Bm||zm||(e||wp(`Needle Cloud connection: reconnecting in ${qm/1e3}s`),zm=setTimeout(()=>{zm=null,Jm()},qm),qm=Math.min(2*qm,Rm))}function Ym(){Lm&&Lm.readyState===Be.OPEN&&Lm.send(JSON.stringify(function(){var e,t,n;const o=nd();return{type:"presence",editor:null!=(e=null==o?void 0:o.editor)?e:"unknown",project:null!=(t=null==o?void 0:o.project_location)?t:null,scene:null!=(n=null==o?void 0:o.scene_location)?n:null,web_project:null!=o&&o.web_location?ae(o.web_location):null,cli_version:cd()}}()))}const Zm=e=>{const t=qe();return t.use("/:action",async(t,n,o)=>{const{action:i}=t.params,a=Fu({navigate:e=>{n.redirect(e)}});switch(i){case"sign-in":e.invalid_login=!1,e.invalid_login_type=null,e.error=void 0,wp("Sign in..."),await a.clearAllTokens(),Ou();try{await a.signIn(`${Jp}/auth-callback`)}catch(e){const t=null==e?void 0:e.cause,o=`Sign-in failed: ${null!=t&&t.code?`${t.code}${t.address?` (${t.address}:${t.port})`:""}`:(null==e?void 0:e.message)||"unknown error"}`;return wp(o),console.error(o),n.status(502).send(o)}break;case"sign-out":{var r,s;const t=await Lu(),n=(null==t||null==(r=t.userInfo)?void 0:r.sub)||(null==t||null==(s=t.claims)?void 0:s.sub),o=null==t?void 0:t.accessToken;wp(`Sign out... (${n})`),n&&o&&await async function(e){return!e.accessToken||import("node-machine-id").then(async t=>{const n=await Ku();return Hu=n,await fetch("https://cloud.needle.tools/api"+ft.account.post_machine,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify({action:"logout",machine_id:n,machine_name:Yu()})}).catch(e=>{wp(`Failed to validate logout: ${e.message} - Make sure https://cloud.needle.tools/api is reachable`),console.error(`Failed to validate logout: ${e.message} - Make sure https://cloud.needle.tools/api is reachable`)}),!0})}({userId:n,accessToken:o}).catch(e=>{console.error(e),wp(`Failed to validate logout: ${e}`)}),e.invalid_login=!1,e.invalid_login_type=null,e.error=void 0,console.log("User signed out"+(n?`: ${n}`:"")),await a.signOut(gu()),Ou();break}case"auth-callback":if(t.url){const o=await a.handleSignInCallback(`${Jp}${t.originalUrl}`).catch(e=>({error:e}));if(Ou(),o&&"error"in o){wp(`Error during sign in: ${o.error}`);const e=o.error instanceof Error?o.error.message:String(o.error);n.redirect(Jp+"?cancelled&message="+encodeURIComponent(e))}else{var c,l,p,u;const t=await Lu();if(null!=t&&t.isAuthenticated){var d,m;e.invalid_login=!1,e.user_email=(null==(d=t.claims)?void 0:d.email)||(null==(m=t.userInfo)?void 0:m.email)||null,e.logged_in_machine_names=[...Gu(t)];const o=await Zu(t,{signout:!0});if(!o)return e.invalid_login=!0,e.invalid_login_type="too-many-logins",n.redirect(gu("too-many-logins"));if("object"==typeof o&&"error"in o)return e.invalid_login=!0,e.invalid_login_type="error",e.error=o.error,n.redirect(gu("error"));Ou()}console.log(`User logged in: ${(null==t||null==(c=t.userInfo)?void 0:c.sub)||(null==t||null==(l=t.claims)?void 0:l.sub)}`),wp(`User logged in: ${(null==t||null==(p=t.userInfo)?void 0:p.sub)||(null==t||null==(u=t.claims)?void 0:u.sub)}`),Wm(),n.redirect(Jp)}}break;default:o()}}),t};function Xm(e,t,n){return!!n||e===np||"string"==typeof t&&t===e}const Qm="2025-06-18";function ef(e){return{jsonrpc:"2.0",id:e,result:{protocolVersion:Qm,capabilities:{tools:{listChanged:!0}},serverInfo:tf}}}const tf={name:"Needle Cloud MCP",version:"1.0.0"};function nf(e){if(null!==e&&"object"==typeof e&&"name"in e&&"version"in e&&"string"==typeof e.name&&"string"==typeof e.version&&e.name.trim()&&e.version.trim())return{name:e.name,version:e.version}}function of(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let af=!1;const rf=qe(),sf=new Map,cf=new Map;let lf=0;function pf(){const e=[];for(const[t,{connectedAt:n,userAgent:o}]of cf)e.push({id:t,connectedAt:n,userAgent:o});return e}function uf(e,t,n,o){if((t.headers.accept||"").includes("text/event-stream")){var i,a;n.setHeader("Content-Type","text/event-stream"),n.setHeader("Cache-Control","no-cache"),n.setHeader("Connection","keep-alive"),n.setHeader("Access-Control-Allow-Origin","*"),n.setHeader("Access-Control-Expose-Headers","Mcp-Session-Id"),n.flushHeaders(),n.write(": connected\n\n");const r=t.headers["mcp-session-id"],s=null!=(i=null!=(a=null!=o?o:"string"==typeof r?sf.get(r):void 0)?a:t.headers["user-agent"])?i:"",c=()=>{clearInterval(l),cf.delete(e)&&(console.log(`[MCP] SSE client disconnected (ID: ${e}): ${s}`),wp(`MCP SSE client disconnected (ID: ${e}): ${s}`))},l=setInterval(()=>{try{n.write(": keepalive\n\n")}catch(t){console.error(`[MCP] SSE heartbeat failed (${e}):`,t),c(),n.destroy()}},15e3);return l.unref(),n.once("close",c),n.once("error",t=>{console.error(`[MCP] SSE stream failed (${e}):`,t),c()}),cf.set(e,{id:e,client:n,connectedAt:Date.now(),userAgent:s,dispose:c}),console.log(`[MCP] SSE client connected (ID: ${e}) ${s}. Total clients: ${cf.size}`),wp(`MCP SSE client connected (ID: ${e}) ${s}. Total clients: ${cf.size}`),!0}return!1}function df(e){if(!Array.isArray(e))return console.error("Invalid input: paths should be an array of strings."),null;for(const t of e)if(!1!==c(t))try{const e=mf(t);if(e)return e}catch(e){}}function mf(e){const t=_(e,".git");if(c(t)){const e=function(e){const t=g(e);if(t.isDirectory())return _(e,"config");if(t.isFile()){const t=p(e,"utf-8").trim().match(/^gitdir:\s*(.+)$/);if(t){let n=t[1].trim();k(n)||(n=w(E(e),n));const o=_(n,"config");if(c(o))return o;const i=_(n,"commondir");if(c(i)){let e=p(i,"utf-8").trim();return k(e)||(e=w(n,e)),_(e,"config")}}}return null}(t);if(e&&c(e)){const t=function(e){const t=p(e,"utf-8"),n=/\[remote\s+"(?<name>.+?)"\].+?url\s*=\s*(?<url>.+?)$/gms,o=[];let i;for(;null!==(i=n.exec(t));)if(i.groups){const e=i.groups.name,t=i.groups.url.trim();t.length&&o.push({name:e,url:t})}const a=o.find(e=>"origin"===e.name)||o.find(e=>"upstream"===e.name)||o[0];return a?a.url:null}(e);if(t)return t}}const n=_(e,".plastic");if(c(n)){const e=_(n,"replicas.db");if(c(e)){const t=p(e,"utf-8").split("\n");for(const e of t){const t=e.split("=");if(2===t.length&&"repo"===t[0].trim()){const e=t[1].trim();if(e.length)return e}}}}const o=_(e,"..");return o===e?null:mf(o)}function ff(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}async function hf(e=pe(ne(),".needle")){let t,n;try{t=await K(pe(e,"local-server-token"),"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return;throw new Error("Cannot read local Needle server credentials. Check the credential file permissions.")}try{n=JSON.parse(t)}catch{throw new Error("Invalid local Needle server credentials. Restart the local server to repair them.")}if(null===n||"object"!=typeof n||!("token"in n)||"string"!=typeof n.token||!/^[\x21-\x7e]+$/.test(n.token))throw new Error("Invalid local Needle server credentials. Restart the local server to repair them.");return n.token}async function gf(){const e=await hf();try{const t=await fetch(`${Jp}/mcp`,{method:"POST",headers:{...e?{Authorization:`Bearer ${e}`}:{},"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"needle-startup-probe",method:"ping"}),signal:AbortSignal.timeout(1e3),redirect:"error"});if(!t.ok)return!1;const n=await t.json();return null!==n&&"object"==typeof n&&"jsonrpc"in n&&"2.0"===n.jsonrpc&&"id"in n&&"needle-startup-probe"===n.id&&"result"in n}catch(e){if(e instanceof TypeError||e instanceof Error&&["TimeoutError","AbortError"].includes(e.name))return!1;throw e}}async function vf(e,t=process.argv[1]){await new Promise((n,o)=>{const i=Je(process.execPath,[t,"start","--integration","mcp","--silent"],{detached:!0,windowsHide:!0,stdio:"ignore",env:process.env});i.once("error",t=>{e(`MCP local server launch failed: ${t.message}`),o(t)}),i.once("spawn",()=>{i.unref(),n(void 0)}),i.once("exit",(t,n)=>{0!==t&&e(`MCP local server process exited (${null!=n?n:t}); see the CLI log for details.`)})})}rf.get("/mcp",async(e,t)=>{if(uf(lf++,e,t))return;const n=function(e){const t=[...ud].sort((e,t)=>e.name.localeCompare(t.name)),n=t.map(e=>`\n <div class="tool">\n <span class="tool-name">${of(e.name)}</span>\n <span class="tool-desc">${of(function(e){const t=e.indexOf("\n");return-1===t?e:e.slice(0,t)}(e.description))}</span>\n </div>`).join("\n");return`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <title>Needle MCP Server</title>\n <style>\n * { box-sizing: border-box; }\n body {\n background: #f0f4ef;\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.6;\n padding: 20px 24px;\n max-width: 960px;\n margin: 0 auto;\n color: #1a1a1a;\n }\n header {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 8px;\n }\n h2 {\n margin-top: 1.2em;\n margin-bottom: 0.4em;\n }\n a { color: inherit; }\n img.logo {\n height: 2em;\n width: auto;\n }\n .badge {\n font-size: 0.75em;\n background: #d0d4cf;\n padding: 2px 8px;\n border-radius: 10px;\n vertical-align: middle;\n font-weight: normal;\n }\n .tools-info {\n color: #555;\n font-size: 0.9rem;\n margin-top: 0;\n margin-bottom: 10px;\n }\n\n /* Tool items */\n .tool {\n background: #fff;\n border: 1px solid #d8dcd7;\n border-radius: 6px;\n margin-bottom: 6px;\n padding: 10px 14px;\n display: flex;\n align-items: baseline;\n gap: 10px;\n }\n .tool-name {\n font-weight: 600;\n white-space: nowrap;\n }\n .tool-desc {\n color: #555;\n font-size: 0.9rem;\n }\n</style>\n</head>\n<body>\n <header>\n <img class="logo" src="https://cdn.needle.tools/static/branding/logo_needle.png" alt="Needle Logo" />\n <strong>Needle MCP Server</strong>\n </header>\n\n <p>The Needle MCP server is alive and running.</p>\n\n <h2>Usage</h2>\n <p><a href="https://fwd.needle.tools/mcp">Open Documentation</a></p>\n\n <h2>Available Tools <span class="badge">${t.length}</span></h2>\n <p class="tools-info">These tools are available to AI agents connected via the Model Context Protocol (MCP).</p>\n ${n}\n</body>\n</html>`}();t.status(200).header("Content-Type","text/html; charset=utf-8").send(n)}),rf.post("/mcp",async(e,t)=>{const n=e.headers.accept||"",o=e.headers["user-agent"]||"",{method:i,id:a}=e.body;console.log(`[MCP] Received request from ${o} (${i}) (ID: ${a})`),t.setHeader("Content-Type","application/json"),t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization, Mcp-Session-Id"),t.setHeader("Access-Control-Expose-Headers","Mcp-Session-Id");try{if("initialize"===i&&n.includes("text/event-stream")){var r;const n=lf++,o=nf(null==(r=e.body.params)?void 0:r.clientInfo);if(uf(n,e,t,o?`${o.name}/${o.version}`:void 0)){af=!0;const e=ef(null!=a?a:0);return void t.write(`data: ${JSON.stringify(e)}\n\n`)}}const l=await async function(e,t){const{method:n,params:o,id:i}=e;if("initialize"===n)return ef(null!=i?i:0);if("ping"===n)return{jsonrpc:"2.0",id:i,result:{}};if("notifications/initialized"===n||"notifications/cancelled"===n)return null;if("tools/list"===n){try{jm()}catch{}return{jsonrpc:"2.0",id:i,result:{tools:ud}}}if("tools/call"===n){const e=null==o?void 0:o.name;try{jm()}catch{}try{return{jsonrpc:"2.0",id:i,result:await vd(e,(null==o?void 0:o.arguments)||{})}}catch(e){return{jsonrpc:"2.0",id:i,error:{code:-32603,message:`Tool execution failed: ${e.message}`}}}}return{jsonrpc:"2.0",id:null!=i?i:null,error:{code:-32601,message:`Method '${n}' not found`}}}(e.body);if("initialize"===i){var s;af=!0;const n=_e(),i=nf(null==(s=e.body.params)?void 0:s.clientInfo);sf.set(n,i?`${i.name}/${i.version}`:void 0),t.setHeader("Mcp-Session-Id",n),console.log(`[MCP] New session created: ${n} for ${o}`),wp(`MCP New session: ${n} for ${o}`)}if(null===l)return t.status(204).end();if(wp(`MCP Request: ${i}`),"tools/list"===i){var c;const e=(null==(c=l.result)||null==(c=c.tools)?void 0:c.map(e=>e.name))||[];console.log(`[MCP] Sending tools/list: ${e.length} tools [${e.join(", ")}]`)}else{const e=JSON.stringify(l);console.log(`[MCP] Sending response for ${i}:`,e.length>500?e.substring(0,500)+" [...]":e)}t.json(l)}catch(e){console.error("[MCP] Error processing request:",e);const n={jsonrpc:"2.0",error:{code:-32603,message:"Internal server error",data:"development"===process.env.NODE_ENV?e.stack:void 0},id:a||null};t.json(n)}}),rf.options("/mcp",(e,t)=>{t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS, DELETE"),t.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization, Mcp-Session-Id"),t.setHeader("Access-Control-Expose-Headers","Mcp-Session-Id"),t.status(204).end()});let bf=!1;function xf(e,t={}){bf&&process.stdout.write(JSON.stringify({jsonrpc:"2.0",method:e,params:t})+"\n")}var yf={__proto__:null,sendStdioNotification:xf,startStdio:function(){bf=!0,console.log=console.info=console.debug=console.error.bind(console);const e=e=>{console.error(e),wp(e)},t=function({endpoint:e,ensureServer:t,notify:n,log:o,getToken:i,retryMs:a=250,streamTimeoutMs:r=45e3}){const s=new AbortController;let c,l,p,u,d=!1,m=!1,f={name:"Needle stdio bridge",version:"1.0.0"};const h=async()=>i?{Authorization:`Bearer ${await i()}`}:{},g=()=>`${encodeURIComponent(f.name)}/${encodeURIComponent(f.version)}`;function v(e){d!==e&&(d=e,m&&n("notifications/tools/list_changed"))}async function b(t){s.signal.throwIfAborted();const n=new AbortController,o=()=>n.abort();s.signal.addEventListener("abort",o,{once:!0});const i=setTimeout(o,"tools/call"===t.method?35e3:5e3);try{var a,r;const o=await h(),i=await fetch(e,{method:"POST",headers:{...o,"User-Agent":g(),"Content-Type":"application/json",Accept:"application/json","MCP-Protocol-Version":Qm,...u?{"Mcp-Session-Id":u}:{}},body:JSON.stringify(t),signal:n.signal,redirect:"error"});if(!i.ok)throw new Error(`MCP server returned HTTP ${i.status}`);if(204===i.status)return null;const s=await i.json();if(!ff(s)||"2.0"!==s.jsonrpc||s.id!==t.id||!ff(s.result)&&!ff(s.error))throw new Error("Invalid response from local MCP server");if(ff(s.error)){var c;if("number"!=typeof s.error.code||"string"!=typeof s.error.message)throw new Error("Invalid MCP error response");return{jsonrpc:"2.0",id:null!=(c=t.id)?c:null,error:{code:s.error.code,message:s.error.message}}}return"initialize"===t.method&&(u=null!=(a=i.headers.get("Mcp-Session-Id"))?a:void 0),{jsonrpc:"2.0",id:null!=(r=t.id)?r:null,result:s.result}}finally{clearTimeout(i),s.signal.removeEventListener("abort",o)}}return{start:()=>(l||(l=new Promise(e=>{p=e}),c=async function(){let i=a;for(;!s.signal.aborted;){let d;const x=new AbortController,y=()=>x.abort();let w;s.signal.addEventListener("abort",y,{once:!0});const _=(e,t=!0)=>{clearTimeout(w),w=setTimeout(()=>{t?j():x.abort(new Error("MCP notification stream connection timed out"))},e)},j=async()=>{try{var e,t;const n=await b({jsonrpc:"2.0",id:"needle-bridge-liveness",method:"ping"});if(null==n||!n.result||n.error)throw new Error(null!=(e=null==n||null==(t=n.error)?void 0:t.message)?e:"Invalid MCP ping response");s.signal.aborted||x.signal.aborted||_(r)}catch(e){s.signal.aborted||x.signal.aborted||x.abort(e)}};try{var c;await t(s.signal);const o=await b({jsonrpc:"2.0",id:"needle-bridge-initialize",method:"initialize",params:{protocolVersion:Qm,capabilities:{},clientInfo:f}});if(null!=o&&o.error)throw new Error(o.error.message);await b({jsonrpc:"2.0",method:"notifications/initialized"}),_(5e3,!1);const y=await h(),w=await fetch(e,{headers:{...y,"User-Agent":g(),Accept:"text/event-stream","MCP-Protocol-Version":Qm,...u?{"Mcp-Session-Id":u}:{}},signal:x.signal,redirect:"error"});var l;if(!w.ok||null==(c=w.headers.get("content-type"))||!c.includes("text/event-stream")||!w.body)throw await(null==(l=w.body)?void 0:l.cancel()),new Error(`MCP notification stream unavailable (HTTP ${w.status})`);_(r),d=w.body.getReader(),v(!0),null==p||p(),i=a;const j=new TextDecoder;let k="";for(;!s.signal.aborted;){const{value:e,done:t}=await d.read();if(t)throw new Error("MCP notification stream closed");let o;for(_(r),k+=j.decode(e,{stream:!0});o=/\r?\n\r?\n/.exec(k);){const e=k.slice(0,o.index);k=k.slice(o.index+o[0].length);const t=e.split(/\r?\n/).filter(e=>e.startsWith("data:")).map(e=>e.slice(5).replace(/^ /,"")).join("\n");if(!t)continue;const i=JSON.parse(t);ff(i)&&"2.0"===i.jsonrpc&&"notifications/tools/list_changed"===i.method&&m&&n("notifications/tools/list_changed")}if(k.length>1048576)throw new Error("MCP notification exceeds size limit")}}catch(e){s.signal.aborted||(o(`MCP bridge disconnected: ${e instanceof Error?e.message:String(e)}; retrying.`),v(!1))}finally{if(clearTimeout(w),s.signal.removeEventListener("abort",y),d){if(!x.signal.aborted)try{await d.cancel()}catch(e){s.signal.aborted||o(`MCP stream cleanup failed: ${String(e)}`)}d.releaseLock()}u=void 0,null==p||p()}if(!s.signal.aborted){try{await Xe(i,void 0,{signal:s.signal})}catch(e){if(!s.signal.aborted)throw e}i=Math.min(2*i,1e4)}}}()),l),async stop(){s.abort(),await c},async handle(e){var t,i;if("initialize"===e.method)return f=null!=(t=nf(null==(i=e.params)?void 0:i.clientInfo))?t:f,null;if("notifications/initialized"===e.method)return m=!0,d&&n("notifications/tools/list_changed"),null;if(void 0===e.id)return null;if(!d)return"tools/list"===e.method?{jsonrpc:"2.0",id:e.id,result:{tools:[]}}:{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:"The local Needle server is unavailable. Reconnecting; try again shortly."}};try{return await b(e)}catch(t){const n=t instanceof Error?t.message:String(t);return o(`MCP bridge ${e.method} failed: ${n}`),{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:`Local Needle server request failed: ${n}`}}}}}}({endpoint:`${Jp}/mcp`,ensureServer:t=>async function(e={}){const{signal:t,lockPath:n=pe(ne(),".needle","mcp-server-start.lock"),probe:o=gf,log:i=(e=>console.error(e)),launch:a=(()=>vf(i)),timeoutMs:r=2e4,pollMs:s=100}=e;if(null==t||t.throwIfAborted(),await o())return;await Z(se(n),{recursive:!0});const c=Date.now()+r;let l;try{for(;Date.now()<c;){if(null==t||t.throwIfAborted(),await o())return;if(!l){try{l=await X(n,"wx",384)}catch(e){if(!(e instanceof Error&&"code"in e&&"EEXIST"===e.code))throw e;try{const e=await Q(n);Date.now()-e.mtimeMs>12e4&&(i("Removing an expired MCP server startup lock."),await ee(n))}catch(e){if(!(e instanceof Error&&"code"in e&&"ENOENT"===e.code))throw e}}if(l){if(await o())return;i("Starting the shared Needle local server."),await a()}}await Xe(s,void 0,{signal:t})}throw new Error("The local Needle server did not become ready in time. See the CLI log for startup errors.")}finally{l&&(await l.close(),await ee(n))}}({signal:t,log:e}),notify:xf,log:e,getToken:()=>async function(e){const t=await hf(void 0);if(void 0===t)throw new Error("Local Needle server credentials are missing. Restart the local server to create them.");return t}()}),n=ze({input:process.stdin,terminal:!1}),o=e=>{bf&&process.stdout.write(JSON.stringify(e)+"\n")};n.on("line",i=>{(async function(n){if(!n.trim())return;let i;try{i=JSON.parse(n)}catch{return void o({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}})}if(!ff(a=i)||"2.0"!==a.jsonrpc||"string"!=typeof a.method||null!=a.id&&"string"!=typeof a.id&&"number"!=typeof a.id||void 0!==a.params&&!ff(a.params))return void o({jsonrpc:"2.0",id:null,error:{code:-32600,message:"Invalid request"}});var a,r;if("initialize"===i.method)return o(ef(null!=(r=i.id)?r:0)),await t.handle(i),void t.start().catch(t=>e(`MCP bridge startup failed: ${String(t)}`));if("ping"===i.method)return void(void 0!==i.id&&o({jsonrpc:"2.0",id:i.id,result:{}}));const s=await t.handle(i);s&&o(s)})(i).catch(t=>{e(`MCP stdio request failed: ${String(t)}`),process.exitCode=1,n.close()})}),n.once("close",()=>{bf=!1,t.stop().then(()=>{var e;return process.exit(null!=(e=process.exitCode)?e:0)},t=>{e(`MCP bridge shutdown failed: ${String(t)}`),process.exit(1)})})}};let wf=null;function _f(){wf&&clearTimeout(wf),wf=setTimeout(()=>{!function(e,t={}){if(0===cf.size)return;const n=`data: ${JSON.stringify({jsonrpc:"2.0",method:"notifications/tools/list_changed",params:t})}\n\n`;for(const[e,{client:t,dispose:o}]of cf)try{t.write(n)}catch(n){console.error(`[MCP] Error sending notification to client (${e}):`,n),o(),t.destroy()}}(),xf("notifications/tools/list_changed"),Gm(),wf=null},10)}function jf(e){if("string"!=typeof e)return!1;const t=/^(localhost|127\.0\.0\.1|\[::1\])(?::([0-9]{1,5}))?$/i.exec(e);return!!t&&(void 0===t[2]||Number(t[2])>0&&Number(t[2])<=65535)}const kf=new Set(["https://cloud.needle.tools","https://needle.tools","https://engine.needle.tools","https://docs.needle.tools","chrome-extension://kjcepmifiddcepiocokclhibpkgcdomk","chrome-extension://jonplpbnhmanoekkgcepnedhghflblmo"]),Sf=new Set(["localhost","127.0.0.1","[::1]","::1"]);function Ef(e){if("string"!=typeof e||0===e.length)return!1;if(kf.has(e))return!0;let t;try{t=new URL(e)}catch{return!1}if("/"!==t.pathname&&""!==t.pathname)return!1;if(""!==t.search||""!==t.hash)return!1;if("http:"!==t.protocol&&"https:"!==t.protocol)return!1;const n=t.hostname.toLowerCase();return!!Sf.has(n)||"::1"===n}const $f="[MCP]",Tf=new Array;function If(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Of(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0}async function Af(){try{return JSON.parse(await K(pe(ne(),".needle","local-server-token"),"utf8"))}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return null;if(e instanceof SyntaxError)throw new Error("The local server record is invalid.");throw e}}function Cf(e){try{return process.kill(e,0),!0}catch(e){if(e instanceof Error&&"code"in e){if("ESRCH"===e.code)return!1;if("EPERM"===e.code)return!0}throw e}}function Rf(e,t){return{api_endpoint:e,version:t,pid:process.pid}}var Nf={__proto__:null,getLocalServerInfo:Rf,getLocalServerStatus:async function(e={}){var t,n,o;const i=null!=(t=e.fetch)?t:globalThis.fetch;let a,r;try{a=await i(`${Jp}/api/info`,{signal:AbortSignal.timeout(3e3)})}catch(e){if(e instanceof Error&&If(e.cause)&&"ECONNREFUSED"===e.cause.code)return{running:!1,url:Jp};throw e}if(!a.ok)throw new Error(`Local server status request failed (HTTP ${a.status}).`);try{r=await a.json()}catch(e){if(e instanceof SyntaxError)throw new Error("Invalid local server info response.");throw e}if(!If(r)||"string"!=typeof r.version||!r.version.trim()||"string"!=typeof r.api_endpoint||!r.api_endpoint.trim())throw new Error("Invalid local server info response.");if(void 0!==r.pid&&!Of(r.pid))throw new Error("Invalid local server PID.");if(Of(r.pid))return{running:!0,url:Jp,version:r.version,pid:r.pid,pidSource:"server"};const s=await(null!=(n=e.readServerRecord)?n:Af)();return If(s)&&s.port===Gp&&Of(s.pid)&&(null!=(o=e.isProcessAlive)?o:Cf)(s.pid)?{running:!0,url:Jp,version:r.version,pid:s.pid,pidSource:"record"}:{running:!0,url:Jp,version:r.version,pid:null,pidSource:"unavailable"}},formatLocalServerStatus:function(e){return e.running?`Needle local server: running\nURL: ${e.url}\nVersion: ${e.version}\nPID: ${null===e.pid?"unavailable":`${e.pid}${"record"===e.pidSource?" (recorded)":""}`}`:`Needle local server: not running\nURL: ${e.url}`}};const Pf="2026-10-14T14:07:33.738Z";var Uf={__proto__:null,BUILD_TIME:Pf};const{json:Lf}=Ze;function zf(e){const t=null==e?void 0:e.cause;return null!=t&&t.code?`${t.code}${t.address?` (${t.address}:${t.port})`:""}`:null!=t&&t.message?t.message:null!=e&&e.code?e.code:null!=e&&e.message&&"fetch failed"!==e.message?e.message:"connection refused or network unreachable"}async function Ff(t={restart:!1}){const n=!0===t.restart,o=await e(Jp).catch(e=>({ok:!1})),a="/sign-in",r="/api/authenticated",s="/api/projects",l="/api/content",p={baseUrl:Jp,port:Gp,isHost:!1,auth_endpoints:{"sign-in":`${Jp}${a}`,"sign-out":`${Jp}/sign-out`,"is-authenticated":`${Jp}${r}`}};let u=o.ok;if(u){var d;const g=await e(`${Jp}/api/info`).catch(()=>null);if(null!=g&&g.ok){const b=await g.json().catch(()=>null);if(null!=b&&b.api_endpoint&&"https://cloud.needle.tools/api"!==b.api_endpoint){if(!Xm(b.api_endpoint,"https://cloud.needle.tools/api",n))return wp(`Keeping CLI server for ${b.api_endpoint}; https://cloud.needle.tools/api did not request an explicit restart.`),p;wp(`Running server uses different API endpoint (${b.api_endpoint} vs https://cloud.needle.tools/api), restarting...`),t||(t={}),t.restart=!0}}if(!0===(null==(d=t)?void 0:d.restart)){wp("Restarting auth server...");const x=`${Jp}/restart`;t.ora&&(t.ora.text="Sending restart request to server");const y=new AbortController;setTimeout(()=>y.abort(),1e4);let w={};try{const k=_(Te(),".needle","local-server-token"),S=JSON.parse((await import("fs")).readFileSync(k,"utf-8"));S.token&&(w={Authorization:`Bearer ${S.token}`})}catch{}const j=await e(x,{method:"post",signal:y.signal,headers:{...w,"x-needle-api-endpoint":"https://cloud.needle.tools/api",...n?{"x-needle-explicit-restart":"true"}:{}}}).catch(e=>({ok:!1,status:400,error:e}));if(j.ok)return await ul(300),Ff({restart:!1});409!==j.status&&console.error("Failed to restart server",j.status),wp(`Failed to restart server: ${j.status}`)}}if(!u){process.title="Needle CLI server";const E=await import("express").catch(e=>{throw console.error("Error starting the auth server (express not found)",e),wp("Error starting the auth server"),new Error("Failed to load express module")});if(!E)throw wp("Error loading auth server module"),new Error("Failed to load express module");wp(`Starting Needle CLI server ${cd()} (built ${Pf})... (Using api at https://cloud.needle.tools/api)`,{emptyLineBefore:!0}),p.isHost=!0;let $=null;const O={invalid_login:!1,invalid_login_type:null,user_email:null,logged_in_machine_names:[]};let A=E.default();const C=_(Te(),".needle"),R=function(e,t){var n;const o=pe(e,"local-server-token"),a=null!=(n=function(e){if(!T(e))return null;try{const t=M(e,"utf-8");if(0===t.length)return null;const n=JSON.parse(t);if(n&&"string"==typeof n.token&&n.token.length>0)return n.token}catch{}return null}(o))?n:i();I(e,{recursive:!0});const r=JSON.stringify({token:a,pid:process.pid,port:t},null,2);if(H(o,r,{encoding:"utf-8",mode:384}),"win32"===process.platform)try{const e=process.env.USERNAME||process.env.USER||"";e&&We("icacls",[o,"/inheritance:r","/grant:r",`${e}:(F)`],{stdio:"ignore",timeout:5e3})}catch{}return a}(C,Gp);wp(`Local token written to ${_(C,"local-server-token")}`);const N=function(e,t=5e3){const n=new Map,o=Math.max(1,Math.round(t/1e3));return(i,a)=>{const r=Date.now(),s=n.get(i);if(!s||r-s.lastLog>t){var c;const t=null!=(c=null==s?void 0:s.suppressed)?c:0;e(t>0?`${a} [+${t} similar in last ${o}s]`:a),n.set(i,{lastLog:r,suppressed:0})}else s.suppressed++}}(e=>wp(`Denied: ${e}`),5e3);A.use((h={onDenied:N},(e,t,n)=>{var o;return jf(e.headers.host)?n():(null==h||null==h.onDenied||h.onDenied(`host|${null!=(o=e.headers.host)?o:"missing"}`,"HTTP Host is not a loopback authority"),t.status(403).send("Forbidden: host not allowed"))})),A.use(function(e){const t=null==e?void 0:e.onDenied;return(e,n,o)=>{var i,a;if("OPTIONS"===e.method)return o();const r=null==(i=e.headers)?void 0:i.origin,s=null==(a=e.headers)?void 0:a["sec-fetch-site"];if(void 0!==r){if(Ef(r))return o();if(t)try{var c,l,p,u;const n=null!=(c=null==(l=e.headers)?void 0:l["user-agent"])?c:"unknown",o=null!=(p=null!=(u=e.path)?u:e.url)?p:"?";t(`origin|${r}|${o}`,`denied origin=${r} path=${o} ua="${n}"`)}catch{}return n.status(403).send("Forbidden: origin not allowed")}var d,m;if(s&&"none"!==s&&"same-origin"!==s&&("GET"!==e.method||"navigate"!==(null==(d=e.headers)?void 0:d["sec-fetch-mode"])||"document"!==(null==(m=e.headers)?void 0:m["sec-fetch-dest"]))){if(t)try{var f,h;const n=null!=(f=null!=(h=e.path)?h:e.url)?f:"?";t(`fetch-site|${s}|${n}`,`denied fetch-site=${s} path=${n}`)}catch{}return n.status(403).send("Forbidden: origin not allowed")}return o()}}({onDenied:N})),A.use(Lf({limit:"10mb"}));const P=new Set(["/","/sign-in","/sign-out","/auth-callback","/api/info","/api/authenticated","/api/public_key","/mcp","/register"]),U="needle_local";A.use((e,t,n)=>{var o,i,a;if("OPTIONS"===e.method)return n();if(P.has(e.path))return n();if(e.path.startsWith("/mcp/"))return n();if(e.path.startsWith("/.well-known/"))return n();const r=null==(o=e.headers)?void 0:o.authorization;if(r){const e=r.split(" ");if(2===e.length&&"Bearer"===e[0]&&e[1]===R)return n()}if((null==(i=e.query)?void 0:i.token)===R)return n();const s=((null==(a=e.headers)?void 0:a.cookie)||"").split(";").map(e=>e.trim()).find(e=>e.startsWith(U+"="));if(s&&s.split("=")[1]===R)return n();try{var c,l;const t=null!=(c=null==(l=e.headers)?void 0:l["user-agent"])?c:"unknown";N(`token|${t}|${e.path}`,`path=${e.path} ua="${t}" — no valid token or cookie`)}catch{}return t.status(401).send("Unauthorized: token required")}),A.use(Zm(O)),t.ora?(t.ora.start("Starting MCP server..."),t.ora.succeed(`MCP server available at ${Jp}/mcp`)):console.log(`\nMCP server available at ${Jp}/mcp .`),A.use(rf);const L="\n <title>Needle Cloud</title>\n <link rel=\"icon\" href=\"https://cdn.needle.tools/static/branding/favicon.ico\" type=\"image/x-icon\">\n <style>\n body { \n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;\n font-size: 18px;\n padding: 2rem;\n background: #f0f4ef;\n }\n a {\n color: rgb(120, 76, 223);\n }\n .main_panel {\n display: flex;\n flex-direction: column;\n gap: .5rem;\n justify-content: flex-start;\n align-items: center;\n width: min(80ch, 90vw);\n margin: 0 auto;\n\n height: 100%;\n\n & img.logo {\n height: 3rem;\n margin-bottom: 1rem;\n }\n }\n .secondary {\n color: rgba(0, 0, 0, .5);\n }\n .error-details {\n font-size: 12px;\n color: rgba(0, 0, 0, .5);\n }\n .error-details a {\n color: inherit;\n }\n </style>",z=`<div class="main_panel"><img class="logo" src="https://cdn.needle.tools/static/branding/logo_needle.png" alt="Needle Logo" title="Needle Logo (${cd()})"/>`,F="</div>";let D="";A.get("/",Wu(),async(e,t)=>{var n,o;if(null!=(n=e.user)&&n.isAuthenticated?t.cookie(U,R,{httpOnly:!0,sameSite:"strict",path:"/"}):t.clearCookie(U,{path:"/"}),t.set({"Content-Type":"text/html; charset=utf-8"}),t.write(L),null!=e.query.cancelled)return t.end("Login cancelled. You can close this window now."),void wp("Login cancelled by user");if(null!=e.query["too-many-logins"]&&O.logged_in_machine_names.length){var i;const e=op();let n="<div>";return n+="<strong>You have reached the maximum number of allowed device logins!</strong><br/><br/>",n+=(null==(i=O.logged_in_machine_names)?void 0:i.map(e=>`• ${e}`).join("<br/>"))+"<br/><br/>",n+=`1) Go to <a href="${e}#device-logins" target="_blank">Needle Cloud device logins</a> and logout one of your devices.<br/>\n 2) Then <a href="${a}">sign-in on this machine</a>.<br/><br/>`,n+="</div>",t.status(406),t.end(z+n+F),void wp(`Login failed: Too many logins from different machines: [${O.logged_in_machine_names.join(", ")}]`)}if(null!=e.query.error)return t.status(500),void t.end(`${z}\n <div>\n <strong>An error occurred</strong>: Please make sure <i>https://cloud.needle.tools/api</i> and <i>https://auth.needle.tools</i> are reachable and not blocked by your firewall or network. After that please try to <a href="${a}">sign-in</a> again.\n <br/><span class="error-details">If the issue persists, please contact support and include the log file: <a title="Link to local log file. Please copy this url and open it in your file explorer or terminal" href="file://${bp()}" target="_blank">${bp()}</a></span>\n </div>\n ${F}`);if(null!=(o=e.user)&&o.isAuthenticated){var r;if(!await Vu(e.user)){if(O.invalid_login=!0,O.logged_in_machine_names=[...Gu(e.user)],bu(),wp("Cleared stored auth data"),"client"in e.user){const t=e.user;await t.client.clearAccessToken(),await t.client.clearAllTokens(),wp("Cleared all tokens")}return t.end(`${z}<div>You have been logged out from this machine. You can close this window now or try to <a href="${a}">sign in</a> again</div>${F}`)}O.invalid_login=!1,t.end(`${z}\n <div>\n Hi ${Bu(e.user)} — you logged in successfully. You can close this window now.\n </div>\n ${F}`);const n=`Logged in successfully as ${Bu(e.user)} (${null==(r=e.user.userInfo)?void 0:r.sub})`;return void(D!==n&&(D=n,wp(D)))}let s=`<span><a href="${a}">Sign in</a> to your Needle account</span>`;"1"===e.query["signed-out"]&&(s=`<span class="secondary">You have been signed out successfully.</span>${s}`),t.write(z+s+F),t.end()}),A.post("/restart",(e,n)=>{var o;if(!Xm("https://cloud.needle.tools/api",e.headers["x-needle-api-endpoint"],"true"===e.headers["x-needle-explicit-restart"]))return wp("Rejected restart from a CLI targeting another API endpoint"),void n.status(409).end("A Needle CLI connected to a different environment is already running.");t.ora&&(t.ora.text="Received restart event. This instance will close"),null==(o=$)||o.close(e=>{e&&console.error(e)}),setTimeout(()=>{process.exit(0)},100),n.status(200).end("Server is restarting"),wp("Server is restarting\n")}),A.get("/api/logs",async(e,t)=>{const n=bp();c(n)?v(n,"utf-8",(e,o)=>{if(e)return console.error(e),void t.status(500).end("Failed to read log file");t.set({"Content-Type":"text/plain; charset=utf-8"});const i=o.split("\n").filter(e=>e.length>0).reverse().join("\n");let a=`--- Needle CLI v${cd()} (built ${Pf}) Log File (newest first) ---\n${n}\n\n`;a+=i,t.status(200).end(a)}):t.status(404).end("Log file not found")}),A.get("/api/info",(e,t)=>{t.json(Rf("https://cloud.needle.tools/api",cd()))}),A.get(r,Wu(),async(e,t)=>{var n;if(!0===O.invalid_login){const e=Df(O);return t.status(e.status).json(e)}O.invalid_login=!1,t.status(null!=(n=e.user)&&n.isAuthenticated?200:400).send()}),A.get("/api/user",Wu(),async(e,t)=>{var n;const o=e.user;if(null==o||!o.isAuthenticated){if(!0===O.invalid_login){const e=Df(O);return t.status(e.status).json(e)}return t.status(401).json({error:"Not authenticated"})}if(O.invalid_login=!1,!await Vu(o))return bu(),t.status(403).json({error:"You have been logged out from this machine"});if(null==o||!o.claims)return t.status(400).json({error:"User claims not found"});if(null==o||!o.userInfo)return t.status(400).json({error:"User info not found"});const i=null==o||null==(n=o.claims)?void 0:n.organization_roles,a=null==o?void 0:o.userInfo.custom_data,r={authenticated:o.isAuthenticated,id:o.userInfo.sub,name:Bu(o),email:o.claims.email||o.userInfo.email||"",profile_picture:o.userInfo.picture||"",default_org_id:(null==a?void 0:a.default_org)||"none",orgs:[]},s=["manage","owner","member","developer"];o.userInfo.organization_data&&(r.orgs=o.userInfo.organization_data.map(e=>{var t;const n={id:e.id,name:e.name,roles:(null==i?void 0:i.filter(t=>t.startsWith(e.id)).map(e=>e.split(":")[1]))||[],canWrite:!1};return n.canWrite=null==(t=n.roles)?void 0:t.some(e=>s.includes(e)),n}).sort((e,t)=>e.id===r.default_org_id?-1:t.id===r.default_org_id?1:e.name.localeCompare(t.name))),t.json(r)}),A.get("/api/license",Wu(),async(t,n)=>{var o,i,a;const r=null==(o=t.query.token)?void 0:o.toString(),s=null==(i=t.query.org)?void 0:i.toString();let c=null;if(r)c={authToken:r};else{const e=await Lu();if(!e||!e.isAuthenticated)return n.status(401).json({error:"Not authenticated",code:"not_authenticated"});if(!await Vu(e))return bu(),n.status(403).json({error:"Invalid login"});c=await Mu(e,s||null).catch(e=>({status:500,error:e.message}))}if(!c)return n.status(500).json({error:"Failed to fetch licenses (Missing auth)"});if("error"in c)return n.status(c.status).json({error:c.error});const l=ht(c),p=null==(a=t.query.integration)?void 0:a.toLocaleString(),u={...l,"x-needle":"cli","x-needle-integration":null!=p&&p.length?p:"unknown"},d=await e(`https://cloud.needle.tools/api${ft.account.get_licenses}`,{method:"GET",headers:u}).catch(e=>{const t=zf(e);return console.error("Failed to fetch licenses:",t),wp(`Failed to fetch licenses: "${t}" - is https://cloud.needle.tools/api reachable?`),null});if(!d)return n.status(502).json({error:"Failed to fetch licenses: upstream API unreachable"});if(d.ok){const e=await d.json();return void 0===e.can_use_editor&&(e.can_use_editor=!0),n.json(e)}return n.status(d.status).json({error:d.statusText})}),A.get("/api/deployments",Wu(),async(e,t)=>{var n;const o=await Lu();if(!o||!o.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const i=null==(n=e.query.org)?void 0:n.toString(),a=await Mu(o,i).catch(e=>({status:500,error:e.message}));if("error"in a)return t.status(a.status).json({error:a.error});if(i&&!a.org)return t.status(400).json({error:"Organization not found"});const r=await Bp({endpoint:"https://cloud.needle.tools/api",authToken:a.authToken,org:a.org||void 0,limit:20,offset:0,names:void 0}).catch(e=>(console.error("List Deployments error: "+e.message),{status:502,error:"Failed to list deployments: upstream API unreachable"}));if("error"in r)return t.status(r.status).json({error:r.error});for(const e of r.deployments)e.editUrl=`${ip()}/${e.id}`;const s={...r};return t.json(s)}),A.get(l,Wu(),async(e,t)=>{var n,o,i,a,r,s,c,l;const p=await Lu();if(!p||!p.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const u=(null==(n=e.query.org)?void 0:n.toString())||(null==(o=p.userInfo)||null==(o=o.custom_data)?void 0:o.default_org)||void 0,d=await Mu(p,u).catch(e=>({status:500,error:e.message}));if("error"in d)return t.status(d.status).json({error:d.error});const m={content_type:(null==(i=e.query.content_type)?void 0:i.toString())||void 0,content_format:(null==(a=e.query.content_format)?void 0:a.toString())||void 0,search:(null==(r=e.query.search)?void 0:r.toString())||void 0,tags:(null==(s=e.query.tags)?void 0:s.toString())||void 0,types:(null==(c=e.query.types)?void 0:c.toString())||void 0,trash:"true"===e.query.trash||void 0,collection_id:(null==(l=e.query.collection_id)?void 0:l.toString())||void 0,limit:e.query.limit?parseInt(e.query.limit.toString()):void 0,page:e.query.page?parseInt(e.query.page.toString()):void 0,offset:e.query.offset?parseInt(e.query.offset.toString()):void 0},f=await ql({baseUrl:"https://cloud.needle.tools/api",authToken:d.authToken,org:d.org||void 0},m).catch(e=>(console.error("List content error: "+e.message),{status:502,error:"Failed to list content: upstream API unreachable"}));return"error"in f?t.status(f.status).json({error:f.error}):t.json(f)}),A.get(l+"/:identifier",Wu(),async(e,t)=>{var n,o;const i=await Lu();if(!i||!i.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const a=(null==(n=e.query.org)?void 0:n.toString())||(null==(o=i.userInfo)||null==(o=o.custom_data)?void 0:o.default_org)||void 0,r=await Mu(i,a).catch(e=>({status:500,error:e.message}));if("error"in r)return t.status(r.status).json({error:r.error});const s=await Bl({baseUrl:"https://cloud.needle.tools/api",authToken:r.authToken,org:r.org||void 0},e.params.identifier).catch(e=>(console.error("Get content error: "+e.message),{status:502,error:"Failed to get content: upstream API unreachable"}));return"error"in s?t.status(s.status).json({error:s.error}):t.json(s)}),A.get(s,Wu(),async(t,n)=>{const o=await Lu();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i=`https://cloud.needle.tools/api${ft.local_projects.get.user}`,a=await e(i,{method:"GET",headers:{Authorization:`Bearer ${o.accessToken}`}}).catch(e=>(console.error("Failed to fetch projects:",zf(e)),null));if(!a)return n.status(502).json({error:"Failed to fetch projects: upstream API unreachable"});if(!a.ok)return n.status(a.status).json({error:a.statusText});const r=await a.json().catch(e=>console.error(e));return n.json(r)}),A.get(s+"/:id",Wu(),async(t,n)=>{var o;const i=await Lu();if(!i||!i.isAuthenticated)return n.status(401).json({error:"Not authenticated"});let a=null==(o=t.query.org)?void 0:o.toString();const r=await Mu(i,a).catch(e=>({status:500,error:e.message}));if(!r)return n.status(500).json({error:"Failed to fetch projects"});if("error"in r)return n.status(r.status).json({error:r.error});const s=ht(r),c=`https://cloud.needle.tools/api${ft.local_projects.get.by_id}${encodeURIComponent(t.params.id)}`,l=await e(c,{method:"GET",headers:{...s}}).catch(e=>(console.error("Failed to fetch project:",zf(e)),null));if(!l)return n.status(502).json({error:"Failed to fetch project: upstream API unreachable. Please try again later or contact hi@needle.tools"});if(!l.ok)return n.status(l.status).json({error:l.statusText});const p=await l.json().catch(e=>(console.error(e),null));return p?n.json(p):n.status(500).json({error:"Failed to parse data. Please try again later or contact hi@needle.tools"})}),A.post("/api/projects",Wu(),async(t,n)=>{const o=await Lu();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i="string"==typeof t.body?JSON.parse(t.body):t.body,a={machine_id:await Ku(),project_id:i.project_id,project_name:i.project_name,scene_name:i.scene_name,web_project_path:i.web_project_path,editor_name:i.editor_name,editor_version:i.editor_version};if(!a.project_id||!a.project_name)return n.status(400).json({error:"Invalid request"});const r=`https://cloud.needle.tools/api${ft.local_projects.post}`,s=await e(r,{method:"POST",headers:{Authorization:`Bearer ${o.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(a)}).catch(e=>(console.error("Failed to upsert project:",zf(e)),null));return s?s.ok?n.send("OK"):n.status(s.status).json({error:s.statusText}):n.status(502).json({error:"Failed to upsert project: upstream API unreachable"})}),A.get("/api/public_key",Wu(),async(t,n)=>{var o,i;const a=await Lu();if(!a||!a.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const r=null==(o=t.query.org)?void 0:o.toString(),s=await Mu(a,r).catch(e=>({error:e.message,status:500}));if(!s)return n.status(500).json({error:"Failed to fetch public key"});if("error"in s)return n.status(s.status).json({error:s.error});const c={project_id:(null==(i=t.query.project_id)?void 0:i.toString())||void 0,machine_id:await Ku()},l=await e(`https://cloud.needle.tools/api${ft.account.public_key}`,{method:"POST",headers:{...ht(s),"Content-Type":"application/json"},body:JSON.stringify(c)}).catch(e=>(console.error("Failed to fetch public key:",zf(e)),null));if(!l)return n.status(502).json({error:"Failed to fetch public key: upstream API unreachable"});if(l.ok){const e=await l.json().catch(console.error);return null!=e&&e.public_key?n.json(e):n.status(500).json({error:"Failed to fetch public key"})}return n.status(l.status).json({error:l.statusText})}),A.get("/api/local_project_id",async(e,t)=>{const n=e.query.paths;if(!n)return t.status(400).json({error:"Missing paths"});let o=[];"string"==typeof n?o=n.split(",").map(e=>e.trim()).filter(e=>e.length>0):Array.isArray(n)&&(o=n.map(e=>e.toString().trim()).filter(e=>e.length>0));const i=df(o);return i?t.json({project_id:i}):t.status(404).json({error:"Project ID not found"})}),A.post("/api/project/info",Wu(),async(e,t)=>{(function(e){try{!function(e){var t,n,o,i;const a={last_accessed:Date.now(),editor:null!=(t=e.scene_path)&&t.endsWith(".unity")?"unity":null!=(n=e.scene_path)&&n.endsWith(".blend")?"blender":"unknown",editor_version:e.editor_version,editor_installation_path:e.editor_installation_path,log_location:e.editor_log_path,project_location:e.unity_project_path||e.blender_project_path||e.scene_path,scene_location:e.scene_path,web_location:e.web_project_path,needle_engine_integration_location:e.needle_sourcecode_location},r=ad();let s=rd();const c=s.entries.findIndex(e=>e.project_location===a.project_location),l=null==(o=s.entries[0])?void 0:o.project_location;-1!==c?s.entries[c]=a:s.entries.push(a),s.entries.sort((e,t)=>t.last_accessed-e.last_accessed);let p=0;s.entries=s.entries.filter(e=>"cli"===e.source||++p<=30);const u=null==(i=s.entries[0])?void 0:i.project_location;u&&u!==l&&wp(`Active project changed: ${l||"(none)"} → ${u}`);try{Xu=s;const e=JSON.stringify(s);f(r,e,"utf-8")}catch(e){console.error("Failed to save project info:",e)}}(e)}catch(e){wp("Error saving project info: "+e)}})("string"==typeof e.body?JSON.parse(e.body):e.body),t.send("OK")});let q=null;const B=new Promise(e=>q=e);let W=!1;if($=A.listen(Gp,()=>{null==q||q()}),$.on("error",e=>{if("EADDRINUSE"===(null==e?void 0:e.code))return wp(`License server port ${Gp} already in use — a server is already running; not starting a second one.`),W=!0,p.isHost=!1,void(null==q||q());console.error("[needle] License server failed to start:",(null==e?void 0:e.message)||e),wp(`License server failed to start: ${(null==e?void 0:e.message)||e}`),process.exit(1)}),function(e,t){e.on("connection",e=>{const n=e.remoteAddress;if(!function(e){if(!e)return!1;const t=e.includes("%")?e.slice(0,e.indexOf("%")):e;return"127.0.0.1"===t||"::1"===t||"::ffff:127.0.0.1"===t}(n)){try{null==t||t(`Local server: rejected non-loopback connection from ${n||"unknown"}`)}catch{}e.destroy()}})}($,wp),$.on("close",m),process.on("exit",m),process.on("SIGINT",()=>{m(),process.exit(0)}),await B.catch(e=>{console.error(e),wp(`Error starting the auth server (promise failed): ${e.message}`)}),W)return p;function m(){wp("Cleaning up auth server...")}(function(e,t){const n=new Me({server:e,path:"/mcp/ws",verifyClient:({req:e},t)=>{var n;if(!jf(e.headers.host))return wp(`${$f} rejected WS upgrade: host not allowed`),void t(!1,403,"Forbidden: host not allowed");const o=null==(n=e.headers)?void 0:n.origin;if(o&&!Ef(o))return wp(`${$f} rejected WS upgrade: disallowed origin ${o}`),void t(!1,403,"Forbidden: origin not allowed");t(!0)}});wp("MCP websocket server created.");let o=0,i=new Map;n.on("connection",e=>{const t=++o;Tf.push(e),console.log(`${$f} client connected (#${t})`),wp(`${$f} client connected (#${t})`),e.on("close",()=>{const n=Tf.indexOf(e);-1!==n&&Tf.splice(n,1);const o=i.get(t);if(o){for(const e of o)fd(e,_f);i.delete(t)}console.log(`${$f} client disconnected (#${t})`),wp(`${$f} client disconnected (#${t})`)});const n=new Map;e.on("message",o=>{try{const a=o.toString(),r=JSON.parse(a);switch(r.command){default:console.log(`${$f} Unknown command: ${r.command}`),wp(`Unknown MCP websocket command received: ${r.command}`);break;case"get_connected_clients":!function(t,n){const o={clients:[...pf()],command:"mcp_server_response",messageId:"messageId"in t?t.messageId:void 0};e.send(JSON.stringify(o))}(r);break;case"register_tools":{const o=r.tools,a=r.source;if("cli"===a)throw new Error("The CLI tool source is reserved for built-in tools.");a&&function(e,t){const n=md.get(e);if(n&&n.size>0){console.log(`[MCP] Removing ${n.size} tools registered from ${e}`);let o=!1;for(const t of n){const n=ud.findIndex(e=>e.name===t);-1!==n&&(ud.splice(n,1),delete dd[t],gd.set(t,e),o=!0)}md.delete(e),o&&t()}}(a,_f);const s=a||"unknown";console.log(`${$f} ${s} registered ${o.length} tool${1===o.length?"":"s"}`),wp(`${$f} ${s} registered ${o.length} tool${1===o.length?"":"s"}`);const c=i.get(t)||new Set;i.set(t,c);for(const t of o)hd(t,async o=>{console.log(`Tool ${t.name} executed via WebSocket with args:`,o);const i=`${t.name}-${Date.now()}-${Math.random()}`;return await new Promise((a,r)=>{const s=setTimeout(()=>{n.has(i)&&(console.error(`${$f} Tool execution timed out for tool: ${t.name}`),n.delete(i),r(new Error(`Tool execution timed out for tool: ${t.name}`)))},3e4);n.set(i,{resolve:e=>{a(e),clearTimeout(s)},reject:r}),e.send(JSON.stringify({command:"execute_tool",toolName:t.name,args:o,requestId:i}))})},{source:a},_f),c.add(t.name);break}case"tool_result":{const e=r.requestId,t=r.result;if(console.log(`${$f} Received tool result for requestId: ${e}`,t),n.has(e)){const o=n.get(e);null==o||o.resolve(t),n.delete(e)}else console.error(`${$f} No pending tool execution found for requestId: ${e}`);break}}}catch(e){console.error(`${$f} Error processing WebSocket message:`,e)}})})})($),jm({logToolCount:!0}),Wm();const G=tm(C,()=>{Zd()?(wp("Settings changed: remote_ai_tools disabled — closing cloud connection"),Hm("remote_ai_tools setting disabled")):(wp("Settings changed: remote_ai_tools enabled — opening cloud connection"),Wm())});process.on("exit",()=>{G(),Hm("process exit")})}var h;return p}function Df(e){let t="";return t=e.error?e.error:e.logged_in_machine_names.length>0?`You're already authenticated on ${e.logged_in_machine_names.length} other machine(s)${e.user_email?` with ${e.user_email}`:""}. Please logout from other machines first on ${op()}. You're currently logged in on: ${e.logged_in_machine_names.join(", ")}`:"An unknown error occured.",{status:403,error:t}}async function qf(e={headless:!1,silent:!1,clearAuthData:!1}){return!0===e.clearAuthData&&await bu(),Mf("sign-in",{...e})}function Bf(e={}){return Mf("sign-out",{...e})}function Mf(t,n){return new Promise(async(o,i)=>{let a=!1;if("sign-in"==t){const e=await Lu();if(null!=e&&e.isAuthenticated&&e.accessToken)return await Zu(e)?(a=!0,n.ora&&(n.ora.text=`Authorized as ${Bu(e)}`),"gotoAccountPage"in n&&!0===n.gotoAccountPage&&(n.ora&&(n.ora.text="Opening account page in the browser"),ap(op()),await new Promise(e=>setTimeout(e,2e3))),o(e)):o(null);if(!0===n.headless)return o(null)}else if("sign-out"==t&&!0===n.headless){a=!0,bu();const t=await Ff(),n=await e(t.auth_endpoints["sign-out"],{follow:2});return o(n.ok)}const r=await Ff();switch(n.timeout||(n.timeout=6e5),"number"==typeof n.timeout&&n.timeout>0&&setTimeout(()=>{a||(n.ora&&n.ora.fail('Timeout "'+t+'"'),o(null))},n.timeout),t){case"sign-in":const e=r.auth_endpoints["sign-in"];setTimeout(()=>ap(e),300),n.ora&&(n.ora.text=`Please authenticate in the browser: ${e}`),setTimeout(l,2e3);break;case"sign-out":bu(),ap(r.auth_endpoints["sign-out"]),setTimeout(l,2e3)}let s=0;const c=10;function l(){e(r.auth_endpoints["is-authenticated"]).then(async e=>{if(200===e.status||400===e.status||403===e.status)switch(t){case"sign-in":if(200===e.status){const e=await Lu();return e&&!await Zu(e)?o(null):(a=!0,n.ora&&e&&(n.ora.text="User is authenticated"),o(e))}if(403===e.status){n.ora&&n.ora.fail("Authentication failed");const t=await e.text();if(t.startsWith("{")){const e=JSON.parse(t);if("logged_in_machine_names"in e&&Array.isArray(e.logged_in_machine_names)){const t=e.logged_in_machine_names;$().fail(`You're already authenticated on ${t.length} other machine(s). Please logout from other machines first. You're currently logged in on: ${t.join(", ")}`)}}return o(null)}break;case"sign-out":if(400===e.status)return a=!0,bu(),n.ora&&(n.ora.text="User is signed-out"),o(!0)}else if(s++,s>c)return n.ora?n.ora.fail(`Failed to complete auth flow. Please try again. Make sure that port ${r.port} is not blocked`):n.silent||console.error(`Failed to complete auth flow. Please try again. Make sure that port ${r.port} is not blocked`),o(null);setTimeout(l,1e3)}).catch(e=>{s>=10&&console.debug("Error polling auth status: "+e.message)})}})}globalThis.fetch||(globalThis.fetch=e),globalThis.File||(globalThis.File=t),globalThis.crypto||(globalThis.crypto=n.webcrypto),function(e={}){var t,n,o;const i=null!=(t=e.proc)?t:process,a=null!=(n=e.log)?n:yp,r=null!=(o=e.error)?o:e=>console.error(e),s=(e,t)=>{const n=t instanceof Error&&t.message||String(t);try{const o=t instanceof Error&&t.stack?`\n${t.stack}`:"";a(`CLI crashed (${e}): ${n}${o}`)}catch{}try{r(`error: ${n}`)}catch{}try{i.exit(1)}catch{}};i.on("unhandledRejection",e=>s("unhandled rejection",e)),i.on("uncaughtException",e=>s("uncaught exception",e))}();const Wf=process.argv.includes("--silent"),Hf=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8")),Gf="The access token to use. Use the login command or get a token from https://cloud.needle.tools. You can pass the access token with your command or set the environment variable NEEDLE_CLOUD_TOKEN";async function Jf(e,t=null,n=!0){let o,i=null==e?void 0:e.toString();var a;if(i||(Ue.config(),process.env.NEEDLE_CLOUD_TOKEN&&(i=process.env.NEEDLE_CLOUD_TOKEN,null!=(a=i)&&a.length&&console.log("Using NEEDLE_CLOUD_TOKEN token from env"))),""===i||"true"===i){const e=(await import("node:readline")).createInterface({input:process.stdin}),t=10;let n,i="",a=!1;return new Promise(r=>{const s="Paste your https://cloud.needle.tools/team#token access token here:",c=$({text:s,interval:200,spinner:"moon"}).start();process.stdin.setRawMode(!0),process.stdin.on("data",l=>{const p=l.toString();""===p&&process.exit();const u="\n"===p||"\r"===p;if(!u&&"\n"!==p&&"\r"!==p){""===p||"\b"===p?i=i.slice(0,-1):i+=p;const e=i.replace(/./g,"*");c.text=`${s} ${e}`}clearTimeout(n),n=setTimeout(()=>{if(!a&&(u||i.trim().length>t)){process.stdin.setRawMode(!1),e.close(),a=!0;const t=i.trim();if(t.length>0){const e=t.slice(3,-3).replace(/./g,"*");c.succeed("Access token received: "+e)}else c.fail("No access token provided");r({accessToken:t,org_id:o})}},150)})})}if(!i){let e;await async function(){const e=await Lu();return null==e?void 0:e.isAuthenticated}()||(e=Wf?void 0:$("No access token found. Please sign in to authenticate...").start()),wp("No access token provided, attempting login. Org: "+t);const a=qf({headless:!n,ora:e,timeout:12e4}),d=await a;var r;if(d&&!await Vu(d)?(null==(r=e)||r.fail("You are not logged in from this machine. Please login again."),await Bf({headless:!0}),process.exit(1)):e&&(wp("User logged in via getAccessToken "+(null==d?void 0:d.isAuthenticated)),d?e.succeed("Logged in"):e.fail("Login failed")),null!=d&&d.isAuthenticated){var s;if(null==t){const e=await zu(d);"string"==typeof e&&(t=e)}else t===(null==(s=d.userInfo)?void 0:s.sub)&&(t=null);if(t){var c,l,p;if(o=null==(c=d.userInfo)||null==(c=c.organization_data)||null==(c=c.find(e=>e.id===t))?void 0:c.id,o||(t=null==(l=t.toString())?void 0:l.toLowerCase(),null!=o||(o=null==(p=d.userInfo)||null==(p=p.organization_data)||null==(p=p.find(e=>e.name.toLowerCase()===t))?void 0:p.id)),!o)throw new Error(`ERR: You (${Bu(d)}) are not a member of the team "${t}" or the team does not exist. Please check the team name/id and try again.`);i=await(null==d?void 0:d.client.getOrganizationToken(o)),wp("Getting access token for org "+o+", "+i.substring(0,8)+"...")}else{var u;wp("Getting access token for user "+(null==(u=d.userInfo)?void 0:u.sub)),i=null==d?void 0:d.accessToken}}}return i||(console.error("ERR: Missing NEEDLE_CLOUD_TOKEN token. Please provide the access token argument or set the environment variable NEEDLE_CLOUD_TOKEN. Get an access token for your team at https://cloud.needle.tools/team"),wp("ERR: Missing NEEDLE_CLOUD_TOKEN token. Org: "+o),process.exit(403)),{accessToken:i,org_id:o}}function Vf(e){return null!=e.org&&console.warn("Warning: --org is deprecated. Use --team instead."),e.team||e.org}const Kf=dt.program;async function Yf(){const{spawn:e}=await import("node:child_process");e(process.execPath,[process.argv[1],"start","--integration","cli-login"],{stdio:"inherit",env:{...process.env,NEEDLE_CLOUD_TOKEN:process.env.NEEDLE_CLOUD_TOKEN||""}}),await new Promise(e=>setTimeout(e,1e3))}Kf.version(Hf.version).description("Command-line interface (CLI) for Needle Cloud"),Kf.command("version","Print the CLI version").configure({visible:!1}).action(()=>{Wf||console.log(`☁ Needle CLI — ${Hf.version}, Node ${process.version}`)}),Kf.command("start","Starts the Needle Auth server").alias("start-server").configure({visible:!1,strictOptions:!1}).help("Start the local server for Needle Cloud. This is required to authenticate with Needle Cloud and access your account and data.").option("--restart <restart>","Restarts the server",{required:!1,validator:Kf.BOOLEAN,default:!1}).option("--integration <integration>","Hint for the process which integration triggered this command",{required:!1,validator:Kf.STRING}).action(async({options:e})=>{const t=e.integration,n=Wf?void 0:$("Starting Needle License server "+(t?`(from ${t})`:"")).start();Ff({ora:n,restart:e.restart}).catch(e=>{console.error("Failed to start server:",e),null==n||n.fail("Failed to start server: "+e.message),process.exit(1)}).then(e=>{null!=e&&e.baseUrl&&e.isHost?null==n||n.succeed(`Server started on ${e.baseUrl} (v${cd()}, built ${function(e){if("string"!=typeof Pf||0===Pf.length)return"unknown";const t=new Date(Pf);if(Number.isNaN(t.getTime()))return"unknown";const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}()})`):!1===(null==e?void 0:e.isHost)?(t||null==n||n.warn(`Server is running on ${e.baseUrl||e.port}`),process.exit(0)):(null==n||n.fail("Failed to start server"),process.exit(1))})}),Kf.command("settings","Show current Needle CLI settings").action(async()=>{const{readSettings:e,KNOWN_SETTINGS:t}=await Promise.resolve().then(function(){return nm}),n=e();for(const[e,o]of Object.entries(t)){const t=n[e],i=void 0!==t?String(t):o.default;console.log(`\n ${"enabled"===i?"[x]":"[ ]"} ${o.displayName}: ${i}${void 0===t?" (default)":""}`),console.log(` ${o.description}`),console.log(` Change: ${o.command}`)}console.log("")}),Kf.command("settings remote-ai-tools","Enable or disable cloud AI tool dispatch to this machine").help("When disabled, the CLI does NOT connect to the Needle Cloud AI tool dispatcher (wss://cloud.needle.tools/v1/cli/ws), so cloud-side AI chats cannot invoke tools (file reads, grep, etc.) on this machine. The local /mcp/ws endpoint used by Unity/Blender stays available. Setting persists in ~/.needle/settings.json.").argument("<enabled>","true to enable, false to disable",{validator:Kf.BOOLEAN}).action(Np("settings remote-ai-tools",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return nm}),o=e.enabled,i=n();o?(t(i,"remote_ai_tools",null),console.log("Remote AI tools enabled (default)."),wp("Settings: remote_ai_tools set to enabled (default) via CLI command")):(t(i,"remote_ai_tools","disabled"),console.log("Remote AI tools disabled. The cloud AI chat will not be able to dispatch tools to this machine."),wp("Settings: remote_ai_tools set to disabled via CLI command"))})),Kf.command("settings local-file-edits","Enable or disable AI file changes on this machine").help("This local setting is checked for every AI write, delete, rename, Undo, and Redo. Cloud chat approval cannot override it. Persists in ~/.needle/settings.json.").argument("<enabled>","true to enable, false to disable",{validator:Kf.BOOLEAN}).action(Np("settings local-file-edits",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return nm}),o=e.enabled;t(n(),"local_file_edits",o?null:"disabled"),console.log(`Local AI file edits ${o?"enabled":"disabled"}.`)})),Kf.command("settings local-project-commands","Enable or disable approved AI project commands on this machine").help("Allows separately approved AI package installs, project creation, builds, and deploys. Enabled by default; Cloud chat approval cannot override this setting. Persists in ~/.needle/settings.json.").argument("<enabled>","true to enable, false to disable",{validator:Kf.BOOLEAN}).action(Np("settings local-project-commands",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return nm}),o=e.enabled;t(n(),"local_project_commands",o?null:"disabled"),console.log(`Local AI project commands ${o?"enabled":"disabled"}.`)})),Kf.command("status","Show the local Needle server status and process ID").action(Np("status",async()=>{const{getLocalServerStatus:e,formatLocalServerStatus:t}=await Promise.resolve().then(function(){return Nf});console.log(t(await e()))})),Kf.command("mcp","Start MCP server for AI agents (stdio transport)").help('Start the Needle Cloud MCP server using stdio transport.\nReuses or starts the shared local server for Inspector/Unity tools and cloud connections.\nThis is the standard way to connect AI agents (Claude Desktop, Cursor, VS Code, etc.).\n\nAdd to your MCP client config:\n{\n "mcpServers": {\n "needle": {\n "command": "npx",\n "args": ["-y", "needle-cloud", "mcp"]\n }\n }\n}').action(Np("mcp",async()=>{const{startStdio:e}=await Promise.resolve().then(function(){return yf});e()})),Kf.command("get-project-id","Gets the project id for a local project").configure({visible:!1,strictOptions:!1}).argument("<paths...>","The path to the local project (web project directory)").action(async({args:e})=>{const t=df(e.paths);t?console.log(`Found project ID: "${t}"`):console.log("No project ID found.")}),Kf.command("send-logs","Upload CLI, editor, and optimization-pipeline logs to Needle (secrets and sensitive info redacted)").help("Stream the current and previous CLI log, the most recent editor log (Unity or Blender), and the optimization-pipeline log to Needle for support diagnosis. Before upload, tokens, Bearer/Authorization values, UUIDs, home-directory paths, email addresses, Username/User fields, and *_KEY / *_TOKEN / *_SECRET / *_PASSWORD env-var values are redacted (replaced with <redacted:Nch> so the length is preserved for debugging). Returns a reference ID to paste into your bug report. Requires sign-in; the upload is tagged with your Needle account.").option("--crash <crash>","Mark this upload as a crash report (uses the crash-mode daily quota)",{required:!1,validator:Kf.BOOLEAN,default:!1}).option("--note <note>","One-line note attached to the upload",{required:!1}).option("--dry-run <dryRun>","Print the redacted payload without uploading",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(Np("send-logs",async({options:e})=>{var t,n,o,i,a,r,s;const{runSendLogs:c,HAYSTACK_RESOURCE:l}=await Promise.resolve().then(function(){return mu}),{tryGetFreshAccessTokenForResource:p}=await Promise.resolve().then(function(){return qu}),{findActiveEditorLog:u}=await import("./cli.send-logs.discovery-4b1990b5.js"),{getLogFilePath:d,getPrevLogsFilePath:m,getPipelineLogFilePath:f}=await Promise.resolve().then(function(){return _p}),{homedir:h,platform:g}=await import("os"),{existsSync:v}=await import("fs"),{BUILD_TIME:b}=await Promise.resolve().then(function(){return Uf}),{getNodeVersion:x,getNpmVersion:y,getArch:w,getOsRelease:_,getCpuCount:j,getTotalMemoryMb:k,getTzOffsetMinutes:S,isCi:E,isTty:T}=await import("./cli.runtime-465aa7a3.js"),I=null!=(t=null!=(n=null==(o=e.crash)||null==o.valueOf?void 0:o.valueOf())?n:e.crash)&&t?"crash":"normal",O=e.note,A=null!=(i=null!=(a=null==(r=e.dryRun)||null==r.valueOf?void 0:r.valueOf())?a:e.dryRun)&&i,C=d(),R=m(),N=f(),P={getAccessToken:()=>p(l),fetch:globalThis.fetch,paths:{cliLogPath:v(C)?C:null,prevLogPath:v(R)?R:null,pipelineLogPath:v(N)?N:null,homeDir:h()},meta:{cli_version:cd(),build_time:b,os:g(),os_release:_(),arch:w(),node_version:x(),npm_version:null!=(s=y())?s:"unknown",cpu_count:j(),total_memory_mb:k(),tz_offset_minutes:S(),is_ci:E(),is_tty:T()},findActiveEditorLog:u,stdout:process.stdout,stderr:process.stderr},U=A?"Building payload (dry-run)":"Uploading logs",L=Wf?void 0:$(U).start();P.recoverAuth=async()=>{null==L||L.stop();try{await Yf();const e=await qf({clearAuthData:!0,silent:Wf,ora:void 0});if(null==e||!e.isAuthenticated)return null}catch(e){return wp(`send-logs: auto-recovery login failed: ${e instanceof Error?e.message:e}`),null}finally{null==L||L.start(U)}return await p(l)};const z=await c({mode:I,note:O,dryRun:A},P);z.ok?A?null==L||L.succeed("Dry-run payload printed above. Nothing was uploaded."):z.truncated?(null==L||L.warn(`Uploaded (truncated at server cap). Reference: ${z.refId}`),console.log(`Share ${z.refId} in your bug report.`)):(null==L||L.succeed(`Uploaded. Reference: ${z.refId}`),console.log(`Share ${z.refId} in your bug report.`)):(null==L||L.fail(z.error||"Upload failed"),process.exitCode=1)})),Kf.command("login","Login to Needle Cloud").help("Login to Needle Cloud. If you are already logged in, this will refresh the access token.").option("--headless <headless>","The headless process will not open a browser window to login. If the user is not authorized then no auth flow can be started. Use this if you only want to **check** if the user is authenticated",{required:!1,validator:Kf.BOOLEAN,default:!1}).option("--clear <clear>","Refresh the access token",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(async({options:e})=>{await Yf();const t=e.headless.valueOf()||!1,n=e.clear.valueOf()||!1,o=Wf?void 0:$("Login").start();await qf({headless:t,silent:Wf,clearAuthData:n,ora:o}).then(async e=>{null!=e&&e.isAuthenticated?null==o||o.succeed("Successfully logged in as "+Bu(e)):0==t?null!=e&&e.claims||null!=e&&e.userInfo?null==o||o.warn(`You (${Bu(e)}) are not authenticated...`):null==o||o.fail("Login failed"):Wf||null==o||o.warn("Not logged in"),process.exit(null!=e&&e.isAuthenticated?0:1)})}),Kf.command("logout","Logout of Needle Cloud").help("Logout of Needle Cloud (if you have logged in before).").option("--headless <headless>","Headless will not open a browser window to logout",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(async({options:e})=>{await Yf();const t=e.headless.valueOf()||!1;await Bf({headless:t}).then(e=>{e?$("Logged out").succeed():$("Logout failed").fail(),process.exit(e?0:1)})}),Kf.command("me","Prints your user information").help("Prints basic informaton about the logged in Needle Cloud account (your account)").action(async({})=>{const e=Wf?void 0:$("Query user data").start(),t=await Lu();if(null!=t&&t.isAuthenticated&&await Vu(t)){const a=t.userInfo||t.claims;var n,o,i;a?(null==e||e.succeed(`You are logged in as ${Bu(t)}`),console.log(`- Name: ${Bu(t)}`),console.log(`- ID: ${a.sub}`),a.email&&console.log(`- Email: ${a.email}`),a.phone_number&&console.log(`- Phone: ${a.phone_number}`),null!=(n=t.userInfo)&&n.organization_data&&console.log(`- Teams [${null==(o=t.userInfo)?void 0:o.organization_data.length}]: ${null==(i=t.userInfo)?void 0:i.organization_data.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.name).join(", ")}`)):null==e||e.fail("Failed to get user data")}else null==e||e.warn("You are not logged in")}),Kf.command("get-pro","Start license flow for Needle Engine PRO").configure({visible:!1,strictArgsCount:!1,strictOptions:!1}).option("--team <team>","The team to purchase the license for",{validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{validator:Kf.STRING,hidden:!0}).action(Np("get-pro",async({options:e})=>{var t;let n=(null==(t=Vf(e))?void 0:t.toString())||null;const o=$().start("Start Needle Engine PRO purchase flow"),i=function(e){e=e||{};const t="undefined"!=typeof window?window.location:null;"current_page"===e.baseUrl&&(e.baseUrl=null==t?void 0:t.href);let n=e.pathname||(null==t?void 0:t.pathname),o=e.baseUrl||(null==t?void 0:t.href);if(!n||!o)return null;const i=new URL(n,o);return t&&(i.search=t.search),e.license||(e.license="needle-engine:pro"),i.searchParams.set("purchase_intent",e.license),e.account_id&&i.searchParams.set("account_id",e.account_id),e.return_url&&i.searchParams.set("return_url",e.return_url),e.checkout_if_possible&&i.searchParams.set("checkout_if_possible","true"),e.show_all_cards&&i.searchParams.set("show_all_cards","true"),e.affiliate_id&&i.searchParams.set("affiliate_id",e.affiliate_id),e.tracking_id&&i.searchParams.set("tracking_id",e.tracking_id),i}({baseUrl:"https://cloud.needle.tools",pathname:n?`/team/${n}`:"/account",account_id:n,license:"needle-engine:pro",return_url:null});if(!i)return void o.fail("Failed to get purchase url - please visit https://cloud.needle.tools");const a=i.toString();o.succeed(`Started Needle Engine PRO purchase flow: opening browser at ${a}`),ap(a)}));const Zf={account:{url:op}},Xf=`"${Object.keys(Zf).join('", "')}"`;Kf.command("open",`Open a page in the default browser. Options are: ${Xf}`).argument("<page>",`The page to open. Options are: ${Xf}`,{validator:Kf.STRING}).configure({strictOptions:!1,strictArgsCount:!1,visible:!1}).help("").action(async({args:e,logger:t})=>{const n=e.page.toString(),o=Zf[n];o?"url"in o?ap(o.url()):t.error(`Unknown argument: ${n}`):t.error(`Unknown argument: ${n}. Options are: ${Xf}`)}),Kf.command("list-deployments","Get a list of deployed websites").configure({visible:!1}).help("").option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).option("--limit <limit>","Limit the number of deployments to show (min: 0, max: 100)",{validator:Kf.NUMBER,default:10}).option("--offset <offset>","The offset for deployments (default: 0, min: 0)",{validator:Kf.NUMBER,default:0}).option("--format <format>","The output format. Options: cli (default), json",{validator:Kf.STRING,default:"cli",hidden:!0}).option("--name","Filter by one or multiple deployment names (separated by ;)",{validator:Kf.STRING}).action(async({options:e,logger:t})=>{var n,o,i;const{accessToken:a,org_id:r}=await Jf(e.token,Vf(e)),s=(null==(n=e.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",c=e.limit.valueOf(),l=e.offset.valueOf(),p=(null==(o=e.format)?void 0:o.toString())||"cli",u=(null==(i=e.name)?void 0:i.toString())||void 0;if(c<0)return void t.error("The limit can not be negative");if(c>100)return void t.error("The limit can not be higher than 100");const d=$("Query deployments").start(),m=await Bp({endpoint:s,authToken:a,org:r,limit:c,offset:l,names:null==u?void 0:u.split(";")}).catch(e=>{t.error(e)});if(m&&"error"in m)d.fail(m.error+" (status: "+m.status+")");else if(m){if("json"===p){d.succeed(`Found ${m.deployments.length} deployments`);const e=JSON.stringify(m.deployments);return void console.log(e)}m.deployments.length>0?(d.succeed(`Found ${m.deployments.length} deployments`),m.deployments.forEach((e,n)=>{t.info(`${n+c*l}: ${e.name} – ${e.url}`)})):d.warn("No deployments found"),process.exit(0)}else d.fail("Failed to query deployments"),process.exit(1)}),Kf.command("list","List content items (3d assets, deployments, materials, etc.)").alias("list-content").help('List content items stored in Needle Cloud.\n\nUse --type to filter by content type (e.g. "material", "3d-asset", "deployment").\nUse --format to filter by output format (e.g. "glb", "textures").').option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).option("--type <type>","Filter by content type (e.g. material, 3d-asset, deployment)",{required:!1,validator:Kf.STRING}).option("--format <format>","Filter by output format (e.g. glb, textures)",{required:!1,validator:Kf.STRING}).option("--search <search>","Search by name, title or description",{required:!1,validator:Kf.STRING}).option("--limit <limit>","Max number of items to show (default: 20, max: 100)",{validator:Kf.NUMBER,default:20}).option("--offset <offset>","Offset for pagination (default: 0)",{validator:Kf.NUMBER,default:0}).option("--output <output>","Output style: cli (default), json",{validator:Kf.STRING,default:"cli"}).action(async({options:e,logger:t})=>{var n,o,i,a,r,s,c,l,p;const{accessToken:u,org_id:d}=await Jf(e.token,Vf(e)),m=(null==(n=e.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",f=Math.min(null!=(o=null==(i=e.limit)?void 0:i.valueOf())?o:20,100),h=null!=(a=null==(r=e.offset)?void 0:r.valueOf())?a:0,g=(null==(s=e.output)?void 0:s.toString())||"cli",v=(null==(c=e.type)?void 0:c.toString())||void 0,b=(null==(l=e.format)?void 0:l.toString())||void 0,x=(null==(p=e.search)?void 0:p.toString())||void 0,y=$("Querying content...").start();try{const e=await ql({baseUrl:m,authToken:u,org:d},{content_type:v,content_format:b,search:x,limit:f,offset:h});if("json"===g)return y.succeed(`Found ${e.items.length} of ${e.total} items`),void console.log(JSON.stringify(e.items,null,2));0===e.items.length&&(y.warn("No content found"+(v?` (type: ${v})`:"")+(b?` (format: ${b})`:"")),process.exit(0)),y.succeed(`Found ${e.items.length} of ${e.total} items`);const n=e.items.map(e=>{var t;const n=e.title||"(untitled)";return{id:e.identifier,type:e.content_type||"?",formats:null!=(t=e.content_formats)&&t.length?e.content_formats.join(", "):"",name:n.length>20?n.slice(0,17)+"...":n,versions:String(e.version_count||0),date:e.created_at?dl(new Date(e.created_at),new Date,{allowSimple:!0,limitInDays:2}):""}}),o={id:Math.max(2,...n.map(e=>e.id.length)),type:Math.max(4,...n.map(e=>e.type.length)),formats:Math.max(7,...n.map(e=>e.formats.length)),name:Math.max(4,...n.map(e=>e.name.length))},i=Hp(` ${"ID".padEnd(o.id)} ${"TYPE".padEnd(o.type)} ${"FORMATS".padEnd(o.formats)} ${"NAME".padEnd(o.name)} ${"#".padStart(3)} AGE`);t.info(i);for(const e of n){const n=Wp(e.type).padEnd(o.type+11),i=(e.formats?e.formats.split(", "):[]).map(e=>Wp(e)).join(", ")+" ".repeat(Math.max(0,o.formats-e.formats.length));t.info(` ${Hp(e.id.padEnd(o.id))} ${n} ${i} ${e.name.padEnd(o.name)} ${e.versions.padStart(3)} ${Hp(e.date)}`)}e.total>h+f&&t.info(` ... ${e.total-h-f} more (use --offset ${h+f})`),process.exit(0)}catch(e){y.fail(e.message),process.exit(1)}}),Kf.command("delete","Move a content item to the trash").help("Move a content item to the trash. This immediately frees total storage capacity but does not refund monthly usage. The item can be restored for 31 days if enough total storage is available.\n\nUsage:\n needle-cloud delete <identifier>").argument("<identifier>","Content item identifier",{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The Needle Cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).action(async({args:e,options:t})=>{var n;const{accessToken:o,org_id:i}=await Jf(t.token,Vf(t)),a=(null==(n=t.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",r=e.identifier.toString(),s=$(`Deleting content "${r}"...`).start();try{const e=await qp({identifier:r,endpoint:a,authToken:o,org:i});s.succeed(e.message||`Moved content "${r}" to the trash`),process.exit(0)}catch(e){s.fail(e.message),process.exit(1)}}),Kf.command("download","Download a content item by identifier").help('Download files from a content item.\n\nUse --format to select which output format to download (e.g. "glb", "textures").\n\nUsage:\n needle-cloud download <identifier> [directory]\n needle-cloud download abc123 --format glb').argument("<identifier>","Content item identifier",{validator:Kf.STRING}).argument("[directory]","Output directory (default: current directory)",{default:"."}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).option("--format <format>","Output format to download (e.g. glb, textures)",{required:!1,validator:Kf.STRING}).option("--name <name>","Output filename (without extension)",{required:!1,validator:Kf.STRING}).option("--verbose","Show detailed download info",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(async({args:e,options:t,logger:n})=>{var o,i,a,r,s,c;const{accessToken:l,org_id:p}=await Jf(t.token,Vf(t)),u=(null==(o=t.endpoint)?void 0:o.toString())||"https://cloud.needle.tools/api",d=e.identifier.toString(),m=(null==(i=e.directory)?void 0:i.toString())||".",f=(null==(a=t.name)?void 0:a.toString())||void 0,h=null!=(r=null==(s=t.verbose)?void 0:s.valueOf())&&r,g=(null==(c=t.format)?void 0:c.toString())||void 0,v=$("Looking up content...").start();try{var b;const e={baseUrl:u,authToken:l,org:p},t=await Bl(e,d).catch(()=>null);if(!t)return void v.fail(`Content not found: "${d}". Use the exact content identifier (see list-content).`);const o=null==(b=t.versions)?void 0:b[0];if(!o)return void v.fail(`Content "${t.title||t.name}" has no versions`);let i=o.identifier;if(g){let e=!1;for(const n of t.versions){if(n.content_format===g){i=n.identifier,e=!0;break}const t=n.variants.find(e=>e.content_format===g);if(t){i=t.identifier,e=!0;break}}if(!e)return void v.fail(`No output with format "${g}" found for "${t.title||t.name}"`)}v.text=`Downloading "${t.title||t.name}"${g?` (format: ${g})`:""}...`,v.stop();const a=await Lp({baseUrl:u,authToken:l,org:p,identifier:i,outDir:m,filename:f,verbose:h,content_format:g});"error"in a&&n.error(a.error)}catch(e){v.fail(e.message)}}),Kf.command("deploy","Deploy a website to Needle").help("").argument("<directory>","The directory to deploy",{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to deploy to (not needed when using token/accesstoken)",{required:!1,validator:Kf.STRING}).option("--org <org>","The organization name or id to deloy to (not needed when using token/accesstoken)",{required:!1,validator:Kf.STRING,hidden:!0}).option("--name <name>","The project name. This name will also be used in your website URL",{required:!1,validator:Kf.STRING}).option("--entrypoint <entrypoint>",'The entrypoint file to use (e.g. "index.html"). This is useful if you want to deploy a folder with multiple HTML files and you want to configure which file to load initially or if you have multiple model files in one folder',{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING,hidden:!0}).option("--open","Open the deployment in the default browser",{default:!0,validator:Kf.BOOLEAN}).option("--verbose <verbose>","Enables verbose output logs",{required:!1,validator:Kf.BOOLEAN,default:!1,hidden:!0}).option("--experimental","Use the experimental upload API. Mostly used for debugging (default: false)",{required:!1,validator:Kf.BOOLEAN,default:!1,hidden:!0}).option("--raw","Use raw to disallow modifications like gzip compression on upload",{required:!1,validator:Kf.BOOLEAN,default:!1,hidden:!0}).option("--no-provenance","Do not record which commit and CI run this deployment came from",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(Np("deploy",async({args:e,options:t,logger:n})=>{var o,i,a,r;const s=t.open,{accessToken:c,org_id:l}=await Jf(t.token,Vf(t)),p=t.verbose.valueOf(),u=t.experimental.valueOf()||!1,d=t.raw.valueOf()||!1,m=(null==(o=t.noProvenance)?void 0:o.valueOf())||!1;await kp({logger:n,endpoint:(null==(i=t.endpoint)?void 0:i.toString())||void 0,token:c,org_id:l,directory:e.directory.toString(),name:(null==(a=t.name)?void 0:a.toString())||void 0,entrypoint:(null==(r=t.entrypoint)?void 0:r.toString())||void 0,open:s,verbose:p||!1,experimental:u||!1,raw:d||!1,noProvenance:m})})),function(e,t){for(const n of["upload","optimize"]){const o="optimize"===n,i=e.command(n,o?"Upload and wait for optimized assets (shorthand for upload --wait)":"Upload source assets to Needle Cloud").help("Upload returns source file identities and links after the transfer completes. Optimization continues in the background. Use upload --wait or optimize to wait for the selected optimized variant. Folders are collected recursively into one grouped upload. Use --format json for its file list. Original links always identify the uploaded source version.").argument("<path>","File or folder to upload",{validator:e.STRING}).option("--token <token>","Access token; also accepts NEEDLE_CLOUD_TOKEN or a saved login",{validator:e.STRING}).option("--team <team>","Team name or ID",{validator:e.STRING}).option("--org <org>","Organization name or ID (deprecated; use --team)",{validator:e.STRING,hidden:!0}).option("--name <name>","Upload name or identifier of an existing asset",{validator:e.STRING}).option("--format <format>","Output: cli (default), json, source-url, edit-url. Diagnostics go to stderr.",{validator:e.STRING,default:"cli"}).option("--outdir <outdir>","Download optimized files to this directory (requires waiting)",{validator:e.STRING}).option("--progressive","Use progressive loading when waiting for optimization",{validator:e.BOOLEAN,default:!!o||void 0}).option("--usecase <usecase>","Optimization variant: product or world (requires waiting)",{validator:e.STRING,default:o?"product":void 0}).option("--verbose <verbose>","Print detailed diagnostics to stderr",{validator:e.BOOLEAN,default:!1});o||i.option("--wait","Wait for the selected optimized result",{validator:e.BOOLEAN,default:!1}).option("--no-optimize","Store source files without requesting processing",{validator:e.BOOLEAN,default:!1}),i.action(Np(n,async({args:e,options:n})=>{var i;const a=globalThis.console,r=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Ne({stdout:r,stderr:r});try{var s,c,l;const i=String(null!=(s=n.format)?s:"cli");if("cli"!==i&&"json"!==i&&"source-url"!==i&&"edit-url"!==i)throw new Error("Invalid --format. Use cli, json, source-url or edit-url.");const a=o||!0===n.wait;if(a&&!0===n.noOptimize)throw new Error("--wait cannot be combined with --no-optimize.");if(!a&&(void 0!==n.outdir||void 0!==n.progressive||void 0!==n.usecase))throw new Error("--wait is required for --outdir, --progressive and --usecase.");const r=n.usecase;if(void 0!==r&&"product"!==r&&"world"!==r)throw new Error("Use case must be product or world.");void 0!==n.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:u,org_id:d}=await t.getAccessToken(n.token,n.team||n.org);if(u!==n.token&&u!==process.env.NEEDLE_CLOUD_TOKEN){const e=await t.getUser();if(null==e||!e.isAuthenticated)throw new Error("Please login to upload files.");if(!d)throw new Error("Please provide a team to upload files.");if(a){var p;const e=await(null!=(p=t.getLicenses)?p:vt)({baseUrl:"https://cloud.needle.tools/api",authToken:u,org:d},{type:"org",org_id:d});if(null==e||!e.some(e=>"Needle Engine"===e.type&&("pro"===e.license||"enterprise"===e.license)))throw new Error("Update to Needle PRO or Enterprise required to optimize files via CLI. Visit https://cloud.needle.tools/get-pro")}}Fp(await(null!=(c=t.upload)?c:zp)({token:u,org_id:d,fileOrDirectory:String(e.path),name:void 0===n.name?void 0:String(n.name),wait:a,noOptimize:!0===n.noOptimize,progressive:void 0===n.progressive?void 0:!0===n.progressive,usecase:r,outDir:void 0===n.outdir?void 0:String(n.outdir),verbose:!0===n.verbose,format:i}),i,null!=(l=t.write)?l:e=>{process.stdout.write(e)})}finally{globalThis.console=a}}))}}(Kf,{getAccessToken:Jf,getUser:Lu}),function(e,t){e.command("label","List, create or move content labels");for(const n of["list","set"]){const o=e.command(`label ${n}`,"list"===n?"List content labels and their source/derived URLs":"Create or move a label to a completed content version").argument("<content-id>","Content item identifier",{validator:e.STRING}).option("--token <token>","Access token; also accepts NEEDLE_CLOUD_TOKEN or a saved login",{validator:e.STRING}).option("--team <team>","Team name or ID",{validator:e.STRING}).option("--org <org>","Organization name or ID (deprecated; use --team)",{validator:e.STRING,hidden:!0}).option("--format <format>","Output: cli (default) or json. Diagnostics go to stderr.",{validator:e.STRING,default:"cli"});"set"===n&&o.argument("<label>","Destination label; latest is managed automatically",{validator:e.STRING}).option("--version <version>","Completed version ID from this content item",{validator:e.STRING}).option("--from <label>","Select the version currently targeted by this label (for example latest)",{validator:e.STRING}).help("Provide exactly one of --version or --from. Moving a label also updates its related completed outputs. Both read and write access are required."),o.action(Np(`label ${n}`,async({args:e,options:o})=>{var i;const a=globalThis.console,r=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Ne({stdout:r,stderr:r});try{var s,c;const i=String(null!=(s=o.format)?s:"cli");if("cli"!==i&&"json"!==i)throw new Error("Invalid --format. Use cli or json.");const a=String(e.contentId);$p(a);const r={contentId:a,label:String(e.label),versionId:void 0===o.version?void 0:String(o.version),from:void 0===o.from?void 0:String(o.from)};"set"===n&&Tp(r),void 0!==o.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:u,org_id:d}=await t.getAccessToken(o.token,o.team||o.org),m={baseUrl:"https://cloud.needle.tools/api",authToken:u,org:d},f=null!=(c=t.write)?c:e=>{process.stdout.write(e)};if("list"===n){var l;const e=await(null!=(l=t.listContentLabels)?l:Ap)(m,a);if("json"===i)f(JSON.stringify(e)+"\n");else if(e.labels.length)for(const t of e.labels)f(`${t.label}: ${t.sourceVersionIds.join(", ")}\n`),Up(t.targets,f);else f(`No labels for ${a}.\n`)}else{var p;const e=await(null!=(p=t.setContentLabel)?p:Cp)(m,r);"json"===i?f(JSON.stringify(e)+"\n"):(f(`${e.label}: ${e.previousVersionIds.join(", ")||"(new label)"} -> ${e.versionId}\n`),Up(e.targets,f))}}finally{globalThis.console=a}}))}}(Kf,{getAccessToken:Jf}),Kf.command("generate-material","Generate a PBR material from a text prompt").help("").argument("<prompt>","The text prompt describing the material to generate",{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Kf.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Kf.STRING,hidden:!0}).option("--resolution <resolution>","The material texture resolution (256, 512, 1k, 2k, 4k)",{default:"512",required:!1,validator:Kf.STRING}).option("--name <name>","Output filename",{required:!1,validator:Kf.STRING}).option("--outdir <outdir>","Output directory to download the generated file(s) to. If not set, the job ID is printed instead.",{required:!1,validator:Kf.STRING}).action(Np("generate-material",async({args:e,options:t,logger:n})=>{var o,i,a;const{accessToken:r,org_id:s}=await Jf(t.token,Vf(t)),c=e.prompt.toString(),l=null==(o=t.resolution)?void 0:o.toString(),p=null==(i=t.outdir)?void 0:i.toString(),u=null==(a=t.name)?void 0:a.toString(),d=await async function(e){if(!e.token||e.token.length<=1||"string"!=typeof e.token||"true"===e.token)return{error:`Missing access token. Create a token at ${op()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";wp(`[generate-material] Starting request to ${t}, prompt="${e.prompt}", resolution=${e.resolution||512}`,{emptyLineBefore:!0});const n=$("Requesting material generation...").start(),o=await Promise.race([Dl({baseUrl:t,authToken:e.token,org:e.org_id,trigger_type:"cli"},{prompt:e.prompt,resolution:e.resolution||512}).catch(e=>({error:e.message||"Request failed"})),new Promise(e=>setTimeout(()=>e({error:"Request timed out after 30s. Please try again."}),3e4))]);if("error"in o)return wp(`[generate-material] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(wp(`[generate-material] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return wp(`[generate-material] Job canceled: ${i.status_message||"quota exceeded"}`),n.fail(i.status_message||"Material generation was canceled (quota exceeded)"),{error:i.status_message||"Quota exceeded"};n.succeed(`Material generation requested: ${i.identifier}`);const a=$("Waiting for material generation...").start();a.color="gray";const r=jc();for(;;){if("completed"===i.status){a.succeed("Material generation completed");break}let n=2e3;const o=await _c(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=r.record(o);if(s)return a.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))a.text="Your material is queued - waiting for generation to start",a.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))a.text=`Generating material: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,a.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){wp(`[generate-material] Job completed: ${i.identifier}`),a.succeed(`Material generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return wp(`[generate-material] Job canceled: ${i.identifier}, error=${o.error}`),a.fail(`Material generation canceled: ${o.error||""}`),{error:o.error||"Material generation canceled"};if("failed"===(null==o?void 0:o.status))return wp(`[generate-material] Job failed: ${i.identifier}, error=${o.error}`),a.fail(`Material generation failed: ${o.error||""}`),{error:o.error||"Material generation failed"}}await ul(n)}if(e.outDir){const n=await Lp({baseUrl:t,authToken:e.token,org:e.org_id,identifier:i.identifier,outDir:e.outDir,filename:e.outputName});if("error"in n)return{error:n.error}}return{success:!0,identifier:i.identifier}}({logger:n,token:r,org_id:s,prompt:c,resolution:l,outputName:u,outDir:p});"error"in d&&(d.error&&n.error(d.error),process.exit(1)),!p&&d.identifier&&console.log(d.identifier),process.exit(0)})),Kf.command("generate-3d","Generate a 3D model from a text prompt").help("").argument("<prompt>",'A description of the object to generate, e.g. "a weathered wooden crate with iron bands"',{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Kf.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Kf.STRING,hidden:!0}).option("--quality <quality>","Quality tier: standard (default, includes physically based material maps) or draft (faster and cheaper, base color only)",{default:"standard",required:!1,validator:Kf.STRING}).option("--face-count <faceCount>","Target polygon count (40000-1500000). Leave unset to let the generator choose.",{required:!1,validator:Kf.NUMBER}).option("--name <name>","Output filename",{required:!1,validator:Kf.STRING}).option("--outdir <outdir>","Output directory to download the generated file(s) to. If not set, the job ID is printed instead.",{required:!1,validator:Kf.STRING}).action(Np("generate-3d",async({args:e,options:t,logger:n})=>{var o,i,a;const{accessToken:r,org_id:s}=await Jf(t.token,Vf(t)),c=e.prompt.toString(),l=null==(o=t.quality)?void 0:o.toString(),p=null!=t.faceCount?Number(t.faceCount):void 0,u=null==(i=t.outdir)?void 0:i.toString(),d=null==(a=t.name)?void 0:a.toString(),m=await async function(e){if(!e.token||e.token.length<=1||"string"!=typeof e.token||"true"===e.token)return{error:`Missing access token. Create a token at ${op()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";wp(`[generate-3d] Starting request to ${t}, prompt="${e.prompt}", quality=${e.quality||"draft"}`,{emptyLineBefore:!0});const n=$("Requesting 3D generation...").start(),o=await async function(e,t){var n;if(null!=(n=e.signal)&&n.aborted)return{error:"The 3D generation request was cancelled"};const o=e.baseUrl+ft.jobs.create,i={...ht(e),"content-type":"application/json"},a={type:"ai-3d-asset",triggered_by:e.trigger_type,parameters:{...t}},r=await fetch(o,{...gt,method:"POST",headers:i,body:JSON.stringify(a),signal:e.signal}).catch(e=>function(e){return"AbortError"===(null==e?void 0:e.name)||"TimeoutError"===(null==e?void 0:e.name)}(e)?{__aborted:!0}:(console.error(`Failed to request 3D asset generation: ${null==e?void 0:e.message}`),{__failed:(null==e?void 0:e.message)||"Request failed"}));if("__aborted"in r)return{error:"The 3D generation request was cancelled"};if("__failed"in r)return{error:r.__failed};if(!r.ok){const e=await r.text();return console.error(`Failed to request 3D asset generation (${r.status}): ${e}`),{error:e||`Request failed (${r.status})`}}const s=await r.json().catch(e=>(console.error(e),null));return null!=s&&s.job?s:{error:"The server did not return a job"}}({baseUrl:t,authToken:e.token,org:e.org_id,trigger_type:"cli",signal:AbortSignal.timeout(3e4)},{prompt:e.prompt,...e.quality?{quality:e.quality}:{},...e.face_count?{face_count:e.face_count}:{}});if("error"in o)return wp(`[generate-3d] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(wp(`[generate-3d] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return wp(`[generate-3d] Job canceled: ${i.status_message||"quota exceeded"}`),n.fail(i.status_message||"3D generation was canceled (quota exceeded)"),{error:i.status_message||"Quota exceeded"};n.succeed(`3D generation requested: ${i.identifier}`);const a=$("Waiting for the 3D model...").start();a.color="gray";const r=jc();for(;;){if("completed"===i.status){a.succeed("3D generation completed");break}let n=2e3;const o=await _c(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=r.record(o);if(s)return a.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))a.text="Your model is queued - waiting for generation to start",a.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))a.text=`Generating 3D model: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,a.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){wp(`[generate-3d] Job completed: ${i.identifier}`),a.succeed(`3D generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return wp(`[generate-3d] Job canceled: ${i.identifier}, error=${o.error}`),a.fail(`3D generation canceled: ${o.error||""}`),{error:o.error||"3D generation canceled"};if("failed"===(null==o?void 0:o.status))return wp(`[generate-3d] Job failed: ${i.identifier}, error=${o.error}`),a.fail(`3D generation failed: ${o.error||""}`),{error:o.error||"3D generation failed"}}await ul(n)}if(e.outDir){const n=await Lp({baseUrl:t,authToken:e.token,org:e.org_id,identifier:i.identifier,outDir:e.outDir,filename:e.outputName});if("error"in n)return{error:n.error}}return{success:!0,identifier:i.identifier}}({logger:n,token:r,org_id:s,prompt:c,quality:l,face_count:p,outputName:d,outDir:u});"error"in m&&(m.error&&n.error(m.error),process.exit(1)),!u&&m.identifier&&console.log(m.identifier),process.exit(0)})),Kf.command("ask","Send a message to the Needle Cloud AI").help("Send a message to the Needle Cloud AI chat.\n\nWithout a message argument, starts an interactive session.\nBy default streams the response to the terminal. Use --no-stream for a single JSON response.\nUse --slug to continue an existing chat conversation.\nDefault slug is <your-user-id>-cli (persistent across sessions).").argument("[message...]","The message to send (omit for interactive mode)").option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--slug <slug>","Chat slug to continue an existing conversation",{required:!1,validator:Kf.STRING}).option("--no-stream","Disable streaming (returns full response at once)",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(Np("ask",async({args:e,options:t})=>{var n,o;const{accessToken:i,org_id:a}=await Jf(t.token,Vf(t)),r=Array.isArray(e.message)?e.message:e.message?[e.message]:[],s=r.length?r.join(" "):void 0,c=(null==(n=t.slug)?void 0:n.toString())||void 0,l=(null==(o=t.noStream)?void 0:o.valueOf())||!1;await async function(e){const{token:t,org_id:n,message:o,slug:i,stream:a}=e,r=i||function(e){try{const t=e.split(".")[1],n=JSON.parse(Buffer.from(t,"base64url").toString());if(n.sub)return n.sub+"-cli"}catch{}return"cli-"+Math.random().toString(36).slice(2,10)}(t);await async function(e){const{token:t,org_id:n,slug:o,stream:i,initialMessage:a}=e,r=Pe({input:process.stdin,output:process.stdout});console.log(`Needle Cloud AI (chat: ${o})`),console.log('Type your message. Press Ctrl+C or type "exit" to quit.\n');try{for(a&&(console.log(`> ${a}`),await Dp({token:t,org_id:n,slug:o,message:a,stream:i}),console.log(""));;){const e=(await r.question("> ")).trim();if(e){if("exit"===e||"quit"===e)break;await Dp({token:t,org_id:n,slug:o,message:e,stream:i}),console.log("")}}}finally{r.close()}}({token:t,org_id:n,slug:r,stream:a,initialMessage:o})}({token:i,org_id:a,message:s,slug:c,stream:!l}),process.exit(0)}));export{Qu as g,Kf as p};
|
|
63
|
+
`;function gm(e,t,n,o){hd(e,async(e,n)=>{try{const o=await t(e,n);return"string"==typeof o?Ed(o):{...o,content:o.content.map(e=>"text"===e.type?{...e,text:Ed(e.text)}:e)}}catch(e){throw new Error(Ed(e instanceof Error?e.message:String(e)))}},n,o)}const vm=function(e,t=zd,n=Date.now){let o,i=0;return Object.assign(async(a={})=>{var r,s,c,l;const p={status:"error",message:"Use mode check, results or error; file/code filters, nonnegative integer offset/index. No paths or commands can be selected."};if(!a||"object"!=typeof a||Array.isArray(a))return p;if(Object.keys(a).some(e=>!["mode","file","code","offset","index"].includes(e)))return p;const u=null!=(r=a.mode)?r:"check";if(!["check","results","error"].includes(u))return p;for(const e of[a.file,a.code])if(void 0!==e&&("string"!=typeof e||e.length>250))return p;for(const e of[a.offset,a.index])if(void 0!==e&&(!Number.isSafeInteger(e)||e<0))return p;const d=e();if(o&&o.project!==d&&(o=void 0),"check"===u){var m;const e=i,a=Dd(d),r=await t(d);o={project:d,result:{...r,...r.message?{message:Ed(r.message)}:{},...r.output?{output:Ed(r.output)}:{},diagnostics:(null!=(m=r.diagnostics)?m:[]).map(e=>({...e,message:Ed(e.message)}))},time:n(),revision:e,snapshot:a}}if(!o)return{status:"unavailable",message:"No saved check for this local project. Run local_files_check_project with mode check first."};const f=Dd(d),h=null===o.snapshot||null===f,g=o.result,v=null!=(s=g.diagnostics)?s:[],b=v.map((e,t)=>({...e,index:t})).filter(e=>{var t;return(!a.file||(null!=(t=e.file)?t:"").toLowerCase().includes(a.file.toLowerCase()))&&(!a.code||e.code===a.code)}),x=null!=(c=a.offset)?c:0,y="error"===u?b.filter(e=>{var t,n;return e.index===(null!=(t=a.index)?t:null==(n=b.at(-1))?void 0:n.index)}):b.slice(x,x+5);if("error"===u&&!y.length)return{status:"unavailable",message:"No matching error in the latest check. Use mode results to list available error indexes."};const w="error"===u?2e3:300;return{status:g.status,check:"typescript",checkedAt:new Date(o.time).toISOString(),cached:"check"!==u,stale:o.revision!==i||h||o.snapshot!==f,project:qd(d,300),totalDiagnostics:null!=(l=g.totalDiagnostics)?l:v.length,retainedDiagnostics:v.length,matchingDiagnostics:b.length,truncated:Boolean(g.truncated),diagnostics:y.map(e=>({...e,...e.file?{file:qd(e.file,300)}:{},message:qd(e.message,w),messageTruncated:e.message.length>w})),..."error"!==u&&x+y.length<b.length?{nextOffset:x+y.length}:{},...g.message||h?{message:qd([g.message,h?"Could not scan project files for changes; this check is marked stale.":null].filter(Boolean).join(" "),500)}:{},...g.output?{output:qd(g.output,"error"===u?2e3:500),outputTruncated:g.output.length>("error"===u?2e3:500)}:{}}},{markStale(){i++}})}(()=>{var e;return null==(e=km())?void 0:e.web_location}),bm=function(e,t=pe(ne(),".needle","cli","ai-checkpoints"),n=(()=>{})){let o=0n,a=!1;function r(t){if(!(t&&t.chatId&&t.sessionId&&t.turnId&&t.project))throw new Error("Local file edit approval is required.");const n=e();if(!n||ae(n)!==ae(t.project))throw new Error("The approved local project has changed.");return{root:A(n),grant:t}}function s(e,t,n){if("string"!=typeof t||!t||t.includes("\0")||ce(t)||ue.isAbsolute(t)||de.isAbsolute(t)||t.split(/[\\/]/).some(e=>!e||"."===e||".."===e||e.includes(":")))throw new Error("Path must be a file inside the selected local project.");if(Td(e)||Td(t))throw new Error("Sensitive files cannot be accessed by local AI tools.");if(t.split(/[\\/]/).some(e=>/[ .]$/.test(e)))throw new Error("Invalid file path.");const o=ae(e,t);if(!o.startsWith(e+le))throw new Error("Path escapes the selected local project.");let i=e;const a=re(e,o).split(le);for(let e=0;e<a.length;e++){if(i=pe(i,a[e]),!T(i)){if(e!==a.length-1||!n)throw new Error("The file or its parent directory does not exist.");continue}const t=B(i);if(t.isSymbolicLink()||t.nlink>1)throw new Error("Symbolic links and hard links cannot be edited.");if(e<a.length-1&&!t.isDirectory())throw new Error("Parent path is not a directory.");if(e===a.length-1&&!t.isFile())throw new Error("Target is not a regular file.")}return o}function c(e,t){const n=`${e}.needle-ai-${i()}.tmp`;try{H(n,t,{flag:"wx",mode:384}),O(n,e)}finally{T(n)&&W(n)}}function l(){return T(t)?q(t).filter(e=>e.endsWith(".json")).reduce((e,n)=>e+C(pe(t,n)).size,0):0}function p(e){if(!a){if(T(t))for(const e of q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e))){const n=JSON.parse(M(pe(t,e),"utf8"));if(n.order&&/^\d+$/.test(n.order)){const e=BigInt(n.order);e>o&&(o=e)}}a=!0}const n=1000000n*BigInt(Date.now());o=n>o?n:o+1n,e.order=o.toString();const r=JSON.stringify(e);if(l()+Buffer.byteLength(r)>Md)throw new Error("Checkpoint storage is full; no file was changed.");I(t,{recursive:!0,mode:448});const s=i(),c=pe(t,`${s}.json`);return H(c,r,{flag:"wx",mode:384}),{id:s,file:c}}function u(e,t){if(e.byteLength>Bd)throw new Error("File exceeds the 1 MiB edit limit.");if(!t||!/^[a-f0-9]{64}$/.test(t))throw new Error("Expected file SHA-256 hash is required before changing a file.");if(Wd(e)!==t)throw new Error("The supplied expectedSha256 does not match this file. The file may have changed, or the hash may be incorrect. Run local_files_stat again and use its sha256 value.")}function d(e,t){try{const n=t=>{const n=s(e,t,!0);return T(n)?M(n):null},o=n(t.path),i=null===t.before?null:Wd(Buffer.from(t.before,"base64"));if("rename"===t.operation){if(!t.newPath)return"conflicted";const e=n(t.newPath);if(null===o&&e&&Wd(e)===t.afterSha256)return"applied";if(null===e&&o&&Wd(o)===i)return"undone"}else if("delete"===t.operation){if(null===o)return"applied";if(o&&Wd(o)===i)return"undone"}else{if(o&&Wd(o)===t.afterSha256)return"applied";if(null===o&&null===t.before||o&&Wd(o)===i)return"undone"}return"conflicted"}catch{return"conflicted"}}return{list(e){const{root:n,grant:o}=r(e);if(!T(t))return{changes:[],total:0};const i=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({...JSON.parse(M(pe(t,e),"utf8")),checkpointId:e.slice(0,-5)})).filter(e=>e.project===n&&e.chatId===o.chatId).sort((e,t)=>e.order&&t.order?BigInt(t.order)>BigInt(e.order)?1:BigInt(t.order)<BigInt(e.order)?-1:0:t.createdAt.localeCompare(e.createdAt));return{changes:i.slice(0,100).map(({path:e,checkpointId:t,turnId:o,createdAt:i,operation:a,newPath:r,...s})=>({path:e,checkpointId:t,turnId:o,createdAt:i,operation:null!=a?a:"write",...r?{newPath:r}:{},state:d(n,{...s,path:e,turnId:o,createdAt:i,operation:a,newPath:r})})),total:i.length}},stat(t){const n=e();if(!n)throw new Error("No connected local web project.");const o=A(n),i=s(o,t,!0);if(!T(i))return{path:t,exists:!1};const a=C(i).size;if(a>Bd)throw new Error("File exceeds the 1 MiB edit limit.");const r=Ad(o,t,{maxBytes:Bd});return Cd(r),{path:t,exists:!0,sha256:Wd(r),size:a}},write(e,t){var o;const{root:i,grant:a}=r(t);if(!e||"string"!=typeof e.content)throw new Error("Text content is required.");const l=Buffer.from(e.content,"utf8");if(l.byteLength>Bd||e.content.includes("\0"))throw new Error("Text file exceeds the 1 MiB limit or contains NUL.");const d=s(i,e.path,!0===e.create),m=T(d);if(!0===e.create&&m)throw new Error("File already exists.");if(!0!==e.create&&!m)throw new Error("File does not exist; use create.");const f=m?M(d):null;if(f&&u(f,e.expectedSha256),f&&Wd(f)===Wd(l))throw new Error("File already has this content; no edit was saved.");const h={project:i,path:re(i,d),chatId:a.chatId,sessionId:a.sessionId,turnId:a.turnId,before:null!=(o=null==f?void 0:f.toString("base64"))?o:null,after:l.toString("base64"),afterSha256:Wd(l),createdAt:(new Date).toISOString(),operation:"write"},g=p(h);try{if(s(i,e.path,!0===e.create),!0===e.create){if(T(d))throw new Error("The file was created since it was checked; check it again.")}else if(!T(d)||Wd(M(d))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");c(d,l)}catch(e){throw W(g.file),e}return n(),{path:e.path,checkpointId:g.id,turnId:a.turnId,afterSha256:h.afterSha256}},delete(e,t){const{root:o,grant:i}=r(t),a=s(o,null==e?void 0:e.path,!1),c=M(a);u(c,e.expectedSha256);const l=p({project:o,path:re(o,a),chatId:i.chatId,sessionId:i.sessionId,turnId:i.turnId,before:c.toString("base64"),after:null,afterSha256:null,createdAt:(new Date).toISOString(),operation:"delete"});try{if(s(o,e.path,!1),Wd(M(a))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");W(a)}catch(e){throw W(l.file),e}return n(),{path:e.path,checkpointId:l.id,turnId:i.turnId,afterSha256:null}},rename(e,t){const{root:o,grant:i}=r(t),a=s(o,null==e?void 0:e.path,!1),c=s(o,null==e?void 0:e.newPath,!0);if(T(c))throw new Error("Destination file already exists.");const l=M(a);u(l,e.expectedSha256);const d={project:o,path:re(o,a),newPath:re(o,c),chatId:i.chatId,sessionId:i.sessionId,turnId:i.turnId,before:l.toString("base64"),after:l.toString("base64"),afterSha256:Wd(l),createdAt:(new Date).toISOString(),operation:"rename"},m=p(d);try{if(s(o,e.path,!1),s(o,e.newPath,!0),T(c))throw new Error("Destination file already exists.");if(Wd(M(a))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");O(a,c)}catch(e){throw W(m.file),e}return n(),{path:e.newPath,checkpointId:m.id,turnId:i.turnId,afterSha256:d.afterSha256}},undo(e,o){const{root:i,grant:a}=r(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const p=pe(t,`${e.checkpointId}.json`),u=JSON.parse(M(p,"utf8"));if(u.project!==i||u.chatId!==a.chatId)throw new Error("Checkpoint belongs to another project or chat.");const d=s(i,u.path,!0);if("delete"===u.operation){var m;if(T(d))throw new Error("File changed after the AI edit; Undo would overwrite later work.");c(d,Buffer.from(null!=(m=u.before)?m:"","base64"))}else if("rename"===u.operation){if(!u.newPath)throw new Error("Invalid rename checkpoint.");const e=s(i,u.newPath,!1);if(T(d)||Wd(M(e))!==u.afterSha256)throw new Error("File changed after the AI edit; Undo would overwrite later work.");O(e,d)}else{const e=M(d);if(Wd(e)!==u.afterSha256)throw new Error("File changed after the AI edit; Undo would overwrite later work.");void 0===u.after&&(u.after=e.toString("base64"),function(e,t){const n=JSON.stringify(t);if(l()-C(e).size+Buffer.byteLength(n)>Md)throw new Error("Checkpoint storage is full; no file was changed.");c(e,Buffer.from(n))}(p,u)),null===u.before?W(d):c(d,Buffer.from(u.before,"base64"))}return n(),{path:u.path,checkpointId:e.checkpointId,undone:!0}},redo(e,o){const{root:i,grant:a}=r(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const l=pe(t,`${e.checkpointId}.json`),p=JSON.parse(M(l,"utf8"));if(p.project!==i||p.chatId!==a.chatId)throw new Error("Checkpoint belongs to another project or chat.");const u=s(i,p.path,!0);if("delete"===p.operation){var d;if(!T(u)||Wd(M(u))!==Wd(Buffer.from(null!=(d=p.before)?d:"","base64")))throw new Error("File changed after Undo; Redo would overwrite later work.");s(i,p.path,!1),W(u)}else if("rename"===p.operation){var m;if(!p.newPath)throw new Error("Invalid rename checkpoint.");const e=s(i,p.newPath,!0);if(!T(u)||T(e)||Wd(M(u))!==Wd(Buffer.from(null!=(m=p.before)?m:"","base64")))throw new Error("File changed after Undo; Redo would overwrite later work.");s(i,p.path,!1),s(i,p.newPath,!0),O(u,e)}else{if("string"!=typeof p.after||null===p.afterSha256)throw new Error("This checkpoint cannot be redone.");const e=Buffer.from(p.after,"base64");if(Wd(e)!==p.afterSha256)throw new Error("Checkpoint content is damaged; Redo was refused.");if(null===p.before?T(u):!T(u)||Wd(M(u))!==Wd(Buffer.from(p.before,"base64")))throw new Error("File changed after Undo; Redo would overwrite later work.");s(i,p.path,null===p.before),c(u,e)}return n(),{path:"rename"===p.operation?p.newPath:p.path,checkpointId:e.checkpointId,redone:!0}},undoTurn(e,n){const{root:o,grant:i}=r(n);if(!e||"string"!=typeof e.turnId||!e.turnId||e.turnId.length>255)throw new Error("Valid turn ID is required.");if(!T(t))throw new Error("No checkpoints found for this turn.");const a=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({checkpoint:JSON.parse(M(pe(t,e),"utf8")),checkpointId:e.slice(0,-5)})).filter(t=>t.checkpoint.project===o&&t.checkpoint.chatId===i.chatId&&t.checkpoint.turnId===e.turnId);if(!a.length)throw new Error("No checkpoints found for this turn.");if(a.some(e=>!e.checkpoint.order||!/^\d+$/.test(e.checkpoint.order)))throw new Error("Older checkpoints cannot be undone as a turn; use local_files_undo for each file.");a.sort((e,t)=>{const n=BigInt(e.checkpoint.order),o=BigInt(t.checkpoint.order);return n<o?1:n>o?-1:0});const c=new Map,l=e=>{const t=s(o,e,!0);return"win32"===process.platform?t.toLowerCase():t},p=e=>{var t;const n=s(o,e,!0),i=l(e);if(c.has(i))return null!=(t=c.get(i))?t:null;const a=T(n)?M(n):null;return c.set(i,a),a};for(const{checkpoint:e}of a){const t=null===e.before?null:Buffer.from(e.before,"base64");if("rename"===e.operation){if(!e.newPath)throw new Error("Invalid rename checkpoint.");const n=p(e.path),o=p(e.newPath);if(null!==n||null===o||Wd(o)!==e.afterSha256)throw new Error("File changed after this turn; no file was undone.");c.set(l(e.path),t),c.set(l(e.newPath),null)}else if("delete"===e.operation){if(null!==p(e.path))throw new Error("File changed after this turn; no file was undone.");c.set(l(e.path),t)}else{const n=p(e.path);if(null===n||Wd(n)!==e.afterSha256)throw new Error("File changed after this turn; no file was undone.");c.set(l(e.path),t)}}const u=[];try{for(const{checkpointId:e}of a)this.undo({checkpointId:e},n),u.push(e)}catch(e){const t=[];for(const e of[...u].reverse())try{this.redo({checkpointId:e},n)}catch(e){t.push(e)}if(t.length)throw new AggregateError([e,...t],"Turn Undo stopped and rollback failed; inspect the listed checkpoints before editing again.");throw new Error("Turn Undo stopped; earlier changes were rolled back.",{cause:e})}return{turnId:e.turnId,checkpointIds:u,undone:!0}}}}(()=>{var e;return null==(e=km())?void 0:e.web_location},void 0,()=>vm.markStale()),xm=function(e=pe(ne(),".needle","cli","ai-observations")){function t(t){if(!t||"string"!=typeof t.root||!t.root||"string"!=typeof t.path||!t.path||"string"!=typeof t.chatId||!t.chatId||t.path.includes("\0")||ce(t.path)||ue.isAbsolute(t.path)||de.isAbsolute(t.path))throw new Error("A project-relative file path and chat are required.");const n=A(t.root),o=ae(n,t.path);if(Od(n,t.path,{allowMissing:!0}),!o.startsWith(n+le))throw new Error("File path escapes the project.");const i=re(n,o).split(le).join("/");return{project:n,target:o,path:i,file:pe(e,Gd(n),Gd(t.chatId),`${Gd(i)}.json`)}}function n(e){if(!T(e.target))return null;if(C(Od(e.project,e.target).path).size>Hd)return{unsupported:"File exceeds the 1 MiB observation limit."};const t=Ad(e.project,e.target,{maxBytes:Hd}),n=t.toString("utf8");if(n.includes("\0")||!Buffer.from(n,"utf8").every((e,n)=>t[n]===e)||Buffer.byteLength(n,"utf8")!==t.length)return{unsupported:"Only UTF-8 text files can be observed."};const o=n.split("\n");return o.length>5e3?{unsupported:"File exceeds the 5,000-line observation limit."}:{content:t,lines:Rd(t).split("\n"),hashes:o.map(Gd),fileSha256:Gd(t)}}function o(e){if(!T(e.file))return null;const t=JSON.parse(M(e.file,"utf8"));if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Stored file observation is damaged.");const n=t;if(1!==n.version||n.project!==e.project||n.path!==e.path||!Array.isArray(n.lineHashes)||!n.lineHashes.every(e=>"string"==typeof e&&/^[a-f0-9]{64}$/.test(e))||"string"!=typeof n.fileSha256||!/^[a-f0-9]{64}$/.test(n.fileSha256)||"string"!=typeof n.chatId||"string"!=typeof n.observedAt)throw new Error("Stored file observation is damaged.");return n}function a(t,n,o){if("unsupported"in n)return{status:"unsupported",reason:n.unsupported};const a={version:1,project:t.project,path:t.path,chatId:o,observedAt:(new Date).toISOString(),fileSha256:n.fileSha256,lineHashes:n.hashes};I(pe(e,Gd(t.project),Gd(o)),{recursive:!0,mode:448});const r=`${t.file}.${i()}.tmp`;try{H(r,JSON.stringify(a),{flag:"wx",mode:384}),O(r,t.file)}finally{T(r)&&W(r)}return{status:"saved",observedAt:a.observedAt,sha256:a.fileSha256}}return{observe(e){const i=t(e),r=n(i);if(!r)throw new Error("File does not exist.");if("unsupported"in r)return{status:"unsupported",reason:r.unsupported};const s=o(i);return s?{status:"existing",observedAt:s.observedAt,sha256:s.fileSha256}:a(i,r,e.chatId)},snapshot(e){const o=t(e),i=n(o);if(!i)throw new Error("File does not exist.");return a(o,i,e.chatId)},diff(e){const i=t(e),a=o(i);if(!a)return{status:"no_baseline",path:i.path};const r=n(i);if(!r)return{status:"deleted",path:i.path,observedAt:a.observedAt};if("unsupported"in r)return{status:"unsupported",path:i.path,reason:r.unsupported};if(a.fileSha256===r.fileSha256)return{status:"unchanged",path:i.path,observedAt:a.observedAt,sha256:r.fileSha256};const s=function(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let o=e.length,i=t.length;for(;o>n&&i>n&&e[o-1]===t[i-1];)o--,i--;if(n===o&&n===i)return[];const a=new Map;for(let t=n;t<o;t++){const n=a.get(e[t]);n?n.count++:a.set(e[t],{index:t,count:1})}const r=new Map;for(let e=n;e<i;e++){var s;r.set(t[e],(null!=(s=r.get(t[e]))?s:0)+1)}const c=[];for(let e=n;e<i;e++){const n=a.get(t[e]);1===(null==n?void 0:n.count)&&1===r.get(t[e])&&c.push({old:n.index,current:e})}const l=[],p=[];for(let e=0;e<c.length;e++){let t=0,n=l.length;for(;t<n;){const o=t+n>>1;c[l[o]].old<c[e].old?t=o+1:n=o}p[e]=t?l[t-1]:-1,l[t]=e}const u=[];for(let e=l.length?l[l.length-1]:-1;e>=0;e=p[e])u.push(c[e]);u.reverse();const d=[];let m=n,f=n;for(const n of[...u,{old:o,current:i}]){let o=n.old,i=n.current;for(;m<o&&f<i&&e[m]===t[f];)m++,f++;for(;o>m&&i>f&&e[o-1]===t[i-1];)o--,i--;m===o&&f===i||d.push({oldStart:m,oldEnd:o,newStart:f,newEnd:i}),m=n.old+1,f=n.current+1}return d}(a.lineHashes,r.hashes);let c=80;const l=s.slice(0,20).map(e=>{const t=Math.min(e.newEnd-e.newStart,c);return c-=t,{before:{start:e.oldStart+1,count:e.oldEnd-e.oldStart},after:{start:e.newStart+1,count:e.newEnd-e.newStart},lines:r.lines.slice(e.newStart,e.newStart+t).map(e=>e.slice(0,300)),omittedLines:e.newEnd-e.newStart-t}});return{status:"changed",path:i.path,observedAt:a.observedAt,beforeSha256:a.fileSha256,afterSha256:r.fileSha256,beforeLineCount:a.lineHashes.length,afterLineCount:r.hashes.length,hunks:l,totalHunks:s.length,truncated:s.length>l.length,detail:s.length?void 0:"File bytes changed without a text-line change (for example line endings)."}}}}(),ym=function(e,t=x){return async function(n){const o=e(),i="web"===n.project?null==o?void 0:o.web_location:"editor"===n.project?null==o?void 0:o.project_location:null;if(!i)throw new Error("The selected local project is unavailable.");if("string"!=typeof n.path||!n.path.trim()||ce(n.path)||n.path.includes("\0"))throw new Error("Use a nonempty project-relative path.");const a=A.native(i),r=ae(a,n.path),s=re(a,r);if(".."===s||s.startsWith(`..${le}`)||ce(s))throw new Error("File path is outside the selected project.");const c=A.native(r),l=re(a,c);if(".."===l||l.startsWith(`..${le}`)||ce(l))throw new Error("File path is outside the selected project.");const p=C(c);if(!p.isFile()&&!p.isDirectory())throw new Error("The selected path is not a file or directory.");if(Jd.has(me(c).toLowerCase()))throw new Error("Opening executable file types is not supported.");return await t(c),{opened:!0,project:n.project,path:re(a,c)||"."}}}(km),wm=function(e){const{getProject:t,getHome:n=ne,run:o=dm,commandsEnabled:a=(()=>!em()),onFailure:r,onCreated:s,onApprovedProject:c,now:l=Date.now,getProcessIdentity:p=im}=e,u=function(e=pe(ne(),".needle","cli","ai-jobs"),t=Date.now){const n=t=>{if(!om.test(t))throw new Error("Invalid project job ID.");return pe(e,`${t}.json`)};return{runtimeFile:t=>(n(t),pe(e,`${t}.runtime.json`)),runtime(e){const t=this.runtimeFile(e);if(!T(t))return;const n=JSON.parse(M(t,"utf8"));if(!n||"object"!=typeof n||Array.isArray(n))throw new Error("Invalid local dev runtime state.");const o=n;if(!["running","completed","failed","canceled"].includes(String(o.status))||void 0!==o.url&&"string"!=typeof o.url||void 0!==o.exitCode&&!Number.isSafeInteger(o.exitCode)||void 0!==o.error&&"string"!=typeof o.error)throw new Error("Invalid local dev runtime state.");return o},save(t){const o=n(t.jobId);I(e,{recursive:!0,mode:448});const a=pe(e,`${t.jobId}.${i()}.tmp`);try{H(a,JSON.stringify(t),{flag:"wx",mode:384}),O(a,o)}finally{T(a)&&W(a)}},get(e){const o=n(e);if(!T(o))return;const i=JSON.parse(M(o,"utf8"));if(!i||"object"!=typeof i||Array.isArray(i))throw new Error("Invalid stored project job.");const a=i;if(a.jobId!==e||"string"!=typeof a.chatId||"string"!=typeof a.operation||void 0!==a.project&&"string"!=typeof a.project||void 0!==a.workingDirectory&&"string"!=typeof a.workingDirectory||void 0!==a.startedAt&&!Number.isFinite(a.startedAt)||void 0!==a.pid&&(!Number.isSafeInteger(a.pid)||Number(a.pid)<1)||void 0!==a.processIdentity&&"string"!=typeof a.processIdentity||!Number.isFinite(a.createdAt)||!Number.isFinite(a.updatedAt)||"string"!=typeof a.output||a.output.length>8e3||!["running","completed","failed","canceled"].includes(String(a.status)))throw new Error("Invalid stored project job.");const r=a;if(!("running"!==r.status&&t()-r.updatedAt>1728e5))return r;{W(o);const t=this.runtimeFile(e);T(t)&&W(t)}},list(){return T(e)?q(e).filter(e=>om.test(e.slice(0,-5))&&e.endsWith(".json")).map(e=>{try{return this.get(e.slice(0,-5))}catch(t){return void console.warn(`Could not read local project job ${e}: ${t instanceof Error?t.message:String(t)}`)}}).filter(e=>!!e):[]},remove(e){const t=n(e);T(t)&&W(t);const o=this.runtimeFile(e);T(o)&&W(o)}}}(pe(n(),".needle","cli","ai-jobs"),l),d=new Map,m=new Map;function f(e){const{controller:t,...n}=e;u.save(n)}function h(e){if("failed"!==e.status||!r)return;const{controller:t,...n}=e;try{r(n)}catch(e){console.error(`Could not record local project job failure: ${e instanceof Error?e.message:String(e)}`)}}function g(){for(const[e,t]of d)l()-t.createdAt>3e5&&d.delete(e);for(const[e,t]of m)"running"!==t.status&&l()-t.updatedAt>36e5&&m.delete(e)}function v(e){const o=pm(e.request,t(),n());if(JSON.stringify({...o,request:null})!==JSON.stringify({...e,request:null,planId:void 0,chatId:void 0,createdAt:void 0}))throw new Error("The project command or its inputs changed since approval. Plan it again.")}function b(e){if("running"!==e.status)return e;const t="dev"===e.operation?u.runtime(e.jobId):void 0;return null!=t&&t.url&&(e.url=t.url),t&&"running"!==t.status?(e.status=t.status,e.exitCode=t.exitCode,t.error&&(e.output=Ed(t.error).slice(-8e3))):"dev"===e.operation&&e.pid&&e.processIdentity&&p(e.pid)===e.processIdentity||(e.status="failed",e.output=`${e.output}\nThe CLI restarted and the original project process is no longer running or cannot be verified.`.trim().slice(-8e3)),"running"!==e.status&&(e.updatedAt=l(),u.save(e)),e}function x(e){if(e)return[...m.values()].find(t=>"dev"===t.operation&&t.project===e&&"running"===t.status)||u.list().map(b).find(t=>"dev"===t.operation&&t.project===e&&"running"===t.status)}function y(){for(const e of u.list())b(e)}y();const w=setInterval(y,36e5);return w.unref(),{plan(e,o){if(g(),!o)throw new Error("A Cloud chat is required to plan an AI project command.");const a={...pm(e,t(),n()),planId:i(),chatId:o,createdAt:l()},r="dev"===a.operation?x(a.project):void 0;if(r)throw new Error(`A dev server for this project is already running (job ID ${r.jobId}). Check its status or cancel it before starting another.`);return d.set(a.planId,a),a},getPlan(e,t){g();const n=d.get(e);if(!n||n.chatId!==t)throw new Error("This project command plan does not belong to this chat or expired.");return v(n),n},async start(e,t){g();const n=d.get(e);if(!n)throw new Error("This project command plan expired or was already used.");if(!t||t.chatId!==n.chatId||t.planId!==e)throw new Error("Exact Cloud approval is required for this project command.");if(!a())throw new Error("AI project commands are disabled in local Needle CLI settings.");v(n);const r="dev"===n.operation?x(n.project):void 0;if(r)throw new Error(`A dev server for this project is already running (job ID ${r.jobId}). Check its status or cancel it before starting another.`);n.customProject&&n.project&&(null==c||c(n.project)),d.delete(e);const p={jobId:i(),chatId:n.chatId,operation:n.operation,project:n.project||n.destination,workingDirectory:n.project||se(n.destination),startedAt:l(),createdAt:l(),updatedAt:l(),status:"running",output:"",controller:new AbortController};return m.set(p.jobId,p),f(p),"dev"===n.operation&&(n.runtimeFile=u.runtimeFile(p.jobId)),Promise.resolve().then(()=>o(n,p.controller.signal,e=>{"running"===p.status&&(void 0!==e.output&&(p.output=Ed(e.output).slice(-8e3)),void 0!==e.url&&(p.url=e.url),void 0!==e.browserOpened&&(p.browserOpened=e.browserOpened),void 0!==e.browserError&&(p.browserError=e.browserError),"dev"===n.operation&&void 0!==e.pid&&e.processIdentity&&(p.pid=e.pid,p.processIdentity=e.processIdentity,void 0!==e.startedAt&&(p.startedAt=e.startedAt)),p.updatedAt=l(),f(p))})).then(e=>{p.exitCode=e.exitCode,p.output=Ed(String(e.output||"")).slice(-8e3),"canceled"!==p.status&&0===e.exitCode&&"create"===n.operation&&n.destination&&(null==s||s(n.destination)),"canceled"!==p.status&&(p.status=0===e.exitCode?"completed":"failed"),p.updatedAt=l(),f(p),h(p)}).catch(e=>{const t=p.controller.signal.aborted;p.controller.abort(),p.output=Ed(e instanceof Error?e.message:String(e)).slice(-8e3),p.status=t?"canceled":"failed",p.updatedAt=l(),f(p),h(p)}),{jobId:p.jobId,status:"running"}},status(e,t){g();const n=m.get(e)||u.get(e);if(!n||n.chatId!==t)throw new Error("This project job does not belong to this chat.");const o=m.get(e);if(o){const{controller:e,...t}=o;return t}return b(n)},async cancel(e,t){const n=m.get(e),o=n?void 0:u.get(e),i=n||o&&b(o);if(!i||i.chatId!==t)throw new Error("This project job does not belong to this chat.");if("running"!==i.status)return{jobId:e,canceled:!1};if(!n){if("dev"!==i.operation)throw new Error("Only supervised dev jobs can be stopped after a CLI restart.");H(`${u.runtimeFile(e)}.cancel`,"",{flag:"w",mode:384});const t=Date.now()+1e4;for(;Date.now()<t;){const t=b(i);if("running"!==t.status)return{jobId:e,canceled:"canceled"===t.status};await new Promise(e=>setTimeout(e,100))}throw new Error("The dev server stop was requested, but the supervisor did not confirm it within 10 seconds. Check the job status.")}return n.controller.abort(),i.status="canceled",i.updatedAt=l(),f(n),{jobId:e,canceled:!0}},dispose(){clearInterval(w);for(const e of m.values())"running"===e.status&&"dev"!==e.operation&&(e.controller.abort(),e.status="canceled",e.updatedAt=l(),f(e))}}}({getProject:()=>{var e;return null==(e=km())?void 0:e.web_location},onCreated:od,onApprovedProject:od,onFailure:e=>{var t;return yp(`[AI project] ${e.operation} failed job=${e.jobId} exit=${null!=(t=e.exitCode)?t:"error"} output=${e.output.replace(/\s+/g," ").slice(0,700)}`)}});function _m(e){if(null==e||!e.editGrant)throw new Error("Local file edit approval is required.");if(Qd())throw new Error("AI file edits are disabled in local Needle CLI settings.");return e.editGrant}function jm(e={}){gm({name:"local_files_editor_log_path",description:"Get the filepath to the editor log file on disk (this may be Unity or Blender)",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=Qu();if(n){const e=null==n?void 0:n.entries.sort((e,t)=>t.last_accessed-e.last_accessed)[0];if(null!=e&&e.log_location){const n=l(e.log_location).mtime;t.content.push({type:"text",text:`${e.log_location} (last modified: ${n.toLocaleString()})`})}else{let n="No recent project with known log location known.";e&&(n+=" Recent project is "+(null==e?void 0:e.project_location)),t.content.push({type:"text",text:n})}}return t},{source:"cli"},()=>{}),gm({name:"local_files_editor_project_path",description:"Get the filepath to the currently opened project in the editor (this may be Unity or Blender)",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=Qu();if(n){const e=null==n?void 0:n.entries.sort((e,t)=>t.last_accessed-e.last_accessed)[0];t.content.push(null!=e&&e.project_location?{type:"text",text:e.project_location}:{type:"text",text:"No recent project with known project location known."})}return t},{source:"cli"},()=>{}),gm({name:"local_files_editor_scene_path",description:"Get the filepath to the currently opened scene in the editor (Unity or Blender). Use this to find out which scene the user is working on.",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=Qu();if(n){const e=null==n?void 0:n.entries.sort((e,t)=>t.last_accessed-e.last_accessed)[0];t.content.push(null!=e&&e.scene_location?{type:"text",text:e.scene_location}:{type:"text",text:"No recent project with known scene location known."})}return t},{source:"cli"},()=>{}),gm({name:"local_files_web_project_path",description:"Get the filepath to the selected Needle Engine web project. Unity-generated web projects may validly live inside the Unity project's Library/Needle directory; do not treat that location alone as a misconfiguration. Use this directory as the web-project root.",inputSchema:{type:"object",properties:{},additionalProperties:!1,required:[]}},async e=>{const t={content:[]},n=km();return t.content.push(null!=n&&n.web_location?{type:"text",text:w(n.web_location)}:{type:"text",text:"No selected web project is known."}),t},{source:"cli"},()=>{}),gm({name:"local_files_diff",description:"Compare a local project text file with the first version observed by this chat. local_files_read saves a hash-only baseline on the first read; later reads do not replace it. Returns changed line ranges and bounded current lines, never removed text or who changed it. If no baseline exists, read the file first. Use mode=reset only after reviewing changes to start a new baseline. Works for web and editor project files.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path relative to the connected web or editor project, or an absolute path within it."},mode:{type:"string",enum:["compare","reset"],description:"Compare with the first observed version (default), or replace that version with the current file."}},required:["path"],additionalProperties:!1}},async(e,t)=>{var n;const o=$m(e.path);if(!o)throw new Error("Path is outside the connected project.");const i={root:o.root,path:j(o.root,o.resolved),chatId:null!=(n=null==t?void 0:t.chatId)?n:"local-mcp"},a="reset"===e.mode?xm.snapshot(i):xm.diff(i);return{content:[{type:"text",text:JSON.stringify(a)}]}},{source:"cli"},()=>{}),gm({name:"local_files_open",description:'Open an existing file or directory in the connected local web or editor project using the operating system default app. Directories open in the file manager; use path="." for the project root. Use a project-relative path and select project="web" or "editor". This affects the user desktop. It does not read or edit files. Executable file types and paths outside the selected project are refused.',inputSchema:{type:"object",properties:{project:{type:"string",enum:["web","editor"]},path:{type:"string"}},required:["project","path"],additionalProperties:!1}},async e=>({content:[{type:"text",text:JSON.stringify(await ym(e))}]}),{source:"cli"},()=>{}),gm({name:"local_files_read",description:"Read a file from the user's local project on disk (editor project or web project). The path must be relative to the project root or an absolute path inside the project. Sensitive files, including .env variants and private keys, are refused. Recognizable secrets are redacted before filtering or selecting lines. UTF-8 files are limited to 8 MiB. Returns the file contents (or a portion if offset/limit are specified). Use 'filter' to search for specific terms within the file.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path (relative to project root, or absolute within the project)"},offset:{type:"number",description:"Line number to start reading from (1-based, default: 1). In filter mode: number of matches to skip."},limit:{type:"number",description:"Maximum number of lines to return (default: 200, max: 1000). In filter mode: max matches to return."},filter:{type:"string",description:'Regex to search for in the file (case-insensitive, e.g. "error|warning"). Falls back to a literal substring match if the pattern isn\'t valid regex. Returns matching lines with line numbers instead of sequential content.'}},additionalProperties:!1,required:["path"]}},async(e,t)=>{const n=$m(e.path);if(!n)return{content:[{type:"text",text:"Error: path is outside the project directory."}]};try{const i=l(n.resolved).mtime.toISOString(),a=Nd(n.root,n.resolved).text.split("\n");let r="";try{var o;const e=xm.observe({root:n.root,path:j(n.root,n.resolved),chatId:null!=(o=null==t?void 0:t.chatId)?o:"local-mcp"});r="unsupported"===e.status?`\nChange baseline unavailable: ${e.reason}`:`\nChange baseline: ${"saved"===e.status?"saved":"kept from first read"}. Use local_files_diff to compare later changes.`}catch(e){console.error("[MCP] Could not observe local file changes",e),r=`\nChange baseline unavailable: ${e instanceof Error?e.message:"unknown error"}`}if(e.filter){const t=mm(e.filter),o=[];for(let e=0;e<a.length;e++)t.test(a[e])&&o.push(`${e+1}: ${a[e]}`);const s=o.length,c=Math.max(0,e.offset||0),l=Math.min(Math.max(e.limit||200,1),1e3),p=o.slice(c,c+l);return{content:[{type:"text",text:`File: ${n.resolved} (modified: ${i}) — filter="${e.filter}" (${t.mode}) → ${s} matches (showing ${c+1}-${c+p.length}) in ${a.length} lines`+r+"\n"+p.join("\n")}]}}const s=Math.max(1,e.offset||1),c=Math.min(e.limit||200,1e3),p=a.slice(s-1,s-1+c),u=p.map((e,t)=>`${s+t}: ${e}`).join("\n");return{content:[{type:"text",text:`File: ${n.resolved} (${a.length} lines, modified: ${i}, showing ${s}-${s+p.length-1})`+r+"\n"+u}]}}catch(e){return{content:[{type:"text",text:`Error reading file: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),gm({name:"local_files_grep",description:"Search for a pattern in the user's local project files on disk (editor project and web project) using grep. Searches sanitized UTF-8 text; sensitive files, links, hidden directories and node_modules are skipped. Reports omitted entries and search limits. Returns matching lines with file paths and line numbers. Note: runtime-only things (e.g. node-material shaders) have no source files — read those with the inspector_* tools instead.",inputSchema:{type:"object",properties:{pattern:{type:"string",description:"Search pattern (regular expression)"},glob:{type:"string",description:"File glob filter, e.g. '*.ts' or '*.cs' (optional)"},max_results:{type:"number",description:"Maximum number of matching lines to return (default: 50)"}},additionalProperties:!1,required:["pattern"]}},async e=>{const t=Em();if(0===t.length)return{content:[{type:"text",text:"Error: no active project found."}]};const n=Math.min(Math.max(Math.floor(e.max_results||50),1),200),o=t.map(t=>Ud(t,{pattern:e.pattern,glob:e.glob,maxResults:n})),i=o.flatMap(e=>e.lines),a=`\nOmitted ${o.reduce((e,t)=>e+t.omitted,0)} sensitive, unsupported or excluded entries.${o.some(e=>e.limited)?" Search stopped at the file, byte, depth or time limit.":""}`;return{content:[{type:"text",text:(i.length?`Found ${i.length} matches:\n`+i.slice(0,n).join("\n"):"No matches found.")+a}]}},{source:"cli"},()=>{}),gm({name:"local_files_list",description:"List files in the user's local project directories on disk matching an optional glob pattern. A list is shallow by default: files in subdirectories are NOT included. When checking whether a file exists anywhere below a folder, use recursive=true or provide its exact subdirectory in path. By default searches both the editor project (Unity/Blender) and the web project. Use the 'project' parameter to target a specific one. Results are prefixed with <web_project>/..., <unity>/..., or <blender>/... so you know which root each file belongs to. Do not conclude that a file is absent from a project based on a shallow listing.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Project-relative subdirectory to list (default: root). Absolute paths, including paths to a different project, are not accepted."},pattern:{type:"string",description:"Glob pattern to filter files, e.g. '*.ts' or '*.glb'. Supports multiple patterns separated by '|', e.g. '*.gltf|*.glb' (optional)"},recursive:{type:"boolean",description:"Set true to include files in all subdirectories. Default false lists only files directly in path; use true before claiming a nested file is absent."},project:{type:"string",enum:["web","editor"],description:"Which project root to search: 'web' for the Needle Engine web project (use this for exported assets, source files, node_modules), 'editor' for the Unity/Blender project. Omit to search both."}},additionalProperties:!1,required:[]}},async e=>{if(void 0!==e.path&&("string"!=typeof e.path||k(e.path)))return{content:[{type:"text",text:"Error: local_files_list requires a project-relative path. It cannot list an absolute path outside the connected project."}]};const t=km();if(!t)return{content:[{type:"text",text:"Error: no active project found."}]};const n="blender"===t.editor?"<blender>":"unity"===t.editor?"<unity>":"<editor_project>",o=[];if(e.project&&"editor"!==e.project||!t.project_location||o.push({root:w(t.project_location),label:n}),e.project&&"web"!==e.project||!t.web_location||o.push({root:w(t.web_location),label:"<web_project>"}),0===o.length)return{content:[{type:"text",text:"Error: no active project found."}]};const i=[],a=[];for(const{root:t,label:n}of o){const o=Sm(e.path||".",t);if(o)try{var r;e.recursive||a.push(...u(o,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(".")&&"node_modules"!==e.name).map(e=>`${n}/${j(t,_(o,e.name))}`));const s=Im(o,t,null!=(r=e.recursive)&&r,e.pattern,0);i.push(...s.map(e=>({file:e,root:t,label:n})))}catch(e){throw new Error(`Could not list project files: ${e instanceof Error?e.message:String(e)}`)}}const s=a.length>0?`\nShallow listing: subdirectories were not searched (${a.slice(0,12).join(", ")}${a.length>12?", ...":""}). To search nested files, call local_files_list with recursive=true or set path to the subdirectory.`:"";if(0===i.length)return{content:[{type:"text",text:`No files found directly in the selected path.${o.length>0?`\nSearched in:\n${o.map(e=>`${e.label} → ${e.root}`).join("\n")}`:"\nNo project directories available to search."}${s}`}]};const c=i.slice(0,500).map(e=>`${e.label}/${j(e.root,e.file)}`);return{content:[{type:"text",text:`Found ${i.length} files${i.length>500?" (showing first 500)":""}:\n`+c.join("\n")+s}]}},{source:"cli"},()=>{}),gm({name:"local_files_read_editor_log",description:"Read or search the Unity or Blender editor log file. By default reads the last N lines. Use the 'filter' parameter to search for specific terms (e.g. error messages, warnings, component names) across the entire log.",inputSchema:{type:"object",properties:{lines:{type:"number",description:"Number of lines to read from the end of the log (default: 100, max: 500). Ignored when filter is set."},filter:{type:"string",description:'Regex to search for in the log (case-insensitive, e.g. "error|exception|warning"). Falls back to a literal substring match if the pattern isn\'t valid regex. Returns all matching lines from the entire log instead of just the tail.'},offset:{type:"number",description:"Number of matching results to skip from the start (default: 0). Only used with filter."},limit:{type:"number",description:"Maximum number of matching results to return (default: 200, max: 500). Only used with filter."}},additionalProperties:!1,required:[]}},async e=>{const t=km();var n;if(null==t||!t.log_location)return wp(`read_editor_log: no editor log file known (project: ${null!=(n=null==t?void 0:t.project_location)?n:"none"})`),{content:[{type:"text",text:"Error: no editor log file known. Is a Unity or Blender project open?"}]};try{if(!t.log_location.toLowerCase().endsWith(".log"))throw new Error("Only the connected editor log can be read.");const n=Nd(se(t.log_location),fe(t.log_location),{maxBytes:67108864,allowPrivateKeys:!0}).text.split("\n");let o,i;if(e.filter){const t=mm(e.filter);o=[];for(let e=0;e<n.length;e++)t.test(n[e])&&o.push(`L${e+1}: ${n[e]}`);const a=o.length,r=Math.max(0,e.offset||0),s=Math.min(Math.max(e.limit||200,1),500);o=o.slice(r,r+s),i=`filter="${e.filter}" (${t.mode}) → ${a} matches (showing ${r+1}-${r+o.length}) in ${n.length} total lines`}else{const t=Math.min(Math.max(e.lines||100,1),500);o=n.slice(-t),i=`last ${t} of ${n.length} lines`}const a="unity"===t.editor?function(e){const t=[],n=new Map;let o=!1,i=0;for(const a of e){if(/^\s+at\s/.test(a)||/^\s*(UnityEngine\.|System\.|Unity\.)/.test(a)||/^\s+\w+[\w.<>]+\s*\(/.test(a)){o||(o=!0,i=0),i++,i<=3?t.push(a):4===i&&t.push(" ... (stack trace truncated)");continue}if(o=!1,i=0,!a.trim())continue;const e=n.get(a)||0;if(n.set(a,e+1),0===e)t.push(a);else if(1===e)t.push(` [repeated ${e+1}x] ${a}`);else{const n=t.length-1;n>=0&&t[n].startsWith(" [repeated")&&(t[n]=` [repeated ${e+1}x] ${a}`)}}return t}(o):o,r=5e4;let s=a.join("\n"),c="";if(s.length>r){s=s.substring(s.length-r);const e=s.indexOf("\n");e>0&&(s=s.substring(e+1)),c=" (output truncated to last ~50KB)"}return{content:[{type:"text",text:`Editor log: ${t.log_location} (${i}, ${a.length} after processing, editor: ${t.editor})${c}:\n`+s}]}}catch(e){return{content:[{type:"text",text:`Error reading log: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),gm({name:"local_files_read_gltf",description:"Read and summarize a glTF or GLB file from the user's local project on disk. Without a query, returns a structured summary including nodes, meshes, materials, animations, extensions, and compression/optimization hints. Use 'query' to drill into specific parts using JSON pointer paths. Use '*' as a wildcard for array indices or object keys. For GLB files, extracts the JSON chunk and skips binary data.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path to a .gltf or .glb file (relative to project root, or absolute path)"},query:{type:"string",description:"JSON pointer path to extract a specific part of the glTF, e.g. '/nodes/0', '/materials', '/extensions/NEEDLE_progressive', '/materials/*/extensions'. Use '*' as a wildcard for array indices or object keys."}},additionalProperties:!1,required:["path"]}},async e=>{let t=$m(e.path);if(!t)return{content:[{type:"text",text:"Error: path is outside the project directory."}]};if(!c(t.resolved))return{content:[{type:"text",text:`Error: file not found: ${t.resolved}`}]};try{const n=function(e,t){const n=e.toLowerCase();if(n.endsWith(".gltf")){const n=Nd(t,e).text;return JSON.parse(n)}if(n.endsWith(".glb")){const n=Ad(t,e,{maxBytes:20,range:{offset:0,length:20}});if(n.length<20)return null;if(1179937895!==n.readUInt32LE(0))return null;const o=n.readUInt32LE(12);if(1313821514!==n.readUInt32LE(16))return null;const i=Ad(t,e,{maxBytes:67108864,range:{offset:20,length:o}}).toString("utf-8"),a=jd(JSON.parse(i));if(!a||"object"!=typeof a||Array.isArray(a))throw new Error("glTF JSON must be an object.");return a}return null}(t.resolved,t.root);if(!n)return{content:[{type:"text",text:"Error: could not parse glTF/GLB file."}]};const o=5e4;if(e.query){const i=Tm(n,e.query.replace(/^\//,"").split("/"));if(void 0===i)return{content:[{type:"text",text:`No data found at pointer: ${e.query}`}]};let a=JSON.stringify(i),r=!1;return a.length>o&&(a=a.substring(0,o),r=!0),{content:[{type:"text",text:`${e.query} in ${t.resolved}`+(r?` (truncated to ${o} chars)`:"")+"\n"+a}]}}let i=function(e,t){var n,o,i,a,r,s,c,l,p,u,d,m,f;const h=[`glTF: ${t}`];if(e.asset){const t=[];e.asset.version&&t.push(`v${e.asset.version}`),e.asset.generator&&t.push(e.asset.generator),h.push(`Asset: ${t.join(", ")}`)}if(null!=(n=e.extensionsUsed)&&n.length&&h.push(`Extensions used: ${e.extensionsUsed.join(", ")}`),null!=(o=e.extensionsRequired)&&o.length&&h.push(`Extensions required: ${e.extensionsRequired.join(", ")}`),null!=(i=e.scenes)&&i.length&&h.push(`Scenes: ${e.scenes.length}${void 0!==e.scene?` (default: ${e.scene})`:""}`),null!=(a=e.nodes)&&a.length){var g,v,b;h.push(`\nNodes (${e.nodes.length}):`);const t=null!=(g=null==(v=e.scenes)||null==(v=v[null!=(b=e.scene)?b:0])?void 0:v.nodes)?g:[],n=new Set,o=(t,i)=>{if(i>6||n.has(t))return;n.add(t);const a=e.nodes[t];if(!a)return;const r=" ".repeat(i),s=[];if(void 0!==a.mesh&&s.push(`mesh:${a.mesh}`),void 0!==a.camera&&s.push(`camera:${a.camera}`),void 0!==a.skin&&s.push(`skin:${a.skin}`),a.extensions&&s.push(`ext:[${Object.keys(a.extensions).join(",")}]`),h.push(`${r}- ${a.name||`node_${t}`}${s.length?` (${s.join(", ")})`:""}`),a.children)for(const e of a.children)o(e,i+1)};for(const e of t)o(e,1);n.size<e.nodes.length&&n.size>0&&h.push(` ... and ${e.nodes.length-n.size} more nodes`)}if(null!=(r=e.meshes)&&r.length){h.push(`\nMeshes (${e.meshes.length}):`);for(const t of e.meshes.slice(0,30)){var x,y;const e=null!=(x=null==(y=t.primitives)?void 0:y.length)?x:0;h.push(` - ${t.name||"(unnamed)"} (${e} primitive${1!==e?"s":""})`)}e.meshes.length>30&&h.push(` ... and ${e.meshes.length-30} more`)}if(null!=(s=e.materials)&&s.length){h.push(`\nMaterials (${e.materials.length}):`);for(const t of e.materials.slice(0,30)){const e=t.name||"(unnamed)",n=[];t.pbrMetallicRoughness&&n.push("PBR"),t.alphaMode&&"OPAQUE"!==t.alphaMode&&n.push(t.alphaMode),t.doubleSided&&n.push("doubleSided"),t.extensions&&n.push(`ext:[${Object.keys(t.extensions).join(",")}]`),h.push(` - ${e}${n.length?` (${n.join(", ")})`:""}`)}e.materials.length>30&&h.push(` ... and ${e.materials.length-30} more`)}if(null!=(c=e.textures)&&c.length&&h.push(`Textures: ${e.textures.length}`),null!=(l=e.images)&&l.length&&h.push(`Images: ${e.images.length}`),null!=(p=e.animations)&&p.length){h.push(`\nAnimations (${e.animations.length}):`);for(const t of e.animations.slice(0,20)){var w,_;const e=null!=(w=null==(_=t.channels)?void 0:_.length)?w:0;h.push(` - ${t.name||"(unnamed)"} (${e} channel${1!==e?"s":""})`)}e.animations.length>20&&h.push(` ... and ${e.animations.length-20} more`)}if(null!=(u=e.skins)&&u.length){h.push(`\nSkins (${e.skins.length}):`);for(const t of e.skins.slice(0,10)){var j,k;h.push(` - ${t.name||"(unnamed)"} (${null!=(j=null==(k=t.joints)?void 0:k.length)?j:0} joints)`)}}if(null!=(d=e.cameras)&&d.length){h.push(`\nCameras (${e.cameras.length}):`);for(const t of e.cameras)h.push(` - ${t.name||"(unnamed)"} (${t.type})`)}if(null!=(m=e.buffers)&&m.length){const t=e.buffers.reduce((e,t)=>e+(t.byteLength||0),0);h.push(`\nBuffers: ${e.buffers.length} (${(t/1024/1024).toFixed(1)} MB total)`)}return null!=(f=e.accessors)&&f.length&&h.push(`Accessors: ${e.accessors.length}`),h.join("\n")}(n,t.resolved);return i.length>o&&(i=i.substring(0,o)+"\n... (truncated)"),{content:[{type:"text",text:i}]}}catch(e){return{content:[{type:"text",text:`Error reading glTF: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),function(){const e=e=>({content:[{type:"text",text:JSON.stringify(e)}]});gm({name:"local_files_resolve_url",description:"Find the working directory of the process serving a localhost URL, including a server started by another app or by the user. Returns the listening PID and working directory, or an explicit reason when unavailable. The URL path is not assumed to be a file path. Works only for a server running on the same machine as the Needle CLI.",inputSchema:{type:"object",properties:{url:{type:"string",description:"HTTP localhost URL or loopback host:port, for example http://127.0.0.1:8765/preview.html."}},required:["url"],additionalProperties:!1}},async t=>e(await async function(e){const t=function(e){if("string"!=typeof e||!e.trim())throw new Error("A localhost URL or host:port is required.");const t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`http://${t}`);if("http:"!==n.protocol&&"https:"!==n.protocol)throw new Error("Only HTTP and HTTPS localhost URLs are supported.");const o=n.hostname.toLowerCase();if(!["localhost","127.0.0.1","[::1]"].includes(o))throw new Error("Only localhost or loopback IP addresses are supported.");const i=n.port?Number(n.port):"https:"===n.protocol?443:80;if(!Number.isInteger(i)||i<1||i>65535)throw new Error("A valid TCP port is required.");return{host:o,port:i,path:n.pathname+n.search}}(e);if("win32"===process.platform){const e=await async function(e,t){const n=hm.replace("__PORT__",String(e)).replace("__HOST__",t),o=Buffer.from(n,"utf16le").toString("base64"),{stdout:i}=await fm("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",o],{timeout:1e4,maxBuffer:1048576});return JSON.parse(i.trim())}(t.port,t.host);return{...t,...e}}if("linux"===process.platform||"darwin"===process.platform){const e="linux"===process.platform?await async function(e){const t=new Set;for(const o of["/proc/net/tcp","/proc/net/tcp6"]){let i;try{i=await K(o,"utf8")}catch(e){if("ENOENT"===e.code)continue;throw e}for(const o of i.split("\n").slice(1)){var n;const i=o.trim().split(/\s+/);i.length<10||Number.parseInt(null!=(n=i[1].split(":").at(-1))?n:"",16)===e&&"0A"===i[3]&&t.add(i[9])}}if(!t.size)return null;const o=await Y("/proc",{withFileTypes:!0});for(const e of o){if(!e.isDirectory()||!/^\d+$/.test(e.name))continue;let n;try{n=await Y(`/proc/${e.name}/fd`)}catch{continue}for(const o of n)try{const n=await V(`/proc/${e.name}/fd/${o}`),i=/^socket:\[(\d+)\]$/.exec(n);if(i&&t.has(i[1]))return Number(e.name)}catch{}}throw new Error("A process is listening, but its PID is not visible to this CLI.")}(t.port):await async function(e){try{const{stdout:t}=await fm("lsof",["-nP","-t",`-iTCP:${e}`,"-sTCP:LISTEN"],{timeout:5e3}),n=Number(t.trim().split(/\s+/)[0]);return Number.isInteger(n)&&n>0?n:null}catch(e){if(1===e.code)return null;throw e}}(t.port);if(null===e)return{...t,status:"not-listening"};try{const n="linux"===process.platform?await V(`/proc/${e}/cwd`):await async function(e){const{stdout:t}=await fm("lsof",["-a","-p",String(e),"-d","cwd","-Fn"],{timeout:5e3}),n=t.split(/\r?\n/).find(e=>e.startsWith("n"));if(!n)throw new Error("The process working directory is not available.");return n.slice(1)}(e);return{...t,status:"found",pid:e,workingDirectory:n}}catch(n){return{...t,status:"unavailable",pid:e,reason:n instanceof Error?n.message:String(n)}}}return{...t,status:"unavailable",reason:`Unsupported platform: ${process.platform}`}}(null==t?void 0:t.url)),{source:"cli"},()=>{}),gm({name:"local_project_list",description:"List web projects registered with the local Needle CLI, including projects created by AI after a successful create job. Each path may be selected with local_project_select. File tools access only the currently selected project.",inputSchema:{type:"object",properties:{},required:[],additionalProperties:!1}},async()=>e(Qu().entries.filter(e=>e.web_location).map(e=>({path:e.web_location,selected:e===km(),editor:e.editor}))),{source:"cli"},()=>{}),gm({name:"local_project_select",description:"Select a registered local web project by its exact path from local_project_list. Subsequent local_files_* tools use this project. Selecting a project does not approve edits; Cloud chat must obtain a separate file-edit grant for the selected project.",inputSchema:{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:!1}},async t=>e({selected:id(t.path).web_location}),{source:"cli"},()=>{}),gm({name:"local_project_action",description:"Prepare a local Needle project action without executing it. Operations: create (name, template, optional absolute parent or destination), install, add_package (packages, optional dev), build, dev (start the dev server and open its local URL in the default browser), deploy (target team ID required; optional name and relative build directory). For dev, hot reload may be disabled in vite.config.js/ts by hmr: false or Needle allowHotReload: false; if edits do not appear, inspect the config and use the normal file-edit approval to enable it if appropriate. For create, parent is an existing folder to create the named project INSIDE, even if the parent has spaces or parentheses; destination is the full path of the new project and must end with name. If the user provides an existing folder path, use parent and do not treat its basename as the project name. If only the name is missing, ask only for a name. For install/add_package/build/dev/deploy, omit project to use the selected web project, or pass an explicit absolute path to another local project; that target needs fresh Cloud approval. An approved action for another project registers and selects it for local file tools, even if the command fails. A successful create job also registers and selects its new project. Use local_project_list and local_project_select to return to another registered project. Never put a project path in directory; that is only the deploy build output. Cloud chat fills the current team if omitted. For a prepared action, pass planId alone to retrieve its exact command and project. Then call request_local_project_command with planId for approval. Local CLI settings can still disable execution.",inputSchema:{type:"object",properties:{operation:{type:"string",enum:["create","install","add_package","build","dev","deploy"]},name:{type:"string"},template:{type:"string",enum:am},parent:{type:"string",description:"Existing absolute folder in which to create the new project. Its name may contain spaces or parentheses; the new child folder uses name."},destination:{type:"string",description:"Full absolute path to the new project folder; its last segment must equal name. Use parent instead when the user supplies an existing containing folder."},project:{type:"string",description:"Absolute local project path. Use the path returned by a completed create job for a new project; omit for the connected web project. A different path requires fresh approval."},packages:{type:"array",items:{type:"string"}},dev:{type:"boolean"},directory:{type:"string"},team:{type:"string",description:"Target Needle Cloud team ID for deploy. Use the org_... identifier, which Cloud data may call orgId. In Cloud chat, omit this to use the current team."},planId:{type:"string"}},required:[],additionalProperties:!1}},async(t,n)=>{if(null==n||!n.chatId)throw new Error("A Cloud chat is required to plan an AI project command.");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Project command arguments must be an object.");return e(t.planId?wm.getPlan(t.planId,n.chatId):wm.plan(t,n.chatId))},{source:"cli"},()=>{}),gm({name:"local_project_start",description:"Internal Cloud approval handoff for a previously planned project command. A model tool call cannot grant approval.",inputSchema:{type:"object",properties:{planId:{type:"string"}},required:["planId"],additionalProperties:!1}},async(t,n)=>{if(!t||"string"!=typeof t.planId)throw new Error("A project plan ID is required.");if(null==n||!n.commandGrant||n.chatId!==n.commandGrant.chatId||t.planId!==n.commandGrant.planId)throw new Error("Exact Cloud approval is required for this project command.");if(em())throw new Error("AI project commands are disabled in local Needle CLI settings.");return e(await wm.start(t.planId,n.commandGrant))},{source:"cli"},()=>{}),gm({name:"local_project_status",description:"Read the status and bounded output of a local project command job in this chat. Poll this after local_project_start; the job may take several minutes.",inputSchema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"],additionalProperties:!1}},async(t,n)=>{if(!t||"string"!=typeof t.jobId)throw new Error("A project job ID is required.");if(null==n||!n.chatId)throw new Error("A Cloud chat is required to inspect this project job.");return e(wm.status(t.jobId,n.chatId))},{source:"cli"},()=>{}),gm({name:"local_project_cancel",description:"Cancel a running local project command job in this chat.",inputSchema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"],additionalProperties:!1}},async(t,n)=>{if(!t||"string"!=typeof t.jobId)throw new Error("A project job ID is required.");if(null==n||!n.chatId)throw new Error("A Cloud chat is required to cancel this project job.");return e(await wm.cancel(t.jobId,n.chatId))},{source:"cli"},()=>{})}(),gm(Wl.schema,async e=>{const t=await Wl.execute(e);return"error"in t?{content:[{type:"text",text:t.error}]}:{content:[{type:"text",text:t.content}]}},{source:"cli"},()=>{}),gm({name:"local_files_stat",description:'Check one exact relative path in the connected local web project and read its SHA-256 hash and size. This does not search by basename or recurse: exists=false only means that exact path was not found. First locate a nested file with local_files_list(path="src", recursive=true), then pass the full relative path such as src/scripts/MyComponent.ts. Use the returned hash as expectedSha256 before replacing or deleting that file.',inputSchema:{type:"object",properties:{path:{type:"string"}},required:["path"],additionalProperties:!1}},async e=>({content:[{type:"text",text:JSON.stringify(bm.stat(e.path))}]}),{source:"cli"},()=>{}),gm({name:"local_files_write",description:"Create or replace a UTF-8 text file in the approved local web project. For an existing file, first call local_files_stat and pass its SHA-256 hash as expectedSha256. Creating a new file requires create=true. Automatically saves an undo checkpoint. Requires user approval for this project and chat session. A successful write only confirms that bytes were saved; run local_files_check_project with mode=check afterward before saying TypeScript errors are fixed.",inputSchema:{type:"object",properties:{path:{type:"string"},content:{type:"string"},create:{type:"boolean"},expectedSha256:{type:"string"}},required:["path","content"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.write(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_delete",description:"Delete a file in the approved local web project. First call local_files_stat and pass its SHA-256 hash as expectedSha256. Saves an undo checkpoint and refuses changed files.",inputSchema:{type:"object",properties:{path:{type:"string"},expectedSha256:{type:"string"}},required:["path","expectedSha256"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.delete(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_rename",description:"Rename a file within the approved local web project. First call local_files_stat and pass its SHA-256 hash as expectedSha256. The destination must not exist. Saves an undo checkpoint.",inputSchema:{type:"object",properties:{path:{type:"string"},newPath:{type:"string"},expectedSha256:{type:"string"}},required:["path","newPath","expectedSha256"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.rename(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_undo",description:"Undo one saved AI file edit in the approved local web project. Refuses to overwrite changes made after the edit. The checkpoint remains available for Redo.",inputSchema:{type:"object",properties:{checkpointId:{type:"string"}},required:["checkpointId"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.undo(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_redo",description:"Reapply one previously undone AI file edit from its checkpoint. Refuses to overwrite changes made after Undo. Requires active file-edit approval.",inputSchema:{type:"object",properties:{checkpointId:{type:"string"}},required:["checkpointId"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.redo(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_undo_turn",description:"Undo all AI file edits from one turn in reverse order. Use a turnId from local_files_list_changes. Checks every file for conflicts before changing anything; refuses changed files. Older checkpoints without turn ordering must be undone individually.",inputSchema:{type:"object",properties:{turnId:{type:"string"}},required:["turnId"],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.undoTurn(e,_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_list_changes",description:"List recent undo checkpoints for this chat and connected local web project. Requires active user approval. Returns filenames and checkpoint IDs, not file contents.",inputSchema:{type:"object",properties:{},required:[],additionalProperties:!1}},async(e,t)=>({content:[{type:"text",text:JSON.stringify(bm.list(_m(t)))}]}),{source:"cli"},()=>{}),gm({name:"local_files_check_project",description:"Check the connected local web project for TypeScript errors without emitting files or applying fixes. Default mode check runs its installed compiler (10 second limit) and returns up to 5 short diagnostics. Use mode results with file/code filters and offset to browse the latest check without rerunning. Use mode error with an index for details; omit index for the last matching error. Results are timestamped snapshots, retained until another check or project change, or CLI exit. Local AI writes and changes to tracked local project files mark saved results stale; dependency files inside node_modules are excluded from the change scan. Retains at most 100 diagnostics. Reports current errors, not whether they predate edits. Not a linter or Unity/Blender compiler.",inputSchema:{type:"object",properties:{mode:{type:"string",enum:["check","results","error"],description:"Run a new check, browse cached results, or inspect one cached error."},file:{type:"string",maxLength:250,description:"Filter diagnostic filenames by case-insensitive substring; does not select a project or restrict compiler inputs."},code:{type:"string",maxLength:250,description:"Exact diagnostic code, e.g. TS2322."},offset:{type:"integer",minimum:0,description:"Offset within filtered results; 5 errors per page."},index:{type:"integer",minimum:0,description:"Diagnostic index from the latest check for mode error; defaults to the last matching error."}},additionalProperties:!1,required:[]}},async e=>{const t=await vm(e);return{content:[{type:"text",text:JSON.stringify(t)}],isError:"error"===t.status||"unavailable"===t.status}},{source:"cli"},()=>{}),null!=e&&e.logToolCount&&wp(`[MCP] registered ${ud.length} built-in tools: ${ud.map(e=>e.name).join(", ")}`)}function km(){return nd()}function Sm(e,t){const n=w(t,e),o=w(t),i=j(o,n);return k(i)||".."===i||i.startsWith(".."+S)?null:Od(o,n,{allowMissing:!0}).path}function Em(){const e=km();if(!e)return[];const t=[];return e.project_location&&t.push(w(e.project_location)),e.web_location&&t.push(w(e.web_location)),t}function $m(e){const t=Em();for(const n of t){const t=Sm(e,n);if(t&&c(t))return{resolved:t,root:n}}for(const n of t){const t=Sm(e,n);if(t)return{resolved:t,root:n}}const n=w(e);for(const e of t)if(n.startsWith(e+S)||n===e)return{resolved:n,root:e};return null}function Tm(e,t){if(0===t.length||null==e)return e;const[n,...o]=t;if("*"!==n)return Tm(e[/^\d+$/.test(n)?Number(n):n],o);if(Array.isArray(e)){const t=e.map(e=>Tm(e,o)).filter(e=>void 0!==e);return t.length>0?t:void 0}if("object"==typeof e){const t={};for(const n of Object.keys(e)){const i=Tm(e[n],o);void 0!==i&&(t[n]=i)}return Object.keys(t).length>0?t:void 0}}function Im(e,t,n,o,i){if(i>10)return[];const a=[],r=u(e,{withFileTypes:!0}),s="node_modules"===(e.split("/").pop()||e.split("\\").pop()||"");for(const c of r){if(s){if(".needle"!==c.name&&".vite"!==c.name)continue}else{if("Library"===c.name)continue;if(c.name.startsWith(".")||"node_modules"===c.name){if(!n)continue;if(c.name.startsWith("."))continue}}const r=_(e,c.name);if(!Td(j(t,r))&&!c.isSymbolicLink())if(Od(t,r),c.isDirectory())n&&a.push(...Im(r,t,!0,o,i+1));else{if(o&&!o.split("|").map(e=>(e=e.trim()).startsWith(".")&&!e.startsWith("*.")?"*"+e:e).filter(Boolean).some(e=>Ve(c.name,e,{nocase:!0})))continue;a.push(r)}}return a}process.once("exit",()=>wm.dispose());const Om="cli-installation-id",Am=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Cm=2e3,Rm=6e4,Nm=25e3,Pm=1e4,Um=i();let Lm=null,zm=null,Fm=null,Dm=null,qm=Cm,Bm=!1,Mm=!1;function Wm(){Lm||(Zd()?wp("Needle Cloud connection: skipped (remote_ai_tools disabled in settings)"):(Bm=!1,zm&&(clearTimeout(zm),zm=null),qm=Cm,Jm()))}function Hm(e){Bm=!0,Vm(),zm&&(clearTimeout(zm),zm=null),Lm?(wp(`Needle Cloud connection: closing (reason: ${null!=e?e:"shutdown"})`),Lm.close(1e3,null!=e?e:"shutdown"),Lm=null):e&&wp(`Needle Cloud connection: disconnect requested (reason: ${e}) — no active connection`)}function Gm(){if(!Lm||Lm.readyState!==Be.OPEN)return;try{jm()}catch(e){wp(`Needle Cloud connection: registerServerTools failed: ${e}`)}const e=ud.map(e=>e.name);var t;wp(`Needle Cloud connection: sending ${e.length} tools: ${e.join(", ")}`),Lm.send(JSON.stringify({type:"tools",tools:(t=ud,t.map(e=>{var t;return{name:e.name,description:e.description,inputSchema:e.inputSchema,capability:null!=(t=e.capability)?t:"local"}}))}))}async function Jm(){let e,t=await Uu();if(t||(t=function(){const e=Eu("accessToken");if(s.existsSync(e)){const t=s.readFileSync(e,"utf8");if(t){const e=JSON.parse(t),n=null==e?void 0:e["@https://cloud.needle.tools/api"];return null==n?void 0:n.token}}return null}(),t&&wp("Needle Cloud connection: using cached token (refresh failed)")),!t)return Mm||(wp("Needle Cloud connection: skipped (not logged in)"),Mm=!0),void Km(!0);Mm=!1;try{e=function(e=Kd()){I(e,{recursive:!0,mode:448});const t=pe(e,Om);try{H(t,i(),{flag:"wx",mode:384})}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"EEXIST"!==e.code)throw e}const n=M(t,"utf8").trim();if(!Am.test(n))throw new Error("Invalid local CLI installation ID.");return n}()}catch(e){return wp(`Needle Cloud connection: could not read local CLI installation identity: ${e instanceof Error?e.message:String(e)}`),void Km(!0)}const n="https://cloud.needle.tools/api".replace(/^http/,"ws")+"/v1/cli/ws?token="+encodeURIComponent(t)+"&instance="+encodeURIComponent(Um)+"&installation="+encodeURIComponent(e);wp("Needle Cloud connection: connecting...");const o=`needle-cloud/${cd()} Node/${process.versions.node}`;Lm=new Be(n,{headers:{"User-Agent":o,Origin:"cli://needle-cloud"}}),Lm.on("open",()=>{qm=Cm,wp("Needle Cloud connection: established"),Ym(),Gm(),Vm(),Fm=setInterval(()=>{Lm&&Lm.readyState===Be.OPEN&&(Lm.ping(),Dm=setTimeout(()=>{wp("Needle Cloud connection: pong timeout, terminating"),Lm&&Lm.terminate()},Pm))},Nm)}),Lm.on("pong",()=>{Dm&&(clearTimeout(Dm),Dm=null)}),Lm.on("message",e=>{try{const n=JSON.parse(e.toString());var t;"execute_tool"===n.type&&n.requestId&&n.toolName&&async function(e,t,n,o,i,a){wp(function(e,t,n){const o=Object.entries(t).slice(0,12).map(([e,t])=>`${e.slice(0,40)}:${"string"==typeof t?t.length+" chars":typeof t}`);return`Cloud tool request: ${e.slice(0,64)}(${o.join(", ")}) [${n.slice(0,64)}]`}(t,n,e));const r=Date.now();try{var s,c;"local_project_action"===t&&Ym();const l=await vd(t,n,{chatId:o,editGrant:i,commandGrant:a});"local_project_select"!==t&&"local_project_start"!==t&&"local_project_status"!==t||Ym(),wp(`Cloud tool result: ${t} → ${null!=(s=null==l||null==(c=l.content)?void 0:c.reduce((e,t)=>{var n;return e+((null==(n=t.text)?void 0:n.length)||0)},0))?s:0} chars in ${Date.now()-r}ms [${e}]`),Lm&&Lm.readyState===Be.OPEN&&Lm.send(JSON.stringify({type:"tool_result",requestId:e,result:l}))}catch(n){const o=n instanceof Error?n.message:String(n);wp(`Cloud tool error: ${t} → ${o} in ${Date.now()-r}ms [${e}]`),Lm&&Lm.readyState===Be.OPEN&&Lm.send(JSON.stringify({type:"tool_result",requestId:e,error:o}))}}(n.requestId,n.toolName,null!=(t=n.args)?t:{},n.chatId,n.editGrant,n.commandGrant)}catch{}}),Lm.on("close",(e,t)=>{const n=(null==t?void 0:t.toString())||"";wp(`Needle Cloud connection: closed (code=${e}${n?" "+n:""})`),Vm(),Lm=null,Bm||Km()}),Lm.on("error",e=>{wp(`Needle Cloud connection: error - ${e.message||"connection refused"} (is https://cloud.needle.tools/api reachable?)`)})}function Vm(){Fm&&(clearInterval(Fm),Fm=null),Dm&&(clearTimeout(Dm),Dm=null)}function Km(e=!1){Bm||zm||(e||wp(`Needle Cloud connection: reconnecting in ${qm/1e3}s`),zm=setTimeout(()=>{zm=null,Jm()},qm),qm=Math.min(2*qm,Rm))}function Ym(){Lm&&Lm.readyState===Be.OPEN&&Lm.send(JSON.stringify(function(){var e,t,n;const o=nd();return{type:"presence",editor:null!=(e=null==o?void 0:o.editor)?e:"unknown",project:null!=(t=null==o?void 0:o.project_location)?t:null,scene:null!=(n=null==o?void 0:o.scene_location)?n:null,web_project:null!=o&&o.web_location?ae(o.web_location):null,cli_version:cd()}}()))}const Zm=e=>{const t=qe();return t.use("/:action",async(t,n,o)=>{const{action:i}=t.params,a=Fu({navigate:e=>{n.redirect(e)}});switch(i){case"sign-in":e.invalid_login=!1,e.invalid_login_type=null,e.error=void 0,wp("Sign in..."),await a.clearAllTokens(),Ou();try{await a.signIn(`${Jp}/auth-callback`)}catch(e){const t=null==e?void 0:e.cause,o=`Sign-in failed: ${null!=t&&t.code?`${t.code}${t.address?` (${t.address}:${t.port})`:""}`:(null==e?void 0:e.message)||"unknown error"}`;return wp(o),console.error(o),n.status(502).send(o)}break;case"sign-out":{var r,s;const t=await Lu(),n=(null==t||null==(r=t.userInfo)?void 0:r.sub)||(null==t||null==(s=t.claims)?void 0:s.sub),o=null==t?void 0:t.accessToken;wp(`Sign out... (${n})`),n&&o&&await async function(e){return!e.accessToken||import("node-machine-id").then(async t=>{const n=await Ku();return Hu=n,await fetch("https://cloud.needle.tools/api"+ft.account.post_machine,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify({action:"logout",machine_id:n,machine_name:Yu()})}).catch(e=>{wp(`Failed to validate logout: ${e.message} - Make sure https://cloud.needle.tools/api is reachable`),console.error(`Failed to validate logout: ${e.message} - Make sure https://cloud.needle.tools/api is reachable`)}),!0})}({userId:n,accessToken:o}).catch(e=>{console.error(e),wp(`Failed to validate logout: ${e}`)}),e.invalid_login=!1,e.invalid_login_type=null,e.error=void 0,console.log("User signed out"+(n?`: ${n}`:"")),await a.signOut(gu()),Ou();break}case"auth-callback":if(t.url){const o=await a.handleSignInCallback(`${Jp}${t.originalUrl}`).catch(e=>({error:e}));if(Ou(),o&&"error"in o){wp(`Error during sign in: ${o.error}`);const e=o.error instanceof Error?o.error.message:String(o.error);n.redirect(Jp+"?cancelled&message="+encodeURIComponent(e))}else{var c,l,p,u;const t=await Lu();if(null!=t&&t.isAuthenticated){var d,m;e.invalid_login=!1,e.user_email=(null==(d=t.claims)?void 0:d.email)||(null==(m=t.userInfo)?void 0:m.email)||null,e.logged_in_machine_names=[...Gu(t)];const o=await Zu(t,{signout:!0});if(!o)return e.invalid_login=!0,e.invalid_login_type="too-many-logins",n.redirect(gu("too-many-logins"));if("object"==typeof o&&"error"in o)return e.invalid_login=!0,e.invalid_login_type="error",e.error=o.error,n.redirect(gu("error"));Ou()}console.log(`User logged in: ${(null==t||null==(c=t.userInfo)?void 0:c.sub)||(null==t||null==(l=t.claims)?void 0:l.sub)}`),wp(`User logged in: ${(null==t||null==(p=t.userInfo)?void 0:p.sub)||(null==t||null==(u=t.claims)?void 0:u.sub)}`),Wm(),n.redirect(Jp)}}break;default:o()}}),t};function Xm(e,t,n){return!!n||e===np||"string"==typeof t&&t===e}const Qm="2025-06-18";function ef(e){return{jsonrpc:"2.0",id:e,result:{protocolVersion:Qm,capabilities:{tools:{listChanged:!0}},serverInfo:tf}}}const tf={name:"Needle Cloud MCP",version:"1.0.0"};function nf(e){if(null!==e&&"object"==typeof e&&"name"in e&&"version"in e&&"string"==typeof e.name&&"string"==typeof e.version&&e.name.trim()&&e.version.trim())return{name:e.name,version:e.version}}function of(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let af=!1;const rf=qe(),sf=new Map,cf=new Map;let lf=0;function pf(){const e=[];for(const[t,{connectedAt:n,userAgent:o}]of cf)e.push({id:t,connectedAt:n,userAgent:o});return e}function uf(e,t,n,o){if((t.headers.accept||"").includes("text/event-stream")){var i,a;n.setHeader("Content-Type","text/event-stream"),n.setHeader("Cache-Control","no-cache"),n.setHeader("Connection","keep-alive"),n.setHeader("Access-Control-Allow-Origin","*"),n.setHeader("Access-Control-Expose-Headers","Mcp-Session-Id"),n.flushHeaders(),n.write(": connected\n\n");const r=t.headers["mcp-session-id"],s=null!=(i=null!=(a=null!=o?o:"string"==typeof r?sf.get(r):void 0)?a:t.headers["user-agent"])?i:"",c=()=>{clearInterval(l),cf.delete(e)&&(console.log(`[MCP] SSE client disconnected (ID: ${e}): ${s}`),wp(`MCP SSE client disconnected (ID: ${e}): ${s}`))},l=setInterval(()=>{try{n.write(": keepalive\n\n")}catch(t){console.error(`[MCP] SSE heartbeat failed (${e}):`,t),c(),n.destroy()}},15e3);return l.unref(),n.once("close",c),n.once("error",t=>{console.error(`[MCP] SSE stream failed (${e}):`,t),c()}),cf.set(e,{id:e,client:n,connectedAt:Date.now(),userAgent:s,dispose:c}),console.log(`[MCP] SSE client connected (ID: ${e}) ${s}. Total clients: ${cf.size}`),wp(`MCP SSE client connected (ID: ${e}) ${s}. Total clients: ${cf.size}`),!0}return!1}function df(e){if(!Array.isArray(e))return console.error("Invalid input: paths should be an array of strings."),null;for(const t of e)if(!1!==c(t))try{const e=mf(t);if(e)return e}catch(e){}}function mf(e){const t=_(e,".git");if(c(t)){const e=function(e){const t=g(e);if(t.isDirectory())return _(e,"config");if(t.isFile()){const t=p(e,"utf-8").trim().match(/^gitdir:\s*(.+)$/);if(t){let n=t[1].trim();k(n)||(n=w(E(e),n));const o=_(n,"config");if(c(o))return o;const i=_(n,"commondir");if(c(i)){let e=p(i,"utf-8").trim();return k(e)||(e=w(n,e)),_(e,"config")}}}return null}(t);if(e&&c(e)){const t=function(e){const t=p(e,"utf-8"),n=/\[remote\s+"(?<name>.+?)"\].+?url\s*=\s*(?<url>.+?)$/gms,o=[];let i;for(;null!==(i=n.exec(t));)if(i.groups){const e=i.groups.name,t=i.groups.url.trim();t.length&&o.push({name:e,url:t})}const a=o.find(e=>"origin"===e.name)||o.find(e=>"upstream"===e.name)||o[0];return a?a.url:null}(e);if(t)return t}}const n=_(e,".plastic");if(c(n)){const e=_(n,"replicas.db");if(c(e)){const t=p(e,"utf-8").split("\n");for(const e of t){const t=e.split("=");if(2===t.length&&"repo"===t[0].trim()){const e=t[1].trim();if(e.length)return e}}}}const o=_(e,"..");return o===e?null:mf(o)}function ff(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}async function hf(e=pe(ne(),".needle")){let t,n;try{t=await K(pe(e,"local-server-token"),"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return;throw new Error("Cannot read local Needle server credentials. Check the credential file permissions.")}try{n=JSON.parse(t)}catch{throw new Error("Invalid local Needle server credentials. Restart the local server to repair them.")}if(null===n||"object"!=typeof n||!("token"in n)||"string"!=typeof n.token||!/^[\x21-\x7e]+$/.test(n.token))throw new Error("Invalid local Needle server credentials. Restart the local server to repair them.");return n.token}async function gf(){const e=await hf();try{const t=await fetch(`${Jp}/mcp`,{method:"POST",headers:{...e?{Authorization:`Bearer ${e}`}:{},"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"needle-startup-probe",method:"ping"}),signal:AbortSignal.timeout(1e3),redirect:"error"});if(!t.ok)return!1;const n=await t.json();return null!==n&&"object"==typeof n&&"jsonrpc"in n&&"2.0"===n.jsonrpc&&"id"in n&&"needle-startup-probe"===n.id&&"result"in n}catch(e){if(e instanceof TypeError||e instanceof Error&&["TimeoutError","AbortError"].includes(e.name))return!1;throw e}}async function vf(e,t=process.argv[1]){await new Promise((n,o)=>{const i=Je(process.execPath,[t,"start","--integration","mcp","--silent"],{detached:!0,windowsHide:!0,stdio:"ignore",env:process.env});i.once("error",t=>{e(`MCP local server launch failed: ${t.message}`),o(t)}),i.once("spawn",()=>{i.unref(),n(void 0)}),i.once("exit",(t,n)=>{0!==t&&e(`MCP local server process exited (${null!=n?n:t}); see the CLI log for details.`)})})}rf.get("/mcp",async(e,t)=>{if(uf(lf++,e,t))return;const n=function(e){const t=[...ud].sort((e,t)=>e.name.localeCompare(t.name)),n=t.map(e=>`\n <div class="tool">\n <span class="tool-name">${of(e.name)}</span>\n <span class="tool-desc">${of(function(e){const t=e.indexOf("\n");return-1===t?e:e.slice(0,t)}(e.description))}</span>\n </div>`).join("\n");return`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <title>Needle MCP Server</title>\n <style>\n * { box-sizing: border-box; }\n body {\n background: #f0f4ef;\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.6;\n padding: 20px 24px;\n max-width: 960px;\n margin: 0 auto;\n color: #1a1a1a;\n }\n header {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-bottom: 8px;\n }\n h2 {\n margin-top: 1.2em;\n margin-bottom: 0.4em;\n }\n a { color: inherit; }\n img.logo {\n height: 2em;\n width: auto;\n }\n .badge {\n font-size: 0.75em;\n background: #d0d4cf;\n padding: 2px 8px;\n border-radius: 10px;\n vertical-align: middle;\n font-weight: normal;\n }\n .tools-info {\n color: #555;\n font-size: 0.9rem;\n margin-top: 0;\n margin-bottom: 10px;\n }\n\n /* Tool items */\n .tool {\n background: #fff;\n border: 1px solid #d8dcd7;\n border-radius: 6px;\n margin-bottom: 6px;\n padding: 10px 14px;\n display: flex;\n align-items: baseline;\n gap: 10px;\n }\n .tool-name {\n font-weight: 600;\n white-space: nowrap;\n }\n .tool-desc {\n color: #555;\n font-size: 0.9rem;\n }\n</style>\n</head>\n<body>\n <header>\n <img class="logo" src="https://cdn.needle.tools/static/branding/logo_needle.png" alt="Needle Logo" />\n <strong>Needle MCP Server</strong>\n </header>\n\n <p>The Needle MCP server is alive and running.</p>\n\n <h2>Usage</h2>\n <p><a href="https://fwd.needle.tools/mcp">Open Documentation</a></p>\n\n <h2>Available Tools <span class="badge">${t.length}</span></h2>\n <p class="tools-info">These tools are available to AI agents connected via the Model Context Protocol (MCP).</p>\n ${n}\n</body>\n</html>`}();t.status(200).header("Content-Type","text/html; charset=utf-8").send(n)}),rf.post("/mcp",async(e,t)=>{const n=e.headers.accept||"",o=e.headers["user-agent"]||"",{method:i,id:a}=e.body;console.log(`[MCP] Received request from ${o} (${i}) (ID: ${a})`),t.setHeader("Content-Type","application/json"),t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization, Mcp-Session-Id"),t.setHeader("Access-Control-Expose-Headers","Mcp-Session-Id");try{if("initialize"===i&&n.includes("text/event-stream")){var r;const n=lf++,o=nf(null==(r=e.body.params)?void 0:r.clientInfo);if(uf(n,e,t,o?`${o.name}/${o.version}`:void 0)){af=!0;const e=ef(null!=a?a:0);return void t.write(`data: ${JSON.stringify(e)}\n\n`)}}const l=await async function(e,t){const{method:n,params:o,id:i}=e;if("initialize"===n)return ef(null!=i?i:0);if("ping"===n)return{jsonrpc:"2.0",id:i,result:{}};if("notifications/initialized"===n||"notifications/cancelled"===n)return null;if("tools/list"===n){try{jm()}catch{}return{jsonrpc:"2.0",id:i,result:{tools:ud}}}if("tools/call"===n){const e=null==o?void 0:o.name;try{jm()}catch{}try{return{jsonrpc:"2.0",id:i,result:await vd(e,(null==o?void 0:o.arguments)||{})}}catch(e){return{jsonrpc:"2.0",id:i,error:{code:-32603,message:`Tool execution failed: ${e.message}`}}}}return{jsonrpc:"2.0",id:null!=i?i:null,error:{code:-32601,message:`Method '${n}' not found`}}}(e.body);if("initialize"===i){var s;af=!0;const n=_e(),i=nf(null==(s=e.body.params)?void 0:s.clientInfo);sf.set(n,i?`${i.name}/${i.version}`:void 0),t.setHeader("Mcp-Session-Id",n),console.log(`[MCP] New session created: ${n} for ${o}`),wp(`MCP New session: ${n} for ${o}`)}if(null===l)return t.status(204).end();if(wp(`MCP Request: ${i}`),"tools/list"===i){var c;const e=(null==(c=l.result)||null==(c=c.tools)?void 0:c.map(e=>e.name))||[];console.log(`[MCP] Sending tools/list: ${e.length} tools [${e.join(", ")}]`)}else{const e=JSON.stringify(l);console.log(`[MCP] Sending response for ${i}:`,e.length>500?e.substring(0,500)+" [...]":e)}t.json(l)}catch(e){console.error("[MCP] Error processing request:",e);const n={jsonrpc:"2.0",error:{code:-32603,message:"Internal server error",data:"development"===process.env.NODE_ENV?e.stack:void 0},id:a||null};t.json(n)}}),rf.options("/mcp",(e,t)=>{t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS, DELETE"),t.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization, Mcp-Session-Id"),t.setHeader("Access-Control-Expose-Headers","Mcp-Session-Id"),t.status(204).end()});let bf=!1;function xf(e,t={}){bf&&process.stdout.write(JSON.stringify({jsonrpc:"2.0",method:e,params:t})+"\n")}var yf={__proto__:null,sendStdioNotification:xf,startStdio:function(){bf=!0,console.log=console.info=console.debug=console.error.bind(console);const e=e=>{console.error(e),wp(e)},t=function({endpoint:e,ensureServer:t,notify:n,log:o,getToken:i,retryMs:a=250,streamTimeoutMs:r=45e3}){const s=new AbortController;let c,l,p,u,d=!1,m=!1,f={name:"Needle stdio bridge",version:"1.0.0"};const h=async()=>i?{Authorization:`Bearer ${await i()}`}:{},g=()=>`${encodeURIComponent(f.name)}/${encodeURIComponent(f.version)}`;function v(e){d!==e&&(d=e,m&&n("notifications/tools/list_changed"))}async function b(t){s.signal.throwIfAborted();const n=new AbortController,o=()=>n.abort();s.signal.addEventListener("abort",o,{once:!0});const i=setTimeout(o,"tools/call"===t.method?35e3:5e3);try{var a,r;const o=await h(),i=await fetch(e,{method:"POST",headers:{...o,"User-Agent":g(),"Content-Type":"application/json",Accept:"application/json","MCP-Protocol-Version":Qm,...u?{"Mcp-Session-Id":u}:{}},body:JSON.stringify(t),signal:n.signal,redirect:"error"});if(!i.ok)throw new Error(`MCP server returned HTTP ${i.status}`);if(204===i.status)return null;const s=await i.json();if(!ff(s)||"2.0"!==s.jsonrpc||s.id!==t.id||!ff(s.result)&&!ff(s.error))throw new Error("Invalid response from local MCP server");if(ff(s.error)){var c;if("number"!=typeof s.error.code||"string"!=typeof s.error.message)throw new Error("Invalid MCP error response");return{jsonrpc:"2.0",id:null!=(c=t.id)?c:null,error:{code:s.error.code,message:s.error.message}}}return"initialize"===t.method&&(u=null!=(a=i.headers.get("Mcp-Session-Id"))?a:void 0),{jsonrpc:"2.0",id:null!=(r=t.id)?r:null,result:s.result}}finally{clearTimeout(i),s.signal.removeEventListener("abort",o)}}return{start:()=>(l||(l=new Promise(e=>{p=e}),c=async function(){let i=a;for(;!s.signal.aborted;){let d;const x=new AbortController,y=()=>x.abort();let w;s.signal.addEventListener("abort",y,{once:!0});const _=(e,t=!0)=>{clearTimeout(w),w=setTimeout(()=>{t?j():x.abort(new Error("MCP notification stream connection timed out"))},e)},j=async()=>{try{var e,t;const n=await b({jsonrpc:"2.0",id:"needle-bridge-liveness",method:"ping"});if(null==n||!n.result||n.error)throw new Error(null!=(e=null==n||null==(t=n.error)?void 0:t.message)?e:"Invalid MCP ping response");s.signal.aborted||x.signal.aborted||_(r)}catch(e){s.signal.aborted||x.signal.aborted||x.abort(e)}};try{var c;await t(s.signal);const o=await b({jsonrpc:"2.0",id:"needle-bridge-initialize",method:"initialize",params:{protocolVersion:Qm,capabilities:{},clientInfo:f}});if(null!=o&&o.error)throw new Error(o.error.message);await b({jsonrpc:"2.0",method:"notifications/initialized"}),_(5e3,!1);const y=await h(),w=await fetch(e,{headers:{...y,"User-Agent":g(),Accept:"text/event-stream","MCP-Protocol-Version":Qm,...u?{"Mcp-Session-Id":u}:{}},signal:x.signal,redirect:"error"});var l;if(!w.ok||null==(c=w.headers.get("content-type"))||!c.includes("text/event-stream")||!w.body)throw await(null==(l=w.body)?void 0:l.cancel()),new Error(`MCP notification stream unavailable (HTTP ${w.status})`);_(r),d=w.body.getReader(),v(!0),null==p||p(),i=a;const j=new TextDecoder;let k="";for(;!s.signal.aborted;){const{value:e,done:t}=await d.read();if(t)throw new Error("MCP notification stream closed");let o;for(_(r),k+=j.decode(e,{stream:!0});o=/\r?\n\r?\n/.exec(k);){const e=k.slice(0,o.index);k=k.slice(o.index+o[0].length);const t=e.split(/\r?\n/).filter(e=>e.startsWith("data:")).map(e=>e.slice(5).replace(/^ /,"")).join("\n");if(!t)continue;const i=JSON.parse(t);ff(i)&&"2.0"===i.jsonrpc&&"notifications/tools/list_changed"===i.method&&m&&n("notifications/tools/list_changed")}if(k.length>1048576)throw new Error("MCP notification exceeds size limit")}}catch(e){s.signal.aborted||(o(`MCP bridge disconnected: ${e instanceof Error?e.message:String(e)}; retrying.`),v(!1))}finally{if(clearTimeout(w),s.signal.removeEventListener("abort",y),d){if(!x.signal.aborted)try{await d.cancel()}catch(e){s.signal.aborted||o(`MCP stream cleanup failed: ${String(e)}`)}d.releaseLock()}u=void 0,null==p||p()}if(!s.signal.aborted){try{await Xe(i,void 0,{signal:s.signal})}catch(e){if(!s.signal.aborted)throw e}i=Math.min(2*i,1e4)}}}()),l),async stop(){s.abort(),await c},async handle(e){var t,i;if("initialize"===e.method)return f=null!=(t=nf(null==(i=e.params)?void 0:i.clientInfo))?t:f,null;if("notifications/initialized"===e.method)return m=!0,d&&n("notifications/tools/list_changed"),null;if(void 0===e.id)return null;if(!d)return"tools/list"===e.method?{jsonrpc:"2.0",id:e.id,result:{tools:[]}}:{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:"The local Needle server is unavailable. Reconnecting; try again shortly."}};try{return await b(e)}catch(t){const n=t instanceof Error?t.message:String(t);return o(`MCP bridge ${e.method} failed: ${n}`),{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:`Local Needle server request failed: ${n}`}}}}}}({endpoint:`${Jp}/mcp`,ensureServer:t=>async function(e={}){const{signal:t,lockPath:n=pe(ne(),".needle","mcp-server-start.lock"),probe:o=gf,log:i=(e=>console.error(e)),launch:a=(()=>vf(i)),timeoutMs:r=2e4,pollMs:s=100}=e;if(null==t||t.throwIfAborted(),await o())return;await Z(se(n),{recursive:!0});const c=Date.now()+r;let l;try{for(;Date.now()<c;){if(null==t||t.throwIfAborted(),await o())return;if(!l){try{l=await X(n,"wx",384)}catch(e){if(!(e instanceof Error&&"code"in e&&"EEXIST"===e.code))throw e;try{const e=await Q(n);Date.now()-e.mtimeMs>12e4&&(i("Removing an expired MCP server startup lock."),await ee(n))}catch(e){if(!(e instanceof Error&&"code"in e&&"ENOENT"===e.code))throw e}}if(l){if(await o())return;i("Starting the shared Needle local server."),await a()}}await Xe(s,void 0,{signal:t})}throw new Error("The local Needle server did not become ready in time. See the CLI log for startup errors.")}finally{l&&(await l.close(),await ee(n))}}({signal:t,log:e}),notify:xf,log:e,getToken:()=>async function(e){const t=await hf(void 0);if(void 0===t)throw new Error("Local Needle server credentials are missing. Restart the local server to create them.");return t}()}),n=ze({input:process.stdin,terminal:!1}),o=e=>{bf&&process.stdout.write(JSON.stringify(e)+"\n")};n.on("line",i=>{(async function(n){if(!n.trim())return;let i;try{i=JSON.parse(n)}catch{return void o({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}})}if(!ff(a=i)||"2.0"!==a.jsonrpc||"string"!=typeof a.method||null!=a.id&&"string"!=typeof a.id&&"number"!=typeof a.id||void 0!==a.params&&!ff(a.params))return void o({jsonrpc:"2.0",id:null,error:{code:-32600,message:"Invalid request"}});var a,r;if("initialize"===i.method)return o(ef(null!=(r=i.id)?r:0)),await t.handle(i),void t.start().catch(t=>e(`MCP bridge startup failed: ${String(t)}`));if("ping"===i.method)return void(void 0!==i.id&&o({jsonrpc:"2.0",id:i.id,result:{}}));const s=await t.handle(i);s&&o(s)})(i).catch(t=>{e(`MCP stdio request failed: ${String(t)}`),process.exitCode=1,n.close()})}),n.once("close",()=>{bf=!1,t.stop().then(()=>{var e;return process.exit(null!=(e=process.exitCode)?e:0)},t=>{e(`MCP bridge shutdown failed: ${String(t)}`),process.exit(1)})})}};let wf=null;function _f(){wf&&clearTimeout(wf),wf=setTimeout(()=>{!function(e,t={}){if(0===cf.size)return;const n=`data: ${JSON.stringify({jsonrpc:"2.0",method:"notifications/tools/list_changed",params:t})}\n\n`;for(const[e,{client:t,dispose:o}]of cf)try{t.write(n)}catch(n){console.error(`[MCP] Error sending notification to client (${e}):`,n),o(),t.destroy()}}(),xf("notifications/tools/list_changed"),Gm(),wf=null},10)}function jf(e){if("string"!=typeof e)return!1;const t=/^(localhost|127\.0\.0\.1|\[::1\])(?::([0-9]{1,5}))?$/i.exec(e);return!!t&&(void 0===t[2]||Number(t[2])>0&&Number(t[2])<=65535)}const kf=new Set(["https://cloud.needle.tools","https://needle.tools","https://engine.needle.tools","https://docs.needle.tools","chrome-extension://kjcepmifiddcepiocokclhibpkgcdomk","chrome-extension://jonplpbnhmanoekkgcepnedhghflblmo"]),Sf=new Set(["localhost","127.0.0.1","[::1]","::1"]);function Ef(e){if("string"!=typeof e||0===e.length)return!1;if(kf.has(e))return!0;let t;try{t=new URL(e)}catch{return!1}if("/"!==t.pathname&&""!==t.pathname)return!1;if(""!==t.search||""!==t.hash)return!1;if("http:"!==t.protocol&&"https:"!==t.protocol)return!1;const n=t.hostname.toLowerCase();return!!Sf.has(n)||"::1"===n}const $f="[MCP]",Tf=new Array;function If(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Of(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0}async function Af(){try{return JSON.parse(await K(pe(ne(),".needle","local-server-token"),"utf8"))}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return null;if(e instanceof SyntaxError)throw new Error("The local server record is invalid.");throw e}}function Cf(e){try{return process.kill(e,0),!0}catch(e){if(e instanceof Error&&"code"in e){if("ESRCH"===e.code)return!1;if("EPERM"===e.code)return!0}throw e}}function Rf(e,t){return{api_endpoint:e,version:t,pid:process.pid}}var Nf={__proto__:null,getLocalServerInfo:Rf,getLocalServerStatus:async function(e={}){var t,n,o;const i=null!=(t=e.fetch)?t:globalThis.fetch;let a,r;try{a=await i(`${Jp}/api/info`,{signal:AbortSignal.timeout(3e3)})}catch(e){if(e instanceof Error&&If(e.cause)&&"ECONNREFUSED"===e.cause.code)return{running:!1,url:Jp};throw e}if(!a.ok)throw new Error(`Local server status request failed (HTTP ${a.status}).`);try{r=await a.json()}catch(e){if(e instanceof SyntaxError)throw new Error("Invalid local server info response.");throw e}if(!If(r)||"string"!=typeof r.version||!r.version.trim()||"string"!=typeof r.api_endpoint||!r.api_endpoint.trim())throw new Error("Invalid local server info response.");if(void 0!==r.pid&&!Of(r.pid))throw new Error("Invalid local server PID.");if(Of(r.pid))return{running:!0,url:Jp,version:r.version,pid:r.pid,pidSource:"server"};const s=await(null!=(n=e.readServerRecord)?n:Af)();return If(s)&&s.port===Gp&&Of(s.pid)&&(null!=(o=e.isProcessAlive)?o:Cf)(s.pid)?{running:!0,url:Jp,version:r.version,pid:s.pid,pidSource:"record"}:{running:!0,url:Jp,version:r.version,pid:null,pidSource:"unavailable"}},formatLocalServerStatus:function(e){return e.running?`Needle local server: running\nURL: ${e.url}\nVersion: ${e.version}\nPID: ${null===e.pid?"unavailable":`${e.pid}${"record"===e.pidSource?" (recorded)":""}`}`:`Needle local server: not running\nURL: ${e.url}`}};const Pf="2026-10-14T15:55:11.780Z";var Uf={__proto__:null,BUILD_TIME:Pf};const{json:Lf}=Ze;function zf(e){const t=null==e?void 0:e.cause;return null!=t&&t.code?`${t.code}${t.address?` (${t.address}:${t.port})`:""}`:null!=t&&t.message?t.message:null!=e&&e.code?e.code:null!=e&&e.message&&"fetch failed"!==e.message?e.message:"connection refused or network unreachable"}async function Ff(t={restart:!1}){const n=!0===t.restart,o=await e(Jp).catch(e=>({ok:!1})),a="/sign-in",r="/api/authenticated",s="/api/projects",l="/api/content",p={baseUrl:Jp,port:Gp,isHost:!1,auth_endpoints:{"sign-in":`${Jp}${a}`,"sign-out":`${Jp}/sign-out`,"is-authenticated":`${Jp}${r}`}};let u=o.ok;if(u){var d;const g=await e(`${Jp}/api/info`).catch(()=>null);if(null!=g&&g.ok){const b=await g.json().catch(()=>null);if(null!=b&&b.api_endpoint&&"https://cloud.needle.tools/api"!==b.api_endpoint){if(!Xm(b.api_endpoint,"https://cloud.needle.tools/api",n))return wp(`Keeping CLI server for ${b.api_endpoint}; https://cloud.needle.tools/api did not request an explicit restart.`),p;wp(`Running server uses different API endpoint (${b.api_endpoint} vs https://cloud.needle.tools/api), restarting...`),t||(t={}),t.restart=!0}}if(!0===(null==(d=t)?void 0:d.restart)){wp("Restarting auth server...");const x=`${Jp}/restart`;t.ora&&(t.ora.text="Sending restart request to server");const y=new AbortController;setTimeout(()=>y.abort(),1e4);let w={};try{const k=_(Te(),".needle","local-server-token"),S=JSON.parse((await import("fs")).readFileSync(k,"utf-8"));S.token&&(w={Authorization:`Bearer ${S.token}`})}catch{}const j=await e(x,{method:"post",signal:y.signal,headers:{...w,"x-needle-api-endpoint":"https://cloud.needle.tools/api",...n?{"x-needle-explicit-restart":"true"}:{}}}).catch(e=>({ok:!1,status:400,error:e}));if(j.ok)return await ul(300),Ff({restart:!1});409!==j.status&&console.error("Failed to restart server",j.status),wp(`Failed to restart server: ${j.status}`)}}if(!u){process.title="Needle CLI server";const E=await import("express").catch(e=>{throw console.error("Error starting the auth server (express not found)",e),wp("Error starting the auth server"),new Error("Failed to load express module")});if(!E)throw wp("Error loading auth server module"),new Error("Failed to load express module");wp(`Starting Needle CLI server ${cd()} (built ${Pf})... (Using api at https://cloud.needle.tools/api)`,{emptyLineBefore:!0}),p.isHost=!0;let $=null;const O={invalid_login:!1,invalid_login_type:null,user_email:null,logged_in_machine_names:[]};let A=E.default();const C=_(Te(),".needle"),R=function(e,t){var n;const o=pe(e,"local-server-token"),a=null!=(n=function(e){if(!T(e))return null;try{const t=M(e,"utf-8");if(0===t.length)return null;const n=JSON.parse(t);if(n&&"string"==typeof n.token&&n.token.length>0)return n.token}catch{}return null}(o))?n:i();I(e,{recursive:!0});const r=JSON.stringify({token:a,pid:process.pid,port:t},null,2);if(H(o,r,{encoding:"utf-8",mode:384}),"win32"===process.platform)try{const e=process.env.USERNAME||process.env.USER||"";e&&We("icacls",[o,"/inheritance:r","/grant:r",`${e}:(F)`],{stdio:"ignore",timeout:5e3})}catch{}return a}(C,Gp);wp(`Local token written to ${_(C,"local-server-token")}`);const N=function(e,t=5e3){const n=new Map,o=Math.max(1,Math.round(t/1e3));return(i,a)=>{const r=Date.now(),s=n.get(i);if(!s||r-s.lastLog>t){var c;const t=null!=(c=null==s?void 0:s.suppressed)?c:0;e(t>0?`${a} [+${t} similar in last ${o}s]`:a),n.set(i,{lastLog:r,suppressed:0})}else s.suppressed++}}(e=>wp(`Denied: ${e}`),5e3);A.use((h={onDenied:N},(e,t,n)=>{var o;return jf(e.headers.host)?n():(null==h||null==h.onDenied||h.onDenied(`host|${null!=(o=e.headers.host)?o:"missing"}`,"HTTP Host is not a loopback authority"),t.status(403).send("Forbidden: host not allowed"))})),A.use(function(e){const t=null==e?void 0:e.onDenied;return(e,n,o)=>{var i,a;if("OPTIONS"===e.method)return o();const r=null==(i=e.headers)?void 0:i.origin,s=null==(a=e.headers)?void 0:a["sec-fetch-site"];if(void 0!==r){if(Ef(r))return o();if(t)try{var c,l,p,u;const n=null!=(c=null==(l=e.headers)?void 0:l["user-agent"])?c:"unknown",o=null!=(p=null!=(u=e.path)?u:e.url)?p:"?";t(`origin|${r}|${o}`,`denied origin=${r} path=${o} ua="${n}"`)}catch{}return n.status(403).send("Forbidden: origin not allowed")}var d,m;if(s&&"none"!==s&&"same-origin"!==s&&("GET"!==e.method||"navigate"!==(null==(d=e.headers)?void 0:d["sec-fetch-mode"])||"document"!==(null==(m=e.headers)?void 0:m["sec-fetch-dest"]))){if(t)try{var f,h;const n=null!=(f=null!=(h=e.path)?h:e.url)?f:"?";t(`fetch-site|${s}|${n}`,`denied fetch-site=${s} path=${n}`)}catch{}return n.status(403).send("Forbidden: origin not allowed")}return o()}}({onDenied:N})),A.use(Lf({limit:"10mb"}));const P=new Set(["/","/sign-in","/sign-out","/auth-callback","/api/info","/api/authenticated","/api/public_key","/mcp","/register"]),U="needle_local";A.use((e,t,n)=>{var o,i,a;if("OPTIONS"===e.method)return n();if(P.has(e.path))return n();if(e.path.startsWith("/mcp/"))return n();if(e.path.startsWith("/.well-known/"))return n();const r=null==(o=e.headers)?void 0:o.authorization;if(r){const e=r.split(" ");if(2===e.length&&"Bearer"===e[0]&&e[1]===R)return n()}if((null==(i=e.query)?void 0:i.token)===R)return n();const s=((null==(a=e.headers)?void 0:a.cookie)||"").split(";").map(e=>e.trim()).find(e=>e.startsWith(U+"="));if(s&&s.split("=")[1]===R)return n();try{var c,l;const t=null!=(c=null==(l=e.headers)?void 0:l["user-agent"])?c:"unknown";N(`token|${t}|${e.path}`,`path=${e.path} ua="${t}" — no valid token or cookie`)}catch{}return t.status(401).send("Unauthorized: token required")}),A.use(Zm(O)),t.ora?(t.ora.start("Starting MCP server..."),t.ora.succeed(`MCP server available at ${Jp}/mcp`)):console.log(`\nMCP server available at ${Jp}/mcp .`),A.use(rf);const L="\n <title>Needle Cloud</title>\n <link rel=\"icon\" href=\"https://cdn.needle.tools/static/branding/favicon.ico\" type=\"image/x-icon\">\n <style>\n body { \n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;\n font-size: 18px;\n padding: 2rem;\n background: #f0f4ef;\n }\n a {\n color: rgb(120, 76, 223);\n }\n .main_panel {\n display: flex;\n flex-direction: column;\n gap: .5rem;\n justify-content: flex-start;\n align-items: center;\n width: min(80ch, 90vw);\n margin: 0 auto;\n\n height: 100%;\n\n & img.logo {\n height: 3rem;\n margin-bottom: 1rem;\n }\n }\n .secondary {\n color: rgba(0, 0, 0, .5);\n }\n .error-details {\n font-size: 12px;\n color: rgba(0, 0, 0, .5);\n }\n .error-details a {\n color: inherit;\n }\n </style>",z=`<div class="main_panel"><img class="logo" src="https://cdn.needle.tools/static/branding/logo_needle.png" alt="Needle Logo" title="Needle Logo (${cd()})"/>`,F="</div>";let D="";A.get("/",Wu(),async(e,t)=>{var n,o;if(null!=(n=e.user)&&n.isAuthenticated?t.cookie(U,R,{httpOnly:!0,sameSite:"strict",path:"/"}):t.clearCookie(U,{path:"/"}),t.set({"Content-Type":"text/html; charset=utf-8"}),t.write(L),null!=e.query.cancelled)return t.end("Login cancelled. You can close this window now."),void wp("Login cancelled by user");if(null!=e.query["too-many-logins"]&&O.logged_in_machine_names.length){var i;const e=op();let n="<div>";return n+="<strong>You have reached the maximum number of allowed device logins!</strong><br/><br/>",n+=(null==(i=O.logged_in_machine_names)?void 0:i.map(e=>`• ${e}`).join("<br/>"))+"<br/><br/>",n+=`1) Go to <a href="${e}#device-logins" target="_blank">Needle Cloud device logins</a> and logout one of your devices.<br/>\n 2) Then <a href="${a}">sign-in on this machine</a>.<br/><br/>`,n+="</div>",t.status(406),t.end(z+n+F),void wp(`Login failed: Too many logins from different machines: [${O.logged_in_machine_names.join(", ")}]`)}if(null!=e.query.error)return t.status(500),void t.end(`${z}\n <div>\n <strong>An error occurred</strong>: Please make sure <i>https://cloud.needle.tools/api</i> and <i>https://auth.needle.tools</i> are reachable and not blocked by your firewall or network. After that please try to <a href="${a}">sign-in</a> again.\n <br/><span class="error-details">If the issue persists, please contact support and include the log file: <a title="Link to local log file. Please copy this url and open it in your file explorer or terminal" href="file://${bp()}" target="_blank">${bp()}</a></span>\n </div>\n ${F}`);if(null!=(o=e.user)&&o.isAuthenticated){var r;if(!await Vu(e.user)){if(O.invalid_login=!0,O.logged_in_machine_names=[...Gu(e.user)],bu(),wp("Cleared stored auth data"),"client"in e.user){const t=e.user;await t.client.clearAccessToken(),await t.client.clearAllTokens(),wp("Cleared all tokens")}return t.end(`${z}<div>You have been logged out from this machine. You can close this window now or try to <a href="${a}">sign in</a> again</div>${F}`)}O.invalid_login=!1,t.end(`${z}\n <div>\n Hi ${Bu(e.user)} — you logged in successfully. You can close this window now.\n </div>\n ${F}`);const n=`Logged in successfully as ${Bu(e.user)} (${null==(r=e.user.userInfo)?void 0:r.sub})`;return void(D!==n&&(D=n,wp(D)))}let s=`<span><a href="${a}">Sign in</a> to your Needle account</span>`;"1"===e.query["signed-out"]&&(s=`<span class="secondary">You have been signed out successfully.</span>${s}`),t.write(z+s+F),t.end()}),A.post("/restart",(e,n)=>{var o;if(!Xm("https://cloud.needle.tools/api",e.headers["x-needle-api-endpoint"],"true"===e.headers["x-needle-explicit-restart"]))return wp("Rejected restart from a CLI targeting another API endpoint"),void n.status(409).end("A Needle CLI connected to a different environment is already running.");t.ora&&(t.ora.text="Received restart event. This instance will close"),null==(o=$)||o.close(e=>{e&&console.error(e)}),setTimeout(()=>{process.exit(0)},100),n.status(200).end("Server is restarting"),wp("Server is restarting\n")}),A.get("/api/logs",async(e,t)=>{const n=bp();c(n)?v(n,"utf-8",(e,o)=>{if(e)return console.error(e),void t.status(500).end("Failed to read log file");t.set({"Content-Type":"text/plain; charset=utf-8"});const i=o.split("\n").filter(e=>e.length>0).reverse().join("\n");let a=`--- Needle CLI v${cd()} (built ${Pf}) Log File (newest first) ---\n${n}\n\n`;a+=i,t.status(200).end(a)}):t.status(404).end("Log file not found")}),A.get("/api/info",(e,t)=>{t.json(Rf("https://cloud.needle.tools/api",cd()))}),A.get(r,Wu(),async(e,t)=>{var n;if(!0===O.invalid_login){const e=Df(O);return t.status(e.status).json(e)}O.invalid_login=!1,t.status(null!=(n=e.user)&&n.isAuthenticated?200:400).send()}),A.get("/api/user",Wu(),async(e,t)=>{var n;const o=e.user;if(null==o||!o.isAuthenticated){if(!0===O.invalid_login){const e=Df(O);return t.status(e.status).json(e)}return t.status(401).json({error:"Not authenticated"})}if(O.invalid_login=!1,!await Vu(o))return bu(),t.status(403).json({error:"You have been logged out from this machine"});if(null==o||!o.claims)return t.status(400).json({error:"User claims not found"});if(null==o||!o.userInfo)return t.status(400).json({error:"User info not found"});const i=null==o||null==(n=o.claims)?void 0:n.organization_roles,a=null==o?void 0:o.userInfo.custom_data,r={authenticated:o.isAuthenticated,id:o.userInfo.sub,name:Bu(o),email:o.claims.email||o.userInfo.email||"",profile_picture:o.userInfo.picture||"",default_org_id:(null==a?void 0:a.default_org)||"none",orgs:[]},s=["manage","owner","member","developer"];o.userInfo.organization_data&&(r.orgs=o.userInfo.organization_data.map(e=>{var t;const n={id:e.id,name:e.name,roles:(null==i?void 0:i.filter(t=>t.startsWith(e.id)).map(e=>e.split(":")[1]))||[],canWrite:!1};return n.canWrite=null==(t=n.roles)?void 0:t.some(e=>s.includes(e)),n}).sort((e,t)=>e.id===r.default_org_id?-1:t.id===r.default_org_id?1:e.name.localeCompare(t.name))),t.json(r)}),A.get("/api/license",Wu(),async(t,n)=>{var o,i,a;const r=null==(o=t.query.token)?void 0:o.toString(),s=null==(i=t.query.org)?void 0:i.toString();let c=null;if(r)c={authToken:r};else{const e=await Lu();if(!e||!e.isAuthenticated)return n.status(401).json({error:"Not authenticated",code:"not_authenticated"});if(!await Vu(e))return bu(),n.status(403).json({error:"Invalid login"});c=await Mu(e,s||null).catch(e=>({status:500,error:e.message}))}if(!c)return n.status(500).json({error:"Failed to fetch licenses (Missing auth)"});if("error"in c)return n.status(c.status).json({error:c.error});const l=ht(c),p=null==(a=t.query.integration)?void 0:a.toLocaleString(),u={...l,"x-needle":"cli","x-needle-integration":null!=p&&p.length?p:"unknown"},d=await e(`https://cloud.needle.tools/api${ft.account.get_licenses}`,{method:"GET",headers:u}).catch(e=>{const t=zf(e);return console.error("Failed to fetch licenses:",t),wp(`Failed to fetch licenses: "${t}" - is https://cloud.needle.tools/api reachable?`),null});if(!d)return n.status(502).json({error:"Failed to fetch licenses: upstream API unreachable"});if(d.ok){const e=await d.json();return void 0===e.can_use_editor&&(e.can_use_editor=!0),n.json(e)}return n.status(d.status).json({error:d.statusText})}),A.get("/api/deployments",Wu(),async(e,t)=>{var n;const o=await Lu();if(!o||!o.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const i=null==(n=e.query.org)?void 0:n.toString(),a=await Mu(o,i).catch(e=>({status:500,error:e.message}));if("error"in a)return t.status(a.status).json({error:a.error});if(i&&!a.org)return t.status(400).json({error:"Organization not found"});const r=await Bp({endpoint:"https://cloud.needle.tools/api",authToken:a.authToken,org:a.org||void 0,limit:20,offset:0,names:void 0}).catch(e=>(console.error("List Deployments error: "+e.message),{status:502,error:"Failed to list deployments: upstream API unreachable"}));if("error"in r)return t.status(r.status).json({error:r.error});for(const e of r.deployments)e.editUrl=`${ip()}/${e.id}`;const s={...r};return t.json(s)}),A.get(l,Wu(),async(e,t)=>{var n,o,i,a,r,s,c,l;const p=await Lu();if(!p||!p.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const u=(null==(n=e.query.org)?void 0:n.toString())||(null==(o=p.userInfo)||null==(o=o.custom_data)?void 0:o.default_org)||void 0,d=await Mu(p,u).catch(e=>({status:500,error:e.message}));if("error"in d)return t.status(d.status).json({error:d.error});const m={content_type:(null==(i=e.query.content_type)?void 0:i.toString())||void 0,content_format:(null==(a=e.query.content_format)?void 0:a.toString())||void 0,search:(null==(r=e.query.search)?void 0:r.toString())||void 0,tags:(null==(s=e.query.tags)?void 0:s.toString())||void 0,types:(null==(c=e.query.types)?void 0:c.toString())||void 0,trash:"true"===e.query.trash||void 0,collection_id:(null==(l=e.query.collection_id)?void 0:l.toString())||void 0,limit:e.query.limit?parseInt(e.query.limit.toString()):void 0,page:e.query.page?parseInt(e.query.page.toString()):void 0,offset:e.query.offset?parseInt(e.query.offset.toString()):void 0},f=await ql({baseUrl:"https://cloud.needle.tools/api",authToken:d.authToken,org:d.org||void 0},m).catch(e=>(console.error("List content error: "+e.message),{status:502,error:"Failed to list content: upstream API unreachable"}));return"error"in f?t.status(f.status).json({error:f.error}):t.json(f)}),A.get(l+"/:identifier",Wu(),async(e,t)=>{var n,o;const i=await Lu();if(!i||!i.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const a=(null==(n=e.query.org)?void 0:n.toString())||(null==(o=i.userInfo)||null==(o=o.custom_data)?void 0:o.default_org)||void 0,r=await Mu(i,a).catch(e=>({status:500,error:e.message}));if("error"in r)return t.status(r.status).json({error:r.error});const s=await Bl({baseUrl:"https://cloud.needle.tools/api",authToken:r.authToken,org:r.org||void 0},e.params.identifier).catch(e=>(console.error("Get content error: "+e.message),{status:502,error:"Failed to get content: upstream API unreachable"}));return"error"in s?t.status(s.status).json({error:s.error}):t.json(s)}),A.get(s,Wu(),async(t,n)=>{const o=await Lu();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i=`https://cloud.needle.tools/api${ft.local_projects.get.user}`,a=await e(i,{method:"GET",headers:{Authorization:`Bearer ${o.accessToken}`}}).catch(e=>(console.error("Failed to fetch projects:",zf(e)),null));if(!a)return n.status(502).json({error:"Failed to fetch projects: upstream API unreachable"});if(!a.ok)return n.status(a.status).json({error:a.statusText});const r=await a.json().catch(e=>console.error(e));return n.json(r)}),A.get(s+"/:id",Wu(),async(t,n)=>{var o;const i=await Lu();if(!i||!i.isAuthenticated)return n.status(401).json({error:"Not authenticated"});let a=null==(o=t.query.org)?void 0:o.toString();const r=await Mu(i,a).catch(e=>({status:500,error:e.message}));if(!r)return n.status(500).json({error:"Failed to fetch projects"});if("error"in r)return n.status(r.status).json({error:r.error});const s=ht(r),c=`https://cloud.needle.tools/api${ft.local_projects.get.by_id}${encodeURIComponent(t.params.id)}`,l=await e(c,{method:"GET",headers:{...s}}).catch(e=>(console.error("Failed to fetch project:",zf(e)),null));if(!l)return n.status(502).json({error:"Failed to fetch project: upstream API unreachable. Please try again later or contact hi@needle.tools"});if(!l.ok)return n.status(l.status).json({error:l.statusText});const p=await l.json().catch(e=>(console.error(e),null));return p?n.json(p):n.status(500).json({error:"Failed to parse data. Please try again later or contact hi@needle.tools"})}),A.post("/api/projects",Wu(),async(t,n)=>{const o=await Lu();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i="string"==typeof t.body?JSON.parse(t.body):t.body,a={machine_id:await Ku(),project_id:i.project_id,project_name:i.project_name,scene_name:i.scene_name,web_project_path:i.web_project_path,editor_name:i.editor_name,editor_version:i.editor_version};if(!a.project_id||!a.project_name)return n.status(400).json({error:"Invalid request"});const r=`https://cloud.needle.tools/api${ft.local_projects.post}`,s=await e(r,{method:"POST",headers:{Authorization:`Bearer ${o.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(a)}).catch(e=>(console.error("Failed to upsert project:",zf(e)),null));return s?s.ok?n.send("OK"):n.status(s.status).json({error:s.statusText}):n.status(502).json({error:"Failed to upsert project: upstream API unreachable"})}),A.get("/api/public_key",Wu(),async(t,n)=>{var o,i;const a=await Lu();if(!a||!a.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const r=null==(o=t.query.org)?void 0:o.toString(),s=await Mu(a,r).catch(e=>({error:e.message,status:500}));if(!s)return n.status(500).json({error:"Failed to fetch public key"});if("error"in s)return n.status(s.status).json({error:s.error});const c={project_id:(null==(i=t.query.project_id)?void 0:i.toString())||void 0,machine_id:await Ku()},l=await e(`https://cloud.needle.tools/api${ft.account.public_key}`,{method:"POST",headers:{...ht(s),"Content-Type":"application/json"},body:JSON.stringify(c)}).catch(e=>(console.error("Failed to fetch public key:",zf(e)),null));if(!l)return n.status(502).json({error:"Failed to fetch public key: upstream API unreachable"});if(l.ok){const e=await l.json().catch(console.error);return null!=e&&e.public_key?n.json(e):n.status(500).json({error:"Failed to fetch public key"})}return n.status(l.status).json({error:l.statusText})}),A.get("/api/local_project_id",async(e,t)=>{const n=e.query.paths;if(!n)return t.status(400).json({error:"Missing paths"});let o=[];"string"==typeof n?o=n.split(",").map(e=>e.trim()).filter(e=>e.length>0):Array.isArray(n)&&(o=n.map(e=>e.toString().trim()).filter(e=>e.length>0));const i=df(o);return i?t.json({project_id:i}):t.status(404).json({error:"Project ID not found"})}),A.post("/api/project/info",Wu(),async(e,t)=>{(function(e){try{!function(e){var t,n,o,i;const a={last_accessed:Date.now(),editor:null!=(t=e.scene_path)&&t.endsWith(".unity")?"unity":null!=(n=e.scene_path)&&n.endsWith(".blend")?"blender":"unknown",editor_version:e.editor_version,editor_installation_path:e.editor_installation_path,log_location:e.editor_log_path,project_location:e.unity_project_path||e.blender_project_path||e.scene_path,scene_location:e.scene_path,web_location:e.web_project_path,needle_engine_integration_location:e.needle_sourcecode_location},r=ad();let s=rd();const c=s.entries.findIndex(e=>e.project_location===a.project_location),l=null==(o=s.entries[0])?void 0:o.project_location;-1!==c?s.entries[c]=a:s.entries.push(a),s.entries.sort((e,t)=>t.last_accessed-e.last_accessed);let p=0;s.entries=s.entries.filter(e=>"cli"===e.source||++p<=30);const u=null==(i=s.entries[0])?void 0:i.project_location;u&&u!==l&&wp(`Active project changed: ${l||"(none)"} → ${u}`);try{Xu=s;const e=JSON.stringify(s);f(r,e,"utf-8")}catch(e){console.error("Failed to save project info:",e)}}(e)}catch(e){wp("Error saving project info: "+e)}})("string"==typeof e.body?JSON.parse(e.body):e.body),t.send("OK")});let q=null;const B=new Promise(e=>q=e);let W=!1;if($=A.listen(Gp,()=>{null==q||q()}),$.on("error",e=>{if("EADDRINUSE"===(null==e?void 0:e.code))return wp(`License server port ${Gp} already in use — a server is already running; not starting a second one.`),W=!0,p.isHost=!1,void(null==q||q());console.error("[needle] License server failed to start:",(null==e?void 0:e.message)||e),wp(`License server failed to start: ${(null==e?void 0:e.message)||e}`),process.exit(1)}),function(e,t){e.on("connection",e=>{const n=e.remoteAddress;if(!function(e){if(!e)return!1;const t=e.includes("%")?e.slice(0,e.indexOf("%")):e;return"127.0.0.1"===t||"::1"===t||"::ffff:127.0.0.1"===t}(n)){try{null==t||t(`Local server: rejected non-loopback connection from ${n||"unknown"}`)}catch{}e.destroy()}})}($,wp),$.on("close",m),process.on("exit",m),process.on("SIGINT",()=>{m(),process.exit(0)}),await B.catch(e=>{console.error(e),wp(`Error starting the auth server (promise failed): ${e.message}`)}),W)return p;function m(){wp("Cleaning up auth server...")}(function(e,t){const n=new Me({server:e,path:"/mcp/ws",verifyClient:({req:e},t)=>{var n;if(!jf(e.headers.host))return wp(`${$f} rejected WS upgrade: host not allowed`),void t(!1,403,"Forbidden: host not allowed");const o=null==(n=e.headers)?void 0:n.origin;if(o&&!Ef(o))return wp(`${$f} rejected WS upgrade: disallowed origin ${o}`),void t(!1,403,"Forbidden: origin not allowed");t(!0)}});wp("MCP websocket server created.");let o=0,i=new Map;n.on("connection",e=>{const t=++o;Tf.push(e),console.log(`${$f} client connected (#${t})`),wp(`${$f} client connected (#${t})`),e.on("close",()=>{const n=Tf.indexOf(e);-1!==n&&Tf.splice(n,1);const o=i.get(t);if(o){for(const e of o)fd(e,_f);i.delete(t)}console.log(`${$f} client disconnected (#${t})`),wp(`${$f} client disconnected (#${t})`)});const n=new Map;e.on("message",o=>{try{const a=o.toString(),r=JSON.parse(a);switch(r.command){default:console.log(`${$f} Unknown command: ${r.command}`),wp(`Unknown MCP websocket command received: ${r.command}`);break;case"get_connected_clients":!function(t,n){const o={clients:[...pf()],command:"mcp_server_response",messageId:"messageId"in t?t.messageId:void 0};e.send(JSON.stringify(o))}(r);break;case"register_tools":{const o=r.tools,a=r.source;if("cli"===a)throw new Error("The CLI tool source is reserved for built-in tools.");a&&function(e,t){const n=md.get(e);if(n&&n.size>0){console.log(`[MCP] Removing ${n.size} tools registered from ${e}`);let o=!1;for(const t of n){const n=ud.findIndex(e=>e.name===t);-1!==n&&(ud.splice(n,1),delete dd[t],gd.set(t,e),o=!0)}md.delete(e),o&&t()}}(a,_f);const s=a||"unknown";console.log(`${$f} ${s} registered ${o.length} tool${1===o.length?"":"s"}`),wp(`${$f} ${s} registered ${o.length} tool${1===o.length?"":"s"}`);const c=i.get(t)||new Set;i.set(t,c);for(const t of o)hd(t,async o=>{console.log(`Tool ${t.name} executed via WebSocket with args:`,o);const i=`${t.name}-${Date.now()}-${Math.random()}`;return await new Promise((a,r)=>{const s=setTimeout(()=>{n.has(i)&&(console.error(`${$f} Tool execution timed out for tool: ${t.name}`),n.delete(i),r(new Error(`Tool execution timed out for tool: ${t.name}`)))},3e4);n.set(i,{resolve:e=>{a(e),clearTimeout(s)},reject:r}),e.send(JSON.stringify({command:"execute_tool",toolName:t.name,args:o,requestId:i}))})},{source:a},_f),c.add(t.name);break}case"tool_result":{const e=r.requestId,t=r.result;if(console.log(`${$f} Received tool result for requestId: ${e}`,t),n.has(e)){const o=n.get(e);null==o||o.resolve(t),n.delete(e)}else console.error(`${$f} No pending tool execution found for requestId: ${e}`);break}}}catch(e){console.error(`${$f} Error processing WebSocket message:`,e)}})})})($),jm({logToolCount:!0}),Wm();const G=tm(C,()=>{Zd()?(wp("Settings changed: remote_ai_tools disabled — closing cloud connection"),Hm("remote_ai_tools setting disabled")):(wp("Settings changed: remote_ai_tools enabled — opening cloud connection"),Wm())});process.on("exit",()=>{G(),Hm("process exit")})}var h;return p}function Df(e){let t="";return t=e.error?e.error:e.logged_in_machine_names.length>0?`You're already authenticated on ${e.logged_in_machine_names.length} other machine(s)${e.user_email?` with ${e.user_email}`:""}. Please logout from other machines first on ${op()}. You're currently logged in on: ${e.logged_in_machine_names.join(", ")}`:"An unknown error occured.",{status:403,error:t}}async function qf(e={headless:!1,silent:!1,clearAuthData:!1}){return!0===e.clearAuthData&&await bu(),Mf("sign-in",{...e})}function Bf(e={}){return Mf("sign-out",{...e})}function Mf(t,n){return new Promise(async(o,i)=>{let a=!1;if("sign-in"==t){const e=await Lu();if(null!=e&&e.isAuthenticated&&e.accessToken)return await Zu(e)?(a=!0,n.ora&&(n.ora.text=`Authorized as ${Bu(e)}`),"gotoAccountPage"in n&&!0===n.gotoAccountPage&&(n.ora&&(n.ora.text="Opening account page in the browser"),ap(op()),await new Promise(e=>setTimeout(e,2e3))),o(e)):o(null);if(!0===n.headless)return o(null)}else if("sign-out"==t&&!0===n.headless){a=!0,bu();const t=await Ff(),n=await e(t.auth_endpoints["sign-out"],{follow:2});return o(n.ok)}const r=await Ff();switch(n.timeout||(n.timeout=6e5),"number"==typeof n.timeout&&n.timeout>0&&setTimeout(()=>{a||(n.ora&&n.ora.fail('Timeout "'+t+'"'),o(null))},n.timeout),t){case"sign-in":const e=r.auth_endpoints["sign-in"];setTimeout(()=>ap(e),300),n.ora&&(n.ora.text=`Please authenticate in the browser: ${e}`),setTimeout(l,2e3);break;case"sign-out":bu(),ap(r.auth_endpoints["sign-out"]),setTimeout(l,2e3)}let s=0;const c=10;function l(){e(r.auth_endpoints["is-authenticated"]).then(async e=>{if(200===e.status||400===e.status||403===e.status)switch(t){case"sign-in":if(200===e.status){const e=await Lu();return e&&!await Zu(e)?o(null):(a=!0,n.ora&&e&&(n.ora.text="User is authenticated"),o(e))}if(403===e.status){n.ora&&n.ora.fail("Authentication failed");const t=await e.text();if(t.startsWith("{")){const e=JSON.parse(t);if("logged_in_machine_names"in e&&Array.isArray(e.logged_in_machine_names)){const t=e.logged_in_machine_names;$().fail(`You're already authenticated on ${t.length} other machine(s). Please logout from other machines first. You're currently logged in on: ${t.join(", ")}`)}}return o(null)}break;case"sign-out":if(400===e.status)return a=!0,bu(),n.ora&&(n.ora.text="User is signed-out"),o(!0)}else if(s++,s>c)return n.ora?n.ora.fail(`Failed to complete auth flow. Please try again. Make sure that port ${r.port} is not blocked`):n.silent||console.error(`Failed to complete auth flow. Please try again. Make sure that port ${r.port} is not blocked`),o(null);setTimeout(l,1e3)}).catch(e=>{s>=10&&console.debug("Error polling auth status: "+e.message)})}})}globalThis.fetch||(globalThis.fetch=e),globalThis.File||(globalThis.File=t),globalThis.crypto||(globalThis.crypto=n.webcrypto),function(e={}){var t,n,o;const i=null!=(t=e.proc)?t:process,a=null!=(n=e.log)?n:yp,r=null!=(o=e.error)?o:e=>console.error(e),s=(e,t)=>{const n=t instanceof Error&&t.message||String(t);try{const o=t instanceof Error&&t.stack?`\n${t.stack}`:"";a(`CLI crashed (${e}): ${n}${o}`)}catch{}try{r(`error: ${n}`)}catch{}try{i.exit(1)}catch{}};i.on("unhandledRejection",e=>s("unhandled rejection",e)),i.on("uncaughtException",e=>s("uncaught exception",e))}();const Wf=process.argv.includes("--silent"),Hf=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8")),Gf="The access token to use. Use the login command or get a token from https://cloud.needle.tools. You can pass the access token with your command or set the environment variable NEEDLE_CLOUD_TOKEN";async function Jf(e,t=null,n=!0){let o,i=null==e?void 0:e.toString();var a;if(i||(Ue.config(),process.env.NEEDLE_CLOUD_TOKEN&&(i=process.env.NEEDLE_CLOUD_TOKEN,null!=(a=i)&&a.length&&console.log("Using NEEDLE_CLOUD_TOKEN token from env"))),""===i||"true"===i){const e=(await import("node:readline")).createInterface({input:process.stdin}),t=10;let n,i="",a=!1;return new Promise(r=>{const s="Paste your https://cloud.needle.tools/team#token access token here:",c=$({text:s,interval:200,spinner:"moon"}).start();process.stdin.setRawMode(!0),process.stdin.on("data",l=>{const p=l.toString();""===p&&process.exit();const u="\n"===p||"\r"===p;if(!u&&"\n"!==p&&"\r"!==p){""===p||"\b"===p?i=i.slice(0,-1):i+=p;const e=i.replace(/./g,"*");c.text=`${s} ${e}`}clearTimeout(n),n=setTimeout(()=>{if(!a&&(u||i.trim().length>t)){process.stdin.setRawMode(!1),e.close(),a=!0;const t=i.trim();if(t.length>0){const e=t.slice(3,-3).replace(/./g,"*");c.succeed("Access token received: "+e)}else c.fail("No access token provided");r({accessToken:t,org_id:o})}},150)})})}if(!i){let e;await async function(){const e=await Lu();return null==e?void 0:e.isAuthenticated}()||(e=Wf?void 0:$("No access token found. Please sign in to authenticate...").start()),wp("No access token provided, attempting login. Org: "+t);const a=qf({headless:!n,ora:e,timeout:12e4}),d=await a;var r;if(d&&!await Vu(d)?(null==(r=e)||r.fail("You are not logged in from this machine. Please login again."),await Bf({headless:!0}),process.exit(1)):e&&(wp("User logged in via getAccessToken "+(null==d?void 0:d.isAuthenticated)),d?e.succeed("Logged in"):e.fail("Login failed")),null!=d&&d.isAuthenticated){var s;if(null==t){const e=await zu(d);"string"==typeof e&&(t=e)}else t===(null==(s=d.userInfo)?void 0:s.sub)&&(t=null);if(t){var c,l,p;if(o=null==(c=d.userInfo)||null==(c=c.organization_data)||null==(c=c.find(e=>e.id===t))?void 0:c.id,o||(t=null==(l=t.toString())?void 0:l.toLowerCase(),null!=o||(o=null==(p=d.userInfo)||null==(p=p.organization_data)||null==(p=p.find(e=>e.name.toLowerCase()===t))?void 0:p.id)),!o)throw new Error(`ERR: You (${Bu(d)}) are not a member of the team "${t}" or the team does not exist. Please check the team name/id and try again.`);i=await(null==d?void 0:d.client.getOrganizationToken(o)),wp("Getting access token for org "+o+", "+i.substring(0,8)+"...")}else{var u;wp("Getting access token for user "+(null==(u=d.userInfo)?void 0:u.sub)),i=null==d?void 0:d.accessToken}}}return i||(console.error("ERR: Missing NEEDLE_CLOUD_TOKEN token. Please provide the access token argument or set the environment variable NEEDLE_CLOUD_TOKEN. Get an access token for your team at https://cloud.needle.tools/team"),wp("ERR: Missing NEEDLE_CLOUD_TOKEN token. Org: "+o),process.exit(403)),{accessToken:i,org_id:o}}function Vf(e){return null!=e.org&&console.warn("Warning: --org is deprecated. Use --team instead."),e.team||e.org}const Kf=dt.program;async function Yf(){const{spawn:e}=await import("node:child_process");e(process.execPath,[process.argv[1],"start","--integration","cli-login"],{stdio:"inherit",env:{...process.env,NEEDLE_CLOUD_TOKEN:process.env.NEEDLE_CLOUD_TOKEN||""}}),await new Promise(e=>setTimeout(e,1e3))}Kf.version(Hf.version).description("Command-line interface (CLI) for Needle Cloud"),Kf.command("version","Print the CLI version").configure({visible:!1}).action(()=>{Wf||console.log(`☁ Needle CLI — ${Hf.version}, Node ${process.version}`)}),Kf.command("start","Starts the Needle Auth server").alias("start-server").configure({visible:!1,strictOptions:!1}).help("Start the local server for Needle Cloud. This is required to authenticate with Needle Cloud and access your account and data.").option("--restart <restart>","Restarts the server",{required:!1,validator:Kf.BOOLEAN,default:!1}).option("--integration <integration>","Hint for the process which integration triggered this command",{required:!1,validator:Kf.STRING}).action(async({options:e})=>{const t=e.integration,n=Wf?void 0:$("Starting Needle License server "+(t?`(from ${t})`:"")).start();Ff({ora:n,restart:e.restart}).catch(e=>{console.error("Failed to start server:",e),null==n||n.fail("Failed to start server: "+e.message),process.exit(1)}).then(e=>{null!=e&&e.baseUrl&&e.isHost?null==n||n.succeed(`Server started on ${e.baseUrl} (v${cd()}, built ${function(e){if("string"!=typeof Pf||0===Pf.length)return"unknown";const t=new Date(Pf);if(Number.isNaN(t.getTime()))return"unknown";const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}()})`):!1===(null==e?void 0:e.isHost)?(t||null==n||n.warn(`Server is running on ${e.baseUrl||e.port}`),process.exit(0)):(null==n||n.fail("Failed to start server"),process.exit(1))})}),Kf.command("settings","Show current Needle CLI settings").action(async()=>{const{readSettings:e,KNOWN_SETTINGS:t}=await Promise.resolve().then(function(){return nm}),n=e();for(const[e,o]of Object.entries(t)){const t=n[e],i=void 0!==t?String(t):o.default;console.log(`\n ${"enabled"===i?"[x]":"[ ]"} ${o.displayName}: ${i}${void 0===t?" (default)":""}`),console.log(` ${o.description}`),console.log(` Change: ${o.command}`)}console.log("")}),Kf.command("settings remote-ai-tools","Enable or disable cloud AI tool dispatch to this machine").help("When disabled, the CLI does NOT connect to the Needle Cloud AI tool dispatcher (wss://cloud.needle.tools/v1/cli/ws), so cloud-side AI chats cannot invoke tools (file reads, grep, etc.) on this machine. The local /mcp/ws endpoint used by Unity/Blender stays available. Setting persists in ~/.needle/settings.json.").argument("<enabled>","true to enable, false to disable",{validator:Kf.BOOLEAN}).action(Np("settings remote-ai-tools",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return nm}),o=e.enabled,i=n();o?(t(i,"remote_ai_tools",null),console.log("Remote AI tools enabled (default)."),wp("Settings: remote_ai_tools set to enabled (default) via CLI command")):(t(i,"remote_ai_tools","disabled"),console.log("Remote AI tools disabled. The cloud AI chat will not be able to dispatch tools to this machine."),wp("Settings: remote_ai_tools set to disabled via CLI command"))})),Kf.command("settings local-file-edits","Enable or disable AI file changes on this machine").help("This local setting is checked for every AI write, delete, rename, Undo, and Redo. Cloud chat approval cannot override it. Persists in ~/.needle/settings.json.").argument("<enabled>","true to enable, false to disable",{validator:Kf.BOOLEAN}).action(Np("settings local-file-edits",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return nm}),o=e.enabled;t(n(),"local_file_edits",o?null:"disabled"),console.log(`Local AI file edits ${o?"enabled":"disabled"}.`)})),Kf.command("settings local-project-commands","Enable or disable approved AI project commands on this machine").help("Allows separately approved AI package installs, project creation, builds, and deploys. Enabled by default; Cloud chat approval cannot override this setting. Persists in ~/.needle/settings.json.").argument("<enabled>","true to enable, false to disable",{validator:Kf.BOOLEAN}).action(Np("settings local-project-commands",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return nm}),o=e.enabled;t(n(),"local_project_commands",o?null:"disabled"),console.log(`Local AI project commands ${o?"enabled":"disabled"}.`)})),Kf.command("status","Show the local Needle server status and process ID").action(Np("status",async()=>{const{getLocalServerStatus:e,formatLocalServerStatus:t}=await Promise.resolve().then(function(){return Nf});console.log(t(await e()))})),Kf.command("mcp","Start MCP server for AI agents (stdio transport)").help('Start the Needle Cloud MCP server using stdio transport.\nReuses or starts the shared local server for Inspector/Unity tools and cloud connections.\nThis is the standard way to connect AI agents (Claude Desktop, Cursor, VS Code, etc.).\n\nAdd to your MCP client config:\n{\n "mcpServers": {\n "needle": {\n "command": "npx",\n "args": ["-y", "needle-cloud", "mcp"]\n }\n }\n}').action(Np("mcp",async()=>{const{startStdio:e}=await Promise.resolve().then(function(){return yf});e()})),Kf.command("get-project-id","Gets the project id for a local project").configure({visible:!1,strictOptions:!1}).argument("<paths...>","The path to the local project (web project directory)").action(async({args:e})=>{const t=df(e.paths);t?console.log(`Found project ID: "${t}"`):console.log("No project ID found.")}),Kf.command("send-logs","Upload CLI, editor, and optimization-pipeline logs to Needle (secrets and sensitive info redacted)").help("Stream the current and previous CLI log, the most recent editor log (Unity or Blender), and the optimization-pipeline log to Needle for support diagnosis. Before upload, tokens, Bearer/Authorization values, UUIDs, home-directory paths, email addresses, Username/User fields, and *_KEY / *_TOKEN / *_SECRET / *_PASSWORD env-var values are redacted (replaced with <redacted:Nch> so the length is preserved for debugging). Returns a reference ID to paste into your bug report. Requires sign-in; the upload is tagged with your Needle account.").option("--crash <crash>","Mark this upload as a crash report (uses the crash-mode daily quota)",{required:!1,validator:Kf.BOOLEAN,default:!1}).option("--note <note>","One-line note attached to the upload",{required:!1}).option("--dry-run <dryRun>","Print the redacted payload without uploading",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(Np("send-logs",async({options:e})=>{var t,n,o,i,a,r,s;const{runSendLogs:c,HAYSTACK_RESOURCE:l}=await Promise.resolve().then(function(){return mu}),{tryGetFreshAccessTokenForResource:p}=await Promise.resolve().then(function(){return qu}),{findActiveEditorLog:u}=await import("./cli.send-logs.discovery-11259aaf.js"),{getLogFilePath:d,getPrevLogsFilePath:m,getPipelineLogFilePath:f}=await Promise.resolve().then(function(){return _p}),{homedir:h,platform:g}=await import("os"),{existsSync:v}=await import("fs"),{BUILD_TIME:b}=await Promise.resolve().then(function(){return Uf}),{getNodeVersion:x,getNpmVersion:y,getArch:w,getOsRelease:_,getCpuCount:j,getTotalMemoryMb:k,getTzOffsetMinutes:S,isCi:E,isTty:T}=await import("./cli.runtime-465aa7a3.js"),I=null!=(t=null!=(n=null==(o=e.crash)||null==o.valueOf?void 0:o.valueOf())?n:e.crash)&&t?"crash":"normal",O=e.note,A=null!=(i=null!=(a=null==(r=e.dryRun)||null==r.valueOf?void 0:r.valueOf())?a:e.dryRun)&&i,C=d(),R=m(),N=f(),P={getAccessToken:()=>p(l),fetch:globalThis.fetch,paths:{cliLogPath:v(C)?C:null,prevLogPath:v(R)?R:null,pipelineLogPath:v(N)?N:null,homeDir:h()},meta:{cli_version:cd(),build_time:b,os:g(),os_release:_(),arch:w(),node_version:x(),npm_version:null!=(s=y())?s:"unknown",cpu_count:j(),total_memory_mb:k(),tz_offset_minutes:S(),is_ci:E(),is_tty:T()},findActiveEditorLog:u,stdout:process.stdout,stderr:process.stderr},U=A?"Building payload (dry-run)":"Uploading logs",L=Wf?void 0:$(U).start();P.recoverAuth=async()=>{null==L||L.stop();try{await Yf();const e=await qf({clearAuthData:!0,silent:Wf,ora:void 0});if(null==e||!e.isAuthenticated)return null}catch(e){return wp(`send-logs: auto-recovery login failed: ${e instanceof Error?e.message:e}`),null}finally{null==L||L.start(U)}return await p(l)};const z=await c({mode:I,note:O,dryRun:A},P);z.ok?A?null==L||L.succeed("Dry-run payload printed above. Nothing was uploaded."):z.truncated?(null==L||L.warn(`Uploaded (truncated at server cap). Reference: ${z.refId}`),console.log(`Share ${z.refId} in your bug report.`)):(null==L||L.succeed(`Uploaded. Reference: ${z.refId}`),console.log(`Share ${z.refId} in your bug report.`)):(null==L||L.fail(z.error||"Upload failed"),process.exitCode=1)})),Kf.command("login","Login to Needle Cloud").help("Login to Needle Cloud. If you are already logged in, this will refresh the access token.").option("--headless <headless>","The headless process will not open a browser window to login. If the user is not authorized then no auth flow can be started. Use this if you only want to **check** if the user is authenticated",{required:!1,validator:Kf.BOOLEAN,default:!1}).option("--clear <clear>","Refresh the access token",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(async({options:e})=>{await Yf();const t=e.headless.valueOf()||!1,n=e.clear.valueOf()||!1,o=Wf?void 0:$("Login").start();await qf({headless:t,silent:Wf,clearAuthData:n,ora:o}).then(async e=>{null!=e&&e.isAuthenticated?null==o||o.succeed("Successfully logged in as "+Bu(e)):0==t?null!=e&&e.claims||null!=e&&e.userInfo?null==o||o.warn(`You (${Bu(e)}) are not authenticated...`):null==o||o.fail("Login failed"):Wf||null==o||o.warn("Not logged in"),process.exit(null!=e&&e.isAuthenticated?0:1)})}),Kf.command("logout","Logout of Needle Cloud").help("Logout of Needle Cloud (if you have logged in before).").option("--headless <headless>","Headless will not open a browser window to logout",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(async({options:e})=>{await Yf();const t=e.headless.valueOf()||!1;await Bf({headless:t}).then(e=>{e?$("Logged out").succeed():$("Logout failed").fail(),process.exit(e?0:1)})}),Kf.command("me","Prints your user information").help("Prints basic informaton about the logged in Needle Cloud account (your account)").action(async({})=>{const e=Wf?void 0:$("Query user data").start(),t=await Lu();if(null!=t&&t.isAuthenticated&&await Vu(t)){const a=t.userInfo||t.claims;var n,o,i;a?(null==e||e.succeed(`You are logged in as ${Bu(t)}`),console.log(`- Name: ${Bu(t)}`),console.log(`- ID: ${a.sub}`),a.email&&console.log(`- Email: ${a.email}`),a.phone_number&&console.log(`- Phone: ${a.phone_number}`),null!=(n=t.userInfo)&&n.organization_data&&console.log(`- Teams [${null==(o=t.userInfo)?void 0:o.organization_data.length}]: ${null==(i=t.userInfo)?void 0:i.organization_data.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.name).join(", ")}`)):null==e||e.fail("Failed to get user data")}else null==e||e.warn("You are not logged in")}),Kf.command("get-pro","Start license flow for Needle Engine PRO").configure({visible:!1,strictArgsCount:!1,strictOptions:!1}).option("--team <team>","The team to purchase the license for",{validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{validator:Kf.STRING,hidden:!0}).action(Np("get-pro",async({options:e})=>{var t;let n=(null==(t=Vf(e))?void 0:t.toString())||null;const o=$().start("Start Needle Engine PRO purchase flow"),i=function(e){e=e||{};const t="undefined"!=typeof window?window.location:null;"current_page"===e.baseUrl&&(e.baseUrl=null==t?void 0:t.href);let n=e.pathname||(null==t?void 0:t.pathname),o=e.baseUrl||(null==t?void 0:t.href);if(!n||!o)return null;const i=new URL(n,o);return t&&(i.search=t.search),e.license||(e.license="needle-engine:pro"),i.searchParams.set("purchase_intent",e.license),e.account_id&&i.searchParams.set("account_id",e.account_id),e.return_url&&i.searchParams.set("return_url",e.return_url),e.checkout_if_possible&&i.searchParams.set("checkout_if_possible","true"),e.show_all_cards&&i.searchParams.set("show_all_cards","true"),e.affiliate_id&&i.searchParams.set("affiliate_id",e.affiliate_id),e.tracking_id&&i.searchParams.set("tracking_id",e.tracking_id),i}({baseUrl:"https://cloud.needle.tools",pathname:n?`/team/${n}`:"/account",account_id:n,license:"needle-engine:pro",return_url:null});if(!i)return void o.fail("Failed to get purchase url - please visit https://cloud.needle.tools");const a=i.toString();o.succeed(`Started Needle Engine PRO purchase flow: opening browser at ${a}`),ap(a)}));const Zf={account:{url:op}},Xf=`"${Object.keys(Zf).join('", "')}"`;Kf.command("open",`Open a page in the default browser. Options are: ${Xf}`).argument("<page>",`The page to open. Options are: ${Xf}`,{validator:Kf.STRING}).configure({strictOptions:!1,strictArgsCount:!1,visible:!1}).help("").action(async({args:e,logger:t})=>{const n=e.page.toString(),o=Zf[n];o?"url"in o?ap(o.url()):t.error(`Unknown argument: ${n}`):t.error(`Unknown argument: ${n}. Options are: ${Xf}`)}),Kf.command("list-deployments","Get a list of deployed websites").configure({visible:!1}).help("").option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).option("--limit <limit>","Limit the number of deployments to show (min: 0, max: 100)",{validator:Kf.NUMBER,default:10}).option("--offset <offset>","The offset for deployments (default: 0, min: 0)",{validator:Kf.NUMBER,default:0}).option("--format <format>","The output format. Options: cli (default), json",{validator:Kf.STRING,default:"cli",hidden:!0}).option("--name","Filter by one or multiple deployment names (separated by ;)",{validator:Kf.STRING}).action(async({options:e,logger:t})=>{var n,o,i;const{accessToken:a,org_id:r}=await Jf(e.token,Vf(e)),s=(null==(n=e.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",c=e.limit.valueOf(),l=e.offset.valueOf(),p=(null==(o=e.format)?void 0:o.toString())||"cli",u=(null==(i=e.name)?void 0:i.toString())||void 0;if(c<0)return void t.error("The limit can not be negative");if(c>100)return void t.error("The limit can not be higher than 100");const d=$("Query deployments").start(),m=await Bp({endpoint:s,authToken:a,org:r,limit:c,offset:l,names:null==u?void 0:u.split(";")}).catch(e=>{t.error(e)});if(m&&"error"in m)d.fail(m.error+" (status: "+m.status+")");else if(m){if("json"===p){d.succeed(`Found ${m.deployments.length} deployments`);const e=JSON.stringify(m.deployments);return void console.log(e)}m.deployments.length>0?(d.succeed(`Found ${m.deployments.length} deployments`),m.deployments.forEach((e,n)=>{t.info(`${n+c*l}: ${e.name} – ${e.url}`)})):d.warn("No deployments found"),process.exit(0)}else d.fail("Failed to query deployments"),process.exit(1)}),Kf.command("list","List content items (3d assets, deployments, materials, etc.)").alias("list-content").help('List content items stored in Needle Cloud.\n\nUse --type to filter by content type (e.g. "material", "3d-asset", "deployment").\nUse --format to filter by output format (e.g. "glb", "textures").\nUse --include-projects to include saved web projects; --type editor-project selects only projects.').option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).option("--include-projects","Include saved web projects (default: uploaded content only)",{validator:Kf.BOOLEAN,default:!1}).option("--type <type>","Filter by content type (e.g. material, 3d-asset, deployment, editor-project)",{required:!1,validator:Kf.STRING}).option("--format <format>","Filter by output format (e.g. glb, textures)",{required:!1,validator:Kf.STRING}).option("--search <search>","Search by name, title or description",{required:!1,validator:Kf.STRING}).option("--limit <limit>","Max number of items to show (default: 20, max: 100)",{validator:Kf.NUMBER,default:20}).option("--offset <offset>","Offset for pagination (default: 0)",{validator:Kf.NUMBER,default:0}).option("--output <output>","Output style: cli (default), json",{validator:Kf.STRING,default:"cli"}).action(async({options:e,logger:t})=>{var n,o,i,a,r,s,c,l,p;const{accessToken:u,org_id:d}=await Jf(e.token,Vf(e)),m=(null==(n=e.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",f=Math.min(null!=(o=null==(i=e.limit)?void 0:i.valueOf())?o:20,100),h=null!=(a=null==(r=e.offset)?void 0:r.valueOf())?a:0,g=(null==(s=e.output)?void 0:s.toString())||"cli",v=(null==(c=e.type)?void 0:c.toString())||void 0,b=(null==(l=e.format)?void 0:l.toString())||void 0,x=(null==(p=e.search)?void 0:p.toString())||void 0,y=$("Querying content...").start();try{const n=await ql({baseUrl:m,authToken:u,org:d},{content_type:v,include_projects:!0===e.includeProjects,content_format:b,search:x,limit:f,offset:h});if("json"===g)return y.succeed(`Found ${n.items.length} of ${n.total} items`),void console.log(JSON.stringify(n.items,null,2));0===n.items.length&&(y.warn("No content found"+(v?` (type: ${v})`:"")+(b?` (format: ${b})`:"")),process.exit(0)),y.succeed(`Found ${n.items.length} of ${n.total} items`);const o=n.items.map(e=>{var t;const n=e.title||"(untitled)";return{id:e.identifier,type:e.content_type||"?",formats:null!=(t=e.content_formats)&&t.length?e.content_formats.join(", "):"",name:n.length>20?n.slice(0,17)+"...":n,versions:String(e.version_count||0),date:e.created_at?dl(new Date(e.created_at),new Date,{allowSimple:!0,limitInDays:2}):""}}),i={id:Math.max(2,...o.map(e=>e.id.length)),type:Math.max(4,...o.map(e=>e.type.length)),formats:Math.max(7,...o.map(e=>e.formats.length)),name:Math.max(4,...o.map(e=>e.name.length))},a=Hp(` ${"ID".padEnd(i.id)} ${"TYPE".padEnd(i.type)} ${"FORMATS".padEnd(i.formats)} ${"NAME".padEnd(i.name)} ${"#".padStart(3)} AGE`);t.info(a);for(const e of o){const n=Wp(e.type).padEnd(i.type+11),o=(e.formats?e.formats.split(", "):[]).map(e=>Wp(e)).join(", ")+" ".repeat(Math.max(0,i.formats-e.formats.length));t.info(` ${Hp(e.id.padEnd(i.id))} ${n} ${o} ${e.name.padEnd(i.name)} ${e.versions.padStart(3)} ${Hp(e.date)}`)}n.total>h+f&&t.info(` ... ${n.total-h-f} more (use --offset ${h+f})`),process.exit(0)}catch(e){y.fail(e.message),process.exit(1)}}),Kf.command("delete","Move a content item to the trash").help("Move a content item to the trash. This immediately frees total storage capacity but does not refund monthly usage. The item can be restored for 31 days if enough total storage is available.\n\nUsage:\n needle-cloud delete <identifier>").argument("<identifier>","Content item identifier",{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The Needle Cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).action(async({args:e,options:t})=>{var n;const{accessToken:o,org_id:i}=await Jf(t.token,Vf(t)),a=(null==(n=t.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",r=e.identifier.toString(),s=$(`Deleting content "${r}"...`).start();try{const e=await qp({identifier:r,endpoint:a,authToken:o,org:i});s.succeed(e.message||`Moved content "${r}" to the trash`),process.exit(0)}catch(e){s.fail(e.message),process.exit(1)}}),Kf.command("download","Download a content item by identifier").help('Download files from a content item.\n\nUse --format to select which output format to download (e.g. "glb", "textures").\n\nUsage:\n needle-cloud download <identifier> [directory]\n needle-cloud download abc123 --format glb').argument("<identifier>","Content item identifier",{validator:Kf.STRING}).argument("[directory]","Output directory (default: current directory)",{default:"."}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING}).option("--format <format>","Output format to download (e.g. glb, textures)",{required:!1,validator:Kf.STRING}).option("--name <name>","Output filename (without extension)",{required:!1,validator:Kf.STRING}).option("--verbose","Show detailed download info",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(async({args:e,options:t,logger:n})=>{var o,i,a,r,s,c;const{accessToken:l,org_id:p}=await Jf(t.token,Vf(t)),u=(null==(o=t.endpoint)?void 0:o.toString())||"https://cloud.needle.tools/api",d=e.identifier.toString(),m=(null==(i=e.directory)?void 0:i.toString())||".",f=(null==(a=t.name)?void 0:a.toString())||void 0,h=null!=(r=null==(s=t.verbose)?void 0:s.valueOf())&&r,g=(null==(c=t.format)?void 0:c.toString())||void 0,v=$("Looking up content...").start();try{var b;const e={baseUrl:u,authToken:l,org:p},t=await Bl(e,d).catch(()=>null);if(!t)return void v.fail(`Content not found: "${d}". Use the exact content identifier (see list-content).`);const o=null==(b=t.versions)?void 0:b[0];if(!o)return void v.fail(`Content "${t.title||t.name}" has no versions`);let i=o.identifier;if(g){let e=!1;for(const n of t.versions){if(n.content_format===g){i=n.identifier,e=!0;break}const t=n.variants.find(e=>e.content_format===g);if(t){i=t.identifier,e=!0;break}}if(!e)return void v.fail(`No output with format "${g}" found for "${t.title||t.name}"`)}v.text=`Downloading "${t.title||t.name}"${g?` (format: ${g})`:""}...`,v.stop();const a=await Lp({baseUrl:u,authToken:l,org:p,identifier:i,outDir:m,filename:f,verbose:h,content_format:g});"error"in a&&n.error(a.error)}catch(e){v.fail(e.message)}}),Kf.command("deploy","Deploy a website to Needle").help("").argument("<directory>","The directory to deploy",{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to deploy to (not needed when using token/accesstoken)",{required:!1,validator:Kf.STRING}).option("--org <org>","The organization name or id to deloy to (not needed when using token/accesstoken)",{required:!1,validator:Kf.STRING,hidden:!0}).option("--name <name>","The project name. This name will also be used in your website URL",{required:!1,validator:Kf.STRING}).option("--entrypoint <entrypoint>",'The entrypoint file to use (e.g. "index.html"). This is useful if you want to deploy a folder with multiple HTML files and you want to configure which file to load initially or if you have multiple model files in one folder',{required:!1,validator:Kf.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Kf.STRING,hidden:!0}).option("--open","Open the deployment in the default browser",{default:!0,validator:Kf.BOOLEAN}).option("--verbose <verbose>","Enables verbose output logs",{required:!1,validator:Kf.BOOLEAN,default:!1,hidden:!0}).option("--experimental","Use the experimental upload API. Mostly used for debugging (default: false)",{required:!1,validator:Kf.BOOLEAN,default:!1,hidden:!0}).option("--raw","Use raw to disallow modifications like gzip compression on upload",{required:!1,validator:Kf.BOOLEAN,default:!1,hidden:!0}).option("--no-provenance","Do not record which commit and CI run this deployment came from",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(Np("deploy",async({args:e,options:t,logger:n})=>{var o,i,a,r;const s=t.open,{accessToken:c,org_id:l}=await Jf(t.token,Vf(t)),p=t.verbose.valueOf(),u=t.experimental.valueOf()||!1,d=t.raw.valueOf()||!1,m=(null==(o=t.noProvenance)?void 0:o.valueOf())||!1;await kp({logger:n,endpoint:(null==(i=t.endpoint)?void 0:i.toString())||void 0,token:c,org_id:l,directory:e.directory.toString(),name:(null==(a=t.name)?void 0:a.toString())||void 0,entrypoint:(null==(r=t.entrypoint)?void 0:r.toString())||void 0,open:s,verbose:p||!1,experimental:u||!1,raw:d||!1,noProvenance:m})})),function(e,t){for(const n of["upload","optimize"]){const o="optimize"===n,i=e.command(n,o?"Upload and wait for optimized assets (shorthand for upload --wait)":"Upload source assets to Needle Cloud").help("Upload returns source file identities and links after the transfer completes. Optimization continues in the background. Use upload --wait or optimize to wait for the selected optimized variant. Folders are collected recursively into one grouped upload. Use --format json for its file list. Original links always identify the uploaded source version.").argument("<path>","File or folder to upload",{validator:e.STRING}).option("--token <token>","Access token; also accepts NEEDLE_CLOUD_TOKEN or a saved login",{validator:e.STRING}).option("--team <team>","Team name or ID",{validator:e.STRING}).option("--org <org>","Organization name or ID (deprecated; use --team)",{validator:e.STRING,hidden:!0}).option("--name <name>","Upload name or identifier of an existing asset",{validator:e.STRING}).option("--format <format>","Output: cli (default), json, source-url, edit-url. Diagnostics go to stderr.",{validator:e.STRING,default:"cli"}).option("--outdir <outdir>","Download optimized files to this directory (requires waiting)",{validator:e.STRING}).option("--progressive","Use progressive loading when waiting for optimization",{validator:e.BOOLEAN,default:!!o||void 0}).option("--usecase <usecase>","Optimization variant: product or world (requires waiting)",{validator:e.STRING,default:o?"product":void 0}).option("--verbose <verbose>","Print detailed diagnostics to stderr",{validator:e.BOOLEAN,default:!1});o||i.option("--wait","Wait for the selected optimized result",{validator:e.BOOLEAN,default:!1}).option("--no-optimize","Store source files without requesting processing",{validator:e.BOOLEAN,default:!1}),i.action(Np(n,async({args:e,options:n})=>{var i;const a=globalThis.console,r=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Ne({stdout:r,stderr:r});try{var s,c,l;const i=String(null!=(s=n.format)?s:"cli");if("cli"!==i&&"json"!==i&&"source-url"!==i&&"edit-url"!==i)throw new Error("Invalid --format. Use cli, json, source-url or edit-url.");const a=o||!0===n.wait;if(a&&!0===n.noOptimize)throw new Error("--wait cannot be combined with --no-optimize.");if(!a&&(void 0!==n.outdir||void 0!==n.progressive||void 0!==n.usecase))throw new Error("--wait is required for --outdir, --progressive and --usecase.");const r=n.usecase;if(void 0!==r&&"product"!==r&&"world"!==r)throw new Error("Use case must be product or world.");void 0!==n.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:u,org_id:d}=await t.getAccessToken(n.token,n.team||n.org);if(u!==n.token&&u!==process.env.NEEDLE_CLOUD_TOKEN){const e=await t.getUser();if(null==e||!e.isAuthenticated)throw new Error("Please login to upload files.");if(!d)throw new Error("Please provide a team to upload files.");if(a){var p;const e=await(null!=(p=t.getLicenses)?p:vt)({baseUrl:"https://cloud.needle.tools/api",authToken:u,org:d},{type:"org",org_id:d});if(null==e||!e.some(e=>"Needle Engine"===e.type&&("pro"===e.license||"enterprise"===e.license)))throw new Error("Update to Needle PRO or Enterprise required to optimize files via CLI. Visit https://cloud.needle.tools/get-pro")}}Fp(await(null!=(c=t.upload)?c:zp)({token:u,org_id:d,fileOrDirectory:String(e.path),name:void 0===n.name?void 0:String(n.name),wait:a,noOptimize:!0===n.noOptimize,progressive:void 0===n.progressive?void 0:!0===n.progressive,usecase:r,outDir:void 0===n.outdir?void 0:String(n.outdir),verbose:!0===n.verbose,format:i}),i,null!=(l=t.write)?l:e=>{process.stdout.write(e)})}finally{globalThis.console=a}}))}}(Kf,{getAccessToken:Jf,getUser:Lu}),function(e,t){e.command("label","List, create or move content labels");for(const n of["list","set"]){const o=e.command(`label ${n}`,"list"===n?"List content labels and their source/derived URLs":"Create or move a label to a completed content version").argument("<content-id>","Content item identifier",{validator:e.STRING}).option("--token <token>","Access token; also accepts NEEDLE_CLOUD_TOKEN or a saved login",{validator:e.STRING}).option("--team <team>","Team name or ID",{validator:e.STRING}).option("--org <org>","Organization name or ID (deprecated; use --team)",{validator:e.STRING,hidden:!0}).option("--format <format>","Output: cli (default) or json. Diagnostics go to stderr.",{validator:e.STRING,default:"cli"});"set"===n&&o.argument("<label>","Destination label; latest is managed automatically",{validator:e.STRING}).option("--version <version>","Completed version ID from this content item",{validator:e.STRING}).option("--from <label>","Select the version currently targeted by this label (for example latest)",{validator:e.STRING}).help("Provide exactly one of --version or --from. Moving a label also updates its related completed outputs. Both read and write access are required."),o.action(Np(`label ${n}`,async({args:e,options:o})=>{var i;const a=globalThis.console,r=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Ne({stdout:r,stderr:r});try{var s,c;const i=String(null!=(s=o.format)?s:"cli");if("cli"!==i&&"json"!==i)throw new Error("Invalid --format. Use cli or json.");const a=String(e.contentId);$p(a);const r={contentId:a,label:String(e.label),versionId:void 0===o.version?void 0:String(o.version),from:void 0===o.from?void 0:String(o.from)};"set"===n&&Tp(r),void 0!==o.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:u,org_id:d}=await t.getAccessToken(o.token,o.team||o.org),m={baseUrl:"https://cloud.needle.tools/api",authToken:u,org:d},f=null!=(c=t.write)?c:e=>{process.stdout.write(e)};if("list"===n){var l;const e=await(null!=(l=t.listContentLabels)?l:Ap)(m,a);if("json"===i)f(JSON.stringify(e)+"\n");else if(e.labels.length)for(const t of e.labels)f(`${t.label}: ${t.sourceVersionIds.join(", ")}\n`),Up(t.targets,f);else f(`No labels for ${a}.\n`)}else{var p;const e=await(null!=(p=t.setContentLabel)?p:Cp)(m,r);"json"===i?f(JSON.stringify(e)+"\n"):(f(`${e.label}: ${e.previousVersionIds.join(", ")||"(new label)"} -> ${e.versionId}\n`),Up(e.targets,f))}}finally{globalThis.console=a}}))}}(Kf,{getAccessToken:Jf}),Kf.command("generate-material","Generate a PBR material from a text prompt").help("").argument("<prompt>","The text prompt describing the material to generate",{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Kf.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Kf.STRING,hidden:!0}).option("--resolution <resolution>","The material texture resolution (256, 512, 1k, 2k, 4k)",{default:"512",required:!1,validator:Kf.STRING}).option("--name <name>","Output filename",{required:!1,validator:Kf.STRING}).option("--outdir <outdir>","Output directory to download the generated file(s) to. If not set, the job ID is printed instead.",{required:!1,validator:Kf.STRING}).action(Np("generate-material",async({args:e,options:t,logger:n})=>{var o,i,a;const{accessToken:r,org_id:s}=await Jf(t.token,Vf(t)),c=e.prompt.toString(),l=null==(o=t.resolution)?void 0:o.toString(),p=null==(i=t.outdir)?void 0:i.toString(),u=null==(a=t.name)?void 0:a.toString(),d=await async function(e){if(!e.token||e.token.length<=1||"string"!=typeof e.token||"true"===e.token)return{error:`Missing access token. Create a token at ${op()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";wp(`[generate-material] Starting request to ${t}, prompt="${e.prompt}", resolution=${e.resolution||512}`,{emptyLineBefore:!0});const n=$("Requesting material generation...").start(),o=await Promise.race([Dl({baseUrl:t,authToken:e.token,org:e.org_id,trigger_type:"cli"},{prompt:e.prompt,resolution:e.resolution||512}).catch(e=>({error:e.message||"Request failed"})),new Promise(e=>setTimeout(()=>e({error:"Request timed out after 30s. Please try again."}),3e4))]);if("error"in o)return wp(`[generate-material] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(wp(`[generate-material] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return wp(`[generate-material] Job canceled: ${i.status_message||"quota exceeded"}`),n.fail(i.status_message||"Material generation was canceled (quota exceeded)"),{error:i.status_message||"Quota exceeded"};n.succeed(`Material generation requested: ${i.identifier}`);const a=$("Waiting for material generation...").start();a.color="gray";const r=jc();for(;;){if("completed"===i.status){a.succeed("Material generation completed");break}let n=2e3;const o=await _c(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=r.record(o);if(s)return a.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))a.text="Your material is queued - waiting for generation to start",a.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))a.text=`Generating material: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,a.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){wp(`[generate-material] Job completed: ${i.identifier}`),a.succeed(`Material generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return wp(`[generate-material] Job canceled: ${i.identifier}, error=${o.error}`),a.fail(`Material generation canceled: ${o.error||""}`),{error:o.error||"Material generation canceled"};if("failed"===(null==o?void 0:o.status))return wp(`[generate-material] Job failed: ${i.identifier}, error=${o.error}`),a.fail(`Material generation failed: ${o.error||""}`),{error:o.error||"Material generation failed"}}await ul(n)}if(e.outDir){const n=await Lp({baseUrl:t,authToken:e.token,org:e.org_id,identifier:i.identifier,outDir:e.outDir,filename:e.outputName});if("error"in n)return{error:n.error}}return{success:!0,identifier:i.identifier}}({logger:n,token:r,org_id:s,prompt:c,resolution:l,outputName:u,outDir:p});"error"in d&&(d.error&&n.error(d.error),process.exit(1)),!p&&d.identifier&&console.log(d.identifier),process.exit(0)})),Kf.command("generate-3d","Generate a 3D model from a text prompt").help("").argument("<prompt>",'A description of the object to generate, e.g. "a weathered wooden crate with iron bands"',{validator:Kf.STRING}).option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Kf.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Kf.STRING,hidden:!0}).option("--quality <quality>","Quality tier: standard (default, includes physically based material maps) or draft (faster and cheaper, base color only)",{default:"standard",required:!1,validator:Kf.STRING}).option("--face-count <faceCount>","Target polygon count (40000-1500000). Leave unset to let the generator choose.",{required:!1,validator:Kf.NUMBER}).option("--name <name>","Output filename",{required:!1,validator:Kf.STRING}).option("--outdir <outdir>","Output directory to download the generated file(s) to. If not set, the job ID is printed instead.",{required:!1,validator:Kf.STRING}).action(Np("generate-3d",async({args:e,options:t,logger:n})=>{var o,i,a;const{accessToken:r,org_id:s}=await Jf(t.token,Vf(t)),c=e.prompt.toString(),l=null==(o=t.quality)?void 0:o.toString(),p=null!=t.faceCount?Number(t.faceCount):void 0,u=null==(i=t.outdir)?void 0:i.toString(),d=null==(a=t.name)?void 0:a.toString(),m=await async function(e){if(!e.token||e.token.length<=1||"string"!=typeof e.token||"true"===e.token)return{error:`Missing access token. Create a token at ${op()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";wp(`[generate-3d] Starting request to ${t}, prompt="${e.prompt}", quality=${e.quality||"draft"}`,{emptyLineBefore:!0});const n=$("Requesting 3D generation...").start(),o=await async function(e,t){var n;if(null!=(n=e.signal)&&n.aborted)return{error:"The 3D generation request was cancelled"};const o=e.baseUrl+ft.jobs.create,i={...ht(e),"content-type":"application/json"},a={type:"ai-3d-asset",triggered_by:e.trigger_type,parameters:{...t}},r=await fetch(o,{...gt,method:"POST",headers:i,body:JSON.stringify(a),signal:e.signal}).catch(e=>function(e){return"AbortError"===(null==e?void 0:e.name)||"TimeoutError"===(null==e?void 0:e.name)}(e)?{__aborted:!0}:(console.error(`Failed to request 3D asset generation: ${null==e?void 0:e.message}`),{__failed:(null==e?void 0:e.message)||"Request failed"}));if("__aborted"in r)return{error:"The 3D generation request was cancelled"};if("__failed"in r)return{error:r.__failed};if(!r.ok){const e=await r.text();return console.error(`Failed to request 3D asset generation (${r.status}): ${e}`),{error:e||`Request failed (${r.status})`}}const s=await r.json().catch(e=>(console.error(e),null));return null!=s&&s.job?s:{error:"The server did not return a job"}}({baseUrl:t,authToken:e.token,org:e.org_id,trigger_type:"cli",signal:AbortSignal.timeout(3e4)},{prompt:e.prompt,...e.quality?{quality:e.quality}:{},...e.face_count?{face_count:e.face_count}:{}});if("error"in o)return wp(`[generate-3d] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(wp(`[generate-3d] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return wp(`[generate-3d] Job canceled: ${i.status_message||"quota exceeded"}`),n.fail(i.status_message||"3D generation was canceled (quota exceeded)"),{error:i.status_message||"Quota exceeded"};n.succeed(`3D generation requested: ${i.identifier}`);const a=$("Waiting for the 3D model...").start();a.color="gray";const r=jc();for(;;){if("completed"===i.status){a.succeed("3D generation completed");break}let n=2e3;const o=await _c(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=r.record(o);if(s)return a.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))a.text="Your model is queued - waiting for generation to start",a.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))a.text=`Generating 3D model: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,a.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){wp(`[generate-3d] Job completed: ${i.identifier}`),a.succeed(`3D generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return wp(`[generate-3d] Job canceled: ${i.identifier}, error=${o.error}`),a.fail(`3D generation canceled: ${o.error||""}`),{error:o.error||"3D generation canceled"};if("failed"===(null==o?void 0:o.status))return wp(`[generate-3d] Job failed: ${i.identifier}, error=${o.error}`),a.fail(`3D generation failed: ${o.error||""}`),{error:o.error||"3D generation failed"}}await ul(n)}if(e.outDir){const n=await Lp({baseUrl:t,authToken:e.token,org:e.org_id,identifier:i.identifier,outDir:e.outDir,filename:e.outputName});if("error"in n)return{error:n.error}}return{success:!0,identifier:i.identifier}}({logger:n,token:r,org_id:s,prompt:c,quality:l,face_count:p,outputName:d,outDir:u});"error"in m&&(m.error&&n.error(m.error),process.exit(1)),!u&&m.identifier&&console.log(m.identifier),process.exit(0)})),Kf.command("ask","Send a message to the Needle Cloud AI").help("Send a message to the Needle Cloud AI chat.\n\nWithout a message argument, starts an interactive session.\nBy default streams the response to the terminal. Use --no-stream for a single JSON response.\nUse --slug to continue an existing chat conversation.\nDefault slug is <your-user-id>-cli (persistent across sessions).").argument("[message...]","The message to send (omit for interactive mode)").option("--token <token>",Gf,{validator:Kf.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Kf.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Kf.STRING,hidden:!0}).option("--slug <slug>","Chat slug to continue an existing conversation",{required:!1,validator:Kf.STRING}).option("--no-stream","Disable streaming (returns full response at once)",{required:!1,validator:Kf.BOOLEAN,default:!1}).action(Np("ask",async({args:e,options:t})=>{var n,o;const{accessToken:i,org_id:a}=await Jf(t.token,Vf(t)),r=Array.isArray(e.message)?e.message:e.message?[e.message]:[],s=r.length?r.join(" "):void 0,c=(null==(n=t.slug)?void 0:n.toString())||void 0,l=(null==(o=t.noStream)?void 0:o.valueOf())||!1;await async function(e){const{token:t,org_id:n,message:o,slug:i,stream:a}=e,r=i||function(e){try{const t=e.split(".")[1],n=JSON.parse(Buffer.from(t,"base64url").toString());if(n.sub)return n.sub+"-cli"}catch{}return"cli-"+Math.random().toString(36).slice(2,10)}(t);await async function(e){const{token:t,org_id:n,slug:o,stream:i,initialMessage:a}=e,r=Pe({input:process.stdin,output:process.stdout});console.log(`Needle Cloud AI (chat: ${o})`),console.log('Type your message. Press Ctrl+C or type "exit" to quit.\n');try{for(a&&(console.log(`> ${a}`),await Dp({token:t,org_id:n,slug:o,message:a,stream:i}),console.log(""));;){const e=(await r.question("> ")).trim();if(e){if("exit"===e||"quit"===e)break;await Dp({token:t,org_id:n,slug:o,message:e,stream:i}),console.log("")}}}finally{r.close()}}({token:t,org_id:n,slug:r,stream:a,initialMessage:o})}({token:i,org_id:a,message:s,slug:c,stream:!l}),process.exit(0)}));export{Qu as g,Kf as p};
|