needle-cloud 3.3.0 → 3.4.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.
- package/CHANGELOG.md +4 -0
- package/README.md +3 -2
- package/dist/{cli-51eba1aa.js → cli-2661cdb5.js} +2 -2
- package/dist/cli.esm.js +1 -1
- package/dist/{cli.send-logs.discovery-29fa4e4a.js → cli.send-logs.discovery-98b97e6b.js} +1 -1
- package/dist/index.d.ts +179 -134
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
|
@@ -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 r,Option as a}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 y from"open";import x,{resolve as w,join as _,relative as j,isAbsolute as k,sep as S,dirname as E}from"path";import T from"ora";import{existsSync as $,mkdirSync as I,renameSync as A,realpathSync as O,statSync as C,rename as N,appendFileSync as R,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 G,watch as H}from"node:fs";import{writeFile as J,readFile as V,readlink 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,{extname as re,basename as ae,join as se,resolve as ce,relative as le,dirname as pe,isAbsolute as ue,sep as de,win32 as me,posix as fe}from"node:path";import he from"util";import ge,{Readable as ve}from"stream";import be from"http";import ye from"https";import xe 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 Te,{homedir as $e,tmpdir as Ie}from"os";import Ae,{EventEmitter as Oe}from"events";import Ce from"http2";import Ne from"zlib";import{Console as Re}from"node:console";import{createInterface as Pe}from"node:readline/promises";import{stripVTControlCharacters as Ue,promisify as Le}from"node:util";import ze from"dotenv";import Fe from"@logto/node";import{createInterface as De}from"node:readline";import{Readable as qe}from"node:stream";import{createGzip as Be}from"node:zlib";import{Router as Me}from"express";import We,{WebSocketServer as Ge}from"ws";import{execFileSync as He,execFile as Je,spawnSync as Ve,spawn as Ke}from"node:child_process";import{minimatch as Ye}from"minimatch";import{fileURLToPath as Ze}from"node:url";import{setTimeout as Xe}from"node:timers/promises";import Qe from"body-parser";const et="STRING",tt="BOOLEAN",nt="NUMBER",ot="ARRAY";function it(e){return e.replace(/[-_](\w)/g,(e,t)=>t.toUpperCase())}function rt(e){const t=e.match(/--[\w-]+/g);return t?t[t.length-1]:e.split(/[\s,]+/)[0]}function at(e){return it(rt(e).replace(/^--/,""))}function st(e){return it(e.replace(/[[\]<>]/g,"").replace(/\.\.\.$/,"").trim())}function ct(e,t){if(null==e)return e;switch(t){case tt:{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 nt:{const t=Number(e);return Number.isNaN(t)?e:t}case ot:return Array.isArray(e)?e:String(e).split(",");case et:return Array.isArray(e)?e:String(e);default:return e}}const lt={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 pt{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:st(e),validator:n.validator,default:n.default}),this}action(e){return this._action=e,this}isHelpCommand(){return!1}}class ut{constructor(){this.STRING=et,this.BOOLEAN=tt,this.NUMBER=nt,this.ARRAY=ot,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 pt(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 r=null!=(n=null==(o=this._testHooks)?void 0:o.error)?n:e=>console.error(e);return r(`error: ${t instanceof Error&&t.message||String(t)}`),(null!=e?e:process.argv).includes("--verbose")&&t instanceof Error&&t.stack&&r(t.stack),null!=(i=this._testHooks)&&i.exit?this._testHooks.exit(1):process.exit(1)}}_build(){const e=new r(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 a=t.get(i);return a||(a=new r(o[o.length-2]),this._exitOverride&&a.exitOverride(),t.set(i,a),n(o.slice(0,-1)).addCommand(a)),a};for(const e of this._commands){const o=e.name.split(/\s+/),i=t.get(e.name),s=null!=i?i:new r(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&&!rt(e).startsWith("--no-")&&(e=/[<[]/.test(e)?e.replace(/<([\w-]+)>/,"[$1]"):`${e} [value]`);const n=new a(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]=ct(void 0===o?e.default:o,e.validator)});const r={};for(const t of e.options){if(rt(t.synopsis).startsWith("--no-")){const e=it(rt(t.synopsis).replace(/^--no-/,""));r[t.name]=!1===o[e];continue}const e=o[t.name];r[t.name]=ct(void 0===e?t.default:e,t.validator)}for(const[e,t]of Object.entries(o))e in r||(r[e]=t);await e._action({args:i,options:r,logger:lt,command:s})}),i||n(o).addCommand(s,{hidden:!e.visible})}return e}}function dt(){return new ut}var mt={program:dt(),createProgram:dt,STRING:et,BOOLEAN:tt,NUMBER:nt,ARRAY:ot};class ft extends Error{constructor(e,t,n){super(n),this.name="ApiError",this.status=e,this.body=t}}const ht={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_usage:"/v1/jobs/post_usage",get_status:"/v1/jobs/status",get_org:"/v1/jobs/org",query:"/v1/jobs/query"},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 gt(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 vt={credentials:"omit"};async function bt(e,t){const n=e.baseUrl+ht.account.get_licenses,o={...{...t},...gt(e)},i=await fetch(n,{...vt,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 yt(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:wt}=Object.prototype,{getPrototypeOf:_t}=Object,{iterator:jt,toStringTag:kt}=Symbol,St=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Et=(e,t)=>{let n=e;const o=[];for(;null!=n&&n!==Object.prototype;){if(-1!==o.indexOf(n))return!1;if(o.push(n),St(n,t))return!0;n=_t(n)}return!1},Tt=($t=Object.create(null),e=>{const t=wt.call(e);return $t[t]||($t[t]=t.slice(8,-1).toLowerCase())});var $t;const It=e=>(e=e.toLowerCase(),t=>Tt(t)===e),At=e=>t=>typeof t===e,{isArray:Ot}=Array,Ct=At("undefined");function Nt(e){return null!==e&&!Ct(e)&&null!==e.constructor&&!Ct(e.constructor)&&Ut(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Rt=It("ArrayBuffer"),Pt=At("string"),Ut=At("function"),Lt=At("number"),zt=e=>null!==e&&"object"==typeof e,Ft=e=>{if(!zt(e))return!1;const t=_t(e);return!(null!==t&&t!==Object.prototype&&null!==_t(t)||Et(e,kt)||Et(e,jt))},Dt=It("Date"),qt=It("File"),Bt=It("Blob"),Mt=It("FileList"),Wt=It("Set"),Gt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Ht=void 0!==Gt.FormData?Gt.FormData:void 0,Jt=It("URLSearchParams"),[Vt,Kt,Yt,Zt]=["ReadableStream","Request","Response","Headers"].map(It);function Xt(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(Nt(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),r=i.length;let a;for(o=0;o<r;o++)a=i[o],t.call(null,e[a],a,e)}}function Qt(e,t){if(Nt(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 en="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,tn=e=>!Ct(e)&&e!==en,nn=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&_t(Uint8Array)),on=It("HTMLFormElement"),{propertyIsEnumerable:rn}=Object.prototype,an=It("RegExp"),sn=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};Xt(n,(n,i)=>{let r;!1!==(r=t(n,i,e))&&(o[i]=r||n)}),Object.defineProperties(e,o)},cn=It("AsyncFunction"),ln=(pn="function"==typeof setImmediate,un=Ut(en.postMessage),pn?setImmediate:un?(dn=`axios@${Math.random()}`,mn=[],en.addEventListener("message",({source:e,data:t})=>{e===en&&t===dn&&mn.length&&mn.shift()()},!1),e=>{mn.push(e),en.postMessage(dn,"*")}):e=>setTimeout(e));var pn,un,dn,mn;const fn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(en):"undefined"!=typeof process&&process.nextTick||ln,hn=e=>null!=e&&Ut(e[jt]);var gn={isArray:Ot,isArrayBuffer:Rt,isBuffer:Nt,isFormData:e=>{if(!e)return!1;if(Ht&&e instanceof Ht)return!0;const t=_t(e);if(!t||t===Object.prototype)return!1;if(!Ut(e.append))return!1;const n=Tt(e);return"formdata"===n||"object"===n&&Ut(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:Pt,isNumber:Lt,isBoolean:e=>!0===e||!1===e,isObject:zt,isPlainObject:Ft,isEmptyObject:e=>{if(!zt(e)||Nt(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Vt,isRequest:Kt,isResponse:Yt,isHeaders:Zt,isUndefined:Ct,isDate:Dt,isFile:qt,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:Bt,isRegExp:an,isFunction:Ut,isStream:e=>zt(e)&&Ut(e.pipe),isURLSearchParams:Jt,isTypedArray:nn,isFileList:Mt,forEach:Xt,merge:function e(...t){const{caseless:n,skipUndefined:o}=tn(this)&&this||{},i={},r=(t,r)=>{if("__proto__"===r||"constructor"===r||"prototype"===r)return;const a=n&&"string"==typeof r&&Qt(i,r)||r,s=St(i,a)?i[a]:void 0;Ft(s)&&Ft(t)?i[a]=e(s,t):Ft(t)?i[a]=e({},t):Ot(t)?i[a]=t.slice():o&&Ct(t)||(i[a]=t)};for(let e=0,n=t.length;e<n;e++){const n=t[e];if(!n||Nt(n))continue;if(Xt(n,r),"object"!=typeof n||Ot(n))continue;const o=Object.getOwnPropertySymbols(n);for(let e=0;e<o.length;e++){const t=o[e];rn.call(n,t)&&r(n[t],t)}}return i},extend:(e,t,n,{allOwnKeys:o}={})=>(Xt(t,(t,o)=>{n&&Ut(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,r,a;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),r=i.length;r-- >0;)a=i[r],o&&!o(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&_t(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Tt,kindOfTest:It,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(!Lt(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[jt]).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:on,hasOwnProperty:St,hasOwnProp:St,hasOwnInPrototypeChain:Et,getSafeProp:(e,t)=>null!=e&&Et(e,t)?e[t]:void 0,reduceDescriptors:sn,freezeMethods:e=>{sn(e,(t,n)=>{if(Ut(e)&&["arguments","caller","callee"].includes(n))return!1;Ut(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:Qt,global:en,isContextDefined:tn,isSpecCompliantForm:function(e){return!!(e&&Ut(e.append)&&"FormData"===e[kt]&&e[jt])},toJSONObject:e=>{const t=new WeakSet,n=e=>{if(zt(e)){if(t.has(e))return;if(Nt(e))return e;if(!("toJSON"in e)){let o;if(t.add(e),Wt(e)){o=[];for(const t of e){const e=n(t);!Ct(e)&&o.push(e)}}else o=Ot(e)?[]:{},Xt(e,(e,t)=>{const i=n(e);!Ct(i)&&(o[t]=i)});return t.delete(e),o}}return e};return n(e)},isAsyncFn:cn,isThenable:e=>e&&(zt(e)||Ut(e))&&Ut(e.then)&&Ut(e.catch),setImmediate:ln,asap:fn,isIterable:hn,isSafeIterable:e=>null!=e&&Et(e,jt)&&hn(e)};const vn=gn.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"]),bn=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),yn=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function xn(e,t){return gn.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 wn(e){const t=Object.create(null);return gn.forEach(e.toJSON(),(e,n)=>{t[n]=(e=>xn(e,yn))(e)}),t}const _n=Symbol("internals");function jn(e){return e&&String(e).trim().toLowerCase()}function kn(e){return!1===e||null==e?e:gn.isArray(e)?e.map(kn):(e=>xn(e,bn))(String(e))}const Sn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function En(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 Tn(e,t,n,o,i){return gn.isFunction(o)?o.call(this,t,n):(i&&(t=n),gn.isString(t)?gn.isString(o)?-1!==t.indexOf(o):gn.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=jn(t);if(!i)return;const r=gn.findKey(o,i);(!r||void 0===o[r]||!0===n||void 0===n&&!1!==o[r])&&(o[r||t]=kn(e))}const r=(e,t)=>gn.forEach(e,(e,n)=>i(e,n,t));if(gn.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(gn.isString(e)&&(e=e.trim())&&!(e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))(e))r((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 r=gn.hasOwnProp(t,n);!n||r&&gn.hasOwnProp(vn,n)||("set-cookie"===n?r?t[n].push(o):t[n]=[o]:t[n]=r?t[n]+", "+o:o)}),t})(e),t);else if(gn.isObject(e)&&gn.isSafeIterable(e)){let n,o,i=Object.create(null);for(const t of e){if(!gn.isArray(t))throw new TypeError("Object iterator must return a key-value pair");o=t[0],gn.hasOwnProp(i,o)?(n=i[o],i[o]=gn.isArray(n)?[...n,t[1]]:[n,t[1]]):i[o]=t[1]}r(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=jn(e)){const n=gn.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(gn.isFunction(t))return t.call(this,e,n);if(gn.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=jn(e)){const n=gn.findKey(this,e);return!(!n||void 0===this[n]||t&&!Tn(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function i(e){if(e=jn(e)){const i=gn.findKey(n,e);!i||t&&!Tn(0,n[i],i,t)||(delete n[i],o=!0)}}return gn.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&&!Tn(0,this[i],i,e,!0)||(delete this[i],o=!0)}return o}normalize(e){const t=this,n={};return gn.forEach(this,(o,i)=>{const r=gn.findKey(n,i);if(r)return t[r]=kn(o),void delete t[i];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();a!==i&&delete t[i],t[a]=kn(o),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return gn.forEach(this,(n,o)=>{null!=n&&!1!==n&&(t[o]=e&&gn.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 gn.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,r=!1;function a(e){const i=En(n.slice(o,e)),r=i.indexOf("=");if(r<1)return;const a=En(i.slice(0,r));if(!Sn.test(a))return;const s=a.toLowerCase();if("__proto__"===s||"constructor"===s||"prototype"===s)return;const c=En(i.slice(r+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?r?r=!1:92===t?r=!0:34===t&&(i=!1):34===t?i=!0:44!==t&&59!==t||(a(e),o=e+1)}return a(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[_n]=this[_n]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=jn(e);t[o]||(function(e,t){const n=gn.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 gn.isArray(e)?e.forEach(o):o(e),this}}$n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),gn.reduceDescriptors($n.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),gn.freezeMethods($n);var In=$n;const An="[REDACTED ****]";class On extends Error{static from(e,t,n,o,i,r){let a=e.message;!a&&gn.isArray(e.errors)&&e.errors.length&&(a=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(a,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),r&&Object.assign(s,r),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&&gn.hasOwnProp(e,"redact")?e.redact:void 0,n=gn.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(gn.isBuffer(e))return e;if(-1!==o.indexOf(e))return;let t;if(e instanceof In&&(e=e.toJSON()),o.push(e),gn.isArray(e))t=[],e.forEach((e,n)=>{const o=i(e);gn.isUndefined(o)||(t[n]=o)});else{if(!gn.isPlainObject(e)&&function(e){if(gn.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(gn.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}(e))return o.pop(),e;t=Object.create(null);for(const[o,r]of Object.entries(e)){const e=n.has(o.toLowerCase())?An:i(r);gn.isUndefined(e)||(t[o]=e)}}return o.pop(),t};return i(e)}(e,t):gn.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 Cn=On,Nn=ge.Stream,Rn=Pn;function Pn(){this.source=null,this.dataSize=0,this.maxDataSize=1048576,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}he.inherits(Pn,Nn),Pn.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(Pn.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}}),Pn.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)},Pn.prototype.resume=function(){this._released||this.release(),this.source.resume()},Pn.prototype.pause=function(){this.source.pause()},Pn.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(e){this.emit.apply(this,e)}.bind(this)),this._bufferedEvents=[]},Pn.prototype.pipe=function(){var e=Nn.prototype.pipe.apply(this,arguments);return this.resume(),e},Pn.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))},Pn.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 Un=ge.Stream,Ln=zn;function zn(){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(zn,Un),zn.create=function(e){var t=new this;for(var n in e=e||{})t[n]=e[n];return t},zn.isStreamLike=function(e){return"function"!=typeof e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Buffer.isBuffer(e)},zn.prototype.append=function(e){if(zn.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},zn.prototype.pipe=function(e,t){return Un.prototype.pipe.call(this,e,t),this.resume(),e},zn.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}}},zn.prototype._realGetNext=function(){var e=this._streams.shift();void 0!==e?"function"==typeof e?e(function(e){zn.isStreamLike(e)&&(e.on("data",this._checkDataSize.bind(this)),this._handleErrors(e)),this._pipeNext(e)}.bind(this)):this._pipeNext(e):this.end()},zn.prototype._pipeNext=function(e){if(this._currentStream=e,zn.isStreamLike(e))return e.on("end",this._getNext.bind(this)),void e.pipe(this,{end:!1});this.write(e),this._getNext()},zn.prototype._handleErrors=function(e){var t=this;e.on("error",function(e){t._emitError(e)})},zn.prototype.write=function(e){this.emit("data",e)},zn.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.pause&&this._currentStream.pause(),this.emit("pause"))},zn.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")},zn.prototype.end=function(){this._reset(),this.emit("end")},zn.prototype.destroy=function(){this._reset(),this.emit("close")},zn.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null},zn.prototype._checkDataSize=function(){this._updateDataSize(),this.dataSize<=this.maxDataSize||this._emitError(new Error("DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded."))},zn.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)},zn.prototype._emitError=function(e){this._reset(),this.emit("error",e)};var Fn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Dn(e){var t={exports:{}};return e(t,t.exports),t.exports}var qn={"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}},Bn=Dn(function(e,t){var n,o,i,r=x.extname,a=/^\s*([^;\s]*)(?:;|\s|$)/,s=/^text\//i;function c(e){if(!e||"string"!=typeof e)return!1;var t=a.exec(e),n=t&&qn[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=a.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=r("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(qn).forEach(function(e){var t=qn[e],r=t.extensions;if(r&&r.length){n[e]=r;for(var a=0;a<r.length;a++){var s=r[a];if(o[s]){var c=i.indexOf(qn[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}}})}),Mn=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)},Wn=function(e){var t=!1;return Mn(function(){t=!0}),function(n,o){t?e(n,o):Mn(function(){e(n,o)})}},Gn=function(e){Object.keys(e.jobs).forEach(Hn.bind(e)),e.jobs={}};function Hn(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}var Jn=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,Wn(o)):e(n,t,Wn(o))}(t,i,e[i],function(e,t){i in n.jobs&&(delete n.jobs[i],e?Gn(n):n.results[i]=t,o(e,n.results))})},Vn=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},Kn=function(e){Object.keys(this.jobs).length&&(this.index=this.size,Gn(this),Wn(e)(null,this.results))},Yn=function(e,t,n,o){var i=Vn(e,n);return Jn(e,t,i,function n(r,a){r?o(r,a):(i.index++,i.index<(i.keyedList||e).length?Jn(e,t,i,n):o(null,i.results))}),Kn.bind(i,o)};function Zn(e,t){return e<t?-1:e>t?1:0}Yn.ascending=Zn,Yn.descending=function(e,t){return-1*Zn(e,t)};var Xn=Object,Qn=Error,eo=EvalError,to=RangeError,no=ReferenceError,oo=SyntaxError,io=TypeError,ro=URIError,ao=Math.abs,so=Math.floor,co=Math.max,lo=Math.min,po=Math.pow,uo=Math.round,mo=Number.isNaN||function(e){return e!=e},fo=Object.getOwnPropertyDescriptor;if(fo)try{fo([],"length")}catch(e){fo=null}var ho=fo,go=Object.defineProperty||!1;if(go)try{go({},"a",{value:1})}catch(e){go=!1}var vo,bo=go,yo=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 r=Object.getOwnPropertyDescriptor(e,t);if(42!==r.value||!0!==r.enumerable)return!1}return!0},xo="undefined"!=typeof Symbol&&Symbol,wo="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null,_o=Xn,jo=_o.getPrototypeOf||null,ko=Object.prototype.toString,So=Math.max,Eo=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},To=Function.prototype.bind||function(e){var t=this;if("function"!=typeof t||"[object Function]"!==ko.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=So(0,t.length-o.length),r=[],a=0;a<i;a++)r[a]="$"+a;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}(r)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof n){var i=t.apply(this,Eo(o,arguments));return Object(i)===i?i:this}return t.apply(e,Eo(o,arguments))}),t.prototype){var s=function(){};s.prototype=t.prototype,n.prototype=new s,s.prototype=null}return n},$o=Function.prototype.call,Io=Function.prototype.apply,Ao="undefined"!=typeof Reflect&&Reflect&&Reflect.apply||To.call($o,Io),Oo=io,Co=ho;try{vo=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var No,Ro=!!vo&&Co&&Co(Object.prototype,"__proto__"),Po=Object,Uo=Po.getPrototypeOf,Lo=Ro&&"function"==typeof Ro.get?function(e){if(e.length<1||"function"!=typeof e[0])throw new Oo("a function is required");return Ao(To,$o,e)}([Ro.get]):"function"==typeof Uo&&function(e){return Uo(null==e?e:Po(e))},zo=wo?function(e){return wo(e)}:jo?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return jo(e)}:Lo?function(e){return Lo(e)}:null,Fo=To.call(Function.prototype.call,Object.prototype.hasOwnProperty),Do=Qn,qo=eo,Bo=to,Mo=no,Wo=oo,Go=ro,Ho=ao,Jo=so,Vo=co,Ko=lo,Yo=po,Zo=uo,Xo=bo,Qo=Fo,ei=Function,ti=function(e){try{return ei('"use strict"; return ('+e+").constructor;")()}catch(e){}},ni=function(){throw new Oo},oi=Co?function(){try{return ni}catch(e){try{return Co(arguments,"callee").get}catch(e){return ni}}}():ni,ii="function"==typeof xo&&"function"==typeof Symbol&&"symbol"==typeof xo("foo")&&"symbol"==typeof Symbol("bar")&&yo(),ri={},ai="undefined"!=typeof Uint8Array&&zo?zo(Uint8Array):No,si={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?No:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?No:ArrayBuffer,"%ArrayIteratorPrototype%":ii&&zo?zo([][Symbol.iterator]()):No,"%AsyncFromSyncIteratorPrototype%":No,"%AsyncFunction%":ri,"%AsyncGenerator%":ri,"%AsyncGeneratorFunction%":ri,"%AsyncIteratorPrototype%":ri,"%Atomics%":"undefined"==typeof Atomics?No:Atomics,"%BigInt%":"undefined"==typeof BigInt?No:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?No:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?No:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?No:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Do,"%eval%":eval,"%EvalError%":qo,"%Float16Array%":"undefined"==typeof Float16Array?No:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?No:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?No:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?No:FinalizationRegistry,"%Function%":ei,"%GeneratorFunction%":ri,"%Int8Array%":"undefined"==typeof Int8Array?No:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?No:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?No:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ii&&zo?zo(zo([][Symbol.iterator]())):No,"%JSON%":"object"==typeof JSON?JSON:No,"%Map%":"undefined"==typeof Map?No:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&ii&&zo?zo((new Map)[Symbol.iterator]()):No,"%Math%":Math,"%Number%":Number,"%Object%":_o,"%Object.getOwnPropertyDescriptor%":Co,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?No:Promise,"%Proxy%":"undefined"==typeof Proxy?No:Proxy,"%RangeError%":Bo,"%ReferenceError%":Mo,"%Reflect%":"undefined"==typeof Reflect?No:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?No:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&ii&&zo?zo((new Set)[Symbol.iterator]()):No,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?No:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ii&&zo?zo(""[Symbol.iterator]()):No,"%Symbol%":ii?Symbol:No,"%SyntaxError%":Wo,"%ThrowTypeError%":oi,"%TypedArray%":ai,"%TypeError%":Oo,"%Uint8Array%":"undefined"==typeof Uint8Array?No:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?No:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?No:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?No:Uint32Array,"%URIError%":Go,"%WeakMap%":"undefined"==typeof WeakMap?No:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?No:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?No:WeakSet,"%Function.prototype.call%":$o,"%Function.prototype.apply%":Io,"%Object.defineProperty%":Xo,"%Object.getPrototypeOf%":jo,"%Math.abs%":Ho,"%Math.floor%":Jo,"%Math.max%":Vo,"%Math.min%":Ko,"%Math.pow%":Yo,"%Math.round%":Zo,"%Math.sign%":function(e){return mo(e)||0===e?e:e<0?-1:1},"%Reflect.getPrototypeOf%":wo};if(zo)try{null.error}catch(e){var ci=zo(zo(e));si["%Error.prototype%"]=ci}var li=function e(t){var n;if("%AsyncFunction%"===t)n=ti("async function () {}");else if("%GeneratorFunction%"===t)n=ti("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=ti("async function* () {}");else if("%AsyncGenerator%"===t){var o=e("%AsyncGeneratorFunction%");o&&(n=o.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&zo&&(n=zo(i.prototype))}return si[t]=n,n},pi={__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"]},ui=To.call($o,Array.prototype.concat),di=To.call(Io,Array.prototype.splice),mi=To.call($o,String.prototype.replace),fi=To.call($o,String.prototype.slice),hi=To.call($o,RegExp.prototype.exec),gi=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,vi=/\\(\\)?/g,bi=function(e,t){var n,o=e;if(Qo(pi,o)&&(o="%"+(n=pi[o])[0]+"%"),Qo(si,o)){var i=si[o];if(i===ri&&(i=li(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 Wo("intrinsic "+e+" does not exist!")},yi=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===hi(/^%?[^%]*%?$/,e))throw new Wo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=fi(e,0,1),n=fi(e,-1);if("%"===t&&"%"!==n)throw new Wo("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new Wo("invalid intrinsic syntax, expected opening `%`");var o=[];return mi(e,gi,function(e,t,n,i){o[o.length]=n?mi(i,vi,"$1"):t||e}),o}(e),o=n.length>0?n[0]:"",i=bi("%"+o+"%",t),r=i.name,a=i.value,s=!1,c=i.alias;c&&(o=c[0],di(n,ui([0,1],c)));for(var l=1,p=!0;l<n.length;l+=1){var u=n[l],d=fi(u,0,1),m=fi(u,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new Wo("property names with quotes must have matching quotes");if("constructor"!==u&&p||(s=!0),Qo(si,r="%"+(o+="."+u)+"%"))a=si[r];else if(null!=a){if(!(u in a)){if(!t)throw new Oo("base intrinsic for "+e+" exists, but the property is not available.");return}if(Co&&l+1>=n.length){var f=Co(a,u);a=(p=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:a[u]}else p=Qo(a,u),a=a[u];p&&!s&&(si[r]=a)}}return a}("%Object.defineProperty%",!0),xi=yo()&&Symbol.toStringTag?Symbol.toStringTag:null,wi=function(e,t){return Object.keys(t).forEach(function(n){e[n]=e[n]||t[n]}),e},_i=xe.parse,ji=ge.Stream;function ki(e){return String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22")}function Si(e){if(!(this instanceof Si))return new Si(e);for(var t in this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],Ln.call(this),e=e||{})this[t]=e[t]}he.inherits(Si,Ln),Si.LINE_BREAK="\r\n",Si.DEFAULT_CONTENT_TYPE="application/octet-stream",Si.prototype.append=function(e,t,n){"string"==typeof(n=n||{})&&(n={filename:n});var o=Ln.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),r=this._multiPartFooter();o(i),o(t),o(r),this._trackLength(i,t,n)}},Si.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)+Si.LINE_BREAK.length,t&&(t.path||t.readable&&Qo(t,"httpVersion")||t instanceof ji)&&(n.knownLength||this._valuesToMeasure.push(t))},Si.prototype._lengthRetriever=function(e,t){Qo(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))}):Qo(e,"httpVersion")?t(null,Number(e.headers["content-length"])):Qo(e,"httpModule")?(e.on("response",function(n){e.pause(),t(null,Number(n.headers["content-length"]))}),e.resume()):t("Unknown stream")},Si.prototype._multiPartHeader=function(e,t,n){if("string"==typeof n.header)return n.header;var o,i=this._getContentDisposition(t,n),r=this._getContentType(t,n),a="",s={"Content-Disposition":["form-data",'name="'+ki(e)+'"'].concat(i||[]),"Content-Type":[].concat(r||[])};for(var c in"object"==typeof n.header&&wi(s,n.header),s)if(Qo(s,c)){if(null==(o=s[c]))continue;Array.isArray(o)||(o=[o]),o.length&&(a+=c+": "+o.join("; ")+Si.LINE_BREAK)}return"--"+this.getBoundary()+Si.LINE_BREAK+a+Si.LINE_BREAK},Si.prototype._getContentDisposition=function(e,t){var n;if("string"==typeof t.filepath?n=x.normalize(t.filepath).replace(/\\/g,"/"):t.filename||e&&(e.name||e.path)?n=x.basename(t.filename||e&&(e.name||e.path)):e&&e.readable&&Qo(e,"httpVersion")&&(n=x.basename(e.client._httpMessage.path||"")),n)return'filename="'+ki(n)+'"'},Si.prototype._getContentType=function(e,t){var n=t.contentType;return!n&&e&&e.name&&(n=Bn.lookup(e.name)),!n&&e&&e.path&&(n=Bn.lookup(e.path)),!n&&e&&e.readable&&Qo(e,"httpVersion")&&(n=e.headers["content-type"]),n||!t.filepath&&!t.filename||(n=Bn.lookup(t.filepath||t.filename)),!n&&e&&"object"==typeof e&&(n=Si.DEFAULT_CONTENT_TYPE),n},Si.prototype._multiPartFooter=function(){return function(e){var t=Si.LINE_BREAK;0===this._streams.length&&(t+=this._lastBoundary()),e(t)}.bind(this)},Si.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+Si.LINE_BREAK},Si.prototype.getHeaders=function(e){var t,n={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(t in e)Qo(e,t)&&(n[t.toLowerCase()]=e[t]);return n},Si.prototype.setBoundary=function(e){if("string"!=typeof e)throw new TypeError("FormData boundary must be a string");this._boundary=e},Si.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary},Si.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(Si.LINE_BREAK)])));return Buffer.concat([e,Buffer.from(this._lastBoundary())])},Si.prototype._generateBoundary=function(){this._boundary="--------------------------"+we.randomBytes(12).toString("hex")},Si.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},Si.prototype.hasKnownLength=function(){var e=!0;return this._valuesToMeasure.length&&(e=!1),e},Si.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=Vn(e);o.index<(o.keyedList||e).length;)Jn(e,t,o,function(e,t){e?n(e,t):0!==Object.keys(o.jobs).length||n(null,o.results)}),o.index++;Kn.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))},Si.prototype.submit=function(e,t){var n,o,i={method:"post"};return"string"==typeof e?(e=_i(e),o=wi({port:e.port,path:e.pathname,host:e.hostname,protocol:e.protocol},i)):(o=wi(e,i)).port||(o.port="https:"===o.protocol?443:80),o.headers=this.getHeaders(e.headers),n="https:"===o.protocol?ye.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,r=function(e,o){return n.removeListener("error",r),n.removeListener("response",i),t.call(this,e,o)};i=r.bind(this,null),n.on("error",r),n.on("response",i)}}.bind(this)),n},Si.prototype._error=function(e){this.error||(this.error=e,this.pause(),this.emit("error",e))},Si.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&&Qo(e,xi)||(yi?yi(e,xi,{configurable:!o,enumerable:!1,value:t,writable:!1}):e[xi]=t)}(Si.prototype,"FormData");var Ei=Si,Ti={isBufferAvailable:()=>"undefined"!=typeof Buffer,from:e=>Buffer.from(e)};const $i=100;function Ii(e){return gn.isPlainObject(e)||gn.isArray(e)}function Ai(e){return gn.endsWith(e,"[]")?e.slice(0,-2):e}function Oi(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ai(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Ci=gn.toFlatObject(gn,{},null,function(e){return/^is[A-Z]/.test(e)});function Ni(e,t,n){if(!gn.isObject(e))throw new TypeError("target must be an object");t=t||new(Ei||FormData);const o=(n=gn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!gn.isUndefined(t[e])})).metaTokens,i=n.visitor||m,r=n.dots,a=n.indexes,s=n.Blob||"undefined"!=typeof Blob&&Blob,c=void 0===n.maxDepth?$i:n.maxDepth,l=s&&gn.isSpecCompliantForm(t),p=[];if(!gn.isFunction(i))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(gn.isDate(e))return e.toISOString();if(gn.isBoolean(e))return e.toString();if(!l&&gn.isBlob(e))throw new Cn("Blob is not supported. Use a Buffer instead.");if(gn.isArrayBuffer(e)||gn.isTypedArray(e)){if(l&&"function"==typeof s)return new s([e]);if(Ti&&Ti.isBufferAvailable())return Ti.from(e);throw new Cn("Blob is not supported. Use a Buffer instead.",Cn.ERR_NOT_SUPPORT)}return e}function d(e){if(e>c)throw new Cn("Object is too deeply nested ("+e+" levels). Max depth: "+c,Cn.ERR_FORM_DATA_DEPTH_EXCEEDED)}function m(e,n,i){let s=e;if(gn.isReactNative(t)&&gn.isReactNativeBlob(e))return t.append(Oi(i,n,r),u(e)),!1;if(e&&!i&&"object"==typeof e)if(gn.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(!gn.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(gn.isArray(e)&&function(e){return gn.isArray(e)&&!e.some(Ii)}(e)||(gn.isFileList(e)||gn.endsWith(n,"[]"))&&(s=gn.toArray(e)))return n=Ai(n),s.forEach(function(e,o){!gn.isUndefined(e)&&null!==e&&t.append(!0===a?Oi([n],o,r):null===a?n:n+"[]",u(e))}),!1;return!!Ii(e)||(t.append(Oi(i,n,r),u(e)),!1)}const f=Object.assign(Ci,{defaultVisitor:m,convertValue:u,isVisitable:Ii});if(!gn.isObject(e))throw new TypeError("data must be an object");return function e(n,o,r=0){if(!gn.isUndefined(n)){if(d(r),-1!==p.indexOf(n))throw new Error("Circular reference detected in "+o.join("."));p.push(n),gn.forEach(n,function(n,a){!0===(!(gn.isUndefined(n)||null===n)&&i.call(t,n,gn.isString(a)?a.trim():a,o,f))&&e(n,o?o.concat(a):[a],r+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 Pi(e,t){this._pairs=[],e&&Ni(e,this,t)}const Ui=Pi.prototype;function Li(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zi(e,t,n){if(!t)return e;e=e||"";const o=gn.isFunction(n)?{serialize:n}:n,i=gn.getSafeProp(o,"encode")||Li,r=gn.getSafeProp(o,"serialize");let a;if(a=r?r(t,o):gn.isURLSearchParams(t)?t.toString():new Pi(t,o).toString(i),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}Ui.append=function(e,t){this._pairs.push([e,t])},Ui.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 Fi=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){gn.forEach(this.handlers,function(t){null!==t&&e(t)})}},Di={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},qi=xe.URLSearchParams;const Bi="abcdefghijklmnopqrstuvwxyz",Mi="0123456789",Wi={DIGIT:Mi,ALPHA:Bi,ALPHA_DIGIT:Bi+Bi.toUpperCase()+Mi};var Gi={isNode:!0,classes:{URLSearchParams:qi,FormData:Ei,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:Wi,generateString:(e=16,t=Wi.ALPHA_DIGIT)=>{let n="";const{length:o}=t,i=new Uint32Array(e);we.randomFillSync(i);for(let r=0;r<e;r++)n+=t[i[r]%o];return n},protocols:["http","https","file","data"]};const Hi="undefined"!=typeof window&&"undefined"!=typeof document,Ji="object"==typeof navigator&&navigator||void 0,Vi=Hi&&(!Ji||["ReactNative","NativeScript","NS"].indexOf(Ji.product)<0);var Ki={__proto__:null,hasBrowserEnv:Hi,hasStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,hasStandardBrowserEnv:Vi,navigator:Ji,origin:Hi&&window.location.href||"http://localhost",...Gi};const Yi=$i;function Zi(e){if(e>Yi)throw new Cn("FormData field is too deeply nested ("+e+" levels). Max depth: "+Yi,Cn.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Xi(e){function t(e,n,o,i){Zi(i);let r=e[i++];if("__proto__"===r)return!0;const a=Number.isFinite(+r),s=i>=e.length;return r=!r&&gn.isArray(o)?o.length:r,s?(o[r]=gn.hasOwnProp(o,r)?gn.isArray(o[r])?o[r].concat(n):[o[r],n]:n,!a):(gn.hasOwnProp(o,r)&&gn.isObject(o[r])||(o[r]=[]),t(e,n,o[r],i)&&gn.isArray(o[r])&&(o[r]=function(e){const t={},n=Object.keys(e);let o;const i=n.length;let r;for(o=0;o<i;o++)r=n[o],t[r]=e[r];return t}(o[r])),!a)}if(gn.isFormData(e)&&gn.isFunction(e.entries)){const n={};return gn.forEachEntry(e,(e,o)=>{t(function(e){const t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g;let o;for(;null!==(o=n.exec(e));)Zi(t.length),t.push("[]"===o[0]?"":o[1]||o[0]);return t}(e),o,n,0)}),n}return null}const Qi=(e,t)=>null!=e&&gn.hasOwnProp(e,t)?e[t]:void 0,er={transitional:Di,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,i=gn.isObject(e);if(i&&gn.isHTMLForm(e)&&(e=new FormData(e)),gn.isFormData(e))return o?JSON.stringify(Xi(e)):e;if(gn.isArrayBuffer(e)||gn.isBuffer(e)||gn.isStream(e)||gn.isFile(e)||gn.isBlob(e)||gn.isReadableStream(e))return e;if(gn.isArrayBufferView(e))return e.buffer;if(gn.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let r;if(i){const t=Qi(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ni(e,new Ki.classes.URLSearchParams,{visitor:function(e,t,n,o){return Ki.isNode&&gn.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}(e,t).toString();if((r=gn.isFileList(e))||n.indexOf("multipart/form-data")>-1){const n=Qi(this,"env"),o=n&&n.FormData;return Ni(r?{"files[]":e}:e,o&&new o,t)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(gn.isString(e))try{return(0,JSON.parse)(e),gn.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=Qi(this,"transitional")||er.transitional,n=t&&t.forcedJSONParsing,o=Qi(this,"responseType"),i="json"===o;if(gn.isResponse(e)||gn.isReadableStream(e))return e;if(e&&gn.isString(e)&&(n&&!o||i)){const n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Qi(this,"parseReviver"))}catch(e){if(n){if("SyntaxError"===e.name)throw Cn.from(e,Cn.ERR_BAD_RESPONSE,this,null,Qi(this,"response"));throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ki.classes.FormData,Blob:Ki.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};gn.forEach(["delete","get","head","post","put","patch","query"],e=>{er.headers[e]={}});var tr=er;function nr(e,t){const n=this||tr,o=t||n,i=In.from(o.headers);let r=o.data;return gn.forEach(e,function(e){r=e.call(n,r,i.normalize(),t?t.status:void 0)}),i.normalize(),r}function or(e){return!(!e||!e.__CANCEL__)}var ir=class extends Cn{constructor(e,t,n){super(null==e?"canceled":e,Cn.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function rr(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new Cn("Request failed with status code "+n.status,n.status>=400&&n.status<500?Cn.ERR_BAD_REQUEST:Cn.ERR_BAD_RESPONSE,n.config,n.request,n)):e(n)}const ar=/^https?:(?!\/\/)/i,sr=/[\t\n\r]/g;function cr(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(sr,"")}(e);if(ar.test(n))throw new Cn(`Invalid URL ${JSON.stringify(function(e){const t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${An}@`),n=t.indexOf("#"),o=(-1===n?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${An}`);return-1===n?o:`${o}#${i=t.slice(n+1),i?i.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,t,n="")=>`${t}${n}${An}`):i}`;var i}(n))}: missing "//" after protocol`,Cn.ERR_INVALID_URL,t)}}function lr(e,t,n,o){cr(t,o);let i=!function(e){return"string"==typeof e&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(i||!1===n)?(cr(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 pr={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function ur(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}var dr=1e3,mr=60*dr,fr=60*mr,hr=24*fr,gr=7*hr,vr=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*gr;case"days":case"day":case"d":return n*hr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*fr;case"minutes":case"minute":case"mins":case"min":case"m":return n*mr;case"seconds":case"second":case"secs":case"sec":case"s":return n*dr;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>=hr?br(e,t,hr,"day"):t>=fr?br(e,t,fr,"hour"):t>=mr?br(e,t,mr,"minute"):t>=dr?br(e,t,dr,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=hr?Math.round(e/hr)+"d":t>=fr?Math.round(e/fr)+"h":t>=mr?Math.round(e/mr)+"m":t>=dr?Math.round(e/dr)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function br(e,t,n,o){var i=t>=1.5*n;return Math.round(e/n)+" "+o+(i?"s":"")}var yr=function(e){function t(e){let o,i,r,a=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 r=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(o,i)=>{if("%%"===o)return"%";r++;const a=t.formatters[i];return"function"==typeof a&&(o=a.call(n,e[r]),e.splice(r,1),r--),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!==a?a:(i!==t.namespaces&&(i=t.namespaces,r=t.enabled(e)),r),set:e=>{a=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=vr,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},xr=Dn(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=yr(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}),wr=(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:_r}=process;let jr;function kr(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Sr(e,t){if(0===jr)return 0;if(wr("color=16m")||wr("color=full")||wr("color=truecolor"))return 3;if(wr("color=256"))return 2;if(e&&!t&&void 0===jr)return 0;const n=jr||0;if("dumb"===_r.TERM)return n;if("win32"===process.platform){const e=Te.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in _r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in _r)||"codeship"===_r.CI_NAME?1:n;if("TEAMCITY_VERSION"in _r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(_r.TEAMCITY_VERSION)?1:0;if("truecolor"===_r.COLORTERM)return 3;if("TERM_PROGRAM"in _r){const e=parseInt((_r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(_r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(_r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(_r.TERM)||"COLORTERM"in _r?1:n}wr("no-color")||wr("no-colors")||wr("color=false")||wr("color=never")?jr=0:(wr("color")||wr("colors")||wr("color=true")||wr("color=always"))&&(jr=1),"FORCE_COLOR"in _r&&(jr="true"===_r.FORCE_COLOR?1:"false"===_r.FORCE_COLOR?0:0===_r.FORCE_COLOR.length?1:Math.min(parseInt(_r.FORCE_COLOR,10),3));var Er={supportsColor:function(e){return kr(Sr(e,e&&e.isTTY))},stdout:kr(Sr(!0,Ee.isatty(1))),stderr:kr(Sr(!0,Ee.isatty(2)))},Tr=Dn(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),r=` ${i};1m${o} [0m`;n[0]=r+n[0].split("\n").join("\n"+r),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{Er&&(Er.stderr||Er).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=yr(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)}}),$r=Dn(function(e){e.exports="undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?xr:Tr}),Ir=/*#__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}),Ar=Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Or=Ar($r),Cr=Ar(Ir),Nr=Or.default("agent-base");function Rr(){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 Pr(e,t){return new Pr.Agent(e,t)}!function(e){e.Agent=class extends Ae.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:Rr()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return"string"==typeof this.explicitProtocol?this.explicitProtocol:Rr()?"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=Rr()),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 r=n.timeout||this.timeout,a=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 ${r}ms`);e.code="ETIMEOUT",a(e)},c=e=>{o||(null!==i&&(clearTimeout(i),i=null),a(e))},l=t=>{if(o)return;if(null!=i&&(clearTimeout(i),i=null),r=t,Boolean(r)&&"function"==typeof r.addRequest)return Nr("Callback returned another Agent instance %o",t.constructor.name),void t.addRequest(e,n);var r;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}\``);a(s)};if("function"==typeof this.callback){this.promisifiedCallback||(this.callback.length>=3?(Nr("Converting legacy callback function to promise"),this.promisifiedCallback=Cr.default(this.callback)):this.promisifiedCallback=this.callback),"number"==typeof r&&r>0&&(i=setTimeout(s,r)),"port"in n&&"number"!=typeof n.port&&(n.port=Number(n.port));try{Nr("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 a(new Error("`callback` is not defined"))}freeSocket(e,t){Nr("Freeing socket %o %o",e.constructor.name,t),e.destroy()}destroy(){Nr("Destroying agent %o",this.constructor.name)}},e.prototype=e.Agent.prototype}(Pr||(Pr={}));var Ur=Pr;const Lr=(Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})($r).default("https-proxy-agent:parse-proxy-response");var zr=/*#__PURE__*/Object.defineProperty({default:function(e){return new Promise((t,n)=>{let o=0;const i=[];function r(){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 Lr("have not received end of HTTP headers yet..."),void r();const a=n.toString("ascii",0,n.indexOf("\r\n")),s=+a.split(" ")[1];Lr("got proxy server response: %o",a),t({statusCode:s,buffered:n})}(n):e.once("readable",r)}function a(e){Lr("onclose had error %o",e)}function s(){Lr("onend")}e.on("error",function t(o){e.removeListener("end",s),e.removeListener("error",t),e.removeListener("close",a),e.removeListener("readable",r),Lr("onerror %o",o),n(o)}),e.on("close",a),e.on("end",s),r()})}},"__esModule",{value:!0}),Fr=Fn&&Fn.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(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(a,s)}c((o=o.apply(e,t||[])).next())})},Dr=Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const qr=Dr(je),Br=Dr(ke),Mr=Dr(xe),Wr=Dr(Se),Gr=Dr($r),Hr=Dr(zr),Jr=Gr.default("https-proxy-agent:agent");function Vr(e){e.resume()}const Kr=(Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:class extends Ur.Agent{constructor(e){let t;if(t="string"==typeof e?Mr.default.parse(e):e,!t)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Jr("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 Fr(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let i;o?(Jr("Creating `tls.Socket`: %o",n),i=Br.default.connect(n)):(Jr("Creating `net.Socket`: %o",n),i=qr.default.connect(n));const r=Object.assign({},n.headers);let a=`CONNECT ${t.host}:${t.port} HTTP/1.1\r\n`;n.auth&&(r["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}`),r.Host=s,r.Connection="close";for(const e of Object.keys(r))a+=`${e}: ${r[e]}\r\n`;const p=Hr.default(i);i.write(`${a}\r\n`);const{statusCode:u,buffered:d}=yield p;if(200===u){if(e.once("socket",Vr),t.secureEndpoint){Jr("Upgrading socket connection to TLS");const e=t.servername||t.host;return Br.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 qr.default.Socket({writable:!1});return m.readable=!0,e.once("socket",e=>{Jr("replaying proxy buffer for failed request"),Wr.default(e.listenerCount("data")>0),e.push(d),e.push(null)}),m})}}},"__esModule",{value:!0}));function Yr(e){return new Kr.default(e)}!function(e){e.HttpsProxyAgent=Kr.default,e.prototype=Kr.default.prototype}(Yr||(Yr={}));var Zr,Xr,Qr,ea,ta=Yr,na=function(){if(!Zr){try{Zr=$r("follow-redirects")}catch(e){}"function"!=typeof Zr&&(Zr=function(){})}Zr.apply(null,arguments)},oa=xe.URL,ia=ge.Writable;Xr="undefined"!=typeof process,Qr="undefined"!=typeof window&&"undefined"!=typeof document,ea=Ea(Error.captureStackTrace),Xr||!Qr&&ea||console.warn("The follow-redirects package should be excluded from browser builds.");var ra=!1;try{Se(new oa(""))}catch(e){ra="ERR_INVALID_URL"===e.code}var aa=["Authorization","Proxy-Authorization","Cookie"],sa=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],ca=["abort","aborted","connect","error","socket","timeout"],la=Object.create(null);ca.forEach(function(e){la[e]=function(t,n,o){this._redirectable.emit(e,t,n,o)}});var pa=ja("ERR_INVALID_URL","Invalid URL",TypeError),ua=ja("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),da=ja("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",ua),ma=ja("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),fa=ja("ERR_STREAM_WRITE_AFTER_END","write after end"),ha=ia.prototype.destroy||ba;function ga(e,t){ia.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 ua?e:new ua({cause:e}))}},this._headerFilter=new RegExp("^(?:"+aa.concat(e.sensitiveHeaders).map(Ta).join("|")+")$","i"),this._performRequest()}function va(e){var t={maxRedirects:21,maxBodyLength:10485760},n={};return Object.keys(e).forEach(function(o){var i=o+":",r=n[i]=e[o],a=t[o]=Object.create(r);Object.defineProperties(a,{request:{value:function(e,o,r){return oa&&e instanceof oa?e=wa(e):Sa(e)?e=wa(ya(e)):(r=o,o=xa(e),e={protocol:i}),Ea(o)&&(r=o,o=null),(o=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,o)).nativeProtocols=n,Sa(o.host)||Sa(o.hostname)||(o.hostname="::1"),Se.equal(o.protocol,i,"protocol mismatch"),na("options",o),new ga(o,r)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,n){var o=a.request(e,t,n);return o.end(),o},configurable:!0,enumerable:!0,writable:!0}})}),t}function ba(){}function ya(e){var t;if(ra)t=new oa(e);else if(!Sa((t=xa(xe.parse(e))).protocol))throw new pa({input:e});return t}function xa(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new pa({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new pa({input:e.href||e});return e}function wa(e,t){var n=t||{};for(var o of sa)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 _a(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 ja(e,t,n){function o(n){Ea(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 ka(e,t){for(var n of ca)e.removeListener(n,la[n]);e.on("error",ba),e.destroy(t)}function Sa(e){return"string"==typeof e||e instanceof String}function Ea(e){return"function"==typeof e}function Ta(e){return e.replace(/[\]\\/()*+?.$]/g,"\\$&")}(ga.prototype=Object.create(ia.prototype)).abort=function(){ka(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},ga.prototype.destroy=function(e){return ka(this._currentRequest,e),ha.call(this,e),this},ga.prototype.write=function(e,t,n){if(this._ending)throw new fa;if(!(Sa(e)||"object"==typeof(o=e)&&"length"in o))throw new TypeError("data should be a string, Buffer or Uint8Array");var o;Ea(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 ma),this.abort()):n&&n()},ga.prototype.end=function(e,t,n){if(Ea(e)?(n=e,e=t=null):Ea(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)},ga.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},ga.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},ga.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"),r()},e),o(t)}function r(){n._timeout&&(clearTimeout(n._timeout),n._timeout=null),n.removeListener("abort",r),n.removeListener("error",r),n.removeListener("response",r),n.removeListener("close",r),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",r),this.on("error",r),this.on("response",r),this.on("close",r),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){ga.prototype[e]=function(t,n){return this._currentRequest[e](t,n)}}),["aborted","connection","socket"].forEach(function(e){Object.defineProperty(ga.prototype,e,{get:function(){return this._currentRequest[e]}})}),ga.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))}},ga.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,ca))o.on(i,la[i]);if(this._currentUrl=/^\//.test(this._options.path)?xe.format(this._options):this._options.path,this._isRedirect){var r=0,a=this,s=this._requestBodyBuffers;!function e(t){if(o===a._currentRequest)if(t)a.emit("error",t);else if(r<s.length){var n=s[r++];o.finished||o.write(n.data,n.encoding,e)}else a._ended&&o.end()}()}},ga.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(ka(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new da;var i=this._options.beforeRedirect;i&&(n=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var r=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=[],_a(/^content-/i,this._options.headers));var a=_a(/^host$/i,this._options.headers),s=ya(this._currentUrl),c=a||s.host,l=/^\w+:/.test(o)?this._currentUrl:xe.format(Object.assign(s,{host:c})),p=function(e,t){return ra?new oa(e,t):ya(xe.resolve(t,e))}(o,l);na("redirecting to",p.href),this._isRedirect=!0,wa(p,this._options),(p.protocol!==s.protocol&&"https:"!==p.protocol||p.host!==c&&!function(e,t){Se(Sa(e)&&Sa(t));var n=e.length-t.length-1;return n>0&&"."===e[n]&&e.endsWith(t)}(p.host,c))&&_a(this._headerFilter,this._options.headers),Ea(i)&&(i(this._options,{headers:e.headers,statusCode:t},{url:l,method:r,headers:n}),this._sanitizeOptions(this._options)),this._performRequest()};var $a=va({http:be,https:ye});$a.wrap=va;const Ia="1.19.0";function Aa(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}const Oa=/^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/,Ca=["content-type","content-length"];function Na(e,t,n){"content-only"===n?Object.entries(t||{}).forEach(([t,n])=>{Ca.includes(t.toLowerCase())&&e.set(t,n)}):e.set(t)}const Ra=Symbol("internals");var Pa=class extends ge.Transform{constructor(e){super({readableHighWaterMark:(e=gn.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!gn.isUndefined(t[e]))).chunkSize});const t=this[Ra]={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[Ra];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){const o=this[Ra],i=o.maxRate,r=this.readableHighWaterMark,a=o.timeWindow,s=i/(1e3/a),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=r,m=0;if(i){const e=Date.now();(!o.ts||(m=e-o.ts)>=a)&&(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)},a-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:Ua}=Symbol;var La=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Ua]?yield*e[Ua]():yield e};const za=Ki.ALPHABET.ALPHA_DIGIT+"-_",Fa="function"==typeof TextEncoder?new TextEncoder:new he.TextEncoder,Da="\r\n",qa=Fa.encode(Da);class Ba{constructor(e,t){const{escapeName:n}=this.constructor,o=gn.isString(t);let i=`Content-Disposition: form-data; name="${n(e)}"${!o&&t.name?`; filename="${n(t.name)}"`:""}${Da}`;o?t=Fa.encode(String(t).replace(/\r?\n|\r\n?/g,Da)):i+=`Content-Type: ${String(t.type||"application/octet-stream").replace(/[\r\n]/g,"")}${Da}`,this.headers=Fa.encode(i+Da),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;gn.isTypedArray(e)?yield e:yield*La(e),yield qa}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}var Ma=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)}},Wa=(e,t)=>gn.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 Ga=new Set(["localhost","0.0.0.0"]),Ha=e=>{const t=e.split(".");return 4===t.length&&"127"===t[0]&&t.every(e=>/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255)},Ja=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},Va=e=>/^0{1,4}$/.test(e),Ka=e=>!!e&&(!!Ga.has(e)||!!Ha(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(":"):[],r=o?o.split(":"):[];return i.length+r.length<8&&i.every(Va)&&r.every(Va)}const n=e.split(":");return 8===n.length&&n.every(Va)})(e)||(e=>{if("::1"===e)return!0;const t=e.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);if(t)return Ha(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)),Ya={http:80,https:443,ws:80,wss:443,ftp:21},Za=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i,Xa=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i,Qa=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(Ja);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,r=Ja(n[n.length-1]);if(null===r)return e;if(r<0||r>(1<<8*i)-1)return e;const a=new Array(i).fill(0);for(let e=i-1,t=r;e>=0;e--,t>>=8)a[e]=255&t;const s=o.map(Ja);return s.some(e=>null===e||e<0||e>255)?e:[...s,...a].join(".")})(t);return n!==t?n:(e=>{if("string"!=typeof e||-1===e.indexOf(":"))return e;const t=e.match(Za);if(t)return t[1];const n=e.match(Xa);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)},es=(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,r=0,a=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),l=o[a];i||(i=c),n[r]=s,o[r]=c;let p=a,u=0;for(;p!==r;)u+=n[p++],p%=e;if(r=(r+1)%e,r===a&&(a=(a+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,r){let a,s,c=0,l=1e3/r;const p=(n,r=Date.now())=>{c=r,a=null,s&&(clearTimeout(s),s=null),(n=>{if(!n||"number"!=typeof n.loaded)return;const r=n.loaded,a=n.lengthComputable?n.total:void 0,s=Math.max(0,null!=a?Math.min(r,a):r),c=Math.max(0,s-o),l=i(c);o=Math.max(o,s),e({loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a?(a-s)/l:void 0,event:n,lengthComputable:null!=a,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-c;n>=l?p(e,t):(a=e,s||(s=setTimeout(()=>{s=null,p(a)},l-n)))},()=>a&&p(a)]}(0,n)},ts=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},ns=(e,t=gn.asap)=>(...n)=>t(()=>e(...n)),os=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,is=(e,t,n)=>t+2<n&&os(e.charCodeAt(t+1))&&os(e.charCodeAt(t+2)),rs=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,ss=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)},cs=e=>{const t=e.length;let n=0,o=0,i=!1;for(let a=0;a<t;a++){let s=e.charCodeAt(a);37===s&&is(e,a,t)&&(s=16*rs(e.charCodeAt(a+1))+rs(e.charCodeAt(a+2)),a+=2),9!==(r=s)&&10!==r&&12!==r&&13!==r&&32!==r&&(61!==s?!as(s)||o>0?i=!0:n++:o++)}var r;return i||o>2||o>0&&(n+o)%4!=0||n%4==1?ss(e):(e=>{const t=e%4;return 3*Math.floor(e/4)+(2===t?1:3===t?2:0)})(n)},ls=(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 r=0;for(let e=0,t=i.length;e<t;e++){const n=i.charCodeAt(e);if(37===n&&is(i,e,t))r+=1,e+=2;else if(n<128)r+=1;else if(n<2048)r+=2;else if(n>=55296&&n<=56319&&e+1<t){const t=i.charCodeAt(e+1);t>=56320&&t<=57343?(r+=4,e++):r+=3}else r+=3}return r},ps={flush:Ne.constants.Z_SYNC_FLUSH,finishFlush:Ne.constants.Z_SYNC_FLUSH},us={flush:Ne.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ne.constants.BROTLI_OPERATION_FLUSH},ds={flush:Ne.constants.ZSTD_e_flush,finishFlush:Ne.constants.ZSTD_e_flush},ms=gn.isFunction(Ne.createBrotliDecompress),fs=gn.isFunction(Ne.createZstdDecompress),hs="gzip, compress, deflate"+(ms?", br":""),gs=hs+(fs?", zstd":""),vs="undefined"!=typeof process&&process.nextTick?process.nextTick.bind(process):gn.asap,{http:bs,https:ys}=$a,xs=/https:?/,ws=Symbol("axios.http.socketListener"),_s=Symbol("axios.http.currentReq"),js=Symbol("axios.http.installedTunnel"),ks=new Map,Ss=new WeakMap,Es={22:21,24:5},Ts=Ki.protocols.map(e=>e+":"),$s=e=>{if(!gn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Is=(e,[t,n])=>(e.on("end",n).on("error",n),t),As=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,r;const a=()=>{if(i)return;i=!0,r&&(clearTimeout(r),r=null);let t=n,a=t.length,s=a;for(;s--;)if(t[s][0]===o)return 1===a?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++,r&&(clearTimeout(r),r=null),t.once("close",()=>{--e||(r=setTimeout(()=>{r=null,a()},c))}),t}}o.once("close",a);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 Cs(e,t,n,o,i,r){let a=t;const s=function(e,t,n){return xs.test(e.protocol)?n||ye.globalAgent:t||be.globalAgent}(e,r,i);if(!a&&!1!==a&&!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!=Es[t]&&n>=Es[t])}(t))return!1;const n=e&&e.options;return Boolean(n&&gn.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=ur("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,r=o?parseInt(o[2]):0;return!(!r||r===t)||(/^[.*]/.test(i)?("*"===i.charAt(0)&&(i=i.slice(1)),!e.endsWith(i)):e!==i)})}(o=o.replace(/:\d*$/,""),i=parseInt(i)||pr[n]||0))return"";var r=ur(n+"_proxy")||ur("all_proxy");return r&&-1===r.indexOf("://")&&(r=n+"://"+r),r}(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)||Ya[t.protocol.split(":",1)[0]]||0,i=Qa(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=Qa(t),!!t&&(!n||n===o)&&("*"===t.charAt(0)&&(t=t.slice(1)),"."===t.charAt(0)?i.endsWith(t):i===t||Ka(i)&&Ka(t))})}(n)||(a=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[js]&&(e.agent=void 0),a){const t=a instanceof URL,o=e=>t||gn.hasOwnProp(a,e)?a[e]:void 0,r=o("username"),s=o("password");let c=gn.hasOwnProp(a,"auth")?a.auth:void 0;if(r&&(c=(r||"")+":"+(s||"")),c){const e="object"==typeof c,t=e&&gn.hasOwnProp(c,"username")?c.username:void 0,n=e&&gn.hasOwnProp(c,"password")?c.password:void 0;if(Boolean(t||n))c=(t||"")+":"+(n||"");else if(e)throw new Cn("Invalid proxy authorization",Cn.ERR_BAD_OPTION,{proxy:a})}if(xs.test(e.protocol)){if(!(i instanceof ta)){const t=o("hostname")||o("host"),n=o("port"),r=o("protocol"),a=r?r.includes(":")?r:`${r}:`:"http:",s=t&&t.includes(":")&&!t.startsWith("[")?`[${t}]`:t,l=new URL(`${a}//${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?Ss.get(t)||Ss.set(t,new Map).get(t):ks;let i=o.get(n);if(i)return i;const r=t&&t.options?{...t.options,...e}:e;if(i=new ta(r),t&&t.options){const e={...t.options},n=i.callback;i.callback=function(t,o){return n.call(this,t,{...e,...o})}}return i[js]=!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 r=o("protocol");r&&(e.protocol=r.includes(":")?r:`${r}:`)}}e.beforeRedirects.proxy=function(e){Cs(e,t,e.href,!0,i,r)}}const Ns="undefined"!=typeof process&&"process"===gn.kindOf(process),Rs=(e,t)=>(({address:e,family:t})=>{if(!gn.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(gn.isObject(e)?e:{address:e,family:t}),Ps={request(e,t){const n=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:o,headers:i}=e,r=As.getSession(n,o),{HTTP2_HEADER_SCHEME:a,HTTP2_HEADER_METHOD:s,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:l}=Ce.constants,p={[a]:e.protocol.replace(":",""),[s]:e.method,[c]:e.path};gn.forEach(i,(e,t)=>{":"!==t.charAt(0)&&(p[t]=e)});const u=r.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 Us,Ls,zs=Ns&&function(e){return t=async function(t,n,o){const i=t=>gn.getSafeProp(e,t),r=i("transitional")||Di;let a=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"),y=i("maxBodyLength"),x=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 T=2===l;if(s){const e=Wa(s,e=>gn.isArray(e)?e:[e]);s=(t,n,o)=>{e(t,n,(e,t,i)=>{if(e)return o(e);const r=gn.isArray(t)?t.map(e=>Rs(e)):[Rs(t,i)];n.all?o(e,r):o(e,r[0].address,r[0].family)})}}const $=new Oe;function I(t){try{$.emit("abort",!t||t.type?new ir(null,e,k):t)}catch(e){}}function A(){S&&(clearTimeout(S),S=null)}$.once("abort",n);const O=()=>{A(),e.cancelToken&&e.cancelToken.unsubscribe(I),e.signal&&e.signal.removeEventListener("abort",I),$.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,A(),t)return E=!0,void O();const{data:n}=e;if(n instanceof ge.Readable||n instanceof ge.Duplex){const e=ge.finished(n,()=>{e(),O()})}else O()});const C=lr(i("baseURL"),i("url"),i("allowAbsoluteUrls"),e),N=new URL(C,g?"http://localhost":Ki.hasBrowserEnv?Ki.origin:void 0),R=N.protocol||Ts[0];if("data:"===R){if(x>-1){const t=function(e){return ls(e,ss)}(String(i("url")||C||""));if(t>x)return n(new Cn("maxContentLength size of "+x+" exceeded",Cn.ERR_BAD_RESPONSE,e))}let o;if("GET"!==v)return rr(t,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{o=function(e,t,n){const o=n&&n.Blob||Ki.classes.Blob,i=Aa(e);if(void 0===t&&o&&(t=!0),"data"===i){e=i.length?e.slice(i.length+1):e;const n=Oa.exec(e);if(!n)throw new Cn("Invalid URL",Cn.ERR_INVALID_URL);const r=n[1],a=n[2],s=n[3]?"base64":"utf8",c=n[4];let l="";r?l=a?r+a:r:a&&(l="text/plain"+a);const p="base64"===s?Buffer.from(c,"base64"):Buffer.from(decodeURIComponent(c),s);if(t){if(!o)throw new Cn("Blob is not supported",Cn.ERR_NOT_SUPPORT);return new o([p],{type:l})}return p}throw new Cn("Unsupported protocol "+i,Cn.ERR_NOT_SUPPORT)}(i("url"),"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw Cn.from(t,Cn.ERR_BAD_REQUEST,e)}return"text"===f?(o=o.toString(h),h&&"utf8"!==h||(o=gn.stripBOM(o))):"stream"===f&&(o=ge.Readable.from(o)),rr(t,n,{data:o,status:200,statusText:"OK",headers:new In,config:e})}if(-1===Ts.indexOf(R))return n(new Cn("Unsupported protocol "+R,Cn.ERR_BAD_REQUEST,e));const P=In.from(e.headers).normalize();P.set("User-Agent","axios/"+Ia,!1);const{onUploadProgress:U,onDownloadProgress:L}=e,z=e.maxRate;let F,D;if(gn.isSpecCompliantForm(a)){const e=P.getContentType(/boundary=([-_\w\d]{10,70})/i);a=((e,t,n)=>{const{tag:o="form-data-boundary",size:i=25,boundary:r=o+"-"+Ki.generateString(i,za)}=n||{};if(!gn.isFormData(e))throw new TypeError("FormData instance required");if(r.length<1||r.length>70)throw new Error("boundary must be 1-70 characters long");const a=Fa.encode("--"+r+Da),s=Fa.encode("--"+r+"--"+Da);let c=s.byteLength;const l=Array.from(e.entries()).map(([e,t])=>{const n=new Ba(e,t);return c+=n.size,n});c+=a.byteLength*l.length,c=gn.toFiniteNumber(c);const p={"Content-Type":`multipart/form-data; boundary=${r}`};return Number.isFinite(c)&&(p["Content-Length"]=c),t&&t(p),ve.from(async function*(){for(const e of l)yield a,yield*e.encode();yield s}())})(a,e=>{P.set(e)},{tag:`axios-${Ia}-boundary`,boundary:e&&e[1]||void 0})}else if(gn.isFormData(a)&&gn.isFunction(a.getHeaders)&&a.getHeaders!==Object.prototype.getHeaders){if(Na(P,a.getHeaders(),i("formDataHeaderPolicy")),!P.hasContentLength())try{const e=await he.promisify(a.getLength).call(a);Number.isFinite(e)&&e>=0&&P.setContentLength(e)}catch(e){}}else if(gn.isBlob(a)||gn.isFile(a))a.size&&P.setContentType(a.type||"application/octet-stream"),P.setContentLength(a.size||0),a=ge.Readable.from(La(a));else if(a&&!gn.isStream(a)){if(Buffer.isBuffer(a));else if(gn.isArrayBuffer(a))a=Buffer.from(new Uint8Array(a));else{if(!gn.isString(a))return n(new Cn("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Cn.ERR_BAD_REQUEST,e));a=Buffer.from(a,"utf-8")}if(P.setContentLength(a.length,!1),y>-1&&a.length>y)return n(new Cn("Request body larger than maxBodyLength limit",Cn.ERR_BAD_REQUEST,e))}const q=gn.toFiniteNumber(P.getContentLength());let B;gn.isArray(z)?(F=z[0],D=z[1]):F=D=z,a&&(U||F)&&(gn.isStream(a)||(a=ge.Readable.from(a,{objectMode:!1})),a=ge.pipeline([a,new Pa({maxRate:gn.toFiniteNumber(F)})],gn.noop),U&&a.on("progress",Is(a,ts(q,es(ns(U,vs),!1,3)))));const M=i("auth");let W;M&&(B=(gn.getSafeProp(M,"username")||"")+":"+(gn.getSafeProp(M,"password")||"")),B||!N.username&&!N.password||(B=$s(N.username)+":"+$s(N.password)),B&&P.delete("authorization");try{W=zi(N.pathname+N.search,i("params"),i("paramsSerializer")).replace(/^\?/,"")}catch(t){return n(Cn.from(t,Cn.ERR_BAD_REQUEST,e,null,null,{url:i("url"),exists:!0}))}P.set("Accept-Encoding",gn.hasOwnProp(r,"advertiseZstdAcceptEncoding")&&!0===r.advertiseZstdAcceptEncoding?gs:hs,!1);const G=Object.assign(Object.create(null),{path:W,method:v,headers:wn(P),agents:{http:u,https:d},auth:B,protocol:R,family:c,beforeRedirect:Os,beforeRedirects:Object.create(null),http2Options:p});if(!gn.isUndefined(s)&&(G.lookup=s),g){if("string"!=typeof g)return n(new Cn("socketPath must be a string",Cn.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 Cn(`socketPath "${g}" is not permitted by allowedSocketPaths`,Cn.ERR_BAD_OPTION_VALUE,e))}G.socketPath=g}else G.hostname=N.hostname.startsWith("[")?N.hostname.slice(1,-1):N.hostname,G.port=N.port,Cs(G,m,R+"//"+N.hostname+(N.port?":"+N.port:"")+G.path,!1,d,u);let H,J=!1,V=!1;const K=xs.test(G.protocol);if(null==G.agent&&(G.agent=K?d:u),T)H=Ps;else{const t=i("transport");if(t)H=t;else if(0===b)H=K?ye:be,J=!0;else{V=!0,G.sensitiveHeaders=[],b&&(G.maxRedirects=b);const t=i("beforeRedirect");if(t&&(G.beforeRedirects.config=t),B){const e=N.origin,t=B;G.beforeRedirects.auth=function(n){try{new URL(n.href).origin===e&&(n.auth=t)}catch(e){}}}const o=i("sensitiveHeaders");if(null!=o){if(!gn.isArray(o))return n(new Cn("sensitiveHeaders must be an array of strings",Cn.ERR_BAD_OPTION_VALUE,e));const t=new Set;for(const i of o){if(!gn.isString(i))return n(new Cn("sensitiveHeaders must be an array of strings",Cn.ERR_BAD_OPTION_VALUE,e));t.add(i.toLowerCase())}t.size&&(G.sensitiveHeaders=Array.from(t),G.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)})}H=K?ys:bs}}G.maxBodyLength=y>-1?y:Infinity,G.insecureHTTPParser=Boolean(i("insecureHTTPParser")),k=H.request(G,function(o){if(A(),k.destroyed)return;const i=[o],r=gn.toFiniteNumber(o.headers["content-length"]);if(L||D){const e=new Pa({maxRate:gn.toFiniteNumber(D)});L&&e.on("progress",Is(e,ts(r,es(ns(L,vs),!0,3)))),i.push(e)}let a=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(Ne.createUnzip(ps)),delete o.headers["content-encoding"];break;case"deflate":i.push(new Ma),i.push(Ne.createUnzip(ps)),delete o.headers["content-encoding"];break;case"br":ms&&(i.push(Ne.createBrotliDecompress(us)),delete o.headers["content-encoding"]);break;case"zstd":fs&&(i.push(Ne.createZstdDecompress(ds)),delete o.headers["content-encoding"])}a=i.length>1?ge.pipeline(i,gn.noop):i[0];const c={status:o.statusCode,statusText:o.statusMessage,headers:new In(o.headers),config:e,request:s};if("stream"===f){if(x>-1){const t=x,n=a;a=ge.Readable.from(async function*(){let o=0;for await(const i of n){if(o+=i.length,o>t)throw new Cn("maxContentLength size of "+t+" exceeded",Cn.ERR_BAD_RESPONSE,e,s);yield i}}(),{objectMode:!1})}c.data=a,rr(t,n,c)}else{const o=[];let i=0;a.on("data",function(t){o.push(t),i+=t.length,x>-1&&i>x&&(E=!0,a.destroy(),I(new Cn("maxContentLength size of "+x+" exceeded",Cn.ERR_BAD_RESPONSE,e,s)))}),a.on("aborted",function(){if(E)return;const t=new Cn("stream has been aborted",Cn.ERR_BAD_RESPONSE,e,s,c);a.destroy(t),n(t)}),a.on("error",function(t){E||n(Cn.from(t,null,e,s,c))}),a.on("end",function(){try{let e=1===o.length?o[0]:Buffer.concat(o);"arraybuffer"!==f&&(e=e.toString(h),h&&"utf8"!==h||(e=gn.stripBOM(e))),c.data=e}catch(t){return n(Cn.from(t,null,e,c.request,c))}rr(t,n,c)})}$.once("abort",e=>{a.destroyed||(a.emit("error",e),a.destroy())})}),$.once("abort",e=>{k.close?k.close():k.destroy(e)}),k.on("error",function(t){n(Cn.from(t,null,e,k))});const Y=new Set;if(k.on("socket",function(e){"function"==typeof e.setKeepAlive&&e.setKeepAlive(!0,6e4),e[ws]||(e.on("error",function(t){const n=e[_s];n&&!n.destroyed&&n.destroy(t)}),e[ws]=!0),e[_s]=k,Y.add(e)}),k.once("close",function(){A();for(const e of Y)e[_s]===k&&(e[_s]=null);Y.clear()}),i("timeout")){const t=parseInt(i("timeout"),10);if(Number.isNaN(t))return void I(new Cn("error trying to parse `config.timeout` to int",Cn.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 Cn(n,r.clarifyTimeoutError?Cn.ETIMEDOUT:Cn.ECONNABORTED,e,k)}())};J&&t>0&&(S=setTimeout(n,t)),k.setTimeout(t,n)}else k.setTimeout(0);if(gn.isStream(a)){let t=!1,n=!1;a.on("end",()=>{t=!0}),a.once("error",e=>{n=!0,k.destroy(e)}),a.on("close",()=>{t||n||I(new ir("Request stream has been aborted",e,k))});let o=a;if(y>-1&&!V){const t=y;let n=0;o=ge.pipeline([a,new ge.Transform({transform(o,i,r){if(n+=o.length,n>t)return r(new Cn("Request body larger than maxBodyLength limit",Cn.ERR_BAD_REQUEST,e,k));r(null,o)}})],gn.noop),o.on("error",e=>{k.destroyed||k.destroy(e)})}o.pipe(k)}else a&&k.write(a),k.end()},new Promise((e,n)=>{let o,i;const r=(e,t)=>{i||(i=!0,o&&o(e,t))},a=e=>{r(e,!0),n(e)};t(t=>{r(t),e(t)},a,e=>o=e).catch(a)});var t},Fs=Ki.hasStandardBrowserEnv?(Us=new URL(Ki.origin),Ls=Ki.navigator&&/(msie|trident)/i.test(Ki.navigator.userAgent),e=>(e=new URL(e,Ki.origin),Us.protocol===e.protocol&&Us.host===e.host&&(Ls||Us.port===e.port))):()=>!0,Ds=Ki.hasStandardBrowserEnv?{write(e,t,n,o,i,r,a){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];gn.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),gn.isString(o)&&s.push(`path=${o}`),gn.isString(i)&&s.push(`domain=${i}`),!0===r&&s.push("secure"),gn.isString(a)&&s.push(`SameSite=${a}`),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 qs=e=>e instanceof In?{...e}:e,Bs=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Ms(e,t){e=e||{},t=t||{};const n=Object.create(null);function o(e,t,n,o){return gn.isPlainObject(e)&&gn.isPlainObject(t)?gn.merge.call({caseless:o},e,t):gn.isPlainObject(t)?gn.merge({},t):gn.isArray(t)?t.slice():t}function i(e,t,n,i){return gn.isUndefined(t)?gn.isUndefined(e)?void 0:o(void 0,e,0,i):o(e,t,0,i)}function r(e,t){if(!gn.isUndefined(t))return o(void 0,t)}function a(e,t){return gn.isUndefined(t)?gn.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function s(n,i,r){return gn.hasOwnProp(t,r)?o(n,i):gn.hasOwnProp(e,r)?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:r,method:r,data:r,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,allowedSocketPaths:a,responseEncoding:a,validateStatus:s,headers:(e,t,n)=>i(qs(e),qs(t),0,!0)};return gn.forEach(Bs({...e,...t}),function(o){if("__proto__"===o||"constructor"===o||"prototype"===o)return;const r=gn.hasOwnProp(c,o)?c[o]:i,a=r(gn.hasOwnProp(e,o)?e[o]:void 0,gn.hasOwnProp(t,o)?t[o]:void 0,o);gn.isUndefined(a)&&r!==s||(n[o]=a)}),gn.hasOwnProp(t,"validateStatus")&&gn.isUndefined(t.validateStatus)&&!1===function(n){const o=gn.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!gn.isUndefined(o)){if(!gn.isPlainObject(o))return;if(gn.hasOwnProp(o,n))return o[n]}const i=gn.hasOwnProp(e,"transitional")?e.transitional:void 0;if(gn.isPlainObject(i)&&gn.hasOwnProp(i,n))return i[n]}("validateStatusUndefinedResolves")&&(gn.hasOwnProp(e,"validateStatus")?n.validateStatus=o(void 0,e.validateStatus):delete n.validateStatus),n}function Ws(e){const t=Ms({},e),n=e=>gn.hasOwnProp(t,e)?t[e]:void 0,o=n("data");let i=n("withXSRFToken");const r=n("xsrfHeaderName"),a=n("xsrfCookieName");let s=n("headers");const c=n("auth"),l=n("baseURL"),p=n("allowAbsoluteUrls"),u=n("url");if(t.headers=s=In.from(s),t.url=zi(lr(l,u,p,t),n("params"),n("paramsSerializer")),c){const t=gn.getSafeProp(c,"username")||"",n=gn.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 Cn.from(t,Cn.ERR_BAD_OPTION_VALUE,e)}}if(gn.isFormData(o)&&(Ki.hasStandardBrowserEnv||Ki.hasStandardBrowserWebWorkerEnv||gn.isReactNative(o)?s.setContentType(void 0):gn.isFunction(o.getHeaders)&&Na(s,o.getHeaders(),n("formDataHeaderPolicy"))),Ki.hasStandardBrowserEnv&&(gn.isFunction(i)&&(i=i(t)),!0===i||null==i&&Fs(t.url))){const e=r&&a&&Ds.read(a);e&&s.set(r,e)}return t}var Gs="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const o=Ws(e);let i=o.data;const r=In.from(o.headers).normalize();let a,s,c,l,p,{responseType:u,onUploadProgress:d,onDownloadProgress:m}=o;function f(){l&&l(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(a),o.signal&&o.signal.removeEventListener("abort",a)}let h=new XMLHttpRequest;function g(){if(!h)return;const o=In.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());rr(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 Cn("Request aborted",Cn.ECONNABORTED,e,h)),f(),h=null)},h.onerror=function(t){const o=new Cn(t&&t.message?t.message:"Network Error",Cn.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 Cn(t,(o.transitional||Di).clarifyTimeoutError?Cn.ETIMEDOUT:Cn.ECONNABORTED,e,h)),f(),h=null},void 0===i&&r.setContentType(null),"setRequestHeader"in h&&gn.forEach(wn(r),function(e,t){h.setRequestHeader(t,e)}),gn.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),u&&"json"!==u&&(h.responseType=o.responseType),m&&([c,p]=es(m,!0),h.addEventListener("progress",c)),d&&h.upload&&([s,l]=es(d),h.upload.addEventListener("progress",s),h.upload.addEventListener("loadend",l)),(o.cancelToken||o.signal)&&(a=t=>{h&&(n(!t||t.type?new ir(null,e,h):t),h.abort(),f(),h=null)},o.cancelToken&&o.cancelToken.subscribe(a),o.signal&&(o.signal.aborted?a():o.signal.addEventListener("abort",a)));const v=Aa(o.url);if(v&&!Ki.protocols.includes(v))return n(new Cn("Unsupported protocol "+v+":",Cn.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,a();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Cn?t:new ir(t instanceof Error?t.message:t))}};let r=t&&setTimeout(()=>{r=null,i(new Cn(`timeout of ${t}ms exceeded`,Cn.ETIMEDOUT))},t);const a=()=>{e&&(r&&clearTimeout(r),r=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=()=>gn.asap(a),s};const Js=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},Vs=(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*Js(n,t)}(e,t);let r,a=0,s=e=>{r||(r=!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=a+=o.byteLength;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},{isFunction:Ks}=gn,Ys=e=>{if(!gn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Zs=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Xs=e=>{const t=null!=gn.global?gn.global:globalThis,{ReadableStream:n,TextEncoder:o}=t;e=gn.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:i,Request:r,Response:a}=e,s=i?Ks(i):"function"==typeof fetch,c=Ks(r),l=Ks(a);if(!s)return!1;const p=s&&Ks(n),u=s&&("function"==typeof o?(d=new o,e=>d.encode(e)):async e=>new Uint8Array(await new r(e).arrayBuffer()));var d;const m=c&&p&&Zs(()=>{let e=!1;const t=new r(Ki.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&&Zs(()=>gn.isReadableStream(new a("").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 Cn(`Response type '${e}' is not supported`,Cn.ERR_NOT_SUPPORT,n)})});const g=async e=>{if(null==e)return 0;if(gn.isBlob(e))return e.size;if(gn.isSpecCompliantForm(e)){const t=new r(Ki.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return gn.isArrayBufferView(e)||gn.isArrayBuffer(e)?e.byteLength:(gn.isURLSearchParams(e)&&(e+=""),gn.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:y,headers:x,withCredentials:w="same-origin",fetchOptions:_,maxContentLength:j,maxBodyLength:k}=Ws(e);const S=gn.isNumber(j)&&j>-1,E=gn.isNumber(k)&&k>-1;let T=i||fetch;y=y?(y+"").toLowerCase():"text";let $=Hs([l,u&&u.toAbortSignal()],d),I=null;const A=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let O,C=null;const N=()=>new Cn("Request body larger than maxBodyLength limit",Cn.ERR_BAD_REQUEST,e,I);try{let i;const l=gn.hasOwnProp(e,"auth")?e.auth:void 0;if(l&&(i={username:gn.getSafeProp(l,"username")||"",password:gn.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,Ki.origin);i||!e.username&&!e.password||(i={username:Ys(e.username),password:Ys(e.password)}),(e.username||e.password)&&(e.username="",e.password="",t=e.href)}if(i&&(x.delete("authorization"),x.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 ls(-1===t?e:e.slice(0,t),cs)}(t);if(n>j)throw new Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I)}if(E&&"get"!==n&&"head"!==n){const e=await g(s);if("number"==typeof e&&isFinite(e)&&(O=e,e>k))throw N()}const u=E&&(gn.isReadableStream(s)||gn.isStream(s)),d=(e,t,n)=>Vs(e,65536,e=>{if(E&&e>k)throw C=N();t&&t(e)},n);if(m&&"get"!==n&&"head"!==n&&(b||u)){if(O=null==O?await(async(e,t)=>{const n=gn.toFiniteNumber(e.getContentLength());return null==n?g(t):n})(x,s):O,0!==O||u){let e,n=new r(t,{method:"POST",body:s,duplex:"half"});if(gn.isFormData(s)&&(e=n.headers.get("content-type"))&&x.setContentType(e),n.body){const[e,t]=b&&ts(O,es(ns(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 Cn("Stream request bodies are not supported by the current fetch implementation",Cn.ERR_NOT_SUPPORT,e,I);gn.isString(w)||(w=w?"include":"omit");const R=c&&"credentials"in r.prototype;if(gn.isFormData(s)){const e=x.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&x.delete("content-type")}x.set("User-Agent","axios/"+Ia,!1);const P={..._,signal:$,method:n.toUpperCase(),headers:wn(x.normalize()),body:s,duplex:"half",credentials:R?w:void 0};I=c&&new r(t,P);let U=await(c?T(I,_):T(t,P));const L=In.from(U.headers);if(S){const t=gn.toFiniteNumber(L.getContentLength());if(null!=t&&t>j)throw new Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I)}const z=f&&("stream"===y||"response"===y);if(f&&U.body&&(v||S||z&&A)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=U[e]});const n=gn.toFiniteNumber(L.getContentLength()),[o,i]=v&&ts(n,es(ns(v),!0))||[];let r=0;U=new a(Vs(U.body,65536,t=>{if(S&&(r=t,r>j))throw new Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I);o&&o(t)},()=>{i&&i(),A&&A()}),t)}y=y||"text";let F=await h[gn.findKey(h,y)||"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 Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I)}return!z&&A&&A(),await new Promise((t,n)=>{rr(t,n,{data:F,headers:In.from(U.headers),status:U.status,statusText:U.statusText,config:e,request:I})})}catch(t){if(A&&A(),$&&$.aborted&&$.reason instanceof Cn){const n=$.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 Cn)throw I&&!t.request&&(t.request=I),t;if(t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message)){const n=new Cn("Network Error",Cn.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 Cn.from(t,t&&t.code,e,I,t&&t.response)}}},Qs=new Map,ec=e=>{let t=e&&e.env||{};const{fetch:n,Request:o,Response:i}=t,r=[o,i,n];let a,s,c=r.length,l=Qs;for(;c--;)a=r[c],s=l.get(a),void 0===s&&l.set(a,s=c?new Map:Xs(t)),l=s;return s};ec();const tc={http:zs,xhr:Gs,fetch:{get:ec}};gn.forEach(tc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch(e){}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const nc=e=>`- ${e}`,oc=e=>gn.isFunction(e)||null===e||!1===e;var ic=function(e,t){e=gn.isArray(e)?e:[e];const{length:n}=e;let o,i;const r={};for(let a=0;a<n;a++){let n;if(o=e[a],i=o,!oc(o)&&(i=tc[(n=String(o)).toLowerCase()],void 0===i))throw new Cn(`Unknown adapter '${n}'`);if(i&&(gn.isFunction(i)||(i=i.get(t))))break;r[n||"#"+a]=i}if(!i){const e=Object.entries(r).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(nc).join("\n"):" "+nc(e[0]):"as no adapter specified";throw new Cn("There is no suitable adapter to dispatch the request "+t,Cn.ERR_NOT_SUPPORT)}return i};function rc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ir(null,e)}function ac(e){return rc(e),e.headers=In.from(e.headers),e.data=nr.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ic(e.adapter||tr.adapter,e)(e).then(function(t){rc(e),e.response=t;try{t.data=nr.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=In.from(t.headers),t},function(t){if(!or(t)&&(rc(e),t&&t.response)){e.response=t.response;try{t.response.data=nr.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=In.from(t.response.headers)}return Promise.reject(t)})}const sc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{sc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const cc={};sc.transitional=function(e,t,n){function o(e,t){return"[Axios v"+Ia+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,r)=>{if(!1===e)throw new Cn(o(i," has been removed"+(t?" in "+t:"")),Cn.ERR_DEPRECATED);return t&&!cc[i]&&(cc[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,r)}},sc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var lc={assertOptions:function(e,t,n){if("object"!=typeof e||null===e)throw new Cn("options must be an object",Cn.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let i=o.length;for(;i-- >0;){const r=o[i],a=Object.prototype.hasOwnProperty.call(t,r)?t[r]:void 0;if(a){const t=e[r],n=void 0===t||a(t,r,e);if(!0!==n)throw new Cn("option "+r+" must be "+n,Cn.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Cn("Unknown option "+r,Cn.ERR_BAD_OPTION)}},validators:sc};const pc=lc.validators;class uc{constructor(e){this.defaults=e||{},this.interceptors={request:new Fi,response:new Fi}}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=Ms(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:i}=t;void 0!==n&&lc.assertOptions(n,{silentJSONParsing:pc.transitional(pc.boolean),forcedJSONParsing:pc.transitional(pc.boolean),clarifyTimeoutError:pc.transitional(pc.boolean),legacyInterceptorReqResOrdering:pc.transitional(pc.boolean),advertiseZstdAcceptEncoding:pc.transitional(pc.boolean),validateStatusUndefinedResolves:pc.transitional(pc.boolean)},!1),null!=o&&(gn.isFunction(o)?t.paramsSerializer={serialize:o}:lc.assertOptions(o,{encode:pc.function,serialize:pc.function},!0)),void 0!==t.allowAbsoluteUrls||(t.allowAbsoluteUrls=void 0===this.defaults.allowAbsoluteUrls||this.defaults.allowAbsoluteUrls),lc.assertOptions(t,{baseUrl:pc.spelling("baseURL"),withXsrfToken:pc.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=i&&gn.merge(i.common,i[t.method]);i&&gn.forEach(["delete","get","head","post","put","patch","query","common"],e=>{delete i[e]}),t.headers=In.concat(r,i);const a=[];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||Di;n&&n.legacyInterceptorReqResOrdering?a.unshift(e.fulfilled,e.rejected):a.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(...a),e.push(...c),p=e.length,l=Promise.resolve(t);u<p;)l=l.then(e[u++],e[u++]);return l}p=a.length;let d=t;for(;u<p;){const e=a[u++],t=a[u++];try{d=e?e(d):d}catch(e){if(!t){l=Promise.reject(e);break}try{const n=t.call(this,e);gn.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 zi(lr((e=Ms(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}}gn.forEach(["delete","get","head","options"],function(e){uc.prototype[e]=function(t,n){return this.request(Ms(n||{},{method:e,url:t,data:n&&gn.hasOwnProp(n,"data")?n.data:void 0}))}}),gn.forEach(["post","put","patch","query"],function(e){function t(t){return function(n,o,i){return this.request(Ms(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}uc.prototype[e]=t(),"query"!==e&&(uc.prototype[e+"Form"]=t(!0))});var dc=uc;class mc{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 ir(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 mc(function(t){e=t}),cancel:e}}}var fc=mc;const hc={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(hc).forEach(([e,t])=>{hc[t]=e});var gc=hc;const vc=function e(t){const n=new dc(t),o=xt(dc.prototype.request,n);return gn.extend(o,dc.prototype,n,{allOwnKeys:!0}),gn.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return e(Ms(t,n))},o}(tr);vc.Axios=dc,vc.CanceledError=ir,vc.CancelToken=fc,vc.isCancel=or,vc.VERSION=Ia,vc.toFormData=Ni,vc.AxiosError=Cn,vc.Cancel=vc.CanceledError,vc.all=function(e){return Promise.all(e)},vc.spread=function(e){return function(t){return e.apply(null,t)}},vc.isAxiosError=function(e){return gn.isObject(e)&&!0===e.isAxiosError},vc.mergeConfig=Ms,vc.AxiosHeaders=In,vc.formToJSON=e=>Xi(gn.isHTMLForm(e)?new FormData(e):e),vc.getAdapter=ic,vc.HttpStatusCode=gc,vc.default=vc;var bc=vc;const{CanceledError:yc}=bc,xc="screenshot.needle.webp",wc=/screenshot(\-\d+?)?\.needle\.(webp|png|jpg|jpeg)/;async function _c(e,t){const n=t.baseUrl+ht.jobs.post_update,o={...gt(t),job_id:e.identifier,status:e.status},i={status_message:e.status_message,error:e.error,progress:e.progress},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)}).catch(e=>(console.error(e),null));return!!r&&r.ok}async function jc(e,t){const n=t.baseUrl+ht.jobs.get_status,o={...gt(t),job_id:e,org:t.org},i=await fetch(n,{...vt,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 kc(e={}){var t,n;const o=null!=(t=e.maxAuthFailures)?t:2,i=null!=(n=e.maxTransientFailures)?n:10;let r=0,a=0;return{record(e){if(e&&!0!==e.failed)return r=0,a=0,null;const t=null==e?void 0:e.httpStatus;return 401===t||403===t?(r++,r>=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):(a++,a>=i?{abort:!0,reason:`Could not read the job status after ${a} attempts${t?` (last: HTTP ${t})`:""}. The job may still be running — check it in the Needle Cloud dashboard.`}:null)}}}const Sc=6,Ec=1e3,Tc=15e3,$c=9e4,Ic=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"]),Ac=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!!Ac.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||!Ic.has(o)}function Cc(e,t={}){const{baseMs:n=Ec,maxMs:o=Tc,random:i=Math.random}=t,r=Math.max(1,Math.floor(e)),a=Math.min(o,n*2**(r-1))/2;return Math.max(1,Math.round(a+i()*a))}async function Nc(e,t={}){const{maxAttempts:n=Sc,budgetMs:o=$c,baseMs:i=Ec,maxMs:r=Tc,isRetryable:a=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,!a(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=Cc(m,{baseMs:i,maxMs:r,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 Pc=5242880,Uc=1e4,Lc=16777216,zc=67108864;var Fc=Dn(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],r=e[3];o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[0]-680876936|0)<<7|n>>>25)+o|0)&o|~n&i)+t[1]-389564586|0)<<12|r>>>20)+n|0)&n|~r&o)+t[2]+606105819|0)<<17|i>>>15)+r|0)&r|~i&n)+t[3]-1044525330|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[4]-176418897|0)<<7|n>>>25)+o|0)&o|~n&i)+t[5]+1200080426|0)<<12|r>>>20)+n|0)&n|~r&o)+t[6]-1473231341|0)<<17|i>>>15)+r|0)&r|~i&n)+t[7]-45705983|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[8]+1770035416|0)<<7|n>>>25)+o|0)&o|~n&i)+t[9]-1958414417|0)<<12|r>>>20)+n|0)&n|~r&o)+t[10]-42063|0)<<17|i>>>15)+r|0)&r|~i&n)+t[11]-1990404162|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[12]+1804603682|0)<<7|n>>>25)+o|0)&o|~n&i)+t[13]-40341101|0)<<12|r>>>20)+n|0)&n|~r&o)+t[14]-1502002290|0)<<17|i>>>15)+r|0)&r|~i&n)+t[15]+1236535329|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[1]-165796510|0)<<5|n>>>27)+o|0)&i|o&~i)+t[6]-1069501632|0)<<9|r>>>23)+n|0)&o|n&~o)+t[11]+643717713|0)<<14|i>>>18)+r|0)&n|r&~n)+t[0]-373897302|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[5]-701558691|0)<<5|n>>>27)+o|0)&i|o&~i)+t[10]+38016083|0)<<9|r>>>23)+n|0)&o|n&~o)+t[15]-660478335|0)<<14|i>>>18)+r|0)&n|r&~n)+t[4]-405537848|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[9]+568446438|0)<<5|n>>>27)+o|0)&i|o&~i)+t[14]-1019803690|0)<<9|r>>>23)+n|0)&o|n&~o)+t[3]-187363961|0)<<14|i>>>18)+r|0)&n|r&~n)+t[8]+1163531501|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[13]-1444681467|0)<<5|n>>>27)+o|0)&i|o&~i)+t[2]-51403784|0)<<9|r>>>23)+n|0)&o|n&~o)+t[7]+1735328473|0)<<14|i>>>18)+r|0)&n|r&~n)+t[12]-1926607734|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[5]-378558|0)<<4|n>>>28)+o|0)^o^i)+t[8]-2022574463|0)<<11|r>>>21)+n|0)^n^o)+t[11]+1839030562|0)<<16|i>>>16)+r|0)^r^n)+t[14]-35309556|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[1]-1530992060|0)<<4|n>>>28)+o|0)^o^i)+t[4]+1272893353|0)<<11|r>>>21)+n|0)^n^o)+t[7]-155497632|0)<<16|i>>>16)+r|0)^r^n)+t[10]-1094730640|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[13]+681279174|0)<<4|n>>>28)+o|0)^o^i)+t[0]-358537222|0)<<11|r>>>21)+n|0)^n^o)+t[3]-722521979|0)<<16|i>>>16)+r|0)^r^n)+t[6]+76029189|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[9]-640364487|0)<<4|n>>>28)+o|0)^o^i)+t[12]-421815835|0)<<11|r>>>21)+n|0)^n^o)+t[15]+530742520|0)<<16|i>>>16)+r|0)^r^n)+t[2]-995338651|0)<<23|o>>>9)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[0]-198630844|0)<<6|n>>>26)+o|0)|~i))+t[7]+1126891415|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[14]-1416354905|0)<<15|i>>>17)+r|0)|~n))+t[5]-57434055|0)<<21|o>>>11)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[12]+1700485571|0)<<6|n>>>26)+o|0)|~i))+t[3]-1894986606|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[10]-1051523|0)<<15|i>>>17)+r|0)|~n))+t[1]-2054922799|0)<<21|o>>>11)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[8]+1873313359|0)<<6|n>>>26)+o|0)|~i))+t[15]-30611744|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[6]-1560198380|0)<<15|i>>>17)+r|0)|~n))+t[13]+1309151649|0)<<21|o>>>11)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[4]-145523070|0)<<6|n>>>26)+o|0)|~i))+t[11]-1120210379|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[2]+718787259|0)<<15|i>>>17)+r|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]=r+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 r(e){var t,i,r,a,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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(n(p,r),t=0;t<16;t+=1)r[t]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),c=parseInt(a[1],16)||0,r[14]=s,r[15]=c,n(p,r),p}function a(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]=a(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(r("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,r,a,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),r=new Uint8Array(i),a=new Uint8Array(this,c,o),r.set(a),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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)r[t>>2]|=o.charCodeAt(t)<<(t%4<<3);return this._finish(r,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,r,a=t;if(e[a>>2]|=128<<(a%4<<3),a>55)for(n(this._hash,e),a=0;a<16;a+=1)e[a]=0;o=(o=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),r=parseInt(o[1],16)||0,e[14]=i,e[15]=r,n(this._hash,e)},p.hash=function(e,t){return p.hashBinary(c(e),t)},p.hashBinary=function(e,t){var n=s(r(e));return t?l(n):n},(p.ArrayBuffer=function(){this.reset()}).prototype.append=function(e){var t,o,r,a,s=(o=this._buff.buffer,r=e,(a=new Uint8Array(o.byteLength+r.byteLength)).set(new Uint8Array(o)),a.set(new Uint8Array(r),o.byteLength),a),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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)r[t>>2]|=o[t]<<(t%4<<3);return this._finish(r,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),r=new Uint8Array(i);for(n=0;n<o;n+=1)r[n]=e.charCodeAt(n);return r}(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,r,a,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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)r[t>>2]|=e[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(n(p,r),t=0;t<16;t+=1)r[t]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),c=parseInt(a[1],16)||0,r[14]=s,r[15]=c,n(p,r),p}(new Uint8Array(e)));return t?l(o):o},p}()}),Dc=Fc;function qc(e,t=0){return Gc(e,t,2).getUint16(0,!0)}function Bc(e,t=0){return Gc(e,t,4).getUint32(0,!0)}function Mc(e,t=0,n=e.byteLength){const o=e.slice(t,t+n);return Hc.decode(new Uint8Array(o))}function Wc(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 Gc(e,t,n){const o=e.slice(t,t+n);return new DataView(new Uint8Array(o).buffer)}const Hc=new TextDecoder("utf8"),Jc=[["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 Vc(e){return e.flatMap(([e,t,n,o={},i=[]])=>[[e,t,n,o],...i])}function Kc(e,t){const n=qc(e,26),o=Mc(e,30,n),[i]=o.split("/"),r=o.endsWith(".xml");return"META-INF"===i?{ext:"jar",mime:"application/java-archive"}:"ppt"===i&&r?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:"word"===i&&r?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:"xl"===i&&r?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:"mimetype"===i?function(e,t){const n=Bc(e,18),o=Bc(e,22),i=qc(e,28);if(n===o){const o=Mc(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 Yc=function(e){return Vc(e).map(([e,t,n,{offset:o=0}={}])=>n.length+o).reduce((e,t)=>t>e?t:e,0)}(Jc);function Zc(e,t){for(const[n,o,i,{exact:r=!0,offset:a=0}={},s=[]]of t)if(Wc(e,i,a)){if("zip"===n&&!r)return Kc(e.buffer,{ext:n,mime:o});if(!r&&s.length)for(const[t,n,o,{offset:i=0}={}]of s)if(Wc(e,o,i))return{ext:t,mime:n};return{ext:n,mime:o}}}function Xc(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)||tl(t,e),r=new File([t],o,{type:i});return r.path=e,r}const Qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function el(e){return 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,r=n+2<e.length?e.charCodeAt(n+2):0;t+=Qc[o>>2]+Qc[(3&o)<<4|i>>4]+(n+1<e.length?Qc[(15&i)<<2|r>>6]:"=")+(n+2<e.length?Qc[63&r]:"=")}return t}(Dc.ArrayBuffer.hash(e,!0))}function tl(e,t=void 0){const n=function(e,{extra:t=!1,hint:n}={}){const o=new Uint8Array(e.slice(0,Yc));if(n){const e=function(e,{ext:t,mime:n}){return t||n?Vc(e).filter(e=>e[0]===t||e[1]===n):[]}(Jc,n);if(e.length>0){const t=Zc(o,e);if(void 0!==t)return t}}return Zc(o,Jc)||(t?function(e){return function(e){try{const t=Mc(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 r=0;r<o.length;r++)i+=o[r].toString(16);let a="unknown";switch(i){case"676c5446":a="model/gltf-binary";break;case"89504e47":a="image/png";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":a="image/jpeg";break;default:a="unknown"}return"unknown"===a&&"string"==typeof t&&(a=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)),a}function nl(e){return"string"==typeof e&&0!==e.length&&e.toLowerCase().endsWith(".exr")}function ol(e){if("string"!=typeof e||0===e.length)return!1;const t=e.toLowerCase();return t.endsWith(".hdr")||t.endsWith(".hdri")}function il(e){return"string"==typeof e&&0!==e.length&&/\.pmrem(\d+x\d+)?\.ktx2$/i.test(e)}function rl(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 al(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 sl(e){return e.split("/").reduce((e,t)=>("."===t||(".."===t?e.pop():null!=t&&t.length&&e.push(t)),e),[]).join("/")}const cl=1179937895,ll=1313821514,pl=12,ul=8;function dl(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))}const ml=4,fl=1;function hl(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e))}function gl(e){return Array.isArray(e)?e:[]}function vl(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0?e:null}function bl(e){return Array.isArray(e)&&3===e.length&&e.every(e=>"number"==typeof e&&Number.isFinite(e))?[e[0],e[1],e[2]]:null}function yl(e){return gl(e).filter(e=>"string"==typeof e)}function xl(e,t){e.meshes+=t.meshes,e.primitives+=t.primitives,e.vertices=null===e.vertices||null===t.vertices?null:e.vertices+t.vertices,e.triangles=null===e.triangles||null===t.triangles?null:e.triangles+t.triangles}const wl=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function _l(e){const t=new Set([...gl(e.buffers),...gl(e.images)].map(e=>hl(e).uri).filter(e=>"string"==typeof e&&!e.startsWith("data:"))),n=new Set;let o=1,i=1;function r(e){let o=1;for(const i of e){const e=gl(hl(hl(hl(i).extensions).NEEDLE_progressive).lods).map(e=>hl(e).path).filter(e=>"string"==typeof e);if(e.length){n.add("NEEDLE_progressive"),o=Math.max(o,e.length+1);for(const n of e)t.add(n)}}return o}o=r(gl(e.meshes)),i=r(gl(e.textures));for(const t of gl(e.nodes)){const e=gl(hl(hl(hl(t).extensions).MSFT_lod).ids);e.length&&(n.add("MSFT_lod"),o=Math.max(o,e.length+1))}return{progressive:n.size>0,mechanisms:[...n],meshLodLevels:o,textureLodLevels:i,dependencies:[...t].sort()}}function jl(e){const t=new Set,n=new Set;let o=!1;function i(e){const n=vl(e);null===n?o=!0:t.add(n)}for(const t of gl(e.meshes))for(const e of gl(hl(t).primitives)){const t=hl(e);for(const e of Object.values(hl(t.attributes)))i(e);void 0!==t.indices&&i(t.indices);for(const e of gl(t.targets))for(const t of Object.values(hl(e)))i(t);"KHR_draco_mesh_compression"in hl(t.extensions)&&n.add("KHR_draco_mesh_compression")}for(const t of gl(e.bufferViews))"EXT_meshopt_compression"in hl(hl(t).extensions)&&n.add("EXT_meshopt_compression");const r=gl(e.accessors),a={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},s={SCALAR:[1,1],VEC2:[1,2],VEC3:[1,3],VEC4:[1,4],MAT2:[2,2],MAT3:[3,3],MAT4:[4,4]};let c=0;for(const e of t){const t=hl(r[e]),n=vl(t.count),i=a[String(t.componentType)],l=s[String(t.type)];if(!i||!l||null===n){o=!0;continue}const[p,u]=l,d=u*i;c+=n*p*(p>1?4*Math.ceil(d/4):d)}return{nodeCount:gl(e.nodes).length,meshCompression:[...n].sort(),geometryBytesEstimate:o||!Number.isSafeInteger(c)?null:c,geometryAssumption:"Unique dense mesh accessors, no renderer overhead"}}async function kl(e){return new Promise(t=>setTimeout(t,e))}function Sl(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 r=!1!==(null==n?void 0:n.prefix),a=!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 r&&(s="on "),`${s}${new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}${c}`;s=r?i?"":"in ":"",c=a&&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 El=/^image_(?<image_lod>\d+)_|^mesh_lod_(?<mesh_lod>\d+)_/;function Tl(e){return e.includes("\\u")?JSON.parse(`"${e}"`):decodeURIComponent(e)}function $l(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 r=e.filter(e=>e.name.toLowerCase().endsWith(".glb")||e.name.toLowerCase().endsWith(".gltf")||e.name.toLowerCase().endsWith(".vrm"));if(r.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=Ol(t)[0])?o:null;var o}(r);return e?(t=e,t):(n="Invalid upload: Multiple glb/glTF/vrm files found. This is currently not supported.",console.error(n,r.map(e=>e.path||e.name)),{error:n})}if(1===r.length)return t=r[0],t;const a=e.filter(e=>e.name.toLowerCase().endsWith(".usdz")||e.name.toLowerCase().endsWith(".usd")||e.name.toLowerCase().endsWith(".usda")||e.name.toLowerCase().endsWith(".usdc"));if(a.length>=1)return t=function(e){var t;const n=Ol(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}(a),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 nl(t)||ol(t)||il(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 Il=new Set(["glb","gltf","vrm"]),Al=new Set(["fbx","obj","stl","usd","usda","usdz"]);function Ol(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 Cl{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,r=(t-this.startTime)/1e3,a=this.speedEMA&&this.speedEMA>0?this.speedEMA:this.uploadedSize/r;let s;if(s=a>0?(this.estimatedTotalSize-this.uploadedSize)/a: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=r/i-r;return this.smoothedRemainingTime=Math.max(this.smoothedRemainingTime,(this.estimatedTotalSize-this.uploadedSize)/a),{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 Nl=15e3;function Rl(e,t,n={setTimeout:setTimeout,clearTimeout:clearTimeout}){return function(o,i){const r=e.call(this,o,i);if(!r||"function"!=typeof r.once)return r;const a=n.setTimeout(()=>{const e=new Error(`connect timeout: no connection within ${t/1e3}s`);e.code="ETIMEDOUT",r.destroy(e)},t),s=()=>n.clearTimeout(a);return r.once("connect",s),r.once("secureConnect",s),r.once("error",s),r.once("close",s),r}}let Pl;async function Ul(e={}){var t,n;if(!(null!=(t=e.isNode)?t:"undefined"!=typeof process&&null!=(n=process.versions)&&n.node))return{};if(Pl)return Pl;const[{default:o},{default:i}]=await Promise.all([import("node:http"),import("node:https")]),r=new o.Agent({keepAlive:!0}),a=new i.Agent({keepAlive:!0});for(const e of[r,a])e.createConnection=Rl(e.createConnection,Nl);return Pl={httpAgent:r,httpsAgent:a},Pl}async function Ll(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 Xc(`${"path"in e?e.path:e.name}.gz`,o,{type:"application/gzip"})}const zl=16777216;async function Fl(e,t,n=void 0){const o=async function(e,t,n){var o,i,r,a,s,c,l,p,u,d,m,f,h,g,v,b,y,x,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=$l(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)&&El.test(s)||i++:p.endsWith(".vrm")&&n++,p.endsWith(".gltf")){var r;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==(r=l.path)?void 0:r.split("/"),c=s.splice(0,s.length-1).join("/");for(const t of n){var a;const n=null==(a=t.groups)?void 0:a.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=sl(`${c}/${Tl(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!=(r=t.entrypoint)&&r.name.endsWith(".html")||null!=(a=t.entrypoint)&&a.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 T=await async function(e,t={}){const{raw:n=!1,loglevel:o="none",entrypoint:i=null}=t,r=(...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 a=new Set(e.map(Bl)),s=[];let c=i;for(const t of e){const n=Bl(t),p=t.name.toLowerCase();if(!Dl.some(e=>p.endsWith(e))){s.push(t);continue}const u=ql.find(e=>a.has(`${n}${e}`));if(u){var l;r(`Skipping gzip compression, using pre-compressed file: ${n}${u}`),i===t&&(c=null!=(l=e.find(e=>Bl(e)===`${n}${u}`))?l:c);continue}r(`gZip compressing file: ${t.name}`);const d=await Ll(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),r(`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(T.error)return{success:!1,error:T.error,status:500};j=T.files,t.files=j,t.entrypoint=T.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:$,authToken:I}=e,A="Bearer "+I,O={...gt(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&&(O.content_id=n.content_id),null!=(u=n)&&u.type&&(O.type=n.type),null!=(d=n)&&d.name&&(O.name=encodeURIComponent(n.name)),null!=(m=n)&&m.parent_job_id&&(O.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 N={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}:{}},R=[];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 r=t.size;let a=t.type;if(null!=(U=a)&&U.length&&"unknown"!==a.toLowerCase()||(a=tl(i,o)),"deployment"===(null==(L=n)?void 0:L.type)){const e=rl(o,a);e&&(o=e.filename,a=e.mimetype)}const s=el(i);R[e]=i,C.files[e]={filename:o,content_type:a,content_length:r,content_md5:s}}if("deployment"!==(null==(y=n)?void 0:y.type)){const e=t.entrypoint.name.toLowerCase();let o;if(e.endsWith(".glb")||e.endsWith(".gltf"))try{var z;const n=R[j.indexOf(t.entrypoint)],i=e.endsWith(".glb")?function(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<pl+ul)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)!==cl)throw new Error("Not a GLB (magic mismatch)");const o=n.getUint32(pl,!0);if(n.getUint32(pl+4,!0)!==ll)throw new Error("First chunk is not JSON");const i=pl+ul,r=i+o;if(r>t.byteLength)throw new Error("JSON chunk exceeds buffer length");const a=t.subarray(i,r),s=(new TextDecoder).decode(a);return JSON.parse(s)}(n):JSON.parse((new TextDecoder).decode(n));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"}(i),"string"==typeof(null==(z=i.asset)?void 0:z.version)&&i.asset.version.startsWith("2.")&&(C.technical_metadata=function(e){const t=hl(e.asset),n=/^(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})$/;if("string"!=typeof t.version||!n.test(t.version)||2!==Number(t.version.split(".")[0]))throw new Error("Metadata collection requires glTF 2.0-compatible asset versions");if(void 0!==t.minVersion&&("string"!=typeof t.minVersion||!n.test(t.minVersion)||"2.0"!==t.minVersion))throw new Error("Metadata collection supports a minimum glTF version of 2.0");const o=gl(e.nodes),i=gl(e.meshes),r=gl(e.accessors),a=gl(e.scenes),s=gl(e.animations),c=gl(e.skins),l=new Set;"2.0"!==t.version&&l.add(`newer-gltf-version:${t.version}`);const p=e=>{const t=vl(e);return hl(null===t?void 0:r[t])};function u(e){const t=gl(hl(e).primitives),n={meshes:1,primitives:0,vertices:0,triangles:0};n.primitives=t.length;for(const e of t){var o;const t=hl(e),i=vl(p(hl(t.attributes).POSITION).count),r=void 0===t.indices?i:vl(p(t.indices).count),a=null!=(o=t.mode)?o:4,s="number"==typeof a&&a>=0&&a<=3?0:null===r?null:4===a?Math.floor(r/3):5===a||6===a?Math.max(0,r-2):null;null!==i&&null!==s||l.add("geometry-counts-unavailable"),xl(n,{meshes:0,primitives:0,vertices:i,triangles:s})}return n}const d={meshes:0,primitives:0,vertices:0,triangles:0};for(const e of i)xl(d,u(e));const m=a.map((e,t)=>{const n=hl(e),r=gl(n.nodes),a={meshes:0,primitives:0,vertices:0,triangles:0},s=[Infinity,Infinity,Infinity],c=[-Infinity,-Infinity,-Infinity];let d=!1,m=!1,f=!1;function h(e,t,n){const r=vl(e);if(null===r||!o[r]||n.has(r))return l.add("invalid-scene-hierarchy"),void(d=!0);const g=hl(o[r]),v=(b=t,y=function(e){var t,n;if(Array.isArray(e.matrix)&&16===e.matrix.length&&e.matrix.every(e=>"number"==typeof e&&Number.isFinite(e)))return[...e.matrix];const[o,i,r]=null!=(t=bl(e.translation))?t:[0,0,0],[a,s,c]=null!=(n=bl(e.scale))?n:[1,1,1],l=e.rotation,[p,u,d,m]=Array.isArray(l)&&4===l.length&&l.every(e=>"number"==typeof e&&Number.isFinite(e))?l:[0,0,0,1];return[(1-2*(u*u+d*d))*a,2*(p*u+d*m)*a,2*(p*d-u*m)*a,0,2*(p*u-d*m)*s,(1-2*(p*p+d*d))*s,2*(u*d+p*m)*s,0,2*(p*d+u*m)*c,2*(u*d-p*m)*c,(1-2*(p*p+u*u))*c,0,o,i,r,1]}(g),Array.from({length:16},(e,t)=>{const n=t%4,o=Math.floor(t/4);return b[n]*y[4*o]+b[n+4]*y[4*o+1]+b[n+8]*y[4*o+2]+b[n+12]*y[4*o+3]}));var b,y;const x=new Set(n);if(x.add(r),void 0!==g.mesh){const e=vl(g.mesh),t=null===e?void 0:i[e];if(t){xl(a,u(t));for(const e of gl(hl(t).primitives)){const t=hl(e),n=p(hl(t.attributes).POSITION),o=bl(n.min),i=bl(n.max);if(o&&i){m||(m=void 0!==g.skin||gl(t.targets).length>0),f=!0;for(let e=0;e<8;e++){const t=1&e?i[0]:o[0],n=2&e?i[1]:o[1],r=4&e?i[2]:o[2];for(let e=0;e<3;e++){const o=v[e]*t+v[e+4]*n+v[e+8]*r+v[e+12];s[e]=Math.min(s[e],o),c[e]=Math.max(c[e],o)}}}else d=!0,l.add("bounds-unavailable")}}else l.add("missing-mesh"),d=!0}for(const e of gl(g.children))h(e,v,x)}for(const e of r)h(e,wl,new Set);let g=null;if(f&&!d){const e=[(c[0]+s[0])/2,(c[1]+s[1])/2,(c[2]+s[2])/2];g={min:s,max:c,dimensions:[c[0]-s[0],c[1]-s[1],c[2]-s[2]],center:e,originOffset:[-e[0],-e[1],-e[2]],pose:"default",approximate:m}}return{index:t,..."string"==typeof n.name?{name:n.name}:{},rootCount:r.length,geometry:a,bounds:g}}),f=s.map((e,t)=>{const n=hl(e),o=gl(n.samplers);let i=Infinity,r=-Infinity,a=0===o.length;for(const e of o){const t=p(hl(e).input),n=gl(t.min)[0],o=gl(t.max)[0];"number"!=typeof n||"number"!=typeof o||!Number.isFinite(n)||!Number.isFinite(o)||o<n?a=!0:(i=Math.min(i,n),r=Math.max(r,o))}return a&&l.add("animation-duration-unavailable"),{index:t,..."string"==typeof n.name?{name:n.name}:{},duration:a?null:r-i,trackCount:gl(n.channels).length}}),h=hl(t.extras),g={};for(const e of["author","license","source","title"])"string"==typeof h[e]&&(g[e]=h[e]);const v=vl(e.scene);null!==v&&v>=a.length&&l.add("invalid-default-scene");let b=0;for(const e of i)for(const t of gl(hl(e).primitives))b+=gl(hl(t).targets).length;return{schemaVersion:fl,collectorVersion:ml,status:l.size?"partial":"complete",issues:[...l],asset:{version:t.version,..."string"==typeof t.minVersion?{minVersion:t.minVersion}:{},..."string"==typeof t.generator?{generator:t.generator}:{},..."string"==typeof t.copyright?{copyright:t.copyright}:{},attribution:g},sceneCount:a.length,defaultSceneIndex:null!==v&&v<a.length?v:null,scenes:m,geometry:d,resourceUsage:jl(e),materialCount:gl(e.materials).length,animationCount:s.length,animations:f,skinCount:c.length,jointCount:new Set(c.flatMap(e=>gl(hl(e).joints))).size,morphTargetCount:b,textureCount:gl(e.textures).length,imageCount:gl(e.images).length,materialVariantCount:gl(hl(hl(e.extensions).KHR_materials_variants).variants).length,extensionsUsed:yl(e.extensionsUsed),extensionsRequired:yl(e.extensionsRequired),loading:_l(e),unit:"meter"}}(i))}catch(e){return{success:!1,error:`Failed to inspect "${t.entrypoint.name}": ${e.message}`}}else e.endsWith(".mtlx")?o="material":(nl(e)||ol(e)||il(e))&&(o="hdri");if(o){var F;if(null!=(F=n)&&F.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,r;if(!e||"function"!=typeof e.slice||"number"!=typeof e.size)return null;const a=Math.min(e.size,65536);if(a<=0)return null;let s;try{const t=await e.slice(0,a).arrayBuffer();s=new Uint8Array(t)}catch{return null}return null!=(t=null!=(n=null!=(o=null!=(i=null!=(r=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))?r: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=dl(e,n);if(null===o)return null;if(0===o.length)return null;n+=o.length+1;const i=dl(e,n);if(null===i)return null;if(n+=i.length+1,n+4>e.length)return null;const r=t.getInt32(n,!0);if(n+=4,r<0||n+r>e.length)return null;if("dataWindow"===o&&"box2i"===i&&16===r){const e=t.getInt32(n,!0),o=t.getInt32(n+4,!0),i=t.getInt32(n+8,!0)-e+1,r=t.getInt32(n+12,!0)-o+1;return i<=0||r<=0?null:{width:i,height:r}}n+=r}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 D=await fetch($+ht.upload.request,{...vt,method:"POST",headers:O,body:JSON.stringify(N)}).catch(e=>"fetch failed"==e.message||"Failed to fetch"==e.message?`Network error. Make sure you are connected to the internet and ${$} is reachable.`:(console.error("Failed to begin upload\n",e),null));if(null===D||"string"==typeof D)return{success:!1,error:D||"Failed to begin upload"};if(!D.ok){const e=await D.text();if(e.startsWith("{")){const t=JSON.parse(e);if("error"in t)return{success:!1,status:D.status,error:t.error}}return"none"!=S&&console.error("Failed to begin upload\n",D.status,e),{success:!1,status:D.status,error:`${e}`}}const q=await D.json();"debug"===S&&console.debug("BeginResponse",q);const B=j.reduce((e,t)=>e+t.size,0);var M;if("exists"===q.type)return"none"!=S&&console.log("Upload already exists",q.id),null!=(M=n)&&M.onStart&&n.onStart(q.id,q.content_id),{success:!0,uploadSkipped:!0,id:q.id,type:q.job_type,content_id:q.content_id,filesUploaded:j.length,totalSize:B,url:q.url,edit_url:q.edit_url};const W=t.entrypoint.webkitRelativePath||t.entrypoint.name;let G=0;null==(x=n)||null==(x=x.abort)||x.addEventListener("abort",async()=>{console.log("Upload aborted: Cancelling upload"),await fetch($+ht.upload.cancel,{...vt,method:"POST",headers:{authorization:A,id:q.id}})});let H=!1,J=Date.now();function V(t,n,o=!1){if(!o&&Date.now()-J<1e3)return!1;if(H&&"completed"!==n)return void("none"!=S&&console.warn("Invalid status update..."));J=Date.now();const i=Math.floor(G/B*100);return"debug"===S&&console.log("SET STATUS: "+n,t,i),_c({identifier:q.id,status:n,status_message:t,progress:i},e),!0}null!=(w=n)&&w.onStart&&n.onStart(q.id,q.content_id);const K=Date.now(),Y=new Cl(j.length,B/1024/1024),Z=new Array,X=function(e){let t=0;for(const n of e)Number.isFinite(n)&&n>=0&&(t=Math.max(t,n));return t>=zc?2:t>=zl?4:10}(C.files.map(e=>e.content_length));"debug"===S&&console.debug(`Upload file concurrency: ${X}`);let Q=!1;const ee=[...j],te=j.length,ne=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))}}(()=>V("Upload in progress","running",!0));try{var oe;for(let o=0;o<ee.length;o++){var ie;if(!(Q||null!=(ie=n)&&null!=(ie=ie.abort)&&ie.aborted)){if(Z.length<X){console.debug(`Uploading file ${o}/${j.length}: ${j[o].name}`);let i=0,r=0;const a=C.files[o],s=a.filename,c=R[o],l=a.content_length,p=a.content_type,u=j[o],d=u.name.endsWith(".gz")?"gzip":u.name.endsWith(".br")?"br":void 0,m=Zl({uploadId:q.id,uploadRequestPUTUrl:q.request_put_url,entrypointPath:W,file:j[o],fileName:s,fileMd5:a.content_md5,fileBuffer:c,fileType:p,content_encoding:d,fileSize:l,fileIndex:o,fileNumber:o+1,fileCount:te,loglevel:S,experimental:t.experimental,args:e,options:n,onProgress:e=>{var t;const a=e.progress||0;i=j[o].size*a;const c=i-r;if(r=i,G+=c,null!=(t=n)&&t.progress){const e=G/B,t=j.length,i=j[o].size,r=(Date.now()-K)/1e3,c=Y.updateProgress(G/1024/1024);n.progress({uploadedBytes:G,totalBytes:B,progress01:e,fileName:j[o].name,fileSize:i,fileProgress01:a,fileIndex:o,totalFiles:t,estimatedTimeLeftDisplay:c.estimatedTimeRemainingString,estimatedTimeLeft:c.estimatedTimeRemaining,elapsedTime:r}),V(`Uploading file ${o+1}/${t} (${s}): ${(100*a).toFixed(0)}% of ${al(B)}. Finished in approx. ${c.estimatedTimeRemainingString}`,"running",!1)}}}).then(e=>{if(!0!==e)return e;for(let e=Z.length-1;e>=0;e--)Z[e]===m&&Z.splice(e,1);V(`Uploaded ${al(G)+" of "+al(B)} 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),Q=!0)});Z.push(m)}Z.length>=X&&await Promise.race(Z)}}null!=(oe=n)&&null!=(oe=oe.abort)&&oe.aborted?console.debug("Upload aborted"):Q&&console.debug("Upload failed"),await Promise.all(Z).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),Q=!0)})}finally{ne()}if(Q)return await _c({identifier:q.id,status:"failed",error:"Failed to upload files"},e),{success:!1,error:"Failed to upload files"};if(null!=(_=n)&&null!=(_=_.abort)&&_.aborted)return await _c({identifier:q.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 ${q.id}`);const re={...gt(e),id:q.id};"none"!=S&&console.log("Completing upload - notify server");let ae=null;for(let e=0;e<5;e++){var se;await kl(1e3*e);const t=AbortSignal.timeout(6e4+5e3*e);if(ae=await fetch($+ht.upload.done,{...vt,method:"POST",headers:re,signal:t}).catch(t=>(console.error(`Failed to complete upload (${e+1} / 5)`,t.message),null)),!0===(null==(se=ae)?void 0:se.ok))break;if(ae&&ae.status>=400&&ae.status<500)break;var ce;"none"!=S&&e<4&&console.warn(`Failed to complete upload (${(null==(ce=ae)?void 0:ce.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 le=await ae.json();return{success:!0,type:le.type,uploadSkipped:!1,id:le.id,content_id:le.content_id,url:le.url,edit_url:le.edit_url,filesUploaded:j.length,totalSize:B}}(e,t,n);return await o.finally(()=>{})}const Dl=[".html",".js",".css"],ql=[".gz",".br"];function Bl(e){return"path"in e&&e.path?e.path:e.name}function Ml(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 Wl=400,Gl=255;function Hl(e){const t="string"==typeof e?e:String(null!=e?e:"");return t.length<=Gl?t:t.slice(0,Gl-1)+"…"}const Jl={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 Vl(e){if(!e)return"unknown upload error";const t=[];try{const i=e.response,r=null==i?void 0:i.status,a=null==i?void 0:i.statusText;r&&t.push(`HTTP ${r}${a?" "+a:""}`);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 r=null==(n=i.match(/<Code>([^<]+)<\/Code>/))?void 0:n[1],a=null==(o=i.match(/<Message>([^<]+)<\/Message>/))?void 0:o[1];if(r)t.push(`S3 ${r}${a?": "+a:""}`);else if(function(e){return/^\s*(<!DOCTYPE\s+html|<html[\s>])/i.test(e)}(i)){const n=Ml(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=Jl[c];t.push(n?`${c} (${n})`:c);const o=Ml(e);o&&t.push(`while uploading to ${o}`)}const l=e.message?String(e.message):"",p=r&&/^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 Kl=12e4;function Yl(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>=zc)return async function(e){const{uploadId:t,entrypointPath:n,file:o,fileName:i,fileMd5:r,fileType:a,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=()=>({...gt(l),"Content-Type":"application/json",org:l.org,job_id:t}),y={...b(),filesize:c.toString()},x=JSON.stringify({filename:i,entrypoint:n,"content-type":a,"content-md5":r,"content-encoding":s,output_index:0});async function w(e,t,n){const o=await fetch(e,{...vt,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=Lc,concurrency:i=4,maxRetries:r=5,retryDelayMs:a=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=Lc){if(!Number.isFinite(e)||e<=0)return[];let n=Math.max(t,Pc,Math.ceil(e/Uc));const o=[];let i=0,r=1;for(;i<e;){const t=Math.min(i+n,e);o.push({partNumber:r,start:i,end:t,size:t-i}),i=t,r++}return o}(t,o);if(0===g.length)throw new Error("Nothing to upload (size <= 0)");const{upload_id:v,key:b}=await s(),y=await c(v,b,g.map(e=>e.partNumber)),x=new Map(y.map(e=>[e.part_number,e.url])),w=[];let _=0,j=null;const k=async e=>{const t=x.get(e.partNumber);if(!t)throw new Error(`Missing presigned url for part ${e.partNumber}`);let o=!1;const i=await Nc(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:r+1,baseMs:a,isRetryable:e=>!o&&Oc(e),...a>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+ht.upload.multipart_create,{...vt,method:"POST",headers:y,body:x});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+ht.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 r=el(t instanceof Uint8Array?new Uint8Array(t).buffer:await t.arrayBuffer()),a=i,s=new AbortController;let c=!1;const l=()=>s.abort();a&&(a.aborted?s.abort():a.addEventListener("abort",l,{once:!0}));const p=Yl(Kl,()=>{c=!0,s.abort()});p.reset();try{var u,d;const n=await bc.put(e,t,{...vt,...await Ul(),withCredentials:!1,signal:s.signal,headers:{"Content-Type":o,"Content-MD5":r},onUploadProgress:()=>p.reset()});if(200!==n.status)throw new Error(Vl({response:n}));const i=(null==(u=n.headers)?void 0:u.etag)||(null==(d=n.headers)?void 0:d.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(c)throw new Error(`Part ${n} stalled: no progress for ${Kl/1e3}s`);throw new Error(Vl(e))}finally{p.cancel(),a&&a.removeEventListener("abort",l)}}({url:e,payload:t,partNumber:n,signal:o,contentType:a})),completeUpload:async(e,t,n)=>w(v+ht.upload.multipart_complete,b(),{key:t,upload_id:e,parts:n}),abortUpload:async(e,t)=>{await fetch(v+ht.upload.multipart_abort,{...vt,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:r,fileBuffer:a,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={...gt(h),"Content-Type":"application/json",org:h.org,job_id:t,filesize:c.toString(),progress:(u/m*100).toFixed(0)},y={filename:r,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 x=JSON.stringify(y);let w=null,_="";const j=await Nc(async()=>{var e;if(null!=g&&null!=(e=g.abort)&&e.aborted)throw new yc("Upload aborted");const t=await fetch(n,{...vt,method:"POST",headers:b,body:x});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 "${r}" "${l}": ${Vl(n)}\n→ Retry #${e} in ${t}ms`)}});if(j.ok)w=j.value;else if(j.error instanceof yc)throw j.error;if(null==w){const e=_||Vl(j.error);throw new Error(`Failed to get presigned url for "${r}" "${l}" \n${e}`)}const k=w.presigned_url;var S=!1;let E=null;const T=[];let $=0;const I=await Nc(async t=>{var n;if(null!=g&&null!=(n=g.abort)&&n.aborted)throw new yc("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}: ${r}`),"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=Yl(Kl,()=>{u=!0,i.abort()});b.reset();try{const t=await bc.put(k,a,{...vt,...await Ul(),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 y;if(null!=g&&null!=(y=g.abort)&&y.aborted)throw new yc("Upload aborted");if(u)throw E=`stalled: no upload progress for ${Kl/1e3}s`,T.push(E),"none"!==f&&console.error(`Upload stalled (PUT) (${d}, ${r}) after ${Kl/1e3}s with no progress`),new Error(E);throw E=Vl(e),T.push(E),e instanceof yc||("none"!==f&&console.error(`Failed to upload file (PUT) (${d}, ${r}) "${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 ${r} in ${t}ms`)}});if($=I.attempts,I.ok)S=!0,"info"===f&&console.log(`Uploaded file ${d}/${m} "${r}" (${l}, ${al(c)})`);else if(I.error instanceof yc)throw I.error;if(!S){var A;const e=null!=(A=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}(T))?A: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>Wl?o.slice(0,Wl)+"…":o}`:`Failed to upload file ${e}${i}`}(r,e,$);throw console.error(n),await _c({identifier:t,status:"failed",status_message:Hl(n),error:"Failed to upload file "+r},h),new Error(n)}return!0}async function Xl(e,t,n){const o=e.baseUrl+ht.jobs.presigned_url,i=await fetch(o,{...vt,method:"POST",headers:{...gt(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 Ql(e,t){const n=e.baseUrl+ht.jobs.create,o={...gt(e),"content-type":"application/json"},i={type:"ai-material",triggered_by:e.trigger_type,parameters:{...t}},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();return console.error(`Failed to request texture generation (${r.status}): ${e}`),{error:e||`Request failed (${r.status})`}}return await r.json().catch(e=>(console.error(e),null))}const ep=["3d-asset","material","deployment","hdri"],tp=["glb","gltf","usd","usda","usdz","obj","fbx","vrm","stl","ply","splat","spz","ksplat","sog","sogs","textures","html","exr","hdr","pmrem"];async function np(e,t={}){const n=new URL(e.baseUrl+ht.content.root);t.include_metadata&&n.searchParams.set("include_metadata",t.include_metadata),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=gt(e),i=await fetch(n,{...vt,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 op(e,t,n={}){const o=new URL(`${e.baseUrl}${ht.content.root}/${encodeURIComponent(t)}`);n.include_metadata&&o.searchParams.set("include_metadata",n.include_metadata),n.item&&o.searchParams.set("item",n.item);const i=gt(e),r=await fetch(o.toString(),{...vt,method:"GET",headers:i});if(!r.ok){const e=await r.text();throw new Error(`Failed to get content (${r.status}): ${e}`)}return await r.json()}async function ip(e,t,n){const o=`${e.baseUrl}${ht.content.root}/${t}`,i=gt(e),r={...n};if(n.thumbnail){const e=n.thumbnail,t=el(await e.arrayBuffer());r.upload_thumbnail={name:e.name,content_size:e.size,content_type:e.type,content_md5:t}}const a=await fetch(o,{...vt,method:"PATCH",headers:{...i,"Content-Type":"application/json"},body:JSON.stringify(r)}).catch(e=>({error:e.message,status:500}));if("error"in a)return a;if(!a.ok)return{error:await a.text(),status:a.status};const s=await a.json();if(s.upload_thumbnail&&n.thumbnail){let e=null;for(let t=0;t<5;t++){const o=s.upload_thumbnail,i=o.put_url,r=await fetch(i,{method:"PUT",headers:{"Content-Type":o.content_type,"Content-MD5":o.content_md5},body:n.thumbnail}).catch(e=>({error:e.message,status:500}));if("error"in r)e=r,await kl(100*t);else{if(r.ok){e=null;break}e={error:await r.text(),status:r.status},await kl(100*t)}}e&&console.error("Failed to upload thumbnail",e.status,e.error)}return{success:!0}}async function rp(e,t){const n=`${e.baseUrl}${ht.content.root}/${t}`,o=gt(e),i=await fetch(n,{...vt,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()}async function ap(e,t){const n=`${e.baseUrl}${ht.content.root}/${t}/restore`,o=gt(e),i=await fetch(n,{...vt,method:"POST",headers:o});if(!i.ok){const e=await i.text();throw new ft(i.status,e,`Failed to restore content (${i.status}): ${e}`)}return i.json()}const sp={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 cp(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function lp(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function pp(e){if(!(cp(e)&&lp(e.requestIndex)&&!(e.requestIndex<1)&&"string"==typeof e.model&&e.model&&lp(e.requestBytes)&&lp(e.messagesBytes)&&lp(e.toolsBytes)&&lp(e.messageCount)&&lp(e.toolCount)&&cp(e.messageRoles)))throw new Error("Invalid chat request diagnostics");const t=Object.create(null);let n=0;for(const[o,i]of Object.entries(e.messageRoles)){if(!lp(i))throw new Error("Invalid chat request diagnostic role count");t[o]=i,n+=i}if(n!==e.messageCount)throw new Error("Inconsistent chat request diagnostic message count");return{requestIndex:e.requestIndex,model:e.model,requestBytes:e.requestBytes,messagesBytes:e.messagesBytes,toolsBytes:e.toolsBytes,messageCount:e.messageCount,toolCount:e.toolCount,messageRoles:t}}function up(e){let t;try{t=JSON.parse(e)}catch{return null}if(!(t&&"object"==typeof t&&"code"in t&&"ai_allowance_exhausted"===t.code&&"limit_reached"in t&&!0===t.limit_reached&&"message"in t&&"string"==typeof t.message&&"account_id"in t&&"string"==typeof t.account_id&&"actions"in t&&Array.isArray(t.actions)))return null;const n=[];for(const e of t.actions){if(!e||"object"!=typeof e||!("kind"in e)||"top_up"!==e.kind&&"view_usage"!==e.kind||!("label"in e)||"string"!=typeof e.label||!("url"in e)||"string"!=typeof e.url)return null;let t;try{t=new URL(e.url)}catch{return null}if("https:"!==t.protocol&&"http:"!==t.protocol)return null;n.push({kind:e.kind,label:e.label,url:e.url})}return{code:t.code,limit_reached:!0,message:t.message,account_id:t.account_id,actions:n}}class dp extends Error{constructor(e,t,n=null){super(e),this.name="AIChatError",this.status=t,this.details=n}}function mp(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"request_diagnostics":i={type:"request_diagnostics",diagnostics:pp(JSON.parse(o))};break;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":{const e=decodeURIComponent(o),t=up(e);i=t?{type:"error",message:t.message,details:t}:{type:"error",message:e};break}case"notice":i={type:"notice",message:decodeURIComponent(o)};break;case"stopped":i={type:"stopped"};break;case"tool-input-available":case"tool-output-available":i={...JSON.parse(o),type:n};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 fp(e,t){var n;const o=gt(e);return null!=t&&t.personal&&(o["x-needle-ai-chat"]="personal"),null!=t&&t.instanceId&&(o["x-needle-instance-id"]=t.instanceId),!0===(null==t||null==(n=t.capabilities)?void 0:n.inlineToolCalls)&&(o["x-needle-chat-inline-tools"]="1"),o}function hp(e,t){return t.stream?async function*(e,t){const n=new URL(e.baseUrl+ht.ai.chat),o=fp(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!0,project_id:t.projectId,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,tool_policy:t.toolPolicy},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();throw new dp(`Failed to stream chat message (${r.status}): ${e}`,r.status,up(e))}if(!r.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 r=o.split("\n\n");o=r.pop()||"";for(const e of r){const t=mp(e);t&&(yield t)}}if(o.trim()){const e=mp(o);e&&(yield e)}}finally{t.releaseLock()}}(r.body)}(e,t):async function(e,t){const n=new URL(e.baseUrl+ht.ai.chat),o=fp(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!1,project_id:t.projectId,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,tool_policy:t.toolPolicy},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();throw new dp(`Failed to send chat message (${r.status}): ${e}`,r.status,up(e))}return await r.json()}(e,t)}const gp=200,vp=["github.com","gitlab.com","bitbucket.org"],bp=/[\w.+-]+@[\w-]+\.[\w.]+/;function yp(e){if(e)return bp.test(e)?void 0:e}function xp(e,t){return String(b("git",e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],...t?{cwd:t}:{}})||"").trim()}function wp(e,t){try{return xp(e,t)}catch{return""}}function _p(e){try{const t=xp(["rev-parse","HEAD"],e);if(!t)return null;const n=wp(["rev-parse","--abbrev-ref","HEAD"],e),o=wp(["log","-1","--pretty=%s"],e),i=yp(wp(["log","-1","--pretty=%an"],e)),r=wp(["status","--porcelain"],e).length>0,a=wp(["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?vp.includes(o)?{repository:i,url:`https://${o}/${i}/${"bitbucket.org"===o?"commits":"commit"}/${t}`}:{repository:i}:{}}(a,t),p={type:"git",id:t,label:`${n||s}@${s}${r?" (dirty)":""}`};return n&&(p.branch=n),i&&(p.author=i),o&&(p.message=o.slice(0,gp)),r&&(p.dirty=!0),c&&(p.repository=c),l&&(p.url=l),p}catch{return null}}function jp(e){if("string"==typeof e)return e.trim()||void 0}const kp="https://cloud.needle.tools/api",Sp=()=>"https://cloud.needle.tools/account",Ep=()=>"https://cloud.needle.tools/edit";function Tp(e){return y(e)}const $p=["node_modules",".git",".vscode",".vercel",".github",".idea"];function Ip(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=Xc(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 r=u(t,{withFileTypes:!0});for(const i of r)if(0==i.isDirectory()){if("optimization"===e&&0==((a=(a=i.name).toLowerCase()).endsWith(".glb")||a.endsWith(".gltf")||a.endsWith(".vrm")||a.endsWith(".usdz")||a.endsWith(".usd")||a.endsWith(".fbx")))continue;const r=Xc(o+i.name,p(t+"/"+i.name));if(n.files.push(r),n.total_size+=r.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 a;for(const a of r)if(a.isDirectory()){if($p.includes(a.name))continue;Ip(e,t+"/"+a.name,n,o+a.name+"/",i+1)}return n}const Ap=new RegExp("\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g"),Op=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"),Cp=new RegExp("(Authorization:\\s*)([^\\s,;\"']+(?:\\s+[^\\s,;\"']+)?)","gi"),Np=new RegExp("\\bBearer\\s+([A-Za-z0-9._\\-=]+)","g"),Rp=new RegExp("([?&]token=)([^&\\s\"'<>]+)","g"),Pp=new RegExp("<redacted:\\d+ch>","g");function Up(e){if("string"!=typeof e)return e;if(0===e.length)return e;if(Pp.test(e)&&(Pp.lastIndex=0,!function(e){Ap.lastIndex=0,Op.lastIndex=0,Cp.lastIndex=0,Np.lastIndex=0,Rp.lastIndex=0;const t=Ap.test(e)||Op.test(e)||Cp.test(e)||Np.test(e)||Rp.test(e);return Ap.lastIndex=0,Op.lastIndex=0,Cp.lastIndex=0,Np.lastIndex=0,Rp.lastIndex=0,t}(e.replace(Pp,""))))return e;Pp.lastIndex=0;let t=e;return t=t.replace(Cp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(Rp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(Np,(e,t)=>`<redacted:${("Bearer "+t).length}ch>`),t=t.replace(Ap,e=>`<redacted:${e.length}ch>`),t=t.replace(Op,e=>`<redacted:${e.length}ch>`),t}const Lp=["cli.log","cli.prev.log"],zp=ie.join(te.homedir(),".needle","cli","logs");I(zp,{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(!$(e))return n;for(const o of Lp){const i=ie.join(e,o);if($(i))try{I(t,{recursive:!0});const e=ie.join(t,o);if($(e)){const e=ie.join(t,o.replace(/\.log$/,"")+".legacy.log");A(i,e),n.skipped.push(o)}else A(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(O(te.tmpdir()),"Needle","Cloud","logs"),zp)}catch(e){console.error(`[needle-cloud] legacy log migration check failed: ${e instanceof Error?e.message:e}`)}const Fp=ie.resolve(zp,"cli.log");if($(Fp)){const e=C(Fp),t=e.mtimeMs;if(Date.now()-t>432e5||e.size>52428800){const e=qp();N(Fp,e,t=>{t?console.error(`Failed to rename log file: ${t.message}`):console.log(`Log file renamed to ${e}`)})}}function Dp(){return Fp}function qp(){return ie.resolve(zp,"cli.prev.log")}function Bp(e,t){try{let n=Up(String(null!=e?e:""));return n=`[${(new Date).toISOString()}] ${n}`,null!=t&&t.emptyLineBefore&&(n="\n"+n),R(Fp,n+"\n"),!0}catch(e){return console.error(`Failed to write to log file: ${e instanceof Error?e.message:e}`),!1}}async function Mp(e,t){return e=Up(e),e=`[${(new Date).toISOString()}] ${e}`,null!=t&&t.emptyLineBefore&&(e="\n"+e),J(Fp,e+"\n",{flag:"a"}).then(()=>!0).catch(e=>(console.error(`Failed to write to log file: ${e.message}`),!1))}var Wp={__proto__:null,getLogFilePath:Dp,getPrevLogsFilePath:qp,getPipelineLogFilePath:function(){return ie.join(te.homedir(),".needle","optimization-pipeline","logs","pipeline.log")},writeToLogFileSync:Bp,writeToLogFile:Mp};function Gp(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 Hp(e){var t;e.directory=x.resolve(e.directory);let{files:n,entrypoint:o}=Ip("deployment",e.directory);if(e.entrypoint&&(o=n.find(t=>t.path===e.entrypoint),!o))return process.exitCode=1,void T().fail(`Entrypoint "${e.entrypoint}" not found. Please make sure you provide a valid entrypoint.`);if(!o){const e=$l(n);if("error"in e)return process.exitCode=1,Mp(`[Deployment] Error determining entrypoint: ${e.error}`),void T().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,Mp("[Deployment] Deployment is not valid: No .html file found."),void T().fail("Deployment is not valid: No .html file found.");if(!o)return process.exitCode=1,Mp("[Deployment] No entrypoint found. Please provide an index.html file in your project."),void T().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 r=e.name;r||(r=Jp(e.directory)||void 0);let a=null==i?void 0:i.includes("localhost");const s=r?` of "${r}"`:"",c=T().start(`Begin deployment${s} ${a?"(local)":""} of ${n.length} files...`);c.spinner="earth",await kl(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(jp(e.NEEDLE_CLOUD_NO_PROVENANCE))return null;let n=_p(t);jp(e.GITHUB_ACTIONS)&&(n=function(e,t){var n,o;const i=jp(t.GITHUB_SHA),r=jp(t.GITHUB_REF_NAME),a=jp(t.GITHUB_REPOSITORY),s=null!=(n=jp(t.GITHUB_SERVER_URL))?n:"https://github.com";if(!i&&!r)return e;const c={type:"git",...null!=e?e:{}};i&&(c.id=i),r&&(c.branch=r),a&&(c.repository=a),a&&i&&(c.url=`${s}/${a}/commit/${i}`);const l=String(null!=(o=c.id)?o:"").slice(0,7);return l&&(c.label=`${r||l}@${l}${c.dirty?" (dirty)":""}`),c}(n,e));const o=function(e=process.env){var t;if(!jp(e.CI))return{type:"local"};if(!jp(e.GITHUB_ACTIONS))return{type:"ci"};const n={type:"github-actions"},o=jp(e.GITHUB_RUN_ID),i=jp(e.GITHUB_REPOSITORY),r=null!=(t=jp(e.GITHUB_SERVER_URL))?t:"https://github.com";o&&(n.id=o);const a=yp(jp(e.GITHUB_ACTOR));return a&&(n.actor=a),jp(e.GITHUB_EVENT_NAME)&&(n.event=jp(e.GITHUB_EVENT_NAME)),o&&i&&(n.url=`${r}/${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&&_p(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;Mp(`[provenance] ${e}${t?` by ${t}`:""} (${null==(d=u.runner)?void 0:d.type})`)}Mp(`Deployment started${s} ${a?"(local)":""} of ${n.length} files...`);const m=await Fl({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:r,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&&Tp(t);try{Gp("deployment_url",t,{logger:e.logger}),Gp("edit_id",m.content_id,{logger:e.logger})}catch(t){e.logger.error("Error writing output for CI: "+t)}return m}{process.exitCode=1;const e=p||(null==m?void 0:m.error)||"Deployment failed";Mp(`[Deployment] Failed: ${e}`),c.fail(e)}}function Jp(e,t=0){if(t>10)return null;const n=x.join(e,"needle.config.json");if(c(n)){const t=x.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 x.basename(e)}const i=x.dirname(e);return i===e?null:Jp(i,t+1)}const Vp={getContent:op,updateContentLabel:async function(e,t={}){const n={...gt(e),content_id:e.content_id,job_id:e.job_id,type:e.type,action:e.action};try{const t=await fetch(`${e.baseUrl}${ht.view.post_version}`,{...vt,method:"POST",headers:n});if(!t.ok){const e=await t.text();throw new ft(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 Kp(e){if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new Error("Invalid content identifier; use the item ID shown by list or upload.")}function Yp(e){if(Kp(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 Zp(e,t){if(e.identifier!==t)throw new Error("The returned content does not match the requested content item.")}function Xp(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 Qp(e,t,n=Vp){Kp(t);const o=await n.getContent(e,t);return Zp(o,t),Xp(o)}async function eu(e,t,n=Vp){var o,i;Yp(t);const r=await n.getContent(e,t.contentId);Zp(r,t.contentId);const a=Xp(r);let s=t.versionId;if(t.from){const e=a.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=r.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 Qp(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=a.labels.find(e=>e.label===t.label))?void 0:i.sourceVersionIds)?o:[],targets:u.targets}}const tu=/token|secret|password|authorization|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret/i;function nu(e,t){return async function(n){const o=function(e,t){const n=[];if(e&&Object.keys(e).length>0&&n.push(`args=${ou(e)}`),t&&Object.keys(t).length>0){const e=Object.fromEntries(Object.entries(t).map(([e,t])=>tu.test(e)?[e,"<redacted>"]:[e,t]));n.push(`options=${ou(e)}`)}return n.join(" ")}(null==n?void 0:n.args,null==n?void 0:n.options);Mp(`CLI action: ${e}${o?" "+o:""}`);const i=Date.now();try{const o=await t(n);return Mp(`CLI action: ${e} succeeded in ${Date.now()-i}ms`),o}catch(t){const n=t instanceof Error?t.message:String(t);throw Bp(`CLI action: ${e} failed in ${Date.now()-i}ms: ${n}`),t}}}function ou(e){try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():"function"==typeof t?"<fn>":t)}catch{return"<unserializable>"}}function iu(e,t){const n=t.team||t.org;return!0===t.nonInteractive?e(t.token,n,!1):e(t.token,n)}function ru(e,t={}){var n;const o=e.output;if(void 0!==o&&"cli"!==o&&"json"!==o)throw new Error("Invalid --output. Use cli or json.");const i=t.legacyFormat?e.format:void 0;if(void 0!==i&&"cli"!==i&&"json"!==i&&(!t.links||"source-url"!==i&&"edit-url"!==i))throw new Error(`Invalid --format. Use cli, json${t.links?", source-url or edit-url":""}.`);if(void 0!==o&&void 0!==i&&o!==i)throw new Error("--output and the legacy output --format must agree.");const r=null!=(n=null!=o?o:i)?n:"cli";if("cli"===r||"json"===r||"source-url"===r||"edit-url"===r)return r;throw new Error("Invalid output mode.")}async function au(e,t){if(!e)return t();const n=globalThis.console;globalThis.console=new Re({stdout:process.stderr,stderr:process.stderr});try{return await t()}finally{globalThis.console=n}}function su(e){return t=>au("json"===t.options.output||"json"===t.options.format,()=>e(t))}function cu(e){process.stdout.write(JSON.stringify(e)+"\n")}async function lu(e){await new Promise((e,t)=>{process.stdout.write("",n=>n?t(n):e(void 0))}),process.exit(e)}function pu(e,t){return e.options.some(e=>e.name===t)}function uu(e){for(const t of e.getCommands())(pu(t,"token")||["login","logout","me"].includes(t.name))&&(pu(t,"output")||t.option("--output <output>","Output style: cli (default) or json",{validator:e.STRING}),pu(t,"nonInteractive")||t.option("--non-interactive","Use saved credentials or a token; never prompt or open a browser",{validator:e.BOOLEAN,default:!1}))}function du(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 mu(e){const n={};if(void 0!==e.title){const t=String(e.title);if(t.length>255)throw new Error("Title must be at most 255 characters.");n.title=t}if(void 0!==e.description){const t=String(e.description);if(t.length>512)throw new Error("Description must be at most 512 characters.");n.description=t}if(void 0!==e.tags){const t=String(e.tags),o=t.split(/[,;\n\r]+/).map(e=>e.trim()).filter(Boolean);if(!o.length||t.length>512||o.length>40||o.some(e=>e.length>=50))throw new Error("Pass 1–40 tags, each under 50 characters, with at most 512 characters total.");n.tags=t}if(void 0!==e.thumbnail){const o=String(e.thumbnail),i=re(o).toLowerCase(),r=".png"===i?"image/png":".webp"===i?"image/webp":".jpg"===i||".jpeg"===i?"image/jpeg":void 0;if(!r)throw new Error("Thumbnail must be a JPEG, PNG or WebP file.");const a=await V(o);if(!a.length||a.length>5242880)throw new Error("Thumbnail must be nonempty and at most 5 MiB.");n.thumbnail=new t([a],ae(o),{type:r})}if(!Object.keys(n).length)throw new Error("Nothing to update. Pass --title, --description, --tags or --thumbnail.");return n}function fu(e){return[e,...e.variants].map(e=>{var t,n;const o=e.labels.map(e=>e.label).join(", ");return` ${e.identifier} ${null!=(t=e.content_format)?t:""} ${null!=(n=e.status)?n:"completed"}${o?` [${o}]`:""}${e.url?` ${e.url}`:""}\n`}).join("")}function hu(e,t={input:!0===process.stdin.isTTY,output:!0===process.stdout.isTTY}){var n,o;if(!0!==e.interactive)return;if(!0===e.nonInteractive||"json"===e.output)throw new Error("--interactive cannot be combined with --non-interactive or --output json.");if(!t.input||!t.output)throw new Error("--interactive requires terminal input and output. Omit it for scripts, Unity or redirected output.");const i=Number(null!=(n=e.limit)?n:20),r=Number(null!=(o=e.offset)?o:0);if(!Number.isInteger(i)||i<1||i>100)throw new Error("--limit must be an integer from 1 to 100 for interactive browsing.");if(!Number.isInteger(r)||r<0)throw new Error("--offset must be a nonnegative integer for interactive browsing.")}function gu(e){return Ue(null!=e?e:"").replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}function vu(e,t){const n=Array.from(gu(e));return n.length<=t?n.join(""):n.slice(0,Math.max(0,t-1)).join("")+"…"}function bu(e,t,n){return e.color?`${"brand"===n?"[1;38;2;173;245;39m":"[2m"}${t}[0m`:t}function yu(e,t,n){var o;const i=Math.max(20,Math.min(e.columns-4,100)),r=null!=(o=n.offset)?o:0;e.write("\n "+bu(e,"NEEDLE CLOUD","brand")+` / ${n.trash?"Trash":"Content"}\n`),e.write(" "+bu(e,"─".repeat(i),"dim")+"\n"),e.write(` ${t.items.length?`${r+1}–${r+t.items.length}`:"0"} of ${t.total} items${n.search?` · Search: ${gu(n.search)}`:""}\n\n`),t.items.length||e.write(" No content found. Try / to clear search, or t to switch Trash.\n"),t.items.forEach((t,n)=>{var o;const r=`${n+1}`.padStart(2);e.write(` ${bu(e,r,"brand")} ${vu(t.title||t.identifier,i-4)}\n`);const a=`${null!=(o=t.content_type)?o:"content"} · ${t.content_formats.join(", ")||"no formats"} · ${t.version_count} versions · ${t.identifier}`;e.write(" "+bu(e,vu(a,i-4),"dim")+"\n")}),e.write("\n Number inspect · /text search · n/p pages · t Trash\n"),e.write(" r refresh · ? help · q quit\n")}function xu(e,t,n,o){const i=Math.max(20,Math.min(e.columns-4,100));e.write("\n "+bu(e,vu((null==n?void 0:n.title)||t.title||t.identifier,i),"brand")+"\n"),e.write(` ID: ${gu(t.identifier)}\n`),(null!=n&&n.description||t.description)&&e.write(` ${gu((null==n?void 0:n.description)||t.description)}\n`);const r=(null==n?void 0:n.tags)||t.tags;null!=r&&r.length&&e.write(` Tags: ${r.map(gu).join(", ")}\n`),o&&e.write(` In Trash${t.deleted_at?` since ${gu(t.deleted_at)}`:""}. Restore to inspect versions.\n`);for(const t of null!=(a=null==n?void 0:n.versions.slice(0,8))?a:[]){var a,s;const n=t.labels.map(e=>gu(e.label)).join(", ");e.write(` ${gu(t.identifier)} ${gu(t.content_format)} ${gu(null!=(s=t.status)?s:"completed")}${n?` [${n}]`:""}\n`);for(const n of t.variants){var c;e.write(` ↳ ${gu(n.identifier)} ${gu(n.content_format)} ${gu(null!=(c=n.status)?c:"completed")}\n`)}}n&&n.versions.length>8&&e.write(" More versions: needle-cloud versions <identifier>\n");const l=/^[\w.-]+$/.test(t.identifier)?t.identifier:"<identifier>";e.write("\n Continue from the terminal:\n"),o?e.write(` needle-cloud restore ${l}\n`):(e.write(` needle-cloud info ${l} --output json\n`),"editor-project"!==t.item_type&&e.write(` needle-cloud download ${l}\n needle-cloud update ${l} --title "New title"\n`)),e.write(" Keep the same --team and --endpoint options for these commands.\n"),e.write(o?"\n b back · q quit\n":"\n o open viewer · e edit in browser · b back · q quit\n")}async function wu(e,t,n){if(!e)return void t.write(" No web URL is available for this action.\n");let o;try{o=new URL(e)}catch(e){if(!(e instanceof TypeError))throw e;return void t.write(" This item does not have a valid web URL.\n")}"https:"===o.protocol||"http:"===o.protocol?await n(e):t.write(" No web URL is available for this action.\n")}async function _u(e){if(!e.outDir)throw new Error("Output directory is required");const t=T("Downloading results...").start(),n=await async function(e){const t=await async function(e){if(!e.identifier)return null;const t={...gt(e)},n={job_id:e.identifier,fields:e.fields,content_format:e.content_format,content_type:e.content_type},o=e.baseUrl+ht.jobs.query,i=await fetch(o,{...vt,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 r=await i.json().catch(e=>(console.error(e),null));return null==r?null:r.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)||wc.test(i)||i.endsWith(".needle.log"))continue;const r=`${n.directory}/${t.filename}`,a=await Xl(e,e.identifier,{bucket:n.bucket,key:r});if(!a){console.error(`Failed to get presigned URL for: ${t.filename}`);continue}const s=await fetch(a).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 r=i.filename;if(e.filename){const t=i.filename.substring(i.filename.lastIndexOf("."));if(1===n.files.length)r=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("."));r=e.filename+"-"+n+t}}const a=e.outDir+"/"+r,s=a.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 "${a}"`),f(a,Buffer.from(i.data)),o.push(a)}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 ju(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 T().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 ${Sp()}`};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=T(`Gathering files ${e.fileOrDirectory}`).start();let i=null;try{i=Ip("optimization",e.fileOrDirectory)}catch(t){return T().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 r=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 a="https://cloud.needle.tools/api";e.verbose&&console.log("Using endpoint:",a);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=>nl(e.name)||ol(e.name)||il(e.name));return 1===t.length&&$l(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&&Il.has(n)}),canConvertToGLB:Al.has(o)}}(i.files),l="asset"===s.kind||"deployment"===s.contentType?void 0:s.contentType,p=await Fl({baseUrl:a,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||`${Ep()}/${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:r}}(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:r}=n,a=r.map(e=>({path:e,sourceUrl:yt({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===a.length?a[0].sourceUrl:null,files:a,optimizedUrl:null,processingStatus:e.noOptimize?"not_requested":"unknown"};if(e.noOptimize&&T().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+ht.jobs.create,o={...gt(e),"content-type":"application/json"},i={type:"optimization",job_id:e.id,triggered_by:e.trigger_type,parameters:{...t}},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();return console.error(`Failed to request optimization (${r.status}): ${e} `),null}return await r.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=T(`Optimization requested for ${d.name||d.identifier}`).start(),f=kc();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 jc(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 kl(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 kl("running"===h?1e3:"stalled"===h?2500:2e3))}}if(m.succeed("Optimization completed"),s.processingStatus="completed",s.optimizedUrl=yt({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 _u({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 ku(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 Su(e){const{token:t,org_id:n,slug:o,message:i,stream:r}=e;if(r){const e=hp({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.stderr.write(`[${t.message}]\n`);break;case"error":throw new Error(t.message);case"tool_call":process.stderr.write(`[tool: ${t.name}]\n`);break;case"done":process.stdout.write("\n")}}else{const r=T("Thinking...").start(),a=await hp({baseUrl:"https://cloud.needle.tools/api",authToken:t,org:n},{slug:o,message:i,stream:!1,source:"cli"});r.stop(),"json"===e.output?cu(a):process.stdout.write(a.content+"\n")}}async function Eu(e,t=rp){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 Tu(e){const t=new URL((e.endpoint||"https://cloud.needle.tools/api")+ht.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:{...gt({authToken:e.authToken,org:e.org})}});return n.ok?await n.json():{status:n.status,error:await n.text()}}const $u=["#e06c75","#d19a66","#e5c07b","#98c379","#7ec8a4","#56b6c2","#61afef","#528bff","#c678dd","#e88de4","#be5046","#d4976c","#b5cea8","#4ec9b0","#9cdcfe","#c8ae9d"];function Iu(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]}($u[Math.abs(t)%$u.length]);return`[38;2;${n};${o};${i}m${e}[0m`}function Au(e){return`[2m${e}[0m`}const Ou=8424,Cu="http://localhost:8424",Nu=/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]\s?(.*)$/,Ru=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}):\s*(.*)$/,Pu=[[/^\[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"]],Uu=[[/^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 Lu(e){for(const[t,n]of Pu)if(t.test(e))return n;return"general"}function zu(e){for(const[t,n]of Uu)if(t.test(e))return n;return"info"}const Fu=new RegExp("\\b([A-Z][A-Z0-9_]*(?:_KEY|_TOKEN|_SECRET|_PASSWORD))=([^\\s,;\"']+)","g"),Du=new RegExp("\\b(User(?:name)?:\\s*)([A-Za-z0-9._\\-]{1,64})","g"),qu=new RegExp("\\b[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,}\\b","g"),Bu=52428800;function Mu(e,t){if(!$(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,r=Buffer.allocUnsafe(i),a=P(e,"r");try{let e=0;for(;e<i;){const t=U(a,r,e,i-e,o+e);if(0===t)break;e+=t}}finally{L(a)}if(o>0){const e=r.indexOf(10);return-1===e?"":r.slice(e+1).toString("utf8")}return r.toString("utf8")}async function*Wu(e){const t=De({input:z(e,{encoding:"utf8"}),crlfDelay:Infinity});for await(const e of t)yield e}function Gu(e,t,n,o){var i,r;if(0===e.length)return[];const a=function(e){if("string"!=typeof e)return{ts:null,level:"info",source:"general",message:""};let t=null,n=e,o=e.match(Nu);if(o)t=o[1],n=o[2];else if(o=e.match(Ru),o){const e=new Date(`${o[1]}T${o[2]}`);Number.isNaN(e.getTime())||(t=e.toISOString(),n=o[3])}return{ts:t,level:zu(n),source:Lu(n),message:n}}(e),s=null!=(i=null!=(r=a.ts)?r:n)?i:null,c=a.level,l=null!=t?t:a.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 r=0;r<o;r++){const a=r*n,s=e.slice(a,a+n);i.push(`${s} [chunk ${r+1}/${o} of ${t} bytes]`)}return i}(function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;let n=Up(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(Fu,(e,t,n)=>`${t}=<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(Du,(e,t,n)=>`${t}<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(qu,e=>`<redacted:${e.length}ch>`)}(n),n}(a.message,o)).map(e=>({ts:s,level:c,source:l,message:e}))}const Hu="https://haystack.needle.tools/api/ingest/logs",Ju="https://haystack.needle.tools";async function Vu(e){try{return await e.json()}catch{return null}}async function Ku(e){try{return await e.text()}catch{return""}}function Yu(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 ${Hu}: ${o}`}var Zu,Xu={__proto__:null,HAYSTACK_RESOURCE:Ju,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}:{}},r=t.findActiveEditorLog(),a=function(e){const t=qe.from(async function*(e){if(yield JSON.stringify(e.meta)+"\n",e.prevLogPath&&$(e.prevLogPath)){let t=null;for await(const n of Wu(e.prevLogPath)){const o=Gu(n,null,t,e.redactOpts);for(const e of o)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}if(e.cliLogPath&&$(e.cliLogPath)){let t=null;for await(const n of Wu(e.cliLogPath)){const o=Gu(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:Bu,i=null!=(n=e.editor.paths)?n:e.editor.path?[e.editor.path]:[];for(const t of i){const n=Mu(t,o);if(!n)continue;let i=null;try{i=C(t).mtime.toISOString()}catch{}for(const t of n.split("\n")){const n=Gu(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&&$(e.pipelineLogPath)){var o;const t=null!=(o=e.pipelineTailBytes)?o:Bu,n=Mu(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=Gu(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(Be())}({meta:i,cliLogPath:t.paths.cliLogPath,prevLogPath:t.paths.prevLogPath,editor:r,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 a)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 a)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(Hu,{method:"POST",body:s,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/x-ndjson","Content-Encoding":"gzip"}})}catch(e){return{ok:!1,error:Yu(e)}}if(401===c.status){const e=await Ku(c);return{ok:!1,error:`401 Unauthorized from ${Hu}: ${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 Ku(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 Vu(c);return{ok:!0,refId:null==e?void 0:e.ref_id,truncated:!0}}if(!c.ok){const e=await Ku(c);return(400===(l=c.status)||l>=500)&&await async function({token:e,fetch:t,baseMeta:n,status:o,bodyText:i}){const{gzipSync:r}=await import("node:zlib"),a={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(a)+"\n"+JSON.stringify(s)+"\n",l=r(Buffer.from(c,"utf8"));await t(Hu,{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 Vu(c);return{ok:!0,refId:null==p?void 0:p.ref_id,truncated:Boolean(null==p?void 0:p.truncated)}}};const Qu={appId:"2stnsoa6a1b0gwc7lra55",appSecret:"seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",endpoint:"https://auth.needle.tools",resources:["https://cloud.needle.tools/api",Ju],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"]},ed={getAccessToken:!0,fetchUserInfo:!0,resource:null==(Zu=Qu.resources)?void 0:Zu[0],resources:Qu.resources||[],scopes:Qu.scopes||[]};function td(e="default"){return null==e?`${Cu}/?signed-out=1`:"too-many-logins"===e?`${Cu}/?too-many-logins=1`:"error"===e?`${Cu}/?error=1`:`${Cu}/?signed-out=1`}var nd;function od(){rd.clear(),s.existsSync(cd)&&s.rmSync(cd,{recursive:!0}),s.existsSync(ld)&&s.rmSync(ld,{recursive:!0})}const id=process.argv.includes("--debug-auth"),rd=new Map;let ad=null==(nd=Qu.resources)?void 0:nd[0];if(ad)try{ad=new URL(ad).hostname}catch(e){id&&console.error("Invalid resource URL",ad)}let sd=ad||"-";sd=sd.replace(/[^a-zA-Z0-9\.\-]/g,"");const cd=x.join($e(),".needle",".auth",sd),ld=`${Ie()}/Needle/Cloud/.auth/${sd}`;!function(){if(s.existsSync(ld)){id&&console.debug("Migrating auth data from legacy location",ld,"→",cd);try{s.existsSync(cd)||s.mkdirSync(cd,{recursive:!0,mode:448});for(const e of s.readdirSync(ld)){const t=x.join(ld,e),n=x.join(cd,e);s.statSync(t).isFile()&&!s.existsSync(n)&&(s.copyFileSync(t,n),s.chmodSync(n,384))}s.rmSync(ld,{recursive:!0}),id&&console.debug("Legacy auth data migrated successfully")}catch(e){id&&console.error("Failed to migrate legacy auth data",e)}}}();const pd={accessToken:`${cd}/accessToken`,refreshToken:`${cd}/refreshToken`,idToken:`${cd}/idToken`,signInSession:`${cd}/signInSession`};function ud(e){return pd[e]||`${cd}/${e}`}const dd=new class{constructor(){this.basePath=cd}async setItem(e,t){id&&console.debug("\n- SET ITEM",e,t),s.existsSync(this.basePath)||s.mkdirSync(this.basePath,{recursive:!0,mode:448});const n=ud(e);n&&s.writeFileSync(n,t,{mode:384}),rd.set(e,t)}async getItem(e){id&&console.debug("\n- GET ITEM",e);const t=rd.get(e);if(void 0===t){const t=ud(e);if(t){if(s.existsSync(t)){const n=s.readFileSync(t,"utf8");return rd.set(e,n),n}}else console.error(`Unknown token name: ${e}`);return null}return String(t)}async removeItem(e){id&&console.debug("\n- REMOVE ITEM",e),rd.delete(e);const t=ud(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 md=null;function fd(){return md||(md=new Fe(Qu,{storage:dd,navigate:()=>{}})),md}function hd(){md=null}let gd=Promise.resolve();function vd(e){const t=gd.then(e,e);return gd=t.then(()=>{},()=>{}),t}async function bd(e){return yd(fd(),e)}async function yd(e,t){try{const n=await vd(()=>e.getAccessToken(t));return null!=n?n:null}catch(e){return function(e){return Boolean(e)&&"object"==typeof e&&"not_authenticated"===e.code}(e)||(Mp(`Token refresh failed for resource ${t}: ${e instanceof Error?e.message:e}`),xd(e)&&(Mp(`Token refresh: clearing dead grant for resource ${t}`),od(),md=null)),null}}function xd(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 wd(){return bd(ed.resource)}function _d(){return Sd(fd())}async function jd(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."),Mp("WARN: You do not have a default organization set. Please visit your Needle Cloud account settings and then try again."),null):null}function kd(e){return new Fe(Qu,{storage:dd,navigate:t=>{if(null==e.navigate)throw new Error("Can not navigate");e.navigate(t)}})}function Sd(e){return function(e,t){return vd(()=>e.getContext(t))}(e,ed).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?(Mp(`OIDC: ${e.code} – token refresh failed, clearing stale tokens`),od(),md=null,console.error("Session expired – please log in again: npx needle-cloud login")):e.code?(console.error(e.code),Mp(`OIDC: ${e.code} – ${t}`)):Mp(`OIDC: getContext failed – ${t}`),null})}var Ed={__proto__:null,resetSharedClient:hd,tryGetFreshAccessTokenForResource:bd,acquireAccessToken:yd,shouldClearAuthOnError:xd,tryGetFreshAccessToken:wd,tryGetUser:_d,tryGetDefaultOrgId:jd,createNodeClient:kd,getUserFromClient:Sd};function Td(e){var t,n,o,i;if(!e)return"";let r=(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 a;return(!r||r.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==(a=e.claims)?void 0:a.email):r}async function $d(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 r=null;if(null==t)r=e.accessToken;else if(null!=t){var a;let n=null==e||null==(a=e.userInfo)||null==(a=a.organization_data)?void 0:a.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,r=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 r?{authToken:r,org:t}:{status:403,error:"No access token found"}}const Id=function(){return async(e,t,n)=>{const o=await _d();Object.defineProperty(e,"user",{enumerable:!0,get:()=>o}),n()}};function Ad(e){return e instanceof Error&&("code"in e&&"ECONNREFUSED"===e.code||!(!("cause"in e)||!Ad(e.cause))||e instanceof AggregateError&&e.errors.length>0&&e.errors.every(Ad))}function Od(e,t,n){let o=!1;e.post("/stop",(e,i)=>{t&&e.headers.authorization===`Bearer ${t}`?(o||(o=!0,i.once("finish",n)),i.status(202).json({status:"stopping"})):i.status(401).send("Unauthorized: local server bearer token required")})}function Cd(e,t,n,o={}){var i,r;const a=null!=(i=o.exit)?i:e=>process.exit(e);let s=!1;const c=()=>{s||(s=!0,clearTimeout(l),a(0))},l=setTimeout(()=>{console.warn("[Needle server] Shutdown deadline reached; closing remaining connections.");for(const e of t.clients)e.terminate();null==e.closeAllConnections||e.closeAllConnections(),c()},null!=(r=o.timeoutMs)?r:3e3);n();let p=2;const u=e=>{e&&console.error("[Needle server] Error closing server",e),0==--p&&c()};for(const e of t.clients)e.close(1001,"Needle server stopping");t.close(u),e.close(u),null==e.closeIdleConnections||e.closeIdleConnections()}var Nd={__proto__:null,stopLocalServer:async function(e={}){var t,n;const o=null!=(t=e.fetch)?t:globalThis.fetch;let i;try{i=await o(`${Cu}/api/info`,{redirect:"error",signal:AbortSignal.timeout(5e3)})}catch(e){if(Ad(e))return"not-running";throw e}if(!i.ok)throw new Error(`The running server cannot be identified (HTTP ${i.status}). It may need to be closed manually.`);await i.arrayBuffer();const r=null!=(n=e.tokenFile)?n:se(ne(),".needle","local-server-token");let a;try{a=JSON.parse(await V(r,"utf8"))}catch{throw new Error("Cannot read the local server token. Older servers must be closed manually.")}if(!a||"object"!=typeof a||!("token"in a)||"string"!=typeof a.token||!a.token)throw new Error("The local server token is invalid. The server must be closed manually.");const s=await o(`${Cu}/stop`,{method:"POST",redirect:"error",signal:AbortSignal.timeout(5e3),headers:{Authorization:`Bearer ${a.token}`}});if(404===s.status)throw new Error("This server version does not support stop. Close it manually, then start an updated CLI.");if(202!==s.status)throw new Error(`The server rejected the stop request (HTTP ${s.status}).`);const c=await s.json();if(!c||"object"!=typeof c||!("status"in c)||"stopping"!==c.status)throw new Error("The server did not acknowledge the stop request.");return"stopping"},registerStopRoute:Od,shutdownLocalServer:Cd};let Rd=null;function Pd(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 Ud=Date.now();async function Ld(e){var t;const n=Date.now();n-Ud>3e4&&"client"in e&&(Ud=n,await e.client.fetchUserInfo().catch(console.error));const o=null==(t=e.userInfo)?void 0:t.custom_data;if(!o)return!1;if(Rd||await zd(),!Rd)return console.error("Failed to get machine id"),!0;const i=o.machines;if(!i)return!1;const r=i.some(e=>e.id===Rd);return r}async function zd(){return Rd||await import("node-machine-id").then(async e=>{const t=await e.default.machineId(!1);Rd=t}),Rd}function Fd(){return Te.userInfo().username+"@"+Te.hostname()}async function Dd(e,t={signout:!1}){if(e.accessToken){const o={machine_id:await zd(),machine_name:Fd(),platform:Te.platform(),arch:Te.arch()},i=await fetch("https://cloud.needle.tools/api"+ht.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`),Mp(`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 r=!0;if(403===i.status){const e=await i.text();if(e.trimStart().startsWith("{")){const t=JSON.parse(e);t.logins&&(r=!1,Mp("Too many logins from different machines"),T().fail("You have reached the maximum number of allowed logins\n"),T().warn(`Please logout from one of the following machines:\n- ${t.logins.join("\n- ")}\n`))}}var n;return!!r||(t.signout&&(od(),"client"in e&&(null==(n=e.client)||n.signOut(td("too-many-logins")))),!1)}return!0}let qd=null;function Bd(){if(qd)return qd;{const e=Kd();return qd=e,e}}const Md="projects.json";function Wd(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(Vd(),JSON.stringify(e),"utf-8"),qd=e}function Gd(){var e;const t=Bd(),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 Hd(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=Bd(),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,Wd(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,Wd(n),i}function Jd(e){if("string"!=typeof e||!e)throw new Error("A registered project path is required.");const t=Bd(),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)],Wd(t),o}function Vd(){const e=process.env.HOME||process.env.USERPROFILE||process.cwd(),t=_(e,".needle");return c(t)||m(t,{recursive:!0}),_(t,Md)}function Kd(){const e=Vd();if(!c(e))return{entries:[]};const t=p(e,"utf-8");try{const e=JSON.parse(t);return qd=e,e}catch(e){return console.error("Failed to parse project info file:",e),{entries:[]}}}const Yd=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8"));function Zd(){return Yd.version}const Xd=process.env.NEEDLE_SEARCH_ENDPOINT||"https://search.needle.tools",Qd=process.env.NEEDLE_SEARCH_API_KEY||"da5737c00d6822c32a1b9e3b5dab094bfc17e205aef2f7f3e1a0fd4ebc77b79f",em=[{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"]}}],tm={needle_my_account:async function(e){try{const e=await _d(),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=`${Xd}/api/semantic-search?q=${encodeURIComponent(n)}&limit=${o}`,r={Accept:"application/json"};Qd&&(r.Authorization=`Bearer ${Qd}`);try{const t=await e(i,{headers:r,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 a=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${a}`}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e instanceof Error?e.message:String(e)}`}]}}}},nm=new Map;function om(e,t){const n=nm.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=em.findIndex(e=>e.name===t);-1!==n&&(em.splice(n,1),delete tm[t],am.set(t,e),o=!0)}nm.delete(e),o&&t()}}function im(e,t){const n=em.findIndex(t=>t.name===e);if(-1!==n){em.splice(n,1),delete tm[e];for(const t of nm.values())t.delete(e);t()}}function rm(e,t,n,o){const i=em.findIndex(t=>t.name===e.name);if(-1!==i){var r;const t=null==(r=[...nm.entries()].find(([,t])=>t.has(e.name)))?void 0:r[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"}.`);em.splice(i,1)}if(em.push(e),tm[e.name]=t,am.delete(e.name),null!=n&&n.source){const t=nm.get(n.source)||new Set;t.add(e.name),nm.set(n.source,t)}o()}const am=new Map;async function sm(e,t,n={}){const o=tm[e];if(!o){const t=am.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 cm=200,lm=2e3,pm=new RegExp("^[A-Za-z0-9_./*?\\[\\]{},\\-]+$"),um="[REDACTED]";function dm(e){return/(?:password|passwd|pwd|secret|token|apikey|privatekey|accesskey|connectionstring|databaseurl|authorization|credentials)$/.test(e.toLowerCase().replace(/[^a-z0-9]/g,""))}function mm(e){return"string"==typeof e?hm(e):Array.isArray(e)?e.map(mm):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,dm(e)&&null!==t?um:mm(t)])):e}function fm(e){var t;return um+"\n".repeat((null!=(t=e.match(/\n/g))?t:[]).length)}function hm(e){let t=e.replace(/-----BEGIN (?:[A-Z0-9 ]*PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g,fm);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||!dm(t[2]))continue;const r=t[1].length;for(n[e]=um;e+1<n.length&&(!n[e+1].trim()||(null!=(o=null==(i=n[e+1].match(/^[ \t]*/))?void 0:i[0].length)?o:0)>r);){var o,i;n[++e]=um}}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)+um),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(!dm(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+um+i+"\n".repeat((null!=(o=n.match(/\n/g))?o:[]).length)}),t=t.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/@]+:[^\s/@]+@/gi,"$1"+um+"@"),t=t.replace(/([?&])([\w%-]+)=([^&#\s"']*)/g,(e,t,n)=>dm(function(e){try{return decodeURIComponent(e)}catch{return e}}(n))?t+n+"="+um: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,um)}function gm(e){if(/^\s*[\[{]/.test(e)){try{JSON.parse(e)}catch{return hm(e)}const o=/"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|[{}\[\]:,]|\s+/g;let i,r="",a=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||!dm(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}}r+=e.slice(a,p)+JSON.stringify(um)+"\n".repeat((null!=(t=e.slice(p,u).match(/\n/g))?t:[]).length),a=u}return r+=e.slice(a),r.replace(/"(?:\\.|[^"\\])*"/g,e=>JSON.stringify(hm(JSON.parse(e))))}return hm(e)}class vm extends Error{}function bm(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 ym(e,t){const n=le(e,t);return""===n||!ue(n)&&".."!==n&&!n.startsWith(".."+de)}function xm(e,t,n={}){if("string"!=typeof t||!t||t.includes("\0"))throw new vm("Invalid file path.");const o=O(e),i=ce(o,t);if(!ym(o,i))throw new vm("Path is outside the connected project.");const r=le(o,i);if(r.split(/[\\/]/).some(e=>e.includes(":")||/[ .]$/.test(e)))throw new vm("Invalid file path.");if(bm(e)||bm(o)||bm(r))throw new vm("Sensitive files cannot be accessed by local AI tools.");let a=i;for(;!$(a)&&a!==o&&n.allowMissing;)a=pe(a);const s=O(a);if(!ym(o,s))throw new vm("Path is outside the connected project.");const c=ce(s,le(a,i));if(bm(c))throw new vm("Sensitive files cannot be accessed by local AI tools.");return{root:o,path:c}}function wm(e,t,n={}){var o,i;const r=xm(e,t);if(!C(r.path).isFile())throw new vm("Path is not a regular file.");const a=P(r.path,F.O_RDONLY|(null!=(o=F.O_NOFOLLOW)?o:0)|(null!=(i=F.O_NONBLOCK)?i:0));try{var s;const o=D(a);if(!o.isFile())throw new vm("Path is not a regular file.");if(o.nlink>1)throw new vm("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 vm("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 vm("Invalid file byte range.");if((l?l.length:o.size)>i)throw new vm(`File exceeds the ${i} byte read limit.`);const p=xm(e,t),u=C(p.path);if(p.path!==r.path||o.ino!==u.ino||o.dev!==u.dev)throw new vm("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(a,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 vm("File exceeds the read size limit.");m.push(Buffer.from(d.subarray(0,f)))}if(l&&h!==l.length)throw new vm("File byte range changed while reading.");const v=xm(e,t),b=C(v.path);if(v.path!==r.path||b.ino!==o.ino||b.dev!==o.dev)throw new vm("File path changed while reading. Retry the request.");return Buffer.concat(m,h)}finally{L(a)}}function _m(e){if(/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(e.toString("utf8")))throw new vm("Files containing private-key material cannot be read.")}function jm(e,t={}){const n=e.toString("utf8");if(n.includes("\0")||!Buffer.from(n,"utf8").equals(e))throw new vm("Only UTF-8 text files can be read.");return t.allowPrivateKeys||_m(e),gm(n)}function km(e,t,n={}){return{...xm(e,t),text:jm(wm(e,t,n),n)}}function Sm(e,t){try{return He("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 Em(e,t,n=Sm){!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>lm)throw new Error(`invalid pattern: exceeds ${lm} characters`);if(null!=t&&""!==t){if("string"!=typeof t)throw new Error("invalid glob: must be a string");if(t.length>cm)throw new Error(`invalid glob: exceeds ${cm} characters`);if(!pm.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 r=0,a=0,s=0,c=0,l=!1;const p=Date.now();!function n(u,d){if(d>20||s>=2e3||a>=33554432||Date.now()-p>1e4)l=!0;else for(const m of q(u,{withFileTypes:!0})){const f=se(u,m.name),h=le(e,f).replace(/\\/g,"/");if(bm(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&&!Ye(h,t.glob,{matchBase:!0}))continue;try{xm(e,f);const t=km(e,f).text.replace(/\n$/,""),n=Buffer.byteLength(t);if(++s>2e3||a+n>33554432||Date.now()-p>1e4)return void(l=!0);const c=t.split("\n").length;i.push({start:r+1,end:r+c,path:h}),r+=c,a+=n,o.push(t+"\n")}catch(e){if(e instanceof vm){c++;continue}throw e}}if(l)return}}}(xm(e,".").path,0);const u=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)}`});return{lines:u,omitted:c,limited:l}}const Tm=new Set;async function $m(e,t=Je){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=ce(e),i=se(o,"tsconfig.json"),r=se(o,"node_modules/typescript/lib/tsc.js");if(!$(i))return{...n,status:"unavailable",message:"The connected web project has no tsconfig.json."};if(!$(r))return{...n,status:"unavailable",message:"TypeScript is not installed in the connected web project. Install the project dependencies first."};if(Tm.has(o))return{...n,status:"error",message:"A check is already running for this project."};Tm.add(o);try{const e={...process.env};delete e.NODE_OPTIONS,delete e.NODE_PATH;const a=await new Promise(n=>{t(process.execPath,[r,"--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}=a,c=gm(a.stdout),l=gm(a.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{Tm.delete(o)}}const Im=new Set([".git","node_modules"]);function Am(e){if(!e)return null;try{const t=O(e),n=o("sha256"),i=[t];let r=0;for(;i.length;){const e=i.pop(),o=q(e,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name));for(const a of o){if(++r>2e4)return null;const o=se(e,a.name),s=le(t,o).replaceAll("\\","/");if(a.isDirectory()&&Im.has(a.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`),a.isDirectory()&&i.push(o)}}return n.digest("hex")}catch{return null}}const Om=(e,t)=>gm(String(null!=e?e:"")).slice(0,t),Cm=1048576,Nm=104857600,Rm=e=>o("sha256").update(e).digest("hex"),Pm=1048576,Um=e=>o("sha256").update(e).digest("hex"),Lm=new Set([".app",".bat",".cmd",".com",".desktop",".exe",".hta",".jar",".lnk",".msi",".ps1",".scr",".sh",".url",".vbs",".wsf"]),zm="settings.json";function Fm(){return se(ne(),".needle")}function Dm(e){const t=se(null!=e?e:Fm(),zm);if(!$(t))return{};try{const e=JSON.parse(M(t,"utf-8"));return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}catch{return{}}}function qm(e){return"disabled"===Dm(e).remote_ai_tools}function Bm(e){const t=se(null!=e?e:Fm(),zm);if(!$(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 Mm(e){const t=Bm(e);return null===t||void 0!==t.local_file_edits&&"enabled"!==t.local_file_edits}function Wm(e){const t=Bm(e);return null===t||void 0!==t.local_project_commands&&"enabled"!==t.local_project_commands}function Gm(e,t){if(!$(e))try{I(e,{recursive:!0})}catch{}let n=null,o=null;try{n=H(e,{persistent:!1},(e,n)=>{n&&n.toString()!==zm||(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 Hm={__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:Fm,readSettings:Dm,writeSetting:function(e,t,n){const o=Dm(e);null===n?delete o[t]:o[t]=n,I(e,{recursive:!0}),G(se(e,zm),JSON.stringify(o,null,2)+"\n","utf-8")},areRemoteAiToolsDisabled:qm,areLocalFileEditsDisabled:Mm,areLocalProjectCommandsDisabled:Wm,watchSettings:Gm};const Jm=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Vm(e,t=process.platform,n=Ve){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 Km=Object.freeze(["vite","react","react-three-fiber","svelte","sveltekit","vue","nextjs"]),Ym=new Set(Km),Zm=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@(?:\d+(?:\.\d+){0,2}(?:-[a-z0-9.-]+)?|latest|next))?$/i,Xm=/^[a-z0-9][a-z0-9._-]{0,79}$/i;function Qm(e,t){if(!e||!$(e)||!C(e).isDirectory())throw new Error(`${t} does not exist.`);return O.native(e)}function ef(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||!Xm.test(e.name))throw new Error("Use a short project name containing letters, numbers, dots, hyphens, or underscores.");if(!Ym.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||!ue(e.parent)))throw new Error("An explicit project parent must be an absolute existing directory.");if(void 0!==e.destination&&("string"!=typeof e.destination||!ue(e.destination)))throw new Error("An explicit project destination must be absolute.");const o=void 0!==e.parent?se(Qm(e.parent,"The project parent"),e.name):void 0!==e.destination?ce(e.destination):se(n,".needle","ai-projects",e.name);if(ae(o)!==e.name)throw new Error("The destination folder must match the project name.");const i=t?se(Qm(pe(o),"The destination parent"),e.name):o;if($(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||!ue(i)))throw new Error("An explicit project path must be absolute.");const r=Qm(i||t||"","The project"),a=r!==(t&&$(t)?O.native(t):null),s=function(e){const t=se(e,"package.json");if(!$(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}}(r);!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($(se(e,t)))throw new Error(`This project uses ${t}; npm-only AI commands cannot modify it.`)}(r,s.packageManager);const c=function(e,t){const n=se(e,"package-lock.json");return i=t+"\0"+($(n)?M(n,"utf8"):""),o("sha256").update(i).digest("hex");var i}(r,s.raw);if("install"===e.operation){const t=$(se(r,"package-lock.json"));return{request:e,operation:"install",project:r,customProject:a,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||!Zm.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:r,customProject:a,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:r,customProject:a,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(!$(se(r,"node_modules")))throw new Error("Install project dependencies before starting the dev server.");return{request:e,operation:"dev",project:r,customProject:a,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=se(r,"needle.config.json");if($(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||ue(t)||t.split(/[\\/]/).some(e=>".."===e||"."===e))throw new Error("Use a project-relative build directory.");const n=function(e,t){const n=O.native(t),o=le(e,n);if(".."===o||o.startsWith(`..${de}`)||ue(o))throw new Error("The build directory is outside the connected project.");return n}(r,Qm(ce(r,t),"The build directory"));if(!$(se(n,"index.html")))throw new Error("The build directory has no index HTML file.");if(void 0!==e.name&&!Xm.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:r,customProject:a,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 tf(e,t=process.platform,n=Ve,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 nf(e,t,n=(()=>{}),o=y){let r,a,s=process.execPath,c=e.project||pe(e.destination);if("deploy"===e.operation){const t=process.argv[1];if(!t||!$(t))throw new Error("Cannot locate the running Needle CLI entry point for deployment.");r=[ce(t),"deploy",e.directory,"--open","false",...e.name?["--name",e.name]:[],...e.team?["--team",e.team]:[]]}else{const t=[process.env.npm_execpath,se(pe(process.execPath),"node_modules","npm","bin","npm-cli.js"),se(pe(pe(process.execPath)),"lib","node_modules","npm","bin","npm-cli.js")].find(e=>"string"==typeof e&&"npm-cli.js"===ae(e)&&$(e));if(!t)throw new Error("Could not locate npm-cli.js. Start Needle CLI through npm or install npm alongside Node.js.");r=[t,...e.args],"create"===e.operation&&I(c,{recursive:!0})}if("dev"===e.operation){const t=[Ze(new URL("../../../bin/cli.project-dev-supervisor.cjs",import.meta.url)),Ze(new URL("../bin/cli.project-dev-supervisor.cjs",import.meta.url))].find($);if(!t)throw new Error("The local dev supervisor is missing from the Needle CLI installation.");a=e.runtimeFile||se(oe(),`needle-dev-${i()}.runtime.json`),r=[t,Buffer.from(JSON.stringify({executable:s,args:r,cwd:c,runtimeFile:a})).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=Ke(s,r,{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,r=!1;function a(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),um;const r=null!=(n=null==(o=e.match(/^[ \t]*/))?void 0:o[0].length)?n:0;if(void 0!==t){if(!e.trim()||r>t)return um;t=void 0}const a=/^([ \t]*)([\w.-]+)[ \t]*:[ \t]*(?:[|>][^\n]*)?$/.exec(e);return a&&dm(a[2])?(t=a[1].length,um):gm(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+(r?um:a(e))+"\n").slice(-8e3),r=!1}return n.length>65536&&(a(n),n="",r=!0),t&&(n||r)&&(o=(o+(r?um:a(n))).slice(-8e3),n="",r=!1),o}}}();let h,g,v=!1,b=!1;const y=e=>{if(b)return!1;try{return n(e),!0}catch(e){return b=!0,g=e,_(),!1}},x=t=>{if(m=f.push(t.toString().replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,"")),"dev"!==e.operation)return;if(!y({output:gm(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];y({url:i})&&o(i).then(()=>{y({browserOpened:!0})}).catch(e=>{y({browserError:e instanceof Error?e.message:String(e)})})};null==(p=d.stdout)||p.on("data",x),null==(u=d.stderr)||u.on("data",x);let w=!1;const _=()=>{if(a)return G(`${a}.cancel`,"",{flag:"w",mode:384}),void(null!=h||(h=setTimeout(()=>{tf(d.pid),null!==d.exitCode||d.killed||d.kill("SIGTERM")},5e3)));tf(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),a){const e=`${a}.cancel`;$(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:gm(w?`${m}\nCommand timed out after 15 minutes.`:m)}))}),"dev"===e.operation&&d.pid){const e=Vm(d.pid);e?y({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 of(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 rf=Le(Je),af=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 r,Option as a}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 y from"open";import x,{resolve as w,join as _,relative as j,isAbsolute as k,sep as S,dirname as E}from"path";import T from"ora";import{existsSync as $,mkdirSync as I,renameSync as A,realpathSync as O,statSync as C,rename as N,appendFileSync as R,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 G,watch as H}from"node:fs";import{writeFile as J,readFile as V,readlink 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,{extname as re,basename as ae,join as se,resolve as ce,relative as le,dirname as pe,isAbsolute as ue,sep as de,win32 as me,posix as fe}from"node:path";import he from"util";import ge,{Readable as ve}from"stream";import be from"http";import ye from"https";import xe 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 Te,{homedir as $e,tmpdir as Ie}from"os";import Ae,{EventEmitter as Oe}from"events";import Ce from"http2";import Ne from"zlib";import{Console as Re}from"node:console";import{createInterface as Pe}from"node:readline/promises";import{stripVTControlCharacters as Ue,promisify as Le}from"node:util";import ze from"dotenv";import Fe from"@logto/node";import{createInterface as De}from"node:readline";import{Readable as qe}from"node:stream";import{createGzip as Be}from"node:zlib";import{Router as Me}from"express";import We,{WebSocketServer as Ge}from"ws";import{execFileSync as He,execFile as Je,spawnSync as Ve,spawn as Ke}from"node:child_process";import{minimatch as Ye}from"minimatch";import{fileURLToPath as Ze}from"node:url";import{setTimeout as Xe}from"node:timers/promises";import Qe from"body-parser";const et="STRING",tt="BOOLEAN",nt="NUMBER",ot="ARRAY";function it(e){return e.replace(/[-_](\w)/g,(e,t)=>t.toUpperCase())}function rt(e){const t=e.match(/--[\w-]+/g);return t?t[t.length-1]:e.split(/[\s,]+/)[0]}function at(e){return it(rt(e).replace(/^--/,""))}function st(e){return it(e.replace(/[[\]<>]/g,"").replace(/\.\.\.$/,"").trim())}function ct(e,t){if(null==e)return e;switch(t){case tt:{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 nt:{const t=Number(e);return Number.isNaN(t)?e:t}case ot:return Array.isArray(e)?e:String(e).split(",");case et:return Array.isArray(e)?e:String(e);default:return e}}const lt={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 pt{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:st(e),validator:n.validator,default:n.default}),this}action(e){return this._action=e,this}isHelpCommand(){return!1}}class ut{constructor(){this.STRING=et,this.BOOLEAN=tt,this.NUMBER=nt,this.ARRAY=ot,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 pt(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 r=null!=(n=null==(o=this._testHooks)?void 0:o.error)?n:e=>console.error(e);return r(`error: ${t instanceof Error&&t.message||String(t)}`),(null!=e?e:process.argv).includes("--verbose")&&t instanceof Error&&t.stack&&r(t.stack),null!=(i=this._testHooks)&&i.exit?this._testHooks.exit(1):process.exit(1)}}_build(){const e=new r(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 a=t.get(i);return a||(a=new r(o[o.length-2]),this._exitOverride&&a.exitOverride(),t.set(i,a),n(o.slice(0,-1)).addCommand(a)),a};for(const e of this._commands){const o=e.name.split(/\s+/),i=t.get(e.name),s=null!=i?i:new r(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&&!rt(e).startsWith("--no-")&&(e=/[<[]/.test(e)?e.replace(/<([\w-]+)>/,"[$1]"):`${e} [value]`);const n=new a(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]=ct(void 0===o?e.default:o,e.validator)});const r={};for(const t of e.options){if(rt(t.synopsis).startsWith("--no-")){const e=it(rt(t.synopsis).replace(/^--no-/,""));r[t.name]=!1===o[e];continue}const e=o[t.name];r[t.name]=ct(void 0===e?t.default:e,t.validator)}for(const[e,t]of Object.entries(o))e in r||(r[e]=t);await e._action({args:i,options:r,logger:lt,command:s})}),i||n(o).addCommand(s,{hidden:!e.visible})}return e}}function dt(){return new ut}var mt={program:dt(),createProgram:dt,STRING:et,BOOLEAN:tt,NUMBER:nt,ARRAY:ot};class ft extends Error{constructor(e,t,n){super(n),this.name="ApiError",this.status=e,this.body=t}}const ht={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_usage:"/v1/jobs/post_usage",get_status:"/v1/jobs/status",get_org:"/v1/jobs/org",query:"/v1/jobs/query"},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 gt(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 vt={credentials:"omit"};async function bt(e,t){const n=e.baseUrl+ht.account.get_licenses,o={...{...t},...gt(e)},i=await fetch(n,{...vt,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 yt(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:wt}=Object.prototype,{getPrototypeOf:_t}=Object,{iterator:jt,toStringTag:kt}=Symbol,St=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Et=(e,t)=>{let n=e;const o=[];for(;null!=n&&n!==Object.prototype;){if(-1!==o.indexOf(n))return!1;if(o.push(n),St(n,t))return!0;n=_t(n)}return!1},Tt=($t=Object.create(null),e=>{const t=wt.call(e);return $t[t]||($t[t]=t.slice(8,-1).toLowerCase())});var $t;const It=e=>(e=e.toLowerCase(),t=>Tt(t)===e),At=e=>t=>typeof t===e,{isArray:Ot}=Array,Ct=At("undefined");function Nt(e){return null!==e&&!Ct(e)&&null!==e.constructor&&!Ct(e.constructor)&&Ut(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Rt=It("ArrayBuffer"),Pt=At("string"),Ut=At("function"),Lt=At("number"),zt=e=>null!==e&&"object"==typeof e,Ft=e=>{if(!zt(e))return!1;const t=_t(e);return!(null!==t&&t!==Object.prototype&&null!==_t(t)||Et(e,kt)||Et(e,jt))},Dt=It("Date"),qt=It("File"),Bt=It("Blob"),Mt=It("FileList"),Wt=It("Set"),Gt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Ht=void 0!==Gt.FormData?Gt.FormData:void 0,Jt=It("URLSearchParams"),[Vt,Kt,Yt,Zt]=["ReadableStream","Request","Response","Headers"].map(It);function Xt(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(Nt(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),r=i.length;let a;for(o=0;o<r;o++)a=i[o],t.call(null,e[a],a,e)}}function Qt(e,t){if(Nt(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 en="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,tn=e=>!Ct(e)&&e!==en,nn=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&_t(Uint8Array)),on=It("HTMLFormElement"),{propertyIsEnumerable:rn}=Object.prototype,an=It("RegExp"),sn=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),o={};Xt(n,(n,i)=>{let r;!1!==(r=t(n,i,e))&&(o[i]=r||n)}),Object.defineProperties(e,o)},cn=It("AsyncFunction"),ln=(pn="function"==typeof setImmediate,un=Ut(en.postMessage),pn?setImmediate:un?(dn=`axios@${Math.random()}`,mn=[],en.addEventListener("message",({source:e,data:t})=>{e===en&&t===dn&&mn.length&&mn.shift()()},!1),e=>{mn.push(e),en.postMessage(dn,"*")}):e=>setTimeout(e));var pn,un,dn,mn;const fn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(en):"undefined"!=typeof process&&process.nextTick||ln,hn=e=>null!=e&&Ut(e[jt]);var gn={isArray:Ot,isArrayBuffer:Rt,isBuffer:Nt,isFormData:e=>{if(!e)return!1;if(Ht&&e instanceof Ht)return!0;const t=_t(e);if(!t||t===Object.prototype)return!1;if(!Ut(e.append))return!1;const n=Tt(e);return"formdata"===n||"object"===n&&Ut(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:Pt,isNumber:Lt,isBoolean:e=>!0===e||!1===e,isObject:zt,isPlainObject:Ft,isEmptyObject:e=>{if(!zt(e)||Nt(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Vt,isRequest:Kt,isResponse:Yt,isHeaders:Zt,isUndefined:Ct,isDate:Dt,isFile:qt,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:Bt,isRegExp:an,isFunction:Ut,isStream:e=>zt(e)&&Ut(e.pipe),isURLSearchParams:Jt,isTypedArray:nn,isFileList:Mt,forEach:Xt,merge:function e(...t){const{caseless:n,skipUndefined:o}=tn(this)&&this||{},i={},r=(t,r)=>{if("__proto__"===r||"constructor"===r||"prototype"===r)return;const a=n&&"string"==typeof r&&Qt(i,r)||r,s=St(i,a)?i[a]:void 0;Ft(s)&&Ft(t)?i[a]=e(s,t):Ft(t)?i[a]=e({},t):Ot(t)?i[a]=t.slice():o&&Ct(t)||(i[a]=t)};for(let e=0,n=t.length;e<n;e++){const n=t[e];if(!n||Nt(n))continue;if(Xt(n,r),"object"!=typeof n||Ot(n))continue;const o=Object.getOwnPropertySymbols(n);for(let e=0;e<o.length;e++){const t=o[e];rn.call(n,t)&&r(n[t],t)}}return i},extend:(e,t,n,{allOwnKeys:o}={})=>(Xt(t,(t,o)=>{n&&Ut(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,r,a;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),r=i.length;r-- >0;)a=i[r],o&&!o(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&_t(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Tt,kindOfTest:It,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(!Lt(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[jt]).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:on,hasOwnProperty:St,hasOwnProp:St,hasOwnInPrototypeChain:Et,getSafeProp:(e,t)=>null!=e&&Et(e,t)?e[t]:void 0,reduceDescriptors:sn,freezeMethods:e=>{sn(e,(t,n)=>{if(Ut(e)&&["arguments","caller","callee"].includes(n))return!1;Ut(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:Qt,global:en,isContextDefined:tn,isSpecCompliantForm:function(e){return!!(e&&Ut(e.append)&&"FormData"===e[kt]&&e[jt])},toJSONObject:e=>{const t=new WeakSet,n=e=>{if(zt(e)){if(t.has(e))return;if(Nt(e))return e;if(!("toJSON"in e)){let o;if(t.add(e),Wt(e)){o=[];for(const t of e){const e=n(t);!Ct(e)&&o.push(e)}}else o=Ot(e)?[]:{},Xt(e,(e,t)=>{const i=n(e);!Ct(i)&&(o[t]=i)});return t.delete(e),o}}return e};return n(e)},isAsyncFn:cn,isThenable:e=>e&&(zt(e)||Ut(e))&&Ut(e.then)&&Ut(e.catch),setImmediate:ln,asap:fn,isIterable:hn,isSafeIterable:e=>null!=e&&Et(e,jt)&&hn(e)};const vn=gn.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"]),bn=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),yn=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function xn(e,t){return gn.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 wn(e){const t=Object.create(null);return gn.forEach(e.toJSON(),(e,n)=>{t[n]=(e=>xn(e,yn))(e)}),t}const _n=Symbol("internals");function jn(e){return e&&String(e).trim().toLowerCase()}function kn(e){return!1===e||null==e?e:gn.isArray(e)?e.map(kn):(e=>xn(e,bn))(String(e))}const Sn=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function En(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 Tn(e,t,n,o,i){return gn.isFunction(o)?o.call(this,t,n):(i&&(t=n),gn.isString(t)?gn.isString(o)?-1!==t.indexOf(o):gn.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=jn(t);if(!i)return;const r=gn.findKey(o,i);(!r||void 0===o[r]||!0===n||void 0===n&&!1!==o[r])&&(o[r||t]=kn(e))}const r=(e,t)=>gn.forEach(e,(e,n)=>i(e,n,t));if(gn.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(gn.isString(e)&&(e=e.trim())&&!(e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))(e))r((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 r=gn.hasOwnProp(t,n);!n||r&&gn.hasOwnProp(vn,n)||("set-cookie"===n?r?t[n].push(o):t[n]=[o]:t[n]=r?t[n]+", "+o:o)}),t})(e),t);else if(gn.isObject(e)&&gn.isSafeIterable(e)){let n,o,i=Object.create(null);for(const t of e){if(!gn.isArray(t))throw new TypeError("Object iterator must return a key-value pair");o=t[0],gn.hasOwnProp(i,o)?(n=i[o],i[o]=gn.isArray(n)?[...n,t[1]]:[n,t[1]]):i[o]=t[1]}r(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=jn(e)){const n=gn.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(gn.isFunction(t))return t.call(this,e,n);if(gn.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=jn(e)){const n=gn.findKey(this,e);return!(!n||void 0===this[n]||t&&!Tn(0,this[n],n,t))}return!1}delete(e,t){const n=this;let o=!1;function i(e){if(e=jn(e)){const i=gn.findKey(n,e);!i||t&&!Tn(0,n[i],i,t)||(delete n[i],o=!0)}}return gn.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&&!Tn(0,this[i],i,e,!0)||(delete this[i],o=!0)}return o}normalize(e){const t=this,n={};return gn.forEach(this,(o,i)=>{const r=gn.findKey(n,i);if(r)return t[r]=kn(o),void delete t[i];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();a!==i&&delete t[i],t[a]=kn(o),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return gn.forEach(this,(n,o)=>{null!=n&&!1!==n&&(t[o]=e&&gn.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 gn.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,r=!1;function a(e){const i=En(n.slice(o,e)),r=i.indexOf("=");if(r<1)return;const a=En(i.slice(0,r));if(!Sn.test(a))return;const s=a.toLowerCase();if("__proto__"===s||"constructor"===s||"prototype"===s)return;const c=En(i.slice(r+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?r?r=!1:92===t?r=!0:34===t&&(i=!1):34===t?i=!0:44!==t&&59!==t||(a(e),o=e+1)}return a(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[_n]=this[_n]={accessors:{}}).accessors,n=this.prototype;function o(e){const o=jn(e);t[o]||(function(e,t){const n=gn.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 gn.isArray(e)?e.forEach(o):o(e),this}}$n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),gn.reduceDescriptors($n.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),gn.freezeMethods($n);var In=$n;const An="[REDACTED ****]";class On extends Error{static from(e,t,n,o,i,r){let a=e.message;!a&&gn.isArray(e.errors)&&e.errors.length&&(a=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(a,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),r&&Object.assign(s,r),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&&gn.hasOwnProp(e,"redact")?e.redact:void 0,n=gn.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(gn.isBuffer(e))return e;if(-1!==o.indexOf(e))return;let t;if(e instanceof In&&(e=e.toJSON()),o.push(e),gn.isArray(e))t=[],e.forEach((e,n)=>{const o=i(e);gn.isUndefined(o)||(t[n]=o)});else{if(!gn.isPlainObject(e)&&function(e){if(gn.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(gn.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}(e))return o.pop(),e;t=Object.create(null);for(const[o,r]of Object.entries(e)){const e=n.has(o.toLowerCase())?An:i(r);gn.isUndefined(e)||(t[o]=e)}}return o.pop(),t};return i(e)}(e,t):gn.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 Cn=On,Nn=ge.Stream,Rn=Pn;function Pn(){this.source=null,this.dataSize=0,this.maxDataSize=1048576,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}he.inherits(Pn,Nn),Pn.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(Pn.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}}),Pn.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)},Pn.prototype.resume=function(){this._released||this.release(),this.source.resume()},Pn.prototype.pause=function(){this.source.pause()},Pn.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(e){this.emit.apply(this,e)}.bind(this)),this._bufferedEvents=[]},Pn.prototype.pipe=function(){var e=Nn.prototype.pipe.apply(this,arguments);return this.resume(),e},Pn.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))},Pn.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 Un=ge.Stream,Ln=zn;function zn(){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(zn,Un),zn.create=function(e){var t=new this;for(var n in e=e||{})t[n]=e[n];return t},zn.isStreamLike=function(e){return"function"!=typeof e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Buffer.isBuffer(e)},zn.prototype.append=function(e){if(zn.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},zn.prototype.pipe=function(e,t){return Un.prototype.pipe.call(this,e,t),this.resume(),e},zn.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}}},zn.prototype._realGetNext=function(){var e=this._streams.shift();void 0!==e?"function"==typeof e?e(function(e){zn.isStreamLike(e)&&(e.on("data",this._checkDataSize.bind(this)),this._handleErrors(e)),this._pipeNext(e)}.bind(this)):this._pipeNext(e):this.end()},zn.prototype._pipeNext=function(e){if(this._currentStream=e,zn.isStreamLike(e))return e.on("end",this._getNext.bind(this)),void e.pipe(this,{end:!1});this.write(e),this._getNext()},zn.prototype._handleErrors=function(e){var t=this;e.on("error",function(e){t._emitError(e)})},zn.prototype.write=function(e){this.emit("data",e)},zn.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.pause&&this._currentStream.pause(),this.emit("pause"))},zn.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")},zn.prototype.end=function(){this._reset(),this.emit("end")},zn.prototype.destroy=function(){this._reset(),this.emit("close")},zn.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null},zn.prototype._checkDataSize=function(){this._updateDataSize(),this.dataSize<=this.maxDataSize||this._emitError(new Error("DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded."))},zn.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)},zn.prototype._emitError=function(e){this._reset(),this.emit("error",e)};var Fn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Dn(e){var t={exports:{}};return e(t,t.exports),t.exports}var qn={"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}},Bn=Dn(function(e,t){var n,o,i,r=x.extname,a=/^\s*([^;\s]*)(?:;|\s|$)/,s=/^text\//i;function c(e){if(!e||"string"!=typeof e)return!1;var t=a.exec(e),n=t&&qn[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=a.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=r("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(qn).forEach(function(e){var t=qn[e],r=t.extensions;if(r&&r.length){n[e]=r;for(var a=0;a<r.length;a++){var s=r[a];if(o[s]){var c=i.indexOf(qn[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}}})}),Mn=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)},Wn=function(e){var t=!1;return Mn(function(){t=!0}),function(n,o){t?e(n,o):Mn(function(){e(n,o)})}},Gn=function(e){Object.keys(e.jobs).forEach(Hn.bind(e)),e.jobs={}};function Hn(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}var Jn=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,Wn(o)):e(n,t,Wn(o))}(t,i,e[i],function(e,t){i in n.jobs&&(delete n.jobs[i],e?Gn(n):n.results[i]=t,o(e,n.results))})},Vn=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},Kn=function(e){Object.keys(this.jobs).length&&(this.index=this.size,Gn(this),Wn(e)(null,this.results))},Yn=function(e,t,n,o){var i=Vn(e,n);return Jn(e,t,i,function n(r,a){r?o(r,a):(i.index++,i.index<(i.keyedList||e).length?Jn(e,t,i,n):o(null,i.results))}),Kn.bind(i,o)};function Zn(e,t){return e<t?-1:e>t?1:0}Yn.ascending=Zn,Yn.descending=function(e,t){return-1*Zn(e,t)};var Xn=Object,Qn=Error,eo=EvalError,to=RangeError,no=ReferenceError,oo=SyntaxError,io=TypeError,ro=URIError,ao=Math.abs,so=Math.floor,co=Math.max,lo=Math.min,po=Math.pow,uo=Math.round,mo=Number.isNaN||function(e){return e!=e},fo=Object.getOwnPropertyDescriptor;if(fo)try{fo([],"length")}catch(e){fo=null}var ho=fo,go=Object.defineProperty||!1;if(go)try{go({},"a",{value:1})}catch(e){go=!1}var vo,bo=go,yo=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 r=Object.getOwnPropertyDescriptor(e,t);if(42!==r.value||!0!==r.enumerable)return!1}return!0},xo="undefined"!=typeof Symbol&&Symbol,wo="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null,_o=Xn,jo=_o.getPrototypeOf||null,ko=Object.prototype.toString,So=Math.max,Eo=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},To=Function.prototype.bind||function(e){var t=this;if("function"!=typeof t||"[object Function]"!==ko.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=So(0,t.length-o.length),r=[],a=0;a<i;a++)r[a]="$"+a;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}(r)+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof n){var i=t.apply(this,Eo(o,arguments));return Object(i)===i?i:this}return t.apply(e,Eo(o,arguments))}),t.prototype){var s=function(){};s.prototype=t.prototype,n.prototype=new s,s.prototype=null}return n},$o=Function.prototype.call,Io=Function.prototype.apply,Ao="undefined"!=typeof Reflect&&Reflect&&Reflect.apply||To.call($o,Io),Oo=io,Co=ho;try{vo=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var No,Ro=!!vo&&Co&&Co(Object.prototype,"__proto__"),Po=Object,Uo=Po.getPrototypeOf,Lo=Ro&&"function"==typeof Ro.get?function(e){if(e.length<1||"function"!=typeof e[0])throw new Oo("a function is required");return Ao(To,$o,e)}([Ro.get]):"function"==typeof Uo&&function(e){return Uo(null==e?e:Po(e))},zo=wo?function(e){return wo(e)}:jo?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return jo(e)}:Lo?function(e){return Lo(e)}:null,Fo=To.call(Function.prototype.call,Object.prototype.hasOwnProperty),Do=Qn,qo=eo,Bo=to,Mo=no,Wo=oo,Go=ro,Ho=ao,Jo=so,Vo=co,Ko=lo,Yo=po,Zo=uo,Xo=bo,Qo=Fo,ei=Function,ti=function(e){try{return ei('"use strict"; return ('+e+").constructor;")()}catch(e){}},ni=function(){throw new Oo},oi=Co?function(){try{return ni}catch(e){try{return Co(arguments,"callee").get}catch(e){return ni}}}():ni,ii="function"==typeof xo&&"function"==typeof Symbol&&"symbol"==typeof xo("foo")&&"symbol"==typeof Symbol("bar")&&yo(),ri={},ai="undefined"!=typeof Uint8Array&&zo?zo(Uint8Array):No,si={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?No:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?No:ArrayBuffer,"%ArrayIteratorPrototype%":ii&&zo?zo([][Symbol.iterator]()):No,"%AsyncFromSyncIteratorPrototype%":No,"%AsyncFunction%":ri,"%AsyncGenerator%":ri,"%AsyncGeneratorFunction%":ri,"%AsyncIteratorPrototype%":ri,"%Atomics%":"undefined"==typeof Atomics?No:Atomics,"%BigInt%":"undefined"==typeof BigInt?No:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?No:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?No:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?No:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Do,"%eval%":eval,"%EvalError%":qo,"%Float16Array%":"undefined"==typeof Float16Array?No:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?No:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?No:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?No:FinalizationRegistry,"%Function%":ei,"%GeneratorFunction%":ri,"%Int8Array%":"undefined"==typeof Int8Array?No:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?No:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?No:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ii&&zo?zo(zo([][Symbol.iterator]())):No,"%JSON%":"object"==typeof JSON?JSON:No,"%Map%":"undefined"==typeof Map?No:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&ii&&zo?zo((new Map)[Symbol.iterator]()):No,"%Math%":Math,"%Number%":Number,"%Object%":_o,"%Object.getOwnPropertyDescriptor%":Co,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?No:Promise,"%Proxy%":"undefined"==typeof Proxy?No:Proxy,"%RangeError%":Bo,"%ReferenceError%":Mo,"%Reflect%":"undefined"==typeof Reflect?No:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?No:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&ii&&zo?zo((new Set)[Symbol.iterator]()):No,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?No:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ii&&zo?zo(""[Symbol.iterator]()):No,"%Symbol%":ii?Symbol:No,"%SyntaxError%":Wo,"%ThrowTypeError%":oi,"%TypedArray%":ai,"%TypeError%":Oo,"%Uint8Array%":"undefined"==typeof Uint8Array?No:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?No:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?No:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?No:Uint32Array,"%URIError%":Go,"%WeakMap%":"undefined"==typeof WeakMap?No:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?No:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?No:WeakSet,"%Function.prototype.call%":$o,"%Function.prototype.apply%":Io,"%Object.defineProperty%":Xo,"%Object.getPrototypeOf%":jo,"%Math.abs%":Ho,"%Math.floor%":Jo,"%Math.max%":Vo,"%Math.min%":Ko,"%Math.pow%":Yo,"%Math.round%":Zo,"%Math.sign%":function(e){return mo(e)||0===e?e:e<0?-1:1},"%Reflect.getPrototypeOf%":wo};if(zo)try{null.error}catch(e){var ci=zo(zo(e));si["%Error.prototype%"]=ci}var li=function e(t){var n;if("%AsyncFunction%"===t)n=ti("async function () {}");else if("%GeneratorFunction%"===t)n=ti("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=ti("async function* () {}");else if("%AsyncGenerator%"===t){var o=e("%AsyncGeneratorFunction%");o&&(n=o.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&zo&&(n=zo(i.prototype))}return si[t]=n,n},pi={__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"]},ui=To.call($o,Array.prototype.concat),di=To.call(Io,Array.prototype.splice),mi=To.call($o,String.prototype.replace),fi=To.call($o,String.prototype.slice),hi=To.call($o,RegExp.prototype.exec),gi=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,vi=/\\(\\)?/g,bi=function(e,t){var n,o=e;if(Qo(pi,o)&&(o="%"+(n=pi[o])[0]+"%"),Qo(si,o)){var i=si[o];if(i===ri&&(i=li(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 Wo("intrinsic "+e+" does not exist!")},yi=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===hi(/^%?[^%]*%?$/,e))throw new Wo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=fi(e,0,1),n=fi(e,-1);if("%"===t&&"%"!==n)throw new Wo("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new Wo("invalid intrinsic syntax, expected opening `%`");var o=[];return mi(e,gi,function(e,t,n,i){o[o.length]=n?mi(i,vi,"$1"):t||e}),o}(e),o=n.length>0?n[0]:"",i=bi("%"+o+"%",t),r=i.name,a=i.value,s=!1,c=i.alias;c&&(o=c[0],di(n,ui([0,1],c)));for(var l=1,p=!0;l<n.length;l+=1){var u=n[l],d=fi(u,0,1),m=fi(u,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new Wo("property names with quotes must have matching quotes");if("constructor"!==u&&p||(s=!0),Qo(si,r="%"+(o+="."+u)+"%"))a=si[r];else if(null!=a){if(!(u in a)){if(!t)throw new Oo("base intrinsic for "+e+" exists, but the property is not available.");return}if(Co&&l+1>=n.length){var f=Co(a,u);a=(p=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:a[u]}else p=Qo(a,u),a=a[u];p&&!s&&(si[r]=a)}}return a}("%Object.defineProperty%",!0),xi=yo()&&Symbol.toStringTag?Symbol.toStringTag:null,wi=function(e,t){return Object.keys(t).forEach(function(n){e[n]=e[n]||t[n]}),e},_i=xe.parse,ji=ge.Stream;function ki(e){return String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22")}function Si(e){if(!(this instanceof Si))return new Si(e);for(var t in this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],Ln.call(this),e=e||{})this[t]=e[t]}he.inherits(Si,Ln),Si.LINE_BREAK="\r\n",Si.DEFAULT_CONTENT_TYPE="application/octet-stream",Si.prototype.append=function(e,t,n){"string"==typeof(n=n||{})&&(n={filename:n});var o=Ln.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),r=this._multiPartFooter();o(i),o(t),o(r),this._trackLength(i,t,n)}},Si.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)+Si.LINE_BREAK.length,t&&(t.path||t.readable&&Qo(t,"httpVersion")||t instanceof ji)&&(n.knownLength||this._valuesToMeasure.push(t))},Si.prototype._lengthRetriever=function(e,t){Qo(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))}):Qo(e,"httpVersion")?t(null,Number(e.headers["content-length"])):Qo(e,"httpModule")?(e.on("response",function(n){e.pause(),t(null,Number(n.headers["content-length"]))}),e.resume()):t("Unknown stream")},Si.prototype._multiPartHeader=function(e,t,n){if("string"==typeof n.header)return n.header;var o,i=this._getContentDisposition(t,n),r=this._getContentType(t,n),a="",s={"Content-Disposition":["form-data",'name="'+ki(e)+'"'].concat(i||[]),"Content-Type":[].concat(r||[])};for(var c in"object"==typeof n.header&&wi(s,n.header),s)if(Qo(s,c)){if(null==(o=s[c]))continue;Array.isArray(o)||(o=[o]),o.length&&(a+=c+": "+o.join("; ")+Si.LINE_BREAK)}return"--"+this.getBoundary()+Si.LINE_BREAK+a+Si.LINE_BREAK},Si.prototype._getContentDisposition=function(e,t){var n;if("string"==typeof t.filepath?n=x.normalize(t.filepath).replace(/\\/g,"/"):t.filename||e&&(e.name||e.path)?n=x.basename(t.filename||e&&(e.name||e.path)):e&&e.readable&&Qo(e,"httpVersion")&&(n=x.basename(e.client._httpMessage.path||"")),n)return'filename="'+ki(n)+'"'},Si.prototype._getContentType=function(e,t){var n=t.contentType;return!n&&e&&e.name&&(n=Bn.lookup(e.name)),!n&&e&&e.path&&(n=Bn.lookup(e.path)),!n&&e&&e.readable&&Qo(e,"httpVersion")&&(n=e.headers["content-type"]),n||!t.filepath&&!t.filename||(n=Bn.lookup(t.filepath||t.filename)),!n&&e&&"object"==typeof e&&(n=Si.DEFAULT_CONTENT_TYPE),n},Si.prototype._multiPartFooter=function(){return function(e){var t=Si.LINE_BREAK;0===this._streams.length&&(t+=this._lastBoundary()),e(t)}.bind(this)},Si.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+Si.LINE_BREAK},Si.prototype.getHeaders=function(e){var t,n={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(t in e)Qo(e,t)&&(n[t.toLowerCase()]=e[t]);return n},Si.prototype.setBoundary=function(e){if("string"!=typeof e)throw new TypeError("FormData boundary must be a string");this._boundary=e},Si.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary},Si.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(Si.LINE_BREAK)])));return Buffer.concat([e,Buffer.from(this._lastBoundary())])},Si.prototype._generateBoundary=function(){this._boundary="--------------------------"+we.randomBytes(12).toString("hex")},Si.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},Si.prototype.hasKnownLength=function(){var e=!0;return this._valuesToMeasure.length&&(e=!1),e},Si.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=Vn(e);o.index<(o.keyedList||e).length;)Jn(e,t,o,function(e,t){e?n(e,t):0!==Object.keys(o.jobs).length||n(null,o.results)}),o.index++;Kn.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))},Si.prototype.submit=function(e,t){var n,o,i={method:"post"};return"string"==typeof e?(e=_i(e),o=wi({port:e.port,path:e.pathname,host:e.hostname,protocol:e.protocol},i)):(o=wi(e,i)).port||(o.port="https:"===o.protocol?443:80),o.headers=this.getHeaders(e.headers),n="https:"===o.protocol?ye.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,r=function(e,o){return n.removeListener("error",r),n.removeListener("response",i),t.call(this,e,o)};i=r.bind(this,null),n.on("error",r),n.on("response",i)}}.bind(this)),n},Si.prototype._error=function(e){this.error||(this.error=e,this.pause(),this.emit("error",e))},Si.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&&Qo(e,xi)||(yi?yi(e,xi,{configurable:!o,enumerable:!1,value:t,writable:!1}):e[xi]=t)}(Si.prototype,"FormData");var Ei=Si,Ti={isBufferAvailable:()=>"undefined"!=typeof Buffer,from:e=>Buffer.from(e)};const $i=100;function Ii(e){return gn.isPlainObject(e)||gn.isArray(e)}function Ai(e){return gn.endsWith(e,"[]")?e.slice(0,-2):e}function Oi(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ai(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Ci=gn.toFlatObject(gn,{},null,function(e){return/^is[A-Z]/.test(e)});function Ni(e,t,n){if(!gn.isObject(e))throw new TypeError("target must be an object");t=t||new(Ei||FormData);const o=(n=gn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!gn.isUndefined(t[e])})).metaTokens,i=n.visitor||m,r=n.dots,a=n.indexes,s=n.Blob||"undefined"!=typeof Blob&&Blob,c=void 0===n.maxDepth?$i:n.maxDepth,l=s&&gn.isSpecCompliantForm(t),p=[];if(!gn.isFunction(i))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(gn.isDate(e))return e.toISOString();if(gn.isBoolean(e))return e.toString();if(!l&&gn.isBlob(e))throw new Cn("Blob is not supported. Use a Buffer instead.");if(gn.isArrayBuffer(e)||gn.isTypedArray(e)){if(l&&"function"==typeof s)return new s([e]);if(Ti&&Ti.isBufferAvailable())return Ti.from(e);throw new Cn("Blob is not supported. Use a Buffer instead.",Cn.ERR_NOT_SUPPORT)}return e}function d(e){if(e>c)throw new Cn("Object is too deeply nested ("+e+" levels). Max depth: "+c,Cn.ERR_FORM_DATA_DEPTH_EXCEEDED)}function m(e,n,i){let s=e;if(gn.isReactNative(t)&&gn.isReactNativeBlob(e))return t.append(Oi(i,n,r),u(e)),!1;if(e&&!i&&"object"==typeof e)if(gn.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(!gn.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(gn.isArray(e)&&function(e){return gn.isArray(e)&&!e.some(Ii)}(e)||(gn.isFileList(e)||gn.endsWith(n,"[]"))&&(s=gn.toArray(e)))return n=Ai(n),s.forEach(function(e,o){!gn.isUndefined(e)&&null!==e&&t.append(!0===a?Oi([n],o,r):null===a?n:n+"[]",u(e))}),!1;return!!Ii(e)||(t.append(Oi(i,n,r),u(e)),!1)}const f=Object.assign(Ci,{defaultVisitor:m,convertValue:u,isVisitable:Ii});if(!gn.isObject(e))throw new TypeError("data must be an object");return function e(n,o,r=0){if(!gn.isUndefined(n)){if(d(r),-1!==p.indexOf(n))throw new Error("Circular reference detected in "+o.join("."));p.push(n),gn.forEach(n,function(n,a){!0===(!(gn.isUndefined(n)||null===n)&&i.call(t,n,gn.isString(a)?a.trim():a,o,f))&&e(n,o?o.concat(a):[a],r+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 Pi(e,t){this._pairs=[],e&&Ni(e,this,t)}const Ui=Pi.prototype;function Li(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zi(e,t,n){if(!t)return e;e=e||"";const o=gn.isFunction(n)?{serialize:n}:n,i=gn.getSafeProp(o,"encode")||Li,r=gn.getSafeProp(o,"serialize");let a;if(a=r?r(t,o):gn.isURLSearchParams(t)?t.toString():new Pi(t,o).toString(i),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}Ui.append=function(e,t){this._pairs.push([e,t])},Ui.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 Fi=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){gn.forEach(this.handlers,function(t){null!==t&&e(t)})}},Di={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},qi=xe.URLSearchParams;const Bi="abcdefghijklmnopqrstuvwxyz",Mi="0123456789",Wi={DIGIT:Mi,ALPHA:Bi,ALPHA_DIGIT:Bi+Bi.toUpperCase()+Mi};var Gi={isNode:!0,classes:{URLSearchParams:qi,FormData:Ei,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:Wi,generateString:(e=16,t=Wi.ALPHA_DIGIT)=>{let n="";const{length:o}=t,i=new Uint32Array(e);we.randomFillSync(i);for(let r=0;r<e;r++)n+=t[i[r]%o];return n},protocols:["http","https","file","data"]};const Hi="undefined"!=typeof window&&"undefined"!=typeof document,Ji="object"==typeof navigator&&navigator||void 0,Vi=Hi&&(!Ji||["ReactNative","NativeScript","NS"].indexOf(Ji.product)<0);var Ki={__proto__:null,hasBrowserEnv:Hi,hasStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,hasStandardBrowserEnv:Vi,navigator:Ji,origin:Hi&&window.location.href||"http://localhost",...Gi};const Yi=$i;function Zi(e){if(e>Yi)throw new Cn("FormData field is too deeply nested ("+e+" levels). Max depth: "+Yi,Cn.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Xi(e){function t(e,n,o,i){Zi(i);let r=e[i++];if("__proto__"===r)return!0;const a=Number.isFinite(+r),s=i>=e.length;return r=!r&&gn.isArray(o)?o.length:r,s?(o[r]=gn.hasOwnProp(o,r)?gn.isArray(o[r])?o[r].concat(n):[o[r],n]:n,!a):(gn.hasOwnProp(o,r)&&gn.isObject(o[r])||(o[r]=[]),t(e,n,o[r],i)&&gn.isArray(o[r])&&(o[r]=function(e){const t={},n=Object.keys(e);let o;const i=n.length;let r;for(o=0;o<i;o++)r=n[o],t[r]=e[r];return t}(o[r])),!a)}if(gn.isFormData(e)&&gn.isFunction(e.entries)){const n={};return gn.forEachEntry(e,(e,o)=>{t(function(e){const t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g;let o;for(;null!==(o=n.exec(e));)Zi(t.length),t.push("[]"===o[0]?"":o[1]||o[0]);return t}(e),o,n,0)}),n}return null}const Qi=(e,t)=>null!=e&&gn.hasOwnProp(e,t)?e[t]:void 0,er={transitional:Di,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",o=n.indexOf("application/json")>-1,i=gn.isObject(e);if(i&&gn.isHTMLForm(e)&&(e=new FormData(e)),gn.isFormData(e))return o?JSON.stringify(Xi(e)):e;if(gn.isArrayBuffer(e)||gn.isBuffer(e)||gn.isStream(e)||gn.isFile(e)||gn.isBlob(e)||gn.isReadableStream(e))return e;if(gn.isArrayBufferView(e))return e.buffer;if(gn.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let r;if(i){const t=Qi(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Ni(e,new Ki.classes.URLSearchParams,{visitor:function(e,t,n,o){return Ki.isNode&&gn.isBuffer(e)?(this.append(t,e.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}(e,t).toString();if((r=gn.isFileList(e))||n.indexOf("multipart/form-data")>-1){const n=Qi(this,"env"),o=n&&n.FormData;return Ni(r?{"files[]":e}:e,o&&new o,t)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(gn.isString(e))try{return(0,JSON.parse)(e),gn.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=Qi(this,"transitional")||er.transitional,n=t&&t.forcedJSONParsing,o=Qi(this,"responseType"),i="json"===o;if(gn.isResponse(e)||gn.isReadableStream(e))return e;if(e&&gn.isString(e)&&(n&&!o||i)){const n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Qi(this,"parseReviver"))}catch(e){if(n){if("SyntaxError"===e.name)throw Cn.from(e,Cn.ERR_BAD_RESPONSE,this,null,Qi(this,"response"));throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ki.classes.FormData,Blob:Ki.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};gn.forEach(["delete","get","head","post","put","patch","query"],e=>{er.headers[e]={}});var tr=er;function nr(e,t){const n=this||tr,o=t||n,i=In.from(o.headers);let r=o.data;return gn.forEach(e,function(e){r=e.call(n,r,i.normalize(),t?t.status:void 0)}),i.normalize(),r}function or(e){return!(!e||!e.__CANCEL__)}var ir=class extends Cn{constructor(e,t,n){super(null==e?"canceled":e,Cn.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function rr(e,t,n){const o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new Cn("Request failed with status code "+n.status,n.status>=400&&n.status<500?Cn.ERR_BAD_REQUEST:Cn.ERR_BAD_RESPONSE,n.config,n.request,n)):e(n)}const ar=/^https?:(?!\/\/)/i,sr=/[\t\n\r]/g;function cr(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(sr,"")}(e);if(ar.test(n))throw new Cn(`Invalid URL ${JSON.stringify(function(e){const t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${An}@`),n=t.indexOf("#"),o=(-1===n?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${An}`);return-1===n?o:`${o}#${i=t.slice(n+1),i?i.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,t,n="")=>`${t}${n}${An}`):i}`;var i}(n))}: missing "//" after protocol`,Cn.ERR_INVALID_URL,t)}}function lr(e,t,n,o){cr(t,o);let i=!function(e){return"string"==typeof e&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(i||!1===n)?(cr(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 pr={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function ur(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}var dr=1e3,mr=60*dr,fr=60*mr,hr=24*fr,gr=7*hr,vr=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*gr;case"days":case"day":case"d":return n*hr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*fr;case"minutes":case"minute":case"mins":case"min":case"m":return n*mr;case"seconds":case"second":case"secs":case"sec":case"s":return n*dr;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>=hr?br(e,t,hr,"day"):t>=fr?br(e,t,fr,"hour"):t>=mr?br(e,t,mr,"minute"):t>=dr?br(e,t,dr,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=hr?Math.round(e/hr)+"d":t>=fr?Math.round(e/fr)+"h":t>=mr?Math.round(e/mr)+"m":t>=dr?Math.round(e/dr)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function br(e,t,n,o){var i=t>=1.5*n;return Math.round(e/n)+" "+o+(i?"s":"")}var yr=function(e){function t(e){let o,i,r,a=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 r=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(o,i)=>{if("%%"===o)return"%";r++;const a=t.formatters[i];return"function"==typeof a&&(o=a.call(n,e[r]),e.splice(r,1),r--),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!==a?a:(i!==t.namespaces&&(i=t.namespaces,r=t.enabled(e)),r),set:e=>{a=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=vr,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},xr=Dn(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=yr(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}),wr=(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:_r}=process;let jr;function kr(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Sr(e,t){if(0===jr)return 0;if(wr("color=16m")||wr("color=full")||wr("color=truecolor"))return 3;if(wr("color=256"))return 2;if(e&&!t&&void 0===jr)return 0;const n=jr||0;if("dumb"===_r.TERM)return n;if("win32"===process.platform){const e=Te.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in _r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in _r)||"codeship"===_r.CI_NAME?1:n;if("TEAMCITY_VERSION"in _r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(_r.TEAMCITY_VERSION)?1:0;if("truecolor"===_r.COLORTERM)return 3;if("TERM_PROGRAM"in _r){const e=parseInt((_r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(_r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(_r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(_r.TERM)||"COLORTERM"in _r?1:n}wr("no-color")||wr("no-colors")||wr("color=false")||wr("color=never")?jr=0:(wr("color")||wr("colors")||wr("color=true")||wr("color=always"))&&(jr=1),"FORCE_COLOR"in _r&&(jr="true"===_r.FORCE_COLOR?1:"false"===_r.FORCE_COLOR?0:0===_r.FORCE_COLOR.length?1:Math.min(parseInt(_r.FORCE_COLOR,10),3));var Er={supportsColor:function(e){return kr(Sr(e,e&&e.isTTY))},stdout:kr(Sr(!0,Ee.isatty(1))),stderr:kr(Sr(!0,Ee.isatty(2)))},Tr=Dn(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),r=` ${i};1m${o} [0m`;n[0]=r+n[0].split("\n").join("\n"+r),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{Er&&(Er.stderr||Er).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=yr(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)}}),$r=Dn(function(e){e.exports="undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?xr:Tr}),Ir=/*#__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}),Ar=Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const Or=Ar($r),Cr=Ar(Ir),Nr=Or.default("agent-base");function Rr(){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 Pr(e,t){return new Pr.Agent(e,t)}!function(e){e.Agent=class extends Ae.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:Rr()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return"string"==typeof this.explicitProtocol?this.explicitProtocol:Rr()?"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=Rr()),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 r=n.timeout||this.timeout,a=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 ${r}ms`);e.code="ETIMEOUT",a(e)},c=e=>{o||(null!==i&&(clearTimeout(i),i=null),a(e))},l=t=>{if(o)return;if(null!=i&&(clearTimeout(i),i=null),r=t,Boolean(r)&&"function"==typeof r.addRequest)return Nr("Callback returned another Agent instance %o",t.constructor.name),void t.addRequest(e,n);var r;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}\``);a(s)};if("function"==typeof this.callback){this.promisifiedCallback||(this.callback.length>=3?(Nr("Converting legacy callback function to promise"),this.promisifiedCallback=Cr.default(this.callback)):this.promisifiedCallback=this.callback),"number"==typeof r&&r>0&&(i=setTimeout(s,r)),"port"in n&&"number"!=typeof n.port&&(n.port=Number(n.port));try{Nr("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 a(new Error("`callback` is not defined"))}freeSocket(e,t){Nr("Freeing socket %o %o",e.constructor.name,t),e.destroy()}destroy(){Nr("Destroying agent %o",this.constructor.name)}},e.prototype=e.Agent.prototype}(Pr||(Pr={}));var Ur=Pr;const Lr=(Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})($r).default("https-proxy-agent:parse-proxy-response");var zr=/*#__PURE__*/Object.defineProperty({default:function(e){return new Promise((t,n)=>{let o=0;const i=[];function r(){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 Lr("have not received end of HTTP headers yet..."),void r();const a=n.toString("ascii",0,n.indexOf("\r\n")),s=+a.split(" ")[1];Lr("got proxy server response: %o",a),t({statusCode:s,buffered:n})}(n):e.once("readable",r)}function a(e){Lr("onclose had error %o",e)}function s(){Lr("onend")}e.on("error",function t(o){e.removeListener("end",s),e.removeListener("error",t),e.removeListener("close",a),e.removeListener("readable",r),Lr("onerror %o",o),n(o)}),e.on("close",a),e.on("end",s),r()})}},"__esModule",{value:!0}),Fr=Fn&&Fn.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(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(a,s)}c((o=o.apply(e,t||[])).next())})},Dr=Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const qr=Dr(je),Br=Dr(ke),Mr=Dr(xe),Wr=Dr(Se),Gr=Dr($r),Hr=Dr(zr),Jr=Gr.default("https-proxy-agent:agent");function Vr(e){e.resume()}const Kr=(Fn&&Fn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(/*#__PURE__*/Object.defineProperty({default:class extends Ur.Agent{constructor(e){let t;if(t="string"==typeof e?Mr.default.parse(e):e,!t)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");Jr("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 Fr(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let i;o?(Jr("Creating `tls.Socket`: %o",n),i=Br.default.connect(n)):(Jr("Creating `net.Socket`: %o",n),i=qr.default.connect(n));const r=Object.assign({},n.headers);let a=`CONNECT ${t.host}:${t.port} HTTP/1.1\r\n`;n.auth&&(r["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}`),r.Host=s,r.Connection="close";for(const e of Object.keys(r))a+=`${e}: ${r[e]}\r\n`;const p=Hr.default(i);i.write(`${a}\r\n`);const{statusCode:u,buffered:d}=yield p;if(200===u){if(e.once("socket",Vr),t.secureEndpoint){Jr("Upgrading socket connection to TLS");const e=t.servername||t.host;return Br.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 qr.default.Socket({writable:!1});return m.readable=!0,e.once("socket",e=>{Jr("replaying proxy buffer for failed request"),Wr.default(e.listenerCount("data")>0),e.push(d),e.push(null)}),m})}}},"__esModule",{value:!0}));function Yr(e){return new Kr.default(e)}!function(e){e.HttpsProxyAgent=Kr.default,e.prototype=Kr.default.prototype}(Yr||(Yr={}));var Zr,Xr,Qr,ea,ta=Yr,na=function(){if(!Zr){try{Zr=$r("follow-redirects")}catch(e){}"function"!=typeof Zr&&(Zr=function(){})}Zr.apply(null,arguments)},oa=xe.URL,ia=ge.Writable;Xr="undefined"!=typeof process,Qr="undefined"!=typeof window&&"undefined"!=typeof document,ea=Ea(Error.captureStackTrace),Xr||!Qr&&ea||console.warn("The follow-redirects package should be excluded from browser builds.");var ra=!1;try{Se(new oa(""))}catch(e){ra="ERR_INVALID_URL"===e.code}var aa=["Authorization","Proxy-Authorization","Cookie"],sa=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],ca=["abort","aborted","connect","error","socket","timeout"],la=Object.create(null);ca.forEach(function(e){la[e]=function(t,n,o){this._redirectable.emit(e,t,n,o)}});var pa=ja("ERR_INVALID_URL","Invalid URL",TypeError),ua=ja("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),da=ja("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",ua),ma=ja("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),fa=ja("ERR_STREAM_WRITE_AFTER_END","write after end"),ha=ia.prototype.destroy||ba;function ga(e,t){ia.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 ua?e:new ua({cause:e}))}},this._headerFilter=new RegExp("^(?:"+aa.concat(e.sensitiveHeaders).map(Ta).join("|")+")$","i"),this._performRequest()}function va(e){var t={maxRedirects:21,maxBodyLength:10485760},n={};return Object.keys(e).forEach(function(o){var i=o+":",r=n[i]=e[o],a=t[o]=Object.create(r);Object.defineProperties(a,{request:{value:function(e,o,r){return oa&&e instanceof oa?e=wa(e):Sa(e)?e=wa(ya(e)):(r=o,o=xa(e),e={protocol:i}),Ea(o)&&(r=o,o=null),(o=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,o)).nativeProtocols=n,Sa(o.host)||Sa(o.hostname)||(o.hostname="::1"),Se.equal(o.protocol,i,"protocol mismatch"),na("options",o),new ga(o,r)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,n){var o=a.request(e,t,n);return o.end(),o},configurable:!0,enumerable:!0,writable:!0}})}),t}function ba(){}function ya(e){var t;if(ra)t=new oa(e);else if(!Sa((t=xa(xe.parse(e))).protocol))throw new pa({input:e});return t}function xa(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new pa({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new pa({input:e.href||e});return e}function wa(e,t){var n=t||{};for(var o of sa)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 _a(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 ja(e,t,n){function o(n){Ea(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 ka(e,t){for(var n of ca)e.removeListener(n,la[n]);e.on("error",ba),e.destroy(t)}function Sa(e){return"string"==typeof e||e instanceof String}function Ea(e){return"function"==typeof e}function Ta(e){return e.replace(/[\]\\/()*+?.$]/g,"\\$&")}(ga.prototype=Object.create(ia.prototype)).abort=function(){ka(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},ga.prototype.destroy=function(e){return ka(this._currentRequest,e),ha.call(this,e),this},ga.prototype.write=function(e,t,n){if(this._ending)throw new fa;if(!(Sa(e)||"object"==typeof(o=e)&&"length"in o))throw new TypeError("data should be a string, Buffer or Uint8Array");var o;Ea(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 ma),this.abort()):n&&n()},ga.prototype.end=function(e,t,n){if(Ea(e)?(n=e,e=t=null):Ea(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)},ga.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},ga.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},ga.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"),r()},e),o(t)}function r(){n._timeout&&(clearTimeout(n._timeout),n._timeout=null),n.removeListener("abort",r),n.removeListener("error",r),n.removeListener("response",r),n.removeListener("close",r),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",r),this.on("error",r),this.on("response",r),this.on("close",r),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){ga.prototype[e]=function(t,n){return this._currentRequest[e](t,n)}}),["aborted","connection","socket"].forEach(function(e){Object.defineProperty(ga.prototype,e,{get:function(){return this._currentRequest[e]}})}),ga.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))}},ga.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,ca))o.on(i,la[i]);if(this._currentUrl=/^\//.test(this._options.path)?xe.format(this._options):this._options.path,this._isRedirect){var r=0,a=this,s=this._requestBodyBuffers;!function e(t){if(o===a._currentRequest)if(t)a.emit("error",t);else if(r<s.length){var n=s[r++];o.finished||o.write(n.data,n.encoding,e)}else a._ended&&o.end()}()}},ga.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(ka(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new da;var i=this._options.beforeRedirect;i&&(n=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var r=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=[],_a(/^content-/i,this._options.headers));var a=_a(/^host$/i,this._options.headers),s=ya(this._currentUrl),c=a||s.host,l=/^\w+:/.test(o)?this._currentUrl:xe.format(Object.assign(s,{host:c})),p=function(e,t){return ra?new oa(e,t):ya(xe.resolve(t,e))}(o,l);na("redirecting to",p.href),this._isRedirect=!0,wa(p,this._options),(p.protocol!==s.protocol&&"https:"!==p.protocol||p.host!==c&&!function(e,t){Se(Sa(e)&&Sa(t));var n=e.length-t.length-1;return n>0&&"."===e[n]&&e.endsWith(t)}(p.host,c))&&_a(this._headerFilter,this._options.headers),Ea(i)&&(i(this._options,{headers:e.headers,statusCode:t},{url:l,method:r,headers:n}),this._sanitizeOptions(this._options)),this._performRequest()};var $a=va({http:be,https:ye});$a.wrap=va;const Ia="1.19.0";function Aa(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}const Oa=/^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/,Ca=["content-type","content-length"];function Na(e,t,n){"content-only"===n?Object.entries(t||{}).forEach(([t,n])=>{Ca.includes(t.toLowerCase())&&e.set(t,n)}):e.set(t)}const Ra=Symbol("internals");var Pa=class extends ge.Transform{constructor(e){super({readableHighWaterMark:(e=gn.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!gn.isUndefined(t[e]))).chunkSize});const t=this[Ra]={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[Ra];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){const o=this[Ra],i=o.maxRate,r=this.readableHighWaterMark,a=o.timeWindow,s=i/(1e3/a),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=r,m=0;if(i){const e=Date.now();(!o.ts||(m=e-o.ts)>=a)&&(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)},a-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:Ua}=Symbol;var La=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Ua]?yield*e[Ua]():yield e};const za=Ki.ALPHABET.ALPHA_DIGIT+"-_",Fa="function"==typeof TextEncoder?new TextEncoder:new he.TextEncoder,Da="\r\n",qa=Fa.encode(Da);class Ba{constructor(e,t){const{escapeName:n}=this.constructor,o=gn.isString(t);let i=`Content-Disposition: form-data; name="${n(e)}"${!o&&t.name?`; filename="${n(t.name)}"`:""}${Da}`;o?t=Fa.encode(String(t).replace(/\r?\n|\r\n?/g,Da)):i+=`Content-Type: ${String(t.type||"application/octet-stream").replace(/[\r\n]/g,"")}${Da}`,this.headers=Fa.encode(i+Da),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;gn.isTypedArray(e)?yield e:yield*La(e),yield qa}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}var Ma=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)}},Wa=(e,t)=>gn.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 Ga=new Set(["localhost","0.0.0.0"]),Ha=e=>{const t=e.split(".");return 4===t.length&&"127"===t[0]&&t.every(e=>/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255)},Ja=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},Va=e=>/^0{1,4}$/.test(e),Ka=e=>!!e&&(!!Ga.has(e)||!!Ha(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(":"):[],r=o?o.split(":"):[];return i.length+r.length<8&&i.every(Va)&&r.every(Va)}const n=e.split(":");return 8===n.length&&n.every(Va)})(e)||(e=>{if("::1"===e)return!0;const t=e.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);if(t)return Ha(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)),Ya={http:80,https:443,ws:80,wss:443,ftp:21},Za=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i,Xa=/^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i,Qa=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(Ja);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,r=Ja(n[n.length-1]);if(null===r)return e;if(r<0||r>(1<<8*i)-1)return e;const a=new Array(i).fill(0);for(let e=i-1,t=r;e>=0;e--,t>>=8)a[e]=255&t;const s=o.map(Ja);return s.some(e=>null===e||e<0||e>255)?e:[...s,...a].join(".")})(t);return n!==t?n:(e=>{if("string"!=typeof e||-1===e.indexOf(":"))return e;const t=e.match(Za);if(t)return t[1];const n=e.match(Xa);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)},es=(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,r=0,a=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),l=o[a];i||(i=c),n[r]=s,o[r]=c;let p=a,u=0;for(;p!==r;)u+=n[p++],p%=e;if(r=(r+1)%e,r===a&&(a=(a+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,r){let a,s,c=0,l=1e3/r;const p=(n,r=Date.now())=>{c=r,a=null,s&&(clearTimeout(s),s=null),(n=>{if(!n||"number"!=typeof n.loaded)return;const r=n.loaded,a=n.lengthComputable?n.total:void 0,s=Math.max(0,null!=a?Math.min(r,a):r),c=Math.max(0,s-o),l=i(c);o=Math.max(o,s),e({loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a?(a-s)/l:void 0,event:n,lengthComputable:null!=a,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-c;n>=l?p(e,t):(a=e,s||(s=setTimeout(()=>{s=null,p(a)},l-n)))},()=>a&&p(a)]}(0,n)},ts=(e,t)=>{const n=null!=e;return[o=>t[0]({lengthComputable:n,total:e,loaded:o}),t[1]]},ns=(e,t=gn.asap)=>(...n)=>t(()=>e(...n)),os=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,is=(e,t,n)=>t+2<n&&os(e.charCodeAt(t+1))&&os(e.charCodeAt(t+2)),rs=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,ss=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)},cs=e=>{const t=e.length;let n=0,o=0,i=!1;for(let a=0;a<t;a++){let s=e.charCodeAt(a);37===s&&is(e,a,t)&&(s=16*rs(e.charCodeAt(a+1))+rs(e.charCodeAt(a+2)),a+=2),9!==(r=s)&&10!==r&&12!==r&&13!==r&&32!==r&&(61!==s?!as(s)||o>0?i=!0:n++:o++)}var r;return i||o>2||o>0&&(n+o)%4!=0||n%4==1?ss(e):(e=>{const t=e%4;return 3*Math.floor(e/4)+(2===t?1:3===t?2:0)})(n)},ls=(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 r=0;for(let e=0,t=i.length;e<t;e++){const n=i.charCodeAt(e);if(37===n&&is(i,e,t))r+=1,e+=2;else if(n<128)r+=1;else if(n<2048)r+=2;else if(n>=55296&&n<=56319&&e+1<t){const t=i.charCodeAt(e+1);t>=56320&&t<=57343?(r+=4,e++):r+=3}else r+=3}return r},ps={flush:Ne.constants.Z_SYNC_FLUSH,finishFlush:Ne.constants.Z_SYNC_FLUSH},us={flush:Ne.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ne.constants.BROTLI_OPERATION_FLUSH},ds={flush:Ne.constants.ZSTD_e_flush,finishFlush:Ne.constants.ZSTD_e_flush},ms=gn.isFunction(Ne.createBrotliDecompress),fs=gn.isFunction(Ne.createZstdDecompress),hs="gzip, compress, deflate"+(ms?", br":""),gs=hs+(fs?", zstd":""),vs="undefined"!=typeof process&&process.nextTick?process.nextTick.bind(process):gn.asap,{http:bs,https:ys}=$a,xs=/https:?/,ws=Symbol("axios.http.socketListener"),_s=Symbol("axios.http.currentReq"),js=Symbol("axios.http.installedTunnel"),ks=new Map,Ss=new WeakMap,Es={22:21,24:5},Ts=Ki.protocols.map(e=>e+":"),$s=e=>{if(!gn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Is=(e,[t,n])=>(e.on("end",n).on("error",n),t),As=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,r;const a=()=>{if(i)return;i=!0,r&&(clearTimeout(r),r=null);let t=n,a=t.length,s=a;for(;s--;)if(t[s][0]===o)return 1===a?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++,r&&(clearTimeout(r),r=null),t.once("close",()=>{--e||(r=setTimeout(()=>{r=null,a()},c))}),t}}o.once("close",a);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 Cs(e,t,n,o,i,r){let a=t;const s=function(e,t,n){return xs.test(e.protocol)?n||ye.globalAgent:t||be.globalAgent}(e,r,i);if(!a&&!1!==a&&!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!=Es[t]&&n>=Es[t])}(t))return!1;const n=e&&e.options;return Boolean(n&&gn.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=ur("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,r=o?parseInt(o[2]):0;return!(!r||r===t)||(/^[.*]/.test(i)?("*"===i.charAt(0)&&(i=i.slice(1)),!e.endsWith(i)):e!==i)})}(o=o.replace(/:\d*$/,""),i=parseInt(i)||pr[n]||0))return"";var r=ur(n+"_proxy")||ur("all_proxy");return r&&-1===r.indexOf("://")&&(r=n+"://"+r),r}(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)||Ya[t.protocol.split(":",1)[0]]||0,i=Qa(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=Qa(t),!!t&&(!n||n===o)&&("*"===t.charAt(0)&&(t=t.slice(1)),"."===t.charAt(0)?i.endsWith(t):i===t||Ka(i)&&Ka(t))})}(n)||(a=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[js]&&(e.agent=void 0),a){const t=a instanceof URL,o=e=>t||gn.hasOwnProp(a,e)?a[e]:void 0,r=o("username"),s=o("password");let c=gn.hasOwnProp(a,"auth")?a.auth:void 0;if(r&&(c=(r||"")+":"+(s||"")),c){const e="object"==typeof c,t=e&&gn.hasOwnProp(c,"username")?c.username:void 0,n=e&&gn.hasOwnProp(c,"password")?c.password:void 0;if(Boolean(t||n))c=(t||"")+":"+(n||"");else if(e)throw new Cn("Invalid proxy authorization",Cn.ERR_BAD_OPTION,{proxy:a})}if(xs.test(e.protocol)){if(!(i instanceof ta)){const t=o("hostname")||o("host"),n=o("port"),r=o("protocol"),a=r?r.includes(":")?r:`${r}:`:"http:",s=t&&t.includes(":")&&!t.startsWith("[")?`[${t}]`:t,l=new URL(`${a}//${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?Ss.get(t)||Ss.set(t,new Map).get(t):ks;let i=o.get(n);if(i)return i;const r=t&&t.options?{...t.options,...e}:e;if(i=new ta(r),t&&t.options){const e={...t.options},n=i.callback;i.callback=function(t,o){return n.call(this,t,{...e,...o})}}return i[js]=!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 r=o("protocol");r&&(e.protocol=r.includes(":")?r:`${r}:`)}}e.beforeRedirects.proxy=function(e){Cs(e,t,e.href,!0,i,r)}}const Ns="undefined"!=typeof process&&"process"===gn.kindOf(process),Rs=(e,t)=>(({address:e,family:t})=>{if(!gn.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(gn.isObject(e)?e:{address:e,family:t}),Ps={request(e,t){const n=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:o,headers:i}=e,r=As.getSession(n,o),{HTTP2_HEADER_SCHEME:a,HTTP2_HEADER_METHOD:s,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:l}=Ce.constants,p={[a]:e.protocol.replace(":",""),[s]:e.method,[c]:e.path};gn.forEach(i,(e,t)=>{":"!==t.charAt(0)&&(p[t]=e)});const u=r.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 Us,Ls,zs=Ns&&function(e){return t=async function(t,n,o){const i=t=>gn.getSafeProp(e,t),r=i("transitional")||Di;let a=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"),y=i("maxBodyLength"),x=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 T=2===l;if(s){const e=Wa(s,e=>gn.isArray(e)?e:[e]);s=(t,n,o)=>{e(t,n,(e,t,i)=>{if(e)return o(e);const r=gn.isArray(t)?t.map(e=>Rs(e)):[Rs(t,i)];n.all?o(e,r):o(e,r[0].address,r[0].family)})}}const $=new Oe;function I(t){try{$.emit("abort",!t||t.type?new ir(null,e,k):t)}catch(e){}}function A(){S&&(clearTimeout(S),S=null)}$.once("abort",n);const O=()=>{A(),e.cancelToken&&e.cancelToken.unsubscribe(I),e.signal&&e.signal.removeEventListener("abort",I),$.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,A(),t)return E=!0,void O();const{data:n}=e;if(n instanceof ge.Readable||n instanceof ge.Duplex){const e=ge.finished(n,()=>{e(),O()})}else O()});const C=lr(i("baseURL"),i("url"),i("allowAbsoluteUrls"),e),N=new URL(C,g?"http://localhost":Ki.hasBrowserEnv?Ki.origin:void 0),R=N.protocol||Ts[0];if("data:"===R){if(x>-1){const t=function(e){return ls(e,ss)}(String(i("url")||C||""));if(t>x)return n(new Cn("maxContentLength size of "+x+" exceeded",Cn.ERR_BAD_RESPONSE,e))}let o;if("GET"!==v)return rr(t,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{o=function(e,t,n){const o=n&&n.Blob||Ki.classes.Blob,i=Aa(e);if(void 0===t&&o&&(t=!0),"data"===i){e=i.length?e.slice(i.length+1):e;const n=Oa.exec(e);if(!n)throw new Cn("Invalid URL",Cn.ERR_INVALID_URL);const r=n[1],a=n[2],s=n[3]?"base64":"utf8",c=n[4];let l="";r?l=a?r+a:r:a&&(l="text/plain"+a);const p="base64"===s?Buffer.from(c,"base64"):Buffer.from(decodeURIComponent(c),s);if(t){if(!o)throw new Cn("Blob is not supported",Cn.ERR_NOT_SUPPORT);return new o([p],{type:l})}return p}throw new Cn("Unsupported protocol "+i,Cn.ERR_NOT_SUPPORT)}(i("url"),"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw Cn.from(t,Cn.ERR_BAD_REQUEST,e)}return"text"===f?(o=o.toString(h),h&&"utf8"!==h||(o=gn.stripBOM(o))):"stream"===f&&(o=ge.Readable.from(o)),rr(t,n,{data:o,status:200,statusText:"OK",headers:new In,config:e})}if(-1===Ts.indexOf(R))return n(new Cn("Unsupported protocol "+R,Cn.ERR_BAD_REQUEST,e));const P=In.from(e.headers).normalize();P.set("User-Agent","axios/"+Ia,!1);const{onUploadProgress:U,onDownloadProgress:L}=e,z=e.maxRate;let F,D;if(gn.isSpecCompliantForm(a)){const e=P.getContentType(/boundary=([-_\w\d]{10,70})/i);a=((e,t,n)=>{const{tag:o="form-data-boundary",size:i=25,boundary:r=o+"-"+Ki.generateString(i,za)}=n||{};if(!gn.isFormData(e))throw new TypeError("FormData instance required");if(r.length<1||r.length>70)throw new Error("boundary must be 1-70 characters long");const a=Fa.encode("--"+r+Da),s=Fa.encode("--"+r+"--"+Da);let c=s.byteLength;const l=Array.from(e.entries()).map(([e,t])=>{const n=new Ba(e,t);return c+=n.size,n});c+=a.byteLength*l.length,c=gn.toFiniteNumber(c);const p={"Content-Type":`multipart/form-data; boundary=${r}`};return Number.isFinite(c)&&(p["Content-Length"]=c),t&&t(p),ve.from(async function*(){for(const e of l)yield a,yield*e.encode();yield s}())})(a,e=>{P.set(e)},{tag:`axios-${Ia}-boundary`,boundary:e&&e[1]||void 0})}else if(gn.isFormData(a)&&gn.isFunction(a.getHeaders)&&a.getHeaders!==Object.prototype.getHeaders){if(Na(P,a.getHeaders(),i("formDataHeaderPolicy")),!P.hasContentLength())try{const e=await he.promisify(a.getLength).call(a);Number.isFinite(e)&&e>=0&&P.setContentLength(e)}catch(e){}}else if(gn.isBlob(a)||gn.isFile(a))a.size&&P.setContentType(a.type||"application/octet-stream"),P.setContentLength(a.size||0),a=ge.Readable.from(La(a));else if(a&&!gn.isStream(a)){if(Buffer.isBuffer(a));else if(gn.isArrayBuffer(a))a=Buffer.from(new Uint8Array(a));else{if(!gn.isString(a))return n(new Cn("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Cn.ERR_BAD_REQUEST,e));a=Buffer.from(a,"utf-8")}if(P.setContentLength(a.length,!1),y>-1&&a.length>y)return n(new Cn("Request body larger than maxBodyLength limit",Cn.ERR_BAD_REQUEST,e))}const q=gn.toFiniteNumber(P.getContentLength());let B;gn.isArray(z)?(F=z[0],D=z[1]):F=D=z,a&&(U||F)&&(gn.isStream(a)||(a=ge.Readable.from(a,{objectMode:!1})),a=ge.pipeline([a,new Pa({maxRate:gn.toFiniteNumber(F)})],gn.noop),U&&a.on("progress",Is(a,ts(q,es(ns(U,vs),!1,3)))));const M=i("auth");let W;M&&(B=(gn.getSafeProp(M,"username")||"")+":"+(gn.getSafeProp(M,"password")||"")),B||!N.username&&!N.password||(B=$s(N.username)+":"+$s(N.password)),B&&P.delete("authorization");try{W=zi(N.pathname+N.search,i("params"),i("paramsSerializer")).replace(/^\?/,"")}catch(t){return n(Cn.from(t,Cn.ERR_BAD_REQUEST,e,null,null,{url:i("url"),exists:!0}))}P.set("Accept-Encoding",gn.hasOwnProp(r,"advertiseZstdAcceptEncoding")&&!0===r.advertiseZstdAcceptEncoding?gs:hs,!1);const G=Object.assign(Object.create(null),{path:W,method:v,headers:wn(P),agents:{http:u,https:d},auth:B,protocol:R,family:c,beforeRedirect:Os,beforeRedirects:Object.create(null),http2Options:p});if(!gn.isUndefined(s)&&(G.lookup=s),g){if("string"!=typeof g)return n(new Cn("socketPath must be a string",Cn.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 Cn(`socketPath "${g}" is not permitted by allowedSocketPaths`,Cn.ERR_BAD_OPTION_VALUE,e))}G.socketPath=g}else G.hostname=N.hostname.startsWith("[")?N.hostname.slice(1,-1):N.hostname,G.port=N.port,Cs(G,m,R+"//"+N.hostname+(N.port?":"+N.port:"")+G.path,!1,d,u);let H,J=!1,V=!1;const K=xs.test(G.protocol);if(null==G.agent&&(G.agent=K?d:u),T)H=Ps;else{const t=i("transport");if(t)H=t;else if(0===b)H=K?ye:be,J=!0;else{V=!0,G.sensitiveHeaders=[],b&&(G.maxRedirects=b);const t=i("beforeRedirect");if(t&&(G.beforeRedirects.config=t),B){const e=N.origin,t=B;G.beforeRedirects.auth=function(n){try{new URL(n.href).origin===e&&(n.auth=t)}catch(e){}}}const o=i("sensitiveHeaders");if(null!=o){if(!gn.isArray(o))return n(new Cn("sensitiveHeaders must be an array of strings",Cn.ERR_BAD_OPTION_VALUE,e));const t=new Set;for(const i of o){if(!gn.isString(i))return n(new Cn("sensitiveHeaders must be an array of strings",Cn.ERR_BAD_OPTION_VALUE,e));t.add(i.toLowerCase())}t.size&&(G.sensitiveHeaders=Array.from(t),G.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)})}H=K?ys:bs}}G.maxBodyLength=y>-1?y:Infinity,G.insecureHTTPParser=Boolean(i("insecureHTTPParser")),k=H.request(G,function(o){if(A(),k.destroyed)return;const i=[o],r=gn.toFiniteNumber(o.headers["content-length"]);if(L||D){const e=new Pa({maxRate:gn.toFiniteNumber(D)});L&&e.on("progress",Is(e,ts(r,es(ns(L,vs),!0,3)))),i.push(e)}let a=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(Ne.createUnzip(ps)),delete o.headers["content-encoding"];break;case"deflate":i.push(new Ma),i.push(Ne.createUnzip(ps)),delete o.headers["content-encoding"];break;case"br":ms&&(i.push(Ne.createBrotliDecompress(us)),delete o.headers["content-encoding"]);break;case"zstd":fs&&(i.push(Ne.createZstdDecompress(ds)),delete o.headers["content-encoding"])}a=i.length>1?ge.pipeline(i,gn.noop):i[0];const c={status:o.statusCode,statusText:o.statusMessage,headers:new In(o.headers),config:e,request:s};if("stream"===f){if(x>-1){const t=x,n=a;a=ge.Readable.from(async function*(){let o=0;for await(const i of n){if(o+=i.length,o>t)throw new Cn("maxContentLength size of "+t+" exceeded",Cn.ERR_BAD_RESPONSE,e,s);yield i}}(),{objectMode:!1})}c.data=a,rr(t,n,c)}else{const o=[];let i=0;a.on("data",function(t){o.push(t),i+=t.length,x>-1&&i>x&&(E=!0,a.destroy(),I(new Cn("maxContentLength size of "+x+" exceeded",Cn.ERR_BAD_RESPONSE,e,s)))}),a.on("aborted",function(){if(E)return;const t=new Cn("stream has been aborted",Cn.ERR_BAD_RESPONSE,e,s,c);a.destroy(t),n(t)}),a.on("error",function(t){E||n(Cn.from(t,null,e,s,c))}),a.on("end",function(){try{let e=1===o.length?o[0]:Buffer.concat(o);"arraybuffer"!==f&&(e=e.toString(h),h&&"utf8"!==h||(e=gn.stripBOM(e))),c.data=e}catch(t){return n(Cn.from(t,null,e,c.request,c))}rr(t,n,c)})}$.once("abort",e=>{a.destroyed||(a.emit("error",e),a.destroy())})}),$.once("abort",e=>{k.close?k.close():k.destroy(e)}),k.on("error",function(t){n(Cn.from(t,null,e,k))});const Y=new Set;if(k.on("socket",function(e){"function"==typeof e.setKeepAlive&&e.setKeepAlive(!0,6e4),e[ws]||(e.on("error",function(t){const n=e[_s];n&&!n.destroyed&&n.destroy(t)}),e[ws]=!0),e[_s]=k,Y.add(e)}),k.once("close",function(){A();for(const e of Y)e[_s]===k&&(e[_s]=null);Y.clear()}),i("timeout")){const t=parseInt(i("timeout"),10);if(Number.isNaN(t))return void I(new Cn("error trying to parse `config.timeout` to int",Cn.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 Cn(n,r.clarifyTimeoutError?Cn.ETIMEDOUT:Cn.ECONNABORTED,e,k)}())};J&&t>0&&(S=setTimeout(n,t)),k.setTimeout(t,n)}else k.setTimeout(0);if(gn.isStream(a)){let t=!1,n=!1;a.on("end",()=>{t=!0}),a.once("error",e=>{n=!0,k.destroy(e)}),a.on("close",()=>{t||n||I(new ir("Request stream has been aborted",e,k))});let o=a;if(y>-1&&!V){const t=y;let n=0;o=ge.pipeline([a,new ge.Transform({transform(o,i,r){if(n+=o.length,n>t)return r(new Cn("Request body larger than maxBodyLength limit",Cn.ERR_BAD_REQUEST,e,k));r(null,o)}})],gn.noop),o.on("error",e=>{k.destroyed||k.destroy(e)})}o.pipe(k)}else a&&k.write(a),k.end()},new Promise((e,n)=>{let o,i;const r=(e,t)=>{i||(i=!0,o&&o(e,t))},a=e=>{r(e,!0),n(e)};t(t=>{r(t),e(t)},a,e=>o=e).catch(a)});var t},Fs=Ki.hasStandardBrowserEnv?(Us=new URL(Ki.origin),Ls=Ki.navigator&&/(msie|trident)/i.test(Ki.navigator.userAgent),e=>(e=new URL(e,Ki.origin),Us.protocol===e.protocol&&Us.host===e.host&&(Ls||Us.port===e.port))):()=>!0,Ds=Ki.hasStandardBrowserEnv?{write(e,t,n,o,i,r,a){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];gn.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),gn.isString(o)&&s.push(`path=${o}`),gn.isString(i)&&s.push(`domain=${i}`),!0===r&&s.push("secure"),gn.isString(a)&&s.push(`SameSite=${a}`),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 qs=e=>e instanceof In?{...e}:e,Bs=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Ms(e,t){e=e||{},t=t||{};const n=Object.create(null);function o(e,t,n,o){return gn.isPlainObject(e)&&gn.isPlainObject(t)?gn.merge.call({caseless:o},e,t):gn.isPlainObject(t)?gn.merge({},t):gn.isArray(t)?t.slice():t}function i(e,t,n,i){return gn.isUndefined(t)?gn.isUndefined(e)?void 0:o(void 0,e,0,i):o(e,t,0,i)}function r(e,t){if(!gn.isUndefined(t))return o(void 0,t)}function a(e,t){return gn.isUndefined(t)?gn.isUndefined(e)?void 0:o(void 0,e):o(void 0,t)}function s(n,i,r){return gn.hasOwnProp(t,r)?o(n,i):gn.hasOwnProp(e,r)?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:r,method:r,data:r,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,allowedSocketPaths:a,responseEncoding:a,validateStatus:s,headers:(e,t,n)=>i(qs(e),qs(t),0,!0)};return gn.forEach(Bs({...e,...t}),function(o){if("__proto__"===o||"constructor"===o||"prototype"===o)return;const r=gn.hasOwnProp(c,o)?c[o]:i,a=r(gn.hasOwnProp(e,o)?e[o]:void 0,gn.hasOwnProp(t,o)?t[o]:void 0,o);gn.isUndefined(a)&&r!==s||(n[o]=a)}),gn.hasOwnProp(t,"validateStatus")&&gn.isUndefined(t.validateStatus)&&!1===function(n){const o=gn.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!gn.isUndefined(o)){if(!gn.isPlainObject(o))return;if(gn.hasOwnProp(o,n))return o[n]}const i=gn.hasOwnProp(e,"transitional")?e.transitional:void 0;if(gn.isPlainObject(i)&&gn.hasOwnProp(i,n))return i[n]}("validateStatusUndefinedResolves")&&(gn.hasOwnProp(e,"validateStatus")?n.validateStatus=o(void 0,e.validateStatus):delete n.validateStatus),n}function Ws(e){const t=Ms({},e),n=e=>gn.hasOwnProp(t,e)?t[e]:void 0,o=n("data");let i=n("withXSRFToken");const r=n("xsrfHeaderName"),a=n("xsrfCookieName");let s=n("headers");const c=n("auth"),l=n("baseURL"),p=n("allowAbsoluteUrls"),u=n("url");if(t.headers=s=In.from(s),t.url=zi(lr(l,u,p,t),n("params"),n("paramsSerializer")),c){const t=gn.getSafeProp(c,"username")||"",n=gn.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 Cn.from(t,Cn.ERR_BAD_OPTION_VALUE,e)}}if(gn.isFormData(o)&&(Ki.hasStandardBrowserEnv||Ki.hasStandardBrowserWebWorkerEnv||gn.isReactNative(o)?s.setContentType(void 0):gn.isFunction(o.getHeaders)&&Na(s,o.getHeaders(),n("formDataHeaderPolicy"))),Ki.hasStandardBrowserEnv&&(gn.isFunction(i)&&(i=i(t)),!0===i||null==i&&Fs(t.url))){const e=r&&a&&Ds.read(a);e&&s.set(r,e)}return t}var Gs="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const o=Ws(e);let i=o.data;const r=In.from(o.headers).normalize();let a,s,c,l,p,{responseType:u,onUploadProgress:d,onDownloadProgress:m}=o;function f(){l&&l(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(a),o.signal&&o.signal.removeEventListener("abort",a)}let h=new XMLHttpRequest;function g(){if(!h)return;const o=In.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());rr(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 Cn("Request aborted",Cn.ECONNABORTED,e,h)),f(),h=null)},h.onerror=function(t){const o=new Cn(t&&t.message?t.message:"Network Error",Cn.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 Cn(t,(o.transitional||Di).clarifyTimeoutError?Cn.ETIMEDOUT:Cn.ECONNABORTED,e,h)),f(),h=null},void 0===i&&r.setContentType(null),"setRequestHeader"in h&&gn.forEach(wn(r),function(e,t){h.setRequestHeader(t,e)}),gn.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),u&&"json"!==u&&(h.responseType=o.responseType),m&&([c,p]=es(m,!0),h.addEventListener("progress",c)),d&&h.upload&&([s,l]=es(d),h.upload.addEventListener("progress",s),h.upload.addEventListener("loadend",l)),(o.cancelToken||o.signal)&&(a=t=>{h&&(n(!t||t.type?new ir(null,e,h):t),h.abort(),f(),h=null)},o.cancelToken&&o.cancelToken.subscribe(a),o.signal&&(o.signal.aborted?a():o.signal.addEventListener("abort",a)));const v=Aa(o.url);if(v&&!Ki.protocols.includes(v))return n(new Cn("Unsupported protocol "+v+":",Cn.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,a();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Cn?t:new ir(t instanceof Error?t.message:t))}};let r=t&&setTimeout(()=>{r=null,i(new Cn(`timeout of ${t}ms exceeded`,Cn.ETIMEDOUT))},t);const a=()=>{e&&(r&&clearTimeout(r),r=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=()=>gn.asap(a),s};const Js=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},Vs=(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*Js(n,t)}(e,t);let r,a=0,s=e=>{r||(r=!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=a+=o.byteLength;n(e)}e.enqueue(new Uint8Array(o))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},{isFunction:Ks}=gn,Ys=e=>{if(!gn.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},Zs=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Xs=e=>{const t=null!=gn.global?gn.global:globalThis,{ReadableStream:n,TextEncoder:o}=t;e=gn.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:i,Request:r,Response:a}=e,s=i?Ks(i):"function"==typeof fetch,c=Ks(r),l=Ks(a);if(!s)return!1;const p=s&&Ks(n),u=s&&("function"==typeof o?(d=new o,e=>d.encode(e)):async e=>new Uint8Array(await new r(e).arrayBuffer()));var d;const m=c&&p&&Zs(()=>{let e=!1;const t=new r(Ki.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&&Zs(()=>gn.isReadableStream(new a("").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 Cn(`Response type '${e}' is not supported`,Cn.ERR_NOT_SUPPORT,n)})});const g=async e=>{if(null==e)return 0;if(gn.isBlob(e))return e.size;if(gn.isSpecCompliantForm(e)){const t=new r(Ki.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return gn.isArrayBufferView(e)||gn.isArrayBuffer(e)?e.byteLength:(gn.isURLSearchParams(e)&&(e+=""),gn.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:y,headers:x,withCredentials:w="same-origin",fetchOptions:_,maxContentLength:j,maxBodyLength:k}=Ws(e);const S=gn.isNumber(j)&&j>-1,E=gn.isNumber(k)&&k>-1;let T=i||fetch;y=y?(y+"").toLowerCase():"text";let $=Hs([l,u&&u.toAbortSignal()],d),I=null;const A=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let O,C=null;const N=()=>new Cn("Request body larger than maxBodyLength limit",Cn.ERR_BAD_REQUEST,e,I);try{let i;const l=gn.hasOwnProp(e,"auth")?e.auth:void 0;if(l&&(i={username:gn.getSafeProp(l,"username")||"",password:gn.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,Ki.origin);i||!e.username&&!e.password||(i={username:Ys(e.username),password:Ys(e.password)}),(e.username||e.password)&&(e.username="",e.password="",t=e.href)}if(i&&(x.delete("authorization"),x.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 ls(-1===t?e:e.slice(0,t),cs)}(t);if(n>j)throw new Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I)}if(E&&"get"!==n&&"head"!==n){const e=await g(s);if("number"==typeof e&&isFinite(e)&&(O=e,e>k))throw N()}const u=E&&(gn.isReadableStream(s)||gn.isStream(s)),d=(e,t,n)=>Vs(e,65536,e=>{if(E&&e>k)throw C=N();t&&t(e)},n);if(m&&"get"!==n&&"head"!==n&&(b||u)){if(O=null==O?await(async(e,t)=>{const n=gn.toFiniteNumber(e.getContentLength());return null==n?g(t):n})(x,s):O,0!==O||u){let e,n=new r(t,{method:"POST",body:s,duplex:"half"});if(gn.isFormData(s)&&(e=n.headers.get("content-type"))&&x.setContentType(e),n.body){const[e,t]=b&&ts(O,es(ns(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 Cn("Stream request bodies are not supported by the current fetch implementation",Cn.ERR_NOT_SUPPORT,e,I);gn.isString(w)||(w=w?"include":"omit");const R=c&&"credentials"in r.prototype;if(gn.isFormData(s)){const e=x.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&x.delete("content-type")}x.set("User-Agent","axios/"+Ia,!1);const P={..._,signal:$,method:n.toUpperCase(),headers:wn(x.normalize()),body:s,duplex:"half",credentials:R?w:void 0};I=c&&new r(t,P);let U=await(c?T(I,_):T(t,P));const L=In.from(U.headers);if(S){const t=gn.toFiniteNumber(L.getContentLength());if(null!=t&&t>j)throw new Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I)}const z=f&&("stream"===y||"response"===y);if(f&&U.body&&(v||S||z&&A)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=U[e]});const n=gn.toFiniteNumber(L.getContentLength()),[o,i]=v&&ts(n,es(ns(v),!0))||[];let r=0;U=new a(Vs(U.body,65536,t=>{if(S&&(r=t,r>j))throw new Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I);o&&o(t)},()=>{i&&i(),A&&A()}),t)}y=y||"text";let F=await h[gn.findKey(h,y)||"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 Cn("maxContentLength size of "+j+" exceeded",Cn.ERR_BAD_RESPONSE,e,I)}return!z&&A&&A(),await new Promise((t,n)=>{rr(t,n,{data:F,headers:In.from(U.headers),status:U.status,statusText:U.statusText,config:e,request:I})})}catch(t){if(A&&A(),$&&$.aborted&&$.reason instanceof Cn){const n=$.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 Cn)throw I&&!t.request&&(t.request=I),t;if(t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message)){const n=new Cn("Network Error",Cn.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 Cn.from(t,t&&t.code,e,I,t&&t.response)}}},Qs=new Map,ec=e=>{let t=e&&e.env||{};const{fetch:n,Request:o,Response:i}=t,r=[o,i,n];let a,s,c=r.length,l=Qs;for(;c--;)a=r[c],s=l.get(a),void 0===s&&l.set(a,s=c?new Map:Xs(t)),l=s;return s};ec();const tc={http:zs,xhr:Gs,fetch:{get:ec}};gn.forEach(tc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch(e){}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const nc=e=>`- ${e}`,oc=e=>gn.isFunction(e)||null===e||!1===e;var ic=function(e,t){e=gn.isArray(e)?e:[e];const{length:n}=e;let o,i;const r={};for(let a=0;a<n;a++){let n;if(o=e[a],i=o,!oc(o)&&(i=tc[(n=String(o)).toLowerCase()],void 0===i))throw new Cn(`Unknown adapter '${n}'`);if(i&&(gn.isFunction(i)||(i=i.get(t))))break;r[n||"#"+a]=i}if(!i){const e=Object.entries(r).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(nc).join("\n"):" "+nc(e[0]):"as no adapter specified";throw new Cn("There is no suitable adapter to dispatch the request "+t,Cn.ERR_NOT_SUPPORT)}return i};function rc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ir(null,e)}function ac(e){return rc(e),e.headers=In.from(e.headers),e.data=nr.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ic(e.adapter||tr.adapter,e)(e).then(function(t){rc(e),e.response=t;try{t.data=nr.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=In.from(t.headers),t},function(t){if(!or(t)&&(rc(e),t&&t.response)){e.response=t.response;try{t.response.data=nr.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=In.from(t.response.headers)}return Promise.reject(t)})}const sc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{sc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const cc={};sc.transitional=function(e,t,n){function o(e,t){return"[Axios v"+Ia+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,r)=>{if(!1===e)throw new Cn(o(i," has been removed"+(t?" in "+t:"")),Cn.ERR_DEPRECATED);return t&&!cc[i]&&(cc[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,r)}},sc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var lc={assertOptions:function(e,t,n){if("object"!=typeof e||null===e)throw new Cn("options must be an object",Cn.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let i=o.length;for(;i-- >0;){const r=o[i],a=Object.prototype.hasOwnProperty.call(t,r)?t[r]:void 0;if(a){const t=e[r],n=void 0===t||a(t,r,e);if(!0!==n)throw new Cn("option "+r+" must be "+n,Cn.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Cn("Unknown option "+r,Cn.ERR_BAD_OPTION)}},validators:sc};const pc=lc.validators;class uc{constructor(e){this.defaults=e||{},this.interceptors={request:new Fi,response:new Fi}}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=Ms(this.defaults,t);const{transitional:n,paramsSerializer:o,headers:i}=t;void 0!==n&&lc.assertOptions(n,{silentJSONParsing:pc.transitional(pc.boolean),forcedJSONParsing:pc.transitional(pc.boolean),clarifyTimeoutError:pc.transitional(pc.boolean),legacyInterceptorReqResOrdering:pc.transitional(pc.boolean),advertiseZstdAcceptEncoding:pc.transitional(pc.boolean),validateStatusUndefinedResolves:pc.transitional(pc.boolean)},!1),null!=o&&(gn.isFunction(o)?t.paramsSerializer={serialize:o}:lc.assertOptions(o,{encode:pc.function,serialize:pc.function},!0)),void 0!==t.allowAbsoluteUrls||(t.allowAbsoluteUrls=void 0===this.defaults.allowAbsoluteUrls||this.defaults.allowAbsoluteUrls),lc.assertOptions(t,{baseUrl:pc.spelling("baseURL"),withXsrfToken:pc.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=i&&gn.merge(i.common,i[t.method]);i&&gn.forEach(["delete","get","head","post","put","patch","query","common"],e=>{delete i[e]}),t.headers=In.concat(r,i);const a=[];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||Di;n&&n.legacyInterceptorReqResOrdering?a.unshift(e.fulfilled,e.rejected):a.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(...a),e.push(...c),p=e.length,l=Promise.resolve(t);u<p;)l=l.then(e[u++],e[u++]);return l}p=a.length;let d=t;for(;u<p;){const e=a[u++],t=a[u++];try{d=e?e(d):d}catch(e){if(!t){l=Promise.reject(e);break}try{const n=t.call(this,e);gn.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 zi(lr((e=Ms(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}}gn.forEach(["delete","get","head","options"],function(e){uc.prototype[e]=function(t,n){return this.request(Ms(n||{},{method:e,url:t,data:n&&gn.hasOwnProp(n,"data")?n.data:void 0}))}}),gn.forEach(["post","put","patch","query"],function(e){function t(t){return function(n,o,i){return this.request(Ms(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}uc.prototype[e]=t(),"query"!==e&&(uc.prototype[e+"Form"]=t(!0))});var dc=uc;class mc{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 ir(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 mc(function(t){e=t}),cancel:e}}}var fc=mc;const hc={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(hc).forEach(([e,t])=>{hc[t]=e});var gc=hc;const vc=function e(t){const n=new dc(t),o=xt(dc.prototype.request,n);return gn.extend(o,dc.prototype,n,{allOwnKeys:!0}),gn.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return e(Ms(t,n))},o}(tr);vc.Axios=dc,vc.CanceledError=ir,vc.CancelToken=fc,vc.isCancel=or,vc.VERSION=Ia,vc.toFormData=Ni,vc.AxiosError=Cn,vc.Cancel=vc.CanceledError,vc.all=function(e){return Promise.all(e)},vc.spread=function(e){return function(t){return e.apply(null,t)}},vc.isAxiosError=function(e){return gn.isObject(e)&&!0===e.isAxiosError},vc.mergeConfig=Ms,vc.AxiosHeaders=In,vc.formToJSON=e=>Xi(gn.isHTMLForm(e)?new FormData(e):e),vc.getAdapter=ic,vc.HttpStatusCode=gc,vc.default=vc;var bc=vc;const{CanceledError:yc}=bc,xc="screenshot.needle.webp",wc=/screenshot(\-\d+?)?\.needle\.(webp|png|jpg|jpeg)/;async function _c(e,t){const n=t.baseUrl+ht.jobs.post_update,o={...gt(t),job_id:e.identifier,status:e.status},i={status_message:e.status_message,error:e.error,progress:e.progress},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)}).catch(e=>(console.error(e),null));return!!r&&r.ok}async function jc(e,t){const n=t.baseUrl+ht.jobs.get_status,o={...gt(t),job_id:e,org:t.org},i=await fetch(n,{...vt,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 kc(e={}){var t,n;const o=null!=(t=e.maxAuthFailures)?t:2,i=null!=(n=e.maxTransientFailures)?n:10;let r=0,a=0;return{record(e){if(e&&!0!==e.failed)return r=0,a=0,null;const t=null==e?void 0:e.httpStatus;return 401===t||403===t?(r++,r>=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):(a++,a>=i?{abort:!0,reason:`Could not read the job status after ${a} attempts${t?` (last: HTTP ${t})`:""}. The job may still be running — check it in the Needle Cloud dashboard.`}:null)}}}const Sc=6,Ec=1e3,Tc=15e3,$c=9e4,Ic=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"]),Ac=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!!Ac.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||!Ic.has(o)}function Cc(e,t={}){const{baseMs:n=Ec,maxMs:o=Tc,random:i=Math.random}=t,r=Math.max(1,Math.floor(e)),a=Math.min(o,n*2**(r-1))/2;return Math.max(1,Math.round(a+i()*a))}async function Nc(e,t={}){const{maxAttempts:n=Sc,budgetMs:o=$c,baseMs:i=Ec,maxMs:r=Tc,isRetryable:a=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,!a(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=Cc(m,{baseMs:i,maxMs:r,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 Pc=5242880,Uc=1e4,Lc=16777216,zc=67108864;var Fc=Dn(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],r=e[3];o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[0]-680876936|0)<<7|n>>>25)+o|0)&o|~n&i)+t[1]-389564586|0)<<12|r>>>20)+n|0)&n|~r&o)+t[2]+606105819|0)<<17|i>>>15)+r|0)&r|~i&n)+t[3]-1044525330|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[4]-176418897|0)<<7|n>>>25)+o|0)&o|~n&i)+t[5]+1200080426|0)<<12|r>>>20)+n|0)&n|~r&o)+t[6]-1473231341|0)<<17|i>>>15)+r|0)&r|~i&n)+t[7]-45705983|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[8]+1770035416|0)<<7|n>>>25)+o|0)&o|~n&i)+t[9]-1958414417|0)<<12|r>>>20)+n|0)&n|~r&o)+t[10]-42063|0)<<17|i>>>15)+r|0)&r|~i&n)+t[11]-1990404162|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&i|~o&r)+t[12]+1804603682|0)<<7|n>>>25)+o|0)&o|~n&i)+t[13]-40341101|0)<<12|r>>>20)+n|0)&n|~r&o)+t[14]-1502002290|0)<<17|i>>>15)+r|0)&r|~i&n)+t[15]+1236535329|0)<<22|o>>>10)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[1]-165796510|0)<<5|n>>>27)+o|0)&i|o&~i)+t[6]-1069501632|0)<<9|r>>>23)+n|0)&o|n&~o)+t[11]+643717713|0)<<14|i>>>18)+r|0)&n|r&~n)+t[0]-373897302|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[5]-701558691|0)<<5|n>>>27)+o|0)&i|o&~i)+t[10]+38016083|0)<<9|r>>>23)+n|0)&o|n&~o)+t[15]-660478335|0)<<14|i>>>18)+r|0)&n|r&~n)+t[4]-405537848|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[9]+568446438|0)<<5|n>>>27)+o|0)&i|o&~i)+t[14]-1019803690|0)<<9|r>>>23)+n|0)&o|n&~o)+t[3]-187363961|0)<<14|i>>>18)+r|0)&n|r&~n)+t[8]+1163531501|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o&r|i&~r)+t[13]-1444681467|0)<<5|n>>>27)+o|0)&i|o&~i)+t[2]-51403784|0)<<9|r>>>23)+n|0)&o|n&~o)+t[7]+1735328473|0)<<14|i>>>18)+r|0)&n|r&~n)+t[12]-1926607734|0)<<20|o>>>12)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[5]-378558|0)<<4|n>>>28)+o|0)^o^i)+t[8]-2022574463|0)<<11|r>>>21)+n|0)^n^o)+t[11]+1839030562|0)<<16|i>>>16)+r|0)^r^n)+t[14]-35309556|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[1]-1530992060|0)<<4|n>>>28)+o|0)^o^i)+t[4]+1272893353|0)<<11|r>>>21)+n|0)^n^o)+t[7]-155497632|0)<<16|i>>>16)+r|0)^r^n)+t[10]-1094730640|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[13]+681279174|0)<<4|n>>>28)+o|0)^o^i)+t[0]-358537222|0)<<11|r>>>21)+n|0)^n^o)+t[3]-722521979|0)<<16|i>>>16)+r|0)^r^n)+t[6]+76029189|0)<<23|o>>>9)+i|0,o=((o+=((i=((i+=((r=((r+=((n=((n+=(o^i^r)+t[9]-640364487|0)<<4|n>>>28)+o|0)^o^i)+t[12]-421815835|0)<<11|r>>>21)+n|0)^n^o)+t[15]+530742520|0)<<16|i>>>16)+r|0)^r^n)+t[2]-995338651|0)<<23|o>>>9)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[0]-198630844|0)<<6|n>>>26)+o|0)|~i))+t[7]+1126891415|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[14]-1416354905|0)<<15|i>>>17)+r|0)|~n))+t[5]-57434055|0)<<21|o>>>11)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[12]+1700485571|0)<<6|n>>>26)+o|0)|~i))+t[3]-1894986606|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[10]-1051523|0)<<15|i>>>17)+r|0)|~n))+t[1]-2054922799|0)<<21|o>>>11)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[8]+1873313359|0)<<6|n>>>26)+o|0)|~i))+t[15]-30611744|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[6]-1560198380|0)<<15|i>>>17)+r|0)|~n))+t[13]+1309151649|0)<<21|o>>>11)+i|0,o=((o+=((r=((r+=(o^((n=((n+=(i^(o|~r))+t[4]-145523070|0)<<6|n>>>26)+o|0)|~i))+t[11]-1120210379|0)<<10|r>>>22)+n|0)^((i=((i+=(n^(r|~o))+t[2]+718787259|0)<<15|i>>>17)+r|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]=r+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 r(e){var t,i,r,a,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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(n(p,r),t=0;t<16;t+=1)r[t]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),c=parseInt(a[1],16)||0,r[14]=s,r[15]=c,n(p,r),p}function a(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]=a(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(r("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,r,a,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),r=new Uint8Array(i),a=new Uint8Array(this,c,o),r.set(a),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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)r[t>>2]|=o.charCodeAt(t)<<(t%4<<3);return this._finish(r,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,r,a=t;if(e[a>>2]|=128<<(a%4<<3),a>55)for(n(this._hash,e),a=0;a<16;a+=1)e[a]=0;o=(o=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),r=parseInt(o[1],16)||0,e[14]=i,e[15]=r,n(this._hash,e)},p.hash=function(e,t){return p.hashBinary(c(e),t)},p.hashBinary=function(e,t){var n=s(r(e));return t?l(n):n},(p.ArrayBuffer=function(){this.reset()}).prototype.append=function(e){var t,o,r,a,s=(o=this._buff.buffer,r=e,(a=new Uint8Array(o.byteLength+r.byteLength)).set(new Uint8Array(o)),a.set(new Uint8Array(r),o.byteLength),a),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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)r[t>>2]|=o[t]<<(t%4<<3);return this._finish(r,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),r=new Uint8Array(i);for(n=0;n<o;n+=1)r[n]=e.charCodeAt(n);return r}(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,r,a,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,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)r[t>>2]|=e[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(n(p,r),t=0;t<16;t+=1)r[t]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),c=parseInt(a[1],16)||0,r[14]=s,r[15]=c,n(p,r),p}(new Uint8Array(e)));return t?l(o):o},p}()}),Dc=Fc;function qc(e,t=0){return Gc(e,t,2).getUint16(0,!0)}function Bc(e,t=0){return Gc(e,t,4).getUint32(0,!0)}function Mc(e,t=0,n=e.byteLength){const o=e.slice(t,t+n);return Hc.decode(new Uint8Array(o))}function Wc(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 Gc(e,t,n){const o=e.slice(t,t+n);return new DataView(new Uint8Array(o).buffer)}const Hc=new TextDecoder("utf8"),Jc=[["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 Vc(e){return e.flatMap(([e,t,n,o={},i=[]])=>[[e,t,n,o],...i])}function Kc(e,t){const n=qc(e,26),o=Mc(e,30,n),[i]=o.split("/"),r=o.endsWith(".xml");return"META-INF"===i?{ext:"jar",mime:"application/java-archive"}:"ppt"===i&&r?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:"word"===i&&r?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:"xl"===i&&r?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:"mimetype"===i?function(e,t){const n=Bc(e,18),o=Bc(e,22),i=qc(e,28);if(n===o){const o=Mc(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 Yc=function(e){return Vc(e).map(([e,t,n,{offset:o=0}={}])=>n.length+o).reduce((e,t)=>t>e?t:e,0)}(Jc);function Zc(e,t){for(const[n,o,i,{exact:r=!0,offset:a=0}={},s=[]]of t)if(Wc(e,i,a)){if("zip"===n&&!r)return Kc(e.buffer,{ext:n,mime:o});if(!r&&s.length)for(const[t,n,o,{offset:i=0}={}]of s)if(Wc(e,o,i))return{ext:t,mime:n};return{ext:n,mime:o}}}function Xc(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)||tl(t,e),r=new File([t],o,{type:i});return r.path=e,r}const Qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function el(e){return 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,r=n+2<e.length?e.charCodeAt(n+2):0;t+=Qc[o>>2]+Qc[(3&o)<<4|i>>4]+(n+1<e.length?Qc[(15&i)<<2|r>>6]:"=")+(n+2<e.length?Qc[63&r]:"=")}return t}(Dc.ArrayBuffer.hash(e,!0))}function tl(e,t=void 0){const n=function(e,{extra:t=!1,hint:n}={}){const o=new Uint8Array(e.slice(0,Yc));if(n){const e=function(e,{ext:t,mime:n}){return t||n?Vc(e).filter(e=>e[0]===t||e[1]===n):[]}(Jc,n);if(e.length>0){const t=Zc(o,e);if(void 0!==t)return t}}return Zc(o,Jc)||(t?function(e){return function(e){try{const t=Mc(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 r=0;r<o.length;r++)i+=o[r].toString(16);let a="unknown";switch(i){case"676c5446":a="model/gltf-binary";break;case"89504e47":a="image/png";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":a="image/jpeg";break;default:a="unknown"}return"unknown"===a&&"string"==typeof t&&(a=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)),a}function nl(e){return"string"==typeof e&&0!==e.length&&e.toLowerCase().endsWith(".exr")}function ol(e){if("string"!=typeof e||0===e.length)return!1;const t=e.toLowerCase();return t.endsWith(".hdr")||t.endsWith(".hdri")}function il(e){return"string"==typeof e&&0!==e.length&&/\.pmrem(\d+x\d+)?\.ktx2$/i.test(e)}function rl(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 al(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 sl(e){return e.split("/").reduce((e,t)=>("."===t||(".."===t?e.pop():null!=t&&t.length&&e.push(t)),e),[]).join("/")}const cl=1179937895,ll=1313821514,pl=12,ul=8;function dl(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))}const ml=4,fl=1;function hl(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e))}function gl(e){return Array.isArray(e)?e:[]}function vl(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0?e:null}function bl(e){return Array.isArray(e)&&3===e.length&&e.every(e=>"number"==typeof e&&Number.isFinite(e))?[e[0],e[1],e[2]]:null}function yl(e){return gl(e).filter(e=>"string"==typeof e)}function xl(e,t){e.meshes+=t.meshes,e.primitives+=t.primitives,e.vertices=null===e.vertices||null===t.vertices?null:e.vertices+t.vertices,e.triangles=null===e.triangles||null===t.triangles?null:e.triangles+t.triangles}const wl=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function _l(e){const t=new Set([...gl(e.buffers),...gl(e.images)].map(e=>hl(e).uri).filter(e=>"string"==typeof e&&!e.startsWith("data:"))),n=new Set;let o=1,i=1;function r(e){let o=1;for(const i of e){const e=gl(hl(hl(hl(i).extensions).NEEDLE_progressive).lods).map(e=>hl(e).path).filter(e=>"string"==typeof e);if(e.length){n.add("NEEDLE_progressive"),o=Math.max(o,e.length+1);for(const n of e)t.add(n)}}return o}o=r(gl(e.meshes)),i=r(gl(e.textures));for(const t of gl(e.nodes)){const e=gl(hl(hl(hl(t).extensions).MSFT_lod).ids);e.length&&(n.add("MSFT_lod"),o=Math.max(o,e.length+1))}return{progressive:n.size>0,mechanisms:[...n],meshLodLevels:o,textureLodLevels:i,dependencies:[...t].sort()}}function jl(e){const t=new Set,n=new Set;let o=!1;function i(e){const n=vl(e);null===n?o=!0:t.add(n)}for(const t of gl(e.meshes))for(const e of gl(hl(t).primitives)){const t=hl(e);for(const e of Object.values(hl(t.attributes)))i(e);void 0!==t.indices&&i(t.indices);for(const e of gl(t.targets))for(const t of Object.values(hl(e)))i(t);"KHR_draco_mesh_compression"in hl(t.extensions)&&n.add("KHR_draco_mesh_compression")}for(const t of gl(e.bufferViews))"EXT_meshopt_compression"in hl(hl(t).extensions)&&n.add("EXT_meshopt_compression");const r=gl(e.accessors),a={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},s={SCALAR:[1,1],VEC2:[1,2],VEC3:[1,3],VEC4:[1,4],MAT2:[2,2],MAT3:[3,3],MAT4:[4,4]};let c=0;for(const e of t){const t=hl(r[e]),n=vl(t.count),i=a[String(t.componentType)],l=s[String(t.type)];if(!i||!l||null===n){o=!0;continue}const[p,u]=l,d=u*i;c+=n*p*(p>1?4*Math.ceil(d/4):d)}return{nodeCount:gl(e.nodes).length,meshCompression:[...n].sort(),geometryBytesEstimate:o||!Number.isSafeInteger(c)?null:c,geometryAssumption:"Unique dense mesh accessors, no renderer overhead"}}async function kl(e){return new Promise(t=>setTimeout(t,e))}function Sl(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 r=!1!==(null==n?void 0:n.prefix),a=!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 r&&(s="on "),`${s}${new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}${c}`;s=r?i?"":"in ":"",c=a&&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 El=/^image_(?<image_lod>\d+)_|^mesh_lod_(?<mesh_lod>\d+)_/;function Tl(e){return e.includes("\\u")?JSON.parse(`"${e}"`):decodeURIComponent(e)}function $l(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 r=e.filter(e=>e.name.toLowerCase().endsWith(".glb")||e.name.toLowerCase().endsWith(".gltf")||e.name.toLowerCase().endsWith(".vrm"));if(r.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=Ol(t)[0])?o:null;var o}(r);return e?(t=e,t):(n="Invalid upload: Multiple glb/glTF/vrm files found. This is currently not supported.",console.error(n,r.map(e=>e.path||e.name)),{error:n})}if(1===r.length)return t=r[0],t;const a=e.filter(e=>e.name.toLowerCase().endsWith(".usdz")||e.name.toLowerCase().endsWith(".usd")||e.name.toLowerCase().endsWith(".usda")||e.name.toLowerCase().endsWith(".usdc"));if(a.length>=1)return t=function(e){var t;const n=Ol(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}(a),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 nl(t)||ol(t)||il(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 Il=new Set(["glb","gltf","vrm"]),Al=new Set(["fbx","obj","stl","usd","usda","usdz"]);function Ol(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 Cl{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,r=(t-this.startTime)/1e3,a=this.speedEMA&&this.speedEMA>0?this.speedEMA:this.uploadedSize/r;let s;if(s=a>0?(this.estimatedTotalSize-this.uploadedSize)/a: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=r/i-r;return this.smoothedRemainingTime=Math.max(this.smoothedRemainingTime,(this.estimatedTotalSize-this.uploadedSize)/a),{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 Nl=15e3;function Rl(e,t,n={setTimeout:setTimeout,clearTimeout:clearTimeout}){return function(o,i){const r=e.call(this,o,i);if(!r||"function"!=typeof r.once)return r;const a=n.setTimeout(()=>{const e=new Error(`connect timeout: no connection within ${t/1e3}s`);e.code="ETIMEDOUT",r.destroy(e)},t),s=()=>n.clearTimeout(a);return r.once("connect",s),r.once("secureConnect",s),r.once("error",s),r.once("close",s),r}}let Pl;async function Ul(e={}){var t,n;if(!(null!=(t=e.isNode)?t:"undefined"!=typeof process&&null!=(n=process.versions)&&n.node))return{};if(Pl)return Pl;const[{default:o},{default:i}]=await Promise.all([import("node:http"),import("node:https")]),r=new o.Agent({keepAlive:!0}),a=new i.Agent({keepAlive:!0});for(const e of[r,a])e.createConnection=Rl(e.createConnection,Nl);return Pl={httpAgent:r,httpsAgent:a},Pl}async function Ll(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 Xc(`${"path"in e?e.path:e.name}.gz`,o,{type:"application/gzip"})}const zl=16777216;async function Fl(e,t,n=void 0){const o=async function(e,t,n){var o,i,r,a,s,c,l,p,u,d,m,f,h,g,v,b,y,x,w,_,j,k,S,E,T,$;let{files:I,skipped:A}=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 A)console.warn(`[upload] Skipping directory entry: "${e.name}"`);t.files=I;const O=(null==(o=n)?void 0:o.loglevel)||"none";if(!I.length)return"none"!=O&&console.error("No files to upload"),{success:!1,error:"No files to upload"};if(!t.entrypoint){const e=$l(I);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"===O&&console.log("Entrypoint: "+e.name),t.entrypoint=e}t.entrypoint&&!I.includes(t.entrypoint)&&I.push(t.entrypoint);const C=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)&&El.test(s)||i++:p.endsWith(".vrm")&&n++,p.endsWith(".gltf")){var r;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==(r=l.path)?void 0:r.split("/"),c=s.splice(0,s.length-1).join("/");for(const t of n){var a;const n=null==(a=t.groups)?void 0:a.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=sl(`${c}/${Tl(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}}(I);if("error"in C)return{success:!1,error:C.error||"Failed to validate files"};if(null!=(i=t.entrypoint)&&i.name.endsWith(".htm")||null!=(r=t.entrypoint)&&r.name.endsWith(".html")||null!=(a=t.entrypoint)&&a.name.endsWith(".html.gz")||null!=(s=t.entrypoint)&&s.name.endsWith(".html.br"))n||(n={}),n.type="deployment";else if(C.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 N=await async function(e,t={}){const{raw:n=!1,loglevel:o="none",entrypoint:i=null}=t,r=(...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 a=new Set(e.map(Bl)),s=[];let c=i;for(const t of e){const n=Bl(t),p=t.name.toLowerCase();if(!Dl.some(e=>p.endsWith(e))){s.push(t);continue}const u=ql.find(e=>a.has(`${n}${e}`));if(u){var l;r(`Skipping gzip compression, using pre-compressed file: ${n}${u}`),i===t&&(c=null!=(l=e.find(e=>Bl(e)===`${n}${u}`))?l:c);continue}r(`gZip compressing file: ${t.name}`);const d=await Ll(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),r(`gZip compressed file: ${t.name} ${m?"(entrypoint)":""}`)}return{files:s,entrypoint:c}}(I,{raw:t.raw,loglevel:null!=(c=null==(l=n)?void 0:l.loglevel)?c:O,entrypoint:t.entrypoint});if(N.error)return{success:!1,error:N.error,status:500};I=N.files,t.files=I,t.entrypoint=N.entrypoint,I.sort((e,t)=>e.name.includes(".needle")&&!t.name.includes(".needle")?-1:!e.name.includes(".needle")&&t.name.includes(".needle")?1:0);const{baseUrl:R,authToken:P}=e,U="Bearer "+P,L={...gt(e),triggered_by:t.triggered_by,filename:`${encodeURIComponent(t.entrypoint.name)}`,"total-files":I.length.toString(),"total-files-size":I.reduce((e,t)=>e+t.size,0).toString()};null!=(p=n)&&p.content_id&&(L.content_id=n.content_id),null!=(u=n)&&u.type&&(L.type=n.type),null!=(d=n)&&d.name&&(L.name=encodeURIComponent(n.name)),null!=(m=n)&&m.parent_job_id&&(L.parent_job_id=n.parent_job_id);const z={entrypoint:(null==(f=t.entrypoint)?void 0:f.path)||(null==(h=t.entrypoint)?void 0:h.name),files:[]};null!=(g=n)&&g.content_type&&(z.content_type=n.content_type);const F={outputs:[z],...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}:{}},D=[];for(let e=0;e<I.length;e++){var q,B,M;const t=I[e];let o=t.path||t.webkitRelativePath||t.name;if(null!=(q=o)&&q.includes(":"))throw new Error(`Invalid filename: ${o}`);let i=await t.arrayBuffer();const r=t.size;let a=t.type;if(null!=(B=a)&&B.length&&"unknown"!==a.toLowerCase()||(a=tl(i,o)),"deployment"===(null==(M=n)?void 0:M.type)){const e=rl(o,a);e&&(o=e.filename,a=e.mimetype)}const s=el(i);D[e]=i,z.files[e]={filename:o,content_type:a,content_length:r,content_md5:s}}if("deployment"!==(null==(y=n)?void 0:y.type)){const e=t.entrypoint.name.toLowerCase();let o;if(e.endsWith(".glb")||e.endsWith(".gltf"))try{var W;const n=D[I.indexOf(t.entrypoint)],i=e.endsWith(".glb")?function(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);if(t.byteLength<pl+ul)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)!==cl)throw new Error("Not a GLB (magic mismatch)");const o=n.getUint32(pl,!0);if(n.getUint32(pl+4,!0)!==ll)throw new Error("First chunk is not JSON");const i=pl+ul,r=i+o;if(r>t.byteLength)throw new Error("JSON chunk exceeds buffer length");const a=t.subarray(i,r),s=(new TextDecoder).decode(a);return JSON.parse(s)}(n):JSON.parse((new TextDecoder).decode(n));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"}(i),"string"==typeof(null==(W=i.asset)?void 0:W.version)&&i.asset.version.startsWith("2.")&&(z.technical_metadata=function(e){const t=hl(e.asset),n=/^(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})$/;if("string"!=typeof t.version||!n.test(t.version)||2!==Number(t.version.split(".")[0]))throw new Error("Metadata collection requires glTF 2.0-compatible asset versions");if(void 0!==t.minVersion&&("string"!=typeof t.minVersion||!n.test(t.minVersion)||"2.0"!==t.minVersion))throw new Error("Metadata collection supports a minimum glTF version of 2.0");const o=gl(e.nodes),i=gl(e.meshes),r=gl(e.accessors),a=gl(e.scenes),s=gl(e.animations),c=gl(e.skins),l=new Set;"2.0"!==t.version&&l.add(`newer-gltf-version:${t.version}`);const p=e=>{const t=vl(e);return hl(null===t?void 0:r[t])};function u(e){const t=gl(hl(e).primitives),n={meshes:1,primitives:0,vertices:0,triangles:0};n.primitives=t.length;for(const e of t){var o;const t=hl(e),i=vl(p(hl(t.attributes).POSITION).count),r=void 0===t.indices?i:vl(p(t.indices).count),a=null!=(o=t.mode)?o:4,s="number"==typeof a&&a>=0&&a<=3?0:null===r?null:4===a?Math.floor(r/3):5===a||6===a?Math.max(0,r-2):null;null!==i&&null!==s||l.add("geometry-counts-unavailable"),xl(n,{meshes:0,primitives:0,vertices:i,triangles:s})}return n}const d={meshes:0,primitives:0,vertices:0,triangles:0};for(const e of i)xl(d,u(e));const m=a.map((e,t)=>{const n=hl(e),r=gl(n.nodes),a={meshes:0,primitives:0,vertices:0,triangles:0},s=[Infinity,Infinity,Infinity],c=[-Infinity,-Infinity,-Infinity];let d=!1,m=!1,f=!1;function h(e,t,n){const r=vl(e);if(null===r||!o[r]||n.has(r))return l.add("invalid-scene-hierarchy"),void(d=!0);const g=hl(o[r]),v=(b=t,y=function(e){var t,n;if(Array.isArray(e.matrix)&&16===e.matrix.length&&e.matrix.every(e=>"number"==typeof e&&Number.isFinite(e)))return[...e.matrix];const[o,i,r]=null!=(t=bl(e.translation))?t:[0,0,0],[a,s,c]=null!=(n=bl(e.scale))?n:[1,1,1],l=e.rotation,[p,u,d,m]=Array.isArray(l)&&4===l.length&&l.every(e=>"number"==typeof e&&Number.isFinite(e))?l:[0,0,0,1];return[(1-2*(u*u+d*d))*a,2*(p*u+d*m)*a,2*(p*d-u*m)*a,0,2*(p*u-d*m)*s,(1-2*(p*p+d*d))*s,2*(u*d+p*m)*s,0,2*(p*d+u*m)*c,2*(u*d-p*m)*c,(1-2*(p*p+u*u))*c,0,o,i,r,1]}(g),Array.from({length:16},(e,t)=>{const n=t%4,o=Math.floor(t/4);return b[n]*y[4*o]+b[n+4]*y[4*o+1]+b[n+8]*y[4*o+2]+b[n+12]*y[4*o+3]}));var b,y;const x=new Set(n);if(x.add(r),void 0!==g.mesh){const e=vl(g.mesh),t=null===e?void 0:i[e];if(t){xl(a,u(t));for(const e of gl(hl(t).primitives)){const t=hl(e),n=p(hl(t.attributes).POSITION),o=bl(n.min),i=bl(n.max);if(o&&i){m||(m=void 0!==g.skin||gl(t.targets).length>0),f=!0;for(let e=0;e<8;e++){const t=1&e?i[0]:o[0],n=2&e?i[1]:o[1],r=4&e?i[2]:o[2];for(let e=0;e<3;e++){const o=v[e]*t+v[e+4]*n+v[e+8]*r+v[e+12];s[e]=Math.min(s[e],o),c[e]=Math.max(c[e],o)}}}else d=!0,l.add("bounds-unavailable")}}else l.add("missing-mesh"),d=!0}for(const e of gl(g.children))h(e,v,x)}for(const e of r)h(e,wl,new Set);let g=null;if(f&&!d){const e=[(c[0]+s[0])/2,(c[1]+s[1])/2,(c[2]+s[2])/2];g={min:s,max:c,dimensions:[c[0]-s[0],c[1]-s[1],c[2]-s[2]],center:e,originOffset:[-e[0],-e[1],-e[2]],pose:"default",approximate:m}}return{index:t,..."string"==typeof n.name?{name:n.name}:{},rootCount:r.length,geometry:a,bounds:g}}),f=s.map((e,t)=>{const n=hl(e),o=gl(n.samplers);let i=Infinity,r=-Infinity,a=0===o.length;for(const e of o){const t=p(hl(e).input),n=gl(t.min)[0],o=gl(t.max)[0];"number"!=typeof n||"number"!=typeof o||!Number.isFinite(n)||!Number.isFinite(o)||o<n?a=!0:(i=Math.min(i,n),r=Math.max(r,o))}return a&&l.add("animation-duration-unavailable"),{index:t,..."string"==typeof n.name?{name:n.name}:{},duration:a?null:r-i,trackCount:gl(n.channels).length}}),h=hl(t.extras),g={};for(const e of["author","license","source","title"])"string"==typeof h[e]&&(g[e]=h[e]);const v=vl(e.scene);null!==v&&v>=a.length&&l.add("invalid-default-scene");let b=0;for(const e of i)for(const t of gl(hl(e).primitives))b+=gl(hl(t).targets).length;return{schemaVersion:fl,collectorVersion:ml,status:l.size?"partial":"complete",issues:[...l],asset:{version:t.version,..."string"==typeof t.minVersion?{minVersion:t.minVersion}:{},..."string"==typeof t.generator?{generator:t.generator}:{},..."string"==typeof t.copyright?{copyright:t.copyright}:{},attribution:g},sceneCount:a.length,defaultSceneIndex:null!==v&&v<a.length?v:null,scenes:m,geometry:d,resourceUsage:jl(e),materialCount:gl(e.materials).length,animationCount:s.length,animations:f,skinCount:c.length,jointCount:new Set(c.flatMap(e=>gl(hl(e).joints))).size,morphTargetCount:b,textureCount:gl(e.textures).length,imageCount:gl(e.images).length,materialVariantCount:gl(hl(hl(e.extensions).KHR_materials_variants).variants).length,extensionsUsed:yl(e.extensionsUsed),extensionsRequired:yl(e.extensionsRequired),loading:_l(e),unit:"meter"}}(i))}catch(e){return{success:!1,error:`Failed to inspect "${t.entrypoint.name}": ${e.message}`}}else e.endsWith(".mtlx")?o="material":(nl(e)||ol(e)||il(e))&&(o="hdri");if(o){var G;if(null!=(G=n)&&G.content_type&&n.content_type!==o)return{success:!1,error:`Content type mismatch: "${t.entrypoint.name}" contains "${o}" but "${n.content_type}" was requested.`};z.content_type=o}}try{const e=await async function(e){var t,n,o,i,r;if(!e||"function"!=typeof e.slice||"number"!=typeof e.size)return null;const a=Math.min(e.size,65536);if(a<=0)return null;let s;try{const t=await e.slice(0,a).arrayBuffer();s=new Uint8Array(t)}catch{return null}return null!=(t=null!=(n=null!=(o=null!=(i=null!=(r=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))?r: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=dl(e,n);if(null===o)return null;if(0===o.length)return null;n+=o.length+1;const i=dl(e,n);if(null===i)return null;if(n+=i.length+1,n+4>e.length)return null;const r=t.getInt32(n,!0);if(n+=4,r<0||n+r>e.length)return null;if("dataWindow"===o&&"box2i"===i&&16===r){const e=t.getInt32(n,!0),o=t.getInt32(n+4,!0),i=t.getInt32(n+8,!0)-e+1,r=t.getInt32(n+12,!0)-o+1;return i<=0||r<=0?null:{width:i,height:r}}n+=r}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&&(z.width=e.width,z.height=e.height)}catch(e){"debug"===O&&console.warn("readImageResolution failed; uploading without dimensions",e)}if(null!=(x=n)&&null!=(x=x.abort)&&x.aborted)return{success:!1,error:"Upload aborted"};const H=await fetch(R+ht.upload.request,{signal:null==(w=n)?void 0:w.abort,...vt,method:"POST",headers:L,body:JSON.stringify(F)}).catch(e=>{var t;return null!=(t=n)&&null!=(t=t.abort)&&t.aborted?"Upload aborted":"fetch failed"==e.message||"Failed to fetch"==e.message?`Network error. Make sure you are connected to the internet and ${R} is reachable.`:(console.error("Failed to begin upload\n",e),null)});if(null===H||"string"==typeof H)return{success:!1,error:H||"Failed to begin upload"};if(!H.ok){const e=await H.text();if(e.startsWith("{")){const t=JSON.parse(e);if("error"in t)return{success:!1,status:H.status,error:t.error}}return"none"!=O&&console.error("Failed to begin upload\n",H.status,e),{success:!1,status:H.status,error:`${e}`}}const J=await H.json();"debug"===O&&console.debug("BeginResponse",J);const V=I.reduce((e,t)=>e+t.size,0);if(null!=(_=n)&&null!=(_=_.abort)&&_.aborted)return{success:!1,error:"Upload aborted"};var K,Y;if("exists"===J.type)return null==(K=n)||null==K.onFinalize||K.onFinalize(),"none"!=O&&console.log("Upload already exists",J.id),null!=(Y=n)&&Y.onStart&&n.onStart(J.id,J.content_id),{success:!0,uploadSkipped:!0,id:J.id,type:J.job_type,content_id:J.content_id,filesUploaded:I.length,totalSize:V,url:J.url,edit_url:J.edit_url};const Z=t.entrypoint.webkitRelativePath||t.entrypoint.name;let X=0,Q=!1;null==(j=n)||null==(j=j.abort)||j.addEventListener("abort",()=>{Q||(console.log("Upload aborted: Cancelling upload"),fetch(R+ht.upload.cancel,{...vt,method:"POST",headers:{authorization:U,id:J.id}}).then(e=>{if(!e.ok)throw new Error(`Cancel returned HTTP ${e.status}`)}).catch(e=>console.error("Could not notify the server of upload cancellation",e)))},{once:!0});let ee=!1,te=Date.now();function ne(t,n,o=!1){if(!o&&Date.now()-te<1e3)return!1;if(ee&&"completed"!==n)return void("none"!=O&&console.warn("Invalid status update..."));te=Date.now();const i=Math.floor(X/V*100);return"debug"===O&&console.log("SET STATUS: "+n,t,i),_c({identifier:J.id,status:n,status_message:t,progress:i},e),!0}null!=(k=n)&&k.onStart&&n.onStart(J.id,J.content_id);const oe=Date.now(),ie=new Cl(I.length,V/1024/1024),re=new Array,ae=function(e){let t=0;for(const n of e)Number.isFinite(n)&&n>=0&&(t=Math.max(t,n));return t>=zc?2:t>=zl?4:10}(z.files.map(e=>e.content_length));"debug"===O&&console.debug(`Upload file concurrency: ${ae}`);let se=!1;const ce=[...I],le=I.length,pe=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))}}(()=>ne("Upload in progress","running",!0));try{var ue;for(let o=0;o<ce.length;o++){var de;if(!(se||null!=(de=n)&&null!=(de=de.abort)&&de.aborted)){if(re.length<ae){console.debug(`Uploading file ${o}/${I.length}: ${I[o].name}`);let i=0,r=0;const a=z.files[o],s=a.filename,c=D[o],l=a.content_length,p=a.content_type,u=I[o],d=u.name.endsWith(".gz")?"gzip":u.name.endsWith(".br")?"br":void 0,m=Zl({uploadId:J.id,uploadRequestPUTUrl:J.request_put_url,entrypointPath:Z,file:I[o],fileName:s,fileMd5:a.content_md5,fileBuffer:c,fileType:p,content_encoding:d,fileSize:l,fileIndex:o,fileNumber:o+1,fileCount:le,loglevel:O,experimental:t.experimental,args:e,options:n,onProgress:e=>{var t;const a=e.progress||0;i=I[o].size*a;const c=i-r;if(r=i,X+=c,null!=(t=n)&&t.progress){const e=X/V,t=I.length,i=I[o].size,r=(Date.now()-oe)/1e3,c=ie.updateProgress(X/1024/1024);n.progress({uploadedBytes:X,totalBytes:V,progress01:e,fileName:I[o].name,fileSize:i,fileProgress01:a,fileIndex:o,totalFiles:t,estimatedTimeLeftDisplay:c.estimatedTimeRemainingString,estimatedTimeLeft:c.estimatedTimeRemaining,elapsedTime:r}),ne(`Uploading file ${o+1}/${t} (${s}): ${(100*a).toFixed(0)}% of ${al(V)}. Finished in approx. ${c.estimatedTimeRemainingString}`,"running",!1)}}}).then(e=>{if(!0!==e)return e;for(let e=re.length-1;e>=0;e--)re[e]===m&&re.splice(e,1);ne(`Uploaded ${al(X)+" of "+al(V)} for ${I[o].name}`,"running")}).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),se=!0)});re.push(m)}re.length>=ae&&await Promise.race(re)}}null!=(ue=n)&&null!=(ue=ue.abort)&&ue.aborted?console.debug("Upload aborted"):se&&console.debug("Upload failed"),await Promise.all(re).catch(e=>{var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),se=!0)})}finally{pe()}if(se)return await _c({identifier:J.id,status:"failed",error:"Failed to upload files"},e),{success:!1,error:"Failed to upload files"};if(null!=(S=n)&&null!=(S=S.abort)&&S.aborted)return _c({identifier:J.id,status:"canceled",status_message:"Upload aborted",error:"Upload aborted"},e).catch(e=>console.error("Could not report canceled upload status",e)),{success:!1,error:"Upload aborted"};Q=!0,null==(E=n)||null==E.onFinalize||E.onFinalize(),ee=!0,console.log(`Upload Done: All files uploaded to ${J.id}`);const me={...gt(e),id:J.id};"none"!=O&&console.log("Completing upload - notify server");let fe=null;for(let e=0;e<5;e++){var he,ge,ve,be;if(null!=(he=n)&&null!=(he=he.abort)&&he.aborted)return{success:!1,error:"Upload aborted"};if(await kl(1e3*e),null!=(ge=n)&&null!=(ge=ge.abort)&&ge.aborted)return{success:!1,error:"Upload aborted"};const t=AbortSignal.timeout(6e4+5e3*e);if(fe=await fetch(R+ht.upload.done,{...vt,method:"POST",headers:me,signal:null!=(ve=n)&&ve.abort?AbortSignal.any([t,n.abort]):t}).catch(t=>(console.error(`Failed to complete upload (${e+1} / 5)`,t.message),null)),!0===(null==(be=fe)?void 0:be.ok))break;if(fe&&fe.status>=400&&fe.status<500)break;var ye;"none"!=O&&e<4&&console.warn(`Failed to complete upload (${(null==(ye=fe)?void 0:ye.status)||"no status"}): will retry in 1 second`)}if(null!=(T=n)&&null!=(T=T.abort)&&T.aborted)return{success:!1,error:"Upload aborted"};if(!fe)return console.error("Failed to complete upload"),{success:!1,error:"Failed to complete upload"};if(!fe.ok){if(524===fe.status)return console.error("Failed to complete upload: Gateway Timeout"),{success:!1,error:"Failed to complete upload: Gateway Timeout"};{const e=await fe.text().catch(()=>"");return console.error(`Failed to complete upload (${fe.status}): ${e}`),{success:!1,error:`Failed to complete upload: ${e?e.substring(0,300):`status ${fe.status}`}`}}}"none"!=O&&console.log("Upload complete");const xe=await fe.json();return null!=($=n)&&null!=($=$.abort)&&$.aborted?{success:!1,error:"Upload aborted"}:{success:!0,type:xe.type,uploadSkipped:!1,id:xe.id,content_id:xe.content_id,url:xe.url,edit_url:xe.edit_url,filesUploaded:I.length,totalSize:V}}(e,t,n);return await o.finally(()=>{})}const Dl=[".html",".js",".css"],ql=[".gz",".br"];function Bl(e){return"path"in e&&e.path?e.path:e.name}function Ml(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 Wl=400,Gl=255;function Hl(e){const t="string"==typeof e?e:String(null!=e?e:"");return t.length<=Gl?t:t.slice(0,Gl-1)+"…"}const Jl={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 Vl(e){if(!e)return"unknown upload error";const t=[];try{const i=e.response,r=null==i?void 0:i.status,a=null==i?void 0:i.statusText;r&&t.push(`HTTP ${r}${a?" "+a:""}`);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 r=null==(n=i.match(/<Code>([^<]+)<\/Code>/))?void 0:n[1],a=null==(o=i.match(/<Message>([^<]+)<\/Message>/))?void 0:o[1];if(r)t.push(`S3 ${r}${a?": "+a:""}`);else if(function(e){return/^\s*(<!DOCTYPE\s+html|<html[\s>])/i.test(e)}(i)){const n=Ml(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=Jl[c];t.push(n?`${c} (${n})`:c);const o=Ml(e);o&&t.push(`while uploading to ${o}`)}const l=e.message?String(e.message):"",p=r&&/^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 Kl=12e4;function Yl(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>=zc)return async function(e){const{uploadId:t,entrypointPath:n,file:o,fileName:i,fileMd5:r,fileType:a,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=()=>({...gt(l),"Content-Type":"application/json",org:l.org,job_id:t}),y={...b(),filesize:c.toString()},x=JSON.stringify({filename:i,entrypoint:n,"content-type":a,"content-md5":r,"content-encoding":s,output_index:0});async function w(e,t,n){const o=await fetch(e,{...vt,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=Lc,concurrency:i=4,maxRetries:r=5,retryDelayMs:a=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=Lc){if(!Number.isFinite(e)||e<=0)return[];let n=Math.max(t,Pc,Math.ceil(e/Uc));const o=[];let i=0,r=1;for(;i<e;){const t=Math.min(i+n,e);o.push({partNumber:r,start:i,end:t,size:t-i}),i=t,r++}return o}(t,o);if(0===g.length)throw new Error("Nothing to upload (size <= 0)");const{upload_id:v,key:b}=await s(),y=await c(v,b,g.map(e=>e.partNumber)),x=new Map(y.map(e=>[e.part_number,e.url])),w=[];let _=0,j=null;const k=async e=>{const t=x.get(e.partNumber);if(!t)throw new Error(`Missing presigned url for part ${e.partNumber}`);let o=!1;const i=await Nc(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:r+1,baseMs:a,isRetryable:e=>!o&&Oc(e),...a>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+ht.upload.multipart_create,{...vt,method:"POST",headers:y,body:x});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+ht.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 r=el(t instanceof Uint8Array?new Uint8Array(t).buffer:await t.arrayBuffer()),a=i,s=new AbortController;let c=!1;const l=()=>s.abort();a&&(a.aborted?s.abort():a.addEventListener("abort",l,{once:!0}));const p=Yl(Kl,()=>{c=!0,s.abort()});p.reset();try{var u,d;const n=await bc.put(e,t,{...vt,...await Ul(),withCredentials:!1,signal:s.signal,headers:{"Content-Type":o,"Content-MD5":r},onUploadProgress:()=>p.reset()});if(200!==n.status)throw new Error(Vl({response:n}));const i=(null==(u=n.headers)?void 0:u.etag)||(null==(d=n.headers)?void 0:d.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(c)throw new Error(`Part ${n} stalled: no progress for ${Kl/1e3}s`);throw new Error(Vl(e))}finally{p.cancel(),a&&a.removeEventListener("abort",l)}}({url:e,payload:t,partNumber:n,signal:o,contentType:a})),completeUpload:async(e,t,n)=>w(v+ht.upload.multipart_complete,b(),{key:t,upload_id:e,parts:n}),abortUpload:async(e,t)=>{await fetch(v+ht.upload.multipart_abort,{...vt,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:r,fileBuffer:a,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={...gt(h),"Content-Type":"application/json",org:h.org,job_id:t,filesize:c.toString(),progress:(u/m*100).toFixed(0)},y={filename:r,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 x=JSON.stringify(y);let w=null,_="";const j=await Nc(async()=>{var e;if(null!=g&&null!=(e=g.abort)&&e.aborted)throw new yc("Upload aborted");const t=await fetch(n,{...vt,signal:null==g?void 0:g.abort,method:"POST",headers:b,body:x});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 "${r}" "${l}": ${Vl(n)}\n→ Retry #${e} in ${t}ms`)}});if(j.ok)w=j.value;else if(j.error instanceof yc)throw j.error;if(null==w){const e=_||Vl(j.error);throw new Error(`Failed to get presigned url for "${r}" "${l}" \n${e}`)}const k=w.presigned_url;var S=!1;let E=null;const T=[];let $=0;const I=await Nc(async t=>{var n;if(null!=g&&null!=(n=g.abort)&&n.aborted)throw new yc("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}: ${r}`),"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=Yl(Kl,()=>{u=!0,i.abort()});b.reset();try{const t=await bc.put(k,a,{...vt,...await Ul(),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 y;if(null!=g&&null!=(y=g.abort)&&y.aborted)throw new yc("Upload aborted");if(u)throw E=`stalled: no upload progress for ${Kl/1e3}s`,T.push(E),"none"!==f&&console.error(`Upload stalled (PUT) (${d}, ${r}) after ${Kl/1e3}s with no progress`),new Error(E);throw E=Vl(e),T.push(E),e instanceof yc||("none"!==f&&console.error(`Failed to upload file (PUT) (${d}, ${r}) "${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 ${r} in ${t}ms`)}});if($=I.attempts,I.ok)S=!0,"info"===f&&console.log(`Uploaded file ${d}/${m} "${r}" (${l}, ${al(c)})`);else if(I.error instanceof yc)throw I.error;if(!S){var A;const e=null!=(A=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}(T))?A: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>Wl?o.slice(0,Wl)+"…":o}`:`Failed to upload file ${e}${i}`}(r,e,$);throw console.error(n),await _c({identifier:t,status:"failed",status_message:Hl(n),error:"Failed to upload file "+r},h),new Error(n)}return!0}async function Xl(e,t,n){const o=e.baseUrl+ht.jobs.presigned_url,i=await fetch(o,{...vt,method:"POST",headers:{...gt(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 Ql(e,t){const n=e.baseUrl+ht.jobs.create,o={...gt(e),"content-type":"application/json"},i={type:"ai-material",triggered_by:e.trigger_type,parameters:{...t}},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();return console.error(`Failed to request texture generation (${r.status}): ${e}`),{error:e||`Request failed (${r.status})`}}return await r.json().catch(e=>(console.error(e),null))}const ep=["3d-asset","material","deployment","hdri"],tp=["glb","gltf","usd","usda","usdz","obj","fbx","vrm","stl","ply","splat","spz","ksplat","sog","sogs","textures","html","exr","hdr","pmrem"];async function np(e,t={}){const n=new URL(e.baseUrl+ht.content.root);t.sort_by&&n.searchParams.set("sort_by",t.sort_by),t.sort_direction&&n.searchParams.set("sort_direction",t.sort_direction),t.include_metadata&&n.searchParams.set("include_metadata",t.include_metadata),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=gt(e),i=await fetch(n,{...vt,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 op(e,t,n={}){const o=new URL(`${e.baseUrl}${ht.content.root}/${encodeURIComponent(t)}`);n.sort_by&&o.searchParams.set("sort_by",n.sort_by),n.sort_direction&&o.searchParams.set("sort_direction",n.sort_direction),n.include_metadata&&o.searchParams.set("include_metadata",n.include_metadata),n.item&&o.searchParams.set("item",n.item);const i=gt(e),r=await fetch(o.toString(),{...vt,method:"GET",headers:i});if(!r.ok){const e=await r.text();throw new Error(`Failed to get content (${r.status}): ${e}`)}return await r.json()}async function ip(e,t,n){const o=`${e.baseUrl}${ht.content.root}/${t}`,i=gt(e),r={...n};if(n.thumbnail){const e=n.thumbnail,t=el(await e.arrayBuffer());r.upload_thumbnail={name:e.name,content_size:e.size,content_type:e.type,content_md5:t}}const a=await fetch(o,{...vt,method:"PATCH",headers:{...i,"Content-Type":"application/json"},body:JSON.stringify(r)}).catch(e=>({error:e.message,status:500}));if("error"in a)return a;if(!a.ok)return{error:await a.text(),status:a.status};const s=await a.json();if(s.upload_thumbnail&&n.thumbnail){let e=null;for(let t=0;t<5;t++){const o=s.upload_thumbnail,i=o.put_url,r=await fetch(i,{method:"PUT",headers:{"Content-Type":o.content_type,"Content-MD5":o.content_md5},body:n.thumbnail}).catch(e=>({error:e.message,status:500}));if("error"in r)e=r,await kl(100*t);else{if(r.ok){e=null;break}e={error:await r.text(),status:r.status},await kl(100*t)}}e&&console.error("Failed to upload thumbnail",e.status,e.error)}return{success:!0}}async function rp(e,t){const n=`${e.baseUrl}${ht.content.root}/${t}`,o=gt(e),i=await fetch(n,{...vt,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()}async function ap(e,t){const n=`${e.baseUrl}${ht.content.root}/${t}/restore`,o=gt(e),i=await fetch(n,{...vt,method:"POST",headers:o});if(!i.ok){const e=await i.text();throw new ft(i.status,e,`Failed to restore content (${i.status}): ${e}`)}return i.json()}const sp={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 cp(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function lp(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function pp(e){if(!(cp(e)&&lp(e.requestIndex)&&!(e.requestIndex<1)&&"string"==typeof e.model&&e.model&&lp(e.requestBytes)&&lp(e.messagesBytes)&&lp(e.toolsBytes)&&lp(e.messageCount)&&lp(e.toolCount)&&cp(e.messageRoles)))throw new Error("Invalid chat request diagnostics");const t=Object.create(null);let n=0;for(const[o,i]of Object.entries(e.messageRoles)){if(!lp(i))throw new Error("Invalid chat request diagnostic role count");t[o]=i,n+=i}if(n!==e.messageCount)throw new Error("Inconsistent chat request diagnostic message count");return{requestIndex:e.requestIndex,model:e.model,requestBytes:e.requestBytes,messagesBytes:e.messagesBytes,toolsBytes:e.toolsBytes,messageCount:e.messageCount,toolCount:e.toolCount,messageRoles:t}}function up(e){let t;try{t=JSON.parse(e)}catch{return null}if(!(t&&"object"==typeof t&&"code"in t&&"ai_allowance_exhausted"===t.code&&"limit_reached"in t&&!0===t.limit_reached&&"message"in t&&"string"==typeof t.message&&"account_id"in t&&"string"==typeof t.account_id&&"actions"in t&&Array.isArray(t.actions)))return null;const n=[];for(const e of t.actions){if(!e||"object"!=typeof e||!("kind"in e)||"top_up"!==e.kind&&"view_usage"!==e.kind||!("label"in e)||"string"!=typeof e.label||!("url"in e)||"string"!=typeof e.url)return null;let t;try{t=new URL(e.url)}catch{return null}if("https:"!==t.protocol&&"http:"!==t.protocol)return null;n.push({kind:e.kind,label:e.label,url:e.url})}return{code:t.code,limit_reached:!0,message:t.message,account_id:t.account_id,actions:n}}class dp extends Error{constructor(e,t,n=null){super(e),this.name="AIChatError",this.status=t,this.details=n}}function mp(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"request_diagnostics":i={type:"request_diagnostics",diagnostics:pp(JSON.parse(o))};break;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":{const e=decodeURIComponent(o),t=up(e);i=t?{type:"error",message:t.message,details:t}:{type:"error",message:e};break}case"notice":i={type:"notice",message:decodeURIComponent(o)};break;case"stopped":i={type:"stopped"};break;case"tool-input-available":case"tool-output-available":i={...JSON.parse(o),type:n};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 fp(e,t){var n,o;const i=gt(e);return null!=t&&t.personal&&(i["x-needle-ai-chat"]="personal"),null!=t&&t.instanceId&&(i["x-needle-instance-id"]=t.instanceId),!0===(null==t||null==(n=t.capabilities)?void 0:n.questionForms)&&(i["x-needle-chat-question-forms"]="1"),!0===(null==t||null==(o=t.capabilities)?void 0:o.inlineToolCalls)&&(i["x-needle-chat-inline-tools"]="1"),i}function hp(e,t){return t.stream?async function*(e,t){const n=new URL(e.baseUrl+ht.ai.chat),o=fp(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!0,project_id:t.projectId,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,tool_policy:t.toolPolicy},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();throw new dp(`Failed to stream chat message (${r.status}): ${e}`,r.status,up(e))}if(!r.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 r=o.split("\n\n");o=r.pop()||"";for(const e of r){const t=mp(e);t&&(yield t)}}if(o.trim()){const e=mp(o);e&&(yield e)}}finally{t.releaseLock()}}(r.body)}(e,t):async function(e,t){const n=new URL(e.baseUrl+ht.ai.chat),o=fp(e,t);o["Content-Type"]="application/json";const i={type:"new_message",slug:t.slug,message:t.message,stream:!1,project_id:t.projectId,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,tool_policy:t.toolPolicy},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();throw new dp(`Failed to send chat message (${r.status}): ${e}`,r.status,up(e))}return await r.json()}(e,t)}const gp=200,vp=["github.com","gitlab.com","bitbucket.org"],bp=/[\w.+-]+@[\w-]+\.[\w.]+/;function yp(e){if(e)return bp.test(e)?void 0:e}function xp(e,t){return String(b("git",e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],...t?{cwd:t}:{}})||"").trim()}function wp(e,t){try{return xp(e,t)}catch{return""}}function _p(e){try{const t=xp(["rev-parse","HEAD"],e);if(!t)return null;const n=wp(["rev-parse","--abbrev-ref","HEAD"],e),o=wp(["log","-1","--pretty=%s"],e),i=yp(wp(["log","-1","--pretty=%an"],e)),r=wp(["status","--porcelain"],e).length>0,a=wp(["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?vp.includes(o)?{repository:i,url:`https://${o}/${i}/${"bitbucket.org"===o?"commits":"commit"}/${t}`}:{repository:i}:{}}(a,t),p={type:"git",id:t,label:`${n||s}@${s}${r?" (dirty)":""}`};return n&&(p.branch=n),i&&(p.author=i),o&&(p.message=o.slice(0,gp)),r&&(p.dirty=!0),c&&(p.repository=c),l&&(p.url=l),p}catch{return null}}function jp(e){if("string"==typeof e)return e.trim()||void 0}const kp="https://cloud.needle.tools/api",Sp=()=>"https://cloud.needle.tools/account",Ep=()=>"https://cloud.needle.tools/edit";function Tp(e){return y(e)}const $p=["node_modules",".git",".vscode",".vercel",".github",".idea"];function Ip(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=Xc(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 r=u(t,{withFileTypes:!0});for(const i of r)if(0==i.isDirectory()){if("optimization"===e&&0==((a=(a=i.name).toLowerCase()).endsWith(".glb")||a.endsWith(".gltf")||a.endsWith(".vrm")||a.endsWith(".usdz")||a.endsWith(".usd")||a.endsWith(".fbx")))continue;const r=Xc(o+i.name,p(t+"/"+i.name));if(n.files.push(r),n.total_size+=r.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 a;for(const a of r)if(a.isDirectory()){if($p.includes(a.name))continue;Ip(e,t+"/"+a.name,n,o+a.name+"/",i+1)}return n}const Ap=new RegExp("\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g"),Op=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"),Cp=new RegExp("(Authorization:\\s*)([^\\s,;\"']+(?:\\s+[^\\s,;\"']+)?)","gi"),Np=new RegExp("\\bBearer\\s+([A-Za-z0-9._\\-=]+)","g"),Rp=new RegExp("([?&]token=)([^&\\s\"'<>]+)","g"),Pp=new RegExp("<redacted:\\d+ch>","g");function Up(e){if("string"!=typeof e)return e;if(0===e.length)return e;if(Pp.test(e)&&(Pp.lastIndex=0,!function(e){Ap.lastIndex=0,Op.lastIndex=0,Cp.lastIndex=0,Np.lastIndex=0,Rp.lastIndex=0;const t=Ap.test(e)||Op.test(e)||Cp.test(e)||Np.test(e)||Rp.test(e);return Ap.lastIndex=0,Op.lastIndex=0,Cp.lastIndex=0,Np.lastIndex=0,Rp.lastIndex=0,t}(e.replace(Pp,""))))return e;Pp.lastIndex=0;let t=e;return t=t.replace(Cp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(Rp,(e,t,n)=>`${t}<redacted:${n.length}ch>`),t=t.replace(Np,(e,t)=>`<redacted:${("Bearer "+t).length}ch>`),t=t.replace(Ap,e=>`<redacted:${e.length}ch>`),t=t.replace(Op,e=>`<redacted:${e.length}ch>`),t}const Lp=["cli.log","cli.prev.log"],zp=ie.join(te.homedir(),".needle","cli","logs");I(zp,{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(!$(e))return n;for(const o of Lp){const i=ie.join(e,o);if($(i))try{I(t,{recursive:!0});const e=ie.join(t,o);if($(e)){const e=ie.join(t,o.replace(/\.log$/,"")+".legacy.log");A(i,e),n.skipped.push(o)}else A(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(O(te.tmpdir()),"Needle","Cloud","logs"),zp)}catch(e){console.error(`[needle-cloud] legacy log migration check failed: ${e instanceof Error?e.message:e}`)}const Fp=ie.resolve(zp,"cli.log");if($(Fp)){const e=C(Fp),t=e.mtimeMs;if(Date.now()-t>432e5||e.size>52428800){const e=qp();N(Fp,e,t=>{t?console.error(`Failed to rename log file: ${t.message}`):console.log(`Log file renamed to ${e}`)})}}function Dp(){return Fp}function qp(){return ie.resolve(zp,"cli.prev.log")}function Bp(e,t){try{let n=Up(String(null!=e?e:""));return n=`[${(new Date).toISOString()}] ${n}`,null!=t&&t.emptyLineBefore&&(n="\n"+n),R(Fp,n+"\n"),!0}catch(e){return console.error(`Failed to write to log file: ${e instanceof Error?e.message:e}`),!1}}async function Mp(e,t){return e=Up(e),e=`[${(new Date).toISOString()}] ${e}`,null!=t&&t.emptyLineBefore&&(e="\n"+e),J(Fp,e+"\n",{flag:"a"}).then(()=>!0).catch(e=>(console.error(`Failed to write to log file: ${e.message}`),!1))}var Wp={__proto__:null,getLogFilePath:Dp,getPrevLogsFilePath:qp,getPipelineLogFilePath:function(){return ie.join(te.homedir(),".needle","optimization-pipeline","logs","pipeline.log")},writeToLogFileSync:Bp,writeToLogFile:Mp};function Gp(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 Hp(e){var t;e.directory=x.resolve(e.directory);let{files:n,entrypoint:o}=Ip("deployment",e.directory);if(e.entrypoint&&(o=n.find(t=>t.path===e.entrypoint),!o))return process.exitCode=1,void T().fail(`Entrypoint "${e.entrypoint}" not found. Please make sure you provide a valid entrypoint.`);if(!o){const e=$l(n);if("error"in e)return process.exitCode=1,Mp(`[Deployment] Error determining entrypoint: ${e.error}`),void T().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,Mp("[Deployment] Deployment is not valid: No .html file found."),void T().fail("Deployment is not valid: No .html file found.");if(!o)return process.exitCode=1,Mp("[Deployment] No entrypoint found. Please provide an index.html file in your project."),void T().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 r=e.name;r||(r=Jp(e.directory)||void 0);let a=null==i?void 0:i.includes("localhost");const s=r?` of "${r}"`:"",c=T().start(`Begin deployment${s} ${a?"(local)":""} of ${n.length} files...`);c.spinner="earth",await kl(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(jp(e.NEEDLE_CLOUD_NO_PROVENANCE))return null;let n=_p(t);jp(e.GITHUB_ACTIONS)&&(n=function(e,t){var n,o;const i=jp(t.GITHUB_SHA),r=jp(t.GITHUB_REF_NAME),a=jp(t.GITHUB_REPOSITORY),s=null!=(n=jp(t.GITHUB_SERVER_URL))?n:"https://github.com";if(!i&&!r)return e;const c={type:"git",...null!=e?e:{}};i&&(c.id=i),r&&(c.branch=r),a&&(c.repository=a),a&&i&&(c.url=`${s}/${a}/commit/${i}`);const l=String(null!=(o=c.id)?o:"").slice(0,7);return l&&(c.label=`${r||l}@${l}${c.dirty?" (dirty)":""}`),c}(n,e));const o=function(e=process.env){var t;if(!jp(e.CI))return{type:"local"};if(!jp(e.GITHUB_ACTIONS))return{type:"ci"};const n={type:"github-actions"},o=jp(e.GITHUB_RUN_ID),i=jp(e.GITHUB_REPOSITORY),r=null!=(t=jp(e.GITHUB_SERVER_URL))?t:"https://github.com";o&&(n.id=o);const a=yp(jp(e.GITHUB_ACTOR));return a&&(n.actor=a),jp(e.GITHUB_EVENT_NAME)&&(n.event=jp(e.GITHUB_EVENT_NAME)),o&&i&&(n.url=`${r}/${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&&_p(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;Mp(`[provenance] ${e}${t?` by ${t}`:""} (${null==(d=u.runner)?void 0:d.type})`)}Mp(`Deployment started${s} ${a?"(local)":""} of ${n.length} files...`);const m=await Fl({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:r,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&&Tp(t);try{Gp("deployment_url",t,{logger:e.logger}),Gp("edit_id",m.content_id,{logger:e.logger})}catch(t){e.logger.error("Error writing output for CI: "+t)}return m}{process.exitCode=1;const e=p||(null==m?void 0:m.error)||"Deployment failed";Mp(`[Deployment] Failed: ${e}`),c.fail(e)}}function Jp(e,t=0){if(t>10)return null;const n=x.join(e,"needle.config.json");if(c(n)){const t=x.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 x.basename(e)}const i=x.dirname(e);return i===e?null:Jp(i,t+1)}const Vp={getContent:op,updateContentLabel:async function(e,t={}){const n={...gt(e),content_id:e.content_id,job_id:e.job_id,type:e.type,action:e.action};try{const t=await fetch(`${e.baseUrl}${ht.view.post_version}`,{...vt,method:"POST",headers:n});if(!t.ok){const e=await t.text();throw new ft(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 Kp(e){if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new Error("Invalid content identifier; use the item ID shown by list or upload.")}function Yp(e){if(Kp(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 Zp(e,t){if(e.identifier!==t)throw new Error("The returned content does not match the requested content item.")}function Xp(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 Qp(e,t,n=Vp){Kp(t);const o=await n.getContent(e,t);return Zp(o,t),Xp(o)}async function eu(e,t,n=Vp){var o,i;Yp(t);const r=await n.getContent(e,t.contentId);Zp(r,t.contentId);const a=Xp(r);let s=t.versionId;if(t.from){const e=a.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=r.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 Qp(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=a.labels.find(e=>e.label===t.label))?void 0:i.sourceVersionIds)?o:[],targets:u.targets}}const tu=/token|secret|password|authorization|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret/i;function nu(e,t){return async function(n){const o=function(e,t){const n=[];if(e&&Object.keys(e).length>0&&n.push(`args=${ou(e)}`),t&&Object.keys(t).length>0){const e=Object.fromEntries(Object.entries(t).map(([e,t])=>tu.test(e)?[e,"<redacted>"]:[e,t]));n.push(`options=${ou(e)}`)}return n.join(" ")}(null==n?void 0:n.args,null==n?void 0:n.options);Mp(`CLI action: ${e}${o?" "+o:""}`);const i=Date.now();try{const o=await t(n);return Mp(`CLI action: ${e} succeeded in ${Date.now()-i}ms`),o}catch(t){const n=t instanceof Error?t.message:String(t);throw Bp(`CLI action: ${e} failed in ${Date.now()-i}ms: ${n}`),t}}}function ou(e){try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():"function"==typeof t?"<fn>":t)}catch{return"<unserializable>"}}function iu(e,t){const n=t.team||t.org;return!0===t.nonInteractive?e(t.token,n,!1):e(t.token,n)}function ru(e,t={}){var n;const o=e.output;if(void 0!==o&&"cli"!==o&&"json"!==o)throw new Error("Invalid --output. Use cli or json.");const i=t.legacyFormat?e.format:void 0;if(void 0!==i&&"cli"!==i&&"json"!==i&&(!t.links||"source-url"!==i&&"edit-url"!==i))throw new Error(`Invalid --format. Use cli, json${t.links?", source-url or edit-url":""}.`);if(void 0!==o&&void 0!==i&&o!==i)throw new Error("--output and the legacy output --format must agree.");const r=null!=(n=null!=o?o:i)?n:"cli";if("cli"===r||"json"===r||"source-url"===r||"edit-url"===r)return r;throw new Error("Invalid output mode.")}async function au(e,t){if(!e)return t();const n=globalThis.console;globalThis.console=new Re({stdout:process.stderr,stderr:process.stderr});try{return await t()}finally{globalThis.console=n}}function su(e){return t=>au("json"===t.options.output||"json"===t.options.format,()=>e(t))}function cu(e){process.stdout.write(JSON.stringify(e)+"\n")}async function lu(e){await new Promise((e,t)=>{process.stdout.write("",n=>n?t(n):e(void 0))}),process.exit(e)}function pu(e,t){return e.options.some(e=>e.name===t)}function uu(e){for(const t of e.getCommands())(pu(t,"token")||["login","logout","me"].includes(t.name))&&(pu(t,"output")||t.option("--output <output>","Output style: cli (default) or json",{validator:e.STRING}),pu(t,"nonInteractive")||t.option("--non-interactive","Use saved credentials or a token; never prompt or open a browser",{validator:e.BOOLEAN,default:!1}))}function du(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 mu(e){const n={};if(void 0!==e.title){const t=String(e.title);if(t.length>255)throw new Error("Title must be at most 255 characters.");n.title=t}if(void 0!==e.description){const t=String(e.description);if(t.length>512)throw new Error("Description must be at most 512 characters.");n.description=t}if(void 0!==e.tags){const t=String(e.tags),o=t.split(/[,;\n\r]+/).map(e=>e.trim()).filter(Boolean);if(!o.length||t.length>512||o.length>40||o.some(e=>e.length>=50))throw new Error("Pass 1–40 tags, each under 50 characters, with at most 512 characters total.");n.tags=t}if(void 0!==e.thumbnail){const o=String(e.thumbnail),i=re(o).toLowerCase(),r=".png"===i?"image/png":".webp"===i?"image/webp":".jpg"===i||".jpeg"===i?"image/jpeg":void 0;if(!r)throw new Error("Thumbnail must be a JPEG, PNG or WebP file.");const a=await V(o);if(!a.length||a.length>5242880)throw new Error("Thumbnail must be nonempty and at most 5 MiB.");n.thumbnail=new t([a],ae(o),{type:r})}if(!Object.keys(n).length)throw new Error("Nothing to update. Pass --title, --description, --tags or --thumbnail.");return n}function fu(e){return[e,...e.variants].map(e=>{var t,n;const o=e.labels.map(e=>e.label).join(", ");return` ${e.identifier} ${null!=(t=e.content_format)?t:""} ${null!=(n=e.status)?n:"completed"}${o?` [${o}]`:""}${e.url?` ${e.url}`:""}\n`}).join("")}function hu(e,t={input:!0===process.stdin.isTTY,output:!0===process.stdout.isTTY}){return!0===e.interactive?(gu(e,t),!0):!(!1===e.interactive||!0===e.nonInteractive||"json"===e.output||!t.input||!t.output||(gu({...e,interactive:!0},t),0))}function gu(e,t={input:!0===process.stdin.isTTY,output:!0===process.stdout.isTTY}){var n,o;if(!0!==e.interactive)return;if(!0===e.nonInteractive||"json"===e.output)throw new Error("--interactive cannot be combined with --non-interactive or --output json.");if(!t.input||!t.output)throw new Error("--interactive requires terminal input and output. Omit it for scripts, Unity or redirected output.");const i=Number(null!=(n=e.limit)?n:20),r=Number(null!=(o=e.offset)?o:0);if(!Number.isInteger(i)||i<1||i>100)throw new Error("--limit must be an integer from 1 to 100 for interactive browsing.");if(!Number.isInteger(r)||r<0)throw new Error("--offset must be a nonnegative integer for interactive browsing.")}function vu(e){return Ue(null!=e?e:"").replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}function bu(e,t){const n=Array.from(vu(e));return n.length<=t?n.join(""):n.slice(0,Math.max(0,t-1)).join("")+"…"}function yu(e,t,n){return e.color?`${"brand"===n?"[1;38;2;173;245;39m":"[2m"}${t}[0m`:t}function xu(e,t,n){var o;const i=Math.max(20,Math.min(e.columns-4,100)),r=null!=(o=n.offset)?o:0;e.write("\n "+yu(e,"NEEDLE CLOUD","brand")+` / ${n.trash?"Trash":"Content"}\n`),e.write(" "+yu(e,"─".repeat(i),"dim")+"\n"),e.write(` ${t.items.length?`${r+1}–${r+t.items.length}`:"0"} of ${t.total} items${n.search?` · Search: ${vu(n.search)}`:""}\n\n`),t.items.length||e.write(" No content found. Try / to clear search, or t to switch Trash.\n"),t.items.forEach((t,n)=>{var o;const r=`${n+1}`.padStart(2);e.write(` ${yu(e,r,"brand")} ${bu(t.title||t.identifier,i-4)}\n`);const a=`${null!=(o=t.content_type)?o:"content"} · ${t.content_formats.join(", ")||"no formats"} · ${t.version_count} versions · ${t.identifier}`;e.write(" "+yu(e,bu(a,i-4),"dim")+"\n")}),e.write("\n Number inspect · /text search · n/p pages · t Trash\n"),e.write(" r refresh · ? help · q quit\n")}function wu(e,t,n,o){const i=Math.max(20,Math.min(e.columns-4,100));e.write("\n "+yu(e,bu((null==n?void 0:n.title)||t.title||t.identifier,i),"brand")+"\n"),e.write(` ID: ${vu(t.identifier)}\n`),(null!=n&&n.description||t.description)&&e.write(` ${vu((null==n?void 0:n.description)||t.description)}\n`);const r=(null==n?void 0:n.tags)||t.tags;null!=r&&r.length&&e.write(` Tags: ${r.map(vu).join(", ")}\n`),o&&e.write(` In Trash${t.deleted_at?` since ${vu(t.deleted_at)}`:""}. Restore to inspect versions.\n`);for(const t of null!=(a=null==n?void 0:n.versions.slice(0,8))?a:[]){var a,s;const n=t.labels.map(e=>vu(e.label)).join(", ");e.write(` ${vu(t.identifier)} ${vu(t.content_format)} ${vu(null!=(s=t.status)?s:"completed")}${n?` [${n}]`:""}\n`);for(const n of t.variants){var c;e.write(` ↳ ${vu(n.identifier)} ${vu(n.content_format)} ${vu(null!=(c=n.status)?c:"completed")}\n`)}}n&&n.versions.length>8&&e.write(" More versions: needle-cloud versions <identifier>\n");const l=/^[\w.-]+$/.test(t.identifier)?t.identifier:"<identifier>";e.write("\n Continue from the terminal:\n"),o?e.write(` needle-cloud restore ${l}\n`):(e.write(` needle-cloud info ${l} --output json\n`),"editor-project"!==t.item_type&&e.write(` needle-cloud download ${l}\n needle-cloud update ${l} --title "New title"\n`)),e.write(" Keep the same --team and --endpoint options for these commands.\n"),e.write(o?"\n b back · q quit\n":"\n o open viewer · e edit in browser · b back · q quit\n")}async function _u(e,t,n){if(!e)return void t.write(" No web URL is available for this action.\n");let o;try{o=new URL(e)}catch(e){if(!(e instanceof TypeError))throw e;return void t.write(" This item does not have a valid web URL.\n")}"https:"===o.protocol||"http:"===o.protocol?await n(e):t.write(" No web URL is available for this action.\n")}async function ju(e,t={}){var n,o,i,r;const a=null!=(n=t.terminal)?n:function(){const e=Pe({input:process.stdin,output:process.stdout,terminal:!0,historySize:0}),t=new AbortController;return e.on("SIGINT",()=>{t.abort(),e.close()}),e.on("close",()=>t.abort()),{get columns(){return process.stdout.columns||80},color:void 0===process.env.NO_COLOR&&"dumb"!==process.env.TERM,write:e=>{process.stdout.write(e)},async readLine(n){if(t.signal.aborted)return null;try{return await e.question(n,{signal:t.signal})}catch(e){if(t.signal.aborted)return null;throw e}},close:()=>e.close()}}(),s=null!=(o=t.listContent)?o:np,c=null!=(i=t.getContent)?i:op,l=null!=(r=t.open)?r:Tp;let p,u={...e.query},d=e.initial;try{for(xu(a,d,u);;){var m,f;const t=await a.readLine(yu(a,"\n › ","brand"));if(null===t)break;const n=t.trim();if("q"===n||"quit"===n)break;if(p){"b"===n?(p=void 0,xu(a,d,u)):u.trash||"o"!==n?u.trash||"e"!==n?a.write(" Choose o/e to open, b to go back, or q to quit.\n"):await _u(p.edit_url,a,l):await _u(p.view_url||p.url,a,l);continue}if(/^\d+$/.test(n)){var h;const t=d.items[Number(n)-1];if(!t){a.write(" Choose a number shown on this page.\n");continue}const o=u.trash?void 0:await c(e.auth,t.identifier,{item:null!=(h=t.item_type)?h:"content"});p=t,wu(a,t,o,!0===u.trash);continue}if("?"===n||"help"===n){a.write("\n Type a number and Enter to inspect an item.\n /wood searches; / clears search. n/p move between pages.\n t switches between content and Trash; r refreshes the page.\n Browsing never changes content. Opening a browser requires o/e.\n q, Ctrl+C or end of input leaves the browser.\n");continue}const o=null!=(m=u.offset)?m:0,i=null!=(f=u.limit)?f:20;if("n"===n){if(o+d.items.length>=d.total){a.write(" No next page.\n");continue}u={...u,offset:o+i}}else if("p"===n){if(!o){a.write(" Already on the first page.\n");continue}u={...u,offset:Math.max(0,o-i)}}else if(n.startsWith("/"))u={...u,offset:0,search:n.slice(1).trim()||void 0};else if("t"===n)u={...u,offset:0,trash:!u.trash};else if("r"!==n){a.write(" Type a number, /search, n, p, t, r, ? or q.\n");continue}d=await s(e.auth,u),xu(a,d,u)}a.write("\n Back to your terminal.\n")}finally{a.close()}}async function ku(e){if(!e.outDir)throw new Error("Output directory is required");const t=T("Downloading results...").start(),n=await async function(e){const t=await async function(e){if(!e.identifier)return null;const t={...gt(e)},n={job_id:e.identifier,fields:e.fields,content_format:e.content_format,content_type:e.content_type},o=e.baseUrl+ht.jobs.query,i=await fetch(o,{...vt,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 r=await i.json().catch(e=>(console.error(e),null));return null==r?null:r.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)||wc.test(i)||i.endsWith(".needle.log"))continue;const r=`${n.directory}/${t.filename}`,a=await Xl(e,e.identifier,{bucket:n.bucket,key:r});if(!a){console.error(`Failed to get presigned URL for: ${t.filename}`);continue}const s=await fetch(a).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 r=i.filename;if(e.filename){const t=i.filename.substring(i.filename.lastIndexOf("."));if(1===n.files.length)r=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("."));r=e.filename+"-"+n+t}}const a=e.outDir+"/"+r,s=a.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 "${a}"`),f(a,Buffer.from(i.data)),o.push(a)}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 Su(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 T().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 ${Sp()}`};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=T(`Gathering files ${e.fileOrDirectory}`).start();let i=null;try{i=Ip("optimization",e.fileOrDirectory)}catch(t){return T().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 r=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 a="https://cloud.needle.tools/api";e.verbose&&console.log("Using endpoint:",a);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=>nl(e.name)||ol(e.name)||il(e.name));return 1===t.length&&$l(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&&Il.has(n)}),canConvertToGLB:Al.has(o)}}(i.files),l="asset"===s.kind||"deployment"===s.contentType?void 0:s.contentType,p=await Fl({baseUrl:a,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||`${Ep()}/${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:r}}(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:r}=n,a=r.map(e=>({path:e,sourceUrl:yt({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===a.length?a[0].sourceUrl:null,files:a,optimizedUrl:null,processingStatus:e.noOptimize?"not_requested":"unknown"};if(e.noOptimize&&T().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+ht.jobs.create,o={...gt(e),"content-type":"application/json"},i={type:"optimization",job_id:e.id,triggered_by:e.trigger_type,parameters:{...t}},r=await fetch(n,{...vt,method:"POST",headers:o,body:JSON.stringify(i)});if(!r.ok){const e=await r.text();return console.error(`Failed to request optimization (${r.status}): ${e} `),null}return await r.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=T(`Optimization requested for ${d.name||d.identifier}`).start(),f=kc();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 jc(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 kl(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 kl("running"===h?1e3:"stalled"===h?2500:2e3))}}if(m.succeed("Optimization completed"),s.processingStatus="completed",s.optimizedUrl=yt({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 ku({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 Eu(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 Tu(e){const{token:t,org_id:n,slug:o,message:i,stream:r}=e;if(r){const e=hp({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.stderr.write(`[${t.message}]\n`);break;case"error":throw new Error(t.message);case"tool_call":process.stderr.write(`[tool: ${t.name}]\n`);break;case"done":process.stdout.write("\n")}}else{const r=T("Thinking...").start(),a=await hp({baseUrl:"https://cloud.needle.tools/api",authToken:t,org:n},{slug:o,message:i,stream:!1,source:"cli"});r.stop(),"json"===e.output?cu(a):process.stdout.write(a.content+"\n")}}async function $u(e,t=rp){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 Iu(e){const t=new URL((e.endpoint||"https://cloud.needle.tools/api")+ht.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:{...gt({authToken:e.authToken,org:e.org})}});return n.ok?await n.json():{status:n.status,error:await n.text()}}const Au=["#e06c75","#d19a66","#e5c07b","#98c379","#7ec8a4","#56b6c2","#61afef","#528bff","#c678dd","#e88de4","#be5046","#d4976c","#b5cea8","#4ec9b0","#9cdcfe","#c8ae9d"];function Ou(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]}(Au[Math.abs(t)%Au.length]);return`[38;2;${n};${o};${i}m${e}[0m`}function Cu(e){return`[2m${e}[0m`}const Nu=8424,Ru="http://localhost:8424",Pu=/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\]\s?(.*)$/,Uu=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}):\s*(.*)$/,Lu=[[/^\[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"]],zu=[[/^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 Fu(e){for(const[t,n]of Lu)if(t.test(e))return n;return"general"}function Du(e){for(const[t,n]of zu)if(t.test(e))return n;return"info"}const qu=new RegExp("\\b([A-Z][A-Z0-9_]*(?:_KEY|_TOKEN|_SECRET|_PASSWORD))=([^\\s,;\"']+)","g"),Bu=new RegExp("\\b(User(?:name)?:\\s*)([A-Za-z0-9._\\-]{1,64})","g"),Mu=new RegExp("\\b[A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z]{2,}\\b","g"),Wu=52428800;function Gu(e,t){if(!$(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,r=Buffer.allocUnsafe(i),a=P(e,"r");try{let e=0;for(;e<i;){const t=U(a,r,e,i-e,o+e);if(0===t)break;e+=t}}finally{L(a)}if(o>0){const e=r.indexOf(10);return-1===e?"":r.slice(e+1).toString("utf8")}return r.toString("utf8")}async function*Hu(e){const t=De({input:z(e,{encoding:"utf8"}),crlfDelay:Infinity});for await(const e of t)yield e}function Ju(e,t,n,o){var i,r;if(0===e.length)return[];const a=function(e){if("string"!=typeof e)return{ts:null,level:"info",source:"general",message:""};let t=null,n=e,o=e.match(Pu);if(o)t=o[1],n=o[2];else if(o=e.match(Uu),o){const e=new Date(`${o[1]}T${o[2]}`);Number.isNaN(e.getTime())||(t=e.toISOString(),n=o[3])}return{ts:t,level:Du(n),source:Fu(n),message:n}}(e),s=null!=(i=null!=(r=a.ts)?r:n)?i:null,c=a.level,l=null!=t?t:a.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 r=0;r<o;r++){const a=r*n,s=e.slice(a,a+n);i.push(`${s} [chunk ${r+1}/${o} of ${t} bytes]`)}return i}(function(e,t){if("string"!=typeof e)return e;if(0===e.length)return e;let n=Up(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(qu,(e,t,n)=>`${t}=<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(Bu,(e,t,n)=>`${t}<redacted:${n.length}ch>`)}(n),n=function(e){return e.replace(Mu,e=>`<redacted:${e.length}ch>`)}(n),n}(a.message,o)).map(e=>({ts:s,level:c,source:l,message:e}))}const Vu="https://haystack.needle.tools/api/ingest/logs",Ku="https://haystack.needle.tools";async function Yu(e){try{return await e.json()}catch{return null}}async function Zu(e){try{return await e.text()}catch{return""}}function Xu(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 ${Vu}: ${o}`}var Qu,ed={__proto__:null,HAYSTACK_RESOURCE:Ku,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}:{}},r=t.findActiveEditorLog(),a=function(e){const t=qe.from(async function*(e){if(yield JSON.stringify(e.meta)+"\n",e.prevLogPath&&$(e.prevLogPath)){let t=null;for await(const n of Hu(e.prevLogPath)){const o=Ju(n,null,t,e.redactOpts);for(const e of o)e.ts&&(t=e.ts),yield JSON.stringify(e)+"\n"}}if(e.cliLogPath&&$(e.cliLogPath)){let t=null;for await(const n of Hu(e.cliLogPath)){const o=Ju(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:Wu,i=null!=(n=e.editor.paths)?n:e.editor.path?[e.editor.path]:[];for(const t of i){const n=Gu(t,o);if(!n)continue;let i=null;try{i=C(t).mtime.toISOString()}catch{}for(const t of n.split("\n")){const n=Ju(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&&$(e.pipelineLogPath)){var o;const t=null!=(o=e.pipelineTailBytes)?o:Wu,n=Gu(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=Ju(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(Be())}({meta:i,cliLogPath:t.paths.cliLogPath,prevLogPath:t.paths.prevLogPath,editor:r,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 a)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 a)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(Vu,{method:"POST",body:s,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/x-ndjson","Content-Encoding":"gzip"}})}catch(e){return{ok:!1,error:Xu(e)}}if(401===c.status){const e=await Zu(c);return{ok:!1,error:`401 Unauthorized from ${Vu}: ${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 Zu(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 Yu(c);return{ok:!0,refId:null==e?void 0:e.ref_id,truncated:!0}}if(!c.ok){const e=await Zu(c);return(400===(l=c.status)||l>=500)&&await async function({token:e,fetch:t,baseMeta:n,status:o,bodyText:i}){const{gzipSync:r}=await import("node:zlib"),a={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(a)+"\n"+JSON.stringify(s)+"\n",l=r(Buffer.from(c,"utf8"));await t(Vu,{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 Yu(c);return{ok:!0,refId:null==p?void 0:p.ref_id,truncated:Boolean(null==p?void 0:p.truncated)}}};const td={appId:"2stnsoa6a1b0gwc7lra55",appSecret:"seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",endpoint:"https://auth.needle.tools",resources:["https://cloud.needle.tools/api",Ku],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"]},nd={getAccessToken:!0,fetchUserInfo:!0,resource:null==(Qu=td.resources)?void 0:Qu[0],resources:td.resources||[],scopes:td.scopes||[]};function od(e="default"){return null==e?`${Ru}/?signed-out=1`:"too-many-logins"===e?`${Ru}/?too-many-logins=1`:"error"===e?`${Ru}/?error=1`:`${Ru}/?signed-out=1`}var id;function rd(){sd.clear(),s.existsSync(pd)&&s.rmSync(pd,{recursive:!0}),s.existsSync(ud)&&s.rmSync(ud,{recursive:!0})}const ad=process.argv.includes("--debug-auth"),sd=new Map;let cd=null==(id=td.resources)?void 0:id[0];if(cd)try{cd=new URL(cd).hostname}catch(e){ad&&console.error("Invalid resource URL",cd)}let ld=cd||"-";ld=ld.replace(/[^a-zA-Z0-9\.\-]/g,"");const pd=x.join($e(),".needle",".auth",ld),ud=`${Ie()}/Needle/Cloud/.auth/${ld}`;!function(){if(s.existsSync(ud)){ad&&console.debug("Migrating auth data from legacy location",ud,"→",pd);try{s.existsSync(pd)||s.mkdirSync(pd,{recursive:!0,mode:448});for(const e of s.readdirSync(ud)){const t=x.join(ud,e),n=x.join(pd,e);s.statSync(t).isFile()&&!s.existsSync(n)&&(s.copyFileSync(t,n),s.chmodSync(n,384))}s.rmSync(ud,{recursive:!0}),ad&&console.debug("Legacy auth data migrated successfully")}catch(e){ad&&console.error("Failed to migrate legacy auth data",e)}}}();const dd={accessToken:`${pd}/accessToken`,refreshToken:`${pd}/refreshToken`,idToken:`${pd}/idToken`,signInSession:`${pd}/signInSession`};function md(e){return dd[e]||`${pd}/${e}`}const fd=new class{constructor(){this.basePath=pd}async setItem(e,t){ad&&console.debug("\n- SET ITEM",e,t),s.existsSync(this.basePath)||s.mkdirSync(this.basePath,{recursive:!0,mode:448});const n=md(e);n&&s.writeFileSync(n,t,{mode:384}),sd.set(e,t)}async getItem(e){ad&&console.debug("\n- GET ITEM",e);const t=sd.get(e);if(void 0===t){const t=md(e);if(t){if(s.existsSync(t)){const n=s.readFileSync(t,"utf8");return sd.set(e,n),n}}else console.error(`Unknown token name: ${e}`);return null}return String(t)}async removeItem(e){ad&&console.debug("\n- REMOVE ITEM",e),sd.delete(e);const t=md(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 hd=null;function gd(){return hd||(hd=new Fe(td,{storage:fd,navigate:()=>{}})),hd}function vd(){hd=null}let bd=Promise.resolve();function yd(e){const t=bd.then(e,e);return bd=t.then(()=>{},()=>{}),t}async function xd(e){return wd(gd(),e)}async function wd(e,t){try{const n=await yd(()=>e.getAccessToken(t));return null!=n?n:null}catch(e){return function(e){return Boolean(e)&&"object"==typeof e&&"not_authenticated"===e.code}(e)||(Mp(`Token refresh failed for resource ${t}: ${e instanceof Error?e.message:e}`),_d(e)&&(Mp(`Token refresh: clearing dead grant for resource ${t}`),rd(),hd=null)),null}}function _d(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 jd(){return xd(nd.resource)}function kd(){return Td(gd())}async function Sd(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."),Mp("WARN: You do not have a default organization set. Please visit your Needle Cloud account settings and then try again."),null):null}function Ed(e){return new Fe(td,{storage:fd,navigate:t=>{if(null==e.navigate)throw new Error("Can not navigate");e.navigate(t)}})}function Td(e){return function(e,t){return yd(()=>e.getContext(t))}(e,nd).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?(Mp(`OIDC: ${e.code} – token refresh failed, clearing stale tokens`),rd(),hd=null,console.error("Session expired – please log in again: npx needle-cloud login")):e.code?(console.error(e.code),Mp(`OIDC: ${e.code} – ${t}`)):Mp(`OIDC: getContext failed – ${t}`),null})}var $d={__proto__:null,resetSharedClient:vd,tryGetFreshAccessTokenForResource:xd,acquireAccessToken:wd,shouldClearAuthOnError:_d,tryGetFreshAccessToken:jd,tryGetUser:kd,tryGetDefaultOrgId:Sd,createNodeClient:Ed,getUserFromClient:Td};function Id(e){var t,n,o,i;if(!e)return"";let r=(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 a;return(!r||r.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==(a=e.claims)?void 0:a.email):r}async function Ad(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 r=null;if(null==t)r=e.accessToken;else if(null!=t){var a;let n=null==e||null==(a=e.userInfo)||null==(a=a.organization_data)?void 0:a.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,r=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 r?{authToken:r,org:t}:{status:403,error:"No access token found"}}const Od=function(){return async(e,t,n)=>{const o=await kd();Object.defineProperty(e,"user",{enumerable:!0,get:()=>o}),n()}};function Cd(e){return e instanceof Error&&("code"in e&&"ECONNREFUSED"===e.code||!(!("cause"in e)||!Cd(e.cause))||e instanceof AggregateError&&e.errors.length>0&&e.errors.every(Cd))}function Nd(e,t,n){let o=!1;e.post("/stop",(e,i)=>{t&&e.headers.authorization===`Bearer ${t}`?(o||(o=!0,i.once("finish",n)),i.status(202).json({status:"stopping"})):i.status(401).send("Unauthorized: local server bearer token required")})}function Rd(e,t,n,o={}){var i,r;const a=null!=(i=o.exit)?i:e=>process.exit(e);let s=!1;const c=()=>{s||(s=!0,clearTimeout(l),a(0))},l=setTimeout(()=>{console.warn("[Needle server] Shutdown deadline reached; closing remaining connections.");for(const e of t.clients)e.terminate();null==e.closeAllConnections||e.closeAllConnections(),c()},null!=(r=o.timeoutMs)?r:3e3);n();let p=2;const u=e=>{e&&console.error("[Needle server] Error closing server",e),0==--p&&c()};for(const e of t.clients)e.close(1001,"Needle server stopping");t.close(u),e.close(u),null==e.closeIdleConnections||e.closeIdleConnections()}var Pd={__proto__:null,stopLocalServer:async function(e={}){var t,n;const o=null!=(t=e.fetch)?t:globalThis.fetch;let i;try{i=await o(`${Ru}/api/info`,{redirect:"error",signal:AbortSignal.timeout(5e3)})}catch(e){if(Cd(e))return"not-running";throw e}if(!i.ok)throw new Error(`The running server cannot be identified (HTTP ${i.status}). It may need to be closed manually.`);await i.arrayBuffer();const r=null!=(n=e.tokenFile)?n:se(ne(),".needle","local-server-token");let a;try{a=JSON.parse(await V(r,"utf8"))}catch{throw new Error("Cannot read the local server token. Older servers must be closed manually.")}if(!a||"object"!=typeof a||!("token"in a)||"string"!=typeof a.token||!a.token)throw new Error("The local server token is invalid. The server must be closed manually.");const s=await o(`${Ru}/stop`,{method:"POST",redirect:"error",signal:AbortSignal.timeout(5e3),headers:{Authorization:`Bearer ${a.token}`}});if(404===s.status)throw new Error("This server version does not support stop. Close it manually, then start an updated CLI.");if(202!==s.status)throw new Error(`The server rejected the stop request (HTTP ${s.status}).`);const c=await s.json();if(!c||"object"!=typeof c||!("status"in c)||"stopping"!==c.status)throw new Error("The server did not acknowledge the stop request.");return"stopping"},registerStopRoute:Nd,shutdownLocalServer:Rd};let Ud=null;function Ld(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 zd=Date.now();async function Fd(e){var t;const n=Date.now();n-zd>3e4&&"client"in e&&(zd=n,await e.client.fetchUserInfo().catch(console.error));const o=null==(t=e.userInfo)?void 0:t.custom_data;if(!o)return!1;if(Ud||await Dd(),!Ud)return console.error("Failed to get machine id"),!0;const i=o.machines;if(!i)return!1;const r=i.some(e=>e.id===Ud);return r}async function Dd(){return Ud||await import("node-machine-id").then(async e=>{const t=await e.default.machineId(!1);Ud=t}),Ud}function qd(){return Te.userInfo().username+"@"+Te.hostname()}async function Bd(e,t={signout:!1}){if(e.accessToken){const o={machine_id:await Dd(),machine_name:qd(),platform:Te.platform(),arch:Te.arch()},i=await fetch("https://cloud.needle.tools/api"+ht.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`),Mp(`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 r=!0;if(403===i.status){const e=await i.text();if(e.trimStart().startsWith("{")){const t=JSON.parse(e);t.logins&&(r=!1,Mp("Too many logins from different machines"),T().fail("You have reached the maximum number of allowed logins\n"),T().warn(`Please logout from one of the following machines:\n- ${t.logins.join("\n- ")}\n`))}}var n;return!!r||(t.signout&&(rd(),"client"in e&&(null==(n=e.client)||n.signOut(od("too-many-logins")))),!1)}return!0}let Md=null;function Wd(){if(Md)return Md;{const e=Zd();return Md=e,e}}const Gd="projects.json";function Hd(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(Yd(),JSON.stringify(e),"utf-8"),Md=e}function Jd(){var e;const t=Wd(),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 Vd(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=Wd(),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,Hd(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,Hd(n),i}function Kd(e){if("string"!=typeof e||!e)throw new Error("A registered project path is required.");const t=Wd(),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)],Hd(t),o}function Yd(){const e=process.env.HOME||process.env.USERPROFILE||process.cwd(),t=_(e,".needle");return c(t)||m(t,{recursive:!0}),_(t,Gd)}function Zd(){const e=Yd();if(!c(e))return{entries:[]};const t=p(e,"utf-8");try{const e=JSON.parse(t);return Md=e,e}catch(e){return console.error("Failed to parse project info file:",e),{entries:[]}}}const Xd=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8"));function Qd(){return Xd.version}const em=process.env.NEEDLE_SEARCH_ENDPOINT||"https://search.needle.tools",tm=process.env.NEEDLE_SEARCH_API_KEY||"da5737c00d6822c32a1b9e3b5dab094bfc17e205aef2f7f3e1a0fd4ebc77b79f",nm=[{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"]}}],om={needle_my_account:async function(e){try{const e=await kd(),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=`${em}/api/semantic-search?q=${encodeURIComponent(n)}&limit=${o}`,r={Accept:"application/json"};tm&&(r.Authorization=`Bearer ${tm}`);try{const t=await e(i,{headers:r,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 a=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${a}`}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e instanceof Error?e.message:String(e)}`}]}}}},im=new Map;function rm(e,t){const n=im.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=nm.findIndex(e=>e.name===t);-1!==n&&(nm.splice(n,1),delete om[t],cm.set(t,e),o=!0)}im.delete(e),o&&t()}}function am(e,t){const n=nm.findIndex(t=>t.name===e);if(-1!==n){nm.splice(n,1),delete om[e];for(const t of im.values())t.delete(e);t()}}function sm(e,t,n,o){const i=nm.findIndex(t=>t.name===e.name);if(-1!==i){var r;const t=null==(r=[...im.entries()].find(([,t])=>t.has(e.name)))?void 0:r[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"}.`);nm.splice(i,1)}if(nm.push(e),om[e.name]=t,cm.delete(e.name),null!=n&&n.source){const t=im.get(n.source)||new Set;t.add(e.name),im.set(n.source,t)}o()}const cm=new Map;async function lm(e,t,n={}){const o=om[e];if(!o){const t=cm.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 pm=200,um=2e3,dm=new RegExp("^[A-Za-z0-9_./*?\\[\\]{},\\-]+$"),mm="[REDACTED]";function fm(e){return/(?:password|passwd|pwd|secret|token|apikey|privatekey|accesskey|connectionstring|databaseurl|authorization|credentials)$/.test(e.toLowerCase().replace(/[^a-z0-9]/g,""))}function hm(e){return"string"==typeof e?vm(e):Array.isArray(e)?e.map(hm):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,fm(e)&&null!==t?mm:hm(t)])):e}function gm(e){var t;return mm+"\n".repeat((null!=(t=e.match(/\n/g))?t:[]).length)}function vm(e){let t=e.replace(/-----BEGIN (?:[A-Z0-9 ]*PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g,gm);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||!fm(t[2]))continue;const r=t[1].length;for(n[e]=mm;e+1<n.length&&(!n[e+1].trim()||(null!=(o=null==(i=n[e+1].match(/^[ \t]*/))?void 0:i[0].length)?o:0)>r);){var o,i;n[++e]=mm}}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)+mm),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(!fm(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+mm+i+"\n".repeat((null!=(o=n.match(/\n/g))?o:[]).length)}),t=t.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/@]+:[^\s/@]+@/gi,"$1"+mm+"@"),t=t.replace(/([?&])([\w%-]+)=([^&#\s"']*)/g,(e,t,n)=>fm(function(e){try{return decodeURIComponent(e)}catch{return e}}(n))?t+n+"="+mm: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,mm)}function bm(e){if(/^\s*[\[{]/.test(e)){try{JSON.parse(e)}catch{return vm(e)}const o=/"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|[{}\[\]:,]|\s+/g;let i,r="",a=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||!fm(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}}r+=e.slice(a,p)+JSON.stringify(mm)+"\n".repeat((null!=(t=e.slice(p,u).match(/\n/g))?t:[]).length),a=u}return r+=e.slice(a),r.replace(/"(?:\\.|[^"\\])*"/g,e=>JSON.stringify(vm(JSON.parse(e))))}return vm(e)}class ym extends Error{}function xm(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 wm(e,t){const n=le(e,t);return""===n||!ue(n)&&".."!==n&&!n.startsWith(".."+de)}function _m(e,t,n={}){if("string"!=typeof t||!t||t.includes("\0"))throw new ym("Invalid file path.");const o=O(e),i=ce(o,t);if(!wm(o,i))throw new ym("Path is outside the connected project.");const r=le(o,i);if(r.split(/[\\/]/).some(e=>e.includes(":")||/[ .]$/.test(e)))throw new ym("Invalid file path.");if(xm(e)||xm(o)||xm(r))throw new ym("Sensitive files cannot be accessed by local AI tools.");let a=i;for(;!$(a)&&a!==o&&n.allowMissing;)a=pe(a);const s=O(a);if(!wm(o,s))throw new ym("Path is outside the connected project.");const c=ce(s,le(a,i));if(xm(c))throw new ym("Sensitive files cannot be accessed by local AI tools.");return{root:o,path:c}}function jm(e,t,n={}){var o,i;const r=_m(e,t);if(!C(r.path).isFile())throw new ym("Path is not a regular file.");const a=P(r.path,F.O_RDONLY|(null!=(o=F.O_NOFOLLOW)?o:0)|(null!=(i=F.O_NONBLOCK)?i:0));try{var s;const o=D(a);if(!o.isFile())throw new ym("Path is not a regular file.");if(o.nlink>1)throw new ym("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 ym("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 ym("Invalid file byte range.");if((l?l.length:o.size)>i)throw new ym(`File exceeds the ${i} byte read limit.`);const p=_m(e,t),u=C(p.path);if(p.path!==r.path||o.ino!==u.ino||o.dev!==u.dev)throw new ym("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(a,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 ym("File exceeds the read size limit.");m.push(Buffer.from(d.subarray(0,f)))}if(l&&h!==l.length)throw new ym("File byte range changed while reading.");const v=_m(e,t),b=C(v.path);if(v.path!==r.path||b.ino!==o.ino||b.dev!==o.dev)throw new ym("File path changed while reading. Retry the request.");return Buffer.concat(m,h)}finally{L(a)}}function km(e){if(/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/.test(e.toString("utf8")))throw new ym("Files containing private-key material cannot be read.")}function Sm(e,t={}){const n=e.toString("utf8");if(n.includes("\0")||!Buffer.from(n,"utf8").equals(e))throw new ym("Only UTF-8 text files can be read.");return t.allowPrivateKeys||km(e),bm(n)}function Em(e,t,n={}){return{..._m(e,t),text:Sm(jm(e,t,n),n)}}function Tm(e,t){try{return He("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 $m(e,t,n=Tm){!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>um)throw new Error(`invalid pattern: exceeds ${um} characters`);if(null!=t&&""!==t){if("string"!=typeof t)throw new Error("invalid glob: must be a string");if(t.length>pm)throw new Error(`invalid glob: exceeds ${pm} characters`);if(!dm.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 r=0,a=0,s=0,c=0,l=!1;const p=Date.now();!function n(u,d){if(d>20||s>=2e3||a>=33554432||Date.now()-p>1e4)l=!0;else for(const m of q(u,{withFileTypes:!0})){const f=se(u,m.name),h=le(e,f).replace(/\\/g,"/");if(xm(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&&!Ye(h,t.glob,{matchBase:!0}))continue;try{_m(e,f);const t=Em(e,f).text.replace(/\n$/,""),n=Buffer.byteLength(t);if(++s>2e3||a+n>33554432||Date.now()-p>1e4)return void(l=!0);const c=t.split("\n").length;i.push({start:r+1,end:r+c,path:h}),r+=c,a+=n,o.push(t+"\n")}catch(e){if(e instanceof ym){c++;continue}throw e}}if(l)return}}}(_m(e,".").path,0);const u=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)}`});return{lines:u,omitted:c,limited:l}}const Im=new Set;async function Am(e,t=Je){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=ce(e),i=se(o,"tsconfig.json"),r=se(o,"node_modules/typescript/lib/tsc.js");if(!$(i))return{...n,status:"unavailable",message:"The connected web project has no tsconfig.json."};if(!$(r))return{...n,status:"unavailable",message:"TypeScript is not installed in the connected web project. Install the project dependencies first."};if(Im.has(o))return{...n,status:"error",message:"A check is already running for this project."};Im.add(o);try{const e={...process.env};delete e.NODE_OPTIONS,delete e.NODE_PATH;const a=await new Promise(n=>{t(process.execPath,[r,"--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}=a,c=bm(a.stdout),l=bm(a.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{Im.delete(o)}}const Om=new Set([".git","node_modules"]);function Cm(e){if(!e)return null;try{const t=O(e),n=o("sha256"),i=[t];let r=0;for(;i.length;){const e=i.pop(),o=q(e,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name));for(const a of o){if(++r>2e4)return null;const o=se(e,a.name),s=le(t,o).replaceAll("\\","/");if(a.isDirectory()&&Om.has(a.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`),a.isDirectory()&&i.push(o)}}return n.digest("hex")}catch{return null}}const Nm=(e,t)=>bm(String(null!=e?e:"")).slice(0,t),Rm=1048576,Pm=104857600,Um=e=>o("sha256").update(e).digest("hex"),Lm=1048576,zm=e=>o("sha256").update(e).digest("hex"),Fm=new Set([".app",".bat",".cmd",".com",".desktop",".exe",".hta",".jar",".lnk",".msi",".ps1",".scr",".sh",".url",".vbs",".wsf"]),Dm="settings.json";function qm(){return se(ne(),".needle")}function Bm(e){const t=se(null!=e?e:qm(),Dm);if(!$(t))return{};try{const e=JSON.parse(M(t,"utf-8"));return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}catch{return{}}}function Mm(e){return"disabled"===Bm(e).remote_ai_tools}function Wm(e){const t=se(null!=e?e:qm(),Dm);if(!$(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 Gm(e){const t=Wm(e);return null===t||void 0!==t.local_file_edits&&"enabled"!==t.local_file_edits}function Hm(e){const t=Wm(e);return null===t||void 0!==t.local_project_commands&&"enabled"!==t.local_project_commands}function Jm(e,t){if(!$(e))try{I(e,{recursive:!0})}catch{}let n=null,o=null;try{n=H(e,{persistent:!1},(e,n)=>{n&&n.toString()!==Dm||(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 Vm={__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:qm,readSettings:Bm,writeSetting:function(e,t,n){const o=Bm(e);null===n?delete o[t]:o[t]=n,I(e,{recursive:!0}),G(se(e,Dm),JSON.stringify(o,null,2)+"\n","utf-8")},areRemoteAiToolsDisabled:Mm,areLocalFileEditsDisabled:Gm,areLocalProjectCommandsDisabled:Hm,watchSettings:Jm};const Km=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ym(e,t=process.platform,n=Ve){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 Zm=Object.freeze(["vite","react","react-three-fiber","svelte","sveltekit","vue","nextjs"]),Xm=new Set(Zm),Qm=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@(?:\d+(?:\.\d+){0,2}(?:-[a-z0-9.-]+)?|latest|next))?$/i,ef=/^[a-z0-9][a-z0-9._-]{0,79}$/i;function tf(e,t){if(!e||!$(e)||!C(e).isDirectory())throw new Error(`${t} does not exist.`);return O.native(e)}function nf(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||!ef.test(e.name))throw new Error("Use a short project name containing letters, numbers, dots, hyphens, or underscores.");if(!Xm.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||!ue(e.parent)))throw new Error("An explicit project parent must be an absolute existing directory.");if(void 0!==e.destination&&("string"!=typeof e.destination||!ue(e.destination)))throw new Error("An explicit project destination must be absolute.");const o=void 0!==e.parent?se(tf(e.parent,"The project parent"),e.name):void 0!==e.destination?ce(e.destination):se(n,".needle","ai-projects",e.name);if(ae(o)!==e.name)throw new Error("The destination folder must match the project name.");const i=t?se(tf(pe(o),"The destination parent"),e.name):o;if($(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||!ue(i)))throw new Error("An explicit project path must be absolute.");const r=tf(i||t||"","The project"),a=r!==(t&&$(t)?O.native(t):null),s=function(e){const t=se(e,"package.json");if(!$(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}}(r);!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($(se(e,t)))throw new Error(`This project uses ${t}; npm-only AI commands cannot modify it.`)}(r,s.packageManager);const c=function(e,t){const n=se(e,"package-lock.json");return i=t+"\0"+($(n)?M(n,"utf8"):""),o("sha256").update(i).digest("hex");var i}(r,s.raw);if("install"===e.operation){const t=$(se(r,"package-lock.json"));return{request:e,operation:"install",project:r,customProject:a,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||!Qm.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:r,customProject:a,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:r,customProject:a,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(!$(se(r,"node_modules")))throw new Error("Install project dependencies before starting the dev server.");return{request:e,operation:"dev",project:r,customProject:a,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=se(r,"needle.config.json");if($(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||ue(t)||t.split(/[\\/]/).some(e=>".."===e||"."===e))throw new Error("Use a project-relative build directory.");const n=function(e,t){const n=O.native(t),o=le(e,n);if(".."===o||o.startsWith(`..${de}`)||ue(o))throw new Error("The build directory is outside the connected project.");return n}(r,tf(ce(r,t),"The build directory"));if(!$(se(n,"index.html")))throw new Error("The build directory has no index HTML file.");if(void 0!==e.name&&!ef.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:r,customProject:a,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 of(e,t=process.platform,n=Ve,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 rf(e,t,n=(()=>{}),o=y){let r,a,s=process.execPath,c=e.project||pe(e.destination);if("deploy"===e.operation){const t=process.argv[1];if(!t||!$(t))throw new Error("Cannot locate the running Needle CLI entry point for deployment.");r=[ce(t),"deploy",e.directory,"--open","false",...e.name?["--name",e.name]:[],...e.team?["--team",e.team]:[]]}else{const t=[process.env.npm_execpath,se(pe(process.execPath),"node_modules","npm","bin","npm-cli.js"),se(pe(pe(process.execPath)),"lib","node_modules","npm","bin","npm-cli.js")].find(e=>"string"==typeof e&&"npm-cli.js"===ae(e)&&$(e));if(!t)throw new Error("Could not locate npm-cli.js. Start Needle CLI through npm or install npm alongside Node.js.");r=[t,...e.args],"create"===e.operation&&I(c,{recursive:!0})}if("dev"===e.operation){const t=[Ze(new URL("../../../bin/cli.project-dev-supervisor.cjs",import.meta.url)),Ze(new URL("../bin/cli.project-dev-supervisor.cjs",import.meta.url))].find($);if(!t)throw new Error("The local dev supervisor is missing from the Needle CLI installation.");a=e.runtimeFile||se(oe(),`needle-dev-${i()}.runtime.json`),r=[t,Buffer.from(JSON.stringify({executable:s,args:r,cwd:c,runtimeFile:a})).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=Ke(s,r,{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,r=!1;function a(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),mm;const r=null!=(n=null==(o=e.match(/^[ \t]*/))?void 0:o[0].length)?n:0;if(void 0!==t){if(!e.trim()||r>t)return mm;t=void 0}const a=/^([ \t]*)([\w.-]+)[ \t]*:[ \t]*(?:[|>][^\n]*)?$/.exec(e);return a&&fm(a[2])?(t=a[1].length,mm):bm(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+(r?mm:a(e))+"\n").slice(-8e3),r=!1}return n.length>65536&&(a(n),n="",r=!0),t&&(n||r)&&(o=(o+(r?mm:a(n))).slice(-8e3),n="",r=!1),o}}}();let h,g,v=!1,b=!1;const y=e=>{if(b)return!1;try{return n(e),!0}catch(e){return b=!0,g=e,_(),!1}},x=t=>{if(m=f.push(t.toString().replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,"")),"dev"!==e.operation)return;if(!y({output:bm(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];y({url:i})&&o(i).then(()=>{y({browserOpened:!0})}).catch(e=>{y({browserError:e instanceof Error?e.message:String(e)})})};null==(p=d.stdout)||p.on("data",x),null==(u=d.stderr)||u.on("data",x);let w=!1;const _=()=>{if(a)return G(`${a}.cancel`,"",{flag:"w",mode:384}),void(null!=h||(h=setTimeout(()=>{of(d.pid),null!==d.exitCode||d.killed||d.kill("SIGTERM")},5e3)));of(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),a){const e=`${a}.cancel`;$(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:bm(w?`${m}\nCommand timed out after 15 minutes.`:m)}))}),"dev"===e.operation&&d.pid){const e=Ym(d.pid);e?y({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 af(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 sf=Le(Je),cf=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 sf(e,t,n,o){rm(e,async(e,n)=>{try{const o=await t(e,n);return"string"==typeof o?gm(o):{...o,content:o.content.map(e=>"text"===e.type?{...e,text:gm(e.text)}:e)}}catch(e){throw new Error(gm(e instanceof Error?e.message:String(e)))}},n,o)}const cf=function(e,t=$m,n=Date.now){let o,i=0;const r=Object.assign(async(r={})=>{var a,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(!r||"object"!=typeof r||Array.isArray(r))return p;if(Object.keys(r).some(e=>!["mode","file","code","offset","index"].includes(e)))return p;const u=null!=(a=r.mode)?a:"check";if(!["check","results","error"].includes(u))return p;for(const e of[r.file,r.code])if(void 0!==e&&("string"!=typeof e||e.length>250))return p;for(const e of[r.offset,r.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,r=Am(d),a=await t(d);o={project:d,result:{...a,...a.message?{message:gm(a.message)}:{},...a.output?{output:gm(a.output)}:{},diagnostics:(null!=(m=a.diagnostics)?m:[]).map(e=>({...e,message:gm(e.message)}))},time:n(),revision:e,snapshot:r}}if(!o)return{status:"unavailable",message:"No saved check for this local project. Run local_files_check_project with mode check first."};const f=Am(d),h=null===o.snapshot||null===f,g=o.result,v=null!=(s=g.diagnostics)?s:[],b=v.map((e,t)=>({...e,index:t})),y=b.filter(e=>{var t;return(!r.file||(null!=(t=e.file)?t:"").toLowerCase().includes(r.file.toLowerCase()))&&(!r.code||e.code===r.code)}),x=null!=(c=r.offset)?c:0,w="error"===u?y.filter(e=>{var t,n;return e.index===(null!=(t=r.index)?t:null==(n=y.at(-1))?void 0:n.index)}):y.slice(x,x+5);if("error"===u&&!w.length)return{status:"unavailable",message:"No matching error in the latest check. Use mode results to list available error indexes."};const _="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:Om(d,300),totalDiagnostics:null!=(l=g.totalDiagnostics)?l:v.length,retainedDiagnostics:v.length,matchingDiagnostics:y.length,truncated:Boolean(g.truncated),diagnostics:w.map(e=>({...e,...e.file?{file:Om(e.file,300)}:{},message:Om(e.message,_),messageTruncated:e.message.length>_})),..."error"!==u&&x+w.length<y.length?{nextOffset:x+w.length}:{},...g.message||h?{message:Om([g.message,h?"Could not scan project files for changes; this check is marked stale.":null].filter(Boolean).join(" "),500)}:{},...g.output?{output:Om(g.output,"error"===u?2e3:500),outputTruncated:g.output.length>("error"===u?2e3:500)}:{}}},{markStale(){i++}});return r}(()=>{var e;return null==(e=hf())?void 0:e.web_location}),lf=function(e,t=se(ne(),".needle","cli","ai-checkpoints"),n=(()=>{})){let o=0n,r=!1;function a(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||ce(n)!==ce(t.project))throw new Error("The approved local project has changed.");return{root:O(n),grant:t}}function s(e,t,n){if("string"!=typeof t||!t||t.includes("\0")||ue(t)||me.isAbsolute(t)||fe.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(bm(e)||bm(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=ce(e,t);if(!o.startsWith(e+de))throw new Error("Path escapes the selected local project.");let i=e;const r=le(e,o).split(de);for(let e=0;e<r.length;e++){if(i=se(i,r[e]),!$(i)){if(e!==r.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<r.length-1&&!t.isDirectory())throw new Error("Parent path is not a directory.");if(e===r.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{G(n,t,{flag:"wx",mode:384}),A(n,e)}finally{$(n)&&W(n)}}function l(){return $(t)?q(t).filter(e=>e.endsWith(".json")).reduce((e,n)=>e+C(se(t,n)).size,0):0}function p(e){if(!r){if($(t))for(const e of q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e))){const n=JSON.parse(M(se(t,e),"utf8"));if(n.order&&/^\d+$/.test(n.order)){const e=BigInt(n.order);e>o&&(o=e)}}r=!0}const n=1000000n*BigInt(Date.now());o=n>o?n:o+1n,e.order=o.toString();const a=JSON.stringify(e);if(l()+Buffer.byteLength(a)>Nm)throw new Error("Checkpoint storage is full; no file was changed.");I(t,{recursive:!0,mode:448});const s=i(),c=se(t,`${s}.json`);return G(c,a,{flag:"wx",mode:384}),{id:s,file:c}}function u(e,t){if(e.byteLength>Cm)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(Rm(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 $(n)?M(n):null},o=n(t.path),i=null===t.before?null:Rm(Buffer.from(t.before,"base64"));if("rename"===t.operation){if(!t.newPath)return"conflicted";const e=n(t.newPath);if(null===o&&e&&Rm(e)===t.afterSha256)return"applied";if(null===e&&o&&Rm(o)===i)return"undone"}else if("delete"===t.operation){if(null===o)return"applied";if(o&&Rm(o)===i)return"undone"}else{if(o&&Rm(o)===t.afterSha256)return"applied";if(null===o&&null===t.before||o&&Rm(o)===i)return"undone"}return"conflicted"}catch{return"conflicted"}}return{list(e){const{root:n,grant:o}=a(e);if(!$(t))return{changes:[],total:0};const i=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({...JSON.parse(M(se(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:r,newPath:a,...s})=>({path:e,checkpointId:t,turnId:o,createdAt:i,operation:null!=r?r:"write",...a?{newPath:a}:{},state:d(n,{...s,path:e,turnId:o,createdAt:i,operation:r,newPath:a})})),total:i.length}},stat(t){const n=e();if(!n)throw new Error("No connected local web project.");const o=O(n),i=s(o,t,!0);if(!$(i))return{path:t,exists:!1};const r=C(i).size;if(r>Cm)throw new Error("File exceeds the 1 MiB edit limit.");const a=wm(o,t,{maxBytes:Cm});return _m(a),{path:t,exists:!0,sha256:Rm(a),size:r}},write(e,t){var o;const{root:i,grant:r}=a(t);if(!e||"string"!=typeof e.content)throw new Error("Text content is required.");const l=Buffer.from(e.content,"utf8");if(l.byteLength>Cm||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=$(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&&Rm(f)===Rm(l))throw new Error("File already has this content; no edit was saved.");const h={project:i,path:le(i,d),chatId:r.chatId,sessionId:r.sessionId,turnId:r.turnId,before:null!=(o=null==f?void 0:f.toString("base64"))?o:null,after:l.toString("base64"),afterSha256:Rm(l),createdAt:(new Date).toISOString(),operation:"write"},g=p(h);try{if(s(i,e.path,!0===e.create),!0===e.create){if($(d))throw new Error("The file was created since it was checked; check it again.")}else if(!$(d)||Rm(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:r.turnId,afterSha256:h.afterSha256}},delete(e,t){const{root:o,grant:i}=a(t),r=s(o,null==e?void 0:e.path,!1),c=M(r);u(c,e.expectedSha256);const l=p({project:o,path:le(o,r),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),Rm(M(r))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");W(r)}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}=a(t),r=s(o,null==e?void 0:e.path,!1),c=s(o,null==e?void 0:e.newPath,!0);if($(c))throw new Error("Destination file already exists.");const l=M(r);u(l,e.expectedSha256);const d={project:o,path:le(o,r),newPath:le(o,c),chatId:i.chatId,sessionId:i.sessionId,turnId:i.turnId,before:l.toString("base64"),after:l.toString("base64"),afterSha256:Rm(l),createdAt:(new Date).toISOString(),operation:"rename"},m=p(d);try{if(s(o,e.path,!1),s(o,e.newPath,!0),$(c))throw new Error("Destination file already exists.");if(Rm(M(r))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");A(r,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:r}=a(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const p=se(t,`${e.checkpointId}.json`),u=JSON.parse(M(p,"utf8"));if(u.project!==i||u.chatId!==r.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($(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($(d)||Rm(M(e))!==u.afterSha256)throw new Error("File changed after the AI edit; Undo would overwrite later work.");A(e,d)}else{const e=M(d);if(Rm(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)>Nm)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:r}=a(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const l=se(t,`${e.checkpointId}.json`),p=JSON.parse(M(l,"utf8"));if(p.project!==i||p.chatId!==r.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(!$(u)||Rm(M(u))!==Rm(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(!$(u)||$(e)||Rm(M(u))!==Rm(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),A(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(Rm(e)!==p.afterSha256)throw new Error("Checkpoint content is damaged; Redo was refused.");if(null===p.before?$(u):!$(u)||Rm(M(u))!==Rm(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}=a(n);if(!e||"string"!=typeof e.turnId||!e.turnId||e.turnId.length>255)throw new Error("Valid turn ID is required.");if(!$(t))throw new Error("No checkpoints found for this turn.");const r=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({checkpoint:JSON.parse(M(se(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(!r.length)throw new Error("No checkpoints found for this turn.");if(r.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.");r.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 r=$(n)?M(n):null;return c.set(i,r),r};for(const{checkpoint:e}of r){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||Rm(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||Rm(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 r)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=hf())?void 0:e.web_location},void 0,()=>cf.markStale()),pf=function(e=se(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")||ue(t.path)||me.isAbsolute(t.path)||fe.isAbsolute(t.path))throw new Error("A project-relative file path and chat are required.");const n=O(t.root),o=ce(n,t.path);if(xm(n,t.path,{allowMissing:!0}),!o.startsWith(n+de))throw new Error("File path escapes the project.");const i=le(n,o).split(de).join("/");return{project:n,target:o,path:i,file:se(e,Um(n),Um(t.chatId),`${Um(i)}.json`)}}function n(e){if(!$(e.target))return null;if(C(xm(e.project,e.target).path).size>Pm)return{unsupported:"File exceeds the 1 MiB observation limit."};const t=wm(e.project,e.target,{maxBytes:Pm}),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:jm(t).split("\n"),hashes:o.map(Um),fileSha256:Um(t)}}function o(e){if(!$(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 r(t,n,o){if("unsupported"in n)return{status:"unsupported",reason:n.unsupported};const r={version:1,project:t.project,path:t.path,chatId:o,observedAt:(new Date).toISOString(),fileSha256:n.fileSha256,lineHashes:n.hashes};I(se(e,Um(t.project),Um(o)),{recursive:!0,mode:448});const a=`${t.file}.${i()}.tmp`;try{G(a,JSON.stringify(r),{flag:"wx",mode:384}),A(a,t.file)}finally{$(a)&&W(a)}return{status:"saved",observedAt:r.observedAt,sha256:r.fileSha256}}return{observe(e){const i=t(e),a=n(i);if(!a)throw new Error("File does not exist.");if("unsupported"in a)return{status:"unsupported",reason:a.unsupported};const s=o(i);return s?{status:"existing",observedAt:s.observedAt,sha256:s.fileSha256}:r(i,a,e.chatId)},snapshot(e){const o=t(e),i=n(o);if(!i)throw new Error("File does not exist.");return r(o,i,e.chatId)},diff(e){const i=t(e),r=o(i);if(!r)return{status:"no_baseline",path:i.path};const a=n(i);if(!a)return{status:"deleted",path:i.path,observedAt:r.observedAt};if("unsupported"in a)return{status:"unsupported",path:i.path,reason:a.unsupported};if(r.fileSha256===a.fileSha256)return{status:"unchanged",path:i.path,observedAt:r.observedAt,sha256:a.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 r=new Map;for(let t=n;t<o;t++){const n=r.get(e[t]);n?n.count++:r.set(e[t],{index:t,count:1})}const a=new Map;for(let e=n;e<i;e++){var s;a.set(t[e],(null!=(s=a.get(t[e]))?s:0)+1)}const c=[];for(let e=n;e<i;e++){const n=r.get(t[e]);1===(null==n?void 0:n.count)&&1===a.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}(r.lineHashes,a.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:a.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:r.observedAt,beforeSha256:r.fileSha256,afterSha256:a.fileSha256,beforeLineCount:r.lineHashes.length,afterLineCount:a.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)."}}}}(),uf=function(e,t=y){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()||ue(n.path)||n.path.includes("\0"))throw new Error("Use a nonempty project-relative path.");const r=O.native(i),a=ce(r,n.path),s=le(r,a);if(".."===s||s.startsWith(`..${de}`)||ue(s))throw new Error("File path is outside the selected project.");const c=O.native(a),l=le(r,c);if(".."===l||l.startsWith(`..${de}`)||ue(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(Lm.has(re(c).toLowerCase()))throw new Error("Opening executable file types is not supported.");return await t(c),{opened:!0,project:n.project,path:le(r,c)||"."}}}(hf),df=function(e){const{getProject:t,getHome:n=ne,run:o=nf,commandsEnabled:r=(()=>!Wm()),onFailure:a,onCreated:s,onApprovedProject:c,now:l=Date.now,getProcessIdentity:p=Vm}=e,u=function(e=se(ne(),".needle","cli","ai-jobs"),t=Date.now){const n=t=>{if(!Jm.test(t))throw new Error("Invalid project job ID.");return se(e,`${t}.json`)};return{runtimeFile:t=>(n(t),se(e,`${t}.runtime.json`)),runtime(e){const t=this.runtimeFile(e);if(!$(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 r=se(e,`${t.jobId}.${i()}.tmp`);try{G(r,JSON.stringify(t),{flag:"wx",mode:384}),A(r,o)}finally{$(r)&&W(r)}},get(e){const o=n(e);if(!$(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 r=i;if(r.jobId!==e||"string"!=typeof r.chatId||"string"!=typeof r.operation||void 0!==r.project&&"string"!=typeof r.project||void 0!==r.workingDirectory&&"string"!=typeof r.workingDirectory||void 0!==r.startedAt&&!Number.isFinite(r.startedAt)||void 0!==r.pid&&(!Number.isSafeInteger(r.pid)||Number(r.pid)<1)||void 0!==r.processIdentity&&"string"!=typeof r.processIdentity||!Number.isFinite(r.createdAt)||!Number.isFinite(r.updatedAt)||"string"!=typeof r.output||r.output.length>8e3||!["running","completed","failed","canceled"].includes(String(r.status)))throw new Error("Invalid stored project job.");const a=r;if(!("running"!==a.status&&t()-a.updatedAt>1728e5))return a;{W(o);const t=this.runtimeFile(e);$(t)&&W(t)}},list(){return $(e)?q(e).filter(e=>Jm.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)&&W(t);const o=this.runtimeFile(e);$(o)&&W(o)}}}(se(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||!a)return;const{controller:t,...n}=e;try{a(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=ef(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=gm(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 y(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 x(){for(const e of u.list())b(e)}x();const w=setInterval(x,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 r={...ef(e,t(),n()),planId:i(),chatId:o,createdAt:l()},a="dev"===r.operation?y(r.project):void 0;if(a)throw new Error(`A dev server for this project is already running (job ID ${a.jobId}). Check its status or cancel it before starting another.`);return d.set(r.planId,r),r},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(!r())throw new Error("AI project commands are disabled in local Needle CLI settings.");v(n);const a="dev"===n.operation?y(n.project):void 0;if(a)throw new Error(`A dev server for this project is already running (job ID ${a.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||pe(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=gm(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=gm(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=gm(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.");G(`${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=hf())?void 0:e.web_location},onCreated:Hd,onApprovedProject:Hd,onFailure:e=>{var t;return Bp(`[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 mf(e){if(null==e||!e.editGrant)throw new Error("Local file edit approval is required.");if(Mm())throw new Error("AI file edits are disabled in local Needle CLI settings.");return e.editGrant}function ff(e={}){sf({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=Bd();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"},()=>{}),sf({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=Bd();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"},()=>{}),sf({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=Bd();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"},()=>{}),sf({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=hf();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"},()=>{}),sf({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=bf(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"},r="reset"===e.mode?pf.snapshot(i):pf.diff(i);return{content:[{type:"text",text:JSON.stringify(r)}]}},{source:"cli"},()=>{}),sf({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 uf(e))}]}),{source:"cli"},()=>{}),sf({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=bf(e.path);if(!n)return{content:[{type:"text",text:"Error: path is outside the project directory."}]};try{const i=l(n.resolved).mtime.toISOString(),r=km(n.root,n.resolved).text.split("\n");let a="";try{var o;const e=pf.observe({root:n.root,path:j(n.root,n.resolved),chatId:null!=(o=null==t?void 0:t.chatId)?o:"local-mcp"});a="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),a=`\nChange baseline unavailable: ${e instanceof Error?e.message:"unknown error"}`}if(e.filter){const t=of(e.filter),o=[];for(let e=0;e<r.length;e++)t.test(r[e])&&o.push(`${e+1}: ${r[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 ${r.length} lines`+a+"\n"+p.join("\n")}]}}const s=Math.max(1,e.offset||1),c=Math.min(e.limit||200,1e3),p=r.slice(s-1,s-1+c),u=p.map((e,t)=>`${s+t}: ${e}`).join("\n");return{content:[{type:"text",text:`File: ${n.resolved} (${r.length} lines, modified: ${i}, showing ${s}-${s+p.length-1})`+a+"\n"+u}]}}catch(e){return{content:[{type:"text",text:`Error reading file: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),sf({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=vf();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=>Em(t,{pattern:e.pattern,glob:e.glob,maxResults:n})),i=o.flatMap(e=>e.lines),r=`\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.")+r}]}},{source:"cli"},()=>{}),sf({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=hf();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=[],r=[];for(const{root:t,label:n}of o){const o=gf(e.path||".",t);if(o)try{var a;e.recursive||r.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=xf(o,t,null!=(a=e.recursive)&&a,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=r.length>0?`\nShallow listing: subdirectories were not searched (${r.slice(0,12).join(", ")}${r.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"},()=>{}),sf({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=hf();var n;if(null==t||!t.log_location)return Mp(`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=km(pe(t.log_location),ae(t.log_location),{maxBytes:67108864,allowPrivateKeys:!0}).text.split("\n");let o,i;if(e.filter){const t=of(e.filter);o=[];for(let e=0;e<n.length;e++)t.test(n[e])&&o.push(`L${e+1}: ${n[e]}`);const r=o.length,a=Math.max(0,e.offset||0),s=Math.min(Math.max(e.limit||200,1),500);o=o.slice(a,a+s),i=`filter="${e.filter}" (${t.mode}) → ${r} matches (showing ${a+1}-${a+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 r="unity"===t.editor?function(e){const t=[],n=new Map;let o=!1,i=0;for(const r of e){if(/^\s+at\s/.test(r)||/^\s*(UnityEngine\.|System\.|Unity\.)/.test(r)||/^\s+\w+[\w.<>]+\s*\(/.test(r)){o||(o=!0,i=0),i++,i<=3?t.push(r):4===i&&t.push(" ... (stack trace truncated)");continue}if(o=!1,i=0,!r.trim())continue;const e=n.get(r)||0;if(n.set(r,e+1),0===e)t.push(r);else if(1===e)t.push(` [repeated ${e+1}x] ${r}`);else{const n=t.length-1;n>=0&&t[n].startsWith(" [repeated")&&(t[n]=` [repeated ${e+1}x] ${r}`)}}return t}(o):o,a=5e4;let s=r.join("\n"),c="";if(s.length>a){s=s.substring(s.length-a);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}, ${r.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"},()=>{}),sf({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=bf(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=km(t,e).text;return JSON.parse(n)}if(n.endsWith(".glb")){const n=wm(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=wm(t,e,{maxBytes:67108864,range:{offset:20,length:o}}).toString("utf-8"),r=mm(JSON.parse(i));if(!r||"object"!=typeof r||Array.isArray(r))throw new Error("glTF JSON must be an object.");return r}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=yf(n,e.query.replace(/^\//,"").split("/"));if(void 0===i)return{content:[{type:"text",text:`No data found at pointer: ${e.query}`}]};let r=JSON.stringify(i),a=!1;return r.length>o&&(r=r.substring(0,o),a=!0),{content:[{type:"text",text:`${e.query} in ${t.resolved}`+(a?` (truncated to ${o} chars)`:"")+"\n"+r}]}}let i=function(e,t){var n,o,i,r,a,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!=(r=e.nodes)&&r.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 r=e.nodes[t];if(!r)return;const a=" ".repeat(i),s=[];if(void 0!==r.mesh&&s.push(`mesh:${r.mesh}`),void 0!==r.camera&&s.push(`camera:${r.camera}`),void 0!==r.skin&&s.push(`skin:${r.skin}`),r.extensions&&s.push(`ext:[${Object.keys(r.extensions).join(",")}]`),h.push(`${a}- ${r.name||`node_${t}`}${s.length?` (${s.join(", ")})`:""}`),r.children)for(const e of r.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!=(a=e.meshes)&&a.length){h.push(`\nMeshes (${e.meshes.length}):`);for(const t of e.meshes.slice(0,30)){var y,x;const e=null!=(y=null==(x=t.primitives)?void 0:x.length)?y: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)}]});sf({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=af.replace("__PORT__",String(e)).replace("__HOST__",t),o=Buffer.from(n,"utf16le").toString("base64"),{stdout:i}=await rf("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 V(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 K(`/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 rf("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 K(`/proc/${e}/cwd`):await async function(e){const{stdout:t}=await rf("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"},()=>{}),sf({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(Bd().entries.filter(e=>e.web_location).map(e=>({path:e.web_location,selected:e===hf(),editor:e.editor}))),{source:"cli"},()=>{}),sf({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:Jd(t.path).web_location}),{source:"cli"},()=>{}),sf({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:Km},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?df.getPlan(t.planId,n.chatId):df.plan(t,n.chatId))},{source:"cli"},()=>{}),sf({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(Wm())throw new Error("AI project commands are disabled in local Needle CLI settings.");return e(await df.start(t.planId,n.commandGrant))},{source:"cli"},()=>{}),sf({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(df.status(t.jobId,n.chatId))},{source:"cli"},()=>{}),sf({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 df.cancel(t.jobId,n.chatId))},{source:"cli"},()=>{})}(),sf(sp.schema,async e=>{const t=await sp.execute(e);return"error"in t?{content:[{type:"text",text:t.error}]}:{content:[{type:"text",text:t.content}]}},{source:"cli"},()=>{}),sf({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(lf.stat(e.path))}]}),{source:"cli"},()=>{}),sf({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(lf.write(e,mf(t)))}]}),{source:"cli"},()=>{}),sf({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(lf.delete(e,mf(t)))}]}),{source:"cli"},()=>{}),sf({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(lf.rename(e,mf(t)))}]}),{source:"cli"},()=>{}),sf({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(lf.undo(e,mf(t)))}]}),{source:"cli"},()=>{}),sf({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(lf.redo(e,mf(t)))}]}),{source:"cli"},()=>{}),sf({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(lf.undoTurn(e,mf(t)))}]}),{source:"cli"},()=>{}),sf({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(lf.list(mf(t)))}]}),{source:"cli"},()=>{}),sf({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 cf(e);return{content:[{type:"text",text:JSON.stringify(t)}],isError:"error"===t.status||"unavailable"===t.status}},{source:"cli"},()=>{}),null!=e&&e.logToolCount&&Mp(`[MCP] registered ${em.length} built-in tools: ${em.map(e=>e.name).join(", ")}`)}function hf(){return Gd()}function gf(e,t){const n=w(t,e),o=w(t),i=j(o,n);return k(i)||".."===i||i.startsWith(".."+S)?null:xm(o,n,{allowMissing:!0}).path}function vf(){const e=hf();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 bf(e){const t=vf();for(const n of t){const t=gf(e,n);if(t&&c(t))return{resolved:t,root:n}}for(const n of t){const t=gf(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 yf(e,t){if(0===t.length||null==e)return e;const[n,...o]=t;if("*"!==n)return yf(e[/^\d+$/.test(n)?Number(n):n],o);if(Array.isArray(e)){const t=e.map(e=>yf(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=yf(e[n],o);void 0!==i&&(t[n]=i)}return Object.keys(t).length>0?t:void 0}}function xf(e,t,n,o,i){if(i>10)return[];const r=[],a=u(e,{withFileTypes:!0}),s="node_modules"===(e.split("/").pop()||e.split("\\").pop()||"");for(const c of a){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 a=_(e,c.name);if(!bm(j(t,a))&&!c.isSymbolicLink())if(xm(t,a),c.isDirectory())n&&r.push(...xf(a,t,!0,o,i+1));else{if(o&&!o.split("|").map(e=>(e=e.trim()).startsWith(".")&&!e.startsWith("*.")?"*"+e:e).filter(Boolean).some(e=>Ye(c.name,e,{nocase:!0})))continue;r.push(a)}}return r}process.once("exit",()=>df.dispose());const wf="cli-installation-id",_f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,jf="2025-06-18";function kf(e){return{jsonrpc:"2.0",id:e,result:{protocolVersion:jf,capabilities:{tools:{listChanged:!0}},serverInfo:Sf}}}const Sf={name:"Needle Cloud MCP",version:"1.0.0"};function Ef(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 Tf(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let $f=!1;const If=Me(),Af=new Map,Of=new Map;let Cf=0;function Nf(){const e=[];for(const[t,{connectedAt:n,userAgent:o}]of Of)e.push({id:t,connectedAt:n,userAgent:o});return e}function Rf(e,t,n,o){if((t.headers.accept||"").includes("text/event-stream")){var i,r;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 a=t.headers["mcp-session-id"],s=null!=(i=null!=(r=null!=o?o:"string"==typeof a?Af.get(a):void 0)?r:t.headers["user-agent"])?i:"",c=()=>{clearInterval(l),Of.delete(e)&&(console.log(`[MCP] SSE client disconnected (ID: ${e}): ${s}`),Mp(`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()}),Of.set(e,{id:e,client:n,connectedAt:Date.now(),userAgent:s,dispose:c}),console.log(`[MCP] SSE client connected (ID: ${e}) ${s}. Total clients: ${Of.size}`),Mp(`MCP SSE client connected (ID: ${e}) ${s}. Total clients: ${Of.size}`),!0}return!1}function Pf(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}async function Uf(e=se(ne(),".needle")){let t,n;try{t=await V(se(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 Lf(){const e=await Uf();try{const t=await fetch(`${Cu}/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 zf(e,t=process.argv[1]){await new Promise((n,o)=>{const i=Ke(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.`)})})}If.get("/mcp",async(e,t)=>{if(Rf(Cf++,e,t))return;const n=function(e){const t=[...em].sort((e,t)=>e.name.localeCompare(t.name)),n=t.map(e=>`\n <div class="tool">\n <span class="tool-name">${Tf(e.name)}</span>\n <span class="tool-desc">${Tf(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)}),If.post("/mcp",async(e,t)=>{const n=e.headers.accept||"",o=e.headers["user-agent"]||"",{method:i,id:r}=e.body;console.log(`[MCP] Received request from ${o} (${i}) (ID: ${r})`),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 a;const n=Cf++,o=Ef(null==(a=e.body.params)?void 0:a.clientInfo);if(Rf(n,e,t,o?`${o.name}/${o.version}`:void 0)){$f=!0;const e=kf(null!=r?r: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 kf(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{ff()}catch{}return{jsonrpc:"2.0",id:i,result:{tools:em}}}if("tools/call"===n){const e=null==o?void 0:o.name;try{ff()}catch{}try{return{jsonrpc:"2.0",id:i,result:await sm(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;$f=!0;const n=_e(),i=Ef(null==(s=e.body.params)?void 0:s.clientInfo);Af.set(n,i?`${i.name}/${i.version}`:void 0),t.setHeader("Mcp-Session-Id",n),console.log(`[MCP] New session created: ${n} for ${o}`),Mp(`MCP New session: ${n} for ${o}`)}if(null===l)return t.status(204).end();if(Mp(`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:r||null};t.json(n)}}),If.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 Ff=!1;function Df(e,t={}){Ff&&process.stdout.write(JSON.stringify({jsonrpc:"2.0",method:e,params:t})+"\n")}var qf={__proto__:null,sendStdioNotification:Df,startStdio:function(){Ff=!0,console.log=console.info=console.debug=console.error.bind(console);const e=e=>{console.error(e),Mp(e)},t=function({endpoint:e,ensureServer:t,notify:n,log:o,getToken:i,retryMs:r=250,streamTimeoutMs:a=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 r,a;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":jf,...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(!Pf(s)||"2.0"!==s.jsonrpc||s.id!==t.id||!Pf(s.result)&&!Pf(s.error))throw new Error("Invalid response from local MCP server");if(Pf(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!=(r=i.headers.get("Mcp-Session-Id"))?r:void 0),{jsonrpc:"2.0",id:null!=(a=t.id)?a: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=r;for(;!s.signal.aborted;){let d;const y=new AbortController,x=()=>y.abort();let w;s.signal.addEventListener("abort",x,{once:!0});const _=(e,t=!0)=>{clearTimeout(w),w=setTimeout(()=>{t?j():y.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||y.signal.aborted||_(a)}catch(e){s.signal.aborted||y.signal.aborted||y.abort(e)}};try{var c;await t(s.signal);const o=await b({jsonrpc:"2.0",id:"needle-bridge-initialize",method:"initialize",params:{protocolVersion:jf,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 x=await h(),w=await fetch(e,{headers:{...x,"User-Agent":g(),Accept:"text/event-stream","MCP-Protocol-Version":jf,...u?{"Mcp-Session-Id":u}:{}},signal:y.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})`);_(a),d=w.body.getReader(),v(!0),null==p||p(),i=r;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(_(a),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);Pf(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",x),d){if(!y.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=Ef(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:`${Cu}/mcp`,ensureServer:t=>async function(e={}){const{signal:t,lockPath:n=se(ne(),".needle","mcp-server-start.lock"),probe:o=Lf,log:i=(e=>console.error(e)),launch:r=(()=>zf(i)),timeoutMs:a=2e4,pollMs:s=100}=e;if(null==t||t.throwIfAborted(),await o())return;await Z(pe(n),{recursive:!0});const c=Date.now()+a;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 r()}}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:Df,log:e,getToken:()=>async function(e){const t=await Uf(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=De({input:process.stdin,terminal:!1}),o=e=>{Ff&&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(!Pf(r=i)||"2.0"!==r.jsonrpc||"string"!=typeof r.method||null!=r.id&&"string"!=typeof r.id&&"number"!=typeof r.id||void 0!==r.params&&!Pf(r.params))return void o({jsonrpc:"2.0",id:null,error:{code:-32600,message:"Invalid request"}});var r,a;if("initialize"===i.method)return o(kf(null!=(a=i.id)?a: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",()=>{Ff=!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 Bf=null;function Mf(){Bf&&clearTimeout(Bf),Bf=setTimeout(()=>{!function(e,t={}){if(0===Of.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 Of)try{t.write(n)}catch(n){console.error(`[MCP] Error sending notification to client (${e}):`,n),o(),t.destroy()}}(),Df("notifications/tools/list_changed"),rh(),Bf=null},10)}const Wf=function({send:e,register:t,clear:n,onError:o}){const r=new Map,a=new Set;let s=null,c=null,l=!1;const p=()=>{l=!1,s=null,c&&clearTimeout(c),c=null,a.size&&n(),a.clear();for(const e of r.values())clearTimeout(e.timer),e.reject(new Error("Needle Cloud disconnected."));r.clear()},u=(t,n)=>new Promise((o,a)=>{if(!l)return void a(new Error("Needle Cloud disconnected."));if(r.size>=4)return void a(new Error("Too many concurrent cloud tool requests."));const s=i(),c=setTimeout(()=>{r.delete(s),a(new Error("Cloud tool request timed out."))},3e4);r.set(s,{resolve:o,reject:a,timer:c});try{e({type:"cloud_tool_call",requestId:s,name:t,args:n})}catch(e){clearTimeout(c),r.delete(s),a(e instanceof Error?e:new Error(String(e)))}});return{connect(){p(),l=!0,s=i(),c=setTimeout(()=>{s=null,o("Cloud tool discovery timed out. Update the Cloud API if it does not support MCP tools.")},15e3);try{e({type:"cloud_tools_list",requestId:s})}catch(e){p(),o(e instanceof Error?e.message:String(e))}},disconnect:p,isCloudTool:e=>a.has(e),receive(e){if(!e||"object"!=typeof e||!("type"in e)||!("requestId"in e)||"string"!=typeof e.requestId)return!1;if("cloud_tools_result"===e.type){if(!l||e.requestId!==s)return!0;if(s=null,c&&clearTimeout(c),c=null,"error"in e&&"string"==typeof e.error)return o(e.error),!0;if(!("tools"in e)||!Array.isArray(e.tools))return o("Invalid cloud tool catalog."),!0;try{for(const n of e.tools){if(!n||"object"!=typeof n||"string"!=typeof n.name||!/^[a-zA-Z0-9_]{1,45}$/.test(n.name)||"string"!=typeof n.description||!n.inputSchema||"object"!=typeof n.inputSchema||Array.isArray(n.inputSchema))throw new Error("Invalid cloud tool schema.");const e=`needle_cloud_${n.name}`;t({name:e,description:n.description,inputSchema:n.inputSchema},e=>u(n.name,e)),a.add(e)}}catch(e){p(),o(e instanceof Error?e.message:String(e))}return!0}if("cloud_tool_result"===e.type){const t=r.get(e.requestId);return!t||(r.delete(e.requestId),clearTimeout(t.timer),"error"in e&&"string"==typeof e.error?t.reject(new Error(e.error)):"result"in e&&"string"==typeof e.result?t.resolve(e.result):t.reject(new Error("Invalid cloud tool result.")),!0)}return!1}}}({send:e=>{if(!Yf||Yf.readyState!==We.OPEN)throw new Error("Needle Cloud disconnected.");Yf.send(JSON.stringify(e))},register:(e,t)=>rm(e,t,{source:"cloud"},Mf),clear:()=>om("cloud",Mf),onError:e=>Mp(`[Cloud MCP] ${e}`)}),Gf=2e3,Hf=6e4,Jf=25e3,Vf=1e4,Kf=i();let Yf=null,Zf=null,Xf=null,Qf=null,eh=Gf,th=!1,nh=!1;function oh(){Yf||(qm()?Mp("Needle Cloud connection: skipped (remote_ai_tools disabled in settings)"):(th=!1,Zf&&(clearTimeout(Zf),Zf=null),eh=Gf,ah()))}function ih(e){Wf.disconnect(),th=!0,sh(),Zf&&(clearTimeout(Zf),Zf=null),Yf?(Mp(`Needle Cloud connection: closing (reason: ${null!=e?e:"shutdown"})`),Yf.close(1e3,null!=e?e:"shutdown"),Yf=null):e&&Mp(`Needle Cloud connection: disconnect requested (reason: ${e}) — no active connection`)}function rh(){if(!Yf||Yf.readyState!==We.OPEN)return;try{ff()}catch(e){Mp(`Needle Cloud connection: registerServerTools failed: ${e}`)}const e=em.filter(e=>!Wf.isCloudTool(e.name)),t=e.map(e=>e.name);var n;Mp(`Needle Cloud connection: sending ${t.length} tools: ${t.join(", ")}`),Yf.send(JSON.stringify({type:"tools",tools:(n=e,n.map(e=>{var t;return{name:e.name,description:e.description,inputSchema:e.inputSchema,capability:null!=(t=e.capability)?t:"local"}}))}))}async function ah(){let e,t,n=await wd();if(n||(n=function(){const e=ud("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}(),n&&Mp("Needle Cloud connection: using cached token (refresh failed)")),!n)return nh||(Mp("Needle Cloud connection: skipped (not logged in)"),nh=!0),void ch(!0);nh=!1;try{e=function(e=Fm()){I(e,{recursive:!0,mode:448});const t=se(e,wf);try{G(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(!_f.test(n))throw new Error("Invalid local CLI installation ID.");return n}()}catch(e){return Mp(`Needle Cloud connection: could not read local CLI installation identity: ${e instanceof Error?e.message:String(e)}`),void ch(!0)}try{t=await async function(e,t={getUser:_d,getDefaultOrg:jd,authHeaders:$d}){var n;const o=await t.getUser();if(null==o||!o.isAuthenticated)return{authToken:e,org:null};const i=await t.getDefaultOrg(o);if(i&&"object"==typeof i)throw new Error(i.error);if(!i)return{authToken:e,org:null};const r=await t.authHeaders(o,i);if("error"in r)throw new Error(r.error);if(!r.authToken)throw new Error("No access token for the default team.");return{authToken:r.authToken,org:null!=(n=r.org)?n:null}}(n)}catch(e){return Mp(`Needle Cloud connection: team authentication failed: ${e instanceof Error?e.message:String(e)}`),void ch()}const o="https://cloud.needle.tools/api".replace(/^http/,"ws")+"/v1/cli/ws?token="+encodeURIComponent(t.authToken)+(t.org?"&org="+encodeURIComponent(t.org):"")+"&instance="+encodeURIComponent(Kf)+"&installation="+encodeURIComponent(e);Mp("Needle Cloud connection: connecting...");const r=`needle-cloud/${Zd()} Node/${process.versions.node}`;Yf=new We(o,{headers:{"User-Agent":r,Origin:"cli://needle-cloud"}}),Yf.on("open",()=>{eh=Gf,Mp("Needle Cloud connection: established"),lh(),rh(),sh(),Xf=setInterval(()=>{Yf&&Yf.readyState===We.OPEN&&(Yf.ping(),Qf=setTimeout(()=>{Mp("Needle Cloud connection: pong timeout, terminating"),Yf&&Yf.terminate()},Vf))},Jf),Wf.connect()}),Yf.on("pong",()=>{Qf&&(clearTimeout(Qf),Qf=null)}),Yf.on("message",e=>{try{const n=JSON.parse(e.toString());if(Wf.receive(n))return;var t;"execute_tool"===n.type&&n.requestId&&n.toolName&&async function(e,t,n,o,i,r){Mp(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 a=Date.now();try{var s,c;if(Wf.isCloudTool(t))throw new Error("Cloud tools cannot be executed as local tools.");"local_project_action"===t&&lh();const l=await sm(t,n,{chatId:o,editGrant:i,commandGrant:r});"local_project_select"!==t&&"local_project_start"!==t&&"local_project_status"!==t||lh(),Mp(`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()-a}ms [${e}]`),Yf&&Yf.readyState===We.OPEN&&Yf.send(JSON.stringify({type:"tool_result",requestId:e,result:l}))}catch(n){const o=n instanceof Error?n.message:String(n);Mp(`Cloud tool error: ${t} → ${o} in ${Date.now()-a}ms [${e}]`),Yf&&Yf.readyState===We.OPEN&&Yf.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{}}),Yf.on("close",(e,t)=>{const n=(null==t?void 0:t.toString())||"";Mp(`Needle Cloud connection: closed (code=${e}${n?" "+n:""})`),sh(),Wf.disconnect(),Yf=null,th||ch()}),Yf.on("error",e=>{Mp(`Needle Cloud connection: error - ${e.message||"connection refused"} (is https://cloud.needle.tools/api reachable?)`)})}function sh(){Xf&&(clearInterval(Xf),Xf=null),Qf&&(clearTimeout(Qf),Qf=null)}function ch(e=!1){th||Zf||(e||Mp(`Needle Cloud connection: reconnecting in ${eh/1e3}s`),Zf=setTimeout(()=>{Zf=null,ah()},eh),eh=Math.min(2*eh,Hf))}function lh(){Yf&&Yf.readyState===We.OPEN&&Yf.send(JSON.stringify(function(){var e,t,n;const o=Gd();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?ce(o.web_location):null,cli_version:Zd()}}()))}const ph=e=>{const t=Me();return t.use("/:action",async(t,n,o)=>{const{action:i}=t.params,r=kd({navigate:e=>{n.redirect(e)}});switch(i){case"sign-in":e.invalid_login=!1,e.invalid_login_type=null,e.error=void 0,Mp("Sign in..."),await r.clearAllTokens(),hd();try{await r.signIn(`${Cu}/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 Mp(o),console.error(o),n.status(502).send(o)}break;case"sign-out":{var a,s;const t=await _d(),n=(null==t||null==(a=t.userInfo)?void 0:a.sub)||(null==t||null==(s=t.claims)?void 0:s.sub),o=null==t?void 0:t.accessToken;Mp(`Sign out... (${n})`),n&&o&&await async function(e){return!e.accessToken||import("node-machine-id").then(async t=>{const n=await zd();return Rd=n,await fetch("https://cloud.needle.tools/api"+ht.account.post_machine,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify({action:"logout",machine_id:n,machine_name:Fd()})}).catch(e=>{Mp(`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),Mp(`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 r.signOut(td()),hd();break}case"auth-callback":if(t.url){const o=await r.handleSignInCallback(`${Cu}${t.originalUrl}`).catch(e=>({error:e}));if(hd(),o&&"error"in o){Mp(`Error during sign in: ${o.error}`);const e=o.error instanceof Error?o.error.message:String(o.error);n.redirect(Cu+"?cancelled&message="+encodeURIComponent(e))}else{var c,l,p,u;const t=await _d();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=[...Pd(t)];const o=await Dd(t,{signout:!0});if(!o)return e.invalid_login=!0,e.invalid_login_type="too-many-logins",n.redirect(td("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(td("error"));hd()}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)}`),Mp(`User logged in: ${(null==t||null==(p=t.userInfo)?void 0:p.sub)||(null==t||null==(u=t.claims)?void 0:u.sub)}`),oh(),n.redirect(Cu)}}break;default:o()}}),t};function uh(e,t,n){return!!n||e===kp||"string"==typeof t&&t===e}function dh(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=mh(t);if(e)return e}catch(e){}}function mh(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 r=o.find(e=>"origin"===e.name)||o.find(e=>"upstream"===e.name)||o[0];return r?r.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:mh(o)}function fh(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 hh=new Set(["https://cloud.needle.tools","https://needle.tools","https://engine.needle.tools","https://docs.needle.tools","chrome-extension://kjcepmifiddcepiocokclhibpkgcdomk","chrome-extension://jonplpbnhmanoekkgcepnedhghflblmo"]),gh=new Set(["localhost","127.0.0.1","[::1]","::1"]);function vh(e){if("string"!=typeof e||0===e.length)return!1;if(hh.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!!gh.has(n)||"::1"===n}const bh="[MCP]",yh=new Array;function xh(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function wh(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0}async function _h(){try{return JSON.parse(await V(se(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 jh(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 kh(e,t){return{api_endpoint:e,version:t,pid:process.pid}}var Sh={__proto__:null,getLocalServerInfo:kh,getLocalServerStatus:async function(e={}){var t,n,o;const i=null!=(t=e.fetch)?t:globalThis.fetch;let r,a;try{r=await i(`${Cu}/api/info`,{signal:AbortSignal.timeout(3e3)})}catch(e){if(e instanceof Error&&xh(e.cause)&&"ECONNREFUSED"===e.cause.code)return{running:!1,url:Cu};throw e}if(!r.ok)throw new Error(`Local server status request failed (HTTP ${r.status}).`);try{a=await r.json()}catch(e){if(e instanceof SyntaxError)throw new Error("Invalid local server info response.");throw e}if(!xh(a)||"string"!=typeof a.version||!a.version.trim()||"string"!=typeof a.api_endpoint||!a.api_endpoint.trim())throw new Error("Invalid local server info response.");if(void 0!==a.pid&&!wh(a.pid))throw new Error("Invalid local server PID.");if(wh(a.pid))return{running:!0,url:Cu,version:a.version,pid:a.pid,pidSource:"server"};const s=await(null!=(n=e.readServerRecord)?n:_h)();return xh(s)&&s.port===Ou&&wh(s.pid)&&(null!=(o=e.isProcessAlive)?o:jh)(s.pid)?{running:!0,url:Cu,version:a.version,pid:s.pid,pidSource:"record"}:{running:!0,url:Cu,version:a.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 Eh="2026-10-26T16:04:39.957Z";var Th={__proto__:null,BUILD_TIME:Eh};const{json:$h}=Qe;function Ih(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 Ah(t={restart:!1}){const n=!0===t.restart,o=await e(Cu).catch(e=>({ok:!1})),r="/sign-in",a="/api/authenticated",s="/api/projects",l="/api/content",p={baseUrl:Cu,port:Ou,isHost:!1,auth_endpoints:{"sign-in":`${Cu}${r}`,"sign-out":`${Cu}/sign-out`,"is-authenticated":`${Cu}${a}`}};let u=o.ok;if(u){var d;const g=await e(`${Cu}/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(!uh(b.api_endpoint,"https://cloud.needle.tools/api",n))return Mp(`Keeping CLI server for ${b.api_endpoint}; https://cloud.needle.tools/api did not request an explicit restart.`),p;Mp(`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)){Mp("Restarting auth server...");const y=`${Cu}/restart`;t.ora&&(t.ora.text="Sending restart request to server");const x=new AbortController;setTimeout(()=>x.abort(),1e4);let w={};try{const k=_($e(),".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(y,{method:"post",signal:x.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 kl(300),Ah({restart:!1});409!==j.status&&console.error("Failed to restart server",j.status),Mp(`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),Mp("Error starting the auth server"),new Error("Failed to load express module")});if(!E)throw Mp("Error loading auth server module"),new Error("Failed to load express module");Mp(`Starting Needle CLI server ${Zd()} (built ${Eh})... (Using api at https://cloud.needle.tools/api)`,{emptyLineBefore:!0}),p.isHost=!0;let T=null;const A={invalid_login:!1,invalid_login_type:null,user_email:null,logged_in_machine_names:[]};let O=E.default();const C=_($e(),".needle"),N=function(e,t){var n;const o=se(e,"local-server-token"),r=null!=(n=function(e){if(!$(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 a=JSON.stringify({token:r,pid:process.pid,port:t},null,2);if(G(o,a,{encoding:"utf-8",mode:384}),"win32"===process.platform)try{const e=process.env.USERNAME||process.env.USER||"";e&&He("icacls",[o,"/inheritance:r","/grant:r",`${e}:(F)`],{stdio:"ignore",timeout:5e3})}catch{}return r}(C,Ou);Mp(`Local token written to ${_(C,"local-server-token")}`);const R=function(e,t=5e3){const n=new Map,o=Math.max(1,Math.round(t/1e3));return(i,r)=>{const a=Date.now(),s=n.get(i);if(!s||a-s.lastLog>t){var c;const t=null!=(c=null==s?void 0:s.suppressed)?c:0;e(t>0?`${r} [+${t} similar in last ${o}s]`:r),n.set(i,{lastLog:a,suppressed:0})}else s.suppressed++}}(e=>Mp(`Denied: ${e}`),5e3);O.use((h={onDenied:R},(e,t,n)=>{var o;return fh(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"))})),O.use(function(e){const t=null==e?void 0:e.onDenied;return(e,n,o)=>{var i,r;if("OPTIONS"===e.method)return o();const a=null==(i=e.headers)?void 0:i.origin,s=null==(r=e.headers)?void 0:r["sec-fetch-site"];if(void 0!==a){if(vh(a))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|${a}|${o}`,`denied origin=${a} 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:R})),O.use($h({limit:"10mb"}));const P=new Set(["/","/sign-in","/sign-out","/auth-callback","/api/info","/api/authenticated","/api/public_key","/mcp","/register"]),U="needle_local";O.use((e,t,n)=>{var o,i,r;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 a=null==(o=e.headers)?void 0:o.authorization;if(a){const e=a.split(" ");if(2===e.length&&"Bearer"===e[0]&&e[1]===N)return n()}if((null==(i=e.query)?void 0:i.token)===N)return n();const s=((null==(r=e.headers)?void 0:r.cookie)||"").split(";").map(e=>e.trim()).find(e=>e.startsWith(U+"="));if(s&&s.split("=")[1]===N)return n();try{var c,l;const t=null!=(c=null==(l=e.headers)?void 0:l["user-agent"])?c:"unknown";R(`token|${t}|${e.path}`,`path=${e.path} ua="${t}" — no valid token or cookie`)}catch{}return t.status(401).send("Unauthorized: token required")}),O.use(ph(A)),t.ora?(t.ora.start("Starting MCP server..."),t.ora.succeed(`MCP server available at ${Cu}/mcp`)):console.log(`\nMCP server available at ${Cu}/mcp .`),O.use(If);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 (${Zd()})"/>`,F="</div>";let D="";O.get("/",Id(),async(e,t)=>{var n,o;if(null!=(n=e.user)&&n.isAuthenticated?t.cookie(U,N,{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 Mp("Login cancelled by user");if(null!=e.query["too-many-logins"]&&A.logged_in_machine_names.length){var i;const e=Sp();let n="<div>";return n+="<strong>You have reached the maximum number of allowed device logins!</strong><br/><br/>",n+=(null==(i=A.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="${r}">sign-in on this machine</a>.<br/><br/>`,n+="</div>",t.status(406),t.end(z+n+F),void Mp(`Login failed: Too many logins from different machines: [${A.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="${r}">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://${Dp()}" target="_blank">${Dp()}</a></span>\n </div>\n ${F}`);if(null!=(o=e.user)&&o.isAuthenticated){var a;if(!await Ld(e.user)){if(A.invalid_login=!0,A.logged_in_machine_names=[...Pd(e.user)],od(),Mp("Cleared stored auth data"),"client"in e.user){const t=e.user;await t.client.clearAccessToken(),await t.client.clearAllTokens(),Mp("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="${r}">sign in</a> again</div>${F}`)}A.invalid_login=!1,t.end(`${z}\n <div>\n Hi ${Td(e.user)} — you logged in successfully. You can close this window now.\n </div>\n ${F}`);const n=`Logged in successfully as ${Td(e.user)} (${null==(a=e.user.userInfo)?void 0:a.sub})`;return void(D!==n&&(D=n,Mp(D)))}let s=`<span><a href="${r}">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()}),O.post("/restart",(e,n)=>{var o;if(!uh("https://cloud.needle.tools/api",e.headers["x-needle-api-endpoint"],"true"===e.headers["x-needle-explicit-restart"]))return Mp("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=T)||o.close(e=>{e&&console.error(e)}),setTimeout(()=>{process.exit(0)},100),n.status(200).end("Server is restarting"),Mp("Server is restarting\n")}),O.get("/api/logs",async(e,t)=>{const n=Dp();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 r=`--- Needle CLI v${Zd()} (built ${Eh}) Log File (newest first) ---\n${n}\n\n`;r+=i,t.status(200).end(r)}):t.status(404).end("Log file not found")}),O.get("/api/info",(e,t)=>{t.json(kh("https://cloud.needle.tools/api",Zd()))}),O.get(a,Id(),async(e,t)=>{var n;if(!0===A.invalid_login){const e=Oh(A);return t.status(e.status).json(e)}A.invalid_login=!1,t.status(null!=(n=e.user)&&n.isAuthenticated?200:400).send()}),O.get("/api/user",Id(),async(e,t)=>{var n;const o=e.user;if(null==o||!o.isAuthenticated){if(!0===A.invalid_login){const e=Oh(A);return t.status(e.status).json(e)}return t.status(401).json({error:"Not authenticated"})}if(A.invalid_login=!1,!await Ld(o))return od(),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,r=null==o?void 0:o.userInfo.custom_data,a={authenticated:o.isAuthenticated,id:o.userInfo.sub,name:Td(o),email:o.claims.email||o.userInfo.email||"",profile_picture:o.userInfo.picture||"",default_org_id:(null==r?void 0:r.default_org)||"none",orgs:[]},s=["manage","owner","member","developer"];o.userInfo.organization_data&&(a.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===a.default_org_id?-1:t.id===a.default_org_id?1:e.name.localeCompare(t.name))),t.json(a)}),O.get("/api/license",Id(),async(t,n)=>{var o,i,r;const a=null==(o=t.query.token)?void 0:o.toString(),s=null==(i=t.query.org)?void 0:i.toString();let c=null;if(a)c={authToken:a};else{const e=await _d();if(!e||!e.isAuthenticated)return n.status(401).json({error:"Not authenticated",code:"not_authenticated"});if(!await Ld(e))return od(),n.status(403).json({error:"Invalid login"});c=await $d(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=gt(c),p=null==(r=t.query.integration)?void 0:r.toLocaleString(),u={...l,"x-needle":"cli","x-needle-integration":null!=p&&p.length?p:"unknown"},d=await e(`https://cloud.needle.tools/api${ht.account.get_licenses}`,{method:"GET",headers:u}).catch(e=>{const t=Ih(e);return console.error("Failed to fetch licenses:",t),Mp(`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})}),O.get("/api/deployments",Id(),async(e,t)=>{var n;const o=await _d();if(!o||!o.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const i=null==(n=e.query.org)?void 0:n.toString(),r=await $d(o,i).catch(e=>({status:500,error:e.message}));if("error"in r)return t.status(r.status).json({error:r.error});if(i&&!r.org)return t.status(400).json({error:"Organization not found"});const a=await Tu({endpoint:"https://cloud.needle.tools/api",authToken:r.authToken,org:r.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 a)return t.status(a.status).json({error:a.error});for(const e of a.deployments)e.editUrl=`${Ep()}/${e.id}`;const s={...a};return t.json(s)}),O.get(l,Id(),async(e,t)=>{var n,o,i,r,a,s,c,l;const p=await _d();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 $d(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==(r=e.query.content_format)?void 0:r.toString())||void 0,search:(null==(a=e.query.search)?void 0:a.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 np({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)}),O.get(l+"/:identifier",Id(),async(e,t)=>{var n,o;const i=await _d();if(!i||!i.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const r=(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,a=await $d(i,r).catch(e=>({status:500,error:e.message}));if("error"in a)return t.status(a.status).json({error:a.error});const s=await op({baseUrl:"https://cloud.needle.tools/api",authToken:a.authToken,org:a.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)}),O.get(s,Id(),async(t,n)=>{const o=await _d();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i=`https://cloud.needle.tools/api${ht.local_projects.get.user}`,r=await e(i,{method:"GET",headers:{Authorization:`Bearer ${o.accessToken}`}}).catch(e=>(console.error("Failed to fetch projects:",Ih(e)),null));if(!r)return n.status(502).json({error:"Failed to fetch projects: upstream API unreachable"});if(!r.ok)return n.status(r.status).json({error:r.statusText});const a=await r.json().catch(e=>console.error(e));return n.json(a)}),O.get(s+"/:id",Id(),async(t,n)=>{var o;const i=await _d();if(!i||!i.isAuthenticated)return n.status(401).json({error:"Not authenticated"});let r=null==(o=t.query.org)?void 0:o.toString();const a=await $d(i,r).catch(e=>({status:500,error:e.message}));if(!a)return n.status(500).json({error:"Failed to fetch projects"});if("error"in a)return n.status(a.status).json({error:a.error});const s=gt(a),c=`https://cloud.needle.tools/api${ht.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:",Ih(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"})}),O.post("/api/projects",Id(),async(t,n)=>{const o=await _d();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i="string"==typeof t.body?JSON.parse(t.body):t.body,r={machine_id:await zd(),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(!r.project_id||!r.project_name)return n.status(400).json({error:"Invalid request"});const a=`https://cloud.needle.tools/api${ht.local_projects.post}`,s=await e(a,{method:"POST",headers:{Authorization:`Bearer ${o.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(r)}).catch(e=>(console.error("Failed to upsert project:",Ih(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"})}),O.get("/api/public_key",Id(),async(t,n)=>{var o,i;const r=await _d();if(!r||!r.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const a=null==(o=t.query.org)?void 0:o.toString(),s=await $d(r,a).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 zd()},l=await e(`https://cloud.needle.tools/api${ht.account.public_key}`,{method:"POST",headers:{...gt(s),"Content-Type":"application/json"},body:JSON.stringify(c)}).catch(e=>(console.error("Failed to fetch public key:",Ih(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})}),O.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=dh(o);return i?t.json({project_id:i}):t.status(404).json({error:"Project ID not found"})}),O.post("/api/project/info",Id(),async(e,t)=>{(function(e){try{!function(e){var t,n,o,i;const r={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},a=Vd();let s=Kd();const c=s.entries.findIndex(e=>e.project_location===r.project_location),l=null==(o=s.entries[0])?void 0:o.project_location;-1!==c?s.entries[c]=r:s.entries.push(r),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&&Mp(`Active project changed: ${l||"(none)"} → ${u}`);try{qd=s;const e=JSON.stringify(s);f(a,e,"utf-8")}catch(e){console.error("Failed to save project info:",e)}}(e)}catch(e){Mp("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(T=O.listen(Ou,()=>{null==q||q()}),T.on("error",e=>{if("EADDRINUSE"===(null==e?void 0:e.code))return Mp(`License server port ${Ou} 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),Mp(`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()}})}(T,Mp),T.on("close",m),process.on("exit",m),process.on("SIGINT",()=>{m(),process.exit(0)}),await B.catch(e=>{console.error(e),Mp(`Error starting the auth server (promise failed): ${e.message}`)}),W)return p;function m(){Mp("Cleaning up auth server...")}const H=function(e,t){const n=new Ge({server:e,path:"/mcp/ws",verifyClient:({req:e},t)=>{var n;if(!fh(e.headers.host))return Mp(`${bh} 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&&!vh(o))return Mp(`${bh} rejected WS upgrade: disallowed origin ${o}`),void t(!1,403,"Forbidden: origin not allowed");t(!0)}});Mp("MCP websocket server created.");let o=0,i=new Map;return n.on("connection",e=>{const t=++o;yh.push(e),console.log(`${bh} client connected (#${t})`),Mp(`${bh} client connected (#${t})`),e.on("close",()=>{const n=yh.indexOf(e);-1!==n&&yh.splice(n,1);const o=i.get(t);if(o){for(const e of o)im(e,Mf);i.delete(t)}console.log(`${bh} client disconnected (#${t})`),Mp(`${bh} client disconnected (#${t})`)});const n=new Map;e.on("message",o=>{try{const r=o.toString(),a=JSON.parse(r);switch(a.command){default:console.log(`${bh} Unknown command: ${a.command}`),Mp(`Unknown MCP websocket command received: ${a.command}`);break;case"get_connected_clients":!function(t,n){const o={clients:[...Nf()],command:"mcp_server_response",messageId:"messageId"in t?t.messageId:void 0};e.send(JSON.stringify(o))}(a);break;case"register_tools":{const o=a.tools,r=a.source;if("cli"===r||"cloud"===r)throw new Error("The CLI and cloud tool sources are reserved for built-in tools.");r&&om(r,Mf);const s=r||"unknown";console.log(`${bh} ${s} registered ${o.length} tool${1===o.length?"":"s"}`),Mp(`${bh} ${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)rm(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((r,a)=>{const s=setTimeout(()=>{n.has(i)&&(console.error(`${bh} Tool execution timed out for tool: ${t.name}`),n.delete(i),a(new Error(`Tool execution timed out for tool: ${t.name}`)))},3e4);n.set(i,{resolve:e=>{r(e),clearTimeout(s)},reject:a}),e.send(JSON.stringify({command:"execute_tool",toolName:t.name,args:o,requestId:i}))})},{source:r},Mf),c.add(t.name);break}case"tool_result":{const e=a.requestId,t=a.result;if(console.log(`${bh} 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(`${bh} No pending tool execution found for requestId: ${e}`);break}}}catch(e){console.error(`${bh} Error processing WebSocket message:`,e)}})}),n}(T);ff({logToolCount:!0}),oh();const J=Gm(C,()=>{qm()?(Mp("Settings changed: remote_ai_tools disabled — closing cloud connection"),ih("remote_ai_tools setting disabled")):(Mp("Settings changed: remote_ai_tools enabled — opening cloud connection"),oh())});Od(O,N,()=>{Mp("Authenticated stop requested; shutting down the local Needle server."),T&&Cd(T,H,()=>{J(),ih("stop requested")})}),process.on("exit",()=>{J(),ih("process exit")})}var h;return p}function Oh(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 ${Sp()}. You're currently logged in on: ${e.logged_in_machine_names.join(", ")}`:"An unknown error occured.",{status:403,error:t}}async function Ch(e={headless:!1,silent:!1,clearAuthData:!1}){return!0===e.clearAuthData&&await od(),Rh("sign-in",{...e})}function Nh(e={}){return Rh("sign-out",{...e})}function Rh(t,n){return new Promise(async(o,i)=>{let r=!1;if("sign-in"==t){const e=await _d();if(null!=e&&e.isAuthenticated&&e.accessToken)return await Dd(e)?(r=!0,n.ora&&(n.ora.text=`Authorized as ${Td(e)}`),"gotoAccountPage"in n&&!0===n.gotoAccountPage&&(n.ora&&(n.ora.text="Opening account page in the browser"),Tp(Sp()),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){r=!0,od();const t=await Ah(),n=await e(t.auth_endpoints["sign-out"],{follow:2});return o(n.ok)}const a=await Ah();switch(n.timeout||(n.timeout=6e5),"number"==typeof n.timeout&&n.timeout>0&&setTimeout(()=>{r||(n.ora&&n.ora.fail('Timeout "'+t+'"'),o(null))},n.timeout),t){case"sign-in":const e=a.auth_endpoints["sign-in"];setTimeout(()=>Tp(e),300),n.ora&&(n.ora.text=`Please authenticate in the browser: ${e}`),setTimeout(l,2e3);break;case"sign-out":od(),Tp(a.auth_endpoints["sign-out"]),setTimeout(l,2e3)}let s=0;const c=10;function l(){e(a.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 _d();return e&&!await Dd(e)?o(null):(r=!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;T().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 r=!0,od(),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 ${a.port} is not blocked`):n.silent||console.error(`Failed to complete auth flow. Please try again. Make sure that port ${a.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,r=null!=(n=e.log)?n:Bp,a=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}`:"";r(`CLI crashed (${e}): ${n}${o}`)}catch{}try{a(`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 Ph=process.argv.includes("--silent"),Uh=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8")),Lh="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 zh(e,t=null,n=!0){let o,i=null==e?void 0:e.toString();var r;if(i||(ze.config(),process.env.NEEDLE_CLOUD_TOKEN&&(i=process.env.NEEDLE_CLOUD_TOKEN,null!=(r=i)&&r.length&&console.error("Using NEEDLE_CLOUD_TOKEN token from env"))),""===i||"true"===i){if(!n)throw new Error("--token requires a value in non-interactive mode.");const e=(await import("node:readline")).createInterface({input:process.stdin}),t=10;let i,r="",a=!1;return new Promise(n=>{const s="Paste your https://cloud.needle.tools/team#token access token here:",c=T({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?r=r.slice(0,-1):r+=p;const e=r.replace(/./g,"*");c.text=`${s} ${e}`}clearTimeout(i),i=setTimeout(()=>{if(!a&&(u||r.trim().length>t)){process.stdin.setRawMode(!1),e.close(),a=!0;const t=r.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");n({accessToken:t,org_id:o})}},150)})})}if(!i){let e;n&&!await async function(){const e=await _d();return null==e?void 0:e.isAuthenticated}()&&(e=Ph?void 0:T("No access token found. Please sign in to authenticate...").start()),Mp("No access token provided, attempting login. Org: "+t);const r=Ch({headless:!n,ora:e,timeout:12e4}),d=await r;if(d&&!await Ld(d)){var a;if(!n)throw new Error("Saved authentication is invalid. Provide --token or NEEDLE_CLOUD_TOKEN.");null==(a=e)||a.fail("You are not logged in from this machine. Please login again."),await Nh({headless:!0}),process.exit(1)}else e&&(Mp("User logged in via getAccessToken "+(null==d?void 0:d.isAuthenticated)),d?e.succeed("Logged in"):e.fail("Login failed"));if(null!=d&&d.isAuthenticated){var s;if(null==t){const e=await jd(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 (${Td(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)),Mp("Getting access token for org "+o+", "+i.substring(0,8)+"...")}else{var u;Mp("Getting access token for user "+(null==(u=d.userInfo)?void 0:u.sub)),i=null==d?void 0:d.accessToken}}}if(!i)throw Mp("ERR: Missing NEEDLE_CLOUD_TOKEN token. Org: "+o),new Error("Missing authentication. Provide --token, set NEEDLE_CLOUD_TOKEN, or run needle-cloud login.");return{accessToken:i,org_id:o}}function Fh(e){return null!=e.org&&console.warn("Warning: --org is deprecated. Use --team instead."),e.team||e.org}const Dh=mt.program;async function qh(){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))}Dh.version(Uh.version).description("Command-line interface (CLI) for Needle Cloud"),Dh.command("version","Print the CLI version").configure({visible:!1}).action(()=>{Ph||console.log(`☁ Needle CLI — ${Uh.version}, Node ${process.version}`)}),Dh.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:Dh.BOOLEAN,default:!1}).option("--integration <integration>","Hint for the process which integration triggered this command",{required:!1,validator:Dh.STRING}).action(async({options:e})=>{const t=e.integration,n=Ph?void 0:T("Starting Needle License server "+(t?`(from ${t})`:"")).start();Ah({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${Zd()}, built ${function(e){if("string"!=typeof Eh||0===Eh.length)return"unknown";const t=new Date(Eh);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))})}),Dh.command("stop","Stop the local Needle license server").alias("quit").help("Request an authenticated shutdown of the local Needle server, then exit. Does not sign out or stop Unity. Older servers without stop support must be closed manually.").action(async()=>{try{const{stopLocalServer:e}=await Promise.resolve().then(function(){return Nd}),t=await e();Ph||console.log("not-running"===t?"Needle server is not running.":"Needle server shutdown requested."),process.exit(0)}catch(e){console.error(`Could not stop the Needle server: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}),Dh.command("settings","Show current Needle CLI settings").action(async()=>{const{readSettings:e,KNOWN_SETTINGS:t}=await Promise.resolve().then(function(){return Hm}),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("")}),Dh.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:Dh.BOOLEAN}).action(nu("settings remote-ai-tools",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return Hm}),o=e.enabled,i=n();o?(t(i,"remote_ai_tools",null),console.log("Remote AI tools enabled (default)."),Mp("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."),Mp("Settings: remote_ai_tools set to disabled via CLI command"))})),Dh.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:Dh.BOOLEAN}).action(nu("settings local-file-edits",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return Hm}),o=e.enabled;t(n(),"local_file_edits",o?null:"disabled"),console.log(`Local AI file edits ${o?"enabled":"disabled"}.`)})),Dh.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:Dh.BOOLEAN}).action(nu("settings local-project-commands",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return Hm}),o=e.enabled;t(n(),"local_project_commands",o?null:"disabled"),console.log(`Local AI project commands ${o?"enabled":"disabled"}.`)})),Dh.command("status","Show the local Needle server status and process ID").action(nu("status",async()=>{const{getLocalServerStatus:e,formatLocalServerStatus:t}=await Promise.resolve().then(function(){return Sh});console.log(t(await e()))})),Dh.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(nu("mcp",async()=>{const{startStdio:e}=await Promise.resolve().then(function(){return qf});e()})),Dh.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=dh(e.paths);t?console.log(`Found project ID: "${t}"`):console.log("No project ID found.")}),Dh.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:Dh.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:Dh.BOOLEAN,default:!1}).action(nu("send-logs",async({options:e})=>{var t,n,o,i,r,a,s;const{runSendLogs:c,HAYSTACK_RESOURCE:l}=await Promise.resolve().then(function(){return Xu}),{tryGetFreshAccessTokenForResource:p}=await Promise.resolve().then(function(){return Ed}),{findActiveEditorLog:u}=await import("./cli.send-logs.discovery-29fa4e4a.js"),{getLogFilePath:d,getPrevLogsFilePath:m,getPipelineLogFilePath:f}=await Promise.resolve().then(function(){return Wp}),{homedir:h,platform:g}=await import("os"),{existsSync:v}=await import("fs"),{BUILD_TIME:b}=await Promise.resolve().then(function(){return Th}),{getNodeVersion:y,getNpmVersion:x,getArch:w,getOsRelease:_,getCpuCount:j,getTotalMemoryMb:k,getTzOffsetMinutes:S,isCi:E,isTty:$}=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",A=e.note,O=null!=(i=null!=(r=null==(a=e.dryRun)||null==a.valueOf?void 0:a.valueOf())?r:e.dryRun)&&i,C=d(),N=m(),R=f(),P={getAccessToken:()=>p(l),fetch:globalThis.fetch,paths:{cliLogPath:v(C)?C:null,prevLogPath:v(N)?N:null,pipelineLogPath:v(R)?R:null,homeDir:h()},meta:{cli_version:Zd(),build_time:b,os:g(),os_release:_(),arch:w(),node_version:y(),npm_version:null!=(s=x())?s:"unknown",cpu_count:j(),total_memory_mb:k(),tz_offset_minutes:S(),is_ci:E(),is_tty:$()},findActiveEditorLog:u,stdout:process.stdout,stderr:process.stderr},U=O?"Building payload (dry-run)":"Uploading logs",L=Ph?void 0:T(U).start();P.recoverAuth=async()=>{null==L||L.stop();try{await qh();const e=await Ch({clearAuthData:!0,silent:Ph,ora:void 0});if(null==e||!e.isAuthenticated)return null}catch(e){return Mp(`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:A,dryRun:O},P);z.ok?O?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)})),Dh.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:Dh.BOOLEAN,default:!1}).option("--clear <clear>","Refresh the access token",{required:!1,validator:Dh.BOOLEAN,default:!1}).action(su(async({options:e})=>{const t=ru(e),n=!0===e.nonInteractive||!0===e.headless;n||await qh();const o=!0===e.clear,i=Ph?void 0:T("Login").start();await Ch({headless:n,silent:Ph,clearAuthData:o,ora:i}).then(async e=>{"json"===t&&cu({authenticated:!0===(null==e?void 0:e.isAuthenticated)}),null!=e&&e.isAuthenticated?null==i||i.succeed("Successfully logged in as "+Td(e)):0==n?null!=e&&e.claims||null!=e&&e.userInfo?null==i||i.warn(`You (${Td(e)}) are not authenticated...`):null==i||i.fail("Login failed"):Ph||null==i||i.warn("Not logged in"),await lu(null!=e&&e.isAuthenticated?0:1)})})),Dh.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:Dh.BOOLEAN,default:!1}).action(su(async({options:e})=>{const t=ru(e),n=!0===e.nonInteractive||!0===e.headless;n||await qh(),await Nh({headless:n}).then(async e=>{"json"===t&&cu({success:e}),e?T("Logged out").succeed():T("Logout failed").fail(),await lu(e?0:1)})})),Dh.command("me","Prints your user information").help("Prints basic informaton about the logged in Needle Cloud account (your account)").action(su(async({options:e})=>{const t=ru(e),n=Ph?void 0:T("Query user data").start(),o=await _d(),i=Boolean((null==o?void 0:o.isAuthenticated)&&await Ld(o));if("json"!==t)if(o&&i){const e=o.userInfo||o.claims;var r,a,s;e?(null==n||n.succeed(`You are logged in as ${Td(o)}`),console.log(`- Name: ${Td(o)}`),console.log(`- ID: ${e.sub}`),e.email&&console.log(`- Email: ${e.email}`),e.phone_number&&console.log(`- Phone: ${e.phone_number}`),null!=(r=o.userInfo)&&r.organization_data&&console.log(`- Teams [${null==(a=o.userInfo)?void 0:a.organization_data.length}]: ${null==(s=o.userInfo)?void 0:s.organization_data.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.name).join(", ")}`)):null==n||n.fail("Failed to get user data")}else null==n||n.warn("You are not logged in");else{null==n||n.stop();const e=(null==o?void 0:o.userInfo)||(null==o?void 0:o.claims);var c,l;o&&i&&e?cu({authenticated:!0,id:e.sub,name:Td(o),email:e.email,teams:(null!=(c=null==(l=o.userInfo)?void 0:l.organization_data)?c:[]).map(e=>({id:e.id,name:e.name}))}):(cu({authenticated:!1}),process.exitCode=1)}})),Dh.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:Dh.STRING}).option("--org <org>","Legacy alias for --team",{validator:Dh.STRING,hidden:!0}).action(nu("get-pro",async({options:e})=>{var t;let n=(null==(t=Fh(e))?void 0:t.toString())||null;const o=T().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 r=i.toString();o.succeed(`Started Needle Engine PRO purchase flow: opening browser at ${r}`),Tp(r)}));const Bh={account:{url:Sp}},Mh=`"${Object.keys(Bh).join('", "')}"`;Dh.command("open",`Open a page in the default browser. Options are: ${Mh}`).argument("<page>",`The page to open. Options are: ${Mh}`,{validator:Dh.STRING}).configure({strictOptions:!1,strictArgsCount:!1,visible:!1}).help("").action(async({args:e,logger:t})=>{const n=e.page.toString(),o=Bh[n];o?"url"in o?Tp(o.url()):t.error(`Unknown argument: ${n}`):t.error(`Unknown argument: ${n}. Options are: ${Mh}`)}),Dh.command("list-deployments","Get a list of deployed websites").configure({visible:!1}).help("").option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Dh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Dh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Dh.STRING}).option("--limit <limit>","Limit the number of deployments to show (min: 0, max: 100)",{validator:Dh.NUMBER,default:10}).option("--offset <offset>","The offset for deployments (default: 0, min: 0)",{validator:Dh.NUMBER,default:0}).option("--format <format>","Legacy output option: cli or json",{validator:Dh.STRING,hidden:!0}).option("--name","Filter by one or multiple deployment names (separated by ;)",{validator:Dh.STRING}).action(su(async({options:e,logger:t})=>{var n,o,i,r;const a=ru(e,{legacyFormat:!0}),{accessToken:s,org_id:c}=await zh(e.token,Fh(e),!0!==e.nonInteractive),l=(null==(n=e.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",p=Number(null!=(o=e.limit)?o:10),u=Number(null!=(i=e.offset)?i:0),d=(null==(r=e.name)?void 0:r.toString())||void 0;if(p<0)throw new Error("The limit cannot be negative.");if(p>100)throw new Error("The limit cannot exceed 100.");const m=T("Query deployments").start(),f=await Tu({endpoint:l,authToken:s,org:c,limit:p,offset:u,names:null==d?void 0:d.split(";")});if(f&&"error"in f)throw new Error(f.error+" (status: "+f.status+")");if(!f)throw new Error("Failed to query deployments.");if("json"===a)return m.succeed(`Found ${f.deployments.length} deployments`),void cu(f.deployments);f.deployments.length>0?(m.succeed(`Found ${f.deployments.length} deployments`),f.deployments.forEach((e,n)=>{t.info(`${n+p*u}: ${e.name} – ${e.url}`)})):m.warn("No deployments found")})),Dh.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>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Dh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Dh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Dh.STRING}).option("--include-projects","Include saved web projects (default: uploaded content only)",{validator:Dh.BOOLEAN,default:!1}).option("--trash","List deleted items instead of active content",{validator:Dh.BOOLEAN,default:!1}).option("--interactive","Override automatic terminal browsing: true or false",{validator:Dh.BOOLEAN}).option("--type <type>","Filter by content type (e.g. material, 3d-asset, deployment, editor-project)",{required:!1,validator:Dh.STRING}).option("--format <format>","Filter by output format (e.g. glb, textures)",{required:!1,validator:Dh.STRING}).option("--search <search>","Search by name, title or description",{required:!1,validator:Dh.STRING}).option("--limit <limit>","Max number of items to show (default: 20, max: 100)",{validator:Dh.NUMBER,default:20}).option("--offset <offset>","Offset for pagination (default: 0)",{validator:Dh.NUMBER,default:0}).option("--output <output>","Output style: cli (default), json",{validator:Dh.STRING,default:"cli"}).action(su(async({options:e,logger:t})=>{var n,o,i,r,a,s;const c=ru(e),l=function(e,t={input:!0===process.stdin.isTTY,output:!0===process.stdout.isTTY}){return!0===e.interactive?(hu(e,t),!0):!(!1===e.interactive||!0===e.nonInteractive||"json"===e.output||!t.input||!t.output||(hu({...e,interactive:!0},t),0))}(e),p=Number(null!=(n=e.limit)?n:20),u=Number(null!=(o=e.offset)?o:0);if(!Number.isInteger(p)||p<1)throw new Error("--limit must be a positive integer.");if(!Number.isInteger(u)||u<0)throw new Error("--offset must be a nonnegative integer.");const d=null==(i=e.type)?void 0:i.toString(),m=null==(r=e.format)?void 0:r.toString();if(d&&"editor-project"!==d&&!ep.some(e=>e===d))throw new Error("Invalid --type. Use "+[...ep,"editor-project"].join(", ")+".");if(m&&!tp.some(e=>e===m))throw new Error("Invalid --format. Use "+tp.join(", ")+".");const{accessToken:f,org_id:h}=await zh(e.token,Fh(e),!0!==e.nonInteractive),g=(null==(a=e.endpoint)?void 0:a.toString())||"https://cloud.needle.tools/api",v=Math.min(p,100),b=d||void 0,y=m||void 0,x=(null==(s=e.search)?void 0:s.toString())||void 0,w={content_type:b,include_projects:!0===e.includeProjects,trash:!0===e.trash,content_format:y,search:x,limit:v,offset:u},_=T("Querying content...").start();try{const e=await np({baseUrl:g,authToken:f,org:h},w);if(l)return _.stop(),await async function(e,t={}){var n,o,i,r;const a=null!=(n=t.terminal)?n:function(){const e=Pe({input:process.stdin,output:process.stdout,terminal:!0,historySize:0}),t=new AbortController;return e.on("SIGINT",()=>{t.abort(),e.close()}),e.on("close",()=>t.abort()),{get columns(){return process.stdout.columns||80},color:void 0===process.env.NO_COLOR&&"dumb"!==process.env.TERM,write:e=>{process.stdout.write(e)},async readLine(n){if(t.signal.aborted)return null;try{return await e.question(n,{signal:t.signal})}catch(e){if(t.signal.aborted)return null;throw e}},close:()=>e.close()}}(),s=null!=(o=t.listContent)?o:np,c=null!=(i=t.getContent)?i:op,l=null!=(r=t.open)?r:Tp;let p,u={...e.query},d=e.initial;try{for(yu(a,d,u);;){var m,f;const t=await a.readLine(bu(a,"\n › ","brand"));if(null===t)break;const n=t.trim();if("q"===n||"quit"===n)break;if(p){"b"===n?(p=void 0,yu(a,d,u)):u.trash||"o"!==n?u.trash||"e"!==n?a.write(" Choose o/e to open, b to go back, or q to quit.\n"):await wu(p.edit_url,a,l):await wu(p.view_url||p.url,a,l);continue}if(/^\d+$/.test(n)){var h;const t=d.items[Number(n)-1];if(!t){a.write(" Choose a number shown on this page.\n");continue}const o=u.trash?void 0:await c(e.auth,t.identifier,{item:null!=(h=t.item_type)?h:"content"});p=t,xu(a,t,o,!0===u.trash);continue}if("?"===n||"help"===n){a.write("\n Type a number and Enter to inspect an item.\n /wood searches; / clears search. n/p move between pages.\n t switches between content and Trash; r refreshes the page.\n Browsing never changes content. Opening a browser requires o/e.\n q, Ctrl+C or end of input leaves the browser.\n");continue}const o=null!=(m=u.offset)?m:0,i=null!=(f=u.limit)?f:20;if("n"===n){if(o+d.items.length>=d.total){a.write(" No next page.\n");continue}u={...u,offset:o+i}}else if("p"===n){if(!o){a.write(" Already on the first page.\n");continue}u={...u,offset:Math.max(0,o-i)}}else if(n.startsWith("/"))u={...u,offset:0,search:n.slice(1).trim()||void 0};else if("t"===n)u={...u,offset:0,trash:!u.trash};else if("r"!==n){a.write(" Type a number, /search, n, p, t, r, ? or q.\n");continue}d=await s(e.auth,u),yu(a,d,u)}a.write("\n Back to your terminal.\n")}finally{a.close()}}({auth:{baseUrl:g,authToken:f,org:h},query:w,initial:e}),void await lu(0);if("json"===c)return _.succeed(`Found ${e.items.length} of ${e.total} items`),void cu(e.items);0===e.items.length&&(_.warn("No content found"+(b?` (type: ${b})`:"")+(y?` (format: ${y})`:"")),process.exit(0)),_.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?Sl(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=Au(` ${"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=Iu(e.type).padEnd(o.type+11),i=(e.formats?e.formats.split(", "):[]).map(e=>Iu(e)).join(", ")+" ".repeat(Math.max(0,o.formats-e.formats.length));t.info(` ${Au(e.id.padEnd(o.id))} ${n} ${i} ${e.name.padEnd(o.name)} ${e.versions.padStart(3)} ${Au(e.date)}`)}e.total>u+v&&t.info(` ... ${e.total-u-v} more (use --offset ${u+v})`),process.exit(0)}catch(e){_.fail(e.message),process.exit(1)}})),Dh.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:Dh.STRING}).option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Dh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Dh.STRING,hidden:!0}).option("--endpoint <endpoint>","The Needle Cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Dh.STRING}).action(su(async({args:e,options:t})=>{var n;const o=ru(t),{accessToken:i,org_id:r}=await zh(t.token,Fh(t),!0!==t.nonInteractive),a=(null==(n=t.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",s=String(e.identifier),c=T(`Deleting content "${s}"...`).start();try{const e=await Eu({identifier:s,endpoint:a,authToken:i,org:r});c.succeed(e.message||`Moved content "${s}" to the trash`),"json"===o&&cu(e)}catch(e){c.fail(e.message),process.exitCode=1}})),Dh.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:Dh.STRING}).argument("[directory]","Output directory (default: current directory)",{default:"."}).option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Dh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Dh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Dh.STRING}).option("--format <format>","Output format to download (e.g. glb, textures)",{required:!1,validator:Dh.STRING}).option("--version <version>","Download this source version or derived output ID",{validator:Dh.STRING}).option("--label <label>","Download the version served by this label",{validator:Dh.STRING}).option("--name <name>","Output filename (without extension)",{required:!1,validator:Dh.STRING}).option("--verbose","Show detailed download info",{required:!1,validator:Dh.BOOLEAN,default:!1}).action(su(async({args:e,options:t})=>{var n,o,i,r,a,s;const c=ru(t),{accessToken:l,org_id:p}=await zh(t.token,Fh(t),!0!==t.nonInteractive),u=(null==(n=t.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",d=String(e.identifier),m=(null==(o=e.directory)?void 0:o.toString())||".",f=(null==(i=t.name)?void 0:i.toString())||void 0,h=null!=(r=null==(a=t.verbose)?void 0:a.valueOf())&&r,g=(null==(s=t.format)?void 0:s.toString())||void 0,v=T("Looking up content...").start();try{var b,y;const e={baseUrl:u,authToken:l,org:p},n=await op(e,d);if(!n)throw new Error(`Content not found: "${d}". Use the exact content identifier (see list).`);const o=function(e,t){if(void 0!==t.version&&!t.version.trim())throw new Error("--version requires a version ID.");if(void 0!==t.label&&!t.label.trim())throw new Error("--label requires a label name.");if(t.version&&t.label)throw new Error("Use either --version or --label, not both.");const n=e.versions[0];if(!n)throw new Error(`Content "${e.title||e.name}" has no upload versions.`);let o;if(t.version){const n=e.versions.find(e=>e.identifier===t.version);if(o=n?[n,...n.variants]:e.versions.flatMap(e=>e.variants).filter(e=>e.identifier===t.version),!o.length)throw new Error(`Version "${t.version}" does not belong to this content item.`)}else if(t.label){if(o=e.versions.flatMap(e=>[e,...e.variants]).filter(e=>e.labels.some(e=>e.label===t.label)),!o.length)throw new Error(`Label "${t.label}" was not found on this content item.`)}else o=t.format?e.versions.flatMap(e=>[e,...e.variants]):[n];const i=t.format?o.find(e=>e.content_format===t.format):o[0];if(!i)throw new Error(`No output with format "${t.format}" found for the requested content selection.`);if((t.version||t.label)&&i.status&&"completed"!==i.status)throw new Error(`Version "${i.identifier}" is ${i.status}; select a completed version.`);return i.identifier}(n,{version:null==(b=t.version)?void 0:b.toString(),label:null==(y=t.label)?void 0:y.toString(),format:g});v.text=`Downloading "${n.title||n.name}"${g?` (format: ${g})`:""}...`,v.stop();const i=await _u({baseUrl:u,authToken:l,org:p,identifier:o,outDir:m,filename:f,verbose:h,content_format:g});if("error"in i)throw new Error(i.error);"json"===c&&cu(i)}catch(e){v.fail(e instanceof Error?e.message:String(e)),process.exitCode=1}})),Dh.command("deploy","Deploy a website to Needle").help("").argument("<directory>","The directory to deploy",{validator:Dh.STRING}).option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id to deploy to (not needed when using token/accesstoken)",{required:!1,validator:Dh.STRING}).option("--org <org>","The organization name or id to deloy to (not needed when using token/accesstoken)",{required:!1,validator:Dh.STRING,hidden:!0}).option("--name <name>","The project name. This name will also be used in your website URL",{required:!1,validator:Dh.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:Dh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Dh.STRING,hidden:!0}).option("--open","Open the deployment in the default browser",{default:!0,validator:Dh.BOOLEAN}).option("--verbose <verbose>","Enables verbose output logs",{required:!1,validator:Dh.BOOLEAN,default:!1,hidden:!0}).option("--experimental","Use the experimental upload API. Mostly used for debugging (default: false)",{required:!1,validator:Dh.BOOLEAN,default:!1,hidden:!0}).option("--raw","Use raw to disallow modifications like gzip compression on upload",{required:!1,validator:Dh.BOOLEAN,default:!1,hidden:!0}).option("--no-provenance","Do not record which commit and CI run this deployment came from",{required:!1,validator:Dh.BOOLEAN,default:!1}).action(su(nu("deploy",async({args:e,options:t,logger:n})=>{var o,i,r,a;const s=ru(t),c=!0!==t.nonInteractive&&t.open,{accessToken:l,org_id:p}=await zh(t.token,Fh(t),!0!==t.nonInteractive),u=!0===t.verbose,d=!0===t.experimental,m=!0===t.raw,f=(null==(o=t.noProvenance)?void 0:o.valueOf())||!1,h=await Hp({logger:n,endpoint:(null==(i=t.endpoint)?void 0:i.toString())||void 0,token:l,org_id:p,directory:String(e.directory),name:(null==(r=t.name)?void 0:r.toString())||void 0,entrypoint:(null==(a=t.entrypoint)?void 0:a.toString())||void 0,open:c,verbose:u||!1,experimental:d||!1,raw:m||!1,noProvenance:f});"json"===s&&null!=h&&h.success&&cu(h)}))),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>","Legacy output option: cli, json, source-url or edit-url",{validator:e.STRING}).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(nu(n,async({args:e,options:n})=>{var i;const r=globalThis.console,a=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Re({stdout:a,stderr:a});try{var s,c;const i=ru(n,{legacyFormat:!0,links:!0}),r=o||!0===n.wait;if(r&&!0===n.noOptimize)throw new Error("--wait cannot be combined with --no-optimize.");if(!r&&(void 0!==n.outdir||void 0!==n.progressive||void 0!==n.usecase))throw new Error("--wait is required for --outdir, --progressive and --usecase.");const a=n.usecase;if(void 0!==a&&"product"!==a&&"world"!==a)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:p,org_id:u}=await iu(t.getAccessToken,n);if(p!==n.token&&p!==process.env.NEEDLE_CLOUD_TOKEN){const e=await t.getUser();if(null==e||!e.isAuthenticated)throw new Error("Please login to upload files.");if(!u)throw new Error("Please provide a team to upload files.");if(r){var l;const e=await(null!=(l=t.getLicenses)?l:bt)({baseUrl:"https://cloud.needle.tools/api",authToken:p,org:u},{type:"org",org_id:u});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")}}ku(await(null!=(s=t.upload)?s:ju)({token:p,org_id:u,fileOrDirectory:String(e.path),name:void 0===n.name?void 0:String(n.name),wait:r,noOptimize:!0===n.noOptimize,progressive:void 0===n.progressive?void 0:!0===n.progressive,usecase:a,outDir:void 0===n.outdir?void 0:String(n.outdir),verbose:!0===n.verbose,format:i}),i,null!=(c=t.write)?c:e=>{process.stdout.write(e)})}finally{globalThis.console=r}}))}uu(e)}(Dh,{getAccessToken:zh,getUser:_d}),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>","Legacy output option: cli or json",{validator:e.STRING});"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(nu(`label ${n}`,async({args:e,options:o})=>{var i;const r=globalThis.console,a=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Re({stdout:a,stderr:a});try{var s;const i=ru(o,{legacyFormat:!0}),r=String(e.contentId);Kp(r);const a={contentId:r,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&&Yp(a),void 0!==o.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:p,org_id:u}=await iu(t.getAccessToken,o),d={baseUrl:"https://cloud.needle.tools/api",authToken:p,org:u},m=null!=(s=t.write)?s:e=>{process.stdout.write(e)};if("list"===n){var c;const e=await(null!=(c=t.listContentLabels)?c:Qp)(d,r);if("json"===i)m(JSON.stringify(e)+"\n");else if(e.labels.length)for(const t of e.labels)m(`${t.label}: ${t.sourceVersionIds.join(", ")}\n`),du(t.targets,m);else m(`No labels for ${r}.\n`)}else{var l;const e=await(null!=(l=t.setContentLabel)?l:eu)(d,a);"json"===i?m(JSON.stringify(e)+"\n"):(m(`${e.label}: ${e.previousVersionIds.join(", ")||"(new label)"} -> ${e.versionId}\n`),du(e.targets,m))}}finally{globalThis.console=r}}))}uu(e)}(Dh,{getAccessToken:zh}),function(e,t){const n={getContent:op,updateContent:ip,restoreContent:ap,...t},o={info:"Inspect content metadata, versions and processing state",versions:"List source versions and their derived outputs, newest first",update:"Update content metadata or its thumbnail",restore:"Restore a content item from Trash"};for(const i of["info","versions","update","restore"]){const r=e.command(i,o[i]).argument("<identifier>","Content 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>","Legacy alias for --team",{validator:e.STRING,hidden:!0}).option("--endpoint <endpoint>","Needle Cloud API endpoint",{validator:e.STRING}).option("--output <output>","Output style: cli (default) or json",{validator:e.STRING,default:"cli"});"update"===i&&r.option("--title <title>","Set the title; an empty string clears it",{validator:e.STRING}).option("--description <description>","Set the description; an empty string clears it",{validator:e.STRING}).option("--tags <tags>","Replace tags with a comma-separated list",{validator:e.STRING}).option("--thumbnail <path>","Set a JPEG, PNG or WebP thumbnail (up to 5 MiB)",{validator:e.STRING}),"restore"===i&&r.help("Restore an item within 31 days of deletion. Requires enough available storage. Use list --trash to find deleted items."),r.action(nu(i,async({args:e,options:o})=>{var r,a,s;const c=String(e.identifier);if(!c.trim()||/[/\\?#\s]/.test(c))throw new Error("Pass an exact content identifier from list.");const l=String(null!=(r=o.output)?r:"cli");if("cli"!==l&&"json"!==l)throw new Error("Invalid --output. Use cli or json.");const p="update"===i?await mu(o):void 0,u=globalThis.console,d=null!=(a=t.stderr)?a:process.stderr,m=null!=(s=t.write)?s:e=>{process.stdout.write(e)};globalThis.console=new Re({stdout:d,stderr:d});try{var f;void 0!==o.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:e,org_id:r}=await iu(t.getAccessToken,o),a={baseUrl:String(null!=(f=o.endpoint)?f:"https://cloud.needle.tools/api"),authToken:e,org:r};if("update"===i&&p){const e=await n.updateContent(a,c,p);if("error"in e)throw new Error(e.error);if(!e.success)throw new Error("Content update was not confirmed.");m("json"===l?JSON.stringify(e)+"\n":`Updated ${c}\n`)}else if("restore"===i){const e=await n.restoreContent(a,c);if(!e.restored)throw new Error("Content restore was not confirmed.");m("json"===l?JSON.stringify(e)+"\n":`Restored ${c}\n`)}else{const e=await n.getContent(a,c);var h,g;"json"===l?m(JSON.stringify("versions"===i?e.versions:e,null,2)+"\n"):("info"===i&&m(`${e.title||e.name} (${e.identifier})\n${null!=(h=e.description)?h:""}\nTags: ${(null!=(g=e.tags)?g:[]).join(", ")}\n`),m(e.versions.length?e.versions.map(fu).join(""):"No upload versions.\n"))}}finally{globalThis.console=u}}))}uu(e)}(Dh,{getAccessToken:zh}),Dh.command("generate-material","Generate a PBR material from a text prompt").help("").argument("<prompt>","The text prompt describing the material to generate",{validator:Dh.STRING}).option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Dh.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Dh.STRING,hidden:!0}).option("--resolution <resolution>","The material texture resolution (256, 512, 1k, 2k, 4k)",{default:"512",required:!1,validator:Dh.STRING}).option("--name <name>","Output filename",{required:!1,validator:Dh.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:Dh.STRING}).action(su(nu("generate-material",async({args:e,options:t,logger:n})=>{var o,i,r;const a=ru(t),{accessToken:s,org_id:c}=await zh(t.token,Fh(t),!0!==t.nonInteractive),l=String(e.prompt),p=null==(o=t.resolution)?void 0:o.toString(),u=null==(i=t.outdir)?void 0:i.toString(),d=null==(r=t.name)?void 0:r.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 ${Sp()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";Mp(`[generate-material] Starting request to ${t}, prompt="${e.prompt}", resolution=${e.resolution||512}`,{emptyLineBefore:!0});const n=T("Requesting material generation...").start(),o=await Promise.race([Ql({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 Mp(`[generate-material] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(Mp(`[generate-material] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return Mp(`[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 r=T("Waiting for material generation...").start();r.color="gray";const a=kc();for(;;){if("completed"===i.status){r.succeed("Material generation completed");break}let n=2e3;const o=await jc(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=a.record(o);if(s)return r.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))r.text="Your material is queued - waiting for generation to start",r.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))r.text=`Generating material: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,r.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){Mp(`[generate-material] Job completed: ${i.identifier}`),r.succeed(`Material generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return Mp(`[generate-material] Job canceled: ${i.identifier}, error=${o.error}`),r.fail(`Material generation canceled: ${o.error||""}`),{error:o.error||"Material generation canceled"};if("failed"===(null==o?void 0:o.status))return Mp(`[generate-material] Job failed: ${i.identifier}, error=${o.error}`),r.fail(`Material generation failed: ${o.error||""}`),{error:o.error||"Material generation failed"}}await kl(n)}if(e.outDir){const n=await _u({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:s,org_id:c,prompt:l,resolution:p,outputName:d,outDir:u});"error"in m&&(m.error&&n.error(m.error),process.exit(1)),"json"===a?cu(m):!u&&"identifier"in m&&console.log(m.identifier),await lu(0)}))),Dh.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:Dh.STRING}).option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Dh.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Dh.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:Dh.STRING}).option("--face-count <faceCount>","Target polygon count (40000-1500000). Leave unset to let the generator choose.",{required:!1,validator:Dh.NUMBER}).option("--name <name>","Output filename",{required:!1,validator:Dh.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:Dh.STRING}).action(su(nu("generate-3d",async({args:e,options:t,logger:n})=>{var o,i,r;const a=ru(t),s=null==(o=t.quality)?void 0:o.toString();if(void 0!==s&&"draft"!==s&&"standard"!==s)throw new Error("Quality must be draft or standard.");const c=null!=t.faceCount?Number(t.faceCount):void 0;if(void 0!==c&&(!Number.isInteger(c)||c<4e4||c>15e5))throw new Error("--face-count must be an integer from 40000 to 1500000.");const{accessToken:l,org_id:p}=await zh(t.token,Fh(t),!0!==t.nonInteractive),u=String(e.prompt),d=null==(i=t.outdir)?void 0:i.toString(),m=null==(r=t.name)?void 0:r.toString(),f=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 ${Sp()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";Mp(`[generate-3d] Starting request to ${t}, prompt="${e.prompt}", quality=${e.quality||"draft"}`,{emptyLineBefore:!0});const n=T("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+ht.jobs.create,i={...gt(e),"content-type":"application/json"},r={type:"ai-3d-asset",triggered_by:e.trigger_type,parameters:{...t}},a=await fetch(o,{...vt,method:"POST",headers:i,body:JSON.stringify(r),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 a)return{error:"The 3D generation request was cancelled"};if("__failed"in a)return{error:a.__failed};if(!a.ok){const e=await a.text();return console.error(`Failed to request 3D asset generation (${a.status}): ${e}`),{error:e||`Request failed (${a.status})`}}const s=await a.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 Mp(`[generate-3d] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(Mp(`[generate-3d] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return Mp(`[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 r=T("Waiting for the 3D model...").start();r.color="gray";const a=kc();for(;;){if("completed"===i.status){r.succeed("3D generation completed");break}let n=2e3;const o=await jc(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=a.record(o);if(s)return r.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))r.text="Your model is queued - waiting for generation to start",r.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))r.text=`Generating 3D model: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,r.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){Mp(`[generate-3d] Job completed: ${i.identifier}`),r.succeed(`3D generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return Mp(`[generate-3d] Job canceled: ${i.identifier}, error=${o.error}`),r.fail(`3D generation canceled: ${o.error||""}`),{error:o.error||"3D generation canceled"};if("failed"===(null==o?void 0:o.status))return Mp(`[generate-3d] Job failed: ${i.identifier}, error=${o.error}`),r.fail(`3D generation failed: ${o.error||""}`),{error:o.error||"3D generation failed"}}await kl(n)}if(e.outDir){const n=await _u({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:l,org_id:p,prompt:u,quality:s,face_count:c,outputName:m,outDir:d});"error"in f&&(f.error&&n.error(f.error),process.exit(1)),"json"===a?cu(f):!d&&"identifier"in f&&console.log(f.identifier),await lu(0)}))),Dh.command("ask","Send a message to the Needle Cloud AI").help("Send a message to Needle Cloud AI. By default, starts an interactive conversation, optionally with an initial message. Use --once to send one message and exit, or --non-interactive to also prohibit authentication prompts and browser launches. Both require a message. --output json returns one complete response and exits. --no-stream prints the full answer as text. Use --slug to continue a conversation.").argument("[message...]","The message to send (omit for interactive mode)").option("--token <token>",Lh,{validator:Dh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Dh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Dh.STRING,hidden:!0}).option("--slug <slug>","Chat slug to continue an existing conversation",{required:!1,validator:Dh.STRING}).option("--no-stream","Disable streaming (returns full response at once)",{required:!1,validator:Dh.BOOLEAN,default:!1}).option("--once","Send one message and exit",{validator:Dh.BOOLEAN,default:!1}).action(nu("ask",async({args:e,options:t})=>{var n,o;const i=ru(t),r=Array.isArray(e.message)?e.message:e.message?[e.message]:[],a=r.length?r.join(" "):void 0;if(!(!0!==t.nonInteractive&&!0!==t.once&&"json"!==i||null!=a&&a.trim()))throw new Error("A message is required for one-shot or non-interactive chat.");const{accessToken:s,org_id:c}=await zh(t.token,Fh(t),!0!==t.nonInteractive),l=(null==(n=t.slug)?void 0:n.toString())||void 0,p=(null==(o=t.noStream)?void 0:o.valueOf())||!1;await async function(e){const{token:t,org_id:n,message:o,slug:i,stream:r}=e,a=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);if(!0===e.nonInteractive||!0===e.once||"json"===e.output){if(null==o||!o.trim())throw new Error("A message is required for one-shot or non-interactive chat.");await au("json"===e.output,()=>Su({token:t,org_id:n,slug:a,message:o,stream:"json"!==e.output&&r,output:e.output}))}else await async function(e){const{token:t,org_id:n,slug:o,stream:i,initialMessage:r}=e,a=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(r&&(console.log(`> ${r}`),await Su({token:t,org_id:n,slug:o,message:r,stream:i}),console.log(""));;){const e=(await a.question("> ")).trim();if(e){if("exit"===e||"quit"===e)break;await Su({token:t,org_id:n,slug:o,message:e,stream:i}),console.log("")}}}finally{a.close()}}({token:t,org_id:n,slug:a,stream:r,initialMessage:o})}({token:s,org_id:c,message:a,slug:l,stream:!p,nonInteractive:!0===t.nonInteractive,once:!0===t.once,output:"json"===i?"json":"cli"}),await lu(0)})),uu(Dh);export{Bd as g,Dh as p};
|
|
63
|
+
`;function lf(e,t,n,o){sm(e,async(e,n)=>{try{const o=await t(e,n);return"string"==typeof o?bm(o):{...o,content:o.content.map(e=>"text"===e.type?{...e,text:bm(e.text)}:e)}}catch(e){throw new Error(bm(e instanceof Error?e.message:String(e)))}},n,o)}const pf=function(e,t=Am,n=Date.now){let o,i=0;const r=Object.assign(async(r={})=>{var a,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(!r||"object"!=typeof r||Array.isArray(r))return p;if(Object.keys(r).some(e=>!["mode","file","code","offset","index"].includes(e)))return p;const u=null!=(a=r.mode)?a:"check";if(!["check","results","error"].includes(u))return p;for(const e of[r.file,r.code])if(void 0!==e&&("string"!=typeof e||e.length>250))return p;for(const e of[r.offset,r.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,r=Cm(d),a=await t(d);o={project:d,result:{...a,...a.message?{message:bm(a.message)}:{},...a.output?{output:bm(a.output)}:{},diagnostics:(null!=(m=a.diagnostics)?m:[]).map(e=>({...e,message:bm(e.message)}))},time:n(),revision:e,snapshot:r}}if(!o)return{status:"unavailable",message:"No saved check for this local project. Run local_files_check_project with mode check first."};const f=Cm(d),h=null===o.snapshot||null===f,g=o.result,v=null!=(s=g.diagnostics)?s:[],b=v.map((e,t)=>({...e,index:t})),y=b.filter(e=>{var t;return(!r.file||(null!=(t=e.file)?t:"").toLowerCase().includes(r.file.toLowerCase()))&&(!r.code||e.code===r.code)}),x=null!=(c=r.offset)?c:0,w="error"===u?y.filter(e=>{var t,n;return e.index===(null!=(t=r.index)?t:null==(n=y.at(-1))?void 0:n.index)}):y.slice(x,x+5);if("error"===u&&!w.length)return{status:"unavailable",message:"No matching error in the latest check. Use mode results to list available error indexes."};const _="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:Nm(d,300),totalDiagnostics:null!=(l=g.totalDiagnostics)?l:v.length,retainedDiagnostics:v.length,matchingDiagnostics:y.length,truncated:Boolean(g.truncated),diagnostics:w.map(e=>({...e,...e.file?{file:Nm(e.file,300)}:{},message:Nm(e.message,_),messageTruncated:e.message.length>_})),..."error"!==u&&x+w.length<y.length?{nextOffset:x+w.length}:{},...g.message||h?{message:Nm([g.message,h?"Could not scan project files for changes; this check is marked stale.":null].filter(Boolean).join(" "),500)}:{},...g.output?{output:Nm(g.output,"error"===u?2e3:500),outputTruncated:g.output.length>("error"===u?2e3:500)}:{}}},{markStale(){i++}});return r}(()=>{var e;return null==(e=vf())?void 0:e.web_location}),uf=function(e,t=se(ne(),".needle","cli","ai-checkpoints"),n=(()=>{})){let o=0n,r=!1;function a(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||ce(n)!==ce(t.project))throw new Error("The approved local project has changed.");return{root:O(n),grant:t}}function s(e,t,n){if("string"!=typeof t||!t||t.includes("\0")||ue(t)||me.isAbsolute(t)||fe.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(xm(e)||xm(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=ce(e,t);if(!o.startsWith(e+de))throw new Error("Path escapes the selected local project.");let i=e;const r=le(e,o).split(de);for(let e=0;e<r.length;e++){if(i=se(i,r[e]),!$(i)){if(e!==r.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<r.length-1&&!t.isDirectory())throw new Error("Parent path is not a directory.");if(e===r.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{G(n,t,{flag:"wx",mode:384}),A(n,e)}finally{$(n)&&W(n)}}function l(){return $(t)?q(t).filter(e=>e.endsWith(".json")).reduce((e,n)=>e+C(se(t,n)).size,0):0}function p(e){if(!r){if($(t))for(const e of q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e))){const n=JSON.parse(M(se(t,e),"utf8"));if(n.order&&/^\d+$/.test(n.order)){const e=BigInt(n.order);e>o&&(o=e)}}r=!0}const n=1000000n*BigInt(Date.now());o=n>o?n:o+1n,e.order=o.toString();const a=JSON.stringify(e);if(l()+Buffer.byteLength(a)>Pm)throw new Error("Checkpoint storage is full; no file was changed.");I(t,{recursive:!0,mode:448});const s=i(),c=se(t,`${s}.json`);return G(c,a,{flag:"wx",mode:384}),{id:s,file:c}}function u(e,t){if(e.byteLength>Rm)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(Um(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 $(n)?M(n):null},o=n(t.path),i=null===t.before?null:Um(Buffer.from(t.before,"base64"));if("rename"===t.operation){if(!t.newPath)return"conflicted";const e=n(t.newPath);if(null===o&&e&&Um(e)===t.afterSha256)return"applied";if(null===e&&o&&Um(o)===i)return"undone"}else if("delete"===t.operation){if(null===o)return"applied";if(o&&Um(o)===i)return"undone"}else{if(o&&Um(o)===t.afterSha256)return"applied";if(null===o&&null===t.before||o&&Um(o)===i)return"undone"}return"conflicted"}catch{return"conflicted"}}return{list(e){const{root:n,grant:o}=a(e);if(!$(t))return{changes:[],total:0};const i=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({...JSON.parse(M(se(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:r,newPath:a,...s})=>({path:e,checkpointId:t,turnId:o,createdAt:i,operation:null!=r?r:"write",...a?{newPath:a}:{},state:d(n,{...s,path:e,turnId:o,createdAt:i,operation:r,newPath:a})})),total:i.length}},stat(t){const n=e();if(!n)throw new Error("No connected local web project.");const o=O(n),i=s(o,t,!0);if(!$(i))return{path:t,exists:!1};const r=C(i).size;if(r>Rm)throw new Error("File exceeds the 1 MiB edit limit.");const a=jm(o,t,{maxBytes:Rm});return km(a),{path:t,exists:!0,sha256:Um(a),size:r}},write(e,t){var o;const{root:i,grant:r}=a(t);if(!e||"string"!=typeof e.content)throw new Error("Text content is required.");const l=Buffer.from(e.content,"utf8");if(l.byteLength>Rm||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=$(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&&Um(f)===Um(l))throw new Error("File already has this content; no edit was saved.");const h={project:i,path:le(i,d),chatId:r.chatId,sessionId:r.sessionId,turnId:r.turnId,before:null!=(o=null==f?void 0:f.toString("base64"))?o:null,after:l.toString("base64"),afterSha256:Um(l),createdAt:(new Date).toISOString(),operation:"write"},g=p(h);try{if(s(i,e.path,!0===e.create),!0===e.create){if($(d))throw new Error("The file was created since it was checked; check it again.")}else if(!$(d)||Um(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:r.turnId,afterSha256:h.afterSha256}},delete(e,t){const{root:o,grant:i}=a(t),r=s(o,null==e?void 0:e.path,!1),c=M(r);u(c,e.expectedSha256);const l=p({project:o,path:le(o,r),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),Um(M(r))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");W(r)}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}=a(t),r=s(o,null==e?void 0:e.path,!1),c=s(o,null==e?void 0:e.newPath,!0);if($(c))throw new Error("Destination file already exists.");const l=M(r);u(l,e.expectedSha256);const d={project:o,path:le(o,r),newPath:le(o,c),chatId:i.chatId,sessionId:i.sessionId,turnId:i.turnId,before:l.toString("base64"),after:l.toString("base64"),afterSha256:Um(l),createdAt:(new Date).toISOString(),operation:"rename"},m=p(d);try{if(s(o,e.path,!1),s(o,e.newPath,!0),$(c))throw new Error("Destination file already exists.");if(Um(M(r))!==e.expectedSha256)throw new Error("The file changed since it was read; check it again.");A(r,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:r}=a(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const p=se(t,`${e.checkpointId}.json`),u=JSON.parse(M(p,"utf8"));if(u.project!==i||u.chatId!==r.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($(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($(d)||Um(M(e))!==u.afterSha256)throw new Error("File changed after the AI edit; Undo would overwrite later work.");A(e,d)}else{const e=M(d);if(Um(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)>Pm)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:r}=a(o);if(!e||"string"!=typeof e.checkpointId||!/^[a-f0-9-]{36}$/.test(e.checkpointId))throw new Error("Invalid checkpoint ID.");const l=se(t,`${e.checkpointId}.json`),p=JSON.parse(M(l,"utf8"));if(p.project!==i||p.chatId!==r.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(!$(u)||Um(M(u))!==Um(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(!$(u)||$(e)||Um(M(u))!==Um(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),A(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(Um(e)!==p.afterSha256)throw new Error("Checkpoint content is damaged; Redo was refused.");if(null===p.before?$(u):!$(u)||Um(M(u))!==Um(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}=a(n);if(!e||"string"!=typeof e.turnId||!e.turnId||e.turnId.length>255)throw new Error("Valid turn ID is required.");if(!$(t))throw new Error("No checkpoints found for this turn.");const r=q(t).filter(e=>/^[a-f0-9-]{36}\.json$/.test(e)).map(e=>({checkpoint:JSON.parse(M(se(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(!r.length)throw new Error("No checkpoints found for this turn.");if(r.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.");r.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 r=$(n)?M(n):null;return c.set(i,r),r};for(const{checkpoint:e}of r){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||Um(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||Um(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 r)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=vf())?void 0:e.web_location},void 0,()=>pf.markStale()),df=function(e=se(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")||ue(t.path)||me.isAbsolute(t.path)||fe.isAbsolute(t.path))throw new Error("A project-relative file path and chat are required.");const n=O(t.root),o=ce(n,t.path);if(_m(n,t.path,{allowMissing:!0}),!o.startsWith(n+de))throw new Error("File path escapes the project.");const i=le(n,o).split(de).join("/");return{project:n,target:o,path:i,file:se(e,zm(n),zm(t.chatId),`${zm(i)}.json`)}}function n(e){if(!$(e.target))return null;if(C(_m(e.project,e.target).path).size>Lm)return{unsupported:"File exceeds the 1 MiB observation limit."};const t=jm(e.project,e.target,{maxBytes:Lm}),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:Sm(t).split("\n"),hashes:o.map(zm),fileSha256:zm(t)}}function o(e){if(!$(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 r(t,n,o){if("unsupported"in n)return{status:"unsupported",reason:n.unsupported};const r={version:1,project:t.project,path:t.path,chatId:o,observedAt:(new Date).toISOString(),fileSha256:n.fileSha256,lineHashes:n.hashes};I(se(e,zm(t.project),zm(o)),{recursive:!0,mode:448});const a=`${t.file}.${i()}.tmp`;try{G(a,JSON.stringify(r),{flag:"wx",mode:384}),A(a,t.file)}finally{$(a)&&W(a)}return{status:"saved",observedAt:r.observedAt,sha256:r.fileSha256}}return{observe(e){const i=t(e),a=n(i);if(!a)throw new Error("File does not exist.");if("unsupported"in a)return{status:"unsupported",reason:a.unsupported};const s=o(i);return s?{status:"existing",observedAt:s.observedAt,sha256:s.fileSha256}:r(i,a,e.chatId)},snapshot(e){const o=t(e),i=n(o);if(!i)throw new Error("File does not exist.");return r(o,i,e.chatId)},diff(e){const i=t(e),r=o(i);if(!r)return{status:"no_baseline",path:i.path};const a=n(i);if(!a)return{status:"deleted",path:i.path,observedAt:r.observedAt};if("unsupported"in a)return{status:"unsupported",path:i.path,reason:a.unsupported};if(r.fileSha256===a.fileSha256)return{status:"unchanged",path:i.path,observedAt:r.observedAt,sha256:a.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 r=new Map;for(let t=n;t<o;t++){const n=r.get(e[t]);n?n.count++:r.set(e[t],{index:t,count:1})}const a=new Map;for(let e=n;e<i;e++){var s;a.set(t[e],(null!=(s=a.get(t[e]))?s:0)+1)}const c=[];for(let e=n;e<i;e++){const n=r.get(t[e]);1===(null==n?void 0:n.count)&&1===a.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}(r.lineHashes,a.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:a.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:r.observedAt,beforeSha256:r.fileSha256,afterSha256:a.fileSha256,beforeLineCount:r.lineHashes.length,afterLineCount:a.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)."}}}}(),mf=function(e,t=y){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()||ue(n.path)||n.path.includes("\0"))throw new Error("Use a nonempty project-relative path.");const r=O.native(i),a=ce(r,n.path),s=le(r,a);if(".."===s||s.startsWith(`..${de}`)||ue(s))throw new Error("File path is outside the selected project.");const c=O.native(a),l=le(r,c);if(".."===l||l.startsWith(`..${de}`)||ue(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(Fm.has(re(c).toLowerCase()))throw new Error("Opening executable file types is not supported.");return await t(c),{opened:!0,project:n.project,path:le(r,c)||"."}}}(vf),ff=function(e){const{getProject:t,getHome:n=ne,run:o=rf,commandsEnabled:r=(()=>!Hm()),onFailure:a,onCreated:s,onApprovedProject:c,now:l=Date.now,getProcessIdentity:p=Ym}=e,u=function(e=se(ne(),".needle","cli","ai-jobs"),t=Date.now){const n=t=>{if(!Km.test(t))throw new Error("Invalid project job ID.");return se(e,`${t}.json`)};return{runtimeFile:t=>(n(t),se(e,`${t}.runtime.json`)),runtime(e){const t=this.runtimeFile(e);if(!$(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 r=se(e,`${t.jobId}.${i()}.tmp`);try{G(r,JSON.stringify(t),{flag:"wx",mode:384}),A(r,o)}finally{$(r)&&W(r)}},get(e){const o=n(e);if(!$(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 r=i;if(r.jobId!==e||"string"!=typeof r.chatId||"string"!=typeof r.operation||void 0!==r.project&&"string"!=typeof r.project||void 0!==r.workingDirectory&&"string"!=typeof r.workingDirectory||void 0!==r.startedAt&&!Number.isFinite(r.startedAt)||void 0!==r.pid&&(!Number.isSafeInteger(r.pid)||Number(r.pid)<1)||void 0!==r.processIdentity&&"string"!=typeof r.processIdentity||!Number.isFinite(r.createdAt)||!Number.isFinite(r.updatedAt)||"string"!=typeof r.output||r.output.length>8e3||!["running","completed","failed","canceled"].includes(String(r.status)))throw new Error("Invalid stored project job.");const a=r;if(!("running"!==a.status&&t()-a.updatedAt>1728e5))return a;{W(o);const t=this.runtimeFile(e);$(t)&&W(t)}},list(){return $(e)?q(e).filter(e=>Km.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)&&W(t);const o=this.runtimeFile(e);$(o)&&W(o)}}}(se(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||!a)return;const{controller:t,...n}=e;try{a(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=nf(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=bm(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 y(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 x(){for(const e of u.list())b(e)}x();const w=setInterval(x,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 r={...nf(e,t(),n()),planId:i(),chatId:o,createdAt:l()},a="dev"===r.operation?y(r.project):void 0;if(a)throw new Error(`A dev server for this project is already running (job ID ${a.jobId}). Check its status or cancel it before starting another.`);return d.set(r.planId,r),r},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(!r())throw new Error("AI project commands are disabled in local Needle CLI settings.");v(n);const a="dev"===n.operation?y(n.project):void 0;if(a)throw new Error(`A dev server for this project is already running (job ID ${a.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||pe(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=bm(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=bm(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=bm(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.");G(`${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=vf())?void 0:e.web_location},onCreated:Vd,onApprovedProject:Vd,onFailure:e=>{var t;return Bp(`[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 hf(e){if(null==e||!e.editGrant)throw new Error("Local file edit approval is required.");if(Gm())throw new Error("AI file edits are disabled in local Needle CLI settings.");return e.editGrant}function gf(e={}){lf({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=Wd();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"},()=>{}),lf({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=Wd();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"},()=>{}),lf({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=Wd();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"},()=>{}),lf({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=vf();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"},()=>{}),lf({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=xf(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"},r="reset"===e.mode?df.snapshot(i):df.diff(i);return{content:[{type:"text",text:JSON.stringify(r)}]}},{source:"cli"},()=>{}),lf({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 mf(e))}]}),{source:"cli"},()=>{}),lf({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=xf(e.path);if(!n)return{content:[{type:"text",text:"Error: path is outside the project directory."}]};try{const i=l(n.resolved).mtime.toISOString(),r=Em(n.root,n.resolved).text.split("\n");let a="";try{var o;const e=df.observe({root:n.root,path:j(n.root,n.resolved),chatId:null!=(o=null==t?void 0:t.chatId)?o:"local-mcp"});a="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),a=`\nChange baseline unavailable: ${e instanceof Error?e.message:"unknown error"}`}if(e.filter){const t=af(e.filter),o=[];for(let e=0;e<r.length;e++)t.test(r[e])&&o.push(`${e+1}: ${r[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 ${r.length} lines`+a+"\n"+p.join("\n")}]}}const s=Math.max(1,e.offset||1),c=Math.min(e.limit||200,1e3),p=r.slice(s-1,s-1+c),u=p.map((e,t)=>`${s+t}: ${e}`).join("\n");return{content:[{type:"text",text:`File: ${n.resolved} (${r.length} lines, modified: ${i}, showing ${s}-${s+p.length-1})`+a+"\n"+u}]}}catch(e){return{content:[{type:"text",text:`Error reading file: ${e instanceof Error?e.message:String(e)}`}]}}},{source:"cli"},()=>{}),lf({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=yf();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=>$m(t,{pattern:e.pattern,glob:e.glob,maxResults:n})),i=o.flatMap(e=>e.lines),r=`\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.")+r}]}},{source:"cli"},()=>{}),lf({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=vf();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=[],r=[];for(const{root:t,label:n}of o){const o=bf(e.path||".",t);if(o)try{var a;e.recursive||r.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=_f(o,t,null!=(a=e.recursive)&&a,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=r.length>0?`\nShallow listing: subdirectories were not searched (${r.slice(0,12).join(", ")}${r.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"},()=>{}),lf({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=vf();var n;if(null==t||!t.log_location)return Mp(`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=Em(pe(t.log_location),ae(t.log_location),{maxBytes:67108864,allowPrivateKeys:!0}).text.split("\n");let o,i;if(e.filter){const t=af(e.filter);o=[];for(let e=0;e<n.length;e++)t.test(n[e])&&o.push(`L${e+1}: ${n[e]}`);const r=o.length,a=Math.max(0,e.offset||0),s=Math.min(Math.max(e.limit||200,1),500);o=o.slice(a,a+s),i=`filter="${e.filter}" (${t.mode}) → ${r} matches (showing ${a+1}-${a+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 r="unity"===t.editor?function(e){const t=[],n=new Map;let o=!1,i=0;for(const r of e){if(/^\s+at\s/.test(r)||/^\s*(UnityEngine\.|System\.|Unity\.)/.test(r)||/^\s+\w+[\w.<>]+\s*\(/.test(r)){o||(o=!0,i=0),i++,i<=3?t.push(r):4===i&&t.push(" ... (stack trace truncated)");continue}if(o=!1,i=0,!r.trim())continue;const e=n.get(r)||0;if(n.set(r,e+1),0===e)t.push(r);else if(1===e)t.push(` [repeated ${e+1}x] ${r}`);else{const n=t.length-1;n>=0&&t[n].startsWith(" [repeated")&&(t[n]=` [repeated ${e+1}x] ${r}`)}}return t}(o):o,a=5e4;let s=r.join("\n"),c="";if(s.length>a){s=s.substring(s.length-a);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}, ${r.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"},()=>{}),lf({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=xf(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=Em(t,e).text;return JSON.parse(n)}if(n.endsWith(".glb")){const n=jm(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=jm(t,e,{maxBytes:67108864,range:{offset:20,length:o}}).toString("utf-8"),r=hm(JSON.parse(i));if(!r||"object"!=typeof r||Array.isArray(r))throw new Error("glTF JSON must be an object.");return r}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=wf(n,e.query.replace(/^\//,"").split("/"));if(void 0===i)return{content:[{type:"text",text:`No data found at pointer: ${e.query}`}]};let r=JSON.stringify(i),a=!1;return r.length>o&&(r=r.substring(0,o),a=!0),{content:[{type:"text",text:`${e.query} in ${t.resolved}`+(a?` (truncated to ${o} chars)`:"")+"\n"+r}]}}let i=function(e,t){var n,o,i,r,a,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!=(r=e.nodes)&&r.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 r=e.nodes[t];if(!r)return;const a=" ".repeat(i),s=[];if(void 0!==r.mesh&&s.push(`mesh:${r.mesh}`),void 0!==r.camera&&s.push(`camera:${r.camera}`),void 0!==r.skin&&s.push(`skin:${r.skin}`),r.extensions&&s.push(`ext:[${Object.keys(r.extensions).join(",")}]`),h.push(`${a}- ${r.name||`node_${t}`}${s.length?` (${s.join(", ")})`:""}`),r.children)for(const e of r.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!=(a=e.meshes)&&a.length){h.push(`\nMeshes (${e.meshes.length}):`);for(const t of e.meshes.slice(0,30)){var y,x;const e=null!=(y=null==(x=t.primitives)?void 0:x.length)?y: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)}]});lf({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=cf.replace("__PORT__",String(e)).replace("__HOST__",t),o=Buffer.from(n,"utf16le").toString("base64"),{stdout:i}=await sf("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 V(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 K(`/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 sf("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 K(`/proc/${e}/cwd`):await async function(e){const{stdout:t}=await sf("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"},()=>{}),lf({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(Wd().entries.filter(e=>e.web_location).map(e=>({path:e.web_location,selected:e===vf(),editor:e.editor}))),{source:"cli"},()=>{}),lf({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:Kd(t.path).web_location}),{source:"cli"},()=>{}),lf({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:Zm},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?ff.getPlan(t.planId,n.chatId):ff.plan(t,n.chatId))},{source:"cli"},()=>{}),lf({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(Hm())throw new Error("AI project commands are disabled in local Needle CLI settings.");return e(await ff.start(t.planId,n.commandGrant))},{source:"cli"},()=>{}),lf({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(ff.status(t.jobId,n.chatId))},{source:"cli"},()=>{}),lf({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 ff.cancel(t.jobId,n.chatId))},{source:"cli"},()=>{})}(),lf(sp.schema,async e=>{const t=await sp.execute(e);return"error"in t?{content:[{type:"text",text:t.error}]}:{content:[{type:"text",text:t.content}]}},{source:"cli"},()=>{}),lf({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(uf.stat(e.path))}]}),{source:"cli"},()=>{}),lf({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(uf.write(e,hf(t)))}]}),{source:"cli"},()=>{}),lf({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(uf.delete(e,hf(t)))}]}),{source:"cli"},()=>{}),lf({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(uf.rename(e,hf(t)))}]}),{source:"cli"},()=>{}),lf({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(uf.undo(e,hf(t)))}]}),{source:"cli"},()=>{}),lf({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(uf.redo(e,hf(t)))}]}),{source:"cli"},()=>{}),lf({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(uf.undoTurn(e,hf(t)))}]}),{source:"cli"},()=>{}),lf({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(uf.list(hf(t)))}]}),{source:"cli"},()=>{}),lf({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 pf(e);return{content:[{type:"text",text:JSON.stringify(t)}],isError:"error"===t.status||"unavailable"===t.status}},{source:"cli"},()=>{}),null!=e&&e.logToolCount&&Mp(`[MCP] registered ${nm.length} built-in tools: ${nm.map(e=>e.name).join(", ")}`)}function vf(){return Jd()}function bf(e,t){const n=w(t,e),o=w(t),i=j(o,n);return k(i)||".."===i||i.startsWith(".."+S)?null:_m(o,n,{allowMissing:!0}).path}function yf(){const e=vf();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 xf(e){const t=yf();for(const n of t){const t=bf(e,n);if(t&&c(t))return{resolved:t,root:n}}for(const n of t){const t=bf(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 wf(e,t){if(0===t.length||null==e)return e;const[n,...o]=t;if("*"!==n)return wf(e[/^\d+$/.test(n)?Number(n):n],o);if(Array.isArray(e)){const t=e.map(e=>wf(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=wf(e[n],o);void 0!==i&&(t[n]=i)}return Object.keys(t).length>0?t:void 0}}function _f(e,t,n,o,i){if(i>10)return[];const r=[],a=u(e,{withFileTypes:!0}),s="node_modules"===(e.split("/").pop()||e.split("\\").pop()||"");for(const c of a){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 a=_(e,c.name);if(!xm(j(t,a))&&!c.isSymbolicLink())if(_m(t,a),c.isDirectory())n&&r.push(..._f(a,t,!0,o,i+1));else{if(o&&!o.split("|").map(e=>(e=e.trim()).startsWith(".")&&!e.startsWith("*.")?"*"+e:e).filter(Boolean).some(e=>Ye(c.name,e,{nocase:!0})))continue;r.push(a)}}return r}process.once("exit",()=>ff.dispose());const jf="cli-installation-id",kf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Sf="2025-06-18";function Ef(e){return{jsonrpc:"2.0",id:e,result:{protocolVersion:Sf,capabilities:{tools:{listChanged:!0}},serverInfo:Tf}}}const Tf={name:"Needle Cloud MCP",version:"1.0.0"};function $f(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 If(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let Af=!1;const Of=Me(),Cf=new Map,Nf=new Map;let Rf=0;function Pf(){const e=[];for(const[t,{connectedAt:n,userAgent:o}]of Nf)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,r;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 a=t.headers["mcp-session-id"],s=null!=(i=null!=(r=null!=o?o:"string"==typeof a?Cf.get(a):void 0)?r:t.headers["user-agent"])?i:"",c=()=>{clearInterval(l),Nf.delete(e)&&(console.log(`[MCP] SSE client disconnected (ID: ${e}): ${s}`),Mp(`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()}),Nf.set(e,{id:e,client:n,connectedAt:Date.now(),userAgent:s,dispose:c}),console.log(`[MCP] SSE client connected (ID: ${e}) ${s}. Total clients: ${Nf.size}`),Mp(`MCP SSE client connected (ID: ${e}) ${s}. Total clients: ${Nf.size}`),!0}return!1}function Lf(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}async function zf(e=se(ne(),".needle")){let t,n;try{t=await V(se(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 Ff(){const e=await zf();try{const t=await fetch(`${Ru}/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 Df(e,t=process.argv[1]){await new Promise((n,o)=>{const i=Ke(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.`)})})}Of.get("/mcp",async(e,t)=>{if(Uf(Rf++,e,t))return;const n=function(e){const t=[...nm].sort((e,t)=>e.name.localeCompare(t.name)),n=t.map(e=>`\n <div class="tool">\n <span class="tool-name">${If(e.name)}</span>\n <span class="tool-desc">${If(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)}),Of.post("/mcp",async(e,t)=>{const n=e.headers.accept||"",o=e.headers["user-agent"]||"",{method:i,id:r}=e.body;console.log(`[MCP] Received request from ${o} (${i}) (ID: ${r})`),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 a;const n=Rf++,o=$f(null==(a=e.body.params)?void 0:a.clientInfo);if(Uf(n,e,t,o?`${o.name}/${o.version}`:void 0)){Af=!0;const e=Ef(null!=r?r: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{gf()}catch{}return{jsonrpc:"2.0",id:i,result:{tools:nm}}}if("tools/call"===n){const e=null==o?void 0:o.name;try{gf()}catch{}try{return{jsonrpc:"2.0",id:i,result:await lm(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=$f(null==(s=e.body.params)?void 0:s.clientInfo);Cf.set(n,i?`${i.name}/${i.version}`:void 0),t.setHeader("Mcp-Session-Id",n),console.log(`[MCP] New session created: ${n} for ${o}`),Mp(`MCP New session: ${n} for ${o}`)}if(null===l)return t.status(204).end();if(Mp(`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:r||null};t.json(n)}}),Of.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 qf=!1;function Bf(e,t={}){qf&&process.stdout.write(JSON.stringify({jsonrpc:"2.0",method:e,params:t})+"\n")}var Mf={__proto__:null,sendStdioNotification:Bf,startStdio:function(){qf=!0,console.log=console.info=console.debug=console.error.bind(console);const e=e=>{console.error(e),Mp(e)},t=function({endpoint:e,ensureServer:t,notify:n,log:o,getToken:i,retryMs:r=250,streamTimeoutMs:a=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 r,a;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":Sf,...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(!Lf(s)||"2.0"!==s.jsonrpc||s.id!==t.id||!Lf(s.result)&&!Lf(s.error))throw new Error("Invalid response from local MCP server");if(Lf(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!=(r=i.headers.get("Mcp-Session-Id"))?r:void 0),{jsonrpc:"2.0",id:null!=(a=t.id)?a: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=r;for(;!s.signal.aborted;){let d;const y=new AbortController,x=()=>y.abort();let w;s.signal.addEventListener("abort",x,{once:!0});const _=(e,t=!0)=>{clearTimeout(w),w=setTimeout(()=>{t?j():y.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||y.signal.aborted||_(a)}catch(e){s.signal.aborted||y.signal.aborted||y.abort(e)}};try{var c;await t(s.signal);const o=await b({jsonrpc:"2.0",id:"needle-bridge-initialize",method:"initialize",params:{protocolVersion:Sf,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 x=await h(),w=await fetch(e,{headers:{...x,"User-Agent":g(),Accept:"text/event-stream","MCP-Protocol-Version":Sf,...u?{"Mcp-Session-Id":u}:{}},signal:y.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})`);_(a),d=w.body.getReader(),v(!0),null==p||p(),i=r;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(_(a),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);Lf(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",x),d){if(!y.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=$f(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:`${Ru}/mcp`,ensureServer:t=>async function(e={}){const{signal:t,lockPath:n=se(ne(),".needle","mcp-server-start.lock"),probe:o=Ff,log:i=(e=>console.error(e)),launch:r=(()=>Df(i)),timeoutMs:a=2e4,pollMs:s=100}=e;if(null==t||t.throwIfAborted(),await o())return;await Z(pe(n),{recursive:!0});const c=Date.now()+a;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 r()}}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:Bf,log:e,getToken:()=>async function(e){const t=await zf(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=De({input:process.stdin,terminal:!1}),o=e=>{qf&&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(!Lf(r=i)||"2.0"!==r.jsonrpc||"string"!=typeof r.method||null!=r.id&&"string"!=typeof r.id&&"number"!=typeof r.id||void 0!==r.params&&!Lf(r.params))return void o({jsonrpc:"2.0",id:null,error:{code:-32600,message:"Invalid request"}});var r,a;if("initialize"===i.method)return o(Ef(null!=(a=i.id)?a: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",()=>{qf=!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 Gf(){Wf&&clearTimeout(Wf),Wf=setTimeout(()=>{!function(e,t={}){if(0===Nf.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 Nf)try{t.write(n)}catch(n){console.error(`[MCP] Error sending notification to client (${e}):`,n),o(),t.destroy()}}(),Bf("notifications/tools/list_changed"),sh(),Wf=null},10)}const Hf=function({send:e,register:t,clear:n,onError:o}){const r=new Map,a=new Set;let s=null,c=null,l=!1;const p=()=>{l=!1,s=null,c&&clearTimeout(c),c=null,a.size&&n(),a.clear();for(const e of r.values())clearTimeout(e.timer),e.reject(new Error("Needle Cloud disconnected."));r.clear()},u=(t,n)=>new Promise((o,a)=>{if(!l)return void a(new Error("Needle Cloud disconnected."));if(r.size>=4)return void a(new Error("Too many concurrent cloud tool requests."));const s=i(),c=setTimeout(()=>{r.delete(s),a(new Error("Cloud tool request timed out."))},3e4);r.set(s,{resolve:o,reject:a,timer:c});try{e({type:"cloud_tool_call",requestId:s,name:t,args:n})}catch(e){clearTimeout(c),r.delete(s),a(e instanceof Error?e:new Error(String(e)))}});return{connect(){p(),l=!0,s=i(),c=setTimeout(()=>{s=null,o("Cloud tool discovery timed out. Update the Cloud API if it does not support MCP tools.")},15e3);try{e({type:"cloud_tools_list",requestId:s})}catch(e){p(),o(e instanceof Error?e.message:String(e))}},disconnect:p,isCloudTool:e=>a.has(e),receive(e){if(!e||"object"!=typeof e||!("type"in e)||!("requestId"in e)||"string"!=typeof e.requestId)return!1;if("cloud_tools_result"===e.type){if(!l||e.requestId!==s)return!0;if(s=null,c&&clearTimeout(c),c=null,"error"in e&&"string"==typeof e.error)return o(e.error),!0;if(!("tools"in e)||!Array.isArray(e.tools))return o("Invalid cloud tool catalog."),!0;try{for(const n of e.tools){if(!n||"object"!=typeof n||"string"!=typeof n.name||!/^[a-zA-Z0-9_]{1,45}$/.test(n.name)||"string"!=typeof n.description||!n.inputSchema||"object"!=typeof n.inputSchema||Array.isArray(n.inputSchema))throw new Error("Invalid cloud tool schema.");const e=`needle_cloud_${n.name}`;t({name:e,description:n.description,inputSchema:n.inputSchema},e=>u(n.name,e)),a.add(e)}}catch(e){p(),o(e instanceof Error?e.message:String(e))}return!0}if("cloud_tool_result"===e.type){const t=r.get(e.requestId);return!t||(r.delete(e.requestId),clearTimeout(t.timer),"error"in e&&"string"==typeof e.error?t.reject(new Error(e.error)):"result"in e&&"string"==typeof e.result?t.resolve(e.result):t.reject(new Error("Invalid cloud tool result.")),!0)}return!1}}}({send:e=>{if(!Xf||Xf.readyState!==We.OPEN)throw new Error("Needle Cloud disconnected.");Xf.send(JSON.stringify(e))},register:(e,t)=>sm(e,t,{source:"cloud"},Gf),clear:()=>rm("cloud",Gf),onError:e=>Mp(`[Cloud MCP] ${e}`)}),Jf=2e3,Vf=6e4,Kf=25e3,Yf=1e4,Zf=i();let Xf=null,Qf=null,eh=null,th=null,nh=Jf,oh=!1,ih=!1;function rh(){Xf||(Mm()?Mp("Needle Cloud connection: skipped (remote_ai_tools disabled in settings)"):(oh=!1,Qf&&(clearTimeout(Qf),Qf=null),nh=Jf,ch()))}function ah(e){Hf.disconnect(),oh=!0,lh(),Qf&&(clearTimeout(Qf),Qf=null),Xf?(Mp(`Needle Cloud connection: closing (reason: ${null!=e?e:"shutdown"})`),Xf.close(1e3,null!=e?e:"shutdown"),Xf=null):e&&Mp(`Needle Cloud connection: disconnect requested (reason: ${e}) — no active connection`)}function sh(){if(!Xf||Xf.readyState!==We.OPEN)return;try{gf()}catch(e){Mp(`Needle Cloud connection: registerServerTools failed: ${e}`)}const e=nm.filter(e=>!Hf.isCloudTool(e.name)),t=e.map(e=>e.name);var n;Mp(`Needle Cloud connection: sending ${t.length} tools: ${t.join(", ")}`),Xf.send(JSON.stringify({type:"tools",tools:(n=e,n.map(e=>{var t;return{name:e.name,description:e.description,inputSchema:e.inputSchema,capability:null!=(t=e.capability)?t:"local"}}))}))}async function ch(){let e,t,n=await jd();if(n||(n=function(){const e=md("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}(),n&&Mp("Needle Cloud connection: using cached token (refresh failed)")),!n)return ih||(Mp("Needle Cloud connection: skipped (not logged in)"),ih=!0),void ph(!0);ih=!1;try{e=function(e=qm()){I(e,{recursive:!0,mode:448});const t=se(e,jf);try{G(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(!kf.test(n))throw new Error("Invalid local CLI installation ID.");return n}()}catch(e){return Mp(`Needle Cloud connection: could not read local CLI installation identity: ${e instanceof Error?e.message:String(e)}`),void ph(!0)}try{t=await async function(e,t={getUser:kd,getDefaultOrg:Sd,authHeaders:Ad}){var n;const o=await t.getUser();if(null==o||!o.isAuthenticated)return{authToken:e,org:null};const i=await t.getDefaultOrg(o);if(i&&"object"==typeof i)throw new Error(i.error);if(!i)return{authToken:e,org:null};const r=await t.authHeaders(o,i);if("error"in r)throw new Error(r.error);if(!r.authToken)throw new Error("No access token for the default team.");return{authToken:r.authToken,org:null!=(n=r.org)?n:null}}(n)}catch(e){return Mp(`Needle Cloud connection: team authentication failed: ${e instanceof Error?e.message:String(e)}`),void ph()}const o="https://cloud.needle.tools/api".replace(/^http/,"ws")+"/v1/cli/ws?token="+encodeURIComponent(t.authToken)+(t.org?"&org="+encodeURIComponent(t.org):"")+"&instance="+encodeURIComponent(Zf)+"&installation="+encodeURIComponent(e);Mp("Needle Cloud connection: connecting...");const r=`needle-cloud/${Qd()} Node/${process.versions.node}`;Xf=new We(o,{headers:{"User-Agent":r,Origin:"cli://needle-cloud"}}),Xf.on("open",()=>{nh=Jf,Mp("Needle Cloud connection: established"),uh(),sh(),lh(),eh=setInterval(()=>{Xf&&Xf.readyState===We.OPEN&&(Xf.ping(),th=setTimeout(()=>{Mp("Needle Cloud connection: pong timeout, terminating"),Xf&&Xf.terminate()},Yf))},Kf),Hf.connect()}),Xf.on("pong",()=>{th&&(clearTimeout(th),th=null)}),Xf.on("message",e=>{try{const n=JSON.parse(e.toString());if(Hf.receive(n))return;var t;"execute_tool"===n.type&&n.requestId&&n.toolName&&async function(e,t,n,o,i,r){Mp(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 a=Date.now();try{var s,c;if(Hf.isCloudTool(t))throw new Error("Cloud tools cannot be executed as local tools.");"local_project_action"===t&&uh();const l=await lm(t,n,{chatId:o,editGrant:i,commandGrant:r});"local_project_select"!==t&&"local_project_start"!==t&&"local_project_status"!==t||uh(),Mp(`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()-a}ms [${e}]`),Xf&&Xf.readyState===We.OPEN&&Xf.send(JSON.stringify({type:"tool_result",requestId:e,result:l}))}catch(n){const o=n instanceof Error?n.message:String(n);Mp(`Cloud tool error: ${t} → ${o} in ${Date.now()-a}ms [${e}]`),Xf&&Xf.readyState===We.OPEN&&Xf.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{}}),Xf.on("close",(e,t)=>{const n=(null==t?void 0:t.toString())||"";Mp(`Needle Cloud connection: closed (code=${e}${n?" "+n:""})`),lh(),Hf.disconnect(),Xf=null,oh||ph()}),Xf.on("error",e=>{Mp(`Needle Cloud connection: error - ${e.message||"connection refused"} (is https://cloud.needle.tools/api reachable?)`)})}function lh(){eh&&(clearInterval(eh),eh=null),th&&(clearTimeout(th),th=null)}function ph(e=!1){oh||Qf||(e||Mp(`Needle Cloud connection: reconnecting in ${nh/1e3}s`),Qf=setTimeout(()=>{Qf=null,ch()},nh),nh=Math.min(2*nh,Vf))}function uh(){Xf&&Xf.readyState===We.OPEN&&Xf.send(JSON.stringify(function(){var e,t,n;const o=Jd();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?ce(o.web_location):null,cli_version:Qd()}}()))}const dh=e=>{const t=Me();return t.use("/:action",async(t,n,o)=>{const{action:i}=t.params,r=Ed({navigate:e=>{n.redirect(e)}});switch(i){case"sign-in":e.invalid_login=!1,e.invalid_login_type=null,e.error=void 0,Mp("Sign in..."),await r.clearAllTokens(),vd();try{await r.signIn(`${Ru}/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 Mp(o),console.error(o),n.status(502).send(o)}break;case"sign-out":{var a,s;const t=await kd(),n=(null==t||null==(a=t.userInfo)?void 0:a.sub)||(null==t||null==(s=t.claims)?void 0:s.sub),o=null==t?void 0:t.accessToken;Mp(`Sign out... (${n})`),n&&o&&await async function(e){return!e.accessToken||import("node-machine-id").then(async t=>{const n=await Dd();return Ud=n,await fetch("https://cloud.needle.tools/api"+ht.account.post_machine,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify({action:"logout",machine_id:n,machine_name:qd()})}).catch(e=>{Mp(`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),Mp(`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 r.signOut(od()),vd();break}case"auth-callback":if(t.url){const o=await r.handleSignInCallback(`${Ru}${t.originalUrl}`).catch(e=>({error:e}));if(vd(),o&&"error"in o){Mp(`Error during sign in: ${o.error}`);const e=o.error instanceof Error?o.error.message:String(o.error);n.redirect(Ru+"?cancelled&message="+encodeURIComponent(e))}else{var c,l,p,u;const t=await kd();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=[...Ld(t)];const o=await Bd(t,{signout:!0});if(!o)return e.invalid_login=!0,e.invalid_login_type="too-many-logins",n.redirect(od("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(od("error"));vd()}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)}`),Mp(`User logged in: ${(null==t||null==(p=t.userInfo)?void 0:p.sub)||(null==t||null==(u=t.claims)?void 0:u.sub)}`),rh(),n.redirect(Ru)}}break;default:o()}}),t};function mh(e,t,n){return!!n||e===kp||"string"==typeof t&&t===e}function fh(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=hh(t);if(e)return e}catch(e){}}function hh(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 r=o.find(e=>"origin"===e.name)||o.find(e=>"upstream"===e.name)||o[0];return r?r.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:hh(o)}function gh(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 vh=new Set(["https://cloud.needle.tools","https://needle.tools","https://engine.needle.tools","https://docs.needle.tools","chrome-extension://kjcepmifiddcepiocokclhibpkgcdomk","chrome-extension://jonplpbnhmanoekkgcepnedhghflblmo"]),bh=new Set(["localhost","127.0.0.1","[::1]","::1"]);function yh(e){if("string"!=typeof e||0===e.length)return!1;if(vh.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!!bh.has(n)||"::1"===n}const xh="[MCP]",wh=new Array;function _h(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function jh(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0}async function kh(){try{return JSON.parse(await V(se(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 Sh(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 Eh(e,t){return{api_endpoint:e,version:t,pid:process.pid}}var Th={__proto__:null,getLocalServerInfo:Eh,getLocalServerStatus:async function(e={}){var t,n,o;const i=null!=(t=e.fetch)?t:globalThis.fetch;let r,a;try{r=await i(`${Ru}/api/info`,{signal:AbortSignal.timeout(3e3)})}catch(e){if(e instanceof Error&&_h(e.cause)&&"ECONNREFUSED"===e.cause.code)return{running:!1,url:Ru};throw e}if(!r.ok)throw new Error(`Local server status request failed (HTTP ${r.status}).`);try{a=await r.json()}catch(e){if(e instanceof SyntaxError)throw new Error("Invalid local server info response.");throw e}if(!_h(a)||"string"!=typeof a.version||!a.version.trim()||"string"!=typeof a.api_endpoint||!a.api_endpoint.trim())throw new Error("Invalid local server info response.");if(void 0!==a.pid&&!jh(a.pid))throw new Error("Invalid local server PID.");if(jh(a.pid))return{running:!0,url:Ru,version:a.version,pid:a.pid,pidSource:"server"};const s=await(null!=(n=e.readServerRecord)?n:kh)();return _h(s)&&s.port===Nu&&jh(s.pid)&&(null!=(o=e.isProcessAlive)?o:Sh)(s.pid)?{running:!0,url:Ru,version:a.version,pid:s.pid,pidSource:"record"}:{running:!0,url:Ru,version:a.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 $h="2026-10-27T17:56:06.221Z";var Ih={__proto__:null,BUILD_TIME:$h};const{json:Ah}=Qe;function Oh(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 Ch(t={restart:!1}){const n=!0===t.restart,o=await e(Ru).catch(e=>({ok:!1})),r="/sign-in",a="/api/authenticated",s="/api/projects",l="/api/content",p={baseUrl:Ru,port:Nu,isHost:!1,auth_endpoints:{"sign-in":`${Ru}${r}`,"sign-out":`${Ru}/sign-out`,"is-authenticated":`${Ru}${a}`}};let u=o.ok;if(u){var d;const g=await e(`${Ru}/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(!mh(b.api_endpoint,"https://cloud.needle.tools/api",n))return Mp(`Keeping CLI server for ${b.api_endpoint}; https://cloud.needle.tools/api did not request an explicit restart.`),p;Mp(`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)){Mp("Restarting auth server...");const y=`${Ru}/restart`;t.ora&&(t.ora.text="Sending restart request to server");const x=new AbortController;setTimeout(()=>x.abort(),1e4);let w={};try{const k=_($e(),".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(y,{method:"post",signal:x.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 kl(300),Ch({restart:!1});409!==j.status&&console.error("Failed to restart server",j.status),Mp(`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),Mp("Error starting the auth server"),new Error("Failed to load express module")});if(!E)throw Mp("Error loading auth server module"),new Error("Failed to load express module");Mp(`Starting Needle CLI server ${Qd()} (built ${$h})... (Using api at https://cloud.needle.tools/api)`,{emptyLineBefore:!0}),p.isHost=!0;let T=null;const A={invalid_login:!1,invalid_login_type:null,user_email:null,logged_in_machine_names:[]};let O=E.default();const C=_($e(),".needle"),N=function(e,t){var n;const o=se(e,"local-server-token"),r=null!=(n=function(e){if(!$(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 a=JSON.stringify({token:r,pid:process.pid,port:t},null,2);if(G(o,a,{encoding:"utf-8",mode:384}),"win32"===process.platform)try{const e=process.env.USERNAME||process.env.USER||"";e&&He("icacls",[o,"/inheritance:r","/grant:r",`${e}:(F)`],{stdio:"ignore",timeout:5e3})}catch{}return r}(C,Nu);Mp(`Local token written to ${_(C,"local-server-token")}`);const R=function(e,t=5e3){const n=new Map,o=Math.max(1,Math.round(t/1e3));return(i,r)=>{const a=Date.now(),s=n.get(i);if(!s||a-s.lastLog>t){var c;const t=null!=(c=null==s?void 0:s.suppressed)?c:0;e(t>0?`${r} [+${t} similar in last ${o}s]`:r),n.set(i,{lastLog:a,suppressed:0})}else s.suppressed++}}(e=>Mp(`Denied: ${e}`),5e3);O.use((h={onDenied:R},(e,t,n)=>{var o;return gh(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"))})),O.use(function(e){const t=null==e?void 0:e.onDenied;return(e,n,o)=>{var i,r;if("OPTIONS"===e.method)return o();const a=null==(i=e.headers)?void 0:i.origin,s=null==(r=e.headers)?void 0:r["sec-fetch-site"];if(void 0!==a){if(yh(a))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|${a}|${o}`,`denied origin=${a} 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:R})),O.use(Ah({limit:"10mb"}));const P=new Set(["/","/sign-in","/sign-out","/auth-callback","/api/info","/api/authenticated","/api/public_key","/mcp","/register"]),U="needle_local";O.use((e,t,n)=>{var o,i,r;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 a=null==(o=e.headers)?void 0:o.authorization;if(a){const e=a.split(" ");if(2===e.length&&"Bearer"===e[0]&&e[1]===N)return n()}if((null==(i=e.query)?void 0:i.token)===N)return n();const s=((null==(r=e.headers)?void 0:r.cookie)||"").split(";").map(e=>e.trim()).find(e=>e.startsWith(U+"="));if(s&&s.split("=")[1]===N)return n();try{var c,l;const t=null!=(c=null==(l=e.headers)?void 0:l["user-agent"])?c:"unknown";R(`token|${t}|${e.path}`,`path=${e.path} ua="${t}" — no valid token or cookie`)}catch{}return t.status(401).send("Unauthorized: token required")}),O.use(dh(A)),t.ora?(t.ora.start("Starting MCP server..."),t.ora.succeed(`MCP server available at ${Ru}/mcp`)):console.log(`\nMCP server available at ${Ru}/mcp .`),O.use(Of);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 (${Qd()})"/>`,F="</div>";let D="";O.get("/",Od(),async(e,t)=>{var n,o;if(null!=(n=e.user)&&n.isAuthenticated?t.cookie(U,N,{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 Mp("Login cancelled by user");if(null!=e.query["too-many-logins"]&&A.logged_in_machine_names.length){var i;const e=Sp();let n="<div>";return n+="<strong>You have reached the maximum number of allowed device logins!</strong><br/><br/>",n+=(null==(i=A.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="${r}">sign-in on this machine</a>.<br/><br/>`,n+="</div>",t.status(406),t.end(z+n+F),void Mp(`Login failed: Too many logins from different machines: [${A.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="${r}">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://${Dp()}" target="_blank">${Dp()}</a></span>\n </div>\n ${F}`);if(null!=(o=e.user)&&o.isAuthenticated){var a;if(!await Fd(e.user)){if(A.invalid_login=!0,A.logged_in_machine_names=[...Ld(e.user)],rd(),Mp("Cleared stored auth data"),"client"in e.user){const t=e.user;await t.client.clearAccessToken(),await t.client.clearAllTokens(),Mp("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="${r}">sign in</a> again</div>${F}`)}A.invalid_login=!1,t.end(`${z}\n <div>\n Hi ${Id(e.user)} — you logged in successfully. You can close this window now.\n </div>\n ${F}`);const n=`Logged in successfully as ${Id(e.user)} (${null==(a=e.user.userInfo)?void 0:a.sub})`;return void(D!==n&&(D=n,Mp(D)))}let s=`<span><a href="${r}">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()}),O.post("/restart",(e,n)=>{var o;if(!mh("https://cloud.needle.tools/api",e.headers["x-needle-api-endpoint"],"true"===e.headers["x-needle-explicit-restart"]))return Mp("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=T)||o.close(e=>{e&&console.error(e)}),setTimeout(()=>{process.exit(0)},100),n.status(200).end("Server is restarting"),Mp("Server is restarting\n")}),O.get("/api/logs",async(e,t)=>{const n=Dp();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 r=`--- Needle CLI v${Qd()} (built ${$h}) Log File (newest first) ---\n${n}\n\n`;r+=i,t.status(200).end(r)}):t.status(404).end("Log file not found")}),O.get("/api/info",(e,t)=>{t.json(Eh("https://cloud.needle.tools/api",Qd()))}),O.get(a,Od(),async(e,t)=>{var n;if(!0===A.invalid_login){const e=Nh(A);return t.status(e.status).json(e)}A.invalid_login=!1,t.status(null!=(n=e.user)&&n.isAuthenticated?200:400).send()}),O.get("/api/user",Od(),async(e,t)=>{var n;const o=e.user;if(null==o||!o.isAuthenticated){if(!0===A.invalid_login){const e=Nh(A);return t.status(e.status).json(e)}return t.status(401).json({error:"Not authenticated"})}if(A.invalid_login=!1,!await Fd(o))return rd(),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,r=null==o?void 0:o.userInfo.custom_data,a={authenticated:o.isAuthenticated,id:o.userInfo.sub,name:Id(o),email:o.claims.email||o.userInfo.email||"",profile_picture:o.userInfo.picture||"",default_org_id:(null==r?void 0:r.default_org)||"none",orgs:[]},s=["manage","owner","member","developer"];o.userInfo.organization_data&&(a.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===a.default_org_id?-1:t.id===a.default_org_id?1:e.name.localeCompare(t.name))),t.json(a)}),O.get("/api/license",Od(),async(t,n)=>{var o,i,r;const a=null==(o=t.query.token)?void 0:o.toString(),s=null==(i=t.query.org)?void 0:i.toString();let c=null;if(a)c={authToken:a};else{const e=await kd();if(!e||!e.isAuthenticated)return n.status(401).json({error:"Not authenticated",code:"not_authenticated"});if(!await Fd(e))return rd(),n.status(403).json({error:"Invalid login"});c=await Ad(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=gt(c),p=null==(r=t.query.integration)?void 0:r.toLocaleString(),u={...l,"x-needle":"cli","x-needle-integration":null!=p&&p.length?p:"unknown"},d=await e(`https://cloud.needle.tools/api${ht.account.get_licenses}`,{method:"GET",headers:u}).catch(e=>{const t=Oh(e);return console.error("Failed to fetch licenses:",t),Mp(`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})}),O.get("/api/deployments",Od(),async(e,t)=>{var n;const o=await kd();if(!o||!o.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const i=null==(n=e.query.org)?void 0:n.toString(),r=await Ad(o,i).catch(e=>({status:500,error:e.message}));if("error"in r)return t.status(r.status).json({error:r.error});if(i&&!r.org)return t.status(400).json({error:"Organization not found"});const a=await Iu({endpoint:"https://cloud.needle.tools/api",authToken:r.authToken,org:r.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 a)return t.status(a.status).json({error:a.error});for(const e of a.deployments)e.editUrl=`${Ep()}/${e.id}`;const s={...a};return t.json(s)}),O.get(l,Od(),async(e,t)=>{var n,o,i,r,a,s,c,l;const p=await kd();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 Ad(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==(r=e.query.content_format)?void 0:r.toString())||void 0,search:(null==(a=e.query.search)?void 0:a.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 np({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)}),O.get(l+"/:identifier",Od(),async(e,t)=>{var n,o;const i=await kd();if(!i||!i.isAuthenticated)return t.status(401).json({error:"Not authenticated"});const r=(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,a=await Ad(i,r).catch(e=>({status:500,error:e.message}));if("error"in a)return t.status(a.status).json({error:a.error});const s=await op({baseUrl:"https://cloud.needle.tools/api",authToken:a.authToken,org:a.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)}),O.get(s,Od(),async(t,n)=>{const o=await kd();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i=`https://cloud.needle.tools/api${ht.local_projects.get.user}`,r=await e(i,{method:"GET",headers:{Authorization:`Bearer ${o.accessToken}`}}).catch(e=>(console.error("Failed to fetch projects:",Oh(e)),null));if(!r)return n.status(502).json({error:"Failed to fetch projects: upstream API unreachable"});if(!r.ok)return n.status(r.status).json({error:r.statusText});const a=await r.json().catch(e=>console.error(e));return n.json(a)}),O.get(s+"/:id",Od(),async(t,n)=>{var o;const i=await kd();if(!i||!i.isAuthenticated)return n.status(401).json({error:"Not authenticated"});let r=null==(o=t.query.org)?void 0:o.toString();const a=await Ad(i,r).catch(e=>({status:500,error:e.message}));if(!a)return n.status(500).json({error:"Failed to fetch projects"});if("error"in a)return n.status(a.status).json({error:a.error});const s=gt(a),c=`https://cloud.needle.tools/api${ht.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:",Oh(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"})}),O.post("/api/projects",Od(),async(t,n)=>{const o=await kd();if(!o||!o.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const i="string"==typeof t.body?JSON.parse(t.body):t.body,r={machine_id:await Dd(),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(!r.project_id||!r.project_name)return n.status(400).json({error:"Invalid request"});const a=`https://cloud.needle.tools/api${ht.local_projects.post}`,s=await e(a,{method:"POST",headers:{Authorization:`Bearer ${o.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify(r)}).catch(e=>(console.error("Failed to upsert project:",Oh(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"})}),O.get("/api/public_key",Od(),async(t,n)=>{var o,i;const r=await kd();if(!r||!r.isAuthenticated)return n.status(401).json({error:"Not authenticated"});const a=null==(o=t.query.org)?void 0:o.toString(),s=await Ad(r,a).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 Dd()},l=await e(`https://cloud.needle.tools/api${ht.account.public_key}`,{method:"POST",headers:{...gt(s),"Content-Type":"application/json"},body:JSON.stringify(c)}).catch(e=>(console.error("Failed to fetch public key:",Oh(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})}),O.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=fh(o);return i?t.json({project_id:i}):t.status(404).json({error:"Project ID not found"})}),O.post("/api/project/info",Od(),async(e,t)=>{(function(e){try{!function(e){var t,n,o,i;const r={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},a=Yd();let s=Zd();const c=s.entries.findIndex(e=>e.project_location===r.project_location),l=null==(o=s.entries[0])?void 0:o.project_location;-1!==c?s.entries[c]=r:s.entries.push(r),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&&Mp(`Active project changed: ${l||"(none)"} → ${u}`);try{Md=s;const e=JSON.stringify(s);f(a,e,"utf-8")}catch(e){console.error("Failed to save project info:",e)}}(e)}catch(e){Mp("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(T=O.listen(Nu,()=>{null==q||q()}),T.on("error",e=>{if("EADDRINUSE"===(null==e?void 0:e.code))return Mp(`License server port ${Nu} 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),Mp(`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()}})}(T,Mp),T.on("close",m),process.on("exit",m),process.on("SIGINT",()=>{m(),process.exit(0)}),await B.catch(e=>{console.error(e),Mp(`Error starting the auth server (promise failed): ${e.message}`)}),W)return p;function m(){Mp("Cleaning up auth server...")}const H=function(e,t){const n=new Ge({server:e,path:"/mcp/ws",verifyClient:({req:e},t)=>{var n;if(!gh(e.headers.host))return Mp(`${xh} 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&&!yh(o))return Mp(`${xh} rejected WS upgrade: disallowed origin ${o}`),void t(!1,403,"Forbidden: origin not allowed");t(!0)}});Mp("MCP websocket server created.");let o=0,i=new Map;return n.on("connection",e=>{const t=++o;wh.push(e),console.log(`${xh} client connected (#${t})`),Mp(`${xh} client connected (#${t})`),e.on("close",()=>{const n=wh.indexOf(e);-1!==n&&wh.splice(n,1);const o=i.get(t);if(o){for(const e of o)am(e,Gf);i.delete(t)}console.log(`${xh} client disconnected (#${t})`),Mp(`${xh} client disconnected (#${t})`)});const n=new Map;e.on("message",o=>{try{const r=o.toString(),a=JSON.parse(r);switch(a.command){default:console.log(`${xh} Unknown command: ${a.command}`),Mp(`Unknown MCP websocket command received: ${a.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))}(a);break;case"register_tools":{const o=a.tools,r=a.source;if("cli"===r||"cloud"===r)throw new Error("The CLI and cloud tool sources are reserved for built-in tools.");r&&rm(r,Gf);const s=r||"unknown";console.log(`${xh} ${s} registered ${o.length} tool${1===o.length?"":"s"}`),Mp(`${xh} ${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)sm(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((r,a)=>{const s=setTimeout(()=>{n.has(i)&&(console.error(`${xh} Tool execution timed out for tool: ${t.name}`),n.delete(i),a(new Error(`Tool execution timed out for tool: ${t.name}`)))},3e4);n.set(i,{resolve:e=>{r(e),clearTimeout(s)},reject:a}),e.send(JSON.stringify({command:"execute_tool",toolName:t.name,args:o,requestId:i}))})},{source:r},Gf),c.add(t.name);break}case"tool_result":{const e=a.requestId,t=a.result;if(console.log(`${xh} 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(`${xh} No pending tool execution found for requestId: ${e}`);break}}}catch(e){console.error(`${xh} Error processing WebSocket message:`,e)}})}),n}(T);gf({logToolCount:!0}),rh();const J=Jm(C,()=>{Mm()?(Mp("Settings changed: remote_ai_tools disabled — closing cloud connection"),ah("remote_ai_tools setting disabled")):(Mp("Settings changed: remote_ai_tools enabled — opening cloud connection"),rh())});Nd(O,N,()=>{Mp("Authenticated stop requested; shutting down the local Needle server."),T&&Rd(T,H,()=>{J(),ah("stop requested")})}),process.on("exit",()=>{J(),ah("process exit")})}var h;return p}function Nh(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 ${Sp()}. You're currently logged in on: ${e.logged_in_machine_names.join(", ")}`:"An unknown error occured.",{status:403,error:t}}async function Rh(e={headless:!1,silent:!1,clearAuthData:!1}){return!0===e.clearAuthData&&await rd(),Uh("sign-in",{...e})}function Ph(e={}){return Uh("sign-out",{...e})}function Uh(t,n){return new Promise(async(o,i)=>{let r=!1;if("sign-in"==t){const e=await kd();if(null!=e&&e.isAuthenticated&&e.accessToken)return await Bd(e)?(r=!0,n.ora&&(n.ora.text=`Authorized as ${Id(e)}`),"gotoAccountPage"in n&&!0===n.gotoAccountPage&&(n.ora&&(n.ora.text="Opening account page in the browser"),Tp(Sp()),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){r=!0,rd();const t=await Ch(),n=await e(t.auth_endpoints["sign-out"],{follow:2});return o(n.ok)}const a=await Ch();switch(n.timeout||(n.timeout=6e5),"number"==typeof n.timeout&&n.timeout>0&&setTimeout(()=>{r||(n.ora&&n.ora.fail('Timeout "'+t+'"'),o(null))},n.timeout),t){case"sign-in":const e=a.auth_endpoints["sign-in"];setTimeout(()=>Tp(e),300),n.ora&&(n.ora.text=`Please authenticate in the browser: ${e}`),setTimeout(l,2e3);break;case"sign-out":rd(),Tp(a.auth_endpoints["sign-out"]),setTimeout(l,2e3)}let s=0;const c=10;function l(){e(a.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 kd();return e&&!await Bd(e)?o(null):(r=!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;T().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 r=!0,rd(),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 ${a.port} is not blocked`):n.silent||console.error(`Failed to complete auth flow. Please try again. Make sure that port ${a.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,r=null!=(n=e.log)?n:Bp,a=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}`:"";r(`CLI crashed (${e}): ${n}${o}`)}catch{}try{a(`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 Lh=process.argv.includes("--silent"),zh=JSON.parse(p(new URL("../package.json",import.meta.url),"utf-8")),Fh="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 Dh(e,t=null,n=!0){let o,i=null==e?void 0:e.toString();var r;if(i||(ze.config(),process.env.NEEDLE_CLOUD_TOKEN&&(i=process.env.NEEDLE_CLOUD_TOKEN,null!=(r=i)&&r.length&&console.error("Using NEEDLE_CLOUD_TOKEN token from env"))),""===i||"true"===i){if(!n)throw new Error("--token requires a value in non-interactive mode.");const e=(await import("node:readline")).createInterface({input:process.stdin}),t=10;let i,r="",a=!1;return new Promise(n=>{const s="Paste your https://cloud.needle.tools/team#token access token here:",c=T({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?r=r.slice(0,-1):r+=p;const e=r.replace(/./g,"*");c.text=`${s} ${e}`}clearTimeout(i),i=setTimeout(()=>{if(!a&&(u||r.trim().length>t)){process.stdin.setRawMode(!1),e.close(),a=!0;const t=r.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");n({accessToken:t,org_id:o})}},150)})})}if(!i){let e;n&&!await async function(){const e=await kd();return null==e?void 0:e.isAuthenticated}()&&(e=Lh?void 0:T("No access token found. Please sign in to authenticate...").start()),Mp("No access token provided, attempting login. Org: "+t);const r=Rh({headless:!n,ora:e,timeout:12e4}),d=await r;if(d&&!await Fd(d)){var a;if(!n)throw new Error("Saved authentication is invalid. Provide --token or NEEDLE_CLOUD_TOKEN.");null==(a=e)||a.fail("You are not logged in from this machine. Please login again."),await Ph({headless:!0}),process.exit(1)}else e&&(Mp("User logged in via getAccessToken "+(null==d?void 0:d.isAuthenticated)),d?e.succeed("Logged in"):e.fail("Login failed"));if(null!=d&&d.isAuthenticated){var s;if(null==t){const e=await Sd(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 (${Id(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)),Mp("Getting access token for org "+o+", "+i.substring(0,8)+"...")}else{var u;Mp("Getting access token for user "+(null==(u=d.userInfo)?void 0:u.sub)),i=null==d?void 0:d.accessToken}}}if(!i)throw Mp("ERR: Missing NEEDLE_CLOUD_TOKEN token. Org: "+o),new Error("Missing authentication. Provide --token, set NEEDLE_CLOUD_TOKEN, or run needle-cloud login.");return{accessToken:i,org_id:o}}function qh(e){return null!=e.org&&console.warn("Warning: --org is deprecated. Use --team instead."),e.team||e.org}const Bh=mt.program;async function Mh(){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))}Bh.version(zh.version).description("Command-line interface (CLI) for Needle Cloud"),Bh.command("version","Print the CLI version").configure({visible:!1}).action(()=>{Lh||console.log(`☁ Needle CLI — ${zh.version}, Node ${process.version}`)}),Bh.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:Bh.BOOLEAN,default:!1}).option("--integration <integration>","Hint for the process which integration triggered this command",{required:!1,validator:Bh.STRING}).action(async({options:e})=>{const t=e.integration,n=Lh?void 0:T("Starting Needle License server "+(t?`(from ${t})`:"")).start();Ch({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${Qd()}, built ${function(e){if("string"!=typeof $h||0===$h.length)return"unknown";const t=new Date($h);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))})}),Bh.command("stop","Stop the local Needle license server").alias("quit").help("Request an authenticated shutdown of the local Needle server, then exit. Does not sign out or stop Unity. Older servers without stop support must be closed manually.").action(async()=>{try{const{stopLocalServer:e}=await Promise.resolve().then(function(){return Pd}),t=await e();Lh||console.log("not-running"===t?"Needle server is not running.":"Needle server shutdown requested."),process.exit(0)}catch(e){console.error(`Could not stop the Needle server: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}),Bh.command("settings","Show current Needle CLI settings").action(async()=>{const{readSettings:e,KNOWN_SETTINGS:t}=await Promise.resolve().then(function(){return Vm}),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("")}),Bh.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:Bh.BOOLEAN}).action(nu("settings remote-ai-tools",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return Vm}),o=e.enabled,i=n();o?(t(i,"remote_ai_tools",null),console.log("Remote AI tools enabled (default)."),Mp("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."),Mp("Settings: remote_ai_tools set to disabled via CLI command"))})),Bh.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:Bh.BOOLEAN}).action(nu("settings local-file-edits",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return Vm}),o=e.enabled;t(n(),"local_file_edits",o?null:"disabled"),console.log(`Local AI file edits ${o?"enabled":"disabled"}.`)})),Bh.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:Bh.BOOLEAN}).action(nu("settings local-project-commands",async({args:e})=>{const{writeSetting:t,defaultSettingsDir:n}=await Promise.resolve().then(function(){return Vm}),o=e.enabled;t(n(),"local_project_commands",o?null:"disabled"),console.log(`Local AI project commands ${o?"enabled":"disabled"}.`)})),Bh.command("status","Show the local Needle server status and process ID").action(nu("status",async()=>{const{getLocalServerStatus:e,formatLocalServerStatus:t}=await Promise.resolve().then(function(){return Th});console.log(t(await e()))})),Bh.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(nu("mcp",async()=>{const{startStdio:e}=await Promise.resolve().then(function(){return Mf});e()})),Bh.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=fh(e.paths);t?console.log(`Found project ID: "${t}"`):console.log("No project ID found.")}),Bh.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:Bh.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:Bh.BOOLEAN,default:!1}).action(nu("send-logs",async({options:e})=>{var t,n,o,i,r,a,s;const{runSendLogs:c,HAYSTACK_RESOURCE:l}=await Promise.resolve().then(function(){return ed}),{tryGetFreshAccessTokenForResource:p}=await Promise.resolve().then(function(){return $d}),{findActiveEditorLog:u}=await import("./cli.send-logs.discovery-98b97e6b.js"),{getLogFilePath:d,getPrevLogsFilePath:m,getPipelineLogFilePath:f}=await Promise.resolve().then(function(){return Wp}),{homedir:h,platform:g}=await import("os"),{existsSync:v}=await import("fs"),{BUILD_TIME:b}=await Promise.resolve().then(function(){return Ih}),{getNodeVersion:y,getNpmVersion:x,getArch:w,getOsRelease:_,getCpuCount:j,getTotalMemoryMb:k,getTzOffsetMinutes:S,isCi:E,isTty:$}=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",A=e.note,O=null!=(i=null!=(r=null==(a=e.dryRun)||null==a.valueOf?void 0:a.valueOf())?r:e.dryRun)&&i,C=d(),N=m(),R=f(),P={getAccessToken:()=>p(l),fetch:globalThis.fetch,paths:{cliLogPath:v(C)?C:null,prevLogPath:v(N)?N:null,pipelineLogPath:v(R)?R:null,homeDir:h()},meta:{cli_version:Qd(),build_time:b,os:g(),os_release:_(),arch:w(),node_version:y(),npm_version:null!=(s=x())?s:"unknown",cpu_count:j(),total_memory_mb:k(),tz_offset_minutes:S(),is_ci:E(),is_tty:$()},findActiveEditorLog:u,stdout:process.stdout,stderr:process.stderr},U=O?"Building payload (dry-run)":"Uploading logs",L=Lh?void 0:T(U).start();P.recoverAuth=async()=>{null==L||L.stop();try{await Mh();const e=await Rh({clearAuthData:!0,silent:Lh,ora:void 0});if(null==e||!e.isAuthenticated)return null}catch(e){return Mp(`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:A,dryRun:O},P);z.ok?O?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)})),Bh.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:Bh.BOOLEAN,default:!1}).option("--clear <clear>","Refresh the access token",{required:!1,validator:Bh.BOOLEAN,default:!1}).action(su(async({options:e})=>{const t=ru(e),n=!0===e.nonInteractive||!0===e.headless;n||await Mh();const o=!0===e.clear,i=Lh?void 0:T("Login").start();await Rh({headless:n,silent:Lh,clearAuthData:o,ora:i}).then(async e=>{"json"===t&&cu({authenticated:!0===(null==e?void 0:e.isAuthenticated)}),null!=e&&e.isAuthenticated?null==i||i.succeed("Successfully logged in as "+Id(e)):0==n?null!=e&&e.claims||null!=e&&e.userInfo?null==i||i.warn(`You (${Id(e)}) are not authenticated...`):null==i||i.fail("Login failed"):Lh||null==i||i.warn("Not logged in"),await lu(null!=e&&e.isAuthenticated?0:1)})})),Bh.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:Bh.BOOLEAN,default:!1}).action(su(async({options:e})=>{const t=ru(e),n=!0===e.nonInteractive||!0===e.headless;n||await Mh(),await Ph({headless:n}).then(async e=>{"json"===t&&cu({success:e}),e?T("Logged out").succeed():T("Logout failed").fail(),await lu(e?0:1)})})),Bh.command("me","Prints your user information").help("Prints basic informaton about the logged in Needle Cloud account (your account)").action(su(async({options:e})=>{const t=ru(e),n=Lh?void 0:T("Query user data").start(),o=await kd(),i=Boolean((null==o?void 0:o.isAuthenticated)&&await Fd(o));if("json"!==t)if(o&&i){const e=o.userInfo||o.claims;var r,a,s;e?(null==n||n.succeed(`You are logged in as ${Id(o)}`),console.log(`- Name: ${Id(o)}`),console.log(`- ID: ${e.sub}`),e.email&&console.log(`- Email: ${e.email}`),e.phone_number&&console.log(`- Phone: ${e.phone_number}`),null!=(r=o.userInfo)&&r.organization_data&&console.log(`- Teams [${null==(a=o.userInfo)?void 0:a.organization_data.length}]: ${null==(s=o.userInfo)?void 0:s.organization_data.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.name).join(", ")}`)):null==n||n.fail("Failed to get user data")}else null==n||n.warn("You are not logged in");else{null==n||n.stop();const e=(null==o?void 0:o.userInfo)||(null==o?void 0:o.claims);var c,l;o&&i&&e?cu({authenticated:!0,id:e.sub,name:Id(o),email:e.email,teams:(null!=(c=null==(l=o.userInfo)?void 0:l.organization_data)?c:[]).map(e=>({id:e.id,name:e.name}))}):(cu({authenticated:!1}),process.exitCode=1)}})),Bh.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:Bh.STRING}).option("--org <org>","Legacy alias for --team",{validator:Bh.STRING,hidden:!0}).action(nu("get-pro",async({options:e})=>{var t;let n=(null==(t=qh(e))?void 0:t.toString())||null;const o=T().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 r=i.toString();o.succeed(`Started Needle Engine PRO purchase flow: opening browser at ${r}`),Tp(r)}));const Wh={account:{url:Sp}},Gh=`"${Object.keys(Wh).join('", "')}"`;Bh.command("open",`Open a page in the default browser. Options are: ${Gh}`).argument("<page>",`The page to open. Options are: ${Gh}`,{validator:Bh.STRING}).configure({strictOptions:!1,strictArgsCount:!1,visible:!1}).help("").action(async({args:e,logger:t})=>{const n=e.page.toString(),o=Wh[n];o?"url"in o?Tp(o.url()):t.error(`Unknown argument: ${n}`):t.error(`Unknown argument: ${n}. Options are: ${Gh}`)}),Bh.command("list-deployments","Get a list of deployed websites").configure({visible:!1}).help("").option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Bh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Bh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Bh.STRING}).option("--limit <limit>","Limit the number of deployments to show (min: 0, max: 100)",{validator:Bh.NUMBER,default:10}).option("--offset <offset>","The offset for deployments (default: 0, min: 0)",{validator:Bh.NUMBER,default:0}).option("--format <format>","Legacy output option: cli or json",{validator:Bh.STRING,hidden:!0}).option("--name","Filter by one or multiple deployment names (separated by ;)",{validator:Bh.STRING}).action(su(async({options:e,logger:t})=>{var n,o,i,r;const a=ru(e,{legacyFormat:!0}),{accessToken:s,org_id:c}=await Dh(e.token,qh(e),!0!==e.nonInteractive),l=(null==(n=e.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",p=Number(null!=(o=e.limit)?o:10),u=Number(null!=(i=e.offset)?i:0),d=(null==(r=e.name)?void 0:r.toString())||void 0;if(p<0)throw new Error("The limit cannot be negative.");if(p>100)throw new Error("The limit cannot exceed 100.");const m=T("Query deployments").start(),f=await Iu({endpoint:l,authToken:s,org:c,limit:p,offset:u,names:null==d?void 0:d.split(";")});if(f&&"error"in f)throw new Error(f.error+" (status: "+f.status+")");if(!f)throw new Error("Failed to query deployments.");if("json"===a)return m.succeed(`Found ${f.deployments.length} deployments`),void cu(f.deployments);f.deployments.length>0?(m.succeed(`Found ${f.deployments.length} deployments`),f.deployments.forEach((e,n)=>{t.info(`${n+p*u}: ${e.name} – ${e.url}`)})):m.warn("No deployments found")}));for(const e of["list","search"]){const t=Bh.command(e,"search"===e?"Search content items by name, title or description":"List content items (3d assets, deployments, materials, etc.)");"list"===e?t.alias("list-content"):t.argument("<query>","Search by name, title or description",{validator:Bh.STRING}),t.help(("search"===e?"Search":"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>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Bh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Bh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Bh.STRING}).option("--include-projects","Include saved web projects (default: uploaded content only)",{validator:Bh.BOOLEAN,default:!1}).option("--trash","List deleted items instead of active content",{validator:Bh.BOOLEAN,default:!1}).option("--interactive","Override automatic terminal browsing: true or false",{validator:Bh.BOOLEAN}).option("--type <type>","Filter by content type (e.g. material, 3d-asset, deployment, editor-project)",{required:!1,validator:Bh.STRING}).option("--format <format>","Filter by output format (e.g. glb, textures)",{required:!1,validator:Bh.STRING}).option("--search <search>","Search by name, title or description",{required:!1,validator:Bh.STRING}).option("--limit <limit>","Max number of items to show (default: 20, max: 100)",{validator:Bh.NUMBER,default:20}).option("--offset <offset>","Offset for pagination (default: 0)",{validator:Bh.NUMBER,default:0}).option("--output <output>","Output style: cli (default), json",{validator:Bh.STRING,default:"cli"}).action(su(async({args:t,options:n,logger:o})=>{var i,r,a,s,c,l,p;const u="search"===e?String(null!=(i=t.query)?i:"").trim():void 0;if("search"===e&&!u)throw new Error("Search query must not be empty.");if(u&&void 0!==n.search&&n.search.toString()!==u)throw new Error("Conflicting query and --search. Supply one search value.");const d=ru(n),m=hu(n),f=Number(null!=(r=n.limit)?r:20),h=Number(null!=(a=n.offset)?a:0);if(!Number.isInteger(f)||f<1)throw new Error("--limit must be a positive integer.");if(!Number.isInteger(h)||h<0)throw new Error("--offset must be a nonnegative integer.");const g=null==(s=n.type)?void 0:s.toString(),v=null==(c=n.format)?void 0:c.toString();if(g&&"editor-project"!==g&&!ep.some(e=>e===g))throw new Error("Invalid --type. Use "+[...ep,"editor-project"].join(", ")+".");if(v&&!tp.some(e=>e===v))throw new Error("Invalid --format. Use "+tp.join(", ")+".");const{accessToken:b,org_id:y}=await Dh(n.token,qh(n),!0!==n.nonInteractive),x=(null==(l=n.endpoint)?void 0:l.toString())||"https://cloud.needle.tools/api",w=Math.min(f,100),_=g||void 0,j=v||void 0,k=null!=u?u:(null==(p=n.search)?void 0:p.toString())||void 0,S={content_type:_,include_projects:!0===n.includeProjects,trash:!0===n.trash,content_format:j,search:k,limit:w,offset:h},E=T("Querying content...").start();try{const e=await np({baseUrl:x,authToken:b,org:y},S);if(m)return E.stop(),await ju({auth:{baseUrl:x,authToken:b,org:y},query:S,initial:e}),void await lu(0);if("json"===d)return E.succeed(`Found ${e.items.length} of ${e.total} items`),void cu(e.items);0===e.items.length&&(E.warn("No content found"+(_?` (type: ${_})`:"")+(j?` (format: ${j})`:"")),process.exit(0)),E.succeed(`Found ${e.items.length} of ${e.total} items`);const t=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?Sl(new Date(e.created_at),new Date,{allowSimple:!0,limitInDays:2}):""}}),n={id:Math.max(2,...t.map(e=>e.id.length)),type:Math.max(4,...t.map(e=>e.type.length)),formats:Math.max(7,...t.map(e=>e.formats.length)),name:Math.max(4,...t.map(e=>e.name.length))},i=Cu(` ${"ID".padEnd(n.id)} ${"TYPE".padEnd(n.type)} ${"FORMATS".padEnd(n.formats)} ${"NAME".padEnd(n.name)} ${"#".padStart(3)} AGE`);o.info(i);for(const e of t){const t=Ou(e.type).padEnd(n.type+11),i=(e.formats?e.formats.split(", "):[]).map(e=>Ou(e)).join(", ")+" ".repeat(Math.max(0,n.formats-e.formats.length));o.info(` ${Cu(e.id.padEnd(n.id))} ${t} ${i} ${e.name.padEnd(n.name)} ${e.versions.padStart(3)} ${Cu(e.date)}`)}e.total>h+w&&o.info(` ... ${e.total-h-w} more (use --offset ${h+w})`),process.exit(0)}catch(e){E.fail(e.message),process.exit(1)}}))}Bh.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:Bh.STRING}).option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Bh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Bh.STRING,hidden:!0}).option("--endpoint <endpoint>","The Needle Cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Bh.STRING}).action(su(async({args:e,options:t})=>{var n;const o=ru(t),{accessToken:i,org_id:r}=await Dh(t.token,qh(t),!0!==t.nonInteractive),a=(null==(n=t.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",s=String(e.identifier),c=T(`Deleting content "${s}"...`).start();try{const e=await $u({identifier:s,endpoint:a,authToken:i,org:r});c.succeed(e.message||`Moved content "${s}" to the trash`),"json"===o&&cu(e)}catch(e){c.fail(e.message),process.exitCode=1}})),Bh.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:Bh.STRING}).argument("[directory]","Output directory (default: current directory)",{default:"."}).option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Bh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Bh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Bh.STRING}).option("--format <format>","Output format to download (e.g. glb, textures)",{required:!1,validator:Bh.STRING}).option("--version <version>","Download this source version or derived output ID",{validator:Bh.STRING}).option("--label <label>","Download the version served by this label",{validator:Bh.STRING}).option("--name <name>","Output filename (without extension)",{required:!1,validator:Bh.STRING}).option("--verbose","Show detailed download info",{required:!1,validator:Bh.BOOLEAN,default:!1}).action(su(async({args:e,options:t})=>{var n,o,i,r,a,s;const c=ru(t),{accessToken:l,org_id:p}=await Dh(t.token,qh(t),!0!==t.nonInteractive),u=(null==(n=t.endpoint)?void 0:n.toString())||"https://cloud.needle.tools/api",d=String(e.identifier),m=(null==(o=e.directory)?void 0:o.toString())||".",f=(null==(i=t.name)?void 0:i.toString())||void 0,h=null!=(r=null==(a=t.verbose)?void 0:a.valueOf())&&r,g=(null==(s=t.format)?void 0:s.toString())||void 0,v=T("Looking up content...").start();try{var b,y;const e={baseUrl:u,authToken:l,org:p},n=await op(e,d);if(!n)throw new Error(`Content not found: "${d}". Use the exact content identifier (see list).`);const o=function(e,t){if(void 0!==t.version&&!t.version.trim())throw new Error("--version requires a version ID.");if(void 0!==t.label&&!t.label.trim())throw new Error("--label requires a label name.");if(t.version&&t.label)throw new Error("Use either --version or --label, not both.");const n=e.versions[0];if(!n)throw new Error(`Content "${e.title||e.name}" has no upload versions.`);let o;if(t.version){const n=e.versions.find(e=>e.identifier===t.version);if(o=n?[n,...n.variants]:e.versions.flatMap(e=>e.variants).filter(e=>e.identifier===t.version),!o.length)throw new Error(`Version "${t.version}" does not belong to this content item.`)}else if(t.label){if(o=e.versions.flatMap(e=>[e,...e.variants]).filter(e=>e.labels.some(e=>e.label===t.label)),!o.length)throw new Error(`Label "${t.label}" was not found on this content item.`)}else o=t.format?e.versions.flatMap(e=>[e,...e.variants]):[n];const i=t.format?o.find(e=>e.content_format===t.format):o[0];if(!i)throw new Error(`No output with format "${t.format}" found for the requested content selection.`);if((t.version||t.label)&&i.status&&"completed"!==i.status)throw new Error(`Version "${i.identifier}" is ${i.status}; select a completed version.`);return i.identifier}(n,{version:null==(b=t.version)?void 0:b.toString(),label:null==(y=t.label)?void 0:y.toString(),format:g});v.text=`Downloading "${n.title||n.name}"${g?` (format: ${g})`:""}...`,v.stop();const i=await ku({baseUrl:u,authToken:l,org:p,identifier:o,outDir:m,filename:f,verbose:h,content_format:g});if("error"in i)throw new Error(i.error);"json"===c&&cu(i)}catch(e){v.fail(e instanceof Error?e.message:String(e)),process.exitCode=1}})),Bh.command("deploy","Deploy a website to Needle").help("").argument("<directory>","The directory to deploy",{validator:Bh.STRING}).option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id to deploy to (not needed when using token/accesstoken)",{required:!1,validator:Bh.STRING}).option("--org <org>","The organization name or id to deloy to (not needed when using token/accesstoken)",{required:!1,validator:Bh.STRING,hidden:!0}).option("--name <name>","The project name. This name will also be used in your website URL",{required:!1,validator:Bh.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:Bh.STRING,hidden:!0}).option("--endpoint <endpoint>","The needle cloud endpoint to use - e.g. https://cloud.needle.tools/api",{required:!1,validator:Bh.STRING,hidden:!0}).option("--open","Open the deployment in the default browser",{default:!0,validator:Bh.BOOLEAN}).option("--verbose <verbose>","Enables verbose output logs",{required:!1,validator:Bh.BOOLEAN,default:!1,hidden:!0}).option("--experimental","Use the experimental upload API. Mostly used for debugging (default: false)",{required:!1,validator:Bh.BOOLEAN,default:!1,hidden:!0}).option("--raw","Use raw to disallow modifications like gzip compression on upload",{required:!1,validator:Bh.BOOLEAN,default:!1,hidden:!0}).option("--no-provenance","Do not record which commit and CI run this deployment came from",{required:!1,validator:Bh.BOOLEAN,default:!1}).action(su(nu("deploy",async({args:e,options:t,logger:n})=>{var o,i,r,a;const s=ru(t),c=!0!==t.nonInteractive&&t.open,{accessToken:l,org_id:p}=await Dh(t.token,qh(t),!0!==t.nonInteractive),u=!0===t.verbose,d=!0===t.experimental,m=!0===t.raw,f=(null==(o=t.noProvenance)?void 0:o.valueOf())||!1,h=await Hp({logger:n,endpoint:(null==(i=t.endpoint)?void 0:i.toString())||void 0,token:l,org_id:p,directory:String(e.directory),name:(null==(r=t.name)?void 0:r.toString())||void 0,entrypoint:(null==(a=t.entrypoint)?void 0:a.toString())||void 0,open:c,verbose:u||!1,experimental:d||!1,raw:m||!1,noProvenance:f});"json"===s&&null!=h&&h.success&&cu(h)}))),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>","Legacy output option: cli, json, source-url or edit-url",{validator:e.STRING}).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(nu(n,async({args:e,options:n})=>{var i;const r=globalThis.console,a=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Re({stdout:a,stderr:a});try{var s,c;const i=ru(n,{legacyFormat:!0,links:!0}),r=o||!0===n.wait;if(r&&!0===n.noOptimize)throw new Error("--wait cannot be combined with --no-optimize.");if(!r&&(void 0!==n.outdir||void 0!==n.progressive||void 0!==n.usecase))throw new Error("--wait is required for --outdir, --progressive and --usecase.");const a=n.usecase;if(void 0!==a&&"product"!==a&&"world"!==a)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:p,org_id:u}=await iu(t.getAccessToken,n);if(p!==n.token&&p!==process.env.NEEDLE_CLOUD_TOKEN){const e=await t.getUser();if(null==e||!e.isAuthenticated)throw new Error("Please login to upload files.");if(!u)throw new Error("Please provide a team to upload files.");if(r){var l;const e=await(null!=(l=t.getLicenses)?l:bt)({baseUrl:"https://cloud.needle.tools/api",authToken:p,org:u},{type:"org",org_id:u});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")}}Eu(await(null!=(s=t.upload)?s:Su)({token:p,org_id:u,fileOrDirectory:String(e.path),name:void 0===n.name?void 0:String(n.name),wait:r,noOptimize:!0===n.noOptimize,progressive:void 0===n.progressive?void 0:!0===n.progressive,usecase:a,outDir:void 0===n.outdir?void 0:String(n.outdir),verbose:!0===n.verbose,format:i}),i,null!=(c=t.write)?c:e=>{process.stdout.write(e)})}finally{globalThis.console=r}}))}uu(e)}(Bh,{getAccessToken:Dh,getUser:kd}),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>","Legacy output option: cli or json",{validator:e.STRING});"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(nu(`label ${n}`,async({args:e,options:o})=>{var i;const r=globalThis.console,a=null!=(i=t.stderr)?i:process.stderr;globalThis.console=new Re({stdout:a,stderr:a});try{var s;const i=ru(o,{legacyFormat:!0}),r=String(e.contentId);Kp(r);const a={contentId:r,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&&Yp(a),void 0!==o.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:p,org_id:u}=await iu(t.getAccessToken,o),d={baseUrl:"https://cloud.needle.tools/api",authToken:p,org:u},m=null!=(s=t.write)?s:e=>{process.stdout.write(e)};if("list"===n){var c;const e=await(null!=(c=t.listContentLabels)?c:Qp)(d,r);if("json"===i)m(JSON.stringify(e)+"\n");else if(e.labels.length)for(const t of e.labels)m(`${t.label}: ${t.sourceVersionIds.join(", ")}\n`),du(t.targets,m);else m(`No labels for ${r}.\n`)}else{var l;const e=await(null!=(l=t.setContentLabel)?l:eu)(d,a);"json"===i?m(JSON.stringify(e)+"\n"):(m(`${e.label}: ${e.previousVersionIds.join(", ")||"(new label)"} -> ${e.versionId}\n`),du(e.targets,m))}}finally{globalThis.console=r}}))}uu(e)}(Bh,{getAccessToken:Dh}),function(e,t){const n={getContent:op,updateContent:ip,restoreContent:ap,...t},o={info:"Inspect content metadata, versions and processing state",versions:"List source versions and their derived outputs, newest first",update:"Update content metadata or its thumbnail",restore:"Restore a content item from Trash"};for(const i of["info","versions","update","restore"]){const r=e.command(i,o[i]).argument("<identifier>","Content 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>","Legacy alias for --team",{validator:e.STRING,hidden:!0}).option("--endpoint <endpoint>","Needle Cloud API endpoint",{validator:e.STRING}).option("--output <output>","Output style: cli (default) or json",{validator:e.STRING,default:"cli"});"update"===i&&r.option("--title <title>","Set the title; an empty string clears it",{validator:e.STRING}).option("--description <description>","Set the description; an empty string clears it",{validator:e.STRING}).option("--tags <tags>","Replace tags with a comma-separated list",{validator:e.STRING}).option("--thumbnail <path>","Set a JPEG, PNG or WebP thumbnail (up to 5 MiB)",{validator:e.STRING}),"restore"===i&&r.help("Restore an item within 31 days of deletion. Requires enough available storage. Use list --trash to find deleted items."),r.action(nu(i,async({args:e,options:o})=>{var r,a,s;const c=String(e.identifier);if(!c.trim()||/[/\\?#\s]/.test(c))throw new Error("Pass an exact content identifier from list.");const l=String(null!=(r=o.output)?r:"cli");if("cli"!==l&&"json"!==l)throw new Error("Invalid --output. Use cli or json.");const p="update"===i?await mu(o):void 0,u=globalThis.console,d=null!=(a=t.stderr)?a:process.stderr,m=null!=(s=t.write)?s:e=>{process.stdout.write(e)};globalThis.console=new Re({stdout:d,stderr:d});try{var f;void 0!==o.org&&console.warn("Warning: --org is deprecated. Use --team instead.");const{accessToken:e,org_id:r}=await iu(t.getAccessToken,o),a={baseUrl:String(null!=(f=o.endpoint)?f:"https://cloud.needle.tools/api"),authToken:e,org:r};if("update"===i&&p){const e=await n.updateContent(a,c,p);if("error"in e)throw new Error(e.error);if(!e.success)throw new Error("Content update was not confirmed.");m("json"===l?JSON.stringify(e)+"\n":`Updated ${c}\n`)}else if("restore"===i){const e=await n.restoreContent(a,c);if(!e.restored)throw new Error("Content restore was not confirmed.");m("json"===l?JSON.stringify(e)+"\n":`Restored ${c}\n`)}else{const e=await n.getContent(a,c);var h,g;"json"===l?m(JSON.stringify("versions"===i?e.versions:e,null,2)+"\n"):("info"===i&&m(`${e.title||e.name} (${e.identifier})\n${null!=(h=e.description)?h:""}\nTags: ${(null!=(g=e.tags)?g:[]).join(", ")}\n`),m(e.versions.length?e.versions.map(fu).join(""):"No upload versions.\n"))}}finally{globalThis.console=u}}))}uu(e)}(Bh,{getAccessToken:Dh}),Bh.command("generate-material","Generate a PBR material from a text prompt").help("").argument("<prompt>","The text prompt describing the material to generate",{validator:Bh.STRING}).option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Bh.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Bh.STRING,hidden:!0}).option("--resolution <resolution>","The material texture resolution (256, 512, 1k, 2k, 4k)",{default:"512",required:!1,validator:Bh.STRING}).option("--name <name>","Output filename",{required:!1,validator:Bh.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:Bh.STRING}).action(su(nu("generate-material",async({args:e,options:t,logger:n})=>{var o,i,r;const a=ru(t),{accessToken:s,org_id:c}=await Dh(t.token,qh(t),!0!==t.nonInteractive),l=String(e.prompt),p=null==(o=t.resolution)?void 0:o.toString(),u=null==(i=t.outdir)?void 0:i.toString(),d=null==(r=t.name)?void 0:r.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 ${Sp()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";Mp(`[generate-material] Starting request to ${t}, prompt="${e.prompt}", resolution=${e.resolution||512}`,{emptyLineBefore:!0});const n=T("Requesting material generation...").start(),o=await Promise.race([Ql({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 Mp(`[generate-material] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(Mp(`[generate-material] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return Mp(`[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 r=T("Waiting for material generation...").start();r.color="gray";const a=kc();for(;;){if("completed"===i.status){r.succeed("Material generation completed");break}let n=2e3;const o=await jc(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=a.record(o);if(s)return r.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))r.text="Your material is queued - waiting for generation to start",r.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))r.text=`Generating material: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,r.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){Mp(`[generate-material] Job completed: ${i.identifier}`),r.succeed(`Material generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return Mp(`[generate-material] Job canceled: ${i.identifier}, error=${o.error}`),r.fail(`Material generation canceled: ${o.error||""}`),{error:o.error||"Material generation canceled"};if("failed"===(null==o?void 0:o.status))return Mp(`[generate-material] Job failed: ${i.identifier}, error=${o.error}`),r.fail(`Material generation failed: ${o.error||""}`),{error:o.error||"Material generation failed"}}await kl(n)}if(e.outDir){const n=await ku({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:s,org_id:c,prompt:l,resolution:p,outputName:d,outDir:u});"error"in m&&(m.error&&n.error(m.error),process.exit(1)),"json"===a?cu(m):!u&&"identifier"in m&&console.log(m.identifier),await lu(0)}))),Bh.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:Bh.STRING}).option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id",{required:!1,validator:Bh.STRING}).option("--org <org>","The organization name or id",{required:!1,validator:Bh.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:Bh.STRING}).option("--face-count <faceCount>","Target polygon count (40000-1500000). Leave unset to let the generator choose.",{required:!1,validator:Bh.NUMBER}).option("--name <name>","Output filename",{required:!1,validator:Bh.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:Bh.STRING}).action(su(nu("generate-3d",async({args:e,options:t,logger:n})=>{var o,i,r;const a=ru(t),s=null==(o=t.quality)?void 0:o.toString();if(void 0!==s&&"draft"!==s&&"standard"!==s)throw new Error("Quality must be draft or standard.");const c=null!=t.faceCount?Number(t.faceCount):void 0;if(void 0!==c&&(!Number.isInteger(c)||c<4e4||c>15e5))throw new Error("--face-count must be an integer from 40000 to 1500000.");const{accessToken:l,org_id:p}=await Dh(t.token,qh(t),!0!==t.nonInteractive),u=String(e.prompt),d=null==(i=t.outdir)?void 0:i.toString(),m=null==(r=t.name)?void 0:r.toString(),f=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 ${Sp()}`};if(!e.prompt||e.prompt.length<=0)return{error:"A prompt is required"};const t="https://cloud.needle.tools/api";Mp(`[generate-3d] Starting request to ${t}, prompt="${e.prompt}", quality=${e.quality||"draft"}`,{emptyLineBefore:!0});const n=T("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+ht.jobs.create,i={...gt(e),"content-type":"application/json"},r={type:"ai-3d-asset",triggered_by:e.trigger_type,parameters:{...t}},a=await fetch(o,{...vt,method:"POST",headers:i,body:JSON.stringify(r),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 a)return{error:"The 3D generation request was cancelled"};if("__failed"in a)return{error:a.__failed};if(!a.ok){const e=await a.text();return console.error(`Failed to request 3D asset generation (${a.status}): ${e}`),{error:e||`Request failed (${a.status})`}}const s=await a.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 Mp(`[generate-3d] Request failed: ${o.error}`),n.fail(o.error),{error:o.error};const i=o.job;if(Mp(`[generate-3d] Job created: ${i.identifier}, status=${i.status}`),"canceled"===i.status)return Mp(`[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 r=T("Waiting for the 3D model...").start();r.color="gray";const a=kc();for(;;){if("completed"===i.status){r.succeed("3D generation completed");break}let n=2e3;const o=await jc(i.identifier,{baseUrl:t,authToken:e.token,org:i.org}),s=a.record(o);if(s)return r.fail(s.reason),{error:s.reason};if("new"===(null==o?void 0:o.status)||"pending"===(null==o?void 0:o.status))r.text="Your model is queued - waiting for generation to start",r.color="yellow",n=2e3;else if("running"===(null==o?void 0:o.status))r.text=`Generating 3D model: ${o.progress?`${o.progress}%`:""} ${o.status_message?`— ${o.status_message}`:""}`,r.color="cyan",n=1e3;else{if("completed"===(null==o?void 0:o.status)){Mp(`[generate-3d] Job completed: ${i.identifier}`),r.succeed(`3D generation completed: ${o.status_message||""}`);break}if("canceled"===(null==o?void 0:o.status))return Mp(`[generate-3d] Job canceled: ${i.identifier}, error=${o.error}`),r.fail(`3D generation canceled: ${o.error||""}`),{error:o.error||"3D generation canceled"};if("failed"===(null==o?void 0:o.status))return Mp(`[generate-3d] Job failed: ${i.identifier}, error=${o.error}`),r.fail(`3D generation failed: ${o.error||""}`),{error:o.error||"3D generation failed"}}await kl(n)}if(e.outDir){const n=await ku({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:l,org_id:p,prompt:u,quality:s,face_count:c,outputName:m,outDir:d});"error"in f&&(f.error&&n.error(f.error),process.exit(1)),"json"===a?cu(f):!d&&"identifier"in f&&console.log(f.identifier),await lu(0)}))),Bh.command("ask","Send a message to the Needle Cloud AI").help("Send a message to Needle Cloud AI. By default, starts an interactive conversation, optionally with an initial message. Use --once to send one message and exit, or --non-interactive to also prohibit authentication prompts and browser launches. Both require a message. --output json returns one complete response and exits. --no-stream prints the full answer as text. Use --slug to continue a conversation.").argument("[message...]","The message to send (omit for interactive mode)").option("--token <token>",Fh,{validator:Bh.STRING}).option("--team <team>","The team name or id to authenticate for",{required:!1,validator:Bh.STRING}).option("--org <org>","Legacy alias for --team",{required:!1,validator:Bh.STRING,hidden:!0}).option("--slug <slug>","Chat slug to continue an existing conversation",{required:!1,validator:Bh.STRING}).option("--no-stream","Disable streaming (returns full response at once)",{required:!1,validator:Bh.BOOLEAN,default:!1}).option("--once","Send one message and exit",{validator:Bh.BOOLEAN,default:!1}).action(nu("ask",async({args:e,options:t})=>{var n,o;const i=ru(t),r=Array.isArray(e.message)?e.message:e.message?[e.message]:[],a=r.length?r.join(" "):void 0;if(!(!0!==t.nonInteractive&&!0!==t.once&&"json"!==i||null!=a&&a.trim()))throw new Error("A message is required for one-shot or non-interactive chat.");const{accessToken:s,org_id:c}=await Dh(t.token,qh(t),!0!==t.nonInteractive),l=(null==(n=t.slug)?void 0:n.toString())||void 0,p=(null==(o=t.noStream)?void 0:o.valueOf())||!1;await async function(e){const{token:t,org_id:n,message:o,slug:i,stream:r}=e,a=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);if(!0===e.nonInteractive||!0===e.once||"json"===e.output){if(null==o||!o.trim())throw new Error("A message is required for one-shot or non-interactive chat.");await au("json"===e.output,()=>Tu({token:t,org_id:n,slug:a,message:o,stream:"json"!==e.output&&r,output:e.output}))}else await async function(e){const{token:t,org_id:n,slug:o,stream:i,initialMessage:r}=e,a=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(r&&(console.log(`> ${r}`),await Tu({token:t,org_id:n,slug:o,message:r,stream:i}),console.log(""));;){const e=(await a.question("> ")).trim();if(e){if("exit"===e||"quit"===e)break;await Tu({token:t,org_id:n,slug:o,message:e,stream:i}),console.log("")}}}finally{a.close()}}({token:t,org_id:n,slug:a,stream:r,initialMessage:o})}({token:s,org_id:c,message:a,slug:l,stream:!p,nonInteractive:!0===t.nonInteractive,once:!0===t.once,output:"json"===i?"json":"cli"}),await lu(0)})),uu(Bh);export{Wd as g,Bh as p};
|