kritzel-stencil 0.1.78 → 0.1.79

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.
@@ -1 +1 @@
1
- import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-CGGiwvWZ.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-53di1Zko.js";import{d as c}from"./p-DxzDda_J.js";import{d}from"./p-DkWWzVg8.js";import{d as h}from"./p-DWsCbu01.js";import{d as g}from"./p-Ck1dhpUQ.js";const p="kritzel-settings",u=-1/0,m=1/0,f=-1/0,b=1/0,k={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0},v=[{id:"general",label:"General",icon:"settings"},{id:"viewport",label:"Viewport",icon:"viewport"},{id:"shortcuts",label:"Keyboard Shortcuts",icon:"command"},{id:"developer",label:"Developer Options",icon:"braces"},{id:"about",label:"About",icon:"info"}],w=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}shortcuts=[];editorId;isDialogOpen=!1;selectedCategoryId=v[0].id;scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;currentTheme="light";viewportBoundaryLeft=u;viewportBoundaryRight=m;viewportBoundaryTop=f;viewportBoundaryBottom=b;debugInfo={...k};settingsChange;componentWillLoad(){this.loadSettings()}get storageKey(){return this.editorId?`${p}-${this.editorId}`:p}loadSettings(){const e=localStorage.getItem(this.storageKey);if(e)try{const t=JSON.parse(e);"number"==typeof t.scaleMin&&(this.scaleMin=t.scaleMin),"number"==typeof t.scaleMax&&(this.scaleMax=t.scaleMax),"boolean"==typeof t.lockDrawingScale&&(this.lockDrawingScale=t.lockDrawingScale),"light"!==t.theme&&"dark"!==t.theme||(this.currentTheme=t.theme),"number"==typeof t.viewportBoundaryLeft&&(this.viewportBoundaryLeft=t.viewportBoundaryLeft),"number"==typeof t.viewportBoundaryRight&&(this.viewportBoundaryRight=t.viewportBoundaryRight),"number"==typeof t.viewportBoundaryTop&&(this.viewportBoundaryTop=t.viewportBoundaryTop),"number"==typeof t.viewportBoundaryBottom&&(this.viewportBoundaryBottom=t.viewportBoundaryBottom),t.debugInfo&&(this.debugInfo={...k,...t.debugInfo})}catch{}}saveSettings(){const e={scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.currentTheme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo};localStorage.setItem(this.storageKey,JSON.stringify(e)),this.settingsChange.emit(e)}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.saveSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.saveSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.saveSettings()};handleThemeChange=e=>{this.currentTheme=e.detail?"dark":"light",this.saveSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.saveSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??m,this.saveSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??f,this.saveSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??b,this.saveSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.saveSettings()};async open(){this.isDialogOpen=!0}closeDialog=()=>{this.isDialogOpen=!1};handleCategorySelect=e=>{this.selectedCategoryId=e.detail.item.id};formatKeyCombo(e){const t=[];return e.ctrl&&t.push("Ctrl"),e.shift&&t.push("Shift"),t.push(this.formatKey(e.key)),t.join("+")}formatKey(e){return{Escape:"Esc",Delete:"Del"," ":"Space"}[e]??e.toUpperCase()}groupShortcutsByCategory(){const e=new Map;for(const t of this.shortcuts){const s=e.get(t.category)||[];s.push(t),e.set(t.category,s)}return e}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,"General Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Dark Mode"),i("p",{class:"settings-description"},"Toggle between light and dark color themes for the editor interface."),i("kritzel-slide-toggle",{checked:"dark"===this.currentTheme,label:"Dark Mode",onCheckedChange:this.handleThemeChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Lock Drawing Scale"),i("p",{class:"settings-description"},"When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level."),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:"Lock Drawing Scale",onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,"Viewport Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Minimum Zoom Level"),i("p",{class:"settings-description"},"Sets the minimum zoom level. Lower values allow zooming out further to see more of the canvas."),i("kritzel-numeric-input",{value:this.scaleMin,min:1e-4,max:1,step:1e-4,onValueChange:this.handleScaleMinChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Maximum Zoom Level"),i("p",{class:"settings-description"},"Sets the maximum zoom level. Higher values allow zooming in closer for detailed work."),i("kritzel-numeric-input",{value:this.scaleMax,min:1,max:1e3,step:1,onValueChange:this.handleScaleMaxChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Left"),i("p",{class:"settings-description"},"Left boundary in world coordinates. Set to limit how far left the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryLeft,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Right"),i("p",{class:"settings-description"},"Right boundary in world coordinates. Set to limit how far right the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryRight,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Top"),i("p",{class:"settings-description"},"Top boundary in world coordinates. Set to limit how far up the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryTop,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Bottom"),i("p",{class:"settings-description"},"Bottom boundary in world coordinates. Set to limit how far down the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryBottom,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,"Keyboard Shortcuts"),i("div",{class:"shortcuts-list"},Array.from(this.groupShortcutsByCategory()).map((([e,t])=>i("div",{class:"shortcuts-category",key:e},i("h4",{class:"shortcuts-category-title"},e),i("div",{class:"shortcuts-group"},t.map((e=>i("div",{class:"shortcut-item",key:e.key+e.label},i("span",{class:"shortcut-label"},e.label),i("kbd",{class:"shortcut-key"},this.formatKeyCombo(e)))))))))));case"developer":return i("div",{class:"settings-content"},i("h3",null,"Developer Options"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Viewport Info"),i("p",{class:"settings-description"},"Display viewport debug information such as position, zoom level, and boundaries."),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:"Show Viewport Info",onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Object Info"),i("p",{class:"settings-description"},"Display debug information about objects on the canvas."),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:"Show Object Info",onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Sync Provider Info"),i("p",{class:"settings-description"},"Display debug information about the sync provider connection status."),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:"Show Sync Provider Info",onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Migration Info"),i("p",{class:"settings-description"},"Display debug information about data migrations."),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:"Show Migration Info",onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,"About"),i("p",null,"Kritzel - A drawing application"),i("p",{class:"version-info"},"Version ","0.1.78"),i("p",{class:"version-info"},"App-State Schema v",l),i("p",{class:"version-info"},"Workspace Schema v",a));default:return null}}render(){return i(o,{key:"0d4cd5ad565a1ff1140f308765ff887ba68ba6c8"},i("kritzel-dialog",{key:"170a15a41d18f56981a99aae266026625d7fe644",isOpen:this.isDialogOpen,dialogTitle:"Settings",size:"large",onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"6569f351fdef57dd189af63f7d6c4d98ce815c1b",items:v,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get style(){return":host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}"}},[513,"kritzel-settings",{shortcuts:[16],editorId:[1,"editor-id"],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],currentTheme:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]}]);function y(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-icon","kritzel-master-detail","kritzel-numeric-input","kritzel-slide-toggle"].forEach((e=>{switch(e){case"kritzel-settings":customElements.get(n(e))||customElements.define(n(e),w);break;case"kritzel-dialog":customElements.get(n(e))||r();break;case"kritzel-icon":customElements.get(n(e))||c();break;case"kritzel-master-detail":customElements.get(n(e))||d();break;case"kritzel-numeric-input":customElements.get(n(e))||h();break;case"kritzel-slide-toggle":customElements.get(n(e))||g()}}))}export{w as K,y as d}
1
+ import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-CGGiwvWZ.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-53di1Zko.js";import{d as c}from"./p-DxzDda_J.js";import{d}from"./p-DkWWzVg8.js";import{d as h}from"./p-DWsCbu01.js";import{d as g}from"./p-Ck1dhpUQ.js";const p="kritzel-settings",u=-1/0,m=1/0,f=-1/0,b=1/0,k={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0},v=[{id:"general",label:"General",icon:"settings"},{id:"viewport",label:"Viewport",icon:"viewport"},{id:"shortcuts",label:"Keyboard Shortcuts",icon:"command"},{id:"developer",label:"Developer Options",icon:"braces"},{id:"about",label:"About",icon:"info"}],w=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}shortcuts=[];editorId;isDialogOpen=!1;selectedCategoryId=v[0].id;scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;currentTheme="light";viewportBoundaryLeft=u;viewportBoundaryRight=m;viewportBoundaryTop=f;viewportBoundaryBottom=b;debugInfo={...k};settingsChange;componentWillLoad(){this.loadSettings()}get storageKey(){return this.editorId?`${p}-${this.editorId}`:p}loadSettings(){const e=localStorage.getItem(this.storageKey);if(e)try{const t=JSON.parse(e);"number"==typeof t.scaleMin&&(this.scaleMin=t.scaleMin),"number"==typeof t.scaleMax&&(this.scaleMax=t.scaleMax),"boolean"==typeof t.lockDrawingScale&&(this.lockDrawingScale=t.lockDrawingScale),"light"!==t.theme&&"dark"!==t.theme||(this.currentTheme=t.theme),"number"==typeof t.viewportBoundaryLeft&&(this.viewportBoundaryLeft=t.viewportBoundaryLeft),"number"==typeof t.viewportBoundaryRight&&(this.viewportBoundaryRight=t.viewportBoundaryRight),"number"==typeof t.viewportBoundaryTop&&(this.viewportBoundaryTop=t.viewportBoundaryTop),"number"==typeof t.viewportBoundaryBottom&&(this.viewportBoundaryBottom=t.viewportBoundaryBottom),t.debugInfo&&(this.debugInfo={...k,...t.debugInfo})}catch{}}saveSettings(){const e={scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.currentTheme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo};localStorage.setItem(this.storageKey,JSON.stringify(e)),this.settingsChange.emit(e)}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.saveSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.saveSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.saveSettings()};handleThemeChange=e=>{this.currentTheme=e.detail?"dark":"light",this.saveSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.saveSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??m,this.saveSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??f,this.saveSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??b,this.saveSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.saveSettings()};async open(){this.isDialogOpen=!0}closeDialog=()=>{this.isDialogOpen=!1};handleCategorySelect=e=>{this.selectedCategoryId=e.detail.item.id};formatKeyCombo(e){const t=[];return e.ctrl&&t.push("Ctrl"),e.shift&&t.push("Shift"),t.push(this.formatKey(e.key)),t.join("+")}formatKey(e){return{Escape:"Esc",Delete:"Del"," ":"Space"}[e]??e.toUpperCase()}groupShortcutsByCategory(){const e=new Map;for(const t of this.shortcuts){const s=e.get(t.category)||[];s.push(t),e.set(t.category,s)}return e}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,"General Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Dark Mode"),i("p",{class:"settings-description"},"Toggle between light and dark color themes for the editor interface."),i("kritzel-slide-toggle",{checked:"dark"===this.currentTheme,label:"Dark Mode",onCheckedChange:this.handleThemeChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Lock Drawing Scale"),i("p",{class:"settings-description"},"When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level."),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:"Lock Drawing Scale",onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,"Viewport Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Minimum Zoom Level"),i("p",{class:"settings-description"},"Sets the minimum zoom level. Lower values allow zooming out further to see more of the canvas."),i("kritzel-numeric-input",{value:this.scaleMin,min:1e-4,max:1,step:1e-4,onValueChange:this.handleScaleMinChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Maximum Zoom Level"),i("p",{class:"settings-description"},"Sets the maximum zoom level. Higher values allow zooming in closer for detailed work."),i("kritzel-numeric-input",{value:this.scaleMax,min:1,max:1e3,step:1,onValueChange:this.handleScaleMaxChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Left"),i("p",{class:"settings-description"},"Left boundary in world coordinates. Set to limit how far left the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryLeft,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Right"),i("p",{class:"settings-description"},"Right boundary in world coordinates. Set to limit how far right the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryRight,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Top"),i("p",{class:"settings-description"},"Top boundary in world coordinates. Set to limit how far up the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryTop,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Bottom"),i("p",{class:"settings-description"},"Bottom boundary in world coordinates. Set to limit how far down the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryBottom,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,"Keyboard Shortcuts"),i("div",{class:"shortcuts-list"},Array.from(this.groupShortcutsByCategory()).map((([e,t])=>i("div",{class:"shortcuts-category",key:e},i("h4",{class:"shortcuts-category-title"},e),i("div",{class:"shortcuts-group"},t.map((e=>i("div",{class:"shortcut-item",key:e.key+e.label},i("span",{class:"shortcut-label"},e.label),i("kbd",{class:"shortcut-key"},this.formatKeyCombo(e)))))))))));case"developer":return i("div",{class:"settings-content"},i("h3",null,"Developer Options"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Viewport Info"),i("p",{class:"settings-description"},"Display viewport debug information such as position, zoom level, and boundaries."),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:"Show Viewport Info",onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Object Info"),i("p",{class:"settings-description"},"Display debug information about objects on the canvas."),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:"Show Object Info",onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Sync Provider Info"),i("p",{class:"settings-description"},"Display debug information about the sync provider connection status."),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:"Show Sync Provider Info",onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Migration Info"),i("p",{class:"settings-description"},"Display debug information about data migrations."),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:"Show Migration Info",onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,"About"),i("p",null,"Kritzel - A drawing application"),i("p",{class:"version-info"},"Version ","0.1.79"),i("p",{class:"version-info"},"App-State Schema v",l),i("p",{class:"version-info"},"Workspace Schema v",a));default:return null}}render(){return i(o,{key:"0d4cd5ad565a1ff1140f308765ff887ba68ba6c8"},i("kritzel-dialog",{key:"170a15a41d18f56981a99aae266026625d7fe644",isOpen:this.isDialogOpen,dialogTitle:"Settings",size:"large",onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"6569f351fdef57dd189af63f7d6c4d98ce815c1b",items:v,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get style(){return":host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}"}},[513,"kritzel-settings",{shortcuts:[16],editorId:[1,"editor-id"],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],currentTheme:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]}]);function y(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-icon","kritzel-master-detail","kritzel-numeric-input","kritzel-slide-toggle"].forEach((e=>{switch(e){case"kritzel-settings":customElements.get(n(e))||customElements.define(n(e),w);break;case"kritzel-dialog":customElements.get(n(e))||r();break;case"kritzel-icon":customElements.get(n(e))||c();break;case"kritzel-master-detail":customElements.get(n(e))||d();break;case"kritzel-numeric-input":customElements.get(n(e))||h();break;case"kritzel-slide-toggle":customElements.get(n(e))||g()}}))}export{w as K,y as d}
@@ -2027,6 +2027,8 @@ const KritzelEditor = class {
2027
2027
  }
