@rettangoli/ui 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rettangoli-iife-ui.min.js +6 -6
- package/package.json +1 -1
- package/src/components/form/form.handlers.js +17 -31
- package/src/components/form/form.view.yaml +0 -4
- package/src/components/popoverInput/popoverInput.handlers.js +1 -2
- package/src/components/select/select.store.js +0 -2
- package/src/components/tooltip/tooltip.view.yaml +0 -4
- package/src/primitives/popover.js +5 -1
- package/src/primitives/slider.js +6 -4
|
@@ -351,7 +351,7 @@ var rettangoli=(()=>{var ei=Object.defineProperty;var N=(e,t)=>{for(var r in t)e
|
|
|
351
351
|
flex-wrap: nowrap;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
`;var
|
|
354
|
+
`;var $e={xs:"--border-width-xs",sm:"--border-width-sm",md:"--border-width-md",lg:"--border-width-lg",xl:"--border-width-xl"},ai={bgc:{pr:`
|
|
355
355
|
background-color: var(--primary);
|
|
356
356
|
`,se:`
|
|
357
357
|
background-color: var(--secondary);
|
|
@@ -391,7 +391,7 @@ var rettangoli=(()=>{var ei=Object.defineProperty;var N=(e,t)=>{for(var r in t)e
|
|
|
391
391
|
left: 0;
|
|
392
392
|
top: 0;
|
|
393
393
|
height: 100%;
|
|
394
|
-
`},shadow:{sm:"--shadow-sm",md:"--shadow-md",lg:"--shadow-lg"},pt:V,pr:V,pb:V,pl:V,p:V,ph:V,pv:V,g:V,gv:V,gh:V,bw
|
|
394
|
+
`},shadow:{sm:"--shadow-sm",md:"--shadow-md",lg:"--shadow-lg"},pt:V,pr:V,pb:V,pl:V,p:V,ph:V,pv:V,g:V,gv:V,gh:V,bw:$e,bwt:$e,bwr:$e,bwb:$e,bwl:$e,bc:{pr:"--primary",se:"--secondary",de:"--destructive",fg:"--foreground",bg:"--background",mu:"--muted",ac:"--accent",bo:"--border",tr:"transparent"},br:{xs:"--border-radius-xs",sm:"--border-radius-sm",md:"--border-radius-md",lg:"--border-radius-lg",xl:"--border-radius-xl",f:"--border-radius-f"}},De=re(ai);var li={mt:V,mr:V,mb:V,ml:V,m:V,mh:V,mv:V},q=re(li);var rt=class e extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){e.styleSheet||(e.styleSheet=new CSSStyleSheet,e.styleSheet.replaceSync(T`
|
|
395
395
|
slot {
|
|
396
396
|
display: contents;
|
|
397
397
|
}
|
|
@@ -807,7 +807,7 @@ var rettangoli=(()=>{var ei=Object.defineProperty;var N=(e,t)=>{for(var r in t)e
|
|
|
807
807
|
}
|
|
808
808
|
${q}
|
|
809
809
|
${J}
|
|
810
|
-
`))}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._inputElement=document.createElement("input"),this._inputElement.type="range",this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._inputElement),this._inputElement.addEventListener("input",this._onInput),this._inputElement.addEventListener("change",this._onChange)}static get observedAttributes(){return["key","value","min","max","step","disabled",...oe([...ne,"wh","w","h","hide","show","op","z"])]}get value(){return this._inputElement.value}set value(t){this._inputElement.value=t}_onInput=
|
|
810
|
+
`))}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._inputElement=document.createElement("input"),this._inputElement.type="range",this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._inputElement),this._inputElement.addEventListener("input",this._onInput),this._inputElement.addEventListener("change",this._onChange)}static get observedAttributes(){return["key","value","min","max","step","disabled",...oe([...ne,"wh","w","h","hide","show","op","z"])]}get value(){return this._inputElement.value}set value(t){this._inputElement.value=t}_onInput=()=>{this.dispatchEvent(new CustomEvent("slider-input",{detail:{value:Number(this._inputElement.value)}}))};_onChange=()=>{this.dispatchEvent(new CustomEvent("slider-change",{detail:{value:Number(this._inputElement.value)}}))};attributeChangedCallback(t,r,s){if(t==="key"&&r!==s){requestAnimationFrame(()=>{let n=this.getAttribute("value"),o=this.getAttribute("min")||"0";this._inputElement.value=n??o});return}if(["value","min","max","step","disabled"].includes(t)){this._updateInputAttributes();return}this._styles={default:{},sm:{},md:{},lg:{},xl:{}},["default","sm","md","lg","xl"].forEach(n=>{let o=h=>`${n==="default"?"":`${n}-`}${h}`,a=this.getAttribute(o("wh")),l=F(a===null?this.getAttribute(o("w")):a),p=F(a===null?this.getAttribute(o("h")):a),c=this.getAttribute(o("op")),u=this.getAttribute(o("z"));u!==null&&(this._styles[n]["z-index"]=u),c!==null&&(this._styles[n].opacity=c),l==="f"?this._styles[n].width="var(--width-stretch)":l!==void 0&&(this._styles[n].width=l,this._styles[n]["min-width"]=l,this._styles[n]["max-width"]=l),p==="f"?this._styles[n].height="100%":p!==void 0&&(this._styles[n].height=p,this._styles[n]["min-height"]=p,this._styles[n]["max-height"]=p),this.hasAttribute(o("hide"))&&(this._styles[n].display="none !important"),this.hasAttribute(o("show"))&&(this._styles[n].display="block !important")});let i=ae(this._styles,'input[type="range"]');i!==this._lastStyleString&&(this._styleElement.textContent=i,this._lastStyleString=i)}_updateInputAttributes(){let t=this.getAttribute("value"),r=this.getAttribute("min"),s=this.getAttribute("max"),i=this.getAttribute("step"),n=this.hasAttribute("disabled");t!==null?this._inputElement.value=t:this._inputElement.value=r??0,r!==null?this._inputElement.min=r:this._inputElement.min="0",s!==null?this._inputElement.max=s:this._inputElement.max="100",i!==null?this._inputElement.step=i:this._inputElement.step="1",n?this._inputElement.setAttribute("disabled",""):this._inputElement.removeAttribute("disabled")}connectedCallback(){this._updateInputAttributes()}},Cr=({render:e,html:t})=>pt;var ct=class e extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){e.styleSheet||(e.styleSheet=new CSSStyleSheet,e.styleSheet.replaceSync(T`
|
|
811
811
|
:host {
|
|
812
812
|
display: contents;
|
|
813
813
|
}
|
|
@@ -932,7 +932,7 @@ var rettangoli=(()=>{var ei=Object.defineProperty;var N=(e,t)=>{for(var r in t)e
|
|
|
932
932
|
min-width: 200px;
|
|
933
933
|
max-width: 400px;
|
|
934
934
|
}
|
|
935
|
-
`))}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._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 i=this._popoverContainer.getBoundingClientRect(),{left:n,top:o}=this._calculatePosition(t,r,i.width,i.height,s);this._popoverContainer.style.left=`${n}px`,this._popoverContainer.style.top=`${o}px`,requestAnimationFrame(()=>{this.setAttribute("positioned","")})})}_calculatePosition(t,r,s,i,n){let a=t,l=r;switch(n){case"top":a=t-s/2,l=r-i-8;break;case"top-start":a=t,l=r-i-8;break;case"top-end":a=t-s,l=r-i-8;break;case"right":a=t+8,l=r-i/2;break;case"right-start":a=t+8,l=r;break;case"right-end":a=t+8,l=r-i;break;case"bottom":a=t-s/2,l=r+8;break;case"bottom-start":a=t,l=r+8;break;case"bottom-end":a=t-s,l=r+8;break;case"left":a=t-s-8,l=r-i/2;break;case"left-start":a=t-s-8,l=r;break;case"left-end":a=t-s-8,l=r-i;break}let p=8;return a=Math.max(p,Math.min(a,window.innerWidth-s-p)),l=Math.max(p,Math.min(l,window.innerHeight-i-p)),{left:a,top:l}}get popover(){return this._popoverContainer}},Ir=({render:e,html:t})=>ut;var dt={};N(dt,{handleClickItem:()=>ui});var ui=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var ht={};N(ht,{createInitialState:()=>di,selectViewData:()=>yi});var di=()=>Object.freeze({}),hi=["id","class","style","slot"],fi=e=>Object.entries(e).filter(([t])=>!hi.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),yi=({props:e,attrs:t})=>{let r=fi(t),s=e.items||[],i=e.separator||"breadcrumb-arrow",n=[];return s.forEach((o,a)=>{n.push(o),a<s.length-1&&n.push({isSeparator:!0})}),{containerAttrString:r,items:n,separator:i}};var Tr={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 ft={};N(ft,{handleClickMenuItem:()=>gi,handleClosePopover:()=>mi});var mi=(e,t)=>{let{dispatchEvent:r}=e;r(new CustomEvent("close"))},gi=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-","")),o=s.items[n];r(new CustomEvent("click-item",{detail:{index:n,item:o}}))};var yt={};N(yt,{createInitialState:()=>vi,selectViewData:()=>bi});var vi=()=>Object.freeze({}),bi=({props:e,attrs:t})=>({items:e.items||[],open:!!t.open,x:t.x,y:t.y,placement:t.placement});var Lr={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 mt={};N(mt,{handleActionClick:()=>Ei,handleAfterMount:()=>xi,handleBeforeMount:()=>wi,handleColorPickerChange:()=>$i,handleImageClick:()=>Ii,handleInputChange:()=>Ai,handleOnUpdate:()=>_i,handlePopoverInputChange:()=>ki,handleSelectAddOption:()=>Li,handleSelectChange:()=>Si,handleSliderChange:()=>Ci,handleSliderInputChange:()=>Oi,handleTooltipMouseEnter:()=>Ri,handleTooltipMouseLeave:()=>Ni,handleWaveformClick:()=>Ti});var Rr=({form:e,defaultValues:t={},refs:r})=>{let{fields:s=[]}=e;s.forEach(i=>{let n=r[`field-${i.name}`]?.elm;if(n){if(["inputText","colorPicker","slider","slider-input","popover-input"].includes(i.inputType)){let o=t[i.name];o!==void 0&&n.setAttribute("value",o)}if(i.inputType==="inputText"&&i.placeholder&&n.getAttribute("placeholder")!==i.placeholder&&n.setAttribute("placeholder",i.placeholder),i.inputType==="select"&&i.placeholder&&n.placeholder!==i.placeholder&&(n.placeholder=i.placeholder),i.inputType==="select"){i.placeholder!==n.getAttribute("placeholder")&&(i.placeholder!==void 0?n.setAttribute("placeholder",i.placeholder):n.removeAttribute("placeholder"),n.render());let o=t[i.name];o!==n.selectedValue&&(n.selectedValue=o,n.render())}}})},wi=e=>{let{store:t,props:r}=e;t.setFormValues(r.defaultValues)},xi=e=>{let{props:t,getRefIds:r,render:s}=e,{form:i={},defaultValues:n}=t,o=r();Rr({form:i,defaultValues:n,refs:o}),s()},_i=(e,t)=>{let{oldAttrs:r,newAttrs:s,newProps:i}=t,{store:n,render:o,getRefIds:a}=e,{form:l={},defaultValues:p}=i;if(r?.key!==s?.key){let c=a();Rr({form:l,defaultValues:p,refs:c});return}n.setFormValues(p),o()},we=(e,t,r,s)=>{s(new CustomEvent("form-change",{detail:{name:e,fieldValue:t,formValues:r}}))},Ei=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("action-","");s(new CustomEvent("action-click",{detail:{actionId:n,formValues:r.selectFormValues()}}))},Ai=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("input-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),we(o,n.detail.value,r.selectFormValues(),s))},ki=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("popover-input-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),we(o,n.detail.value,r.selectFormValues(),s))},Si=(e,t)=>{let{store:r,dispatchEvent:s,render:i,props:n}=e,o=t._event,a=o.currentTarget.id.replace("select-","");a&&(r.setFormFieldValue({name:a,value:o.detail.selectedValue,props:n}),we(a,o.detail.selectedValue,r.selectFormValues(),s),i())},$i=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("colorpicker-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),we(o,n.detail.value,r.selectFormValues(),s))},Ci=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("slider-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),we(o,n.detail.value,r.selectFormValues(),s))},Oi=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("slider-input-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),we(o,n.detail.value,r.selectFormValues(),s))},Ii=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("image-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ti=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("waveform-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Li=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("select-","");s(new CustomEvent("action-click",{detail:{actionId:"select-options-add",name:n,formValues:r.selectFormValues()}}))},Ri=(e,t)=>{let{store:r,render:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("tooltip-icon-",""),l=i.form.fields.find(p=>p.name===o);if(l&&l.tooltip){let p=n.currentTarget.getBoundingClientRect();r.showTooltip({x:p.left+p.width/2,y:p.top-8,content:l.tooltip.content}),s()}},Ni=(e,t)=>{let{store:r,render:s}=e;r.hideTooltip(),s()};var Et={};N(Et,{createInitialState:()=>pn,getFormFieldValue:()=>mn,hideTooltip:()=>wn,selectForm:()=>We,selectFormValues:()=>yn,selectState:()=>fn,selectViewData:()=>hn,setFormFieldValue:()=>vn,setFormValues:()=>gn,showTooltip:()=>bn});var b={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9},K={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8},Oe={NOT:0};var B=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},xe=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var gt=e=>{if(!e||e.trim()==="")throw new B("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new B(`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 B(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Nr=e=>{if(e.trim().endsWith(" in"))throw new B(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new B(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new B(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(i=>i.trim());for(let i of s)if(!i)throw new B(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new B(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var Vr=(e,t)=>{if(t===null)return new xe(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new xe(`Cannot iterate over undefined value at '$for ${e}'`);let r=typeof t;return new xe(`Cannot iterate over non-array value (got: ${r}) at '$for ${e}'`)},Pr=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new xe(`Unknown function '${e}' (${r})`)};var Vi=(e,t,r={})=>{let s=L(e,r,t,{});return s===void 0?{}:s},L=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);if(e.type===b.LITERAL)return e.value;if(e.type===b.VARIABLE)return z(e.path,r,s);if(e.type===b.INTERPOLATION)return ji(e.parts,t,r,s);switch(e.type){case b.FUNCTION:return Dr(e,t,r,s);case b.BINARY:return Br(e,t,r,s);case b.UNARY:return Mr(e,t,r,s);case b.CONDITIONAL:return Bi(e,t,r,s);case b.LOOP:return Ui(e,t,r,s);case b.OBJECT:return Hi(e,t,r,s);case b.ARRAY:return Ji(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},jr=new Map,Pi=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();/^\d+$/.test(o)?t.push({type:"index",value:parseInt(o,10)}):t.push({type:"property",value:`[${r}]`}),r=""}s=!1}else r+=n}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=jr.get(e);if(!s){let n=[],o="",a=0;for(let l=0;l<e.length;l++){let p=e[l];p==="["?(a++,o+=p):p==="]"?(a--,o+=p):p==="."&&a===0?o&&(n.push(o),o=""):o+=p}o&&n.push(o),s=[];for(let l of n){let p=Pi(l.trim());s.push(...p)}jr.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},ji=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=L(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},Dr=(e,t,r,s)=>{let i=t[e.name];if(!i)throw Pr(e.name,t);let n=e.args.map(o=>L(o,t,r,s));return i(...n)},Ie=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);switch(e.type){case b.VARIABLE:return z(e.path,r,s);case b.LITERAL:return e.value;case b.BINARY:return Br(e,t,r,s);case b.UNARY:return Mr(e,t,r,s);case b.FUNCTION:return Dr(e,t,r,s);default:return L(e,t,r,s)}},Br=(e,t,r,s)=>{if(e.op===K.AND||e.op===K.OR){let o=Ie(e.left,t,r,s),a=Ie(e.right,t,r,s);switch(e.op){case K.AND:return o&&a;case K.OR:return o||a}}let i=L(e.left,t,r,s),n=L(e.right,t,r,s);switch(e.op){case K.EQ:return i==n;case K.NEQ:return i!=n;case K.GT:return i>n;case K.LT:return i<n;case K.GTE:return i>=n;case K.LTE:return i<=n;case K.IN:return Array.isArray(n)?n.includes(i):!1;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Mr=(e,t,r,s)=>{let i=e.op===Oe.NOT?Ie(e.operand,t,r,s):L(e.operand,t,r,s);switch(e.op){case Oe.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Di=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===b.VARIABLE)if(z(i.path,r,s)){let o=e.bodies[0];if(o.type===b.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?L(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===b.LITERAL)a[p]=c.value;else if(c.type===b.VARIABLE)a[p]=z(c.path,r,s);else if(c.type===b.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===b.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=L(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=L(c,t,r,s)}return a}}else{let o=e.bodies[1];if(o.type===b.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?L(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===b.LITERAL)a[p]=c.value;else if(c.type===b.VARIABLE)a[p]=z(c.path,r,s);else if(c.type===b.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===b.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=L(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=L(c,t,r,s)}return a}}}return null},Bi=(e,t,r,s)=>{let i=Di(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||Ie(o,t,r,s))return L(e.bodies[n],t,r,s)}return Wr},Mi=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===b.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===b.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===b.OBJECT&&n.properties.length<=5){for(let l of n.properties)if(l.parsedKey)return null;let a=[];for(let l=0;l<t.length;l++){let p=t[l];if(p[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===b.LITERAL)c[h]=f.value;else if(f.type===b.VARIABLE){let d=f.path;if(d===s)c[h]=p;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=p[y]}else return null}else if(f.type===b.INTERPOLATION){let d=[],y=!0;for(let v of f.parts)if(typeof v=="string")d.push(v);else if(v.type===b.VARIABLE){let g=v.path;if(g===s)d.push(p!=null?String(p):"");else if(g.startsWith(s+".")){let w=g.substring(s.length+1),x=p[w];d.push(x!=null?String(x):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}a.push(c)}}return a}}}return null},Wi=(e,t)=>{let r=e.body,s=e.itemVar,i=Mi(e,t);if(i!==null)return i;if(r.type===b.OBJECT&&r.properties.length<=5){for(let a of r.properties)if(a.parsedKey)return null;let n=[],o=!0;for(let a of r.properties){let l=a.key,p=a.value;if(p.type===b.LITERAL)n.push({key:l,type:"literal",value:p.value});else if(p.type===b.VARIABLE){let c=p.path;if(c===s)n.push({key:l,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:l,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(p.type===b.INTERPOLATION&&p.parts.length===1){let c=p.parts[0];if(c.type===b.VARIABLE){let u=c.path;if(u===s)n.push({key:l,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:l,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let a=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let l=0;l<t.length;l++){let p=t[l];a[l]={id:p.id,title:p.title!=null?String(p.title):"",completed:p.completed}}else for(let l=0;l<t.length;l++){let p=t[l],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=p;else if(u.type==="prop")c[u.key]=p[u.prop];else if(u.type==="item_string")c[u.key]=p!=null?String(p):"";else if(u.type==="prop_string"){let h=p[u.prop];c[u.key]=h!=null?String(h):""}a[l]=c}return a}}return null},Fi=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===b.OBJECT&&o.fast!==!1){let a=e.itemVar,l=e.indexVar;for(let p=0;p<i.length;p++){let c=i[p],u={},h={...s,[a]:c,...l&&{[l]:p}};for(let f of o.properties){let d=f.parsedKey?L(f.parsedKey,t,r,h):f.key,y=f.value;if(y.type===b.LITERAL)u[d]=y.value;else if(y.type===b.VARIABLE){let v=y.path;if(v===a)u[d]=c;else if(v===l)u[d]=p;else if(v.startsWith(a+".")){let g=v.substring(a.length+1);!g.includes(".")&&!g.includes("[")?u[d]=c[g]:u[d]=z(v,r,{...s,[a]:c,...l&&{[l]:p}})}else u[d]=z(v,r,{...s,[a]:c,...l&&{[l]:p}})}else if(y.type===b.INTERPOLATION){let v=[];for(let g of y.parts)if(typeof g=="string")v.push(g);else if(g.type===b.VARIABLE){let w=g.path,x;if(w===a)x=c;else if(w===l)x=p;else if(w.startsWith(a+".")){let _=w.substring(a.length+1);!_.includes(".")&&!_.includes("[")?x=c[_]:x=z(w,r,{...s,[a]:c,...l&&{[l]:p}})}else x=z(w,r,{...s,[a]:c,...l&&{[l]:p}});v.push(x!=null?String(x):"")}else{let w={...s,[a]:c,...l&&{[l]:p}},x=L(g,t,r,w);v.push(x!=null?String(x):"")}u[d]=v.join("")}else{let v={...s,[a]:c,...l&&{[l]:p}};u[d]=L(y,t,r,v)}}n.push(u)}return n}return null},Ki=(e,t,r)=>{let s=e.body;if(s.type===b.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===b.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===b.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===b.OBJECT&&o.properties.length===2){let a=o.properties[0],l=o.properties[1];if(a.key==="id"&&a.value.type===b.VARIABLE&&a.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===b.CONDITIONAL){let p=[];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),p.push(h)}}return p}}}}return null},Ui=(e,t,r,s)=>{let i=L(e.iterable,t,r,s);if(!Array.isArray(i)){let a=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${e.iterable.path}`;throw Vr(a,i)}if(!e.indexVar){let a=Ki(e,i,e.itemVar);if(a!==null)return a}if(!e.indexVar){let a=Wi(e,i);if(a!==null)return a}let n=Fi(e,t,r,s,i);if(n!==null)return n;let o=[];for(let a=0;a<i.length;a++){let l=e.indexVar?{...s,[e.itemVar]:i[a],[e.indexVar]:a}:{...s,[e.itemVar]:i[a]},p=L(e.body,t,r,l);Array.isArray(p)&&p.length===1?o.push(p[0]):o.push(p)}return o},zi=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?L(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===b.OBJECT&&o.properties.length<=10&&!o.whenCondition){let a={},l={},p=!0;for(let c of o.properties){let u=c.parsedKey?L(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===b.LITERAL)l[u]=h.value;else if(h.type===b.VARIABLE)l[u]=z(h.path,r,s);else if(h.type===b.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===b.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{p=!1;break}if(!p)break;l[u]=f.join("")}else if(h.type===b.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,v=d.value;if(v.type===b.LITERAL)f[y]=v.value;else if(v.type===b.VARIABLE)f[y]=z(v.path,r,s);else if(v.type===b.INTERPOLATION){let g=[];for(let w of v.parts)if(typeof w=="string")g.push(w);else if(w.type===b.VARIABLE){let x=z(w.path,r,s);g.push(x!=null?String(x):"")}else{p=!1;break}if(!p)break;f[y]=g.join("")}else{p=!1;break}}if(!p)break;l[u]=f}else{p=!1;break}}if(p)return a[n]=l,a}}return null},Hi=(e,t,r,s)=>{if(e.whenCondition&&!Ie(e.whenCondition,t,r,s))return;let i=zi(e,t,r,s);if(i!==null)return i;if(e.fast){let l={};for(let p of e.properties){let c=p.parsedKey?L(p.parsedKey,t,r,s):p.key,u=p.value;if(u.type===b.LITERAL)l[c]=u.value;else if(u.type===b.VARIABLE)l[c]=z(u.path,r,s);else if(u.type===b.INTERPOLATION){let h=[];for(let f of u.parts)if(typeof f=="string")h.push(f);else if(f.type===b.VARIABLE){let d=z(f.path,r,s);h.push(d!=null?String(d):"")}else{let d=L(f,t,r,s);h.push(d!=null?String(d):"")}l[c]=h.join("")}else l[c]=L(u,t,r,s)}return l}let n={},o=null,a=!1;for(let l of e.properties)if(!l.key.startsWith("$if ")&&!l.key.match(/^\$if\s+\w+.*:?$/)&&!l.key.startsWith("$elif")&&!l.key.startsWith("$else")&&!l.key.startsWith("$for ")){a=!0;break}for(let l of e.properties)if(l.key.startsWith("$if ")||l.key.match(/^\$if\s+\w+.*:?$/)){let p=L(l.value,t,r,s);if(!a&&p!==null&&p!==void 0)return Array.isArray(p)&&p.length===1?p[0]:p;typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.assign(n,p)}else if(!l.key.startsWith("$for ")){let p=l.value;if(p&&p.type===b.OBJECT&&p.properties){let c=p.properties.find(u=>u.key.startsWith("$for "));if(c){let u=L(c.value,t,r,s);u!==void 0&&(n[l.key]=u)}else{let u=L(l.value,t,r,s);u!==void 0&&(n[l.key]=u)}}else{let c=l.parsedKey?L(l.parsedKey,t,r,s):l.key,u=L(l.value,t,r,s);u!==void 0&&(n[c]=u)}}return n},Wr={},Ji=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===b.LOOP){let o=L(n,t,r,s);i.push(o)}else{let o=L(n,t,r,s);o!==Wr&&o!==void 0&&i.push(o)}return i},vt=Vi;var qi=/\$\{([^}]*)\}/g,Kr=e=>{let t=e.match(/^(\w+)\((.*)\)$/);if(!t)return{isFunction:!1};let[,r,s]=t,i=Yi(s);return{isFunction:!0,type:b.FUNCTION,name:r,args:i}},Yi=e=>e.trim()?Gi(e).map(r=>Xi(r.trim())):[],Gi=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let a=e[o],l=o>0?e[o-1]:"";!i&&(a==='"'||a==="'")?(i=!0,n=a,r+=a):i&&a===n&&l!=="\\"?(i=!1,n="",r+=a):!i&&a==="("?(s++,r+=a):!i&&a===")"?(s--,r+=a):!i&&a===","&&s===0?(t.push(r),r=""):r+=a}return r&&t.push(r),t},Xi=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:b.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:b.LITERAL,value:parseFloat(e)};if(e==="true")return{type:b.LITERAL,value:!0};if(e==="false")return{type:b.LITERAL,value:!1};if(e==="null")return{type:b.LITERAL,value:null};let t=Kr(e);return t.isFunction?{type:t.type,name:t.name,args:t.args}:{type:b.VARIABLE,path:e}},Qi=/^\w+\(.*\)$/,Zi=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,en=e=>{if(!(!e||e.trim()===""||Qi.test(e))&&Zi.test(e))throw e.includes("?")&&e.includes(":")?new B(`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 B(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new B(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Fr=(e,t={})=>{let r=e.trim();en(r);let s=Kr(r);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:b.VARIABLE,path:r}},bt=(e,t={})=>{let r=e,s=[];e.includes("\\${")&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(a,l)=>{let p=`__ESCAPED_${s.length}__`;return s.push(l),p}),r=r.replace(/\\DOUBLE_ESC/g,"\\"));let i=[...r.matchAll(qi)];if(i.length===0){let a=r;for(let l=0;l<s.length;l++)a=a.replace(`__ESCAPED_${l}__`,s[l]);return{type:b.LITERAL,value:a}}if(i.length===1&&i[0][0]===r&&s.length===0)try{return Fr(i[0][1],t)}catch(a){if(a.message==="Invalid array index syntax")return{type:b.LITERAL,value:r};throw a}let n=[],o=0;for(let a of i){let[l,p]=a,c=a.index;if(c>o){let u=r.substring(o,c);for(let h=0;h<s.length;h++)u=u.replace(`__ESCAPED_${h}__`,s[h]);u&&n.push(u)}try{let u=Fr(p.trim(),t);n.push(u)}catch(u){if(u.message==="Invalid array index syntax")n.push(l);else throw u}o=c+l.length}if(o<r.length){let a=r.substring(o);for(let l=0;l<s.length;l++)a=a.replace(`__ESCAPED_${l}__`,s[l]);a&&n.push(a)}return{type:b.INTERPOLATION,parts:n}};var ue=(e,t)=>typeof e=="string"?bt(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?tn(e,t):rn(e,t):{type:b.LITERAL,value:e},tn=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let a=Object.keys(n);if(a.length===1&&a[0].startsWith("$for ")){let l=Ur(a[0],n[a[0]],t);r.push(l),s=!0;continue}}let o=ue(n,t);r.push(o),(o.type===b.FUNCTION||o.type===b.CONDITIONAL||o.type===b.LOOP||o.type===b.OBJECT&&!o.fast||o.type===b.ARRAY&&!o.fast)&&(s=!0)}return{type:b.ARRAY,items:r,fast:!s}},rn=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;for(let[l,p]of n)if(l==="$when"){if(i!==null)throw new B("Multiple '$when' directives on the same object are not allowed");if(p==null)throw new B("Missing condition expression after '$when'");let c=typeof p=="string"?p:JSON.stringify(p);if(c.trim()==="")throw new B("Empty condition expression after '$when'");i=se(c),s=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new B("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[l,p]=n[o];if(l==="$when"){o++;continue}if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=sn(n,o,t);r.push({key:l,value:c.node}),s=!0,o=c.nextIndex}else if(l.startsWith("$for ")){let c=Ur(l,p,t);r.push({key:l,value:c}),s=!0,o++}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new B(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new B("Missing condition expression after '$if'");{let c=ue(p,t);(c.type===b.FUNCTION||c.type===b.CONDITIONAL||c.type===b.LOOP||c.type===b.OBJECT&&!c.fast||c.type===b.ARRAY&&!c.fast)&&(s=!0);let u=bt(l,t),h={key:l,value:c};(u.type!==b.LITERAL||u.value!==l)&&(h.parsedKey=u),r.push(h),o++}}}let a={type:b.OBJECT,properties:r,fast:!s};return i&&(a.whenCondition=i),a},sn=(e,t,r={})=>{let s=[],i=[],n=t,[o,a]=e[n],l=null,p;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)l=u[1],p=u[2];else throw new B(`Invalid conditional syntax: ${o}`)}else p=o.substring(4),p.endsWith(":")&&(p=p.slice(0,-1).trim());gt(p);let c=se(p);for(s.push(c),i.push(ue(a,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(l?u.startsWith(`$elif#${l} `)?(d=u.substring(`$elif#${l} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${l}`||u===`$else#${l}:`)&&(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{gt(d);let y=se(d);s.push(y)}if(i.push(ue(h,r)),n++,d===null)break}else break}return{node:{type:b.CONDITIONAL,conditions:s,bodies:i,id:l},nextIndex:n}},se=e=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")"))return se(e.slice(1,-1));let t=Me(e,"||");if(t!==-1)return{type:b.BINARY,op:K.OR,left:se(e.substring(0,t).trim()),right:se(e.substring(t+2).trim())};let r=Me(e,"&&");if(r!==-1)return{type:b.BINARY,op:K.AND,left:se(e.substring(0,r).trim()),right:se(e.substring(r+2).trim())};let s=[{op:">=",type:K.GTE},{op:"<=",type:K.LTE},{op:"==",type:K.EQ},{op:"!=",type:K.NEQ},{op:">",type:K.GT},{op:"<",type:K.LT},{op:" in ",type:K.IN}];for(let{op:n,type:o}of s){let a=Me(e,n);if(a!==-1)return{type:b.BINARY,op:o,left:se(e.substring(0,a).trim()),right:se(e.substring(a+n.length).trim())}}let i=[" + "," - "," * "," / "," % "];for(let n of i)if(Me(e,n)!==-1)throw new B(`Arithmetic expressions not supported in conditionals - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`);return e.startsWith("!")?{type:b.UNARY,op:Oe.NOT,operand:se(e.substring(1).trim())}:nn(e)},Me=(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},nn=e=>{if(e=e.trim(),e==="true")return{type:b.LITERAL,value:!0};if(e==="false")return{type:b.LITERAL,value:!1};if(e==="null")return{type:b.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:b.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:b.LITERAL,value:""};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:b.LITERAL,value:t}:{type:b.VARIABLE,path:e}},Ur=(e,t,r)=>{let s=e.substring(5).trim();Nr(s);let i=s.match(/^(.+?)\s+in\s+(.+)$/);if(!i)throw new B(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let n=i[1].trim(),o=i[2].trim(),a,l=null;if(n.includes(",")){let u=n.split(",").map(h=>h.trim());if(u.length!==2)throw new B(`Invalid loop variables: ${n}. Expected format: "item" or "item, index"`);a=u[0],l=u[1]}else a=n;let p={type:b.VARIABLE,path:o},c=ue(t,r);return{type:b.LOOP,itemVar:a,indexVar:l,iterable:p,body:c}};var on=(e,t={})=>{let{functions:r={}}=t;return ue(e,r)},wt=on;var xt={};N(xt,{now:()=>an});var an=()=>Date.now();var ln=(e,t,r={})=>{let{functions:s={}}=r,i={...xt,...s},n=wt(e,{functions:i});return vt(n,t,i)},_t=ln;function zr(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}var pn=()=>Object.freeze({formValues:{},tooltipState:{open:!1,x:0,y:0,content:""}}),Hr=(e,t,r=void 0)=>{if(!t)return;let s=t.split(/[\[\].]/).filter(n=>n!==""),i=e;for(let n of s){if(i==null||!(n in i))return r;i=i[n]}return i},cn=(e,t,r)=>{let s=t.split(/[\[\].]/).filter(n=>n!=="");t.includes("[")&&t in e&&delete e[t];let i=e;for(let n=0;n<s.length-1;n++){let o=s[n];if(!(o in i)||typeof i[o]!="object"||i[o]===null){let a=s[n+1],l=/^\d+$/.test(a);i[o]=l?[]:{}}i=i[o]}return i[s[s.length-1]]=r,e},un=["id","class","style","slot"],dn=e=>Object.entries(e).filter(([t])=>!un.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),We=({props:e})=>{let{form:t={}}=e,{context:r}=e;return r?_t(t,r):t},hn=({state:e,props:t,attrs:r})=>{let s=dn(r),i=We({state:e,props:t}),n=structuredClone(i.fields||[]);return n.forEach(o=>{let a=Hr(e.formValues,o.name);if(["read-only-text"].includes(o.inputType)&&(o.defaultValue=a),o.inputType==="image"){let l=o.src;o.imageSrc=l&&l.trim()?l:null,o.placeholderText=o.placeholder||"No Image"}if(o.inputType==="waveform"){let l=o.waveformData;o.waveformData=l||null,o.placeholderText=o.placeholder||"No Waveform"}}),{key:r?.key,containerAttrString:s,title:i?.title||"",description:i?.description||"",fields:n,actions:t?.form?.actions||{buttons:[]},formValues:e.formValues,tooltipState:e.tooltipState}},fn=({state:e})=>e,yn=({state:e,props:t})=>{let r=We({state:e,props:t});return zr(e.formValues,r.fields.map(s=>s.name))},mn=({state:e},t)=>Hr(e.formValues,t),gn=(e,t)=>{e.formValues=t||{}},vn=(e,{name:t,value:r,props:s})=>{cn(e.formValues,t,r);let i=We({state:e,props:s}),n=zr(e.formValues,i.fields.map(o=>o.name));e.formValues=n},bn=(e,{x:t,y:r,content:s})=>{e.tooltipState={open:!0,x:t,y:r,content:s}},wn=e=>{e.tooltipState={...e.tooltipState,open:!1}};var Jr={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"}}},"popover-input-*":{eventListeners:{"input-change":{handler:"handlePopoverInputChange"}}}},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:"rtgl-text s=lg",value:{type:1,path:"title"}}],fast:!0},{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:1,path:"description"}}],fast:!0}],fast:!0}}],fast:!0},{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:"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:"rtgl-text",value:{type:1,path:"field.label"}}],fast:!0},{type:8,properties:[{key:"$if field.tooltip",value:{type:6,conditions:[{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:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"field.description"}}],fast:!0}],fast:!1}}],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"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"inputText"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input#field-${field.name} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#field-",{type:1,path:"field.name"}," 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",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"]}}],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 At={};N(At,{closeAll:()=>On,handleCancel:()=>En,handleConfirm:()=>_n,handleDialogClose:()=>xn,handleDropdownClose:()=>An,handleDropdownItemClick:()=>kn,showAlert:()=>Sn,showConfirm:()=>$n,showDropdownMenu:()=>Cn});var xn=(e,t)=>{let{store:r,render:s}=e;r.closeAll(),s()},_n=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!0)},En=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!1)},An=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",null)},kn=(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t._event,{index:o,item:a}=n.detail;r.closeAll(),s(),i.emit("event",{index:o,item:a})},Sn=(e,t)=>{let{store:r,render:s}=e,i=t;r.selectIsOpen()&&(r.closeAll(),s()),r.setAlertConfig(i),s()},$n=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setConfirmConfig(n),s(),new Promise(o=>{i.once("event",a=>{o(a)})})},Cn=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setDropdownConfig(n),s(),new Promise(o=>{i.once("event",a=>{o(a)})})},On=e=>{let{store:t,render:r}=e;t.selectIsOpen()&&(t.closeAll(),r())};var kt={};N(kt,{closeAll:()=>Nn,createInitialState:()=>In,selectConfig:()=>Vn,selectDropdownConfig:()=>Pn,selectIsOpen:()=>Dn,selectUiType:()=>jn,selectViewData:()=>Bn,setAlertConfig:()=>Tn,setConfirmConfig:()=>Ln,setDropdownConfig:()=>Rn});var In=()=>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"}}),Tn=(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},Ln=(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},Rn=(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},Nn=e=>{e.isOpen=!1,e.uiType="dialog"},Vn=({state:e})=>e.config,Pn=({state:e})=>e.dropdownConfig,jn=({state:e})=>e.uiType,Dn=({state:e})=>e.isOpen,Bn=({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 qr={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 St={};N(St,{handleClickStart:()=>Mn});var Mn=(e,t)=>{let{dispatchEvent:r,store:s}=e,i=t._event;console.log("handle click start",s.selectPath()),r(new CustomEvent("clickStart",{detail:{path:s.selectPath()}}))};var $t={};N($t,{createInitialState:()=>Wn,selectPath:()=>zn,selectViewData:()=>Un,setState:()=>Hn});var Wn=()=>Object.freeze({}),Fn=["id","class","style","slot"],Kn=e=>Object.entries(e).filter(([t])=>!Fn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Un=({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:Kn(r),start:s||{label:"",image:{src:"",width:32,height:32,alt:""}}}},zn=({props:e})=>e.start.path,Hn=e=>{};var Yr={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 Ct={};N(Ct,{handleBeforeMount:()=>qn});var Gr=(e,t,r)=>{let{store:s,render:i}=r,n,o=-1/0;if(e.forEach(a=>{let l=a.getBoundingClientRect();l.top<=t&&l.top>o&&(o=l.top,n=a.id)}),!n){let a=1/0;e.forEach(l=>{let p=l.getBoundingClientRect();p.top>t&&p.top<a&&(a=p.top,n=l.id)})}n&&n!==s.selectCurrentId()&&(s.setCurrentId(n),i())},Jn=(e,t,r,s)=>{let{store:i,render:n}=s,o=e.querySelectorAll("h1[id], h2[id], h3[id], h4[id], rtgl-text[id]"),a=Array.from(o),l=a.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}});i.setItems(l),Gr(a,r,s),n();let p=Gr.bind(void 0,a,r,s);return t.addEventListener("scroll",p,{passive:!0}),()=>{t.removeEventListener("scroll",p)}},qn=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 i=parseInt(t["offset-top"]||"100",10),n=Jn(r,s,i,e);return()=>{n()}})};var Ot={};N(Ot,{createInitialState:()=>Yn,selectCurrentId:()=>Qn,selectState:()=>Xn,selectViewData:()=>Gn,setContentContainer:()=>to,setCurrentId:()=>eo,setItems:()=>Zn});var Yn=()=>Object.freeze({items:[],currentId:null,contentContainer:null}),Gn=({state:e})=>{let r=((s,i)=>{let n=new Set,o=s.findIndex(l=>l.id===i);if(o===-1)return n;let a=s[o].level;for(let l=o-1;l>=0;l--)if(s[l].level<a){let p=s[l].level;n.add(s[l].id);for(let c=l-1;c>=0;c--)s[c].level<p&&(n.add(s[c].id),p=s[c].level);break}return n})(e.items,e.currentId);return{items:e.items.map(s=>{let i={1:"0",2:"12px",3:"24px",4:"32px"},n=s.id===e.currentId,o=r.has(s.id),a=n||o;return{...s,c:a?"fg":"mu-fg",ml:i[s.level]||"",bc:a?"fg":"mu-fg"}}),currentId:e.currentId}},Xn=({state:e})=>e,Qn=({state:e})=>e.currentId,Zn=(e,t)=>{e.items=t},eo=(e,t)=>{e.currentId=t},to=(e,t)=>{e.contentContainer=t};var Xr={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 It={};N(It,{handleBeforeMount:()=>ro,handleInputChange:()=>oo,handleInputKeydown:()=>lo,handleOnUpdate:()=>so,handlePopoverClose:()=>no,handleSubmitClick:()=>ao,handleTextClick:()=>io});var ro=e=>{let{store:t,attrs:r}=e;r.value!==void 0&&t.setValue(r.value||"")},so=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??"";i.setValue(o)}n()},io=(e,t)=>{let{store:r,render:s,getRefIds:i,attrs:n}=e,o=t._event,a=r.selectValue();r.setTempValue(a),r.openPopover({position:{x:o.currentTarget.getBoundingClientRect().left,y:o.currentTarget.getBoundingClientRect().bottom}});let{input:l}=i();l.elm.value=a,s(),n["auto-focus"]&&setTimeout(()=>{l.elm.focus()},50)},no=(e,t)=>{let{store:r,render:s}=e;r.closePopover(),s()},oo=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.detail.value;r.setTempValue(o),i(new CustomEvent("temp-input-change",{detail:{value:o},bubbles:!0})),s()},ao=(e,t)=>{let{store:r,render:s,dispatchEvent:i,getRefIds:n}=e,o=t._event,{input:a}=n(),l=a.elm.value;r.setValue(l),r.closePopover(),i(new CustomEvent("input-change",{detail:{value:l},bubbles:!0})),s()},lo=(e,t)=>{let{store:r,render:s,dispatchEvent:i,getRefIds:n}=e,o=t._event;if(o.key==="Enter"){let{input:a}=n(),l=a.elm.value;r.closePopover(),i(new CustomEvent("input-change",{detail:{value:l},bubbles:!0})),s()}else o.key==="Escape"&&(r.closePopover(),s())};var Tt={};N(Tt,{closePopover:()=>fo,createInitialState:()=>po,openPopover:()=>ho,selectValue:()=>mo,selectViewData:()=>co,setTempValue:()=>uo,setValue:()=>yo});var po=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},value:"",tempValue:""}),co=({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}},uo=(e,t)=>{e.tempValue=t},ho=(e,t)=>{let{position:r}=t;e.position=r,e.isOpen=!0,e.hasUnsavedChanges=!1},fo=e=>{e.isOpen=!1,e.tempValue=""},yo=(e,t)=>{e.value=t},mo=({state:e})=>e.value;var Qr={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 Lt={};N(Lt,{handleAddOptionClick:()=>ko,handleAddOptionMouseEnter:()=>So,handleAddOptionMouseLeave:()=>$o,handleBeforeMount:()=>go,handleButtonClick:()=>bo,handleClearClick:()=>Ao,handleClickOptionsPopoverOverlay:()=>wo,handleOnUpdate:()=>vo,handleOptionClick:()=>xo,handleOptionMouseEnter:()=>_o,handleOptionMouseLeave:()=>Eo});var go=e=>{let{store:t,props:r,render:s}=e;if(r.selectedValue!==null&&r.selectedValue!==void 0&&r.options){let i=r.options.find(n=>pe(n.value,r.selectedValue));i&&(t.updateSelectedValue({value:i?.value}),s())}},vo=(e,t)=>{let{oldAttrs:r,newAttrs:s,oldProps:i,newProps:n}=t,{store:o,props:a,render:l}=e;if(r?.key!==s?.key&&s?.key){o.resetSelection();let p=n?.selectedValue||a?.selectedValue,c=n?.options||a?.options;if(p!=null&&c){let u=c.find(h=>pe(h.value,p));u&&o.updateSelectedValue({value:u.value})}l()}else i.selectedValue!==n.selectedValue&&(o.updateSelectedValue(n.selectedValue),l())},bo=(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e;t._event.stopPropagation();let a=i()["select-button"].elm,l=a.firstElementChild,p=l?l.getBoundingClientRect():a.getBoundingClientRect(),c=r.selectSelectedValue(),u=c!==null?c:n.selectedValue,h=null;u!=null&&n.options&&(h=n.options.findIndex(f=>pe(f.value,u)),h===-1&&(h=null)),r.openOptionsPopover({position:{y:p.bottom+12,x:p.left-24},selectedIndex:h}),s()},wo=e=>{let{store:t,render:r}=e;t.closeOptionsPopover(),r()},xo=(e,t)=>{let{render:r,dispatchEvent:s,props:i,store:n}=e,o=t._event;o.stopPropagation();let a=o.currentTarget.id.replace("option-",""),l=i.options[a];n.updateSelectedValue({value:l?.value}),i.onChange&&typeof i.onChange=="function"&&i.onChange(l.value),s(new CustomEvent("option-selected",{detail:{value:l.value,label:l.label},bubbles:!0})),s(new CustomEvent("select-change",{detail:{selectedValue:l.value},bubbles:!0})),r()},_o=(e,t)=>{let{store:r,render:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-",""));r.setHoveredOption(n),s()},Eo=(e,t)=>{let{store:r,render:s}=e;r.clearHoveredOption(),s()},Ao=(e,t)=>{let{store:r,render:s,dispatchEvent:i,props:n}=e;t._event.stopPropagation(),r.clearSelectedValue(),n.onChange&&typeof n.onChange=="function"&&n.onChange(void 0),i(new CustomEvent("option-selected",{detail:{value:void 0,label:void 0},bubbles:!0})),i(new CustomEvent("select-change",{detail:{selectedValue:void 0},bubbles:!0})),s()},ko=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,{_event:n}=t;n.stopPropagation(),r.closeOptionsPopover(),i(new CustomEvent("add-option-selected",{bubbles:!0})),s()},So=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!0),s()},$o=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!1),s()};var Rt={};N(Rt,{clearHoveredOption:()=>Bo,clearSelectedValue:()=>Mo,closeOptionsPopover:()=>Vo,createInitialState:()=>Io,openOptionsPopover:()=>No,resetSelection:()=>jo,selectSelectedValue:()=>Ro,selectState:()=>Lo,selectViewData:()=>To,setHoveredAddOption:()=>Wo,setHoveredOption:()=>Do,updateSelectedValue:()=>Po});var Co=["id","class","style","slot","placeholder","selectedValue","selected-value","onChange","on-change","options"],Oo=e=>Object.entries(e||{}).filter(([t])=>!Co.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Io=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},selectedValue:null,hoveredOptionId:null,hoveredAddOption:!1}),To=({state:e,props:t,attrs:r})=>{let s=Oo(r),i=e.selectedValue!==null?e.selectedValue:t.selectedValue,n=r.placeholder||"Select an option",o=!0;if(i!=null&&t.options){let l=t.options.find(p=>pe(p.value,i));l&&(n=l.label,o=!1)}let a=(t.options||[]).map((l,p)=>{let c=pe(l.value,i),u=e.hoveredOptionId===p;return{...l,isSelected:c,bgc:u?"ac":c?"mu":""}});return console.log("attrs.placeholder",r.placeholder),{containerAttrString:s,isOpen:e.isOpen,position:e.position,options:a,selectedValue:i,selectedLabel:n,selectedLabelColor:o?"mu-fg":"fg",hasValue:i!=null,showClear:!r["no-clear"]&&!t["no-clear"]&&i!=null,showAddOption:!!t.addOption,addOptionLabel:t.addOption?.label?`+ ${t.addOption.label}`:"+ Add",addOptionBgc:e.hoveredAddOption?"ac":""}},Lo=({state:e})=>e,Ro=({state:e})=>e.selectedValue,No=(e,t)=>{let{position:r,selectedIndex:s}=t;e.position=r,e.isOpen=!0,s!=null&&(e.hoveredOptionId=s)},Vo=e=>{e.isOpen=!1},Po=(e,t)=>{e.selectedValue=t.value,e.isOpen=!1},jo=e=>{e.selectedValue=void 0},Do=(e,t)=>{e.hoveredOptionId=t},Bo=e=>{e.hoveredOptionId=null},Mo=e=>{e.selectedValue=void 0},Wo=(e,t)=>{e.hoveredAddOption=t};var Zr={elementName:"rtgl-select",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{placeholder:{type:"string"}}},propsSchema:{type:"object",properties:{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}",value:{type:1,path:"selectedLabel"},parsedKey:{type:2,parts:["rtgl-text c=",{type:1,path:"selectedLabelColor"}]}}],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 Nt={};N(Nt,{handleHeaderClick:()=>Fo,handleItemClick:()=>Ko});var Fo=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event,n,o=r.selectHeader();i.currentTarget.id==="header-label"?n=o.labelPath:i.currentTarget.id==="header-image"?n=o.image.path:i.currentTarget.id==="header"&&(n=o.path),s(new CustomEvent("headerClick",{detail:{path:n},bubbles:!0,composed:!0}))},Ko=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("item-",""),o=r.selectItem(n);s(new CustomEvent("itemClick",{detail:{item:o},bubbles:!0,composed:!0}))};var Pt={};N(Pt,{createInitialState:()=>Uo,selectActiveItem:()=>Yo,selectHeader:()=>qo,selectItem:()=>Go,selectViewData:()=>Jo,setState:()=>Xo});var Uo=()=>Object.freeze({}),zo=["id","class","style","slot"],Ho=e=>Object.entries(e).filter(([t])=>!zo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" ");function Vt(e,t=null){let r=[];for(let s of e){let i=s.id||s.href||s.path,n=t===i;if(r.push({id:i,title:s.title,href:s.href,type:s.type||"item",icon:s.icon,hrefAttr:s.href?`href=${s.href}`:"",isSelected:n,itemBgc:n?"ac":"bg",itemHoverBgc:n?"ac":"mu"}),s.items&&Array.isArray(s.items))for(let o of s.items){let a=o.id||o.href||o.path,l=t===a;r.push({id:a,title:o.title,href:o.href,type:o.type||"item",icon:o.icon,hrefAttr:o.href?`href=${o.href}`:"",isSelected:l,itemBgc:l?"ac":"bg",itemHoverBgc:l?"ac":"mu"})}}return r}var Jo=({state:e,props:t,attrs:r})=>{let s=r.header?JSON.parse(decodeURIComponent(r.header)):t.header,i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items,n=r.selectedItemId||t.selectedItemId,o=Ho(r),a=r.mode||"full",l=s||{label:"",path:"",image:{src:"",alt:"",width:0,height:0}},p=i?Vt(i,n):[],c=a==="full"?272:64,u=a==="full"?"fs":"c",h=a==="full"?"fs":"c",f=a==="full"?"lg":"sm",d=a==="full"?"md":"sm",y=a==="shrunk-lg"?48:40,v=a==="shrunk-lg"?28:20,g=a==="shrunk-lg"?"md":"sm",w=a==="full",x=a==="full",_=a==="full"?"fs":"c",A=a==="full"?"":`ah=${h}`,k=a==="full"?"f":y;return{containerAttrString:o,mode:a,header:l,items:p,sidebarWidth:c,headerAlign:u,itemAlign:h,headerPadding:f,itemPadding:d,itemHeight:y,iconSize:v,firstLetterSize:g,showLabels:w,showGroupLabels:x,itemContentAlign:_,itemAlignAttr:A,itemWidth:k,headerWidth:k,selectedItemId:n,ah:a==="shrunk-lg"||a==="shrunk-md"?"c":""}},qo=({state:e,props:t,attrs:r})=>r.header?JSON.parse(decodeURIComponent(r.header)):t.header,Yo=({state:e,props:t})=>(t.items?Vt(t.items):[]).find(s=>s.active),Go=({state:e,props:t,attrs:r},s)=>{let i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items;return(i?Vt(i):[]).find(o=>o.id===s)},Xo=e=>{};var es={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 jt={};N(jt,{handleBeforeMount:()=>Qo,handleOnUpdate:()=>Zo,handleValueChange:()=>ea});var Qo=e=>{let{store:t,attrs:r}=e;t.setValue(r.value??0)},Zo=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??0;i.setValue(o),n()}},ea=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,n=t._event,o=Number(n.detail.value);r.setValue(o),s(),i(new CustomEvent("slider-input-value-change",{detail:{value:o},bubbles:!0}))};var Dt={};N(Dt,{createInitialState:()=>ta,selectViewData:()=>ra,setValue:()=>sa});var ta=()=>Object.freeze({value:0}),ra=({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}),sa=(e,t)=>{e.value=t};var ts={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 Bt={};N(Bt,{handleBeforeMount:()=>ia,handleHeaderClick:()=>oa,handleRowClick:()=>na});var ia=e=>{},na=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("row-","")),o=s.data?.rows?.[n];o&&r(new CustomEvent("row-click",{detail:{rowIndex:n,rowData:o}}))},oa=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.currentTarget.id.replace("header-",""),a=r.selectSortInfo(),l="asc";a.column===o&&(a.direction==="asc"?l="desc":a.direction==="desc"&&(l=null)),l?r.setSortColumn({column:o,direction:l}):r.clearSort(),s(),i(new CustomEvent("header-click",{detail:{column:o,direction:l,sortInfo:l?{column:o,direction:l}:null}}))};var Mt={};N(Mt,{clearSort:()=>ya,createInitialState:()=>aa,selectSortInfo:()=>ha,selectState:()=>da,selectViewData:()=>ua,setSortColumn:()=>fa});var aa=()=>Object.freeze({sortColumn:null,sortDirection:null}),la=["id","class","style","slot"],pa=e=>Object.entries(e).filter(([t])=>!la.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),ca=(e,t)=>{let r=t.split("."),s=e;for(let i of r){if(s==null)return null;s=s[i]}return s},ua=({state:e,props:t,attrs:r})=>{let s=pa(r),i=t.data||{columns:[],rows:[]},n=i.rows.map((o,a)=>{let l=i.columns.map(p=>{let c=ca(o,p.key);return{key:p.key,value:c!=null?String(c):""}});return{index:a,cells:l}});return{containerAttrString:s,columns:i.columns||[],rows:n||[]}},da=({state:e})=>e,ha=({state:e})=>({column:e.sortColumn,direction:e.sortDirection}),fa=(e,{column:t,direction:r})=>{e.sortColumn=t,e.sortDirection=r},ya=e=>{e.sortColumn=null,e.sortDirection=null};var rs={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 Wt={};N(Wt,{handleClickItem:()=>ma});var ma=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var Ft={};N(Ft,{createInitialState:()=>ga,selectViewData:()=>wa});var ga=()=>Object.freeze({}),va=["id","class","style","slot"],ba=e=>Object.entries(e).filter(([t])=>!va.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),wa=({state:e,props:t,attrs:r})=>{let s=ba(r),i=t.items||[],n=r["selected-tab"],o=i.map(a=>({...a,isSelected:a.id===n,bgColor:a.id===n?"ac":"",borderColor:a.id===n?"":"tr",textColor:a.id===n?"":"mu-fg"}));return{containerAttrString:s,items:o,selectedTab:n}};var ss={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 is={};var Kt={};N(Kt,{createInitialState:()=>xa,selectViewData:()=>_a});var xa=()=>Object.freeze({}),_a=({attrs:e})=>({open:!!e.open,x:e.x||0,y:e.y||0,placement:e.placement||"top",content:e.content||""});var ns={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"}}},refs:{popover:null},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 Ut={};N(Ut,{handleAfterMount:()=>Ea,handleOnUpdate:()=>Aa});var Ea=async e=>{let{props:t,store:r,render:s,getRefIds:i}=e,{waveformData:n}=t;r.setWaveformData(n),s();let o=i().canvas?.elm;o&&os(n,o)},Aa=async(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e,{waveformData:o}=n;if(!o){console.log("waveform handleOnUpdate: no waveformData provided");return}r.setWaveformData(o),s();let a=i().canvas?.elm;a&&os(o,a)};async function os(e,t){let r=t.getContext("2d"),s=t.getBoundingClientRect(),i=s.width,n=s.height;t.width=i,t.height=n;let o=t.width,a=t.height;if(r.clearRect(0,0,o,a),r.fillStyle="#1a1a1a",r.fillRect(0,0,o,a),!e||!e.amplitudes)return;let l=e.amplitudes,p=a/2,c=r.createLinearGradient(0,0,0,a);c.addColorStop(0,"#404040"),c.addColorStop(.5,"#A1A1A1"),c.addColorStop(1,"#404040");let u=Math.max(1,o/l.length),h=.2;for(let f=0;f<l.length;f++){let y=l[f]/255*(a*.85),v=f*u,g=p-y/2;r.fillStyle=c,r.fillRect(v,g,Math.max(1,u*(1-h)),y)}r.strokeStyle="rgba(255, 255, 255, 0.1)",r.lineWidth=1,r.beginPath(),r.moveTo(0,p),r.lineTo(o,p),r.stroke(),r.shadowBlur=10,r.shadowColor="#2196F3"}var zt={};N(zt,{createInitialState:()=>ka,selectViewData:()=>$a,setWaveformData:()=>Sa});var ka=()=>Object.freeze({waveformData:null}),Sa=(e,t)=>{e.waveformData=t},$a=({state:e,attrs:t,props:r})=>({isLoading:r.isLoading,w:t.w||"250",h:t.h||"150",cur:t.cur,waveformData:r.waveformData});var as={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 hs=Symbol.for("immer-nothing"),ls=Symbol.for("immer-draftable"),Q=Symbol.for("immer-state");function ie(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var _e=Object.getPrototypeOf;function Ee(e){return!!e&&!!e[Q]}function he(e){return e?fs(e)||Array.isArray(e)||!!e[ls]||!!e.constructor?.[ls]||He(e)||Je(e):!1}var Ca=Object.prototype.constructor.toString();function fs(e){if(!e||typeof e!="object")return!1;let t=_e(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)===Ca}function Fe(e,t){ze(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,s)=>t(s,r,e))}function ze(e){let t=e[Q];return t?t.type_:Array.isArray(e)?1:He(e)?2:Je(e)?3:0}function qt(e,t){return ze(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ys(e,t,r){let s=ze(e);s===2?e.set(t,r):s===3?e.add(r):e[t]=r}function Oa(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function He(e){return e instanceof Map}function Je(e){return e instanceof Set}function de(e){return e.copy_||e.base_}function Yt(e,t){if(He(e))return new Map(e);if(Je(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=fs(e);if(t===!0||t==="class_only"&&!r){let s=Object.getOwnPropertyDescriptors(e);delete s[Q];let i=Reflect.ownKeys(s);for(let n=0;n<i.length;n++){let o=i[n],a=s[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(s[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(_e(e),s)}else{let s=_e(e);if(s!==null&&r)return{...e};let i=Object.create(s);return Object.assign(i,e)}}function er(e,t=!1){return qe(e)||Ee(e)||!he(e)||(ze(e)>1&&(e.set=e.add=e.clear=e.delete=Ia),Object.freeze(e),t&&Object.entries(e).forEach(([r,s])=>er(s,!0))),e}function Ia(){ie(2)}function qe(e){return Object.isFrozen(e)}var Ta={};function fe(e){let t=Ta[e];return t||ie(0,e),t}var Te;function ms(){return Te}function La(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ps(e,t){t&&(fe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Gt(e){Xt(e),e.drafts_.forEach(Ra),e.drafts_=null}function Xt(e){e===Te&&(Te=e.parent_)}function cs(e){return Te=La(Te,e)}function Ra(e){let t=e[Q];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function us(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[Q].modified_&&(Gt(t),ie(4)),he(e)&&(e=Ke(t,e),t.parent_||Ue(t,e)),t.patches_&&fe("Patches").generateReplacementPatches_(r[Q].base_,e,t.patches_,t.inversePatches_)):e=Ke(t,r,[]),Gt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hs?e:void 0}function Ke(e,t,r){if(qe(t))return t;let s=t[Q];if(!s)return Fe(t,(i,n)=>ds(e,s,t,i,n,r)),t;if(s.scope_!==e)return t;if(!s.modified_)return Ue(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;let i=s.copy_,n=i,o=!1;s.type_===3&&(n=new Set(i),i.clear(),o=!0),Fe(n,(a,l)=>ds(e,s,i,a,l,r,o)),Ue(e,i,!1),r&&e.patches_&&fe("Patches").generatePatches_(s,r,e.patches_,e.inversePatches_)}return s.copy_}function ds(e,t,r,s,i,n,o){if(Ee(i)){let a=n&&t&&t.type_!==3&&!qt(t.assigned_,s)?n.concat(s):void 0,l=Ke(e,i,a);if(ys(r,s,l),Ee(l))e.canAutoFreeze_=!1;else return}else o&&r.add(i);if(he(i)&&!qe(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ke(e,i),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,s)&&Ue(e,i)}}function Ue(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&er(t,r)}function Na(e,t){let r=Array.isArray(e),s={type_:r?1:0,scope_:t?t.scope_:ms(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=s,n=tr;r&&(i=[s],n=Le);let{revoke:o,proxy:a}=Proxy.revocable(i,n);return s.draft_=a,s.revoke_=o,a}var tr={get(e,t){if(t===Q)return e;let r=de(e);if(!qt(r,t))return Va(e,r,t);let s=r[t];return e.finalized_||!he(s)?s:s===Ht(e.base_,t)?(Jt(e),e.copy_[t]=Zt(s,e)):s},has(e,t){return t in de(e)},ownKeys(e){return Reflect.ownKeys(de(e))},set(e,t,r){let s=gs(de(e),t);if(s?.set)return s.set.call(e.draft_,r),!0;if(!e.modified_){let i=Ht(de(e),t),n=i?.[Q];if(n&&n.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Oa(r,i)&&(r!==void 0||qt(e.base_,t)))return!0;Jt(e),Qt(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 Ht(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Jt(e),Qt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=de(e),s=Reflect.getOwnPropertyDescriptor(r,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:r[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return _e(e.base_)},setPrototypeOf(){ie(12)}},Le={};Fe(tr,(e,t)=>{Le[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Le.deleteProperty=function(e,t){return Le.set.call(this,e,t,void 0)};Le.set=function(e,t,r){return tr.set.call(this,e[0],t,r,e[0])};function Ht(e,t){let r=e[Q];return(r?de(r):e)[t]}function Va(e,t,r){let s=gs(t,r);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}function gs(e,t){if(!(t in e))return;let r=_e(e);for(;r;){let s=Object.getOwnPropertyDescriptor(r,t);if(s)return s;r=_e(r)}}function Qt(e){e.modified_||(e.modified_=!0,e.parent_&&Qt(e.parent_))}function Jt(e){e.copy_||(e.copy_=Yt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Pa=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,s)=>{if(typeof t=="function"&&typeof r!="function"){let n=r;r=t;let o=this;return function(l=n,...p){return o.produce(l,c=>r.call(this,c,...p))}}typeof r!="function"&&ie(6),s!==void 0&&typeof s!="function"&&ie(7);let i;if(he(t)){let n=cs(this),o=Zt(t,void 0),a=!0;try{i=r(o),a=!1}finally{a?Gt(n):Xt(n)}return ps(n,s),us(i,n)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===hs&&(i=void 0),this.autoFreeze_&&er(i,!0),s){let n=[],o=[];fe("Patches").generateReplacementPatches_(t,i,n,o),s(n,o)}return i}else ie(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...a)=>this.produceWithPatches(o,l=>t(l,...a));let s,i;return[this.produce(t,r,(o,a)=>{s=o,i=a}),s,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){he(e)||ie(8),Ee(e)&&(e=ja(e));let t=cs(this),r=Zt(e,void 0);return r[Q].isManual_=!0,Xt(t),r}finishDraft(e,t){let r=e&&e[Q];(!r||!r.isManual_)&&ie(9);let{scope_:s}=r;return ps(s,t),us(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 i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));let s=fe("Patches").applyPatches_;return Ee(e)?s(e,t):this.produce(e,i=>s(i,t))}};function Zt(e,t){let r=He(e)?fe("MapSet").proxyMap_(e,t):Je(e)?fe("MapSet").proxySet_(e,t):Na(e,t);return(t?t.scope_:ms()).drafts_.push(r),r}function ja(e){return Ee(e)||ie(10,e),vs(e)}function vs(e){if(!he(e)||qe(e))return e;let t=e[Q],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Yt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Yt(e,!0);return Fe(r,(s,i)=>{ys(r,s,vs(i))}),t&&(t.finalized_=!1),r}var Z=new Pa,bs=Z.produce,lu=Z.produceWithPatches.bind(Z),pu=Z.setAutoFreeze.bind(Z),cu=Z.setUseStrictShallowCopy.bind(Z),uu=Z.applyPatches.bind(Z),du=Z.createDraft.bind(Z),hu=Z.finishDraft.bind(Z);var m={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},D={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Re={NOT:0};var I=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},G=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var rr=e=>{if(!e||e.trim()==="")throw new I("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new I(`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 I(`Incomplete comparison expression - missing right operand (got: '${e}')`)},ws=e=>{if(e.trim().endsWith(" in"))throw new I(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new I(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new I(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(i=>i.trim());for(let i of s)if(!i)throw new I(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new I(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var xs=(e,t,r=!1)=>{if(t===null)return new G(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new G(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new G(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new G(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},_s=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new G(`Unknown function '${e}' (${r})`)};var Da=(e,t,r={})=>{let s={},i={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},i=r.partials||{}):typeof r=="object"&&(s=r));let o=O(e,{functions:s,partials:i},t,{});return o===void 0?{}:o},O=(e,t,r,s)=>{let i=t.functions||t;if(e.var&&!e.type)return H(e.var,r,s);if(e.type===m.LITERAL)return e.value;if(e.type===m.VARIABLE)return H(e.path,r,s);if(e.type===m.INTERPOLATION)return Ma(e.parts,t,r,s);switch(e.type){case m.FUNCTION:return As(e,t,r,s);case m.BINARY:return ks(e,t,r,s);case m.UNARY:return Ss(e,t,r,s);case m.CONDITIONAL:return Fa(e,t,r,s);case m.LOOP:return Ja(e,t,r,s);case m.OBJECT:return Ya(e,t,r,s);case m.ARRAY:return Ga(e,t,r,s);case m.PARTIAL:return Xa(e,t,r,s);case m.PATH_REFERENCE:return Qa(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},Es=new Map,Ba=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();if(/^\d+$/.test(o))t.push({type:"index",value:parseInt(o,10)});else if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")){let a=o.slice(1,-1);t.push({type:"property",value:a})}else t.push({type:"property",value:o});r=""}s=!1}else r+=n}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=Es.get(e);if(!s){let n=[],o="",a=0;for(let l=0;l<e.length;l++){let p=e[l];p==="["?(a++,o+=p):p==="]"?(a--,o+=p):p==="."&&a===0?o&&(n.push(o),o=""):o+=p}o&&n.push(o),s=[];for(let l of n){let p=Ba(l.trim());s.push(...p)}Es.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Ma=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=O(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},As=(e,t,r,s)=>{let i=t.functions||t,n=i[e.name];if(!n)throw _s(e.name,i);let o=e.args.map(a=>O(a,t,r,s));return n(...o)},Ae=(e,t,r,s)=>{if(e.var&&!e.type)return H(e.var,r,s);switch(e.type){case m.VARIABLE:return H(e.path,r,s);case m.LITERAL:return e.value;case m.BINARY:return ks(e,t,r,s);case m.UNARY:return Ss(e,t,r,s);case m.FUNCTION:return As(e,t,r,s);default:return O(e,t,r,s)}},ks=(e,t,r,s)=>{if(e.op===D.AND||e.op===D.OR){let o=Ae(e.left,t,r,s),a=Ae(e.right,t,r,s);switch(e.op){case D.AND:return o&&a;case D.OR:return o||a}}let i=O(e.left,t,r,s),n=O(e.right,t,r,s);switch(e.op){case D.EQ:return i==n;case D.NEQ:return i!=n;case D.GT:return i>n;case D.LT:return i<n;case D.GTE:return i>=n;case D.LTE:return i<=n;case D.IN:return Array.isArray(n)?n.includes(i):!1;case D.ADD:if(typeof i!="number"||typeof n!="number")throw new G(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof n}`);return i+n;case D.SUBTRACT:if(typeof i!="number"||typeof n!="number")throw new G(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof n}`);return i-n;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ss=(e,t,r,s)=>{let i=e.op===Re.NOT?Ae(e.operand,t,r,s):O(e.operand,t,r,s);switch(e.op){case Re.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Wa=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===m.VARIABLE)if(H(i.path,r,s)){let o=e.bodies[0];if(o.type===m.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?O(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===m.LITERAL)a[p]=c.value;else if(c.type===m.VARIABLE)a[p]=H(c.path,r,s);else if(c.type===m.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===m.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=O(c,t,r,s)}return a}}else{let o=e.bodies[1];if(o.type===m.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?O(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===m.LITERAL)a[p]=c.value;else if(c.type===m.VARIABLE)a[p]=H(c.path,r,s);else if(c.type===m.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===m.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=O(c,t,r,s)}return a}}}return null},Fa=(e,t,r,s)=>{let i=Wa(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||Ae(o,t,r,s))return O(e.bodies[n],t,r,s)}return $s},Ka=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===m.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===m.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===m.OBJECT&&n.properties.length<=5){for(let l of n.properties)if(l.parsedKey)return null;let a=[];for(let l=0;l<t.length;l++){let p=t[l];if(p[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===m.LITERAL)c[h]=f.value;else if(f.type===m.VARIABLE){let d=f.path;if(d===s)c[h]=p;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=p[y]}else return null}else if(f.type===m.INTERPOLATION){let d=[],y=!0;for(let v of f.parts)if(typeof v=="string")d.push(v);else if(v.type===m.VARIABLE){let g=v.path;if(g===s)d.push(p!=null?String(p):"");else if(g.startsWith(s+".")){let w=g.substring(s.length+1),x=p[w];d.push(x!=null?String(x):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}a.push(c)}}return a}}}return null},Ua=(e,t)=>{let r=e.body,s=e.itemVar,i=Ka(e,t);if(i!==null)return i;if(r.type===m.OBJECT&&r.properties.length<=5){for(let a of r.properties)if(a.parsedKey)return null;let n=[],o=!0;for(let a of r.properties){let l=a.key,p=a.value;if(p.type===m.LITERAL)n.push({key:l,type:"literal",value:p.value});else if(p.type===m.VARIABLE){let c=p.path;if(c===s)n.push({key:l,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:l,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(p.type===m.INTERPOLATION&&p.parts.length===1){let c=p.parts[0];if(c.type===m.VARIABLE){let u=c.path;if(u===s)n.push({key:l,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:l,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let a=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let l=0;l<t.length;l++){let p=t[l];a[l]={id:p.id,title:p.title!=null?String(p.title):"",completed:p.completed}}else for(let l=0;l<t.length;l++){let p=t[l],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=p;else if(u.type==="prop")c[u.key]=p[u.prop];else if(u.type==="item_string")c[u.key]=p!=null?String(p):"";else if(u.type==="prop_string"){let h=p[u.prop];c[u.key]=h!=null?String(h):""}a[l]=c}return a}}return null},za=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===m.OBJECT&&o.fast!==!1){let a=e.itemVar,l=e.indexVar;for(let p=0;p<i.length;p++){let c=i[p],u={},h={...s,[a]:c,...l&&{[l]:p}};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__,[a]:`${f}[${p}]`,...l&&{[l]:p}};for(let d of o.properties){let y=d.parsedKey?O(d.parsedKey,t,r,h):d.key,v=d.value;if(v.type===m.LITERAL)u[y]=v.value;else if(v.type===m.VARIABLE){let g=v.path;if(g===a)u[y]=c;else if(g===l)u[y]=p;else if(g.startsWith(a+".")){let w=g.substring(a.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=H(g,r,{...s,[a]:c,...l&&{[l]:p}})}else u[y]=H(g,r,{...s,[a]:c,...l&&{[l]:p}})}else if(v.type===m.INTERPOLATION){let g=[];for(let w of v.parts)if(typeof w=="string")g.push(w);else if(w.type===m.VARIABLE){let x=w.path,_;if(x===a)_=c;else if(x===l)_=p;else if(x.startsWith(a+".")){let A=x.substring(a.length+1);!A.includes(".")&&!A.includes("[")?_=c[A]:_=H(x,r,{...s,[a]:c,...l&&{[l]:p}})}else _=H(x,r,{...s,[a]:c,...l&&{[l]:p}});g.push(_!=null?String(_):"")}else{let x={...s,[a]:c,...l&&{[l]:p}},_=O(w,t,r,x);g.push(_!=null?String(_):"")}u[y]=g.join("")}else{let g={...s,[a]:c,...l&&{[l]:p}};u[y]=O(v,t,r,g)}}n.push(u)}return n}return null},Ha=(e,t,r)=>{let s=e.body;if(s.type===m.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===m.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===m.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===m.OBJECT&&o.properties.length===2){let a=o.properties[0],l=o.properties[1];if(a.key==="id"&&a.value.type===m.VARIABLE&&a.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===m.CONDITIONAL){let p=[];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),p.push(h)}}return p}}}}return null},Ja=(e,t,r,s)=>{let i=O(e.iterable,t,r,s);if(!Array.isArray(i)){let p,c=!1;if(e.iterable.type===m.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===m.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===m.VARIABLE?f.path:f.type===m.FUNCTION?`${f.name}(...)`:"?").join(", ");p=`${e.iterable.name}(${h})`}else p=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${p}`;throw xs(u,i,c)}if(!e.indexVar){let p=Ha(e,i,e.itemVar);if(p!==null)return p}if(!e.indexVar){let p=Ua(e,i);if(p!==null)return p}let n=za(e,t,r,s,i);if(n!==null)return n;let o=[],a=e.iterable.path||"";if(s&&s.__paths__&&a){let p=a.split("."),c=p[0];c in s.__paths__&&(a=s.__paths__[c],p.length>1&&(a+="."+p.slice(1).join(".")))}let l=!1;e.body.type===m.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(p=>p.type===m.OBJECT&&p.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let p=0;p<i.length;p++){let c=e.indexVar?{...s,[e.itemVar]:i[p],[e.indexVar]:p}:{...s,[e.itemVar]:i[p]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${a}[${p}]`},e.indexVar&&(c.__paths__[e.indexVar]=p);let u=O(e.body,t,r,c);Array.isArray(u)&&u.length===1&&!l?o.push(u[0]):o.push(u)}return o},qa=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?O(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===m.OBJECT&&o.properties.length<=10&&!o.whenCondition){let a={},l={},p=!0;for(let c of o.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===m.LITERAL)l[u]=h.value;else if(h.type===m.VARIABLE)l[u]=H(h.path,r,s);else if(h.type===m.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===m.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{p=!1;break}if(!p)break;l[u]=f.join("")}else if(h.type===m.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,v=d.value;if(v.type===m.LITERAL)f[y]=v.value;else if(v.type===m.VARIABLE)f[y]=H(v.path,r,s);else if(v.type===m.INTERPOLATION){let g=[];for(let w of v.parts)if(typeof w=="string")g.push(w);else if(w.type===m.VARIABLE){let x=H(w.path,r,s);g.push(x!=null?String(x):"")}else{p=!1;break}if(!p)break;f[y]=g.join("")}else{p=!1;break}}if(!p)break;l[u]=f}else{p=!1;break}}if(p)return a[n]=l,a}}return null},Ya=(e,t,r,s)=>{let i=t.functions||t;if(e.whenCondition&&!Ae(e.whenCondition,i,r,s))return;let n=qa(e,t,r,s);if(n!==null)return n;if(e.fast){let p={};for(let c of e.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===m.LITERAL)p[u]=h.value;else if(h.type===m.VARIABLE)p[u]=H(h.path,r,s);else if(h.type===m.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===m.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=O(d,t,r,s);f.push(y!=null?String(y):"")}p[u]=f.join("")}else p[u]=O(h,t,r,s)}return p}let o={},a=null,l=!1;for(let p of e.properties)if(!p.key.startsWith("$if ")&&!p.key.match(/^\$if\s+\w+.*:?$/)&&!p.key.startsWith("$elif")&&!p.key.startsWith("$else")&&!p.key.startsWith("$for ")){l=!0;break}for(let p of e.properties)if(p.key.startsWith("$if ")||p.key.match(/^\$if\s+\w+.*:?$/)){let c=O(p.value,t,r,s);if(!l&&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(o,c)}else if(p.key.startsWith("$for ")){if(e.properties.length===1)return O(p.value,t,r,s)}else{let c=p.value;if(c&&c.type===m.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&&(o[p.key]=h)}else{let h=O(p.value,t,r,s);h!==void 0&&(o[p.key]=h)}}else{let u=p.parsedKey?O(p.parsedKey,t,r,s):p.key,h=O(p.value,t,r,s);h!==void 0&&(o[u]=h)}}return o},$s={},Ga=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===m.LOOP){let o=O(n,t,r,s);i.push(o)}else{let o=O(n,t,r,s);o!==$s&&o!==void 0&&i.push(o)}return i},Xa=(e,t,r,s)=>{let{name:i,data:n,whenCondition:o}=e,a=t.partials||{},l=t.functions||t;if(o&&!Ae(o,l,r,s))return;if(!a[i])throw new G(`Partial '${i}' is not defined`);let p=s._partialStack||[];if(p.includes(i))throw new G(`Circular partial reference detected: ${i}`);let c=a[i],u=r,h={...s,_partialStack:[...p,i]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(n){let f=O(n,t,r,s);u={...u,...f}}return O(c,t,u,h)},Qa=(e,t,r,s)=>{let{path:i}=e,n=i.split("."),o=n[0],a=n.slice(1);if(!s||!(o in s))throw new G(`Path reference '#{${i}}' refers to '${o}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(o in s.__paths__))throw new G(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let l=s.__paths__[o];if(typeof l=="number"){if(a.length>0)throw new G(`Path reference '#{${i}}' - cannot access properties on index variable '${o}'`);return String(l)}return a.length>0&&(l+="."+a.join(".")),l},Ne=Da;var Za=/\$\{([^}]*)\}/g,el=/#\{([^}]*)\}/g,Os=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,i]=r,n=tl(i,t);return{isFunction:!0,type:m.FUNCTION,name:s,args:n}},tl=(e,t={})=>e.trim()?rl(e).map(s=>sl(s.trim(),t)):[],rl=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let a=e[o],l=o>0?e[o-1]:"";!i&&(a==='"'||a==="'")?(i=!0,n=a,r+=a):i&&a===n&&l!=="\\"?(i=!1,n="",r+=a):!i&&a==="("?(s++,r+=a):!i&&a===")"?(s--,r+=a):!i&&a===","&&s===0?(t.push(r),r=""):r+=a}return r&&t.push(r),t},sl=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:m.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:m.LITERAL,value:parseFloat(e)};if(e==="true")return{type:m.LITERAL,value:!0};if(e==="false")return{type:m.LITERAL,value:!1};if(e==="null")return{type:m.LITERAL,value:null};let r=Os(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],n=-1,o=null;for(let{op:a,type:l}of i){let p=0;for(;p<s.length;){let c=ye(s.substring(p),a);if(c===-1)break;let u=p+c;u>n&&(n=u,o={op:a,type:l}),p=u+a.length}}if(n!==-1)try{return Y(s,t)}catch{return{type:m.VARIABLE,path:s}}return{type:m.VARIABLE,path:s}},Is=/^\w+\(.*\)$/,il=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,nl=e=>{if(!(!e||e.trim()===""||Is.test(e))&&il.test(e))throw e.includes("?")&&e.includes(":")?new I(`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 I(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new I(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Cs=e=>{let t=e.trim();if(Is.test(t))throw new I(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new I(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new I(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new I(`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 I(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:m.PATH_REFERENCE,path:t}},Ve=(e,t={})=>{let r=e.trim();nl(r);let s=Os(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:m.VARIABLE,path:r}},sr=(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,(p,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(p,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 i=[...r.matchAll(Za)],n=[...r.matchAll(el)],o=[...i.map(p=>({match:p,type:"variable"})),...n.map(p=>({match:p,type:"pathref"}))].sort((p,c)=>p.match.index-c.match.index);if(o.length===0){let p=r;for(let c=0;c<s.length;c++)p=p.replace(`__ESCAPED_${c}__`,s[c]);return{type:m.LITERAL,value:p}}if(o.length===1&&o[0].match[0]===r&&s.length===0){let{match:p,type:c}=o[0];try{return c==="variable"?Ve(p[1],t):Cs(p[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:m.LITERAL,value:r};throw u}}let a=[],l=0;for(let{match:p,type:c}of o){let[u,h]=p,f=p.index;if(f>l){let d=r.substring(l,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&a.push(d)}try{let d;c==="variable"?d=Ve(h.trim(),t):d=Cs(h.trim()),a.push(d)}catch(d){if(d.message==="Invalid array index syntax")a.push(u);else throw d}l=f+u.length}if(l<r.length){let p=r.substring(l);for(let c=0;c<s.length;c++)p=p.replace(`__ESCAPED_${c}__`,s[c]);p&&a.push(p)}return{type:m.INTERPOLATION,parts:a}};var ce=(e,t)=>typeof e=="string"?sr(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?ol(e,t):al(e,t):{type:m.LITERAL,value:e},ol=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let a=Object.keys(n);if(a.length===1&&a[0].startsWith("$for ")){let l=Ls(a[0],n[a[0]],t);r.push(l),s=!0;continue}}let o=ce(n,t);r.push(o),(o.type===m.FUNCTION||o.type===m.CONDITIONAL||o.type===m.LOOP||o.type===m.PARTIAL||o.type===m.OBJECT&&!o.fast||o.type===m.ARRAY&&!o.fast)&&(s=!0)}return{type:m.ARRAY,items:r,fast:!s}},al=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new I("$partial value must be a string");if(e.$partial.trim()==="")throw new I("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],p=[];for(let[g]of n)for(let w of l)if(g===w||g.startsWith(w+" ")||g.startsWith(w+"#")){p.push(w);break}if(p.length>0)throw new I(`Cannot use $partial with ${p.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[g,w]of Object.entries(h)){let x=g;(g.startsWith("\\$")||g.startsWith("$$"))&&(x=g.slice(1)),f[x]=w,d=!0}let y=null;if(d&&(y=ce(f,t),y.type===m.OBJECT)){let g=!1;for(let w of y.properties)if(w.value.type===m.VARIABLE||w.value.type===m.INTERPOLATION||w.value.type===m.FUNCTION||w.value.type===m.CONDITIONAL||w.value.type===m.LOOP||w.value.type===m.OBJECT&&!w.value.fast||w.value.type===m.ARRAY&&!w.value.fast){g=!0;break}g&&(y.fast=!1)}let v={type:m.PARTIAL,name:c,data:y};if(u!==void 0){let g;if(typeof u=="string"){if(u.trim()==="")throw new I("Empty condition expression after '$when'");g=Y(u,t)}else g={type:m.LITERAL,value:u};v.whenCondition=g}return v}for(let[l,p]of n)if(l==="$when"){if(i!==null)throw new I("Multiple '$when' directives on the same object are not allowed");if(p==null)throw new I("Missing condition expression after '$when'");let c=typeof p=="string"?p:JSON.stringify(p);if(c.trim()==="")throw new I("Empty condition expression after '$when'");i=Y(c,t),s=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new I("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[l,p]=n[o];if(l==="$when"){o++;continue}if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=ll(n,o,t);r.push({key:l,value:c.node}),s=!0,o=c.nextIndex}else if(l.startsWith("$for ")){let c=Ls(l,p,t);r.push({key:l,value:c}),s=!0,o++}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new I(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new I("Missing condition expression after '$if'");{let c=ce(p,t);(c.type===m.FUNCTION||c.type===m.CONDITIONAL||c.type===m.LOOP||c.type===m.PARTIAL||c.type===m.OBJECT&&!c.fast||c.type===m.ARRAY&&!c.fast)&&(s=!0);let u=sr(l,t),h={key:l,value:c};(u.type!==m.LITERAL||u.value!==l)&&(h.parsedKey=u),r.push(h),o++}}}let a={type:m.OBJECT,properties:r,fast:!s};return i&&(a.whenCondition=i),a},ll=(e,t,r={})=>{let s=[],i=[],n=t,[o,a]=e[n],l=null,p;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)l=u[1],p=u[2];else throw new I(`Invalid conditional syntax: ${o}`)}else p=o.substring(4),p.endsWith(":")&&(p=p.slice(0,-1).trim());rr(p);let c=Y(p,r);for(s.push(c),i.push(ce(a,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(l?u.startsWith(`$elif#${l} `)?(d=u.substring(`$elif#${l} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${l}`||u===`$else#${l}:`)&&(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{rr(d);let y=Y(d,r);s.push(y)}if(i.push(ce(h,r)),n++,d===null)break}else break}return{node:{type:m.CONDITIONAL,conditions:s,bodies:i,id:l},nextIndex:n}},Y=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let p=e.slice(1,-1),c=0,u=!0;for(let h=0;h<p.length;h++)if(p[h]==="("?c++:p[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return Y(p,t)}let r=ye(e,"||");if(r!==-1)return{type:m.BINARY,op:D.OR,left:Y(e.substring(0,r).trim(),t),right:Y(e.substring(r+2).trim(),t)};let s=ye(e,"&&");if(s!==-1)return{type:m.BINARY,op:D.AND,left:Y(e.substring(0,s).trim(),t),right:Y(e.substring(s+2).trim(),t)};let i=[{op:">=",type:D.GTE},{op:"<=",type:D.LTE},{op:"==",type:D.EQ},{op:"!=",type:D.NEQ},{op:">",type:D.GT},{op:"<",type:D.LT},{op:" in ",type:D.IN}];for(let{op:p,type:c}of i){let u=ye(e,p);if(u!==-1)return{type:m.BINARY,op:c,left:Y(e.substring(0,u).trim(),t),right:Y(e.substring(u+p.length).trim(),t)}}let n=-1,o=null,a=[{op:" + ",type:D.ADD},{op:" - ",type:D.SUBTRACT}];for(let{op:p,type:c}of a){let u=0;for(;u<e.length;){let h=ye(e.substring(u),p);if(h===-1)break;let f=u+h;f>n&&(n=f,o={op:p,type:c}),u=f+p.length}}if(n!==-1&&o)return{type:m.BINARY,op:o.type,left:Y(e.substring(0,n).trim(),t),right:Y(e.substring(n+o.op.length).trim(),t)};let l=[" * "," / "," % "];for(let p of l)if(ye(e,p)!==-1)throw new I(`Arithmetic operations are not allowed in conditionals: "${p}"`);return e.startsWith("!")?{type:m.UNARY,op:Re.NOT,operand:Y(e.substring(1).trim(),t)}:Ts(e,t)},ye=(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},pl=e=>{if(e=e.trim(),e==="true")return{type:m.LITERAL,value:!0};if(e==="false")return{type:m.LITERAL,value:!1};if(e==="null")return{type:m.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:m.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:m.LITERAL,value:""};if(e==="{}")return{type:m.LITERAL,value:{}};if(e==="[]")return{type:m.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:m.LITERAL,value:t}:{type:m.VARIABLE,path:e}},Ts=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return Ve(r,t);let i=pl(r);if(i.type===m.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:m.VARIABLE,path:r};try{return Ve(r,t)}catch(n){if(n.message&&n.message.includes("not supported"))return i;throw n}},Ls=(e,t,r)=>{let s=e.substring(5).trim();ws(s);let i=s.match(/^(.+?)\s+in\s+(.+)$/);if(!i)throw new I(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let n=i[1].trim(),o=i[2].trim(),a,l=null;if(n.includes(",")){let u=n.split(",").map(h=>h.trim());if(u.length!==2)throw new I(`Invalid loop variables: ${n}. Expected format: "item" or "item, index"`);a=u[0],l=u[1]}else a=n;let p=Ts(o,r),c=ce(t,r);return{type:m.LOOP,itemVar:a,indexVar:l,iterable:p,body:c}};var cl=(e,t={})=>{let{functions:r={}}=t;return ce(e,r)},Ye=cl;var ir={};N(ir,{now:()=>ul});var ul=()=>Date.now();var dl=(e,t,r={})=>{let{functions:s={},partials:i={}}=r,n={...ir,...s},o=Ye(e,{functions:n}),a={};for(let[l,p]of Object.entries(i))a[l]=Ye(p,{functions:n});return Ne(o,t,{functions:n,partials:a})},nr=dl;var Ge=e=>Array.isArray(e)?e.reduce((t,r)=>{if(Array.isArray(r))t.push(...Ge(r));else{if(r&&typeof r=="object"){let s=Object.entries(r);if(s.length>0){let[i,n]=s[0];Array.isArray(n)&&(r={[i]:Ge(n)})}}t.push(r)}return t},[]):e;var Rs=(e,t)=>{if(!t)return e;let r=[],s="",i=!1,n=null;for(let o=0;o<t.length;o++){let a=t[o];if(!i&&a===".")s&&(r.push(s),s="");else if(!i&&a==="[")s&&(r.push(s),s=""),i=!0;else if(i&&a==="]"){if(s){if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))r.push(s.slice(1,-1));else{let l=Number(s);r.push(isNaN(l)?s:l)}s=""}i=!1,n=null}else i&&(a==='"'||a==="'")&&(n?a===n&&(n=null):n=a),s+=a}return s&&r.push(s),r.reduce((o,a)=>o&&o[a],e)},Ns=({h:e,template:t,viewData:r,refs:s,handlers:i})=>{let n=Ne(t,r,{}),o=Ge(n),a=hl({h:e,items:o,refs:s,handlers:i,viewData:r});return e("div",{style:{display:"contents"}},a)},hl=({h:e,items:t,refs:r={},handlers:s={},viewData:i={}})=>{if(!Array.isArray(t))return console.error("Input to createVirtualDom must be an array."),[e("div",{},[])];function n(o,a=""){return o.map((l,p)=>{if(typeof l=="string"||typeof l=="number")return String(l);if(typeof l!="object"||l===null)return console.warn("Skipping invalid item in DOM structure:",l),null;let c=Object.entries(l);if(c.length===0)return null;let[u,h]=c[0];if(!isNaN(Number(u)))return Array.isArray(h)?n(h,`${a}.${u}`):typeof h=="object"&&h!==null&&Object.entries(h).length>0?n([h],`${a}.${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 v=f.split(/[.#]/)[0],g=v.includes("-"),w={},x={};if(d){let $=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g,E,j=new Set;for(;(E=$.exec(d))!==null;)if(j.add(E[1]),E[1].startsWith(".")){let te=E[1].substring(1),$e=E[4];x[te]=Rs(i,$e)}else if(E[1].startsWith("?")){let te=E[1].substring(1),$e=E[2]||E[3]||E[4],je;$e==="true"?je=!0:$e==="false"?je=!1:je=Rs(i,$e),je&&(w[te]="")}else w[E[1]]=E[2]||E[3]||E[4];let W=d,M=[],ee,Ze=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g;for(;(ee=Ze.exec(d))!==null;)M.push(ee[0]);M.forEach(te=>{W=W.replace(te," ")});let et=/\b(\S+?)(?=\s|$)/g,U;for(;(U=et.exec(W))!==null;){let te=U[1];!j.has(te)&&!te.startsWith(".")&&!te.includes("=")&&(w[te]="")}}let _=f.match(/#([^.#\s]+)/);_&&!Object.prototype.hasOwnProperty.call(w,"id")&&(w.id=_[1]);let A=null;w.id?A=w.id:g&&(A=v);let k=Object.create(null),C=null;if(g)C=v;else{let $=f.match(/\.([^.#]+)/g);$&&$.forEach(j=>{let W=j.substring(1);k[W]=!0});let E=f.match(/#([^.#\s]+)/);E&&(C=E[1])}let S;typeof h=="string"||typeof h=="number"?S=String(h):Array.isArray(h)?S=n(h,`${a}.${u}`):S=[],C&&!g&&(w.id=C);let R=Object.create(null);if(A&&r){let $=[];if(Object.keys(r).forEach(E=>{if(E.includes("*")){let j="^"+E.replace(/[.*+?^${}()|[\\\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$";try{new RegExp(j).test(A)&&$.push(E)}catch(W){console.warn(`[Parser] Invalid regex pattern created from refKey '${E}': ${j}`,W)}}else A===E&&$.push(E)}),$.length>0){$.sort((j,W)=>{let M=!j.includes("*"),ee=!W.includes("*");return M&&!ee?-1:!M&&ee?1:W.length-j.length});let E=$[0];if(r[E]&&r[E].eventListeners){let j=r[E].eventListeners;Object.entries(j).forEach(([W,M])=>{if(M.handler&&M.action)throw new Error("Each listener can have hanlder or action but not both");if(M.action){R[W]=ee=>{s.handleCallStoreAction({...M.payload,_event:ee,_action:M.action})};return}M.handler&&s[M.handler]?R[W]=ee=>{s[M.handler]({...M.payload,_event:ee})}:M.handler&&console.warn(`[Parser] Handler '${M.handler}' for refKey '${E}' (matching elementId '${A}') is referenced but not found in available handlers.`)})}}}let P={};if(A)P.key=A;else if(f){let $=a?`${a}.${p}`:String(p);if(P.key=`${f}-${$}`,Object.keys(x).length>0){let E=JSON.stringify(x).substring(0,50);P.key+=`-${E}`}}Object.keys(w).length>0&&(P.attrs=w),Object.keys(k).length>0&&(P.class=k),Object.keys(R).length>0&&(P.on=R),Object.keys(x).length>0&&(P.props=x),g&&(P.hook={update:($,E)=>{let j=$.data?.props||{},W=E.data?.props||{},M=$.data?.attrs||{},ee=E.data?.attrs||{},Ze=JSON.stringify(j)!==JSON.stringify(W),et=JSON.stringify(M)!==JSON.stringify(ee);if(Ze||et){let U=E.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 te={...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(te,{oldProps:j,newProps:W,oldAttrs:M,newAttrs:ee})}}))}}});try{return e(v,P,S)}catch($){return console.error("Error creating virtual node:",$,{tagName:v,snabbdomData:P,childrenOrText:S}),e("div",{},["Error creating element"])}}).filter(Boolean)}return n(t)};var fl=(e,t)=>{if(!t||typeof t!="object")return"";let r="",s=n=>Object.entries(n).map(([o,a])=>` ${o}: ${a};`).join(`
|
|
935
|
+
`))}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 i=this._popoverContainer.getBoundingClientRect(),{left:n,top:o}=this._calculatePosition(t,r,i.width,i.height,s);this._popoverContainer.style.left=`${n}px`,this._popoverContainer.style.top=`${o}px`,requestAnimationFrame(()=>{this.setAttribute("positioned","")})})}_calculatePosition(t,r,s,i,n){let a=t,l=r;switch(n){case"top":a=t-s/2,l=r-i-8;break;case"top-start":a=t,l=r-i-8;break;case"top-end":a=t-s,l=r-i-8;break;case"right":a=t+8,l=r-i/2;break;case"right-start":a=t+8,l=r;break;case"right-end":a=t+8,l=r-i;break;case"bottom":a=t-s/2,l=r+8;break;case"bottom-start":a=t,l=r+8;break;case"bottom-end":a=t-s,l=r+8;break;case"left":a=t-s-8,l=r-i/2;break;case"left-start":a=t-s-8,l=r;break;case"left-end":a=t-s-8,l=r-i;break}let p=8;return a=Math.max(p,Math.min(a,window.innerWidth-s-p)),l=Math.max(p,Math.min(l,window.innerHeight-i-p)),{left:a,top:l}}get popover(){return this._popoverContainer}},Ir=({render:e,html:t})=>ut;var dt={};N(dt,{handleClickItem:()=>ui});var ui=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var ht={};N(ht,{createInitialState:()=>di,selectViewData:()=>yi});var di=()=>Object.freeze({}),hi=["id","class","style","slot"],fi=e=>Object.entries(e).filter(([t])=>!hi.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),yi=({props:e,attrs:t})=>{let r=fi(t),s=e.items||[],i=e.separator||"breadcrumb-arrow",n=[];return s.forEach((o,a)=>{n.push(o),a<s.length-1&&n.push({isSeparator:!0})}),{containerAttrString:r,items:n,separator:i}};var Tr={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 ft={};N(ft,{handleClickMenuItem:()=>gi,handleClosePopover:()=>mi});var mi=(e,t)=>{let{dispatchEvent:r}=e;r(new CustomEvent("close"))},gi=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-","")),o=s.items[n];r(new CustomEvent("click-item",{detail:{index:n,item:o}}))};var yt={};N(yt,{createInitialState:()=>vi,selectViewData:()=>bi});var vi=()=>Object.freeze({}),bi=({props:e,attrs:t})=>({items:e.items||[],open:!!t.open,x:t.x,y:t.y,placement:t.placement});var Lr={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 mt={};N(mt,{handleActionClick:()=>Ei,handleAfterMount:()=>xi,handleBeforeMount:()=>wi,handleColorPickerChange:()=>Si,handleImageClick:()=>Oi,handleInputChange:()=>Ai,handleOnUpdate:()=>_i,handleSelectAddOption:()=>Ti,handleSelectChange:()=>ki,handleSliderChange:()=>$i,handleSliderInputChange:()=>Ci,handleTooltipMouseEnter:()=>Li,handleTooltipMouseLeave:()=>Ri,handleWaveformClick:()=>Ii});var Rr=({form:e,defaultValues:t={},refs:r})=>{let{fields:s=[]}=e;s.forEach(i=>{let n=r[`field-${i.name}`]?.elm;if(n){if(["inputText","colorPicker","slider","slider-input","popover-input"].includes(i.inputType)){let o=t[i.name];o==null?n.removeAttribute("value"):n.setAttribute("value",o)}if(i.inputType==="inputText"&&i.placeholder&&n.getAttribute("placeholder")!==i.placeholder&&(i.placeholder===void 0||i.placeholder===null?n.removeAttribute("placeholder"):n.setAttribute("placeholder",i.placeholder)),i.inputType==="select"&&i.placeholder&&n.placeholder!==i.placeholder&&(n.placeholder=i.placeholder),i.inputType==="select"){i.placeholder!==n.getAttribute("placeholder")&&(i.placeholder!==void 0?n.setAttribute("placeholder",i.placeholder):n.removeAttribute("placeholder"),n.render());let o=t[i.name];o!==n.selectedValue&&(n.selectedValue=o,n.render())}}})},wi=e=>{let{store:t,props:r}=e;t.setFormValues(r.defaultValues)},xi=e=>{let{props:t,getRefIds:r,render:s}=e,{form:i={},defaultValues:n}=t,o=r();Rr({form:i,defaultValues:n,refs:o}),s()},_i=(e,t)=>{let{oldAttrs:r,newAttrs:s,newProps:i}=t,{store:n,render:o,getRefIds:a}=e,{form:l={},defaultValues:p}=i;if(r?.key!==s?.key){let c=a();Rr({form:l,defaultValues:p,refs:c}),n.setFormValues(p),o();return}o()},Ce=(e,t,r,s)=>{s(new CustomEvent("form-change",{detail:{name:e,fieldValue:t,formValues:r}}))},Ei=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("action-","");s(new CustomEvent("action-click",{detail:{actionId:n,formValues:r.selectFormValues()}}))},Ai=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ce(o,n.detail.value,r.selectFormValues(),s))},ki=(e,t)=>{let{store:r,dispatchEvent:s,render:i,props:n}=e,o=t._event,a=o.currentTarget.id.replace("field-","");a&&(r.setFormFieldValue({name:a,value:o.detail.selectedValue,props:n}),Ce(a,o.detail.selectedValue,r.selectFormValues(),s),i())},Si=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ce(o,n.detail.value,r.selectFormValues(),s))},$i=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ce(o,n.detail.value,r.selectFormValues(),s))},Ci=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ce(o,n.detail.value,r.selectFormValues(),s))},Oi=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("image-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ii=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("waveform-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ti=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("field-","");s(new CustomEvent("action-click",{detail:{actionId:"select-options-add",name:n,formValues:r.selectFormValues()}}))},Li=(e,t)=>{let{store:r,render:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("tooltip-icon-",""),l=i.form.fields.find(p=>p.name===o);if(l&&l.tooltip){let p=n.currentTarget.getBoundingClientRect();r.showTooltip({x:p.left+p.width/2,y:p.top-8,content:l.tooltip.content}),s()}},Ri=e=>{let{store:t,render:r}=e;t.hideTooltip(),r()};var Et={};N(Et,{createInitialState:()=>ln,getFormFieldValue:()=>yn,hideTooltip:()=>bn,selectForm:()=>We,selectFormValues:()=>fn,selectState:()=>hn,selectViewData:()=>dn,setFormFieldValue:()=>gn,setFormValues:()=>mn,showTooltip:()=>vn});var b={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9},K={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8},Oe={NOT:0};var B=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},we=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var gt=e=>{if(!e||e.trim()==="")throw new B("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new B(`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 B(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Nr=e=>{if(e.trim().endsWith(" in"))throw new B(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new B(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new B(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(i=>i.trim());for(let i of s)if(!i)throw new B(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new B(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var Vr=(e,t)=>{if(t===null)return new we(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new we(`Cannot iterate over undefined value at '$for ${e}'`);let r=typeof t;return new we(`Cannot iterate over non-array value (got: ${r}) at '$for ${e}'`)},Pr=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new we(`Unknown function '${e}' (${r})`)};var Ni=(e,t,r={})=>{let s=L(e,r,t,{});return s===void 0?{}:s},L=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);if(e.type===b.LITERAL)return e.value;if(e.type===b.VARIABLE)return z(e.path,r,s);if(e.type===b.INTERPOLATION)return Pi(e.parts,t,r,s);switch(e.type){case b.FUNCTION:return Dr(e,t,r,s);case b.BINARY:return Br(e,t,r,s);case b.UNARY:return Mr(e,t,r,s);case b.CONDITIONAL:return Di(e,t,r,s);case b.LOOP:return Ki(e,t,r,s);case b.OBJECT:return zi(e,t,r,s);case b.ARRAY:return Hi(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},jr=new Map,Vi=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();/^\d+$/.test(o)?t.push({type:"index",value:parseInt(o,10)}):t.push({type:"property",value:`[${r}]`}),r=""}s=!1}else r+=n}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=jr.get(e);if(!s){let n=[],o="",a=0;for(let l=0;l<e.length;l++){let p=e[l];p==="["?(a++,o+=p):p==="]"?(a--,o+=p):p==="."&&a===0?o&&(n.push(o),o=""):o+=p}o&&n.push(o),s=[];for(let l of n){let p=Vi(l.trim());s.push(...p)}jr.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Pi=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=L(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},Dr=(e,t,r,s)=>{let i=t[e.name];if(!i)throw Pr(e.name,t);let n=e.args.map(o=>L(o,t,r,s));return i(...n)},Ie=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);switch(e.type){case b.VARIABLE:return z(e.path,r,s);case b.LITERAL:return e.value;case b.BINARY:return Br(e,t,r,s);case b.UNARY:return Mr(e,t,r,s);case b.FUNCTION:return Dr(e,t,r,s);default:return L(e,t,r,s)}},Br=(e,t,r,s)=>{if(e.op===K.AND||e.op===K.OR){let o=Ie(e.left,t,r,s),a=Ie(e.right,t,r,s);switch(e.op){case K.AND:return o&&a;case K.OR:return o||a}}let i=L(e.left,t,r,s),n=L(e.right,t,r,s);switch(e.op){case K.EQ:return i==n;case K.NEQ:return i!=n;case K.GT:return i>n;case K.LT:return i<n;case K.GTE:return i>=n;case K.LTE:return i<=n;case K.IN:return Array.isArray(n)?n.includes(i):!1;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Mr=(e,t,r,s)=>{let i=e.op===Oe.NOT?Ie(e.operand,t,r,s):L(e.operand,t,r,s);switch(e.op){case Oe.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},ji=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===b.VARIABLE)if(z(i.path,r,s)){let o=e.bodies[0];if(o.type===b.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?L(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===b.LITERAL)a[p]=c.value;else if(c.type===b.VARIABLE)a[p]=z(c.path,r,s);else if(c.type===b.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===b.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=L(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=L(c,t,r,s)}return a}}else{let o=e.bodies[1];if(o.type===b.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?L(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===b.LITERAL)a[p]=c.value;else if(c.type===b.VARIABLE)a[p]=z(c.path,r,s);else if(c.type===b.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===b.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=L(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=L(c,t,r,s)}return a}}}return null},Di=(e,t,r,s)=>{let i=ji(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||Ie(o,t,r,s))return L(e.bodies[n],t,r,s)}return Wr},Bi=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===b.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===b.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===b.OBJECT&&n.properties.length<=5){for(let l of n.properties)if(l.parsedKey)return null;let a=[];for(let l=0;l<t.length;l++){let p=t[l];if(p[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===b.LITERAL)c[h]=f.value;else if(f.type===b.VARIABLE){let d=f.path;if(d===s)c[h]=p;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=p[y]}else return null}else if(f.type===b.INTERPOLATION){let d=[],y=!0;for(let v of f.parts)if(typeof v=="string")d.push(v);else if(v.type===b.VARIABLE){let g=v.path;if(g===s)d.push(p!=null?String(p):"");else if(g.startsWith(s+".")){let w=g.substring(s.length+1),x=p[w];d.push(x!=null?String(x):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}a.push(c)}}return a}}}return null},Mi=(e,t)=>{let r=e.body,s=e.itemVar,i=Bi(e,t);if(i!==null)return i;if(r.type===b.OBJECT&&r.properties.length<=5){for(let a of r.properties)if(a.parsedKey)return null;let n=[],o=!0;for(let a of r.properties){let l=a.key,p=a.value;if(p.type===b.LITERAL)n.push({key:l,type:"literal",value:p.value});else if(p.type===b.VARIABLE){let c=p.path;if(c===s)n.push({key:l,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:l,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(p.type===b.INTERPOLATION&&p.parts.length===1){let c=p.parts[0];if(c.type===b.VARIABLE){let u=c.path;if(u===s)n.push({key:l,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:l,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let a=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let l=0;l<t.length;l++){let p=t[l];a[l]={id:p.id,title:p.title!=null?String(p.title):"",completed:p.completed}}else for(let l=0;l<t.length;l++){let p=t[l],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=p;else if(u.type==="prop")c[u.key]=p[u.prop];else if(u.type==="item_string")c[u.key]=p!=null?String(p):"";else if(u.type==="prop_string"){let h=p[u.prop];c[u.key]=h!=null?String(h):""}a[l]=c}return a}}return null},Wi=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===b.OBJECT&&o.fast!==!1){let a=e.itemVar,l=e.indexVar;for(let p=0;p<i.length;p++){let c=i[p],u={},h={...s,[a]:c,...l&&{[l]:p}};for(let f of o.properties){let d=f.parsedKey?L(f.parsedKey,t,r,h):f.key,y=f.value;if(y.type===b.LITERAL)u[d]=y.value;else if(y.type===b.VARIABLE){let v=y.path;if(v===a)u[d]=c;else if(v===l)u[d]=p;else if(v.startsWith(a+".")){let g=v.substring(a.length+1);!g.includes(".")&&!g.includes("[")?u[d]=c[g]:u[d]=z(v,r,{...s,[a]:c,...l&&{[l]:p}})}else u[d]=z(v,r,{...s,[a]:c,...l&&{[l]:p}})}else if(y.type===b.INTERPOLATION){let v=[];for(let g of y.parts)if(typeof g=="string")v.push(g);else if(g.type===b.VARIABLE){let w=g.path,x;if(w===a)x=c;else if(w===l)x=p;else if(w.startsWith(a+".")){let _=w.substring(a.length+1);!_.includes(".")&&!_.includes("[")?x=c[_]:x=z(w,r,{...s,[a]:c,...l&&{[l]:p}})}else x=z(w,r,{...s,[a]:c,...l&&{[l]:p}});v.push(x!=null?String(x):"")}else{let w={...s,[a]:c,...l&&{[l]:p}},x=L(g,t,r,w);v.push(x!=null?String(x):"")}u[d]=v.join("")}else{let v={...s,[a]:c,...l&&{[l]:p}};u[d]=L(y,t,r,v)}}n.push(u)}return n}return null},Fi=(e,t,r)=>{let s=e.body;if(s.type===b.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===b.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===b.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===b.OBJECT&&o.properties.length===2){let a=o.properties[0],l=o.properties[1];if(a.key==="id"&&a.value.type===b.VARIABLE&&a.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===b.CONDITIONAL){let p=[];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),p.push(h)}}return p}}}}return null},Ki=(e,t,r,s)=>{let i=L(e.iterable,t,r,s);if(!Array.isArray(i)){let a=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${e.iterable.path}`;throw Vr(a,i)}if(!e.indexVar){let a=Fi(e,i,e.itemVar);if(a!==null)return a}if(!e.indexVar){let a=Mi(e,i);if(a!==null)return a}let n=Wi(e,t,r,s,i);if(n!==null)return n;let o=[];for(let a=0;a<i.length;a++){let l=e.indexVar?{...s,[e.itemVar]:i[a],[e.indexVar]:a}:{...s,[e.itemVar]:i[a]},p=L(e.body,t,r,l);Array.isArray(p)&&p.length===1?o.push(p[0]):o.push(p)}return o},Ui=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?L(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===b.OBJECT&&o.properties.length<=10&&!o.whenCondition){let a={},l={},p=!0;for(let c of o.properties){let u=c.parsedKey?L(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===b.LITERAL)l[u]=h.value;else if(h.type===b.VARIABLE)l[u]=z(h.path,r,s);else if(h.type===b.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===b.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{p=!1;break}if(!p)break;l[u]=f.join("")}else if(h.type===b.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,v=d.value;if(v.type===b.LITERAL)f[y]=v.value;else if(v.type===b.VARIABLE)f[y]=z(v.path,r,s);else if(v.type===b.INTERPOLATION){let g=[];for(let w of v.parts)if(typeof w=="string")g.push(w);else if(w.type===b.VARIABLE){let x=z(w.path,r,s);g.push(x!=null?String(x):"")}else{p=!1;break}if(!p)break;f[y]=g.join("")}else{p=!1;break}}if(!p)break;l[u]=f}else{p=!1;break}}if(p)return a[n]=l,a}}return null},zi=(e,t,r,s)=>{if(e.whenCondition&&!Ie(e.whenCondition,t,r,s))return;let i=Ui(e,t,r,s);if(i!==null)return i;if(e.fast){let l={};for(let p of e.properties){let c=p.parsedKey?L(p.parsedKey,t,r,s):p.key,u=p.value;if(u.type===b.LITERAL)l[c]=u.value;else if(u.type===b.VARIABLE)l[c]=z(u.path,r,s);else if(u.type===b.INTERPOLATION){let h=[];for(let f of u.parts)if(typeof f=="string")h.push(f);else if(f.type===b.VARIABLE){let d=z(f.path,r,s);h.push(d!=null?String(d):"")}else{let d=L(f,t,r,s);h.push(d!=null?String(d):"")}l[c]=h.join("")}else l[c]=L(u,t,r,s)}return l}let n={},o=null,a=!1;for(let l of e.properties)if(!l.key.startsWith("$if ")&&!l.key.match(/^\$if\s+\w+.*:?$/)&&!l.key.startsWith("$elif")&&!l.key.startsWith("$else")&&!l.key.startsWith("$for ")){a=!0;break}for(let l of e.properties)if(l.key.startsWith("$if ")||l.key.match(/^\$if\s+\w+.*:?$/)){let p=L(l.value,t,r,s);if(!a&&p!==null&&p!==void 0)return Array.isArray(p)&&p.length===1?p[0]:p;typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.assign(n,p)}else if(!l.key.startsWith("$for ")){let p=l.value;if(p&&p.type===b.OBJECT&&p.properties){let c=p.properties.find(u=>u.key.startsWith("$for "));if(c){let u=L(c.value,t,r,s);u!==void 0&&(n[l.key]=u)}else{let u=L(l.value,t,r,s);u!==void 0&&(n[l.key]=u)}}else{let c=l.parsedKey?L(l.parsedKey,t,r,s):l.key,u=L(l.value,t,r,s);u!==void 0&&(n[c]=u)}}return n},Wr={},Hi=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===b.LOOP){let o=L(n,t,r,s);i.push(o)}else{let o=L(n,t,r,s);o!==Wr&&o!==void 0&&i.push(o)}return i},vt=Ni;var Ji=/\$\{([^}]*)\}/g,Kr=e=>{let t=e.match(/^(\w+)\((.*)\)$/);if(!t)return{isFunction:!1};let[,r,s]=t,i=qi(s);return{isFunction:!0,type:b.FUNCTION,name:r,args:i}},qi=e=>e.trim()?Yi(e).map(r=>Gi(r.trim())):[],Yi=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let a=e[o],l=o>0?e[o-1]:"";!i&&(a==='"'||a==="'")?(i=!0,n=a,r+=a):i&&a===n&&l!=="\\"?(i=!1,n="",r+=a):!i&&a==="("?(s++,r+=a):!i&&a===")"?(s--,r+=a):!i&&a===","&&s===0?(t.push(r),r=""):r+=a}return r&&t.push(r),t},Gi=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:b.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:b.LITERAL,value:parseFloat(e)};if(e==="true")return{type:b.LITERAL,value:!0};if(e==="false")return{type:b.LITERAL,value:!1};if(e==="null")return{type:b.LITERAL,value:null};let t=Kr(e);return t.isFunction?{type:t.type,name:t.name,args:t.args}:{type:b.VARIABLE,path:e}},Xi=/^\w+\(.*\)$/,Qi=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Zi=e=>{if(!(!e||e.trim()===""||Xi.test(e))&&Qi.test(e))throw e.includes("?")&&e.includes(":")?new B(`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 B(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new B(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Fr=(e,t={})=>{let r=e.trim();Zi(r);let s=Kr(r);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:b.VARIABLE,path:r}},bt=(e,t={})=>{let r=e,s=[];e.includes("\\${")&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(a,l)=>{let p=`__ESCAPED_${s.length}__`;return s.push(l),p}),r=r.replace(/\\DOUBLE_ESC/g,"\\"));let i=[...r.matchAll(Ji)];if(i.length===0){let a=r;for(let l=0;l<s.length;l++)a=a.replace(`__ESCAPED_${l}__`,s[l]);return{type:b.LITERAL,value:a}}if(i.length===1&&i[0][0]===r&&s.length===0)try{return Fr(i[0][1],t)}catch(a){if(a.message==="Invalid array index syntax")return{type:b.LITERAL,value:r};throw a}let n=[],o=0;for(let a of i){let[l,p]=a,c=a.index;if(c>o){let u=r.substring(o,c);for(let h=0;h<s.length;h++)u=u.replace(`__ESCAPED_${h}__`,s[h]);u&&n.push(u)}try{let u=Fr(p.trim(),t);n.push(u)}catch(u){if(u.message==="Invalid array index syntax")n.push(l);else throw u}o=c+l.length}if(o<r.length){let a=r.substring(o);for(let l=0;l<s.length;l++)a=a.replace(`__ESCAPED_${l}__`,s[l]);a&&n.push(a)}return{type:b.INTERPOLATION,parts:n}};var ue=(e,t)=>typeof e=="string"?bt(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?en(e,t):tn(e,t):{type:b.LITERAL,value:e},en=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let a=Object.keys(n);if(a.length===1&&a[0].startsWith("$for ")){let l=Ur(a[0],n[a[0]],t);r.push(l),s=!0;continue}}let o=ue(n,t);r.push(o),(o.type===b.FUNCTION||o.type===b.CONDITIONAL||o.type===b.LOOP||o.type===b.OBJECT&&!o.fast||o.type===b.ARRAY&&!o.fast)&&(s=!0)}return{type:b.ARRAY,items:r,fast:!s}},tn=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;for(let[l,p]of n)if(l==="$when"){if(i!==null)throw new B("Multiple '$when' directives on the same object are not allowed");if(p==null)throw new B("Missing condition expression after '$when'");let c=typeof p=="string"?p:JSON.stringify(p);if(c.trim()==="")throw new B("Empty condition expression after '$when'");i=se(c),s=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new B("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[l,p]=n[o];if(l==="$when"){o++;continue}if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=rn(n,o,t);r.push({key:l,value:c.node}),s=!0,o=c.nextIndex}else if(l.startsWith("$for ")){let c=Ur(l,p,t);r.push({key:l,value:c}),s=!0,o++}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new B(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new B("Missing condition expression after '$if'");{let c=ue(p,t);(c.type===b.FUNCTION||c.type===b.CONDITIONAL||c.type===b.LOOP||c.type===b.OBJECT&&!c.fast||c.type===b.ARRAY&&!c.fast)&&(s=!0);let u=bt(l,t),h={key:l,value:c};(u.type!==b.LITERAL||u.value!==l)&&(h.parsedKey=u),r.push(h),o++}}}let a={type:b.OBJECT,properties:r,fast:!s};return i&&(a.whenCondition=i),a},rn=(e,t,r={})=>{let s=[],i=[],n=t,[o,a]=e[n],l=null,p;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)l=u[1],p=u[2];else throw new B(`Invalid conditional syntax: ${o}`)}else p=o.substring(4),p.endsWith(":")&&(p=p.slice(0,-1).trim());gt(p);let c=se(p);for(s.push(c),i.push(ue(a,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(l?u.startsWith(`$elif#${l} `)?(d=u.substring(`$elif#${l} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${l}`||u===`$else#${l}:`)&&(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{gt(d);let y=se(d);s.push(y)}if(i.push(ue(h,r)),n++,d===null)break}else break}return{node:{type:b.CONDITIONAL,conditions:s,bodies:i,id:l},nextIndex:n}},se=e=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")"))return se(e.slice(1,-1));let t=Me(e,"||");if(t!==-1)return{type:b.BINARY,op:K.OR,left:se(e.substring(0,t).trim()),right:se(e.substring(t+2).trim())};let r=Me(e,"&&");if(r!==-1)return{type:b.BINARY,op:K.AND,left:se(e.substring(0,r).trim()),right:se(e.substring(r+2).trim())};let s=[{op:">=",type:K.GTE},{op:"<=",type:K.LTE},{op:"==",type:K.EQ},{op:"!=",type:K.NEQ},{op:">",type:K.GT},{op:"<",type:K.LT},{op:" in ",type:K.IN}];for(let{op:n,type:o}of s){let a=Me(e,n);if(a!==-1)return{type:b.BINARY,op:o,left:se(e.substring(0,a).trim()),right:se(e.substring(a+n.length).trim())}}let i=[" + "," - "," * "," / "," % "];for(let n of i)if(Me(e,n)!==-1)throw new B(`Arithmetic expressions not supported in conditionals - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`);return e.startsWith("!")?{type:b.UNARY,op:Oe.NOT,operand:se(e.substring(1).trim())}:sn(e)},Me=(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},sn=e=>{if(e=e.trim(),e==="true")return{type:b.LITERAL,value:!0};if(e==="false")return{type:b.LITERAL,value:!1};if(e==="null")return{type:b.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:b.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:b.LITERAL,value:""};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:b.LITERAL,value:t}:{type:b.VARIABLE,path:e}},Ur=(e,t,r)=>{let s=e.substring(5).trim();Nr(s);let i=s.match(/^(.+?)\s+in\s+(.+)$/);if(!i)throw new B(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let n=i[1].trim(),o=i[2].trim(),a,l=null;if(n.includes(",")){let u=n.split(",").map(h=>h.trim());if(u.length!==2)throw new B(`Invalid loop variables: ${n}. Expected format: "item" or "item, index"`);a=u[0],l=u[1]}else a=n;let p={type:b.VARIABLE,path:o},c=ue(t,r);return{type:b.LOOP,itemVar:a,indexVar:l,iterable:p,body:c}};var nn=(e,t={})=>{let{functions:r={}}=t;return ue(e,r)},wt=nn;var xt={};N(xt,{now:()=>on});var on=()=>Date.now();var an=(e,t,r={})=>{let{functions:s={}}=r,i={...xt,...s},n=wt(e,{functions:i});return vt(n,t,i)},_t=an;function zr(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}var ln=()=>Object.freeze({formValues:{},tooltipState:{open:!1,x:0,y:0,content:""}}),Hr=(e,t,r=void 0)=>{if(!t)return;let s=t.split(/[\[\].]/).filter(n=>n!==""),i=e;for(let n of s){if(i==null||!(n in i))return r;i=i[n]}return i},pn=(e,t,r)=>{let s=t.split(/[\[\].]/).filter(n=>n!=="");t.includes("[")&&t in e&&delete e[t];let i=e;for(let n=0;n<s.length-1;n++){let o=s[n];if(!(o in i)||typeof i[o]!="object"||i[o]===null){let a=s[n+1],l=/^\d+$/.test(a);i[o]=l?[]:{}}i=i[o]}return i[s[s.length-1]]=r,e},cn=["id","class","style","slot"],un=e=>Object.entries(e).filter(([t])=>!cn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),We=({props:e})=>{let{form:t={}}=e,{context:r}=e;return r?_t(t,r):t},dn=({state:e,props:t,attrs:r})=>{let s=un(r),i=We({state:e,props:t}),n=structuredClone(i.fields||[]);return n.forEach(o=>{let a=Hr(e.formValues,o.name);if(["read-only-text"].includes(o.inputType)&&(o.defaultValue=a),o.inputType==="image"){let l=o.src;o.imageSrc=l&&l.trim()?l:null,o.placeholderText=o.placeholder||"No Image"}if(o.inputType==="waveform"){let l=o.waveformData;o.waveformData=l||null,o.placeholderText=o.placeholder||"No Waveform"}}),{key:r?.key,containerAttrString:s,title:i?.title||"",description:i?.description||"",fields:n,actions:t?.form?.actions||{buttons:[]},formValues:e.formValues,tooltipState:e.tooltipState}},hn=({state:e})=>e,fn=({state:e,props:t})=>{let r=We({state:e,props:t});return zr(e.formValues,r.fields.map(s=>s.name))},yn=({state:e},t)=>Hr(e.formValues,t),mn=(e,t)=>{e.formValues=t||{}},gn=(e,{name:t,value:r,props:s})=>{pn(e.formValues,t,r);let i=We({state:e,props:s}),n=zr(e.formValues,i.fields.map(o=>o.name));e.formValues=n},vn=(e,{x:t,y:r,content:s})=>{e.tooltipState={open:!0,x:t,y:r,content:s}},bn=e=>{e.tooltipState={...e.tooltipState,open:!1}};var Jr={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:"rtgl-text s=lg",value:{type:1,path:"title"}}],fast:!0},{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:1,path:"description"}}],fast:!0}],fast:!0}}],fast:!0},{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:"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:"rtgl-text",value:{type:1,path:"field.label"}}],fast:!0},{type:8,properties:[{key:"$if field.tooltip",value:{type:6,conditions:[{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:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"field.description"}}],fast:!0}],fast:!1}}],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"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"inputText"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input#field-${field.name} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#field-",{type:1,path:"field.name"}," 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",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"]}}],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 At={};N(At,{closeAll:()=>Cn,handleCancel:()=>_n,handleConfirm:()=>xn,handleDialogClose:()=>wn,handleDropdownClose:()=>En,handleDropdownItemClick:()=>An,showAlert:()=>kn,showConfirm:()=>Sn,showDropdownMenu:()=>$n});var wn=(e,t)=>{let{store:r,render:s}=e;r.closeAll(),s()},xn=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!0)},_n=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!1)},En=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",null)},An=(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t._event,{index:o,item:a}=n.detail;r.closeAll(),s(),i.emit("event",{index:o,item:a})},kn=(e,t)=>{let{store:r,render:s}=e,i=t;r.selectIsOpen()&&(r.closeAll(),s()),r.setAlertConfig(i),s()},Sn=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setConfirmConfig(n),s(),new Promise(o=>{i.once("event",a=>{o(a)})})},$n=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setDropdownConfig(n),s(),new Promise(o=>{i.once("event",a=>{o(a)})})},Cn=e=>{let{store:t,render:r}=e;t.selectIsOpen()&&(t.closeAll(),r())};var kt={};N(kt,{closeAll:()=>Rn,createInitialState:()=>On,selectConfig:()=>Nn,selectDropdownConfig:()=>Vn,selectIsOpen:()=>jn,selectUiType:()=>Pn,selectViewData:()=>Dn,setAlertConfig:()=>In,setConfirmConfig:()=>Tn,setDropdownConfig:()=>Ln});var On=()=>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"}}),In=(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},Tn=(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},Ln=(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},Rn=e=>{e.isOpen=!1,e.uiType="dialog"},Nn=({state:e})=>e.config,Vn=({state:e})=>e.dropdownConfig,Pn=({state:e})=>e.uiType,jn=({state:e})=>e.isOpen,Dn=({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 qr={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 St={};N(St,{handleClickStart:()=>Bn});var Bn=(e,t)=>{let{dispatchEvent:r,store:s}=e,i=t._event;console.log("handle click start",s.selectPath()),r(new CustomEvent("clickStart",{detail:{path:s.selectPath()}}))};var $t={};N($t,{createInitialState:()=>Mn,selectPath:()=>Un,selectViewData:()=>Kn,setState:()=>zn});var Mn=()=>Object.freeze({}),Wn=["id","class","style","slot"],Fn=e=>Object.entries(e).filter(([t])=>!Wn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Kn=({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:Fn(r),start:s||{label:"",image:{src:"",width:32,height:32,alt:""}}}},Un=({props:e})=>e.start.path,zn=e=>{};var Yr={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 Ct={};N(Ct,{handleBeforeMount:()=>Jn});var Gr=(e,t,r)=>{let{store:s,render:i}=r,n,o=-1/0;if(e.forEach(a=>{let l=a.getBoundingClientRect();l.top<=t&&l.top>o&&(o=l.top,n=a.id)}),!n){let a=1/0;e.forEach(l=>{let p=l.getBoundingClientRect();p.top>t&&p.top<a&&(a=p.top,n=l.id)})}n&&n!==s.selectCurrentId()&&(s.setCurrentId(n),i())},Hn=(e,t,r,s)=>{let{store:i,render:n}=s,o=e.querySelectorAll("h1[id], h2[id], h3[id], h4[id], rtgl-text[id]"),a=Array.from(o),l=a.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}});i.setItems(l),Gr(a,r,s),n();let p=Gr.bind(void 0,a,r,s);return t.addEventListener("scroll",p,{passive:!0}),()=>{t.removeEventListener("scroll",p)}},Jn=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 i=parseInt(t["offset-top"]||"100",10),n=Hn(r,s,i,e);return()=>{n()}})};var Ot={};N(Ot,{createInitialState:()=>qn,selectCurrentId:()=>Xn,selectState:()=>Gn,selectViewData:()=>Yn,setContentContainer:()=>eo,setCurrentId:()=>Zn,setItems:()=>Qn});var qn=()=>Object.freeze({items:[],currentId:null,contentContainer:null}),Yn=({state:e})=>{let r=((s,i)=>{let n=new Set,o=s.findIndex(l=>l.id===i);if(o===-1)return n;let a=s[o].level;for(let l=o-1;l>=0;l--)if(s[l].level<a){let p=s[l].level;n.add(s[l].id);for(let c=l-1;c>=0;c--)s[c].level<p&&(n.add(s[c].id),p=s[c].level);break}return n})(e.items,e.currentId);return{items:e.items.map(s=>{let i={1:"0",2:"12px",3:"24px",4:"32px"},n=s.id===e.currentId,o=r.has(s.id),a=n||o;return{...s,c:a?"fg":"mu-fg",ml:i[s.level]||"",bc:a?"fg":"mu-fg"}}),currentId:e.currentId}},Gn=({state:e})=>e,Xn=({state:e})=>e.currentId,Qn=(e,t)=>{e.items=t},Zn=(e,t)=>{e.currentId=t},eo=(e,t)=>{e.contentContainer=t};var Xr={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 It={};N(It,{handleBeforeMount:()=>to,handleInputChange:()=>no,handleInputKeydown:()=>ao,handleOnUpdate:()=>ro,handlePopoverClose:()=>io,handleSubmitClick:()=>oo,handleTextClick:()=>so});var to=e=>{let{store:t,attrs:r}=e;r.value!==void 0&&t.setValue(r.value||"")},ro=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??"";i.setValue(o)}n()},so=(e,t)=>{let{store:r,render:s,getRefIds:i,attrs:n}=e,o=t._event,a=r.selectValue();r.setTempValue(a),r.openPopover({position:{x:o.currentTarget.getBoundingClientRect().left,y:o.currentTarget.getBoundingClientRect().bottom}});let{input:l}=i();l.elm.value=a,s(),n["auto-focus"]&&setTimeout(()=>{l.elm.focus()},50)},io=(e,t)=>{let{store:r,render:s}=e;r.closePopover(),s()},no=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.detail.value;r.setTempValue(o),i(new CustomEvent("temp-input-change",{detail:{value:o},bubbles:!0})),s()},oo=e=>{let{store:t,render:r,dispatchEvent:s,getRefIds:i}=e,{input:n}=i(),o=n.elm.value;t.setValue(o),t.closePopover(),s(new CustomEvent("input-change",{detail:{value:o},bubbles:!0})),r()},ao=(e,t)=>{let{store:r,render:s,dispatchEvent:i,getRefIds:n}=e,o=t._event;if(o.key==="Enter"){let{input:a}=n(),l=a.elm.value;r.closePopover(),i(new CustomEvent("input-change",{detail:{value:l},bubbles:!0})),s()}else o.key==="Escape"&&(r.closePopover(),s())};var Tt={};N(Tt,{closePopover:()=>ho,createInitialState:()=>lo,openPopover:()=>uo,selectValue:()=>yo,selectViewData:()=>po,setTempValue:()=>co,setValue:()=>fo});var lo=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},value:"",tempValue:""}),po=({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}},co=(e,t)=>{e.tempValue=t},uo=(e,t)=>{let{position:r}=t;e.position=r,e.isOpen=!0,e.hasUnsavedChanges=!1},ho=e=>{e.isOpen=!1,e.tempValue=""},fo=(e,t)=>{e.value=t},yo=({state:e})=>e.value;var Qr={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 Lt={};N(Lt,{handleAddOptionClick:()=>Ao,handleAddOptionMouseEnter:()=>ko,handleAddOptionMouseLeave:()=>So,handleBeforeMount:()=>mo,handleButtonClick:()=>vo,handleClearClick:()=>Eo,handleClickOptionsPopoverOverlay:()=>bo,handleOnUpdate:()=>go,handleOptionClick:()=>wo,handleOptionMouseEnter:()=>xo,handleOptionMouseLeave:()=>_o});var mo=e=>{let{store:t,props:r,render:s}=e;if(r.selectedValue!==null&&r.selectedValue!==void 0&&r.options){let i=r.options.find(n=>pe(n.value,r.selectedValue));i&&(t.updateSelectedValue({value:i?.value}),s())}},go=(e,t)=>{let{oldAttrs:r,newAttrs:s,oldProps:i,newProps:n}=t,{store:o,props:a,render:l}=e;if(r?.key!==s?.key&&s?.key){o.resetSelection();let p=n?.selectedValue||a?.selectedValue,c=n?.options||a?.options;if(p!=null&&c){let u=c.find(h=>pe(h.value,p));u&&o.updateSelectedValue({value:u.value})}l()}else i.selectedValue!==n.selectedValue&&(o.updateSelectedValue(n.selectedValue),l())},vo=(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e;t._event.stopPropagation();let a=i()["select-button"].elm,l=a.firstElementChild,p=l?l.getBoundingClientRect():a.getBoundingClientRect(),c=r.selectSelectedValue(),u=c!==null?c:n.selectedValue,h=null;u!=null&&n.options&&(h=n.options.findIndex(f=>pe(f.value,u)),h===-1&&(h=null)),r.openOptionsPopover({position:{y:p.bottom+12,x:p.left-24},selectedIndex:h}),s()},bo=e=>{let{store:t,render:r}=e;t.closeOptionsPopover(),r()},wo=(e,t)=>{let{render:r,dispatchEvent:s,props:i,store:n}=e,o=t._event;o.stopPropagation();let a=o.currentTarget.id.replace("option-",""),l=i.options[a];n.updateSelectedValue({value:l?.value}),i.onChange&&typeof i.onChange=="function"&&i.onChange(l.value),s(new CustomEvent("option-selected",{detail:{value:l.value,label:l.label},bubbles:!0})),s(new CustomEvent("select-change",{detail:{selectedValue:l.value},bubbles:!0})),r()},xo=(e,t)=>{let{store:r,render:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-",""));r.setHoveredOption(n),s()},_o=(e,t)=>{let{store:r,render:s}=e;r.clearHoveredOption(),s()},Eo=(e,t)=>{let{store:r,render:s,dispatchEvent:i,props:n}=e;t._event.stopPropagation(),r.clearSelectedValue(),n.onChange&&typeof n.onChange=="function"&&n.onChange(void 0),i(new CustomEvent("option-selected",{detail:{value:void 0,label:void 0},bubbles:!0})),i(new CustomEvent("select-change",{detail:{selectedValue:void 0},bubbles:!0})),s()},Ao=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,{_event:n}=t;n.stopPropagation(),r.closeOptionsPopover(),i(new CustomEvent("add-option-selected",{bubbles:!0})),s()},ko=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!0),s()},So=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!1),s()};var Rt={};N(Rt,{clearHoveredOption:()=>Do,clearSelectedValue:()=>Bo,closeOptionsPopover:()=>No,createInitialState:()=>Oo,openOptionsPopover:()=>Ro,resetSelection:()=>Po,selectSelectedValue:()=>Lo,selectState:()=>To,selectViewData:()=>Io,setHoveredAddOption:()=>Mo,setHoveredOption:()=>jo,updateSelectedValue:()=>Vo});var $o=["id","class","style","slot","placeholder","selectedValue","selected-value","onChange","on-change","options"],Co=e=>Object.entries(e||{}).filter(([t])=>!$o.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Oo=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},selectedValue:null,hoveredOptionId:null,hoveredAddOption:!1}),Io=({state:e,props:t,attrs:r})=>{let s=Co(r),i=e.selectedValue!==null?e.selectedValue:t.selectedValue,n=r.placeholder||"Select an option",o=!0;if(i!=null&&t.options){let l=t.options.find(p=>pe(p.value,i));l&&(n=l.label,o=!1)}let a=(t.options||[]).map((l,p)=>{let c=pe(l.value,i),u=e.hoveredOptionId===p;return{...l,isSelected:c,bgc:u?"ac":c?"mu":""}});return{containerAttrString:s,isOpen:e.isOpen,position:e.position,options:a,selectedValue:i,selectedLabel:n,selectedLabelColor:o?"mu-fg":"fg",hasValue:i!=null,showClear:!r["no-clear"]&&!t["no-clear"]&&i!=null,showAddOption:!!t.addOption,addOptionLabel:t.addOption?.label?`+ ${t.addOption.label}`:"+ Add",addOptionBgc:e.hoveredAddOption?"ac":""}},To=({state:e})=>e,Lo=({state:e})=>e.selectedValue,Ro=(e,t)=>{let{position:r,selectedIndex:s}=t;e.position=r,e.isOpen=!0,s!=null&&(e.hoveredOptionId=s)},No=e=>{e.isOpen=!1},Vo=(e,t)=>{e.selectedValue=t.value,e.isOpen=!1},Po=e=>{e.selectedValue=void 0},jo=(e,t)=>{e.hoveredOptionId=t},Do=e=>{e.hoveredOptionId=null},Bo=e=>{e.selectedValue=void 0},Mo=(e,t)=>{e.hoveredAddOption=t};var Zr={elementName:"rtgl-select",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{placeholder:{type:"string"}}},propsSchema:{type:"object",properties:{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}",value:{type:1,path:"selectedLabel"},parsedKey:{type:2,parts:["rtgl-text c=",{type:1,path:"selectedLabelColor"}]}}],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 Nt={};N(Nt,{handleHeaderClick:()=>Wo,handleItemClick:()=>Fo});var Wo=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event,n,o=r.selectHeader();i.currentTarget.id==="header-label"?n=o.labelPath:i.currentTarget.id==="header-image"?n=o.image.path:i.currentTarget.id==="header"&&(n=o.path),s(new CustomEvent("headerClick",{detail:{path:n},bubbles:!0,composed:!0}))},Fo=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("item-",""),o=r.selectItem(n);s(new CustomEvent("itemClick",{detail:{item:o},bubbles:!0,composed:!0}))};var Pt={};N(Pt,{createInitialState:()=>Ko,selectActiveItem:()=>qo,selectHeader:()=>Jo,selectItem:()=>Yo,selectViewData:()=>Ho,setState:()=>Go});var Ko=()=>Object.freeze({}),Uo=["id","class","style","slot"],zo=e=>Object.entries(e).filter(([t])=>!Uo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" ");function Vt(e,t=null){let r=[];for(let s of e){let i=s.id||s.href||s.path,n=t===i;if(r.push({id:i,title:s.title,href:s.href,type:s.type||"item",icon:s.icon,hrefAttr:s.href?`href=${s.href}`:"",isSelected:n,itemBgc:n?"ac":"bg",itemHoverBgc:n?"ac":"mu"}),s.items&&Array.isArray(s.items))for(let o of s.items){let a=o.id||o.href||o.path,l=t===a;r.push({id:a,title:o.title,href:o.href,type:o.type||"item",icon:o.icon,hrefAttr:o.href?`href=${o.href}`:"",isSelected:l,itemBgc:l?"ac":"bg",itemHoverBgc:l?"ac":"mu"})}}return r}var Ho=({state:e,props:t,attrs:r})=>{let s=r.header?JSON.parse(decodeURIComponent(r.header)):t.header,i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items,n=r.selectedItemId||t.selectedItemId,o=zo(r),a=r.mode||"full",l=s||{label:"",path:"",image:{src:"",alt:"",width:0,height:0}},p=i?Vt(i,n):[],c=a==="full"?272:64,u=a==="full"?"fs":"c",h=a==="full"?"fs":"c",f=a==="full"?"lg":"sm",d=a==="full"?"md":"sm",y=a==="shrunk-lg"?48:40,v=a==="shrunk-lg"?28:20,g=a==="shrunk-lg"?"md":"sm",w=a==="full",x=a==="full",_=a==="full"?"fs":"c",A=a==="full"?"":`ah=${h}`,k=a==="full"?"f":y;return{containerAttrString:o,mode:a,header:l,items:p,sidebarWidth:c,headerAlign:u,itemAlign:h,headerPadding:f,itemPadding:d,itemHeight:y,iconSize:v,firstLetterSize:g,showLabels:w,showGroupLabels:x,itemContentAlign:_,itemAlignAttr:A,itemWidth:k,headerWidth:k,selectedItemId:n,ah:a==="shrunk-lg"||a==="shrunk-md"?"c":""}},Jo=({state:e,props:t,attrs:r})=>r.header?JSON.parse(decodeURIComponent(r.header)):t.header,qo=({state:e,props:t})=>(t.items?Vt(t.items):[]).find(s=>s.active),Yo=({state:e,props:t,attrs:r},s)=>{let i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items;return(i?Vt(i):[]).find(o=>o.id===s)},Go=e=>{};var es={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 jt={};N(jt,{handleBeforeMount:()=>Xo,handleOnUpdate:()=>Qo,handleValueChange:()=>Zo});var Xo=e=>{let{store:t,attrs:r}=e;t.setValue(r.value??0)},Qo=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??0;i.setValue(o),n()}},Zo=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,n=t._event,o=Number(n.detail.value);r.setValue(o),s(),i(new CustomEvent("slider-input-value-change",{detail:{value:o},bubbles:!0}))};var Dt={};N(Dt,{createInitialState:()=>ea,selectViewData:()=>ta,setValue:()=>ra});var ea=()=>Object.freeze({value:0}),ta=({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}),ra=(e,t)=>{e.value=t};var ts={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 Bt={};N(Bt,{handleBeforeMount:()=>sa,handleHeaderClick:()=>na,handleRowClick:()=>ia});var sa=e=>{},ia=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("row-","")),o=s.data?.rows?.[n];o&&r(new CustomEvent("row-click",{detail:{rowIndex:n,rowData:o}}))},na=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.currentTarget.id.replace("header-",""),a=r.selectSortInfo(),l="asc";a.column===o&&(a.direction==="asc"?l="desc":a.direction==="desc"&&(l=null)),l?r.setSortColumn({column:o,direction:l}):r.clearSort(),s(),i(new CustomEvent("header-click",{detail:{column:o,direction:l,sortInfo:l?{column:o,direction:l}:null}}))};var Mt={};N(Mt,{clearSort:()=>fa,createInitialState:()=>oa,selectSortInfo:()=>da,selectState:()=>ua,selectViewData:()=>ca,setSortColumn:()=>ha});var oa=()=>Object.freeze({sortColumn:null,sortDirection:null}),aa=["id","class","style","slot"],la=e=>Object.entries(e).filter(([t])=>!aa.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),pa=(e,t)=>{let r=t.split("."),s=e;for(let i of r){if(s==null)return null;s=s[i]}return s},ca=({state:e,props:t,attrs:r})=>{let s=la(r),i=t.data||{columns:[],rows:[]},n=i.rows.map((o,a)=>{let l=i.columns.map(p=>{let c=pa(o,p.key);return{key:p.key,value:c!=null?String(c):""}});return{index:a,cells:l}});return{containerAttrString:s,columns:i.columns||[],rows:n||[]}},ua=({state:e})=>e,da=({state:e})=>({column:e.sortColumn,direction:e.sortDirection}),ha=(e,{column:t,direction:r})=>{e.sortColumn=t,e.sortDirection=r},fa=e=>{e.sortColumn=null,e.sortDirection=null};var rs={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 Wt={};N(Wt,{handleClickItem:()=>ya});var ya=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var Ft={};N(Ft,{createInitialState:()=>ma,selectViewData:()=>ba});var ma=()=>Object.freeze({}),ga=["id","class","style","slot"],va=e=>Object.entries(e).filter(([t])=>!ga.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),ba=({state:e,props:t,attrs:r})=>{let s=va(r),i=t.items||[],n=r["selected-tab"],o=i.map(a=>({...a,isSelected:a.id===n,bgColor:a.id===n?"ac":"",borderColor:a.id===n?"":"tr",textColor:a.id===n?"":"mu-fg"}));return{containerAttrString:s,items:o,selectedTab:n}};var ss={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 is={};var Kt={};N(Kt,{createInitialState:()=>wa,selectViewData:()=>xa});var wa=()=>Object.freeze({}),xa=({attrs:e})=>({open:!!e.open,x:e.x||0,y:e.y||0,placement:e.placement||"top",content:e.content||""});var ns={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 Ut={};N(Ut,{handleAfterMount:()=>_a,handleOnUpdate:()=>Ea});var _a=async e=>{let{props:t,store:r,render:s,getRefIds:i}=e,{waveformData:n}=t;r.setWaveformData(n),s();let o=i().canvas?.elm;o&&os(n,o)},Ea=async(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e,{waveformData:o}=n;if(!o){console.log("waveform handleOnUpdate: no waveformData provided");return}r.setWaveformData(o),s();let a=i().canvas?.elm;a&&os(o,a)};async function os(e,t){let r=t.getContext("2d"),s=t.getBoundingClientRect(),i=s.width,n=s.height;t.width=i,t.height=n;let o=t.width,a=t.height;if(r.clearRect(0,0,o,a),r.fillStyle="#1a1a1a",r.fillRect(0,0,o,a),!e||!e.amplitudes)return;let l=e.amplitudes,p=a/2,c=r.createLinearGradient(0,0,0,a);c.addColorStop(0,"#404040"),c.addColorStop(.5,"#A1A1A1"),c.addColorStop(1,"#404040");let u=Math.max(1,o/l.length),h=.2;for(let f=0;f<l.length;f++){let y=l[f]/255*(a*.85),v=f*u,g=p-y/2;r.fillStyle=c,r.fillRect(v,g,Math.max(1,u*(1-h)),y)}r.strokeStyle="rgba(255, 255, 255, 0.1)",r.lineWidth=1,r.beginPath(),r.moveTo(0,p),r.lineTo(o,p),r.stroke(),r.shadowBlur=10,r.shadowColor="#2196F3"}var zt={};N(zt,{createInitialState:()=>Aa,selectViewData:()=>Sa,setWaveformData:()=>ka});var Aa=()=>Object.freeze({waveformData:null}),ka=(e,t)=>{e.waveformData=t},Sa=({state:e,attrs:t,props:r})=>({isLoading:r.isLoading,w:t.w||"250",h:t.h||"150",cur:t.cur,waveformData:r.waveformData});var as={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 hs=Symbol.for("immer-nothing"),ls=Symbol.for("immer-draftable"),Q=Symbol.for("immer-state");function ie(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var xe=Object.getPrototypeOf;function _e(e){return!!e&&!!e[Q]}function he(e){return e?fs(e)||Array.isArray(e)||!!e[ls]||!!e.constructor?.[ls]||He(e)||Je(e):!1}var $a=Object.prototype.constructor.toString();function fs(e){if(!e||typeof e!="object")return!1;let t=xe(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)===$a}function Fe(e,t){ze(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,s)=>t(s,r,e))}function ze(e){let t=e[Q];return t?t.type_:Array.isArray(e)?1:He(e)?2:Je(e)?3:0}function qt(e,t){return ze(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ys(e,t,r){let s=ze(e);s===2?e.set(t,r):s===3?e.add(r):e[t]=r}function Ca(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function He(e){return e instanceof Map}function Je(e){return e instanceof Set}function de(e){return e.copy_||e.base_}function Yt(e,t){if(He(e))return new Map(e);if(Je(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=fs(e);if(t===!0||t==="class_only"&&!r){let s=Object.getOwnPropertyDescriptors(e);delete s[Q];let i=Reflect.ownKeys(s);for(let n=0;n<i.length;n++){let o=i[n],a=s[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(s[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(xe(e),s)}else{let s=xe(e);if(s!==null&&r)return{...e};let i=Object.create(s);return Object.assign(i,e)}}function er(e,t=!1){return qe(e)||_e(e)||!he(e)||(ze(e)>1&&(e.set=e.add=e.clear=e.delete=Oa),Object.freeze(e),t&&Object.entries(e).forEach(([r,s])=>er(s,!0))),e}function Oa(){ie(2)}function qe(e){return Object.isFrozen(e)}var Ia={};function fe(e){let t=Ia[e];return t||ie(0,e),t}var Te;function ms(){return Te}function Ta(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ps(e,t){t&&(fe("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Gt(e){Xt(e),e.drafts_.forEach(La),e.drafts_=null}function Xt(e){e===Te&&(Te=e.parent_)}function cs(e){return Te=Ta(Te,e)}function La(e){let t=e[Q];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function us(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[Q].modified_&&(Gt(t),ie(4)),he(e)&&(e=Ke(t,e),t.parent_||Ue(t,e)),t.patches_&&fe("Patches").generateReplacementPatches_(r[Q].base_,e,t.patches_,t.inversePatches_)):e=Ke(t,r,[]),Gt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hs?e:void 0}function Ke(e,t,r){if(qe(t))return t;let s=t[Q];if(!s)return Fe(t,(i,n)=>ds(e,s,t,i,n,r)),t;if(s.scope_!==e)return t;if(!s.modified_)return Ue(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;let i=s.copy_,n=i,o=!1;s.type_===3&&(n=new Set(i),i.clear(),o=!0),Fe(n,(a,l)=>ds(e,s,i,a,l,r,o)),Ue(e,i,!1),r&&e.patches_&&fe("Patches").generatePatches_(s,r,e.patches_,e.inversePatches_)}return s.copy_}function ds(e,t,r,s,i,n,o){if(_e(i)){let a=n&&t&&t.type_!==3&&!qt(t.assigned_,s)?n.concat(s):void 0,l=Ke(e,i,a);if(ys(r,s,l),_e(l))e.canAutoFreeze_=!1;else return}else o&&r.add(i);if(he(i)&&!qe(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ke(e,i),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,s)&&Ue(e,i)}}function Ue(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&er(t,r)}function Ra(e,t){let r=Array.isArray(e),s={type_:r?1:0,scope_:t?t.scope_:ms(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=s,n=tr;r&&(i=[s],n=Le);let{revoke:o,proxy:a}=Proxy.revocable(i,n);return s.draft_=a,s.revoke_=o,a}var tr={get(e,t){if(t===Q)return e;let r=de(e);if(!qt(r,t))return Na(e,r,t);let s=r[t];return e.finalized_||!he(s)?s:s===Ht(e.base_,t)?(Jt(e),e.copy_[t]=Zt(s,e)):s},has(e,t){return t in de(e)},ownKeys(e){return Reflect.ownKeys(de(e))},set(e,t,r){let s=gs(de(e),t);if(s?.set)return s.set.call(e.draft_,r),!0;if(!e.modified_){let i=Ht(de(e),t),n=i?.[Q];if(n&&n.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Ca(r,i)&&(r!==void 0||qt(e.base_,t)))return!0;Jt(e),Qt(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 Ht(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Jt(e),Qt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=de(e),s=Reflect.getOwnPropertyDescriptor(r,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:r[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return xe(e.base_)},setPrototypeOf(){ie(12)}},Le={};Fe(tr,(e,t)=>{Le[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Le.deleteProperty=function(e,t){return Le.set.call(this,e,t,void 0)};Le.set=function(e,t,r){return tr.set.call(this,e[0],t,r,e[0])};function Ht(e,t){let r=e[Q];return(r?de(r):e)[t]}function Na(e,t,r){let s=gs(t,r);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}function gs(e,t){if(!(t in e))return;let r=xe(e);for(;r;){let s=Object.getOwnPropertyDescriptor(r,t);if(s)return s;r=xe(r)}}function Qt(e){e.modified_||(e.modified_=!0,e.parent_&&Qt(e.parent_))}function Jt(e){e.copy_||(e.copy_=Yt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Va=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,s)=>{if(typeof t=="function"&&typeof r!="function"){let n=r;r=t;let o=this;return function(l=n,...p){return o.produce(l,c=>r.call(this,c,...p))}}typeof r!="function"&&ie(6),s!==void 0&&typeof s!="function"&&ie(7);let i;if(he(t)){let n=cs(this),o=Zt(t,void 0),a=!0;try{i=r(o),a=!1}finally{a?Gt(n):Xt(n)}return ps(n,s),us(i,n)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===hs&&(i=void 0),this.autoFreeze_&&er(i,!0),s){let n=[],o=[];fe("Patches").generateReplacementPatches_(t,i,n,o),s(n,o)}return i}else ie(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...a)=>this.produceWithPatches(o,l=>t(l,...a));let s,i;return[this.produce(t,r,(o,a)=>{s=o,i=a}),s,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){he(e)||ie(8),_e(e)&&(e=Pa(e));let t=cs(this),r=Zt(e,void 0);return r[Q].isManual_=!0,Xt(t),r}finishDraft(e,t){let r=e&&e[Q];(!r||!r.isManual_)&&ie(9);let{scope_:s}=r;return ps(s,t),us(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 i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));let s=fe("Patches").applyPatches_;return _e(e)?s(e,t):this.produce(e,i=>s(i,t))}};function Zt(e,t){let r=He(e)?fe("MapSet").proxyMap_(e,t):Je(e)?fe("MapSet").proxySet_(e,t):Ra(e,t);return(t?t.scope_:ms()).drafts_.push(r),r}function Pa(e){return _e(e)||ie(10,e),vs(e)}function vs(e){if(!he(e)||qe(e))return e;let t=e[Q],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Yt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Yt(e,!0);return Fe(r,(s,i)=>{ys(r,s,vs(i))}),t&&(t.finalized_=!1),r}var Z=new Va,bs=Z.produce,au=Z.produceWithPatches.bind(Z),lu=Z.setAutoFreeze.bind(Z),pu=Z.setUseStrictShallowCopy.bind(Z),cu=Z.applyPatches.bind(Z),uu=Z.createDraft.bind(Z),du=Z.finishDraft.bind(Z);var m={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},D={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Re={NOT:0};var I=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},G=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var rr=e=>{if(!e||e.trim()==="")throw new I("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new I(`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 I(`Incomplete comparison expression - missing right operand (got: '${e}')`)},ws=e=>{if(e.trim().endsWith(" in"))throw new I(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new I(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new I(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(i=>i.trim());for(let i of s)if(!i)throw new I(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new I(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var xs=(e,t,r=!1)=>{if(t===null)return new G(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new G(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new G(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new G(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},_s=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new G(`Unknown function '${e}' (${r})`)};var ja=(e,t,r={})=>{let s={},i={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},i=r.partials||{}):typeof r=="object"&&(s=r));let o=O(e,{functions:s,partials:i},t,{});return o===void 0?{}:o},O=(e,t,r,s)=>{let i=t.functions||t;if(e.var&&!e.type)return H(e.var,r,s);if(e.type===m.LITERAL)return e.value;if(e.type===m.VARIABLE)return H(e.path,r,s);if(e.type===m.INTERPOLATION)return Ba(e.parts,t,r,s);switch(e.type){case m.FUNCTION:return As(e,t,r,s);case m.BINARY:return ks(e,t,r,s);case m.UNARY:return Ss(e,t,r,s);case m.CONDITIONAL:return Wa(e,t,r,s);case m.LOOP:return Ha(e,t,r,s);case m.OBJECT:return qa(e,t,r,s);case m.ARRAY:return Ya(e,t,r,s);case m.PARTIAL:return Ga(e,t,r,s);case m.PATH_REFERENCE:return Xa(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},Es=new Map,Da=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();if(/^\d+$/.test(o))t.push({type:"index",value:parseInt(o,10)});else if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")){let a=o.slice(1,-1);t.push({type:"property",value:a})}else t.push({type:"property",value:o});r=""}s=!1}else r+=n}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=Es.get(e);if(!s){let n=[],o="",a=0;for(let l=0;l<e.length;l++){let p=e[l];p==="["?(a++,o+=p):p==="]"?(a--,o+=p):p==="."&&a===0?o&&(n.push(o),o=""):o+=p}o&&n.push(o),s=[];for(let l of n){let p=Da(l.trim());s.push(...p)}Es.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Ba=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=O(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},As=(e,t,r,s)=>{let i=t.functions||t,n=i[e.name];if(!n)throw _s(e.name,i);let o=e.args.map(a=>O(a,t,r,s));return n(...o)},Ee=(e,t,r,s)=>{if(e.var&&!e.type)return H(e.var,r,s);switch(e.type){case m.VARIABLE:return H(e.path,r,s);case m.LITERAL:return e.value;case m.BINARY:return ks(e,t,r,s);case m.UNARY:return Ss(e,t,r,s);case m.FUNCTION:return As(e,t,r,s);default:return O(e,t,r,s)}},ks=(e,t,r,s)=>{if(e.op===D.AND||e.op===D.OR){let o=Ee(e.left,t,r,s),a=Ee(e.right,t,r,s);switch(e.op){case D.AND:return o&&a;case D.OR:return o||a}}let i=O(e.left,t,r,s),n=O(e.right,t,r,s);switch(e.op){case D.EQ:return i==n;case D.NEQ:return i!=n;case D.GT:return i>n;case D.LT:return i<n;case D.GTE:return i>=n;case D.LTE:return i<=n;case D.IN:return Array.isArray(n)?n.includes(i):!1;case D.ADD:if(typeof i!="number"||typeof n!="number")throw new G(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof n}`);return i+n;case D.SUBTRACT:if(typeof i!="number"||typeof n!="number")throw new G(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof n}`);return i-n;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ss=(e,t,r,s)=>{let i=e.op===Re.NOT?Ee(e.operand,t,r,s):O(e.operand,t,r,s);switch(e.op){case Re.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Ma=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===m.VARIABLE)if(H(i.path,r,s)){let o=e.bodies[0];if(o.type===m.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?O(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===m.LITERAL)a[p]=c.value;else if(c.type===m.VARIABLE)a[p]=H(c.path,r,s);else if(c.type===m.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===m.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=O(c,t,r,s)}return a}}else{let o=e.bodies[1];if(o.type===m.OBJECT&&o.properties.length<=5){let a={};for(let l of o.properties){let p=l.parsedKey?O(l.parsedKey,t,r,s):l.key,c=l.value;if(c.type===m.LITERAL)a[p]=c.value;else if(c.type===m.VARIABLE)a[p]=H(c.path,r,s);else if(c.type===m.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===m.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=O(h,t,r,s);u.push(f!=null?String(f):"")}a[p]=u.join("")}else a[p]=O(c,t,r,s)}return a}}}return null},Wa=(e,t,r,s)=>{let i=Ma(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||Ee(o,t,r,s))return O(e.bodies[n],t,r,s)}return $s},Fa=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===m.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===m.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===m.OBJECT&&n.properties.length<=5){for(let l of n.properties)if(l.parsedKey)return null;let a=[];for(let l=0;l<t.length;l++){let p=t[l];if(p[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===m.LITERAL)c[h]=f.value;else if(f.type===m.VARIABLE){let d=f.path;if(d===s)c[h]=p;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=p[y]}else return null}else if(f.type===m.INTERPOLATION){let d=[],y=!0;for(let v of f.parts)if(typeof v=="string")d.push(v);else if(v.type===m.VARIABLE){let g=v.path;if(g===s)d.push(p!=null?String(p):"");else if(g.startsWith(s+".")){let w=g.substring(s.length+1),x=p[w];d.push(x!=null?String(x):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}a.push(c)}}return a}}}return null},Ka=(e,t)=>{let r=e.body,s=e.itemVar,i=Fa(e,t);if(i!==null)return i;if(r.type===m.OBJECT&&r.properties.length<=5){for(let a of r.properties)if(a.parsedKey)return null;let n=[],o=!0;for(let a of r.properties){let l=a.key,p=a.value;if(p.type===m.LITERAL)n.push({key:l,type:"literal",value:p.value});else if(p.type===m.VARIABLE){let c=p.path;if(c===s)n.push({key:l,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:l,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(p.type===m.INTERPOLATION&&p.parts.length===1){let c=p.parts[0];if(c.type===m.VARIABLE){let u=c.path;if(u===s)n.push({key:l,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:l,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let a=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let l=0;l<t.length;l++){let p=t[l];a[l]={id:p.id,title:p.title!=null?String(p.title):"",completed:p.completed}}else for(let l=0;l<t.length;l++){let p=t[l],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=p;else if(u.type==="prop")c[u.key]=p[u.prop];else if(u.type==="item_string")c[u.key]=p!=null?String(p):"";else if(u.type==="prop_string"){let h=p[u.prop];c[u.key]=h!=null?String(h):""}a[l]=c}return a}}return null},Ua=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===m.OBJECT&&o.fast!==!1){let a=e.itemVar,l=e.indexVar;for(let p=0;p<i.length;p++){let c=i[p],u={},h={...s,[a]:c,...l&&{[l]:p}};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__,[a]:`${f}[${p}]`,...l&&{[l]:p}};for(let d of o.properties){let y=d.parsedKey?O(d.parsedKey,t,r,h):d.key,v=d.value;if(v.type===m.LITERAL)u[y]=v.value;else if(v.type===m.VARIABLE){let g=v.path;if(g===a)u[y]=c;else if(g===l)u[y]=p;else if(g.startsWith(a+".")){let w=g.substring(a.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=H(g,r,{...s,[a]:c,...l&&{[l]:p}})}else u[y]=H(g,r,{...s,[a]:c,...l&&{[l]:p}})}else if(v.type===m.INTERPOLATION){let g=[];for(let w of v.parts)if(typeof w=="string")g.push(w);else if(w.type===m.VARIABLE){let x=w.path,_;if(x===a)_=c;else if(x===l)_=p;else if(x.startsWith(a+".")){let A=x.substring(a.length+1);!A.includes(".")&&!A.includes("[")?_=c[A]:_=H(x,r,{...s,[a]:c,...l&&{[l]:p}})}else _=H(x,r,{...s,[a]:c,...l&&{[l]:p}});g.push(_!=null?String(_):"")}else{let x={...s,[a]:c,...l&&{[l]:p}},_=O(w,t,r,x);g.push(_!=null?String(_):"")}u[y]=g.join("")}else{let g={...s,[a]:c,...l&&{[l]:p}};u[y]=O(v,t,r,g)}}n.push(u)}return n}return null},za=(e,t,r)=>{let s=e.body;if(s.type===m.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===m.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===m.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===m.OBJECT&&o.properties.length===2){let a=o.properties[0],l=o.properties[1];if(a.key==="id"&&a.value.type===m.VARIABLE&&a.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===m.CONDITIONAL){let p=[];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),p.push(h)}}return p}}}}return null},Ha=(e,t,r,s)=>{let i=O(e.iterable,t,r,s);if(!Array.isArray(i)){let p,c=!1;if(e.iterable.type===m.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===m.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===m.VARIABLE?f.path:f.type===m.FUNCTION?`${f.name}(...)`:"?").join(", ");p=`${e.iterable.name}(${h})`}else p=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${p}`;throw xs(u,i,c)}if(!e.indexVar){let p=za(e,i,e.itemVar);if(p!==null)return p}if(!e.indexVar){let p=Ka(e,i);if(p!==null)return p}let n=Ua(e,t,r,s,i);if(n!==null)return n;let o=[],a=e.iterable.path||"";if(s&&s.__paths__&&a){let p=a.split("."),c=p[0];c in s.__paths__&&(a=s.__paths__[c],p.length>1&&(a+="."+p.slice(1).join(".")))}let l=!1;e.body.type===m.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(p=>p.type===m.OBJECT&&p.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let p=0;p<i.length;p++){let c=e.indexVar?{...s,[e.itemVar]:i[p],[e.indexVar]:p}:{...s,[e.itemVar]:i[p]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${a}[${p}]`},e.indexVar&&(c.__paths__[e.indexVar]=p);let u=O(e.body,t,r,c);Array.isArray(u)&&u.length===1&&!l?o.push(u[0]):o.push(u)}return o},Ja=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?O(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===m.OBJECT&&o.properties.length<=10&&!o.whenCondition){let a={},l={},p=!0;for(let c of o.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===m.LITERAL)l[u]=h.value;else if(h.type===m.VARIABLE)l[u]=H(h.path,r,s);else if(h.type===m.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===m.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{p=!1;break}if(!p)break;l[u]=f.join("")}else if(h.type===m.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,v=d.value;if(v.type===m.LITERAL)f[y]=v.value;else if(v.type===m.VARIABLE)f[y]=H(v.path,r,s);else if(v.type===m.INTERPOLATION){let g=[];for(let w of v.parts)if(typeof w=="string")g.push(w);else if(w.type===m.VARIABLE){let x=H(w.path,r,s);g.push(x!=null?String(x):"")}else{p=!1;break}if(!p)break;f[y]=g.join("")}else{p=!1;break}}if(!p)break;l[u]=f}else{p=!1;break}}if(p)return a[n]=l,a}}return null},qa=(e,t,r,s)=>{let i=t.functions||t;if(e.whenCondition&&!Ee(e.whenCondition,i,r,s))return;let n=Ja(e,t,r,s);if(n!==null)return n;if(e.fast){let p={};for(let c of e.properties){let u=c.parsedKey?O(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===m.LITERAL)p[u]=h.value;else if(h.type===m.VARIABLE)p[u]=H(h.path,r,s);else if(h.type===m.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===m.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=O(d,t,r,s);f.push(y!=null?String(y):"")}p[u]=f.join("")}else p[u]=O(h,t,r,s)}return p}let o={},a=null,l=!1;for(let p of e.properties)if(!p.key.startsWith("$if ")&&!p.key.match(/^\$if\s+\w+.*:?$/)&&!p.key.startsWith("$elif")&&!p.key.startsWith("$else")&&!p.key.startsWith("$for ")){l=!0;break}for(let p of e.properties)if(p.key.startsWith("$if ")||p.key.match(/^\$if\s+\w+.*:?$/)){let c=O(p.value,t,r,s);if(!l&&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(o,c)}else if(p.key.startsWith("$for ")){if(e.properties.length===1)return O(p.value,t,r,s)}else{let c=p.value;if(c&&c.type===m.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&&(o[p.key]=h)}else{let h=O(p.value,t,r,s);h!==void 0&&(o[p.key]=h)}}else{let u=p.parsedKey?O(p.parsedKey,t,r,s):p.key,h=O(p.value,t,r,s);h!==void 0&&(o[u]=h)}}return o},$s={},Ya=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===m.LOOP){let o=O(n,t,r,s);i.push(o)}else{let o=O(n,t,r,s);o!==$s&&o!==void 0&&i.push(o)}return i},Ga=(e,t,r,s)=>{let{name:i,data:n,whenCondition:o}=e,a=t.partials||{},l=t.functions||t;if(o&&!Ee(o,l,r,s))return;if(!a[i])throw new G(`Partial '${i}' is not defined`);let p=s._partialStack||[];if(p.includes(i))throw new G(`Circular partial reference detected: ${i}`);let c=a[i],u=r,h={...s,_partialStack:[...p,i]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(n){let f=O(n,t,r,s);u={...u,...f}}return O(c,t,u,h)},Xa=(e,t,r,s)=>{let{path:i}=e,n=i.split("."),o=n[0],a=n.slice(1);if(!s||!(o in s))throw new G(`Path reference '#{${i}}' refers to '${o}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(o in s.__paths__))throw new G(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let l=s.__paths__[o];if(typeof l=="number"){if(a.length>0)throw new G(`Path reference '#{${i}}' - cannot access properties on index variable '${o}'`);return String(l)}return a.length>0&&(l+="."+a.join(".")),l},Ne=ja;var Qa=/\$\{([^}]*)\}/g,Za=/#\{([^}]*)\}/g,Os=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,i]=r,n=el(i,t);return{isFunction:!0,type:m.FUNCTION,name:s,args:n}},el=(e,t={})=>e.trim()?tl(e).map(s=>rl(s.trim(),t)):[],tl=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let a=e[o],l=o>0?e[o-1]:"";!i&&(a==='"'||a==="'")?(i=!0,n=a,r+=a):i&&a===n&&l!=="\\"?(i=!1,n="",r+=a):!i&&a==="("?(s++,r+=a):!i&&a===")"?(s--,r+=a):!i&&a===","&&s===0?(t.push(r),r=""):r+=a}return r&&t.push(r),t},rl=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:m.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:m.LITERAL,value:parseFloat(e)};if(e==="true")return{type:m.LITERAL,value:!0};if(e==="false")return{type:m.LITERAL,value:!1};if(e==="null")return{type:m.LITERAL,value:null};let r=Os(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],n=-1,o=null;for(let{op:a,type:l}of i){let p=0;for(;p<s.length;){let c=ye(s.substring(p),a);if(c===-1)break;let u=p+c;u>n&&(n=u,o={op:a,type:l}),p=u+a.length}}if(n!==-1)try{return Y(s,t)}catch{return{type:m.VARIABLE,path:s}}return{type:m.VARIABLE,path:s}},Is=/^\w+\(.*\)$/,sl=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,il=e=>{if(!(!e||e.trim()===""||Is.test(e))&&sl.test(e))throw e.includes("?")&&e.includes(":")?new I(`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 I(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new I(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Cs=e=>{let t=e.trim();if(Is.test(t))throw new I(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new I(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new I(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new I(`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 I(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:m.PATH_REFERENCE,path:t}},Ve=(e,t={})=>{let r=e.trim();il(r);let s=Os(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:m.VARIABLE,path:r}},sr=(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,(p,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(p,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 i=[...r.matchAll(Qa)],n=[...r.matchAll(Za)],o=[...i.map(p=>({match:p,type:"variable"})),...n.map(p=>({match:p,type:"pathref"}))].sort((p,c)=>p.match.index-c.match.index);if(o.length===0){let p=r;for(let c=0;c<s.length;c++)p=p.replace(`__ESCAPED_${c}__`,s[c]);return{type:m.LITERAL,value:p}}if(o.length===1&&o[0].match[0]===r&&s.length===0){let{match:p,type:c}=o[0];try{return c==="variable"?Ve(p[1],t):Cs(p[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:m.LITERAL,value:r};throw u}}let a=[],l=0;for(let{match:p,type:c}of o){let[u,h]=p,f=p.index;if(f>l){let d=r.substring(l,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&a.push(d)}try{let d;c==="variable"?d=Ve(h.trim(),t):d=Cs(h.trim()),a.push(d)}catch(d){if(d.message==="Invalid array index syntax")a.push(u);else throw d}l=f+u.length}if(l<r.length){let p=r.substring(l);for(let c=0;c<s.length;c++)p=p.replace(`__ESCAPED_${c}__`,s[c]);p&&a.push(p)}return{type:m.INTERPOLATION,parts:a}};var ce=(e,t)=>typeof e=="string"?sr(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?nl(e,t):ol(e,t):{type:m.LITERAL,value:e},nl=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let a=Object.keys(n);if(a.length===1&&a[0].startsWith("$for ")){let l=Ls(a[0],n[a[0]],t);r.push(l),s=!0;continue}}let o=ce(n,t);r.push(o),(o.type===m.FUNCTION||o.type===m.CONDITIONAL||o.type===m.LOOP||o.type===m.PARTIAL||o.type===m.OBJECT&&!o.fast||o.type===m.ARRAY&&!o.fast)&&(s=!0)}return{type:m.ARRAY,items:r,fast:!s}},ol=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new I("$partial value must be a string");if(e.$partial.trim()==="")throw new I("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],p=[];for(let[g]of n)for(let w of l)if(g===w||g.startsWith(w+" ")||g.startsWith(w+"#")){p.push(w);break}if(p.length>0)throw new I(`Cannot use $partial with ${p.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[g,w]of Object.entries(h)){let x=g;(g.startsWith("\\$")||g.startsWith("$$"))&&(x=g.slice(1)),f[x]=w,d=!0}let y=null;if(d&&(y=ce(f,t),y.type===m.OBJECT)){let g=!1;for(let w of y.properties)if(w.value.type===m.VARIABLE||w.value.type===m.INTERPOLATION||w.value.type===m.FUNCTION||w.value.type===m.CONDITIONAL||w.value.type===m.LOOP||w.value.type===m.OBJECT&&!w.value.fast||w.value.type===m.ARRAY&&!w.value.fast){g=!0;break}g&&(y.fast=!1)}let v={type:m.PARTIAL,name:c,data:y};if(u!==void 0){let g;if(typeof u=="string"){if(u.trim()==="")throw new I("Empty condition expression after '$when'");g=Y(u,t)}else g={type:m.LITERAL,value:u};v.whenCondition=g}return v}for(let[l,p]of n)if(l==="$when"){if(i!==null)throw new I("Multiple '$when' directives on the same object are not allowed");if(p==null)throw new I("Missing condition expression after '$when'");let c=typeof p=="string"?p:JSON.stringify(p);if(c.trim()==="")throw new I("Empty condition expression after '$when'");i=Y(c,t),s=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new I("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[l,p]=n[o];if(l==="$when"){o++;continue}if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=al(n,o,t);r.push({key:l,value:c.node}),s=!0,o=c.nextIndex}else if(l.startsWith("$for ")){let c=Ls(l,p,t);r.push({key:l,value:c}),s=!0,o++}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new I(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new I("Missing condition expression after '$if'");{let c=ce(p,t);(c.type===m.FUNCTION||c.type===m.CONDITIONAL||c.type===m.LOOP||c.type===m.PARTIAL||c.type===m.OBJECT&&!c.fast||c.type===m.ARRAY&&!c.fast)&&(s=!0);let u=sr(l,t),h={key:l,value:c};(u.type!==m.LITERAL||u.value!==l)&&(h.parsedKey=u),r.push(h),o++}}}let a={type:m.OBJECT,properties:r,fast:!s};return i&&(a.whenCondition=i),a},al=(e,t,r={})=>{let s=[],i=[],n=t,[o,a]=e[n],l=null,p;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)l=u[1],p=u[2];else throw new I(`Invalid conditional syntax: ${o}`)}else p=o.substring(4),p.endsWith(":")&&(p=p.slice(0,-1).trim());rr(p);let c=Y(p,r);for(s.push(c),i.push(ce(a,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(l?u.startsWith(`$elif#${l} `)?(d=u.substring(`$elif#${l} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${l}`||u===`$else#${l}:`)&&(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{rr(d);let y=Y(d,r);s.push(y)}if(i.push(ce(h,r)),n++,d===null)break}else break}return{node:{type:m.CONDITIONAL,conditions:s,bodies:i,id:l},nextIndex:n}},Y=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let p=e.slice(1,-1),c=0,u=!0;for(let h=0;h<p.length;h++)if(p[h]==="("?c++:p[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return Y(p,t)}let r=ye(e,"||");if(r!==-1)return{type:m.BINARY,op:D.OR,left:Y(e.substring(0,r).trim(),t),right:Y(e.substring(r+2).trim(),t)};let s=ye(e,"&&");if(s!==-1)return{type:m.BINARY,op:D.AND,left:Y(e.substring(0,s).trim(),t),right:Y(e.substring(s+2).trim(),t)};let i=[{op:">=",type:D.GTE},{op:"<=",type:D.LTE},{op:"==",type:D.EQ},{op:"!=",type:D.NEQ},{op:">",type:D.GT},{op:"<",type:D.LT},{op:" in ",type:D.IN}];for(let{op:p,type:c}of i){let u=ye(e,p);if(u!==-1)return{type:m.BINARY,op:c,left:Y(e.substring(0,u).trim(),t),right:Y(e.substring(u+p.length).trim(),t)}}let n=-1,o=null,a=[{op:" + ",type:D.ADD},{op:" - ",type:D.SUBTRACT}];for(let{op:p,type:c}of a){let u=0;for(;u<e.length;){let h=ye(e.substring(u),p);if(h===-1)break;let f=u+h;f>n&&(n=f,o={op:p,type:c}),u=f+p.length}}if(n!==-1&&o)return{type:m.BINARY,op:o.type,left:Y(e.substring(0,n).trim(),t),right:Y(e.substring(n+o.op.length).trim(),t)};let l=[" * "," / "," % "];for(let p of l)if(ye(e,p)!==-1)throw new I(`Arithmetic operations are not allowed in conditionals: "${p}"`);return e.startsWith("!")?{type:m.UNARY,op:Re.NOT,operand:Y(e.substring(1).trim(),t)}:Ts(e,t)},ye=(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},ll=e=>{if(e=e.trim(),e==="true")return{type:m.LITERAL,value:!0};if(e==="false")return{type:m.LITERAL,value:!1};if(e==="null")return{type:m.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:m.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:m.LITERAL,value:""};if(e==="{}")return{type:m.LITERAL,value:{}};if(e==="[]")return{type:m.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:m.LITERAL,value:t}:{type:m.VARIABLE,path:e}},Ts=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return Ve(r,t);let i=ll(r);if(i.type===m.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:m.VARIABLE,path:r};try{return Ve(r,t)}catch(n){if(n.message&&n.message.includes("not supported"))return i;throw n}},Ls=(e,t,r)=>{let s=e.substring(5).trim();ws(s);let i=s.match(/^(.+?)\s+in\s+(.+)$/);if(!i)throw new I(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let n=i[1].trim(),o=i[2].trim(),a,l=null;if(n.includes(",")){let u=n.split(",").map(h=>h.trim());if(u.length!==2)throw new I(`Invalid loop variables: ${n}. Expected format: "item" or "item, index"`);a=u[0],l=u[1]}else a=n;let p=Ts(o,r),c=ce(t,r);return{type:m.LOOP,itemVar:a,indexVar:l,iterable:p,body:c}};var pl=(e,t={})=>{let{functions:r={}}=t;return ce(e,r)},Ye=pl;var ir={};N(ir,{now:()=>cl});var cl=()=>Date.now();var ul=(e,t,r={})=>{let{functions:s={},partials:i={}}=r,n={...ir,...s},o=Ye(e,{functions:n}),a={};for(let[l,p]of Object.entries(i))a[l]=Ye(p,{functions:n});return Ne(o,t,{functions:n,partials:a})},nr=ul;var Ge=e=>Array.isArray(e)?e.reduce((t,r)=>{if(Array.isArray(r))t.push(...Ge(r));else{if(r&&typeof r=="object"){let s=Object.entries(r);if(s.length>0){let[i,n]=s[0];Array.isArray(n)&&(r={[i]:Ge(n)})}}t.push(r)}return t},[]):e;var Rs=(e,t)=>{if(!t)return e;let r=[],s="",i=!1,n=null;for(let o=0;o<t.length;o++){let a=t[o];if(!i&&a===".")s&&(r.push(s),s="");else if(!i&&a==="[")s&&(r.push(s),s=""),i=!0;else if(i&&a==="]"){if(s){if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))r.push(s.slice(1,-1));else{let l=Number(s);r.push(isNaN(l)?s:l)}s=""}i=!1,n=null}else i&&(a==='"'||a==="'")&&(n?a===n&&(n=null):n=a),s+=a}return s&&r.push(s),r.reduce((o,a)=>o&&o[a],e)},Ns=({h:e,template:t,viewData:r,refs:s,handlers:i})=>{let n=Ne(t,r,{}),o=Ge(n),a=dl({h:e,items:o,refs:s,handlers:i,viewData:r});return e("div",{style:{display:"contents"}},a)},dl=({h:e,items:t,refs:r={},handlers:s={},viewData:i={}})=>{if(!Array.isArray(t))return console.error("Input to createVirtualDom must be an array."),[e("div",{},[])];function n(o,a=""){return o.map((l,p)=>{if(typeof l=="string"||typeof l=="number")return String(l);if(typeof l!="object"||l===null)return console.warn("Skipping invalid item in DOM structure:",l),null;let c=Object.entries(l);if(c.length===0)return null;let[u,h]=c[0];if(!isNaN(Number(u)))return Array.isArray(h)?n(h,`${a}.${u}`):typeof h=="object"&&h!==null&&Object.entries(h).length>0?n([h],`${a}.${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 v=f.split(/[.#]/)[0],g=v.includes("-"),w={},x={};if(d){let $=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g,E,j=new Set;for(;(E=$.exec(d))!==null;)if(j.add(E[1]),E[1].startsWith(".")){let te=E[1].substring(1),Se=E[4];x[te]=Rs(i,Se)}else if(E[1].startsWith("?")){let te=E[1].substring(1),Se=E[2]||E[3]||E[4],je;Se==="true"?je=!0:Se==="false"?je=!1:je=Rs(i,Se),je&&(w[te]="")}else w[E[1]]=E[2]||E[3]||E[4];let W=d,M=[],ee,Ze=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g;for(;(ee=Ze.exec(d))!==null;)M.push(ee[0]);M.forEach(te=>{W=W.replace(te," ")});let et=/\b(\S+?)(?=\s|$)/g,U;for(;(U=et.exec(W))!==null;){let te=U[1];!j.has(te)&&!te.startsWith(".")&&!te.includes("=")&&(w[te]="")}}let _=f.match(/#([^.#\s]+)/);_&&!Object.prototype.hasOwnProperty.call(w,"id")&&(w.id=_[1]);let A=null;w.id?A=w.id:g&&(A=v);let k=Object.create(null),C=null;if(g)C=v;else{let $=f.match(/\.([^.#]+)/g);$&&$.forEach(j=>{let W=j.substring(1);k[W]=!0});let E=f.match(/#([^.#\s]+)/);E&&(C=E[1])}let S;typeof h=="string"||typeof h=="number"?S=String(h):Array.isArray(h)?S=n(h,`${a}.${u}`):S=[],C&&!g&&(w.id=C);let R=Object.create(null);if(A&&r){let $=[];if(Object.keys(r).forEach(E=>{if(E.includes("*")){let j="^"+E.replace(/[.*+?^${}()|[\\\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$";try{new RegExp(j).test(A)&&$.push(E)}catch(W){console.warn(`[Parser] Invalid regex pattern created from refKey '${E}': ${j}`,W)}}else A===E&&$.push(E)}),$.length>0){$.sort((j,W)=>{let M=!j.includes("*"),ee=!W.includes("*");return M&&!ee?-1:!M&&ee?1:W.length-j.length});let E=$[0];if(r[E]&&r[E].eventListeners){let j=r[E].eventListeners;Object.entries(j).forEach(([W,M])=>{if(M.handler&&M.action)throw new Error("Each listener can have hanlder or action but not both");if(M.action){R[W]=ee=>{s.handleCallStoreAction({...M.payload,_event:ee,_action:M.action})};return}M.handler&&s[M.handler]?R[W]=ee=>{s[M.handler]({...M.payload,_event:ee})}:M.handler&&console.warn(`[Parser] Handler '${M.handler}' for refKey '${E}' (matching elementId '${A}') is referenced but not found in available handlers.`)})}}}let P={};if(A)P.key=A;else if(f){let $=a?`${a}.${p}`:String(p);if(P.key=`${f}-${$}`,Object.keys(x).length>0){let E=JSON.stringify(x).substring(0,50);P.key+=`-${E}`}}Object.keys(w).length>0&&(P.attrs=w),Object.keys(k).length>0&&(P.class=k),Object.keys(R).length>0&&(P.on=R),Object.keys(x).length>0&&(P.props=x),g&&(P.hook={update:($,E)=>{let j=$.data?.props||{},W=E.data?.props||{},M=$.data?.attrs||{},ee=E.data?.attrs||{},Ze=JSON.stringify(j)!==JSON.stringify(W),et=JSON.stringify(M)!==JSON.stringify(ee);if(Ze||et){let U=E.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 te={...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(te,{oldProps:j,newProps:W,oldAttrs:M,newAttrs:ee})}}))}}});try{return e(v,P,S)}catch($){return console.error("Error creating virtual node:",$,{tagName:v,snabbdomData:P,childrenOrText:S}),e("div",{},["Error creating element"])}}).filter(Boolean)}return n(t)};var hl=(e,t)=>{if(!t||typeof t!="object")return"";let r="",s=n=>Object.entries(n).map(([o,a])=>` ${o}: ${a};`).join(`
|
|
936
936
|
`),i=(n,o)=>{if(typeof o!="object"||o===null)return"";if(n.startsWith("@")){let a=Object.entries(o).map(([l,p])=>{let c=s(p);return` ${l} {
|
|
937
937
|
${c.split(`
|
|
938
938
|
`).map(u=>u?` ${u}`:"").join(`
|
|
@@ -944,7 +944,7 @@ ${a}
|
|
|
944
944
|
${a}
|
|
945
945
|
}`}};return Object.entries(t).forEach(([n,o])=>{let a=i(n,o);a&&(r+=(r?`
|
|
946
946
|
|
|
947
|
-
`:"")+a)}),r},
|
|
947
|
+
`:"")+a)}),r},fl=e=>{let t=e.map(r=>r.subscribe());return()=>{for(let r of t)r&&typeof r.unsubscribe=="function"&&r.unsubscribe()}};function yl(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 ml(e,t){let r=new Set(t);return new Proxy({},{get(s,i){if(typeof i=="string"&&r.has(i))return e[i]},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,i){return typeof i=="string"&&r.has(i)},ownKeys(){return[...r]},getOwnPropertyDescriptor(s,i){if(typeof i=="string"&&r.has(i))return{configurable:!0,enumerable:!0,get:()=>e[i]}}})}var or=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(`
|
|
948
948
|
a, a:link, a:visited, a:hover, a:active {
|
|
949
949
|
display: contents;
|
|
950
950
|
color: inherit;
|
|
@@ -956,4 +956,4 @@ ${a}
|
|
|
956
956
|
font: inherit;
|
|
957
957
|
cursor: pointer;
|
|
958
958
|
}
|
|
959
|
-
`);let r=[t];if(this.cssText){let i=new CSSStyleSheet;i.replaceSync(this.cssText),r.push(i)}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:i=>{let{render:n,store:o}=s,{_event:a,_action:l}=i,p=nr(i,{event:a});if(console.log("context",p),!o[l])throw new Error(`store action store.${o._action} is not defined`);o[l](p),n()}},Object.keys(this.handlers||{}).forEach(i=>{this.transformedHandlers[i]=(n,o)=>this.handlers[i](s,n,o)}),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=yl(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 i={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this),store:this.store,render:this.render.bind(this)},n={oldAttrs:{[t]:r},newAttrs:{[t]:s},oldProps:i.props,newProps:i.props};this.handlers.handleOnUpdate(i,n)}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=Ns({h:this.h,template:this.template,viewData:this.viewData,refs:this.refs,handlers:this.transformedHandlers}),s={},i=n=>{n.data?.attrs&&n.data.attrs.id&&(s[n.data.attrs.id]=n),n.children&&n.children.forEach(i)};i(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)}}},vl=(e,t,r)=>{let{createInitialState:s,...i}=e,n={},o={},a={};return s&&(a=s()),Object.entries(i).forEach(([l,p])=>{l.startsWith("select")?n[l]=(...c)=>p({state:a,props:t,attrs:r},...c):o[l]=c=>(a=bs(a,u=>p(u,c)),a)}),{getState:()=>a,...o,...n}},bl=({handlers:e,view:t,store:r,patch:s,h:i},n)=>{let{elementName:o,propsSchema:a,attrsSchema:l,template:p,refs:c,styles:u}=t;if(!s)throw new Error("Patch is not defined");if(!i)throw new Error("h is not defined");if(!t)throw new Error("view is not defined");class h extends or{static get observedAttributes(){let d=["key"],y=l?.properties?Object.keys(l.properties):[];return[...d,...y]}constructor(){super();let d=ml(this);this.propsSchema=a,this.props=a?gl(this,Object.keys(a.properties)):{},this.elementName=o,this.styles=u,this.store=vl(r,this.props,d),this.template=p,this.handlers=e,this.refs=c,this.patch=s,this.deps={...n,store:this.store,render:this.render,handlers:e,attrs:d,props:this.props},this.h=i,this.cssText=fl(o,u)}}return h},ar=bl;function me(e,t,r,s,i){let n=t===void 0?void 0:t.key;return{sel:e,data:t,children:r,text:s,elm:i,key:n}}var ke=Array.isArray;function Se(e){return typeof e=="string"||typeof e=="number"||e instanceof String||e instanceof Number}function wl(e,t){return document.createElement(e,t)}function xl(e,t,r){return document.createElementNS(e,t,r)}function _l(){return ge(document.createDocumentFragment())}function El(e){return document.createTextNode(e)}function Al(e){return document.createComment(e)}function kl(e,t,r){if(le(e)){let s=e;for(;s&&le(s);)s=ge(s).parent;e=s??e}le(t)&&(t=ge(t,e)),r&&le(r)&&(r=ge(r).firstChildNode),e.insertBefore(t,r)}function Sl(e,t){e.removeChild(t)}function $l(e,t){le(t)&&(t=ge(t,e)),e.appendChild(t)}function Ps(e){if(le(e)){for(;e&&le(e);)e=ge(e).parent;return e??null}return e.parentNode}function Cl(e){var t;if(le(e)){let r=ge(e),s=Ps(r);if(s&&r.lastChildNode){let i=Array.from(s.childNodes),n=i.indexOf(r.lastChildNode);return(t=i[n+1])!==null&&t!==void 0?t:null}return null}return e.nextSibling}function Ol(e){return e.tagName}function Il(e,t){e.textContent=t}function Tl(e){return e.textContent}function Ll(e){return e.nodeType===1}function Rl(e){return e.nodeType===3}function Nl(e){return e.nodeType===8}function le(e){return e.nodeType===11}function ge(e,t){var r,s,i;let n=e;return(r=n.parent)!==null&&r!==void 0||(n.parent=t??null),(s=n.firstChildNode)!==null&&s!==void 0||(n.firstChildNode=e.firstChild),(i=n.lastChildNode)!==null&&i!==void 0||(n.lastChildNode=e.lastChild),n}var js={createElement:wl,createElementNS:xl,createTextNode:El,createDocumentFragment:_l,createComment:Al,insertBefore:kl,removeChild:Sl,appendChild:$l,parentNode:Ps,nextSibling:Cl,tagName:Ol,setTextContent:Il,getTextContent:Tl,isElement:Ll,isText:Rl,isComment:Nl,isDocumentFragment:le};function Xe(e){return e===void 0}function X(e){return e!==void 0}var lr=me("",{},[],void 0,void 0);function Pe(e,t){var r,s;let i=e.key===t.key,n=((r=e.data)===null||r===void 0?void 0:r.is)===((s=t.data)===null||s===void 0?void 0:s.is),o=e.sel===t.sel,a=!e.sel&&e.sel===t.sel?typeof e.text==typeof t.text:!0;return o&&i&&n&&a}function Vl(){throw new Error("The document fragment is not supported on this platform.")}function Pl(e,t){return e.isElement(t)}function jl(e,t){return e.isDocumentFragment(t)}function Dl(e,t,r){var s;let i={};for(let n=t;n<=r;++n){let o=(s=e[n])===null||s===void 0?void 0:s.key;o!==void 0&&(i[o]=n)}return i}var Bl=["create","update","remove","destroy","pre","post"];function Ds(e,t,r){let s={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},i=t!==void 0?t:js;for(let d of Bl)for(let y of e){let v=y[d];v!==void 0&&s[d].push(v)}function n(d){let y=d.id?"#"+d.id:"",v=d.getAttribute("class"),g=v?"."+v.split(" ").join("."):"";return me(i.tagName(d).toLowerCase()+y+g,{},[],void 0,d)}function o(d){return me(void 0,{},[],void 0,d)}function a(d,y){return function(){if(--y===0){let g=i.parentNode(d);g!==null&&i.removeChild(g,d)}}}function l(d,y){var v,g,w,x;let _,A=d.data;if(A!==void 0){let S=(v=A.hook)===null||v===void 0?void 0:v.init;X(S)&&(S(d),A=d.data)}let k=d.children,C=d.sel;if(C==="!")Xe(d.text)&&(d.text=""),d.elm=i.createComment(d.text);else if(C==="")d.elm=i.createTextNode(d.text);else if(C!==void 0){let S=C.indexOf("#"),R=C.indexOf(".",S),P=S>0?S:C.length,$=R>0?R:C.length,E=S!==-1||R!==-1?C.slice(0,Math.min(P,$)):C,j=d.elm=X(A)&&X(_=A.ns)?i.createElementNS(_,E,A):i.createElement(E,A);for(P<$&&j.setAttribute("id",C.slice(P+1,$)),R>0&&j.setAttribute("class",C.slice($+1).replace(/\./g," ")),_=0;_<s.create.length;++_)s.create[_](lr,d);if(Se(d.text)&&(!ke(k)||k.length===0)&&i.appendChild(j,i.createTextNode(d.text)),ke(k))for(_=0;_<k.length;++_){let M=k[_];M!=null&&i.appendChild(j,l(M,y))}let W=d.data.hook;X(W)&&((g=W.create)===null||g===void 0||g.call(W,lr,d),W.insert&&y.push(d))}else if(!((w=r?.experimental)===null||w===void 0)&&w.fragments&&d.children){for(d.elm=((x=i.createDocumentFragment)!==null&&x!==void 0?x:Vl)(),_=0;_<s.create.length;++_)s.create[_](lr,d);for(_=0;_<d.children.length;++_){let S=d.children[_];S!=null&&i.appendChild(d.elm,l(S,y))}}else d.elm=i.createTextNode(d.text);return d.elm}function p(d,y,v,g,w,x){for(;g<=w;++g){let _=v[g];_!=null&&i.insertBefore(d,l(_,x),y)}}function c(d){var y,v;let g=d.data;if(g!==void 0){(v=(y=g?.hook)===null||y===void 0?void 0:y.destroy)===null||v===void 0||v.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 x=d.children[w];x!=null&&typeof x!="string"&&c(x)}}}function u(d,y,v,g){for(var w,x;v<=g;++v){let _,A,k=y[v];if(k!=null)if(X(k.sel)){c(k),_=s.remove.length+1,A=a(k.elm,_);for(let S=0;S<s.remove.length;++S)s.remove[S](k,A);let C=(x=(w=k?.data)===null||w===void 0?void 0:w.hook)===null||x===void 0?void 0:x.remove;X(C)?C(k,A):A()}else k.children?(c(k),u(d,k.children,0,k.children.length-1)):i.removeChild(d,k.elm)}}function h(d,y,v,g){let w=0,x=0,_=y.length-1,A=y[0],k=y[_],C=v.length-1,S=v[0],R=v[C],P,$,E,j;for(;w<=_&&x<=C;)A==null?A=y[++w]:k==null?k=y[--_]:S==null?S=v[++x]:R==null?R=v[--C]:Pe(A,S)?(f(A,S,g),A=y[++w],S=v[++x]):Pe(k,R)?(f(k,R,g),k=y[--_],R=v[--C]):Pe(A,R)?(f(A,R,g),i.insertBefore(d,A.elm,i.nextSibling(k.elm)),A=y[++w],R=v[--C]):Pe(k,S)?(f(k,S,g),i.insertBefore(d,k.elm,A.elm),k=y[--_],S=v[++x]):(P===void 0&&(P=Dl(y,w,_)),$=P[S.key],Xe($)?(i.insertBefore(d,l(S,g),A.elm),S=v[++x]):Xe(P[R.key])?(i.insertBefore(d,l(R,g),i.nextSibling(k.elm)),R=v[--C]):(E=y[$],E.sel!==S.sel?i.insertBefore(d,l(S,g),A.elm):(f(E,S,g),y[$]=void 0,i.insertBefore(d,E.elm,A.elm)),S=v[++x]));x<=C&&(j=v[C+1]==null?null:v[C+1].elm,p(d,j,v,x,C,g)),w<=_&&u(d,y,w,_)}function f(d,y,v){var g,w,x,_,A,k,C,S;let R=(g=y.data)===null||g===void 0?void 0:g.hook;(w=R?.prepatch)===null||w===void 0||w.call(R,d,y);let P=y.elm=d.elm;if(d===y)return;if(y.data!==void 0||X(y.text)&&y.text!==d.text){(x=y.data)!==null&&x!==void 0||(y.data={}),(_=d.data)!==null&&_!==void 0||(d.data={});for(let j=0;j<s.update.length;++j)s.update[j](d,y);(C=(k=(A=y.data)===null||A===void 0?void 0:A.hook)===null||k===void 0?void 0:k.update)===null||C===void 0||C.call(k,d,y)}let $=d.children,E=y.children;Xe(y.text)?X($)&&X(E)?$!==E&&h(P,$,E,v):X(E)?(X(d.text)&&i.setTextContent(P,""),p(P,null,E,0,E.length-1,v)):X($)?u(P,$,0,$.length-1):X(d.text)&&i.setTextContent(P,""):d.text!==y.text&&(X($)&&u(P,$,0,$.length-1),i.setTextContent(P,y.text)),(S=R?.postpatch)===null||S===void 0||S.call(R,d,y)}return function(y,v){let g,w,x,_=[];for(g=0;g<s.pre.length;++g)s.pre[g]();for(Pl(i,y)?y=n(y):jl(i,y)&&(y=o(y)),Pe(y,v)?f(y,v,_):(w=y.elm,x=i.parentNode(w),l(v,_),x!==null&&(i.insertBefore(x,v.elm,i.nextSibling(w)),u(x,[y],0,0))),g=0;g<_.length;++g)_[g].data.hook.insert(_[g]);for(g=0;g<s.post.length;++g)s.post[g]();return v}}function Bs(e,t){let r,s,i=t.elm,n=e.data.class,o=t.data.class;if(!(!n&&!o)&&n!==o){n=n||{},o=o||{};for(s in n)n[s]&&!Object.prototype.hasOwnProperty.call(o,s)&&i.classList.remove(s);for(s in o)r=o[s],r!==n[s]&&i.classList[r?"add":"remove"](s)}}var Ms={create:Bs,update:Bs};function Ws(e,t){let r,s,i,n=t.elm,o=e.data.props,a=t.data.props;if(!(!o&&!a)&&o!==a){o=o||{},a=a||{};for(r in a)s=a[r],i=o[r],i!==s&&(r!=="value"||n[r]!==s)&&(n[r]=s)}}var Fs={create:Ws,update:Ws};var Ml="http://www.w3.org/1999/xlink",Wl="http://www.w3.org/2000/xmlns/",Fl="http://www.w3.org/XML/1998/namespace";function Ks(e,t){let r,s=t.elm,i=e.data.attrs,n=t.data.attrs;if(!(!i&&!n)&&i!==n){i=i||{},n=n||{};for(r in n){let o=n[r];i[r]!==o&&(o===!0?s.setAttribute(r,""):o===!1?s.removeAttribute(r):r.charCodeAt(0)!==120?s.setAttribute(r,o):r.charCodeAt(3)===58?s.setAttributeNS(Fl,r,o):r.charCodeAt(5)===58?r.charCodeAt(1)===109?s.setAttributeNS(Wl,r,o):s.setAttributeNS(Ml,r,o):s.setAttribute(r,o))}for(r in i)r in n||s.removeAttribute(r)}}var Us={create:Ks,update:Ks};var zs=typeof window?.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):setTimeout,Kl=function(e){zs(function(){zs(e)})},pr=!1;function Ul(e,t,r){Kl(function(){e[t]=r})}function Hs(e,t){let r,s,i=t.elm,n=e.data.style,o=t.data.style;if(!n&&!o||n===o)return;n=n||{},o=o||{};let a="delayed"in n;for(s in n)s in o||(s[0]==="-"&&s[1]==="-"?i.style.removeProperty(s):i.style[s]="");for(s in o)if(r=o[s],s==="delayed"&&o.delayed)for(let l in o.delayed)r=o.delayed[l],(!a||r!==n.delayed[l])&&Ul(i.style,l,r);else s!=="remove"&&r!==n[s]&&(s[0]==="-"&&s[1]==="-"?i.style.setProperty(s,r):i.style[s]=r)}function zl(e){let t,r,s=e.elm,i=e.data.style;if(!(!i||!(t=i.destroy)))for(r in t)s.style[r]=t[r]}function Hl(e,t){let r=e.data.style;if(!r||!r.remove){t();return}pr||(e.elm.offsetLeft,pr=!0);let s,i=e.elm,n=0,o=r.remove,a=0,l=[];for(s in o)l.push(s),i.style[s]=o[s];let c=getComputedStyle(i)["transition-property"].split(", ");for(;n<c.length;++n)l.indexOf(c[n])!==-1&&a++;i.addEventListener("transitionend",function(u){u.target===i&&--a,a===0&&t()})}function Jl(){pr=!1}var Js={pre:Jl,create:Hs,update:Hs,destroy:zl,remove:Hl};function qs(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++)qs(e[s],t,r)}function ql(e,t){let r=e.type,s=t.data.on;s&&s[r]&&qs(s[r],t,e)}function Yl(){return function e(t){ql(t,e.vnode)}}function cr(e,t){let r=e.data.on,s=e.listener,i=e.elm,n=t&&t.data.on,o=t&&t.elm,a;if(r!==n){if(r&&s)if(n)for(a in r)n[a]||i.removeEventListener(a,s,!1);else for(a in r)i.removeEventListener(a,s,!1);if(n){let l=t.listener=e.listener||Yl();if(l.vnode=t,r)for(a in n)r[a]||o.addEventListener(a,l,!1);else for(a in n)o.addEventListener(a,l,!1)}}}var Ys={create:cr,update:cr,destroy:cr};var Gl=()=>Ds([Ms,Fs,Us,Js,Ys]),ur=Gl;var Xl=e=>{let t={};return{once:(r,s)=>{t[r]||(t[r]=[]);let i=(...n)=>{s(...n),t[r]=t[r].filter(o=>o!==i)};t[r].push(i)},emit:(r,...s)=>{t[r]&&t[r].forEach(i=>{i(...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()}}},Gs=Xl;function Xs(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 i=t[s];if(typeof i=="string")continue;let n=i.data;n!==void 0&&Xs(n,i.children,i.sel)}}function dr(e,t,r){let s={},i,n,o;if(r!==void 0?(t!==null&&(s=t),ke(r)?i=r:Se(r)?n=r.toString():r&&r.sel&&(i=[r])):t!=null&&(ke(t)?i=t:Se(t)?n=t.toString():t&&t.sel?i=[t]:s=t),i!==void 0)for(o=0;o<i.length;++o)Se(i[o])&&(i[o]=me(void 0,void 0,void 0,i[o],void 0));return e.startsWith("svg")&&(e.length===3||e[3]==="."||e[3]==="#")&&Xs(s,i,e),me(e,s,i,n,void 0)}var Ql=Gs(),Zl={globalUI:Ql},Qs={components:Zl},Zs=ur();var Qe={components:{breadcrumb:{handlers:dt,store:ht,view:Tr},dropdownMenu:{handlers:ft,store:yt,view:Lr},form:{handlers:mt,store:Et,view:Jr},globalUi:{handlers:At,store:kt,view:qr},navbar:{handlers:St,store:$t,view:Yr},pageOutline:{handlers:Ct,store:Ot,view:Xr},popoverInput:{handlers:It,store:Tt,view:Qr},select:{handlers:Lt,store:Rt,view:Zr},sidebar:{handlers:Nt,store:Pt,view:es},sliderInput:{handlers:jt,store:Dt,view:ts},table:{handlers:Bt,store:Mt,view:rs},tabs:{handlers:Wt,store:Ft,view:ss},tooltip:{handlers:is,store:Kt,view:ns},waveform:{handlers:Ut,store:zt,view:as}}};Object.keys(Qe).forEach(e=>{Object.keys(Qe[e]).forEach(t=>{let r=ar({...Qe[e][t],patch:Zs,h:dr},Qs[e]);customElements.define(Qe[e][t].view.elementName,r)})});customElements.define("rtgl-button",mr({}));customElements.define("rtgl-view",br({}));customElements.define("rtgl-text",xr({}));customElements.define("rtgl-image",_r({}));customElements.define("rtgl-svg",Ar({}));customElements.define("rtgl-input",kr({}));customElements.define("rtgl-textarea",Sr({}));customElements.define("rtgl-color-picker",$r({}));customElements.define("rtgl-slider",Cr({}));customElements.define("rtgl-dialog",Or({}));customElements.define("rtgl-popover",Ir({}));})();
|
|
959
|
+
`);let r=[t];if(this.cssText){let i=new CSSStyleSheet;i.replaceSync(this.cssText),r.push(i)}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:i=>{let{render:n,store:o}=s,{_event:a,_action:l}=i,p=nr(i,{event:a});if(console.log("context",p),!o[l])throw new Error(`store action store.${o._action} is not defined`);o[l](p),n()}},Object.keys(this.handlers||{}).forEach(i=>{this.transformedHandlers[i]=(n,o)=>this.handlers[i](s,n,o)}),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=fl(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 i={...this.deps,refIds:this.refIds,getRefIds:()=>this.refIds,dispatchEvent:this.dispatchEvent.bind(this),store:this.store,render:this.render.bind(this)},n={oldAttrs:{[t]:r},newAttrs:{[t]:s},oldProps:i.props,newProps:i.props};this.handlers.handleOnUpdate(i,n)}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=Ns({h:this.h,template:this.template,viewData:this.viewData,refs:this.refs,handlers:this.transformedHandlers}),s={},i=n=>{n.data?.attrs&&n.data.attrs.id&&(s[n.data.attrs.id]=n),n.children&&n.children.forEach(i)};i(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)}}},gl=(e,t,r)=>{let{createInitialState:s,...i}=e,n={},o={},a={};return s&&(a=s()),Object.entries(i).forEach(([l,p])=>{l.startsWith("select")?n[l]=(...c)=>p({state:a,props:t,attrs:r},...c):o[l]=c=>(a=bs(a,u=>p(u,c)),a)}),{getState:()=>a,...o,...n}},vl=({handlers:e,view:t,store:r,patch:s,h:i},n)=>{let{elementName:o,propsSchema:a,attrsSchema:l,template:p,refs:c,styles:u}=t;if(!s)throw new Error("Patch is not defined");if(!i)throw new Error("h is not defined");if(!t)throw new Error("view is not defined");class h extends or{static get observedAttributes(){let d=["key"],y=l?.properties?Object.keys(l.properties):[];return[...d,...y]}constructor(){super();let d=yl(this);this.propsSchema=a,this.props=a?ml(this,Object.keys(a.properties)):{},this.elementName=o,this.styles=u,this.store=gl(r,this.props,d),this.template=p,this.handlers=e,this.refs=c,this.patch=s,this.deps={...n,store:this.store,render:this.render,handlers:e,attrs:d,props:this.props},this.h=i,this.cssText=hl(o,u)}}return h},ar=vl;function me(e,t,r,s,i){let n=t===void 0?void 0:t.key;return{sel:e,data:t,children:r,text:s,elm:i,key:n}}var Ae=Array.isArray;function ke(e){return typeof e=="string"||typeof e=="number"||e instanceof String||e instanceof Number}function bl(e,t){return document.createElement(e,t)}function wl(e,t,r){return document.createElementNS(e,t,r)}function xl(){return ge(document.createDocumentFragment())}function _l(e){return document.createTextNode(e)}function El(e){return document.createComment(e)}function Al(e,t,r){if(le(e)){let s=e;for(;s&&le(s);)s=ge(s).parent;e=s??e}le(t)&&(t=ge(t,e)),r&&le(r)&&(r=ge(r).firstChildNode),e.insertBefore(t,r)}function kl(e,t){e.removeChild(t)}function Sl(e,t){le(t)&&(t=ge(t,e)),e.appendChild(t)}function Ps(e){if(le(e)){for(;e&&le(e);)e=ge(e).parent;return e??null}return e.parentNode}function $l(e){var t;if(le(e)){let r=ge(e),s=Ps(r);if(s&&r.lastChildNode){let i=Array.from(s.childNodes),n=i.indexOf(r.lastChildNode);return(t=i[n+1])!==null&&t!==void 0?t:null}return null}return e.nextSibling}function Cl(e){return e.tagName}function Ol(e,t){e.textContent=t}function Il(e){return e.textContent}function Tl(e){return e.nodeType===1}function Ll(e){return e.nodeType===3}function Rl(e){return e.nodeType===8}function le(e){return e.nodeType===11}function ge(e,t){var r,s,i;let n=e;return(r=n.parent)!==null&&r!==void 0||(n.parent=t??null),(s=n.firstChildNode)!==null&&s!==void 0||(n.firstChildNode=e.firstChild),(i=n.lastChildNode)!==null&&i!==void 0||(n.lastChildNode=e.lastChild),n}var js={createElement:bl,createElementNS:wl,createTextNode:_l,createDocumentFragment:xl,createComment:El,insertBefore:Al,removeChild:kl,appendChild:Sl,parentNode:Ps,nextSibling:$l,tagName:Cl,setTextContent:Ol,getTextContent:Il,isElement:Tl,isText:Ll,isComment:Rl,isDocumentFragment:le};function Xe(e){return e===void 0}function X(e){return e!==void 0}var lr=me("",{},[],void 0,void 0);function Pe(e,t){var r,s;let i=e.key===t.key,n=((r=e.data)===null||r===void 0?void 0:r.is)===((s=t.data)===null||s===void 0?void 0:s.is),o=e.sel===t.sel,a=!e.sel&&e.sel===t.sel?typeof e.text==typeof t.text:!0;return o&&i&&n&&a}function Nl(){throw new Error("The document fragment is not supported on this platform.")}function Vl(e,t){return e.isElement(t)}function Pl(e,t){return e.isDocumentFragment(t)}function jl(e,t,r){var s;let i={};for(let n=t;n<=r;++n){let o=(s=e[n])===null||s===void 0?void 0:s.key;o!==void 0&&(i[o]=n)}return i}var Dl=["create","update","remove","destroy","pre","post"];function Ds(e,t,r){let s={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},i=t!==void 0?t:js;for(let d of Dl)for(let y of e){let v=y[d];v!==void 0&&s[d].push(v)}function n(d){let y=d.id?"#"+d.id:"",v=d.getAttribute("class"),g=v?"."+v.split(" ").join("."):"";return me(i.tagName(d).toLowerCase()+y+g,{},[],void 0,d)}function o(d){return me(void 0,{},[],void 0,d)}function a(d,y){return function(){if(--y===0){let g=i.parentNode(d);g!==null&&i.removeChild(g,d)}}}function l(d,y){var v,g,w,x;let _,A=d.data;if(A!==void 0){let S=(v=A.hook)===null||v===void 0?void 0:v.init;X(S)&&(S(d),A=d.data)}let k=d.children,C=d.sel;if(C==="!")Xe(d.text)&&(d.text=""),d.elm=i.createComment(d.text);else if(C==="")d.elm=i.createTextNode(d.text);else if(C!==void 0){let S=C.indexOf("#"),R=C.indexOf(".",S),P=S>0?S:C.length,$=R>0?R:C.length,E=S!==-1||R!==-1?C.slice(0,Math.min(P,$)):C,j=d.elm=X(A)&&X(_=A.ns)?i.createElementNS(_,E,A):i.createElement(E,A);for(P<$&&j.setAttribute("id",C.slice(P+1,$)),R>0&&j.setAttribute("class",C.slice($+1).replace(/\./g," ")),_=0;_<s.create.length;++_)s.create[_](lr,d);if(ke(d.text)&&(!Ae(k)||k.length===0)&&i.appendChild(j,i.createTextNode(d.text)),Ae(k))for(_=0;_<k.length;++_){let M=k[_];M!=null&&i.appendChild(j,l(M,y))}let W=d.data.hook;X(W)&&((g=W.create)===null||g===void 0||g.call(W,lr,d),W.insert&&y.push(d))}else if(!((w=r?.experimental)===null||w===void 0)&&w.fragments&&d.children){for(d.elm=((x=i.createDocumentFragment)!==null&&x!==void 0?x:Nl)(),_=0;_<s.create.length;++_)s.create[_](lr,d);for(_=0;_<d.children.length;++_){let S=d.children[_];S!=null&&i.appendChild(d.elm,l(S,y))}}else d.elm=i.createTextNode(d.text);return d.elm}function p(d,y,v,g,w,x){for(;g<=w;++g){let _=v[g];_!=null&&i.insertBefore(d,l(_,x),y)}}function c(d){var y,v;let g=d.data;if(g!==void 0){(v=(y=g?.hook)===null||y===void 0?void 0:y.destroy)===null||v===void 0||v.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 x=d.children[w];x!=null&&typeof x!="string"&&c(x)}}}function u(d,y,v,g){for(var w,x;v<=g;++v){let _,A,k=y[v];if(k!=null)if(X(k.sel)){c(k),_=s.remove.length+1,A=a(k.elm,_);for(let S=0;S<s.remove.length;++S)s.remove[S](k,A);let C=(x=(w=k?.data)===null||w===void 0?void 0:w.hook)===null||x===void 0?void 0:x.remove;X(C)?C(k,A):A()}else k.children?(c(k),u(d,k.children,0,k.children.length-1)):i.removeChild(d,k.elm)}}function h(d,y,v,g){let w=0,x=0,_=y.length-1,A=y[0],k=y[_],C=v.length-1,S=v[0],R=v[C],P,$,E,j;for(;w<=_&&x<=C;)A==null?A=y[++w]:k==null?k=y[--_]:S==null?S=v[++x]:R==null?R=v[--C]:Pe(A,S)?(f(A,S,g),A=y[++w],S=v[++x]):Pe(k,R)?(f(k,R,g),k=y[--_],R=v[--C]):Pe(A,R)?(f(A,R,g),i.insertBefore(d,A.elm,i.nextSibling(k.elm)),A=y[++w],R=v[--C]):Pe(k,S)?(f(k,S,g),i.insertBefore(d,k.elm,A.elm),k=y[--_],S=v[++x]):(P===void 0&&(P=jl(y,w,_)),$=P[S.key],Xe($)?(i.insertBefore(d,l(S,g),A.elm),S=v[++x]):Xe(P[R.key])?(i.insertBefore(d,l(R,g),i.nextSibling(k.elm)),R=v[--C]):(E=y[$],E.sel!==S.sel?i.insertBefore(d,l(S,g),A.elm):(f(E,S,g),y[$]=void 0,i.insertBefore(d,E.elm,A.elm)),S=v[++x]));x<=C&&(j=v[C+1]==null?null:v[C+1].elm,p(d,j,v,x,C,g)),w<=_&&u(d,y,w,_)}function f(d,y,v){var g,w,x,_,A,k,C,S;let R=(g=y.data)===null||g===void 0?void 0:g.hook;(w=R?.prepatch)===null||w===void 0||w.call(R,d,y);let P=y.elm=d.elm;if(d===y)return;if(y.data!==void 0||X(y.text)&&y.text!==d.text){(x=y.data)!==null&&x!==void 0||(y.data={}),(_=d.data)!==null&&_!==void 0||(d.data={});for(let j=0;j<s.update.length;++j)s.update[j](d,y);(C=(k=(A=y.data)===null||A===void 0?void 0:A.hook)===null||k===void 0?void 0:k.update)===null||C===void 0||C.call(k,d,y)}let $=d.children,E=y.children;Xe(y.text)?X($)&&X(E)?$!==E&&h(P,$,E,v):X(E)?(X(d.text)&&i.setTextContent(P,""),p(P,null,E,0,E.length-1,v)):X($)?u(P,$,0,$.length-1):X(d.text)&&i.setTextContent(P,""):d.text!==y.text&&(X($)&&u(P,$,0,$.length-1),i.setTextContent(P,y.text)),(S=R?.postpatch)===null||S===void 0||S.call(R,d,y)}return function(y,v){let g,w,x,_=[];for(g=0;g<s.pre.length;++g)s.pre[g]();for(Vl(i,y)?y=n(y):Pl(i,y)&&(y=o(y)),Pe(y,v)?f(y,v,_):(w=y.elm,x=i.parentNode(w),l(v,_),x!==null&&(i.insertBefore(x,v.elm,i.nextSibling(w)),u(x,[y],0,0))),g=0;g<_.length;++g)_[g].data.hook.insert(_[g]);for(g=0;g<s.post.length;++g)s.post[g]();return v}}function Bs(e,t){let r,s,i=t.elm,n=e.data.class,o=t.data.class;if(!(!n&&!o)&&n!==o){n=n||{},o=o||{};for(s in n)n[s]&&!Object.prototype.hasOwnProperty.call(o,s)&&i.classList.remove(s);for(s in o)r=o[s],r!==n[s]&&i.classList[r?"add":"remove"](s)}}var Ms={create:Bs,update:Bs};function Ws(e,t){let r,s,i,n=t.elm,o=e.data.props,a=t.data.props;if(!(!o&&!a)&&o!==a){o=o||{},a=a||{};for(r in a)s=a[r],i=o[r],i!==s&&(r!=="value"||n[r]!==s)&&(n[r]=s)}}var Fs={create:Ws,update:Ws};var Bl="http://www.w3.org/1999/xlink",Ml="http://www.w3.org/2000/xmlns/",Wl="http://www.w3.org/XML/1998/namespace";function Ks(e,t){let r,s=t.elm,i=e.data.attrs,n=t.data.attrs;if(!(!i&&!n)&&i!==n){i=i||{},n=n||{};for(r in n){let o=n[r];i[r]!==o&&(o===!0?s.setAttribute(r,""):o===!1?s.removeAttribute(r):r.charCodeAt(0)!==120?s.setAttribute(r,o):r.charCodeAt(3)===58?s.setAttributeNS(Wl,r,o):r.charCodeAt(5)===58?r.charCodeAt(1)===109?s.setAttributeNS(Ml,r,o):s.setAttributeNS(Bl,r,o):s.setAttribute(r,o))}for(r in i)r in n||s.removeAttribute(r)}}var Us={create:Ks,update:Ks};var zs=typeof window?.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):setTimeout,Fl=function(e){zs(function(){zs(e)})},pr=!1;function Kl(e,t,r){Fl(function(){e[t]=r})}function Hs(e,t){let r,s,i=t.elm,n=e.data.style,o=t.data.style;if(!n&&!o||n===o)return;n=n||{},o=o||{};let a="delayed"in n;for(s in n)s in o||(s[0]==="-"&&s[1]==="-"?i.style.removeProperty(s):i.style[s]="");for(s in o)if(r=o[s],s==="delayed"&&o.delayed)for(let l in o.delayed)r=o.delayed[l],(!a||r!==n.delayed[l])&&Kl(i.style,l,r);else s!=="remove"&&r!==n[s]&&(s[0]==="-"&&s[1]==="-"?i.style.setProperty(s,r):i.style[s]=r)}function Ul(e){let t,r,s=e.elm,i=e.data.style;if(!(!i||!(t=i.destroy)))for(r in t)s.style[r]=t[r]}function zl(e,t){let r=e.data.style;if(!r||!r.remove){t();return}pr||(e.elm.offsetLeft,pr=!0);let s,i=e.elm,n=0,o=r.remove,a=0,l=[];for(s in o)l.push(s),i.style[s]=o[s];let c=getComputedStyle(i)["transition-property"].split(", ");for(;n<c.length;++n)l.indexOf(c[n])!==-1&&a++;i.addEventListener("transitionend",function(u){u.target===i&&--a,a===0&&t()})}function Hl(){pr=!1}var Js={pre:Hl,create:Hs,update:Hs,destroy:Ul,remove:zl};function qs(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++)qs(e[s],t,r)}function Jl(e,t){let r=e.type,s=t.data.on;s&&s[r]&&qs(s[r],t,e)}function ql(){return function e(t){Jl(t,e.vnode)}}function cr(e,t){let r=e.data.on,s=e.listener,i=e.elm,n=t&&t.data.on,o=t&&t.elm,a;if(r!==n){if(r&&s)if(n)for(a in r)n[a]||i.removeEventListener(a,s,!1);else for(a in r)i.removeEventListener(a,s,!1);if(n){let l=t.listener=e.listener||ql();if(l.vnode=t,r)for(a in n)r[a]||o.addEventListener(a,l,!1);else for(a in n)o.addEventListener(a,l,!1)}}}var Ys={create:cr,update:cr,destroy:cr};var Yl=()=>Ds([Ms,Fs,Us,Js,Ys]),ur=Yl;var Gl=e=>{let t={};return{once:(r,s)=>{t[r]||(t[r]=[]);let i=(...n)=>{s(...n),t[r]=t[r].filter(o=>o!==i)};t[r].push(i)},emit:(r,...s)=>{t[r]&&t[r].forEach(i=>{i(...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()}}},Gs=Gl;function Xs(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 i=t[s];if(typeof i=="string")continue;let n=i.data;n!==void 0&&Xs(n,i.children,i.sel)}}function dr(e,t,r){let s={},i,n,o;if(r!==void 0?(t!==null&&(s=t),Ae(r)?i=r:ke(r)?n=r.toString():r&&r.sel&&(i=[r])):t!=null&&(Ae(t)?i=t:ke(t)?n=t.toString():t&&t.sel?i=[t]:s=t),i!==void 0)for(o=0;o<i.length;++o)ke(i[o])&&(i[o]=me(void 0,void 0,void 0,i[o],void 0));return e.startsWith("svg")&&(e.length===3||e[3]==="."||e[3]==="#")&&Xs(s,i,e),me(e,s,i,n,void 0)}var Xl=Gs(),Ql={globalUI:Xl},Qs={components:Ql},Zs=ur();var Qe={components:{breadcrumb:{handlers:dt,store:ht,view:Tr},dropdownMenu:{handlers:ft,store:yt,view:Lr},form:{handlers:mt,store:Et,view:Jr},globalUi:{handlers:At,store:kt,view:qr},navbar:{handlers:St,store:$t,view:Yr},pageOutline:{handlers:Ct,store:Ot,view:Xr},popoverInput:{handlers:It,store:Tt,view:Qr},select:{handlers:Lt,store:Rt,view:Zr},sidebar:{handlers:Nt,store:Pt,view:es},sliderInput:{handlers:jt,store:Dt,view:ts},table:{handlers:Bt,store:Mt,view:rs},tabs:{handlers:Wt,store:Ft,view:ss},tooltip:{handlers:is,store:Kt,view:ns},waveform:{handlers:Ut,store:zt,view:as}}};Object.keys(Qe).forEach(e=>{Object.keys(Qe[e]).forEach(t=>{let r=ar({...Qe[e][t],patch:Zs,h:dr},Qs[e]);customElements.define(Qe[e][t].view.elementName,r)})});customElements.define("rtgl-button",mr({}));customElements.define("rtgl-view",br({}));customElements.define("rtgl-text",xr({}));customElements.define("rtgl-image",_r({}));customElements.define("rtgl-svg",Ar({}));customElements.define("rtgl-input",kr({}));customElements.define("rtgl-textarea",Sr({}));customElements.define("rtgl-color-picker",$r({}));customElements.define("rtgl-slider",Cr({}));customElements.define("rtgl-dialog",Or({}));customElements.define("rtgl-popover",Ir({}));})();
|
package/package.json
CHANGED
|
@@ -10,14 +10,20 @@ const updateAttributes = ({ form, defaultValues = {}, refs }) => {
|
|
|
10
10
|
|
|
11
11
|
if (['inputText', 'colorPicker', 'slider', 'slider-input', 'popover-input'].includes(field.inputType)) {
|
|
12
12
|
const defaultValue = defaultValues[field.name];
|
|
13
|
-
if (defaultValue
|
|
13
|
+
if (defaultValue === undefined || defaultValue === null) {
|
|
14
|
+
ref.removeAttribute('value')
|
|
15
|
+
} else {
|
|
14
16
|
ref.setAttribute('value', defaultValue)
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
if (field.inputType === 'inputText' && field.placeholder) {
|
|
18
20
|
const currentPlaceholder = ref.getAttribute('placeholder')
|
|
19
21
|
if (currentPlaceholder !== field.placeholder) {
|
|
20
|
-
|
|
22
|
+
if (field.placeholder === undefined || field.placeholder === null) {
|
|
23
|
+
ref.removeAttribute('placeholder');
|
|
24
|
+
} else {
|
|
25
|
+
ref.setAttribute('placeholder', field.placeholder);
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
if (field.inputType === 'select' && field.placeholder) {
|
|
@@ -64,9 +70,10 @@ export const handleOnUpdate = (deps, payload) => {
|
|
|
64
70
|
if (oldAttrs?.key !== newAttrs?.key) {
|
|
65
71
|
const refs = getRefIds();
|
|
66
72
|
updateAttributes({ form, defaultValues, refs });
|
|
73
|
+
store.setFormValues(defaultValues);
|
|
74
|
+
render();
|
|
67
75
|
return;
|
|
68
76
|
}
|
|
69
|
-
store.setFormValues(defaultValues);
|
|
70
77
|
render();
|
|
71
78
|
};
|
|
72
79
|
|
|
@@ -99,28 +106,7 @@ export const handleActionClick = (deps, payload) => {
|
|
|
99
106
|
export const handleInputChange = (deps, payload) => {
|
|
100
107
|
const { store, dispatchEvent, props } = deps;
|
|
101
108
|
const event = payload._event;
|
|
102
|
-
|
|
103
|
-
// TODO fix double event
|
|
104
|
-
if (name && event.detail.value !== undefined) {
|
|
105
|
-
store.setFormFieldValue({
|
|
106
|
-
name: name,
|
|
107
|
-
value: event.detail.value,
|
|
108
|
-
props,
|
|
109
|
-
});
|
|
110
|
-
dispatchFormChange(
|
|
111
|
-
name,
|
|
112
|
-
event.detail.value,
|
|
113
|
-
store.selectFormValues(),
|
|
114
|
-
dispatchEvent,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const handlePopoverInputChange = (deps, payload) => {
|
|
120
|
-
const { store, dispatchEvent, props } = deps;
|
|
121
|
-
const event = payload._event;
|
|
122
|
-
const name = event.currentTarget.id.replace("popover-input-", "");
|
|
123
|
-
// TODO fix double event
|
|
109
|
+
let name = event.currentTarget.id.replace("field-", "");
|
|
124
110
|
if (name && event.detail.value !== undefined) {
|
|
125
111
|
store.setFormFieldValue({
|
|
126
112
|
name: name,
|
|
@@ -139,7 +125,7 @@ export const handlePopoverInputChange = (deps, payload) => {
|
|
|
139
125
|
export const handleSelectChange = (deps, payload) => {
|
|
140
126
|
const { store, dispatchEvent, render, props } = deps;
|
|
141
127
|
const event = payload._event;
|
|
142
|
-
const name = event.currentTarget.id.replace("
|
|
128
|
+
const name = event.currentTarget.id.replace("field-", "");
|
|
143
129
|
if (name) {
|
|
144
130
|
store.setFormFieldValue({
|
|
145
131
|
name: name,
|
|
@@ -159,7 +145,7 @@ export const handleSelectChange = (deps, payload) => {
|
|
|
159
145
|
export const handleColorPickerChange = (deps, payload) => {
|
|
160
146
|
const { store, dispatchEvent, props } = deps;
|
|
161
147
|
const event = payload._event;
|
|
162
|
-
const name = event.currentTarget.id.replace("
|
|
148
|
+
const name = event.currentTarget.id.replace("field-", "");
|
|
163
149
|
if (name && event.detail.value !== undefined) {
|
|
164
150
|
store.setFormFieldValue({
|
|
165
151
|
name: name,
|
|
@@ -178,7 +164,7 @@ export const handleColorPickerChange = (deps, payload) => {
|
|
|
178
164
|
export const handleSliderChange = (deps, payload) => {
|
|
179
165
|
const { store, dispatchEvent, props } = deps;
|
|
180
166
|
const event = payload._event;
|
|
181
|
-
const name = event.currentTarget.id.replace("
|
|
167
|
+
const name = event.currentTarget.id.replace("field-", "");
|
|
182
168
|
if (name && event.detail.value !== undefined) {
|
|
183
169
|
store.setFormFieldValue({
|
|
184
170
|
name: name,
|
|
@@ -197,7 +183,7 @@ export const handleSliderChange = (deps, payload) => {
|
|
|
197
183
|
export const handleSliderInputChange = (deps, payload) => {
|
|
198
184
|
const { store, dispatchEvent, props } = deps;
|
|
199
185
|
const event = payload._event;
|
|
200
|
-
const name = event.currentTarget.id.replace("
|
|
186
|
+
const name = event.currentTarget.id.replace("field-", "");
|
|
201
187
|
if (name && event.detail.value !== undefined) {
|
|
202
188
|
store.setFormFieldValue({
|
|
203
189
|
name: name,
|
|
@@ -254,7 +240,7 @@ export const handleWaveformClick = (deps, payload) => {
|
|
|
254
240
|
export const handleSelectAddOption = (deps, payload) => {
|
|
255
241
|
const { store, dispatchEvent } = deps;
|
|
256
242
|
const event = payload._event;
|
|
257
|
-
const name = event.currentTarget.id.replace("
|
|
243
|
+
const name = event.currentTarget.id.replace("field-", "");
|
|
258
244
|
dispatchEvent(
|
|
259
245
|
new CustomEvent("action-click", {
|
|
260
246
|
detail: {
|
|
@@ -286,7 +272,7 @@ export const handleTooltipMouseEnter = (deps, payload) => {
|
|
|
286
272
|
}
|
|
287
273
|
};
|
|
288
274
|
|
|
289
|
-
export const handleTooltipMouseLeave = (deps
|
|
275
|
+
export const handleTooltipMouseLeave = (deps) => {
|
|
290
276
|
const { store, render } = deps;
|
|
291
277
|
store.hideTooltip();
|
|
292
278
|
render();
|
|
@@ -64,9 +64,8 @@ export const handleInputChange = (deps, payload) => {
|
|
|
64
64
|
render();
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export const handleSubmitClick = (deps
|
|
67
|
+
export const handleSubmitClick = (deps) => {
|
|
68
68
|
const { store, render, dispatchEvent, getRefIds } = deps;
|
|
69
|
-
const event = payload._event;
|
|
70
69
|
const { input } = getRefIds()
|
|
71
70
|
const value = input.elm.value;
|
|
72
71
|
|
|
@@ -17,11 +17,7 @@ attrsSchema:
|
|
|
17
17
|
content:
|
|
18
18
|
type: string
|
|
19
19
|
|
|
20
|
-
refs:
|
|
21
|
-
popover:
|
|
22
|
-
|
|
23
20
|
template:
|
|
24
21
|
- rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement} no-overlay:
|
|
25
22
|
- rtgl-view slot=content bgc=background bc=border br=md p=sm ah=c av=c:
|
|
26
23
|
- rtgl-text ta=c s=sm c=foreground: ${content}
|
|
27
|
-
|
|
@@ -172,7 +172,11 @@ class RettangoliPopoverElement extends HTMLElement {
|
|
|
172
172
|
if (!this._dialogElement.open) {
|
|
173
173
|
setTimeout(() => {
|
|
174
174
|
if (this._dialogElement && !this._dialogElement.open) {
|
|
175
|
-
this.
|
|
175
|
+
if (this.hasAttribute('no-overlay')) {
|
|
176
|
+
this._dialogElement.show();
|
|
177
|
+
} else {
|
|
178
|
+
this._dialogElement.showModal();
|
|
179
|
+
}
|
|
176
180
|
}
|
|
177
181
|
}, 0);
|
|
178
182
|
}
|
package/src/primitives/slider.js
CHANGED
|
@@ -131,18 +131,18 @@ class RettangoliSliderElement extends HTMLElement {
|
|
|
131
131
|
this._inputElement.value = newValue;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
_onInput = (
|
|
134
|
+
_onInput = () => {
|
|
135
135
|
this.dispatchEvent(new CustomEvent('slider-input', {
|
|
136
136
|
detail: {
|
|
137
|
-
value: this._inputElement.value,
|
|
137
|
+
value: Number(this._inputElement.value),
|
|
138
138
|
},
|
|
139
139
|
}));
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
_onChange = (
|
|
142
|
+
_onChange = () => {
|
|
143
143
|
this.dispatchEvent(new CustomEvent('slider-change', {
|
|
144
144
|
detail: {
|
|
145
|
-
value: this._inputElement.value,
|
|
145
|
+
value: Number(this._inputElement.value),
|
|
146
146
|
},
|
|
147
147
|
}));
|
|
148
148
|
};
|
|
@@ -238,6 +238,8 @@ class RettangoliSliderElement extends HTMLElement {
|
|
|
238
238
|
|
|
239
239
|
if (value !== null) {
|
|
240
240
|
this._inputElement.value = value;
|
|
241
|
+
} else {
|
|
242
|
+
this._inputElement.value = min ?? 0;
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
if (min !== null) {
|