import { html, css, LitElement, PropertyValues } from "lit";
import { provide, consume, createContext } from "@lit/context";
import { LitElementWw } from "@webwriter/lit";
import { customElement, property, query } from "lit/decorators.js";
import search from "@tabler/icons/outline/search.svg";
import file from "@tabler/icons/outline/file.svg";
import squares from "@tabler/icons/outline/squares.svg";
import arrowsSplit2 from "@tabler/icons/outline/arrows-split-2.svg";
import book from "@tabler/icons/outline/book.svg";
import packages from "@tabler/icons/outline/packages.svg";
import trash from "@tabler/icons/outline/trash.svg";
import circleArrowRight from "@tabler/icons/filled/circle-arrow-right.svg";
import infoSquareRounded from "@tabler/icons/filled/info-square-rounded.svg";
import {
editorState,
GamebookEditorState,
} from "../../utils/gamebook-editor-state-context";
//Drawflow Imports
import Drawflow, { DrawflowNode } from "drawflow";
// Shoelace Imports
import "@shoelace-style/shoelace/dist/themes/light.css";
import {
SlInput,
SlIcon,
SlButton,
SlSwitch,
SlSelect,
SlDivider,
SlIconButton,
SlButtonGroup,
SlDropdown,
SlMenu,
SlMenuItem,
SlMenuLabel,
} from "@shoelace-style/shoelace";
@customElement("webwriter-gamebook-options")
export class WebWriterGamebookOptions extends LitElementWw {
static get styles() {
return css`
:host {
padding-left: 10px;
}
.author-only {
display: flex;
flex-direction: column;
box-sizing: border-box;
gap: 10px;
width: 180px;
}
.author-only .header p {
margin: 0px;
font-weight: 500;
font-size: 15px;
box-sizing: border-box;
color: #52525b;
}
.author-only .header {
display: flex;
flex-direction: row;
align-items: center;
justify-items: center;
border-bottom: 2px solid #52525b;
gap: 7px;
padding-bottom: 10px;
}
.author-only .searchBar {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-items: center;
width: 100%;
height: 65px;
}
.author-only .searchBar * {
width: 100%;
}
.author-only sl-icon {
color: #52525b;
}
.author-only .horizontalStack {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
width: 100%;
}
sl-button.square {
width: 42px; /* Set this value to whatever size you want */
height: 42px; /* Same value as width to ensure it's a square */
}
p {
margin: 0px;
font-weight: 400;
font-size: 15px;
box-sizing: border-box;
color: #52525b;
}
`;
}
//registering custom elements used in the widget
static get scopedElements() {
return {
"sl-input": SlInput,
"sl-icon": SlIcon,
"sl-button": SlButton,
"sl-button-group": SlButtonGroup,
"sl-select": SlSelect,
"sl-divider": SlDivider,
"sl-icon-button": SlIconButton,
"sl-switch": SlSwitch,
"sl-dropdown": SlDropdown,
"sl-menu": SlMenu,
"sl-menu-item": SlMenuItem,
"sl-menu-label": SlMenuLabel,
};
}
@query("#searchInput") accessor searchInput;
@consume({ context: editorState, subscribe: true })
@property({ type: Object, attribute: true, reflect: false })
public accessor editorStore = new GamebookEditorState("Default");
render() {
const options = (data) =>
Object.keys(data)
.filter(
(key) =>
this.editorStore.searchResults !== undefined
? this.editorStore.searchResults.includes(Number(key))
: true // No filtering when searchResults is empty
)
.map(
(key) => html` ${data[key].data.title}