2028
2028
  ]
2029
2029
  };
2030
+ /** Whether the editor is in a loading state. When true, a loading overlay is displayed. */
2031
+ isLoading = false;
2030
2032
  /** Optional unique identifier for namespacing storage keys across multiple editor instances. */
2031
2033
  editorId;
2032
2034
  /** Optional workspace ID to set as active. If provided, the editor will automatically activate the workspace with this ID. */
@@ -2066,9 +2068,10 @@ const KritzelEditor = class {
2066
2068
  }
2067
2069
  }
2068
2070
  onWorkspacesChange(newWorkspaces) {
2069
- if (this.activeWorkspace) {
2070
- const updatedActiveWorkspace = newWorkspaces.find(ws => ws.id === this.activeWorkspace.id);
2071
- if (updatedActiveWorkspace && updatedActiveWorkspace !== this.activeWorkspace) {
2071
+ const activeWorkspace = this.activeWorkspace;
2072
+ if (activeWorkspace) {
2073
+ const updatedActiveWorkspace = newWorkspaces.find(ws => ws.id === activeWorkspace.id);
2074
+ if (updatedActiveWorkspace && updatedActiveWorkspace !== activeWorkspace) {
2072
2075
  this.activeWorkspace = updatedActiveWorkspace;
2073
2076
  }
2074
2077
  }
@@ -2295,7 +2298,7 @@ const KritzelEditor = class {
2295
2298
  await customElements.whenDefined('kritzel-workspace-manager');
2296
2299
  await customElements.whenDefined('kritzel-controls');
2297
2300
  await customElements.whenDefined('kritzel-engine');
2298
- if (!this.isEngineReady || !this.isControlsReady || !this.isWorkspaceManagerReady) {
2301
+ if (!this.isEngineReady || !this.isControlsReady || !this.isWorkspaceManagerReady || !this.activeWorkspace) {
2299
2302
  return;
2300
2303
  }
2301
2304
  const { id, name, isPublic, createdAt, updatedAt } = this.activeWorkspace;
@@ -2314,6 +2317,9 @@ const KritzelEditor = class {
2314
2317
  }
2315
2318
  async onEngineReady(event) {
2316
2319
  this.isEngineReady = true;
2320
+ if (!event.detail.activeWorkspace) {
2321
+ return;
2322
+ }
2317
2323
  this.activeWorkspace = event.detail.activeWorkspace;
2318
2324
  this.workspaces = event.detail.workspaces;
2319
2325
  this.currentIsPublic = await this.engineRef.getIsPublic();
@@ -2396,7 +2402,7 @@ const KritzelEditor = class {
2396
2402
  icon: 'upload',
2397
2403
  action: async () => {
2398
2404
  const preview = await this.engineRef.getScreenshot('png');
2399
- this.exportRef.open(preview);
2405
+ this.exportRef.open(preview ?? undefined);
2400
2406
  },
2401
2407
  },
2402
2408
  {
@@ -2427,7 +2433,7 @@ const KritzelEditor = class {
2427
2433
  activeWorkspace.isPublic = isPublic;
2428
2434
  await this.engineRef.updateWorkspace(activeWorkspace);
2429
2435
  this.activeWorkspace = activeWorkspace.clone();
2430
- this.isPublicChange.emit({ isPublic, workspaceId: this.activeWorkspace?.id });
2436
+ this.isPublicChange.emit({ isPublic, workspaceId: activeWorkspace.id });
2431
2437
  };
2432
2438
  /**
2433
2439
  * Updates the currentIsPublic state from the active workspace and emits the isPublicChange event.
@@ -2436,6 +2442,9 @@ const KritzelEditor = class {
2436
2442
  const isPublic = this.activeWorkspace?.isPublic ?? false;
2437
2443
  const workspaceId = this.activeWorkspace?.id;
2438
2444
  this.currentIsPublic = isPublic;
2445
+ if (!workspaceId) {
2446
+ return;
2447
+ }
2439
2448
  this.isPublicChange.emit({ isPublic, workspaceId });
2440
2449
  }
2441
2450
  handleProviderLogin = (event) => {
@@ -2540,7 +2549,31 @@ const KritzelEditor = class {
2540
2549
  const isLoggedIn = this.isLoggedIn;
2541
2550
  const shouldShowCurrentUser = isLoggedIn;
2542
2551
  const shouldShowLoginButton = !!this.loginConfig && !isLoggedIn;
2543
- return (h(Host, { key: '6dbc3a8c64dd097ba82e46341b3fb97cbd0194db' }, h("div", { key: '26ceb62f59ad830fd651a1712f57e5d711e7c6f4', class: "top-left-buttons" }, h("kritzel-workspace-manager", { key: 'afb4f5b87c5dc0a673444fb27930e43994df4e02', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-back-to-content", { key: 'f3c0f31841cb819917c3277852bc9b5ce291c09a', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), h("kritzel-engine", { key: '8a9e57132e6b74ec812ee516dc7f0d5fc6c8a2e1', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, debugInfo: this.debugInfo, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), h("kritzel-controls", { key: '6caadf512a0208fecdb18b6d68b17daa522161a3', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), h("div", { key: 'e27e5f3965be2fd15c83b91470ef87c4031dd7a2', class: "top-right-buttons" }, h("kritzel-settings", { key: '57f8e75287402aecbb7740d46dfa15839de2169f', ref: el => (this.settingsRef = el), shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), h("kritzel-export", { key: '5ccf176d4fe1221c5d7597bd1c8537cf3324d3ee', ref: el => (this.exportRef = el), workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), h("kritzel-active-users", { key: '44a334b808706e11163e89b91074ca4ea8ab4b18', users: this.activeUsers }), shouldShowCurrentUser && h("kritzel-current-user", { key: 'bcb3c966e630b1a8fc4ccd438fc8fbb11cd2b167', user: this.user }), shouldShowLoginButton && h("kritzel-button", { key: 'f1957e56257b7c565311e41b770579f7e2bb910d', onButtonClick: () => this.loginDialogRef?.open() }, "Sign in"), h("kritzel-more-menu", { key: 'd8c1d1b51cf87725d68aaf4457b88828986a40dc', items: this.moreMenuItems }), h("kritzel-share-dialog", { key: 'f5840e7f56cf6897ec28b0f28d9b204037bf3348', ref: el => (this.shareDialogRef = el), isPublic: this.currentIsPublic, workspaceId: this.activeWorkspace?.id, onToggleIsPublic: this.handleToggleIsPublic }), this.loginConfig && (h("kritzel-login-dialog", { key: 'cfdcc3d5e7a5e29b0a352f0d4423ae79195dbf69', ref: el => (this.loginDialogRef = el), providers: this.loginConfig.providers, dialogTitle: this.loginConfig.title, subtitle: this.loginConfig.subtitle, onProviderLogin: this.handleProviderLogin })))));
2552
+ return (h(Host, { key: '1e3c220506d14f276ca246365c2bda79110c6c35' }, h("div", { key: '154b45141b995f749adb52a11dc3363ab2989475', class: "top-left-buttons" }, h("kritzel-workspace-manager", { key: '22519269ea7227a1a7a05d2f282bbcd2466edf5d', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-back-to-content", { key: 'e89f0609dfd031cb040fd80a1f60ecb56d56734c', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), h("kritzel-engine", { key: '0b3acdf827d48c9589fb8170b49a602beb273684', ref: el => {
2553
+ if (el) {
2554
+ this.engineRef = el;
2555
+ }
2556
+ }, workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, isLoading: this.isLoading, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, debugInfo: this.debugInfo, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), h("kritzel-controls", { key: '324ba00f982938abc7a3f4dc47368f3b9bad665e', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => {
2557
+ if (el) {
2558
+ this.controlsRef = el;
2559
+ }
2560
+ }, controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState ?? undefined, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), h("div", { key: '0c4662e92cbe90a958f8704e6db0375915d9c634', class: "top-right-buttons" }, h("kritzel-settings", { key: 'e0422c1a02bc895bafd4b777d4d593afcfdf335b', ref: el => {
2561
+ if (el) {
2562
+ this.settingsRef = el;
2563
+ }
2564
+ }, shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), h("kritzel-export", { key: '72f59ec2eab76d753bb64475f199f0fa33e935d4', ref: el => {
2565
+ if (el) {
2566
+ this.exportRef = el;
2567
+ }
2568
+ }, workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), h("kritzel-active-users", { key: 'c60411370947fc408b5e9d7adade3e28210b8d47', users: this.activeUsers }), shouldShowCurrentUser && h("kritzel-current-user", { key: '4783940d3d4f9c2a7e8156c0713f29cb8b043125', user: this.user }), shouldShowLoginButton && h("kritzel-button", { key: 'bdb727d5641f8cda3711856086e1b9aa8533a5a6', onButtonClick: () => this.loginDialogRef?.open() }, "Sign in"), h("kritzel-more-menu", { key: '3afa57ea46636c92cc7232dfe22a27cace85766e', items: this.moreMenuItems }), h("kritzel-share-dialog", { key: '852f9980fa3b89ceb5b6d8bde1bdd5598d3dc6e4', ref: el => {
2569
+ if (el) {
2570
+ this.shareDialogRef = el;
2571
+ }
2572
+ }, isPublic: this.currentIsPublic, workspaceId: this.activeWorkspace?.id, onToggleIsPublic: this.handleToggleIsPublic }), this.loginConfig && (h("kritzel-login-dialog", { key: 'cdccbb7ef0b9932c0747545a18071f22e5683d8c', ref: el => {
2573
+ if (el) {
2574
+ this.loginDialogRef = el;
2575
+ }
2576
+ }, providers: this.loginConfig.providers, dialogTitle: this.loginConfig.title, subtitle: this.loginConfig.subtitle, onProviderLogin: this.handleProviderLogin })))));
2544
2577
  }
2545
2578
  static get watchers() { return {
2546
2579
  "isEngineReady": [{
@@ -20878,7 +20911,7 @@ class KritzelReviver {
20878
20911
  }
20879
20912
 
20880
20913
  const DEFAULT_ENGINE_CONFIG = {
20881
- activeWorkspace: null,
20914
+ activeWorkspace: undefined,
20882
20915
  activeTool: null,
20883
20916
  copiedObjects: null,
20884
20917
  objects: null,
@@ -20904,7 +20937,7 @@ const DEFAULT_ENGINE_CONFIG = {
20904
20937
  isDrawing: false,
20905
20938
  isErasing: false,
20906
20939
  isWriting: false,
20907
- isWorkspaceLoading: false,
20940
+ isLoading: false,
20908
20941
  isCtrlKeyPressed: false,
20909
20942
  isContextMenuVisible: false,
20910
20943
  contextMenuItems: [],
@@ -25484,7 +25517,7 @@ async function toPng(node, options = {}) {
25484
25517
  return canvas.toDataURL();
25485
25518
  }
25486
25519
 
25487
- const kritzelEngineCss = () => `:host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.workspace-loading-overlay{position:absolute;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background-color:var(--kritzel-loading-overlay-background, rgba(255, 255, 255, 0.6));color:var(--kritzel-loading-overlay-color, #333);font-size:1.25rem;pointer-events:all;animation:workspace-loading-fade-in var(--kritzel-loading-overlay-delay, 300ms) ease-out forwards;opacity:0}@keyframes workspace-loading-fade-in{to{opacity:1}}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}`;
25520
+ const kritzelEngineCss = () => `:host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.workspace-loading-overlay{position:absolute;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;gap:10px;background-color:var(--kritzel-loading-overlay-background, rgba(255, 255, 255, 0.6));color:var(--kritzel-loading-overlay-color, #333);font-family:var(--kritzel-font-family, sans-serif);font-size:1.25rem;pointer-events:all;animation:workspace-loading-fade-in 200ms ease-out var(--kritzel-loading-overlay-delay, 300ms) forwards;opacity:0}.workspace-loading-spinner{width:20px;height:20px;box-sizing:border-box;display:block;flex-shrink:0;border:2px solid var(--kritzel-loading-overlay-spinner-color, #cccccc);border-top-color:var(--kritzel-loading-overlay-spinner-active-color, #333333);border-radius:50%;animation:workspace-loading-spin 0.6s linear infinite}@keyframes workspace-loading-spin{to{transform:rotate(360deg)}}@keyframes workspace-loading-fade-in{to{opacity:1}}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}`;
25488
25521
 
25489
25522
  const KritzelEngine = class {
25490
25523
  get host() { return getElement(this); }
@@ -25603,6 +25636,11 @@ const KritzelEngine = class {
25603
25636
  }
25604
25637
  /** When false, wheel events will not trigger viewport pan/zoom. The event still propagates to parent elements. */
25605
25638
  wheelEnabled = true;
25639
+ /** External loading state. Combined with internal workspace-loading state to drive the overlay. */
25640
+ isLoading = false;
25641
+ onIsLoadingChange() {
25642
+ this.syncLoadingState();
25643
+ }
25606
25644
  /** Emitted when the engine has fully initialized and is ready for interaction. */
25607
25645
  isEngineReady;
25608
25646
  /** Emitted when the active drawing tool changes. */
@@ -25894,9 +25932,9 @@ const KritzelEngine = class {
25894
25932
  async hideContextMenu() {
25895
25933
  this.core.store.state.pointers.clear();
25896
25934
  this.core.store.state.isContextMenuVisible = false;
25897
- this.core.store.state.objects.remove(o => o instanceof KritzelSelectionBox);
25935
+ this.core.store.state.objects?.remove(o => o instanceof KritzelSelectionBox);
25898
25936
  this.core.store.setSelectionBox(null);
25899
- this.core.store.state.objects.clearLocalSelectionBox();
25937
+ this.core.store.state.objects?.clearLocalSelectionBox();
25900
25938
  this.core.store.state.isSelecting = false;
25901
25939
  this.core.store.state.isEnabled = true;
25902
25940
  this.core.rerender();
@@ -26025,8 +26063,12 @@ const KritzelEngine = class {
26025
26063
  * @returns The removed object.
26026
26064
  */
26027
26065
  async removeObject(object) {
26066
+ const objectsMap = this.core.store.state.objects;
26067
+ if (!objectsMap) {
26068
+ return null;
26069
+ }
26028
26070
  this.core.deselectAllObjects();
26029
- this.core.store.state.objects.remove(o => o.id === object.id);
26071
+ objectsMap.remove(o => o.id === object.id);
26030
26072
  this.core.rerender();
26031
26073
  this.emitObjectsRemoved([object]);
26032
26074
  return object;
@@ -26045,15 +26087,23 @@ const KritzelEngine = class {
26045
26087
  * @param objects - The objects to select.
26046
26088
  */
26047
26089
  async selectObjects(objects) {
26090
+ const selectionTool = KritzelToolRegistry.getTool('selection');
26091
+ if (!selectionTool) {
26092
+ return;
26093
+ }
26048
26094
  this.core.store.state.activeTool?.onDeactivate();
26049
- this.core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
26095
+ this.core.store.setState('activeTool', selectionTool);
26050
26096
  this.core.deselectAllObjects();
26051
26097
  this.core.selectObjects(objects);
26052
26098
  }
26053
26099
  /** Selects all objects currently visible in the viewport. Switches to the selection tool automatically. */
26054
26100
  async selectAllObjectsInViewport() {
26101
+ const selectionTool = KritzelToolRegistry.getTool('selection');
26102
+ if (!selectionTool) {
26103
+ return;
26104
+ }
26055
26105
  this.core.store.state.activeTool?.onDeactivate();
26056
- this.core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
26106
+ this.core.store.setState('activeTool', selectionTool);
26057
26107
  this.core.deselectAllObjects();
26058
26108
  this.core.selectAllObjectsInViewport();
26059
26109
  }
@@ -26211,6 +26261,10 @@ const KritzelEngine = class {
26211
26261
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
26212
26262
  const filename = `${activeWorkspaceName}-${timestamp}.png`;
26213
26263
  const dataUrl = await this.getScreenshot('png');
26264
+ if (!dataUrl) {
26265
+ console.error('Failed to export viewport as PNG: screenshot could not be generated');
26266
+ return;
26267
+ }
26214
26268
  const link = document.createElement('a');
26215
26269
  link.download = filename;
26216
26270
  link.href = dataUrl;
@@ -26228,6 +26282,10 @@ const KritzelEngine = class {
26228
26282
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
26229
26283
  const filename = `${activeWorkspaceName}-${timestamp}.svg`;
26230
26284
  const dataUrl = await this.getScreenshot('svg');
26285
+ if (!dataUrl) {
26286
+ console.error('Failed to export viewport as SVG: screenshot could not be generated');
26287
+ return;
26288
+ }
26231
26289
  const link = document.createElement('a');
26232
26290
  link.download = filename;
26233
26291
  link.href = dataUrl;
@@ -26351,6 +26409,9 @@ const KritzelEngine = class {
26351
26409
  */
26352
26410
  async exportAsJson() {
26353
26411
  const workspace = this.core.store.state.activeWorkspace;
26412
+ if (!workspace) {
26413
+ throw new Error('Cannot export workspace: no active workspace is loaded');
26414
+ }
26354
26415
  const serialized = workspace.serialize({ includeObjects: true });
26355
26416
  return JSON.stringify(serialized, null, 2);
26356
26417
  }
@@ -26423,7 +26484,11 @@ const KritzelEngine = class {
26423
26484
  if (data.version && data.version !== WORKSPACE_EXPORT_VERSION) {
26424
26485
  console.warn(`Workspace version mismatch: expected ${WORKSPACE_EXPORT_VERSION}, got ${data.version}`);
26425
26486
  }
26426
- const currentWorkspaceId = this.core.store.state.activeWorkspace.id;
26487
+ const activeWorkspace = this.core.store.state.activeWorkspace;
26488
+ if (!activeWorkspace) {
26489
+ throw new Error('Cannot load objects: no active workspace is loaded');
26490
+ }
26491
+ const currentWorkspaceId = activeWorkspace.id;
26427
26492
  let loadedCount = 0;
26428
26493
  // Revive and add objects to the current workspace
26429
26494
  if (data.objects && Array.isArray(data.objects)) {
@@ -26559,7 +26624,11 @@ const KritzelEngine = class {
26559
26624
  }
26560
26625
  /** Returns the currently active workspace. */
26561
26626
  async getActiveWorkspace() {
26562
- return this.core.store.state.activeWorkspace;
26627
+ const activeWorkspace = this.core.store.state.activeWorkspace;
26628
+ if (!activeWorkspace) {
26629
+ throw new Error('No active workspace is loaded');
26630
+ }
26631
+ return activeWorkspace;
26563
26632
  }
26564
26633
  /**
26565
26634
  * Gets whether the active workspace is publicly accessible.
@@ -26617,6 +26686,16 @@ const KritzelEngine = class {
26617
26686
  _workspaceInitializationTargetKey = null;
26618
26687
  _syncInitPromise = null;
26619
26688
  _syncConfigRevision = 0;
26689
+ _isWorkspaceLoading = false;
26690
+ _defaultUndoState = {
26691
+ canUndo: false,
26692
+ canRedo: false,
26693
+ undoStackSize: 0,
26694
+ redoStackSize: 0,
26695
+ };
26696
+ syncLoadingState() {
26697
+ this.core.store.state.isLoading = this._isWorkspaceLoading || this.isLoading;
26698
+ }
26620
26699
  get isSelecting() {
26621
26700
  return this.core.store.state.activeTool instanceof KritzelSelectionTool && this.core.store.state.isSelecting;
26622
26701
  }
@@ -26665,6 +26744,8 @@ const KritzelEngine = class {
26665
26744
  this.core.store.state.viewportBoundaryRight = this.viewportBoundaryRight;
26666
26745
  this.core.store.state.viewportBoundaryTop = this.viewportBoundaryTop;
26667
26746
  this.core.store.state.viewportBoundaryBottom = this.viewportBoundaryBottom;
26747
+ this._isWorkspaceLoading = true;
26748
+ this.syncLoadingState();
26668
26749
  }
26669
26750
  async componentDidLoad() {
26670
26751
  setTimeout(async () => {
@@ -26673,7 +26754,9 @@ const KritzelEngine = class {
26673
26754
  this.viewport = new KritzelViewport(this.core, this.host);
26674
26755
  // Initialize cursor manager with target element and shadow root
26675
26756
  this.core.cursorManager.setTargetElement(this.cursorTarget || document.body);
26676
- this.core.cursorManager.setShadowRoot(this.host.shadowRoot);
26757
+ if (this.host.shadowRoot) {
26758
+ this.core.cursorManager.setShadowRoot(this.host.shadowRoot);
26759
+ }
26677
26760
  // Initialize theme manager with kritzel-editor as target element
26678
26761
  const editorElement = this.host.closest('kritzel-editor');
26679
26762
  this.core.themeManager.setTargetElement(editorElement || this.host);
@@ -26796,7 +26879,8 @@ const KritzelEngine = class {
26796
26879
  await this._workspaceInitializationPromise;
26797
26880
  return;
26798
26881
  }
26799
- this.core.store.state.isWorkspaceLoading = true;
26882
+ this._isWorkspaceLoading = true;
26883
+ this.syncLoadingState();
26800
26884
  const initializationPromise = this.core.initializeWorkspace(workspace, options);
26801
26885
  this._workspaceInitializationPromise = initializationPromise;
26802
26886
  this._workspaceInitializationTargetKey = targetKey;
@@ -26808,12 +26892,23 @@ const KritzelEngine = class {
26808
26892
  this._workspaceInitializationPromise = null;
26809
26893
  this._workspaceInitializationTargetKey = null;
26810
26894
  }
26811
- this.core.store.state.isWorkspaceLoading = false;
26895
+ this._isWorkspaceLoading = false;
26896
+ this.syncLoadingState();
26812
26897
  }
26813
26898
  }
26814
26899
  emitObjectsChange() {
26900
+ const objectsMap = this.core.store.state.objects;
26901
+ if (!objectsMap) {
26902
+ this.objectsChange.emit([]);
26903
+ this.undoStateChange.emit(this._defaultUndoState);
26904
+ if (this._lastHadSelectionGroup) {
26905
+ this._lastHadSelectionGroup = false;
26906
+ this.objectsSelectionChange.emit();
26907
+ }
26908
+ return;
26909
+ }
26815
26910
  const objects = this.core.store.allObjects;
26816
- const undoState = this.core.store.state.objects.undoState;
26911
+ const undoState = objectsMap.undoState;
26817
26912
  const hasSelectionGroup = this.core.store.selectionGroup !== null;
26818
26913
  this.objectsChange.emit(objects);
26819
26914
  this.undoStateChange.emit(undoState);
@@ -26844,22 +26939,24 @@ const KritzelEngine = class {
26844
26939
  _handleActiveToolChange(activeTool) {
26845
26940
  if (!(activeTool instanceof KritzelSelectionTool)) {
26846
26941
  this.core.clearSelection();
26847
- this.core.store.state.objects.remove(o => o instanceof KritzelSelectionBox);
26942
+ this.core.store.state.objects?.remove(o => o instanceof KritzelSelectionBox);
26848
26943
  this.core.store.setSelectionBox(null);
26849
- this.core.store.state.objects.clearLocalSelectionBox();
26944
+ this.core.store.state.objects?.clearLocalSelectionBox();
26850
26945
  this.core.store.state.isSelecting = false;
26851
26946
  this.core.store.state.isResizeHandleSelected = false;
26852
26947
  this.core.store.state.isRotationHandleSelected = false;
26853
26948
  }
26854
26949
  this.core.store.state.skipContextMenu = false;
26855
- this.core.store.state.copiedObjects = null;
26856
- this.activeToolChange.emit(activeTool);
26950
+ this.core.store.state.copiedObjects = undefined;
26951
+ if (activeTool) {
26952
+ this.activeToolChange.emit(activeTool);
26953
+ }
26857
26954
  KritzelKeyboardHelper.forceHideKeyboard();
26858
26955
  this.core.rerender();
26859
26956
  }
26860
26957
  render() {
26861
26958
  if (!this.viewport) {
26862
- return null;
26959
+ return (h(Host, null, this.core.store.state.isLoading && (h("div", { class: "workspace-loading-overlay" }, h("span", { class: "workspace-loading-spinner" }), "Loading..."))));
26863
26960
  }
26864
26961
  const currentTheme = this.core.themeManager.getStoredTheme();
26865
26962
  const computedStyle = window.getComputedStyle(this.host);
@@ -26876,7 +26973,7 @@ const KritzelEngine = class {
26876
26973
  this.emitObjectsInViewportChange();
26877
26974
  }
26878
26975
  }
26879
- return (h(Host, null, this.core.store.state.isWorkspaceLoading && (h("div", { class: "workspace-loading-overlay" }, "Loading...")), this.core.store.state.debugInfo.showViewportInfo && (h("div", { class: "debug-panel" }, h("div", null, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), h("div", null, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), h("div", null, "TranslateX: ", this.core.store.state?.translateX), h("div", null, "TranslateY: ", this.core.store.state?.translateY), h("div", null, "ViewportWidth: ", this.core.store.state?.viewportWidth), h("div", null, "ViewportHeight: ", this.core.store.state?.viewportHeight), h("div", null, "PointerCount: ", this.core.store.state.pointers.size), h("div", null, "Scale: ", this.core.store.state?.scale), h("div", null, "ActiveTool: ", this.core.store.state?.activeTool?.name), h("div", null, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), h("div", null, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), h("div", null, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), h("div", null, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), h("div", null, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", null, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", null, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", null, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", null, "IsRotationHandleHovered: ", this.core.store.state.isRotationHandleHovered ? 'true' : 'false'), h("div", null, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), h("div", null, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), h("div", null, "IsPointerDown: ", this.core.store.isPointerDown ? 'true' : 'false'), h("div", null, "PointerX: ", this.core.store.state?.pointerX), h("div", null, "PointerY: ", this.core.store.state?.pointerY), h("div", null, "TotalObjects: ", this.core.store.totalObjectCount), h("div", null, "ObjectsInViewport: ", this.core.store.objectsInViewport.length), h("div", null, "SelectedObjects: ", this.core.store.selectionGroup?.objects.length || 0), h("div", null, "ViewportCenter: (", viewportCenterX.toFixed(2), ", ", viewportCenterY.toFixed(2), ")"))), h("div", { id: "origin", class: "origin", style: {
26976
+ return (h(Host, null, this.core.store.state.isLoading && (h("div", { class: "workspace-loading-overlay" }, h("span", { class: "workspace-loading-spinner" }), "Loading...")), this.core.store.state.debugInfo.showViewportInfo && (h("div", { class: "debug-panel" }, h("div", null, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), h("div", null, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), h("div", null, "TranslateX: ", this.core.store.state?.translateX), h("div", null, "TranslateY: ", this.core.store.state?.translateY), h("div", null, "ViewportWidth: ", this.core.store.state?.viewportWidth), h("div", null, "ViewportHeight: ", this.core.store.state?.viewportHeight), h("div", null, "PointerCount: ", this.core.store.state.pointers.size), h("div", null, "Scale: ", this.core.store.state?.scale), h("div", null, "ActiveTool: ", this.core.store.state?.activeTool?.name), h("div", null, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), h("div", null, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), h("div", null, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), h("div", null, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), h("div", null, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", null, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", null, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", null, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", null, "IsRotationHandleHovered: ", this.core.store.state.isRotationHandleHovered ? 'true' : 'false'), h("div", null, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), h("div", null, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), h("div", null, "IsPointerDown: ", this.core.store.isPointerDown ? 'true' : 'false'), h("div", null, "PointerX: ", this.core.store.state?.pointerX), h("div", null, "PointerY: ", this.core.store.state?.pointerY), h("div", null, "TotalObjects: ", this.core.store.totalObjectCount), h("div", null, "ObjectsInViewport: ", this.core.store.objectsInViewport.length), h("div", null, "SelectedObjects: ", this.core.store.selectionGroup?.objects.length || 0), h("div", null, "ViewportCenter: (", viewportCenterX.toFixed(2), ", ", viewportCenterY.toFixed(2), ")"))), h("div", { id: "origin", class: "origin", style: {
26880
26977
  transform: `matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`,
26881
26978
  } }, visibleObjects?.map(object => {
26882
26979
  return (h("div", { key: object.id, id: object.id, class: "object", style: {
@@ -26885,7 +26982,7 @@ const KritzelEngine = class {
26885
26982
  position: 'absolute',
26886
26983
  zIndex: object.zIndex.toString(),
26887
26984
  pointerEvents: this.core.store.state.isScaling ? 'none' : 'auto',
26888
- } }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
26985
+ } }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => el && object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
26889
26986
  height: object?.totalHeight + 'px',
26890
26987
  width: object?.totalWidth + 'px',
26891
26988
  left: '0',
@@ -26896,7 +26993,7 @@ const KritzelEngine = class {
26896
26993
  opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
26897
26994
  pointerEvents: object.markedForRemoval ? 'none' : 'auto',
26898
26995
  overflow: 'visible',
26899
- }, viewBox: object?.viewBox }, h("path", { d: object?.d, fill: KritzelColorHelper.resolveThemeColor(object.fill, currentTheme), stroke: KritzelColorHelper.resolveThemeColor(object?.stroke, currentTheme), "shape-rendering": object.isLowRes() ? 'optimizeSpeed' : 'auto' }))), KritzelClassHelper.isInstanceOf(object, 'KritzelLine') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
26996
+ }, viewBox: object?.viewBox }, h("path", { d: object?.d, fill: KritzelColorHelper.resolveThemeColor(object.fill, currentTheme), stroke: KritzelColorHelper.resolveThemeColor(object?.stroke, currentTheme), "shape-rendering": object.isLowRes() ? 'optimizeSpeed' : 'auto' }))), KritzelClassHelper.isInstanceOf(object, 'KritzelLine') && (h("svg", { ref: el => el && object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
26900
26997
  height: object?.totalHeight + 'px',
26901
26998
  width: object?.totalWidth + 'px',
26902
26999
  left: '0',
@@ -26907,7 +27004,7 @@ const KritzelEngine = class {
26907
27004
  opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
26908
27005
  pointerEvents: object.markedForRemoval ? 'none' : 'auto',
26909
27006
  overflow: 'visible',
26910
- }, viewBox: object?.viewBox }, (object.hasStartArrow || object.hasEndArrow) && (h("defs", null, object.hasStartArrow && (h("marker", { id: object.startMarkerId, markerWidth: object.getArrowSize('start'), markerHeight: object.getArrowSize('start'), refX: 0, refY: object.getArrowSize('start') / 2, orient: "auto-start-reverse", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.start?.style), fill: object.getArrowFill('start'), transform: `scale(${object.getArrowSize('start') / 10})` }))), object.hasEndArrow && (h("marker", { id: object.endMarkerId, markerWidth: object.getArrowSize('end'), markerHeight: object.getArrowSize('end'), refX: 0, refY: object.getArrowSize('end') / 2, orient: "auto", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.end?.style), fill: object.getArrowFill('end'), transform: `scale(${object.getArrowSize('end') / 10})` }))))), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: "transparent", "stroke-width": Math.max(object?.strokeWidth || 0, 10), "stroke-linecap": "round" }), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: KritzelColorHelper.resolveThemeColor(object?.stroke, currentTheme), "stroke-width": object?.strokeWidth, "stroke-linecap": "round", "marker-start": object.hasStartArrow ? `url(#${object.startMarkerId})` : undefined, "marker-end": object.hasEndArrow ? `url(#${object.endMarkerId})` : undefined }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => object.mount(el), src: object.src, style: {
27007
+ }, viewBox: object?.viewBox }, (object.hasStartArrow || object.hasEndArrow) && (h("defs", null, object.hasStartArrow && (h("marker", { id: object.startMarkerId, markerWidth: object.getArrowSize('start'), markerHeight: object.getArrowSize('start'), refX: 0, refY: object.getArrowSize('start') / 2, orient: "auto-start-reverse", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.start?.style), fill: object.getArrowFill('start'), transform: `scale(${object.getArrowSize('start') / 10})` }))), object.hasEndArrow && (h("marker", { id: object.endMarkerId, markerWidth: object.getArrowSize('end'), markerHeight: object.getArrowSize('end'), refX: 0, refY: object.getArrowSize('end') / 2, orient: "auto", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.end?.style), fill: object.getArrowFill('end'), transform: `scale(${object.getArrowSize('end') / 10})` }))))), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: "transparent", "stroke-width": Math.max(object?.strokeWidth || 0, 10), "stroke-linecap": "round" }), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: KritzelColorHelper.resolveThemeColor(object?.stroke, currentTheme), "stroke-width": object?.strokeWidth, "stroke-linecap": "round", "marker-start": object.hasStartArrow ? `url(#${object.startMarkerId})` : undefined, "marker-end": object.hasEndArrow ? `url(#${object.endMarkerId})` : undefined }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => el && object.mount(el), src: object.src, style: {
26911
27008
  position: 'absolute',
26912
27009
  left: '0',
26913
27010
  top: '0',
@@ -26925,7 +27022,7 @@ const KritzelEngine = class {
26925
27022
  overflow: 'visible',
26926
27023
  userSelect: 'none',
26927
27024
  imageRendering: this.core.store.state.isScaling || this.core.store.state.isPanning ? 'pixelated' : 'auto',
26928
- }, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => object.mount(el), style: {
27025
+ }, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => el && object.mount(el), style: {
26929
27026
  position: 'absolute',
26930
27027
  left: '0',
26931
27028
  top: '0',
@@ -26942,7 +27039,7 @@ const KritzelEngine = class {
26942
27039
  padding: object.padding + 'px',
26943
27040
  overflow: 'hidden',
26944
27041
  display: 'block',
26945
- } })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && !this.core.displaySelectionLineUI(object) && (h("div", { ref: el => object.mount(el), style: {
27042
+ } })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && !this.core.displaySelectionLineUI(object) && (h("div", { ref: el => el && object.mount(el), style: {
26946
27043
  position: 'absolute',
26947
27044
  left: '0',
26948
27045
  top: '0',
@@ -26952,7 +27049,7 @@ const KritzelEngine = class {
26952
27049
  transformOrigin: object.rotationDegrees !== 0 ? `${object.totalWidth / 2}px ${object.totalHeight / 2}px` : undefined,
26953
27050
  opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
26954
27051
  pointerEvents: object.markedForRemoval ? 'none' : 'auto',
26955
- } })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionBox') && (h("div", { ref: el => object.mount(el), style: {
27052
+ } })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionBox') && (h("div", { ref: el => el && object.mount(el), style: {
26956
27053
  position: 'absolute',
26957
27054
  left: '0',
26958
27055
  top: '0',
@@ -26976,7 +27073,7 @@ const KritzelEngine = class {
26976
27073
  transformOrigin: object.rotationDegrees !== 0 ? `${object.totalWidth / 2}px ${object.totalHeight / 2}px` : undefined,
26977
27074
  opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
26978
27075
  pointerEvents: object.markedForRemoval ? 'none' : 'auto',
26979
- } }, h("div", { id: "text-object", ref: el => object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
27076
+ } }, h("div", { id: "text-object", ref: el => el && object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
26980
27077
  minWidth: object.initialWidth + 'px',
26981
27078
  minHeight: object.initialHeight + 'px',
26982
27079
  maxWidth: '500px',
@@ -26986,7 +27083,7 @@ const KritzelEngine = class {
26986
27083
  transform: `scale(${object.scaleFactor})`,
26987
27084
  backgroundColor: KritzelColorHelper.resolveThemeColor(object.backgroundColor, currentTheme),
26988
27085
  overflow: 'visible',
26989
- } }))), KritzelClassHelper.isInstanceOf(object, 'KritzelShape') && (h("div", { ref: el => object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
27086
+ } }))), KritzelClassHelper.isInstanceOf(object, 'KritzelShape') && (h("div", { ref: el => el && object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
26990
27087
  position: 'absolute',
26991
27088
  left: '0',
26992
27089
  top: '0',
@@ -27005,7 +27102,7 @@ const KritzelEngine = class {
27005
27102
  height: '100%',
27006
27103
  overflow: 'visible',
27007
27104
  pointerEvents: 'none',
27008
- }, viewBox: object.viewBox, preserveAspectRatio: "none" }, h("path", { d: object.getSvgPath(), fill: KritzelColorHelper.resolveThemeColor(object.fillColor, currentTheme), stroke: KritzelColorHelper.resolveThemeColor(object.strokeColor, currentTheme), "stroke-width": object.strokeWidth })), h("div", { ref: el => object.mountTextEditor(el), style: {
27105
+ }, viewBox: object.viewBox, preserveAspectRatio: "none" }, h("path", { d: object.getSvgPath(), fill: KritzelColorHelper.resolveThemeColor(object.fillColor, currentTheme), stroke: KritzelColorHelper.resolveThemeColor(object.strokeColor, currentTheme), "stroke-width": object.strokeWidth })), h("div", { ref: el => el && object.mountTextEditor(el), style: {
27009
27106
  position: 'absolute',
27010
27107
  top: '0',
27011
27108
  left: '0',
@@ -27255,16 +27352,18 @@ const KritzelEngine = class {
27255
27352
  stroke: 'var(--kritzel-snap-indicator-stroke, #007bff)',
27256
27353
  strokeWidth: data.indicatorStrokeWidth,
27257
27354
  } }))));
27258
- })()), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.selectionGroup?.objects || [], style: {
27355
+ })()), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { class: "context-menu", ref: el => (this.contextMenuElement = el ?? null), items: this.core.store.state.contextMenuItems, objects: this.core.store.selectionGroup?.objects || [], style: {
27259
27356
  position: 'fixed',
27260
27357
  left: `${this.core.store.state.contextMenuX}px`,
27261
27358
  top: `${this.core.store.state.contextMenuY}px`,
27262
27359
  zIndex: '10002',
27263
27360
  }, onActionSelected: event => {
27264
- event.detail.action({
27265
- x: (-this.core.store.state.translateX + this.core.store.state.contextMenuX) / this.core.store.state.scale,
27266
- y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
27267
- }, this.core.store.selectionGroup?.objects);
27361
+ if (event.detail.action) {
27362
+ event.detail.action({
27363
+ x: (-this.core.store.state.translateX + this.core.store.state.contextMenuX) / this.core.store.state.scale,
27364
+ y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
27365
+ }, this.core.store.selectionGroup?.objects || []);
27366
+ }
27268
27367
  this.hideContextMenu();
27269
27368
  }, onClose: () => this.hideContextMenu() })), this.core.store.state.objects?.hasAwareness && h("kritzel-awareness-cursors", { core: this.core }), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { core: this.core })));
27270
27369
  }
@@ -27310,6 +27409,9 @@ const KritzelEngine = class {
27310
27409
  }],
27311
27410
  "debugInfo": [{
27312
27411
  "onDebugInfoChange": 0
27412
+ }],
27413
+ "isLoading": [{
27414
+ "onIsLoadingChange": 0
27313
27415
  }]
27314
27416
  }; }
27315
27417
  };
@@ -28537,7 +28639,7 @@ const KritzelPortal = class {
28537
28639
  * This file is auto-generated by the version bump scripts.
28538
28640
  * Do not modify manually.
28539
28641
  */
28540
- const KRITZEL_VERSION = '0.1.78';
28642
+ const KRITZEL_VERSION = '0.1.79';
28541
28643
 
28542
28644
  const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
28543
28645