@rettangoli/ui 0.1.24 → 0.1.25

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.
@@ -769,7 +769,7 @@ var rettangoli=(()=>{function d(s,...t){let i="";return s.forEach((n,o)=>{i+=n+(
769
769
  }
770
770
  ${f}
771
771
  ${g}
772
- `))}constructor(){super(),s.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"closed"}),this.shadow.adoptedStyleSheets=[s.styleSheet],this._styles={default:{},sm:{},md:{},lg:{},xl:{}},this._lastStyleString="",this._textareaElement=document.createElement("textarea"),this._textareaElement.setAttribute("type","text"),this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._textareaElement),this._textareaElement.addEventListener("input",this._onChange)}_onChange=t=>{this.dispatchEvent(new CustomEvent("textarea-change",{detail:{value:this._textareaElement.value}}))};static get observedAttributes(){return["key","type","placeholder","disabled","value","cols","rows","ellipsis",...y([...v,"wh","w","h","hide","show","op","z"])]}get value(){return this._textareaElement.value}set value(t){this._textareaElement.value=t}connectedCallback(){this._updateTextareaAttributes()}attributeChangedCallback(t,i,n){if(t==="value"&&requestAnimationFrame(()=>{let e=this.getAttribute("value");this._textareaElement.value=e??""}),t==="placeholder"&&requestAnimationFrame(()=>{let e=this.getAttribute("placeholder");e===void 0||e==="null"?this._textareaElement.removeAttribute("placeholder"):this._textareaElement.setAttribute("placeholder",e??"")}),["cols","rows","disabled"].includes(t)){this._updateTextareaAttributes();return}this._styles={default:{},sm:{},md:{},lg:{},xl:{}},["default","sm","md","lg","xl"].forEach(e=>{let l=b=>`${e==="default"?"":`${e}-`}${b}`,a=this.getAttribute(l("wh")),r=u(a===null?this.getAttribute(l("w")):a),h=u(a===null?this.getAttribute(l("h")):a),p=this.getAttribute(l("op")),m=this.getAttribute(l("z"));m!==null&&(this._styles[e]["z-index"]=m),p!==null&&(this._styles[e].opacity=p),r==="f"?this._styles[e].width="var(--width-stretch)":r!==void 0&&(this._styles[e].width=r,this._styles[e]["min-width"]=r,this._styles[e]["max-width"]=r),h==="f"?this._styles[e].height="100%":h!==void 0&&(this._styles[e].height=h,this._styles[e]["min-height"]=h,this._styles[e]["max-height"]=h),this.hasAttribute(l("hide"))&&(this._styles[e].display="none !important"),this.hasAttribute(l("show"))&&(this._styles[e].display="block !important")});let o=_(this._styles,"textarea");o!==this._lastStyleString&&(this._styleElement.textContent=o,this._lastStyleString=o)}_updateTextareaAttributes(){let t=this.getAttribute("cols"),i=this.getAttribute("rows"),n=this.hasAttribute("disabled");t!==null?this._textareaElement.setAttribute("cols",t):this._textareaElement.removeAttribute("cols"),i!==null?this._textareaElement.setAttribute("rows",i):this._textareaElement.removeAttribute("rows"),n?this._textareaElement.setAttribute("disabled",""):this._textareaElement.removeAttribute("disabled")}},lt=({render:s,html:t})=>B;var H=class s extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){s.styleSheet||(s.styleSheet=new CSSStyleSheet,s.styleSheet.replaceSync(d`
772
+ `))}constructor(){super(),s.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"closed"}),this.shadow.adoptedStyleSheets=[s.styleSheet],this._styles={default:{},sm:{},md:{},lg:{},xl:{}},this._lastStyleString="",this._textareaElement=document.createElement("textarea"),this._textareaElement.setAttribute("type","text"),this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._textareaElement),this._textareaElement.addEventListener("input",this._onChange)}_onChange=t=>{this.dispatchEvent(new CustomEvent("textarea-change",{detail:{value:this._textareaElement.value}}))};static get observedAttributes(){return["key","type","placeholder","disabled","value","cols","rows","ellipsis",...y([...v,"wh","w","h","hide","show","op","z"])]}get value(){return this._textareaElement.value}set value(t){this._textareaElement.value=t}connectedCallback(){this._updateTextareaAttributes()}focus(){this._textareaElement&&this._textareaElement.focus()}select(){this._textareaElement&&this._textareaElement.select()}attributeChangedCallback(t,i,n){if(t==="value"&&requestAnimationFrame(()=>{let e=this.getAttribute("value");this._textareaElement.value=e??""}),t==="placeholder"&&requestAnimationFrame(()=>{let e=this.getAttribute("placeholder");e===void 0||e==="null"?this._textareaElement.removeAttribute("placeholder"):this._textareaElement.setAttribute("placeholder",e??"")}),["cols","rows","disabled"].includes(t)){this._updateTextareaAttributes();return}this._styles={default:{},sm:{},md:{},lg:{},xl:{}},["default","sm","md","lg","xl"].forEach(e=>{let l=b=>`${e==="default"?"":`${e}-`}${b}`,a=this.getAttribute(l("wh")),r=u(a===null?this.getAttribute(l("w")):a),h=u(a===null?this.getAttribute(l("h")):a),p=this.getAttribute(l("op")),m=this.getAttribute(l("z"));m!==null&&(this._styles[e]["z-index"]=m),p!==null&&(this._styles[e].opacity=p),r==="f"?this._styles[e].width="var(--width-stretch)":r!==void 0&&(this._styles[e].width=r,this._styles[e]["min-width"]=r,this._styles[e]["max-width"]=r),h==="f"?this._styles[e].height="100%":h!==void 0&&(this._styles[e].height=h,this._styles[e]["min-height"]=h,this._styles[e]["max-height"]=h),this.hasAttribute(l("hide"))&&(this._styles[e].display="none !important"),this.hasAttribute(l("show"))&&(this._styles[e].display="block !important")});let o=_(this._styles,"textarea");o!==this._lastStyleString&&(this._styleElement.textContent=o,this._lastStyleString=o)}_updateTextareaAttributes(){let t=this.getAttribute("cols"),i=this.getAttribute("rows"),n=this.hasAttribute("disabled");t!==null?this._textareaElement.setAttribute("cols",t):this._textareaElement.removeAttribute("cols"),i!==null?this._textareaElement.setAttribute("rows",i):this._textareaElement.removeAttribute("rows"),n?this._textareaElement.setAttribute("disabled",""):this._textareaElement.removeAttribute("disabled")}},lt=({render:s,html:t})=>B;var H=class s extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){s.styleSheet||(s.styleSheet=new CSSStyleSheet,s.styleSheet.replaceSync(d`
773
773
  :host {
774
774
  display: contents;
775
775
  }
@@ -769,7 +769,7 @@ var rettangoli=(()=>{var ni=Object.defineProperty;var P=(e,t)=>{for(var r in t)n
769
769
  }
770
770
  ${q}
771
771
  ${J}
772
- `))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"closed"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._styles={default:{},sm:{},md:{},lg:{},xl:{}},this._lastStyleString="",this._textareaElement=document.createElement("textarea"),this._textareaElement.setAttribute("type","text"),this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._textareaElement),this._textareaElement.addEventListener("input",this._onChange)}_onChange=t=>{this.dispatchEvent(new CustomEvent("textarea-change",{detail:{value:this._textareaElement.value}}))};static get observedAttributes(){return["key","type","placeholder","disabled","value","cols","rows","ellipsis",...ee([...Z,"wh","w","h","hide","show","op","z"])]}get value(){return this._textareaElement.value}set value(t){this._textareaElement.value=t}connectedCallback(){this._updateTextareaAttributes()}attributeChangedCallback(t,r,s){if(t==="value"&&requestAnimationFrame(()=>{let i=this.getAttribute("value");this._textareaElement.value=i??""}),t==="placeholder"&&requestAnimationFrame(()=>{let i=this.getAttribute("placeholder");i===void 0||i==="null"?this._textareaElement.removeAttribute("placeholder"):this._textareaElement.setAttribute("placeholder",i??"")}),["cols","rows","disabled"].includes(t)){this._updateTextareaAttributes();return}this._styles={default:{},sm:{},md:{},lg:{},xl:{}},["default","sm","md","lg","xl"].forEach(i=>{let a=h=>`${i==="default"?"":`${i}-`}${h}`,l=this.getAttribute(a("wh")),p=j(l===null?this.getAttribute(a("w")):l),o=j(l===null?this.getAttribute(a("h")):l),c=this.getAttribute(a("op")),u=this.getAttribute(a("z"));u!==null&&(this._styles[i]["z-index"]=u),c!==null&&(this._styles[i].opacity=c),p==="f"?this._styles[i].width="var(--width-stretch)":p!==void 0&&(this._styles[i].width=p,this._styles[i]["min-width"]=p,this._styles[i]["max-width"]=p),o==="f"?this._styles[i].height="100%":o!==void 0&&(this._styles[i].height=o,this._styles[i]["min-height"]=o,this._styles[i]["max-height"]=o),this.hasAttribute(a("hide"))&&(this._styles[i].display="none !important"),this.hasAttribute(a("show"))&&(this._styles[i].display="block !important")});let n=te(this._styles,"textarea");n!==this._lastStyleString&&(this._styleElement.textContent=n,this._lastStyleString=n)}_updateTextareaAttributes(){let t=this.getAttribute("cols"),r=this.getAttribute("rows"),s=this.hasAttribute("disabled");t!==null?this._textareaElement.setAttribute("cols",t):this._textareaElement.removeAttribute("cols"),r!==null?this._textareaElement.setAttribute("rows",r):this._textareaElement.removeAttribute("rows"),s?this._textareaElement.setAttribute("disabled",""):this._textareaElement.removeAttribute("disabled")}},Ir=({render:e,html:t})=>ct;var ut=class e extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){e.styleSheet||(e.styleSheet=new CSSStyleSheet,e.styleSheet.replaceSync(L`
772
+ `))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"closed"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._styles={default:{},sm:{},md:{},lg:{},xl:{}},this._lastStyleString="",this._textareaElement=document.createElement("textarea"),this._textareaElement.setAttribute("type","text"),this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._textareaElement),this._textareaElement.addEventListener("input",this._onChange)}_onChange=t=>{this.dispatchEvent(new CustomEvent("textarea-change",{detail:{value:this._textareaElement.value}}))};static get observedAttributes(){return["key","type","placeholder","disabled","value","cols","rows","ellipsis",...ee([...Z,"wh","w","h","hide","show","op","z"])]}get value(){return this._textareaElement.value}set value(t){this._textareaElement.value=t}connectedCallback(){this._updateTextareaAttributes()}focus(){this._textareaElement&&this._textareaElement.focus()}select(){this._textareaElement&&this._textareaElement.select()}attributeChangedCallback(t,r,s){if(t==="value"&&requestAnimationFrame(()=>{let i=this.getAttribute("value");this._textareaElement.value=i??""}),t==="placeholder"&&requestAnimationFrame(()=>{let i=this.getAttribute("placeholder");i===void 0||i==="null"?this._textareaElement.removeAttribute("placeholder"):this._textareaElement.setAttribute("placeholder",i??"")}),["cols","rows","disabled"].includes(t)){this._updateTextareaAttributes();return}this._styles={default:{},sm:{},md:{},lg:{},xl:{}},["default","sm","md","lg","xl"].forEach(i=>{let a=h=>`${i==="default"?"":`${i}-`}${h}`,l=this.getAttribute(a("wh")),p=j(l===null?this.getAttribute(a("w")):l),o=j(l===null?this.getAttribute(a("h")):l),c=this.getAttribute(a("op")),u=this.getAttribute(a("z"));u!==null&&(this._styles[i]["z-index"]=u),c!==null&&(this._styles[i].opacity=c),p==="f"?this._styles[i].width="var(--width-stretch)":p!==void 0&&(this._styles[i].width=p,this._styles[i]["min-width"]=p,this._styles[i]["max-width"]=p),o==="f"?this._styles[i].height="100%":o!==void 0&&(this._styles[i].height=o,this._styles[i]["min-height"]=o,this._styles[i]["max-height"]=o),this.hasAttribute(a("hide"))&&(this._styles[i].display="none !important"),this.hasAttribute(a("show"))&&(this._styles[i].display="block !important")});let n=te(this._styles,"textarea");n!==this._lastStyleString&&(this._styleElement.textContent=n,this._lastStyleString=n)}_updateTextareaAttributes(){let t=this.getAttribute("cols"),r=this.getAttribute("rows"),s=this.hasAttribute("disabled");t!==null?this._textareaElement.setAttribute("cols",t):this._textareaElement.removeAttribute("cols"),r!==null?this._textareaElement.setAttribute("rows",r):this._textareaElement.removeAttribute("rows"),s?this._textareaElement.setAttribute("disabled",""):this._textareaElement.removeAttribute("disabled")}},Ir=({render:e,html:t})=>ct;var ut=class e extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){e.styleSheet||(e.styleSheet=new CSSStyleSheet,e.styleSheet.replaceSync(L`
773
773
  :host {
774
774
  display: contents;
775
775
  }
@@ -971,7 +971,7 @@ var rettangoli=(()=>{var ni=Object.defineProperty;var P=(e,t)=>{for(var r in t)n
971
971
  min-width: 200px;
972
972
  max-width: 400px;
973
973
  }
974
- `))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._dialogElement=document.createElement("dialog"),this.shadow.appendChild(this._dialogElement),this._dialogElement.addEventListener("click",t=>{t.stopPropagation();let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._dialogElement.addEventListener("contextmenu",t=>{let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}})))}),this._dialogElement.addEventListener("cancel",t=>{t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._popoverContainer=document.createElement("div"),this._popoverContainer.className="popover-container",this._dialogElement.appendChild(this._popoverContainer),this._slotElement=null,this._isOpen=!1}static get observedAttributes(){return["open","x","y","placement"]}connectedCallback(){this.hasAttribute("open")&&this._show()}disconnectedCallback(){this._isOpen&&this._dialogElement.open&&this._dialogElement.close()}attributeChangedCallback(t,r,s){t==="open"?s!==null&&!this._isOpen?this.isConnected&&this._show():s===null&&this._isOpen&&this._hide():(t==="x"||t==="y"||t==="placement")&&this._isOpen&&this._updatePosition()}_show(){this._isOpen||(this._slotElement||(this._slotElement=document.createElement("slot"),this._slotElement.setAttribute("name","content"),this._popoverContainer.appendChild(this._slotElement)),this._isOpen=!0,this._dialogElement.open||setTimeout(()=>{this._dialogElement&&!this._dialogElement.open&&(this.hasAttribute("no-overlay")?this._dialogElement.show():this._dialogElement.showModal())},0),requestAnimationFrame(()=>{this._updatePosition()}))}_hide(){this._isOpen&&(this._isOpen=!1,this._dialogElement.open&&this._dialogElement.close(),this._slotElement&&(this._popoverContainer.removeChild(this._slotElement),this._slotElement=null))}_updatePosition(){let t=parseFloat(this.getAttribute("x")||"0"),r=parseFloat(this.getAttribute("y")||"0"),s=this.getAttribute("placement")||"bottom-start";this.removeAttribute("positioned"),requestAnimationFrame(()=>{let n=this._popoverContainer.getBoundingClientRect(),{left:i,top:a}=this._calculatePosition(t,r,n.width,n.height,s);this._popoverContainer.style.left=`${i}px`,this._popoverContainer.style.top=`${a}px`,requestAnimationFrame(()=>{this.setAttribute("positioned","")})})}_calculatePosition(t,r,s,n,i){let l=t,p=r;switch(i){case"top":l=t-s/2,p=r-n-8;break;case"top-start":l=t,p=r-n-8;break;case"top-end":l=t-s,p=r-n-8;break;case"right":l=t+8,p=r-n/2;break;case"right-start":l=t+8,p=r;break;case"right-end":l=t+8,p=r-n;break;case"bottom":l=t-s/2,p=r+8;break;case"bottom-start":l=t,p=r+8;break;case"bottom-end":l=t-s,p=r+8;break;case"left":l=t-s-8,p=r-n/2;break;case"left-start":l=t-s-8,p=r;break;case"left-end":l=t-s-8,p=r-n;break}let o=8;return l=Math.max(o,Math.min(l,window.innerWidth-s-o)),p=Math.max(o,Math.min(p,window.innerHeight-n-o)),{left:l,top:p}}get popover(){return this._popoverContainer}},Rr=({render:e,html:t})=>ft;var yt={};P(yt,{handleClickItem:()=>mi});var mi=(e,t)=>{let{dispatchEvent:r}=e,n=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:n}}))};var mt={};P(mt,{createInitialState:()=>gi,selectViewData:()=>wi});var gi=()=>Object.freeze({}),vi=["id","class","style","slot"],bi=e=>Object.entries(e).filter(([t])=>!vi.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),wi=({props:e,attrs:t})=>{let r=bi(t),s=e.items||[],n=e.separator||"breadcrumb-arrow",i=[];return s.forEach((a,l)=>{i.push(a),l<s.length-1&&i.push({isSeparator:!0})}),{containerAttrString:r,items:i,separator:n}};var Nr={elementName:"rtgl-breadcrumb",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string",default:"breadcrumb-arrow"}}},refs:{"item-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{item:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}},index:{type:"number"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md p=sm ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.isSeparator",value:{type:6,conditions:[{type:1,path:"item.isSeparator"},{type:1,path:"item.id"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${separator} c=mu-fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"separator"}," c=mu-fg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} data-id=${item.id} cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md p=sm ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var gt={};P(gt,{handleClickMenuItem:()=>xi,handleClosePopover:()=>_i});var _i=(e,t)=>{let{dispatchEvent:r}=e;r(new CustomEvent("close"))},xi=(e,t)=>{let{dispatchEvent:r,props:s}=e,n=t._event,i=parseInt(n.currentTarget.id.replace("option-","")),a=s.items[i];r(new CustomEvent("click-item",{detail:{index:i,item:a}}))};var vt={};P(vt,{createInitialState:()=>Ai,selectViewData:()=>Ei});var Ai=()=>Object.freeze({}),Ei=({props:e,attrs:t})=>({items:e.items||[],open:!!t.open,x:t.x,y:t.y,placement:t.placement});var Pr={elementName:"rtgl-dropdown-menu",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},type:{type:"string",enum:["label","item","separator"]}}}}}},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"}}},refs:{popover:{eventListeners:{close:{handler:"handleClosePopover"}}},"option-*":{eventListeners:{click:{handler:"handleClickMenuItem"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 sv g=xs slot=content bgc=background br=md",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.type == 'label'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"label"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"item"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"separator"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f ph=lg pv=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=1 ph=lg mv=md bgc=bo",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}]}}],fast:!1}],fast:!1}};var bt={};P(bt,{handleActionClick:()=>Ci,handleAfterMount:()=>$i,handleBeforeMount:()=>ki,handleColorPickerChange:()=>Ti,handleImageClick:()=>Ni,handleInputChange:()=>Ii,handleOnUpdate:()=>Si,handleSelectAddOption:()=>Vi,handleSelectChange:()=>Oi,handleSliderChange:()=>Li,handleSliderInputChange:()=>Ri,handleTooltipMouseEnter:()=>Di,handleTooltipMouseLeave:()=>ji,handleWaveformClick:()=>Pi});var Vr=({form:e,defaultValues:t={},refs:r})=>{let{fields:s=[]}=e;s.forEach(n=>{let i=r[`field-${n.name}`]?.elm;if(i){if(["input-textarea","inputText","input-text","input-number","colorPicker","slider","slider-input","popover-input"].includes(n.inputType)){let a=t[n.name];a==null?i.removeAttribute("value"):i.setAttribute("value",a)}["inputText","input-text","input-textarea"].includes(n.inputType)&&n.placeholder&&i.getAttribute("placeholder")!==n.placeholder&&(n.placeholder===void 0||n.placeholder===null?i.removeAttribute("placeholder"):i.setAttribute("placeholder",n.placeholder))}})},ki=e=>{let{store:t,props:r}=e;t.setFormValues(r.defaultValues)},$i=e=>{let{props:t,getRefIds:r,render:s}=e,{form:n={},defaultValues:i}=t,a=r();Vr({form:n,defaultValues:i,refs:a}),s()},Si=(e,t)=>{let{oldAttrs:r,newAttrs:s,newProps:n}=t,{store:i,render:a,getRefIds:l}=e,{form:p={},defaultValues:o}=n;if(r?.key!==s?.key){let c=l();Vr({form:p,defaultValues:o,refs:c}),i.setFormValues(o),a();return}a()},Oe=(e,t,r,s)=>{s(new CustomEvent("form-change",{detail:{name:e,fieldValue:t,formValues:r}}))},Ci=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event.currentTarget.id.replace("action-","");s(new CustomEvent("action-click",{detail:{actionId:i,formValues:r.selectFormValues()}}))},Ii=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");if(a&&i.detail.value!==void 0){let l=i.detail.value;r.setFormFieldValue({name:a,value:l,props:n}),Oe(a,l,r.selectFormValues(),s)}},Oi=(e,t)=>{let{store:r,dispatchEvent:s,render:n,props:i}=e,a=t._event,l=a.currentTarget.id.replace("field-","");l&&(r.setFormFieldValue({name:l,value:a.detail.selectedValue,props:i}),Oe(l,a.detail.selectedValue,r.selectFormValues(),s),n())},Ti=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");a&&i.detail.value!==void 0&&(r.setFormFieldValue({name:a,value:i.detail.value,props:n}),Oe(a,i.detail.value,r.selectFormValues(),s))},Li=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");a&&i.detail.value!==void 0&&(r.setFormFieldValue({name:a,value:i.detail.value,props:n}),Oe(a,i.detail.value,r.selectFormValues(),s))},Ri=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");a&&i.detail.value!==void 0&&(r.setFormFieldValue({name:a,value:i.detail.value,props:n}),Oe(a,i.detail.value,r.selectFormValues(),s))},Ni=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,n=r.currentTarget.id.replace("image-","");s(new CustomEvent("extra-event",{detail:{name:n,x:r.clientX,y:r.clientY,trigger:r.type}}))},Pi=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,n=r.currentTarget.id.replace("waveform-","");s(new CustomEvent("extra-event",{detail:{name:n,x:r.clientX,y:r.clientY,trigger:r.type}}))},Vi=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event.currentTarget.id.replace("field-","");s(new CustomEvent("action-click",{detail:{actionId:"select-options-add",name:i,formValues:r.selectFormValues()}}))},Di=(e,t)=>{let{store:r,render:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("tooltip-icon-",""),p=n.form.fields.find(o=>o.name===a);if(p&&p.tooltip){let o=i.currentTarget.getBoundingClientRect();r.showTooltip({x:o.left+o.width/2,y:o.top-8,content:p.tooltip.content}),s()}},ji=e=>{let{store:t,render:r}=e;t.hideTooltip(),r()};var kt={};P(kt,{createInitialState:()=>gn,getFormFieldValue:()=>En,hideTooltip:()=>Cn,selectForm:()=>Ue,selectFormValues:()=>An,selectState:()=>xn,selectViewData:()=>_n,setFormFieldValue:()=>$n,setFormValues:()=>kn,showTooltip:()=>Sn});var v={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},W={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Te={NOT:0};var k=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},X=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var wt=e=>{if(!e||e.trim()==="")throw new k("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new k(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new k(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Dr=e=>{if(e.trim().endsWith(" in"))throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new k(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);let s=t.includes(",")?t.split(",").map(n=>n.trim()):[t.trim()];for(let n of s){if(!n)throw new k(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n))throw new k(`Invalid loop syntax (got: '$for ${e}')`)}};var jr=(e,t,r=!1)=>{if(t===null)return new X(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new X(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new X(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new X(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},Br=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new X(`Unknown function '${e}' (${r})`)};var Bi=(e,t,r={})=>{let s={},n={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},n=r.partials||{}):typeof r=="object"&&(s=r));let a=O(e,{functions:s,partials:n},t,{});return a===void 0?{}:a},O=(e,t,r,s)=>{let n=t.functions||t;if(e.var&&!e.type)return z(e.var,r,s);if(e.type===v.LITERAL)return e.value;if(e.type===v.VARIABLE)return z(e.path,r,s);if(e.type===v.INTERPOLATION)return Mi(e.parts,t,r,s);switch(e.type){case v.FUNCTION:return Mr(e,t,r,s);case v.BINARY:return Fr(e,t,r,s);case v.UNARY:return Ur(e,t,r,s);case v.CONDITIONAL:return Ui(e,t,r,s);case v.LOOP:return qi(e,t,r,s);case v.OBJECT:return Gi(e,t,r,s);case v.ARRAY:return Xi(e,t,r,s);case v.PARTIAL:return Qi(e,t,r,s);case v.PATH_REFERENCE:return Zi(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},Wr=new Map,Wi=e=>{let t=[],r="",s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(i==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(i==="]"){if(s&&r){let a=r.trim();if(/^\d+$/.test(a))t.push({type:"index",value:parseInt(a,10)});else if(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")){let l=a.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:a});r=""}s=!1}else r+=i}return r&&t.push({type:"property",value:r}),t},z=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=Wr.get(e);if(!s){let i=[],a="",l=0;for(let p=0;p<e.length;p++){let o=e[p];o==="["?(l++,a+=o):o==="]"?(l--,a+=o):o==="."&&l===0?a&&(i.push(a),a=""):a+=o}a&&i.push(a),s=[];for(let p of i){let o=Wi(p.trim());s.push(...o)}Wr.set(e,s)}let n=t;for(let i=0;i<s.length;i++){let a=s[i];if(a.type==="property"&&a.value in r){n=r[a.value];continue}if(n==null)return;(a.type==="property"||a.type==="index")&&(n=n[a.value])}return n},Mi=(e,t,r,s)=>{let n=[];for(let i of e)if(typeof i=="string")n.push(i);else{let a=O(i,t,r,s);n.push(a!=null?String(a):"")}return n.join("")},Mr=(e,t,r,s)=>{let n=t.functions||t,i=n[e.name];if(!i)throw Br(e.name,n);let a=e.args.map(l=>O(l,t,r,s));return i(...a)},xe=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);switch(e.type){case v.VARIABLE:return z(e.path,r,s);case v.LITERAL:return e.value;case v.BINARY:return Fr(e,t,r,s);case v.UNARY:return Ur(e,t,r,s);case v.FUNCTION:return Mr(e,t,r,s);default:return O(e,t,r,s)}},Fr=(e,t,r,s)=>{if(e.op===W.AND||e.op===W.OR){let a=xe(e.left,t,r,s),l=xe(e.right,t,r,s);switch(e.op){case W.AND:return a&&l;case W.OR:return a||l}}let n=O(e.left,t,r,s),i=O(e.right,t,r,s);switch(e.op){case W.EQ:return n==i;case W.NEQ:return n!=i;case W.GT:return n>i;case W.LT:return n<i;case W.GTE:return n>=i;case W.LTE:return n<=i;case W.IN:return Array.isArray(i)?i.includes(n):!1;case W.ADD:if(typeof n!="number"||typeof i!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof n} + ${typeof i}`);return n+i;case W.SUBTRACT:if(typeof n!="number"||typeof i!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof n} - ${typeof i}`);return n-i;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ur=(e,t,r,s)=>{let n=e.op===Te.NOT?xe(e.operand,t,r,s):O(e.operand,t,r,s);switch(e.op){case Te.NOT:return!n;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Fi=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let n=e.conditions[0];if(n.type===v.VARIABLE)if(z(n.path,r,s)){let a=e.bodies[0];if(a.type===v.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?O(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[o]=c.value;else if(c.type===v.VARIABLE)l[o]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=O(c,t,r,s)}return l}}else{let a=e.bodies[1];if(a.type===v.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?O(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[o]=c.value;else if(c.type===v.VARIABLE)l[o]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=O(c,t,r,s)}return l}}}return null},Ui=(e,t,r,s)=>{let n=Fi(e,t,r,s);if(n!==null)return n;for(let i=0;i<e.conditions.length;i++){let a=e.conditions[i];if(a===null||xe(a,t,r,s))return O(e.bodies[i],t,r,s)}return Kr},Ki=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===v.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===v.VARIABLE){let n=r.conditions[0].path,i=r.bodies[0];if(n.startsWith(s+".")){let a=n.substring(s.length+1);if(i.type===v.OBJECT&&i.properties.length<=5){for(let p of i.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let o=t[p];if(o[a]){let c={};for(let u of i.properties){let h=u.key,f=u.value;if(f.type===v.LITERAL)c[h]=f.value;else if(f.type===v.VARIABLE){let d=f.path;if(d===s)c[h]=o;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=o[y]}else return null}else if(f.type===v.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===v.VARIABLE){let m=b.path;if(m===s)d.push(o!=null?String(o):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=o[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},zi=(e,t)=>{let r=e.body,s=e.itemVar,n=Ki(e,t);if(n!==null)return n;if(r.type===v.OBJECT&&r.properties.length<=5&&!r.whenCondition){for(let l of r.properties)if(l.parsedKey)return null;let i=[],a=!0;for(let l of r.properties){let p=l.key,o=l.value;if(o.type===v.LITERAL)i.push({key:p,type:"literal",value:o.value});else if(o.type===v.VARIABLE){let c=o.path;if(c===s)i.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))i.push({key:p,type:"prop",prop:u});else{a=!1;break}}else{a=!1;break}}else if(o.type===v.INTERPOLATION&&o.parts.length===1){let c=o.parts[0];if(c.type===v.VARIABLE){let u=c.path;if(u===s)i.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))i.push({key:p,type:"prop_string",prop:h});else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}if(a){let l=new Array(t.length);if(i.length===3&&i[0].type==="prop"&&i[0].key==="id"&&i[1].type==="prop_string"&&i[1].key==="title"&&i[2].type==="prop"&&i[2].key==="completed")for(let p=0;p<t.length;p++){let o=t[p];l[p]={id:o.id,title:o.title!=null?String(o.title):"",completed:o.completed}}else for(let p=0;p<t.length;p++){let o=t[p],c={};for(let u of i)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=o;else if(u.type==="prop")c[u.key]=o[u.prop];else if(u.type==="item_string")c[u.key]=o!=null?String(o):"";else if(u.type==="prop_string"){let h=o[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},Hi=(e,t,r,s,n)=>{let i=[],a=e.body;if(a.type===v.OBJECT&&a.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let o=0;o<n.length;o++){let c=n[o],u={},h={...s,[l]:c,...p&&{[p]:o}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${o}]`,...p&&{[p]:o}};for(let d of a.properties){let y=d.parsedKey?O(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===v.LITERAL)u[y]=b.value;else if(b.type===v.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=o;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:o}})}else u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:o}})}else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=o;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=z(_,r,{...s,[l]:c,...p&&{[p]:o}})}else x=z(_,r,{...s,[l]:c,...p&&{[p]:o}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:o}},x=O(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:o}};u[y]=O(b,t,r,m)}}i.push(u)}return i}return null},Ji=(e,t,r)=>{let s=e.body;if(s.type===v.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let i=s.properties[0].value;if(i.type===v.CONDITIONAL&&i.conditions.length===1&&i.conditions[0].type===v.VARIABLE&&i.conditions[0].path==="item.visible"){let a=i.bodies[0];if(a.type===v.OBJECT&&a.properties.length===2){let l=a.properties[0],p=a.properties[1];if(l.key==="id"&&l.value.type===v.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===v.CONDITIONAL){let o=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),o.push(h)}}return o}}}}return null},qi=(e,t,r,s)=>{let n=O(e.iterable,t,r,s);if(!Array.isArray(n)){let o,c=!1;if(e.iterable.type===v.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===v.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===v.VARIABLE?f.path:f.type===v.FUNCTION?`${f.name}(...)`:"?").join(", ");o=`${e.iterable.name}(${h})`}else o=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${o}`;throw jr(u,n,c)}if(!e.indexVar){let o=Ji(e,n,e.itemVar);if(o!==null)return o}if(!e.indexVar){let o=zi(e,n);if(o!==null)return o}let i=Hi(e,t,r,s,n);if(i!==null)return i;let a=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let o=l.split("."),c=o[0];c in s.__paths__&&(l=s.__paths__[c],o.length>1&&(l+="."+o.slice(1).join(".")))}let p=!1;e.body.type===v.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(o=>o.type===v.OBJECT&&o.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let o=0;o<n.length;o++){let c=e.indexVar?{...s,[e.itemVar]:n[o],[e.indexVar]:o}:{...s,[e.itemVar]:n[o]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${o}]`},e.indexVar&&(c.__paths__[e.indexVar]=o);let u=O(e.body,t,r,c);if(Array.isArray(u)&&u.length===1&&!p){let h=u[0];a.push(h===void 0?{}:h)}else a.push(u===void 0?{}:u)}return a},Yi=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let n=e.properties[0],i=n.parsedKey?O(n.parsedKey,t,r,s):n.key,a=n.value;if(a.type===v.OBJECT&&a.properties.length<=10&&!a.whenCondition){let l={},p={},o=!0;for(let c of a.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)p[u]=h.value;else if(h.type===v.VARIABLE)p[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{o=!1;break}if(!o)break;p[u]=f.join("")}else if(h.type===v.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===v.LITERAL)f[y]=b.value;else if(b.type===v.VARIABLE)f[y]=z(b.path,r,s);else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=z(w.path,r,s);m.push(_!=null?String(_):"")}else{o=!1;break}if(!o)break;f[y]=m.join("")}else{o=!1;break}}if(!o)break;p[u]=f}else{o=!1;break}}if(o)return l[i]=p,l}}return null},Gi=(e,t,r,s)=>{let n=t.functions||t;if(e.whenCondition&&!xe(e.whenCondition,n,r,s))return;let i=Yi(e,t,r,s);if(i!==null)return i;if(e.fast){let o={};for(let c of e.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)o[u]=h.value;else if(h.type===v.VARIABLE)o[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=O(d,t,r,s);f.push(y!=null?String(y):"")}o[u]=f.join("")}else o[u]=O(h,t,r,s)}return o}let a={},l=null,p=!1;for(let o of e.properties)if(!o.key.startsWith("$if ")&&!o.key.match(/^\$if\s+\w+.*:?$/)&&!o.key.startsWith("$elif")&&!o.key.startsWith("$else")&&!o.key.startsWith("$for ")){p=!0;break}for(let o of e.properties)if(o.key.startsWith("$if ")||o.key.match(/^\$if\s+\w+.*:?$/)){let c=O(o.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(a,c)}else if(o.key.startsWith("$for ")){if(e.properties.length===1)return O(o.value,t,r,s)}else{let c=o.value;if(c&&c.type===v.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=O(u.value,t,r,s);h!==void 0&&(a[o.key]=h)}else{let h=O(o.value,t,r,s);h!==void 0&&(a[o.key]=h)}}else{let u=o.parsedKey?O(o.parsedKey,t,r,s):o.key,h=O(o.value,t,r,s);h!==void 0&&(a[u]=h)}}return a},Kr={},Xi=(e,t,r,s)=>{let n=[];for(let i of e.items)if(i.type===v.LOOP){let a=O(i,t,r,s);Array.isArray(a)&&i.flatten!==!1?n.push(...a):n.push(a)}else{let a=O(i,t,r,s);a!==Kr&&a!==void 0&&n.push(a)}return n},Qi=(e,t,r,s)=>{let{name:n,data:i,whenCondition:a}=e,l=t.partials||{},p=t.functions||t;if(a&&!xe(a,p,r,s))return;if(!l[n])throw new X(`Partial '${n}' is not defined`);let o=s._partialStack||[];if(o.includes(n))throw new X(`Circular partial reference detected: ${n}`);let c=l[n],u=r,h={...s,_partialStack:[...o,n]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(i){let f=O(i,t,r,s);u={...u,...f}}return O(c,t,u,h)},Zi=(e,t,r,s)=>{let{path:n}=e,i=n.split("."),a=i[0],l=i.slice(1);if(!s||!(a in s))throw new X(`Path reference '#{${n}}' refers to '${a}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(a in s.__paths__))throw new X(`Path reference '#{${n}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[a];if(typeof p=="number"){if(l.length>0)throw new X(`Path reference '#{${n}}' - cannot access properties on index variable '${a}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},_t=Bi;var en=/\$\{([^}]*)\}/g,tn=/#\{([^}]*)\}/g,Hr=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,n]=r,i=rn(n,t);return{isFunction:!0,type:v.FUNCTION,name:s,args:i}},rn=(e,t={})=>e.trim()?sn(e).map(s=>nn(s.trim(),t)):[],sn=e=>{let t=[],r="",s=0,n=!1,i="";for(let a=0;a<e.length;a++){let l=e[a],p=a>0?e[a-1]:"";!n&&(l==='"'||l==="'")?(n=!0,i=l,r+=l):n&&l===i&&p!=="\\"?(n=!1,i="",r+=l):!n&&l==="("?(s++,r+=l):!n&&l===")"?(s--,r+=l):!n&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},nn=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:v.LITERAL,value:parseFloat(e)};if(e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};let r=Hr(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),n=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],i=-1,a=null;for(let{op:l,type:p}of n){let o=0;for(;o<s.length;){let c=de(s.substring(o),l);if(c===-1)break;let u=o+c;u>i&&(i=u,a={op:l,type:p}),o=u+l.length}}if(i!==-1)try{return Y(s,t)}catch{return{type:v.VARIABLE,path:s}}return{type:v.VARIABLE,path:s}},Jr=/^\w+\(.*\)$/,an=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,on=e=>{if(!(!e||e.trim()===""||Jr.test(e))&&an.test(e))throw e.includes("?")&&e.includes(":")?new k(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new k(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new k(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},zr=e=>{let t=e.trim();if(Jr.test(t))throw new k(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new k(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new k(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new k(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new k(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:v.PATH_REFERENCE,path:t}},Le=(e,t={})=>{let r=e.trim();on(r);let s=Hr(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let n=0;for(let i of r)i==="["?n++:i==="]"&&n--;if(n!==0)throw new Error("Invalid array index syntax")}return{type:v.VARIABLE,path:r}},xt=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let n=[...r.matchAll(en)],i=[...r.matchAll(tn)],a=[...n.map(o=>({match:o,type:"variable"})),...i.map(o=>({match:o,type:"pathref"}))].sort((o,c)=>o.match.index-c.match.index);if(a.length===0){let o=r;for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);return{type:v.LITERAL,value:o}}if(a.length===1&&a[0].match[0]===r&&s.length===0){let{match:o,type:c}=a[0];try{return c==="variable"?Le(o[1],t):zr(o[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:v.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:o,type:c}of a){let[u,h]=o,f=o.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=Le(h.trim(),t):d=zr(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let o=r.substring(p);for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);o&&l.push(o)}return{type:v.INTERPOLATION,parts:l}};var ue=(e,t)=>typeof e=="string"?xt(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?pn(e,t):cn(e,t):{type:v.LITERAL,value:e},ln=e=>{let{$each:t,...r}=e;if(typeof t!="string")throw new k("$each value must be a non-empty string");let s=t.trim();if(s==="")throw new k("$each value must be a non-empty string");if(Object.keys(r).length===0)throw new k("Empty $each body not allowed");if(r.$partial!==void 0)throw new k("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${s}`]:r}},pn=(e,t)=>{let r=[],s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(typeof i=="object"&&i!==null&&!Array.isArray(i)){if(i.$each!==void 0)try{let p=ln(i),o=Object.keys(p);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let c=qr(o[0],p[o[0]],t,!0);r.push(c),s=!0;continue}}catch(p){throw p instanceof k?p:new k(p.message)}let l=Object.keys(i);if(l.length===1&&/^\$for(?::\w+)?\s/.test(l[0])){let p=qr(l[0],i[l[0]],t);r.push(p),s=!0;continue}}let a=ue(i,t);r.push(a),(a.type===v.FUNCTION||a.type===v.CONDITIONAL||a.type===v.LOOP||a.type===v.PARTIAL||a.type===v.OBJECT&&!a.fast||a.type===v.ARRAY&&!a.fast)&&(s=!0)}return{type:v.ARRAY,items:r,fast:!s}},cn=(e,t)=>{let r=[],s=!1,n=null,i=Object.entries(e),a=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new k("$partial value must be a string");if(e.$partial.trim()==="")throw new k("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],o=[];for(let[m]of i)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){o.push(w);break}if(o.length>0)throw new k(`Cannot use $partial with ${o.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=ue(f,t),y.type===v.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===v.VARIABLE||w.value.type===v.INTERPOLATION||w.value.type===v.FUNCTION||w.value.type===v.CONDITIONAL||w.value.type===v.OBJECT&&!w.value.fast||w.value.type===v.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:v.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new k("Empty condition expression after '$when'");m=Y(u,t)}else m={type:v.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,o]of i)if(p==="$when"){if(n!==null)throw new k("Multiple '$when' directives on the same object are not allowed");if(o==null)throw new k("Missing condition expression after '$when'");let c=typeof o=="string"?o:JSON.stringify(o);if(c.trim()==="")throw new k("Empty condition expression after '$when'");n=Y(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new k("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;a<i.length;){let[p,o]=i[a];if(p==="$when"){a++;continue}if(p==="$each")throw new k("$each can only be used inside arrays");if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=un(i,a,t);r.push({key:p,value:c.node}),s=!0,a=c.nextIndex}else if(/^\$for(?::\w+)?\s/.test(p)){let c=p.match(/^\$for(?::(\w+))?\s/)?.[1]||"",u=c?`:${c}`:"";throw new k(`$for loops must be inside arrays - use '- $for${u} item in items:' instead of '$for${u} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new k(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new k("Missing condition expression after '$if'");{let c=ue(o,t);(c.type===v.FUNCTION||c.type===v.CONDITIONAL||c.type===v.PARTIAL||c.type===v.OBJECT&&!c.fast||c.type===v.ARRAY&&!c.fast)&&(s=!0);let u=xt(p,t),h={key:p,value:c};(u.type!==v.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),a++}}}let l={type:v.OBJECT,properties:r,fast:!s};return n&&(l.whenCondition=n),l},un=(e,t,r={})=>{let s=[],n=[],i=t,[a,l]=e[i],p=null,o;if(a.startsWith("$if#")){let u=a.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],o=u[2];else throw new k(`Invalid conditional syntax: ${a}`)}else o=a.substring(4),o.endsWith(":")&&(o=o.slice(0,-1).trim());wt(o);let c=Y(o,r);for(s.push(c),n.push(ue(l,r)),i++;i<e.length;){let[u,h]=e[i],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{wt(d);let y=Y(d,r);s.push(y)}if(n.push(ue(h,r)),i++,d===null)break}else break}return{node:{type:v.CONDITIONAL,conditions:s,bodies:n,id:p},nextIndex:i}},Y=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let o=e.slice(1,-1),c=0,u=!0;for(let h=0;h<o.length;h++)if(o[h]==="("?c++:o[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return Y(o,t)}let r=de(e,"||");if(r!==-1)return{type:v.BINARY,op:W.OR,left:Y(e.substring(0,r).trim(),t),right:Y(e.substring(r+2).trim(),t)};let s=de(e,"&&");if(s!==-1)return{type:v.BINARY,op:W.AND,left:Y(e.substring(0,s).trim(),t),right:Y(e.substring(s+2).trim(),t)};let n=[{op:">=",type:W.GTE},{op:"<=",type:W.LTE},{op:"==",type:W.EQ},{op:"!=",type:W.NEQ},{op:">",type:W.GT},{op:"<",type:W.LT},{op:" in ",type:W.IN}];for(let{op:o,type:c}of n){let u=de(e,o);if(u!==-1)return{type:v.BINARY,op:c,left:Y(e.substring(0,u).trim(),t),right:Y(e.substring(u+o.length).trim(),t)}}let i=-1,a=null,l=[{op:" + ",type:W.ADD},{op:" - ",type:W.SUBTRACT}];for(let{op:o,type:c}of l){let u=0;for(;u<e.length;){let h=de(e.substring(u),o);if(h===-1)break;let f=u+h;f>i&&(i=f,a={op:o,type:c}),u=f+o.length}}if(i!==-1&&a)return{type:v.BINARY,op:a.type,left:Y(e.substring(0,i).trim(),t),right:Y(e.substring(i+a.op.length).trim(),t)};let p=[" * "," / "," % "];for(let o of p)if(de(e,o)!==-1)throw new k(`Arithmetic operations are not allowed in conditionals: "${o}"`);return e.startsWith("!")?{type:v.UNARY,op:Te.NOT,operand:Y(e.substring(1).trim(),t)}:Yr(e,t)},de=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},hn=e=>{if(e=e.trim(),e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:v.LITERAL,value:""};if(e==="{}")return{type:v.LITERAL,value:{}};if(e==="[]")return{type:v.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:v.LITERAL,value:t}:{type:v.VARIABLE,path:e}},Yr=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return Le(r,t);let n=hn(r);if(n.type===v.LITERAL)return n;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:v.VARIABLE,path:r};try{return Le(r,t)}catch(i){if(i.message&&i.message.includes("not supported"))return n;throw i}},dn=(e,t=!1)=>{let r=t?"$each":"$for";try{Dr(e)}catch(s){if(s instanceof k&&t){let n=s.message.replace(/\$for/g,"$each");throw new k(n.replace("Parse Error: ",""))}throw s}},qr=(e,t,r,s=!1)=>{let n=/^\$for(?::(\w+))?\s+(.+)$/,i=e.match(n);if(!i){let b=s?"$each":"$for";throw new k(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let a=i[1],l=i[2].trim();dn(l,s);let p=l.match(/^(.+?)\s+in\s+(.+)$/);if(!p){let b=s?"$each":"$for";throw new k(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${l}')`)}let o=p[1].trim(),c=p[2].trim(),u,h=null;if(o.includes(",")){let b=o.split(",").map(m=>m.trim());if(b.length!==2)throw new k(`Invalid loop variables: ${o}. Expected format: "item" or "item, index"`);u=b[0],h=b[1]}else u=o;let f=["this","undefined","null","true","false"];if(f.includes(u))throw new k(`Reserved variable name: ${u}`);if(h&&f.includes(h))throw new k(`Reserved variable name: ${h}`);let d=Yr(c,r),y=ue(t,r);return{type:v.LOOP,itemVar:u,indexVar:h,iterable:d,body:y,flatten:a!=="nested"}};var fn=(e,t={})=>{let{functions:r={}}=t;return ue(e,r)},Fe=fn;var At={};P(At,{now:()=>yn});var yn=()=>Date.now();var mn=(e,t,r={})=>{let{functions:s={},partials:n={}}=r,i={...At,...s},a=Fe(e,{functions:i}),l={};for(let[p,o]of Object.entries(n))l[p]=Fe(o,{functions:i});return _t(a,t,{functions:i,partials:l})},Et=mn;function Gr(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}var gn=()=>Object.freeze({formValues:{},tooltipState:{open:!1,x:0,y:0,content:""}}),Xr=(e,t,r=void 0)=>{if(!t)return;let s=t.split(/[\[\].]/).filter(i=>i!==""),n=e;for(let i of s){if(n==null||!(i in n))return r;n=n[i]}return n},vn=(e,t,r)=>{let s=t.split(/[\[\].]/).filter(i=>i!=="");t.includes("[")&&t in e&&delete e[t];let n=e;for(let i=0;i<s.length-1;i++){let a=s[i];if(!(a in n)||typeof n[a]!="object"||n[a]===null){let l=s[i+1],p=/^\d+$/.test(l);n[a]=p?[]:{}}n=n[a]}return n[s[s.length-1]]=r,e},bn=["id","class","style","slot"],wn=e=>Object.entries(e).filter(([t])=>!bn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Ue=({props:e})=>{let{form:t={}}=e,{context:r}=e;return r?Et(t,r):t},_n=({state:e,props:t,attrs:r})=>{let s=wn(r),n=Ue({state:e,props:t}),i=structuredClone(n.fields||[]);return i.forEach(a=>{let l=Xr(e.formValues,a.name);if(["read-only-text"].includes(a.inputType)&&(a.defaultValue=l),["select"].includes(a.inputType)){let p=t?.defaultValues;p&&p[a.name]!==void 0&&(a.selectedValue=p[a.name])}if(a.inputType==="image"){let p=a.src;a.imageSrc=p&&p.trim()?p:null,a.placeholderText=a.placeholder||"No Image"}if(a.inputType==="waveform"){let p=a.waveformData;a.waveformData=p||null,a.placeholderText=a.placeholder||"No Waveform"}}),{key:r?.key,containerAttrString:s,title:n?.title||"",description:n?.description||"",fields:i,actions:t?.form?.actions||{buttons:[]},formValues:e.formValues,tooltipState:e.tooltipState}},xn=({state:e})=>e,An=({state:e,props:t})=>{let r=Ue({state:e,props:t});return Gr(e.formValues,r.fields.map(s=>s.name))},En=({state:e},t)=>Xr(e.formValues,t),kn=(e,t)=>{e.formValues=t||{}},$n=(e,{name:t,value:r,props:s})=>{vn(e.formValues,t,r);let n=Ue({state:e,props:s}),i=Gr(e.formValues,n.fields.map(a=>a.name));e.formValues=i},Sn=(e,{x:t,y:r,content:s})=>{e.tooltipState={open:!0,x:t,y:r,content:s}},Cn=e=>{e.tooltipState={...e.tooltipState,open:!1}};var Qr={elementName:"rtgl-form",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{defaultValues:{type:"object"},context:{type:"object"},form:{type:"object",properties:{title:{type:"string"},description:{type:"string"},fields:{type:"array",items:{anyOf:[{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"inputText"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"select"},placeholder:{type:"string"},noClear:{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}},options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}},required:["label","value"]}},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType","options"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"colorPicker"},value:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider-input"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"image"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"waveform"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},defaultValue:{type:"object"},waveformData:{type:"object"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"popover-input"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1}]}},actions:{type:"object",properties:{buttons:{type:"array",items:{type:"object",properties:{id:{type:"string"},content:{type:"string"}},required:["id","content"]}}}}}}}},refs:{"action-*":{eventListeners:{click:{handler:"handleActionClick"}}},"tooltip-icon-*":{eventListeners:{mouseenter:{handler:"handleTooltipMouseEnter"},mouseleave:{handler:"handleTooltipMouseLeave"}}},"field-*":{eventListeners:{"input-change":{handler:"handleInputChange"},"select-change":{handler:"handleSelectChange"},"add-option-selected":{handler:"handleSelectAddOption"},"colorpicker-change":{handler:"handleColorPickerChange"},"slider-change":{handler:"handleSliderChange"},"slider-input-value-change":{handler:"handleSliderInputChange"}}},"image-*":{eventListeners:{click:{handler:"handleImageClick"},contextmenu:{handler:"handleImageClick"}}},"waveform-*":{eventListeners:{click:{handler:"handleWaveformClick"},contextmenu:{handler:"handleWaveformClick"}}}},events:{"form-change":{},"extra-event":{},"action-click":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f p=md g=lg ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"$if title",value:{type:6,conditions:[{type:1,path:"title"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"title"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"$if description",value:{type:6,conditions:[{type:1,path:"description"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:1,path:"description"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-view g=lg w=f",value:{type:9,items:[{type:7,itemVar:"field",indexVar:"i",iterable:{type:1,path:"fields"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=f",value:{type:9,items:[{type:8,properties:[{key:"$if field.label || field.description",value:{type:6,conditions:[{type:4,op:7,left:{type:1,path:"field.label"},right:{type:1,path:"field.description"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md av=c",value:{type:9,items:[{type:8,properties:[{key:"$if field.label",value:{type:6,conditions:[{type:1,path:"field.label"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"field.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"$if field.label && field.tooltip",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"field.label"},right:{type:1,path:"field.tooltip"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-svg#tooltip-icon-${field.name} svg="info" wh=16 c=mu-fg cur=help ml=xs',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg#tooltip-icon-",{type:1,path:"field.name"},' svg="info" wh=16 c=mu-fg cur=help ml=xs']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"$if field.description",value:{type:6,conditions:[{type:1,path:"field.description"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"field.description"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "read-only-text"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"read-only-text"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"field.defaultValue"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:`$if field.inputType == "inputText" || field.inputType == 'input-text'`,value:{type:6,conditions:[{type:4,op:7,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"inputText"}},right:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"input-text"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input#field-${field.name} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#field-",{type:1,path:"field.name"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "input-number"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"input-number"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input-number#field-${field.name} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input-number#field-",{type:1,path:"field.name"}," w=f"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "input-textarea"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"input-textarea"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-textarea#field-${field.name} w=f rows=${field.rows} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-textarea#field-",{type:1,path:"field.name"}," w=f rows=",{type:1,path:"field.rows"}," w=f"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "popover-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"popover-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-popover-input#field-${field.name} label="${field.label}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-popover-input#field-",{type:1,path:"field.name"},' label="',{type:1,path:"field.label"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "select"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"select"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-select#field-${field.name} key=${key} w=f .options=fields[${i}].options ?no-clear=fields[${i}].noClear .addOption=fields[${i}].addOption .selectedValue=#{field.selectedValue} .placeholder=#{field.placeholder}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-select#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f .options=fields[",{type:1,path:"i"},"].options ?no-clear=fields[",{type:1,path:"i"},"].noClear .addOption=fields[",{type:1,path:"i"},"].addOption .selectedValue=",{type:11,path:"field.selectedValue"}," .placeholder=",{type:11,path:"field.placeholder"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "colorPicker"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"colorPicker"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-color-picker#field-${field.name} key=${key}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-color-picker#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider#field-${field.name} key=${key} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider-input#field-${field.name} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider-input#field-",{type:1,path:"field.name"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:1,path:"field.imageSrc"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image#image-${field.name} src=${field.imageSrc} w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image#image-",{type:1,path:"field.name"}," src=",{type:1,path:"field.imageSrc"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && !field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:5,op:0,operand:{type:1,path:"field.imageSrc"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholderText"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:1,path:"field.waveformData"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-waveform#field-${field.name} .waveformData=fields[${i}].waveformData w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-waveform#field-",{type:1,path:"field.name"}," .waveformData=fields[",{type:1,path:"i"},"].waveformData w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && !field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:5,op:0,operand:{type:1,path:"field.waveformData"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholder"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slot"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slot"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'slot#field-${field.slotName} name=${field.slot} style="display: contents;"',value:{type:0,value:null},parsedKey:{type:2,parts:["slot#field-",{type:1,path:"field.slotName"}," name=",{type:1,path:"field.slot"},' style="display: contents;"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=e g=sm w=f",value:{type:9,items:[{type:7,itemVar:"button",indexVar:"i",iterable:{type:1,path:"actions.buttons"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-button#action-${button.id}",value:{type:1,path:"button.content"},parsedKey:{type:2,parts:["rtgl-button#action-",{type:1,path:"button.id"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:'rtgl-tooltip ?open=${tooltipState.open} x=${tooltipState.x} y=${tooltipState.y} placement="top" content="${tooltipState.content}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-tooltip ?open=",{type:1,path:"tooltipState.open"}," x=",{type:1,path:"tooltipState.x"}," y=",{type:1,path:"tooltipState.y"},' placement="top" content="',{type:1,path:"tooltipState.content"},'"']}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f p=md g=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var $t={};P($t,{closeAll:()=>Dn,handleCancel:()=>Tn,handleConfirm:()=>On,handleDialogClose:()=>In,handleDropdownClose:()=>Ln,handleDropdownItemClick:()=>Rn,showAlert:()=>Nn,showConfirm:()=>Pn,showDropdownMenu:()=>Vn});var In=(e,t)=>{let{store:r,render:s}=e;r.closeAll(),s()},On=(e,t)=>{let{store:r,render:s,globalUI:n}=e;r.closeAll(),s(),n.emit("event",!0)},Tn=(e,t)=>{let{store:r,render:s,globalUI:n}=e;r.closeAll(),s(),n.emit("event",!1)},Ln=(e,t)=>{let{store:r,render:s,globalUI:n}=e;r.closeAll(),s(),n.emit("event",null)},Rn=(e,t)=>{let{store:r,render:s,globalUI:n}=e,i=t._event,{index:a,item:l}=i.detail;r.closeAll(),s(),n.emit("event",{index:a,item:l})},Nn=(e,t)=>{let{store:r,render:s}=e,n=t;r.selectIsOpen()&&(r.closeAll(),s()),r.setAlertConfig(n),s()},Pn=async(e,t)=>{let{store:r,render:s,globalUI:n}=e,i=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setConfirmConfig(i),s(),new Promise(a=>{n.once("event",l=>{a(l)})})},Vn=async(e,t)=>{let{store:r,render:s,globalUI:n}=e,i=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setDropdownConfig(i),s(),new Promise(a=>{n.once("event",l=>{a(l)})})},Dn=e=>{let{store:t,render:r}=e;t.selectIsOpen()&&(t.closeAll(),r())};var St={};P(St,{closeAll:()=>Fn,createInitialState:()=>jn,selectConfig:()=>Un,selectDropdownConfig:()=>Kn,selectIsOpen:()=>Hn,selectUiType:()=>zn,selectViewData:()=>Jn,setAlertConfig:()=>Bn,setConfirmConfig:()=>Wn,setDropdownConfig:()=>Mn});var jn=()=>Object.freeze({isOpen:!1,uiType:"dialog",config:{status:void 0,title:"",message:"",confirmText:"OK",cancelText:"Cancel",mode:"alert"},dropdownConfig:{items:[],x:0,y:0,placement:"bottom-start"}}),Bn=(e,t)=>{if(!t.message)throw new Error("message is required for showAlert");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"OK",cancelText:"",mode:"alert"},e.uiType="dialog",e.isOpen=!0},Wn=(e,t)=>{if(!t.message)throw new Error("message is required for showConfirm");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"Yes",cancelText:t.cancelText||"Cancel",mode:"confirm"},e.uiType="dialog",e.isOpen=!0},Mn=(e,t)=>{if(!t.items||!Array.isArray(t.items))throw new Error("items array is required for showDropdown");e.dropdownConfig={items:t.items,x:t.x||0,y:t.y||0,placement:t.placement||"bottom-start"},e.uiType="dropdown",e.isOpen=!0},Fn=e=>{e.isOpen=!1,e.uiType="dialog"},Un=({state:e})=>e.config,Kn=({state:e})=>e.dropdownConfig,zn=({state:e})=>e.uiType,Hn=({state:e})=>e.isOpen,Jn=({state:e})=>({isOpen:e.isOpen,uiType:e.uiType,config:e.config,dropdownConfig:{items:e.dropdownConfig?.items||[],x:e.dropdownConfig?.x||0,y:e.dropdownConfig?.y||0,placement:e.dropdownConfig?.placement||"bottom-start"},isDialogOpen:e.isOpen&&e.uiType==="dialog",isDropdownOpen:e.isOpen&&e.uiType==="dropdown"});var Zr={elementName:"rtgl-global-ui",viewDataSchema:{type:"object",properties:{isOpen:{type:"boolean"},uiType:{type:"string"},config:{type:"object",properties:{status:{type:"string"},title:{type:"string"},message:{type:"string"},confirmText:{type:"string"},cancelText:{type:"string"},mode:{type:"string"}}},dropdownConfig:{type:"object",properties:{items:{type:"array"},x:{type:"number"},y:{type:"number"},placement:{type:"string"}}}}},refs:{dialog:{eventListeners:{close:{handler:"handleDialogClose"}}},"confirm-button":{eventListeners:{click:{handler:"handleConfirm"}}},"cancel-button":{eventListeners:{click:{handler:"handleCancel"}}},"dropdown-menu":{eventListeners:{close:{handler:"handleDropdownClose"},"click-item":{handler:"handleDropdownItemClick"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-dialog#dialog ?open=${isDialogOpen} s=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content g=lg p=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=c av=c g=md",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=24 av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text fw=600",value:{type:1,path:"config.title"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"config.message"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h g=md mt=lg w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"$if config.mode == 'confirm'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"config.mode"},right:{type:0,value:"confirm"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-button#cancel-button v=se",value:{type:1,path:"config.cancelText"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-button#confirm-button v=pr",value:{type:1,path:"config.confirmText"}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-dialog#dialog ?open=",{type:1,path:"isDialogOpen"}," s=sm"]}}],fast:!1},{type:8,properties:[{key:"rtgl-dropdown-menu#dropdown-menu ?open=${isDropdownOpen} x=${dropdownConfig.x} y=${dropdownConfig.y} placement=${dropdownConfig.placement} .items=dropdownConfig.items key=dropdown-${isDropdownOpen}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-dropdown-menu#dropdown-menu ?open=",{type:1,path:"isDropdownOpen"}," x=",{type:1,path:"dropdownConfig.x"}," y=",{type:1,path:"dropdownConfig.y"}," placement=",{type:1,path:"dropdownConfig.placement"}," .items=dropdownConfig.items key=dropdown-",{type:1,path:"isDropdownOpen"}]}}],fast:!0}],fast:!1}};var Ct={};P(Ct,{handleClickStart:()=>qn});var qn=(e,t)=>{let{dispatchEvent:r,store:s}=e,n=t._event;console.log("handle click start",s.selectPath()),r(new CustomEvent("clickStart",{detail:{path:s.selectPath()}}))};var It={};P(It,{createInitialState:()=>Yn,selectPath:()=>Zn,selectViewData:()=>Qn,setState:()=>ea});var Yn=()=>Object.freeze({}),Gn=["id","class","style","slot"],Xn=e=>Object.entries(e).filter(([t])=>!Gn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Qn=({state:e,props:t,attrs:r})=>{console.log("attrs",{attrs:r,entries:Object.entries(r)});let s=r.start?JSON.parse(decodeURIComponent(r.start)):t.start;return{containerAttrString:Xn(r),start:s||{label:"",image:{src:"",width:32,height:32,alt:""}}}},Zn=({props:e})=>e.start.path,ea=e=>{};var es={elementName:"rtgl-navbar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}},hasImage:{type:"boolean"},hasHref:{type:"boolean"}}}}},propsSchema:{type:"object",properties:{start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}}}}}},refs:{start:{eventListeners:{click:{handler:"handleClickStart"}}}},events:{clickStart:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"rtgl-text s=lg":"${start.label}"},{"$if start.image && start.image.src":[{"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}":null}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view bgc=bg d=h h=48 av=c w=f ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if start.href",value:{type:6,conditions:[{type:1,path:"start.href"},{type:1,path:"start.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${start.href}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["a href=",{type:1,path:"start.href"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#start d=h av=c g=lg g=md cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-view flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h av=c g=lg",value:{type:9,items:[{type:8,properties:[{key:"slot name=right",value:{type:0,value:null}}],fast:!0}],fast:!0}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view bgc=bg d=h h=48 av=c w=f ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ot={};P(Ot,{handleBeforeMount:()=>ra});var ts=(e,t,r)=>{let{store:s,render:n}=r,i,a=-1/0;if(e.forEach(l=>{let p=l.getBoundingClientRect();p.top<=t&&p.top>a&&(a=p.top,i=l.id)}),!i){let l=1/0;e.forEach(p=>{let o=p.getBoundingClientRect();o.top>t&&o.top<l&&(l=o.top,i=p.id)})}i&&i!==s.selectCurrentId()&&(s.setCurrentId(i),n())},ta=(e,t,r,s)=>{let{store:n,render:i}=s,a=e.querySelectorAll("h1[id], h2[id], h3[id], h4[id], rtgl-text[id]"),l=Array.from(a),p=l.map(c=>{let u=1,h=c.tagName.toLowerCase();return h==="h1"?u=1:h==="h2"?u=2:h==="h3"?u=3:h==="h4"?u=4:h==="rtgl-text"&&(u=parseInt(c.getAttribute("data-level")||"1",10)),{id:c.id,href:`#${c.id}`,title:c.textContent,level:u}});n.setItems(p),ts(l,r,s),i();let o=ts.bind(void 0,l,r,s);return t.addEventListener("scroll",o,{passive:!0}),()=>{t.removeEventListener("scroll",o)}},ra=e=>{let{attrs:t}=e;requestAnimationFrame(()=>{let r=document.getElementById(t["target-id"]),s=window;t["scroll-container-id"]&&(s=document.getElementById(t["scroll-container-id"])||window);let n=parseInt(t["offset-top"]||"100",10),i=ta(r,s,n,e);return()=>{i()}})};var Tt={};P(Tt,{createInitialState:()=>sa,selectCurrentId:()=>aa,selectState:()=>na,selectViewData:()=>ia,setContentContainer:()=>pa,setCurrentId:()=>la,setItems:()=>oa});var sa=()=>Object.freeze({items:[],currentId:null,contentContainer:null}),ia=({state:e})=>{let r=((s,n)=>{let i=new Set,a=s.findIndex(p=>p.id===n);if(a===-1)return i;let l=s[a].level;for(let p=a-1;p>=0;p--)if(s[p].level<l){let o=s[p].level;i.add(s[p].id);for(let c=p-1;c>=0;c--)s[c].level<o&&(i.add(s[c].id),o=s[c].level);break}return i})(e.items,e.currentId);return{items:e.items.map(s=>{let n={1:"0",2:"12px",3:"24px",4:"32px"},i=s.id===e.currentId,a=r.has(s.id),l=i||a;return{...s,c:l?"fg":"mu-fg",ml:n[s.level]||"",bc:l?"fg":"mu-fg"}}),currentId:e.currentId}},na=({state:e})=>e,aa=({state:e})=>e.currentId,oa=(e,t)=>{e.items=t},la=(e,t)=>{e.currentId=t},pa=(e,t)=>{e.contentContainer=t};var rs={elementName:"rtgl-page-outline",viewDataSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{slug:{type:"string"},title:{type:"string"}}}},selectedSlug:{type:"string",nullable:!0}}},propsSchema:{type:"object",properties:{}},refs:{},events:{onItemClick:{type:"object"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=272 pr=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f mt=xl",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'rtgl-view d=h bwl=xs bc="${item.bc}" pv=sm av=c href=${item.href} pl=md',value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=${item.ml}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-view w=",{type:1,path:"item.ml"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm c=${item.c} h-c=fg",value:{type:1,path:"item.title"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.c"}," h-c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:['rtgl-view d=h bwl=xs bc="',{type:1,path:"item.bc"},'" pv=sm av=c href=',{type:1,path:"item.href"}," pl=md"]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}};var Lt={};P(Lt,{handleBeforeMount:()=>ca,handleInputChange:()=>fa,handleInputKeydown:()=>ma,handleOnUpdate:()=>ua,handlePopoverClose:()=>da,handleSubmitClick:()=>ya,handleTextClick:()=>ha});var ca=e=>{let{store:t,attrs:r}=e;r.value!==void 0&&t.setValue(r.value||"")},ua=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:n,render:i}=e;if(r?.value!==s?.value){let a=s?.value??"";n.setValue(a)}i()},ha=(e,t)=>{let{store:r,render:s,getRefIds:n,attrs:i}=e,a=t._event,l=r.selectValue();r.setTempValue(l),r.openPopover({position:{x:a.currentTarget.getBoundingClientRect().left,y:a.currentTarget.getBoundingClientRect().bottom}});let{input:p}=n();p.elm.value=l,s(),i["auto-focus"]&&setTimeout(()=>{p.elm.focus()},50)},da=(e,t)=>{let{store:r,render:s}=e;r.closePopover(),s()},fa=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,a=t._event.detail.value;r.setTempValue(a),n(new CustomEvent("temp-input-change",{detail:{value:a},bubbles:!0})),s()},ya=e=>{let{store:t,render:r,dispatchEvent:s,getRefIds:n}=e,{input:i}=n(),a=i.elm.value;t.setValue(a),t.closePopover(),s(new CustomEvent("input-change",{detail:{value:a},bubbles:!0})),r()},ma=(e,t)=>{let{store:r,render:s,dispatchEvent:n,getRefIds:i}=e,a=t._event;if(a.key==="Enter"){let{input:l}=i(),p=l.elm.value;r.closePopover(),n(new CustomEvent("input-change",{detail:{value:p},bubbles:!0})),s()}else a.key==="Escape"&&(r.closePopover(),s())};var Rt={};P(Rt,{closePopover:()=>_a,createInitialState:()=>ga,openPopover:()=>wa,selectValue:()=>Aa,selectViewData:()=>va,setTempValue:()=>ba,setValue:()=>xa});var ga=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},value:"",tempValue:""}),va=({attrs:e,state:t})=>{let r=t.value||"-";return{isOpen:t.isOpen,position:t.position,value:r,tempValue:t.tempValue,placeholder:e.placeholder??"",label:e.label}},ba=(e,t)=>{e.tempValue=t},wa=(e,t)=>{let{position:r}=t;e.position=r,e.isOpen=!0,e.hasUnsavedChanges=!1},_a=e=>{e.isOpen=!1,e.tempValue=""},xa=(e,t)=>{e.value=t},Aa=({state:e})=>e.value;var ss={elementName:"rtgl-popover-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string"},placeholder:{type:"string"}}},refs:{"text-display":{eventListeners:{click:{handler:"handleTextClick"}}},popover:{eventListeners:{close:{handler:"handlePopoverClose"}}},input:{eventListeners:{"input-change":{handler:"handleInputChange"},keydown:{handler:"handleInputKeydown"}}},submit:{eventListeners:{click:{handler:"handleSubmitClick"}}}},events:{"input-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view#text-display w=f cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"value"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=240 slot=content bgc=background br=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"label"}}],fast:!0},{type:8,properties:[{key:"rtgl-input#input w=f placeholder=${placeholder}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input w=f placeholder=",{type:1,path:"placeholder"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"rtgl-button#submit",value:{type:0,value:"Submit"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}]}}],fast:!0}],fast:!0}};var Nt={};P(Nt,{handleAddOptionClick:()=>La,handleAddOptionMouseEnter:()=>Ra,handleAddOptionMouseLeave:()=>Na,handleBeforeMount:()=>Ea,handleButtonClick:()=>$a,handleClearClick:()=>Ta,handleClickOptionsPopoverOverlay:()=>Sa,handleOnUpdate:()=>ka,handleOptionClick:()=>Ca,handleOptionMouseEnter:()=>Ia,handleOptionMouseLeave:()=>Oa});var Ea=e=>{let{store:t,props:r,render:s}=e;if(r.selectedValue!==null&&r.selectedValue!==void 0&&r.options){let n=r.options.find(i=>ce(i.value,r.selectedValue));n&&(t.updateSelectedValue({value:n?.value}),s())}},ka=(e,t)=>{let{oldAttrs:r,newAttrs:s,oldProps:n,newProps:i}=t,{store:a,render:l}=e;if(r?.key!==s?.key&&s?.key){a.resetSelection();let p=i?.selectedValue,o=i?.options||[];if(p!=null&&o){let c=o.find(u=>ce(u.value,p));c&&a.updateSelectedValue({value:c.value})}l()}else n.selectedValue!==i.selectedValue&&(a.updateSelectedValue({value:i.selectedValue}),l())},$a=(e,t)=>{let{store:r,render:s,getRefIds:n,props:i}=e;t._event.stopPropagation();let l=n()["select-button"].elm,p=l.firstElementChild,o=p?p.getBoundingClientRect():l.getBoundingClientRect(),c=r.selectSelectedValue(),u=c!==null?c:i.selectedValue,h=null;u!=null&&i.options&&(h=i.options.findIndex(f=>ce(f.value,u)),h===-1&&(h=null)),r.openOptionsPopover({position:{y:o.bottom+12,x:o.left-24},selectedIndex:h}),s()},Sa=e=>{let{store:t,render:r}=e;t.closeOptionsPopover(),r()},Ca=(e,t)=>{let{render:r,dispatchEvent:s,props:n,store:i}=e,a=t._event;a.stopPropagation();let l=a.currentTarget.id.replace("option-",""),p=n.options[l];i.updateSelectedValue({value:p?.value}),n.onChange&&typeof n.onChange=="function"&&n.onChange(p.value),s(new CustomEvent("option-selected",{detail:{value:p.value,label:p.label},bubbles:!0})),s(new CustomEvent("select-change",{detail:{selectedValue:p.value},bubbles:!0})),r()},Ia=(e,t)=>{let{store:r,render:s}=e,n=t._event,i=parseInt(n.currentTarget.id.replace("option-",""));r.setHoveredOption(i),s()},Oa=(e,t)=>{let{store:r,render:s}=e;r.clearHoveredOption(),s()},Ta=(e,t)=>{let{store:r,render:s,dispatchEvent:n,props:i}=e;t._event.stopPropagation(),r.clearSelectedValue(),i.onChange&&typeof i.onChange=="function"&&i.onChange(void 0),n(new CustomEvent("option-selected",{detail:{value:void 0,label:void 0},bubbles:!0})),n(new CustomEvent("select-change",{detail:{selectedValue:void 0},bubbles:!0})),s()},La=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,{_event:i}=t;i.stopPropagation(),r.closeOptionsPopover(),n(new CustomEvent("add-option-selected",{bubbles:!0})),s()},Ra=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!0),s()},Na=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!1),s()};var Pt={};P(Pt,{clearHoveredOption:()=>Ha,clearSelectedValue:()=>Ja,closeOptionsPopover:()=>Fa,createInitialState:()=>Da,openOptionsPopover:()=>Ma,resetSelection:()=>Ka,selectSelectedValue:()=>Wa,selectState:()=>Ba,selectViewData:()=>ja,setHoveredAddOption:()=>qa,setHoveredOption:()=>za,updateSelectedValue:()=>Ua});var Pa=["id","class","style","slot","placeholder","selectedValue","selected-value","onChange","on-change","options"],Va=e=>Object.entries(e||{}).filter(([t])=>!Pa.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Da=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},selectedValue:null,hoveredOptionId:null,hoveredAddOption:!1}),ja=({state:e,props:t,attrs:r})=>{let s=Va(r),n=e.selectedValue!==null?e.selectedValue:t.selectedValue,i=t.placeholder||r.placeholder||"Select an option",a=!0,l=t.options||[],p=l.find(c=>ce(c.value,n));p&&(i=p.label,a=!1);let o=l.map((c,u)=>{let h=ce(c.value,n),f=e.hoveredOptionId===u;return{...c,isSelected:h,bgc:f?"ac":h?"mu":""}});return{containerAttrString:s,isOpen:e.isOpen,position:e.position,options:o,selectedValue:n,selectedLabel:i,selectedLabelColor:a?"mu-fg":"fg",hasValue:n!=null,showClear:!r["no-clear"]&&!t["no-clear"]&&n!=null,showAddOption:!!t.addOption,addOptionLabel:t.addOption?.label?`+ ${t.addOption.label}`:"+ Add",addOptionBgc:e.hoveredAddOption?"ac":""}},Ba=({state:e})=>e,Wa=({state:e})=>e.selectedValue,Ma=(e,t)=>{let{position:r,selectedIndex:s}=t;e.position=r,e.isOpen=!0,s!=null&&(e.hoveredOptionId=s)},Fa=e=>{e.isOpen=!1},Ua=(e,t)=>{e.selectedValue=t.value,e.isOpen=!1},Ka=e=>{e.selectedValue=void 0},za=(e,t)=>{e.hoveredOptionId=t},Ha=e=>{e.hoveredOptionId=null},Ja=e=>{e.selectedValue=void 0},qa=(e,t)=>{e.hoveredAddOption=t};var is={elementName:"rtgl-select",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{placeholder:{type:"string"}}},propsSchema:{type:"object",properties:{placeholder:{type:"string"},options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}}}},selectedValue:{type:"any"},onChange:{type:"function"},"no-clear":{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}}}},refs:{"select-button":{eventListeners:{click:{handler:"handleButtonClick"}}},"clear-button":{eventListeners:{click:{handler:"handleClearClick"}}},popover:{eventListeners:{close:{handler:"handleClickOptionsPopoverOverlay"}}},"option-*":{eventListeners:{click:{handler:"handleOptionClick"},mouseenter:{handler:"handleOptionMouseEnter"},mouseleave:{handler:"handleOptionMouseLeave"}}},"option-add":{eventListeners:{click:{handler:"handleAddOptionClick"},mouseenter:{handler:"handleAddOptionMouseEnter"},mouseleave:{handler:"handleAddOptionMouseLeave"}}}},events:{},template:{type:9,items:[{type:8,properties:[{key:"rtgl-button#select-button v=ol ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=${selectedLabelColor} ellipsis",value:{type:1,path:"selectedLabel"},parsedKey:{type:2,parts:["rtgl-text c=",{type:1,path:"selectedLabelColor"}," ellipsis"]}}],fast:!0},{type:8,properties:[{key:"rtgl-view mh=md flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"$if showClear",value:{type:6,conditions:[{type:1,path:"showClear"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg#clear-button mr=md svg=x wh=16 c=mu-fg cur=p",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-svg svg=chevronDown wh=16 c=mu-fg",value:{type:0,value:null}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-button#select-button v=ol ",{type:1,path:"containerAttrString"}]}}],fast:!1},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} placement=right-start",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 g=xs slot=content bgc=background br=md sv=true",value:{type:9,items:[{type:7,itemVar:"option",indexVar:"i",iterable:{type:1,path:"options"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f ph=lg pv=md cur=p br=md bgc=${option.bgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"option.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"option.bgc"}]}}],fast:!0}],fast:!0}},{type:8,properties:[{key:"$if showAddOption",value:{type:6,conditions:[{type:1,path:"showAddOption"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f bw=xs bc=mu-bg bt=sm",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=${addOptionBgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=ac",value:{type:1,path:"addOptionLabel"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"addOptionBgc"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}," placement=right-start"]}}],fast:!1}],fast:!1}};var Vt={};P(Vt,{handleHeaderClick:()=>Ya,handleItemClick:()=>Ga});var Ya=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event,i,a=r.selectHeader();n.currentTarget.id==="header-label"?i=a.labelPath:n.currentTarget.id==="header-image"?i=a.image.path:n.currentTarget.id==="header"&&(i=a.path),s(new CustomEvent("headerClick",{detail:{path:i},bubbles:!0,composed:!0}))},Ga=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event.currentTarget.id.replace("item-",""),a=r.selectItem(i);s(new CustomEvent("itemClick",{detail:{item:a},bubbles:!0,composed:!0}))};var jt={};P(jt,{createInitialState:()=>Xa,selectActiveItem:()=>ro,selectHeader:()=>to,selectItem:()=>so,selectViewData:()=>eo,setState:()=>io});var Xa=()=>Object.freeze({}),Qa=["id","class","style","slot"],Za=e=>Object.entries(e).filter(([t])=>!Qa.includes(t)).map(([t,r])=>`${t}=${r}`).join(" ");function Dt(e,t=null){let r=[];for(let s of e){let n=s.id||s.href||s.path,i=t===n;if(r.push({id:n,title:s.title,href:s.href,type:s.type||"item",icon:s.icon,hrefAttr:s.href?`href=${s.href}`:"",isSelected:i,itemBgc:i?"ac":"bg",itemHoverBgc:i?"ac":"mu"}),s.items&&Array.isArray(s.items))for(let a of s.items){let l=a.id||a.href||a.path,p=t===l;r.push({id:l,title:a.title,href:a.href,type:a.type||"item",icon:a.icon,hrefAttr:a.href?`href=${a.href}`:"",isSelected:p,itemBgc:p?"ac":"bg",itemHoverBgc:p?"ac":"mu"})}}return r}var eo=({state:e,props:t,attrs:r})=>{let s=r.header?JSON.parse(decodeURIComponent(r.header)):t.header,n=r.items?JSON.parse(decodeURIComponent(r.items)):t.items,i=r.selectedItemId||t.selectedItemId,a=Za(r),l=r.mode||"full",p=s||{label:"",path:"",image:{src:"",alt:"",width:0,height:0}},o=n?Dt(n,i):[],c=l==="full"?272:64,u=l==="full"?"fs":"c",h=l==="full"?"fs":"c",f=l==="full"?"lg":"sm",d=l==="full"?"md":"sm",y=l==="shrunk-lg"?48:40,b=l==="shrunk-lg"?28:20,m=l==="shrunk-lg"?"md":"sm",w=l==="full",_=l==="full",x=l==="full"?"fs":"c",E=l==="full"?"":`ah=${h}`,$=l==="full"?"f":y;return{containerAttrString:a,mode:l,header:p,items:o,sidebarWidth:c,headerAlign:u,itemAlign:h,headerPadding:f,itemPadding:d,itemHeight:y,iconSize:b,firstLetterSize:m,showLabels:w,showGroupLabels:_,itemContentAlign:x,itemAlignAttr:E,itemWidth:$,headerWidth:$,selectedItemId:i,ah:l==="shrunk-lg"||l==="shrunk-md"?"c":""}},to=({state:e,props:t,attrs:r})=>r.header?JSON.parse(decodeURIComponent(r.header)):t.header,ro=({state:e,props:t})=>(t.items?Dt(t.items):[]).find(s=>s.active),so=({state:e,props:t,attrs:r},s)=>{let n=r.items?JSON.parse(decodeURIComponent(r.items)):t.items;return(n?Dt(n):[]).find(a=>a.id===s)},io=e=>{};var ns={elementName:"rtgl-sidebar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},mode:{type:"string",enum:["full","shrunk","shrunk-lg"],default:"full"},sidebarWidth:{type:"number"},headerAlign:{type:"string"},itemAlign:{type:"string"},headerPadding:{type:"string"},itemPadding:{type:"string"},itemHeight:{type:"number"},iconSize:{type:"number"},firstLetterSize:{type:"string"},showLabels:{type:"boolean"},showGroupLabels:{type:"boolean"},itemContentAlign:{type:"string"},itemAlignAttr:{type:"string"},itemWidth:{type:"string"},headerWidth:{type:"string"},selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},active:{type:"boolean"},icon:{type:"string"}}}}}},propsSchema:{type:"object",properties:{selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},items:{type:"array"}}}}}},refs:{"header-image":{eventListeners:{click:{handler:"handleHeaderClick"}}},"header-label":{eventListeners:{click:{handler:"handleHeaderClick"}}},header:{eventListeners:{click:{handler:"handleHeaderClick"}}},"item-*":{eventListeners:{click:{handler:"handleItemClick"}}}},events:{headerClick:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"$if header.image && header.image.src":[{"$if header.image.href":[{"a href=${header.image.href}":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],"$elif header.image.path":[{"rtgl-view#header-image cur=p":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],$else:[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}]},{"$if header.label && showLabels":[{"$if header.labelHref":[{"rtgl-text href=${header.labelHref} s=lg":"${header.label}"}],"$elif header.labelPath":[{"rtgl-view#header-label cur=p":[{"rtgl-text s=lg":"${header.label}"}]}],$else:[{"rtgl-text s=lg":"${header.label}"}]}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=${sidebarWidth} bwr=xs ah=${ah} ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view ph=${headerPadding} pv=lg",value:{type:9,items:[{type:8,properties:[{key:"$if header.href",value:{type:6,conditions:[{type:1,path:"header.href"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view href=${header.href} d=h av=c ah=${headerAlign} g=lg w=${headerWidth}",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view href=",{type:1,path:"header.href"}," d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header d=h av=c ah=${headerAlign} g=lg w=${headerWidth} cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#header d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view ph=",{type:1,path:"headerPadding"}," pv=lg"]}}],fast:!1},{type:8,properties:[{key:"rtgl-view w=f ph=${headerPadding} pb=lg g=xs ah=${ah}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'$if item.type == "groupLabel"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"groupLabel"}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showGroupLabels",value:{type:6,conditions:[{type:1,path:"showGroupLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=32 av=c ph=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=xs c=mu-fg",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=1 bgc=mu-bg",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} ${item.hrefAttr} h=${itemHeight} av=c ${itemAlignAttr} ph=${itemPadding} w=${itemWidth} h-bgc=${item.itemHoverBgc} br=lg bgc=${item.itemBgc} cur=p",value:{type:9,items:[{type:8,properties:[{key:"$if item.icon",value:{type:6,conditions:[{type:1,path:"item.icon"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=${itemContentAlign} g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h ah=",{type:1,path:"itemContentAlign"}," g=sm"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=${iconSize} svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=",{type:1,path:"iconSize"}," svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=${iconSize} br=f bgc=mu av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=${firstLetterSize} c=fg",value:{type:1,path:"item.title.charAt(0).toUpperCase()"},parsedKey:{type:2,parts:["rtgl-text s=",{type:1,path:"firstLetterSize"}," c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view wh=",{type:1,path:"iconSize"}," br=f bgc=mu av=c ah=c"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," ",{type:1,path:"item.hrefAttr"}," h=",{type:1,path:"itemHeight"}," av=c ",{type:1,path:"itemAlignAttr"}," ph=",{type:1,path:"itemPadding"}," w=",{type:1,path:"itemWidth"}," h-bgc=",{type:1,path:"item.itemHoverBgc"}," br=lg bgc=",{type:1,path:"item.itemBgc"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f ph=",{type:1,path:"headerPadding"}," pb=lg g=xs ah=",{type:1,path:"ah"}]}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view h=f w=",{type:1,path:"sidebarWidth"}," bwr=xs ah=",{type:1,path:"ah"}," ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Bt={};P(Bt,{handleBeforeMount:()=>no,handleOnUpdate:()=>ao,handleValueChange:()=>oo});var no=e=>{let{store:t,attrs:r}=e;t.setValue(r.value??0)},ao=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:n,render:i}=e;if(r?.value!==s?.value){let a=s?.value??0;n.setValue(a),i()}},oo=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,i=t._event,a=Number(i.detail.value);r.setValue(a),s(),n(new CustomEvent("slider-input-value-change",{detail:{value:a},bubbles:!0}))};var Wt={};P(Wt,{createInitialState:()=>lo,selectViewData:()=>po,setValue:()=>co});var lo=()=>Object.freeze({value:0}),po=({state:e,attrs:t})=>({key:t.key,value:e.value,w:t.w||"",min:t.min||0,max:t.max||100,step:t.step||1}),co=(e,t)=>{e.value=t};var as={elementName:"rtgl-slider-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string",default:"0"},w:{type:"string",default:""},min:{type:"string",default:"0"},max:{type:"string",default:"100"},step:{type:"string",default:"1"}}},refs:{input:{eventListeners:{"input-change":{handler:"handleValueChange"}}},slider:{eventListeners:{"slider-change":{handler:"handleValueChange"}}}},events:{"form-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md w=${w}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-slider#slider key=${key} w=f type=range min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#slider key=",{type:1,path:"key"}," w=f type=range min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=84",value:{type:9,items:[{type:8,properties:[{key:"rtgl-input#input key=${key} w=f type=number min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input key=",{type:1,path:"key"}," w=f type=number min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md w=",{type:1,path:"w"}]}}],fast:!0}],fast:!0}};var Mt={};P(Mt,{handleBeforeMount:()=>uo,handleHeaderClick:()=>fo,handleRowClick:()=>ho});var uo=e=>{},ho=(e,t)=>{let{dispatchEvent:r,props:s}=e,n=t._event,i=parseInt(n.currentTarget.id.replace("row-","")),a=s.data?.rows?.[i];a&&r(new CustomEvent("row-click",{detail:{rowIndex:i,rowData:a}}))},fo=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,a=t._event.currentTarget.id.replace("header-",""),l=r.selectSortInfo(),p="asc";l.column===a&&(l.direction==="asc"?p="desc":l.direction==="desc"&&(p=null)),p?r.setSortColumn({column:a,direction:p}):r.clearSort(),s(),n(new CustomEvent("header-click",{detail:{column:a,direction:p,sortInfo:p?{column:a,direction:p}:null}}))};var Ft={};P(Ft,{clearSort:()=>Ao,createInitialState:()=>yo,selectSortInfo:()=>_o,selectState:()=>wo,selectViewData:()=>bo,setSortColumn:()=>xo});var yo=()=>Object.freeze({sortColumn:null,sortDirection:null}),mo=["id","class","style","slot"],go=e=>Object.entries(e).filter(([t])=>!mo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),vo=(e,t)=>{let r=t.split("."),s=e;for(let n of r){if(s==null)return null;s=s[n]}return s},bo=({state:e,props:t,attrs:r})=>{let s=go(r),n=t.data||{columns:[],rows:[]},i=n.rows.map((a,l)=>{let p=n.columns.map(o=>{let c=vo(a,o.key);return{key:o.key,value:c!=null?String(c):""}});return{index:l,cells:p}});return{containerAttrString:s,columns:n.columns||[],rows:i||[]}},wo=({state:e})=>e,_o=({state:e})=>({column:e.sortColumn,direction:e.sortDirection}),xo=(e,{column:t,direction:r})=>{e.sortColumn=t,e.sortDirection=r},Ao=e=>{e.sortColumn=null,e.sortDirection=null};var os={elementName:"rtgl-table",viewDataSchema:{type:"object",properties:{columns:{type:"array"},rows:{type:"array"},containerAttrString:{type:"string"}}},propsSchema:{type:"object",properties:{data:{type:"object",properties:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"}}}},rows:{type:"array",items:{type:"object"}}}},responsive:{type:"boolean",default:!0}}},refs:{"row-*":{eventListeners:{click:{handler:"handleRowClick"}}},"header-*":{eventListeners:{click:{handler:"handleHeaderClick"}}}},events:{},styles:{table:{width:"100%","border-collapse":"collapse","border-spacing":0},thead:{"border-bottom":"2px solid var(--border)"},th:{padding:"12px","text-align":"left","font-weight":500,color:"var(--foreground)","background-color":"var(--muted)",cursor:"pointer",position:"sticky",top:0,"z-index":1},"tbody tr":{"border-bottom":"1px solid var(--border)"},"tbody tr:last-child":{"border-bottom":"none"},td:{padding:"12px",color:"var(--foreground)"},".table-container":{width:"100%",height:"100%",overflow:"auto"},".empty-state":{"text-align":"center",padding:"24px",color:"var(--muted-foreground)"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view.table-container ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if rows.length > 0",value:{type:6,conditions:[{type:4,op:2,left:{type:1,path:"rows.length"},right:{type:0,value:0}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"table",value:{type:9,items:[{type:8,properties:[{key:"thead",value:{type:9,items:[{type:8,properties:[{key:"tr",value:{type:9,items:[{type:7,itemVar:"column",indexVar:"i",iterable:{type:1,path:"columns"},body:{type:9,items:[{type:8,properties:[{key:"th#header-${column.key}",value:{type:1,path:"column.label"},parsedKey:{type:2,parts:["th#header-",{type:1,path:"column.key"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"tbody",value:{type:9,items:[{type:7,itemVar:"row",indexVar:"rowIndex",iterable:{type:1,path:"rows"},body:{type:9,items:[{type:8,properties:[{key:"tr#row-${row.index}",value:{type:9,items:[{type:7,itemVar:"cell",indexVar:"cellIndex",iterable:{type:1,path:"row.cells"},body:{type:9,items:[{type:8,properties:[{key:"td",value:{type:1,path:"cell.value"}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["tr#row-",{type:1,path:"row.index"}]}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view.empty-state w=f p=xl",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"No data available"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view.table-container ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ut={};P(Ut,{handleClickItem:()=>Eo});var Eo=(e,t)=>{let{dispatchEvent:r}=e,n=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:n}}))};var Kt={};P(Kt,{createInitialState:()=>ko,selectViewData:()=>Co});var ko=()=>Object.freeze({}),$o=["id","class","style","slot"],So=e=>Object.entries(e).filter(([t])=>!$o.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Co=({state:e,props:t,attrs:r})=>{let s=So(r),n=t.items||[],i=r["selected-tab"],a=n.map(l=>({...l,isSelected:l.id===i,bgColor:l.id===i?"ac":"",borderColor:l.id===i?"":"tr",textColor:l.id===i?"":"mu-fg"}));return{containerAttrString:s,items:a,selectedTab:i}};var ls={elementName:"rtgl-tabs",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"},isSelected:{type:"boolean"},bgColor:{type:"string"},textColor:{type:"string"},borderColor:{type:"string"}}}},selectedTab:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}}}},attrsSchema:{type:"object",properties:{"selected-tab":{type:"string"}}},refs:{"tab-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{id:{type:"string"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=sm bgc=mu p=sm br=lg ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#tab-${item.id} data-id=${item.id} cur=p bgc=${item.bgColor} bw=xs bc=${item.borderColor} pv=md ph=lg br=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=${item.textColor}",value:{type:1,path:"item.label"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.textColor"}]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#tab-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p bgc=",{type:1,path:"item.bgColor"}," bw=xs bc=",{type:1,path:"item.borderColor"}," pv=md ph=lg br=lg"]}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h g=sm bgc=mu p=sm br=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var ps={};var zt={};P(zt,{createInitialState:()=>Io,selectViewData:()=>Oo});var Io=()=>Object.freeze({}),Oo=({attrs:e})=>({open:!!e.open,x:e.x||0,y:e.y||0,placement:e.placement||"top",content:e.content||""});var cs={elementName:"rtgl-tooltip",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"},content:{type:"string"}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement} no-overlay",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content bgc=background bc=border br=md p=sm ah=c av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text ta=c s=sm c=foreground",value:{type:1,path:"content"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}," no-overlay"]}}],fast:!0}],fast:!0}};var Ht={};P(Ht,{handleAfterMount:()=>To,handleOnUpdate:()=>Lo});var To=async e=>{let{props:t,store:r,render:s,getRefIds:n}=e,{waveformData:i}=t;r.setWaveformData(i),s();let a=n().canvas?.elm;a&&us(i,a)},Lo=async(e,t)=>{let{store:r,render:s,getRefIds:n,props:i}=e,{waveformData:a}=i;if(!a){console.log("waveform handleOnUpdate: no waveformData provided");return}r.setWaveformData(a),s();let l=n().canvas?.elm;l&&us(a,l)};async function us(e,t){let r=t.getContext("2d"),s=t.getBoundingClientRect(),n=s.width,i=s.height;t.width=n,t.height=i;let a=t.width,l=t.height;if(r.clearRect(0,0,a,l),r.fillStyle="#1a1a1a",r.fillRect(0,0,a,l),!e||!e.amplitudes)return;let p=e.amplitudes,o=l/2,c=r.createLinearGradient(0,0,0,l);c.addColorStop(0,"#404040"),c.addColorStop(.5,"#A1A1A1"),c.addColorStop(1,"#404040");let u=Math.max(1,a/p.length),h=.2;for(let f=0;f<p.length;f++){let y=p[f]/255*(l*.85),b=f*u,m=o-y/2;r.fillStyle=c,r.fillRect(b,m,Math.max(1,u*(1-h)),y)}r.strokeStyle="rgba(255, 255, 255, 0.1)",r.lineWidth=1,r.beginPath(),r.moveTo(0,o),r.lineTo(a,o),r.stroke(),r.shadowBlur=10,r.shadowColor="#2196F3"}var Jt={};P(Jt,{createInitialState:()=>Ro,selectViewData:()=>Po,setWaveformData:()=>No});var Ro=()=>Object.freeze({waveformData:null}),No=(e,t)=>{e.waveformData=t},Po=({state:e,attrs:t,props:r})=>({isLoading:r.isLoading,w:t.w||"250",h:t.h||"150",cur:t.cur,waveformData:r.waveformData});var hs={elementName:"rtgl-waveform",attrsSchema:{type:"object",properties:{w:{type:"string",description:"Width of the waveform visualizer",default:"250"},h:{type:"string",description:"Height of the waveform visualizer",default:"150"},cur:{type:"string",description:"cursor"}}},propsSchema:{type:"object",properties:{waveformData:{type:"object",description:"File ID of the waveform data in object storage"},isLoading:{type:"boolean",description:"Whether the waveform data is currently being loaded"}}},refs:{canvas:{selector:"canvas"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f pos=rel w=${w} h=${h} cur=${cur}",value:{type:9,items:[{type:8,properties:[{key:"$if isLoading",value:{type:6,conditions:[{type:1,path:"isLoading"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"..."}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'canvas#canvas style="width:100%; height:100%;"',value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f h=f pos=rel w=",{type:1,path:"w"}," h=",{type:1,path:"h"}," cur=",{type:1,path:"cur"}]}}],fast:!1}],fast:!1}};var vs=Symbol.for("immer-nothing"),ds=Symbol.for("immer-draftable"),se=Symbol.for("immer-state");function le(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ae=Object.getPrototypeOf;function Ee(e){return!!e&&!!e[se]}function ye(e){return e?bs(e)||Array.isArray(e)||!!e[ds]||!!e.constructor?.[ds]||qe(e)||Ye(e):!1}var Vo=Object.prototype.constructor.toString();function bs(e){if(!e||typeof e!="object")return!1;let t=Ae(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Vo}function Ke(e,t){Je(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,s)=>t(s,r,e))}function Je(e){let t=e[se];return t?t.type_:Array.isArray(e)?1:qe(e)?2:Ye(e)?3:0}function Gt(e,t){return Je(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ws(e,t,r){let s=Je(e);s===2?e.set(t,r):s===3?e.add(r):e[t]=r}function Do(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qe(e){return e instanceof Map}function Ye(e){return e instanceof Set}function fe(e){return e.copy_||e.base_}function Xt(e,t){if(qe(e))return new Map(e);if(Ye(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=bs(e);if(t===!0||t==="class_only"&&!r){let s=Object.getOwnPropertyDescriptors(e);delete s[se];let n=Reflect.ownKeys(s);for(let i=0;i<n.length;i++){let a=n[i],l=s[a];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[a]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[a]})}return Object.create(Ae(e),s)}else{let s=Ae(e);if(s!==null&&r)return{...e};let n=Object.create(s);return Object.assign(n,e)}}function rr(e,t=!1){return Ge(e)||Ee(e)||!ye(e)||(Je(e)>1&&(e.set=e.add=e.clear=e.delete=jo),Object.freeze(e),t&&Object.entries(e).forEach(([r,s])=>rr(s,!0))),e}function jo(){le(2)}function Ge(e){return Object.isFrozen(e)}var Bo={};function me(e){let t=Bo[e];return t||le(0,e),t}var Re;function _s(){return Re}function Wo(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function fs(e,t){t&&(me("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Qt(e){Zt(e),e.drafts_.forEach(Mo),e.drafts_=null}function Zt(e){e===Re&&(Re=e.parent_)}function ys(e){return Re=Wo(Re,e)}function Mo(e){let t=e[se];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ms(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[se].modified_&&(Qt(t),le(4)),ye(e)&&(e=ze(t,e),t.parent_||He(t,e)),t.patches_&&me("Patches").generateReplacementPatches_(r[se].base_,e,t.patches_,t.inversePatches_)):e=ze(t,r,[]),Qt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==vs?e:void 0}function ze(e,t,r){if(Ge(t))return t;let s=t[se];if(!s)return Ke(t,(n,i)=>gs(e,s,t,n,i,r)),t;if(s.scope_!==e)return t;if(!s.modified_)return He(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;let n=s.copy_,i=n,a=!1;s.type_===3&&(i=new Set(n),n.clear(),a=!0),Ke(i,(l,p)=>gs(e,s,n,l,p,r,a)),He(e,n,!1),r&&e.patches_&&me("Patches").generatePatches_(s,r,e.patches_,e.inversePatches_)}return s.copy_}function gs(e,t,r,s,n,i,a){if(Ee(n)){let l=i&&t&&t.type_!==3&&!Gt(t.assigned_,s)?i.concat(s):void 0,p=ze(e,n,l);if(ws(r,s,p),Ee(p))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(ye(n)&&!Ge(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ze(e,n),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,s)&&He(e,n)}}function He(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&rr(t,r)}function Fo(e,t){let r=Array.isArray(e),s={type_:r?1:0,scope_:t?t.scope_:_s(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=s,i=sr;r&&(n=[s],i=Ne);let{revoke:a,proxy:l}=Proxy.revocable(n,i);return s.draft_=l,s.revoke_=a,l}var sr={get(e,t){if(t===se)return e;let r=fe(e);if(!Gt(r,t))return Uo(e,r,t);let s=r[t];return e.finalized_||!ye(s)?s:s===qt(e.base_,t)?(Yt(e),e.copy_[t]=tr(s,e)):s},has(e,t){return t in fe(e)},ownKeys(e){return Reflect.ownKeys(fe(e))},set(e,t,r){let s=xs(fe(e),t);if(s?.set)return s.set.call(e.draft_,r),!0;if(!e.modified_){let n=qt(fe(e),t),i=n?.[se];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Do(r,n)&&(r!==void 0||Gt(e.base_,t)))return!0;Yt(e),er(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return qt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Yt(e),er(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=fe(e),s=Reflect.getOwnPropertyDescriptor(r,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:r[t]}},defineProperty(){le(11)},getPrototypeOf(e){return Ae(e.base_)},setPrototypeOf(){le(12)}},Ne={};Ke(sr,(e,t)=>{Ne[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ne.deleteProperty=function(e,t){return Ne.set.call(this,e,t,void 0)};Ne.set=function(e,t,r){return sr.set.call(this,e[0],t,r,e[0])};function qt(e,t){let r=e[se];return(r?fe(r):e)[t]}function Uo(e,t,r){let s=xs(t,r);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}function xs(e,t){if(!(t in e))return;let r=Ae(e);for(;r;){let s=Object.getOwnPropertyDescriptor(r,t);if(s)return s;r=Ae(r)}}function er(e){e.modified_||(e.modified_=!0,e.parent_&&er(e.parent_))}function Yt(e){e.copy_||(e.copy_=Xt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ko=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,s)=>{if(typeof t=="function"&&typeof r!="function"){let i=r;r=t;let a=this;return function(p=i,...o){return a.produce(p,c=>r.call(this,c,...o))}}typeof r!="function"&&le(6),s!==void 0&&typeof s!="function"&&le(7);let n;if(ye(t)){let i=ys(this),a=tr(t,void 0),l=!0;try{n=r(a),l=!1}finally{l?Qt(i):Zt(i)}return fs(i,s),ms(n,i)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===vs&&(n=void 0),this.autoFreeze_&&rr(n,!0),s){let i=[],a=[];me("Patches").generateReplacementPatches_(t,n,i,a),s(i,a)}return n}else le(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(a,...l)=>this.produceWithPatches(a,p=>t(p,...l));let s,n;return[this.produce(t,r,(a,l)=>{s=a,n=l}),s,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ye(e)||le(8),Ee(e)&&(e=zo(e));let t=ys(this),r=tr(e,void 0);return r[se].isManual_=!0,Zt(t),r}finishDraft(e,t){let r=e&&e[se];(!r||!r.isManual_)&&le(9);let{scope_:s}=r;return fs(s,t),ms(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let s=me("Patches").applyPatches_;return Ee(e)?s(e,t):this.produce(e,n=>s(n,t))}};function tr(e,t){let r=qe(e)?me("MapSet").proxyMap_(e,t):Ye(e)?me("MapSet").proxySet_(e,t):Fo(e,t);return(t?t.scope_:_s()).drafts_.push(r),r}function zo(e){return Ee(e)||le(10,e),As(e)}function As(e){if(!ye(e)||Ge(e))return e;let t=e[se],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Xt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Xt(e,!0);return Ke(r,(s,n)=>{ws(r,s,As(n))}),t&&(t.finalized_=!1),r}var ie=new Ko,Es=ie.produce,wu=ie.produceWithPatches.bind(ie),_u=ie.setAutoFreeze.bind(ie),xu=ie.setUseStrictShallowCopy.bind(ie),Au=ie.applyPatches.bind(ie),Eu=ie.createDraft.bind(ie),ku=ie.finishDraft.bind(ie);var g={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},M={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Pe={NOT:0};var R=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Q=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var ir=e=>{if(!e||e.trim()==="")throw new R("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new R(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new R(`Incomplete comparison expression - missing right operand (got: '${e}')`)},ks=e=>{if(e.trim().endsWith(" in"))throw new R(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new R(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new R(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(n=>n.trim());for(let n of s)if(!n)throw new R(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new R(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var $s=(e,t,r=!1)=>{if(t===null)return new Q(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Q(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new Q(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new Q(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},Ss=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Q(`Unknown function '${e}' (${r})`)};var Ho=(e,t,r={})=>{let s={},n={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},n=r.partials||{}):typeof r=="object"&&(s=r));let a=T(e,{functions:s,partials:n},t,{});return a===void 0?{}:a},T=(e,t,r,s)=>{let n=t.functions||t;if(e.var&&!e.type)return H(e.var,r,s);if(e.type===g.LITERAL)return e.value;if(e.type===g.VARIABLE)return H(e.path,r,s);if(e.type===g.INTERPOLATION)return qo(e.parts,t,r,s);switch(e.type){case g.FUNCTION:return Is(e,t,r,s);case g.BINARY:return Os(e,t,r,s);case g.UNARY:return Ts(e,t,r,s);case g.CONDITIONAL:return Go(e,t,r,s);case g.LOOP:return tl(e,t,r,s);case g.OBJECT:return sl(e,t,r,s);case g.ARRAY:return il(e,t,r,s);case g.PARTIAL:return nl(e,t,r,s);case g.PATH_REFERENCE:return al(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},Cs=new Map,Jo=e=>{let t=[],r="",s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(i==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(i==="]"){if(s&&r){let a=r.trim();if(/^\d+$/.test(a))t.push({type:"index",value:parseInt(a,10)});else if(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")){let l=a.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:a});r=""}s=!1}else r+=i}return r&&t.push({type:"property",value:r}),t},H=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=Cs.get(e);if(!s){let i=[],a="",l=0;for(let p=0;p<e.length;p++){let o=e[p];o==="["?(l++,a+=o):o==="]"?(l--,a+=o):o==="."&&l===0?a&&(i.push(a),a=""):a+=o}a&&i.push(a),s=[];for(let p of i){let o=Jo(p.trim());s.push(...o)}Cs.set(e,s)}let n=t;for(let i=0;i<s.length;i++){let a=s[i];if(a.type==="property"&&a.value in r){n=r[a.value];continue}if(n==null)return;(a.type==="property"||a.type==="index")&&(n=n[a.value])}return n},qo=(e,t,r,s)=>{let n=[];for(let i of e)if(typeof i=="string")n.push(i);else{let a=T(i,t,r,s);n.push(a!=null?String(a):"")}return n.join("")},Is=(e,t,r,s)=>{let n=t.functions||t,i=n[e.name];if(!i)throw Ss(e.name,n);let a=e.args.map(l=>T(l,t,r,s));return i(...a)},ke=(e,t,r,s)=>{if(e.var&&!e.type)return H(e.var,r,s);switch(e.type){case g.VARIABLE:return H(e.path,r,s);case g.LITERAL:return e.value;case g.BINARY:return Os(e,t,r,s);case g.UNARY:return Ts(e,t,r,s);case g.FUNCTION:return Is(e,t,r,s);default:return T(e,t,r,s)}},Os=(e,t,r,s)=>{if(e.op===M.AND||e.op===M.OR){let a=ke(e.left,t,r,s),l=ke(e.right,t,r,s);switch(e.op){case M.AND:return a&&l;case M.OR:return a||l}}let n=T(e.left,t,r,s),i=T(e.right,t,r,s);switch(e.op){case M.EQ:return n==i;case M.NEQ:return n!=i;case M.GT:return n>i;case M.LT:return n<i;case M.GTE:return n>=i;case M.LTE:return n<=i;case M.IN:return Array.isArray(i)?i.includes(n):!1;case M.ADD:if(typeof n!="number"||typeof i!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof n} + ${typeof i}`);return n+i;case M.SUBTRACT:if(typeof n!="number"||typeof i!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof n} - ${typeof i}`);return n-i;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ts=(e,t,r,s)=>{let n=e.op===Pe.NOT?ke(e.operand,t,r,s):T(e.operand,t,r,s);switch(e.op){case Pe.NOT:return!n;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Yo=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let n=e.conditions[0];if(n.type===g.VARIABLE)if(H(n.path,r,s)){let a=e.bodies[0];if(a.type===g.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[o]=c.value;else if(c.type===g.VARIABLE)l[o]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=T(c,t,r,s)}return l}}else{let a=e.bodies[1];if(a.type===g.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[o]=c.value;else if(c.type===g.VARIABLE)l[o]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=T(c,t,r,s)}return l}}}return null},Go=(e,t,r,s)=>{let n=Yo(e,t,r,s);if(n!==null)return n;for(let i=0;i<e.conditions.length;i++){let a=e.conditions[i];if(a===null||ke(a,t,r,s))return T(e.bodies[i],t,r,s)}return Ls},Xo=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===g.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===g.VARIABLE){let n=r.conditions[0].path,i=r.bodies[0];if(n.startsWith(s+".")){let a=n.substring(s.length+1);if(i.type===g.OBJECT&&i.properties.length<=5){for(let p of i.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let o=t[p];if(o[a]){let c={};for(let u of i.properties){let h=u.key,f=u.value;if(f.type===g.LITERAL)c[h]=f.value;else if(f.type===g.VARIABLE){let d=f.path;if(d===s)c[h]=o;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=o[y]}else return null}else if(f.type===g.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===g.VARIABLE){let m=b.path;if(m===s)d.push(o!=null?String(o):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=o[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},Qo=(e,t)=>{let r=e.body,s=e.itemVar,n=Xo(e,t);if(n!==null)return n;if(r.type===g.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let i=[],a=!0;for(let l of r.properties){let p=l.key,o=l.value;if(o.type===g.LITERAL)i.push({key:p,type:"literal",value:o.value});else if(o.type===g.VARIABLE){let c=o.path;if(c===s)i.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))i.push({key:p,type:"prop",prop:u});else{a=!1;break}}else{a=!1;break}}else if(o.type===g.INTERPOLATION&&o.parts.length===1){let c=o.parts[0];if(c.type===g.VARIABLE){let u=c.path;if(u===s)i.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))i.push({key:p,type:"prop_string",prop:h});else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}if(a){let l=new Array(t.length);if(i.length===3&&i[0].type==="prop"&&i[0].key==="id"&&i[1].type==="prop_string"&&i[1].key==="title"&&i[2].type==="prop"&&i[2].key==="completed")for(let p=0;p<t.length;p++){let o=t[p];l[p]={id:o.id,title:o.title!=null?String(o.title):"",completed:o.completed}}else for(let p=0;p<t.length;p++){let o=t[p],c={};for(let u of i)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=o;else if(u.type==="prop")c[u.key]=o[u.prop];else if(u.type==="item_string")c[u.key]=o!=null?String(o):"";else if(u.type==="prop_string"){let h=o[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},Zo=(e,t,r,s,n)=>{let i=[],a=e.body;if(a.type===g.OBJECT&&a.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let o=0;o<n.length;o++){let c=n[o],u={},h={...s,[l]:c,...p&&{[p]:o}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${o}]`,...p&&{[p]:o}};for(let d of a.properties){let y=d.parsedKey?T(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===g.LITERAL)u[y]=b.value;else if(b.type===g.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=o;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:o}})}else u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:o}})}else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=o;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=H(_,r,{...s,[l]:c,...p&&{[p]:o}})}else x=H(_,r,{...s,[l]:c,...p&&{[p]:o}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:o}},x=T(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:o}};u[y]=T(b,t,r,m)}}i.push(u)}return i}return null},el=(e,t,r)=>{let s=e.body;if(s.type===g.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let i=s.properties[0].value;if(i.type===g.CONDITIONAL&&i.conditions.length===1&&i.conditions[0].type===g.VARIABLE&&i.conditions[0].path==="item.visible"){let a=i.bodies[0];if(a.type===g.OBJECT&&a.properties.length===2){let l=a.properties[0],p=a.properties[1];if(l.key==="id"&&l.value.type===g.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===g.CONDITIONAL){let o=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),o.push(h)}}return o}}}}return null},tl=(e,t,r,s)=>{let n=T(e.iterable,t,r,s);if(!Array.isArray(n)){let o,c=!1;if(e.iterable.type===g.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===g.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===g.VARIABLE?f.path:f.type===g.FUNCTION?`${f.name}(...)`:"?").join(", ");o=`${e.iterable.name}(${h})`}else o=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${o}`;throw $s(u,n,c)}if(!e.indexVar){let o=el(e,n,e.itemVar);if(o!==null)return o}if(!e.indexVar){let o=Qo(e,n);if(o!==null)return o}let i=Zo(e,t,r,s,n);if(i!==null)return i;let a=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let o=l.split("."),c=o[0];c in s.__paths__&&(l=s.__paths__[c],o.length>1&&(l+="."+o.slice(1).join(".")))}let p=!1;e.body.type===g.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(o=>o.type===g.OBJECT&&o.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let o=0;o<n.length;o++){let c=e.indexVar?{...s,[e.itemVar]:n[o],[e.indexVar]:o}:{...s,[e.itemVar]:n[o]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${o}]`},e.indexVar&&(c.__paths__[e.indexVar]=o);let u=T(e.body,t,r,c);Array.isArray(u)&&u.length===1&&!p?a.push(u[0]):a.push(u)}return a},rl=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let n=e.properties[0],i=n.parsedKey?T(n.parsedKey,t,r,s):n.key,a=n.value;if(a.type===g.OBJECT&&a.properties.length<=10&&!a.whenCondition){let l={},p={},o=!0;for(let c of a.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)p[u]=h.value;else if(h.type===g.VARIABLE)p[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{o=!1;break}if(!o)break;p[u]=f.join("")}else if(h.type===g.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===g.LITERAL)f[y]=b.value;else if(b.type===g.VARIABLE)f[y]=H(b.path,r,s);else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=H(w.path,r,s);m.push(_!=null?String(_):"")}else{o=!1;break}if(!o)break;f[y]=m.join("")}else{o=!1;break}}if(!o)break;p[u]=f}else{o=!1;break}}if(o)return l[i]=p,l}}return null},sl=(e,t,r,s)=>{let n=t.functions||t;if(e.whenCondition&&!ke(e.whenCondition,n,r,s))return;let i=rl(e,t,r,s);if(i!==null)return i;if(e.fast){let o={};for(let c of e.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)o[u]=h.value;else if(h.type===g.VARIABLE)o[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=T(d,t,r,s);f.push(y!=null?String(y):"")}o[u]=f.join("")}else o[u]=T(h,t,r,s)}return o}let a={},l=null,p=!1;for(let o of e.properties)if(!o.key.startsWith("$if ")&&!o.key.match(/^\$if\s+\w+.*:?$/)&&!o.key.startsWith("$elif")&&!o.key.startsWith("$else")&&!o.key.startsWith("$for ")){p=!0;break}for(let o of e.properties)if(o.key.startsWith("$if ")||o.key.match(/^\$if\s+\w+.*:?$/)){let c=T(o.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(a,c)}else if(o.key.startsWith("$for ")){if(e.properties.length===1)return T(o.value,t,r,s)}else{let c=o.value;if(c&&c.type===g.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=T(u.value,t,r,s);h!==void 0&&(a[o.key]=h)}else{let h=T(o.value,t,r,s);h!==void 0&&(a[o.key]=h)}}else{let u=o.parsedKey?T(o.parsedKey,t,r,s):o.key,h=T(o.value,t,r,s);h!==void 0&&(a[u]=h)}}return a},Ls={},il=(e,t,r,s)=>{let n=[];for(let i of e.items)if(i.type===g.LOOP){let a=T(i,t,r,s);n.push(a)}else{let a=T(i,t,r,s);a!==Ls&&a!==void 0&&n.push(a)}return n},nl=(e,t,r,s)=>{let{name:n,data:i,whenCondition:a}=e,l=t.partials||{},p=t.functions||t;if(a&&!ke(a,p,r,s))return;if(!l[n])throw new Q(`Partial '${n}' is not defined`);let o=s._partialStack||[];if(o.includes(n))throw new Q(`Circular partial reference detected: ${n}`);let c=l[n],u=r,h={...s,_partialStack:[...o,n]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(i){let f=T(i,t,r,s);u={...u,...f}}return T(c,t,u,h)},al=(e,t,r,s)=>{let{path:n}=e,i=n.split("."),a=i[0],l=i.slice(1);if(!s||!(a in s))throw new Q(`Path reference '#{${n}}' refers to '${a}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(a in s.__paths__))throw new Q(`Path reference '#{${n}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[a];if(typeof p=="number"){if(l.length>0)throw new Q(`Path reference '#{${n}}' - cannot access properties on index variable '${a}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},Ve=Ho;var ol=/\$\{([^}]*)\}/g,ll=/#\{([^}]*)\}/g,Ns=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,n]=r,i=pl(n,t);return{isFunction:!0,type:g.FUNCTION,name:s,args:i}},pl=(e,t={})=>e.trim()?cl(e).map(s=>ul(s.trim(),t)):[],cl=e=>{let t=[],r="",s=0,n=!1,i="";for(let a=0;a<e.length;a++){let l=e[a],p=a>0?e[a-1]:"";!n&&(l==='"'||l==="'")?(n=!0,i=l,r+=l):n&&l===i&&p!=="\\"?(n=!1,i="",r+=l):!n&&l==="("?(s++,r+=l):!n&&l===")"?(s--,r+=l):!n&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},ul=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:g.LITERAL,value:parseFloat(e)};if(e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};let r=Ns(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),n=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],i=-1,a=null;for(let{op:l,type:p}of n){let o=0;for(;o<s.length;){let c=ge(s.substring(o),l);if(c===-1)break;let u=o+c;u>i&&(i=u,a={op:l,type:p}),o=u+l.length}}if(i!==-1)try{return G(s,t)}catch{return{type:g.VARIABLE,path:s}}return{type:g.VARIABLE,path:s}},Ps=/^\w+\(.*\)$/,hl=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,dl=e=>{if(!(!e||e.trim()===""||Ps.test(e))&&hl.test(e))throw e.includes("?")&&e.includes(":")?new R(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new R(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new R(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Rs=e=>{let t=e.trim();if(Ps.test(t))throw new R(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new R(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new R(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new R(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new R(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:g.PATH_REFERENCE,path:t}},De=(e,t={})=>{let r=e.trim();dl(r);let s=Ns(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let n=0;for(let i of r)i==="["?n++:i==="]"&&n--;if(n!==0)throw new Error("Invalid array index syntax")}return{type:g.VARIABLE,path:r}},nr=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let n=[...r.matchAll(ol)],i=[...r.matchAll(ll)],a=[...n.map(o=>({match:o,type:"variable"})),...i.map(o=>({match:o,type:"pathref"}))].sort((o,c)=>o.match.index-c.match.index);if(a.length===0){let o=r;for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);return{type:g.LITERAL,value:o}}if(a.length===1&&a[0].match[0]===r&&s.length===0){let{match:o,type:c}=a[0];try{return c==="variable"?De(o[1],t):Rs(o[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:g.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:o,type:c}of a){let[u,h]=o,f=o.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=De(h.trim(),t):d=Rs(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let o=r.substring(p);for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);o&&l.push(o)}return{type:g.INTERPOLATION,parts:l}};var he=(e,t)=>typeof e=="string"?nr(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?fl(e,t):yl(e,t):{type:g.LITERAL,value:e},fl=(e,t)=>{let r=[],s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=Object.keys(i);if(l.length===1&&l[0].startsWith("$for ")){let p=Ds(l[0],i[l[0]],t);r.push(p),s=!0;continue}}let a=he(i,t);r.push(a),(a.type===g.FUNCTION||a.type===g.CONDITIONAL||a.type===g.LOOP||a.type===g.PARTIAL||a.type===g.OBJECT&&!a.fast||a.type===g.ARRAY&&!a.fast)&&(s=!0)}return{type:g.ARRAY,items:r,fast:!s}},yl=(e,t)=>{let r=[],s=!1,n=null,i=Object.entries(e),a=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new R("$partial value must be a string");if(e.$partial.trim()==="")throw new R("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],o=[];for(let[m]of i)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){o.push(w);break}if(o.length>0)throw new R(`Cannot use $partial with ${o.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=he(f,t),y.type===g.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===g.VARIABLE||w.value.type===g.INTERPOLATION||w.value.type===g.FUNCTION||w.value.type===g.CONDITIONAL||w.value.type===g.LOOP||w.value.type===g.OBJECT&&!w.value.fast||w.value.type===g.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:g.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new R("Empty condition expression after '$when'");m=G(u,t)}else m={type:g.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,o]of i)if(p==="$when"){if(n!==null)throw new R("Multiple '$when' directives on the same object are not allowed");if(o==null)throw new R("Missing condition expression after '$when'");let c=typeof o=="string"?o:JSON.stringify(o);if(c.trim()==="")throw new R("Empty condition expression after '$when'");n=G(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new R("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;a<i.length;){let[p,o]=i[a];if(p==="$when"){a++;continue}if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=ml(i,a,t);r.push({key:p,value:c.node}),s=!0,a=c.nextIndex}else if(p.startsWith("$for ")){let c=Ds(p,o,t);r.push({key:p,value:c}),s=!0,a++}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new R(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new R("Missing condition expression after '$if'");{let c=he(o,t);(c.type===g.FUNCTION||c.type===g.CONDITIONAL||c.type===g.LOOP||c.type===g.PARTIAL||c.type===g.OBJECT&&!c.fast||c.type===g.ARRAY&&!c.fast)&&(s=!0);let u=nr(p,t),h={key:p,value:c};(u.type!==g.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),a++}}}let l={type:g.OBJECT,properties:r,fast:!s};return n&&(l.whenCondition=n),l},ml=(e,t,r={})=>{let s=[],n=[],i=t,[a,l]=e[i],p=null,o;if(a.startsWith("$if#")){let u=a.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],o=u[2];else throw new R(`Invalid conditional syntax: ${a}`)}else o=a.substring(4),o.endsWith(":")&&(o=o.slice(0,-1).trim());ir(o);let c=G(o,r);for(s.push(c),n.push(he(l,r)),i++;i<e.length;){let[u,h]=e[i],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{ir(d);let y=G(d,r);s.push(y)}if(n.push(he(h,r)),i++,d===null)break}else break}return{node:{type:g.CONDITIONAL,conditions:s,bodies:n,id:p},nextIndex:i}},G=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let o=e.slice(1,-1),c=0,u=!0;for(let h=0;h<o.length;h++)if(o[h]==="("?c++:o[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return G(o,t)}let r=ge(e,"||");if(r!==-1)return{type:g.BINARY,op:M.OR,left:G(e.substring(0,r).trim(),t),right:G(e.substring(r+2).trim(),t)};let s=ge(e,"&&");if(s!==-1)return{type:g.BINARY,op:M.AND,left:G(e.substring(0,s).trim(),t),right:G(e.substring(s+2).trim(),t)};let n=[{op:">=",type:M.GTE},{op:"<=",type:M.LTE},{op:"==",type:M.EQ},{op:"!=",type:M.NEQ},{op:">",type:M.GT},{op:"<",type:M.LT},{op:" in ",type:M.IN}];for(let{op:o,type:c}of n){let u=ge(e,o);if(u!==-1)return{type:g.BINARY,op:c,left:G(e.substring(0,u).trim(),t),right:G(e.substring(u+o.length).trim(),t)}}let i=-1,a=null,l=[{op:" + ",type:M.ADD},{op:" - ",type:M.SUBTRACT}];for(let{op:o,type:c}of l){let u=0;for(;u<e.length;){let h=ge(e.substring(u),o);if(h===-1)break;let f=u+h;f>i&&(i=f,a={op:o,type:c}),u=f+o.length}}if(i!==-1&&a)return{type:g.BINARY,op:a.type,left:G(e.substring(0,i).trim(),t),right:G(e.substring(i+a.op.length).trim(),t)};let p=[" * "," / "," % "];for(let o of p)if(ge(e,o)!==-1)throw new R(`Arithmetic operations are not allowed in conditionals: "${o}"`);return e.startsWith("!")?{type:g.UNARY,op:Pe.NOT,operand:G(e.substring(1).trim(),t)}:Vs(e,t)},ge=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},gl=e=>{if(e=e.trim(),e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:g.LITERAL,value:""};if(e==="{}")return{type:g.LITERAL,value:{}};if(e==="[]")return{type:g.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:g.LITERAL,value:t}:{type:g.VARIABLE,path:e}},Vs=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return De(r,t);let n=gl(r);if(n.type===g.LITERAL)return n;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:g.VARIABLE,path:r};try{return De(r,t)}catch(i){if(i.message&&i.message.includes("not supported"))return n;throw i}},Ds=(e,t,r)=>{let s=e.substring(5).trim();ks(s);let n=s.match(/^(.+?)\s+in\s+(.+)$/);if(!n)throw new R(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let i=n[1].trim(),a=n[2].trim(),l,p=null;if(i.includes(",")){let u=i.split(",").map(h=>h.trim());if(u.length!==2)throw new R(`Invalid loop variables: ${i}. Expected format: "item" or "item, index"`);l=u[0],p=u[1]}else l=i;let o=Vs(a,r),c=he(t,r);return{type:g.LOOP,itemVar:l,indexVar:p,iterable:o,body:c}};var vl=(e,t={})=>{let{functions:r={}}=t;return he(e,r)},Xe=vl;var ar={};P(ar,{now:()=>bl});var bl=()=>Date.now();var wl=(e,t,r={})=>{let{functions:s={},partials:n={}}=r,i={...ar,...s},a=Xe(e,{functions:i}),l={};for(let[p,o]of Object.entries(n))l[p]=Xe(o,{functions:i});return Ve(a,t,{functions:i,partials:l})},or=wl;var Qe=e=>Array.isArray(e)?e.reduce((t,r)=>{if(Array.isArray(r))t.push(...Qe(r));else{if(r&&typeof r=="object"){let s=Object.entries(r);if(s.length>0){let[n,i]=s[0];Array.isArray(i)&&(r={[n]:Qe(i)})}}t.push(r)}return t},[]):e;var js=(e,t)=>{if(!t)return e;let r=[],s="",n=!1,i=null;for(let a=0;a<t.length;a++){let l=t[a];if(!n&&l===".")s&&(r.push(s),s="");else if(!n&&l==="[")s&&(r.push(s),s=""),n=!0;else if(n&&l==="]"){if(s){if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))r.push(s.slice(1,-1));else{let p=Number(s);r.push(isNaN(p)?s:p)}s=""}n=!1,i=null}else n&&(l==='"'||l==="'")&&(i?l===i&&(i=null):i=l),s+=l}return s&&r.push(s),r.reduce((a,l)=>a&&a[l],e)},Bs=({h:e,template:t,viewData:r,refs:s,handlers:n})=>{let i=Ve(t,r,{}),a=Qe(i),l=_l({h:e,items:a,refs:s,handlers:n,viewData:r});return e("div",{style:{display:"contents"}},l)},_l=({h:e,items:t,refs:r={},handlers:s={},viewData:n={}})=>{if(!Array.isArray(t))return console.error("Input to createVirtualDom must be an array."),[e("div",{},[])];function i(a,l=""){return a.map((p,o)=>{if(typeof p=="string"||typeof p=="number")return String(p);if(typeof p!="object"||p===null)return console.warn("Skipping invalid item in DOM structure:",p),null;let c=Object.entries(p);if(c.length===0)return null;let[u,h]=c[0];if(!isNaN(Number(u)))return Array.isArray(h)?i(h,`${l}.${u}`):typeof h=="object"&&h!==null&&Object.entries(h).length>0?i([h],`${l}.${u}`):String(h);c.length>1&&console.warn("Item has multiple keys, processing only the first:",u);let f,d,y=u.indexOf(" ");y===-1?(f=u,d=""):(f=u.substring(0,y),d=u.substring(y+1).trim());let b=f.split(/[.#]/)[0],m=b.includes("-"),w={},_={};if(d){let C=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g,A,B=new Set;for(;(A=C.exec(d))!==null;)if(B.add(A[1]),A[1].startsWith(".")){let ae=A[1].substring(1),Ce=A[4];_[ae]=js(n,Ce)}else if(A[1].startsWith("?")){let ae=A[1].substring(1),Ce=A[2]||A[3]||A[4],Be;Ce==="true"?Be=!0:Ce==="false"?Be=!1:Be=js(n,Ce),Be&&(w[ae]="")}else w[A[1]]=A[2]||A[3]||A[4];let U=d,F=[],ne,tt=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g;for(;(ne=tt.exec(d))!==null;)F.push(ne[0]);F.forEach(ae=>{U=U.replace(ae," ")});let rt=/\b(\S+?)(?=\s|$)/g,K;for(;(K=rt.exec(U))!==null;){let ae=K[1];!B.has(ae)&&!ae.startsWith(".")&&!ae.includes("=")&&(w[ae]="")}}let x=f.match(/#([^.#\s]+)/);x&&!Object.prototype.hasOwnProperty.call(w,"id")&&(w.id=x[1]);let E=null;w.id?E=w.id:m&&(E=b);let $=Object.create(null),I=null;if(m)I=b;else{let C=f.match(/\.([^.#]+)/g);C&&C.forEach(B=>{let U=B.substring(1);$[U]=!0});let A=f.match(/#([^.#\s]+)/);A&&(I=A[1])}let S;typeof h=="string"||typeof h=="number"?S=String(h):Array.isArray(h)?S=i(h,`${l}.${u}`):S=[],I&&!m&&(w.id=I);let N=Object.create(null);if(E&&r){let C=[];if(Object.keys(r).forEach(A=>{if(A.includes("*")){let B="^"+A.replace(/[.*+?^${}()|[\\\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$";try{new RegExp(B).test(E)&&C.push(A)}catch(U){console.warn(`[Parser] Invalid regex pattern created from refKey '${A}': ${B}`,U)}}else E===A&&C.push(A)}),C.length>0){C.sort((B,U)=>{let F=!B.includes("*"),ne=!U.includes("*");return F&&!ne?-1:!F&&ne?1:U.length-B.length});let A=C[0];if(r[A]&&r[A].eventListeners){let B=r[A].eventListeners;Object.entries(B).forEach(([U,F])=>{if(F.handler&&F.action)throw new Error("Each listener can have hanlder or action but not both");if(F.action){N[U]=ne=>{s.handleCallStoreAction({...F.payload,_event:ne,_action:F.action})};return}F.handler&&s[F.handler]?N[U]=ne=>{s[F.handler]({...F.payload,_event:ne})}:F.handler&&console.warn(`[Parser] Handler '${F.handler}' for refKey '${A}' (matching elementId '${E}') is referenced but not found in available handlers.`)})}}}let D={};if(E)D.key=E;else if(f){let C=l?`${l}.${o}`:String(o);if(D.key=`${f}-${C}`,Object.keys(_).length>0){let A=JSON.stringify(_).substring(0,50);D.key+=`-${A}`}}Object.keys(w).length>0&&(D.attrs=w),Object.keys($).length>0&&(D.class=$),Object.keys(N).length>0&&(D.on=N),Object.keys(_).length>0&&(D.props=_),m&&(D.hook={update:(C,A)=>{let B=C.data?.props||{},U=A.data?.props||{},F=C.data?.attrs||{},ne=A.data?.attrs||{},tt=JSON.stringify(B)!==JSON.stringify(U),rt=JSON.stringify(F)!==JSON.stringify(ne);if(tt||rt){let K=A.elm;K&&K.render&&typeof K.render=="function"&&(K.setAttribute("isDirty","true"),requestAnimationFrame(()=>{if(K.render(),K.removeAttribute("isDirty"),K.handlers&&K.handlers.handleOnUpdate){let ae={...K.deps,store:K.store,render:K.render.bind(K),handlers:K.handlers,dispatchEvent:K.dispatchEvent.bind(K),refIds:K.refIds||{},getRefIds:()=>K.refIds||{}};K.handlers.handleOnUpdate(ae,{oldProps:B,newProps:U,oldAttrs:F,newAttrs:ne})}}))}}});try{return e(b,D,S)}catch(C){return console.error("Error creating virtual node:",C,{tagName:b,snabbdomData:D,childrenOrText:S}),e("div",{},["Error creating element"])}}).filter(Boolean)}return i(t)};var xl=(e,t)=>{if(!t||typeof t!="object")return"";let r="",s=i=>Object.entries(i).map(([a,l])=>` ${a}: ${l};`).join(`
974
+ `))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._dialogElement=document.createElement("dialog"),this.shadow.appendChild(this._dialogElement),this._dialogElement.addEventListener("click",t=>{t.stopPropagation();let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._dialogElement.addEventListener("contextmenu",t=>{let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}})))}),this._dialogElement.addEventListener("cancel",t=>{t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._popoverContainer=document.createElement("div"),this._popoverContainer.className="popover-container",this._dialogElement.appendChild(this._popoverContainer),this._slotElement=null,this._isOpen=!1}static get observedAttributes(){return["open","x","y","placement"]}connectedCallback(){this.hasAttribute("open")&&this._show()}disconnectedCallback(){this._isOpen&&this._dialogElement.open&&this._dialogElement.close()}attributeChangedCallback(t,r,s){t==="open"?s!==null&&!this._isOpen?this.isConnected&&this._show():s===null&&this._isOpen&&this._hide():(t==="x"||t==="y"||t==="placement")&&this._isOpen&&this._updatePosition()}_show(){this._isOpen||(this._slotElement||(this._slotElement=document.createElement("slot"),this._slotElement.setAttribute("name","content"),this._popoverContainer.appendChild(this._slotElement)),this._isOpen=!0,this._dialogElement.open||setTimeout(()=>{this._dialogElement&&!this._dialogElement.open&&(this.hasAttribute("no-overlay")?this._dialogElement.show():this._dialogElement.showModal())},0),requestAnimationFrame(()=>{this._updatePosition()}))}_hide(){this._isOpen&&(this._isOpen=!1,this._dialogElement.open&&this._dialogElement.close(),this._slotElement&&(this._popoverContainer.removeChild(this._slotElement),this._slotElement=null))}_updatePosition(){let t=parseFloat(this.getAttribute("x")||"0"),r=parseFloat(this.getAttribute("y")||"0"),s=this.getAttribute("placement")||"bottom-start";this.removeAttribute("positioned"),requestAnimationFrame(()=>{let n=this._popoverContainer.getBoundingClientRect(),{left:i,top:a}=this._calculatePosition(t,r,n.width,n.height,s);this._popoverContainer.style.left=`${i}px`,this._popoverContainer.style.top=`${a}px`,requestAnimationFrame(()=>{this.setAttribute("positioned","")})})}_calculatePosition(t,r,s,n,i){let l=t,p=r;switch(i){case"top":l=t-s/2,p=r-n-8;break;case"top-start":l=t,p=r-n-8;break;case"top-end":l=t-s,p=r-n-8;break;case"right":l=t+8,p=r-n/2;break;case"right-start":l=t+8,p=r;break;case"right-end":l=t+8,p=r-n;break;case"bottom":l=t-s/2,p=r+8;break;case"bottom-start":l=t,p=r+8;break;case"bottom-end":l=t-s,p=r+8;break;case"left":l=t-s-8,p=r-n/2;break;case"left-start":l=t-s-8,p=r;break;case"left-end":l=t-s-8,p=r-n;break}let o=8;return l=Math.max(o,Math.min(l,window.innerWidth-s-o)),p=Math.max(o,Math.min(p,window.innerHeight-n-o)),{left:l,top:p}}get popover(){return this._popoverContainer}},Rr=({render:e,html:t})=>ft;var yt={};P(yt,{handleClickItem:()=>mi});var mi=(e,t)=>{let{dispatchEvent:r}=e,n=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:n}}))};var mt={};P(mt,{createInitialState:()=>gi,selectViewData:()=>wi});var gi=()=>Object.freeze({}),vi=["id","class","style","slot"],bi=e=>Object.entries(e).filter(([t])=>!vi.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),wi=({props:e,attrs:t})=>{let r=bi(t),s=e.items||[],n=e.separator||"breadcrumb-arrow",i=[];return s.forEach((a,l)=>{i.push(a),l<s.length-1&&i.push({isSeparator:!0})}),{containerAttrString:r,items:i,separator:n}};var Nr={elementName:"rtgl-breadcrumb",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string",default:"breadcrumb-arrow"}}},refs:{"item-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{item:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}},index:{type:"number"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md p=sm ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.isSeparator",value:{type:6,conditions:[{type:1,path:"item.isSeparator"},{type:1,path:"item.id"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${separator} c=mu-fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"separator"}," c=mu-fg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} data-id=${item.id} cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md p=sm ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var gt={};P(gt,{handleClickMenuItem:()=>xi,handleClosePopover:()=>_i});var _i=(e,t)=>{let{dispatchEvent:r}=e;r(new CustomEvent("close"))},xi=(e,t)=>{let{dispatchEvent:r,props:s}=e,n=t._event,i=parseInt(n.currentTarget.id.replace("option-","")),a=s.items[i];r(new CustomEvent("click-item",{detail:{index:i,item:a}}))};var vt={};P(vt,{createInitialState:()=>Ai,selectViewData:()=>Ei});var Ai=()=>Object.freeze({}),Ei=({props:e,attrs:t})=>({items:e.items||[],open:!!t.open,x:t.x,y:t.y,placement:t.placement});var Pr={elementName:"rtgl-dropdown-menu",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},type:{type:"string",enum:["label","item","separator"]}}}}}},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"}}},refs:{popover:{eventListeners:{close:{handler:"handleClosePopover"}}},"option-*":{eventListeners:{click:{handler:"handleClickMenuItem"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 sv g=xs slot=content bgc=background br=md",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.type == 'label'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"label"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"item"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"separator"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f ph=lg pv=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=1 ph=lg mv=md bgc=bo",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}]}}],fast:!1}],fast:!1}};var bt={};P(bt,{handleActionClick:()=>Ii,handleAfterMount:()=>Si,handleBeforeMount:()=>$i,handleColorPickerChange:()=>Li,handleImageClick:()=>Pi,handleInputChange:()=>Oi,handleKeyDown:()=>Wi,handleOnUpdate:()=>Ci,handleSelectAddOption:()=>Di,handleSelectChange:()=>Ti,handleSliderChange:()=>Ri,handleSliderInputChange:()=>Ni,handleTooltipMouseEnter:()=>ji,handleTooltipMouseLeave:()=>Bi,handleWaveformClick:()=>Vi});var Vr=({form:e,defaultValues:t={},refs:r})=>{let{fields:s=[]}=e;s.forEach(n=>{let i=r[`field-${n.name}`]?.elm;if(i){if(["input-textarea","inputText","input-text","input-number","colorPicker","slider","slider-input","popover-input"].includes(n.inputType)){let a=t[n.name];a==null?i.removeAttribute("value"):i.setAttribute("value",a)}["inputText","input-text","input-textarea"].includes(n.inputType)&&n.placeholder&&i.getAttribute("placeholder")!==n.placeholder&&(n.placeholder===void 0||n.placeholder===null?i.removeAttribute("placeholder"):i.setAttribute("placeholder",n.placeholder))}})},ki=e=>{for(let t in e)if(t.startsWith("field-")){let r=e[t];if(r&&r.elm){let s=r.elm;if(s.focus){s.focus();return}}}},$i=e=>{let{store:t,props:r}=e;t.setFormValues(r.defaultValues)},Si=e=>{let{props:t,getRefIds:r,render:s,attrs:n}=e,{form:i={},defaultValues:a}=t,l=r();Vr({form:i,defaultValues:a,refs:l}),s(),n?.autofocus&&setTimeout(()=>{ki(l)},50)},Ci=(e,t)=>{let{oldAttrs:r,newAttrs:s,newProps:n}=t,{store:i,render:a,getRefIds:l}=e,{form:p={},defaultValues:o}=n;if(r?.key!==s?.key){let c=l();Vr({form:p,defaultValues:o,refs:c}),i.setFormValues(o),a();return}a()},Oe=(e,t,r,s)=>{s(new CustomEvent("form-change",{detail:{name:e,fieldValue:t,formValues:r}}))},Ii=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event.currentTarget.id.replace("action-","");s(new CustomEvent("action-click",{detail:{actionId:i,formValues:r.selectFormValues()}}))},Oi=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");if(a&&i.detail.value!==void 0){let l=i.detail.value;r.setFormFieldValue({name:a,value:l,props:n}),Oe(a,l,r.selectFormValues(),s)}},Ti=(e,t)=>{let{store:r,dispatchEvent:s,render:n,props:i}=e,a=t._event,l=a.currentTarget.id.replace("field-","");l&&(r.setFormFieldValue({name:l,value:a.detail.selectedValue,props:i}),Oe(l,a.detail.selectedValue,r.selectFormValues(),s),n())},Li=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");a&&i.detail.value!==void 0&&(r.setFormFieldValue({name:a,value:i.detail.value,props:n}),Oe(a,i.detail.value,r.selectFormValues(),s))},Ri=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");a&&i.detail.value!==void 0&&(r.setFormFieldValue({name:a,value:i.detail.value,props:n}),Oe(a,i.detail.value,r.selectFormValues(),s))},Ni=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("field-","");a&&i.detail.value!==void 0&&(r.setFormFieldValue({name:a,value:i.detail.value,props:n}),Oe(a,i.detail.value,r.selectFormValues(),s))},Pi=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,n=r.currentTarget.id.replace("image-","");s(new CustomEvent("extra-event",{detail:{name:n,x:r.clientX,y:r.clientY,trigger:r.type}}))},Vi=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,n=r.currentTarget.id.replace("waveform-","");s(new CustomEvent("extra-event",{detail:{name:n,x:r.clientX,y:r.clientY,trigger:r.type}}))},Di=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event.currentTarget.id.replace("field-","");s(new CustomEvent("action-click",{detail:{actionId:"select-options-add",name:i,formValues:r.selectFormValues()}}))},ji=(e,t)=>{let{store:r,render:s,props:n}=e,i=t._event,a=i.currentTarget.id.replace("tooltip-icon-",""),p=n.form.fields.find(o=>o.name===a);if(p&&p.tooltip){let o=i.currentTarget.getBoundingClientRect();r.showTooltip({x:o.left+o.width/2,y:o.top-8,content:p.tooltip.content}),s()}},Bi=e=>{let{store:t,render:r}=e;t.hideTooltip(),r()},Wi=(e,t)=>{let{store:r,dispatchEvent:s,props:n}=e,i=t._event;if(i.key==="Enter"&&!i.shiftKey){let a=i.target;if(a.tagName==="TEXTAREA"||a.tagName==="RTGL-TEXTAREA")return;i.preventDefault();let o=((n.form||{}).actions||{}).buttons||[];if(o.length>0){let c=o[0].id,u=r.selectFormValues();s(new CustomEvent("action-click",{detail:{actionId:c,formValues:u}}))}}};var kt={};P(kt,{createInitialState:()=>bn,getFormFieldValue:()=>$n,hideTooltip:()=>On,selectForm:()=>Ke,selectFormValues:()=>kn,selectState:()=>En,selectViewData:()=>An,setFormFieldValue:()=>Cn,setFormValues:()=>Sn,showTooltip:()=>In});var v={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},W={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Te={NOT:0};var k=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},X=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var wt=e=>{if(!e||e.trim()==="")throw new k("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new k(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new k(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Dr=e=>{if(e.trim().endsWith(" in"))throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new k(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);let s=t.includes(",")?t.split(",").map(n=>n.trim()):[t.trim()];for(let n of s){if(!n)throw new k(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n))throw new k(`Invalid loop syntax (got: '$for ${e}')`)}};var jr=(e,t,r=!1)=>{if(t===null)return new X(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new X(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new X(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new X(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},Br=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new X(`Unknown function '${e}' (${r})`)};var Mi=(e,t,r={})=>{let s={},n={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},n=r.partials||{}):typeof r=="object"&&(s=r));let a=O(e,{functions:s,partials:n},t,{});return a===void 0?{}:a},O=(e,t,r,s)=>{let n=t.functions||t;if(e.var&&!e.type)return z(e.var,r,s);if(e.type===v.LITERAL)return e.value;if(e.type===v.VARIABLE)return z(e.path,r,s);if(e.type===v.INTERPOLATION)return Ki(e.parts,t,r,s);switch(e.type){case v.FUNCTION:return Mr(e,t,r,s);case v.BINARY:return Fr(e,t,r,s);case v.UNARY:return Kr(e,t,r,s);case v.CONDITIONAL:return zi(e,t,r,s);case v.LOOP:return Yi(e,t,r,s);case v.OBJECT:return Qi(e,t,r,s);case v.ARRAY:return Zi(e,t,r,s);case v.PARTIAL:return en(e,t,r,s);case v.PATH_REFERENCE:return tn(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},Wr=new Map,Fi=e=>{let t=[],r="",s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(i==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(i==="]"){if(s&&r){let a=r.trim();if(/^\d+$/.test(a))t.push({type:"index",value:parseInt(a,10)});else if(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")){let l=a.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:a});r=""}s=!1}else r+=i}return r&&t.push({type:"property",value:r}),t},z=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=Wr.get(e);if(!s){let i=[],a="",l=0;for(let p=0;p<e.length;p++){let o=e[p];o==="["?(l++,a+=o):o==="]"?(l--,a+=o):o==="."&&l===0?a&&(i.push(a),a=""):a+=o}a&&i.push(a),s=[];for(let p of i){let o=Fi(p.trim());s.push(...o)}Wr.set(e,s)}let n=t;for(let i=0;i<s.length;i++){let a=s[i];if(a.type==="property"&&a.value in r){n=r[a.value];continue}if(n==null)return;(a.type==="property"||a.type==="index")&&(n=n[a.value])}return n},Ki=(e,t,r,s)=>{let n=[];for(let i of e)if(typeof i=="string")n.push(i);else{let a=O(i,t,r,s);n.push(a!=null?String(a):"")}return n.join("")},Mr=(e,t,r,s)=>{let n=t.functions||t,i=n[e.name];if(!i)throw Br(e.name,n);let a=e.args.map(l=>O(l,t,r,s));return i(...a)},xe=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);switch(e.type){case v.VARIABLE:return z(e.path,r,s);case v.LITERAL:return e.value;case v.BINARY:return Fr(e,t,r,s);case v.UNARY:return Kr(e,t,r,s);case v.FUNCTION:return Mr(e,t,r,s);default:return O(e,t,r,s)}},Fr=(e,t,r,s)=>{if(e.op===W.AND||e.op===W.OR){let a=xe(e.left,t,r,s),l=xe(e.right,t,r,s);switch(e.op){case W.AND:return a&&l;case W.OR:return a||l}}let n=O(e.left,t,r,s),i=O(e.right,t,r,s);switch(e.op){case W.EQ:return n==i;case W.NEQ:return n!=i;case W.GT:return n>i;case W.LT:return n<i;case W.GTE:return n>=i;case W.LTE:return n<=i;case W.IN:return Array.isArray(i)?i.includes(n):!1;case W.ADD:if(typeof n!="number"||typeof i!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof n} + ${typeof i}`);return n+i;case W.SUBTRACT:if(typeof n!="number"||typeof i!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof n} - ${typeof i}`);return n-i;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Kr=(e,t,r,s)=>{let n=e.op===Te.NOT?xe(e.operand,t,r,s):O(e.operand,t,r,s);switch(e.op){case Te.NOT:return!n;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Ui=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let n=e.conditions[0];if(n.type===v.VARIABLE)if(z(n.path,r,s)){let a=e.bodies[0];if(a.type===v.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?O(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[o]=c.value;else if(c.type===v.VARIABLE)l[o]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=O(c,t,r,s)}return l}}else{let a=e.bodies[1];if(a.type===v.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?O(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[o]=c.value;else if(c.type===v.VARIABLE)l[o]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=O(c,t,r,s)}return l}}}return null},zi=(e,t,r,s)=>{let n=Ui(e,t,r,s);if(n!==null)return n;for(let i=0;i<e.conditions.length;i++){let a=e.conditions[i];if(a===null||xe(a,t,r,s))return O(e.bodies[i],t,r,s)}return Ur},Hi=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===v.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===v.VARIABLE){let n=r.conditions[0].path,i=r.bodies[0];if(n.startsWith(s+".")){let a=n.substring(s.length+1);if(i.type===v.OBJECT&&i.properties.length<=5){for(let p of i.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let o=t[p];if(o[a]){let c={};for(let u of i.properties){let h=u.key,f=u.value;if(f.type===v.LITERAL)c[h]=f.value;else if(f.type===v.VARIABLE){let d=f.path;if(d===s)c[h]=o;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=o[y]}else return null}else if(f.type===v.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===v.VARIABLE){let m=b.path;if(m===s)d.push(o!=null?String(o):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=o[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},Ji=(e,t)=>{let r=e.body,s=e.itemVar,n=Hi(e,t);if(n!==null)return n;if(r.type===v.OBJECT&&r.properties.length<=5&&!r.whenCondition){for(let l of r.properties)if(l.parsedKey)return null;let i=[],a=!0;for(let l of r.properties){let p=l.key,o=l.value;if(o.type===v.LITERAL)i.push({key:p,type:"literal",value:o.value});else if(o.type===v.VARIABLE){let c=o.path;if(c===s)i.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))i.push({key:p,type:"prop",prop:u});else{a=!1;break}}else{a=!1;break}}else if(o.type===v.INTERPOLATION&&o.parts.length===1){let c=o.parts[0];if(c.type===v.VARIABLE){let u=c.path;if(u===s)i.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))i.push({key:p,type:"prop_string",prop:h});else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}if(a){let l=new Array(t.length);if(i.length===3&&i[0].type==="prop"&&i[0].key==="id"&&i[1].type==="prop_string"&&i[1].key==="title"&&i[2].type==="prop"&&i[2].key==="completed")for(let p=0;p<t.length;p++){let o=t[p];l[p]={id:o.id,title:o.title!=null?String(o.title):"",completed:o.completed}}else for(let p=0;p<t.length;p++){let o=t[p],c={};for(let u of i)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=o;else if(u.type==="prop")c[u.key]=o[u.prop];else if(u.type==="item_string")c[u.key]=o!=null?String(o):"";else if(u.type==="prop_string"){let h=o[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},qi=(e,t,r,s,n)=>{let i=[],a=e.body;if(a.type===v.OBJECT&&a.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let o=0;o<n.length;o++){let c=n[o],u={},h={...s,[l]:c,...p&&{[p]:o}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${o}]`,...p&&{[p]:o}};for(let d of a.properties){let y=d.parsedKey?O(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===v.LITERAL)u[y]=b.value;else if(b.type===v.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=o;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:o}})}else u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:o}})}else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=o;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=z(_,r,{...s,[l]:c,...p&&{[p]:o}})}else x=z(_,r,{...s,[l]:c,...p&&{[p]:o}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:o}},x=O(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:o}};u[y]=O(b,t,r,m)}}i.push(u)}return i}return null},Gi=(e,t,r)=>{let s=e.body;if(s.type===v.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let i=s.properties[0].value;if(i.type===v.CONDITIONAL&&i.conditions.length===1&&i.conditions[0].type===v.VARIABLE&&i.conditions[0].path==="item.visible"){let a=i.bodies[0];if(a.type===v.OBJECT&&a.properties.length===2){let l=a.properties[0],p=a.properties[1];if(l.key==="id"&&l.value.type===v.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===v.CONDITIONAL){let o=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),o.push(h)}}return o}}}}return null},Yi=(e,t,r,s)=>{let n=O(e.iterable,t,r,s);if(!Array.isArray(n)){let o,c=!1;if(e.iterable.type===v.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===v.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===v.VARIABLE?f.path:f.type===v.FUNCTION?`${f.name}(...)`:"?").join(", ");o=`${e.iterable.name}(${h})`}else o=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${o}`;throw jr(u,n,c)}if(!e.indexVar){let o=Gi(e,n,e.itemVar);if(o!==null)return o}if(!e.indexVar){let o=Ji(e,n);if(o!==null)return o}let i=qi(e,t,r,s,n);if(i!==null)return i;let a=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let o=l.split("."),c=o[0];c in s.__paths__&&(l=s.__paths__[c],o.length>1&&(l+="."+o.slice(1).join(".")))}let p=!1;e.body.type===v.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(o=>o.type===v.OBJECT&&o.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let o=0;o<n.length;o++){let c=e.indexVar?{...s,[e.itemVar]:n[o],[e.indexVar]:o}:{...s,[e.itemVar]:n[o]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${o}]`},e.indexVar&&(c.__paths__[e.indexVar]=o);let u=O(e.body,t,r,c);if(Array.isArray(u)&&u.length===1&&!p){let h=u[0];a.push(h===void 0?{}:h)}else a.push(u===void 0?{}:u)}return a},Xi=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let n=e.properties[0],i=n.parsedKey?O(n.parsedKey,t,r,s):n.key,a=n.value;if(a.type===v.OBJECT&&a.properties.length<=10&&!a.whenCondition){let l={},p={},o=!0;for(let c of a.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)p[u]=h.value;else if(h.type===v.VARIABLE)p[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{o=!1;break}if(!o)break;p[u]=f.join("")}else if(h.type===v.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===v.LITERAL)f[y]=b.value;else if(b.type===v.VARIABLE)f[y]=z(b.path,r,s);else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=z(w.path,r,s);m.push(_!=null?String(_):"")}else{o=!1;break}if(!o)break;f[y]=m.join("")}else{o=!1;break}}if(!o)break;p[u]=f}else{o=!1;break}}if(o)return l[i]=p,l}}return null},Qi=(e,t,r,s)=>{let n=t.functions||t;if(e.whenCondition&&!xe(e.whenCondition,n,r,s))return;let i=Xi(e,t,r,s);if(i!==null)return i;if(e.fast){let o={};for(let c of e.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)o[u]=h.value;else if(h.type===v.VARIABLE)o[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=O(d,t,r,s);f.push(y!=null?String(y):"")}o[u]=f.join("")}else o[u]=O(h,t,r,s)}return o}let a={},l=null,p=!1;for(let o of e.properties)if(!o.key.startsWith("$if ")&&!o.key.match(/^\$if\s+\w+.*:?$/)&&!o.key.startsWith("$elif")&&!o.key.startsWith("$else")&&!o.key.startsWith("$for ")){p=!0;break}for(let o of e.properties)if(o.key.startsWith("$if ")||o.key.match(/^\$if\s+\w+.*:?$/)){let c=O(o.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(a,c)}else if(o.key.startsWith("$for ")){if(e.properties.length===1)return O(o.value,t,r,s)}else{let c=o.value;if(c&&c.type===v.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=O(u.value,t,r,s);h!==void 0&&(a[o.key]=h)}else{let h=O(o.value,t,r,s);h!==void 0&&(a[o.key]=h)}}else{let u=o.parsedKey?O(o.parsedKey,t,r,s):o.key,h=O(o.value,t,r,s);h!==void 0&&(a[u]=h)}}return a},Ur={},Zi=(e,t,r,s)=>{let n=[];for(let i of e.items)if(i.type===v.LOOP){let a=O(i,t,r,s);Array.isArray(a)&&i.flatten!==!1?n.push(...a):n.push(a)}else{let a=O(i,t,r,s);a!==Ur&&a!==void 0&&n.push(a)}return n},en=(e,t,r,s)=>{let{name:n,data:i,whenCondition:a}=e,l=t.partials||{},p=t.functions||t;if(a&&!xe(a,p,r,s))return;if(!l[n])throw new X(`Partial '${n}' is not defined`);let o=s._partialStack||[];if(o.includes(n))throw new X(`Circular partial reference detected: ${n}`);let c=l[n],u=r,h={...s,_partialStack:[...o,n]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(i){let f=O(i,t,r,s);u={...u,...f}}return O(c,t,u,h)},tn=(e,t,r,s)=>{let{path:n}=e,i=n.split("."),a=i[0],l=i.slice(1);if(!s||!(a in s))throw new X(`Path reference '#{${n}}' refers to '${a}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(a in s.__paths__))throw new X(`Path reference '#{${n}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[a];if(typeof p=="number"){if(l.length>0)throw new X(`Path reference '#{${n}}' - cannot access properties on index variable '${a}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},_t=Mi;var rn=/\$\{([^}]*)\}/g,sn=/#\{([^}]*)\}/g,Hr=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,n]=r,i=nn(n,t);return{isFunction:!0,type:v.FUNCTION,name:s,args:i}},nn=(e,t={})=>e.trim()?an(e).map(s=>on(s.trim(),t)):[],an=e=>{let t=[],r="",s=0,n=!1,i="";for(let a=0;a<e.length;a++){let l=e[a],p=a>0?e[a-1]:"";!n&&(l==='"'||l==="'")?(n=!0,i=l,r+=l):n&&l===i&&p!=="\\"?(n=!1,i="",r+=l):!n&&l==="("?(s++,r+=l):!n&&l===")"?(s--,r+=l):!n&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},on=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:v.LITERAL,value:parseFloat(e)};if(e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};let r=Hr(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),n=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],i=-1,a=null;for(let{op:l,type:p}of n){let o=0;for(;o<s.length;){let c=de(s.substring(o),l);if(c===-1)break;let u=o+c;u>i&&(i=u,a={op:l,type:p}),o=u+l.length}}if(i!==-1)try{return G(s,t)}catch{return{type:v.VARIABLE,path:s}}return{type:v.VARIABLE,path:s}},Jr=/^\w+\(.*\)$/,ln=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,pn=e=>{if(!(!e||e.trim()===""||Jr.test(e))&&ln.test(e))throw e.includes("?")&&e.includes(":")?new k(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new k(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new k(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},zr=e=>{let t=e.trim();if(Jr.test(t))throw new k(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new k(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new k(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new k(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new k(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:v.PATH_REFERENCE,path:t}},Le=(e,t={})=>{let r=e.trim();pn(r);let s=Hr(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let n=0;for(let i of r)i==="["?n++:i==="]"&&n--;if(n!==0)throw new Error("Invalid array index syntax")}return{type:v.VARIABLE,path:r}},xt=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let n=[...r.matchAll(rn)],i=[...r.matchAll(sn)],a=[...n.map(o=>({match:o,type:"variable"})),...i.map(o=>({match:o,type:"pathref"}))].sort((o,c)=>o.match.index-c.match.index);if(a.length===0){let o=r;for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);return{type:v.LITERAL,value:o}}if(a.length===1&&a[0].match[0]===r&&s.length===0){let{match:o,type:c}=a[0];try{return c==="variable"?Le(o[1],t):zr(o[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:v.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:o,type:c}of a){let[u,h]=o,f=o.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=Le(h.trim(),t):d=zr(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let o=r.substring(p);for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);o&&l.push(o)}return{type:v.INTERPOLATION,parts:l}};var ue=(e,t)=>typeof e=="string"?xt(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?un(e,t):hn(e,t):{type:v.LITERAL,value:e},cn=e=>{let{$each:t,...r}=e;if(typeof t!="string")throw new k("$each value must be a non-empty string");let s=t.trim();if(s==="")throw new k("$each value must be a non-empty string");if(Object.keys(r).length===0)throw new k("Empty $each body not allowed");if(r.$partial!==void 0)throw new k("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${s}`]:r}},un=(e,t)=>{let r=[],s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(typeof i=="object"&&i!==null&&!Array.isArray(i)){if(i.$each!==void 0)try{let p=cn(i),o=Object.keys(p);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let c=qr(o[0],p[o[0]],t,!0);r.push(c),s=!0;continue}}catch(p){throw p instanceof k?p:new k(p.message)}let l=Object.keys(i);if(l.length===1&&/^\$for(?::\w+)?\s/.test(l[0])){let p=qr(l[0],i[l[0]],t);r.push(p),s=!0;continue}}let a=ue(i,t);r.push(a),(a.type===v.FUNCTION||a.type===v.CONDITIONAL||a.type===v.LOOP||a.type===v.PARTIAL||a.type===v.OBJECT&&!a.fast||a.type===v.ARRAY&&!a.fast)&&(s=!0)}return{type:v.ARRAY,items:r,fast:!s}},hn=(e,t)=>{let r=[],s=!1,n=null,i=Object.entries(e),a=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new k("$partial value must be a string");if(e.$partial.trim()==="")throw new k("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],o=[];for(let[m]of i)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){o.push(w);break}if(o.length>0)throw new k(`Cannot use $partial with ${o.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=ue(f,t),y.type===v.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===v.VARIABLE||w.value.type===v.INTERPOLATION||w.value.type===v.FUNCTION||w.value.type===v.CONDITIONAL||w.value.type===v.OBJECT&&!w.value.fast||w.value.type===v.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:v.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new k("Empty condition expression after '$when'");m=G(u,t)}else m={type:v.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,o]of i)if(p==="$when"){if(n!==null)throw new k("Multiple '$when' directives on the same object are not allowed");if(o==null)throw new k("Missing condition expression after '$when'");let c=typeof o=="string"?o:JSON.stringify(o);if(c.trim()==="")throw new k("Empty condition expression after '$when'");n=G(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new k("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;a<i.length;){let[p,o]=i[a];if(p==="$when"){a++;continue}if(p==="$each")throw new k("$each can only be used inside arrays");if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=dn(i,a,t);r.push({key:p,value:c.node}),s=!0,a=c.nextIndex}else if(/^\$for(?::\w+)?\s/.test(p)){let c=p.match(/^\$for(?::(\w+))?\s/)?.[1]||"",u=c?`:${c}`:"";throw new k(`$for loops must be inside arrays - use '- $for${u} item in items:' instead of '$for${u} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new k(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new k("Missing condition expression after '$if'");{let c=ue(o,t);(c.type===v.FUNCTION||c.type===v.CONDITIONAL||c.type===v.PARTIAL||c.type===v.OBJECT&&!c.fast||c.type===v.ARRAY&&!c.fast)&&(s=!0);let u=xt(p,t),h={key:p,value:c};(u.type!==v.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),a++}}}let l={type:v.OBJECT,properties:r,fast:!s};return n&&(l.whenCondition=n),l},dn=(e,t,r={})=>{let s=[],n=[],i=t,[a,l]=e[i],p=null,o;if(a.startsWith("$if#")){let u=a.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],o=u[2];else throw new k(`Invalid conditional syntax: ${a}`)}else o=a.substring(4),o.endsWith(":")&&(o=o.slice(0,-1).trim());wt(o);let c=G(o,r);for(s.push(c),n.push(ue(l,r)),i++;i<e.length;){let[u,h]=e[i],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{wt(d);let y=G(d,r);s.push(y)}if(n.push(ue(h,r)),i++,d===null)break}else break}return{node:{type:v.CONDITIONAL,conditions:s,bodies:n,id:p},nextIndex:i}},G=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let o=e.slice(1,-1),c=0,u=!0;for(let h=0;h<o.length;h++)if(o[h]==="("?c++:o[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return G(o,t)}let r=de(e,"||");if(r!==-1)return{type:v.BINARY,op:W.OR,left:G(e.substring(0,r).trim(),t),right:G(e.substring(r+2).trim(),t)};let s=de(e,"&&");if(s!==-1)return{type:v.BINARY,op:W.AND,left:G(e.substring(0,s).trim(),t),right:G(e.substring(s+2).trim(),t)};let n=[{op:">=",type:W.GTE},{op:"<=",type:W.LTE},{op:"==",type:W.EQ},{op:"!=",type:W.NEQ},{op:">",type:W.GT},{op:"<",type:W.LT},{op:" in ",type:W.IN}];for(let{op:o,type:c}of n){let u=de(e,o);if(u!==-1)return{type:v.BINARY,op:c,left:G(e.substring(0,u).trim(),t),right:G(e.substring(u+o.length).trim(),t)}}let i=-1,a=null,l=[{op:" + ",type:W.ADD},{op:" - ",type:W.SUBTRACT}];for(let{op:o,type:c}of l){let u=0;for(;u<e.length;){let h=de(e.substring(u),o);if(h===-1)break;let f=u+h;f>i&&(i=f,a={op:o,type:c}),u=f+o.length}}if(i!==-1&&a)return{type:v.BINARY,op:a.type,left:G(e.substring(0,i).trim(),t),right:G(e.substring(i+a.op.length).trim(),t)};let p=[" * "," / "," % "];for(let o of p)if(de(e,o)!==-1)throw new k(`Arithmetic operations are not allowed in conditionals: "${o}"`);return e.startsWith("!")?{type:v.UNARY,op:Te.NOT,operand:G(e.substring(1).trim(),t)}:Gr(e,t)},de=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},fn=e=>{if(e=e.trim(),e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:v.LITERAL,value:""};if(e==="{}")return{type:v.LITERAL,value:{}};if(e==="[]")return{type:v.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:v.LITERAL,value:t}:{type:v.VARIABLE,path:e}},Gr=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return Le(r,t);let n=fn(r);if(n.type===v.LITERAL)return n;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:v.VARIABLE,path:r};try{return Le(r,t)}catch(i){if(i.message&&i.message.includes("not supported"))return n;throw i}},yn=(e,t=!1)=>{let r=t?"$each":"$for";try{Dr(e)}catch(s){if(s instanceof k&&t){let n=s.message.replace(/\$for/g,"$each");throw new k(n.replace("Parse Error: ",""))}throw s}},qr=(e,t,r,s=!1)=>{let n=/^\$for(?::(\w+))?\s+(.+)$/,i=e.match(n);if(!i){let b=s?"$each":"$for";throw new k(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let a=i[1],l=i[2].trim();yn(l,s);let p=l.match(/^(.+?)\s+in\s+(.+)$/);if(!p){let b=s?"$each":"$for";throw new k(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${l}')`)}let o=p[1].trim(),c=p[2].trim(),u,h=null;if(o.includes(",")){let b=o.split(",").map(m=>m.trim());if(b.length!==2)throw new k(`Invalid loop variables: ${o}. Expected format: "item" or "item, index"`);u=b[0],h=b[1]}else u=o;let f=["this","undefined","null","true","false"];if(f.includes(u))throw new k(`Reserved variable name: ${u}`);if(h&&f.includes(h))throw new k(`Reserved variable name: ${h}`);let d=Gr(c,r),y=ue(t,r);return{type:v.LOOP,itemVar:u,indexVar:h,iterable:d,body:y,flatten:a!=="nested"}};var mn=(e,t={})=>{let{functions:r={}}=t;return ue(e,r)},Fe=mn;var At={};P(At,{now:()=>gn});var gn=()=>Date.now();var vn=(e,t,r={})=>{let{functions:s={},partials:n={}}=r,i={...At,...s},a=Fe(e,{functions:i}),l={};for(let[p,o]of Object.entries(n))l[p]=Fe(o,{functions:i});return _t(a,t,{functions:i,partials:l})},Et=vn;function Yr(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}var bn=()=>Object.freeze({formValues:{},tooltipState:{open:!1,x:0,y:0,content:""}}),Xr=(e,t,r=void 0)=>{if(!t)return;let s=t.split(/[\[\].]/).filter(i=>i!==""),n=e;for(let i of s){if(n==null||!(i in n))return r;n=n[i]}return n},wn=(e,t,r)=>{let s=t.split(/[\[\].]/).filter(i=>i!=="");t.includes("[")&&t in e&&delete e[t];let n=e;for(let i=0;i<s.length-1;i++){let a=s[i];if(!(a in n)||typeof n[a]!="object"||n[a]===null){let l=s[i+1],p=/^\d+$/.test(l);n[a]=p?[]:{}}n=n[a]}return n[s[s.length-1]]=r,e},_n=["id","class","style","slot"],xn=e=>Object.entries(e).filter(([t])=>!_n.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Ke=({props:e})=>{let{form:t={}}=e,{context:r}=e;return r?Et(t,r):t},An=({state:e,props:t,attrs:r})=>{let s=xn(r),n=Ke({state:e,props:t}),i=structuredClone(n.fields||[]);return i.forEach(a=>{let l=Xr(e.formValues,a.name);if(["read-only-text"].includes(a.inputType)&&(a.defaultValue=l),["select"].includes(a.inputType)){let p=t?.defaultValues;p&&p[a.name]!==void 0&&(a.selectedValue=p[a.name])}if(a.inputType==="image"){let p=a.src;a.imageSrc=p&&p.trim()?p:null,a.placeholderText=a.placeholder||"No Image"}if(a.inputType==="waveform"){let p=a.waveformData;a.waveformData=p||null,a.placeholderText=a.placeholder||"No Waveform"}}),{key:r?.key,containerAttrString:s,title:n?.title||"",description:n?.description||"",fields:i,actions:t?.form?.actions||{buttons:[]},formValues:e.formValues,tooltipState:e.tooltipState}},En=({state:e})=>e,kn=({state:e,props:t})=>{let r=Ke({state:e,props:t});return Yr(e.formValues,r.fields.map(s=>s.name))},$n=({state:e},t)=>Xr(e.formValues,t),Sn=(e,t)=>{e.formValues=t||{}},Cn=(e,{name:t,value:r,props:s})=>{wn(e.formValues,t,r);let n=Ke({state:e,props:s}),i=Yr(e.formValues,n.fields.map(a=>a.name));e.formValues=i},In=(e,{x:t,y:r,content:s})=>{e.tooltipState={open:!0,x:t,y:r,content:s}},On=e=>{e.tooltipState={...e.tooltipState,open:!1}};var Qr={elementName:"rtgl-form",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{defaultValues:{type:"object"},context:{type:"object"},form:{type:"object",properties:{title:{type:"string"},description:{type:"string"},fields:{type:"array",items:{anyOf:[{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"inputText"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"select"},placeholder:{type:"string"},noClear:{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}},options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}},required:["label","value"]}},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType","options"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"colorPicker"},value:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider-input"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"image"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"waveform"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},defaultValue:{type:"object"},waveformData:{type:"object"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"popover-input"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1}]}},actions:{type:"object",properties:{buttons:{type:"array",items:{type:"object",properties:{id:{type:"string"},content:{type:"string"}},required:["id","content"]}}}}}}}},refs:{"form-container":{eventListeners:{keydown:{handler:"handleKeyDown"}}},"action-*":{eventListeners:{click:{handler:"handleActionClick"}}},"tooltip-icon-*":{eventListeners:{mouseenter:{handler:"handleTooltipMouseEnter"},mouseleave:{handler:"handleTooltipMouseLeave"}}},"field-*":{eventListeners:{"input-change":{handler:"handleInputChange"},"textarea-change":{handler:"handleInputChange"},"select-change":{handler:"handleSelectChange"},"add-option-selected":{handler:"handleSelectAddOption"},"colorpicker-change":{handler:"handleColorPickerChange"},"slider-change":{handler:"handleSliderChange"},"slider-input-value-change":{handler:"handleSliderInputChange"}}},"image-*":{eventListeners:{click:{handler:"handleImageClick"},contextmenu:{handler:"handleImageClick"}}},"waveform-*":{eventListeners:{click:{handler:"handleWaveformClick"},contextmenu:{handler:"handleWaveformClick"}}}},events:{"form-change":{},"extra-event":{},"action-click":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view#form-container w=f p=md g=lg ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"$if title",value:{type:6,conditions:[{type:1,path:"title"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"title"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"$if description",value:{type:6,conditions:[{type:1,path:"description"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:1,path:"description"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-view g=lg w=f",value:{type:9,items:[{type:7,itemVar:"field",indexVar:"i",iterable:{type:1,path:"fields"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=f",value:{type:9,items:[{type:8,properties:[{key:"$if field.label || field.description",value:{type:6,conditions:[{type:4,op:7,left:{type:1,path:"field.label"},right:{type:1,path:"field.description"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md av=c",value:{type:9,items:[{type:8,properties:[{key:"$if field.label",value:{type:6,conditions:[{type:1,path:"field.label"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"field.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"$if field.label && field.tooltip",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"field.label"},right:{type:1,path:"field.tooltip"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-svg#tooltip-icon-${field.name} svg="info" wh=16 c=mu-fg cur=help ml=xs',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg#tooltip-icon-",{type:1,path:"field.name"},' svg="info" wh=16 c=mu-fg cur=help ml=xs']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"$if field.description",value:{type:6,conditions:[{type:1,path:"field.description"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"field.description"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "read-only-text"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"read-only-text"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"field.defaultValue"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:`$if field.inputType == "inputText" || field.inputType == 'input-text'`,value:{type:6,conditions:[{type:4,op:7,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"inputText"}},right:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"input-text"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input#field-${field.name} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#field-",{type:1,path:"field.name"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "input-number"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"input-number"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input-number#field-${field.name} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input-number#field-",{type:1,path:"field.name"}," w=f"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "input-textarea"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"input-textarea"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-textarea#field-${field.name} w=f rows=${field.rows} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-textarea#field-",{type:1,path:"field.name"}," w=f rows=",{type:1,path:"field.rows"}," w=f"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "popover-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"popover-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-popover-input#field-${field.name} label="${field.label}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-popover-input#field-",{type:1,path:"field.name"},' label="',{type:1,path:"field.label"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "select"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"select"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-select#field-${field.name} key=${key} w=f .options=fields[${i}].options ?no-clear=fields[${i}].noClear .addOption=fields[${i}].addOption .selectedValue=#{field.selectedValue} .placeholder=#{field.placeholder}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-select#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f .options=fields[",{type:1,path:"i"},"].options ?no-clear=fields[",{type:1,path:"i"},"].noClear .addOption=fields[",{type:1,path:"i"},"].addOption .selectedValue=",{type:11,path:"field.selectedValue"}," .placeholder=",{type:11,path:"field.placeholder"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "colorPicker"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"colorPicker"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-color-picker#field-${field.name} key=${key}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-color-picker#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider#field-${field.name} key=${key} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider-input#field-${field.name} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider-input#field-",{type:1,path:"field.name"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:1,path:"field.imageSrc"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image#image-${field.name} src=${field.imageSrc} w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image#image-",{type:1,path:"field.name"}," src=",{type:1,path:"field.imageSrc"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && !field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:5,op:0,operand:{type:1,path:"field.imageSrc"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholderText"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:1,path:"field.waveformData"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-waveform#field-${field.name} .waveformData=fields[${i}].waveformData w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-waveform#field-",{type:1,path:"field.name"}," .waveformData=fields[",{type:1,path:"i"},"].waveformData w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && !field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:5,op:0,operand:{type:1,path:"field.waveformData"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholder"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slot"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slot"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'slot#field-${field.slotName} name=${field.slot} style="display: contents;"',value:{type:0,value:null},parsedKey:{type:2,parts:["slot#field-",{type:1,path:"field.slotName"}," name=",{type:1,path:"field.slot"},' style="display: contents;"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=e g=sm w=f",value:{type:9,items:[{type:7,itemVar:"button",indexVar:"i",iterable:{type:1,path:"actions.buttons"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-button#action-${button.id}",value:{type:1,path:"button.content"},parsedKey:{type:2,parts:["rtgl-button#action-",{type:1,path:"button.id"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:'rtgl-tooltip ?open=${tooltipState.open} x=${tooltipState.x} y=${tooltipState.y} placement="top" content="${tooltipState.content}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-tooltip ?open=",{type:1,path:"tooltipState.open"}," x=",{type:1,path:"tooltipState.x"}," y=",{type:1,path:"tooltipState.y"},' placement="top" content="',{type:1,path:"tooltipState.content"},'"']}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#form-container w=f p=md g=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var $t={};P($t,{closeAll:()=>Bn,handleCancel:()=>Rn,handleConfirm:()=>Ln,handleDialogClose:()=>Tn,handleDropdownClose:()=>Nn,handleDropdownItemClick:()=>Pn,showAlert:()=>Vn,showConfirm:()=>Dn,showDropdownMenu:()=>jn});var Tn=(e,t)=>{let{store:r,render:s}=e;r.closeAll(),s()},Ln=(e,t)=>{let{store:r,render:s,globalUI:n}=e;r.closeAll(),s(),n.emit("event",!0)},Rn=(e,t)=>{let{store:r,render:s,globalUI:n}=e;r.closeAll(),s(),n.emit("event",!1)},Nn=(e,t)=>{let{store:r,render:s,globalUI:n}=e;r.closeAll(),s(),n.emit("event",null)},Pn=(e,t)=>{let{store:r,render:s,globalUI:n}=e,i=t._event,{index:a,item:l}=i.detail;r.closeAll(),s(),n.emit("event",{index:a,item:l})},Vn=(e,t)=>{let{store:r,render:s}=e,n=t;r.selectIsOpen()&&(r.closeAll(),s()),r.setAlertConfig(n),s()},Dn=async(e,t)=>{let{store:r,render:s,globalUI:n}=e,i=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setConfirmConfig(i),s(),new Promise(a=>{n.once("event",l=>{a(l)})})},jn=async(e,t)=>{let{store:r,render:s,globalUI:n}=e,i=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setDropdownConfig(i),s(),new Promise(a=>{n.once("event",l=>{a(l)})})},Bn=e=>{let{store:t,render:r}=e;t.selectIsOpen()&&(t.closeAll(),r())};var St={};P(St,{closeAll:()=>Un,createInitialState:()=>Wn,selectConfig:()=>zn,selectDropdownConfig:()=>Hn,selectIsOpen:()=>qn,selectUiType:()=>Jn,selectViewData:()=>Gn,setAlertConfig:()=>Mn,setConfirmConfig:()=>Fn,setDropdownConfig:()=>Kn});var Wn=()=>Object.freeze({isOpen:!1,uiType:"dialog",config:{status:void 0,title:"",message:"",confirmText:"OK",cancelText:"Cancel",mode:"alert"},dropdownConfig:{items:[],x:0,y:0,placement:"bottom-start"}}),Mn=(e,t)=>{if(!t.message)throw new Error("message is required for showAlert");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"OK",cancelText:"",mode:"alert"},e.uiType="dialog",e.isOpen=!0},Fn=(e,t)=>{if(!t.message)throw new Error("message is required for showConfirm");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"Yes",cancelText:t.cancelText||"Cancel",mode:"confirm"},e.uiType="dialog",e.isOpen=!0},Kn=(e,t)=>{if(!t.items||!Array.isArray(t.items))throw new Error("items array is required for showDropdown");e.dropdownConfig={items:t.items,x:t.x||0,y:t.y||0,placement:t.placement||"bottom-start"},e.uiType="dropdown",e.isOpen=!0},Un=e=>{e.isOpen=!1,e.uiType="dialog"},zn=({state:e})=>e.config,Hn=({state:e})=>e.dropdownConfig,Jn=({state:e})=>e.uiType,qn=({state:e})=>e.isOpen,Gn=({state:e})=>({isOpen:e.isOpen,uiType:e.uiType,config:e.config,dropdownConfig:{items:e.dropdownConfig?.items||[],x:e.dropdownConfig?.x||0,y:e.dropdownConfig?.y||0,placement:e.dropdownConfig?.placement||"bottom-start"},isDialogOpen:e.isOpen&&e.uiType==="dialog",isDropdownOpen:e.isOpen&&e.uiType==="dropdown"});var Zr={elementName:"rtgl-global-ui",viewDataSchema:{type:"object",properties:{isOpen:{type:"boolean"},uiType:{type:"string"},config:{type:"object",properties:{status:{type:"string"},title:{type:"string"},message:{type:"string"},confirmText:{type:"string"},cancelText:{type:"string"},mode:{type:"string"}}},dropdownConfig:{type:"object",properties:{items:{type:"array"},x:{type:"number"},y:{type:"number"},placement:{type:"string"}}}}},refs:{dialog:{eventListeners:{close:{handler:"handleDialogClose"}}},"confirm-button":{eventListeners:{click:{handler:"handleConfirm"}}},"cancel-button":{eventListeners:{click:{handler:"handleCancel"}}},"dropdown-menu":{eventListeners:{close:{handler:"handleDropdownClose"},"click-item":{handler:"handleDropdownItemClick"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-dialog#dialog ?open=${isDialogOpen} s=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content g=lg p=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=c av=c g=md",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=24 av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text fw=600",value:{type:1,path:"config.title"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"config.message"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h g=md mt=lg w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"$if config.mode == 'confirm'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"config.mode"},right:{type:0,value:"confirm"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-button#cancel-button v=se",value:{type:1,path:"config.cancelText"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-button#confirm-button v=pr",value:{type:1,path:"config.confirmText"}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-dialog#dialog ?open=",{type:1,path:"isDialogOpen"}," s=sm"]}}],fast:!1},{type:8,properties:[{key:"rtgl-dropdown-menu#dropdown-menu ?open=${isDropdownOpen} x=${dropdownConfig.x} y=${dropdownConfig.y} placement=${dropdownConfig.placement} .items=dropdownConfig.items key=dropdown-${isDropdownOpen}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-dropdown-menu#dropdown-menu ?open=",{type:1,path:"isDropdownOpen"}," x=",{type:1,path:"dropdownConfig.x"}," y=",{type:1,path:"dropdownConfig.y"}," placement=",{type:1,path:"dropdownConfig.placement"}," .items=dropdownConfig.items key=dropdown-",{type:1,path:"isDropdownOpen"}]}}],fast:!0}],fast:!1}};var Ct={};P(Ct,{handleClickStart:()=>Yn});var Yn=(e,t)=>{let{dispatchEvent:r,store:s}=e,n=t._event;console.log("handle click start",s.selectPath()),r(new CustomEvent("clickStart",{detail:{path:s.selectPath()}}))};var It={};P(It,{createInitialState:()=>Xn,selectPath:()=>ta,selectViewData:()=>ea,setState:()=>ra});var Xn=()=>Object.freeze({}),Qn=["id","class","style","slot"],Zn=e=>Object.entries(e).filter(([t])=>!Qn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),ea=({state:e,props:t,attrs:r})=>{console.log("attrs",{attrs:r,entries:Object.entries(r)});let s=r.start?JSON.parse(decodeURIComponent(r.start)):t.start;return{containerAttrString:Zn(r),start:s||{label:"",image:{src:"",width:32,height:32,alt:""}}}},ta=({props:e})=>e.start.path,ra=e=>{};var es={elementName:"rtgl-navbar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}},hasImage:{type:"boolean"},hasHref:{type:"boolean"}}}}},propsSchema:{type:"object",properties:{start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}}}}}},refs:{start:{eventListeners:{click:{handler:"handleClickStart"}}}},events:{clickStart:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"rtgl-text s=lg":"${start.label}"},{"$if start.image && start.image.src":[{"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}":null}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view bgc=bg d=h h=48 av=c w=f ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if start.href",value:{type:6,conditions:[{type:1,path:"start.href"},{type:1,path:"start.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${start.href}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["a href=",{type:1,path:"start.href"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#start d=h av=c g=lg g=md cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-view flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h av=c g=lg",value:{type:9,items:[{type:8,properties:[{key:"slot name=right",value:{type:0,value:null}}],fast:!0}],fast:!0}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view bgc=bg d=h h=48 av=c w=f ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ot={};P(Ot,{handleBeforeMount:()=>ia});var ts=(e,t,r)=>{let{store:s,render:n}=r,i,a=-1/0;if(e.forEach(l=>{let p=l.getBoundingClientRect();p.top<=t&&p.top>a&&(a=p.top,i=l.id)}),!i){let l=1/0;e.forEach(p=>{let o=p.getBoundingClientRect();o.top>t&&o.top<l&&(l=o.top,i=p.id)})}i&&i!==s.selectCurrentId()&&(s.setCurrentId(i),n())},sa=(e,t,r,s)=>{let{store:n,render:i}=s,a=e.querySelectorAll("h1[id], h2[id], h3[id], h4[id], rtgl-text[id]"),l=Array.from(a),p=l.map(c=>{let u=1,h=c.tagName.toLowerCase();return h==="h1"?u=1:h==="h2"?u=2:h==="h3"?u=3:h==="h4"?u=4:h==="rtgl-text"&&(u=parseInt(c.getAttribute("data-level")||"1",10)),{id:c.id,href:`#${c.id}`,title:c.textContent,level:u}});n.setItems(p),ts(l,r,s),i();let o=ts.bind(void 0,l,r,s);return t.addEventListener("scroll",o,{passive:!0}),()=>{t.removeEventListener("scroll",o)}},ia=e=>{let{attrs:t}=e;requestAnimationFrame(()=>{let r=document.getElementById(t["target-id"]),s=window;t["scroll-container-id"]&&(s=document.getElementById(t["scroll-container-id"])||window);let n=parseInt(t["offset-top"]||"100",10),i=sa(r,s,n,e);return()=>{i()}})};var Tt={};P(Tt,{createInitialState:()=>na,selectCurrentId:()=>la,selectState:()=>oa,selectViewData:()=>aa,setContentContainer:()=>ua,setCurrentId:()=>ca,setItems:()=>pa});var na=()=>Object.freeze({items:[],currentId:null,contentContainer:null}),aa=({state:e})=>{let r=((s,n)=>{let i=new Set,a=s.findIndex(p=>p.id===n);if(a===-1)return i;let l=s[a].level;for(let p=a-1;p>=0;p--)if(s[p].level<l){let o=s[p].level;i.add(s[p].id);for(let c=p-1;c>=0;c--)s[c].level<o&&(i.add(s[c].id),o=s[c].level);break}return i})(e.items,e.currentId);return{items:e.items.map(s=>{let n={1:"0",2:"12px",3:"24px",4:"32px"},i=s.id===e.currentId,a=r.has(s.id),l=i||a;return{...s,c:l?"fg":"mu-fg",ml:n[s.level]||"",bc:l?"fg":"mu-fg"}}),currentId:e.currentId}},oa=({state:e})=>e,la=({state:e})=>e.currentId,pa=(e,t)=>{e.items=t},ca=(e,t)=>{e.currentId=t},ua=(e,t)=>{e.contentContainer=t};var rs={elementName:"rtgl-page-outline",viewDataSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{slug:{type:"string"},title:{type:"string"}}}},selectedSlug:{type:"string",nullable:!0}}},propsSchema:{type:"object",properties:{}},refs:{},events:{onItemClick:{type:"object"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=272 pr=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f mt=xl",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'rtgl-view d=h bwl=xs bc="${item.bc}" pv=sm av=c href=${item.href} pl=md',value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=${item.ml}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-view w=",{type:1,path:"item.ml"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm c=${item.c} h-c=fg",value:{type:1,path:"item.title"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.c"}," h-c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:['rtgl-view d=h bwl=xs bc="',{type:1,path:"item.bc"},'" pv=sm av=c href=',{type:1,path:"item.href"}," pl=md"]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}};var Lt={};P(Lt,{handleBeforeMount:()=>ha,handleInputChange:()=>ma,handleInputKeydown:()=>va,handleOnUpdate:()=>da,handlePopoverClose:()=>ya,handleSubmitClick:()=>ga,handleTextClick:()=>fa});var ha=e=>{let{store:t,attrs:r}=e;r.value!==void 0&&t.setValue(r.value||"")},da=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:n,render:i}=e;if(r?.value!==s?.value){let a=s?.value??"";n.setValue(a)}i()},fa=(e,t)=>{let{store:r,render:s,getRefIds:n,attrs:i}=e,a=t._event,l=r.selectValue();r.setTempValue(l),r.openPopover({position:{x:a.currentTarget.getBoundingClientRect().left,y:a.currentTarget.getBoundingClientRect().bottom}});let{input:p}=n();p.elm.value=l,s(),i["auto-focus"]&&setTimeout(()=>{p.elm.focus()},50)},ya=(e,t)=>{let{store:r,render:s}=e;r.closePopover(),s()},ma=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,a=t._event.detail.value;r.setTempValue(a),n(new CustomEvent("temp-input-change",{detail:{value:a},bubbles:!0})),s()},ga=e=>{let{store:t,render:r,dispatchEvent:s,getRefIds:n}=e,{input:i}=n(),a=i.elm.value;t.setValue(a),t.closePopover(),s(new CustomEvent("input-change",{detail:{value:a},bubbles:!0})),r()},va=(e,t)=>{let{store:r,render:s,dispatchEvent:n,getRefIds:i}=e,a=t._event;if(a.key==="Enter"){let{input:l}=i(),p=l.elm.value;r.closePopover(),n(new CustomEvent("input-change",{detail:{value:p},bubbles:!0})),s()}else a.key==="Escape"&&(r.closePopover(),s())};var Rt={};P(Rt,{closePopover:()=>Aa,createInitialState:()=>ba,openPopover:()=>xa,selectValue:()=>ka,selectViewData:()=>wa,setTempValue:()=>_a,setValue:()=>Ea});var ba=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},value:"",tempValue:""}),wa=({attrs:e,state:t})=>{let r=t.value||"-";return{isOpen:t.isOpen,position:t.position,value:r,tempValue:t.tempValue,placeholder:e.placeholder??"",label:e.label}},_a=(e,t)=>{e.tempValue=t},xa=(e,t)=>{let{position:r}=t;e.position=r,e.isOpen=!0,e.hasUnsavedChanges=!1},Aa=e=>{e.isOpen=!1,e.tempValue=""},Ea=(e,t)=>{e.value=t},ka=({state:e})=>e.value;var ss={elementName:"rtgl-popover-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string"},placeholder:{type:"string"}}},refs:{"text-display":{eventListeners:{click:{handler:"handleTextClick"}}},popover:{eventListeners:{close:{handler:"handlePopoverClose"}}},input:{eventListeners:{"input-change":{handler:"handleInputChange"},keydown:{handler:"handleInputKeydown"}}},submit:{eventListeners:{click:{handler:"handleSubmitClick"}}}},events:{"input-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view#text-display w=f cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"value"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=240 slot=content bgc=background br=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"label"}}],fast:!0},{type:8,properties:[{key:"rtgl-input#input w=f placeholder=${placeholder}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input w=f placeholder=",{type:1,path:"placeholder"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"rtgl-button#submit",value:{type:0,value:"Submit"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}]}}],fast:!0}],fast:!0}};var Nt={};P(Nt,{handleAddOptionClick:()=>Na,handleAddOptionMouseEnter:()=>Pa,handleAddOptionMouseLeave:()=>Va,handleBeforeMount:()=>$a,handleButtonClick:()=>Ca,handleClearClick:()=>Ra,handleClickOptionsPopoverOverlay:()=>Ia,handleOnUpdate:()=>Sa,handleOptionClick:()=>Oa,handleOptionMouseEnter:()=>Ta,handleOptionMouseLeave:()=>La});var $a=e=>{let{store:t,props:r,render:s}=e;if(r.selectedValue!==null&&r.selectedValue!==void 0&&r.options){let n=r.options.find(i=>ce(i.value,r.selectedValue));n&&(t.updateSelectedValue({value:n?.value}),s())}},Sa=(e,t)=>{let{oldAttrs:r,newAttrs:s,oldProps:n,newProps:i}=t,{store:a,render:l}=e;if(r?.key!==s?.key&&s?.key){a.resetSelection();let p=i?.selectedValue,o=i?.options||[];if(p!=null&&o){let c=o.find(u=>ce(u.value,p));c&&a.updateSelectedValue({value:c.value})}l()}else n.selectedValue!==i.selectedValue&&(a.updateSelectedValue({value:i.selectedValue}),l())},Ca=(e,t)=>{let{store:r,render:s,getRefIds:n,props:i}=e;t._event.stopPropagation();let l=n()["select-button"].elm,p=l.firstElementChild,o=p?p.getBoundingClientRect():l.getBoundingClientRect(),c=r.selectSelectedValue(),u=c!==null?c:i.selectedValue,h=null;u!=null&&i.options&&(h=i.options.findIndex(f=>ce(f.value,u)),h===-1&&(h=null)),r.openOptionsPopover({position:{y:o.bottom+12,x:o.left-24},selectedIndex:h}),s()},Ia=e=>{let{store:t,render:r}=e;t.closeOptionsPopover(),r()},Oa=(e,t)=>{let{render:r,dispatchEvent:s,props:n,store:i}=e,a=t._event;a.stopPropagation();let l=a.currentTarget.id.replace("option-",""),p=n.options[l];i.updateSelectedValue({value:p?.value}),n.onChange&&typeof n.onChange=="function"&&n.onChange(p.value),s(new CustomEvent("option-selected",{detail:{value:p.value,label:p.label},bubbles:!0})),s(new CustomEvent("select-change",{detail:{selectedValue:p.value},bubbles:!0})),r()},Ta=(e,t)=>{let{store:r,render:s}=e,n=t._event,i=parseInt(n.currentTarget.id.replace("option-",""));r.setHoveredOption(i),s()},La=(e,t)=>{let{store:r,render:s}=e;r.clearHoveredOption(),s()},Ra=(e,t)=>{let{store:r,render:s,dispatchEvent:n,props:i}=e;t._event.stopPropagation(),r.clearSelectedValue(),i.onChange&&typeof i.onChange=="function"&&i.onChange(void 0),n(new CustomEvent("option-selected",{detail:{value:void 0,label:void 0},bubbles:!0})),n(new CustomEvent("select-change",{detail:{selectedValue:void 0},bubbles:!0})),s()},Na=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,{_event:i}=t;i.stopPropagation(),r.closeOptionsPopover(),n(new CustomEvent("add-option-selected",{bubbles:!0})),s()},Pa=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!0),s()},Va=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!1),s()};var Pt={};P(Pt,{clearHoveredOption:()=>qa,clearSelectedValue:()=>Ga,closeOptionsPopover:()=>Ua,createInitialState:()=>Ba,openOptionsPopover:()=>Ka,resetSelection:()=>Ha,selectSelectedValue:()=>Fa,selectState:()=>Ma,selectViewData:()=>Wa,setHoveredAddOption:()=>Ya,setHoveredOption:()=>Ja,updateSelectedValue:()=>za});var Da=["id","class","style","slot","placeholder","selectedValue","selected-value","onChange","on-change","options"],ja=e=>Object.entries(e||{}).filter(([t])=>!Da.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Ba=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},selectedValue:null,hoveredOptionId:null,hoveredAddOption:!1}),Wa=({state:e,props:t,attrs:r})=>{let s=ja(r),n=e.selectedValue!==null?e.selectedValue:t.selectedValue,i=t.placeholder||r.placeholder||"Select an option",a=!0,l=t.options||[],p=l.find(c=>ce(c.value,n));p&&(i=p.label,a=!1);let o=l.map((c,u)=>{let h=ce(c.value,n),f=e.hoveredOptionId===u;return{...c,isSelected:h,bgc:f?"ac":h?"mu":""}});return{containerAttrString:s,isOpen:e.isOpen,position:e.position,options:o,selectedValue:n,selectedLabel:i,selectedLabelColor:a?"mu-fg":"fg",hasValue:n!=null,showClear:!r["no-clear"]&&!t["no-clear"]&&n!=null,showAddOption:!!t.addOption,addOptionLabel:t.addOption?.label?`+ ${t.addOption.label}`:"+ Add",addOptionBgc:e.hoveredAddOption?"ac":""}},Ma=({state:e})=>e,Fa=({state:e})=>e.selectedValue,Ka=(e,t)=>{let{position:r,selectedIndex:s}=t;e.position=r,e.isOpen=!0,s!=null&&(e.hoveredOptionId=s)},Ua=e=>{e.isOpen=!1},za=(e,t)=>{e.selectedValue=t.value,e.isOpen=!1},Ha=e=>{e.selectedValue=void 0},Ja=(e,t)=>{e.hoveredOptionId=t},qa=e=>{e.hoveredOptionId=null},Ga=e=>{e.selectedValue=void 0},Ya=(e,t)=>{e.hoveredAddOption=t};var is={elementName:"rtgl-select",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{placeholder:{type:"string"}}},propsSchema:{type:"object",properties:{placeholder:{type:"string"},options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}}}},selectedValue:{type:"any"},onChange:{type:"function"},"no-clear":{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}}}},refs:{"select-button":{eventListeners:{click:{handler:"handleButtonClick"}}},"clear-button":{eventListeners:{click:{handler:"handleClearClick"}}},popover:{eventListeners:{close:{handler:"handleClickOptionsPopoverOverlay"}}},"option-*":{eventListeners:{click:{handler:"handleOptionClick"},mouseenter:{handler:"handleOptionMouseEnter"},mouseleave:{handler:"handleOptionMouseLeave"}}},"option-add":{eventListeners:{click:{handler:"handleAddOptionClick"},mouseenter:{handler:"handleAddOptionMouseEnter"},mouseleave:{handler:"handleAddOptionMouseLeave"}}}},events:{},template:{type:9,items:[{type:8,properties:[{key:"rtgl-button#select-button v=ol ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=${selectedLabelColor} ellipsis",value:{type:1,path:"selectedLabel"},parsedKey:{type:2,parts:["rtgl-text c=",{type:1,path:"selectedLabelColor"}," ellipsis"]}}],fast:!0},{type:8,properties:[{key:"rtgl-view mh=md flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"$if showClear",value:{type:6,conditions:[{type:1,path:"showClear"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg#clear-button mr=md svg=x wh=16 c=mu-fg cur=p",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-svg svg=chevronDown wh=16 c=mu-fg",value:{type:0,value:null}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-button#select-button v=ol ",{type:1,path:"containerAttrString"}]}}],fast:!1},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} placement=right-start",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 g=xs slot=content bgc=background br=md sv=true",value:{type:9,items:[{type:7,itemVar:"option",indexVar:"i",iterable:{type:1,path:"options"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f ph=lg pv=md cur=p br=md bgc=${option.bgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"option.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"option.bgc"}]}}],fast:!0}],fast:!0}},{type:8,properties:[{key:"$if showAddOption",value:{type:6,conditions:[{type:1,path:"showAddOption"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f bw=xs bc=mu-bg bt=sm",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=${addOptionBgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=ac",value:{type:1,path:"addOptionLabel"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"addOptionBgc"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}," placement=right-start"]}}],fast:!1}],fast:!1}};var Vt={};P(Vt,{handleHeaderClick:()=>Xa,handleItemClick:()=>Qa});var Xa=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event,i,a=r.selectHeader();n.currentTarget.id==="header-label"?i=a.labelPath:n.currentTarget.id==="header-image"?i=a.image.path:n.currentTarget.id==="header"&&(i=a.path),s(new CustomEvent("headerClick",{detail:{path:i},bubbles:!0,composed:!0}))},Qa=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event.currentTarget.id.replace("item-",""),a=r.selectItem(i);s(new CustomEvent("itemClick",{detail:{item:a},bubbles:!0,composed:!0}))};var jt={};P(jt,{createInitialState:()=>Za,selectActiveItem:()=>io,selectHeader:()=>so,selectItem:()=>no,selectViewData:()=>ro,setState:()=>ao});var Za=()=>Object.freeze({}),eo=["id","class","style","slot"],to=e=>Object.entries(e).filter(([t])=>!eo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" ");function Dt(e,t=null){let r=[];for(let s of e){let n=s.id||s.href||s.path,i=t===n;if(r.push({id:n,title:s.title,href:s.href,type:s.type||"item",icon:s.icon,hrefAttr:s.href?`href=${s.href}`:"",isSelected:i,itemBgc:i?"ac":"bg",itemHoverBgc:i?"ac":"mu"}),s.items&&Array.isArray(s.items))for(let a of s.items){let l=a.id||a.href||a.path,p=t===l;r.push({id:l,title:a.title,href:a.href,type:a.type||"item",icon:a.icon,hrefAttr:a.href?`href=${a.href}`:"",isSelected:p,itemBgc:p?"ac":"bg",itemHoverBgc:p?"ac":"mu"})}}return r}var ro=({state:e,props:t,attrs:r})=>{let s=r.header?JSON.parse(decodeURIComponent(r.header)):t.header,n=r.items?JSON.parse(decodeURIComponent(r.items)):t.items,i=r.selectedItemId||t.selectedItemId,a=to(r),l=r.mode||"full",p=s||{label:"",path:"",image:{src:"",alt:"",width:0,height:0}},o=n?Dt(n,i):[],c=l==="full"?272:64,u=l==="full"?"fs":"c",h=l==="full"?"fs":"c",f=l==="full"?"lg":"sm",d=l==="full"?"md":"sm",y=l==="shrunk-lg"?48:40,b=l==="shrunk-lg"?28:20,m=l==="shrunk-lg"?"md":"sm",w=l==="full",_=l==="full",x=l==="full"?"fs":"c",E=l==="full"?"":`ah=${h}`,$=l==="full"?"f":y;return{containerAttrString:a,mode:l,header:p,items:o,sidebarWidth:c,headerAlign:u,itemAlign:h,headerPadding:f,itemPadding:d,itemHeight:y,iconSize:b,firstLetterSize:m,showLabels:w,showGroupLabels:_,itemContentAlign:x,itemAlignAttr:E,itemWidth:$,headerWidth:$,selectedItemId:i,ah:l==="shrunk-lg"||l==="shrunk-md"?"c":""}},so=({state:e,props:t,attrs:r})=>r.header?JSON.parse(decodeURIComponent(r.header)):t.header,io=({state:e,props:t})=>(t.items?Dt(t.items):[]).find(s=>s.active),no=({state:e,props:t,attrs:r},s)=>{let n=r.items?JSON.parse(decodeURIComponent(r.items)):t.items;return(n?Dt(n):[]).find(a=>a.id===s)},ao=e=>{};var ns={elementName:"rtgl-sidebar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},mode:{type:"string",enum:["full","shrunk","shrunk-lg"],default:"full"},sidebarWidth:{type:"number"},headerAlign:{type:"string"},itemAlign:{type:"string"},headerPadding:{type:"string"},itemPadding:{type:"string"},itemHeight:{type:"number"},iconSize:{type:"number"},firstLetterSize:{type:"string"},showLabels:{type:"boolean"},showGroupLabels:{type:"boolean"},itemContentAlign:{type:"string"},itemAlignAttr:{type:"string"},itemWidth:{type:"string"},headerWidth:{type:"string"},selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},active:{type:"boolean"},icon:{type:"string"}}}}}},propsSchema:{type:"object",properties:{selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},items:{type:"array"}}}}}},refs:{"header-image":{eventListeners:{click:{handler:"handleHeaderClick"}}},"header-label":{eventListeners:{click:{handler:"handleHeaderClick"}}},header:{eventListeners:{click:{handler:"handleHeaderClick"}}},"item-*":{eventListeners:{click:{handler:"handleItemClick"}}}},events:{headerClick:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"$if header.image && header.image.src":[{"$if header.image.href":[{"a href=${header.image.href}":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],"$elif header.image.path":[{"rtgl-view#header-image cur=p":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],$else:[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}]},{"$if header.label && showLabels":[{"$if header.labelHref":[{"rtgl-text href=${header.labelHref} s=lg":"${header.label}"}],"$elif header.labelPath":[{"rtgl-view#header-label cur=p":[{"rtgl-text s=lg":"${header.label}"}]}],$else:[{"rtgl-text s=lg":"${header.label}"}]}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=${sidebarWidth} bwr=xs ah=${ah} ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view ph=${headerPadding} pv=lg",value:{type:9,items:[{type:8,properties:[{key:"$if header.href",value:{type:6,conditions:[{type:1,path:"header.href"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view href=${header.href} d=h av=c ah=${headerAlign} g=lg w=${headerWidth}",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view href=",{type:1,path:"header.href"}," d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header d=h av=c ah=${headerAlign} g=lg w=${headerWidth} cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#header d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view ph=",{type:1,path:"headerPadding"}," pv=lg"]}}],fast:!1},{type:8,properties:[{key:"rtgl-view w=f ph=${headerPadding} pb=lg g=xs ah=${ah}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'$if item.type == "groupLabel"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"groupLabel"}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showGroupLabels",value:{type:6,conditions:[{type:1,path:"showGroupLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=32 av=c ph=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=xs c=mu-fg",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=1 bgc=mu-bg",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} ${item.hrefAttr} h=${itemHeight} av=c ${itemAlignAttr} ph=${itemPadding} w=${itemWidth} h-bgc=${item.itemHoverBgc} br=lg bgc=${item.itemBgc} cur=p",value:{type:9,items:[{type:8,properties:[{key:"$if item.icon",value:{type:6,conditions:[{type:1,path:"item.icon"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=${itemContentAlign} g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h ah=",{type:1,path:"itemContentAlign"}," g=sm"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=${iconSize} svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=",{type:1,path:"iconSize"}," svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=${iconSize} br=f bgc=mu av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=${firstLetterSize} c=fg",value:{type:1,path:"item.title.charAt(0).toUpperCase()"},parsedKey:{type:2,parts:["rtgl-text s=",{type:1,path:"firstLetterSize"}," c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view wh=",{type:1,path:"iconSize"}," br=f bgc=mu av=c ah=c"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," ",{type:1,path:"item.hrefAttr"}," h=",{type:1,path:"itemHeight"}," av=c ",{type:1,path:"itemAlignAttr"}," ph=",{type:1,path:"itemPadding"}," w=",{type:1,path:"itemWidth"}," h-bgc=",{type:1,path:"item.itemHoverBgc"}," br=lg bgc=",{type:1,path:"item.itemBgc"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f ph=",{type:1,path:"headerPadding"}," pb=lg g=xs ah=",{type:1,path:"ah"}]}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view h=f w=",{type:1,path:"sidebarWidth"}," bwr=xs ah=",{type:1,path:"ah"}," ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Bt={};P(Bt,{handleBeforeMount:()=>oo,handleOnUpdate:()=>lo,handleValueChange:()=>po});var oo=e=>{let{store:t,attrs:r}=e;t.setValue(r.value??0)},lo=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:n,render:i}=e;if(r?.value!==s?.value){let a=s?.value??0;n.setValue(a),i()}},po=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,i=t._event,a=Number(i.detail.value);r.setValue(a),s(),n(new CustomEvent("slider-input-value-change",{detail:{value:a},bubbles:!0}))};var Wt={};P(Wt,{createInitialState:()=>co,selectViewData:()=>uo,setValue:()=>ho});var co=()=>Object.freeze({value:0}),uo=({state:e,attrs:t})=>({key:t.key,value:e.value,w:t.w||"",min:t.min||0,max:t.max||100,step:t.step||1}),ho=(e,t)=>{e.value=t};var as={elementName:"rtgl-slider-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string",default:"0"},w:{type:"string",default:""},min:{type:"string",default:"0"},max:{type:"string",default:"100"},step:{type:"string",default:"1"}}},refs:{input:{eventListeners:{"input-change":{handler:"handleValueChange"}}},slider:{eventListeners:{"slider-change":{handler:"handleValueChange"}}}},events:{"form-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md w=${w}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-slider#slider key=${key} w=f type=range min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#slider key=",{type:1,path:"key"}," w=f type=range min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=84",value:{type:9,items:[{type:8,properties:[{key:"rtgl-input#input key=${key} w=f type=number min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input key=",{type:1,path:"key"}," w=f type=number min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md w=",{type:1,path:"w"}]}}],fast:!0}],fast:!0}};var Mt={};P(Mt,{handleBeforeMount:()=>fo,handleHeaderClick:()=>mo,handleRowClick:()=>yo});var fo=e=>{},yo=(e,t)=>{let{dispatchEvent:r,props:s}=e,n=t._event,i=parseInt(n.currentTarget.id.replace("row-","")),a=s.data?.rows?.[i];a&&r(new CustomEvent("row-click",{detail:{rowIndex:i,rowData:a}}))},mo=(e,t)=>{let{store:r,render:s,dispatchEvent:n}=e,a=t._event.currentTarget.id.replace("header-",""),l=r.selectSortInfo(),p="asc";l.column===a&&(l.direction==="asc"?p="desc":l.direction==="desc"&&(p=null)),p?r.setSortColumn({column:a,direction:p}):r.clearSort(),s(),n(new CustomEvent("header-click",{detail:{column:a,direction:p,sortInfo:p?{column:a,direction:p}:null}}))};var Ft={};P(Ft,{clearSort:()=>ko,createInitialState:()=>go,selectSortInfo:()=>Ao,selectState:()=>xo,selectViewData:()=>_o,setSortColumn:()=>Eo});var go=()=>Object.freeze({sortColumn:null,sortDirection:null}),vo=["id","class","style","slot"],bo=e=>Object.entries(e).filter(([t])=>!vo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),wo=(e,t)=>{let r=t.split("."),s=e;for(let n of r){if(s==null)return null;s=s[n]}return s},_o=({state:e,props:t,attrs:r})=>{let s=bo(r),n=t.data||{columns:[],rows:[]},i=n.rows.map((a,l)=>{let p=n.columns.map(o=>{let c=wo(a,o.key);return{key:o.key,value:c!=null?String(c):""}});return{index:l,cells:p}});return{containerAttrString:s,columns:n.columns||[],rows:i||[]}},xo=({state:e})=>e,Ao=({state:e})=>({column:e.sortColumn,direction:e.sortDirection}),Eo=(e,{column:t,direction:r})=>{e.sortColumn=t,e.sortDirection=r},ko=e=>{e.sortColumn=null,e.sortDirection=null};var os={elementName:"rtgl-table",viewDataSchema:{type:"object",properties:{columns:{type:"array"},rows:{type:"array"},containerAttrString:{type:"string"}}},propsSchema:{type:"object",properties:{data:{type:"object",properties:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"}}}},rows:{type:"array",items:{type:"object"}}}},responsive:{type:"boolean",default:!0}}},refs:{"row-*":{eventListeners:{click:{handler:"handleRowClick"}}},"header-*":{eventListeners:{click:{handler:"handleHeaderClick"}}}},events:{},styles:{table:{width:"100%","border-collapse":"collapse","border-spacing":0},thead:{"border-bottom":"2px solid var(--border)"},th:{padding:"12px","text-align":"left","font-weight":500,color:"var(--foreground)","background-color":"var(--muted)",cursor:"pointer",position:"sticky",top:0,"z-index":1},"tbody tr":{"border-bottom":"1px solid var(--border)"},"tbody tr:last-child":{"border-bottom":"none"},td:{padding:"12px",color:"var(--foreground)"},".table-container":{width:"100%",height:"100%",overflow:"auto"},".empty-state":{"text-align":"center",padding:"24px",color:"var(--muted-foreground)"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view.table-container ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if rows.length > 0",value:{type:6,conditions:[{type:4,op:2,left:{type:1,path:"rows.length"},right:{type:0,value:0}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"table",value:{type:9,items:[{type:8,properties:[{key:"thead",value:{type:9,items:[{type:8,properties:[{key:"tr",value:{type:9,items:[{type:7,itemVar:"column",indexVar:"i",iterable:{type:1,path:"columns"},body:{type:9,items:[{type:8,properties:[{key:"th#header-${column.key}",value:{type:1,path:"column.label"},parsedKey:{type:2,parts:["th#header-",{type:1,path:"column.key"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"tbody",value:{type:9,items:[{type:7,itemVar:"row",indexVar:"rowIndex",iterable:{type:1,path:"rows"},body:{type:9,items:[{type:8,properties:[{key:"tr#row-${row.index}",value:{type:9,items:[{type:7,itemVar:"cell",indexVar:"cellIndex",iterable:{type:1,path:"row.cells"},body:{type:9,items:[{type:8,properties:[{key:"td",value:{type:1,path:"cell.value"}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["tr#row-",{type:1,path:"row.index"}]}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view.empty-state w=f p=xl",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"No data available"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view.table-container ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Kt={};P(Kt,{handleClickItem:()=>$o});var $o=(e,t)=>{let{dispatchEvent:r}=e,n=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:n}}))};var Ut={};P(Ut,{createInitialState:()=>So,selectViewData:()=>Oo});var So=()=>Object.freeze({}),Co=["id","class","style","slot"],Io=e=>Object.entries(e).filter(([t])=>!Co.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Oo=({state:e,props:t,attrs:r})=>{let s=Io(r),n=t.items||[],i=r["selected-tab"],a=n.map(l=>({...l,isSelected:l.id===i,bgColor:l.id===i?"ac":"",borderColor:l.id===i?"":"tr",textColor:l.id===i?"":"mu-fg"}));return{containerAttrString:s,items:a,selectedTab:i}};var ls={elementName:"rtgl-tabs",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"},isSelected:{type:"boolean"},bgColor:{type:"string"},textColor:{type:"string"},borderColor:{type:"string"}}}},selectedTab:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}}}},attrsSchema:{type:"object",properties:{"selected-tab":{type:"string"}}},refs:{"tab-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{id:{type:"string"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=sm bgc=mu p=sm br=lg ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#tab-${item.id} data-id=${item.id} cur=p bgc=${item.bgColor} bw=xs bc=${item.borderColor} pv=md ph=lg br=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=${item.textColor}",value:{type:1,path:"item.label"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.textColor"}]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#tab-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p bgc=",{type:1,path:"item.bgColor"}," bw=xs bc=",{type:1,path:"item.borderColor"}," pv=md ph=lg br=lg"]}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h g=sm bgc=mu p=sm br=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var ps={};var zt={};P(zt,{createInitialState:()=>To,selectViewData:()=>Lo});var To=()=>Object.freeze({}),Lo=({attrs:e})=>({open:!!e.open,x:e.x||0,y:e.y||0,placement:e.placement||"top",content:e.content||""});var cs={elementName:"rtgl-tooltip",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"},content:{type:"string"}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement} no-overlay",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content bgc=background bc=border br=md p=sm ah=c av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text ta=c s=sm c=foreground",value:{type:1,path:"content"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}," no-overlay"]}}],fast:!0}],fast:!0}};var Ht={};P(Ht,{handleAfterMount:()=>Ro,handleOnUpdate:()=>No});var Ro=async e=>{let{props:t,store:r,render:s,getRefIds:n}=e,{waveformData:i}=t;r.setWaveformData(i),s();let a=n().canvas?.elm;a&&us(i,a)},No=async(e,t)=>{let{store:r,render:s,getRefIds:n,props:i}=e,{waveformData:a}=i;if(!a){console.log("waveform handleOnUpdate: no waveformData provided");return}r.setWaveformData(a),s();let l=n().canvas?.elm;l&&us(a,l)};async function us(e,t){let r=t.getContext("2d"),s=t.getBoundingClientRect(),n=s.width,i=s.height;t.width=n,t.height=i;let a=t.width,l=t.height;if(r.clearRect(0,0,a,l),r.fillStyle="#1a1a1a",r.fillRect(0,0,a,l),!e||!e.amplitudes)return;let p=e.amplitudes,o=l/2,c=r.createLinearGradient(0,0,0,l);c.addColorStop(0,"#404040"),c.addColorStop(.5,"#A1A1A1"),c.addColorStop(1,"#404040");let u=Math.max(1,a/p.length),h=.2;for(let f=0;f<p.length;f++){let y=p[f]/255*(l*.85),b=f*u,m=o-y/2;r.fillStyle=c,r.fillRect(b,m,Math.max(1,u*(1-h)),y)}r.strokeStyle="rgba(255, 255, 255, 0.1)",r.lineWidth=1,r.beginPath(),r.moveTo(0,o),r.lineTo(a,o),r.stroke(),r.shadowBlur=10,r.shadowColor="#2196F3"}var Jt={};P(Jt,{createInitialState:()=>Po,selectViewData:()=>Do,setWaveformData:()=>Vo});var Po=()=>Object.freeze({waveformData:null}),Vo=(e,t)=>{e.waveformData=t},Do=({state:e,attrs:t,props:r})=>({isLoading:r.isLoading,w:t.w||"250",h:t.h||"150",cur:t.cur,waveformData:r.waveformData});var hs={elementName:"rtgl-waveform",attrsSchema:{type:"object",properties:{w:{type:"string",description:"Width of the waveform visualizer",default:"250"},h:{type:"string",description:"Height of the waveform visualizer",default:"150"},cur:{type:"string",description:"cursor"}}},propsSchema:{type:"object",properties:{waveformData:{type:"object",description:"File ID of the waveform data in object storage"},isLoading:{type:"boolean",description:"Whether the waveform data is currently being loaded"}}},refs:{canvas:{selector:"canvas"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f pos=rel w=${w} h=${h} cur=${cur}",value:{type:9,items:[{type:8,properties:[{key:"$if isLoading",value:{type:6,conditions:[{type:1,path:"isLoading"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"..."}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'canvas#canvas style="width:100%; height:100%;"',value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f h=f pos=rel w=",{type:1,path:"w"}," h=",{type:1,path:"h"}," cur=",{type:1,path:"cur"}]}}],fast:!1}],fast:!1}};var vs=Symbol.for("immer-nothing"),ds=Symbol.for("immer-draftable"),se=Symbol.for("immer-state");function le(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ae=Object.getPrototypeOf;function Ee(e){return!!e&&!!e[se]}function ye(e){return e?bs(e)||Array.isArray(e)||!!e[ds]||!!e.constructor?.[ds]||qe(e)||Ge(e):!1}var jo=Object.prototype.constructor.toString();function bs(e){if(!e||typeof e!="object")return!1;let t=Ae(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===jo}function Ue(e,t){Je(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,s)=>t(s,r,e))}function Je(e){let t=e[se];return t?t.type_:Array.isArray(e)?1:qe(e)?2:Ge(e)?3:0}function Yt(e,t){return Je(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ws(e,t,r){let s=Je(e);s===2?e.set(t,r):s===3?e.add(r):e[t]=r}function Bo(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qe(e){return e instanceof Map}function Ge(e){return e instanceof Set}function fe(e){return e.copy_||e.base_}function Xt(e,t){if(qe(e))return new Map(e);if(Ge(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=bs(e);if(t===!0||t==="class_only"&&!r){let s=Object.getOwnPropertyDescriptors(e);delete s[se];let n=Reflect.ownKeys(s);for(let i=0;i<n.length;i++){let a=n[i],l=s[a];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[a]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[a]})}return Object.create(Ae(e),s)}else{let s=Ae(e);if(s!==null&&r)return{...e};let n=Object.create(s);return Object.assign(n,e)}}function rr(e,t=!1){return Ye(e)||Ee(e)||!ye(e)||(Je(e)>1&&(e.set=e.add=e.clear=e.delete=Wo),Object.freeze(e),t&&Object.entries(e).forEach(([r,s])=>rr(s,!0))),e}function Wo(){le(2)}function Ye(e){return Object.isFrozen(e)}var Mo={};function me(e){let t=Mo[e];return t||le(0,e),t}var Re;function _s(){return Re}function Fo(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function fs(e,t){t&&(me("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Qt(e){Zt(e),e.drafts_.forEach(Ko),e.drafts_=null}function Zt(e){e===Re&&(Re=e.parent_)}function ys(e){return Re=Fo(Re,e)}function Ko(e){let t=e[se];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ms(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[se].modified_&&(Qt(t),le(4)),ye(e)&&(e=ze(t,e),t.parent_||He(t,e)),t.patches_&&me("Patches").generateReplacementPatches_(r[se].base_,e,t.patches_,t.inversePatches_)):e=ze(t,r,[]),Qt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==vs?e:void 0}function ze(e,t,r){if(Ye(t))return t;let s=t[se];if(!s)return Ue(t,(n,i)=>gs(e,s,t,n,i,r)),t;if(s.scope_!==e)return t;if(!s.modified_)return He(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;let n=s.copy_,i=n,a=!1;s.type_===3&&(i=new Set(n),n.clear(),a=!0),Ue(i,(l,p)=>gs(e,s,n,l,p,r,a)),He(e,n,!1),r&&e.patches_&&me("Patches").generatePatches_(s,r,e.patches_,e.inversePatches_)}return s.copy_}function gs(e,t,r,s,n,i,a){if(Ee(n)){let l=i&&t&&t.type_!==3&&!Yt(t.assigned_,s)?i.concat(s):void 0,p=ze(e,n,l);if(ws(r,s,p),Ee(p))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(ye(n)&&!Ye(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ze(e,n),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,s)&&He(e,n)}}function He(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&rr(t,r)}function Uo(e,t){let r=Array.isArray(e),s={type_:r?1:0,scope_:t?t.scope_:_s(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=s,i=sr;r&&(n=[s],i=Ne);let{revoke:a,proxy:l}=Proxy.revocable(n,i);return s.draft_=l,s.revoke_=a,l}var sr={get(e,t){if(t===se)return e;let r=fe(e);if(!Yt(r,t))return zo(e,r,t);let s=r[t];return e.finalized_||!ye(s)?s:s===qt(e.base_,t)?(Gt(e),e.copy_[t]=tr(s,e)):s},has(e,t){return t in fe(e)},ownKeys(e){return Reflect.ownKeys(fe(e))},set(e,t,r){let s=xs(fe(e),t);if(s?.set)return s.set.call(e.draft_,r),!0;if(!e.modified_){let n=qt(fe(e),t),i=n?.[se];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Bo(r,n)&&(r!==void 0||Yt(e.base_,t)))return!0;Gt(e),er(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return qt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Gt(e),er(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=fe(e),s=Reflect.getOwnPropertyDescriptor(r,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:r[t]}},defineProperty(){le(11)},getPrototypeOf(e){return Ae(e.base_)},setPrototypeOf(){le(12)}},Ne={};Ue(sr,(e,t)=>{Ne[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ne.deleteProperty=function(e,t){return Ne.set.call(this,e,t,void 0)};Ne.set=function(e,t,r){return sr.set.call(this,e[0],t,r,e[0])};function qt(e,t){let r=e[se];return(r?fe(r):e)[t]}function zo(e,t,r){let s=xs(t,r);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}function xs(e,t){if(!(t in e))return;let r=Ae(e);for(;r;){let s=Object.getOwnPropertyDescriptor(r,t);if(s)return s;r=Ae(r)}}function er(e){e.modified_||(e.modified_=!0,e.parent_&&er(e.parent_))}function Gt(e){e.copy_||(e.copy_=Xt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ho=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,s)=>{if(typeof t=="function"&&typeof r!="function"){let i=r;r=t;let a=this;return function(p=i,...o){return a.produce(p,c=>r.call(this,c,...o))}}typeof r!="function"&&le(6),s!==void 0&&typeof s!="function"&&le(7);let n;if(ye(t)){let i=ys(this),a=tr(t,void 0),l=!0;try{n=r(a),l=!1}finally{l?Qt(i):Zt(i)}return fs(i,s),ms(n,i)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===vs&&(n=void 0),this.autoFreeze_&&rr(n,!0),s){let i=[],a=[];me("Patches").generateReplacementPatches_(t,n,i,a),s(i,a)}return n}else le(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(a,...l)=>this.produceWithPatches(a,p=>t(p,...l));let s,n;return[this.produce(t,r,(a,l)=>{s=a,n=l}),s,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ye(e)||le(8),Ee(e)&&(e=Jo(e));let t=ys(this),r=tr(e,void 0);return r[se].isManual_=!0,Zt(t),r}finishDraft(e,t){let r=e&&e[se];(!r||!r.isManual_)&&le(9);let{scope_:s}=r;return fs(s,t),ms(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let s=me("Patches").applyPatches_;return Ee(e)?s(e,t):this.produce(e,n=>s(n,t))}};function tr(e,t){let r=qe(e)?me("MapSet").proxyMap_(e,t):Ge(e)?me("MapSet").proxySet_(e,t):Uo(e,t);return(t?t.scope_:_s()).drafts_.push(r),r}function Jo(e){return Ee(e)||le(10,e),As(e)}function As(e){if(!ye(e)||Ye(e))return e;let t=e[se],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Xt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Xt(e,!0);return Ue(r,(s,n)=>{ws(r,s,As(n))}),t&&(t.finalized_=!1),r}var ie=new Ho,Es=ie.produce,xu=ie.produceWithPatches.bind(ie),Au=ie.setAutoFreeze.bind(ie),Eu=ie.setUseStrictShallowCopy.bind(ie),ku=ie.applyPatches.bind(ie),$u=ie.createDraft.bind(ie),Su=ie.finishDraft.bind(ie);var g={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},M={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Pe={NOT:0};var R=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Q=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var ir=e=>{if(!e||e.trim()==="")throw new R("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new R(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new R(`Incomplete comparison expression - missing right operand (got: '${e}')`)},ks=e=>{if(e.trim().endsWith(" in"))throw new R(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new R(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new R(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(n=>n.trim());for(let n of s)if(!n)throw new R(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new R(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var $s=(e,t,r=!1)=>{if(t===null)return new Q(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Q(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new Q(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new Q(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},Ss=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Q(`Unknown function '${e}' (${r})`)};var qo=(e,t,r={})=>{let s={},n={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},n=r.partials||{}):typeof r=="object"&&(s=r));let a=T(e,{functions:s,partials:n},t,{});return a===void 0?{}:a},T=(e,t,r,s)=>{let n=t.functions||t;if(e.var&&!e.type)return H(e.var,r,s);if(e.type===g.LITERAL)return e.value;if(e.type===g.VARIABLE)return H(e.path,r,s);if(e.type===g.INTERPOLATION)return Yo(e.parts,t,r,s);switch(e.type){case g.FUNCTION:return Is(e,t,r,s);case g.BINARY:return Os(e,t,r,s);case g.UNARY:return Ts(e,t,r,s);case g.CONDITIONAL:return Qo(e,t,r,s);case g.LOOP:return sl(e,t,r,s);case g.OBJECT:return nl(e,t,r,s);case g.ARRAY:return al(e,t,r,s);case g.PARTIAL:return ol(e,t,r,s);case g.PATH_REFERENCE:return ll(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},Cs=new Map,Go=e=>{let t=[],r="",s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(i==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(i==="]"){if(s&&r){let a=r.trim();if(/^\d+$/.test(a))t.push({type:"index",value:parseInt(a,10)});else if(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")){let l=a.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:a});r=""}s=!1}else r+=i}return r&&t.push({type:"property",value:r}),t},H=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=Cs.get(e);if(!s){let i=[],a="",l=0;for(let p=0;p<e.length;p++){let o=e[p];o==="["?(l++,a+=o):o==="]"?(l--,a+=o):o==="."&&l===0?a&&(i.push(a),a=""):a+=o}a&&i.push(a),s=[];for(let p of i){let o=Go(p.trim());s.push(...o)}Cs.set(e,s)}let n=t;for(let i=0;i<s.length;i++){let a=s[i];if(a.type==="property"&&a.value in r){n=r[a.value];continue}if(n==null)return;(a.type==="property"||a.type==="index")&&(n=n[a.value])}return n},Yo=(e,t,r,s)=>{let n=[];for(let i of e)if(typeof i=="string")n.push(i);else{let a=T(i,t,r,s);n.push(a!=null?String(a):"")}return n.join("")},Is=(e,t,r,s)=>{let n=t.functions||t,i=n[e.name];if(!i)throw Ss(e.name,n);let a=e.args.map(l=>T(l,t,r,s));return i(...a)},ke=(e,t,r,s)=>{if(e.var&&!e.type)return H(e.var,r,s);switch(e.type){case g.VARIABLE:return H(e.path,r,s);case g.LITERAL:return e.value;case g.BINARY:return Os(e,t,r,s);case g.UNARY:return Ts(e,t,r,s);case g.FUNCTION:return Is(e,t,r,s);default:return T(e,t,r,s)}},Os=(e,t,r,s)=>{if(e.op===M.AND||e.op===M.OR){let a=ke(e.left,t,r,s),l=ke(e.right,t,r,s);switch(e.op){case M.AND:return a&&l;case M.OR:return a||l}}let n=T(e.left,t,r,s),i=T(e.right,t,r,s);switch(e.op){case M.EQ:return n==i;case M.NEQ:return n!=i;case M.GT:return n>i;case M.LT:return n<i;case M.GTE:return n>=i;case M.LTE:return n<=i;case M.IN:return Array.isArray(i)?i.includes(n):!1;case M.ADD:if(typeof n!="number"||typeof i!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof n} + ${typeof i}`);return n+i;case M.SUBTRACT:if(typeof n!="number"||typeof i!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof n} - ${typeof i}`);return n-i;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ts=(e,t,r,s)=>{let n=e.op===Pe.NOT?ke(e.operand,t,r,s):T(e.operand,t,r,s);switch(e.op){case Pe.NOT:return!n;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Xo=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let n=e.conditions[0];if(n.type===g.VARIABLE)if(H(n.path,r,s)){let a=e.bodies[0];if(a.type===g.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[o]=c.value;else if(c.type===g.VARIABLE)l[o]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=T(c,t,r,s)}return l}}else{let a=e.bodies[1];if(a.type===g.OBJECT&&a.properties.length<=5){let l={};for(let p of a.properties){let o=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[o]=c.value;else if(c.type===g.VARIABLE)l[o]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[o]=u.join("")}else l[o]=T(c,t,r,s)}return l}}}return null},Qo=(e,t,r,s)=>{let n=Xo(e,t,r,s);if(n!==null)return n;for(let i=0;i<e.conditions.length;i++){let a=e.conditions[i];if(a===null||ke(a,t,r,s))return T(e.bodies[i],t,r,s)}return Ls},Zo=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===g.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===g.VARIABLE){let n=r.conditions[0].path,i=r.bodies[0];if(n.startsWith(s+".")){let a=n.substring(s.length+1);if(i.type===g.OBJECT&&i.properties.length<=5){for(let p of i.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let o=t[p];if(o[a]){let c={};for(let u of i.properties){let h=u.key,f=u.value;if(f.type===g.LITERAL)c[h]=f.value;else if(f.type===g.VARIABLE){let d=f.path;if(d===s)c[h]=o;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=o[y]}else return null}else if(f.type===g.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===g.VARIABLE){let m=b.path;if(m===s)d.push(o!=null?String(o):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=o[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},el=(e,t)=>{let r=e.body,s=e.itemVar,n=Zo(e,t);if(n!==null)return n;if(r.type===g.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let i=[],a=!0;for(let l of r.properties){let p=l.key,o=l.value;if(o.type===g.LITERAL)i.push({key:p,type:"literal",value:o.value});else if(o.type===g.VARIABLE){let c=o.path;if(c===s)i.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))i.push({key:p,type:"prop",prop:u});else{a=!1;break}}else{a=!1;break}}else if(o.type===g.INTERPOLATION&&o.parts.length===1){let c=o.parts[0];if(c.type===g.VARIABLE){let u=c.path;if(u===s)i.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))i.push({key:p,type:"prop_string",prop:h});else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}else{a=!1;break}}if(a){let l=new Array(t.length);if(i.length===3&&i[0].type==="prop"&&i[0].key==="id"&&i[1].type==="prop_string"&&i[1].key==="title"&&i[2].type==="prop"&&i[2].key==="completed")for(let p=0;p<t.length;p++){let o=t[p];l[p]={id:o.id,title:o.title!=null?String(o.title):"",completed:o.completed}}else for(let p=0;p<t.length;p++){let o=t[p],c={};for(let u of i)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=o;else if(u.type==="prop")c[u.key]=o[u.prop];else if(u.type==="item_string")c[u.key]=o!=null?String(o):"";else if(u.type==="prop_string"){let h=o[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},tl=(e,t,r,s,n)=>{let i=[],a=e.body;if(a.type===g.OBJECT&&a.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let o=0;o<n.length;o++){let c=n[o],u={},h={...s,[l]:c,...p&&{[p]:o}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${o}]`,...p&&{[p]:o}};for(let d of a.properties){let y=d.parsedKey?T(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===g.LITERAL)u[y]=b.value;else if(b.type===g.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=o;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:o}})}else u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:o}})}else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=o;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=H(_,r,{...s,[l]:c,...p&&{[p]:o}})}else x=H(_,r,{...s,[l]:c,...p&&{[p]:o}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:o}},x=T(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:o}};u[y]=T(b,t,r,m)}}i.push(u)}return i}return null},rl=(e,t,r)=>{let s=e.body;if(s.type===g.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let i=s.properties[0].value;if(i.type===g.CONDITIONAL&&i.conditions.length===1&&i.conditions[0].type===g.VARIABLE&&i.conditions[0].path==="item.visible"){let a=i.bodies[0];if(a.type===g.OBJECT&&a.properties.length===2){let l=a.properties[0],p=a.properties[1];if(l.key==="id"&&l.value.type===g.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===g.CONDITIONAL){let o=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),o.push(h)}}return o}}}}return null},sl=(e,t,r,s)=>{let n=T(e.iterable,t,r,s);if(!Array.isArray(n)){let o,c=!1;if(e.iterable.type===g.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===g.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===g.VARIABLE?f.path:f.type===g.FUNCTION?`${f.name}(...)`:"?").join(", ");o=`${e.iterable.name}(${h})`}else o=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${o}`;throw $s(u,n,c)}if(!e.indexVar){let o=rl(e,n,e.itemVar);if(o!==null)return o}if(!e.indexVar){let o=el(e,n);if(o!==null)return o}let i=tl(e,t,r,s,n);if(i!==null)return i;let a=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let o=l.split("."),c=o[0];c in s.__paths__&&(l=s.__paths__[c],o.length>1&&(l+="."+o.slice(1).join(".")))}let p=!1;e.body.type===g.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(o=>o.type===g.OBJECT&&o.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let o=0;o<n.length;o++){let c=e.indexVar?{...s,[e.itemVar]:n[o],[e.indexVar]:o}:{...s,[e.itemVar]:n[o]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${o}]`},e.indexVar&&(c.__paths__[e.indexVar]=o);let u=T(e.body,t,r,c);Array.isArray(u)&&u.length===1&&!p?a.push(u[0]):a.push(u)}return a},il=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let n=e.properties[0],i=n.parsedKey?T(n.parsedKey,t,r,s):n.key,a=n.value;if(a.type===g.OBJECT&&a.properties.length<=10&&!a.whenCondition){let l={},p={},o=!0;for(let c of a.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)p[u]=h.value;else if(h.type===g.VARIABLE)p[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{o=!1;break}if(!o)break;p[u]=f.join("")}else if(h.type===g.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===g.LITERAL)f[y]=b.value;else if(b.type===g.VARIABLE)f[y]=H(b.path,r,s);else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=H(w.path,r,s);m.push(_!=null?String(_):"")}else{o=!1;break}if(!o)break;f[y]=m.join("")}else{o=!1;break}}if(!o)break;p[u]=f}else{o=!1;break}}if(o)return l[i]=p,l}}return null},nl=(e,t,r,s)=>{let n=t.functions||t;if(e.whenCondition&&!ke(e.whenCondition,n,r,s))return;let i=il(e,t,r,s);if(i!==null)return i;if(e.fast){let o={};for(let c of e.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)o[u]=h.value;else if(h.type===g.VARIABLE)o[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=T(d,t,r,s);f.push(y!=null?String(y):"")}o[u]=f.join("")}else o[u]=T(h,t,r,s)}return o}let a={},l=null,p=!1;for(let o of e.properties)if(!o.key.startsWith("$if ")&&!o.key.match(/^\$if\s+\w+.*:?$/)&&!o.key.startsWith("$elif")&&!o.key.startsWith("$else")&&!o.key.startsWith("$for ")){p=!0;break}for(let o of e.properties)if(o.key.startsWith("$if ")||o.key.match(/^\$if\s+\w+.*:?$/)){let c=T(o.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(a,c)}else if(o.key.startsWith("$for ")){if(e.properties.length===1)return T(o.value,t,r,s)}else{let c=o.value;if(c&&c.type===g.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=T(u.value,t,r,s);h!==void 0&&(a[o.key]=h)}else{let h=T(o.value,t,r,s);h!==void 0&&(a[o.key]=h)}}else{let u=o.parsedKey?T(o.parsedKey,t,r,s):o.key,h=T(o.value,t,r,s);h!==void 0&&(a[u]=h)}}return a},Ls={},al=(e,t,r,s)=>{let n=[];for(let i of e.items)if(i.type===g.LOOP){let a=T(i,t,r,s);n.push(a)}else{let a=T(i,t,r,s);a!==Ls&&a!==void 0&&n.push(a)}return n},ol=(e,t,r,s)=>{let{name:n,data:i,whenCondition:a}=e,l=t.partials||{},p=t.functions||t;if(a&&!ke(a,p,r,s))return;if(!l[n])throw new Q(`Partial '${n}' is not defined`);let o=s._partialStack||[];if(o.includes(n))throw new Q(`Circular partial reference detected: ${n}`);let c=l[n],u=r,h={...s,_partialStack:[...o,n]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(i){let f=T(i,t,r,s);u={...u,...f}}return T(c,t,u,h)},ll=(e,t,r,s)=>{let{path:n}=e,i=n.split("."),a=i[0],l=i.slice(1);if(!s||!(a in s))throw new Q(`Path reference '#{${n}}' refers to '${a}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(a in s.__paths__))throw new Q(`Path reference '#{${n}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[a];if(typeof p=="number"){if(l.length>0)throw new Q(`Path reference '#{${n}}' - cannot access properties on index variable '${a}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},Ve=qo;var pl=/\$\{([^}]*)\}/g,cl=/#\{([^}]*)\}/g,Ns=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,n]=r,i=ul(n,t);return{isFunction:!0,type:g.FUNCTION,name:s,args:i}},ul=(e,t={})=>e.trim()?hl(e).map(s=>dl(s.trim(),t)):[],hl=e=>{let t=[],r="",s=0,n=!1,i="";for(let a=0;a<e.length;a++){let l=e[a],p=a>0?e[a-1]:"";!n&&(l==='"'||l==="'")?(n=!0,i=l,r+=l):n&&l===i&&p!=="\\"?(n=!1,i="",r+=l):!n&&l==="("?(s++,r+=l):!n&&l===")"?(s--,r+=l):!n&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},dl=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:g.LITERAL,value:parseFloat(e)};if(e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};let r=Ns(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),n=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],i=-1,a=null;for(let{op:l,type:p}of n){let o=0;for(;o<s.length;){let c=ge(s.substring(o),l);if(c===-1)break;let u=o+c;u>i&&(i=u,a={op:l,type:p}),o=u+l.length}}if(i!==-1)try{return Y(s,t)}catch{return{type:g.VARIABLE,path:s}}return{type:g.VARIABLE,path:s}},Ps=/^\w+\(.*\)$/,fl=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,yl=e=>{if(!(!e||e.trim()===""||Ps.test(e))&&fl.test(e))throw e.includes("?")&&e.includes(":")?new R(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new R(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new R(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Rs=e=>{let t=e.trim();if(Ps.test(t))throw new R(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new R(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new R(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new R(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new R(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:g.PATH_REFERENCE,path:t}},De=(e,t={})=>{let r=e.trim();yl(r);let s=Ns(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let n=0;for(let i of r)i==="["?n++:i==="]"&&n--;if(n!==0)throw new Error("Invalid array index syntax")}return{type:g.VARIABLE,path:r}},nr=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(o,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let n=[...r.matchAll(pl)],i=[...r.matchAll(cl)],a=[...n.map(o=>({match:o,type:"variable"})),...i.map(o=>({match:o,type:"pathref"}))].sort((o,c)=>o.match.index-c.match.index);if(a.length===0){let o=r;for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);return{type:g.LITERAL,value:o}}if(a.length===1&&a[0].match[0]===r&&s.length===0){let{match:o,type:c}=a[0];try{return c==="variable"?De(o[1],t):Rs(o[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:g.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:o,type:c}of a){let[u,h]=o,f=o.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=De(h.trim(),t):d=Rs(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let o=r.substring(p);for(let c=0;c<s.length;c++)o=o.replace(`__ESCAPED_${c}__`,s[c]);o&&l.push(o)}return{type:g.INTERPOLATION,parts:l}};var he=(e,t)=>typeof e=="string"?nr(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?ml(e,t):gl(e,t):{type:g.LITERAL,value:e},ml=(e,t)=>{let r=[],s=!1;for(let n=0;n<e.length;n++){let i=e[n];if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let l=Object.keys(i);if(l.length===1&&l[0].startsWith("$for ")){let p=Ds(l[0],i[l[0]],t);r.push(p),s=!0;continue}}let a=he(i,t);r.push(a),(a.type===g.FUNCTION||a.type===g.CONDITIONAL||a.type===g.LOOP||a.type===g.PARTIAL||a.type===g.OBJECT&&!a.fast||a.type===g.ARRAY&&!a.fast)&&(s=!0)}return{type:g.ARRAY,items:r,fast:!s}},gl=(e,t)=>{let r=[],s=!1,n=null,i=Object.entries(e),a=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new R("$partial value must be a string");if(e.$partial.trim()==="")throw new R("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],o=[];for(let[m]of i)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){o.push(w);break}if(o.length>0)throw new R(`Cannot use $partial with ${o.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=he(f,t),y.type===g.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===g.VARIABLE||w.value.type===g.INTERPOLATION||w.value.type===g.FUNCTION||w.value.type===g.CONDITIONAL||w.value.type===g.LOOP||w.value.type===g.OBJECT&&!w.value.fast||w.value.type===g.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:g.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new R("Empty condition expression after '$when'");m=Y(u,t)}else m={type:g.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,o]of i)if(p==="$when"){if(n!==null)throw new R("Multiple '$when' directives on the same object are not allowed");if(o==null)throw new R("Missing condition expression after '$when'");let c=typeof o=="string"?o:JSON.stringify(o);if(c.trim()==="")throw new R("Empty condition expression after '$when'");n=Y(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new R("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;a<i.length;){let[p,o]=i[a];if(p==="$when"){a++;continue}if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=vl(i,a,t);r.push({key:p,value:c.node}),s=!0,a=c.nextIndex}else if(p.startsWith("$for ")){let c=Ds(p,o,t);r.push({key:p,value:c}),s=!0,a++}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new R(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new R("Missing condition expression after '$if'");{let c=he(o,t);(c.type===g.FUNCTION||c.type===g.CONDITIONAL||c.type===g.LOOP||c.type===g.PARTIAL||c.type===g.OBJECT&&!c.fast||c.type===g.ARRAY&&!c.fast)&&(s=!0);let u=nr(p,t),h={key:p,value:c};(u.type!==g.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),a++}}}let l={type:g.OBJECT,properties:r,fast:!s};return n&&(l.whenCondition=n),l},vl=(e,t,r={})=>{let s=[],n=[],i=t,[a,l]=e[i],p=null,o;if(a.startsWith("$if#")){let u=a.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],o=u[2];else throw new R(`Invalid conditional syntax: ${a}`)}else o=a.substring(4),o.endsWith(":")&&(o=o.slice(0,-1).trim());ir(o);let c=Y(o,r);for(s.push(c),n.push(he(l,r)),i++;i<e.length;){let[u,h]=e[i],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{ir(d);let y=Y(d,r);s.push(y)}if(n.push(he(h,r)),i++,d===null)break}else break}return{node:{type:g.CONDITIONAL,conditions:s,bodies:n,id:p},nextIndex:i}},Y=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let o=e.slice(1,-1),c=0,u=!0;for(let h=0;h<o.length;h++)if(o[h]==="("?c++:o[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return Y(o,t)}let r=ge(e,"||");if(r!==-1)return{type:g.BINARY,op:M.OR,left:Y(e.substring(0,r).trim(),t),right:Y(e.substring(r+2).trim(),t)};let s=ge(e,"&&");if(s!==-1)return{type:g.BINARY,op:M.AND,left:Y(e.substring(0,s).trim(),t),right:Y(e.substring(s+2).trim(),t)};let n=[{op:">=",type:M.GTE},{op:"<=",type:M.LTE},{op:"==",type:M.EQ},{op:"!=",type:M.NEQ},{op:">",type:M.GT},{op:"<",type:M.LT},{op:" in ",type:M.IN}];for(let{op:o,type:c}of n){let u=ge(e,o);if(u!==-1)return{type:g.BINARY,op:c,left:Y(e.substring(0,u).trim(),t),right:Y(e.substring(u+o.length).trim(),t)}}let i=-1,a=null,l=[{op:" + ",type:M.ADD},{op:" - ",type:M.SUBTRACT}];for(let{op:o,type:c}of l){let u=0;for(;u<e.length;){let h=ge(e.substring(u),o);if(h===-1)break;let f=u+h;f>i&&(i=f,a={op:o,type:c}),u=f+o.length}}if(i!==-1&&a)return{type:g.BINARY,op:a.type,left:Y(e.substring(0,i).trim(),t),right:Y(e.substring(i+a.op.length).trim(),t)};let p=[" * "," / "," % "];for(let o of p)if(ge(e,o)!==-1)throw new R(`Arithmetic operations are not allowed in conditionals: "${o}"`);return e.startsWith("!")?{type:g.UNARY,op:Pe.NOT,operand:Y(e.substring(1).trim(),t)}:Vs(e,t)},ge=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},bl=e=>{if(e=e.trim(),e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:g.LITERAL,value:""};if(e==="{}")return{type:g.LITERAL,value:{}};if(e==="[]")return{type:g.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:g.LITERAL,value:t}:{type:g.VARIABLE,path:e}},Vs=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return De(r,t);let n=bl(r);if(n.type===g.LITERAL)return n;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:g.VARIABLE,path:r};try{return De(r,t)}catch(i){if(i.message&&i.message.includes("not supported"))return n;throw i}},Ds=(e,t,r)=>{let s=e.substring(5).trim();ks(s);let n=s.match(/^(.+?)\s+in\s+(.+)$/);if(!n)throw new R(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let i=n[1].trim(),a=n[2].trim(),l,p=null;if(i.includes(",")){let u=i.split(",").map(h=>h.trim());if(u.length!==2)throw new R(`Invalid loop variables: ${i}. Expected format: "item" or "item, index"`);l=u[0],p=u[1]}else l=i;let o=Vs(a,r),c=he(t,r);return{type:g.LOOP,itemVar:l,indexVar:p,iterable:o,body:c}};var wl=(e,t={})=>{let{functions:r={}}=t;return he(e,r)},Xe=wl;var ar={};P(ar,{now:()=>_l});var _l=()=>Date.now();var xl=(e,t,r={})=>{let{functions:s={},partials:n={}}=r,i={...ar,...s},a=Xe(e,{functions:i}),l={};for(let[p,o]of Object.entries(n))l[p]=Xe(o,{functions:i});return Ve(a,t,{functions:i,partials:l})},or=xl;var Qe=e=>Array.isArray(e)?e.reduce((t,r)=>{if(Array.isArray(r))t.push(...Qe(r));else{if(r&&typeof r=="object"){let s=Object.entries(r);if(s.length>0){let[n,i]=s[0];Array.isArray(i)&&(r={[n]:Qe(i)})}}t.push(r)}return t},[]):e;var js=(e,t)=>{if(!t)return e;let r=[],s="",n=!1,i=null;for(let a=0;a<t.length;a++){let l=t[a];if(!n&&l===".")s&&(r.push(s),s="");else if(!n&&l==="[")s&&(r.push(s),s=""),n=!0;else if(n&&l==="]"){if(s){if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))r.push(s.slice(1,-1));else{let p=Number(s);r.push(isNaN(p)?s:p)}s=""}n=!1,i=null}else n&&(l==='"'||l==="'")&&(i?l===i&&(i=null):i=l),s+=l}return s&&r.push(s),r.reduce((a,l)=>a&&a[l],e)},Bs=({h:e,template:t,viewData:r,refs:s,handlers:n})=>{let i=Ve(t,r,{}),a=Qe(i),l=Al({h:e,items:a,refs:s,handlers:n,viewData:r});return e("div",{style:{display:"contents"}},l)},Al=({h:e,items:t,refs:r={},handlers:s={},viewData:n={}})=>{if(!Array.isArray(t))return console.error("Input to createVirtualDom must be an array."),[e("div",{},[])];function i(a,l=""){return a.map((p,o)=>{if(typeof p=="string"||typeof p=="number")return String(p);if(typeof p!="object"||p===null)return console.warn("Skipping invalid item in DOM structure:",p),null;let c=Object.entries(p);if(c.length===0)return null;let[u,h]=c[0];if(!isNaN(Number(u)))return Array.isArray(h)?i(h,`${l}.${u}`):typeof h=="object"&&h!==null&&Object.entries(h).length>0?i([h],`${l}.${u}`):String(h);c.length>1&&console.warn("Item has multiple keys, processing only the first:",u);let f,d,y=u.indexOf(" ");y===-1?(f=u,d=""):(f=u.substring(0,y),d=u.substring(y+1).trim());let b=f.split(/[.#]/)[0],m=b.includes("-"),w={},_={};if(d){let C=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g,A,B=new Set;for(;(A=C.exec(d))!==null;)if(B.add(A[1]),A[1].startsWith(".")){let ae=A[1].substring(1),Ce=A[4];_[ae]=js(n,Ce)}else if(A[1].startsWith("?")){let ae=A[1].substring(1),Ce=A[2]||A[3]||A[4],Be;Ce==="true"?Be=!0:Ce==="false"?Be=!1:Be=js(n,Ce),Be&&(w[ae]="")}else w[A[1]]=A[2]||A[3]||A[4];let K=d,F=[],ne,tt=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g;for(;(ne=tt.exec(d))!==null;)F.push(ne[0]);F.forEach(ae=>{K=K.replace(ae," ")});let rt=/\b(\S+?)(?=\s|$)/g,U;for(;(U=rt.exec(K))!==null;){let ae=U[1];!B.has(ae)&&!ae.startsWith(".")&&!ae.includes("=")&&(w[ae]="")}}let x=f.match(/#([^.#\s]+)/);x&&!Object.prototype.hasOwnProperty.call(w,"id")&&(w.id=x[1]);let E=null;w.id?E=w.id:m&&(E=b);let $=Object.create(null),I=null;if(m)I=b;else{let C=f.match(/\.([^.#]+)/g);C&&C.forEach(B=>{let K=B.substring(1);$[K]=!0});let A=f.match(/#([^.#\s]+)/);A&&(I=A[1])}let S;typeof h=="string"||typeof h=="number"?S=String(h):Array.isArray(h)?S=i(h,`${l}.${u}`):S=[],I&&!m&&(w.id=I);let N=Object.create(null);if(E&&r){let C=[];if(Object.keys(r).forEach(A=>{if(A.includes("*")){let B="^"+A.replace(/[.*+?^${}()|[\\\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$";try{new RegExp(B).test(E)&&C.push(A)}catch(K){console.warn(`[Parser] Invalid regex pattern created from refKey '${A}': ${B}`,K)}}else E===A&&C.push(A)}),C.length>0){C.sort((B,K)=>{let F=!B.includes("*"),ne=!K.includes("*");return F&&!ne?-1:!F&&ne?1:K.length-B.length});let A=C[0];if(r[A]&&r[A].eventListeners){let B=r[A].eventListeners;Object.entries(B).forEach(([K,F])=>{if(F.handler&&F.action)throw new Error("Each listener can have hanlder or action but not both");if(F.action){N[K]=ne=>{s.handleCallStoreAction({...F.payload,_event:ne,_action:F.action})};return}F.handler&&s[F.handler]?N[K]=ne=>{s[F.handler]({...F.payload,_event:ne})}:F.handler&&console.warn(`[Parser] Handler '${F.handler}' for refKey '${A}' (matching elementId '${E}') is referenced but not found in available handlers.`)})}}}let D={};if(E)D.key=E;else if(f){let C=l?`${l}.${o}`:String(o);if(D.key=`${f}-${C}`,Object.keys(_).length>0){let A=JSON.stringify(_).substring(0,50);D.key+=`-${A}`}}Object.keys(w).length>0&&(D.attrs=w),Object.keys($).length>0&&(D.class=$),Object.keys(N).length>0&&(D.on=N),Object.keys(_).length>0&&(D.props=_),m&&(D.hook={update:(C,A)=>{let B=C.data?.props||{},K=A.data?.props||{},F=C.data?.attrs||{},ne=A.data?.attrs||{},tt=JSON.stringify(B)!==JSON.stringify(K),rt=JSON.stringify(F)!==JSON.stringify(ne);if(tt||rt){let U=A.elm;U&&U.render&&typeof U.render=="function"&&(U.setAttribute("isDirty","true"),requestAnimationFrame(()=>{if(U.render(),U.removeAttribute("isDirty"),U.handlers&&U.handlers.handleOnUpdate){let ae={...U.deps,store:U.store,render:U.render.bind(U),handlers:U.handlers,dispatchEvent:U.dispatchEvent.bind(U),refIds:U.refIds||{},getRefIds:()=>U.refIds||{}};U.handlers.handleOnUpdate(ae,{oldProps:B,newProps:K,oldAttrs:F,newAttrs:ne})}}))}}});try{return e(b,D,S)}catch(C){return console.error("Error creating virtual node:",C,{tagName:b,snabbdomData:D,childrenOrText:S}),e("div",{},["Error creating element"])}}).filter(Boolean)}return i(t)};var El=(e,t)=>{if(!t||typeof t!="object")return"";let r="",s=i=>Object.entries(i).map(([a,l])=>` ${a}: ${l};`).join(`
975
975
  `),n=(i,a)=>{if(typeof a!="object"||a===null)return"";if(i.startsWith("@")){let l=Object.entries(a).map(([p,o])=>{let c=s(o);return` ${p} {
976
976
  ${c.split(`
977
977
  `).map(u=>u?` ${u}`:"").join(`
@@ -983,7 +983,7 @@ ${l}
983
983
  ${l}
984
984
  }`}};return Object.entries(t).forEach(([i,a])=>{let l=n(i,a);l&&(r+=(r?`
985
985
 
986
- `:"")+l)}),r},Al=e=>{let t=e.map(r=>r.subscribe());return()=>{for(let r of t)r&&typeof r.unsubscribe=="function"&&r.unsubscribe()}};function El(e){return new Proxy({},{get(t,r){if(typeof r=="string"){let s=e.getAttribute(r);return s===""?!0:s}},set(){throw new Error("Cannot assign to read-only proxy")},defineProperty(){throw new Error("Cannot define properties on read-only proxy")},deleteProperty(){throw new Error("Cannot delete properties from read-only proxy")},has(t,r){return typeof r=="string"&&e.hasAttribute(r)},ownKeys(){return e.getAttributeNames()},getOwnPropertyDescriptor(t,r){if(typeof r=="string"&&e.hasAttribute(r))return{configurable:!0,enumerable:!0,get:()=>e.getAttribute(r)}}})}function kl(e,t){let r=new Set(t);return new Proxy({},{get(s,n){if(typeof n=="string"&&r.has(n))return e[n]},set(){throw new Error("Cannot assign to read-only proxy")},defineProperty(){throw new Error("Cannot define properties on read-only proxy")},deleteProperty(){throw new Error("Cannot delete properties from read-only proxy")},has(s,n){return typeof n=="string"&&r.has(n)},ownKeys(){return[...r]},getOwnPropertyDescriptor(s,n){if(typeof n=="string"&&r.has(n))return{configurable:!0,enumerable:!0,get:()=>e[n]}}})}var lr=class extends HTMLElement{elementName;styles;h;store;props;propsSchema;template;handlers;transformedHandlers={};refs;refIds={};patch;_unmountCallback;_oldVNode;deps;cssText;static get observedAttributes(){return["key"]}get viewData(){let t={};return this.store.selectViewData&&(t=this.store.selectViewData()),t}connectedCallback(){this.shadow=this.attachShadow({mode:"open"});let t=new CSSStyleSheet;t.replaceSync(`
986
+ `:"")+l)}),r},kl=e=>{let t=e.map(r=>r.subscribe());return()=>{for(let r of t)r&&typeof r.unsubscribe=="function"&&r.unsubscribe()}};function $l(e){return new Proxy({},{get(t,r){if(typeof r=="string"){let s=e.getAttribute(r);return s===""?!0:s}},set(){throw new Error("Cannot assign to read-only proxy")},defineProperty(){throw new Error("Cannot define properties on read-only proxy")},deleteProperty(){throw new Error("Cannot delete properties from read-only proxy")},has(t,r){return typeof r=="string"&&e.hasAttribute(r)},ownKeys(){return e.getAttributeNames()},getOwnPropertyDescriptor(t,r){if(typeof r=="string"&&e.hasAttribute(r))return{configurable:!0,enumerable:!0,get:()=>e.getAttribute(r)}}})}function Sl(e,t){let r=new Set(t);return new Proxy({},{get(s,n){if(typeof n=="string"&&r.has(n))return e[n]},set(){throw new Error("Cannot assign to read-only proxy")},defineProperty(){throw new Error("Cannot define properties on read-only proxy")},deleteProperty(){throw new Error("Cannot delete properties from read-only proxy")},has(s,n){return typeof n=="string"&&r.has(n)},ownKeys(){return[...r]},getOwnPropertyDescriptor(s,n){if(typeof n=="string"&&r.has(n))return{configurable:!0,enumerable:!0,get:()=>e[n]}}})}var lr=class extends HTMLElement{elementName;styles;h;store;props;propsSchema;template;handlers;transformedHandlers={};refs;refIds={};patch;_unmountCallback;_oldVNode;deps;cssText;static get observedAttributes(){return["key"]}get viewData(){let t={};return this.store.selectViewData&&(t=this.store.selectViewData()),t}connectedCallback(){this.shadow=this.attachShadow({mode:"open"});let t=new CSSStyleSheet;t.replaceSync(`
987
987
  a, a:link, a:visited, a:hover, a:active {
988
988
  display: contents;
989
989
  color: inherit;
@@ -995,4 +995,4 @@ ${l}
995
995
  font: inherit;
996
996
  cursor: pointer;
997
997
  }
998
- `);let r=[t];if(this.cssText){let n=new CSSStyleSheet;n.replaceSync(this.cssText),r.push(n)}this.shadow.adoptedStyleSheets=r,this.renderTarget=document.createElement("div"),this.renderTarget.style.cssText="display: contents;",this.shadow.appendChild(this.renderTarget),this.renderTarget.parentNode||this.appendChild(this.renderTarget),this.style.display="contents";let s={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this)};if(this.transformedHandlers={handleCallStoreAction:n=>{let{render:i,store:a}=s,{_event:l,_action:p}=n,o=or(n,{event:l});if(console.log("context",o),!a[p])throw new Error(`store action store.${a._action} is not defined`);a[p](o),i()}},Object.keys(this.handlers||{}).forEach(n=>{this.transformedHandlers[n]=(i,a)=>this.handlers[n](s,i,a)}),this.handlers?.handleBeforeMount&&(this._unmountCallback=this.handlers?.handleBeforeMount(s),this._unmountCallback&&typeof this._unmountCallback.then=="function"))throw new Error("handleBeforeMount must be synchronous and cannot return a Promise.");this.render(),this.handlers?.handleAfterMount&&this.handlers?.handleAfterMount(s),this.handlers?.subscriptions&&(this.unsubscribeAll=Al(this.handlers.subscriptions(s)))}disconnectedCallback(){this._unmountCallback&&this._unmountCallback(),this.unsubscribeAll&&this.unsubscribeAll()}attributeChangedCallback(t,r,s){if(r!==s&&this.render)if(this.handlers?.handleOnUpdate){let n={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this),store:this.store,render:this.render.bind(this)},i={oldAttrs:{[t]:r},newAttrs:{[t]:s},oldProps:n.props,newProps:n.props};this.handlers.handleOnUpdate(n,i)}else requestAnimationFrame(()=>{this.render()})}render=()=>{if(!this.patch){console.error("Patch function is not defined!");return}if(!this.template){console.error("Template is not defined!");return}try{let t={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this),store:this.store,render:this.render.bind(this)},r=Bs({h:this.h,template:this.template,viewData:this.viewData,refs:this.refs,handlers:this.transformedHandlers}),s={},n=i=>{i.data?.attrs&&i.data.attrs.id&&(s[i.data.attrs.id]=i),i.children&&i.children.forEach(n)};n(r),this.refIds=s,this._oldVNode?this._oldVNode=this.patch(this._oldVNode,r):this._oldVNode=this.patch(this.renderTarget,r)}catch(t){console.error("Error during patching:",t)}}},$l=(e,t,r)=>{let{createInitialState:s,...n}=e,i={},a={},l={};return s&&(l=s()),Object.entries(n).forEach(([p,o])=>{p.startsWith("select")?i[p]=(...c)=>o({state:l,props:t,attrs:r},...c):a[p]=c=>(l=Es(l,u=>o(u,c)),l)}),{getState:()=>l,...a,...i}},Sl=({handlers:e,view:t,store:r,patch:s,h:n},i)=>{let{elementName:a,propsSchema:l,attrsSchema:p,template:o,refs:c,styles:u}=t;if(!s)throw new Error("Patch is not defined");if(!n)throw new Error("h is not defined");if(!t)throw new Error("view is not defined");class h extends lr{static get observedAttributes(){let d=["key"],y=p?.properties?Object.keys(p.properties):[];return[...d,...y]}constructor(){super();let d=El(this);this.propsSchema=l,this.props=l?kl(this,Object.keys(l.properties)):{},this.elementName=a,this.styles=u,this.store=$l(r,this.props,d),this.template=o,this.handlers=e,this.refs=c,this.patch=s,this.deps={...i,store:this.store,render:this.render,handlers:e,attrs:d,props:this.props},this.h=n,this.cssText=xl(a,u)}}return h},pr=Sl;function ve(e,t,r,s,n){let i=t===void 0?void 0:t.key;return{sel:e,data:t,children:r,text:s,elm:n,key:i}}var $e=Array.isArray;function Se(e){return typeof e=="string"||typeof e=="number"||e instanceof String||e instanceof Number}function Cl(e,t){return document.createElement(e,t)}function Il(e,t,r){return document.createElementNS(e,t,r)}function Ol(){return be(document.createDocumentFragment())}function Tl(e){return document.createTextNode(e)}function Ll(e){return document.createComment(e)}function Rl(e,t,r){if(pe(e)){let s=e;for(;s&&pe(s);)s=be(s).parent;e=s??e}pe(t)&&(t=be(t,e)),r&&pe(r)&&(r=be(r).firstChildNode),e.insertBefore(t,r)}function Nl(e,t){e.removeChild(t)}function Pl(e,t){pe(t)&&(t=be(t,e)),e.appendChild(t)}function Ms(e){if(pe(e)){for(;e&&pe(e);)e=be(e).parent;return e??null}return e.parentNode}function Vl(e){var t;if(pe(e)){let r=be(e),s=Ms(r);if(s&&r.lastChildNode){let n=Array.from(s.childNodes),i=n.indexOf(r.lastChildNode);return(t=n[i+1])!==null&&t!==void 0?t:null}return null}return e.nextSibling}function Dl(e){return e.tagName}function jl(e,t){e.textContent=t}function Bl(e){return e.textContent}function Wl(e){return e.nodeType===1}function Ml(e){return e.nodeType===3}function Fl(e){return e.nodeType===8}function pe(e){return e.nodeType===11}function be(e,t){var r,s,n;let i=e;return(r=i.parent)!==null&&r!==void 0||(i.parent=t??null),(s=i.firstChildNode)!==null&&s!==void 0||(i.firstChildNode=e.firstChild),(n=i.lastChildNode)!==null&&n!==void 0||(i.lastChildNode=e.lastChild),i}var Fs={createElement:Cl,createElementNS:Il,createTextNode:Tl,createDocumentFragment:Ol,createComment:Ll,insertBefore:Rl,removeChild:Nl,appendChild:Pl,parentNode:Ms,nextSibling:Vl,tagName:Dl,setTextContent:jl,getTextContent:Bl,isElement:Wl,isText:Ml,isComment:Fl,isDocumentFragment:pe};function Ze(e){return e===void 0}function re(e){return e!==void 0}var cr=ve("",{},[],void 0,void 0);function je(e,t){var r,s;let n=e.key===t.key,i=((r=e.data)===null||r===void 0?void 0:r.is)===((s=t.data)===null||s===void 0?void 0:s.is),a=e.sel===t.sel,l=!e.sel&&e.sel===t.sel?typeof e.text==typeof t.text:!0;return a&&n&&i&&l}function Ul(){throw new Error("The document fragment is not supported on this platform.")}function Kl(e,t){return e.isElement(t)}function zl(e,t){return e.isDocumentFragment(t)}function Hl(e,t,r){var s;let n={};for(let i=t;i<=r;++i){let a=(s=e[i])===null||s===void 0?void 0:s.key;a!==void 0&&(n[a]=i)}return n}var Jl=["create","update","remove","destroy","pre","post"];function Us(e,t,r){let s={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},n=t!==void 0?t:Fs;for(let d of Jl)for(let y of e){let b=y[d];b!==void 0&&s[d].push(b)}function i(d){let y=d.id?"#"+d.id:"",b=d.getAttribute("class"),m=b?"."+b.split(" ").join("."):"";return ve(n.tagName(d).toLowerCase()+y+m,{},[],void 0,d)}function a(d){return ve(void 0,{},[],void 0,d)}function l(d,y){return function(){if(--y===0){let m=n.parentNode(d);m!==null&&n.removeChild(m,d)}}}function p(d,y){var b,m,w,_;let x,E=d.data;if(E!==void 0){let S=(b=E.hook)===null||b===void 0?void 0:b.init;re(S)&&(S(d),E=d.data)}let $=d.children,I=d.sel;if(I==="!")Ze(d.text)&&(d.text=""),d.elm=n.createComment(d.text);else if(I==="")d.elm=n.createTextNode(d.text);else if(I!==void 0){let S=I.indexOf("#"),N=I.indexOf(".",S),D=S>0?S:I.length,C=N>0?N:I.length,A=S!==-1||N!==-1?I.slice(0,Math.min(D,C)):I,B=d.elm=re(E)&&re(x=E.ns)?n.createElementNS(x,A,E):n.createElement(A,E);for(D<C&&B.setAttribute("id",I.slice(D+1,C)),N>0&&B.setAttribute("class",I.slice(C+1).replace(/\./g," ")),x=0;x<s.create.length;++x)s.create[x](cr,d);if(Se(d.text)&&(!$e($)||$.length===0)&&n.appendChild(B,n.createTextNode(d.text)),$e($))for(x=0;x<$.length;++x){let F=$[x];F!=null&&n.appendChild(B,p(F,y))}let U=d.data.hook;re(U)&&((m=U.create)===null||m===void 0||m.call(U,cr,d),U.insert&&y.push(d))}else if(!((w=r?.experimental)===null||w===void 0)&&w.fragments&&d.children){for(d.elm=((_=n.createDocumentFragment)!==null&&_!==void 0?_:Ul)(),x=0;x<s.create.length;++x)s.create[x](cr,d);for(x=0;x<d.children.length;++x){let S=d.children[x];S!=null&&n.appendChild(d.elm,p(S,y))}}else d.elm=n.createTextNode(d.text);return d.elm}function o(d,y,b,m,w,_){for(;m<=w;++m){let x=b[m];x!=null&&n.insertBefore(d,p(x,_),y)}}function c(d){var y,b;let m=d.data;if(m!==void 0){(b=(y=m?.hook)===null||y===void 0?void 0:y.destroy)===null||b===void 0||b.call(y,d);for(let w=0;w<s.destroy.length;++w)s.destroy[w](d);if(d.children!==void 0)for(let w=0;w<d.children.length;++w){let _=d.children[w];_!=null&&typeof _!="string"&&c(_)}}}function u(d,y,b,m){for(var w,_;b<=m;++b){let x,E,$=y[b];if($!=null)if(re($.sel)){c($),x=s.remove.length+1,E=l($.elm,x);for(let S=0;S<s.remove.length;++S)s.remove[S]($,E);let I=(_=(w=$?.data)===null||w===void 0?void 0:w.hook)===null||_===void 0?void 0:_.remove;re(I)?I($,E):E()}else $.children?(c($),u(d,$.children,0,$.children.length-1)):n.removeChild(d,$.elm)}}function h(d,y,b,m){let w=0,_=0,x=y.length-1,E=y[0],$=y[x],I=b.length-1,S=b[0],N=b[I],D,C,A,B;for(;w<=x&&_<=I;)E==null?E=y[++w]:$==null?$=y[--x]:S==null?S=b[++_]:N==null?N=b[--I]:je(E,S)?(f(E,S,m),E=y[++w],S=b[++_]):je($,N)?(f($,N,m),$=y[--x],N=b[--I]):je(E,N)?(f(E,N,m),n.insertBefore(d,E.elm,n.nextSibling($.elm)),E=y[++w],N=b[--I]):je($,S)?(f($,S,m),n.insertBefore(d,$.elm,E.elm),$=y[--x],S=b[++_]):(D===void 0&&(D=Hl(y,w,x)),C=D[S.key],Ze(C)?(n.insertBefore(d,p(S,m),E.elm),S=b[++_]):Ze(D[N.key])?(n.insertBefore(d,p(N,m),n.nextSibling($.elm)),N=b[--I]):(A=y[C],A.sel!==S.sel?n.insertBefore(d,p(S,m),E.elm):(f(A,S,m),y[C]=void 0,n.insertBefore(d,A.elm,E.elm)),S=b[++_]));_<=I&&(B=b[I+1]==null?null:b[I+1].elm,o(d,B,b,_,I,m)),w<=x&&u(d,y,w,x)}function f(d,y,b){var m,w,_,x,E,$,I,S;let N=(m=y.data)===null||m===void 0?void 0:m.hook;(w=N?.prepatch)===null||w===void 0||w.call(N,d,y);let D=y.elm=d.elm;if(d===y)return;if(y.data!==void 0||re(y.text)&&y.text!==d.text){(_=y.data)!==null&&_!==void 0||(y.data={}),(x=d.data)!==null&&x!==void 0||(d.data={});for(let B=0;B<s.update.length;++B)s.update[B](d,y);(I=($=(E=y.data)===null||E===void 0?void 0:E.hook)===null||$===void 0?void 0:$.update)===null||I===void 0||I.call($,d,y)}let C=d.children,A=y.children;Ze(y.text)?re(C)&&re(A)?C!==A&&h(D,C,A,b):re(A)?(re(d.text)&&n.setTextContent(D,""),o(D,null,A,0,A.length-1,b)):re(C)?u(D,C,0,C.length-1):re(d.text)&&n.setTextContent(D,""):d.text!==y.text&&(re(C)&&u(D,C,0,C.length-1),n.setTextContent(D,y.text)),(S=N?.postpatch)===null||S===void 0||S.call(N,d,y)}return function(y,b){let m,w,_,x=[];for(m=0;m<s.pre.length;++m)s.pre[m]();for(Kl(n,y)?y=i(y):zl(n,y)&&(y=a(y)),je(y,b)?f(y,b,x):(w=y.elm,_=n.parentNode(w),p(b,x),_!==null&&(n.insertBefore(_,b.elm,n.nextSibling(w)),u(_,[y],0,0))),m=0;m<x.length;++m)x[m].data.hook.insert(x[m]);for(m=0;m<s.post.length;++m)s.post[m]();return b}}function Ks(e,t){let r,s,n=t.elm,i=e.data.class,a=t.data.class;if(!(!i&&!a)&&i!==a){i=i||{},a=a||{};for(s in i)i[s]&&!Object.prototype.hasOwnProperty.call(a,s)&&n.classList.remove(s);for(s in a)r=a[s],r!==i[s]&&n.classList[r?"add":"remove"](s)}}var zs={create:Ks,update:Ks};function Hs(e,t){let r,s,n,i=t.elm,a=e.data.props,l=t.data.props;if(!(!a&&!l)&&a!==l){a=a||{},l=l||{};for(r in l)s=l[r],n=a[r],n!==s&&(r!=="value"||i[r]!==s)&&(i[r]=s)}}var Js={create:Hs,update:Hs};var ql="http://www.w3.org/1999/xlink",Yl="http://www.w3.org/2000/xmlns/",Gl="http://www.w3.org/XML/1998/namespace";function qs(e,t){let r,s=t.elm,n=e.data.attrs,i=t.data.attrs;if(!(!n&&!i)&&n!==i){n=n||{},i=i||{};for(r in i){let a=i[r];n[r]!==a&&(a===!0?s.setAttribute(r,""):a===!1?s.removeAttribute(r):r.charCodeAt(0)!==120?s.setAttribute(r,a):r.charCodeAt(3)===58?s.setAttributeNS(Gl,r,a):r.charCodeAt(5)===58?r.charCodeAt(1)===109?s.setAttributeNS(Yl,r,a):s.setAttributeNS(ql,r,a):s.setAttribute(r,a))}for(r in n)r in i||s.removeAttribute(r)}}var Ys={create:qs,update:qs};var Gs=typeof window?.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):setTimeout,Xl=function(e){Gs(function(){Gs(e)})},ur=!1;function Ql(e,t,r){Xl(function(){e[t]=r})}function Xs(e,t){let r,s,n=t.elm,i=e.data.style,a=t.data.style;if(!i&&!a||i===a)return;i=i||{},a=a||{};let l="delayed"in i;for(s in i)s in a||(s[0]==="-"&&s[1]==="-"?n.style.removeProperty(s):n.style[s]="");for(s in a)if(r=a[s],s==="delayed"&&a.delayed)for(let p in a.delayed)r=a.delayed[p],(!l||r!==i.delayed[p])&&Ql(n.style,p,r);else s!=="remove"&&r!==i[s]&&(s[0]==="-"&&s[1]==="-"?n.style.setProperty(s,r):n.style[s]=r)}function Zl(e){let t,r,s=e.elm,n=e.data.style;if(!(!n||!(t=n.destroy)))for(r in t)s.style[r]=t[r]}function ep(e,t){let r=e.data.style;if(!r||!r.remove){t();return}ur||(e.elm.offsetLeft,ur=!0);let s,n=e.elm,i=0,a=r.remove,l=0,p=[];for(s in a)p.push(s),n.style[s]=a[s];let c=getComputedStyle(n)["transition-property"].split(", ");for(;i<c.length;++i)p.indexOf(c[i])!==-1&&l++;n.addEventListener("transitionend",function(u){u.target===n&&--l,l===0&&t()})}function tp(){ur=!1}var Qs={pre:tp,create:Xs,update:Xs,destroy:Zl,remove:ep};function Zs(e,t,r){if(typeof e=="function")e.call(t,r,t);else if(typeof e=="object")for(let s=0;s<e.length;s++)Zs(e[s],t,r)}function rp(e,t){let r=e.type,s=t.data.on;s&&s[r]&&Zs(s[r],t,e)}function sp(){return function e(t){rp(t,e.vnode)}}function hr(e,t){let r=e.data.on,s=e.listener,n=e.elm,i=t&&t.data.on,a=t&&t.elm,l;if(r!==i){if(r&&s)if(i)for(l in r)i[l]||n.removeEventListener(l,s,!1);else for(l in r)n.removeEventListener(l,s,!1);if(i){let p=t.listener=e.listener||sp();if(p.vnode=t,r)for(l in i)r[l]||a.addEventListener(l,p,!1);else for(l in i)a.addEventListener(l,p,!1)}}}var ei={create:hr,update:hr,destroy:hr};var ip=()=>Us([zs,Js,Ys,Qs,ei]),dr=ip;var np=e=>{let t={};return{once:(r,s)=>{t[r]||(t[r]=[]);let n=(...i)=>{s(...i),t[r]=t[r].filter(a=>a!==n)};t[r].push(n)},emit:(r,...s)=>{t[r]&&t[r].forEach(n=>{n(...s)})},showAlert:async r=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");e.transformedHandlers.showAlert(r)},showConfirm:async r=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");return e.transformedHandlers.showConfirm(r)},showDropdownMenu:async r=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");return e.transformedHandlers.showDropdownMenu(r)},closeAll:async()=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");return e.transformedHandlers.closeAll()}}},ti=np;function ri(e,t,r){if(e.ns="http://www.w3.org/2000/svg",r!=="foreignObject"&&t!==void 0)for(let s=0;s<t.length;++s){let n=t[s];if(typeof n=="string")continue;let i=n.data;i!==void 0&&ri(i,n.children,n.sel)}}function fr(e,t,r){let s={},n,i,a;if(r!==void 0?(t!==null&&(s=t),$e(r)?n=r:Se(r)?i=r.toString():r&&r.sel&&(n=[r])):t!=null&&($e(t)?n=t:Se(t)?i=t.toString():t&&t.sel?n=[t]:s=t),n!==void 0)for(a=0;a<n.length;++a)Se(n[a])&&(n[a]=ve(void 0,void 0,void 0,n[a],void 0));return e.startsWith("svg")&&(e.length===3||e[3]==="."||e[3]==="#")&&ri(s,n,e),ve(e,s,n,i,void 0)}var ap=ti(),op={globalUI:ap},si={components:op},ii=dr();var et={components:{breadcrumb:{handlers:yt,store:mt,view:Nr},dropdownMenu:{handlers:gt,store:vt,view:Pr},form:{handlers:bt,store:kt,view:Qr},globalUi:{handlers:$t,store:St,view:Zr},navbar:{handlers:Ct,store:It,view:es},pageOutline:{handlers:Ot,store:Tt,view:rs},popoverInput:{handlers:Lt,store:Rt,view:ss},select:{handlers:Nt,store:Pt,view:is},sidebar:{handlers:Vt,store:jt,view:ns},sliderInput:{handlers:Bt,store:Wt,view:as},table:{handlers:Mt,store:Ft,view:os},tabs:{handlers:Ut,store:Kt,view:ls},tooltip:{handlers:ps,store:zt,view:cs},waveform:{handlers:Ht,store:Jt,view:hs}}};Object.keys(et).forEach(e=>{Object.keys(et[e]).forEach(t=>{let r=pr({...et[e][t],patch:ii,h:fr},si[e]);customElements.define(et[e][t].view.elementName,r)})});customElements.define("rtgl-button",vr({}));customElements.define("rtgl-view",_r({}));customElements.define("rtgl-text",Ar({}));customElements.define("rtgl-image",Er({}));customElements.define("rtgl-svg",$r({}));customElements.define("rtgl-input",Sr({}));customElements.define("rtgl-input-number",Cr({}));customElements.define("rtgl-textarea",Ir({}));customElements.define("rtgl-color-picker",Or({}));customElements.define("rtgl-slider",Tr({}));customElements.define("rtgl-dialog",Lr({}));customElements.define("rtgl-popover",Rr({}));})();
998
+ `);let r=[t];if(this.cssText){let n=new CSSStyleSheet;n.replaceSync(this.cssText),r.push(n)}this.shadow.adoptedStyleSheets=r,this.renderTarget=document.createElement("div"),this.renderTarget.style.cssText="display: contents;",this.shadow.appendChild(this.renderTarget),this.renderTarget.parentNode||this.appendChild(this.renderTarget),this.style.display="contents";let s={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this)};if(this.transformedHandlers={handleCallStoreAction:n=>{let{render:i,store:a}=s,{_event:l,_action:p}=n,o=or(n,{event:l});if(console.log("context",o),!a[p])throw new Error(`store action store.${a._action} is not defined`);a[p](o),i()}},Object.keys(this.handlers||{}).forEach(n=>{this.transformedHandlers[n]=(i,a)=>this.handlers[n](s,i,a)}),this.handlers?.handleBeforeMount&&(this._unmountCallback=this.handlers?.handleBeforeMount(s),this._unmountCallback&&typeof this._unmountCallback.then=="function"))throw new Error("handleBeforeMount must be synchronous and cannot return a Promise.");this.render(),this.handlers?.handleAfterMount&&this.handlers?.handleAfterMount(s),this.handlers?.subscriptions&&(this.unsubscribeAll=kl(this.handlers.subscriptions(s)))}disconnectedCallback(){this._unmountCallback&&this._unmountCallback(),this.unsubscribeAll&&this.unsubscribeAll()}attributeChangedCallback(t,r,s){if(r!==s&&this.render)if(this.handlers?.handleOnUpdate){let n={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this),store:this.store,render:this.render.bind(this)},i={oldAttrs:{[t]:r},newAttrs:{[t]:s},oldProps:n.props,newProps:n.props};this.handlers.handleOnUpdate(n,i)}else requestAnimationFrame(()=>{this.render()})}render=()=>{if(!this.patch){console.error("Patch function is not defined!");return}if(!this.template){console.error("Template is not defined!");return}try{let t={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this),store:this.store,render:this.render.bind(this)},r=Bs({h:this.h,template:this.template,viewData:this.viewData,refs:this.refs,handlers:this.transformedHandlers}),s={},n=i=>{i.data?.attrs&&i.data.attrs.id&&(s[i.data.attrs.id]=i),i.children&&i.children.forEach(n)};n(r),this.refIds=s,this._oldVNode?this._oldVNode=this.patch(this._oldVNode,r):this._oldVNode=this.patch(this.renderTarget,r)}catch(t){console.error("Error during patching:",t)}}},Cl=(e,t,r)=>{let{createInitialState:s,...n}=e,i={},a={},l={};return s&&(l=s()),Object.entries(n).forEach(([p,o])=>{p.startsWith("select")?i[p]=(...c)=>o({state:l,props:t,attrs:r},...c):a[p]=c=>(l=Es(l,u=>o(u,c)),l)}),{getState:()=>l,...a,...i}},Il=({handlers:e,view:t,store:r,patch:s,h:n},i)=>{let{elementName:a,propsSchema:l,attrsSchema:p,template:o,refs:c,styles:u}=t;if(!s)throw new Error("Patch is not defined");if(!n)throw new Error("h is not defined");if(!t)throw new Error("view is not defined");class h extends lr{static get observedAttributes(){let d=["key"],y=p?.properties?Object.keys(p.properties):[];return[...d,...y]}constructor(){super();let d=$l(this);this.propsSchema=l,this.props=l?Sl(this,Object.keys(l.properties)):{},this.elementName=a,this.styles=u,this.store=Cl(r,this.props,d),this.template=o,this.handlers=e,this.refs=c,this.patch=s,this.deps={...i,store:this.store,render:this.render,handlers:e,attrs:d,props:this.props},this.h=n,this.cssText=El(a,u)}}return h},pr=Il;function ve(e,t,r,s,n){let i=t===void 0?void 0:t.key;return{sel:e,data:t,children:r,text:s,elm:n,key:i}}var $e=Array.isArray;function Se(e){return typeof e=="string"||typeof e=="number"||e instanceof String||e instanceof Number}function Ol(e,t){return document.createElement(e,t)}function Tl(e,t,r){return document.createElementNS(e,t,r)}function Ll(){return be(document.createDocumentFragment())}function Rl(e){return document.createTextNode(e)}function Nl(e){return document.createComment(e)}function Pl(e,t,r){if(pe(e)){let s=e;for(;s&&pe(s);)s=be(s).parent;e=s??e}pe(t)&&(t=be(t,e)),r&&pe(r)&&(r=be(r).firstChildNode),e.insertBefore(t,r)}function Vl(e,t){e.removeChild(t)}function Dl(e,t){pe(t)&&(t=be(t,e)),e.appendChild(t)}function Ms(e){if(pe(e)){for(;e&&pe(e);)e=be(e).parent;return e??null}return e.parentNode}function jl(e){var t;if(pe(e)){let r=be(e),s=Ms(r);if(s&&r.lastChildNode){let n=Array.from(s.childNodes),i=n.indexOf(r.lastChildNode);return(t=n[i+1])!==null&&t!==void 0?t:null}return null}return e.nextSibling}function Bl(e){return e.tagName}function Wl(e,t){e.textContent=t}function Ml(e){return e.textContent}function Fl(e){return e.nodeType===1}function Kl(e){return e.nodeType===3}function Ul(e){return e.nodeType===8}function pe(e){return e.nodeType===11}function be(e,t){var r,s,n;let i=e;return(r=i.parent)!==null&&r!==void 0||(i.parent=t??null),(s=i.firstChildNode)!==null&&s!==void 0||(i.firstChildNode=e.firstChild),(n=i.lastChildNode)!==null&&n!==void 0||(i.lastChildNode=e.lastChild),i}var Fs={createElement:Ol,createElementNS:Tl,createTextNode:Rl,createDocumentFragment:Ll,createComment:Nl,insertBefore:Pl,removeChild:Vl,appendChild:Dl,parentNode:Ms,nextSibling:jl,tagName:Bl,setTextContent:Wl,getTextContent:Ml,isElement:Fl,isText:Kl,isComment:Ul,isDocumentFragment:pe};function Ze(e){return e===void 0}function re(e){return e!==void 0}var cr=ve("",{},[],void 0,void 0);function je(e,t){var r,s;let n=e.key===t.key,i=((r=e.data)===null||r===void 0?void 0:r.is)===((s=t.data)===null||s===void 0?void 0:s.is),a=e.sel===t.sel,l=!e.sel&&e.sel===t.sel?typeof e.text==typeof t.text:!0;return a&&n&&i&&l}function zl(){throw new Error("The document fragment is not supported on this platform.")}function Hl(e,t){return e.isElement(t)}function Jl(e,t){return e.isDocumentFragment(t)}function ql(e,t,r){var s;let n={};for(let i=t;i<=r;++i){let a=(s=e[i])===null||s===void 0?void 0:s.key;a!==void 0&&(n[a]=i)}return n}var Gl=["create","update","remove","destroy","pre","post"];function Ks(e,t,r){let s={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},n=t!==void 0?t:Fs;for(let d of Gl)for(let y of e){let b=y[d];b!==void 0&&s[d].push(b)}function i(d){let y=d.id?"#"+d.id:"",b=d.getAttribute("class"),m=b?"."+b.split(" ").join("."):"";return ve(n.tagName(d).toLowerCase()+y+m,{},[],void 0,d)}function a(d){return ve(void 0,{},[],void 0,d)}function l(d,y){return function(){if(--y===0){let m=n.parentNode(d);m!==null&&n.removeChild(m,d)}}}function p(d,y){var b,m,w,_;let x,E=d.data;if(E!==void 0){let S=(b=E.hook)===null||b===void 0?void 0:b.init;re(S)&&(S(d),E=d.data)}let $=d.children,I=d.sel;if(I==="!")Ze(d.text)&&(d.text=""),d.elm=n.createComment(d.text);else if(I==="")d.elm=n.createTextNode(d.text);else if(I!==void 0){let S=I.indexOf("#"),N=I.indexOf(".",S),D=S>0?S:I.length,C=N>0?N:I.length,A=S!==-1||N!==-1?I.slice(0,Math.min(D,C)):I,B=d.elm=re(E)&&re(x=E.ns)?n.createElementNS(x,A,E):n.createElement(A,E);for(D<C&&B.setAttribute("id",I.slice(D+1,C)),N>0&&B.setAttribute("class",I.slice(C+1).replace(/\./g," ")),x=0;x<s.create.length;++x)s.create[x](cr,d);if(Se(d.text)&&(!$e($)||$.length===0)&&n.appendChild(B,n.createTextNode(d.text)),$e($))for(x=0;x<$.length;++x){let F=$[x];F!=null&&n.appendChild(B,p(F,y))}let K=d.data.hook;re(K)&&((m=K.create)===null||m===void 0||m.call(K,cr,d),K.insert&&y.push(d))}else if(!((w=r?.experimental)===null||w===void 0)&&w.fragments&&d.children){for(d.elm=((_=n.createDocumentFragment)!==null&&_!==void 0?_:zl)(),x=0;x<s.create.length;++x)s.create[x](cr,d);for(x=0;x<d.children.length;++x){let S=d.children[x];S!=null&&n.appendChild(d.elm,p(S,y))}}else d.elm=n.createTextNode(d.text);return d.elm}function o(d,y,b,m,w,_){for(;m<=w;++m){let x=b[m];x!=null&&n.insertBefore(d,p(x,_),y)}}function c(d){var y,b;let m=d.data;if(m!==void 0){(b=(y=m?.hook)===null||y===void 0?void 0:y.destroy)===null||b===void 0||b.call(y,d);for(let w=0;w<s.destroy.length;++w)s.destroy[w](d);if(d.children!==void 0)for(let w=0;w<d.children.length;++w){let _=d.children[w];_!=null&&typeof _!="string"&&c(_)}}}function u(d,y,b,m){for(var w,_;b<=m;++b){let x,E,$=y[b];if($!=null)if(re($.sel)){c($),x=s.remove.length+1,E=l($.elm,x);for(let S=0;S<s.remove.length;++S)s.remove[S]($,E);let I=(_=(w=$?.data)===null||w===void 0?void 0:w.hook)===null||_===void 0?void 0:_.remove;re(I)?I($,E):E()}else $.children?(c($),u(d,$.children,0,$.children.length-1)):n.removeChild(d,$.elm)}}function h(d,y,b,m){let w=0,_=0,x=y.length-1,E=y[0],$=y[x],I=b.length-1,S=b[0],N=b[I],D,C,A,B;for(;w<=x&&_<=I;)E==null?E=y[++w]:$==null?$=y[--x]:S==null?S=b[++_]:N==null?N=b[--I]:je(E,S)?(f(E,S,m),E=y[++w],S=b[++_]):je($,N)?(f($,N,m),$=y[--x],N=b[--I]):je(E,N)?(f(E,N,m),n.insertBefore(d,E.elm,n.nextSibling($.elm)),E=y[++w],N=b[--I]):je($,S)?(f($,S,m),n.insertBefore(d,$.elm,E.elm),$=y[--x],S=b[++_]):(D===void 0&&(D=ql(y,w,x)),C=D[S.key],Ze(C)?(n.insertBefore(d,p(S,m),E.elm),S=b[++_]):Ze(D[N.key])?(n.insertBefore(d,p(N,m),n.nextSibling($.elm)),N=b[--I]):(A=y[C],A.sel!==S.sel?n.insertBefore(d,p(S,m),E.elm):(f(A,S,m),y[C]=void 0,n.insertBefore(d,A.elm,E.elm)),S=b[++_]));_<=I&&(B=b[I+1]==null?null:b[I+1].elm,o(d,B,b,_,I,m)),w<=x&&u(d,y,w,x)}function f(d,y,b){var m,w,_,x,E,$,I,S;let N=(m=y.data)===null||m===void 0?void 0:m.hook;(w=N?.prepatch)===null||w===void 0||w.call(N,d,y);let D=y.elm=d.elm;if(d===y)return;if(y.data!==void 0||re(y.text)&&y.text!==d.text){(_=y.data)!==null&&_!==void 0||(y.data={}),(x=d.data)!==null&&x!==void 0||(d.data={});for(let B=0;B<s.update.length;++B)s.update[B](d,y);(I=($=(E=y.data)===null||E===void 0?void 0:E.hook)===null||$===void 0?void 0:$.update)===null||I===void 0||I.call($,d,y)}let C=d.children,A=y.children;Ze(y.text)?re(C)&&re(A)?C!==A&&h(D,C,A,b):re(A)?(re(d.text)&&n.setTextContent(D,""),o(D,null,A,0,A.length-1,b)):re(C)?u(D,C,0,C.length-1):re(d.text)&&n.setTextContent(D,""):d.text!==y.text&&(re(C)&&u(D,C,0,C.length-1),n.setTextContent(D,y.text)),(S=N?.postpatch)===null||S===void 0||S.call(N,d,y)}return function(y,b){let m,w,_,x=[];for(m=0;m<s.pre.length;++m)s.pre[m]();for(Hl(n,y)?y=i(y):Jl(n,y)&&(y=a(y)),je(y,b)?f(y,b,x):(w=y.elm,_=n.parentNode(w),p(b,x),_!==null&&(n.insertBefore(_,b.elm,n.nextSibling(w)),u(_,[y],0,0))),m=0;m<x.length;++m)x[m].data.hook.insert(x[m]);for(m=0;m<s.post.length;++m)s.post[m]();return b}}function Us(e,t){let r,s,n=t.elm,i=e.data.class,a=t.data.class;if(!(!i&&!a)&&i!==a){i=i||{},a=a||{};for(s in i)i[s]&&!Object.prototype.hasOwnProperty.call(a,s)&&n.classList.remove(s);for(s in a)r=a[s],r!==i[s]&&n.classList[r?"add":"remove"](s)}}var zs={create:Us,update:Us};function Hs(e,t){let r,s,n,i=t.elm,a=e.data.props,l=t.data.props;if(!(!a&&!l)&&a!==l){a=a||{},l=l||{};for(r in l)s=l[r],n=a[r],n!==s&&(r!=="value"||i[r]!==s)&&(i[r]=s)}}var Js={create:Hs,update:Hs};var Yl="http://www.w3.org/1999/xlink",Xl="http://www.w3.org/2000/xmlns/",Ql="http://www.w3.org/XML/1998/namespace";function qs(e,t){let r,s=t.elm,n=e.data.attrs,i=t.data.attrs;if(!(!n&&!i)&&n!==i){n=n||{},i=i||{};for(r in i){let a=i[r];n[r]!==a&&(a===!0?s.setAttribute(r,""):a===!1?s.removeAttribute(r):r.charCodeAt(0)!==120?s.setAttribute(r,a):r.charCodeAt(3)===58?s.setAttributeNS(Ql,r,a):r.charCodeAt(5)===58?r.charCodeAt(1)===109?s.setAttributeNS(Xl,r,a):s.setAttributeNS(Yl,r,a):s.setAttribute(r,a))}for(r in n)r in i||s.removeAttribute(r)}}var Gs={create:qs,update:qs};var Ys=typeof window?.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):setTimeout,Zl=function(e){Ys(function(){Ys(e)})},ur=!1;function ep(e,t,r){Zl(function(){e[t]=r})}function Xs(e,t){let r,s,n=t.elm,i=e.data.style,a=t.data.style;if(!i&&!a||i===a)return;i=i||{},a=a||{};let l="delayed"in i;for(s in i)s in a||(s[0]==="-"&&s[1]==="-"?n.style.removeProperty(s):n.style[s]="");for(s in a)if(r=a[s],s==="delayed"&&a.delayed)for(let p in a.delayed)r=a.delayed[p],(!l||r!==i.delayed[p])&&ep(n.style,p,r);else s!=="remove"&&r!==i[s]&&(s[0]==="-"&&s[1]==="-"?n.style.setProperty(s,r):n.style[s]=r)}function tp(e){let t,r,s=e.elm,n=e.data.style;if(!(!n||!(t=n.destroy)))for(r in t)s.style[r]=t[r]}function rp(e,t){let r=e.data.style;if(!r||!r.remove){t();return}ur||(e.elm.offsetLeft,ur=!0);let s,n=e.elm,i=0,a=r.remove,l=0,p=[];for(s in a)p.push(s),n.style[s]=a[s];let c=getComputedStyle(n)["transition-property"].split(", ");for(;i<c.length;++i)p.indexOf(c[i])!==-1&&l++;n.addEventListener("transitionend",function(u){u.target===n&&--l,l===0&&t()})}function sp(){ur=!1}var Qs={pre:sp,create:Xs,update:Xs,destroy:tp,remove:rp};function Zs(e,t,r){if(typeof e=="function")e.call(t,r,t);else if(typeof e=="object")for(let s=0;s<e.length;s++)Zs(e[s],t,r)}function ip(e,t){let r=e.type,s=t.data.on;s&&s[r]&&Zs(s[r],t,e)}function np(){return function e(t){ip(t,e.vnode)}}function hr(e,t){let r=e.data.on,s=e.listener,n=e.elm,i=t&&t.data.on,a=t&&t.elm,l;if(r!==i){if(r&&s)if(i)for(l in r)i[l]||n.removeEventListener(l,s,!1);else for(l in r)n.removeEventListener(l,s,!1);if(i){let p=t.listener=e.listener||np();if(p.vnode=t,r)for(l in i)r[l]||a.addEventListener(l,p,!1);else for(l in i)a.addEventListener(l,p,!1)}}}var ei={create:hr,update:hr,destroy:hr};var ap=()=>Ks([zs,Js,Gs,Qs,ei]),dr=ap;var op=e=>{let t={};return{once:(r,s)=>{t[r]||(t[r]=[]);let n=(...i)=>{s(...i),t[r]=t[r].filter(a=>a!==n)};t[r].push(n)},emit:(r,...s)=>{t[r]&&t[r].forEach(n=>{n(...s)})},showAlert:async r=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");e.transformedHandlers.showAlert(r)},showConfirm:async r=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");return e.transformedHandlers.showConfirm(r)},showDropdownMenu:async r=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");return e.transformedHandlers.showDropdownMenu(r)},closeAll:async()=>{if(!e)throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");return e.transformedHandlers.closeAll()}}},ti=op;function ri(e,t,r){if(e.ns="http://www.w3.org/2000/svg",r!=="foreignObject"&&t!==void 0)for(let s=0;s<t.length;++s){let n=t[s];if(typeof n=="string")continue;let i=n.data;i!==void 0&&ri(i,n.children,n.sel)}}function fr(e,t,r){let s={},n,i,a;if(r!==void 0?(t!==null&&(s=t),$e(r)?n=r:Se(r)?i=r.toString():r&&r.sel&&(n=[r])):t!=null&&($e(t)?n=t:Se(t)?i=t.toString():t&&t.sel?n=[t]:s=t),n!==void 0)for(a=0;a<n.length;++a)Se(n[a])&&(n[a]=ve(void 0,void 0,void 0,n[a],void 0));return e.startsWith("svg")&&(e.length===3||e[3]==="."||e[3]==="#")&&ri(s,n,e),ve(e,s,n,i,void 0)}var lp=ti(),pp={globalUI:lp},si={components:pp},ii=dr();var et={components:{breadcrumb:{handlers:yt,store:mt,view:Nr},dropdownMenu:{handlers:gt,store:vt,view:Pr},form:{handlers:bt,store:kt,view:Qr},globalUi:{handlers:$t,store:St,view:Zr},navbar:{handlers:Ct,store:It,view:es},pageOutline:{handlers:Ot,store:Tt,view:rs},popoverInput:{handlers:Lt,store:Rt,view:ss},select:{handlers:Nt,store:Pt,view:is},sidebar:{handlers:Vt,store:jt,view:ns},sliderInput:{handlers:Bt,store:Wt,view:as},table:{handlers:Mt,store:Ft,view:os},tabs:{handlers:Kt,store:Ut,view:ls},tooltip:{handlers:ps,store:zt,view:cs},waveform:{handlers:Ht,store:Jt,view:hs}}};Object.keys(et).forEach(e=>{Object.keys(et[e]).forEach(t=>{let r=pr({...et[e][t],patch:ii,h:fr},si[e]);customElements.define(et[e][t].view.elementName,r)})});customElements.define("rtgl-button",vr({}));customElements.define("rtgl-view",_r({}));customElements.define("rtgl-text",Ar({}));customElements.define("rtgl-image",Er({}));customElements.define("rtgl-svg",$r({}));customElements.define("rtgl-input",Sr({}));customElements.define("rtgl-input-number",Cr({}));customElements.define("rtgl-textarea",Ir({}));customElements.define("rtgl-color-picker",Or({}));customElements.define("rtgl-slider",Tr({}));customElements.define("rtgl-dialog",Lr({}));customElements.define("rtgl-popover",Rr({}));})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rettangoli/ui",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "A UI component library for building web interfaces.",
5
5
  "main": "dist/rettangoli-esm.min.js",
6
6
  "type": "module",
@@ -1,4 +1,3 @@
1
-
2
1
  const updateAttributes = ({ form, defaultValues = {}, refs }) => {
3
2
  const { fields = [] } = form;
4
3
  fields.forEach((field) => {
@@ -29,17 +28,43 @@ const updateAttributes = ({ form, defaultValues = {}, refs }) => {
29
28
  })
30
29
  }
31
30
 
31
+ const autoFocusFirstInput = (refs) => {
32
+ // Find first focusable field
33
+ for (const fieldKey in refs) {
34
+ if (fieldKey.startsWith('field-')) {
35
+ const fieldRef = refs[fieldKey];
36
+ if (fieldRef && fieldRef.elm) {
37
+ const element = fieldRef.elm;
38
+
39
+ if (element.focus) {
40
+ // Currently only available for input-text and input-textarea
41
+ element.focus();
42
+ return;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ };
48
+
49
+
32
50
  export const handleBeforeMount = (deps) => {
33
51
  const { store, props } = deps;
34
52
  store.setFormValues(props.defaultValues);
35
53
  };
36
54
 
37
55
  export const handleAfterMount = (deps) => {
38
- const { props, getRefIds, render } = deps;
56
+ const { props, getRefIds, render, attrs } = deps;
39
57
  const { form = {}, defaultValues } = props;
40
58
  const refs = getRefIds();
41
59
  updateAttributes({ form, defaultValues, refs });
42
60
  render();
61
+
62
+ // Auto-focus first input field if autofocus attribute is set
63
+ if (attrs?.autofocus) {
64
+ setTimeout(() => {
65
+ autoFocusFirstInput(refs);
66
+ }, 50);
67
+ }
43
68
  };
44
69
 
45
70
  export const handleOnUpdate = (deps, payload) => {
@@ -257,3 +282,38 @@ export const handleTooltipMouseLeave = (deps) => {
257
282
  store.hideTooltip();
258
283
  render();
259
284
  };
285
+
286
+ export const handleKeyDown = (deps, payload) => {
287
+ const { store, dispatchEvent, props } = deps;
288
+ const event = payload._event;
289
+
290
+ // Handle Enter key to submit form
291
+ if (event.key === 'Enter' && !event.shiftKey) {
292
+ const target = event.target;
293
+ // Don't submit if we're in a textarea (native or custom component)
294
+ if (target.tagName === 'TEXTAREA' || target.tagName === 'RTGL-TEXTAREA') {
295
+ return;
296
+ }
297
+
298
+ event.preventDefault();
299
+
300
+ // Dispatch action-click event for the first button
301
+ const form = props.form || {};
302
+ const actions = form.actions || {};
303
+ const buttons = actions.buttons || [];
304
+
305
+ if (buttons.length > 0) {
306
+ const firstButtonId = buttons[0].id;
307
+ const formValues = store.selectFormValues();
308
+
309
+ dispatchEvent(
310
+ new CustomEvent("action-click", {
311
+ detail: {
312
+ actionId: firstButtonId,
313
+ formValues: formValues,
314
+ },
315
+ }),
316
+ );
317
+ }
318
+ }
319
+ };
@@ -258,6 +258,10 @@ propsSchema:
258
258
  - content
259
259
 
260
260
  refs:
261
+ form-container:
262
+ eventListeners:
263
+ keydown:
264
+ handler: handleKeyDown
261
265
  action-*:
262
266
  eventListeners:
263
267
  click:
@@ -272,6 +276,8 @@ refs:
272
276
  eventListeners:
273
277
  input-change:
274
278
  handler: handleInputChange
279
+ textarea-change:
280
+ handler: handleInputChange
275
281
  select-change:
276
282
  handler: handleSelectChange
277
283
  add-option-selected:
@@ -301,7 +307,7 @@ events:
301
307
  action-click: {}
302
308
 
303
309
  template:
304
- - rtgl-view w=f p=md g=lg ${containerAttrString}:
310
+ - rtgl-view#form-container w=f p=md g=lg ${containerAttrString}:
305
311
  - rtgl-view g=sm w=f:
306
312
  - $if title:
307
313
  - rtgl-text s=lg: ${title}
@@ -115,6 +115,19 @@ class RettangoliTextAreaElement extends HTMLElement {
115
115
  this._updateTextareaAttributes();
116
116
  }
117
117
 
118
+ // Public methods to proxy focus and select to internal textarea
119
+ focus() {
120
+ if (this._textareaElement) {
121
+ this._textareaElement.focus();
122
+ }
123
+ }
124
+
125
+ select() {
126
+ if (this._textareaElement) {
127
+ this._textareaElement.select();
128
+ }
129
+ }
130
+
118
131
  attributeChangedCallback(name, oldValue, newValue) {
119
132
  if (name === 'value') {
120
133
  requestAnimationFrame((() => {