@cursor/sdk 1.0.21 → 1.0.23-beta.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/README.md +59 -0
- package/dist/cjs/162.js +1 -0
- package/dist/cjs/18.js +1 -1
- package/dist/cjs/181.js +1 -0
- package/dist/cjs/250.js +2 -0
- package/dist/cjs/250.js.LICENSE.txt +1 -0
- package/dist/cjs/284.js +1 -0
- package/dist/cjs/295.js +1 -0
- package/dist/cjs/361.js +1 -0
- package/dist/cjs/642.js +1 -1
- package/dist/cjs/690.js +1 -0
- package/dist/cjs/731.js +1 -0
- package/dist/cjs/745.js +8 -0
- package/dist/cjs/745.js.LICENSE.txt +30 -0
- package/dist/cjs/831.js +1 -0
- package/dist/cjs/856.js +1 -1
- package/dist/cjs/agent/backend-fetch.d.ts +9 -0
- package/dist/cjs/agent/backend-fetch.d.ts.map +1 -0
- package/dist/cjs/agent/options.d.ts +13 -0
- package/dist/cjs/agent/options.d.ts.map +1 -1
- package/dist/cjs/agent/run-event-notifier-api.d.ts.map +1 -1
- package/dist/cjs/agent/run-store-public-types.d.ts +5 -0
- package/dist/cjs/agent/run-store-public-types.d.ts.map +1 -1
- package/dist/cjs/agent/store/local-agent-record-conversion.d.ts.map +1 -1
- package/dist/cjs/agent/store/local-agent-store.d.ts +3 -0
- package/dist/cjs/agent/store/local-agent-store.d.ts.map +1 -1
- package/dist/cjs/agent/usage-types.d.ts +21 -0
- package/dist/cjs/agent/usage-types.d.ts.map +1 -0
- package/dist/cjs/agent.d.ts +11 -0
- package/dist/cjs/agent.d.ts.map +1 -1
- package/dist/cjs/analytics.d.ts +12 -5
- package/dist/cjs/analytics.d.ts.map +1 -1
- package/dist/cjs/backend-fetch.d.ts +9 -0
- package/dist/cjs/backend-fetch.d.ts.map +1 -0
- package/dist/cjs/cloud-agent.d.ts.map +1 -1
- package/dist/cjs/cloud-api-client.d.ts +7 -2
- package/dist/cjs/cloud-api-client.d.ts.map +1 -1
- package/dist/cjs/errors.d.ts +2 -0
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/executor-common.d.ts +6 -5
- package/dist/cjs/executor-common.d.ts.map +1 -1
- package/dist/cjs/executor-types.d.ts +2 -0
- package/dist/cjs/executor-types.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/local-executor.d.ts +1 -0
- package/dist/cjs/local-executor.d.ts.map +1 -1
- package/dist/cjs/messages.d.ts +9 -1
- package/dist/cjs/messages.d.ts.map +1 -1
- package/dist/cjs/options.d.ts +13 -0
- package/dist/cjs/options.d.ts.map +1 -1
- package/dist/cjs/platform.d.ts +5 -1
- package/dist/cjs/platform.d.ts.map +1 -1
- package/dist/cjs/public-api.d.ts +5 -4
- package/dist/cjs/public-api.d.ts.map +1 -1
- package/dist/cjs/run-event-notifier-api.d.ts.map +1 -1
- package/dist/cjs/run-interaction-accumulator.d.ts +4 -0
- package/dist/cjs/run-interaction-accumulator.d.ts.map +1 -1
- package/dist/cjs/run-store-public-types.d.ts +5 -0
- package/dist/cjs/run-store-public-types.d.ts.map +1 -1
- package/dist/cjs/run.d.ts +13 -0
- package/dist/cjs/run.d.ts.map +1 -1
- package/dist/cjs/sdk-statsig.d.ts +3 -1
- package/dist/cjs/sdk-statsig.d.ts.map +1 -1
- package/dist/cjs/sqlite.js +1 -1
- package/dist/cjs/store/atomic-write.d.ts +10 -0
- package/dist/cjs/store/atomic-write.d.ts.map +1 -0
- package/dist/cjs/store/jsonl-local-agent-store.d.ts.map +1 -1
- package/dist/cjs/store/local-agent-record-conversion.d.ts.map +1 -1
- package/dist/cjs/store/local-agent-store.d.ts +3 -0
- package/dist/cjs/store/local-agent-store.d.ts.map +1 -1
- package/dist/cjs/stubs.d.ts +1 -0
- package/dist/cjs/stubs.d.ts.map +1 -1
- package/dist/cjs/transport.d.ts +6 -0
- package/dist/cjs/transport.d.ts.map +1 -1
- package/dist/cjs/usage-types.d.ts +21 -0
- package/dist/cjs/usage-types.d.ts.map +1 -0
- package/dist/cjs/vendor/cursor-sdk-shared/core-adapter.test.d.ts +1 -0
- package/dist/cjs/vendor/cursor-sdk-shared/delta-types.d.ts +10 -0
- package/dist/esm/162.js +1 -0
- package/dist/esm/18.js +1 -1
- package/dist/esm/181.js +1 -0
- package/dist/esm/250.js +2 -0
- package/dist/esm/250.js.LICENSE.txt +1 -0
- package/dist/esm/284.js +1 -0
- package/dist/esm/295.js +1 -0
- package/dist/esm/357.js +1 -1
- package/dist/esm/642.js +1 -1
- package/dist/esm/690.js +1 -0
- package/dist/esm/731.js +1 -0
- package/dist/esm/745.js +8 -0
- package/dist/esm/745.js.LICENSE.txt +30 -0
- package/dist/esm/831.js +1 -0
- package/dist/esm/856.js +1 -1
- package/dist/esm/agent/backend-fetch.d.ts +9 -0
- package/dist/esm/agent/backend-fetch.d.ts.map +1 -0
- package/dist/esm/agent/options.d.ts +13 -0
- package/dist/esm/agent/options.d.ts.map +1 -1
- package/dist/esm/agent/run-event-notifier-api.d.ts.map +1 -1
- package/dist/esm/agent/run-store-public-types.d.ts +5 -0
- package/dist/esm/agent/run-store-public-types.d.ts.map +1 -1
- package/dist/esm/agent/store/local-agent-record-conversion.d.ts.map +1 -1
- package/dist/esm/agent/store/local-agent-store.d.ts +3 -0
- package/dist/esm/agent/store/local-agent-store.d.ts.map +1 -1
- package/dist/esm/agent/usage-types.d.ts +21 -0
- package/dist/esm/agent/usage-types.d.ts.map +1 -0
- package/dist/esm/agent.d.ts +11 -0
- package/dist/esm/agent.d.ts.map +1 -1
- package/dist/esm/analytics.d.ts +12 -5
- package/dist/esm/analytics.d.ts.map +1 -1
- package/dist/esm/backend-fetch.d.ts +9 -0
- package/dist/esm/backend-fetch.d.ts.map +1 -0
- package/dist/esm/cloud-agent.d.ts.map +1 -1
- package/dist/esm/cloud-api-client.d.ts +7 -2
- package/dist/esm/cloud-api-client.d.ts.map +1 -1
- package/dist/esm/errors.d.ts +2 -0
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/executor-common.d.ts +6 -5
- package/dist/esm/executor-common.d.ts.map +1 -1
- package/dist/esm/executor-types.d.ts +2 -0
- package/dist/esm/executor-types.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/local-executor.d.ts +1 -0
- package/dist/esm/local-executor.d.ts.map +1 -1
- package/dist/esm/messages.d.ts +9 -1
- package/dist/esm/messages.d.ts.map +1 -1
- package/dist/esm/options.d.ts +13 -0
- package/dist/esm/options.d.ts.map +1 -1
- package/dist/esm/platform.d.ts +5 -1
- package/dist/esm/platform.d.ts.map +1 -1
- package/dist/esm/public-api.d.ts +5 -4
- package/dist/esm/public-api.d.ts.map +1 -1
- package/dist/esm/run-event-notifier-api.d.ts.map +1 -1
- package/dist/esm/run-interaction-accumulator.d.ts +4 -0
- package/dist/esm/run-interaction-accumulator.d.ts.map +1 -1
- package/dist/esm/run-store-public-types.d.ts +5 -0
- package/dist/esm/run-store-public-types.d.ts.map +1 -1
- package/dist/esm/run.d.ts +13 -0
- package/dist/esm/run.d.ts.map +1 -1
- package/dist/esm/sdk-statsig.d.ts +3 -1
- package/dist/esm/sdk-statsig.d.ts.map +1 -1
- package/dist/esm/sqlite.js +1 -1
- package/dist/esm/store/atomic-write.d.ts +10 -0
- package/dist/esm/store/atomic-write.d.ts.map +1 -0
- package/dist/esm/store/jsonl-local-agent-store.d.ts.map +1 -1
- package/dist/esm/store/local-agent-record-conversion.d.ts.map +1 -1
- package/dist/esm/store/local-agent-store.d.ts +3 -0
- package/dist/esm/store/local-agent-store.d.ts.map +1 -1
- package/dist/esm/stubs.d.ts +1 -0
- package/dist/esm/stubs.d.ts.map +1 -1
- package/dist/esm/transport.d.ts +6 -0
- package/dist/esm/transport.d.ts.map +1 -1
- package/dist/esm/usage-types.d.ts +21 -0
- package/dist/esm/usage-types.d.ts.map +1 -0
- package/dist/esm/vendor/cursor-sdk-shared/core-adapter.test.d.ts +1 -0
- package/dist/esm/vendor/cursor-sdk-shared/delta-types.d.ts +10 -0
- package/package.json +7 -6
- package/dist/cjs/403.js +0 -8
- package/dist/cjs/403.js.LICENSE.txt +0 -285
- package/dist/cjs/88.js +0 -1
- package/dist/esm/403.js +0 -8
- package/dist/esm/403.js.LICENSE.txt +0 -285
package/dist/esm/642.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const __webpack_esm_id__=642;export const __webpack_esm_ids__=[642];export const __webpack_esm_modules__={"./src/agent/cloud-agent.ts"(t,e,i){i.d(e,{archiveCloudAgent:()=>K,cancelCloudRun:()=>x,createCloudAgent:()=>O,deleteCloudAgent:()=>q,getCloudAgent:()=>E,getCloudMe:()=>T,getCloudRun:()=>N,listCloudAgents:()=>k,listCloudModels:()=>U,listCloudRepositories:()=>L,listCloudRuns:()=>M,resumeCloudAgent:()=>A,unarchiveCloudAgent:()=>P,validateCloudModelAvailability:()=>j}),i.r(e);var n=i("../cursor-sdk-local-runtime/dist/run-store/index.js"),s=i("./src/agent/analytics.ts"),o=i("./src/agent/cloud-api-client.ts"),r=i("./src/agent/errors.ts");function a(t){if(void 0===t)return;const e=[];for(const[i,n]of Object.entries(t))if("command"in n){if(void 0!==n.cwd)throw new r.j1(`Cloud MCP server "${i}" cannot include cwd.`);e.push(Object.assign({name:i},n))}else e.push(Object.assign({name:i},n));return e.length>0?e:void 0}var d=i("./src/agent/run-interaction-accumulator.ts"),u=i("./src/agent/subagent-conversion.ts"),l=i("./src/agent/tool-call-utils.ts"),c=i("./src/agent/types/delta-types.ts"),h=function(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{d(n.next(t))}catch(t){o(t)}}function a(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}d((n=n.apply(t,e||[])).next())}))},v=function(t){return this instanceof v?(this.v=t,this):new v(t)};function f(t){if(""===t)throw new r.j1("API key is required for cloud operations. Caller passed an empty apiKey explicitly; refusing to fall back to CURSOR_API_KEY.",{isRetryable:!1,code:"unauthenticated"});const e=null!=t?t:process.env.CURSOR_API_KEY;if(!e)throw new r.j1("API key is required for cloud operations. Set CURSOR_API_KEY or pass apiKey.",{isRetryable:!1,code:"unauthenticated"});return e}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function g(t){if(!t.startsWith("bc-")||!m.test(t.slice(3)))throw new r.j1("Agent ID must be in the format 'bc-<uuid>'",{isRetryable:!1})}function p(t){if(!t.startsWith("run-")||!m.test(t.slice(4)))throw new r.j1("Run ID must be in the format 'run-<uuid>'",{isRetryable:!1})}function y(t){switch(t){case"CREATING":case"RUNNING":return"running";case"FINISHED":return"finished";case"CANCELLED":return"cancelled";default:return"error"}}function w(t){return"running"===t||"completed"===t||"error"===t}const b=new Set(["assistant","thinking","tool_call"]);class _{constructor(){this.queue=[],this.waiters=[],this.closed=!1}push(t){if(this.closed)return;const e=this.waiters.shift();if(!e)return this.queue.length>=8192?(this.overflow=new r.LF("Cloud agent message buffer overflow; consumer is too slow",{code:"stream_buffer_overflow",errorName:"CursorSdkError"}),void(this.closed=!0)):void this.queue.push(t);e({value:t,done:!1})}close(){var t;if(!this.closed)for(this.closed=!0;this.waiters.length>0;)null===(t=this.waiters.shift())||void 0===t||t({value:void 0,done:!0})}stream(){return function(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,s=i.apply(t,e||[]),o=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",(function(t){return function(e){return Promise.resolve(e).then(t,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function r(t,e){s[t]&&(n[t]=function(e){return new Promise((function(i,n){o.push([t,e,i,n])>1||a(t,e)}))},e&&(n[t]=e(n[t])))}function a(t,e){try{(i=s[t](e)).value instanceof v?Promise.resolve(i.value.v).then(d,u):l(o[0][2],i)}catch(t){l(o[0][3],t)}var i}function d(t){a("next",t)}function u(t){a("throw",t)}function l(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}(this,arguments,(function*(){for(;;){const t=this.queue.shift();if(t){yield yield v(t);continue}if(this.overflow)throw this.overflow;if(this.closed)return yield v(void 0);const e=yield v(new Promise((t=>{this.waiters.push(t)})));if(e.done)return yield v(void 0);yield yield v(e.value)}}))}}const I=new Set(["unauthorized","forbidden","not_found"]);function S(t,e){return h(this,void 0,void 0,(function*(){t<=0||(null==e?void 0:e.aborted)||(yield new Promise((i=>{const n=setTimeout((()=>{null==e||e.removeEventListener("abort",s),i()}),t),s=()=>{clearTimeout(n),i()};null==e||e.addEventListener("abort",s,{once:!0})})))}))}class R{constructor(t,e,i,n){this.client=t,this.buffer=new _,this.listeners=new Set,this.streamStarted=!1,this.emittedLegacyFrameIds=new Set,this.id=e.id,this.agentId=e.agentId,this.requestId=e.requestId,this._status=y(e.status),this.createdAt=Date.parse(e.createdAt);const s=(0,o.O)(e);this._result=s.result,this._durationMs=s.durationMs,this._git=s.git,this._model=n,this.sendOptions=i}get status(){return this._status}get result(){return this._result}get durationMs(){return this._durationMs}get git(){return this._git}get model(){return this._model}supports(t){return"stream"===t||"wait"===t||"cancel"===t||"conversation"===t}unsupportedReason(t){if(!this.supports(t))return`Unknown run operation "${t}"`}stream(){try{return this.ensureStreamStarted(),this.buffer.stream()}catch(t){throw(0,r.Nt)(t,{operation:"run.stream"})}}conversation(){return h(this,void 0,void 0,(function*(){var t,e;try{this.ensureStreamStarted();try{yield this.streamPromise}catch(t){}return null!==(e=null===(t=this.accumulator)||void 0===t?void 0:t.conversation())&&void 0!==e?e:[]}catch(t){throw(0,r.Nt)(t,{operation:"run.conversation"})}}))}wait(){return h(this,void 0,void 0,(function*(){try{if("running"!==this._status)return this.buildResult();this.ensureStreamStarted();try{yield this.streamPromise}catch(t){"running"===this._status&&this.setStatus("error")}return this.buildResult()}catch(t){throw(0,r.Nt)(t,{operation:"run.wait"})}}))}cancel(){return h(this,void 0,void 0,(function*(){var t;try{if("cancelled"===this._status)return;yield this.client.cancelRun({agentId:this.agentId,runId:this.id}),null===(t=this.abortController)||void 0===t||t.abort(),this.setStatus("cancelled")}catch(t){throw(0,r.Nt)(t,{operation:"run.cancel"})}}))}onDidChangeStatus(t){return this.listeners.add(t),()=>this.listeners.delete(t)}abortClientStream(){var t;null===(t=this.abortController)||void 0===t||t.abort()}disposeClientStream(){return h(this,void 0,void 0,(function*(){this.abortClientStream(),void 0!==this.streamPromise&&(yield function(t){return h(this,void 0,void 0,(function*(){let e;try{yield Promise.race([t.catch((()=>{})),new Promise((t=>{var i;e=setTimeout(t,2e3),null===(i=e.unref)||void 0===i||i.call(e)}))])}finally{void 0!==e&&clearTimeout(e)}}))}(this.streamPromise))}))}ensureStreamStarted(){var t,e;if(this.streamStarted)return;this.streamStarted=!0,this.abortController=new AbortController;const i=new d.e4({onDelta:null===(t=this.sendOptions)||void 0===t?void 0:t.onDelta,onStep:null===(e=this.sendOptions)||void 0===e?void 0:e.onStep});this.accumulator=i,this.streamPromise=this.runStreamLoop(i,this.abortController.signal),this.streamPromise.catch((()=>{}))}runStreamLoop(t,e){return h(this,void 0,void 0,(function*(){let i=0;const n=Date.now()+72e5;try{do{const o=yield this.runOneStreamAttempt(t,e);if(e.aborted)break;if("received-result"===o)break;if(yield this.refetchAndSync(),e.aborted||"running"!==this._status)break;if(Date.now()>=n)break;if(i>=6){yield this.pollRunUntilTerminal(e,n);break}const r=Math.min((s=i,Math.min(3e4,1e3*Math.pow(2,s))),Math.max(0,n-Date.now()));i++,yield S(r,e)}while("running"===this._status&&!e.aborted);"running"===this._status&&Date.now()>=n&&this.setStatus("error"),"finished"===this._status&&(yield t.flushPendingStep())}finally{this.buffer.close()}var s}))}runOneStreamAttempt(t,e){return h(this,void 0,void 0,(function*(){const i=this.lastEventId;let n=!1;try{const i=yield this.client.streamRun(Object.assign({agentId:this.agentId,runId:this.id,signal:e},void 0!==this.lastEventId?{lastEventId:this.lastEventId}:{}));yield function(t,e,i,n,s){return h(this,void 0,void 0,(function*(){var a,d,u,h,v,f,m,g;const p=t.body.getReader(),_=new TextDecoder;let S="";try{for(;;){if(null==s?void 0:s.aborted)return;const{value:t,done:R}=yield p.read();if(R)break;S+=_.decode(t,{stream:!0});let C=S.indexOf("\n\n");for(;-1!==C;){const t=S.slice(0,C);S=S.slice(C+2),C=S.indexOf("\n\n");const s=t.split("\n");let _,R;const O=[];for(const t of s)t.startsWith("id: ")?R=t.slice(4).trim():t.startsWith("event: ")?_=t.slice(7).trim():t.startsWith("data: ")&&O.push(t.slice(6));if(void 0!==R&&R.length>0&&(void 0===_||!b.has(_))&&(null===(a=n.onEventId)||void 0===a||a.call(n,R)),"done"===_)return void(yield p.cancel());if(0===O.length)continue;const j=O.join("\n");let A;try{A=JSON.parse(j)}catch(t){throw new r.Dr(`Malformed SSE event: ${j}`,{isRetryable:!0})}if(_&&(!b.has(_)||void 0===R||!1!==(null===(d=n.shouldEmitLegacyFrame)||void 0===d?void 0:d.call(n,R))))switch(_){case"assistant":{const t=(0,l.u)(A)?A:{};n.onMessage({type:"assistant",agent_id:e,run_id:i,message:{role:"assistant",content:[{type:"text",text:null!==(u=t.text)&&void 0!==u?u:""}]}});break}case"thinking":{const t=(0,l.u)(A)?A:{};n.onMessage({type:"thinking",agent_id:e,run_id:i,text:null!==(h=t.text)&&void 0!==h?h:""});break}case"tool_call":{const t=(0,l.u)(A)?A:{},s=(0,l.u)(t.data)?t.data:t,o=w(s.status)?s.status:"running",r="string"==typeof s.callId?s.callId:"",a="string"==typeof s.name?s.name:"unknown";n.onMessage(Object.assign(Object.assign(Object.assign({type:"tool_call",agent_id:e,run_id:i,call_id:r,name:a,status:o},"args"in s?{args:s.args}:{}),"result"in s?{result:s.result}:{}),(0,l.D)(s.truncated)?{truncated:s.truncated}:{}));break}case"interaction_update":{if(void 0===n.onInteractionUpdate)break;const t=c.Zs.safeParse(A);if(!t.success)break;yield n.onInteractionUpdate(t.data);break}case"status":{const t=((0,l.u)(A)?A:{}).status;t&&(null===(v=n.onStatusChange)||void 0===v||v.call(n,y(t)),n.onMessage({type:"status",agent_id:e,run_id:i,status:t}));break}case"result":if((0,l.u)(A)){const t=A,e=Object.assign(Object.assign({},t),"string"==typeof t.text&&void 0===t.result?{result:t.text}:{});null===(f=n.onResult)||void 0===f||f.call(n,(0,o.O)(e))}return void(yield p.cancel());case"heartbeat":break;case"error":{const t=(0,l.u)(A)?A:{},e=null!==(m=t.code)&&void 0!==m?m:"UNKNOWN",i=null!==(g=t.message)&&void 0!==g?g:"Unknown error";if(I.has(e))throw new r.j1(`[${e}] ${i}`,{code:e,isRetryable:!1});throw new r.c$(`[${e}] ${i}`,{code:e,isRetryable:!1})}}}}}catch(t){if((null==s?void 0:s.aborted)||"object"==typeof t&&null!==t&&"name"in t&&"AbortError"===t.name)return;throw t}finally{try{yield p.cancel()}catch(t){}}}))}(i,this.agentId,this.id,{onMessage:t=>this.buffer.push(t),onResult:t=>{var e;this._result=t.result,this._durationMs=t.durationMs,this._git=t.git,this.setStatus(y(null!==(e=t.status)&&void 0!==e?e:"FINISHED")),n=!0},onStatusChange:t=>{"running"===t&&this.setStatus(t)},onInteractionUpdate:e=>t.apply(e),onEventId:t=>{this.lastEventId=t,this.emittedLegacyFrameIds.clear()},shouldEmitLegacyFrame:t=>!this.emittedLegacyFrameIds.has(t)&&(this.emittedLegacyFrameIds.add(t),!0)},e)}catch(t){if(function(t){return t instanceof Error&&t.message.startsWith("[invalid_last_event_id]")}(t))this.lastEventId===i&&(this.lastEventId=void 0);else if(function(t){if(t instanceof r.v3||t instanceof r.j1)return!0;if(t instanceof Error){const e=/^\[([a-z_]+)\]/.exec(t.message);if(null!==e&&I.has(e[1]))return!0}return!1}(t))throw"running"===this._status&&this.setStatus("error"),t}return n?"received-result":"stream-dropped"}))}pollRunUntilTerminal(t,e){return h(this,void 0,void 0,(function*(){for(;"running"===this._status&&!t.aborted;){const i=e-Date.now();if(i<=0)return void this.setStatus("error");if(yield S(Math.min(15e3,i),t),t.aborted)return;yield this.refetchAndSync()}}))}setStatus(t){if(this._status!==t){this._status=t;for(const e of this.listeners)e(t)}}refetchAndSync(){return h(this,void 0,void 0,(function*(){let t;try{t=yield this.client.getRun({agentId:this.agentId,runId:this.id})}catch(t){if(t instanceof r.v3||t instanceof r.j1)throw"running"===this._status&&this.setStatus("error"),t;return}const e=(0,o.O)(t);void 0!==e.result&&(this._result=e.result),void 0!==e.durationMs&&(this._durationMs=e.durationMs),void 0!==e.git&&(this._git=e.git),"running"===this._status&&this.setStatus(y(t.status))}))}buildResult(){const t="running"===this._status?"error":this._status;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({id:this.id},void 0!==this.requestId?{requestId:this.requestId}:{}),{status:t}),void 0!==this._result?{result:this._result}:{}),void 0!==this._model?{model:this._model}:{}),void 0!==this._durationMs?{durationMs:this._durationMs}:{}),void 0!==this._git?{git:this._git}:{})}}class C{constructor(t,e,i,n){this.client=e,this.options=i,this.activeRuns=new Set,this.agentId=t,this.serverCreated=n,this._model=i.model}get model(){return this._model}send(t,e){return h(this,void 0,void 0,(function*(){var i,n,o,d,l,c,h,v,f,m,g,p,y,w,b,_,I,S,C,O;try{if(void 0!==(null===(i=null==e?void 0:e.local)||void 0===i?void 0:i.customTools))throw new r.j1("Custom local tools are only supported for local SDK agents. Create the agent with getLocalPlatformOptions() or omit local.customTools.",{isRetryable:!1});const j=function(t){var e;return"string"==typeof t?{text:t}:{text:t.text,images:null===(e=t.images)||void 0===e?void 0:e.map((t=>"url"in t?{url:t.url,dimension:t.dimension}:{data:t.data,mimeType:t.mimeType,dimension:t.dimension}))}}(t),A=!this.serverCreated,k=null!==(n=null==e?void 0:e.mcpServers)&&void 0!==n?n:this.options.mcpServers,M=null!==(o=null==e?void 0:e.model)&&void 0!==o?o:this._model,N=void 0!==(null==e?void 0:e.mode)?e.mode:A?this.options.mode:void 0,x=void 0!==(null==e?void 0:e.onStep)||void 0!==(null==e?void 0:e.onDelta)?Object.assign(Object.assign({},void 0!==e.onStep?{onStep:e.onStep}:{}),void 0!==e.onDelta?{onDelta:e.onDelta}:{}):void 0;let D;if(A){const t=(0,u.SB)(this.options.agents),i=void 0!==(null===(d=this.options.cloud)||void 0===d?void 0:d.envVars),n=yield this.client.createAgent(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},i?{}:{agentId:this.agentId}),{prompt:j}),void 0!==M?{model:M}:{}),void 0!==this.options.name?{name:this.options.name}:{}),{mcpServers:a(k)}),void 0!==t?{customSubagents:t}:{}),{env:null===(l=this.options.cloud)||void 0===l?void 0:l.env,envVars:null===(c=this.options.cloud)||void 0===c?void 0:c.envVars,repos:null===(h=this.options.cloud)||void 0===h?void 0:h.repos,workOnCurrentBranch:null===(v=this.options.cloud)||void 0===v?void 0:v.workOnCurrentBranch,autoCreatePR:null===(f=this.options.cloud)||void 0===f?void 0:f.autoCreatePR,skipReviewerRequest:null===(m=this.options.cloud)||void 0===m?void 0:m.skipReviewerRequest}),void 0!==N?{mode:N}:{}),{idempotencyKey:null!==(g=null==e?void 0:e.idempotencyKey)&&void 0!==g?g:this.options.idempotencyKey});if(i)this.agentId=n.agent.id;else if(n.agent.id!==this.agentId)throw new r.c$(`Server returned mismatched agent id "${n.agent.id}"; expected "${this.agentId}". This indicates a backend bug.`,{isRetryable:!1});this.serverCreated=!0,D=new R(this.client,n.run,x,M)}else{const t=yield this.client.createRun(this.agentId,Object.assign(Object.assign({prompt:j,mcpServers:a(k)},void 0!==(null==e?void 0:e.model)?{model:e.model}:{}),void 0!==N?{mode:N}:{}),{idempotencyKey:null==e?void 0:e.idempotencyKey});D=new R(this.client,t.run,x,M)}void 0!==(null==e?void 0:e.model)&&(this._model=e.model);const E=null!==(w=null===(y=null===(p=this.options.cloud)||void 0===p?void 0:p.env)||void 0===y?void 0:y.type)&&void 0!==w?w:"cloud",K=null==M?void 0:M.params;(0,s.Zn)(this.options.apiKey,Object.assign(Object.assign({agent_id:this.agentId,run_id:D.id,request_id:D.requestId,runtime:E,model:null!==(b=null==M?void 0:M.id)&&void 0!==b?b:"default"},K&&K.length>0?{model_params:JSON.stringify(K)}:{}),{prompt_length:j.text.length,has_images:(null!==(I=null===(_=j.images)||void 0===_?void 0:_.length)&&void 0!==I?I:0)>0,is_resume:!A,mcp_server_count:Object.keys(null!=k?k:{}).length,cloud_repo_count:null===(C=null===(S=this.options.cloud)||void 0===S?void 0:S.repos)||void 0===C?void 0:C.length,cloud_auto_create_pr:null===(O=this.options.cloud)||void 0===O?void 0:O.autoCreatePR})),this.activeRuns.add(D);const P=this.options.apiKey,q=this.agentId,T=D.id;return D.wait().then((t=>{(0,s.G5)(P,{agent_id:q,run_id:T,request_id:D.requestId,runtime:E,end_reason:"finished"===t.status?"success":"cancelled"===t.status?"abort":"error"})})).finally((()=>{this.activeRuns.delete(D)})),D.ensureStreamStarted(),D}catch(t){throw(0,r.Nt)(t,{operation:"agent.send"})}}))}close(){for(const t of this.activeRuns)t.abortClientStream();(0,s.rd)()}reload(){return h(this,void 0,void 0,(function*(){}))}[Symbol.asyncDispose](){return h(this,void 0,void 0,(function*(){yield Promise.allSettled(Array.from(this.activeRuns,(t=>t.disposeClientStream()))),yield(0,s.rd)()}))}listArtifacts(){return h(this,void 0,void 0,(function*(){try{return this.serverCreated?(yield this.client.listArtifacts(this.agentId)).items.map((t=>({path:t.path,sizeBytes:t.sizeBytes,updatedAt:t.updatedAt}))):[]}catch(t){throw(0,r.Nt)(t,{operation:"agent.listArtifacts"})}}))}downloadArtifact(t){return h(this,void 0,void 0,(function*(){try{if(!this.serverCreated)throw new r.j1("Agent has not been created yet; call send() first.",{isRetryable:!1});const{url:e}=yield this.client.getArtifactDownloadUrl({agentId:this.agentId,path:t});let i;try{i=yield fetch(e)}catch(t){throw new r.Dr("Failed to download artifact",{cause:t,isRetryable:!0})}if(!i.ok)throw new r.Dr(`Failed to download artifact: ${i.status}`,{status:i.status,isRetryable:i.status>=500});return Buffer.from(yield i.arrayBuffer())}catch(t){throw(0,r.Nt)(t,{operation:"agent.downloadArtifact"})}}))}}function O(t){var e,i;const s=f(t.apiKey);if(void 0!==t.agentId&&void 0!==(null===(e=t.cloud)||void 0===e?void 0:e.envVars))throw new r.j1("cloud.envVars cannot be combined with agentId; omit agentId so the server can mint an agent id.",{isRetryable:!1});const a=new o.N(s),d=null!==(i=t.agentId)&&void 0!==i?i:(0,n.M2)();return new C(d,a,t,!1)}function j(t){return h(this,arguments,void 0,(function*({apiKey:t,model:e}){const i="string"==typeof e?e.trim():e.id.trim();if(0===i.length)throw new r.j1("Model id is required. Pass a non-empty `model.id` or `model: '<model-id>'`.",{isRetryable:!1,code:"invalid_model"});let n,s;try{n=f(t)}catch(t){if(t instanceof r.j1)return;throw t}try{s=(yield new o.N(n).listModels()).items}catch(t){if(t instanceof r.Dr||t instanceof r.v3||t instanceof r.OE)return;throw t}const a=s.some((t=>{var e;return t.id===i||!0===(null===(e=t.aliases)||void 0===e?void 0:e.includes(i))}));if(!a)throw new r.j1(`Model '${i}' is not available or invalid. Call Cursor.models.list() to see valid model ids.`,{isRetryable:!1,code:"invalid_model"})}))}function A(t,e){const i=f(e.apiKey),n=new o.N(i);return new C(t,n,Object.assign({},e),!0)}function k(t){return h(this,void 0,void 0,(function*(){const e=f(t.apiKey),i=new o.N(e),n=yield i.listAgents({limit:t.limit,cursor:t.cursor,prUrl:t.prUrl,includeArchived:t.includeArchived});return{items:n.items.map(D),nextCursor:n.nextCursor}}))}function M(t,e){return h(this,void 0,void 0,(function*(){const i=f(e.apiKey),n=new o.N(i),s=yield n.listRuns(t,{limit:e.limit,cursor:e.cursor});return{items:s.items.map((t=>new R(n,t))),nextCursor:s.nextCursor}}))}function N(t,e){return h(this,void 0,void 0,(function*(){p(t),g(e.agentId);const i=f(e.apiKey),n=new o.N(i),s=yield n.getRun({agentId:e.agentId,runId:t});return new R(n,s)}))}function x(t,e){return h(this,void 0,void 0,(function*(){p(t),g(e.agentId);const i=f(e.apiKey),n=new o.N(i);yield n.cancelRun({agentId:e.agentId,runId:t})}))}function D(t){var e,i,n;return{agentId:t.id,name:null!==(e=t.name)&&void 0!==e?e:"",summary:null!==(i=t.name)&&void 0!==i?i:"",lastModified:new Date(t.updatedAt).getTime(),createdAt:new Date(t.createdAt).getTime(),archived:"ARCHIVED"===t.status,runtime:"cloud",env:t.env,repos:null===(n=t.repos)||void 0===n?void 0:n.map((t=>t.url))}}function E(t,e){return h(this,void 0,void 0,(function*(){const i=f(e.apiKey),n=new o.N(i);return D(yield n.getAgent(t))}))}function K(t,e){return h(this,void 0,void 0,(function*(){const i=f(e.apiKey),n=new o.N(i);yield n.archiveAgent(t)}))}function P(t,e){return h(this,void 0,void 0,(function*(){const i=f(e.apiKey),n=new o.N(i);yield n.unarchiveAgent(t)}))}function q(t,e){return h(this,void 0,void 0,(function*(){const i=f(e.apiKey),n=new o.N(i);yield n.deleteAgent(t)}))}function T(t){return h(this,void 0,void 0,(function*(){const e=f(t.apiKey);return new o.N(e).getMe()}))}function U(t){return h(this,void 0,void 0,(function*(){const e=f(t.apiKey),i=new o.N(e);return(yield i.listModels()).items}))}function L(t){return h(this,void 0,void 0,(function*(){const e=f(t.apiKey),i=new o.N(e);return(yield i.listRepositories()).items}))}}};
|
|
1
|
+
export const __webpack_esm_id__=642;export const __webpack_esm_ids__=[642];export const __webpack_esm_modules__={"./src/agent/cloud-agent.ts"(t,e,i){i.d(e,{archiveCloudAgent:()=>U,cancelCloudRun:()=>x,createCloudAgent:()=>A,deleteCloudAgent:()=>T,getCloudAgent:()=>P,getCloudMe:()=>$,getCloudRun:()=>N,listCloudAgents:()=>E,listCloudModels:()=>L,listCloudRepositories:()=>F,listCloudRuns:()=>M,resumeCloudAgent:()=>D,unarchiveCloudAgent:()=>q,validateCloudModelAvailability:()=>k}),i.r(e);var n=i("../cursor-sdk-local-runtime/dist/run-store/index.js"),s=i("./src/agent/analytics.ts"),r=i("./src/agent/cloud-api-client.ts"),o=i("./src/agent/errors.ts");function a(t){if(void 0===t)return;const e=[];for(const[i,n]of Object.entries(t))if("command"in n){if(void 0!==n.cwd)throw new o.j1(`Cloud MCP server "${i}" cannot include cwd.`);e.push(Object.assign({name:i},n))}else e.push(Object.assign({name:i},n));return e.length>0?e:void 0}var d=i("./src/agent/run-interaction-accumulator.ts"),u=i("./src/agent/subagent-conversion.ts"),l=i("./src/agent/tool-call-utils.ts"),c=i("./src/agent/types/delta-types.ts"),h=i("./src/agent/usage-types.ts"),v=function(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{d(n.next(t))}catch(t){r(t)}}function a(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}d((n=n.apply(t,e||[])).next())}))},f=function(t){return this instanceof f?(this.v=t,this):new f(t)};function g(t){if(""===t)throw new o.j1("API key is required for cloud operations. Caller passed an empty apiKey explicitly; refusing to fall back to CURSOR_API_KEY.",{isRetryable:!1,code:"unauthenticated"});const e=null!=t?t:process.env.CURSOR_API_KEY;if(!e)throw new o.j1("API key is required for cloud operations. Set CURSOR_API_KEY or pass apiKey.",{isRetryable:!1,code:"unauthenticated"});return e}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function p(t){if(!t.startsWith("bc-")||!m.test(t.slice(3)))throw new o.j1("Agent ID must be in the format 'bc-<uuid>'",{isRetryable:!1})}function y(t){if(!t.startsWith("run-")||!m.test(t.slice(4)))throw new o.j1("Run ID must be in the format 'run-<uuid>'",{isRetryable:!1})}function w(t){switch(t){case"CREATING":case"RUNNING":return"running";case"FINISHED":return"finished";case"CANCELLED":return"cancelled";default:return"error"}}function b(t){return"running"===t||"completed"===t||"error"===t}const _=new Set(["assistant","thinking","tool_call"]);class I{constructor(){this.queue=[],this.waiters=[],this.closed=!1}push(t){if(this.closed)return;const e=this.waiters.shift();if(!e)return this.queue.length>=8192?(this.overflow=new o.LF("Cloud agent message buffer overflow; consumer is too slow",{code:"stream_buffer_overflow",errorName:"CursorSdkError"}),void(this.closed=!0)):void this.queue.push(t);e({value:t,done:!1})}close(){var t;if(!this.closed)for(this.closed=!0;this.waiters.length>0;)null===(t=this.waiters.shift())||void 0===t||t({value:void 0,done:!0})}stream(){return function(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,s=i.apply(t,e||[]),r=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(t){return function(e){return Promise.resolve(e).then(t,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function o(t,e){s[t]&&(n[t]=function(e){return new Promise((function(i,n){r.push([t,e,i,n])>1||a(t,e)}))},e&&(n[t]=e(n[t])))}function a(t,e){try{(i=s[t](e)).value instanceof f?Promise.resolve(i.value.v).then(d,u):l(r[0][2],i)}catch(t){l(r[0][3],t)}var i}function d(t){a("next",t)}function u(t){a("throw",t)}function l(t,e){t(e),r.shift(),r.length&&a(r[0][0],r[0][1])}}(this,arguments,(function*(){for(;;){const t=this.queue.shift();if(t){yield yield f(t);continue}if(this.overflow)throw this.overflow;if(this.closed)return yield f(void 0);const e=yield f(new Promise((t=>{this.waiters.push(t)})));if(e.done)return yield f(void 0);yield yield f(e.value)}}))}}const S=new Set(["unauthorized","forbidden","not_found"]);function O(t,e){return v(this,void 0,void 0,(function*(){t<=0||(null==e?void 0:e.aborted)||(yield new Promise((i=>{const n=setTimeout((()=>{null==e||e.removeEventListener("abort",s),i()}),t),s=()=>{clearTimeout(n),i()};null==e||e.addEventListener("abort",s,{once:!0})})))}))}class R{constructor(t,e,i,n){this.client=t,this.buffer=new I,this.listeners=new Set,this.streamStarted=!1,this.emittedLegacyFrameIds=new Set,this.appliedInteractionUpdates=new Set,this.id=e.id,this.agentId=e.agentId,this.requestId=e.requestId,this._status=w(e.status),this.createdAt=Date.parse(e.createdAt);const s=(0,r.O)(e);this._result=s.result,this._error="error"===this._status?s.error:void 0,this._durationMs=s.durationMs,this._git=s.git,this._model=n,this.sendOptions=i}get status(){return this._status}get result(){return this._result}get error(){return"error"===this._status?this._error:void 0}get usage(){return this._usage}get durationMs(){return this._durationMs}get git(){return this._git}get model(){return this._model}supports(t){return"stream"===t||"wait"===t||"cancel"===t||"conversation"===t}unsupportedReason(t){if(!this.supports(t))return`Unknown run operation "${t}"`}stream(){try{return this.ensureStreamStarted(),this.buffer.stream()}catch(t){throw(0,o.Nt)(t,{operation:"run.stream"})}}conversation(){return v(this,void 0,void 0,(function*(){var t,e;try{this.ensureStreamStarted();try{yield this.streamPromise}catch(t){}return null!==(e=null===(t=this.accumulator)||void 0===t?void 0:t.conversation())&&void 0!==e?e:[]}catch(t){throw(0,o.Nt)(t,{operation:"run.conversation"})}}))}wait(){return v(this,void 0,void 0,(function*(){try{if("running"!==this._status)return this.buildResult();this.ensureStreamStarted();try{yield this.streamPromise}catch(t){"running"===this._status&&(this._error=(0,o.D7)(t),this.setStatus("error"))}return this.buildResult()}catch(t){throw(0,o.Nt)(t,{operation:"run.wait"})}}))}cancel(){return v(this,void 0,void 0,(function*(){var t;try{if("cancelled"===this._status)return;yield this.client.cancelRun({agentId:this.agentId,runId:this.id}),null===(t=this.abortController)||void 0===t||t.abort(),this.setStatus("cancelled")}catch(t){throw(0,o.Nt)(t,{operation:"run.cancel"})}}))}onDidChangeStatus(t){return this.listeners.add(t),()=>this.listeners.delete(t)}abortClientStream(){var t;null===(t=this.abortController)||void 0===t||t.abort()}disposeClientStream(){return v(this,void 0,void 0,(function*(){this.abortClientStream(),void 0!==this.streamPromise&&(yield function(t){return v(this,void 0,void 0,(function*(){let e;try{yield Promise.race([t.catch((()=>{})),new Promise((t=>{var i;e=setTimeout(t,2e3),null===(i=e.unref)||void 0===i||i.call(e)}))])}finally{void 0!==e&&clearTimeout(e)}}))}(this.streamPromise))}))}ensureStreamStarted(){var t,e;if(this.streamStarted)return;this.streamStarted=!0,this.abortController=new AbortController;const i=new d.e4({onDelta:null===(t=this.sendOptions)||void 0===t?void 0:t.onDelta,onStep:null===(e=this.sendOptions)||void 0===e?void 0:e.onStep});this.accumulator=i,this.streamPromise=this.runStreamLoop(i,this.abortController.signal),this.streamPromise.catch((()=>{}))}runStreamLoop(t,e){return v(this,void 0,void 0,(function*(){let i=0;const n=Date.now()+72e5;try{do{const r=yield this.runOneStreamAttempt(t,e);if(e.aborted)break;if("received-result"===r)break;if(yield this.refetchAndSync(),e.aborted||"running"!==this._status)break;if(Date.now()>=n)break;if(i>=6){yield this.pollRunUntilTerminal(e,n);break}const o=Math.min((s=i,Math.min(3e4,1e3*Math.pow(2,s))),Math.max(0,n-Date.now()));i++,yield O(o,e)}while("running"===this._status&&!e.aborted);"running"===this._status&&Date.now()>=n&&this.setWaitDeadlineError(),yield t.flushPendingStep()}finally{this.buffer.close()}var s}))}applyInteractionUpdate(t,e){return v(this,void 0,void 0,(function*(){var i;if(yield t.apply(e),this._usage=null!==(i=t.usage())&&void 0!==i?i:this._usage,"turn-ended"!==e.type)return;const n=(0,h.q)(e.usage);n&&this.buffer.push({type:"usage",agent_id:this.agentId,run_id:this.id,usage:n})}))}runOneStreamAttempt(t,e){return v(this,void 0,void 0,(function*(){const i=this.lastEventId;let n=!1;try{const i=yield this.client.streamRun(Object.assign({agentId:this.agentId,runId:this.id,signal:e},void 0!==this.lastEventId?{lastEventId:this.lastEventId}:{}));yield function(t,e,i,n,s){return v(this,void 0,void 0,(function*(){var a,d,u,h,v,f,g,m,p;const y=t.body.getReader(),I=new TextDecoder;let O="";try{for(;;){if(null==s?void 0:s.aborted)return;const{value:t,done:R}=yield y.read();if(R)break;O+=I.decode(t,{stream:!0});let j=O.indexOf("\n\n");for(;-1!==j;){const t=O.slice(0,j);O=O.slice(j+2),j=O.indexOf("\n\n");const s=t.split("\n");let I,R;const C=[];for(const t of s)t.startsWith("id: ")?R=t.slice(4).trim():t.startsWith("event: ")?I=t.slice(7).trim():t.startsWith("data: ")&&C.push(t.slice(6));if(void 0!==R&&R.length>0&&(void 0===I||!_.has(I))&&(null===(a=n.onEventId)||void 0===a||a.call(n,R)),"done"===I)return void(yield y.cancel());if(0===C.length)continue;const A=C.join("\n");let k;try{k=JSON.parse(A)}catch(t){throw new o.Dr(`Malformed SSE event: ${A}`,{isRetryable:!0})}if(I&&(!_.has(I)||void 0===R||!1!==(null===(d=n.shouldEmitLegacyFrame)||void 0===d?void 0:d.call(n,R))))switch(I){case"assistant":{const t=(0,l.u)(k)?k:{};n.onMessage({type:"assistant",agent_id:e,run_id:i,message:{role:"assistant",content:[{type:"text",text:null!==(u=t.text)&&void 0!==u?u:""}]}});break}case"thinking":{const t=(0,l.u)(k)?k:{};n.onMessage({type:"thinking",agent_id:e,run_id:i,text:null!==(h=t.text)&&void 0!==h?h:""});break}case"tool_call":{const t=(0,l.u)(k)?k:{},s=(0,l.u)(t.data)?t.data:t,r=b(s.status)?s.status:"running",o="string"==typeof s.callId?s.callId:"",a="string"==typeof s.name?s.name:"unknown";n.onMessage(Object.assign(Object.assign(Object.assign({type:"tool_call",agent_id:e,run_id:i,call_id:o,name:a,status:r},"args"in s?{args:s.args}:{}),"result"in s?{result:s.result}:{}),(0,l.D)(s.truncated)?{truncated:s.truncated}:{}));break}case"interaction_update":{if(void 0===n.onInteractionUpdate)break;if(!1===(null===(v=n.shouldApplyInteractionUpdate)||void 0===v?void 0:v.call(n,R,A)))break;const t=c.Zs.safeParse(k);if(!t.success)break;yield n.onInteractionUpdate(t.data);break}case"status":{const t=((0,l.u)(k)?k:{}).status;t&&(null===(f=n.onStatusChange)||void 0===f||f.call(n,w(t)),n.onMessage({type:"status",agent_id:e,run_id:i,status:t}));break}case"result":if((0,l.u)(k)){const t=k,e=Object.assign(Object.assign({},t),"string"==typeof t.text&&void 0===t.result?{result:t.text}:{});null===(g=n.onResult)||void 0===g||g.call(n,(0,r.O)(e))}return void(yield y.cancel());case"heartbeat":break;case"error":{const t=(0,l.u)(k)?k:{},e=null!==(m=t.code)&&void 0!==m?m:"UNKNOWN",i=null!==(p=t.message)&&void 0!==p?p:"Unknown error";if(S.has(e))throw new o.j1(`[${e}] ${i}`,{code:e,isRetryable:!1});throw new o.c$(`[${e}] ${i}`,{code:e,isRetryable:!1})}}}}}catch(t){if((null==s?void 0:s.aborted)||"object"==typeof t&&null!==t&&"name"in t&&"AbortError"===t.name)return;throw t}finally{try{yield y.cancel()}catch(t){}}}))}(i,this.agentId,this.id,{onMessage:t=>this.buffer.push(t),onResult:t=>{var e,i;this._result=t.result;const s=w(null!==(e=t.status)&&void 0!==e?e:"FINISHED");this._error="error"===s?null!==(i=t.error)&&void 0!==i?i:this._error:void 0,this._durationMs=t.durationMs,this._git=t.git,this.setStatus(s),n=!0},onStatusChange:t=>{"running"===t&&this.setStatus(t)},onInteractionUpdate:e=>this.applyInteractionUpdate(t,e),onEventId:t=>{this.lastEventId=t,this.emittedLegacyFrameIds.clear()},shouldEmitLegacyFrame:t=>!this.emittedLegacyFrameIds.has(t)&&(this.emittedLegacyFrameIds.add(t),!0),shouldApplyInteractionUpdate:(t,e)=>{var i;const n=void 0!==t&&t.length>0?t:`${null!==(i=this.lastEventId)&&void 0!==i?i:""}\0${e}`;return!this.appliedInteractionUpdates.has(n)&&(this.appliedInteractionUpdates.add(n),!0)}},e)}catch(t){if(function(t){return t instanceof Error&&t.message.startsWith("[invalid_last_event_id]")}(t))this.lastEventId===i&&(this.lastEventId=void 0);else if(function(t){if(t instanceof o.v3||t instanceof o.j1)return!0;if(t instanceof Error){const e=/^\[([a-z_]+)\]/.exec(t.message);if(null!==e&&S.has(e[1]))return!0}return!1}(t))throw"running"===this._status&&(this._error=(0,o.D7)(t),this.setStatus("error")),t}return n?"received-result":"stream-dropped"}))}pollRunUntilTerminal(t,e){return v(this,void 0,void 0,(function*(){for(;"running"===this._status&&!t.aborted;){const i=e-Date.now();if(i<=0)return void this.setWaitDeadlineError();if(yield O(Math.min(15e3,i),t),t.aborted)return;yield this.refetchAndSync()}}))}setWaitDeadlineError(){this._error={message:"Timed out waiting for the cloud run to finish."},this.setStatus("error")}setStatus(t){if(this._status!==t){this._status=t;for(const e of this.listeners)e(t)}}refetchAndSync(){return v(this,void 0,void 0,(function*(){let t;try{t=yield this.client.getRun({agentId:this.agentId,runId:this.id})}catch(t){if(t instanceof o.v3||t instanceof o.j1)throw"running"===this._status&&(this._error=(0,o.D7)(t),this.setStatus("error")),t;return}const e=(0,r.O)(t);void 0!==e.result&&(this._result=e.result);const i=w(t.status);"error"===i&&void 0!==e.error?this._error=e.error:"error"!==i&&(this._error=void 0),void 0!==e.durationMs&&(this._durationMs=e.durationMs),void 0!==e.git&&(this._git=e.git),"running"===this._status&&this.setStatus(i)}))}buildResult(){const t="running"===this._status?"error":this._status;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({id:this.id},void 0!==this.requestId?{requestId:this.requestId}:{}),{status:t}),void 0!==this._result?{result:this._result}:{}),"error"===t&&void 0!==this._error?{error:this._error}:{}),void 0!==this._model?{model:this._model}:{}),void 0!==this._durationMs?{durationMs:this._durationMs}:{}),void 0!==this._git?{git:this._git}:{}),void 0!==this._usage?{usage:this._usage}:{})}}class j{constructor(t,e,i,n){this.client=e,this.options=i,this.activeRuns=new Set,this.agentId=t,this.serverCreated=n,this._model=i.model}get model(){return this._model}send(t,e){return v(this,void 0,void 0,(function*(){var i,n,r,d,l,c,h,v,f,g,m,p,y,w,b,_,I,S,O,j;try{if(void 0!==(null===(i=null==e?void 0:e.local)||void 0===i?void 0:i.customTools))throw new o.j1("Custom local tools are only supported for local SDK agents. Create the agent with getLocalPlatformOptions() or omit local.customTools.",{isRetryable:!1});const A=function(t){var e;return"string"==typeof t?{text:t}:{text:t.text,images:null===(e=t.images)||void 0===e?void 0:e.map((t=>"url"in t?{url:t.url,dimension:t.dimension}:{data:t.data,mimeType:t.mimeType,dimension:t.dimension}))}}(t),k=!this.serverCreated,D=null!==(n=null==e?void 0:e.mcpServers)&&void 0!==n?n:this.options.mcpServers,E=null!==(r=null==e?void 0:e.model)&&void 0!==r?r:this._model,M=void 0!==(null==e?void 0:e.mode)?e.mode:k?this.options.mode:void 0,N=null===(d=this.options.cloud)||void 0===d?void 0:d.envVars,x=null===(l=null==e?void 0:e.cloud)||void 0===l?void 0:l.envVars,K=void 0!==(null==e?void 0:e.onStep)||void 0!==(null==e?void 0:e.onDelta)?Object.assign(Object.assign({},void 0!==e.onStep?{onStep:e.onStep}:{}),void 0!==e.onDelta?{onDelta:e.onDelta}:{}):void 0;let P;if(k){const t=(0,u.SB)(this.options.agents),i=C(N),n=yield this.client.createAgent(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},i?{}:{agentId:this.agentId}),{prompt:A}),void 0!==E?{model:E}:{}),void 0!==this.options.name?{name:this.options.name}:{}),{mcpServers:a(D)}),void 0!==t?{customSubagents:t}:{}),{env:null===(c=this.options.cloud)||void 0===c?void 0:c.env}),C(N)?{envVars:N}:{}),C(x)?{runEnvVars:x}:{}),{repos:null===(h=this.options.cloud)||void 0===h?void 0:h.repos,workOnCurrentBranch:null===(v=this.options.cloud)||void 0===v?void 0:v.workOnCurrentBranch,autoCreatePR:null===(f=this.options.cloud)||void 0===f?void 0:f.autoCreatePR,skipReviewerRequest:null===(g=this.options.cloud)||void 0===g?void 0:g.skipReviewerRequest}),void 0!==M?{mode:M}:{}),{idempotencyKey:null!==(m=null==e?void 0:e.idempotencyKey)&&void 0!==m?m:this.options.idempotencyKey});if(i)this.agentId=n.agent.id;else if(n.agent.id!==this.agentId)throw new o.c$(`Server returned mismatched agent id "${n.agent.id}"; expected "${this.agentId}". This indicates a backend bug.`,{isRetryable:!1});this.serverCreated=!0,P=new R(this.client,n.run,K,E)}else{const t=yield this.client.createRun(this.agentId,Object.assign(Object.assign(Object.assign({prompt:A,mcpServers:a(D)},void 0!==(null==e?void 0:e.model)?{model:e.model}:{}),C(x)?{envVars:x}:{}),void 0!==M?{mode:M}:{}),{idempotencyKey:null==e?void 0:e.idempotencyKey});P=new R(this.client,t.run,K,E)}void 0!==(null==e?void 0:e.model)&&(this._model=e.model);const U=null!==(w=null===(y=null===(p=this.options.cloud)||void 0===p?void 0:p.env)||void 0===y?void 0:y.type)&&void 0!==w?w:"cloud",q=null==E?void 0:E.params;(0,s.Zn)(this.options.apiKey,Object.assign(Object.assign({agent_id:this.agentId,run_id:P.id,request_id:P.requestId,runtime:U,model:null!==(b=null==E?void 0:E.id)&&void 0!==b?b:"default"},q&&q.length>0?{model_params:JSON.stringify(q)}:{}),{prompt_length:A.text.length,has_images:(null!==(I=null===(_=A.images)||void 0===_?void 0:_.length)&&void 0!==I?I:0)>0,is_resume:!k,mcp_server_count:Object.keys(null!=D?D:{}).length,cloud_repo_count:null===(O=null===(S=this.options.cloud)||void 0===S?void 0:S.repos)||void 0===O?void 0:O.length,cloud_auto_create_pr:null===(j=this.options.cloud)||void 0===j?void 0:j.autoCreatePR})),this.activeRuns.add(P);const T=this.options.apiKey,$=this.agentId,L=P.id;return P.wait().then((t=>{(0,s.G5)(T,{agent_id:$,run_id:L,request_id:P.requestId,runtime:U,end_reason:"finished"===t.status?"success":"cancelled"===t.status?"abort":"error"})})).finally((()=>{this.activeRuns.delete(P)})),P.ensureStreamStarted(),P}catch(t){throw(0,o.Nt)(t,{operation:"agent.send"})}}))}close(){for(const t of this.activeRuns)t.abortClientStream();(0,s.rd)()}reload(){return v(this,void 0,void 0,(function*(){}))}[Symbol.asyncDispose](){return v(this,void 0,void 0,(function*(){yield Promise.allSettled(Array.from(this.activeRuns,(t=>t.disposeClientStream()))),yield(0,s.rd)()}))}listArtifacts(){return v(this,void 0,void 0,(function*(){try{return this.serverCreated?(yield this.client.listArtifacts(this.agentId)).items.map((t=>({path:t.path,sizeBytes:t.sizeBytes,updatedAt:t.updatedAt}))):[]}catch(t){throw(0,o.Nt)(t,{operation:"agent.listArtifacts"})}}))}downloadArtifact(t){return v(this,void 0,void 0,(function*(){try{if(!this.serverCreated)throw new o.j1("Agent has not been created yet; call send() first.",{isRetryable:!1});const{url:e}=yield this.client.getArtifactDownloadUrl({agentId:this.agentId,path:t});let i;try{i=yield fetch(e)}catch(t){throw new o.Dr("Failed to download artifact",{cause:t,isRetryable:!0})}if(!i.ok)throw new o.Dr(`Failed to download artifact: ${i.status}`,{status:i.status,isRetryable:i.status>=500});return Buffer.from(yield i.arrayBuffer())}catch(t){throw(0,o.Nt)(t,{operation:"agent.downloadArtifact"})}}))}}function C(t){return void 0!==t&&Object.keys(t).length>0}function A(t){var e,i;const s=g(t.apiKey);if(void 0!==t.agentId&&C(null===(e=t.cloud)||void 0===e?void 0:e.envVars))throw new o.j1("cloud.envVars cannot be combined with agentId; omit agentId so the server can mint an agent id.",{isRetryable:!1});const a=new r.N(s),d=null!==(i=t.agentId)&&void 0!==i?i:(0,n.M2)();return new j(d,a,t,!1)}function k(t){return v(this,arguments,void 0,(function*({apiKey:t,model:e}){const i="string"==typeof e?e.trim():e.id.trim();if(0===i.length)throw new o.j1("Model id is required. Pass a non-empty `model.id` or `model: '<model-id>'`.",{isRetryable:!1,code:"invalid_model"});let n,s;try{n=g(t)}catch(t){if(t instanceof o.j1)return;throw t}try{s=(yield new r.N(n).listModels()).items}catch(t){if(t instanceof o.Dr||t instanceof o.v3||t instanceof o.OE)return;throw t}const a=s.some((t=>{var e;return t.id===i||!0===(null===(e=t.aliases)||void 0===e?void 0:e.includes(i))}));if(!a)throw new o.j1(`Model '${i}' is not available or invalid. Call Cursor.models.list() to see valid model ids.`,{isRetryable:!1,code:"invalid_model"})}))}function D(t,e){const i=g(e.apiKey),n=new r.N(i);return new j(t,n,Object.assign({},e),!0)}function E(t){return v(this,void 0,void 0,(function*(){const e=g(t.apiKey),i=new r.N(e),n=yield i.listAgents({limit:t.limit,cursor:t.cursor,prUrl:t.prUrl,includeArchived:t.includeArchived});return{items:n.items.map(K),nextCursor:n.nextCursor}}))}function M(t,e){return v(this,void 0,void 0,(function*(){const i=g(e.apiKey),n=new r.N(i),s=yield n.listRuns(t,{limit:e.limit,cursor:e.cursor});return{items:s.items.map((t=>new R(n,t))),nextCursor:s.nextCursor}}))}function N(t,e){return v(this,void 0,void 0,(function*(){y(t),p(e.agentId);const i=g(e.apiKey),n=new r.N(i),s=yield n.getRun({agentId:e.agentId,runId:t});return new R(n,s)}))}function x(t,e){return v(this,void 0,void 0,(function*(){y(t),p(e.agentId);const i=g(e.apiKey),n=new r.N(i);yield n.cancelRun({agentId:e.agentId,runId:t})}))}function K(t){var e,i,n;return{agentId:t.id,name:null!==(e=t.name)&&void 0!==e?e:"",summary:null!==(i=t.name)&&void 0!==i?i:"",lastModified:new Date(t.updatedAt).getTime(),createdAt:new Date(t.createdAt).getTime(),archived:"ARCHIVED"===t.status,runtime:"cloud",env:t.env,repos:null===(n=t.repos)||void 0===n?void 0:n.map((t=>t.url))}}function P(t,e){return v(this,void 0,void 0,(function*(){const i=g(e.apiKey),n=new r.N(i);return K(yield n.getAgent(t))}))}function U(t,e){return v(this,void 0,void 0,(function*(){const i=g(e.apiKey),n=new r.N(i);yield n.archiveAgent(t)}))}function q(t,e){return v(this,void 0,void 0,(function*(){const i=g(e.apiKey),n=new r.N(i);yield n.unarchiveAgent(t)}))}function T(t,e){return v(this,void 0,void 0,(function*(){const i=g(e.apiKey),n=new r.N(i);yield n.deleteAgent(t)}))}function $(t){return v(this,void 0,void 0,(function*(){const e=g(t.apiKey);return new r.N(e).getMe()}))}function L(t){return v(this,void 0,void 0,(function*(){const e=g(t.apiKey),i=new r.N(e);return(yield i.listModels()).items}))}function F(t){return v(this,void 0,void 0,(function*(){const e=g(t.apiKey),i=new r.N(e);return(yield i.listRepositories()).items}))}}};
|
package/dist/esm/690.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=690;export const __webpack_esm_ids__=[690];export const __webpack_esm_modules__={"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitmapper.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/interlace.js"),s=[function(){},function(t,e,n,i){if(i===e.length)throw new Error("Ran out of data");let s=e[i];t[n]=s,t[n+1]=s,t[n+2]=s,t[n+3]=255},function(t,e,n,i){if(i+1>=e.length)throw new Error("Ran out of data");let s=e[i];t[n]=s,t[n+1]=s,t[n+2]=s,t[n+3]=e[i+1]},function(t,e,n,i){if(i+2>=e.length)throw new Error("Ran out of data");t[n]=e[i],t[n+1]=e[i+1],t[n+2]=e[i+2],t[n+3]=255},function(t,e,n,i){if(i+3>=e.length)throw new Error("Ran out of data");t[n]=e[i],t[n+1]=e[i+1],t[n+2]=e[i+2],t[n+3]=e[i+3]}],r=[function(){},function(t,e,n,i){let s=e[0];t[n]=s,t[n+1]=s,t[n+2]=s,t[n+3]=i},function(t,e,n){let i=e[0];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=e[1]},function(t,e,n,i){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=i},function(t,e,n){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3]}];function o(t,e,n,i,r,o){let h=t.width,l=t.height,a=t.index;for(let t=0;t<l;t++)for(let l=0;l<h;l++){let h=n(l,t,a);s[i](e,r,h,o),o+=i}return o}function h(t,e,n,i,s,o){let h=t.width,l=t.height,a=t.index;for(let t=0;t<l;t++){for(let l=0;l<h;l++){let h=s.get(i),p=n(l,t,a);r[i](e,h,p,o)}s.resetAfterLine()}}e.dataToBitMap=function(t,e){let n,s,r=e.width,l=e.height,a=e.depth,p=e.bpp,d=e.interlace;8!==a&&(n=function(t,e){let n=[],i=0;function s(){if(i===t.length)throw new Error("Ran out of data");let s,r,o,h,l,a,p,d,u=t[i];switch(i++,e){default:throw new Error("unrecognised depth");case 16:p=t[i],i++,n.push((u<<8)+p);break;case 4:p=15&u,d=u>>4,n.push(d,p);break;case 2:l=3&u,a=u>>2&3,p=u>>4&3,d=u>>6&3,n.push(d,p,a,l);break;case 1:s=1&u,r=u>>1&1,o=u>>2&1,h=u>>3&1,l=u>>4&1,a=u>>5&1,p=u>>6&1,d=u>>7&1,n.push(d,p,a,l,h,o,r,s)}}return{get:function(t){for(;n.length<t;)s();let e=n.slice(0,t);return n=n.slice(t),e},resetAfterLine:function(){n.length=0},end:function(){if(i!==t.length)throw new Error("extra data found")}}}(t,a)),s=a<=8?Buffer.alloc(r*l*4):new Uint16Array(r*l*4);let u,f,_=Math.pow(2,a)-1,c=0;if(d)u=i.getImagePasses(r,l),f=i.getInterlaceIterator(r,l);else{let t=0;f=function(){let e=t;return t+=4,e},u=[{width:r,height:l}]}for(let e=0;e<u.length;e++)8===a?c=o(u[e],s,f,p,t,c):h(u[e],s,f,p,n,_);if(8===a){if(c!==t.length)throw new Error("extra data found")}else n.end();return s}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitpacker.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js");t.exports=function(t,e,n,s){let r=-1!==[i.COLORTYPE_COLOR_ALPHA,i.COLORTYPE_ALPHA].indexOf(s.colorType);if(s.colorType===s.inputColorType){let e=function(){let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),256!==new Int16Array(t)[0]}();if(8===s.bitDepth||16===s.bitDepth&&e)return t}let o=16!==s.bitDepth?t:new Uint16Array(t.buffer),h=255,l=i.COLORTYPE_TO_BPP_MAP[s.inputColorType];4!==l||s.inputHasAlpha||(l=3);let a=i.COLORTYPE_TO_BPP_MAP[s.colorType];16===s.bitDepth&&(h=65535,a*=2);let p=Buffer.alloc(e*n*a),d=0,u=0,f=s.bgColor||{};function _(){let t,e,n,l=h;switch(s.inputColorType){case i.COLORTYPE_COLOR_ALPHA:l=o[d+3],t=o[d],e=o[d+1],n=o[d+2];break;case i.COLORTYPE_COLOR:t=o[d],e=o[d+1],n=o[d+2];break;case i.COLORTYPE_ALPHA:l=o[d+1],t=o[d],e=t,n=t;break;case i.COLORTYPE_GRAYSCALE:t=o[d],e=t,n=t;break;default:throw new Error("input color type:"+s.inputColorType+" is not supported at present")}return s.inputHasAlpha&&(r||(l/=h,t=Math.min(Math.max(Math.round((1-l)*f.red+l*t),0),h),e=Math.min(Math.max(Math.round((1-l)*f.green+l*e),0),h),n=Math.min(Math.max(Math.round((1-l)*f.blue+l*n),0),h))),{red:t,green:e,blue:n,alpha:l}}void 0===f.red&&(f.red=h),void 0===f.green&&(f.green=h),void 0===f.blue&&(f.blue=h);for(let t=0;t<n;t++)for(let t=0;t<e;t++){let t=_();switch(s.colorType){case i.COLORTYPE_COLOR_ALPHA:case i.COLORTYPE_COLOR:8===s.bitDepth?(p[u]=t.red,p[u+1]=t.green,p[u+2]=t.blue,r&&(p[u+3]=t.alpha)):(p.writeUInt16BE(t.red,u),p.writeUInt16BE(t.green,u+2),p.writeUInt16BE(t.blue,u+4),r&&p.writeUInt16BE(t.alpha,u+6));break;case i.COLORTYPE_ALPHA:case i.COLORTYPE_GRAYSCALE:{let e=(t.red+t.green+t.blue)/3;8===s.bitDepth?(p[u]=e,r&&(p[u+1]=t.alpha)):(p.writeUInt16BE(e,u),r&&p.writeUInt16BE(t.alpha,u+2));break}default:throw new Error("unrecognised color Type "+s.colorType)}d+=l,u+=a}return p}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/chunkstream.js"(t,e,n){let i=n("util"),s=n("stream"),r=t.exports=function(){s.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};i.inherits(r,s),r.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))},r.prototype.write=function(t,e){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let n;return n=Buffer.isBuffer(t)?t:Buffer.from(t,e||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused},r.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},r.prototype.destroySoon=r.prototype.end,r.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()},r.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},r.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))},r.prototype._processRead=function(t){this._reads.shift();let e=0,n=0,i=Buffer.alloc(t.length);for(;e<t.length;){let s=this._buffers[n++],r=Math.min(s.length,t.length-e);s.copy(i,e,0,r),e+=r,r!==s.length&&(this._buffers[--n]=s.slice(r))}n>0&&this._buffers.splice(0,n),this._buffered-=t.length,t.func.call(this,i)},r.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else{if(!(this._buffered>=t.length))break;this._processRead(t)}}this._buffers&&!this.writable&&this._end()}catch(t){this.emit("error",t)}}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js"(t){t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/crc.js"(t){let e=[];!function(){for(let t=0;t<256;t++){let n=t;for(let t=0;t<8;t++)1&n?n=3988292384^n>>>1:n>>>=1;e[t]=n}}();let n=t.exports=function(){this._crc=-1};n.prototype.write=function(t){for(let n=0;n<t.length;n++)this._crc=e[255&(this._crc^t[n])]^this._crc>>>8;return!0},n.prototype.crc32=function(){return~this._crc},n.crc32=function(t){let n=-1;for(let i=0;i<t.length;i++)n=e[255&(n^t[i])]^n>>>8;return~n}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-pack.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/paeth-predictor.js"),s={0:function(t,e,n,i,s){for(let r=0;r<n;r++)i[s+r]=t[e+r]},1:function(t,e,n,i,s,r){for(let o=0;o<n;o++){let n=o>=r?t[e+o-r]:0,h=t[e+o]-n;i[s+o]=h}},2:function(t,e,n,i,s){for(let r=0;r<n;r++){let o=e>0?t[e+r-n]:0,h=t[e+r]-o;i[s+r]=h}},3:function(t,e,n,i,s,r){for(let o=0;o<n;o++){let h=o>=r?t[e+o-r]:0,l=e>0?t[e+o-n]:0,a=t[e+o]-(h+l>>1);i[s+o]=a}},4:function(t,e,n,s,r,o){for(let h=0;h<n;h++){let l=h>=o?t[e+h-o]:0,a=e>0?t[e+h-n]:0,p=e>0&&h>=o?t[e+h-(n+o)]:0,d=t[e+h]-i(l,a,p);s[r+h]=d}}},r={0:function(t,e,n){let i=0,s=e+n;for(let n=e;n<s;n++)i+=Math.abs(t[n]);return i},1:function(t,e,n,i){let s=0;for(let r=0;r<n;r++){let n=r>=i?t[e+r-i]:0,o=t[e+r]-n;s+=Math.abs(o)}return s},2:function(t,e,n){let i=0,s=e+n;for(let r=e;r<s;r++){let s=e>0?t[r-n]:0,o=t[r]-s;i+=Math.abs(o)}return i},3:function(t,e,n,i){let s=0;for(let r=0;r<n;r++){let o=r>=i?t[e+r-i]:0,h=e>0?t[e+r-n]:0,l=t[e+r]-(o+h>>1);s+=Math.abs(l)}return s},4:function(t,e,n,s){let r=0;for(let o=0;o<n;o++){let h=o>=s?t[e+o-s]:0,l=e>0?t[e+o-n]:0,a=e>0&&o>=s?t[e+o-(n+s)]:0,p=t[e+o]-i(h,l,a);r+=Math.abs(p)}return r}};t.exports=function(t,e,n,i,o){let h;if("filterType"in i&&-1!==i.filterType){if("number"!=typeof i.filterType)throw new Error("unrecognised filter types");h=[i.filterType]}else h=[0,1,2,3,4];16===i.bitDepth&&(o*=2);let l=e*o,a=0,p=0,d=Buffer.alloc((l+1)*n),u=h[0];for(let e=0;e<n;e++){if(h.length>1){let e=1/0;for(let n=0;n<h.length;n++){let i=r[h[n]](t,p,l,o);i<e&&(u=h[n],e=i)}}d[a]=u,a++,s[u](t,p,l,d,a,o),a+=l,p+=l}return d}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-async.js"(t,e,n){let i=n("util"),s=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/chunkstream.js"),r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse.js"),o=t.exports=function(t){s.call(this);let e=[],n=this;this._filter=new r(t,{read:this.read.bind(this),write:function(t){e.push(t)},complete:function(){n.emit("complete",Buffer.concat(e))}}),this._filter.start()};i.inherits(o,s)},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-sync.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-reader.js"),s=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse.js");e.process=function(t,e){let n=[],r=new i(t);return new s(e,{read:r.read.bind(r),write:function(t){n.push(t)},complete:function(){}}).start(),r.process(),Buffer.concat(n)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/interlace.js"),s=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/paeth-predictor.js");function r(t,e,n){let i=t*e;return 8!==n&&(i=Math.ceil(i/(8/n))),i}let o=t.exports=function(t,e){let n=t.width,s=t.height,o=t.interlace,h=t.bpp,l=t.depth;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],o){let t=i.getImagePasses(n,s);for(let e=0;e<t.length;e++)this._images.push({byteWidth:r(t[e].width,h,l),height:t[e].height,lineIndex:0})}else this._images.push({byteWidth:r(n,h,l),height:s,lineIndex:0});this._xComparison=8===l?h:16===l?2*h:1};o.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},o.prototype._unFilterType1=function(t,e,n){let i=this._xComparison,s=i-1;for(let r=0;r<n;r++){let n=t[1+r],o=r>s?e[r-i]:0;e[r]=n+o}},o.prototype._unFilterType2=function(t,e,n){let i=this._lastLine;for(let s=0;s<n;s++){let n=t[1+s],r=i?i[s]:0;e[s]=n+r}},o.prototype._unFilterType3=function(t,e,n){let i=this._xComparison,s=i-1,r=this._lastLine;for(let o=0;o<n;o++){let n=t[1+o],h=r?r[o]:0,l=o>s?e[o-i]:0,a=Math.floor((l+h)/2);e[o]=n+a}},o.prototype._unFilterType4=function(t,e,n){let i=this._xComparison,r=i-1,o=this._lastLine;for(let h=0;h<n;h++){let n=t[1+h],l=o?o[h]:0,a=h>r?e[h-i]:0,p=h>r&&o?o[h-i]:0,d=s(a,l,p);e[h]=n+d}},o.prototype._reverseFilterLine=function(t){let e,n=t[0],i=this._images[this._imageIndex],s=i.byteWidth;if(0===n)e=t.slice(1,s+1);else switch(e=Buffer.alloc(s),n){case 1:this._unFilterType1(t,e,s);break;case 2:this._unFilterType2(t,e,s);break;case 3:this._unFilterType3(t,e,s);break;case 4:this._unFilterType4(t,e,s);break;default:throw new Error("Unrecognised filter type - "+n)}this.write(e),i.lineIndex++,i.lineIndex>=i.height?(this._lastLine=null,this._imageIndex++,i=this._images[this._imageIndex]):this._lastLine=e,i?this.read(i.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/format-normaliser.js"(t){t.exports=function(t,e,n=!1){let i=e.depth,s=e.width,r=e.height,o=e.colorType,h=e.transColor,l=e.palette,a=t;return 3===o?function(t,e,n,i,s){let r=0;for(let o=0;o<i;o++)for(let i=0;i<n;i++){let n=s[t[r]];if(!n)throw new Error("index "+t[r]+" not in palette");for(let t=0;t<4;t++)e[r+t]=n[t];r+=4}}(t,a,s,r,l):(h&&function(t,e,n,i,s){let r=0;for(let o=0;o<i;o++)for(let i=0;i<n;i++){let n=!1;if(1===s.length?s[0]===t[r]&&(n=!0):s[0]===t[r]&&s[1]===t[r+1]&&s[2]===t[r+2]&&(n=!0),n)for(let t=0;t<4;t++)e[r+t]=0;r+=4}}(t,a,s,r,h),8===i||n||(16===i&&(a=Buffer.alloc(s*r*4)),function(t,e,n,i,s){let r=Math.pow(2,s)-1,o=0;for(let s=0;s<i;s++)for(let i=0;i<n;i++){for(let n=0;n<4;n++)e[o+n]=Math.floor(255*t[o+n]/r+.5);o+=4}}(t,a,s,r,i))),a}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/interlace.js"(t,e){let n=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(t,e){let i=[],s=t%8,r=e%8,o=(t-s)/8,h=(e-r)/8;for(let t=0;t<n.length;t++){let e=n[t],l=o*e.x.length,a=h*e.y.length;for(let t=0;t<e.x.length&&e.x[t]<s;t++)l++;for(let t=0;t<e.y.length&&e.y[t]<r;t++)a++;l>0&&a>0&&i.push({width:l,height:a,index:t})}return i},e.getInterlaceIterator=function(t){return function(e,i,s){let r=e%n[s].x.length,o=(e-r)/n[s].x.length*8+n[s].x[r],h=i%n[s].y.length;return 4*o+((i-h)/n[s].y.length*8+n[s].y[h])*t*4}}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-async.js"(t,e,n){let i=n("util"),s=n("stream"),r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer.js"),h=t.exports=function(t){s.call(this);let e=t||{};this._packer=new o(e),this._deflate=this._packer.createDeflate(),this.readable=!0};i.inherits(h,s),h.prototype.pack=function(t,e,n,i){this.emit("data",Buffer.from(r.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),i&&this.emit("data",this._packer.packGAMA(i));let s=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(t){this.emit("data",this._packer.packIDAT(t))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(s)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-sync.js"(t,e,n){let i=!0,s=n("zlib?1ecc");s.deflateSync||(i=!1);let r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer.js");t.exports=function(t,e){if(!i)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n=new o(e||{}),h=[];h.push(Buffer.from(r.PNG_SIGNATURE)),h.push(n.packIHDR(t.width,t.height)),t.gamma&&h.push(n.packGAMA(t.gamma));let l=n.filterData(t.data,t.width,t.height),a=s.deflateSync(l,n.getDeflateOptions());if(l=null,!a||!a.length)throw new Error("bad png - invalid compressed data response");return h.push(n.packIDAT(a)),h.push(n.packIEND()),Buffer.concat(h)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/crc.js"),r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitpacker.js"),o=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-pack.js"),h=n("zlib?1ecc"),l=t.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=null!=t.deflateLevel?t.deflateLevel:9,t.deflateStrategy=null!=t.deflateStrategy?t.deflateStrategy:3,t.inputHasAlpha=null==t.inputHasAlpha||t.inputHasAlpha,t.deflateFactory=t.deflateFactory||h.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType="number"==typeof t.colorType?t.colorType:i.COLORTYPE_COLOR_ALPHA,t.inputColorType="number"==typeof t.inputColorType?t.inputColorType:i.COLORTYPE_COLOR_ALPHA,-1===[i.COLORTYPE_GRAYSCALE,i.COLORTYPE_COLOR,i.COLORTYPE_COLOR_ALPHA,i.COLORTYPE_ALPHA].indexOf(t.colorType))throw new Error("option color type:"+t.colorType+" is not supported at present");if(-1===[i.COLORTYPE_GRAYSCALE,i.COLORTYPE_COLOR,i.COLORTYPE_COLOR_ALPHA,i.COLORTYPE_ALPHA].indexOf(t.inputColorType))throw new Error("option input color type:"+t.inputColorType+" is not supported at present");if(8!==t.bitDepth&&16!==t.bitDepth)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};l.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},l.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},l.prototype.filterData=function(t,e,n){let s=r(t,e,n,this._options),h=i.COLORTYPE_TO_BPP_MAP[this._options.colorType];return o(s,e,n,this._options,h)},l.prototype._packChunk=function(t,e){let n=e?e.length:0,i=Buffer.alloc(n+12);return i.writeUInt32BE(n,0),i.writeUInt32BE(t,4),e&&e.copy(i,8),i.writeInt32BE(s.crc32(i.slice(4,i.length-4)),i.length-4),i},l.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*i.GAMMA_DIVISION),0),this._packChunk(i.TYPE_gAMA,e)},l.prototype.packIHDR=function(t,e){let n=Buffer.alloc(13);return n.writeUInt32BE(t,0),n.writeUInt32BE(e,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(i.TYPE_IHDR,n)},l.prototype.packIDAT=function(t){return this._packChunk(i.TYPE_IDAT,t)},l.prototype.packIEND=function(){return this._packChunk(i.TYPE_IEND,null)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/paeth-predictor.js"(t){t.exports=function(t,e,n){let i=t+e-n,s=Math.abs(i-t),r=Math.abs(i-e),o=Math.abs(i-n);return s<=r&&s<=o?t:r<=o?e:n}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-async.js"(t,e,n){let i=n("util"),s=n("zlib?1ecc"),r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/chunkstream.js"),o=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-async.js"),h=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser.js"),l=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitmapper.js"),a=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/format-normaliser.js"),p=t.exports=function(t){r.call(this),this._parser=new h(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};i.inherits(p,r),p.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",(function(){}))),this.errord=!0},p.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=s.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let t=(1+(this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3))*this._bitmapInfo.height,e=Math.max(t,s.Z_MIN_CHUNK);this._inflate=s.createInflate({chunkSize:e});let n=t,i=this.emit.bind(this,"error");this._inflate.on("error",(function(t){n&&i(t)})),this._filter.on("complete",this._complete.bind(this));let r=this._filter.write.bind(this._filter);this._inflate.on("data",(function(t){n&&(t.length>n&&(t=t.slice(0,n)),n-=t.length,r(t))})),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)},p.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new o(this._bitmapInfo)},p.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t},p.prototype._handlePalette=function(t){this._bitmapInfo.palette=t},p.prototype._simpleTransparency=function(){this._metaData.alpha=!0},p.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},p.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},p.prototype._complete=function(t){if(this.errord)return;let e;try{let n=l.dataToBitMap(t,this._bitmapInfo);e=a(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(t){return void this._handleError(t)}this.emit("parsed",e)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-sync.js"(t,e,n){let i=!0,s=n("zlib?1ecc"),r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-inflate.js");s.deflateSync||(i=!1);let o=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-reader.js"),h=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-sync.js"),l=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser.js"),a=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitmapper.js"),p=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/format-normaliser.js");t.exports=function(t,e){if(!i)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n,d,u,f=[],_=new o(t),c=new l(e,{read:_.read.bind(_),error:function(t){n=t},metadata:function(t){d=t},gamma:function(t){u=t},palette:function(t){d.palette=t},transColor:function(t){d.transColor=t},inflateData:function(t){f.push(t)},simpleTransparency:function(){d.alpha=!0}});if(c.start(),_.process(),n)throw n;let m,g=Buffer.concat(f);if(f.length=0,d.interlace)m=s.inflateSync(g);else{let t=(1+(d.width*d.bpp*d.depth+7>>3))*d.height;m=r(g,{chunkSize:t,maxLength:t})}if(g=null,!m||!m.length)throw new Error("bad png - invalid inflate data response");let b=h.process(m,d);g=null;let y=a.dataToBitMap(b,d);b=null;let w=p(y,d,e.skipRescale);return d.data=w,d.gamma=u||0,d}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/crc.js"),r=t.exports=function(t,e){this._options=t,t.checkCRC=!1!==t.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[i.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[i.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[i.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[i.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[i.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[i.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};r.prototype.start=function(){this.read(i.PNG_SIGNATURE.length,this._parseSignature.bind(this))},r.prototype._parseSignature=function(t){let e=i.PNG_SIGNATURE;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return void this.error(new Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},r.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r="";for(let e=4;e<8;e++)r+=String.fromCharCode(t[e]);let o=Boolean(32&t[4]);if(this._hasIHDR||n===i.TYPE_IHDR){if(this._crc=new s,this._crc.write(Buffer.from(r)),this._chunks[n])return this._chunks[n](e);o?this.read(e+4,this._skipChunk.bind(this)):this.error(new Error("Unsupported critical chunk type "+r))}else this.error(new Error("Expected IHDR on beggining"))},r.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},r.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},r.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),n=this._crc.crc32();this._options.checkCRC&&n!==e?this.error(new Error("Crc error - "+e+" - "+n)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},r.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))},r.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),n=t.readUInt32BE(4),s=t[8],r=t[9],o=t[10],h=t[11],l=t[12];if(8!==s&&4!==s&&2!==s&&1!==s&&16!==s)return void this.error(new Error("Unsupported bit depth "+s));if(!(r in i.COLORTYPE_TO_BPP_MAP))return void this.error(new Error("Unsupported color type"));if(0!==o)return void this.error(new Error("Unsupported compression method"));if(0!==h)return void this.error(new Error("Unsupported filter method"));if(0!==l&&1!==l)return void this.error(new Error("Unsupported interlace method"));this._colorType=r;let a=i.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:n,depth:s,interlace:Boolean(l),palette:Boolean(r&i.COLORTYPE_PALETTE),color:Boolean(r&i.COLORTYPE_COLOR),alpha:Boolean(r&i.COLORTYPE_ALPHA),bpp:a,colorType:r}),this._handleChunkEnd()},r.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))},r.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let n=0;n<e;n++)this._palette.push([t[3*n],t[3*n+1],t[3*n+2],255]);this.palette(this._palette),this._handleChunkEnd()},r.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))},r.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===i.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(new Error("Transparency chunk must be after palette"));if(t.length>this._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}this._colorType===i.COLORTYPE_GRAYSCALE&&this.transColor([t.readUInt16BE(0)]),this._colorType===i.COLORTYPE_COLOR&&this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]),this._handleChunkEnd()},r.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))},r.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/i.GAMMA_DIVISION),this._handleChunkEnd()},r.prototype._handleIDAT=function(t){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-t,this._parseIDAT.bind(this,t))},r.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===i.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw new Error("Expected palette not found");this.inflateData(e);let n=t-e.length;n>0?this._handleIDAT(n):this._handleChunkEnd()},r.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},r.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png-sync.js"(t,e,n){let i=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-sync.js"),s=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-sync.js");e.read=function(t,e){return i(t,e||{})},e.write=function(t,e){return s(t,e)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png.js"(t,e,n){let i=n("util"),s=n("stream"),r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-async.js"),o=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-async.js"),h=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png-sync.js"),l=e.O=function(t){s.call(this),t=t||{},this.width=0|t.width,this.height=0|t.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new r(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new o(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};i.inherits(l,s),l.sync=h,l.prototype.pack=function(){return this.data&&this.data.length?(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this):(this.emit("error","No data provided"),this)},l.prototype.parse=function(t,e){if(e){let t,n;t=function(t){this.removeListener("error",n),this.data=t,e(null,this)}.bind(this),n=function(n){this.removeListener("parsed",t),e(n,null)}.bind(this),this.once("parsed",t),this.once("error",n)}return this.end(t),this},l.prototype.write=function(t){return this._parser.write(t),!0},l.prototype.end=function(t){this._parser.end(t)},l.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)},l.prototype._gamma=function(t){this.gamma=t},l.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},l.bitblt=function(t,e,n,i,s,r,o,h){if(i|=0,s|=0,r|=0,o|=0,h|=0,(n|=0)>t.width||i>t.height||n+s>t.width||i+r>t.height)throw new Error("bitblt reading outside image");if(o>e.width||h>e.height||o+s>e.width||h+r>e.height)throw new Error("bitblt writing outside image");for(let l=0;l<r;l++)t.data.copy(e.data,(h+l)*e.width+o<<2,(i+l)*t.width+n<<2,(i+l)*t.width+n+s<<2)},l.prototype.bitblt=function(t,e,n,i,s,r,o){return l.bitblt(this,t,e,n,i,s,r,o),this},l.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let n=0;n<t.width;n++){let i=t.width*e+n<<2;for(let e=0;e<3;e++){let n=t.data[i+e]/255;n=Math.pow(n,1/2.2/t.gamma),t.data[i+e]=Math.round(255*n)}}t.gamma=0}},l.prototype.adjustGamma=function(){l.adjustGamma(this)}},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-inflate.js"(t,e,n){let i=n("assert?95cd").ok,s=n("zlib?1ecc"),r=n("util"),o=n("buffer?4949").kMaxLength;function h(t){if(!(this instanceof h))return new h(t);t&&t.chunkSize<s.Z_MIN_CHUNK&&(t.chunkSize=s.Z_MIN_CHUNK),s.Inflate.call(this,t),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&null!=t.maxLength&&(this._maxLength=t.maxLength)}function l(t,e){e&&process.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function a(t,e){return function(t,e){if("string"==typeof e&&(e=Buffer.from(e)),!(e instanceof Buffer))throw new TypeError("Not a string or buffer");let n=t._finishFlushFlag;return null==n&&(n=s.Z_FINISH),t._processChunk(e,n)}(new h(e),t)}h.prototype._processChunk=function(t,e,n){if("function"==typeof n)return s.Inflate._processChunk.call(this,t,e,n);let r,h,a=this,p=t&&t.length,d=this._chunkSize-this._offset,u=this._maxLength,f=0,_=[],c=0;function m(t,e){if(a._hadError)return;let n=d-e;if(i(n>=0,"have should not go down"),n>0){let t=a._buffer.slice(a._offset,a._offset+n);if(a._offset+=n,t.length>u&&(t=t.slice(0,u)),_.push(t),c+=t.length,u-=t.length,0===u)return!1}return(0===e||a._offset>=a._chunkSize)&&(d=a._chunkSize,a._offset=0,a._buffer=Buffer.allocUnsafe(a._chunkSize)),0===e&&(f+=p-t,p=t,!0)}this.on("error",(function(t){r=t})),i(this._handle,"zlib binding closed");do{h=this._handle.writeSync(e,t,f,p,this._buffer,this._offset,d),h=h||this._writeState}while(!this._hadError&&m(h[0],h[1]));if(this._hadError)throw r;if(c>=o)throw l(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+o.toString(16)+" bytes");let g=Buffer.concat(_,c);return l(this),g},r.inherits(h,s.Inflate),t.exports=e=a,e.Inflate=h,e.createInflate=function(t){return new h(t)},e.inflateSync=a},"../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-reader.js"(t){let e=t.exports=function(t){this._buffer=t,this._reads=[]};e.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})},e.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let t=this._reads[0];if(!this._buffer.length||!(this._buffer.length>=t.length||t.allowLess))break;{this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}}if(this._reads.length>0)throw new Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw new Error("unrecognised content at end of stream")}},"../../node_modules/.pnpm/@jimp+js-png@1.6.0/node_modules/@jimp/js-png/dist/esm/index.js"(t,e,n){n.d(e,{PNGColorType:()=>s,PNGFilterType:()=>i,default:()=>o}),n.r(e);var i,s,r=n("../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png.js");function o(){return{mime:"image/png",hasAlpha:!0,encode:(t,{deflateLevel:e=9,deflateStrategy:n=3,filterType:o=i.AUTO,colorType:h,inputHasAlpha:l=!0,...a}={})=>{const p=new r.O({width:t.width,height:t.height});return p.data=t.data,r.O.sync.write(p,{...a,deflateLevel:e,deflateStrategy:n,filterType:o,colorType:void 0!==h?h:l?s.COLOR_ALPHA:s.COLOR,inputHasAlpha:l})},decode:(t,e)=>{const n=r.O.sync.read(t,e);return{data:n.data,width:n.width,height:n.height}}}}!function(t){t[t.AUTO=-1]="AUTO",t[t.NONE=0]="NONE",t[t.SUB=1]="SUB",t[t.UP=2]="UP",t[t.AVERAGE=3]="AVERAGE",t[t.PATH=4]="PATH"}(i||(i={})),function(t){t[t.GRAYSCALE=0]="GRAYSCALE",t[t.COLOR=2]="COLOR",t[t.GRAYSCALE_ALPHA=4]="GRAYSCALE_ALPHA",t[t.COLOR_ALPHA=6]="COLOR_ALPHA"}(s||(s={}))}};
|
package/dist/esm/731.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=731;export const __webpack_esm_ids__=[731];export const __webpack_esm_modules__={"../../node_modules/.pnpm/@jimp+utils@1.6.0/node_modules/@jimp/utils/dist/esm/index.js"(t,r,e){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}e.d(r,{by:()=>$,QH:()=>P,SQ:()=>T,QQ:()=>O});var a=/^\s+/,i=/\s+$/;function o(t,r){if(r=r||{},(t=t||"")instanceof o)return t;if(!(this instanceof o))return new o(t,r);var e=function(t){var r,e,o,h={r:0,g:0,b:0},s=1,f=null,u=null,l=null,c=!1,d=!1;return"string"==typeof t&&(t=function(t){t=t.replace(a,"").replace(i,"").toLowerCase();var r,e=!1;if(A[t])t=A[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};return(r=L.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=L.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=L.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=L.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=L.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=L.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=L.hex8.exec(t))?{r:R(r[1]),g:R(r[2]),b:R(r[3]),a:q(r[4]),format:e?"name":"hex8"}:(r=L.hex6.exec(t))?{r:R(r[1]),g:R(r[2]),b:R(r[3]),format:e?"name":"hex"}:(r=L.hex4.exec(t))?{r:R(r[1]+""+r[1]),g:R(r[2]+""+r[2]),b:R(r[3]+""+r[3]),a:q(r[4]+""+r[4]),format:e?"name":"hex8"}:!!(r=L.hex3.exec(t))&&{r:R(r[1]+""+r[1]),g:R(r[2]+""+r[2]),b:R(r[3]+""+r[3]),format:e?"name":"hex"}}(t)),"object"==n(t)&&(z(t.r)&&z(t.g)&&z(t.b)?(r=t.r,e=t.g,o=t.b,h={r:255*S(r,255),g:255*S(e,255),b:255*S(o,255)},c=!0,d="%"===String(t.r).substr(-1)?"prgb":"rgb"):z(t.h)&&z(t.s)&&z(t.v)?(f=C(t.s),u=C(t.v),h=function(t,r,e){t=6*S(t,360),r=S(r,100),e=S(e,100);var n=Math.floor(t),a=t-n,i=e*(1-r),o=e*(1-a*r),h=e*(1-(1-a)*r),s=n%6;return{r:255*[e,o,i,i,h,e][s],g:255*[h,e,e,o,i,i][s],b:255*[i,i,h,e,e,o][s]}}(t.h,f,u),c=!0,d="hsv"):z(t.h)&&z(t.s)&&z(t.l)&&(f=C(t.s),l=C(t.l),h=function(t,r,e){var n,a,i;function o(t,r,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+6*(r-t)*e:e<.5?r:e<2/3?t+(r-t)*(2/3-e)*6:t}if(t=S(t,360),r=S(r,100),e=S(e,100),0===r)n=a=i=e;else{var h=e<.5?e*(1+r):e+r-e*r,s=2*e-h;n=o(s,h,t+1/3),a=o(s,h,t),i=o(s,h,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(t.h,f,l),c=!0,d="hsl"),t.hasOwnProperty("a")&&(s=t.a)),s=k(s),{ok:c,format:t.format||d,r:Math.min(255,Math.max(h.r,0)),g:Math.min(255,Math.max(h.g,0)),b:Math.min(255,Math.max(h.b,0)),a:s}}(t);this._originalInput=t,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=r.format||e.format,this._gradientType=r.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}function h(t,r,e){t=S(t,255),r=S(r,255),e=S(e,255);var n,a,i=Math.max(t,r,e),o=Math.min(t,r,e),h=(i+o)/2;if(i==o)n=a=0;else{var s=i-o;switch(a=h>.5?s/(2-i-o):s/(i+o),i){case t:n=(r-e)/s+(r<e?6:0);break;case r:n=(e-t)/s+2;break;case e:n=(t-r)/s+4}n/=6}return{h:n,s:a,l:h}}function s(t,r,e){t=S(t,255),r=S(r,255),e=S(e,255);var n,a,i=Math.max(t,r,e),o=Math.min(t,r,e),h=i,s=i-o;if(a=0===i?0:s/i,i==o)n=0;else{switch(i){case t:n=(r-e)/s+(r<e?6:0);break;case r:n=(e-t)/s+2;break;case e:n=(t-r)/s+4}n/=6}return{h:n,s:a,v:h}}function f(t,r,e,n){var a=[F(Math.round(t).toString(16)),F(Math.round(r).toString(16)),F(Math.round(e).toString(16))];return n&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function u(t,r,e,n){return[F(E(n)),F(Math.round(t).toString(16)),F(Math.round(r).toString(16)),F(Math.round(e).toString(16))].join("")}function l(t,r){r=0===r?0:r||10;var e=o(t).toHsl();return e.s-=r/100,e.s=H(e.s),o(e)}function c(t,r){r=0===r?0:r||10;var e=o(t).toHsl();return e.s+=r/100,e.s=H(e.s),o(e)}function d(t){return o(t).desaturate(100)}function g(t,r){r=0===r?0:r||10;var e=o(t).toHsl();return e.l+=r/100,e.l=H(e.l),o(e)}function b(t,r){r=0===r?0:r||10;var e=o(t).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(-r/100*255))),e.g=Math.max(0,Math.min(255,e.g-Math.round(-r/100*255))),e.b=Math.max(0,Math.min(255,e.b-Math.round(-r/100*255))),o(e)}function m(t,r){r=0===r?0:r||10;var e=o(t).toHsl();return e.l-=r/100,e.l=H(e.l),o(e)}function p(t,r){var e=o(t).toHsl(),n=(e.h+r)%360;return e.h=n<0?360+n:n,o(e)}function _(t){var r=o(t).toHsl();return r.h=(r.h+180)%360,o(r)}function v(t,r){if(isNaN(r)||r<=0)throw new Error("Argument to polyad must be a positive number");for(var e=o(t).toHsl(),n=[o(t)],a=360/r,i=1;i<r;i++)n.push(o({h:(e.h+i*a)%360,s:e.s,l:e.l}));return n}function M(t){var r=o(t).toHsl(),e=r.h;return[o(t),o({h:(e+72)%360,s:r.s,l:r.l}),o({h:(e+216)%360,s:r.s,l:r.l})]}function y(t,r,e){r=r||6,e=e||30;var n=o(t).toHsl(),a=360/e,i=[o(t)];for(n.h=(n.h-(a*r>>1)+720)%360;--r;)n.h=(n.h+a)%360,i.push(o(n));return i}function x(t,r){r=r||6;for(var e=o(t).toHsv(),n=e.h,a=e.s,i=e.v,h=[],s=1/r;r--;)h.push(o({h:n,s:a,v:i})),i=(i+s)%1;return h}o.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,r,e,n=this.toRgb();return t=n.r/255,r=n.g/255,e=n.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))},setAlpha:function(t){return this._a=k(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),r=Math.round(360*t.h),e=Math.round(100*t.s),n=Math.round(100*t.v);return 1==this._a?"hsv("+r+", "+e+"%, "+n+"%)":"hsva("+r+", "+e+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=h(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=h(this._r,this._g,this._b),r=Math.round(360*t.h),e=Math.round(100*t.s),n=Math.round(100*t.l);return 1==this._a?"hsl("+r+", "+e+"%, "+n+"%)":"hsla("+r+", "+e+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return f(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,r,e,n,a){var i=[F(Math.round(t).toString(16)),F(Math.round(r).toString(16)),F(Math.round(e).toString(16)),F(E(n))];return a&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)&&i[3].charAt(0)==i[3].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0)+i[3].charAt(0):i.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*S(this._r,255))+"%",g:Math.round(100*S(this._g,255))+"%",b:Math.round(100*S(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*S(this._r,255))+"%, "+Math.round(100*S(this._g,255))+"%, "+Math.round(100*S(this._b,255))+"%)":"rgba("+Math.round(100*S(this._r,255))+"%, "+Math.round(100*S(this._g,255))+"%, "+Math.round(100*S(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(w[f(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),e=r,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=o(t);e="#"+u(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+r+",endColorstr="+e+")"},toString:function(t){var r=!!t;t=t||this._format;var e=!1,n=this._a<1&&this._a>=0;return r||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(e=this.toRgbString()),"prgb"===t&&(e=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(e=this.toHexString()),"hex3"===t&&(e=this.toHexString(!0)),"hex4"===t&&(e=this.toHex8String(!0)),"hex8"===t&&(e=this.toHex8String()),"name"===t&&(e=this.toName()),"hsl"===t&&(e=this.toHslString()),"hsv"===t&&(e=this.toHsvString()),e||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return o(this.toString())},_applyModification:function(t,r){var e=t.apply(null,[this].concat([].slice.call(r)));return this._r=e._r,this._g=e._g,this._b=e._b,this.setAlpha(e._a),this},lighten:function(){return this._applyModification(g,arguments)},brighten:function(){return this._applyModification(b,arguments)},darken:function(){return this._applyModification(m,arguments)},desaturate:function(){return this._applyModification(l,arguments)},saturate:function(){return this._applyModification(c,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(p,arguments)},_applyCombination:function(t,r){return t.apply(null,[this].concat([].slice.call(r)))},analogous:function(){return this._applyCombination(y,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(x,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(v,[3])},tetrad:function(){return this._applyCombination(v,[4])}},o.fromRatio=function(t,r){if("object"==n(t)){var e={};for(var a in t)t.hasOwnProperty(a)&&(e[a]="a"===a?t[a]:C(t[a]));t=e}return o(t,r)},o.equals=function(t,r){return!(!t||!r)&&o(t).toRgbString()==o(r).toRgbString()},o.random=function(){return o.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},o.mix=function(t,r,e){e=0===e?0:e||50;var n=o(t).toRgb(),a=o(r).toRgb(),i=e/100;return o({r:(a.r-n.r)*i+n.r,g:(a.g-n.g)*i+n.g,b:(a.b-n.b)*i+n.b,a:(a.a-n.a)*i+n.a})},o.readability=function(t,r){var e=o(t),n=o(r);return(Math.max(e.getLuminance(),n.getLuminance())+.05)/(Math.min(e.getLuminance(),n.getLuminance())+.05)},o.isReadable=function(t,r,e){var n,a,i,h,s,f=o.readability(t,r);switch(a=!1,(i=e,"AA"!==(h=((i=i||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==h&&(h="AA"),"small"!==(s=(i.size||"small").toLowerCase())&&"large"!==s&&(s="small"),n={level:h,size:s}).level+n.size){case"AAsmall":case"AAAlarge":a=f>=4.5;break;case"AAlarge":a=f>=3;break;case"AAAsmall":a=f>=7}return a},o.mostReadable=function(t,r,e){var n,a,i,h,s=null,f=0;a=(e=e||{}).includeFallbackColors,i=e.level,h=e.size;for(var u=0;u<r.length;u++)(n=o.readability(t,r[u]))>f&&(f=n,s=o(r[u]));return o.isReadable(t,s,{level:i,size:h})||!a?s:(e.includeFallbackColors=!1,o.mostReadable(t,["#fff","#000"],e))};var A=o.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},w=o.hexNames=function(t){var r={};for(var e in t)t.hasOwnProperty(e)&&(r[t[e]]=e);return r}(A);function k(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function S(t,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var e=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=Math.min(r,Math.max(0,parseFloat(t))),e&&(t=parseInt(t*r,10)/100),Math.abs(t-r)<1e-6?1:t%r/parseFloat(r)}function H(t){return Math.min(1,Math.max(0,t))}function R(t){return parseInt(t,16)}function F(t){return 1==t.length?"0"+t:""+t}function C(t){return t<=1&&(t=100*t+"%"),t}function E(t){return Math.round(255*parseFloat(t)).toString(16)}function q(t){return R(t)/255}var N,j,I,L=(j="[\\s|\\(]+("+(N="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+N+")[,|\\s]+("+N+")\\s*\\)?",I="[\\s|\\(]+("+N+")[,|\\s]+("+N+")[,|\\s]+("+N+")[,|\\s]+("+N+")\\s*\\)?",{CSS_UNIT:new RegExp(N),rgb:new RegExp("rgb"+j),rgba:new RegExp("rgba"+I),hsl:new RegExp("hsl"+j),hsla:new RegExp("hsla"+I),hsv:new RegExp("hsv"+j),hsva:new RegExp("hsva"+I),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function z(t){return!!L.CSS_UNIT.exec(t)}function T(t,r,e,n,a,i){let o,h,s,f,u;if("function"==typeof r)u=r,o=0,h=0,s=t.bitmap.width,f=t.bitmap.height;else{if(o=r,"number"!=typeof e)throw new Error("y must be a number");if(h=e,"number"!=typeof n)throw new Error("w must be a number");if(s=n,"number"!=typeof a)throw new Error("h must be a number");if(f=a,"function"!=typeof i)throw new Error("cb must be a function");u=i}o=Math.round(o),h=Math.round(h),s=Math.round(s),f=Math.round(f);const l=u.bind(t);for(let r=h;r<h+f;r++)for(let e=o;e<o+s;e++)l(e,r,t.bitmap.width*r+e<<2);return t}function*O(t,r,e,n,a){r=Math.round(r),e=Math.round(e),n=Math.round(n),a=Math.round(a);for(let i=e;i<e+a;i++)for(let e=r;e<r+n;e++){const r=t.bitmap.width*i+e<<2;yield{x:e,y:i,idx:r,image:t}}}function P(t){return t=Math.max(t,0),Math.min(t,255)}function $(t){return"number"==typeof t?t:parseInt(o(t).toHex8(),16)}}};
|