@telepath-computer/television 0.1.1 → 0.1.2
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 +10 -0
- package/dist/browser/assets/index-BmwVdck9.css +1 -0
- package/dist/browser/assets/index-DZhAP0Dt.js +430 -0
- package/dist/browser/index.html +2 -2
- package/dist/cli.cjs +100 -13
- package/dist/electron.cjs +100 -13
- package/package.json +3 -2
- package/dist/browser/assets/index-C0a55XYe.js +0 -413
- package/dist/browser/assets/index-C0onxKEP.css +0 -1
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
var Vr=Object.defineProperty;var xs=s=>{throw TypeError(s)};var Qr=(s,t,e)=>t in s?Vr(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var h=(s,t,e)=>Qr(s,typeof t!="symbol"?t+"":t,e),bt=(s,t,e)=>t.has(s)||xs("Cannot "+e);var d=(s,t,e)=>(bt(s,t,"read from private field"),e?e.call(s):t.get(s)),S=(s,t,e)=>t.has(s)?xs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),I=(s,t,e,r)=>(bt(s,t,"write to private field"),r?r.call(s,e):t.set(s,e),e),g=(s,t,e)=>(bt(s,t,"access private method"),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(i){if(i.ep)return;i.ep=!0;const n=e(i);fetch(i.href,n)}})();const ys=new WeakMap;function Xr(s){return(typeof s=="object"||typeof s=="function")&&s!==null&&"then"in s&&typeof s.then=="function"}function oe(s){return typeof s=="string"?s:typeof s=="symbol"?s.description??s.toString():s.name||"(anonymous class)"}function _s(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function Kr(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Yr{constructor(){h(this,"entries",new Map);h(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw _s();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw _s();if(e.constructor.name==="AsyncFunction")throw Kr();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=ys.get(t);if(e){if(t.length!==e.length)throw new Error(`${oe(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${oe(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=ys.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,r)=>{if(r==="then")return;const i=this.getInstance(t),n=Reflect.get(i,r,i);return typeof n=="function"?n.bind(i):n},set:(e,r,i)=>{const n=this.getInstance(t);return Reflect.set(n,r,i,n)},has:(e,r)=>{const i=this.getInstance(t);return r in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${oe(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const r=[...this.constructionStack.slice(e),t.key].map(i=>oe(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(Xr(r))throw new Error(`Factory for ${oe(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${oe(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const W=new Yr;function Jr(s){return{all:s=s||new Map,on:function(t,e){var r=s.get(t);r?r.push(e):s.set(t,[e])},off:function(t,e){var r=s.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):s.set(t,[]))},emit:function(t,e){var r=s.get(t);r&&r.slice().map(function(i){i(e)}),(r=s.get("*"))&&r.slice().map(function(i){i(t,e)})}}}let Yt=class{constructor(){h(this,"emitter",Jr());h(this,"on",(t,e)=>(this.emitter.on(t,e),{dispose:()=>this.emitter.off(t,e)}));h(this,"once",(t,e)=>{const r=i=>{e(i),this.emitter.off(t,r)};return this.emitter.on(t,r),{dispose:()=>this.emitter.off(t,r)}});h(this,"off",this.emitter.off)}emit(t,...[e]){this.emitter.emit(t,e)}};const Xs="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Je=32,ei=16,Ks=10,Ss=0xffffffffffff;var K;(function(s){s.Base32IncorrectEncoding="B32_ENC_INVALID",s.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",s.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",s.EncodeTimeNegative="ENC_TIME_NEG",s.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",s.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",s.PRNGDetectFailure="PRNG_DETECT",s.ULIDInvalid="ULID_INVALID",s.Unexpected="UNEXPECTED",s.UUIDInvalid="UUID_INVALID"})(K||(K={}));class me extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function ti(s){const t=Math.floor(s()*Je)%Je;return Xs.charAt(t)}function si(s){const t=ri(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new me(K.PRNGDetectFailure,"Failed to find a reliable PRNG")}function ri(){return ai()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function ii(s,t){let e="";for(;s>0;s--)e=ti(t)+e;return e}function ni(s,t=Ks){if(isNaN(s))throw new me(K.EncodeTimeValueMalformed,`Time must be a number: ${s}`);if(s>Ss)throw new me(K.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Ss}: ${s}`);if(s<0)throw new me(K.EncodeTimeNegative,`Time must be positive: ${s}`);if(Number.isInteger(s)===!1)throw new me(K.EncodeTimeValueMalformed,`Time must be an integer: ${s}`);let e,r="";for(let i=t;i>0;i--)e=s%Je,r=Xs.charAt(e)+r,s=(s-e)/Je;return r}function ai(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function As(s,t){const e=si(),r=Date.now();return ni(r,Ks)+ii(ei,e)}class oi extends Yt{constructor(e){var i,n;super();h(this,"artifacts",new Map);h(this,"activeWorkspaceID",null);h(this,"focusedArtifactID",null);h(this,"scrollPosition",0);h(this,"activeWorkspaceData",null);h(this,"clientStore");h(this,"servers");h(this,"pendingCreateRollbacks",new Map);h(this,"pendingRemoveRollbacks",new Map);h(this,"pendingWorkspaceCreates",new Map);h(this,"pendingWorkspaceDeletes",new Map);this.clientStore=e.clientStore,this.servers=e.servers;const r=this.clientStore.get();this.activeWorkspaceID=(r==null?void 0:r.lastWorkspaceID)??null,this.activeWorkspaceID&&(this.focusedArtifactID=((i=r==null?void 0:r.workspaces[this.activeWorkspaceID])==null?void 0:i.focusedArtifactID)??null,this.scrollPosition=((n=r==null?void 0:r.workspaces[this.activeWorkspaceID])==null?void 0:n.scrollPosition)??0)}get workspaces(){return[...this.servers.values()].flatMap(e=>[...e.workspaces.values()])}get activeWorkspace(){return this.activeWorkspaceData}get activeWorkspaceServerURL(){var e;return this.activeWorkspaceID?((e=this.findWorkspace(this.activeWorkspaceID))==null?void 0:e.serverURL)??null:null}get activeArtifacts(){var e;return(((e=this.activeWorkspaceData)==null?void 0:e.artifactIDs)??[]).map(r=>this.artifacts.get(r)).filter(r=>r!==void 0)}setActiveWorkspace(e){this.selectWorkspace(e)}focusArtifact(e){this.artifacts.has(e)&&(this.focusedArtifactID=e,this.persistFocusedArtifact(),this.emit("change"))}clearFocusedArtifact(){this.focusedArtifactID!==null&&(this.focusedArtifactID=null,this.persistFocusedArtifact(),this.emit("change"))}setScrollPosition(e){const r=Math.max(0,Math.floor(e));this.scrollPosition!==r&&(this.scrollPosition=r,this.persistFocusedArtifact(),this.emit("change"))}createArtifact(e){var o;const r=this.activeWorkspaceData;if(!r)return;const i=this.snapshotArtifactState(),n={id:As(),type:"markdown",title:e.title,content:e.content};r.artifactIDs.includes(n.id)||r.artifactIDs.push(n.id),this.artifacts.set(n.id,n),this.focusedArtifactID=n.id,this.scrollPosition=Math.max(r.artifactIDs.length-1,0),this.persistFocusedArtifact(),this.emit("change");const a=((o=this.findWorkspace(r.id))==null?void 0:o.server)??null;this.pendingCreateRollbacks.set(n.id,i),this.sendServerMessage(a,{type:"create-artifact",id:n.id,title:e.title,content:e.content,workspaceID:r.id})||(this.pendingCreateRollbacks.delete(n.id),this.restoreArtifactState(i),this.emit("change"))}removeArtifact(e){var a;const r=this.activeWorkspaceData;if(!r||!this.artifacts.has(e))return;const i=this.snapshotArtifactState();this.removeArtifactLocally(e),this.emit("change");const n=((a=this.findWorkspace(r.id))==null?void 0:a.server)??null;this.pendingRemoveRollbacks.set(e,i),this.sendServerMessage(n,{type:"remove-artifact",artifactID:e,workspaceID:r.id})||(this.pendingRemoveRollbacks.delete(e),this.restoreArtifactState(i),this.emit("change"))}handleServerEvent(e,r){var i;switch(r.type){case"workspace-list":case"workspace-updated":this.syncActiveWorkspaceSelection(e,r.type==="workspace-list");break;case"workspace-removed":{this.syncActiveWorkspaceSelection(e,!1);const n=this.pendingWorkspaceDeletes.get(r.workspaceID);n&&(this.pendingWorkspaceDeletes.delete(r.workspaceID),n.resolve());break}case"workspace-created":if(this.pendingWorkspaceCreates.has(r.workspace.id)){const n=this.pendingWorkspaceCreates.get(r.workspace.id);this.pendingWorkspaceCreates.delete(r.workspace.id),this.selectWorkspace(r.workspace.id),n==null||n.resolve();return}this.syncActiveWorkspaceSelection(e,!1);break;case"workspace":this.applyWorkspaceSnapshot(r.workspace,r.artifacts);break;case"artifact-created":this.pendingCreateRollbacks.delete(r.artifact.id),this.applyArtifactCreated(r);break;case"artifact-updated":this.applyArtifactUpdated(r);break;case"artifact-removed":if(this.pendingRemoveRollbacks.delete(r.artifactID),((i=this.activeWorkspaceData)==null?void 0:i.id)!==r.workspaceID)return;this.removeArtifactLocally(r.artifactID)&&this.emit("change");break;case"error":this.handleServerError(r);break}}createWorkspace(e,r){const i=this.servers.get(e)??null,n=As(),a=$s();return this.pendingWorkspaceCreates.set(n,a),this.sendServerMessage(i,{type:"create-workspace",id:n,name:r})||(this.pendingWorkspaceCreates.delete(n),a.reject(new Error(`Server unavailable: ${e}`))),a.promise}deleteWorkspace(){var a;const e=this.activeWorkspaceData;if(!e)return Promise.reject(new Error("No active workspace"));const r=this.pendingWorkspaceDeletes.get(e.id);if(r)return r.promise;const i=((a=this.findWorkspace(e.id))==null?void 0:a.server)??null,n=$s();return this.pendingWorkspaceDeletes.set(e.id,n),this.sendServerMessage(i,{type:"delete-workspace",workspaceID:e.id})||(this.pendingWorkspaceDeletes.delete(e.id),n.reject(new Error(`Server unavailable: ${e.id}`))),n.promise}renameWorkspace(e){var n;const r=this.activeWorkspaceData;if(!r)return;const i=((n=this.findWorkspace(r.id))==null?void 0:n.server)??null;r.name=e,this.emit("change"),this.sendServerMessage(i,{type:"update-workspace",workspaceID:r.id,fields:{name:e}})}syncActiveWorkspaceSelection(e,r){const i=this.activeWorkspaceID?this.findWorkspace(this.activeWorkspaceID):null;if(!i){const n=this.pickNextWorkspace();if(!n){const a=this.activeWorkspaceID!==null||this.activeWorkspaceData!==null||this.artifacts.size>0||this.focusedArtifactID!==null;this.activeWorkspaceID=null,this.activeWorkspaceData=null,this.artifacts.clear(),this.focusedArtifactID=null,this.scrollPosition=0,a&&this.emit("change");return}this.selectWorkspace(n.workspace.id);return}!this.activeWorkspaceData||this.activeWorkspaceData.id!==i.workspace.id?this.activeWorkspaceData=structuredClone(i.workspace):this.activeWorkspaceData.name=i.workspace.name,r&&i.serverURL===e&&this.requestWorkspace(i.serverURL,i.workspace.id)}selectWorkspace(e){const r=this.findWorkspace(e);r&&(this.activeWorkspaceID=e,this.activeWorkspaceData=structuredClone(r.workspace),this.artifacts.clear(),this.restoreFocusedArtifact(),this.persistActiveWorkspace(),this.requestWorkspace(r.serverURL,e),this.emit("change"))}requestWorkspace(e,r){const i=this.servers.get(e);this.sendServerMessage(i??null,{type:"get-workspace",workspaceID:r})}applyWorkspaceSnapshot(e,r){if(e.id===this.activeWorkspaceID){this.activeWorkspaceData=structuredClone(e),this.artifacts.clear();for(const i of r)this.artifacts.set(i.id,i);this.restoreFocusedArtifact(),this.emit("change")}}applyArtifactCreated(e){var r;((r=this.activeWorkspaceData)==null?void 0:r.id)===e.workspaceID&&(this.activeWorkspaceData.artifactIDs.includes(e.artifact.id)||this.activeWorkspaceData.artifactIDs.push(e.artifact.id),this.artifacts.set(e.artifact.id,e.artifact),this.emit("change"))}applyArtifactUpdated(e){const r=this.artifacts.get(e.artifactID);r&&(Object.assign(r,e.fields),this.emit("change"))}removeArtifactLocally(e){if(!this.activeWorkspaceData)return!1;const r=this.artifacts.delete(e),i=this.activeWorkspaceData.artifactIDs.length;if(this.activeWorkspaceData.artifactIDs=this.activeWorkspaceData.artifactIDs.filter(n=>n!==e),!r&&i===this.activeWorkspaceData.artifactIDs.length)return!1;if(this.focusedArtifactID===e){const n=this.activeWorkspaceData.artifactIDs;this.focusedArtifactID=n.length>0?n[n.length-1]:null,this.scrollPosition=Math.min(this.scrollPosition,Math.max(n.length-1,0)),this.persistFocusedArtifact()}return!0}snapshotArtifactState(){return{activeWorkspaceData:this.activeWorkspaceData?structuredClone(this.activeWorkspaceData):null,focusedArtifactID:this.focusedArtifactID,scrollPosition:this.scrollPosition,artifacts:new Map([...this.artifacts.entries()].map(([e,r])=>[e,structuredClone(r)]))}}restoreArtifactState(e){this.activeWorkspaceData=e.activeWorkspaceData?structuredClone(e.activeWorkspaceData):null,this.focusedArtifactID=e.focusedArtifactID,this.scrollPosition=e.scrollPosition,this.artifacts.clear();for(const[r,i]of e.artifacts.entries())this.artifacts.set(r,structuredClone(i));this.persistFocusedArtifact()}handleServerError(e){const r=e.request;if(r){if(r.type==="create-artifact"){const i=this.pendingCreateRollbacks.get(r.id);if(!i)return;this.pendingCreateRollbacks.delete(r.id),this.restoreArtifactState(i),this.emit("change");return}if(r.type==="create-workspace"){const i=this.pendingWorkspaceCreates.get(r.id);if(!i)return;this.pendingWorkspaceCreates.delete(r.id),i.reject(new Error(e.message));return}if(r.type==="delete-workspace"){const i=this.pendingWorkspaceDeletes.get(r.workspaceID);if(!i)return;this.pendingWorkspaceDeletes.delete(r.workspaceID),i.reject(new Error(e.message));return}if(r.type==="remove-artifact"){const i=this.pendingRemoveRollbacks.get(r.artifactID);if(!i)return;this.pendingRemoveRollbacks.delete(r.artifactID),this.restoreArtifactState(i),this.emit("change")}}}restoreFocusedArtifact(){var n,a,o,c,l;if(!this.activeWorkspaceID){this.focusedArtifactID=null,this.scrollPosition=0;return}const e=((a=(n=this.clientStore.get())==null?void 0:n.workspaces[this.activeWorkspaceID])==null?void 0:a.focusedArtifactID)??null,r=((c=(o=this.clientStore.get())==null?void 0:o.workspaces[this.activeWorkspaceID])==null?void 0:c.scrollPosition)??0,i=((l=this.activeWorkspaceData)==null?void 0:l.artifactIDs)??[];e&&i.includes(e)?this.focusedArtifactID=e:this.focusedArtifactID=null,this.scrollPosition=Math.max(0,Math.min(r,Math.max(i.length-1,0))),this.persistFocusedArtifact()}persistActiveWorkspace(){this.clientStore.update(e=>{e.lastWorkspaceID=this.activeWorkspaceID})}persistFocusedArtifact(){this.activeWorkspaceID&&this.clientStore.update(e=>{var r,i;(r=e.workspaces)[i=this.activeWorkspaceID]??(r[i]={focusedArtifactID:null,scrollPosition:0}),e.workspaces[this.activeWorkspaceID].focusedArtifactID=this.focusedArtifactID,e.workspaces[this.activeWorkspaceID].scrollPosition=this.scrollPosition})}findWorkspace(e){for(const[r,i]of this.servers){const n=i.workspaces.get(e);if(n)return{serverURL:r,server:i,workspace:n}}return null}pickNextWorkspace(){var r;const e=(r=this.clientStore.get())==null?void 0:r.lastWorkspaceID;if(e){const i=this.findWorkspace(e);if(i)return i}for(const[i,n]of this.servers){const a=n.workspaces.values().next().value;if(a)return{serverURL:i,server:n,workspace:a}}return null}sendServerMessage(e,r){return!(e!=null&&e.socket)||e.socket.readyState!==1?!1:(e.socket.send(JSON.stringify(r)),!0)}}function $s(){let s,t;return{promise:new Promise((r,i)=>{s=r,t=i}),resolve:s,reject:t}}var Ys=Symbol.for("immer-nothing"),Es=Symbol.for("immer-draftable"),P=Symbol.for("immer-state");function N(s,...t){throw new Error(`[Immer] minified error nr: ${s}. Full error at: https://bit.ly/3cXEKWf`)}var _e=Object.getPrototypeOf;function he(s){return!!s&&!!s[P]}function ee(s){var t;return s?Js(s)||Array.isArray(s)||!!s[Es]||!!((t=s.constructor)!=null&&t[Es])||Oe(s)||dt(s):!1}var li=Object.prototype.constructor.toString(),Rs=new WeakMap;function Js(s){if(!s||typeof s!="object")return!1;const t=Object.getPrototypeOf(s);if(t===null||t===Object.prototype)return!0;const e=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(e===Object)return!0;if(typeof e!="function")return!1;let r=Rs.get(e);return r===void 0&&(r=Function.toString.call(e),Rs.set(e,r)),r===li}function et(s,t,e=!0){ut(s)===0?(e?Reflect.ownKeys(s):Object.keys(s)).forEach(i=>{t(i,s[i],s)}):s.forEach((r,i)=>t(i,r,s))}function ut(s){const t=s[P];return t?t.type_:Array.isArray(s)?1:Oe(s)?2:dt(s)?3:0}function St(s,t){return ut(s)===2?s.has(t):Object.prototype.hasOwnProperty.call(s,t)}function er(s,t,e){const r=ut(s);r===2?s.set(t,e):r===3?s.add(e):s[t]=e}function ci(s,t){return s===t?s!==0||1/s===1/t:s!==s&&t!==t}function Oe(s){return s instanceof Map}function dt(s){return s instanceof Set}function G(s){return s.copy_||s.base_}function At(s,t){if(Oe(s))return new Map(s);if(dt(s))return new Set(s);if(Array.isArray(s))return Array.prototype.slice.call(s);const e=Js(s);if(t===!0||t==="class_only"&&!e){const r=Object.getOwnPropertyDescriptors(s);delete r[P];let i=Reflect.ownKeys(r);for(let n=0;n<i.length;n++){const a=i[n],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:s[a]})}return Object.create(_e(s),r)}else{const r=_e(s);if(r!==null&&e)return{...s};const i=Object.create(r);return Object.assign(i,s)}}function Jt(s,t=!1){return pt(s)||he(s)||!ee(s)||(ut(s)>1&&Object.defineProperties(s,{set:Be,add:Be,clear:Be,delete:Be}),Object.freeze(s),t&&Object.values(s).forEach(e=>Jt(e,!0))),s}function hi(){N(2)}var Be={value:hi};function pt(s){return s===null||typeof s!="object"?!0:Object.isFrozen(s)}var ui={};function te(s){const t=ui[s];return t||N(0,s),t}var Se;function tr(){return Se}function di(s,t){return{drafts_:[],parent_:s,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ds(s,t){t&&(te("Patches"),s.patches_=[],s.inversePatches_=[],s.patchListener_=t)}function $t(s){Et(s),s.drafts_.forEach(pi),s.drafts_=null}function Et(s){s===Se&&(Se=s.parent_)}function Cs(s){return Se=di(Se,s)}function pi(s){const t=s[P];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Is(s,t){t.unfinalizedDrafts_=t.drafts_.length;const e=t.drafts_[0];return s!==void 0&&s!==e?(e[P].modified_&&($t(t),N(4)),ee(s)&&(s=tt(t,s),t.parent_||st(t,s)),t.patches_&&te("Patches").generateReplacementPatches_(e[P].base_,s,t.patches_,t.inversePatches_)):s=tt(t,e,[]),$t(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),s!==Ys?s:void 0}function tt(s,t,e){if(pt(t))return t;const r=s.immer_.shouldUseStrictIteration(),i=t[P];if(!i)return et(t,(n,a)=>Ps(s,i,t,n,a,e),r),t;if(i.scope_!==s)return t;if(!i.modified_)return st(s,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const n=i.copy_;let a=n,o=!1;i.type_===3&&(a=new Set(n),n.clear(),o=!0),et(a,(c,l)=>Ps(s,i,n,c,l,e,o),r),st(s,n,!1),e&&s.patches_&&te("Patches").generatePatches_(i,e,s.patches_,s.inversePatches_)}return i.copy_}function Ps(s,t,e,r,i,n,a){if(i==null||typeof i!="object"&&!a)return;const o=pt(i);if(!(o&&!a)){if(he(i)){const c=n&&t&&t.type_!==3&&!St(t.assigned_,r)?n.concat(r):void 0,l=tt(s,i,c);if(er(e,r,l),he(l))s.canAutoFreeze_=!1;else return}else a&&e.add(i);if(ee(i)&&!o){if(!s.immer_.autoFreeze_&&s.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&o)return;tt(s,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Oe(e)?e.has(r):Object.prototype.propertyIsEnumerable.call(e,r))&&st(s,i)}}}function st(s,t,e=!1){!s.parent_&&s.immer_.autoFreeze_&&s.canAutoFreeze_&&Jt(t,e)}function fi(s,t){const e=Array.isArray(s),r={type_:e?1:0,scope_:t?t.scope_:tr(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:s,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,n=es;e&&(i=[r],n=Ae);const{revoke:a,proxy:o}=Proxy.revocable(i,n);return r.draft_=o,r.revoke_=a,o}var es={get(s,t){if(t===P)return s;const e=G(s);if(!St(e,t))return gi(s,e,t);const r=e[t];return s.finalized_||!ee(r)?r:r===wt(s.base_,t)?(vt(s),s.copy_[t]=Dt(r,s)):r},has(s,t){return t in G(s)},ownKeys(s){return Reflect.ownKeys(G(s))},set(s,t,e){const r=sr(G(s),t);if(r!=null&&r.set)return r.set.call(s.draft_,e),!0;if(!s.modified_){const i=wt(G(s),t),n=i==null?void 0:i[P];if(n&&n.base_===e)return s.copy_[t]=e,s.assigned_[t]=!1,!0;if(ci(e,i)&&(e!==void 0||St(s.base_,t)))return!0;vt(s),Rt(s)}return s.copy_[t]===e&&(e!==void 0||t in s.copy_)||Number.isNaN(e)&&Number.isNaN(s.copy_[t])||(s.copy_[t]=e,s.assigned_[t]=!0),!0},deleteProperty(s,t){return wt(s.base_,t)!==void 0||t in s.base_?(s.assigned_[t]=!1,vt(s),Rt(s)):delete s.assigned_[t],s.copy_&&delete s.copy_[t],!0},getOwnPropertyDescriptor(s,t){const e=G(s),r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:s.type_!==1||t!=="length",enumerable:r.enumerable,value:e[t]}},defineProperty(){N(11)},getPrototypeOf(s){return _e(s.base_)},setPrototypeOf(){N(12)}},Ae={};et(es,(s,t)=>{Ae[s]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ae.deleteProperty=function(s,t){return Ae.set.call(this,s,t,void 0)};Ae.set=function(s,t,e){return es.set.call(this,s[0],t,e,s[0])};function wt(s,t){const e=s[P];return(e?G(e):s)[t]}function gi(s,t,e){var i;const r=sr(t,e);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(s.draft_):void 0}function sr(s,t){if(!(t in s))return;let e=_e(s);for(;e;){const r=Object.getOwnPropertyDescriptor(e,t);if(r)return r;e=_e(e)}}function Rt(s){s.modified_||(s.modified_=!0,s.parent_&&Rt(s.parent_))}function vt(s){s.copy_||(s.copy_=At(s.base_,s.scope_.immer_.useStrictShallowCopy_))}var ki=class{constructor(s){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,e,r)=>{if(typeof t=="function"&&typeof e!="function"){const n=e;e=t;const a=this;return function(c=n,...l){return a.produce(c,u=>e.call(this,u,...l))}}typeof e!="function"&&N(6),r!==void 0&&typeof r!="function"&&N(7);let i;if(ee(t)){const n=Cs(this),a=Dt(t,void 0);let o=!0;try{i=e(a),o=!1}finally{o?$t(n):Et(n)}return Ds(n,r),Is(i,n)}else if(!t||typeof t!="object"){if(i=e(t),i===void 0&&(i=t),i===Ys&&(i=void 0),this.autoFreeze_&&Jt(i,!0),r){const n=[],a=[];te("Patches").generateReplacementPatches_(t,i,n,a),r(n,a)}return i}else N(1,t)},this.produceWithPatches=(t,e)=>{if(typeof t=="function")return(a,...o)=>this.produceWithPatches(a,c=>t(c,...o));let r,i;return[this.produce(t,e,(a,o)=>{r=a,i=o}),r,i]},typeof(s==null?void 0:s.autoFreeze)=="boolean"&&this.setAutoFreeze(s.autoFreeze),typeof(s==null?void 0:s.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(s.useStrictShallowCopy),typeof(s==null?void 0:s.useStrictIteration)=="boolean"&&this.setUseStrictIteration(s.useStrictIteration)}createDraft(s){ee(s)||N(8),he(s)&&(s=mi(s));const t=Cs(this),e=Dt(s,void 0);return e[P].isManual_=!0,Et(t),e}finishDraft(s,t){const e=s&&s[P];(!e||!e.isManual_)&&N(9);const{scope_:r}=e;return Ds(r,t),Is(void 0,r)}setAutoFreeze(s){this.autoFreeze_=s}setUseStrictShallowCopy(s){this.useStrictShallowCopy_=s}setUseStrictIteration(s){this.useStrictIteration_=s}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(s,t){let e;for(e=t.length-1;e>=0;e--){const i=t[e];if(i.path.length===0&&i.op==="replace"){s=i.value;break}}e>-1&&(t=t.slice(e+1));const r=te("Patches").applyPatches_;return he(s)?r(s,t):this.produce(s,i=>r(i,t))}};function Dt(s,t){const e=Oe(s)?te("MapSet").proxyMap_(s,t):dt(s)?te("MapSet").proxySet_(s,t):fi(s,t);return(t?t.scope_:tr()).drafts_.push(e),e}function mi(s){return he(s)||N(10,s),rr(s)}function rr(s){if(!ee(s)||pt(s))return s;const t=s[P];let e,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,e=At(s,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else e=At(s,!0);return et(e,(i,n)=>{er(e,i,rr(n))},r),t&&(t.finalized_=!1),e}var bi=new ki,wi=bi.produce,vi=Object.defineProperty,xi=(s,t,e)=>t in s?vi(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,je=(s,t,e)=>xi(s,typeof t!="symbol"?t+"":t,e);function yi(s){return{all:s=s||new Map,on:function(t,e){var r=s.get(t);r?r.push(e):s.set(t,[e])},off:function(t,e){var r=s.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):s.set(t,[]))},emit:function(t,e){var r=s.get(t);r&&r.slice().map(function(i){i(e)}),(r=s.get("*"))&&r.slice().map(function(i){i(t,e)})}}}var _i=class{constructor(){je(this,"emitter",yi()),je(this,"on",(s,t)=>(this.emitter.on(s,t),{dispose:()=>this.emitter.off(s,t)})),je(this,"once",(s,t)=>{const e=r=>{t(r),this.emitter.off(s,e)};return this.emitter.on(s,e),{dispose:()=>this.emitter.off(s,e)}}),je(this,"off",this.emitter.off)}emit(s,...[t]){this.emitter.emit(s,t)}},Si="store-",Ai=class extends _i{emitChange(s){this.emit("change",{state:s})}},$i=class{constructor(s,t,e){this.emitter=new Ai,this.id=s,this.initValue=t,this.key=`${Si}${s}`,this.storage=(e==null?void 0:e.storage)==="session"?sessionStorage:localStorage,this.get()===void 0&&this.storage.setItem(this.key,JSON.stringify(t))}get(){const s=this.storage.getItem(this.key);return s===null?void 0:JSON.parse(s)}update(s){const t=this.get()??{},e=wi(t,s);this.storage.setItem(this.key,JSON.stringify(e)),this.emitter.emitChange(e)}reset(){this.storage.setItem(this.key,JSON.stringify(this.initValue)),this.emitter.emitChange(this.initValue)}on(s,t){return this.emitter.on(s,({state:e})=>t(e))}subscribe(s){const t=this.on("change",s),e=this.get();return e!==void 0&&s(e),t}};const Ei="Local";function H(s){return new URL(s).origin}function Ri(s){return{servers:[{url:H(s),name:Ei}],lastWorkspaceID:null,workspaces:{}}}function Di(s,t){return new $i(s,Ri(t))}const Ci=4401,Ts=1e3,Ii=3e4,Pi=2;class ir extends Yt{constructor(e){super();h(this,"url");h(this,"name");h(this,"token");h(this,"servers");h(this,"createSocket");h(this,"reconnectDelay",Ts);h(this,"reconnectTimer",null);h(this,"closed",!1);this.url=H(e.url),this.name=e.name,this.token=e.token??null,this.servers=e.servers,this.createSocket=e.createSocket??(r=>new WebSocket(r))}connect(){var i;this.closed=!1,this.clearReconnectTimer();const e=this.createSocket(Ti(this.url,this.token)),r={url:this.url,name:this.name,socket:e,workspaces:((i=this.servers.get(this.url))==null?void 0:i.workspaces)??new Map};this.servers.set(this.url,r),this.reconnectDelay=Ts,this.emit("change"),e.addEventListener("message",n=>{const a=Li(n);this.applyServerMessage(r,a),this.emit("serverEvent",{serverURL:r.url,event:a}),this.emit("change")}),e.addEventListener("close",n=>{if(this.servers.get(r.url)!==r||(r.socket=null,this.emit("change"),this.closed))return;if(Wi(n)===Ci){this.closed=!0,this.emit("auth-failed");return}const a=this.reconnectDelay;this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},a),this.reconnectDelay=Math.min(a*Pi,Ii)})}disconnect(){var r;this.closed=!0,this.clearReconnectTimer();const e=this.servers.get(this.url);e&&(this.servers.delete(this.url),(r=e.socket)==null||r.close(),this.emit("change"))}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}applyServerMessage(e,r){switch(r.type){case"workspace-list":e.workspaces=new Map(r.workspaces.map(i=>[i.id,structuredClone(i)]));break;case"workspace-created":e.workspaces.set(r.workspace.id,structuredClone(r.workspace));break;case"workspace-updated":{const i=e.workspaces.get(r.workspaceID);i&&Object.assign(i,r.fields);break}case"workspace-removed":e.workspaces.delete(r.workspaceID);break;case"artifact-created":{const i=e.workspaces.get(r.workspaceID);i&&!i.artifactIDs.includes(r.artifact.id)&&i.artifactIDs.push(r.artifact.id);break}case"artifact-removed":{const i=e.workspaces.get(r.workspaceID);i&&(i.artifactIDs=i.artifactIDs.filter(n=>n!==r.artifactID));break}}}}function Ti(s,t){const e=new URL(s);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/ws",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function Wi(s){return typeof s=="object"&&s!==null&&"code"in s&&typeof s.code=="number"?s.code:null}function Li(s){const t=typeof s=="string"?s:typeof s=="object"&&s!==null&&"data"in s&&typeof s.data=="string"?s.data:"";return JSON.parse(t)}class Mi extends Yt{constructor(e){super();h(this,"localServerURL");h(this,"clientStore");h(this,"servers");h(this,"workspaceService");h(this,"createSocket");h(this,"connections",new Map);this.clientStore=e.clientStore,this.servers=e.servers,this.workspaceService=e.workspaceService,this.localServerURL=e.localServerURL?H(e.localServerURL):null,this.createSocket=e.createSocket??(r=>new WebSocket(r))}get serverRecords(){return[...this.servers.values()]}connectConfiguredServers(){const e=this.clientStore.get();for(const r of(e==null?void 0:e.servers)??[])this.connectServer(r)}addServer(e,r){const i=H(e),n=this.connections.get(i);n&&(n.disconnect(),this.connections.delete(i)),this.connectServer({url:i,name:r}),this.clientStore.update(a=>{a.servers=a.servers.filter(o=>H(o.url)!==i),a.servers.push({url:i,name:r})}),this.emit("change")}removeServer(e){var n;const r=H(e);this.localServerURL&&r===this.localServerURL||!this.servers.get(r)||((n=this.connections.get(r))==null||n.disconnect(),this.connections.delete(r),this.clientStore.update(a=>{a.servers=a.servers.filter(o=>H(o.url)!==r)}),this.emit("change"))}connectServer(e){const r=H(e.url),i=new ir({url:r,name:e.name,servers:this.servers,createSocket:this.createSocket});this.connections.set(r,i),i.on("serverEvent",({serverURL:n,event:a})=>{this.workspaceService.handleServerEvent(n,a),this.emit("change")}),i.on("change",()=>this.emit("change")),i.connect()}}const zi="serverURL",Ni="token",Fi="mode",Oi="electron";function Ui(s=window.location.search,t=window.location.origin){const r=new URLSearchParams(s).get(zi);return r?new URL(r).origin:new URL(t).origin}function Hi(s=window.location.search){return new URLSearchParams(s).get(Ni)}function qi(s=window.location.search){return new URLSearchParams(s).get(Fi)===Oi}/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const ye=globalThis,Ws=s=>s,rt=ye.trustedTypes,Ls=rt?rt.createPolicy("lit-html",{createHTML:s=>s}):void 0,nr="$lit$",q=`lit$${Math.random().toFixed(9).slice(2)}$`,ar="?"+q,Bi=`<${ar}>`,se=document,$e=()=>se.createComment(""),Ee=s=>s===null||typeof s!="object"&&typeof s!="function",ts=Array.isArray,ji=s=>ts(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",xt=`[
|
|
6
|
-
\f\r]`,fe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ms=/-->/g,zs=/>/g,Z=RegExp(`>|${xt}(?:([^\\s"'>=/]+)(${xt}*=${xt}*(?:[^
|
|
7
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ns=/'/g,Fs=/"/g,or=/^(?:script|style|textarea|title)$/i,Zi=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),b=Zi(1),ue=Symbol.for("lit-noChange"),$=Symbol.for("lit-nothing"),Os=new WeakMap,Y=se.createTreeWalker(se,129);function lr(s,t){if(!ts(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ls!==void 0?Ls.createHTML(t):t}const Gi=(s,t)=>{const e=s.length-1,r=[];let i,n=t===2?"<svg>":t===3?"<math>":"",a=fe;for(let o=0;o<e;o++){const c=s[o];let l,u,f=-1,k=0;for(;k<c.length&&(a.lastIndex=k,u=a.exec(c),u!==null);)k=a.lastIndex,a===fe?u[1]==="!--"?a=Ms:u[1]!==void 0?a=zs:u[2]!==void 0?(or.test(u[2])&&(i=RegExp("</"+u[2],"g")),a=Z):u[3]!==void 0&&(a=Z):a===Z?u[0]===">"?(a=i??fe,f=-1):u[1]===void 0?f=-2:(f=a.lastIndex-u[2].length,l=u[1],a=u[3]===void 0?Z:u[3]==='"'?Fs:Ns):a===Fs||a===Ns?a=Z:a===Ms||a===zs?a=fe:(a=Z,i=void 0);const p=a===Z&&s[o+1].startsWith("/>")?" ":"";n+=a===fe?c+Bi:f>=0?(r.push(l),c.slice(0,f)+nr+c.slice(f)+q+p):c+q+(f===-2?o:p)}return[lr(s,n+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class Re{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let n=0,a=0;const o=t.length-1,c=this.parts,[l,u]=Gi(t,e);if(this.el=Re.createElement(l,r),Y.currentNode=this.el.content,e===2||e===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Y.nextNode())!==null&&c.length<o;){if(i.nodeType===1){if(i.hasAttributes())for(const f of i.getAttributeNames())if(f.endsWith(nr)){const k=u[a++],p=i.getAttribute(f).split(q),x=/([.?@])?(.*)/.exec(k);c.push({type:1,index:n,name:x[2],strings:p,ctor:x[1]==="."?Qi:x[1]==="?"?Xi:x[1]==="@"?Ki:ft}),i.removeAttribute(f)}else f.startsWith(q)&&(c.push({type:6,index:n}),i.removeAttribute(f));if(or.test(i.tagName)){const f=i.textContent.split(q),k=f.length-1;if(k>0){i.textContent=rt?rt.emptyScript:"";for(let p=0;p<k;p++)i.append(f[p],$e()),Y.nextNode(),c.push({type:2,index:++n});i.append(f[k],$e())}}}else if(i.nodeType===8)if(i.data===ar)c.push({type:2,index:n});else{let f=-1;for(;(f=i.data.indexOf(q,f+1))!==-1;)c.push({type:7,index:n}),f+=q.length-1}n++}}static createElement(t,e){const r=se.createElement("template");return r.innerHTML=t,r}}function de(s,t,e=s,r){var a,o;if(t===ue)return t;let i=r!==void 0?(a=e._$Co)==null?void 0:a[r]:e._$Cl;const n=Ee(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((o=i==null?void 0:i._$AO)==null||o.call(i,!1),n===void 0?i=void 0:(i=new n(s),i._$AT(s,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=i:e._$Cl=i),i!==void 0&&(t=de(s,i._$AS(s,t.values),i,r)),t}class Vi{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,i=((t==null?void 0:t.creationScope)??se).importNode(e,!0);Y.currentNode=i;let n=Y.nextNode(),a=0,o=0,c=r[0];for(;c!==void 0;){if(a===c.index){let l;c.type===2?l=new ss(n,n.nextSibling,this,t):c.type===1?l=new c.ctor(n,c.name,c.strings,this,t):c.type===6&&(l=new Yi(n,this,t)),this._$AV.push(l),c=r[++o]}a!==(c==null?void 0:c.index)&&(n=Y.nextNode(),a++)}return Y.currentNode=se,i}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}let ss=class cr{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=$,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=de(this,t,e),Ee(t)?t===$||t==null||t===""?(this._$AH!==$&&this._$AR(),this._$AH=$):t!==this._$AH&&t!==ue&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ji(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==$&&Ee(this._$AH)?this._$AA.nextSibling.data=t:this.T(se.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=Re.createElement(lr(r.h,r.h[0]),this.options)),r);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(e);else{const a=new Vi(i,this),o=a.u(this.options);a.p(e),this.T(o),this._$AH=a}}_$AC(t){let e=Os.get(t.strings);return e===void 0&&Os.set(t.strings,e=new Re(t)),e}k(t){ts(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,i=0;for(const n of t)i===e.length?e.push(r=new cr(this.O($e()),this.O($e()),this,this.options)):r=e[i],r._$AI(n),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,e);t!==this._$AB;){const i=Ws(t).nextSibling;Ws(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class ft{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,n){this.type=1,this._$AH=$,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=$}_$AI(t,e=this,r,i){const n=this.strings;let a=!1;if(n===void 0)t=de(this,t,e,0),a=!Ee(t)||t!==this._$AH&&t!==ue,a&&(this._$AH=t);else{const o=t;let c,l;for(t=n[0],c=0;c<n.length-1;c++)l=de(this,o[r+c],e,c),l===ue&&(l=this._$AH[c]),a||(a=!Ee(l)||l!==this._$AH[c]),l===$?t=$:t!==$&&(t+=(l??"")+n[c+1]),this._$AH[c]=l}a&&!i&&this.j(t)}j(t){t===$?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Qi extends ft{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$?void 0:t}}let Xi=class extends ft{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==$)}},Ki=class extends ft{constructor(t,e,r,i,n){super(t,e,r,i,n),this.type=5}_$AI(t,e=this){if((t=de(this,t,e,0)??$)===ue)return;const r=this._$AH,i=t===$&&r!==$||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==$&&(r===$||i);i&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Yi=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){de(this,t)}};const yt=ye.litHtmlPolyfillSupport;yt==null||yt(Re,ss),(ye.litHtmlVersions??(ye.litHtmlVersions=[])).push("3.3.2");const R=(s,t,e)=>{const r=t;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new ss(t.insertBefore($e(),null),null,void 0,{})),i._$AI(s),i};/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2017 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/const Ji={CHILD:2},hr=s=>(...t)=>({_$litDirective$:s,values:t});class en{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}/**
|
|
12
|
-
* @license
|
|
13
|
-
* Copyright 2017 Google LLC
|
|
14
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
15
|
-
*/class it extends en{constructor(t){if(super(t),this.it=$,t.type!==Ji.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===$||t==null)return this._t=void 0,this.it=t;if(t===ue)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}it.directiveName="unsafeHTML",it.resultType=1;const tn=hr(it);/**
|
|
16
|
-
* @license
|
|
17
|
-
* Copyright 2017 Google LLC
|
|
18
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/class Ct extends it{}Ct.directiveName="unsafeSVG",Ct.resultType=2;const sn=hr(Ct),rn={size:16,color:"currentColor",weight:"regular"};function nn(s){return typeof s=="string"?{regular:s}:s}function rs(s,t="0 0 256 256"){const e=nn(s);return r=>{const{size:i,color:n,weight:a}={...rn,...r},o=e[a]??e.regular;return b`<svg
|
|
20
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
-
data-ui-icon=""
|
|
22
|
-
width="${i}"
|
|
23
|
-
height="${i}"
|
|
24
|
-
viewBox="${t}"
|
|
25
|
-
fill="${n}"
|
|
26
|
-
>${sn(o)}</svg>`}}const an=new Map,_t=new Set;var le,Ve;const fs=class fs extends HTMLElement{constructor(){super(...arguments);S(this,le)}connectedCallback(){g(this,le,Ve).call(this)}disconnectedCallback(){_t.delete(this)}attributeChangedCallback(){g(this,le,Ve).call(this)}refresh(){g(this,le,Ve).call(this)}get name(){return this.getAttribute("name")}get size(){const e=this.getAttribute("size");if(e===null)return;const r=Number(e);return Number.isFinite(r)?r:void 0}get weight(){const e=this.getAttribute("weight");return e==="bold"||e==="regular"?e:void 0}};le=new WeakSet,Ve=function(){const e=this.name?an.get(this.name):null;if(!e){this.name&&_t.add(this),R(null,this);return}_t.delete(this),R(e({size:this.size,weight:this.weight}),this)},fs.observedAttributes=["name","size","weight"];let It=fs;customElements.get("icon-element")||customElements.define("icon-element",It);const ur=rs('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>'),Pt=rs('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),on=rs('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class dr extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0}),this.value=t}}class pr extends Event{constructor(t){super("select",{bubbles:!0,composed:!0}),this.value=t}}var T,L,B,ce,_,De,m,fr,be,gr,kr,Wt,Lt,Qe,V,J,Ce,Ie,Pe,ct,mr,br,Mt,we,zt,O;const gs=class gs extends HTMLElement{constructor(){super();S(this,m);S(this,T,!1);S(this,L,null);S(this,B,null);S(this,ce);S(this,_,null);S(this,De,new MutationObserver(e=>g(this,m,mr).call(this,e)));S(this,J,()=>{g(this,m,Qe).call(this,!d(this,T))});S(this,Ce,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),d(this,J).call(this))});S(this,Ie,e=>{d(this,T)&&(e.composedPath().includes(this)||g(this,m,Qe).call(this,!1))});S(this,Pe,e=>{e instanceof dr&&(e.stopPropagation(),I(this,T,!1),g(this,m,be).call(this,e.value),g(this,m,O).call(this),this.dispatchEvent(new pr(e.value)))});S(this,ct,()=>{g(this,m,Mt).call(this)});I(this,ce,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",d(this,Pe)),document.addEventListener("click",d(this,Ie),!0),g(this,m,fr).call(this),d(this,De).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),g(this,m,O).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",d(this,Pe)),document.removeEventListener("click",d(this,Ie),!0),d(this,De).disconnect(),g(this,m,zt).call(this)}attributeChangedCallback(){g(this,m,O).call(this)}get title(){return this.getAttribute("title")??""}get value(){return d(this,L)}set value(e){e===null?(g(this,m,V).call(this,null,null),g(this,m,gr).call(this)):g(this,m,be).call(this,e),g(this,m,O).call(this)}close(){g(this,m,Qe).call(this,!1)}};T=new WeakMap,L=new WeakMap,B=new WeakMap,ce=new WeakMap,_=new WeakMap,De=new WeakMap,m=new WeakSet,fr=function(){var r;const e=this.querySelector("dropdown-item[selected]");e&&g(this,m,V).call(this,e.value,((r=e.textContent)==null?void 0:r.trim())??null)},be=function(e){var r;for(const i of d(this,m,Wt))i.value===e?(g(this,m,V).call(this,e,((r=i.textContent)==null?void 0:r.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},gr=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const r of e)r.removeAttribute("selected")},kr=function(e){for(const r of d(this,m,Wt))if(r.value===e)return r;return null},Wt=function(){return this.querySelectorAll("dropdown-item")},Lt=function(){return d(this,B)??this.title},Qe=function(e){d(this,T)!==e&&(I(this,T,e),g(this,m,O).call(this))},V=function(e,r){I(this,L,e),I(this,B,r)},J=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Pe=new WeakMap,ct=new WeakMap,mr=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||g(this,m,br).call(this)},br=function(){var r,i;const e=this.querySelector("dropdown-item[selected]");if(e){const n=e.value,a=((r=e.textContent)==null?void 0:r.trim())??null,o=d(this,L)!==n||d(this,B)!==a;g(this,m,V).call(this,n,a),g(this,m,be).call(this,n),o?g(this,m,O).call(this):g(this,m,we).call(this);return}if(d(this,L)!==null){const n=g(this,m,kr).call(this,d(this,L));if(n){const a=((i=n.textContent)==null?void 0:i.trim())??null,o=d(this,B)!==a;g(this,m,V).call(this,d(this,L),a),g(this,m,be).call(this,d(this,L)),o?g(this,m,O).call(this):g(this,m,we).call(this);return}}if(d(this,L)!==null||d(this,B)!==null){g(this,m,V).call(this,null,null),g(this,m,O).call(this);return}g(this,m,we).call(this)},Mt=function(){const e=d(this,ce).querySelector('slot[name="trigger"]'),r=e instanceof HTMLSlotElement?e.assignedElements({flatten:!0})[0]??null:null;d(this,_)!==r&&(g(this,m,zt).call(this),I(this,_,r),d(this,_)&&(d(this,_).addEventListener("click",d(this,J)),d(this,_)instanceof HTMLButtonElement?d(this,_).hasAttribute("type")||(d(this,_).type="button"):(d(this,_).hasAttribute("role")||d(this,_).setAttribute("role","button"),d(this,_).hasAttribute("tabindex")||(d(this,_).tabIndex=0),d(this,_).addEventListener("keydown",d(this,Ce))))),g(this,m,we).call(this)},we=function(){d(this,_)&&(d(this,_).setAttribute("data-dropdown-trigger",""),d(this,_).setAttribute("aria-haspopup","listbox"),d(this,_).setAttribute("aria-expanded",d(this,T)?"true":"false"),R(b`
|
|
27
|
-
<span class="trigger-label" data-dropdown-trigger-label>${d(this,m,Lt)}</span>
|
|
28
|
-
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
29
|
-
${Pt({size:14})}
|
|
30
|
-
</span>
|
|
31
|
-
`,d(this,_)))},zt=function(){d(this,_)&&(d(this,_).removeEventListener("click",d(this,J)),d(this,_).removeEventListener("keydown",d(this,Ce)),d(this,_).removeAttribute("data-dropdown-trigger"),d(this,_).removeAttribute("aria-haspopup"),d(this,_).removeAttribute("aria-expanded"),I(this,_,null))},O=function(){this.toggleAttribute("open",d(this,T)),R(b`
|
|
32
|
-
<slot name="trigger" @slotchange=${d(this,ct)}>
|
|
33
|
-
<button
|
|
34
|
-
class="fallback-trigger"
|
|
35
|
-
part="trigger"
|
|
36
|
-
type="button"
|
|
37
|
-
aria-haspopup="listbox"
|
|
38
|
-
aria-expanded=${d(this,T)?"true":"false"}
|
|
39
|
-
@click=${d(this,J)}
|
|
40
|
-
>
|
|
41
|
-
<span class="trigger-label" part="trigger-label">${d(this,m,Lt)}</span>
|
|
42
|
-
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
43
|
-
${Pt({size:14})}
|
|
44
|
-
</span>
|
|
45
|
-
</button>
|
|
46
|
-
</slot>
|
|
47
|
-
${d(this,T)?b`
|
|
48
|
-
<div class="panel" part="panel" role="listbox">
|
|
49
|
-
<slot></slot>
|
|
50
|
-
</div>
|
|
51
|
-
`:null}
|
|
52
|
-
`,d(this,ce)),queueMicrotask(()=>g(this,m,Mt).call(this))},gs.observedAttributes=["title"];let Tt=gs;class ln extends HTMLElement{}class cn extends HTMLElement{}class hn extends HTMLElement{}var ie,Ft,wr,Te,We;const ks=class ks extends HTMLElement{constructor(){super(...arguments);S(this,ie);S(this,Te,()=>{this.action||g(this,ie,wr).call(this)});S(this,We,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",d(this,Te)),this.addEventListener("keydown",d(this,We)),g(this,ie,Ft).call(this)}disconnectedCallback(){this.removeEventListener("click",d(this,Te)),this.removeEventListener("keydown",d(this,We))}attributeChangedCallback(){g(this,ie,Ft).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}};ie=new WeakSet,Ft=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},wr=function(){this.dispatchEvent(new dr(this.value))},Te=new WeakMap,We=new WeakMap,ks.observedAttributes=["action","selected","value"];let Nt=ks;customElements.get("dropdown-menu")||customElements.define("dropdown-menu",Tt);customElements.get("dropdown-group")||customElements.define("dropdown-group",ln);customElements.get("dropdown-label")||customElements.define("dropdown-label",cn);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",hn);customElements.get("dropdown-item")||customElements.define("dropdown-item",Nt);class un extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Le,j,Ut,ht,Me,Ht;const ms=class ms extends HTMLElement{constructor(){super();S(this,j);S(this,Le);S(this,ht,e=>{e.target===e.currentTarget&&g(this,j,Ut).call(this)});S(this,Me,e=>{this.open&&e.key==="Escape"&&g(this,j,Ut).call(this)});I(this,Le,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",d(this,Me)),g(this,j,Ht).call(this)}disconnectedCallback(){document.removeEventListener("keydown",d(this,Me))}attributeChangedCallback(){g(this,j,Ht).call(this)}get open(){return this.hasAttribute("open")}};Le=new WeakMap,j=new WeakSet,Ut=function(){this.dispatchEvent(new un)},ht=new WeakMap,Me=new WeakMap,Ht=function(){R(b`
|
|
53
|
-
${this.open?b`
|
|
54
|
-
<div class="backdrop" part="backdrop" @click=${d(this,ht)}>
|
|
55
|
-
<slot></slot>
|
|
56
|
-
</div>
|
|
57
|
-
`:null}
|
|
58
|
-
`,d(this,Le))},ms.observedAttributes=["open"];let Ot=ms;customElements.get("modal-overlay")||customElements.define("modal-overlay",Ot);class vr extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class dn extends HTMLElement{}var ze,C,Ne,A,Xe,Ke,xr,yr,ve,_r,Fe,Bt;const bs=class bs extends HTMLElement{constructor(){super();S(this,A);S(this,ze);S(this,C,[]);S(this,Ne,new MutationObserver(()=>g(this,A,_r).call(this)));S(this,Fe,e=>{const r=e.target;if(!(r instanceof Element))return;const i=r.closest("[data-navigate]");if(i){this.navigate(i.dataset.navigate??"");return}r.closest("[data-back]")&&this.back()});I(this,ze,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("click",d(this,Fe)),d(this,Ne).observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["id","title"]}),g(this,A,ve).call(this)}disconnectedCallback(){this.removeEventListener("click",d(this,Fe)),d(this,Ne).disconnect(),I(this,C,[])}attributeChangedCallback(){g(this,A,Bt).call(this)}get closable(){return this.hasAttribute("closable")}navigate(e){var n;const r=((n=d(this,A,Xe))==null?void 0:n.id)??null;e===r||!g(this,A,Ke).call(this,e)||(d(this,C).push(e),g(this,A,ve).call(this))}back(){d(this,C).length<=1||(d(this,C).pop(),g(this,A,ve).call(this))}};ze=new WeakMap,C=new WeakMap,Ne=new WeakMap,A=new WeakSet,Xe=function(){const e=d(this,C)[d(this,C).length-1]??null;return e?g(this,A,Ke).call(this,e):null},Ke=function(e){const r=this.querySelectorAll("panel-page");for(const i of r)if(i.id===e)return i;return null},xr=function(){if(I(this,C,d(this,C).filter(r=>g(this,A,Ke).call(this,r)!==null)),d(this,C).length>0)return;const e=this.querySelector("panel-page");e!=null&&e.id&&I(this,C,[e.id])},yr=function(){g(this,A,xr).call(this);const e=d(this,A,Xe),r=this.querySelectorAll("panel-page");for(const i of r)i.hidden=i!==e},ve=function(){g(this,A,yr).call(this),g(this,A,Bt).call(this)},_r=function(){g(this,A,ve).call(this)},Fe=new WeakMap,Bt=function(){const e=d(this,A,Xe);R(b`
|
|
59
|
-
<section class="panel" part="panel">
|
|
60
|
-
<header class="title-bar" part="header">
|
|
61
|
-
<div class="title-group" part="title-group">
|
|
62
|
-
${d(this,C).length>1?b`
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
class="title-button"
|
|
66
|
-
part="button back-button"
|
|
67
|
-
aria-label="Back"
|
|
68
|
-
@click=${()=>this.back()}
|
|
69
|
-
>
|
|
70
|
-
<span class="back-icon" part="icon back-icon">
|
|
71
|
-
${Pt({size:14})}
|
|
72
|
-
</span>
|
|
73
|
-
</button>
|
|
74
|
-
`:null}
|
|
75
|
-
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
76
|
-
</div>
|
|
77
|
-
${this.closable?b`
|
|
78
|
-
<button
|
|
79
|
-
type="button"
|
|
80
|
-
class="title-button"
|
|
81
|
-
part="button close-button"
|
|
82
|
-
aria-label="Close"
|
|
83
|
-
@click=${()=>this.dispatchEvent(new vr)}
|
|
84
|
-
>
|
|
85
|
-
<span class="close-icon" part="icon close-icon">${ur({size:14})}</span>
|
|
86
|
-
</button>
|
|
87
|
-
`:null}
|
|
88
|
-
</header>
|
|
89
|
-
<slot></slot>
|
|
90
|
-
</section>
|
|
91
|
-
`,d(this,ze))},bs.observedAttributes=["closable"];let qt=bs;customElements.get("panel-view")||customElements.define("panel-view",qt);customElements.get("panel-page")||customElements.define("panel-page",dn);class Ue{constructor(){this.disposables=[]}add(t){return this.disposables.push(t),t}dispose(){for(const t of this.disposables)t.dispose();this.disposables=[]}}function is(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ne=is();function Sr(s){ne=s}var X={exec:()=>null};function v(s,t=""){let e=typeof s=="string"?s:s.source,r={replace:(i,n)=>{let a=typeof n=="string"?n:n.source;return a=a.replace(D.caret,"$1"),e=e.replace(i,a),r},getRegex:()=>new RegExp(e,t)};return r}var pn=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),D={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:s=>new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}#`),htmlBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}>`)},fn=/^(?:[ \t]*(?:\n|$))+/,gn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,He=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,mn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ns=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ar=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$r=v(Ar).replace(/bull/g,ns).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),bn=v(Ar).replace(/bull/g,ns).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),as=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,wn=/^[^\n]+/,os=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,vn=v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",os).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),xn=v(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ns).getRegex(),gt="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ls=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yn=v("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ls).replace("tag",gt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Er=v(as).replace("hr",He).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",gt).getRegex(),_n=v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Er).getRegex(),cs={blockquote:_n,code:gn,def:vn,fences:kn,heading:mn,hr:He,html:yn,lheading:$r,list:xn,newline:fn,paragraph:Er,table:X,text:wn},Us=v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",He).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",gt).getRegex(),Sn={...cs,lheading:bn,table:Us,paragraph:v(as).replace("hr",He).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Us).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",gt).getRegex()},An={...cs,html:v(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ls).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:X,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:v(as).replace("hr",He).replace("heading",` *#{1,6} *[^
|
|
92
|
-
]`).replace("lheading",$r).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},$n=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,En=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Rr=/^( {2,}|\\)\n(?!\s*$)/,Rn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,kt=/[\p{P}\p{S}]/u,hs=/[\s\p{P}\p{S}]/u,Dr=/[^\s\p{P}\p{S}]/u,Dn=v(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,hs).getRegex(),Cr=/(?!~)[\p{P}\p{S}]/u,Cn=/(?!~)[\s\p{P}\p{S}]/u,In=/(?:[^\s\p{P}\p{S}]|~)/u,Ir=/(?![*_])[\p{P}\p{S}]/u,Pn=/(?![*_])[\s\p{P}\p{S}]/u,Tn=/(?:[^\s\p{P}\p{S}]|[*_])/u,Wn=v(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",pn?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Pr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ln=v(Pr,"u").replace(/punct/g,kt).getRegex(),Mn=v(Pr,"u").replace(/punct/g,Cr).getRegex(),Tr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",zn=v(Tr,"gu").replace(/notPunctSpace/g,Dr).replace(/punctSpace/g,hs).replace(/punct/g,kt).getRegex(),Nn=v(Tr,"gu").replace(/notPunctSpace/g,In).replace(/punctSpace/g,Cn).replace(/punct/g,Cr).getRegex(),Fn=v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Dr).replace(/punctSpace/g,hs).replace(/punct/g,kt).getRegex(),On=v(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ir).getRegex(),Un="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Hn=v(Un,"gu").replace(/notPunctSpace/g,Tn).replace(/punctSpace/g,Pn).replace(/punct/g,Ir).getRegex(),qn=v(/\\(punct)/,"gu").replace(/punct/g,kt).getRegex(),Bn=v(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),jn=v(ls).replace("(?:-->|$)","-->").getRegex(),Zn=v("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",jn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),nt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Gn=v(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",nt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Wr=v(/^!?\[(label)\]\[(ref)\]/).replace("label",nt).replace("ref",os).getRegex(),Lr=v(/^!?\[(ref)\](?:\[\])?/).replace("ref",os).getRegex(),Vn=v("reflink|nolink(?!\\()","g").replace("reflink",Wr).replace("nolink",Lr).getRegex(),Hs=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,us={_backpedal:X,anyPunctuation:qn,autolink:Bn,blockSkip:Wn,br:Rr,code:En,del:X,delLDelim:X,delRDelim:X,emStrongLDelim:Ln,emStrongRDelimAst:zn,emStrongRDelimUnd:Fn,escape:$n,link:Gn,nolink:Lr,punctuation:Dn,reflink:Wr,reflinkSearch:Vn,tag:Zn,text:Rn,url:X},Qn={...us,link:v(/^!?\[(label)\]\((.*?)\)/).replace("label",nt).getRegex(),reflink:v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",nt).getRegex()},jt={...us,emStrongRDelimAst:Nn,emStrongLDelim:Mn,delLDelim:On,delRDelim:Hn,url:v(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Hs).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:v(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Hs).getRegex()},Xn={...jt,br:v(Rr).replace("{2,}","*").getRegex(),text:v(jt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ze={normal:cs,gfm:Sn,pedantic:An},ge={normal:us,gfm:jt,breaks:Xn,pedantic:Qn},Kn={"&":"&","<":"<",">":">",'"':""","'":"'"},qs=s=>Kn[s];function F(s,t){if(t){if(D.escapeTest.test(s))return s.replace(D.escapeReplace,qs)}else if(D.escapeTestNoEncode.test(s))return s.replace(D.escapeReplaceNoEncode,qs);return s}function Bs(s){try{s=encodeURI(s).replace(D.percentDecode,"%")}catch{return null}return s}function js(s,t){var n;let e=s.replace(D.findPipe,(a,o,c)=>{let l=!1,u=o;for(;--u>=0&&c[u]==="\\";)l=!l;return l?"|":" |"}),r=e.split(D.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((n=r.at(-1))!=null&&n.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(D.slashPipe,"|");return r}function ke(s,t,e){let r=s.length;if(r===0)return"";let i=0;for(;i<r&&s.charAt(r-i-1)===t;)i++;return s.slice(0,r-i)}function Yn(s,t){if(s.indexOf(t[1])===-1)return-1;let e=0;for(let r=0;r<s.length;r++)if(s[r]==="\\")r++;else if(s[r]===t[0])e++;else if(s[r]===t[1]&&(e--,e<0))return r;return e>0?-2:-1}function Jn(s,t=0){let e=t,r="";for(let i of s)if(i===" "){let n=4-e%4;r+=" ".repeat(n),e+=n}else r+=i,e++;return r}function Zs(s,t,e,r,i){let n=t.href,a=t.title||null,o=s[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:s[0].charAt(0)==="!"?"image":"link",raw:e,href:n,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,c}function ea(s,t,e){let r=s.match(e.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
93
|
-
`).map(n=>{let a=n.match(e.other.beginningSpace);if(a===null)return n;let[o]=a;return o.length>=i.length?n.slice(i.length):n}).join(`
|
|
94
|
-
`)}var at=class{constructor(s){h(this,"options");h(this,"rules");h(this,"lexer");this.options=s||ne}space(s){let t=this.rules.block.newline.exec(s);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(s){let t=this.rules.block.code.exec(s);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ke(e,`
|
|
95
|
-
`)}}}fences(s){let t=this.rules.block.fences.exec(s);if(t){let e=t[0],r=ea(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(s){let t=this.rules.block.heading.exec(s);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let r=ke(e,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(e=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(s){let t=this.rules.block.hr.exec(s);if(t)return{type:"hr",raw:ke(t[0],`
|
|
96
|
-
`)}}blockquote(s){let t=this.rules.block.blockquote.exec(s);if(t){let e=ke(t[0],`
|
|
97
|
-
`).split(`
|
|
98
|
-
`),r="",i="",n=[];for(;e.length>0;){let a=!1,o=[],c;for(c=0;c<e.length;c++)if(this.rules.other.blockquoteStart.test(e[c]))o.push(e[c]),a=!0;else if(!a)o.push(e[c]);else break;e=e.slice(c);let l=o.join(`
|
|
99
|
-
`),u=l.replace(this.rules.other.blockquoteSetextReplace,`
|
|
100
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
101
|
-
${l}`:l,i=i?`${i}
|
|
102
|
-
${u}`:u;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,n,!0),this.lexer.state.top=f,e.length===0)break;let k=n.at(-1);if((k==null?void 0:k.type)==="code")break;if((k==null?void 0:k.type)==="blockquote"){let p=k,x=p.raw+`
|
|
103
|
-
`+e.join(`
|
|
104
|
-
`),w=this.blockquote(x);n[n.length-1]=w,r=r.substring(0,r.length-p.raw.length)+w.raw,i=i.substring(0,i.length-p.text.length)+w.text;break}else if((k==null?void 0:k.type)==="list"){let p=k,x=p.raw+`
|
|
105
|
-
`+e.join(`
|
|
106
|
-
`),w=this.list(x);n[n.length-1]=w,r=r.substring(0,r.length-k.raw.length)+w.raw,i=i.substring(0,i.length-p.raw.length)+w.raw,e=x.substring(n.at(-1).raw.length).split(`
|
|
107
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:n,text:i}}}list(s){var e,r;let t=this.rules.block.list.exec(s);if(t){let i=t[1].trim(),n=i.length>1,a={type:"list",raw:"",ordered:n,start:n?+i.slice(0,-1):"",loose:!1,items:[]};i=n?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=n?i:"[*+-]");let o=this.rules.other.listItemRegex(i),c=!1;for(;s;){let u=!1,f="",k="";if(!(t=o.exec(s))||this.rules.block.hr.test(s))break;f=t[0],s=s.substring(f.length);let p=Jn(t[2].split(`
|
|
108
|
-
`,1)[0],t[1].length),x=s.split(`
|
|
109
|
-
`,1)[0],w=!p.trim(),E=0;if(this.options.pedantic?(E=2,k=p.trimStart()):w?E=t[1].length+1:(E=p.search(this.rules.other.nonSpaceChar),E=E>4?1:E,k=p.slice(E),E+=t[1].length),w&&this.rules.other.blankLine.test(x)&&(f+=x+`
|
|
110
|
-
`,s=s.substring(x.length+1),u=!0),!u){let ae=this.rules.other.nextBulletRegex(E),qe=this.rules.other.hrRegex(E),ws=this.rules.other.fencesBeginRegex(E),vs=this.rules.other.headingBeginRegex(E),Zr=this.rules.other.htmlBeginRegex(E),Gr=this.rules.other.blockquoteBeginRegex(E);for(;s;){let mt=s.split(`
|
|
111
|
-
`,1)[0],pe;if(x=mt,this.options.pedantic?(x=x.replace(this.rules.other.listReplaceNesting," "),pe=x):pe=x.replace(this.rules.other.tabCharGlobal," "),ws.test(x)||vs.test(x)||Zr.test(x)||Gr.test(x)||ae.test(x)||qe.test(x))break;if(pe.search(this.rules.other.nonSpaceChar)>=E||!x.trim())k+=`
|
|
112
|
-
`+pe.slice(E);else{if(w||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ws.test(p)||vs.test(p)||qe.test(p))break;k+=`
|
|
113
|
-
`+x}w=!x.trim(),f+=mt+`
|
|
114
|
-
`,s=s.substring(mt.length+1),p=pe.slice(E)}}a.loose||(c?a.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(c=!0)),a.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(k),loose:!1,text:k,tokens:[]}),a.raw+=f}let l=a.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let u of a.items){if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),u.task){if(u.text=u.text.replace(this.rules.other.listReplaceTask,""),((e=u.tokens[0])==null?void 0:e.type)==="text"||((r=u.tokens[0])==null?void 0:r.type)==="paragraph"){u.tokens[0].raw=u.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),u.tokens[0].text=u.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let k=this.lexer.inlineQueue.length-1;k>=0;k--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)){this.lexer.inlineQueue[k].src=this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(u.raw);if(f){let k={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};u.checked=k.checked,a.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=k.raw+u.tokens[0].raw,u.tokens[0].text=k.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(k)):u.tokens.unshift({type:"paragraph",raw:k.raw,text:k.raw,tokens:[k]}):u.tokens.unshift(k)}}if(!a.loose){let f=u.tokens.filter(p=>p.type==="space"),k=f.length>0&&f.some(p=>this.rules.other.anyLine.test(p.raw));a.loose=k}}if(a.loose)for(let u of a.items){u.loose=!0;for(let f of u.tokens)f.type==="text"&&(f.type="paragraph")}return a}}html(s){let t=this.rules.block.html.exec(s);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(s){let t=this.rules.block.def.exec(s);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:r,title:i}}}table(s){var a;let t=this.rules.block.table.exec(s);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=js(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
115
|
-
`):[],n={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?n.align.push("right"):this.rules.other.tableAlignCenter.test(o)?n.align.push("center"):this.rules.other.tableAlignLeft.test(o)?n.align.push("left"):n.align.push(null);for(let o=0;o<e.length;o++)n.header.push({text:e[o],tokens:this.lexer.inline(e[o]),header:!0,align:n.align[o]});for(let o of i)n.rows.push(js(o,n.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:n.align[l]})));return n}}lheading(s){let t=this.rules.block.lheading.exec(s);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(s){let t=this.rules.block.paragraph.exec(s);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
116
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(s){let t=this.rules.block.text.exec(s);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(s){let t=this.rules.inline.escape.exec(s);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(s){let t=this.rules.inline.tag.exec(s);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(s){let t=this.rules.inline.link.exec(s);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=ke(e.slice(0,-1),"\\");if((e.length-n.length)%2===0)return}else{let n=Yn(t[2],"()");if(n===-2)return;if(n>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+n;t[2]=t[2].substring(0,n),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let n=this.rules.other.pedanticHrefTitle.exec(r);n&&(r=n[1],i=n[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?r=r.slice(1):r=r.slice(1,-1)),Zs(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(s,t){let e;if((e=this.rules.inline.reflink.exec(s))||(e=this.rules.inline.nolink.exec(s))){let r=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let n=e[0].charAt(0);return{type:"text",raw:n,text:n}}return Zs(e,i,e[0],this.lexer,this.rules)}}emStrong(s,t,e=""){let r=this.rules.inline.emStrongLDelim.exec(s);if(!(!r||r[3]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,n,a,o=i,c=0,l=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*s.length+i);(r=l.exec(t))!=null;){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(a=[...n].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&i%3&&!((i+a)%3)){c+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+c);let u=[...r[0]][0].length,f=s.slice(0,i+r.index+u+a);if(Math.min(i,a)%2){let p=f.slice(1,-1);return{type:"em",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}let k=f.slice(2,-2);return{type:"strong",raw:f,text:k,tokens:this.lexer.inlineTokens(k)}}}}codespan(s){let t=this.rules.inline.code.exec(s);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return r&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(s){let t=this.rules.inline.br.exec(s);if(t)return{type:"br",raw:t[0]}}del(s,t,e=""){let r=this.rules.inline.delLDelim.exec(s);if(r&&(!r[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,n,a,o=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*s.length+i);(r=c.exec(t))!=null;){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n||(a=[...n].length,a!==i))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let l=[...r[0]][0].length,u=s.slice(0,i+r.index+l+a),f=u.slice(i,-i);return{type:"del",raw:u,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(s){let t=this.rules.inline.autolink.exec(s);if(t){let e,r;return t[2]==="@"?(e=t[1],r="mailto:"+e):(e=t[1],r=e),{type:"link",raw:t[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(s){var e;let t;if(t=this.rules.inline.url.exec(s)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let n;do n=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(n!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(s){let t=this.rules.inline.text.exec(s);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},M=class Zt{constructor(t){h(this,"tokens");h(this,"options");h(this,"state");h(this,"inlineQueue");h(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ne,this.options.tokenizer=this.options.tokenizer||new at,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:D,block:Ze.normal,inline:ge.normal};this.options.pedantic?(e.block=Ze.pedantic,e.inline=ge.pedantic):this.options.gfm&&(e.block=Ze.gfm,this.options.breaks?e.inline=ge.breaks:e.inline=ge.gfm),this.tokenizer.rules=e}static get rules(){return{block:Ze,inline:ge}}static lex(t,e){return new Zt(e).lex(t)}static lexInline(t,e){return new Zt(e).inlineTokens(t)}lex(t){t=t.replace(D.carriageReturn,`
|
|
117
|
-
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let r=this.inlineQueue[e];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],r=!1){var i,n,a;for(this.options.pedantic&&(t=t.replace(D.tabCharGlobal," ").replace(D.spaceLine,""));t;){let o;if((n=(i=this.options.extensions)==null?void 0:i.block)!=null&&n.some(l=>(o=l.call({lexer:this},t,e))?(t=t.substring(o.raw.length),e.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let l=e.at(-1);o.raw.length===1&&l!==void 0?l.raw+=`
|
|
118
|
-
`:e.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let l=e.at(-1);(l==null?void 0:l.type)==="paragraph"||(l==null?void 0:l.type)==="text"?(l.raw+=(l.raw.endsWith(`
|
|
119
|
-
`)?"":`
|
|
120
|
-
`)+o.raw,l.text+=`
|
|
121
|
-
`+o.text,this.inlineQueue.at(-1).src=l.text):e.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let l=e.at(-1);(l==null?void 0:l.type)==="paragraph"||(l==null?void 0:l.type)==="text"?(l.raw+=(l.raw.endsWith(`
|
|
122
|
-
`)?"":`
|
|
123
|
-
`)+o.raw,l.text+=`
|
|
124
|
-
`+o.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},e.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),e.push(o);continue}let c=t;if((a=this.options.extensions)!=null&&a.startBlock){let l=1/0,u=t.slice(1),f;this.options.extensions.startBlock.forEach(k=>{f=k.call({lexer:this},u),typeof f=="number"&&f>=0&&(l=Math.min(l,f))}),l<1/0&&l>=0&&(c=t.substring(0,l+1))}if(this.state.top&&(o=this.tokenizer.paragraph(c))){let l=e.at(-1);r&&(l==null?void 0:l.type)==="paragraph"?(l.raw+=(l.raw.endsWith(`
|
|
125
|
-
`)?"":`
|
|
126
|
-
`)+o.raw,l.text+=`
|
|
127
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):e.push(o),r=c.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let l=e.at(-1);(l==null?void 0:l.type)==="text"?(l.raw+=(l.raw.endsWith(`
|
|
128
|
-
`)?"":`
|
|
129
|
-
`)+o.raw,l.text+=`
|
|
130
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):e.push(o);continue}if(t){let l="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var c,l,u,f,k;let r=t,i=null;if(this.tokens.links){let p=Object.keys(this.tokens.links);if(p.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)p.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let n;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)n=i[2]?i[2].length:0,r=r.slice(0,i.index+n)+"["+"a".repeat(i[0].length-n-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((l=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:l.call({lexer:this},r))??r;let a=!1,o="";for(;t;){a||(o=""),a=!1;let p;if((f=(u=this.options.extensions)==null?void 0:u.inline)!=null&&f.some(w=>(p=w.call({lexer:this},t,e))?(t=t.substring(p.raw.length),e.push(p),!0):!1))continue;if(p=this.tokenizer.escape(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.tag(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.link(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(p.raw.length);let w=e.at(-1);p.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=p.raw,w.text+=p.text):e.push(p);continue}if(p=this.tokenizer.emStrong(t,r,o)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.codespan(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.br(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.del(t,r,o)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.autolink(t)){t=t.substring(p.raw.length),e.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(t))){t=t.substring(p.raw.length),e.push(p);continue}let x=t;if((k=this.options.extensions)!=null&&k.startInline){let w=1/0,E=t.slice(1),ae;this.options.extensions.startInline.forEach(qe=>{ae=qe.call({lexer:this},E),typeof ae=="number"&&ae>=0&&(w=Math.min(w,ae))}),w<1/0&&w>=0&&(x=t.substring(0,w+1))}if(p=this.tokenizer.inlineText(x)){t=t.substring(p.raw.length),p.raw.slice(-1)!=="_"&&(o=p.raw.slice(-1)),a=!0;let w=e.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=p.raw,w.text+=p.text):e.push(p);continue}if(t){let w="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(w);break}else throw new Error(w)}}return e}},ot=class{constructor(s){h(this,"options");h(this,"parser");this.options=s||ne}space(s){return""}code({text:s,lang:t,escaped:e}){var n;let r=(n=(t||"").match(D.notSpaceStart))==null?void 0:n[0],i=s.replace(D.endingNewline,"")+`
|
|
131
|
-
`;return r?'<pre><code class="language-'+F(r)+'">'+(e?i:F(i,!0))+`</code></pre>
|
|
132
|
-
`:"<pre><code>"+(e?i:F(i,!0))+`</code></pre>
|
|
133
|
-
`}blockquote({tokens:s}){return`<blockquote>
|
|
134
|
-
${this.parser.parse(s)}</blockquote>
|
|
135
|
-
`}html({text:s}){return s}def(s){return""}heading({tokens:s,depth:t}){return`<h${t}>${this.parser.parseInline(s)}</h${t}>
|
|
136
|
-
`}hr(s){return`<hr>
|
|
137
|
-
`}list(s){let t=s.ordered,e=s.start,r="";for(let a=0;a<s.items.length;a++){let o=s.items[a];r+=this.listitem(o)}let i=t?"ol":"ul",n=t&&e!==1?' start="'+e+'"':"";return"<"+i+n+`>
|
|
138
|
-
`+r+"</"+i+`>
|
|
139
|
-
`}listitem(s){return`<li>${this.parser.parse(s.tokens)}</li>
|
|
140
|
-
`}checkbox({checked:s}){return"<input "+(s?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:s}){return`<p>${this.parser.parseInline(s)}</p>
|
|
141
|
-
`}table(s){let t="",e="";for(let i=0;i<s.header.length;i++)e+=this.tablecell(s.header[i]);t+=this.tablerow({text:e});let r="";for(let i=0;i<s.rows.length;i++){let n=s.rows[i];e="";for(let a=0;a<n.length;a++)e+=this.tablecell(n[a]);r+=this.tablerow({text:e})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
142
|
-
<thead>
|
|
143
|
-
`+t+`</thead>
|
|
144
|
-
`+r+`</table>
|
|
145
|
-
`}tablerow({text:s}){return`<tr>
|
|
146
|
-
${s}</tr>
|
|
147
|
-
`}tablecell(s){let t=this.parser.parseInline(s.tokens),e=s.header?"th":"td";return(s.align?`<${e} align="${s.align}">`:`<${e}>`)+t+`</${e}>
|
|
148
|
-
`}strong({tokens:s}){return`<strong>${this.parser.parseInline(s)}</strong>`}em({tokens:s}){return`<em>${this.parser.parseInline(s)}</em>`}codespan({text:s}){return`<code>${F(s,!0)}</code>`}br(s){return"<br>"}del({tokens:s}){return`<del>${this.parser.parseInline(s)}</del>`}link({href:s,title:t,tokens:e}){let r=this.parser.parseInline(e),i=Bs(s);if(i===null)return r;s=i;let n='<a href="'+s+'"';return t&&(n+=' title="'+F(t)+'"'),n+=">"+r+"</a>",n}image({href:s,title:t,text:e,tokens:r}){r&&(e=this.parser.parseInline(r,this.parser.textRenderer));let i=Bs(s);if(i===null)return F(e);s=i;let n=`<img src="${s}" alt="${F(e)}"`;return t&&(n+=` title="${F(t)}"`),n+=">",n}text(s){return"tokens"in s&&s.tokens?this.parser.parseInline(s.tokens):"escaped"in s&&s.escaped?s.text:F(s.text)}},ds=class{strong({text:s}){return s}em({text:s}){return s}codespan({text:s}){return s}del({text:s}){return s}html({text:s}){return s}text({text:s}){return s}link({text:s}){return""+s}image({text:s}){return""+s}br(){return""}checkbox({raw:s}){return s}},z=class Gt{constructor(t){h(this,"options");h(this,"renderer");h(this,"textRenderer");this.options=t||ne,this.options.renderer=this.options.renderer||new ot,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ds}static parse(t,e){return new Gt(e).parse(t)}static parseInline(t,e){return new Gt(e).parseInline(t)}parse(t){var r,i;let e="";for(let n=0;n<t.length;n++){let a=t[n];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[a.type]){let c=a,l=this.options.extensions.renderers[c.type].call({parser:this},c);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){e+=l||"";continue}}let o=a;switch(o.type){case"space":{e+=this.renderer.space(o);break}case"hr":{e+=this.renderer.hr(o);break}case"heading":{e+=this.renderer.heading(o);break}case"code":{e+=this.renderer.code(o);break}case"table":{e+=this.renderer.table(o);break}case"blockquote":{e+=this.renderer.blockquote(o);break}case"list":{e+=this.renderer.list(o);break}case"checkbox":{e+=this.renderer.checkbox(o);break}case"html":{e+=this.renderer.html(o);break}case"def":{e+=this.renderer.def(o);break}case"paragraph":{e+=this.renderer.paragraph(o);break}case"text":{e+=this.renderer.text(o);break}default:{let c='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return e}parseInline(t,e=this.renderer){var i,n;let r="";for(let a=0;a<t.length;a++){let o=t[a];if((n=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&n[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){r+=l||"";continue}}let c=o;switch(c.type){case"escape":{r+=e.text(c);break}case"html":{r+=e.html(c);break}case"link":{r+=e.link(c);break}case"image":{r+=e.image(c);break}case"checkbox":{r+=e.checkbox(c);break}case"strong":{r+=e.strong(c);break}case"em":{r+=e.em(c);break}case"codespan":{r+=e.codespan(c);break}case"br":{r+=e.br(c);break}case"del":{r+=e.del(c);break}case"text":{r+=e.text(c);break}default:{let l='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},Ge,xe=(Ge=class{constructor(s){h(this,"options");h(this,"block");this.options=s||ne}preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}emStrongMask(s){return s}provideLexer(){return this.block?M.lex:M.lexInline}provideParser(){return this.block?z.parse:z.parseInline}},h(Ge,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),h(Ge,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ge),ta=class{constructor(...s){h(this,"defaults",is());h(this,"options",this.setOptions);h(this,"parse",this.parseMarkdown(!0));h(this,"parseInline",this.parseMarkdown(!1));h(this,"Parser",z);h(this,"Renderer",ot);h(this,"TextRenderer",ds);h(this,"Lexer",M);h(this,"Tokenizer",at);h(this,"Hooks",xe);this.use(...s)}walkTokens(s,t){var r,i;let e=[];for(let n of s)switch(e=e.concat(t.call(this,n)),n.type){case"table":{let a=n;for(let o of a.header)e=e.concat(this.walkTokens(o.tokens,t));for(let o of a.rows)for(let c of o)e=e.concat(this.walkTokens(c.tokens,t));break}case"list":{let a=n;e=e.concat(this.walkTokens(a.items,t));break}default:{let a=n;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{let c=a[o].flat(1/0);e=e.concat(this.walkTokens(c,t))}):a.tokens&&(e=e.concat(this.walkTokens(a.tokens,t)))}}return e}use(...s){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return s.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let n=t.renderers[i.name];n?t.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===!1&&(o=n.apply(this,a)),o}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let n=t[i.level];n?n.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),e.renderer){let i=this.defaults.renderer||new ot(this.defaults);for(let n in e.renderer){if(!(n in i))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let a=n,o=e.renderer[a],c=i[a];i[a]=(...l)=>{let u=o.apply(i,l);return u===!1&&(u=c.apply(i,l)),u||""}}r.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new at(this.defaults);for(let n in e.tokenizer){if(!(n in i))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let a=n,o=e.tokenizer[a],c=i[a];i[a]=(...l)=>{let u=o.apply(i,l);return u===!1&&(u=c.apply(i,l)),u}}r.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new xe;for(let n in e.hooks){if(!(n in i))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let a=n,o=e.hooks[a],c=i[a];xe.passThroughHooks.has(n)?i[a]=l=>{if(this.defaults.async&&xe.passThroughHooksRespectAsync.has(n))return(async()=>{let f=await o.call(i,l);return c.call(i,f)})();let u=o.call(i,l);return c.call(i,u)}:i[a]=(...l)=>{if(this.defaults.async)return(async()=>{let f=await o.apply(i,l);return f===!1&&(f=await c.apply(i,l)),f})();let u=o.apply(i,l);return u===!1&&(u=c.apply(i,l)),u}}r.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,n=e.walkTokens;r.walkTokens=function(a){let o=[];return o.push(n.call(this,a)),i&&(o=o.concat(i.call(this,a))),o}}this.defaults={...this.defaults,...r}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,t){return M.lex(s,t??this.defaults)}parser(s,t){return z.parse(s,t??this.defaults)}parseMarkdown(s){return(t,e)=>{let r={...e},i={...this.defaults,...r},n=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return n(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return n(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return n(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=s),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(t):t,o=await(i.hooks?await i.hooks.provideLexer():s?M.lex:M.lexInline)(a,i),c=i.hooks?await i.hooks.processAllTokens(o):o;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let l=await(i.hooks?await i.hooks.provideParser():s?z.parse:z.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(n);try{i.hooks&&(t=i.hooks.preprocess(t));let a=(i.hooks?i.hooks.provideLexer():s?M.lex:M.lexInline)(t,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let o=(i.hooks?i.hooks.provideParser():s?z.parse:z.parseInline)(a,i);return i.hooks&&(o=i.hooks.postprocess(o)),o}catch(a){return n(a)}}}onError(s,t){return e=>{if(e.message+=`
|
|
149
|
-
Please report this to https://github.com/markedjs/marked.`,s){let r="<p>An error occurred:</p><pre>"+F(e.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(e);throw e}}},re=new ta;function y(s,t){return re.parse(s,t)}y.options=y.setOptions=function(s){return re.setOptions(s),y.defaults=re.defaults,Sr(y.defaults),y};y.getDefaults=is;y.defaults=ne;y.use=function(...s){return re.use(...s),y.defaults=re.defaults,Sr(y.defaults),y};y.walkTokens=function(s,t){return re.walkTokens(s,t)};y.parseInline=re.parseInline;y.Parser=z;y.parser=z.parse;y.Renderer=ot;y.TextRenderer=ds;y.Lexer=M;y.lexer=M.lex;y.Tokenizer=at;y.Hooks=xe;y.parse=y;y.options;y.setOptions;y.use;y.walkTokens;y.parseInline;z.parse;M.lex;class Mr extends Event{constructor(e){super("close-artifact",{bubbles:!0,composed:!0});h(this,"id");this.id=e}}function sa(s){return y.parse(s,{async:!1})}class ra extends HTMLElement{constructor(){super(...arguments);h(this,"_artifact",null)}set artifact(e){this._artifact=e,this.render()}get artifact(){return this._artifact}handleClose(){this._artifact&&this.dispatchEvent(new Mr(this._artifact.id))}template(){const e=this._artifact;return b`
|
|
150
|
-
<header class="artifact-title-bar">
|
|
151
|
-
<span class="artifact-title">${e.title}</span>
|
|
152
|
-
<button
|
|
153
|
-
class="artifact-close-btn"
|
|
154
|
-
@click=${()=>this.handleClose()}
|
|
155
|
-
aria-label="Close"
|
|
156
|
-
>${ur({size:14})}</button>
|
|
157
|
-
</header>
|
|
158
|
-
<div class="artifact-content">
|
|
159
|
-
${this.renderContent(e)}
|
|
160
|
-
</div>
|
|
161
|
-
`}renderContent(e){switch(e.type){case"markdown":return b`<div class="markdown-body">${tn(sa(e.content))}</div>`;default:return b`<pre>${e.content}</pre>`}}render(){this._artifact&&R(this.template(),this)}}customElements.define("artifact-view",ra);const lt=600,Vt=800,U=16,ia=800,Gs=.85,Vs=50,na=150,Ye=2;function aa(s){if(s.artifactCount<=0)return{cardWidth:lt,cardHeight:Vt,visibleCount:0,windowWidth:0,sidePeek:0,totalTrackWidth:0,maxScrollPosition:0,scrollPosition:0,translateX:0};const t=s.viewportWidth<ia,e=t?s.viewportWidth*Gs:lt,r=t?s.viewportHeight*Gs:Vt,i=Math.max(1,Math.floor((s.viewportWidth+U)/(e+U))),n=Math.min(s.artifactCount,i),a=n*e+Math.max(n-1,0)*U,o=(s.viewportWidth-a)/Ye,c=s.artifactCount*e+Math.max(s.artifactCount-1,0)*U,l=Math.max(s.artifactCount-n,0),u=Math.min(l,Math.max(0,Math.floor(s.scrollPosition))),f=o-u*(e+U),k=c<=s.viewportWidth?f:Math.min(U,Math.max(s.viewportWidth-U-c,f));return{cardWidth:e,cardHeight:r,visibleCount:n,windowWidth:a,sidePeek:o,totalTrackWidth:c,maxScrollPosition:l,scrollPosition:u,translateX:k}}class zr extends Event{constructor(e){super("focus-changed",{bubbles:!0,composed:!0});h(this,"id");this.id=e}}class Nr extends Event{constructor(){super("focus-cleared",{bubbles:!0,composed:!0})}}class Fr extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});h(this,"scrollPosition");this.scrollPosition=e}}class oa extends HTMLElement{constructor(){super(...arguments);h(this,"_artifacts",[]);h(this,"_focusedArtifactID",null);h(this,"_scrollPosition",0);h(this,"_trackEl",null);h(this,"resizeObserver",null);h(this,"accumulatedScrollDelta",0);h(this,"scrollIdleTimer",null);h(this,"renderPending",!1);h(this,"handleKeyDown",e=>{if(e.key==="Escape")e.preventDefault(),this.exitCenteredMode();else if(e.key==="ArrowRight"){if(e.preventDefault(),this.moveCenteredFocus(1))return;this.shiftWindow(1)}else if(e.key==="ArrowLeft"){if(e.preventDefault(),this.moveCenteredFocus(-1))return;this.shiftWindow(-1)}});h(this,"handleWheel",e=>{const r=e.shiftKey&&e.deltaY!==0?e.deltaY:e.deltaX;if(r!==0){if(e.preventDefault(),this.accumulatedScrollDelta+=r,this.accumulatedScrollDelta>=Vs){if(this.accumulatedScrollDelta=0,this.exitCenteredMode(1))return;this.shiftWindow(1)}else if(this.accumulatedScrollDelta<=-Vs){if(this.accumulatedScrollDelta=0,this.exitCenteredMode(-1))return;this.shiftWindow(-1)}this.scrollIdleTimer!==null&&clearTimeout(this.scrollIdleTimer),this.scrollIdleTimer=setTimeout(()=>{this.accumulatedScrollDelta=0,this.scrollIdleTimer=null},na)}});h(this,"handleBackgroundClick",e=>{const r=e.target;r instanceof Element&&(r.closest(".card-slot")||this.exitCenteredMode())})}set artifacts(e){this._artifacts=e,this.scheduleRender()}get artifacts(){return this._artifacts}set focusedArtifactID(e){this._focusedArtifactID=e,this.scheduleRender()}get focusedArtifactID(){return this._focusedArtifactID}set scrollPosition(e){this._scrollPosition=this.clampScrollPosition(e),this.scheduleRender()}get scrollPosition(){return this.clampScrollPosition(this._scrollPosition)}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("click",this.handleBackgroundClick),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.renderView()),this.resizeObserver.observe(this)),this.renderView()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("click",this.handleBackgroundClick),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this._trackEl=null,this.scrollIdleTimer!==null&&(clearTimeout(this.scrollIdleTimer),this.scrollIdleTimer=null)}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.renderView()}))}getMetrics(){return aa({artifactCount:this._artifacts.length,viewportWidth:this.clientWidth>0?this.clientWidth:lt,viewportHeight:this.clientHeight>0?this.clientHeight:Vt,scrollPosition:this._scrollPosition})}clampScrollPosition(e){return Math.min(this.getMetrics().maxScrollPosition,Math.max(0,Math.floor(e)))}getEffectiveFocusedID(){return this._focusedArtifactID&&this._artifacts.some(e=>e.id===this._focusedArtifactID)?this._focusedArtifactID:null}emitFocusChanged(e){this.dispatchEvent(new zr(e))}emitFocusCleared(){this.dispatchEvent(new Nr)}emitScrollPositionChanged(e){this.dispatchEvent(new Fr(e))}shiftWindow(e){const r=this.clampScrollPosition(this._scrollPosition+e);r!==this._scrollPosition&&(this._scrollPosition=r,this.emitScrollPositionChanged(this._scrollPosition),this.scheduleRender())}getRestoreScrollPositionForCard(e){const{visibleCount:r}=this.getMetrics();if(r<=0)return this._scrollPosition;const i=this._scrollPosition,n=i+r-1;return e<i?this.clampScrollPosition(e):e>n?this.clampScrollPosition(e-r+1):this._scrollPosition}handleCardClick(e){if(this._focusedArtifactID===e)return;const r=this._artifacts.findIndex(a=>a.id===e);if(r===-1)return;const i=this.getRestoreScrollPositionForCard(r),n=i!==this._scrollPosition;this._scrollPosition=i,n&&this.emitScrollPositionChanged(this._scrollPosition),this._focusedArtifactID=e,this.scheduleRender(),this.emitFocusChanged(e)}moveCenteredFocus(e){if(!this._focusedArtifactID)return!1;const r=this._artifacts.findIndex(c=>c.id===this._focusedArtifactID);if(r===-1)return!1;const i=r+e;if(i<0||i>=this._artifacts.length)return!0;const n=this._artifacts[i].id,a=this.getRestoreScrollPositionForCard(i),o=a!==this._scrollPosition;return this._scrollPosition=a,this._focusedArtifactID=n,this.scheduleRender(),o&&this.emitScrollPositionChanged(this._scrollPosition),this.emitFocusChanged(n),!0}exitCenteredMode(e){if(!this._focusedArtifactID)return!1;const r=this._artifacts.findIndex(c=>c.id===this._focusedArtifactID),{visibleCount:i}=this.getMetrics();if(r===-1||i<=0)return this._focusedArtifactID=null,this.emitFocusCleared(),!1;const n=r-(i-1)/Ye;let a;e===1?a=Number.isInteger(n)?n+1:Math.ceil(n):e===-1?a=Number.isInteger(n)?n-1:Math.floor(n):a=this._scrollPosition;const o=this.clampScrollPosition(a)!==this._scrollPosition;return this._focusedArtifactID=null,this._scrollPosition=this.clampScrollPosition(a),this.emitFocusCleared(),o&&this.emitScrollPositionChanged(this._scrollPosition),this.scheduleRender(),!0}calculateTranslateX(){if(this._focusedArtifactID){const e=this._artifacts.findIndex(r=>r.id===this._focusedArtifactID);if(e!==-1){const{cardWidth:r}=this.getMetrics(),i=e*(r+U)+r/Ye;return(this.clientWidth>0?this.clientWidth:lt)/Ye-i}}return this.getMetrics().translateX}updateTrackPosition(){if(!this._trackEl)return;const e=this.calculateTranslateX();this._trackEl.style.transform=`translateX(${e}px)`}template(){const{cardWidth:e,cardHeight:r}=this.getMetrics(),i=this.getEffectiveFocusedID();return b`
|
|
162
|
-
<div class="track" style="gap: ${U}px;">
|
|
163
|
-
${this._artifacts.map(n=>{const a=n.id===i?"focused":"";return b`
|
|
164
|
-
<div
|
|
165
|
-
class="card-slot ${a}"
|
|
166
|
-
data-artifact-id=${n.id}
|
|
167
|
-
style="width: ${e}px; height: ${r}px;"
|
|
168
|
-
@click=${()=>this.handleCardClick(n.id)}
|
|
169
|
-
>
|
|
170
|
-
<artifact-view .artifact=${n}></artifact-view>
|
|
171
|
-
</div>
|
|
172
|
-
`})}
|
|
173
|
-
</div>
|
|
174
|
-
`}renderView(){this._scrollPosition=this.clampScrollPosition(this._scrollPosition),R(this.template(),this),this._trackEl||(this._trackEl=this.querySelector(".track")),this.updateTrackPosition()}}customElements.define("layout-stream",oa);class la extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",W.resolve("WorkspaceService"));h(this,"subscriptions",new Ue);h(this,"handleFocusChanged",e=>{e instanceof zr&&this.workspaceService.focusArtifact(e.id)});h(this,"handleCloseArtifact",e=>{e instanceof Mr&&this.workspaceService.removeArtifact(e.id)});h(this,"handleFocusCleared",e=>{e instanceof Nr&&this.workspaceService.clearFocusedArtifact()});h(this,"handleScrollPositionChanged",e=>{e instanceof Fr&&this.workspaceService.setScrollPosition(e.scrollPosition)})}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}render(){const e=this.workspaceService.activeArtifacts;if(e.length===0){R(b`<p data-testid="empty-workspace">No artifacts yet.</p>`,this);return}R(b`
|
|
175
|
-
<layout-stream
|
|
176
|
-
.artifacts=${e}
|
|
177
|
-
.focusedArtifactID=${this.workspaceService.focusedArtifactID}
|
|
178
|
-
.scrollPosition=${this.workspaceService.scrollPosition}
|
|
179
|
-
@focus-changed=${this.handleFocusChanged}
|
|
180
|
-
@focus-cleared=${this.handleFocusCleared}
|
|
181
|
-
@scroll=${this.handleScrollPositionChanged}
|
|
182
|
-
@close-artifact=${this.handleCloseArtifact}
|
|
183
|
-
></layout-stream>
|
|
184
|
-
`,this)}}customElements.define("workspace-view",la);class ca extends Event{constructor(){super("edit-workspace",{bubbles:!0,composed:!0})}}class Or extends Event{constructor(e){super("create-workspace",{bubbles:!0,composed:!0});h(this,"serverURL");this.serverURL=e}}class ha extends Event{constructor(){super("delete-workspace",{bubbles:!0,composed:!0})}}class ua extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",W.resolve("WorkspaceService"));h(this,"serverManager",W.has("ServerManager")?W.resolve("ServerManager"):null);h(this,"subscriptions",new Ue)}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render())),this.serverManager&&this.subscriptions.add(this.serverManager.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}handleSelect(e){e instanceof pr&&this.workspaceService.setActiveWorkspace(e.value)}closeDropdown(){var e;(e=this.querySelector("dropdown-menu"))==null||e.close()}handleEditWorkspace(){this.workspaceService.activeWorkspace&&(this.closeDropdown(),this.dispatchEvent(new ca))}handleCreateWorkspace(e){this.closeDropdown(),this.dispatchEvent(new Or(e))}handleDeleteWorkspace(){this.workspaceService.activeWorkspace&&(this.closeDropdown(),this.dispatchEvent(new ha))}render(){var a;const e=((a=this.workspaceService.activeWorkspace)==null?void 0:a.name)??"No workspaces",r=this.serverManager?this.serverManager.serverRecords.map(o=>({...o,sortedWorkspaces:[...o.workspaces.values()].sort((c,l)=>c.name.localeCompare(l.name,void 0,{sensitivity:"base"}))})):[],i=this.serverManager?[]:[...this.workspaceService.workspaces??[]].sort((o,c)=>o.name.localeCompare(c.name,void 0,{sensitivity:"base"})),n=this.workspaceService.activeWorkspaceServerURL;R(b`
|
|
185
|
-
<dropdown-menu
|
|
186
|
-
title=${e}
|
|
187
|
-
@select=${o=>this.handleSelect(o)}
|
|
188
|
-
>
|
|
189
|
-
<button
|
|
190
|
-
slot="trigger"
|
|
191
|
-
trigger
|
|
192
|
-
type="button"
|
|
193
|
-
aria-label="Choose workspace"
|
|
194
|
-
></button>
|
|
195
|
-
${this.serverManager?r.map(o=>b`
|
|
196
|
-
<dropdown-group>
|
|
197
|
-
<dropdown-label>${o.name}</dropdown-label>
|
|
198
|
-
${o.sortedWorkspaces.map(c=>this.renderWorkspaceItem(c))}
|
|
199
|
-
<dropdown-item action @click=${()=>this.handleCreateWorkspace(o.url)}>
|
|
200
|
-
+ New workspace
|
|
201
|
-
</dropdown-item>
|
|
202
|
-
</dropdown-group>
|
|
203
|
-
`):b`
|
|
204
|
-
<dropdown-group>
|
|
205
|
-
${i.map(o=>this.renderWorkspaceItem(o))}
|
|
206
|
-
${n?b`
|
|
207
|
-
<dropdown-item action @click=${()=>this.handleCreateWorkspace(n)}>
|
|
208
|
-
+ New workspace
|
|
209
|
-
</dropdown-item>
|
|
210
|
-
`:null}
|
|
211
|
-
</dropdown-group>
|
|
212
|
-
`}
|
|
213
|
-
${this.workspaceService.activeWorkspace?b`
|
|
214
|
-
<dropdown-divider></dropdown-divider>
|
|
215
|
-
<dropdown-group>
|
|
216
|
-
<dropdown-item action @click=${()=>this.handleEditWorkspace()}>
|
|
217
|
-
Edit workspace...
|
|
218
|
-
</dropdown-item>
|
|
219
|
-
<dropdown-item action danger @click=${()=>this.handleDeleteWorkspace()}>
|
|
220
|
-
Delete workspace...
|
|
221
|
-
</dropdown-item>
|
|
222
|
-
</dropdown-group>
|
|
223
|
-
`:null}
|
|
224
|
-
</dropdown-menu>
|
|
225
|
-
`,this)}renderWorkspaceItem(e){var i;const r=e.id===this.workspaceService.activeWorkspaceID?((i=this.workspaceService.activeWorkspace)==null?void 0:i.name)??e.name:e.name;return b`
|
|
226
|
-
<dropdown-item
|
|
227
|
-
value=${e.id}
|
|
228
|
-
?selected=${e.id===this.workspaceService.activeWorkspaceID}
|
|
229
|
-
>
|
|
230
|
-
${r}
|
|
231
|
-
</dropdown-item>
|
|
232
|
-
`}}customElements.define("workspace-picker",ua);class Ur extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",W.resolve("WorkspaceService"));h(this,"subscriptions",new Ue);h(this,"_mode","edit");h(this,"_targetServerURL");h(this,"createPending",!1)}get open(){return this.hasAttribute("open")}set mode(e){this._mode=e,this.render()}get mode(){return this._mode}set targetServerURL(e){this._targetServerURL=e,this.render()}get targetServerURL(){return this._targetServerURL}attributeChangedCallback(e){e==="open"&&(this.open||(this.createPending=!1),this.render())}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleSubmit(e){e.preventDefault();const r=e.currentTarget,i=new FormData(r),n=String(i.get("name")??"").trim();if(n){if(this._mode==="edit"){this.workspaceService.renameWorkspace(n),this.emitClose();return}if(this._targetServerURL){this.createPending=!0,this.render();try{await this.workspaceService.createWorkspace(this._targetServerURL,n),this.emitClose()}catch{this.createPending=!1,this.render()}}}}render(){var n;const e=this._mode==="edit"?"Edit workspace":"New workspace",r=this._mode==="edit"?"Save":this.createPending?"Creating...":"Create",i=this._mode==="edit"?((n=this.workspaceService.activeWorkspace)==null?void 0:n.name)??"":"";R(b`
|
|
233
|
-
<modal-overlay ?open=${this.open}>
|
|
234
|
-
<section class="workspace-modal">
|
|
235
|
-
<form class="workspace-form" @submit=${a=>void this.handleSubmit(a)}>
|
|
236
|
-
<h2 class="workspace-modal-title">${e}</h2>
|
|
237
|
-
<label class="settings-field">
|
|
238
|
-
<span>Name</span>
|
|
239
|
-
<input type="text" name="name" .value=${i} required />
|
|
240
|
-
</label>
|
|
241
|
-
<div class="workspace-form-actions">
|
|
242
|
-
<button type="submit" class="settings-submit-button" ?disabled=${this.createPending}>
|
|
243
|
-
${r}
|
|
244
|
-
</button>
|
|
245
|
-
<button type="button" class="settings-cancel-button" @click=${()=>this.emitClose()}>
|
|
246
|
-
Cancel
|
|
247
|
-
</button>
|
|
248
|
-
</div>
|
|
249
|
-
</form>
|
|
250
|
-
</section>
|
|
251
|
-
</modal-overlay>
|
|
252
|
-
`,this)}}h(Ur,"observedAttributes",["open"]);customElements.define("workspace-form-modal",Ur);class Hr extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",W.resolve("WorkspaceService"));h(this,"serverManager",W.has("ServerManager")?W.resolve("ServerManager"):null);h(this,"subscriptions",new Ue);h(this,"deletePending",!1);h(this,"deleteError",null)}get open(){return this.hasAttribute("open")}attributeChangedCallback(e,r,i){e==="open"&&(i!==null&&r===null&&(this.deletePending=!1,this.deleteError=null),this.render())}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render())),this.serverManager&&this.subscriptions.add(this.serverManager.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleDeleteWorkspace(){this.deletePending=!0,this.deleteError=null,this.render();try{await this.workspaceService.deleteWorkspace(),this.emitClose()}catch(e){this.deletePending=!1,this.deleteError=e instanceof Error?e.message:String(e),this.render()}}render(){var r;const e=this.workspaceService.activeWorkspaceServerURL!==null&&this.serverManager!==null&&this.workspaceService.activeWorkspaceServerURL!==this.serverManager.localServerURL;R(b`
|
|
253
|
-
<modal-overlay ?open=${this.open}>
|
|
254
|
-
<section class="workspace-modal workspace-delete-modal">
|
|
255
|
-
<div class="workspace-form">
|
|
256
|
-
<h2 class="workspace-modal-title">Delete workspace</h2>
|
|
257
|
-
<p class="workspace-delete-copy">
|
|
258
|
-
Delete <strong>${((r=this.workspaceService.activeWorkspace)==null?void 0:r.name)??""}</strong>?
|
|
259
|
-
</p>
|
|
260
|
-
${e?b`<p class="workspace-delete-warning">This will delete it for everyone.</p>`:null}
|
|
261
|
-
${this.deleteError?b`<p class="workspace-delete-error">${this.deleteError}</p>`:null}
|
|
262
|
-
<div class="workspace-form-actions">
|
|
263
|
-
<button
|
|
264
|
-
type="button"
|
|
265
|
-
class="settings-server-remove-button"
|
|
266
|
-
?disabled=${this.deletePending}
|
|
267
|
-
@click=${()=>void this.handleDeleteWorkspace()}
|
|
268
|
-
>
|
|
269
|
-
${this.deletePending?"Deleting...":"Delete"}
|
|
270
|
-
</button>
|
|
271
|
-
<button
|
|
272
|
-
type="button"
|
|
273
|
-
class="settings-cancel-button"
|
|
274
|
-
?disabled=${this.deletePending}
|
|
275
|
-
@click=${()=>this.emitClose()}
|
|
276
|
-
>
|
|
277
|
-
Cancel
|
|
278
|
-
</button>
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
</section>
|
|
282
|
-
</modal-overlay>
|
|
283
|
-
`,this)}}h(Hr,"observedAttributes",["open"]);customElements.define("workspace-delete-modal",Hr);class qr extends HTMLElement{constructor(){super(...arguments);h(this,"serverManager",W.has("ServerManager")?W.resolve("ServerManager"):null);h(this,"subscriptions",new Ue);h(this,"addServerFormOpen",!1)}get open(){return this.hasAttribute("open")}attributeChangedCallback(e){e==="open"&&(this.open||(this.addServerFormOpen=!1),this.render())}connectedCallback(){this.render(),this.serverManager&&this.subscriptions.add(this.serverManager.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}openAddServerForm(){this.addServerFormOpen=!0,this.render()}closeAddServerForm(){this.addServerFormOpen&&(this.addServerFormOpen=!1,this.render())}handleAddServer(e){if(!this.serverManager)return;e.preventDefault();const r=e.currentTarget,i=new FormData(r),n=String(i.get("name")??"").trim(),a=String(i.get("url")??"").trim();!n||!a||(this.serverManager.addServer(a,n),this.addServerFormOpen=!1,r.reset(),this.render())}render(){var i;const e=((i=this.serverManager)==null?void 0:i.serverRecords)??[],r=this.serverManager!==null;R(b`
|
|
284
|
-
<modal-overlay ?open=${this.open}>
|
|
285
|
-
<section class="settings-panel">
|
|
286
|
-
<panel-view closable @close=${n=>n instanceof vr&&this.emitClose()}>
|
|
287
|
-
<panel-page id="main" title="Settings">
|
|
288
|
-
<div class="settings-section">
|
|
289
|
-
${r?b`
|
|
290
|
-
<h3 class="settings-section-title">Servers</h3>
|
|
291
|
-
<div class="settings-server-list">
|
|
292
|
-
${e.map(n=>{var a;return b`
|
|
293
|
-
<div class="settings-card settings-server">
|
|
294
|
-
<div class="settings-server-details">
|
|
295
|
-
<div class="settings-server-name">${n.name}</div>
|
|
296
|
-
<div class="settings-server-url">${n.url}</div>
|
|
297
|
-
</div>
|
|
298
|
-
${n.url!==((a=this.serverManager)==null?void 0:a.localServerURL)?b`
|
|
299
|
-
<button
|
|
300
|
-
type="button"
|
|
301
|
-
class="settings-server-remove-button"
|
|
302
|
-
aria-label=${`Remove ${n.name}`}
|
|
303
|
-
@click=${()=>{var o;return(o=this.serverManager)==null?void 0:o.removeServer(n.url)}}
|
|
304
|
-
>
|
|
305
|
-
Remove
|
|
306
|
-
</button>
|
|
307
|
-
`:null}
|
|
308
|
-
</div>
|
|
309
|
-
`})}
|
|
310
|
-
</div>
|
|
311
|
-
${this.addServerFormOpen?b`
|
|
312
|
-
<form class="settings-card settings-add-server-form" @submit=${n=>this.handleAddServer(n)}>
|
|
313
|
-
<label class="settings-field">
|
|
314
|
-
<span>Name</span>
|
|
315
|
-
<input type="text" name="name" required />
|
|
316
|
-
</label>
|
|
317
|
-
<label class="settings-field">
|
|
318
|
-
<span>URL</span>
|
|
319
|
-
<input type="url" name="url" required />
|
|
320
|
-
</label>
|
|
321
|
-
<div class="settings-form-actions">
|
|
322
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
323
|
-
<button
|
|
324
|
-
type="button"
|
|
325
|
-
class="settings-cancel-button"
|
|
326
|
-
data-action="cancel-connect-form"
|
|
327
|
-
@click=${()=>this.closeAddServerForm()}
|
|
328
|
-
>
|
|
329
|
-
Cancel
|
|
330
|
-
</button>
|
|
331
|
-
</div>
|
|
332
|
-
</form>
|
|
333
|
-
`:b`
|
|
334
|
-
<button
|
|
335
|
-
type="button"
|
|
336
|
-
class="settings-submit-button settings-connect-button"
|
|
337
|
-
data-action="show-connect-form"
|
|
338
|
-
@click=${()=>this.openAddServerForm()}
|
|
339
|
-
>
|
|
340
|
-
+ Connect to server
|
|
341
|
-
</button>
|
|
342
|
-
`}
|
|
343
|
-
`:b`<p class="settings-copy">No additional settings yet.</p>`}
|
|
344
|
-
</div>
|
|
345
|
-
</panel-page>
|
|
346
|
-
</panel-view>
|
|
347
|
-
</section>
|
|
348
|
-
</modal-overlay>
|
|
349
|
-
`,this)}}h(qr,"observedAttributes",["open"]);customElements.define("settings-modal",qr);class Br extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});h(this,"token");this.token=e}}class da extends HTMLElement{constructor(){super(...arguments);h(this,"_invalid",!1);h(this,"_tokenValue","")}set invalid(e){this._invalid=e,this.render()}get invalid(){return this._invalid}set tokenValue(e){this._tokenValue=e,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(e){const r=e.currentTarget;this._tokenValue=r.value}handleSubmit(e){e.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new Br(r))}render(){R(b`
|
|
350
|
-
<modal-overlay open>
|
|
351
|
-
<section class="auth-modal">
|
|
352
|
-
<form class="auth-form" @submit=${e=>this.handleSubmit(e)}>
|
|
353
|
-
<h2 class="auth-modal-title">Enter access token</h2>
|
|
354
|
-
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
355
|
-
<label class="settings-field">
|
|
356
|
-
<span>Token</span>
|
|
357
|
-
<input
|
|
358
|
-
class=${this.invalid?"auth-token-input-invalid":""}
|
|
359
|
-
type="password"
|
|
360
|
-
name="token"
|
|
361
|
-
.value=${this.tokenValue}
|
|
362
|
-
@input=${e=>this.handleInput(e)}
|
|
363
|
-
required
|
|
364
|
-
/>
|
|
365
|
-
</label>
|
|
366
|
-
<button type="submit" class="settings-submit-button">Connect</button>
|
|
367
|
-
</form>
|
|
368
|
-
</section>
|
|
369
|
-
</modal-overlay>
|
|
370
|
-
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",da);class pa extends HTMLElement{constructor(){super(...arguments);h(this,"modals",{workspaceForm:{open:!1,mode:"edit"},deleteWorkspace:{open:!1},settings:{open:!1}});h(this,"_authRequired",!1);h(this,"_authInvalid",!1);h(this,"_authToken","");h(this,"_authError",null)}set authRequired(e){this._authRequired=e,this.render()}get authRequired(){return this._authRequired}set authInvalid(e){this._authInvalid=e,this.render()}get authInvalid(){return this._authInvalid}set authToken(e){this._authToken=e,this.render()}get authToken(){return this._authToken}set authError(e){this._authError=e,this.render()}get authError(){return this._authError}connectedCallback(){this.render()}render(){if(this.authRequired){R(b`
|
|
371
|
-
<main class="auth-gate">
|
|
372
|
-
<auth-modal
|
|
373
|
-
.invalid=${this.authInvalid}
|
|
374
|
-
.tokenValue=${this.authToken}
|
|
375
|
-
></auth-modal>
|
|
376
|
-
</main>
|
|
377
|
-
`,this);return}const e=b`
|
|
378
|
-
<header>
|
|
379
|
-
<nav>
|
|
380
|
-
<workspace-picker
|
|
381
|
-
@edit-workspace=${()=>{this.modals.workspaceForm={open:!0,mode:"edit"},this.render()}}
|
|
382
|
-
@create-workspace=${r=>{r instanceof Or&&(this.modals.workspaceForm={open:!0,mode:"create",targetServerURL:r.serverURL},this.render())}}
|
|
383
|
-
@delete-workspace=${()=>{this.modals.deleteWorkspace={open:!0},this.render()}}
|
|
384
|
-
></workspace-picker>
|
|
385
|
-
</nav>
|
|
386
|
-
<button
|
|
387
|
-
type="button"
|
|
388
|
-
variant="toolbar"
|
|
389
|
-
size="sm"
|
|
390
|
-
aria-label="Settings"
|
|
391
|
-
@click=${()=>{this.modals.settings={open:!this.modals.settings.open},this.render()}}
|
|
392
|
-
>
|
|
393
|
-
${on({size:16,weight:"bold"})}
|
|
394
|
-
</button>
|
|
395
|
-
</header>
|
|
396
|
-
<main>
|
|
397
|
-
${this.authError?b`<p data-testid="auth-error">${this.authError}</p>`:b`<workspace-view></workspace-view>`}
|
|
398
|
-
</main>
|
|
399
|
-
<workspace-form-modal
|
|
400
|
-
?open=${this.modals.workspaceForm.open}
|
|
401
|
-
.mode=${this.modals.workspaceForm.mode}
|
|
402
|
-
.targetServerURL=${this.modals.workspaceForm.targetServerURL}
|
|
403
|
-
@close=${()=>{this.modals.workspaceForm={open:!1,mode:"edit"},this.render()}}
|
|
404
|
-
></workspace-form-modal>
|
|
405
|
-
<workspace-delete-modal
|
|
406
|
-
?open=${this.modals.deleteWorkspace.open}
|
|
407
|
-
@close=${()=>{this.modals.deleteWorkspace={open:!1},this.render()}}
|
|
408
|
-
></workspace-delete-modal>
|
|
409
|
-
<settings-modal
|
|
410
|
-
?open=${this.modals.settings.open}
|
|
411
|
-
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
412
|
-
></settings-modal>
|
|
413
|
-
`;R(e,this)}}customElements.define("television-app",pa);const ps=qi(),Qt=Ui(),Qs=Hi(),jr=Di(ps?"television-electron":"television-browser",Qt),Xt=new Map,Kt=new oi({clientStore:jr,servers:Xt}),Q=document.createElement("television-app");W.register("WorkspaceService",()=>Kt);if(ps){const s=new Mi({clientStore:jr,servers:Xt,workspaceService:Kt,localServerURL:Qt});W.register("ServerManager",()=>s),s.connectConfiguredServers()}else{let s=null;const t=(i,n,a)=>{Q.authRequired=i,Q.authInvalid=n,Q.authToken=a},e=i=>{const n=new URL(window.location.href);n.searchParams.set("token",i),window.history.replaceState({},"",`${n.pathname}${n.search}${n.hash}`)},r=i=>{s==null||s.disconnect();const n=new ir({url:Qt,name:"Server",token:i,servers:Xt});s=n,n.on("serverEvent",({serverURL:a,event:o})=>{s===n&&(Q.authError=null,t(!1,!1,i),Kt.handleServerEvent(a,o))}),n.on("auth-failed",()=>{s===n&&t(!0,!0,i)}),n.connect()};Q.addEventListener("auth-submit",i=>{var a;const n=i instanceof Br?i.token:i instanceof CustomEvent&&typeof((a=i.detail)==null?void 0:a.token)=="string"?i.detail.token:null;n&&(Q.authError=null,t(!0,!1,n),e(n),r(n))}),Qs?r(Qs):t(!0,!1,"")}ps&&document.body.classList.add("electron");document.body.appendChild(Q);
|