citadel_cli 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -3
- package/dist/.vite/manifest.json +0 -4
- package/dist/citadel.es.js +1150 -1688
- package/dist/citadel.umd.js +281 -836
- package/dist/components/Citadel/config/defaults.d.ts +2 -2
- package/dist/components/Citadel/config/types.d.ts +2 -4
- package/dist/components/Citadel/utils/typography.d.ts +0 -1
- package/package.json +8 -5
- package/dist/citadel.css +0 -1
package/dist/citadel.umd.js
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`+
|
|
3
|
-
`)))};var X=(t=>(t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t))(X||{});const se=!0;class E{static configure(e){this.level=e.level,this.prefix=e.prefix||"[Citadel]"}static trace(...e){this.level>=5&&!se&&console.trace(this.prefix,...e)}static debug(...e){this.level>=4&&!se&&console.debug(this.prefix,...e)}static info(...e){this.level>=3&&console.info(this.prefix,...e)}static warn(...e){this.level>=2&&console.warn(this.prefix,...e)}static error(...e){this.level>=1&&console.error(this.prefix,...e)}}C(E,"level",0),C(E,"prefix","");const N={commandTimeoutMs:1e4,cursorColor:"var(--cursor-color, #fff)",cursorSpeed:530,cursorType:"blink",includeHelpCommand:!0,fontFamily:"monospace",fontSize:"0.875rem",initialHeight:"40vh",logLevel:X.ERROR,maxHeight:"80vh",minHeight:"200",outputFontSize:"0.875rem",resetStateOnHide:!1,showCitadelKey:".",displayMode:"panel",storage:{type:"localStorage",maxCommands:100}},ae=async()=>new L("");class Q{constructor(e,n,r){this.type=e,this.name=n,this.description=r}toString(){return this.name}}class Z extends Q{constructor(){super("null",">null<","Empty segment")}}class ie extends Q{constructor(e,n){super("word",e,n)}}class j extends Q{constructor(e,n,r,o){super("argument",e,n),this.value=r,this.valid=o}}const _e=t=>{if(t.type==="word")return new ie(t.name,t.description);if(t.type==="argument"){const e=t;return new j(e.name,e.description,e.value,e.valid)}return new Z},A=t=>t.map(e=>_e(e));class Ae{constructor(e,n,r=ae){C(this,"_segments");C(this,"_description");C(this,"_handler");this._segments=e,this._description=n,this._handler=r}get segments(){return this._segments}get description(){return this._description}get handler(){return this._handler}get hasArguments(){return this.segments.some(e=>e.type==="argument")}get fullPath(){return this.segments.map(e=>e.name)}get fullPath_s(){return this.fullPath.join(" ")}equals(e){return this.fullPath.join(" ")===e.fullPath.join(" ")}}class O{constructor(){C(this,"_commands",[])}get commands(){return this._commands}addCommand(e,n,r=ae){if(e===void 0||e.length===0)throw new Error("Command path cannot be empty");const o=new Ae(e,n,r),a=this._commands.find(l=>{const d=l.segments.map(m=>m.type==="argument"?"*":m.name).join(" "),i=e.map(m=>m.type==="argument"?"*":m.name).join(" ");return d===i});if(a)throw new Error(`Duplicate commands: '${a.fullPath_s}' and '${o.fullPath_s}'`);this._commands.push(o)}removeCommand(e){const n=e.join(" "),r=this._commands.findIndex(o=>o.fullPath.join(" ")===n);return r===-1?!1:(this._commands.splice(r,1),!0)}getCommand(e){return this._commands.find(n=>{const r=n.fullPath.join(" "),o=e.join(" ");if(r===o)return!0;const l=n.segments.filter(d=>d.type==="word").map(d=>d.name);return l.length===e.length&&l.join(" ")===o})}commandExistsForPath(e){const n=this._commands.map(o=>o.segments.map(a=>a.type==="argument"?"*":a.name).join(" ")),r=e.map((o,a)=>this._commands.some(d=>{var i;return((i=d.segments[a])==null?void 0:i.type)==="argument"})?"*":o).join(" ");return n.includes(r)}getCompletionNames(e){return this.getCompletions(e).map(n=>n.name)}getMatchingCompletions(e,n){const r=n.trim().toLowerCase(),o=this.getCompletions(e);return r?o.filter(a=>a.name.toLowerCase().startsWith(r)):o}getUniqueCompletion(e,n){const r=this.getMatchingCompletions(e,n);if(r.length===1)return r[0]}getCompletions(e){if(E.debug("[getCompletions] path: ",e),!e.length){const a=this._commands.map(i=>i.segments[0]),l=(i,m)=>i.type===m.type&&i.name===m.name;return a.filter((i,m,w)=>m===w.findIndex(b=>l(b,i)))}const n=e.length;return this._commands.filter(a=>{const l=a.segments;if(l.length<=n-1)return!1;for(let d=0;d<n;d++){const i=e[d],m=l[d];if(!(i==="*"&&m.type==="argument")&&i!==m.name)return!1}return!0}).filter(a=>a.segments.length>n).map(a=>{const l=a.segments[n],d=l.type==="argument"?j:ie;return new d(l.name,l.description)}).filter((a,l,d)=>l===d.findIndex(i=>i.type===a.type&&i.name===a.name))}hasNextSegment(e){return this.getCompletions(e).length>0}}class le{constructor(e){C(this,"config");this.config={type:"localStorage",maxCommands:100,...e}}async addStoredCommand(e){const n=await this.getStoredCommands();for(n.push(e);n.length>this.config.maxCommands;)n.shift();await this.saveCommands(n)}}class Ie extends le{constructor(n){super(n);C(this,"storageKey","citadel_command_history")}async getStoredCommands(){try{const n=window.localStorage.getItem(this.storageKey);return n?JSON.parse(n).map(o=>({commandSegments:Array.isArray(o.commandSegments)?A(o.commandSegments):[],timestamp:o.timestamp})):[]}catch(n){return console.warn("Failed to load commands from localStorage:",n),[]}}async clear(){try{window.localStorage.removeItem(this.storageKey)}catch(n){console.warn("Failed to clear localStorage:",n)}}async saveCommands(n){try{const r=n.map(o=>({commandSegments:Array.isArray(o.commandSegments)?A(o.commandSegments).map(a=>({type:a.type,name:a.name,description:a.description,...a instanceof j?{value:a.value}:{}})):[],timestamp:o.timestamp}));window.localStorage.setItem(this.storageKey,JSON.stringify(r))}catch(r){throw console.warn("Failed to save commands to localStorage:",r),r}}}class ce extends le{constructor(n){super(n);C(this,"storedCommands",[])}async getStoredCommands(){return this.storedCommands.map(n=>({commandSegments:Array.isArray(n.commandSegments)?A(n.commandSegments):[],timestamp:n.timestamp}))}async clear(){this.storedCommands=[]}async saveCommands(n){this.storedCommands=n.map(r=>({commandSegments:Array.isArray(r.commandSegments)?A(r.commandSegments):[],timestamp:r.timestamp}))}}const T=class T{constructor(){C(this,"currentStorage")}static reset(){T.instance=void 0}static getInstance(){return T.instance||(T.instance=new T),T.instance}initializeStorage(e){try{e.type==="memory"?this.currentStorage=new ce(e):this.currentStorage=new Ie(e)}catch(n){console.warn("Failed to create storage, falling back to memory storage:",n),this.currentStorage=new ce(e)}}getStorage(){if(!this.currentStorage)throw new Error("Storage not initialized. Call initializeStorage first.");return this.currentStorage}};C(T,"instance");let W=T;class de{constructor(){C(this,"segments",[]);C(this,"nullSegment",new Z);C(this,"observers",[])}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(n=>n!==e)}notifyObservers(){this.observers.forEach(e=>e.update())}clear(){this.segments=[],this.notifyObservers()}push(e){this.segments.push(e),this.notifyObservers()}pushAll(e){e.forEach(n=>this.push(n))}pop(){const e=this.segments.pop()||this.nullSegment;return this.notifyObservers(),e}peek(){return this.segments[this.segments.length-1]||this.nullSegment}size(){return this.segments.length}isEmpty(){return this.segments.length===0}get hasArguments(){return this.segments.some(e=>e.type==="argument")}get arguments(){return this.segments.filter(e=>e.type==="argument")}path(){return this.segments.map(e=>e.name)}toArray(){return[...this.segments]}}const Me={config:N,commands:new O,segmentStack:new de},$=s.createContext(Me),Pe=({config:t=N,commandRegistry:e,children:n})=>{const[r,o]=s.useState(),[a]=s.useState(()=>new de),l=s.useMemo(()=>({...N,...t,storage:{...N.storage,...t.storage},cursorType:t.cursorType??N.cursorType,cursorColor:t.cursorColor??N.cursorColor,cursorSpeed:t.cursorSpeed??N.cursorSpeed,showCitadelKey:t.showCitadelKey||"."}),[t]);s.useEffect(()=>{W.getInstance().initializeStorage(l.storage??N.storage),o(W.getInstance().getStorage())},[l.storage]),s.useEffect(()=>{if(e){if(l.includeHelpCommand){if(!e.commandExistsForPath(["help"])){const i=ze(e);e.addCommand([{type:"word",name:"help"}],"Show available commands",i)}return}e.removeCommand(["help"])}},[e,l.includeHelpCommand]);const d=s.useMemo(()=>({config:l,commands:e||new O,storage:r,segmentStack:a}),[l,e,r,a]);return c.jsx($.Provider,{value:d,children:n})},H=()=>{const t=s.useContext($);if(t===void 0)throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");return t.config},B=()=>{const t=s.useContext($);if(t===void 0)throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");return t.commands},me=()=>{const t=s.useContext($);if(t===void 0)throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");return t.storage},q=()=>{const t=s.useContext($);if(t===void 0)throw new Error("useSegmentStack must be used within a CitadelConfigProvider");return t.segmentStack},G=class G{constructor(e,n){C(this,"id");C(this,"timestamp");C(this,"command");C(this,"result");this.id=`output-${Date.now()}-${G.idCounter++}`,this.command=e.toArray().map(r=>r.type==="argument"?r.value||"":r.name),this.timestamp=Date.now(),this.result=n??new re}};C(G,"idCounter",0);let Y=G;function He(t){return{commandSegments:A(t),timestamp:Date.now()}}function ue(){const t=me(),[e,n]=s.useState({storedCommands:[],position:null}),r=s.useCallback(async d=>{if(t)try{const i=He(d);await t.addStoredCommand(i),n(m=>({...m,storedCommands:[...m.storedCommands,{...i,commandSegments:A(i.commandSegments)}],position:null}))}catch(i){console.warn("Failed to save command to history:",i)}},[t]),o=s.useCallback(async()=>t?(await t.getStoredCommands()).map(i=>({...i,commandSegments:A(i.commandSegments)})):[],[t]);s.useEffect(()=>{if(!t)return;(async()=>{try{const m=(await t.getStoredCommands()).map(w=>({...w,commandSegments:A(w.commandSegments)}));return n(w=>({...w,storedCommands:m})),m}catch(i){console.warn("Failed to load command history:",i)}})()},[t]);const a=s.useCallback(async d=>{const i=await o();if(i.length===0)return n(b=>({...b,storedCommands:[],position:null})),{segments:null,position:null};let m=null;if(d==="up"?e.position===null?m=i.length-1:e.position>0?m=e.position-1:m=0:e.position===null||e.position>=i.length-1?m=null:m=e.position+1,n(b=>({...b,storedCommands:i.map(v=>({...v,commandSegments:A(v.commandSegments)})),position:m})),m===null)return{segments:[],position:null};const w=i[m];return w?{segments:A(w.commandSegments),position:m}:{segments:[],position:null}},[e.position,o]),l=s.useCallback(async()=>{try{if(!t)return;await t.clear(),n({storedCommands:[],position:null})}catch(d){console.warn("Failed to clear command history:",d)}},[t]);return{history:e,addStoredCommand:r,getStoredCommands:o,navigateHistory:a,clear:l}}const R=()=>{const t=H(),e=B(),n=ue(),r=q(),o=me(),[a,l]=s.useState({currentInput:"",isEnteringArg:!1,output:[],history:{commands:[],position:null,storage:o}});s.useEffect(()=>{},[o]),s.useEffect(()=>{l(i=>({...i,history:{commands:n.history.storedCommands,position:n.history.position,storage:o}}))},[n.history,o]);const d={setCurrentInput:s.useCallback(i=>{E.debug("[CitadelActions] setCurrentInput: ",i),l(m=>({...m,currentInput:i}))},[]),setIsEnteringArg:s.useCallback(i=>{E.debug("[CitadelActions] setIsEnteringArg: ",i),l(m=>({...m,isEnteringArg:i}))},[]),addOutput:s.useCallback(i=>{E.debug("[CitadelActions]addOutput: ",i),l(m=>({...m,output:[...m.output,i]}))},[]),executeCommand:s.useCallback(async()=>{const i=r.path(),m=e.getCommand(i);if(!m){console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ",i);return}const w=new Y(r);l(b=>({...b,output:[...b.output,w]}));try{const b=new Promise((f,k)=>{setTimeout(()=>{k(new Error("Request timed out"))},t.commandTimeoutMs)}),v=r.arguments.map(f=>f.value||""),y=await Promise.race([m.handler(v),b]);if(!(y instanceof D))throw new Error(`The ${i.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
1
|
+
(function(f,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom/client"],c):(f=typeof globalThis<"u"?globalThis:f||self,c(f.Citadel={},f.jsxRuntime,f.React,f.client))})(this,function(f,c,o,Ae){"use strict";var ct=Object.defineProperty;var dt=(f,c,o)=>c in f?ct(f,c,{enumerable:!0,configurable:!0,writable:!0,value:o}):f[c]=o;var C=(f,c,o)=>dt(f,typeof c!="symbol"?c+"":c,o);var L=(n=>(n.Pending="pending",n.Success="success",n.Failure="failure",n.Timeout="timeout",n))(L||{});class j{constructor(e=Date.now()){C(this,"_status","pending");this.timestamp=e}get status(){return this._status}markSuccess(){this._status="success"}markFailure(){this._status="failure"}markTimeout(){this._status="timeout"}}class ae extends j{constructor(e,t){super(t),this.data=e}render(){return c.jsx("pre",{className:"citadel-result-json",children:JSON.stringify(this.data,null,2)})}}class O extends j{constructor(e,t){super(t),this.text=e}render(){return c.jsx("div",{className:"citadel-result-text",children:this.text})}}class Q extends j{constructor(e,t){super(t),this.error=e,this.markFailure()}render(){return c.jsx("div",{className:"citadel-result-error",children:this.error})}}class ie extends j{render(){return c.jsx("div",{className:"citadel-result-pending",children:"..."})}}class le extends j{constructor(e,t="",s){super(s),this.imageUrl=e,this.altText=t}render(){return c.jsx("div",{className:"citadel-result-image-wrap",children:c.jsx("img",{src:this.imageUrl,alt:this.altText,className:"citadel-result-image"})})}}const Pe=n=>async function(){const t=n.commands.filter(s=>s.fullPath[0]!=="help").map(s=>{const a=`${s.segments.map(d=>d.type==="argument"?`<${d.name}>`:d.name).join(" ")} - ${s.description}`,i=s.segments.filter(d=>d.type==="argument"&&d.description).map(d=>` <${d.name}>: ${d.description}`);return{commandLine:a,argumentLines:i}}).sort((s,r)=>s.commandLine.localeCompare(r.commandLine)).flatMap(s=>[s.commandLine,...s.argumentLines]);return t.length===0?new O("No commands available yet. Add some commands to get started!"):(t.push("help - Show available commands"),new O(`Available Commands:
|
|
2
|
+
`+t.join(`
|
|
3
|
+
`)))};var X=(n=>(n[n.NONE=0]="NONE",n[n.ERROR=1]="ERROR",n[n.WARN=2]="WARN",n[n.INFO=3]="INFO",n[n.DEBUG=4]="DEBUG",n[n.TRACE=5]="TRACE",n))(X||{});const ce=!0;class k{static configure(e){this.level=e.level,this.prefix=e.prefix||"[Citadel]"}static trace(...e){this.level>=5&&!ce&&console.trace(this.prefix,...e)}static debug(...e){this.level>=4&&!ce&&console.debug(this.prefix,...e)}static info(...e){this.level>=3&&console.info(this.prefix,...e)}static warn(...e){this.level>=2&&console.warn(this.prefix,...e)}static error(...e){this.level>=1&&console.error(this.prefix,...e)}}C(k,"level",0),C(k,"prefix","");const I={commandTimeoutMs:1e4,cursorColor:"var(--cursor-color, #fff)",cursorSpeed:530,cursorType:"blink",includeHelpCommand:!0,fontFamily:"monospace",fontSize:"0.875rem",initialHeight:"50vh",logLevel:X.ERROR,maxHeight:"80vh",minHeight:"200",outputFontSize:"0.875rem",resetStateOnHide:!1,showCitadelKey:".",displayMode:"panel",storage:{type:"localStorage",maxCommands:100}},de=async()=>new O("");class Z{constructor(e,t,s){this.type=e,this.name=t,this.description=s}toString(){return this.name}}class R extends Z{constructor(){super("null",">null<","Empty segment")}}class me extends Z{constructor(e,t){super("word",e,t)}}class U extends Z{constructor(e,t,s,r){super("argument",e,t),this.value=s,this.valid=r}}const Me=n=>{if(n.type==="word")return new me(n.name,n.description);if(n.type==="argument"){const e=n;return new U(e.name,e.description,e.value,e.valid)}return new R},M=n=>n.map(e=>Me(e));class He{constructor(e,t,s=de){C(this,"_segments");C(this,"_description");C(this,"_handler");this._segments=e,this._description=t,this._handler=s}get segments(){return this._segments}get description(){return this._description}get handler(){return this._handler}get hasArguments(){return this.segments.some(e=>e.type==="argument")}get fullPath(){return this.segments.map(e=>e.name)}get fullPath_s(){return this.fullPath.join(" ")}equals(e){return this.fullPath.join(" ")===e.fullPath.join(" ")}}class ${constructor(){C(this,"_commands",[])}get commands(){return this._commands}addCommand(e,t,s=de){if(e===void 0||e.length===0)throw new Error("Command path cannot be empty");const r=new He(e,t,s),a=this._commands.find(i=>{const d=i.segments.map(u=>u.type==="argument"?"*":u.name).join(" "),l=e.map(u=>u.type==="argument"?"*":u.name).join(" ");return d===l});if(a)throw new Error(`Duplicate commands: '${a.fullPath_s}' and '${r.fullPath_s}'`);this._commands.push(r)}removeCommand(e){const t=e.join(" "),s=this._commands.findIndex(r=>r.fullPath.join(" ")===t);return s===-1?!1:(this._commands.splice(s,1),!0)}getCommand(e){return this._commands.find(t=>{const s=t.fullPath.join(" "),r=e.join(" ");if(s===r)return!0;const i=t.segments.filter(d=>d.type==="word").map(d=>d.name);return i.length===e.length&&i.join(" ")===r})}commandExistsForPath(e){const t=this._commands.map(r=>r.segments.map(a=>a.type==="argument"?"*":a.name).join(" ")),s=e.map((r,a)=>this._commands.some(d=>{var l;return((l=d.segments[a])==null?void 0:l.type)==="argument"})?"*":r).join(" ");return t.includes(s)}getCompletionNames(e){return this.getCompletions(e).map(t=>t.name)}getMatchingCompletions(e,t){const s=t.trim().toLowerCase(),r=this.getCompletions(e);return s?r.filter(a=>a.name.toLowerCase().startsWith(s)):r}getUniqueCompletion(e,t){const s=this.getMatchingCompletions(e,t);if(s.length===1)return s[0]}getCompletions(e){if(k.debug("[getCompletions] path: ",e),!e.length){const a=this._commands.map(l=>l.segments[0]),i=(l,u)=>l.type===u.type&&l.name===u.name;return a.filter((l,u,y)=>u===y.findIndex(p=>i(p,l)))}const t=e.length;return this._commands.filter(a=>{const i=a.segments;if(i.length<=t-1)return!1;for(let d=0;d<t;d++){const l=e[d],u=i[d];if(!(l==="*"&&u.type==="argument")&&l!==u.name)return!1}return!0}).filter(a=>a.segments.length>t).map(a=>{const i=a.segments[t],d=i.type==="argument"?U:me;return new d(i.name,i.description)}).filter((a,i,d)=>i===d.findIndex(l=>l.type===a.type&&l.name===a.name))}hasNextSegment(e){return this.getCompletions(e).length>0}}class ue{constructor(e){C(this,"config");this.config={type:"localStorage",maxCommands:100,...e}}async addStoredCommand(e){const t=await this.getStoredCommands();for(t.push(e);t.length>this.config.maxCommands;)t.shift();await this.saveCommands(t)}}class _e extends ue{constructor(t){super(t);C(this,"storageKey","citadel_command_history")}async getStoredCommands(){try{const t=window.localStorage.getItem(this.storageKey);return t?JSON.parse(t).map(r=>({commandSegments:Array.isArray(r.commandSegments)?M(r.commandSegments):[],timestamp:r.timestamp})):[]}catch(t){return console.warn("Failed to load commands from localStorage:",t),[]}}async clear(){try{window.localStorage.removeItem(this.storageKey)}catch(t){console.warn("Failed to clear localStorage:",t)}}async saveCommands(t){try{const s=t.map(r=>({commandSegments:Array.isArray(r.commandSegments)?M(r.commandSegments).map(a=>({type:a.type,name:a.name,description:a.description,...a instanceof U?{value:a.value}:{}})):[],timestamp:r.timestamp}));window.localStorage.setItem(this.storageKey,JSON.stringify(s))}catch(s){throw console.warn("Failed to save commands to localStorage:",s),s}}}class pe extends ue{constructor(t){super(t);C(this,"storedCommands",[])}async getStoredCommands(){return this.storedCommands.map(t=>({commandSegments:Array.isArray(t.commandSegments)?M(t.commandSegments):[],timestamp:t.timestamp}))}async clear(){this.storedCommands=[]}async saveCommands(t){this.storedCommands=t.map(s=>({commandSegments:Array.isArray(s.commandSegments)?M(s.commandSegments):[],timestamp:s.timestamp}))}}const z=class z{constructor(){C(this,"currentStorage")}static reset(){z.instance=void 0}static getInstance(){return z.instance||(z.instance=new z),z.instance}initializeStorage(e){try{e.type==="memory"?this.currentStorage=new pe(e):this.currentStorage=new _e(e)}catch(t){console.warn("Failed to create storage, falling back to memory storage:",t),this.currentStorage=new pe(e)}}getStorage(){if(!this.currentStorage)throw new Error("Storage not initialized. Call initializeStorage first.");return this.currentStorage}};C(z,"instance");let B=z;class he{constructor(){C(this,"segments",[]);C(this,"nullSegment",new R);C(this,"observers",[])}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(t=>t!==e)}notifyObservers(){this.observers.forEach(e=>e.update())}clear(){this.segments=[],this.notifyObservers()}push(e){this.segments.push(e),this.notifyObservers()}pushAll(e){e.forEach(t=>this.push(t))}pop(){const e=this.segments.pop()||this.nullSegment;return this.notifyObservers(),e}peek(){return this.segments[this.segments.length-1]||this.nullSegment}size(){return this.segments.length}isEmpty(){return this.segments.length===0}get hasArguments(){return this.segments.some(e=>e.type==="argument")}get arguments(){return this.segments.filter(e=>e.type==="argument")}path(){return this.segments.map(e=>e.name)}toArray(){return[...this.segments]}}const Te={config:I,commands:new $,segmentStack:new he},q=o.createContext(Te),ze=({config:n=I,commandRegistry:e,children:t})=>{const[s,r]=o.useState(),[a]=o.useState(()=>new he),i=o.useMemo(()=>({...I,...n,storage:{...I.storage,...n.storage},cursorType:n.cursorType??I.cursorType,cursorColor:n.cursorColor??I.cursorColor,cursorSpeed:n.cursorSpeed??I.cursorSpeed,showCitadelKey:n.showCitadelKey||"."}),[n]);o.useEffect(()=>{B.getInstance().initializeStorage(i.storage??I.storage),r(B.getInstance().getStorage())},[i.storage]),o.useEffect(()=>{if(e){if(i.includeHelpCommand){if(!e.commandExistsForPath(["help"])){const l=Pe(e);e.addCommand([{type:"word",name:"help"}],"Show available commands",l)}return}e.removeCommand(["help"])}},[e,i.includeHelpCommand]);const d=o.useMemo(()=>({config:i,commands:e||new $,storage:s,segmentStack:a}),[i,e,s,a]);return c.jsx(q.Provider,{value:d,children:t})},T=()=>{const n=o.useContext(q);if(n===void 0)throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");return n.config},V=()=>{const n=o.useContext(q);if(n===void 0)throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");return n.commands},ge=()=>{const n=o.useContext(q);if(n===void 0)throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");return n.storage},W=()=>{const n=o.useContext(q);if(n===void 0)throw new Error("useSegmentStack must be used within a CitadelConfigProvider");return n.segmentStack},G=class G{constructor(e,t){C(this,"id");C(this,"timestamp");C(this,"command");C(this,"result");this.id=`output-${Date.now()}-${G.idCounter++}`,this.command=e.toArray().map(s=>s.type==="argument"?s.value||"":s.name),this.timestamp=Date.now(),this.result=t??new ie}};C(G,"idCounter",0);let Y=G;function De(n){return{commandSegments:M(n),timestamp:Date.now()}}function fe(){const n=ge(),[e,t]=o.useState({storedCommands:[],position:null}),s=o.useCallback(async d=>{if(n)try{const l=De(d);await n.addStoredCommand(l),t(u=>({...u,storedCommands:[...u.storedCommands,{...l,commandSegments:M(l.commandSegments)}],position:null}))}catch(l){console.warn("Failed to save command to history:",l)}},[n]),r=o.useCallback(async()=>n?(await n.getStoredCommands()).map(l=>({...l,commandSegments:M(l.commandSegments)})):[],[n]);o.useEffect(()=>{if(!n)return;(async()=>{try{const u=(await n.getStoredCommands()).map(y=>({...y,commandSegments:M(y.commandSegments)}));return t(y=>({...y,storedCommands:u})),u}catch(l){console.warn("Failed to load command history:",l)}})()},[n]);const a=o.useCallback(async d=>{const l=await r();if(l.length===0)return t(p=>({...p,storedCommands:[],position:null})),{segments:null,position:null};let u=null;if(d==="up"?e.position===null?u=l.length-1:e.position>0?u=e.position-1:u=0:e.position===null||e.position>=l.length-1?u=null:u=e.position+1,t(p=>({...p,storedCommands:l.map(g=>({...g,commandSegments:M(g.commandSegments)})),position:u})),u===null)return{segments:[],position:null};const y=l[u];return y?{segments:M(y.commandSegments),position:u}:{segments:[],position:null}},[e.position,r]),i=o.useCallback(async()=>{try{if(!n)return;await n.clear(),t({storedCommands:[],position:null})}catch(d){console.warn("Failed to clear command history:",d)}},[n]);return{history:e,addStoredCommand:s,getStoredCommands:r,navigateHistory:a,clear:i}}const ee=()=>{const n=T(),e=V(),t=fe(),s=W(),r=ge(),[a,i]=o.useState({currentInput:"",isEnteringArg:!1,output:[],history:{commands:[],position:null,storage:r}});o.useEffect(()=>{},[r]),o.useEffect(()=>{i(l=>({...l,history:{commands:t.history.storedCommands,position:t.history.position,storage:r}}))},[t.history,r]);const d={setCurrentInput:o.useCallback(l=>{k.debug("[CitadelActions] setCurrentInput: ",l),i(u=>({...u,currentInput:l}))},[]),setIsEnteringArg:o.useCallback(l=>{k.debug("[CitadelActions] setIsEnteringArg: ",l),i(u=>({...u,isEnteringArg:l}))},[]),addOutput:o.useCallback(l=>{k.debug("[CitadelActions]addOutput: ",l),i(u=>({...u,output:[...u.output,l]}))},[]),executeCommand:o.useCallback(async()=>{const l=s.path(),u=e.getCommand(l);if(!u){console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ",l);return}const y=new Y(s);i(p=>({...p,output:[...p.output,y]}));try{const p=new Promise((w,S)=>{setTimeout(()=>{S(new Error("Request timed out"))},n.commandTimeoutMs)}),g=s.arguments.map(w=>w.value||""),x=await Promise.race([u.handler(g),p]);if(!(x instanceof j))throw new Error(`The ${l.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
4
4
|
For example:
|
|
5
5
|
return new JsonCommandResult({ text: "Hello World" });
|
|
6
|
-
Check the definition of the ${i.join(".")} command and update the return type for its handler.`);y.markSuccess(),l(f=>({...f,output:f.output.map(k=>k.id===w.id?{...k,result:y}:k)}))}catch(b){const v=new J(b instanceof Error?b.message:"Unknown error");v.markFailure(),l(y=>({...y,output:y.output.map(f=>f.id===w.id?{...f,result:v}:f)}))}},[e,t.commandTimeoutMs,r]),clearHistory:s.useCallback(async()=>{try{await n.clear()}catch(i){console.warn("Failed to clear history:",i)}},[n])};return{state:a,actions:d}},Te=({onOpen:t,onClose:e,isVisible:n,showCitadelKey:r})=>{s.useEffect(()=>{const o=a=>{var l,d;!n&&a.key===r&&!["input","textarea"].includes(((d=(l=a.target)==null?void 0:l.tagName)==null?void 0:d.toLowerCase())||"")&&(a.preventDefault(),t()),n&&a.key==="Escape"&&(a.preventDefault(),e())};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t,e,n,r])},pe={panelContainer:"_panelContainer_1pav9_3",innerContainer:"_innerContainer_1pav9_19",inputSection:"_inputSection_1pav9_29",resizeHandle:"_resizeHandle_1pav9_36",citadel_slideUp:"_citadel_slideUp_1pav9_65",citadel_slideDown:"_citadel_slideDown_1pav9_69",inlineContainer:"_inlineContainer_1pav9_73"},Fe=t=>{const{isVisible:e,isClosing:n,onAnimationComplete:r}=t,o=s.useMemo(()=>e?n?pe.slideDown:pe.slideUp:"",[e,n]);return s.useEffect(()=>{if(r){const l=setTimeout(()=>{r()},200);return()=>clearTimeout(l)}},[n,r]),{style:s.useMemo(()=>({opacity:e?1:0,transform:e?"translateY(0)":n?"translateY(100%)":"translateY(-100%)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),[e,n]),animationClass:o}},De=()=>c.jsx("div",{"data-testid":"spinner",className:"animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"}),Ue=/^text-(xs|sm|base|lg|xl|[2-9]xl|\[[^\]]+\])$/,he=t=>{const e=t==null?void 0:t.trim();return e||void 0},je=t=>{const e=he(t);return e?Ue.test(e)?{className:e}:{style:{fontSize:e}}:{}},V=(t,e)=>{const n=he(t),r=je(e),o={...r.style};return n&&(o.fontFamily=n),{className:r.className,style:Object.keys(o).length>0?o:void 0}},Le=({command:t,timestamp:e,status:n,fontFamily:r,fontSize:o})=>{const a=s.useMemo(()=>V(r,o??"text-sm"),[r,o]);return c.jsxs("div",{className:`flex items-center gap-2 ${a.className??""}`.trim(),style:a.style,children:[c.jsxs("span",{className:"text-gray-200",children:["> ",t.split(" ").map((l,d)=>{const i=l.startsWith("<")&&l.endsWith(">");return c.jsxs("span",{className:i?"text-green-400":"text-gray-200",children:[d>0?" ":"",l]},d)})]}),c.jsx("span",{className:"text-gray-400",children:"·"}),c.jsx("span",{className:"text-gray-500",children:e}),n===U.Pending&&c.jsx(De,{}),n===U.Success&&c.jsx("div",{"data-testid":"success-indicator",className:"w-4 h-4 rounded-full bg-green-500"}),(n===U.Timeout||n===U.Failure)&&c.jsx("div",{"data-testid":"success-indicator",className:"w-4 h-4 rounded-full bg-red-500"})]})},Oe=({output:t,outputRef:e})=>{const n=H(),r=s.useMemo(()=>V(n.fontFamily,n.outputFontSize??n.fontSize),[n.fontFamily,n.fontSize,n.outputFontSize]),o=s.useCallback(()=>{if(e.current){const a=e.current;requestAnimationFrame(()=>{a.scrollTop=a.scrollHeight})}},[e]);return s.useEffect(()=>{if(o(),e.current){const a=e.current.getElementsByTagName("img"),l=a[a.length-1];if(l&&!l.complete)return l.addEventListener("load",o),()=>l.removeEventListener("load",o)}},[t,o,e]),c.jsx("div",{ref:e,className:"h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left","data-testid":"citadel-command-output",children:t.map(a=>c.jsxs("div",{className:"mb-4 last:mb-0",children:[c.jsx(Le,{command:a.command.join(" "),timestamp:new Date(a.timestamp).toLocaleTimeString(),status:a.result.status,fontFamily:n.fontFamily,fontSize:n.fontSize}),c.jsx("pre",{className:`text-gray-200 whitespace-pre ${r.className??""}`.trim(),style:r.style,children:a.result.render()})]},a.id))})},ge={blink:{character:"▋",speed:530,color:"#fff"},spin:{character:"⠋",speed:120,color:"#fff"},solid:{character:"▋",speed:0,color:"#fff"},bbs:{character:"|",speed:120,color:"#fff"}},fe=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],we=["|","/","-","\\"],$e=({style:t={type:"blink"},isValid:e=!0,errorMessage:n})=>{const r=s.useMemo(()=>({...ge[t.type],...t}),[t]),[o,a]=s.useState(!0),[l,d]=s.useState(0);s.useEffect(()=>{if(r.speed===0)return;const w=setInterval(()=>{r.type==="blink"?a(b=>!b):["spin","bbs"].includes(r.type)&&d(b=>(b+1)%(r.type==="bbs"?we.length:fe.length))},r.speed);return()=>clearInterval(w)},[r.type,r.speed]);const i=s.useMemo(()=>({color:e?r.color:"#ff4444",transition:"color 0.15s ease-in-out"}),[e,r.color]),m=()=>!e&&n?"✗":["spin","bbs"].includes(r.type)?(r.type==="bbs"?we:fe)[l]:r.type==="solid"||o?r.character:" ";return c.jsx("div",{className:"relative inline-block",children:c.jsx("span",{className:`command-cursor ${e?"":"animate-shake"}`,style:i,title:n,children:m()})})};function qe(t,e){switch(e.type){case"set":return E.debug(`[inputStateReducer] InputState changing from ${t} to ${e.state}`),e.state;default:return t}}const Ke=()=>{const{state:t}=R(),e=B(),n=ue(),r=q(),[o,a]=s.useReducer(qe,"idle"),l=u=>{a({type:"set",state:u})},d=s.useCallback(()=>{const p=e.getCompletions(r.path())[0]||r.nullSegment;return E.debug("[getNextExpectedSegment] ",p),p},[e,r]),i=s.useCallback(()=>e.getCompletionNames(r.path()).map(p=>e.getCommand([...r.path(),p])).filter(p=>p!==void 0),[e,r]),m=s.useCallback((u,p)=>{if(!u)return p;const h=r.path().length;return p.filter(I=>{const S=I.segments[h];return!S||S.type!=="word"?!1:S.name.toLowerCase().startsWith(u.toLowerCase())})},[r]),w=s.useCallback(u=>{const p=e.getUniqueCompletion(r.path(),u);return p&&p.type==="word"?p:r.nullSegment},[e,r]),b=s.useCallback(u=>{const p=r.path(),h=e.getCompletions(p);return h.length===0&&u?!1:h.some(S=>S.type==="argument")?!0:e.getMatchingCompletions(p,u).some(S=>S.type==="word")},[e,r]),v=s.useCallback(u=>{E.debug("[tryAutoComplete] input: ",u);const p=w(u);return!p||p.type==="null"?new Z:(E.debug("[tryAutoComplete] result: ",p),p)},[w]),y=s.useCallback((u,p)=>{if(t.history.position!==null)return;p.setCurrentInput(u),E.debug("[useCommandParser][handleInputChange] newValue: ",u);const h=d();if(h.type==="argument"||o==="entering_argument"){const z=be(u);if(z.isQuoted)if(z.isComplete){if(!(h instanceof j))return;h.value=u.trim()||"",E.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",h),r.push(h),p.setCurrentInput(""),l("idle");return}else return;else if(z.isComplete){if(!(h instanceof j))return;h.value=u.trim()||"",E.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",h),r.push(h),p.setCurrentInput(""),l("idle");return}else return}if(u.endsWith(" ")){const z=u.trim().toLowerCase(),M=e.getCompletions(r.path()).filter(x=>x.type==="word"&&x.name.toLowerCase()===z);if(M.length===1){r.push(M[0]),p.setCurrentInput(""),l("idle");return}}const S=v(u);if(S.type==="word"){E.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",S),r.push(S),p.setCurrentInput(""),l("idle");return}},[v,t,d,o,r,e]),f=s.useCallback(u=>{u.setCurrentInput(""),u.setIsEnteringArg(!1),r.clear(),l("idle")},[r]),k=s.useCallback((u,p,h)=>{if(!(u.key==="Backspace"||u.key==="Enter"||u.key==="ArrowUp"||u.key==="ArrowDown"||u.key==="ArrowLeft"||u.key==="ArrowRight"||u.key==="Escape"||u.key==="Delete"||u.key==="Home"||u.key==="End"||u.key.length===1))return!0;const{currentInput:S,isEnteringArg:z}=p,M=be(S);switch(u.key){case"Backspace":return S===""&&(u.preventDefault(),r.size()>0&&r.pop(),l("idle")),!0;case"Enter":{if(u.preventDefault(),M.isQuoted&&!M.isComplete)return!0;if(o==="entering_argument"||z&&S.trim()){const P=d();P instanceof j&&(P.value=S,E.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ",P),r.push(P))}const x=r.path(),_=e.getCommand(x);if(!_)return!1;const F=_.segments.filter(P=>P.type==="argument"),K=r.arguments;return F.length>K.length?!1:(E.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ",r),h.executeCommand(),n.addStoredCommand(r.toArray()),f(h),!0)}case"ArrowUp":return u.preventDefault(),(async()=>{const x=await n.navigateHistory("up");return x.segments&&(r.clear(),r.pushAll(x.segments),h.setCurrentInput("")),!0})();case"ArrowDown":return u.preventDefault(),(async()=>{const x=await n.navigateHistory("down");return x.segments&&(r.clear(),r.pushAll(x.segments),h.setCurrentInput("")),!0})();default:{if(!z&&u.key.length===1){const x=S+u.key;if(!b(x))return u.preventDefault(),!1}return!0}}},[o,b,d,n,f,e,r]);return{handleInputChange:y,handleKeyDown:k,inputState:o,setInputStateWithLogging:l,findMatchingCommands:m,getAutocompleteSuggestion:w,getAvailableNodes:i,getNextExpectedSegment:d,isValidCommandInput:b}};function be(t){const e=[];let n="",r=!1,o;for(let a=0;a<t.length;a++){const l=t[a];(l==='"'||l==="'")&&(!r||l===o)?r?(e.push(n),n="",r=!1,o=void 0):(n&&(e.push(n),n=""),r=!0,o=l):!r&&l===" "?n&&(e.push(n),n=""):n+=l}return{words:e,currentWord:n,isQuoted:r,quoteChar:o,isComplete:!r&&!n}}const We=()=>{const t=q(),[e,n]=s.useState(0);return s.useEffect(()=>{const r={update:()=>{n(o=>o+1)}};return t.subscribe(r),()=>{t.unsubscribe(r)}},[t]),e},Be=({state:t,actions:e})=>{const n=s.useRef(null),r=B(),o=q(),{handleKeyDown:a,handleInputChange:l,inputState:d,setInputStateWithLogging:i,getNextExpectedSegment:m}=Ke(),[w,b]=s.useState(!1),v=H(),y=We(),f=s.useMemo(()=>V(v.fontFamily,v.fontSize),[v.fontFamily,v.fontSize]),k=async x=>{const _=a(x,t,e);await Promise.resolve(_)===!1&&(b(!0),setTimeout(()=>b(!1),500))},u=x=>{l(x.target.value,e)},p=x=>{x.preventDefault();const _=x.clipboardData.getData("text");l(_,e)};s.useEffect(()=>{n.current&&n.current.focus(),d!=="entering_command"&&i("entering_command")},[d,i]),s.useEffect(()=>{if(d!=="idle")return;const x=m();let _="idle";switch(x.type){case"word":_="entering_command",e.setIsEnteringArg(!1);break;case"argument":_="entering_argument",e.setIsEnteringArg(!0);break}i(_)},[y,d,m,i,e]);const h=s.useMemo(()=>{const x=[],_=o.toArray().map((F,K)=>{x.push(F.name);const P=r.hasNextSegment(x);if(F.type==="argument"){const ne=F;return c.jsxs(s.Fragment,{children:[c.jsx("span",{className:"text-gray-200 whitespace-pre",children:ne.value}),K<o.size()&&P&&c.jsx("span",{className:"text-gray-200 whitespace-pre",children:" "})]},"arg-"+ne.name+ne.value)}return c.jsxs(s.Fragment,{children:[c.jsx("span",{className:"text-blue-400 whitespace-pre",children:F.name}),K<o.size()&&P&&c.jsx("span",{className:"text-blue-400 whitespace-pre",children:" "})]},"word-"+F.name)});return[c.jsx("div",{className:"flex items-center gap-1","data-testid":"user-input-area",children:_},y)]},[y,r,o]),[I,S]=s.useState("");s.useEffect(()=>{const x=m();x.type==="argument"?S(x.name):S("")},[y,m]);const z=!t.isEnteringArg,M=t.currentInput.length;return c.jsxs("div",{className:"flex flex-col w-full bg-gray-900 rounded-lg p-4",children:[c.jsx("style",{children:`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
--citadel-
|
|
16
|
-
--citadel-
|
|
17
|
-
--citadel-border: rgb(55, 65, 81);
|
|
18
|
-
--citadel-accent: #646cff;
|
|
19
|
-
--citadel-accent-hover: #535bf2;
|
|
6
|
+
Check the definition of the ${l.join(".")} command and update the return type for its handler.`);x.markSuccess(),i(w=>({...w,output:w.output.map(S=>S.id===y.id?{...S,result:x}:S)}))}catch(p){const g=new Q(p instanceof Error?p.message:"Unknown error");g.markFailure(),i(x=>({...x,output:x.output.map(w=>w.id===y.id?{...w,result:g}:w)}))}},[e,n.commandTimeoutMs,s]),clearHistory:o.useCallback(async()=>{try{await t.clear()}catch(l){console.warn("Failed to clear history:",l)}},[t])};return{state:a,actions:d}},Fe=({onOpen:n,onClose:e,isVisible:t,showCitadelKey:s})=>{o.useEffect(()=>{const r=a=>{var i,d;!t&&a.key===s&&!["input","textarea"].includes(((d=(i=a.target)==null?void 0:i.tagName)==null?void 0:d.toLowerCase())||"")&&(a.preventDefault(),n()),t&&a.key==="Escape"&&(a.preventDefault(),e())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n,e,t,s])},je=n=>{const{isVisible:e,isClosing:t,onAnimationComplete:s}=n,r=o.useMemo(()=>e?t?"citadel_slideDown":"citadel_slideUp":"",[e,t]);return o.useEffect(()=>{if(s){const i=setTimeout(()=>{s()},200);return()=>clearTimeout(i)}},[t,s]),{style:o.useMemo(()=>({opacity:e?1:0,transform:e?"translateY(0)":t?"translateY(100%)":"translateY(-100%)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),[e,t]),animationClass:r}},Le=()=>c.jsx("div",{"data-testid":"spinner",className:"citadel-spinner"}),ye=n=>{const e=n==null?void 0:n.trim();return e||void 0},Ue=n=>{const e=ye(n);return e?{style:{fontSize:e}}:{}},J=(n,e)=>{const t=ye(n),r={...Ue(e).style};return t&&(r.fontFamily=t),{style:Object.keys(r).length>0?r:void 0}},Oe=({command:n,timestamp:e,status:t,fontFamily:s,fontSize:r})=>{const a=o.useMemo(()=>J(s,r??"0.875rem"),[s,r]);return c.jsxs("div",{className:"citadel-output-line",style:a.style,children:[c.jsxs("span",{className:"citadel-output-command",children:["> ",n.split(" ").map((i,d)=>{const l=i.startsWith("<")&&i.endsWith(">");return c.jsxs("span",{className:l?"citadel-output-command-arg":"citadel-output-command-word",children:[d>0?" ":"",i]},d)})]}),c.jsx("span",{className:"citadel-output-separator",children:"·"}),c.jsx("span",{className:"citadel-output-timestamp",children:e}),t===L.Pending&&c.jsx(Le,{}),t===L.Success&&c.jsx("div",{"data-testid":"success-indicator",className:"citadel-status-dot citadel-status-dot-success"}),(t===L.Timeout||t===L.Failure)&&c.jsx("div",{"data-testid":"success-indicator",className:"citadel-status-dot citadel-status-dot-failure"})]})},$e=({output:n,outputRef:e})=>{const t=T(),s=o.useMemo(()=>J(t.fontFamily,t.outputFontSize??t.fontSize),[t.fontFamily,t.fontSize,t.outputFontSize]),r=o.useCallback(()=>{if(e.current){const a=e.current;requestAnimationFrame(()=>{a.scrollTop=a.scrollHeight})}},[e]);return o.useEffect(()=>{if(r(),e.current){const a=e.current.getElementsByTagName("img"),i=a[a.length-1];if(i&&!i.complete)return i.addEventListener("load",r),()=>i.removeEventListener("load",r)}},[n,r,e]),c.jsx("div",{ref:e,className:"citadel-output","data-testid":"citadel-command-output",children:n.map(a=>c.jsxs("div",{className:"citadel-output-item",children:[c.jsx(Oe,{command:a.command.join(" "),timestamp:new Date(a.timestamp).toLocaleTimeString(),status:a.result.status,fontFamily:t.fontFamily,fontSize:t.fontSize}),c.jsx("div",{className:"citadel-output-content",style:s.style,children:a.result.render()})]},a.id))})},Ce={blink:{character:"▋",speed:530,color:"#fff"},spin:{character:"⠋",speed:120,color:"#fff"},solid:{character:"▋",speed:0,color:"#fff"},bbs:{character:"|",speed:120,color:"#fff"}},we=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],ve=["|","/","-","\\"],qe=({style:n={type:"blink"},isValid:e=!0,errorMessage:t})=>{const s=o.useMemo(()=>({...Ce[n.type],...n}),[n]),[r,a]=o.useState(!0),[i,d]=o.useState(0);o.useEffect(()=>{if(s.speed===0)return;const y=setInterval(()=>{s.type==="blink"?a(p=>!p):["spin","bbs"].includes(s.type)&&d(p=>(p+1)%(s.type==="bbs"?ve.length:we.length))},s.speed);return()=>clearInterval(y)},[s.type,s.speed]);const l=o.useMemo(()=>({color:e?s.color:"#ff4444",transition:"color 0.15s ease-in-out"}),[e,s.color]),u=()=>!e&&t?"✗":["spin","bbs"].includes(s.type)?(s.type==="bbs"?ve:we)[i]:s.type==="solid"||r?s.character:" ";return c.jsx("div",{className:"citadel-cursor-wrapper",children:c.jsx("span",{className:`command-cursor ${e?"":"animate-shake"}`,style:l,title:t,children:u()})})};function We(n,e){switch(e.type){case"set":return k.debug(`[inputStateReducer] InputState changing from ${n} to ${e.state}`),e.state;default:return n}}const Ke=()=>{const{state:n}=ee(),e=V(),t=fe(),s=W(),[r,a]=o.useReducer(We,"idle"),i=m=>{a({type:"set",state:m})},d=o.useCallback(()=>{const h=e.getCompletions(s.path())[0]||s.nullSegment;return k.debug("[getNextExpectedSegment] ",h),h},[e,s]),l=o.useCallback(()=>e.getCompletionNames(s.path()).map(h=>e.getCommand([...s.path(),h])).filter(h=>h!==void 0),[e,s]),u=o.useCallback((m,h)=>{if(!m)return h;const v=s.path().length;return h.filter(H=>{const b=H.segments[v];return!b||b.type!=="word"?!1:b.name.toLowerCase().startsWith(m.toLowerCase())})},[s]),y=o.useCallback(m=>{const h=e.getUniqueCompletion(s.path(),m);return h&&h.type==="word"?h:s.nullSegment},[e,s]),p=o.useCallback(m=>{const h=s.path(),v=e.getCompletions(h);return v.length===0&&m?!1:v.some(b=>b.type==="argument")?!0:e.getMatchingCompletions(h,m).some(b=>b.type==="word")},[e,s]),g=o.useCallback(m=>{k.debug("[tryAutoComplete] input: ",m);const h=y(m);return!h||h.type==="null"?new R:(k.debug("[tryAutoComplete] result: ",h),h)},[y]),x=o.useCallback((m,h)=>{if(n.history.position!==null)return;h.setCurrentInput(m),k.debug("[useCommandParser][handleInputChange] newValue: ",m);const v=d();if(v.type==="argument"||r==="entering_argument"){const A=Se(m);if(A.isQuoted)if(A.isComplete){if(!(v instanceof U))return;v.value=m.trim()||"",k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",v),s.push(v),h.setCurrentInput(""),i("idle");return}else return;else if(A.isComplete){if(!(v instanceof U))return;v.value=m.trim()||"",k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",v),s.push(v),h.setCurrentInput(""),i("idle");return}else return}if(m.endsWith(" ")){const A=m.trim().toLowerCase(),_=e.getCompletions(s.path()).filter(E=>E.type==="word"&&E.name.toLowerCase()===A);if(_.length===1){s.push(_[0]),h.setCurrentInput(""),i("idle");return}}const b=g(m);if(b.type==="word"){k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",b),s.push(b),h.setCurrentInput(""),i("idle");return}},[g,n,d,r,s,e]),w=o.useCallback(m=>{m.setCurrentInput(""),m.setIsEnteringArg(!1),s.clear(),i("idle")},[s]),S=o.useCallback((m,h,v)=>{if(!(m.key==="Backspace"||m.key==="Enter"||m.key==="ArrowUp"||m.key==="ArrowDown"||m.key==="ArrowLeft"||m.key==="ArrowRight"||m.key==="Escape"||m.key==="Delete"||m.key==="Home"||m.key==="End"||m.key.length===1))return!0;const{currentInput:b,isEnteringArg:A}=h,_=Se(b);switch(m.key){case"Backspace":return b===""&&(m.preventDefault(),s.size()>0&&s.pop(),i("idle")),!0;case"Enter":{if(m.preventDefault(),_.isQuoted&&!_.isComplete)return!0;if(r==="entering_argument"||A&&b.trim()){const D=d();D instanceof U&&(D.value=b,k.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ",D),s.push(D))}const E=s.path(),ne=e.getCommand(E);if(!ne)return!1;const K=ne.segments.filter(D=>D.type==="argument"),se=s.arguments;return K.length>se.length?!1:(k.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ",s),v.executeCommand(),t.addStoredCommand(s.toArray()),w(v),!0)}case"ArrowUp":return m.preventDefault(),(async()=>{const E=await t.navigateHistory("up");return E.segments&&(s.clear(),s.pushAll(E.segments),v.setCurrentInput("")),!0})();case"ArrowDown":return m.preventDefault(),(async()=>{const E=await t.navigateHistory("down");return E.segments&&(s.clear(),s.pushAll(E.segments),v.setCurrentInput("")),!0})();default:{if(!A&&m.key.length===1){const E=b+m.key;if(!p(E))return m.preventDefault(),!1}return!0}}},[r,p,d,t,w,e,s]);return{handleInputChange:x,handleKeyDown:S,inputState:r,setInputStateWithLogging:i,findMatchingCommands:u,getAutocompleteSuggestion:y,getAvailableNodes:l,getNextExpectedSegment:d,isValidCommandInput:p}};function Se(n){const e=[];let t="",s=!1,r;for(let a=0;a<n.length;a++){const i=n[a];(i==='"'||i==="'")&&(!s||i===r)?s?(e.push(t),t="",s=!1,r=void 0):(t&&(e.push(t),t=""),s=!0,r=i):!s&&i===" "?t&&(e.push(t),t=""):t+=i}return{words:e,currentWord:t,isQuoted:s,quoteChar:r,isComplete:!s&&!t}}const Be=()=>{const n=W(),[e,t]=o.useState(0);return o.useEffect(()=>{const s={update:()=>{t(r=>r+1)}};return n.subscribe(s),()=>{n.unsubscribe(s)}},[n]),e},Ve=({state:n,actions:e})=>{const t=o.useRef(null),s=V(),r=W(),{handleKeyDown:a,handleInputChange:i,inputState:d,setInputStateWithLogging:l,getNextExpectedSegment:u}=Ke(),[y,p]=o.useState(!1),g=T(),x=Be(),w=o.useRef(null),[S,m]=o.useState(0),h=o.useMemo(()=>J(g.fontFamily,g.fontSize),[g.fontFamily,g.fontSize]),v=o.useCallback(async N=>{const P=a(N,n,e);await Promise.resolve(P)===!1&&(p(!0),setTimeout(()=>p(!1),500))},[e,a,n]),H=o.useCallback(N=>{i(N.target.value,e)},[e,i]),b=o.useCallback(N=>{N.preventDefault();const P=N.clipboardData.getData("text");i(P,e)},[e,i]);o.useEffect(()=>{t.current&&t.current.focus(),d!=="entering_command"&&l("entering_command")},[d,l]),o.useEffect(()=>{if(d!=="idle")return;const N=u();let P="idle";switch(N.type){case"word":P="entering_command",e.setIsEnteringArg(!1);break;case"argument":P="entering_argument",e.setIsEnteringArg(!0);break}l(P)},[x,d,u,l,e]);const A=o.useMemo(()=>{const N=[],P=r.toArray().map((F,re)=>{N.push(F.name);const Ie=s.hasNextSegment(N);if(F.type==="argument"){const oe=F;return c.jsxs(o.Fragment,{children:[c.jsx("span",{className:"citadel-input-segment-arg",children:oe.value}),re<r.size()&&Ie&&c.jsx("span",{className:"citadel-input-segment-space",children:" "})]},"arg-"+oe.name+oe.value)}return c.jsxs(o.Fragment,{children:[c.jsx("span",{className:"citadel-input-segment-word",children:F.name}),re<r.size()&&Ie&&c.jsx("span",{className:"citadel-input-segment-space citadel-input-segment-space-command",children:" "})]},"word-"+F.name)});return[c.jsx("div",{className:"citadel-input-segments","data-testid":"user-input-area",children:P},x)]},[x,s,r]),[_,E]=o.useState("");o.useEffect(()=>{const N=u();N.type==="argument"?E(N.name):E("")},[x,u]);const K=!n.isEnteringArg?"is-command-mode":"is-argument-mode",se=o.useMemo(()=>({left:`${S}px`,transition:"left 0.05s ease-out"}),[S]),D=o.useMemo(()=>({type:g.cursorType??I.cursorType,color:g.cursorColor||I.cursorColor,speed:g.cursorSpeed||I.cursorSpeed}),[g.cursorColor,g.cursorSpeed,g.cursorType]);return o.useLayoutEffect(()=>{const N=w.current,P=t.current;if(!N||!P){m(0);return}const F=N.getBoundingClientRect().width;m(Math.max(0,F-P.scrollLeft))},[n.currentInput,K,h.style]),c.jsx("div",{className:"citadel-input-shell",children:c.jsxs("div",{className:"citadel-input-line",style:h.style,children:[c.jsx("div",{className:"citadel-input-prompt",children:">"}),c.jsxs("div",{className:"citadel-input-row",children:[A,c.jsxs("div",{className:"citadel-input-control",children:[c.jsx("span",{ref:w,className:`citadel-input-measure ${K}`.trim(),"aria-hidden":"true",children:n.currentInput}),c.jsx("input",{ref:t,type:"text",role:"textbox",value:n.currentInput,onChange:H,onKeyDown:v,onPaste:b,"data-testid":"citadel-command-input",className:`citadel-input-field ${K} ${y?"invalid-input-animation":""}`.trim(),spellCheck:!1,autoComplete:"off",placeholder:_}),c.jsx("div",{className:"citadel-input-cursor",style:se,children:c.jsx(qe,{style:D})})]})]})]})})},Ye=({currentInput:n=""})=>{const e=V(),t=T(),s=W(),r=o.useMemo(()=>J(t.fontFamily,t.fontSize),[t.fontFamily,t.fontSize]),a=n.trim().toLowerCase(),i=e.getMatchingCompletions(s.path(),a);k.debug("[AvailableCommands] nextCommandSegments: ",i);const d=o.useMemo(()=>{const p=[...i],g=m=>m.name.toLowerCase()==="help",x=p.filter(g);return[...p.filter(m=>!g(m)).sort((m,h)=>m.name.localeCompare(h.name,void 0,{sensitivity:"base"})),...x]},[i]),l=o.useMemo(()=>{const p=new Map;for(const g of d){const x=d.reduce((w,S)=>{if(S===g)return w;let m=0;for(;m<g.name.length&&m<S.name.length&&g.name[m].toLowerCase()===S.name[m].toLowerCase();)m++;return Math.max(w,m+1)},1);p.set(g.name,x)}return p},[d]),u=i.some(p=>p.type==="argument"),y=i[0];return c.jsx("div",{className:"citadel-available-commands","data-testid":"available-commands",children:c.jsx("div",{className:"citadel-available-commands-content",style:r.style,children:u?i.length>0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"citadel-available-next-arg",children:y.name}),y.description&&c.jsxs("span",{className:"citadel-available-next-desc",children:["- ",y.description]})]}):null:c.jsx("div",{className:"citadel-available-chip-list",children:d==null?void 0:d.map(p=>{const g=l.get(p.name)??1;return c.jsx("div",{"data-testid":"available-command-chip",className:"citadel-available-chip",children:c.jsxs("span",{className:"citadel-available-chip-text",children:[c.jsx("strong",{className:"citadel-available-chip-prefix",children:p.name.slice(0,g)}),p.name.slice(g)]})},p.name)})})})})},be=({state:n,actions:e,outputRef:t})=>{const r=T().displayMode==="inline",a=o.useMemo(()=>r?{overflow:"hidden"}:void 0,[r]);return c.jsxs("div",{className:"innerContainer citadel-tty",children:[c.jsx("div",{className:"citadel-tty-output-pane","data-testid":"citadel-output-pane",style:a,children:c.jsx($e,{output:n.output,outputRef:t})}),c.jsxs("div",{className:"citadel-tty-input-region",children:[c.jsx(Ve,{state:n,actions:e}),c.jsx(Ye,{currentInput:n.isEnteringArg?"":n.currentInput})]})]})},Je=()=>{const[n,e]=o.useState(!1),[t,s]=o.useState(!1),r=T(),[a,i]=o.useState(()=>r.initialHeight||null),d=o.useRef(null),l=o.useRef(null),u=o.useRef(!1),y=o.useRef(0),p=o.useRef(0),{state:g,actions:x}=ee();Fe({onOpen:()=>e(!0),onClose:()=>s(!0),isVisible:n,showCitadelKey:r.showCitadelKey||"."});const w=o.useCallback(H=>{var E;if(!u.current)return;const b=H.clientY-y.current,A=(E=r.maxHeight)!=null&&E.endsWith("vh")?window.innerHeight*parseInt(r.maxHeight,10)/100:parseInt(r.maxHeight||"80vh",10),_=Math.min(Math.max(p.current-b,parseInt(r.minHeight||"200",10)),A);l.current&&(l.current.style.height=`${_}px`,l.current.style.bottom="0",i(`${_}px`))},[r.maxHeight,r.minHeight]),S=o.useCallback(()=>{u.current=!1,document.documentElement.style.userSelect="",document.documentElement.style.webkitUserSelect="",document.documentElement.style.mozUserSelect="",document.documentElement.style.msUserSelect="",document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)},[w]),m=o.useCallback(H=>{l.current&&(u.current=!0,y.current=H.clientY,p.current=l.current.offsetHeight,document.documentElement.style.userSelect="none",document.documentElement.style.webkitUserSelect="none",document.documentElement.style.mozUserSelect="none",document.documentElement.style.msUserSelect="none",document.addEventListener("mousemove",w),document.addEventListener("mouseup",S))},[w,S]);o.useEffect(()=>()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S)},[w,S]);const h=o.useCallback(()=>{t&&(e(!1),s(!1))},[t]);je({isVisible:n,isClosing:t,onAnimationComplete:h});const v=o.useMemo(()=>({...a?{height:a}:{},maxHeight:r.maxHeight}),[r.maxHeight,a]);return n?c.jsxs("div",{ref:l,className:`panelContainer ${n?"citadel_slideUp":""} ${t?"citadel_slideDown":""}`,style:v,children:[c.jsx("div",{className:"resizeHandle",onMouseDown:m}),c.jsx(be,{state:g,actions:x,outputRef:d})]}):null},te=n=>{if(!n)return;const e=n.trim();if(e)return/^\d+(\.\d+)?$/.test(e)?`${e}px`:e},Ge=()=>{const{state:n,actions:e}=ee(),t=T(),s=o.useRef(null),r=o.useMemo(()=>({height:te(t.initialHeight),maxHeight:te(t.maxHeight),minHeight:te(t.minHeight)}),[t.initialHeight,t.maxHeight,t.minHeight]);return c.jsx("div",{className:"inlineContainer","data-testid":"citadel-inline-container",style:r,children:c.jsx(be,{state:n,actions:e,outputRef:s})})},xe=`:host {
|
|
7
|
+
--citadel-bg: oklch(20.8% 0.042 265.8);
|
|
8
|
+
--citadel-surface: oklch(27.9% 0.041 260);
|
|
9
|
+
--citadel-border: oklch(37.2% 0.044 257.3);
|
|
10
|
+
--citadel-text: oklch(92.8% 0.006 264.5);
|
|
11
|
+
--citadel-muted: oklch(70.7% 0.022 261.3);
|
|
12
|
+
--citadel-subtle: oklch(55.1% 0.023 264.4);
|
|
13
|
+
--citadel-word: oklch(70.7% 0.165 254.6);
|
|
14
|
+
--citadel-arg: oklch(72.3% 0.219 149.6);
|
|
15
|
+
--citadel-error: oklch(70.4% 0.191 22.2);
|
|
16
|
+
--citadel-success: oklch(72.3% 0.219 149.6);
|
|
20
17
|
--citadel-min-height: 200px;
|
|
21
18
|
--citadel-max-height: 80vh;
|
|
22
19
|
--citadel-default-height: 35vh;
|
|
23
|
-
--citadel-error: rgb(239, 68, 68);
|
|
24
20
|
|
|
25
21
|
display: block;
|
|
26
22
|
pointer-events: auto;
|
|
23
|
+
color: var(--citadel-text);
|
|
27
24
|
font-synthesis: none;
|
|
28
25
|
text-rendering: optimizeLegibility;
|
|
29
26
|
-webkit-font-smoothing: antialiased;
|
|
30
27
|
-moz-osx-font-smoothing: grayscale;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
:host([data-display-mode=
|
|
30
|
+
:host([data-display-mode='panel']) {
|
|
34
31
|
position: fixed;
|
|
35
32
|
bottom: 0;
|
|
36
33
|
left: 0;
|
|
@@ -39,11 +36,11 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
39
36
|
height: var(--citadel-default-height);
|
|
40
37
|
max-height: var(--citadel-max-height);
|
|
41
38
|
min-height: var(--citadel-min-height);
|
|
42
|
-
z-index: 2147483647;
|
|
39
|
+
z-index: 2147483647;
|
|
43
40
|
overflow: hidden;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
:host([data-display-mode=
|
|
43
|
+
:host([data-display-mode='inline']) {
|
|
47
44
|
position: relative;
|
|
48
45
|
bottom: auto;
|
|
49
46
|
left: auto;
|
|
@@ -56,127 +53,93 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
56
53
|
overflow: hidden;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
border: 1px solid transparent;
|
|
62
|
-
padding: 0.6em 1.2em;
|
|
63
|
-
font-size: 1em;
|
|
64
|
-
font-weight: 500;
|
|
65
|
-
font-family: inherit;
|
|
66
|
-
background-color: #1a1a1a;
|
|
67
|
-
cursor: pointer;
|
|
68
|
-
transition: border-color 0.25s;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
button:hover {
|
|
72
|
-
border-color: var(--citadel-accent);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
button:focus,
|
|
76
|
-
button:focus-visible {
|
|
77
|
-
outline: 4px auto -webkit-focus-ring-color;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
a {
|
|
81
|
-
font-weight: 500;
|
|
82
|
-
color: var(--citadel-accent);
|
|
83
|
-
text-decoration: inherit;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
a:hover {
|
|
87
|
-
color: var(--citadel-accent-hover);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.flex-1 { flex: 1 1 0%; }
|
|
91
|
-
.flex-shrink-0 { flex-shrink: 0; }
|
|
92
|
-
.min-h-0 { min-height: 0px; }
|
|
93
|
-
.pt-3 { padding-top: 0.75rem; }
|
|
94
|
-
.px-4 { padding-left: 1rem; padding-right: 1rem; }
|
|
95
|
-
|
|
96
|
-
.h-full {
|
|
56
|
+
#citadel-root {
|
|
57
|
+
width: 100%;
|
|
97
58
|
height: 100%;
|
|
98
59
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
border-width: 1px;
|
|
104
|
-
}
|
|
105
|
-
.border-gray-700 {
|
|
106
|
-
--tw-border-opacity: 1;
|
|
107
|
-
border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
|
|
108
|
-
}
|
|
109
|
-
.rounded-lg {
|
|
110
|
-
border-radius: 0.5rem;
|
|
111
|
-
}
|
|
112
|
-
.p-3 {
|
|
113
|
-
padding: 0.75rem;
|
|
114
|
-
}
|
|
115
|
-
.text-left {
|
|
116
|
-
text-align: left;
|
|
60
|
+
|
|
61
|
+
#citadel-root,
|
|
62
|
+
#citadel-root * {
|
|
63
|
+
box-sizing: border-box;
|
|
117
64
|
}
|
|
118
|
-
`,Ce=`/* Keep only component-specific styles here */
|
|
119
65
|
|
|
120
66
|
.panelContainer {
|
|
121
67
|
position: fixed;
|
|
68
|
+
bottom: 0;
|
|
69
|
+
left: 0;
|
|
70
|
+
right: 0;
|
|
71
|
+
width: 100%;
|
|
122
72
|
height: var(--citadel-default-height);
|
|
123
73
|
min-height: var(--citadel-min-height);
|
|
124
74
|
max-height: var(--citadel-max-height);
|
|
125
|
-
background-color: var(--citadel-bg);
|
|
126
|
-
overflow: hidden;
|
|
127
|
-
width: 100%;
|
|
128
|
-
box-sizing: border-box;
|
|
129
75
|
margin: 0;
|
|
130
76
|
padding: 0;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
right: 0;
|
|
77
|
+
background-color: var(--citadel-bg);
|
|
78
|
+
overflow: hidden;
|
|
134
79
|
}
|
|
135
80
|
|
|
136
81
|
.innerContainer {
|
|
137
|
-
height: 100%;
|
|
138
|
-
flex: 1;
|
|
139
82
|
width: 100%;
|
|
140
|
-
|
|
141
|
-
flex-direction: column;
|
|
83
|
+
height: 100%;
|
|
142
84
|
margin: 0;
|
|
143
85
|
padding: 0;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex: 1;
|
|
88
|
+
flex-direction: column;
|
|
144
89
|
}
|
|
145
90
|
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
91
|
+
.citadel-tty {
|
|
92
|
+
background: var(--citadel-bg);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.citadel-tty-output-pane {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex: 1 1 auto;
|
|
98
|
+
min-height: 0;
|
|
99
|
+
padding: 0.75rem 1rem 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.citadel-tty-input-region {
|
|
103
|
+
flex-shrink: 0;
|
|
151
104
|
}
|
|
152
105
|
|
|
153
106
|
.resizeHandle {
|
|
154
|
-
width: 100%;
|
|
155
|
-
height: 6px;
|
|
156
|
-
background: transparent;
|
|
157
|
-
cursor: ns-resize;
|
|
158
107
|
position: absolute;
|
|
159
108
|
top: -3px;
|
|
160
109
|
left: 0;
|
|
161
110
|
right: 0;
|
|
162
111
|
z-index: 10;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 6px;
|
|
114
|
+
background: transparent;
|
|
115
|
+
cursor: ns-resize;
|
|
163
116
|
user-select: none;
|
|
164
117
|
-webkit-user-select: none;
|
|
165
118
|
pointer-events: all;
|
|
166
119
|
}
|
|
167
120
|
|
|
168
121
|
.resizeHandle:hover {
|
|
169
|
-
background:
|
|
122
|
+
background: color-mix(in oklch, var(--citadel-text) 10%, transparent);
|
|
170
123
|
}
|
|
171
124
|
|
|
172
125
|
@keyframes citadel_slideUp {
|
|
173
|
-
from {
|
|
174
|
-
|
|
126
|
+
from {
|
|
127
|
+
transform: translateY(100%);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
to {
|
|
131
|
+
transform: translateY(0);
|
|
132
|
+
}
|
|
175
133
|
}
|
|
176
134
|
|
|
177
135
|
@keyframes citadel_slideDown {
|
|
178
|
-
from {
|
|
179
|
-
|
|
136
|
+
from {
|
|
137
|
+
transform: translateY(0);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
to {
|
|
141
|
+
transform: translateY(100%);
|
|
142
|
+
}
|
|
180
143
|
}
|
|
181
144
|
|
|
182
145
|
.citadel_slideUp {
|
|
@@ -195,827 +158,309 @@ a:hover {
|
|
|
195
158
|
flex-direction: column;
|
|
196
159
|
background-color: var(--citadel-bg);
|
|
197
160
|
overflow: hidden;
|
|
198
|
-
box-sizing: border-box;
|
|
199
161
|
}
|
|
200
|
-
`,ve=`@tailwind base;
|
|
201
|
-
@tailwind components;
|
|
202
|
-
@tailwind utilities;
|
|
203
|
-
`,Je=`*, ::before, ::after {
|
|
204
|
-
--tw-border-spacing-x: 0;
|
|
205
|
-
--tw-border-spacing-y: 0;
|
|
206
|
-
--tw-translate-x: 0;
|
|
207
|
-
--tw-translate-y: 0;
|
|
208
|
-
--tw-rotate: 0;
|
|
209
|
-
--tw-skew-x: 0;
|
|
210
|
-
--tw-skew-y: 0;
|
|
211
|
-
--tw-scale-x: 1;
|
|
212
|
-
--tw-scale-y: 1;
|
|
213
|
-
--tw-pan-x: ;
|
|
214
|
-
--tw-pan-y: ;
|
|
215
|
-
--tw-pinch-zoom: ;
|
|
216
|
-
--tw-scroll-snap-strictness: proximity;
|
|
217
|
-
--tw-gradient-from-position: ;
|
|
218
|
-
--tw-gradient-via-position: ;
|
|
219
|
-
--tw-gradient-to-position: ;
|
|
220
|
-
--tw-ordinal: ;
|
|
221
|
-
--tw-slashed-zero: ;
|
|
222
|
-
--tw-numeric-figure: ;
|
|
223
|
-
--tw-numeric-spacing: ;
|
|
224
|
-
--tw-numeric-fraction: ;
|
|
225
|
-
--tw-ring-inset: ;
|
|
226
|
-
--tw-ring-offset-width: 0px;
|
|
227
|
-
--tw-ring-offset-color: #fff;
|
|
228
|
-
--tw-ring-color: rgb(59 130 246 / 0.5);
|
|
229
|
-
--tw-ring-offset-shadow: 0 0 #0000;
|
|
230
|
-
--tw-ring-shadow: 0 0 #0000;
|
|
231
|
-
--tw-shadow: 0 0 #0000;
|
|
232
|
-
--tw-shadow-colored: 0 0 #0000;
|
|
233
|
-
--tw-blur: ;
|
|
234
|
-
--tw-brightness: ;
|
|
235
|
-
--tw-contrast: ;
|
|
236
|
-
--tw-grayscale: ;
|
|
237
|
-
--tw-hue-rotate: ;
|
|
238
|
-
--tw-invert: ;
|
|
239
|
-
--tw-saturate: ;
|
|
240
|
-
--tw-sepia: ;
|
|
241
|
-
--tw-drop-shadow: ;
|
|
242
|
-
--tw-backdrop-blur: ;
|
|
243
|
-
--tw-backdrop-brightness: ;
|
|
244
|
-
--tw-backdrop-contrast: ;
|
|
245
|
-
--tw-backdrop-grayscale: ;
|
|
246
|
-
--tw-backdrop-hue-rotate: ;
|
|
247
|
-
--tw-backdrop-invert: ;
|
|
248
|
-
--tw-backdrop-opacity: ;
|
|
249
|
-
--tw-backdrop-saturate: ;
|
|
250
|
-
--tw-backdrop-sepia: ;
|
|
251
|
-
--tw-contain-size: ;
|
|
252
|
-
--tw-contain-layout: ;
|
|
253
|
-
--tw-contain-paint: ;
|
|
254
|
-
--tw-contain-style: ;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
::backdrop {
|
|
258
|
-
--tw-border-spacing-x: 0;
|
|
259
|
-
--tw-border-spacing-y: 0;
|
|
260
|
-
--tw-translate-x: 0;
|
|
261
|
-
--tw-translate-y: 0;
|
|
262
|
-
--tw-rotate: 0;
|
|
263
|
-
--tw-skew-x: 0;
|
|
264
|
-
--tw-skew-y: 0;
|
|
265
|
-
--tw-scale-x: 1;
|
|
266
|
-
--tw-scale-y: 1;
|
|
267
|
-
--tw-pan-x: ;
|
|
268
|
-
--tw-pan-y: ;
|
|
269
|
-
--tw-pinch-zoom: ;
|
|
270
|
-
--tw-scroll-snap-strictness: proximity;
|
|
271
|
-
--tw-gradient-from-position: ;
|
|
272
|
-
--tw-gradient-via-position: ;
|
|
273
|
-
--tw-gradient-to-position: ;
|
|
274
|
-
--tw-ordinal: ;
|
|
275
|
-
--tw-slashed-zero: ;
|
|
276
|
-
--tw-numeric-figure: ;
|
|
277
|
-
--tw-numeric-spacing: ;
|
|
278
|
-
--tw-numeric-fraction: ;
|
|
279
|
-
--tw-ring-inset: ;
|
|
280
|
-
--tw-ring-offset-width: 0px;
|
|
281
|
-
--tw-ring-offset-color: #fff;
|
|
282
|
-
--tw-ring-color: rgb(59 130 246 / 0.5);
|
|
283
|
-
--tw-ring-offset-shadow: 0 0 #0000;
|
|
284
|
-
--tw-ring-shadow: 0 0 #0000;
|
|
285
|
-
--tw-shadow: 0 0 #0000;
|
|
286
|
-
--tw-shadow-colored: 0 0 #0000;
|
|
287
|
-
--tw-blur: ;
|
|
288
|
-
--tw-brightness: ;
|
|
289
|
-
--tw-contrast: ;
|
|
290
|
-
--tw-grayscale: ;
|
|
291
|
-
--tw-hue-rotate: ;
|
|
292
|
-
--tw-invert: ;
|
|
293
|
-
--tw-saturate: ;
|
|
294
|
-
--tw-sepia: ;
|
|
295
|
-
--tw-drop-shadow: ;
|
|
296
|
-
--tw-backdrop-blur: ;
|
|
297
|
-
--tw-backdrop-brightness: ;
|
|
298
|
-
--tw-backdrop-contrast: ;
|
|
299
|
-
--tw-backdrop-grayscale: ;
|
|
300
|
-
--tw-backdrop-hue-rotate: ;
|
|
301
|
-
--tw-backdrop-invert: ;
|
|
302
|
-
--tw-backdrop-opacity: ;
|
|
303
|
-
--tw-backdrop-saturate: ;
|
|
304
|
-
--tw-backdrop-sepia: ;
|
|
305
|
-
--tw-contain-size: ;
|
|
306
|
-
--tw-contain-layout: ;
|
|
307
|
-
--tw-contain-paint: ;
|
|
308
|
-
--tw-contain-style: ;
|
|
309
|
-
}/*
|
|
310
|
-
! tailwindcss v3.4.15 | MIT License | https://tailwindcss.com
|
|
311
|
-
*//*
|
|
312
|
-
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
313
|
-
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
314
|
-
*/
|
|
315
|
-
|
|
316
|
-
*,
|
|
317
|
-
::before,
|
|
318
|
-
::after {
|
|
319
|
-
box-sizing: border-box; /* 1 */
|
|
320
|
-
border-width: 0; /* 2 */
|
|
321
|
-
border-style: solid; /* 2 */
|
|
322
|
-
border-color: #e5e7eb; /* 2 */
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
::before,
|
|
326
|
-
::after {
|
|
327
|
-
--tw-content: '';
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/*
|
|
331
|
-
1. Use a consistent sensible line-height in all browsers.
|
|
332
|
-
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
333
|
-
3. Use a more readable tab size.
|
|
334
|
-
4. Use the user's configured \`sans\` font-family by default.
|
|
335
|
-
5. Use the user's configured \`sans\` font-feature-settings by default.
|
|
336
|
-
6. Use the user's configured \`sans\` font-variation-settings by default.
|
|
337
|
-
7. Disable tap highlights on iOS
|
|
338
|
-
*/
|
|
339
|
-
|
|
340
|
-
html,
|
|
341
|
-
:host {
|
|
342
|
-
line-height: 1.5; /* 1 */
|
|
343
|
-
-webkit-text-size-adjust: 100%; /* 2 */
|
|
344
|
-
-moz-tab-size: 4; /* 3 */
|
|
345
|
-
-o-tab-size: 4;
|
|
346
|
-
tab-size: 4; /* 3 */
|
|
347
|
-
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
|
|
348
|
-
font-feature-settings: normal; /* 5 */
|
|
349
|
-
font-variation-settings: normal; /* 6 */
|
|
350
|
-
-webkit-tap-highlight-color: transparent; /* 7 */
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/*
|
|
354
|
-
1. Remove the margin in all browsers.
|
|
355
|
-
2. Inherit line-height from \`html\` so users can set them as a class directly on the \`html\` element.
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
body {
|
|
359
|
-
margin: 0; /* 1 */
|
|
360
|
-
line-height: inherit; /* 2 */
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/*
|
|
364
|
-
1. Add the correct height in Firefox.
|
|
365
|
-
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
|
366
|
-
3. Ensure horizontal rules are visible by default.
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
hr {
|
|
370
|
-
height: 0; /* 1 */
|
|
371
|
-
color: inherit; /* 2 */
|
|
372
|
-
border-top-width: 1px; /* 3 */
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/*
|
|
376
|
-
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
|
-
abbr:where([title]) {
|
|
380
|
-
-webkit-text-decoration: underline dotted;
|
|
381
|
-
text-decoration: underline dotted;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/*
|
|
385
|
-
Remove the default font size and weight for headings.
|
|
386
|
-
*/
|
|
387
|
-
|
|
388
|
-
h1,
|
|
389
|
-
h2,
|
|
390
|
-
h3,
|
|
391
|
-
h4,
|
|
392
|
-
h5,
|
|
393
|
-
h6 {
|
|
394
|
-
font-size: inherit;
|
|
395
|
-
font-weight: inherit;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/*
|
|
399
|
-
Reset links to optimize for opt-in styling instead of opt-out.
|
|
400
|
-
*/
|
|
401
|
-
|
|
402
|
-
a {
|
|
403
|
-
color: inherit;
|
|
404
|
-
text-decoration: inherit;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/*
|
|
408
|
-
Add the correct font weight in Edge and Safari.
|
|
409
|
-
*/
|
|
410
|
-
|
|
411
|
-
b,
|
|
412
|
-
strong {
|
|
413
|
-
font-weight: bolder;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/*
|
|
417
|
-
1. Use the user's configured \`mono\` font-family by default.
|
|
418
|
-
2. Use the user's configured \`mono\` font-feature-settings by default.
|
|
419
|
-
3. Use the user's configured \`mono\` font-variation-settings by default.
|
|
420
|
-
4. Correct the odd \`em\` font sizing in all browsers.
|
|
421
|
-
*/
|
|
422
|
-
|
|
423
|
-
code,
|
|
424
|
-
kbd,
|
|
425
|
-
samp,
|
|
426
|
-
pre {
|
|
427
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
|
|
428
|
-
font-feature-settings: normal; /* 2 */
|
|
429
|
-
font-variation-settings: normal; /* 3 */
|
|
430
|
-
font-size: 1em; /* 4 */
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/*
|
|
434
|
-
Add the correct font size in all browsers.
|
|
435
|
-
*/
|
|
436
162
|
|
|
437
|
-
|
|
438
|
-
|
|
163
|
+
.citadel-output {
|
|
164
|
+
width: 100%;
|
|
165
|
+
height: 100%;
|
|
166
|
+
overflow-y: auto;
|
|
167
|
+
padding: 0.75rem;
|
|
168
|
+
border: 1px solid var(--citadel-border);
|
|
169
|
+
border-radius: 0.5rem;
|
|
170
|
+
background: color-mix(in oklch, var(--citadel-bg) 75%, black);
|
|
171
|
+
text-align: left;
|
|
439
172
|
}
|
|
440
173
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
*/
|
|
444
|
-
|
|
445
|
-
sub,
|
|
446
|
-
sup {
|
|
447
|
-
font-size: 75%;
|
|
448
|
-
line-height: 0;
|
|
449
|
-
position: relative;
|
|
450
|
-
vertical-align: baseline;
|
|
174
|
+
.citadel-output-item {
|
|
175
|
+
margin-bottom: 1rem;
|
|
451
176
|
}
|
|
452
177
|
|
|
453
|
-
|
|
454
|
-
bottom:
|
|
178
|
+
.citadel-output-item:last-child {
|
|
179
|
+
margin-bottom: 0;
|
|
455
180
|
}
|
|
456
181
|
|
|
457
|
-
|
|
458
|
-
top:
|
|
182
|
+
.citadel-output-content {
|
|
183
|
+
margin-top: 0.35rem;
|
|
184
|
+
color: var(--citadel-text);
|
|
459
185
|
}
|
|
460
186
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
|
464
|
-
3. Remove gaps between table borders by default.
|
|
465
|
-
*/
|
|
466
|
-
|
|
467
|
-
table {
|
|
468
|
-
text-indent: 0; /* 1 */
|
|
469
|
-
border-color: inherit; /* 2 */
|
|
470
|
-
border-collapse: collapse; /* 3 */
|
|
187
|
+
.citadel-output-content > :first-child {
|
|
188
|
+
margin-top: 0;
|
|
471
189
|
}
|
|
472
190
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
2. Remove the margin in Firefox and Safari.
|
|
476
|
-
3. Remove default padding in all browsers.
|
|
477
|
-
*/
|
|
478
|
-
|
|
479
|
-
button,
|
|
480
|
-
input,
|
|
481
|
-
optgroup,
|
|
482
|
-
select,
|
|
483
|
-
textarea {
|
|
484
|
-
font-family: inherit; /* 1 */
|
|
485
|
-
font-feature-settings: inherit; /* 1 */
|
|
486
|
-
font-variation-settings: inherit; /* 1 */
|
|
487
|
-
font-size: 100%; /* 1 */
|
|
488
|
-
font-weight: inherit; /* 1 */
|
|
489
|
-
line-height: inherit; /* 1 */
|
|
490
|
-
letter-spacing: inherit; /* 1 */
|
|
491
|
-
color: inherit; /* 1 */
|
|
492
|
-
margin: 0; /* 2 */
|
|
493
|
-
padding: 0; /* 3 */
|
|
191
|
+
.citadel-output-content > :last-child {
|
|
192
|
+
margin-bottom: 0;
|
|
494
193
|
}
|
|
495
194
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
select {
|
|
502
|
-
text-transform: none;
|
|
195
|
+
.citadel-output-line {
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-wrap: wrap;
|
|
198
|
+
align-items: center;
|
|
199
|
+
gap: 0.5rem;
|
|
503
200
|
}
|
|
504
201
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
*/
|
|
509
|
-
|
|
510
|
-
button,
|
|
511
|
-
input:where([type='button']),
|
|
512
|
-
input:where([type='reset']),
|
|
513
|
-
input:where([type='submit']) {
|
|
514
|
-
-webkit-appearance: button; /* 1 */
|
|
515
|
-
background-color: transparent; /* 2 */
|
|
516
|
-
background-image: none; /* 2 */
|
|
202
|
+
.citadel-output-command,
|
|
203
|
+
.citadel-output-command-word {
|
|
204
|
+
color: var(--citadel-text);
|
|
517
205
|
}
|
|
518
206
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
*/
|
|
522
|
-
|
|
523
|
-
:-moz-focusring {
|
|
524
|
-
outline: auto;
|
|
207
|
+
.citadel-output-command-arg {
|
|
208
|
+
color: var(--citadel-arg);
|
|
525
209
|
}
|
|
526
210
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
211
|
+
.citadel-output-separator {
|
|
212
|
+
color: var(--citadel-muted);
|
|
213
|
+
}
|
|
530
214
|
|
|
531
|
-
|
|
532
|
-
|
|
215
|
+
.citadel-output-timestamp {
|
|
216
|
+
color: var(--citadel-subtle);
|
|
533
217
|
}
|
|
534
218
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
219
|
+
.citadel-status-dot {
|
|
220
|
+
width: 1rem;
|
|
221
|
+
height: 1rem;
|
|
222
|
+
border-radius: 999px;
|
|
223
|
+
}
|
|
538
224
|
|
|
539
|
-
|
|
540
|
-
|
|
225
|
+
.citadel-status-dot-success {
|
|
226
|
+
background: var(--citadel-success);
|
|
541
227
|
}
|
|
542
228
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
229
|
+
.citadel-status-dot-failure {
|
|
230
|
+
background: var(--citadel-error);
|
|
231
|
+
}
|
|
546
232
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
height:
|
|
233
|
+
.citadel-spinner {
|
|
234
|
+
width: 1rem;
|
|
235
|
+
height: 1rem;
|
|
236
|
+
border: 2px solid color-mix(in oklch, var(--citadel-text) 60%, transparent);
|
|
237
|
+
border-top-color: color-mix(in oklch, var(--citadel-muted) 80%, black);
|
|
238
|
+
border-radius: 999px;
|
|
239
|
+
animation: citadel-spin 0.9s linear infinite;
|
|
550
240
|
}
|
|
551
241
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
242
|
+
@keyframes citadel-spin {
|
|
243
|
+
to {
|
|
244
|
+
transform: rotate(360deg);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
556
247
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
248
|
+
.citadel-input-shell {
|
|
249
|
+
width: 100%;
|
|
250
|
+
padding: 1rem;
|
|
251
|
+
border-radius: 0.5rem;
|
|
252
|
+
background-color: var(--citadel-bg);
|
|
560
253
|
}
|
|
561
254
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
255
|
+
.citadel-input-line {
|
|
256
|
+
display: flex;
|
|
257
|
+
align-items: center;
|
|
258
|
+
gap: 0.5rem;
|
|
259
|
+
}
|
|
565
260
|
|
|
566
|
-
|
|
567
|
-
|
|
261
|
+
.citadel-input-prompt {
|
|
262
|
+
color: var(--citadel-muted);
|
|
568
263
|
}
|
|
569
264
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
265
|
+
.citadel-input-row {
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
flex: 1 1 auto;
|
|
269
|
+
min-width: 0;
|
|
270
|
+
}
|
|
574
271
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
272
|
+
.citadel-input-segments {
|
|
273
|
+
display: flex;
|
|
274
|
+
align-items: center;
|
|
275
|
+
gap: 0.25rem;
|
|
578
276
|
}
|
|
579
277
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
278
|
+
.citadel-input-segment-arg {
|
|
279
|
+
color: var(--citadel-text);
|
|
280
|
+
white-space: pre;
|
|
281
|
+
}
|
|
583
282
|
|
|
584
|
-
|
|
585
|
-
|
|
283
|
+
.citadel-input-segment-word {
|
|
284
|
+
color: var(--citadel-word);
|
|
285
|
+
white-space: pre;
|
|
586
286
|
}
|
|
587
287
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
288
|
+
.citadel-input-segment-space {
|
|
289
|
+
color: var(--citadel-text);
|
|
290
|
+
white-space: pre;
|
|
291
|
+
}
|
|
591
292
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
dd,
|
|
595
|
-
h1,
|
|
596
|
-
h2,
|
|
597
|
-
h3,
|
|
598
|
-
h4,
|
|
599
|
-
h5,
|
|
600
|
-
h6,
|
|
601
|
-
hr,
|
|
602
|
-
figure,
|
|
603
|
-
p,
|
|
604
|
-
pre {
|
|
605
|
-
margin: 0;
|
|
293
|
+
.citadel-input-segment-space-command {
|
|
294
|
+
color: var(--citadel-word);
|
|
606
295
|
}
|
|
607
296
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
297
|
+
.citadel-input-control {
|
|
298
|
+
position: relative;
|
|
299
|
+
flex: 1 1 auto;
|
|
300
|
+
min-width: 0;
|
|
611
301
|
}
|
|
612
302
|
|
|
613
|
-
|
|
614
|
-
|
|
303
|
+
.citadel-input-measure {
|
|
304
|
+
position: absolute;
|
|
305
|
+
top: 0;
|
|
306
|
+
left: 0;
|
|
307
|
+
visibility: hidden;
|
|
308
|
+
pointer-events: none;
|
|
309
|
+
white-space: pre;
|
|
310
|
+
font: inherit;
|
|
311
|
+
letter-spacing: inherit;
|
|
615
312
|
}
|
|
616
313
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
menu {
|
|
620
|
-
list-style: none;
|
|
314
|
+
.citadel-input-field {
|
|
315
|
+
width: 100%;
|
|
621
316
|
margin: 0;
|
|
622
317
|
padding: 0;
|
|
318
|
+
border: 0;
|
|
319
|
+
border-radius: 0;
|
|
320
|
+
outline: none;
|
|
321
|
+
background: transparent;
|
|
322
|
+
font: inherit;
|
|
323
|
+
line-height: inherit;
|
|
324
|
+
letter-spacing: inherit;
|
|
325
|
+
appearance: none;
|
|
326
|
+
-webkit-appearance: none;
|
|
327
|
+
caret-color: transparent;
|
|
623
328
|
}
|
|
624
329
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
dialog {
|
|
629
|
-
padding: 0;
|
|
330
|
+
.citadel-input-field::placeholder {
|
|
331
|
+
color: var(--citadel-subtle);
|
|
332
|
+
opacity: 1;
|
|
630
333
|
}
|
|
631
334
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
*/
|
|
635
|
-
|
|
636
|
-
textarea {
|
|
637
|
-
resize: vertical;
|
|
335
|
+
.citadel-input-field.is-command-mode {
|
|
336
|
+
color: var(--citadel-word);
|
|
638
337
|
}
|
|
639
338
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
2. Set the default placeholder color to the user's configured gray 400 color.
|
|
643
|
-
*/
|
|
644
|
-
|
|
645
|
-
input::-moz-placeholder, textarea::-moz-placeholder {
|
|
646
|
-
opacity: 1; /* 1 */
|
|
647
|
-
color: #9ca3af; /* 2 */
|
|
339
|
+
.citadel-input-field.is-argument-mode {
|
|
340
|
+
color: var(--citadel-text);
|
|
648
341
|
}
|
|
649
342
|
|
|
650
|
-
input
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
343
|
+
.citadel-input-cursor {
|
|
344
|
+
position: absolute;
|
|
345
|
+
top: 0;
|
|
346
|
+
pointer-events: none;
|
|
654
347
|
}
|
|
655
348
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
349
|
+
@keyframes citadel-invalid-glow {
|
|
350
|
+
0%,
|
|
351
|
+
100% {
|
|
352
|
+
box-shadow: 0 0 0 color-mix(in oklch, var(--citadel-error) 0%, transparent);
|
|
353
|
+
}
|
|
659
354
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
355
|
+
50% {
|
|
356
|
+
box-shadow: 0 0 8px color-mix(in oklch, var(--citadel-error) 70%, transparent);
|
|
357
|
+
}
|
|
663
358
|
}
|
|
664
359
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
*/
|
|
668
|
-
:disabled {
|
|
669
|
-
cursor: default;
|
|
360
|
+
.invalid-input-animation {
|
|
361
|
+
animation: citadel-invalid-glow 0.4s ease-in-out;
|
|
670
362
|
}
|
|
671
363
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
*/
|
|
364
|
+
.citadel-cursor-wrapper {
|
|
365
|
+
position: relative;
|
|
366
|
+
display: inline-block;
|
|
367
|
+
}
|
|
677
368
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
canvas,
|
|
682
|
-
audio,
|
|
683
|
-
iframe,
|
|
684
|
-
embed,
|
|
685
|
-
object {
|
|
686
|
-
display: block; /* 1 */
|
|
687
|
-
vertical-align: middle; /* 2 */
|
|
369
|
+
.command-cursor {
|
|
370
|
+
display: inline-block;
|
|
371
|
+
white-space: pre;
|
|
688
372
|
}
|
|
689
373
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
374
|
+
@keyframes citadel-shake {
|
|
375
|
+
0%,
|
|
376
|
+
100% {
|
|
377
|
+
transform: translateX(0);
|
|
378
|
+
}
|
|
693
379
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
height: auto;
|
|
698
|
-
}
|
|
380
|
+
25% {
|
|
381
|
+
transform: translateX(-4px);
|
|
382
|
+
}
|
|
699
383
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
.container {
|
|
705
|
-
width: 100%;
|
|
706
|
-
}
|
|
707
|
-
.pointer-events-none {
|
|
708
|
-
pointer-events: none;
|
|
709
|
-
}
|
|
710
|
-
.visible {
|
|
711
|
-
visibility: visible;
|
|
712
|
-
}
|
|
713
|
-
.static {
|
|
714
|
-
position: static;
|
|
715
|
-
}
|
|
716
|
-
.fixed {
|
|
717
|
-
position: fixed;
|
|
718
|
-
}
|
|
719
|
-
.absolute {
|
|
720
|
-
position: absolute;
|
|
721
|
-
}
|
|
722
|
-
.relative {
|
|
723
|
-
position: relative;
|
|
724
|
-
}
|
|
725
|
-
.top-0 {
|
|
726
|
-
top: 0px;
|
|
727
|
-
}
|
|
728
|
-
.my-2 {
|
|
729
|
-
margin-top: 0.5rem;
|
|
730
|
-
margin-bottom: 0.5rem;
|
|
731
|
-
}
|
|
732
|
-
.mb-4 {
|
|
733
|
-
margin-bottom: 1rem;
|
|
734
|
-
}
|
|
735
|
-
.ml-2 {
|
|
736
|
-
margin-left: 0.5rem;
|
|
737
|
-
}
|
|
738
|
-
.mr-2 {
|
|
739
|
-
margin-right: 0.5rem;
|
|
384
|
+
75% {
|
|
385
|
+
transform: translateX(4px);
|
|
386
|
+
}
|
|
740
387
|
}
|
|
741
|
-
|
|
742
|
-
|
|
388
|
+
|
|
389
|
+
.animate-shake {
|
|
390
|
+
animation: citadel-shake 0.2s ease-in-out;
|
|
743
391
|
}
|
|
744
|
-
|
|
392
|
+
|
|
393
|
+
.citadel-available-commands {
|
|
745
394
|
margin-top: 0.5rem;
|
|
395
|
+
padding: 0.5rem 1rem;
|
|
396
|
+
border-top: 1px solid var(--citadel-border);
|
|
746
397
|
}
|
|
747
|
-
.block {
|
|
748
|
-
display: block;
|
|
749
|
-
}
|
|
750
|
-
.inline-block {
|
|
751
|
-
display: inline-block;
|
|
752
|
-
}
|
|
753
|
-
.flex {
|
|
754
|
-
display: flex;
|
|
755
|
-
}
|
|
756
|
-
.hidden {
|
|
757
|
-
display: none;
|
|
758
|
-
}
|
|
759
|
-
.h-12 {
|
|
760
|
-
height: 3rem;
|
|
761
|
-
}
|
|
762
|
-
.h-4 {
|
|
763
|
-
height: 1rem;
|
|
764
|
-
}
|
|
765
|
-
.h-auto {
|
|
766
|
-
height: auto;
|
|
767
|
-
}
|
|
768
|
-
.h-full {
|
|
769
|
-
height: 100%;
|
|
770
|
-
}
|
|
771
|
-
.max-h-\\[300px\\] {
|
|
772
|
-
max-height: 300px;
|
|
773
|
-
}
|
|
774
|
-
.min-h-0 {
|
|
775
|
-
min-height: 0px;
|
|
776
|
-
}
|
|
777
|
-
.min-h-screen {
|
|
778
|
-
min-height: 100vh;
|
|
779
|
-
}
|
|
780
|
-
.w-4 {
|
|
781
|
-
width: 1rem;
|
|
782
|
-
}
|
|
783
|
-
.w-full {
|
|
784
|
-
width: 100%;
|
|
785
|
-
}
|
|
786
|
-
.max-w-\\[400px\\] {
|
|
787
|
-
max-width: 400px;
|
|
788
|
-
}
|
|
789
|
-
.flex-1 {
|
|
790
|
-
flex: 1 1 0%;
|
|
791
|
-
}
|
|
792
|
-
.flex-shrink-0 {
|
|
793
|
-
flex-shrink: 0;
|
|
794
|
-
}
|
|
795
|
-
.transform {
|
|
796
|
-
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
797
|
-
}
|
|
798
|
-
@keyframes spin {
|
|
799
398
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
.animate-spin {
|
|
805
|
-
animation: spin 1s linear infinite;
|
|
806
|
-
}
|
|
807
|
-
.flex-col {
|
|
808
|
-
flex-direction: column;
|
|
399
|
+
.citadel-available-commands-content {
|
|
400
|
+
color: var(--citadel-muted);
|
|
809
401
|
}
|
|
810
|
-
|
|
402
|
+
|
|
403
|
+
.citadel-available-chip-list {
|
|
404
|
+
display: flex;
|
|
811
405
|
flex-wrap: wrap;
|
|
812
|
-
}
|
|
813
|
-
.items-center {
|
|
814
|
-
align-items: center;
|
|
815
|
-
}
|
|
816
|
-
.justify-center {
|
|
817
|
-
justify-content: center;
|
|
818
|
-
}
|
|
819
|
-
.gap-2 {
|
|
820
406
|
gap: 0.5rem;
|
|
821
407
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
.rounded {
|
|
829
|
-
border-radius: 0.25rem;
|
|
830
|
-
}
|
|
831
|
-
.rounded-full {
|
|
832
|
-
border-radius: 9999px;
|
|
833
|
-
}
|
|
834
|
-
.rounded-lg {
|
|
835
|
-
border-radius: 0.5rem;
|
|
836
|
-
}
|
|
837
|
-
.border {
|
|
838
|
-
border-width: 1px;
|
|
839
|
-
}
|
|
840
|
-
.border-2 {
|
|
841
|
-
border-width: 2px;
|
|
842
|
-
}
|
|
843
|
-
.border-t {
|
|
844
|
-
border-top-width: 1px;
|
|
845
|
-
}
|
|
846
|
-
.border-gray-300 {
|
|
847
|
-
--tw-border-opacity: 1;
|
|
848
|
-
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
|
849
|
-
}
|
|
850
|
-
.border-gray-700 {
|
|
851
|
-
--tw-border-opacity: 1;
|
|
852
|
-
border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
|
|
853
|
-
}
|
|
854
|
-
.border-t-gray-600 {
|
|
855
|
-
--tw-border-opacity: 1;
|
|
856
|
-
border-top-color: rgb(75 85 99 / var(--tw-border-opacity, 1));
|
|
857
|
-
}
|
|
858
|
-
.bg-gray-100 {
|
|
859
|
-
--tw-bg-opacity: 1;
|
|
860
|
-
background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
|
|
861
|
-
}
|
|
862
|
-
.bg-gray-800 {
|
|
863
|
-
--tw-bg-opacity: 1;
|
|
864
|
-
background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
|
|
865
|
-
}
|
|
866
|
-
.bg-gray-900 {
|
|
867
|
-
--tw-bg-opacity: 1;
|
|
868
|
-
background-color: rgb(17 24 39 / var(--tw-bg-opacity, 1));
|
|
869
|
-
}
|
|
870
|
-
.bg-green-500 {
|
|
871
|
-
--tw-bg-opacity: 1;
|
|
872
|
-
background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1));
|
|
873
|
-
}
|
|
874
|
-
.bg-red-500 {
|
|
875
|
-
--tw-bg-opacity: 1;
|
|
876
|
-
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
|
|
877
|
-
}
|
|
878
|
-
.bg-transparent {
|
|
879
|
-
background-color: transparent;
|
|
880
|
-
}
|
|
881
|
-
.bg-white {
|
|
882
|
-
--tw-bg-opacity: 1;
|
|
883
|
-
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
|
|
884
|
-
}
|
|
885
|
-
.object-contain {
|
|
886
|
-
-o-object-fit: contain;
|
|
887
|
-
object-fit: contain;
|
|
888
|
-
}
|
|
889
|
-
.p-3 {
|
|
890
|
-
padding: 0.75rem;
|
|
891
|
-
}
|
|
892
|
-
.p-4 {
|
|
893
|
-
padding: 1rem;
|
|
894
|
-
}
|
|
895
|
-
.p-6 {
|
|
896
|
-
padding: 1.5rem;
|
|
897
|
-
}
|
|
898
|
-
.px-2 {
|
|
899
|
-
padding-left: 0.5rem;
|
|
900
|
-
padding-right: 0.5rem;
|
|
901
|
-
}
|
|
902
|
-
.px-4 {
|
|
903
|
-
padding-left: 1rem;
|
|
904
|
-
padding-right: 1rem;
|
|
905
|
-
}
|
|
906
|
-
.py-1 {
|
|
907
|
-
padding-top: 0.25rem;
|
|
908
|
-
padding-bottom: 0.25rem;
|
|
909
|
-
}
|
|
910
|
-
.pt-2 {
|
|
911
|
-
padding-top: 0.5rem;
|
|
912
|
-
}
|
|
913
|
-
.pt-3 {
|
|
914
|
-
padding-top: 0.75rem;
|
|
915
|
-
}
|
|
916
|
-
.text-left {
|
|
917
|
-
text-align: left;
|
|
918
|
-
}
|
|
919
|
-
.font-mono {
|
|
920
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
921
|
-
}
|
|
922
|
-
.text-base {
|
|
923
|
-
font-size: 1rem;
|
|
924
|
-
line-height: 1.5rem;
|
|
925
|
-
}
|
|
926
|
-
.text-lg {
|
|
927
|
-
font-size: 1.125rem;
|
|
928
|
-
line-height: 1.75rem;
|
|
929
|
-
}
|
|
930
|
-
.text-sm {
|
|
931
|
-
font-size: 0.875rem;
|
|
932
|
-
line-height: 1.25rem;
|
|
933
|
-
}
|
|
934
|
-
.text-xs {
|
|
935
|
-
font-size: 0.75rem;
|
|
936
|
-
line-height: 1rem;
|
|
937
|
-
}
|
|
938
|
-
.text-blue-400 {
|
|
939
|
-
--tw-text-opacity: 1;
|
|
940
|
-
color: rgb(96 165 250 / var(--tw-text-opacity, 1));
|
|
941
|
-
}
|
|
942
|
-
.text-gray-200 {
|
|
943
|
-
--tw-text-opacity: 1;
|
|
944
|
-
color: rgb(229 231 235 / var(--tw-text-opacity, 1));
|
|
945
|
-
}
|
|
946
|
-
.text-gray-300 {
|
|
947
|
-
--tw-text-opacity: 1;
|
|
948
|
-
color: rgb(209 213 219 / var(--tw-text-opacity, 1));
|
|
949
|
-
}
|
|
950
|
-
.text-gray-400 {
|
|
951
|
-
--tw-text-opacity: 1;
|
|
952
|
-
color: rgb(156 163 175 / var(--tw-text-opacity, 1));
|
|
953
|
-
}
|
|
954
|
-
.text-gray-500 {
|
|
955
|
-
--tw-text-opacity: 1;
|
|
956
|
-
color: rgb(107 114 128 / var(--tw-text-opacity, 1));
|
|
957
|
-
}
|
|
958
|
-
.text-gray-700 {
|
|
959
|
-
--tw-text-opacity: 1;
|
|
960
|
-
color: rgb(55 65 81 / var(--tw-text-opacity, 1));
|
|
961
|
-
}
|
|
962
|
-
.text-green-500 {
|
|
963
|
-
--tw-text-opacity: 1;
|
|
964
|
-
color: rgb(34 197 94 / var(--tw-text-opacity, 1));
|
|
965
|
-
}
|
|
966
|
-
.text-red-400 {
|
|
967
|
-
--tw-text-opacity: 1;
|
|
968
|
-
color: rgb(248 113 113 / var(--tw-text-opacity, 1));
|
|
969
|
-
}
|
|
970
|
-
.text-red-500 {
|
|
971
|
-
--tw-text-opacity: 1;
|
|
972
|
-
color: rgb(239 68 68 / var(--tw-text-opacity, 1));
|
|
973
|
-
}
|
|
974
|
-
.text-white {
|
|
975
|
-
--tw-text-opacity: 1;
|
|
976
|
-
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
|
|
408
|
+
|
|
409
|
+
.citadel-available-chip {
|
|
410
|
+
padding: 0.25rem 0.5rem;
|
|
411
|
+
border-radius: 0.375rem;
|
|
412
|
+
background: var(--citadel-surface);
|
|
977
413
|
}
|
|
978
|
-
|
|
979
|
-
|
|
414
|
+
|
|
415
|
+
.citadel-available-chip-text {
|
|
416
|
+
color: white;
|
|
980
417
|
}
|
|
981
|
-
|
|
982
|
-
|
|
418
|
+
|
|
419
|
+
.citadel-available-chip-prefix {
|
|
420
|
+
text-decoration: underline;
|
|
983
421
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
422
|
+
|
|
423
|
+
.citadel-available-next-arg {
|
|
424
|
+
color: var(--citadel-word);
|
|
988
425
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
426
|
+
|
|
427
|
+
.citadel-available-next-desc {
|
|
428
|
+
margin-left: 0.5rem;
|
|
429
|
+
color: var(--citadel-muted);
|
|
993
430
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
431
|
+
|
|
432
|
+
.citadel-result-json,
|
|
433
|
+
.citadel-result-text {
|
|
434
|
+
color: var(--citadel-text);
|
|
997
435
|
}
|
|
998
|
-
|
|
999
|
-
|
|
436
|
+
|
|
437
|
+
.citadel-result-json {
|
|
438
|
+
margin: 0;
|
|
1000
439
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
|
|
1005
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
1006
|
-
transition-duration: 150ms;
|
|
440
|
+
|
|
441
|
+
.citadel-result-text {
|
|
442
|
+
white-space: pre;
|
|
1007
443
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
444
|
+
|
|
445
|
+
.citadel-result-error {
|
|
446
|
+
margin-top: 0.25rem;
|
|
447
|
+
color: var(--citadel-error);
|
|
1010
448
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
449
|
+
|
|
450
|
+
.citadel-result-pending {
|
|
451
|
+
color: var(--citadel-muted);
|
|
1013
452
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
453
|
+
|
|
454
|
+
.citadel-result-image-wrap {
|
|
455
|
+
margin-block: 0.5rem;
|
|
1016
456
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
457
|
+
|
|
458
|
+
.citadel-result-image {
|
|
459
|
+
max-width: 400px;
|
|
460
|
+
max-height: 300px;
|
|
461
|
+
height: auto;
|
|
462
|
+
object-fit: contain;
|
|
463
|
+
border-radius: 0.5rem;
|
|
1019
464
|
}
|
|
1020
|
-
`,
|
|
1021
|
-
`),
|
|
465
|
+
`,Qe=({config:n=I,commandRegistry:e,containerId:t=null})=>{const s=o.useRef(new $),r=e??s.current,a=o.useRef(null),i=o.useMemo(()=>({width:"100%",height:"100%"}),[]),d=n.displayMode??I.displayMode??"panel";return o.useEffect(()=>{k.configure({level:n.logLevel||I.logLevel||X.ERROR,prefix:"[Citadel]"});const l=new ke(r,n),u=d==="inline"&&!t,y=u?a.current:t?document.getElementById(t):document.body;if(y)y.appendChild(l);else{if(u){console.warn("[Citadel] No host available for inline mode; skipping mount.");return}console.warn(`Container with id "${t}" not found, falling back to body`),document.body.appendChild(l)}return()=>{var p;(p=l.parentElement)==null||p.removeChild(l)}},[r,t,n,d]),d==="inline"&&!t?c.jsx("div",{ref:a,style:i}):null};class ke extends HTMLElement{constructor(t,s){var a;super();C(this,"shadow");C(this,"root",null);C(this,"commandRegistry");C(this,"config");this.shadow=this.attachShadow({mode:"open"}),this.commandRegistry=t,this.config=s;const r=((a=this.config)==null?void 0:a.displayMode)??"panel";this.setAttribute("data-display-mode",r)}connectedCallback(){try{const s=[xe].map(r=>{const a=new CSSStyleSheet;return a.replaceSync(r),a});this.shadow.adoptedStyleSheets=[...s]}catch{const s=[xe].join(`
|
|
466
|
+
`),r=document.createElement("style");r.textContent=s,this.shadow.appendChild(r)}const t=document.createElement("div");t.id="citadel-root",t.style.width="100%",t.style.height="100%",this.shadow.appendChild(t),this.root=Ae.createRoot(t),this.root.render(c.jsx(ze,{config:this.config||I,commandRegistry:this.commandRegistry,children:c.jsx(Xe,{})}))}disconnectedCallback(){const t=this.root;if(this.root=null,!t){this.shadow.replaceChildren();return}queueMicrotask(()=>{t.unmount(),this.shadow.replaceChildren()})}}typeof window<"u"&&window.customElements&&!window.customElements.get("citadel-element")&&window.customElements.define("citadel-element",ke);const Xe=()=>(T().displayMode??"panel")==="inline"?c.jsx(Ge,{}):c.jsx(Je,{});class Ze{constructor(){C(this,"_description")}describe(e){return this._description=e,this}get description(){return this._description}}class Re{constructor(e){C(this,"state");this.state={path:e,description:"",segments:et(e)}}describe(e){return this.state.description=e,this}details(e){return this.state.details=e,this}arg(e,t){const s=new Ze;return t==null||t(s),this.state.segments.push({type:"argument",name:e,description:s.description}),this}handle(e){return{path:this.state.path,description:this.state.description,details:this.state.details,segments:[...this.state.segments],handler:e}}}function et(n){const e=n.trim();if(!e)throw new Error("Command path cannot be empty");const t=e.split(".");if(t.some(s=>s.trim()===""))throw new Error(`Invalid command path "${n}". Empty segments are not allowed.`);if(t.some(s=>s.includes(" ")))throw new Error(`Invalid command path "${n}". Use dot-delimited words (e.g. "user.show").`);return t.map(s=>({type:"word",name:s}))}function tt(n){return n.flatMap(e=>e.type==="argument"?[e.name]:[])}function nt(n){const e=tt(n.segments);return async t=>{const s=e.reduce((r,a,i)=>(r[a]=t[i],r),{});return Promise.resolve(n.handler({rawArgs:t,namedArgs:s,commandPath:n.path}))}}function st(n){return new Re(n)}function Ee(n,e){n.addCommand(e.segments,e.description,nt(e))}function Ne(n,e){return e.forEach(t=>Ee(n,t)),n}function rt(n){const e=new $;return Ne(e,n)}function ot(n){return new O(n)}function at(n){return new ae(n)}function it(n,e=""){return new le(n,e)}function lt(n){return new Q(n)}f.Citadel=Qe,f.CommandRegistry=$,f.CommandResult=j,f.CommandStatus=L,f.DEFAULT_CURSOR_CONFIGS=Ce,f.ErrorCommandResult=Q,f.ImageCommandResult=le,f.JsonCommandResult=ae,f.OutputItem=Y,f.PendingCommandResult=ie,f.TextCommandResult=O,f.command=st,f.createCommandRegistry=rt,f.error=lt,f.image=it,f.json=at,f.registerCommand=Ee,f.registerCommands=Ne,f.text=ot,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|