sliccy 1.60.0 → 1.62.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 +1 -1
- package/dist/ui/assets/{anthropic-Boy3af-y.js → anthropic-DJckjOlq.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-G5rlwrl5.js → azure-openai-responses-C2FJywrV.js} +1 -1
- package/dist/ui/assets/{cdp-DZeKGOJx.js → cdp-Dln7uDXr.js} +3 -3
- package/dist/ui/assets/dist-BTNmMc0W.js +6 -0
- package/dist/ui/assets/dist-D3v74401.js +12 -0
- package/dist/ui/assets/dist-DNNsRoDw.js +1 -0
- package/dist/ui/assets/{dist-B3JYrjq2.js → dist-Di8uHUFs.js} +2 -2
- package/dist/ui/assets/dist-QUgp9WHE.js +23 -0
- package/dist/ui/assets/dist-naddiFT8.js +1 -0
- package/dist/ui/assets/{env-api-keys-DlVZ9FrG.js → env-api-keys-qwjmVNjS.js} +1 -1
- package/dist/ui/assets/{google-CiqbbNbH.js → google-CchlJ2pb.js} +1 -1
- package/dist/ui/assets/{google-gemini-cli-3AIzUCEY.js → google-gemini-cli-BAp8rpk2.js} +1 -1
- package/dist/ui/assets/{google-shared-BQIq1jLR.js → google-shared-CQBCs09B.js} +1 -1
- package/dist/ui/assets/{google-vertex-CYEauGk8.js → google-vertex-BGVALhcw.js} +1 -1
- package/dist/ui/assets/{index-E1B9kb9t.css → index-BKr9s8eO.css} +1 -1
- package/dist/ui/assets/{index-CuhOB_iL.js → index-D0lLs-87.js} +467 -132
- package/dist/ui/assets/lick-manager-BYOpVqJe.js +1 -0
- package/dist/ui/assets/{magick-wasm-BsXj6zh2.js → magick-wasm-zICxCuIf.js} +1 -1
- package/dist/ui/assets/{mistral-DlH9JH9-.js → mistral-BQjOMDVy.js} +1 -1
- package/dist/ui/assets/{openai-codex-responses-BAgPA0HP.js → openai-codex-responses-D__tCT7_.js} +1 -1
- package/dist/ui/assets/{openai-completions-CD0ojk0e.js → openai-completions-BPXYpKig.js} +1 -1
- package/dist/ui/assets/{openai-responses-CUf4U6xB.js → openai-responses-CaBkqdM9.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-DcVKlc8e.js → openai-responses-shared-BcQ7jhVk.js} +1 -1
- package/dist/ui/assets/{pdfjs-DqPUb7Z_.js → pdfjs-CiRlXug8.js} +1 -1
- package/dist/ui/assets/{provider-settings-Dr2RHpL6.js → provider-settings-C5wu60VY.js} +1 -1
- package/dist/ui/assets/{provider-settings-BmSR5EGC.js → provider-settings-Cd1ewVSe.js} +4 -4
- package/dist/ui/assets/providers-BBlrK0ha.js +1 -0
- package/dist/ui/assets/{pyodide-CDyS-YOW.js → pyodide-BIt8RVoH.js} +1 -1
- package/dist/ui/assets/secret-env-BpF8oEtM.js +1 -0
- package/dist/ui/assets/shell-1TCSfA9a.js +1 -0
- package/dist/ui/assets/slicc-editor-BZFYYDy6.js +12 -0
- package/dist/ui/assets/sprinkle-renderer-Dg53jWV0.js +1 -0
- package/dist/ui/index.html +8 -8
- package/dist/ui/lucide-icons.js +1717 -0
- package/dist/ui/packages/webapp/index.html +8 -8
- package/dist/ui/slicc-diff.js +1874 -0
- package/dist/ui/slicc-editor.js +39 -0
- package/package.json +1 -1
- package/dist/ui/assets/lick-manager-C-A7CGJX.js +0 -1
- package/dist/ui/assets/providers-DD66IcEk.js +0 -1
- package/dist/ui/assets/secret-env-D83DkY1_.js +0 -1
- package/dist/ui/assets/shell-Cyv5Aspu.js +0 -1
- package/dist/ui/assets/sprinkle-renderer-C2J1zYa4.js +0 -1
- /package/dist/ui/assets/{addon-fit-CJBYijzN.js → addon-fit-D9TBVRj9.js} +0 -0
- /package/dist/ui/assets/{bsh-watchdog-BaiyTJC8.js → bsh-watchdog-UyxqvRBs.js} +0 -0
- /package/dist/ui/assets/{dist-B5eLXQdt.js → dist-DgEIzJ_s.js} +0 -0
- /package/dist/ui/assets/{github-copilot-headers-BpGzQFlb.js → github-copilot-headers-CRKKjjGu.js} +0 -0
- /package/dist/ui/assets/{hash-K0cSe8jy.js → hash-BVv7lWoO.js} +0 -0
- /package/dist/ui/assets/{lick-manager-proxy-BsVSy3SO.js → lick-manager-proxy-IUmr_HMW.js} +0 -0
- /package/dist/ui/assets/{oauth-service-t9Y4KdOX.js → oauth-service-BPHxAgX7.js} +0 -0
- /package/dist/ui/assets/{offscreen-client-BhqrZE0B.js → offscreen-client-BMlTH2Sh.js} +0 -0
- /package/dist/ui/assets/{preload-helper-ca-nBW7U.js → preload-helper-D4M6sveU.js} +0 -0
- /package/dist/ui/assets/{sanitize-unicode-BA6bNBBh.js → sanitize-unicode-Cj3sbkBy.js} +0 -0
- /package/dist/ui/assets/{secret-masking-CfbASE5x.js → secret-masking-B5wKpwRC.js} +0 -0
- /package/dist/ui/assets/{sql-wasm-Cx-UtEsl.js → sql-wasm-CLEWdRiw.js} +0 -0
- /package/dist/ui/assets/{tray-follower-status-BlQSlF6m.js → tray-follower-status-LqS6IS1u.js} +0 -0
- /package/dist/ui/assets/{xterm-DHgoOdoP.js → xterm-CGWDoeX1.js} +0 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ If this scares, confuses, or excites you, keep reading.
|
|
|
11
11
|
|
|
12
12
|
# slicc — Self-Licking Ice Cream Cone
|
|
13
13
|
|
|
14
|
-
[](https://github.com/ai-ecoverse/vibe-coded-badge-action)
|
|
15
15
|
|
|
16
16
|
[](https://www.npmjs.com/package/sliccy)
|
|
17
17
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./env-api-keys-
|
|
1
|
+
import{t as e}from"./env-api-keys-qwjmVNjS.js";import{a as t,i as n,n as r,s as i,t as a}from"./simple-options-DZXt61Q2.js";import{t as o}from"./json-parse-JW3qhabb.js";import{t as s}from"./sanitize-unicode-Cj3sbkBy.js";import{n as c,t as l}from"./github-copilot-headers-CRKKjjGu.js";function u(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function d(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var f=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return f=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function p(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var ee=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},m=class extends Error{},h=class e extends m{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new te({message:r,cause:ee(n)});let a=n;return t===400?new re(t,a,r,i):t===401?new ie(t,a,r,i):t===403?new ae(t,a,r,i):t===404?new oe(t,a,r,i):t===409?new se(t,a,r,i):t===422?new ce(t,a,r,i):t===429?new le(t,a,r,i):t>=500?new ue(t,a,r,i):new e(t,a,r,i)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},te=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ne=class extends te{constructor({message:e}={}){super({message:e??`Request timed out.`})}},re=class extends h{},ie=class extends h{},ae=class extends h{},oe=class extends h{},se=class extends h{},ce=class extends h{},le=class extends h{},ue=class extends h{},de=/^[a-z][a-z0-9+.-]*:/i,fe=e=>de.test(e),pe=e=>(pe=Array.isArray,pe(e)),me=pe;function he(e){return typeof e==`object`?e??{}:{}}function ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function _e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ve=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},ye=e=>{try{return JSON.parse(e)}catch{return}},be=e=>new Promise(t=>setTimeout(t,e)),_=`0.73.0`,xe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Ce=()=>{let e=Se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":Ee(Deno.build.os),"X-Stainless-Arch":Te(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":Ee(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Te(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=we();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function we(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Te=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ee=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),De,Oe=()=>De??=Ce();function ke(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ae(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function je(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ae({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Me(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ne(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Pe=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Fe(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Ie;function Le(e){let t;return(Ie??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Re;function ze(e){let t;return(Re??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var v,y,b=class{constructor(){v.set(this,void 0),y.set(this,void 0),u(this,v,new Uint8Array,`f`),u(this,y,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Le(e):e;u(this,v,Fe([d(this,v,`f`),t]),`f`);let n=[],r;for(;(r=Be(d(this,v,`f`),d(this,y,`f`)))!=null;){if(r.carriage&&d(this,y,`f`)==null){u(this,y,r.index,`f`);continue}if(d(this,y,`f`)!=null&&(r.index!==d(this,y,`f`)+1||r.carriage)){n.push(ze(d(this,v,`f`).subarray(0,d(this,y,`f`)-1))),u(this,v,d(this,v,`f`).subarray(d(this,y,`f`)),`f`),u(this,y,null,`f`);continue}let e=d(this,y,`f`)===null?r.preceding:r.preceding-1,t=ze(d(this,v,`f`).subarray(0,e));n.push(t),u(this,v,d(this,v,`f`).subarray(r.index),`f`),u(this,y,null,`f`)}return n}flush(){return d(this,v,`f`).length?this.decode(`
|
|
2
2
|
`):[]}};v=new WeakMap,y=new WeakMap,b.NEWLINE_CHARS=new Set([`
|
|
3
3
|
`,`\r`]),b.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Be(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function Ve(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var He={off:0,error:200,warn:300,info:400,debug:500},Ue=(e,t,n)=>{if(e){if(_e(He,e))return e;S(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(He))}`)}};function x(){}function We(e,t,n){return!t||He[e]>He[n]?x:t[e].bind(t)}var Ge={error:x,warn:x,info:x,debug:x},Ke=new WeakMap;function S(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Ge;let r=Ke.get(t);if(r&&r[0]===n)return r[1];let i={error:We(`error`,t,n),warn:We(`warn`,t,n),info:We(`info`,t,n),debug:We(`debug`,t,n)};return Ke.set(t,[n,i]),i}var C=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),qe,Je=class e{constructor(e,t,n){this.iterator=e,qe.set(this,void 0),this.controller=t,u(this,qe,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?S(r):console;async function*o(){if(i)throw new m("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of Ye(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`)throw new h(void 0,ye(e.data)??e.data,void 0,t.headers)}e=!0}catch(e){if(p(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new b,n=Me(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new m("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(p(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(qe=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,d(this,qe,`f`)),new e(()=>i(n),this.controller,d(this,qe,`f`))]}toReadableStream(){let e=this,t;return Ae({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Le(JSON.stringify(n)+`
|
|
4
4
|
`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}};async function*Ye(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new m(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new m(`Attempted to iterate over a response with no body`);let n=new Ze,r=new b,i=Me(e.body);for await(let e of Xe(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Xe(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Le(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=Ve(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}var Ze=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
|
package/dist/ui/assets/{azure-openai-responses-G5rlwrl5.js → azure-openai-responses-C2FJywrV.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./env-api-keys-
|
|
1
|
+
import{t as e}from"./env-api-keys-qwjmVNjS.js";import{a as t,d as n,n as r,r as i}from"./simple-options-DZXt61Q2.js";import{t as a}from"./openai-Cn7eGqwa.js";import{n as o,r as s,t as c}from"./openai-responses-shared-BcQ7jhVk.js";var l=`v1`,u=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function d(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function f(e,t){return t?.azureDeploymentName?t.azureDeploymentName:d({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}var p=(n,r,i)=>{let a=new t;return(async()=>{let t=f(n,i),o={role:`assistant`,content:[],api:`azure-openai-responses`,provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=v(n,i?.apiKey||e(n.provider)||``,i),l=y(n,r,i,t),u=await i?.onPayload?.(l,n);u!==void 0&&(l=u);let d=await c.responses.create(l,i?.signal?{signal:i.signal}:void 0);if(a.push({type:`start`,partial:o}),await s(d,o,a,n),i?.signal?.aborted)throw Error(`Request was aborted`);if(o.stopReason===`aborted`||o.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:o.stopReason,message:o}),a.end()}catch(e){for(let e of o.content)delete e.index;o.stopReason=i?.signal?.aborted?`aborted`:`error`,o.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:o.stopReason,error:o}),a.end()}})(),a},m=(t,a,o)=>{let s=o?.apiKey||e(t.provider);if(!s)throw Error(`No API key for provider: ${t.provider}`);let c=r(t,o,s),l=n(t)?o?.reasoning:i(o?.reasoning);return p(t,a,{...c,reasoningEffort:l})};function h(e){return e.replace(/\/+$/,``)}function g(e){return`https://${e}.openai.azure.com/openai/v1`}function _(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||l,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=g(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:h(a),apiVersion:n}}function v(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:i,apiVersion:o}=_(e,n);return new a({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:i})}function y(e,t,n,r){let i={model:r,input:c(e,t,u),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&(i.tools=o(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):i.reasoning={effort:`none`}),i}export{p as streamAzureOpenAIResponses,m as streamSimpleAzureOpenAIResponses};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-
|
|
2
|
-
import{r as e}from"./chunk-zsgVPwQN.js";import{t}from"./logger-B-No_qN_.js";import{t as n}from"./preload-helper-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-zICxCuIf.js","assets/chunk-zsgVPwQN.js","assets/preload-helper-D4M6sveU.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./chunk-zsgVPwQN.js";import{t}from"./logger-B-No_qN_.js";import{t as n}from"./preload-helper-D4M6sveU.js";var r=t(`cdp`),i=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,r.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(r.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),r.info(`Disconnected`)}async send(e,t,n,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),n&&(o.sessionId=n),r.debug(`Send`,{method:e,id:a,sessionId:n}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;r.debug(`Response`,{id:e.id,hasError:!!e.error});let n=this.pending.get(e.id);n&&(this.pending.delete(e.id),e.error?(r.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),n.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):n.resolve(e.result??{}));return}if(`method`in t){let e=t;r.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(){r.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function a(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var o=`(function() {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
// ===== DOM Utilities =====
|
|
@@ -869,7 +869,7 @@ import{r as e}from"./chunk-zsgVPwQN.js";import{t}from"./logger-B-No_qN_.js";impo
|
|
|
869
869
|
} catch(e) {
|
|
870
870
|
return { role: 'RootWebArea', name: '', description: 'Error: ' + (e.message || String(e)) };
|
|
871
871
|
}
|
|
872
|
-
})()`,s=`ws://localhost:5710/cdp`,c=t(`browser-api`);function l(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:s}var u=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),c.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){c.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new i,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??l(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);return this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r},this.sessionId=(await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0})).sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}return this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected(),this.sessionId=(await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0})).sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let t={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(t.quality=e.quality),e?.clip||e?.fullPage){let n=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),t=JSON.parse(e.result?.value??`{}`);n=t.w??0,r=t.h??0}catch{}e?.clip?t.clip={...e.clip,scale:e.clip.scale??1}:t.clip={x:0,y:0,width:n||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:t}=await n(async()=>{let{getMagick:e}=await import(`./magick-wasm-
|
|
872
|
+
})()`,s=`ws://localhost:5710/cdp`,c=t(`browser-api`);function l(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:s}var u=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),c.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){c.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new i,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??l(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);return this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r},this.sessionId=(await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0})).sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}return this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected(),this.sessionId=(await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0})).sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let t={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(t.quality=e.quality),e?.clip||e?.fullPage){let n=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),t=JSON.parse(e.result?.value??`{}`);n=t.w??0,r=t.h??0}catch{}e?.clip?t.clip={...e.clip,scale:e.clip.scale??1}:t.clip={x:0,y:0,width:n||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,t,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:t}=await n(async()=>{let{getMagick:e}=await import(`./magick-wasm-zICxCuIf.js`).then(e=>e.n);return{getMagick:e}},__vite__mapDeps([0,1,2])),r=await t(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async t=>{let n=Math.min(e.maxWidth,s),r=Math.max(t.width,t.height);if(t.width>n||r>s){let e=Math.min(n/t.width,s/r);t.resize(Math.round(t.width*e),Math.round(t.height*e)),c=!0}c&&t.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(o,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:d(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
|
|
873
873
|
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
874
874
|
const r = this.getBoundingClientRect();
|
|
875
875
|
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{A as e,C as t,D as n,G as r,H as i,P as a,Q as o,S as s,V as c,_ as l,a as u,at as d,b as f,dt as p,et as m,f as h,g,i as ee,lt as te,nt as _,o as ne,ot as re,s as ie,st as v,tt as y,ut as b}from"./dist-D3v74401.js";import{html as ae,htmlCompletionSource as oe,t as se}from"./dist-QUgp9WHE.js";var ce=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[d.contextHash,r]]}addChild(e,t){e.prop(d.contextHash)!=this.hash&&(e=new b(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new b(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new b(v.none,e,t,n,this.hashProp)})}},x;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(x||={});var le=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},ue=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return C(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function de(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==x.OrderedList?D:E)(n,t,!1);return r>0&&(e.type!=x.BulletList||w(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var fe={[x.Blockquote](e,t,n){return n.next==62?(n.markers.push(R(x.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(S(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[x.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[x.OrderedList]:de,[x.BulletList]:de,[x.Document](){return!0}};function S(e){return e==32||e==9||e==10||e==13}function C(e,t=0){for(;t<e.length&&S(e.charCodeAt(t));)t++;return t}function pe(e,t,n){for(;t>n&&S(e.charCodeAt(t-1));)t--;return t}function me(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function he(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function w(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!S(n))return-1}return n&&e.next==45&&_e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(we.SetextHeading)>-1||r<3?-1:1}function T(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function E(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||S(e.text.charCodeAt(e.pos+1)))&&(!n||T(t,x.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function D(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!S(e.text.charCodeAt(r+1))||n&&!T(t,x.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function ge(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function _e(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&S(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var O=/^[ \t]*$/,ve=/-->/,ye=/\?>/,k=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ve],[/^\s*<\?/,ye],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,O],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,O]];function be(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=k.length-+!!n;e<t;e++)if(k[e][0].test(r))return e;return-1}function xe(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function A(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==x.CodeText?e[r].to=n:e.push(R(x.CodeText,t,n))}var j={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(A(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){A(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==x.CodeText?A(o,e.from,e.to):o.push(e);s=[]}A(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&A(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=x.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(x.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=me(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=pe(t.text,t.text.length,o),c=[R(x.CodeMark,r,r+a)];o<s&&c.push(R(x.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&A(c,e.lineStart-1,e.lineStart),c.push(R(x.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(A(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(A(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(x.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=he(t);return n<0?!1:(e.startContext(x.Blockquote,t.pos),e.addNode(x.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(w(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(x.HorizontalRule,n),!0},BulletList(e,t){let n=E(t,e,!1);if(n<0)return!1;e.block.type!=x.BulletList&&e.startContext(x.BulletList,t.basePos,t.next);let r=xe(t,t.pos+1);return e.startContext(x.ListItem,t.basePos,r-t.baseIndent),e.addNode(x.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=D(t,e,!1);if(n<0)return!1;e.block.type!=x.OrderedList&&e.startContext(x.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=xe(t,t.pos+n);return e.startContext(x.ListItem,t.basePos,r-t.baseIndent),e.addNode(x.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=ge(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=pe(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!S(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(x.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(x.HeaderMark,o-r,a-r);let c=s.finish(x.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=be(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=k[n][1],a=[],o=i!=O;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==ve?x.CommentBlock:i==ye?x.ProcessingInstructionBlock:x.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},Se=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
|
|
2
|
+
`+t.scrub(),i=this.advance(r);return i>-1&&i<r.length?this.complete(e,n,i):!1}finish(e,t){return(this.stage==2||this.stage==3)&&C(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,R(x.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(ze(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(R(x.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Le(e,C(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=C(e,this.pos),n=0;if(t>this.pos){let r=Re(e,t,this.start);if(r){let t=M(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=M(e,this.pos),n>0&&n<e.length?n:-1}else return M(e,this.pos)}};function M(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!S(n))return-1}return t}var Ce=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:_e(t),i=t.next;if(r<0)return!1;let a=R(x.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,R(i==61?x.SetextHeading1:x.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},we={LinkReference(e,t){return t.content.charCodeAt(0)==91?new Se(t):null},SetextHeading(){return new Ce}},Te=[(e,t)=>ge(t)>=0,(e,t)=>me(t)>=0,(e,t)=>he(t)>=0,(e,t)=>E(t,e,!0)>=0,(e,t)=>D(t,e,!0)>=0,(e,t)=>w(t,e,!0)>=0,(e,t)=>be(t,e,!0)>=0],Ee={text:``,end:0},De=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new ue,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=ce.create(x.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Ve(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}let t=new le(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
|
|
3
|
+
`+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=He(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=Ee;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+x[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
|
|
4
|
+
`?``:t;else{let e=t.indexOf(`
|
|
5
|
+
`);n=e<0?t:t.slice(0,e)}return e+n.length>this.to?n.slice(0,this.to-e):n}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,n=0){this.block=ce.create(e,n,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,n=0){this.startContext(this.parser.getNodeType(e),t,n)}addNode(e,t,n){typeof e==`number`&&(e=new b(this.parser.nodeSet.types[e],I,I,(n??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(G(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?Oe(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let t of e.parsers)if(t.finish(this,e))return;let t=G(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(x.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return typeof e==`string`?R(this.parser.getNodeType(e),t,n,r):new Me(e,t)}get buffer(){return new je(this.parser.nodeSet)}};function Oe(e,t,n,r,i){let a=e[t].to,o=[],s=[],c=n.from+r;function l(n,i){for(;i?n>=a:n>a;){let i=e[t+1].from-a;r+=i,n+=i,t++,a=e[t].to}}for(let u=n.firstChild;u;u=u.nextSibling){l(u.from+r,!0);let n=u.from+r,d,f=i.get(u.tree);f?d=f:u.to+r>a?(d=Oe(e,t,u,r,i),l(u.to+r,!1)):d=u.toTree(),o.push(d),s.push(n-c)}return l(n.to+r,!1),new b(n.type,o,s,n.to+r-c,n.tree?n.tree.propValues:void 0)}var ke=class e extends te{constructor(e,t,n,r,i,a,o,s,c){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=n,this.blockNames=r,this.endLeafBlock=i,this.skipContextMarkup=a,this.inlineParsers=o,this.inlineNames=s,this.wrappers=c,this.nodeTypes=Object.create(null);for(let t of e.types)this.nodeTypes[t.name]=t.id}createParse(e,t,n){let r=new De(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}configure(t){let n=P(t);if(!n)return this;let{nodeSet:r,skipContextMarkup:i}=this,a=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),s=this.blockNames.slice(),c=this.inlineParsers.slice(),l=this.inlineNames.slice(),u=this.endLeafBlock.slice(),f=this.wrappers;if(N(n.defineNodes)){i=Object.assign({},i);let e=r.types.slice(),t;for(let r of n.defineNodes){let{name:n,block:a,composite:o,style:s}=typeof r==`string`?{name:r}:r;if(e.some(e=>e.name==n))continue;o&&(i[e.length]=(e,t,n)=>o(t,n,e.value));let c=e.length,l=o?[`Block`,`BlockContext`]:a?c>=x.ATXHeading1&&c<=x.SetextHeading2?[`Block`,`LeafBlock`,`Heading`]:[`Block`,`LeafBlock`]:void 0;e.push(v.define({id:c,name:n,props:l&&[[d.group,l]]})),s&&(t||={},Array.isArray(s)||s instanceof m?t[n]=s:Object.assign(t,s))}r=new re(e),t&&(r=r.extend(y(t)))}if(N(n.props)&&(r=r.extend(...n.props)),N(n.remove))for(let e of n.remove){let t=this.blockNames.indexOf(e),n=this.inlineNames.indexOf(e);t>-1&&(a[t]=o[t]=void 0),n>-1&&(c[n]=void 0)}if(N(n.parseBlock))for(let e of n.parseBlock){let t=s.indexOf(e.name);if(t>-1)a[t]=e.parse,o[t]=e.leaf;else{let t=e.before?F(s,e.before):e.after?F(s,e.after)+1:s.length-1;a.splice(t,0,e.parse),o.splice(t,0,e.leaf),s.splice(t,0,e.name)}e.endLeaf&&u.push(e.endLeaf)}if(N(n.parseInline))for(let e of n.parseInline){let t=l.indexOf(e.name);if(t>-1)c[t]=e.parse;else{let t=e.before?F(l,e.before):e.after?F(l,e.after)+1:l.length-1;c.splice(t,0,e.parse),l.splice(t,0,e.name)}}return n.wrap&&(f=f.concat(n.wrap)),new e(r,a,o,s,u,i,c,l,f)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let n=new W(this,e,t);outer:for(let e=t;e<n.end;){let t=n.char(e);for(let r of this.inlineParsers)if(r){let i=r(n,t,e);if(i>=0){e=i;continue outer}}e++}return n.resolveMarkers(0)}};function N(e){return e!=null&&e.length>0}function P(e){if(!Array.isArray(e))return e;if(e.length==0)return null;let t=P(e[0]);if(e.length==1)return t;let n=P(e.slice(1));if(!n||!t)return t||n;let r=(e,t)=>(e||I).concat(t||I),i=t.wrap,a=n.wrap;return{props:r(t.props,n.props),defineNodes:r(t.defineNodes,n.defineNodes),parseBlock:r(t.parseBlock,n.parseBlock),parseInline:r(t.parseInline,n.parseInline),remove:r(t.remove,n.remove),wrap:i?a?(e,t,n,r)=>i(a(e,t,n,r),t,n,r):i:a}}function F(e,t){let n=e.indexOf(t);if(n<0)throw RangeError(`Position specified relative to unknown parser ${t}`);return n}var Ae=[v.none];for(let e=1,t;t=x[e];e++)Ae[e]=v.define({id:e,name:t,props:e>=x.Escape?[]:[[d.group,e in fe?[`Block`,`BlockContext`]:[`Block`,`LeafBlock`]]],top:t==`Document`});var I=[],je=class{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,n,r=0){return this.content.push(e,t,n,4+r*4),this}writeElements(e,t=0){for(let n of e)n.writeTo(this,t);return this}finish(e,t){return b.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}},L=class{constructor(e,t,n,r=I){this.type=e,this.from=t,this.to=n,this.children=r}writeTo(e,t){let n=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-n)}toTree(e){return new je(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},Me=class{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return I}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}};function R(e,t,n,r){return new L(e,t,n,r)}var Ne={resolve:`Emphasis`,mark:`EmphasisMark`},Pe={resolve:`Emphasis`,mark:`EmphasisMark`},z={},B={},V=class{constructor(e,t,n,r){this.type=e,this.from=t,this.to=n,this.side=r}},Fe=`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`,H=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{H=RegExp(`[\\p{S}|\\p{P}]`,`u`)}catch{}var U={Escape(e,t,n){if(t!=92||n==e.end-1)return-1;let r=e.char(n+1);for(let t=0;t<32;t++)if(Fe.charCodeAt(t)==r)return e.append(R(x.Escape,n,n+2));return-1},Entity(e,t,n){if(t!=38)return-1;let r=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(e.slice(n+1,n+31));return r?e.append(R(x.Entity,n,n+1+r[0].length)):-1},InlineCode(e,t,n){if(t!=96||n&&e.char(n-1)==96)return-1;let r=n+1;for(;r<e.end&&e.char(r)==96;)r++;let i=r-n,a=0;for(;r<e.end;r++)if(e.char(r)==96){if(a++,a==i&&e.char(r+1)!=96)return e.append(R(x.InlineCode,n,r+1,[R(x.CodeMark,n,n+i),R(x.CodeMark,r+1-i,r+1)]))}else a=0;return-1},HTMLTag(e,t,n){if(t!=60||n==e.end-1)return-1;let r=e.slice(n+1,e.end),i=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(r);if(i)return e.append(R(x.Autolink,n,n+1+i[0].length,[R(x.LinkMark,n,n+1),R(x.URL,n+1,n+i[0].length),R(x.LinkMark,n+i[0].length,n+1+i[0].length)]));let a=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(r);if(a)return e.append(R(x.Comment,n,n+1+a[0].length));let o=/^\?[^]*?\?>/.exec(r);if(o)return e.append(R(x.ProcessingInstruction,n,n+1+o[0].length));let s=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);return s?e.append(R(x.HTMLTag,n,n+1+s[0].length)):-1},Emphasis(e,t,n){if(t!=95&&t!=42)return-1;let r=n+1;for(;e.char(r)==t;)r++;let i=e.slice(n-1,n),a=e.slice(r,r+1),o=H.test(i),s=H.test(a),c=/\s|^$/.test(i),l=/\s|^$/.test(a),u=!l&&(!s||c||o),d=!c&&(!o||l||s),f=u&&(t==42||!d||o),p=d&&(t==42||!u||s);return e.append(new V(t==95?Ne:Pe,n,r,!!f|(p?2:0)))},HardBreak(e,t,n){if(t==92&&e.char(n+1)==10)return e.append(R(x.HardBreak,n,n+2));if(t==32){let t=n+1;for(;e.char(t)==32;)t++;if(e.char(t)==10&&t>=n+2)return e.append(R(x.HardBreak,n,t+1))}return-1},Link(e,t,n){return t==91?e.append(new V(z,n,n+1,1)):-1},Image(e,t,n){return t==33&&e.char(n+1)==91?e.append(new V(B,n,n+2,1)):-1},LinkEnd(e,t,n){if(t!=93)return-1;for(let t=e.parts.length-1;t>=0;t--){let r=e.parts[t];if(r instanceof V&&(r.type==z||r.type==B)){if(!r.side||e.skipSpace(r.to)==n&&!/[(\[]/.test(e.slice(n+1,n+2)))return e.parts[t]=null,-1;let i=e.takeContent(t),a=e.parts[t]=Ie(e,i,r.type==z?x.Link:x.Image,r.from,n+1);if(r.type==z)for(let n=0;n<t;n++){let t=e.parts[n];t instanceof V&&t.type==z&&(t.side=0)}return a.to}}return-1}};function Ie(e,t,n,r,i){let{text:a}=e,o=e.char(i),s=i;if(t.unshift(R(x.LinkMark,r,r+(n==x.Image?2:1))),t.push(R(x.LinkMark,i-1,i)),o==40){let n=e.skipSpace(i+1),r=Le(a,n-e.offset,e.offset),o;r&&(n=e.skipSpace(r.to),n!=r.to&&(o=Re(a,n-e.offset,e.offset),o&&(n=e.skipSpace(o.to)))),e.char(n)==41&&(t.push(R(x.LinkMark,i,i+1)),s=n+1,r&&t.push(r),o&&t.push(o),t.push(R(x.LinkMark,n,s)))}else if(o==91){let n=ze(a,i-e.offset,e.offset,!1);n&&(t.push(n),s=n.to)}return R(n,r,s,t)}function Le(e,t,n){if(e.charCodeAt(t)==60){for(let r=t+1;r<e.length;r++){let i=e.charCodeAt(r);if(i==62)return R(x.URL,t+n,r+1+n);if(i==60||i==10)return!1}return null}else{let r=0,i=t;for(let t=!1;i<e.length;i++){let n=e.charCodeAt(i);if(S(n))break;if(t)t=!1;else if(n==40)r++;else if(n==41){if(!r)break;r--}else n==92&&(t=!0)}return i>t?R(x.URL,t+n,i+n):i==e.length?null:!1}}function Re(e,t,n){let r=e.charCodeAt(t);if(r!=39&&r!=34&&r!=40)return!1;let i=r==40?41:r;for(let r=t+1,a=!1;r<e.length;r++){let o=e.charCodeAt(r);if(a)a=!1;else if(o==i)return R(x.LinkTitle,t+n,r+1+n);else o==92&&(a=!0)}return null}function ze(e,t,n,r){for(let i=!1,a=t+1,o=Math.min(e.length,a+999);a<o;a++){let o=e.charCodeAt(a);if(i)i=!1;else if(o==93)return r?!1:R(x.LinkLabel,t+n,a+1+n);else{if(r&&!S(o)&&(r=!1),o==91)return!1;o==92&&(i=!0)}}return null}var W=class{constructor(e,t,n){this.parser=e,this.text=t,this.offset=n,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,n,r,i){return this.append(new V(e,t,n,!!r|(i?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof V&&(t.type==z||t.type==B))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let t=e;t<this.parts.length;t++){let n=this.parts[t];if(!(n instanceof V&&n.type.resolve&&n.side&2))continue;let r=n.type==Ne||n.type==Pe,i=n.to-n.from,a,o=t-1;for(;o>=e;o--){let e=this.parts[o];if(e instanceof V&&e.side&1&&e.type==n.type&&!(r&&(n.side&1||e.side&2)&&(e.to-e.from+i)%3==0&&((e.to-e.from)%3||i%3))){a=e;break}}if(!a)continue;let s=n.type.resolve,c=[],l=a.from,u=n.to;if(r){let e=Math.min(2,a.to-a.from,i);l=a.to-e,u=n.from+e,s=e==1?`Emphasis`:`StrongEmphasis`}a.type.mark&&c.push(this.elt(a.type.mark,l,a.to));for(let e=o+1;e<t;e++)this.parts[e]instanceof L&&c.push(this.parts[e]),this.parts[e]=null;n.type.mark&&c.push(this.elt(n.type.mark,n.from,u));let d=this.elt(s,l,u,c);this.parts[o]=r&&a.from!=l?new V(a.type,a.from,l,a.side):null,(this.parts[t]=r&&n.to!=u?new V(n.type,u,n.to,n.side):null)?this.parts.splice(t,0,d):this.parts[t]=d}let t=[];for(let n=e;n<this.parts.length;n++){let e=this.parts[n];e instanceof L&&t.push(e)}return t}findOpeningDelimiter(e){for(let t=this.parts.length-1;t>=0;t--){let n=this.parts[t];if(n instanceof V&&n.type==e&&n.side&1)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof V?t:null}skipSpace(e){return C(this.text,e-this.offset)+this.offset}elt(e,t,n,r){return typeof e==`string`?R(this.parser.getNodeType(e),t,n,r):new Me(e,t)}};W.linkStart=z,W.imageStart=B;function G(e,t){if(!t.length)return e;if(!e.length)return t;let n=e.slice(),r=0;for(let e of t){for(;r<n.length&&n[r].to<e.to;)r++;if(r<n.length&&n[r].from<e.from){let t=n[r];t instanceof L&&(n[r]=new L(t.type,t.from,t.to,G(t.children,[e])))}else n.splice(r++,0,e)}return n}var Be=[x.CodeBlock,x.ListItem,x.OrderedList,x.BulletList],Ve=class{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,t){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let e=this.fragment.to;for(;e>0&&this.input.read(e-1,e)!=`
|
|
6
|
+
`;)e--;this.fragmentEnd=e?e-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let r=e+this.fragment.offset;for(;n.to<=r;)if(!n.parent())return!1;for(;;){if(n.from>=r)return this.fragment.from<=t;if(!n.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(d.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,r=this.fragmentEnd-+!!this.fragment.openEnd,i=e.absoluteLineStart,a=i,o=e.block.children.length,s=a,c=o;for(;;){if(t.to-n>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let i=He(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,i);else{let n=new b(e.parser.nodeSet.types[x.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(n,t.tree),e.addNode(n,i)}if(t.type.is(`Block`)&&(Be.indexOf(t.type.id)<0?(a=t.to-n,o=e.block.children.length):(a=s,o=c),s=t.to-n,c=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return a-i}};function He(e,t){let n=e;for(let r=1;r<t.length;r++){let i=t[r-1].to,a=t[r].from;i<e&&(n-=a-i)}return n}var Ue=y({"Blockquote/...":_.quote,HorizontalRule:_.contentSeparator,"ATXHeading1/... SetextHeading1/...":_.heading1,"ATXHeading2/... SetextHeading2/...":_.heading2,"ATXHeading3/...":_.heading3,"ATXHeading4/...":_.heading4,"ATXHeading5/...":_.heading5,"ATXHeading6/...":_.heading6,"Comment CommentBlock":_.comment,Escape:_.escape,Entity:_.character,"Emphasis/...":_.emphasis,"StrongEmphasis/...":_.strong,"Link/... Image/...":_.link,"OrderedList/... BulletList/...":_.list,"BlockQuote/...":_.quote,"InlineCode CodeText":_.monospace,"URL Autolink":_.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":_.processingInstruction,"CodeInfo LinkLabel":_.labelName,LinkTitle:_.string,Paragraph:_.content}),We=new ke(new re(Ae).extend(Ue),Object.keys(j).map(e=>j[e]),Object.keys(j).map(e=>we[e]),Object.keys(j),Te,fe,Object.keys(U).map(e=>U[e]),Object.keys(U),[]);function Ge(e,t,n){let r=[];for(let i=e.firstChild,a=t;;i=i.nextSibling){let e=i?i.from:n;if(e>a&&r.push({from:a,to:e}),!i)break;a=i.to}return r}function Ke(e){let{codeParser:t,htmlParser:n}=e;return{wrap:p((e,r)=>{let i=e.type.id;if(t&&(i==x.CodeBlock||i==x.FencedCode)){let n=``;if(i==x.FencedCode){let t=e.node.getChild(x.CodeInfo);t&&(n=r.read(t.from,t.to))}let a=t(n);if(a)return{parser:a,overlay:e=>e.type.id==x.CodeText,bracketed:i==x.FencedCode}}else if(n&&(i==x.HTMLBlock||i==x.HTMLTag||i==x.CommentBlock))return{parser:n,overlay:Ge(e.node,e.from,e.to)};return null})}}var qe={resolve:`Strikethrough`,mark:`StrikethroughMark`},Je={defineNodes:[{name:`Strikethrough`,style:{"Strikethrough/...":_.strikethrough}},{name:`StrikethroughMark`,style:_.processingInstruction}],parseInline:[{name:`Strikethrough`,parse(e,t,n){if(t!=126||e.char(n+1)!=126||e.char(n+2)==126)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=H.test(r),c=H.test(i);return e.addDelimiter(qe,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))},after:`Emphasis`}]};function K(e,t,n=0,r,i=0){let a=0,o=!0,s=-1,c=-1,l=!1,u=()=>{r.push(e.elt(`TableCell`,i+s,i+c,e.parser.parseInline(t.slice(s,c),i+s)))};for(let d=n;d<t.length;d++){let n=t.charCodeAt(d);n==124&&!l?((!o||s>-1)&&a++,o=!1,r&&(s>-1&&u(),r.push(e.elt(`TableDelimiter`,d+i,d+i+1))),s=c=-1):(l||n!=32&&n!=9)&&(s<0&&(s=d),c=d+1),l=!l&&n==92}return s>-1&&(a++,r&&u()),a}function Ye(e,t){for(let n=t;n<e.length;n++){let t=e.charCodeAt(n);if(t==124)return!0;t==92&&n++}return!1}var Xe=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Ze=class{constructor(){this.rows=null}nextLine(e,t,n){if(this.rows==null){this.rows=!1;let r;if((t.next==45||t.next==58||t.next==124)&&Xe.test(r=t.text.slice(t.pos))){let i=[];K(e,n.content,0,i,n.start)==K(e,r,t.pos)&&(this.rows=[e.elt(`TableHeader`,n.start,n.start+n.content.length,i),e.elt(`TableDelimiter`,e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let n=[];K(e,t.text,t.pos,n,e.lineStart),this.rows.push(e.elt(`TableRow`,e.lineStart+t.pos,e.lineStart+t.text.length,n))}return!1}finish(e,t){return this.rows?(e.addLeafElement(t,e.elt(`Table`,t.start,t.start+t.content.length,this.rows)),!0):!1}},Qe={defineNodes:[{name:`Table`,block:!0},{name:`TableHeader`,style:{"TableHeader/...":_.heading}},`TableRow`,{name:`TableCell`,style:_.content},{name:`TableDelimiter`,style:_.processingInstruction}],parseBlock:[{name:`Table`,leaf(e,t){return Ye(t.content,0)?new Ze:null},endLeaf(e,t,n){if(n.parsers.some(e=>e instanceof Ze)||!Ye(t.text,t.basePos))return!1;let r=e.peekLine();return Xe.test(r)&&K(e,t.text,t.basePos)==K(e,r,t.basePos)},before:`SetextHeading`}]},$e=class{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt(`Task`,t.start,t.start+t.content.length,[e.elt(`TaskMarker`,t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}},et={defineNodes:[{name:`Task`,block:!0,style:_.list},{name:`TaskMarker`,style:_.atom}],parseBlock:[{name:`TaskList`,leaf(e,t){return/^\[[ xX]\][ \t]/.test(t.content)&&e.parentType().name==`ListItem`?new $e:null},after:`SetextHeading`}]},tt=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,nt=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,rt=/[\w-]+\.[\w-]+($|\/)/,it=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,at=/\/[a-zA-Z\d@.]+/gy;function ot(e,t,n,r){let i=0;for(let a=t;a<n;a++)e[a]==r&&i++;return i}function st(e,t){nt.lastIndex=t;let n=nt.exec(e);if(!n||rt.exec(n[0])[0].indexOf(`_`)>-1)return-1;let r=t+n[0].length;for(;;){let n=e[r-1],i;if(/[?!.,:*_~]/.test(n)||n==`)`&&ot(e,t,r,`)`)>ot(e,t,r,`(`))r--;else if(n==`;`&&(i=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t,r))))r=t+i.index;else break}return r}function ct(e,t){it.lastIndex=t;let n=it.exec(e);if(!n)return-1;let r=n[0][n[0].length-1];return r==`_`||r==`-`?-1:t+n[0].length-+(r==`.`)}var lt=[Qe,et,Je,{parseInline:[{name:`Autolink`,parse(e,t,n){let r=n-e.offset;if(r&&/\w/.test(e.text[r-1]))return-1;tt.lastIndex=r;let i=tt.exec(e.text),a=-1;return!i||(i[1]||i[2]?(a=st(e.text,r+i[0].length),a>-1&&e.hasOpenLink&&(a=r+/([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(r,a))[0].length)):i[3]?a=ct(e.text,r):(a=ct(e.text,r+i[0].length),a>-1&&i[0]==`xmpp:`&&(at.lastIndex=a,i=at.exec(e.text),i&&(a=i.index+i[0].length))),a<0)?-1:(e.addElement(e.elt(`URL`,n,a+e.offset)),a+e.offset)}}]}];function ut(e,t,n){return(r,i,a)=>{if(i!=e||r.char(a+1)==e)return-1;let o=[r.elt(n,a,a+1)];for(let i=a+1;i<r.end;i++){let s=r.char(i);if(s==e)return r.addElement(r.elt(t,a,i+1,o.concat(r.elt(n,i,i+1))));if(s==92&&o.push(r.elt(`Escape`,i,i+++2)),S(s))break}return-1}}var dt={defineNodes:[{name:`Superscript`,style:_.special(_.content)},{name:`SuperscriptMark`,style:_.processingInstruction}],parseInline:[{name:`Superscript`,parse:ut(94,`Superscript`,`SuperscriptMark`)}]},ft={defineNodes:[{name:`Subscript`,style:_.special(_.content)},{name:`SubscriptMark`,style:_.processingInstruction}],parseInline:[{name:`Subscript`,parse:ut(126,`Subscript`,`SubscriptMark`)}]},pt={defineNodes:[{name:`Emoji`,style:_.character}],parseInline:[{name:`Emoji`,parse(e,t,n){let r;return t!=58||!(r=/^[a-zA-Z_0-9]+:/.exec(e.slice(n+1,e.end)))?-1:e.addElement(e.elt(`Emoji`,n,n+1+r[0].length))}}]},mt=h({commentTokens:{block:{open:`<!--`,close:`-->`}}}),ht=new d,gt=We.configure({props:[g.add(e=>!e.is(`Block`)||e.is(`Document`)||q(e)!=null||_t(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),ht.add(q),f.add({Document:()=>null}),t.add({Document:mt})]});function q(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function _t(e){return e.name==`OrderedList`||e.name==`BulletList`}function vt(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=q(e.type))!=null&&r<=t)break;n=e}return n.to}var yt=l.of((e,t,r)=>{for(let i=n(e).resolveInner(r,-1);i&&!(i.from<t);i=i.parent){let e=i.type.prop(ht);if(e==null)continue;let t=vt(i,e);if(t>r)return{from:r,to:t}}return null});function J(e){return new ee(mt,e,[],`markdown`)}var bt=J(gt),Y=J(gt.configure([lt,ft,dt,pt,{props:[g.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function xt(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):u.matchLanguageName(e,n,!0),t instanceof u)return t.support?t.support.language.parser:ie.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var X=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}else{for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}}marker(e,t){let n=this.node.name==`OrderedList`?String(+Ct(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function St(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new X(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new X(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new X(i.parent,s,s+t,a[1],e,n,i))}}return r}function Ct(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Z(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=Ct(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function Q(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(s)!=` `)return e;let r=o(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}var wt=((e={})=>({state:t,dispatch:r})=>{let i=n(t),{doc:a}=t,s=null,l=t.changeByRange(n=>{if(!n.empty||!Y.isActiveAt(t,n.from,-1)&&!Y.isActiveAt(t,n.from,1))return s={range:n};let r=n.from,l=a.lineAt(r),u=St(i.resolveInner(r,-1),a);for(;u.length&&u[u.length-1].from>r-l.from;)u.pop();if(!u.length)return s={range:n};let d=u[u.length-1];if(d.to-d.spaceAfter.length>r-l.from)return s={range:n};let f=r>=d.to-d.spaceAfter.length&&!/\S/.test(l.text.slice(d.to));if(d.item&&f){let n=d.node.firstChild,i=d.node.getChild(`ListItem`,`ListItem`);if(n.to>=r||i&&i.to<r||l.from>0&&!/[^\s>]/.test(a.lineAt(l.from-1).text)||e.nonTightLists===!1){let e=u.length>1?u[u.length-2]:null,t,n=``;e&&e.item?(t=l.from+e.from,n=e.marker(a,1)):t=l.from+(e?e.to:0);let i=[{from:t,to:r,insert:n}];return d.node.name==`OrderedList`&&Z(d.item,a,i,-2),e&&e.node.name==`OrderedList`&&Z(e.item,a,i),{range:c.cursor(t+n.length),changes:i}}else{let e=Dt(u,t,l);return{range:c.cursor(r+e.length+1),changes:{from:l.from,insert:e+t.lineBreak}}}}if(d.node.name==`Blockquote`&&f&&l.from){let e=a.lineAt(l.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==d.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:l.from+d.from,to:l.to}]);return{range:n.map(i),changes:i}}}let p=[];d.node.name==`OrderedList`&&Z(d.item,a,p);let m=d.item&&d.item.from<l.from,h=``;if(!m||/^[\s\d.)\-+*>]*/.exec(l.text)[0].length>=d.to)for(let e=0,t=u.length-1;e<=t;e++)h+=e==t&&!m?u[e].marker(a,1):u[e].blank(e<t?o(l.text,4,u[e+1].from)-h.length:null);let g=r;for(;g>l.from&&/\s/.test(l.text.charAt(g-l.from-1));)g--;return h=Q(h,t),Et(d.node,t.doc)&&(h=Dt(u,t,l)+t.lineBreak+h),p.push({from:g,to:r,insert:t.lineBreak+h}),{range:c.cursor(g+h.length+1),changes:p}});return s?!1:(r(t.update(l,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Tt(e){return e.name==`QuoteMark`||e.name==`ListMark`}function Et(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function Dt(e,t,n){let r=``;for(let t=0,i=e.length-2;t<=i;t++)r+=e[t].blank(t<i?o(n.text,4,e[t+1].from)-r.length:null,t<i);return Q(r,t)}function Ot(e,t){let n=e.resolveInner(t,-1),r=t;Tt(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(Tt(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var kt=[{key:`Enter`,run:wt},{key:`Backspace`,run:({state:e,dispatch:t})=>{let r=n(e),i=null,a=e.changeByRange(t=>{let n=t.from,{doc:a}=e;if(t.empty&&Y.isActiveAt(e,t.from)){let t=a.lineAt(n),i=St(Ot(r,n),a);if(i.length){let r=i[i.length-1],a=r.to-r.spaceAfter.length+ +!!r.spaceAfter;if(n-t.from>a&&!/\S/.test(t.text.slice(a,n-t.from)))return{range:c.cursor(t.from+a),changes:{from:t.from+a,to:n}};if(n-t.from==a&&(!r.item||t.from<=r.item.from||!/\S/.test(t.text.slice(0,r.to)))){let i=t.from+r.from;if(r.item&&r.node.from<r.item.from&&/\S/.test(t.text.slice(r.from,r.to))){let n=r.blank(o(t.text,4,r.to)-o(t.text,4,r.from));return i==t.from&&(n=Q(n,e)),{range:c.cursor(i+n.length),changes:{from:i,to:t.from+r.to,insert:n}}}if(i<n)return{range:c.cursor(i),changes:{from:i,to:n}}}}}return i={range:t}});return i?!1:(t(e.update(a,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],At=ae({matchClosingTags:!1});function jt(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:i=!0,base:{parser:o}=bt,completeHTMLTags:s=!0,pasteURLAsLink:c=!0,htmlTagLanguage:l=At}=e;if(!(o instanceof ke))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let u=e.extensions?[e.extensions]:[],d=[l.support,yt],f;c&&d.push(Ft),n instanceof ne?(d.push(n.support),f=n.language):n&&(f=n);let p=t||f?xt(t,f):void 0;u.push(Ke({codeParser:p,htmlParser:l.language.parser})),i&&d.push(r.high(a.of(kt)));let m=J(o.configure(u));return s&&d.push(m.data.of({autocomplete:Mt})),new ne(m,d)}function Mt(e){let{state:t,pos:r}=e,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(r-25,r));if(!i)return null;let a=n(t).resolveInner(r,-1);for(;a&&!a.type.isTop;){if(a.name==`CodeBlock`||a.name==`FencedCode`||a.name==`ProcessingInstructionBlock`||a.name==`CommentBlock`||a.name==`Link`||a.name==`Image`)return null;a=a.parent}return{from:r-i[0].length,to:r,options:Nt(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var $=null;function Nt(){if($)return $;let e=oe(new se(i.create({extensions:At}),0,!0));return $=e?e.options:[]}var Pt=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Ft=e.domEventHandlers({paste:(e,t)=>{let{main:r}=t.state.selection;if(r.empty)return!1;let i=e.clipboardData?.getData(`text/plain`);if(!i||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(i)||(/^www\./.test(i)&&(i=`https://`+i),!Y.isActiveAt(t.state,r.from,1)))return!1;let a=n(t.state),o=!1;return a.iterate({from:r.from,to:r.to,enter:e=>{(e.from>r.from||Pt.test(e.name))&&(o=!0)},leave:e=>{e.to<r.to&&(o=!0)}}),o?!1:(t.dispatch({changes:[{from:r.from,insert:`[`},{from:r.to,insert:`](${i})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});export{jt as markdown};
|