From ff712e09420eaefbb04b1c4f1d5243155fc6ecee Mon Sep 17 00:00:00 2001 From: domi7777 Date: Sun, 22 Dec 2024 14:29:06 +0000 Subject: [PATCH] deploy: 321e01e1bb1dce2c8656c3e3b8891a7f120cb23f --- assets/{index-EpgoMCE5.js => index-wNIA1T8-.js} | 14 +++++++------- index.html | 2 +- sw.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) rename assets/{index-EpgoMCE5.js => index-wNIA1T8-.js} (57%) diff --git a/assets/index-EpgoMCE5.js b/assets/index-wNIA1T8-.js similarity index 57% rename from assets/index-EpgoMCE5.js rename to assets/index-wNIA1T8-.js index 8de1dd7..93d9302 100644 --- a/assets/index-EpgoMCE5.js +++ b/assets/index-wNIA1T8-.js @@ -1,7 +1,7 @@ -var Vl=Object.defineProperty;var Tl=(n,e,t)=>e in n?Vl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var b=(n,e,t)=>(Tl(n,typeof e!="symbol"?e+"":e,t),t);import{P as U}from"./phaser-4DlKUGm0.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();const x={white:"#D3D3D3",black:"#1F2023FF",grey:"#2C2C2C",darkGrey:"#1F2023",orange:"#FDA341",red:"#F24E1E",blue:"#4A90E2",green:"#A0D8C5",yellow:"#F9F871",yellow2:"#F5C542",orange2:"#FF7F50",purple:"#9B59B6",pink:"#FFC0CB"},O={get white(){return K(x.white)},get black(){return K(x.black)},get grey(){return K(x.grey)},get darkGrey(){return K(x.darkGrey)},get orange(){return K(x.orange)},get red(){return K(x.red)},get blue(){return K(x.blue)},get green(){return K(x.green)},get yellow(){return K(x.yellow)},get yellow2(){return K(x.yellow2)},get orange2(){return K(x.orange2)},get purple(){return K(x.purple)},get pink(){return K(x.pink)}},K=n=>U.Display.Color.HexStringToColor(n),Pn=n=>U.Display.Color.RGBToString(n.red,n.green,n.blue),Kt={Icons:"Icons",Text:"Verdana, Geneva, sans-serif"},qt={tiny:"15px",small:"30px",medium:"50px",big:"90px"},_i={white:x.white},Sl=async()=>{const n=new FontFace(Kt.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(e=>console.error(e))};/*! Tweakpane 4.0.4 (c) 2016 cocopon, licensed under the MIT license. */function P(n){return n==null}function Ri(n){return n!==null&&typeof n=="object"}function gi(n){return n!==null&&typeof n=="object"}function Ll(n,e){if(n.length!==e.length)return!1;for(let t=0;t{const r=n[s],o=e[s];return gi(r)&&gi(o)?Object.assign(Object.assign({},i),{[s]:Qe(r,o)}):Object.assign(Object.assign({},i),{[s]:s in e?o:r})},{})}function Di(n){return Ri(n)?"target"in n:!1}const $l={alreadydisposed:()=>"View has been already disposed",invalidparams:n=>`Invalid parameters for '${n.name}'`,nomatchingcontroller:n=>`No matching controller for '${n.key}'`,nomatchingview:n=>`No matching view for '${JSON.stringify(n.params)}'`,notbindable:()=>"Value is not bindable",notcompatible:n=>`Not compatible with plugin '${n.id}'`,propertynotfound:n=>`Property '${n.name}' not found`,shouldneverhappen:()=>"This error should never happen"};let F=class vt{static alreadyDisposed(){return new vt({type:"alreadydisposed"})}static notBindable(){return new vt({type:"notbindable"})}static notCompatible(e,t){return new vt({type:"notcompatible",context:{id:`${e}.${t}`}})}static propertyNotFound(e){return new vt({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new vt({type:"shouldneverhappen"})}constructor(e){var t;this.message=(t=$l[e.type](e.context))!==null&&t!==void 0?t:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}toString(){return this.message}},Hs=class ao{constructor(e,t){this.obj_=e,this.key=t}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}read(){return this.obj_[this.key]}write(e){this.obj_[this.key]=e}writeProperty(e,t){const i=this.read();if(!ao.isBindable(i))throw F.notBindable();if(!(e in i))throw F.propertyNotFound(e);i[e]=t}},A=class{constructor(){this.observers_={}}on(e,t,i){var s;let r=this.observers_[e];return r||(r=this.observers_[e]=[]),r.push({handler:t,key:(s=i==null?void 0:i.key)!==null&&s!==void 0?s:t}),this}off(e,t){const i=this.observers_[e];return i&&(this.observers_[e]=i.filter(s=>s.key!==t)),this}emit(e,t){const i=this.observers_[e];i&&i.forEach(s=>{s.handler(t)})}},Al=class{constructor(e,t){var i;this.constraint_=t==null?void 0:t.constraint,this.equals_=(i=t==null?void 0:t.equals)!==null&&i!==void 0?i:(s,r)=>s===r,this.emitter=new A,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.constraint_?this.constraint_.constrain(e):e,r=this.rawValue_;this.equals_(r,s)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=s,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:s,sender:this}))}},Ml=class{constructor(e){this.emitter=new A,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.value_;s===e&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:this.value_,sender:this}))}},Ol=class{constructor(e){this.emitter=new A,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}};function k(n,e){const t=e==null?void 0:e.constraint,i=e==null?void 0:e.equals;return!t&&!i?new Ml(n):new Al(n,e)}function Rl(n){return[new Ol(n),(e,t)=>{n.setRawValue(e,t)}]}let v=class lo{constructor(e){this.emitter=new A,this.valMap_=e;for(const t in this.valMap_)this.valMap_[t].emitter.on("change",()=>{this.emitter.emit("change",{key:t,sender:this})})}static createCore(e){return Object.keys(e).reduce((i,s)=>Object.assign(i,{[s]:k(e[s])}),{})}static fromObject(e){const t=this.createCore(e);return new lo(t)}get(e){return this.valMap_[e].rawValue}set(e,t){this.valMap_[e].rawValue=t}value(e){return this.valMap_[e]}},tn=class{constructor(e){this.values=v.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(e,i),t)}},Dl=class{constructor(e){this.values=v.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");let s=e;return P(i)||(s=Math.max(s,i)),P(t)||(s=Math.min(s,t)),s}},Bl=class{constructor(e,t=0){this.step=e,this.origin=t}constrain(e){const t=this.origin%this.step,i=Math.round((e-t)/this.step);return t+i*this.step}},Nl=class{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}};const jl={"**":(n,e)=>Math.pow(n,e),"*":(n,e)=>n*e,"/":(n,e)=>n/e,"%":(n,e)=>n%e,"+":(n,e)=>n+e,"-":(n,e)=>n-e,"<<":(n,e)=>n<>":(n,e)=>n>>e,">>>":(n,e)=>n>>>e,"&":(n,e)=>n&e,"^":(n,e)=>n^e,"|":(n,e)=>n|e};let Il=class{constructor(e,t,i){this.left=t,this.operator=e,this.right=i}evaluate(){const e=jl[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}};const Fl={"+":n=>n,"-":n=>-n,"~":n=>~n};let zl=class{constructor(e,t){this.operator=e,this.expression=t}evaluate(){const e=Fl[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}};function Bi(n){return(e,t)=>{for(let i=0;ie.startsWith(s,t))[0];return i?(t+=i.length,t+=Ut(e,t).length,{cursor:t,operator:i}):null}function ac(n,e){return(t,i)=>{const s=n(t,i);if(!s)return null;i=s.cursor;let r=s.evaluable;for(;;){const o=oc(e,t,i);if(!o)break;i=o.cursor;const a=n(t,i);if(!a)return null;i=a.cursor,r=new Il(o.operator,r,a.evaluable)}return r?{cursor:i,evaluable:r}:null}}const lc=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,e)=>ac(n,e),po);function uo(n,e){return e+=Ut(n,e).length,lc(n,e)}function cc(n){const e=uo(n,0);return!e||e.cursor+Ut(n,e.cursor).length!==n.length?null:e.evaluable}function Pe(n){var e;const t=cc(n);return(e=t==null?void 0:t.evaluate())!==null&&e!==void 0?e:null}function ho(n){if(typeof n=="number")return n;if(typeof n=="string"){const e=Pe(n);if(!P(e))return e}return 0}function pc(n){return String(n)}function Z(n){return e=>e.toFixed(Math.max(Math.min(n,20),0))}function g(n,e,t,i,s){const r=(n-e)/(t-e);return i+r*(s-i)}function Gs(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function M(n,e,t){return Math.min(Math.max(n,e),t)}function mo(n,e){return(n%e+e)%e}function uc(n,e){return P(n.step)?Math.max(Gs(e),2):Gs(n.step)}function vo(n){var e;return(e=n.step)!==null&&e!==void 0?e:1}function bo(n,e){var t;const i=Math.abs((t=n.step)!==null&&t!==void 0?t:e);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function fo(n,e){return P(n.step)?null:new Bl(n.step,e)}function wo(n){return!P(n.max)&&!P(n.min)?new tn({max:n.max,min:n.min}):!P(n.max)||!P(n.min)?new Dl({max:n.max,min:n.min}):null}function _o(n,e){var t,i,s;return{formatter:(t=n.format)!==null&&t!==void 0?t:Z(uc(n,e)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:vo(n),pointerScale:(s=n.pointerScale)!==null&&s!==void 0?s:bo(n,e)}}function go(n){return{format:n.optional.function,keyScale:n.optional.number,max:n.optional.number,min:n.optional.number,pointerScale:n.optional.number,step:n.optional.number}}function ji(n){return{constraint:n.constraint,textProps:v.fromObject(_o(n.params,n.initialValue))}}let it=class{constructor(e){this.controller=e}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(e){this.controller.viewProps.set("disabled",e)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(e){this.controller.viewProps.set("hidden",e)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(e){return this.controller.importState(e)}exportState(){return this.controller.exportState()}},Nn=class{constructor(e){this.target=e}},nn=class extends Nn{constructor(e,t,i){super(e),this.value=t,this.last=i??!0}},hc=class extends Nn{constructor(e,t){super(e),this.expanded=t}},dc=class extends Nn{constructor(e,t){super(e),this.index=t}};class mc extends Nn{constructor(e,t){super(e),this.native=t}}let Gt=class extends it{constructor(e){super(e),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new A,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(e){this.controller.tag=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}refresh(){this.controller.value.fetch()}onValueChange_(e){const t=this.controller.value;this.emitter_.emit("change",new nn(this,t.binding.target.read(),e.options.last))}};class vc{constructor(e,t){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t,this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new A}get rawValue(){return this.value_.rawValue}set rawValue(e){this.value_.rawValue=e}setRawValue(e,t){this.value_.setRawValue(e,t)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function bc(n){if(!("binding"in n))return!1;const e=n.binding;return Di(e)&&"read"in e&&"write"in e}function fc(n,e){const i=Object.keys(e).reduce((s,r)=>{if(s===void 0)return;const o=e[r],a=o(n[r]);return a.succeeded?Object.assign(Object.assign({},s),{[r]:a.value}):void 0},{});return i}function wc(n,e){return n.reduce((t,i)=>{if(t===void 0)return;const s=e(i);if(!(!s.succeeded||s.value===void 0))return[...t,s.value]},[])}function _c(n){return n===null?!1:typeof n=="object"}function _e(n){return e=>t=>{if(!e&&t===void 0)return{succeeded:!1,value:void 0};if(e&&t===void 0)return{succeeded:!0,value:void 0};const i=n(t);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function Ws(n){return{custom:e=>_e(e)(n),boolean:_e(e=>typeof e=="boolean"?e:void 0)(n),number:_e(e=>typeof e=="number"?e:void 0)(n),string:_e(e=>typeof e=="string"?e:void 0)(n),function:_e(e=>typeof e=="function"?e:void 0)(n),constant:e=>_e(t=>t===e?e:void 0)(n),raw:_e(e=>e)(n),object:e=>_e(t=>{if(_c(t))return fc(t,e)})(n),array:e=>_e(t=>{if(Array.isArray(t))return wc(t,e)})(n)}}const Ci={optional:Ws(!0),required:Ws(!1)};function T(n,e){const t=e(Ci),i=Ci.required.object(t)(n);return i.succeeded?i.value:void 0}function ee(n,e,t,i){if(e&&!e(n))return!1;const s=T(n,t);return s?i(s):!1}function te(n,e){var t;return Qe((t=n==null?void 0:n())!==null&&t!==void 0?t:{},e)}function Ye(n){return"value"in n}function Co(n){if(!Ri(n)||!("binding"in n))return!1;const e=n.binding;return Di(e)}const ve="http://www.w3.org/2000/svg";function En(n){n.offsetHeight}function gc(n,e){const t=n.style.transition;n.style.transition="none",e(),n.style.transition=t}function Ii(n){return n.ontouchstart!==void 0}function Cc(){return globalThis}function xc(){return Cc().document}function yc(n){const e=n.ownerDocument.defaultView;return e&&"document"in e?n.getContext("2d",{willReadFrequently:!0}):null}const Pc={check:'',dropdown:'',p2dpad:''};function jn(n,e){const t=n.createElementNS(ve,"svg");return t.innerHTML=Pc[e],t}function xo(n,e,t){n.insertBefore(e,n.children[t])}function Fi(n){n.parentElement&&n.parentElement.removeChild(n)}function yo(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function Ec(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function Po(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function ye(n,e){n.emitter.on("change",t=>{e(t.rawValue)}),e(n.rawValue)}function be(n,e,t){ye(n.value(e),t)}const kc="tp";function f(n){return(t,i)=>[kc,"-",n,"v",t?`_${t}`:"",i?`-${i}`:""].join("")}const $t=f("lbl");function Vc(n,e){const t=n.createDocumentFragment();return e.split(` -`).map(s=>n.createTextNode(s)).forEach((s,r)=>{r>0&&t.appendChild(n.createElement("br")),t.appendChild(s)}),t}let Eo=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add($t()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add($t("l")),be(t.props,"label",r=>{P(r)?this.element.classList.add($t(void 0,"nol")):(this.element.classList.remove($t(void 0,"nol")),Ec(i),i.appendChild(Vc(e,r)))}),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("div");s.classList.add($t("v")),this.element.appendChild(s),this.valueElement=s}},ko=class{constructor(e,t){this.props=t.props,this.valueController=t.valueController,this.viewProps=t.valueController.viewProps,this.view=new Eo(e,{props:t.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(e){return ee(e,null,t=>({label:t.optional.string}),t=>(this.props.set("label",t.label),!0))}exportProps(){return te(null,{label:this.props.get("label")})}};function Tc(){return["veryfirst","first","last","verylast"]}const Ys=f(""),Xs={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};let In=class{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const t=this.view.element;this.blade.value("positions").emitter.on("change",()=>{Tc().forEach(i=>{t.classList.remove(Ys(void 0,Xs[i]))}),this.blade.get("positions").forEach(i=>{t.classList.add(Ys(void 0,Xs[i]))})}),this.viewProps.handleDispose(()=>{Fi(t)})}get parent(){return this.parent_}set parent(e){this.parent_=e,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(e){return ee(e,null,t=>({disabled:t.required.boolean,hidden:t.required.boolean}),t=>(this.viewProps.importState(t),!0))}exportState(){return te(null,Object.assign({},this.viewProps.exportState()))}},Ze=class extends In{constructor(e,t){if(t.value!==t.valueController.value)throw F.shouldNeverHappen();const i=t.valueController.viewProps,s=new ko(e,{blade:t.blade,props:t.props,valueController:t.valueController});super(Object.assign(Object.assign({},t),{view:new Eo(e,{props:t.props,viewProps:i}),viewProps:i})),this.labelController=s,this.value=t.value,this.valueController=t.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(e){return ee(e,t=>{var i,s,r;return super.importState(t)&&this.labelController.importProps(t)&&((r=(s=(i=this.valueController).importProps)===null||s===void 0?void 0:s.call(i,e))!==null&&r!==void 0?r:!0)},t=>({value:t.optional.raw}),t=>(t.value&&(this.value.rawValue=t.value),!0))}exportState(){var e,t,i;return te(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(t=(e=this.valueController).exportProps)===null||t===void 0?void 0:t.call(e))!==null&&i!==void 0?i:{}))}};function Qs(n){const e=Object.assign({},n);return delete e.value,e}class Vo extends Ze{constructor(e,t){super(e,t),this.tag=t.tag}importState(e){return ee(e,t=>super.importState(Qs(e)),t=>({tag:t.optional.string}),t=>(this.tag=t.tag,!0))}exportState(){return te(()=>Qs(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function Sc(n){return Ye(n)&&Co(n.value)}class Lc extends Vo{importState(e){return ee(e,t=>super.importState(t),t=>({binding:t.required.object({value:t.required.raw})}),t=>(this.value.binding.inject(t.binding.value),this.value.fetch(),!0))}}function $c(n){return Ye(n)&&bc(n.value)}function To(n,e){for(;n.lengthn.length?t.splice(0,t.length-n.length):To(t,n.length),t}class Rc{constructor(e){this.emitter=new A,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e.binding,this.value_=k(Ac(e.bufferSize)),this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.ticker=e.ticker,this.ticker.emitter.on("tick",this.onTick_),this.fetch()}get rawValue(){return this.value_.rawValue}set rawValue(e){this.value_.rawValue=e}setRawValue(e,t){this.value_.setRawValue(e,t)}fetch(){this.value_.rawValue=Oc(this.value_.rawValue,this.binding.read())}onTick_(){this.fetch()}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function Dc(n){if(!("binding"in n))return!1;const e=n.binding;return Di(e)&&"read"in e&&!("write"in e)}class Bc extends Vo{exportState(){return te(()=>super.exportState(),{binding:{readonly:!0}})}}function Nc(n){return Ye(n)&&Dc(n.value)}let jc=class extends it{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get title(){var e;return(e=this.controller.buttonController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.buttonController.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller.buttonController.emitter.on(e,r=>{i(new mc(this,r.nativeEvent))}),this}off(e,t){return this.controller.buttonController.emitter.off(e,t),this}};function Ic(n,e,t){t?n.classList.add(e):n.classList.remove(e)}function Pt(n,e){return t=>{Ic(n,e,t)}}function zi(n,e){ye(n,t=>{e.textContent=t??""})}const Zn=f("btn");let Fc=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Zn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("button");i.classList.add(Zn("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(Zn("t")),zi(t.props.value("title"),s),this.buttonElement.appendChild(s)}},zc=class{constructor(e,t){this.emitter=new A,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new Fc(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(e){return ee(e,null,t=>({title:t.optional.string}),t=>(this.props.set("title",t.title),!0))}exportProps(){return te(null,{title:this.props.get("title")})}onClick_(e){this.emitter.emit("click",{nativeEvent:e,sender:this})}},Zs=class extends In{constructor(e,t){const i=new zc(e,{props:t.buttonProps,viewProps:t.viewProps}),s=new ko(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:t.viewProps}),this.buttonController=i,this.labelController=s}importState(e){return ee(e,t=>super.importState(t)&&this.buttonController.importProps(t)&&this.labelController.importProps(t),()=>({}),()=>!0)}exportState(){return te(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}},So=class{constructor(e){const[t,i]=e.split("-"),s=t.split(".");this.major=parseInt(s[0],10),this.minor=parseInt(s[1],10),this.patch=parseInt(s[2],10),this.prerelease=i??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}};const Et=new So("2.0.4");function Y(n){return Object.assign({core:Et},n)}const Kc=Y({id:"button",type:"blade",accept(n){const e=T(n,t=>({title:t.required.string,view:t.required.constant("button"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new Zs(n.document,{blade:n.blade,buttonProps:v.fromObject({title:n.params.title}),labelProps:v.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof Zs?new jc(n.controller):null}});function qc(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function Uc(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function Hc(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}function Gc(n){return Ri(n)?"refresh"in n&&typeof n.refresh=="function":!1}function Wc(n,e){if(!Hs.isBindable(n))throw F.notBindable();return new Hs(n,e)}let Yc=class{constructor(e,t){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=e,this.emitter_=new A,this.pool_=t,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(e=>this.pool_.createApi(e))}addBinding(e,t,i){const s=i??{},r=this.controller_.element.ownerDocument,o=this.pool_.createBinding(r,Wc(e,t),s),a=this.pool_.createBindingApi(o);return this.add(a,s.index)}addFolder(e){return Uc(this,e)}addButton(e){return qc(this,e)}addTab(e){return Hc(this,e)}add(e,t){const i=e.controller;return this.controller_.rack.add(i,t),e}remove(e){this.controller_.rack.remove(e.controller)}addBlade(e){const t=this.controller_.element.ownerDocument,i=this.pool_.createBlade(t,e),s=this.pool_.createApi(i);return this.add(s,e.index)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}refresh(){this.children.forEach(e=>{Gc(e)&&e.refresh()})}onRackValueChange_(e){const t=e.bladeController,i=this.pool_.createApi(t),s=Co(t.value)?t.value.binding:null;this.emitter_.emit("change",new nn(i,s?s.target.read():t.value.rawValue,e.options.last))}},Ki=class extends it{constructor(e,t){super(e),this.rackApi_=new Yc(e.rackController,t)}refresh(){this.rackApi_.refresh()}},qi=class extends In{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}importState(e){return ee(e,t=>super.importState(t),t=>({children:t.required.array(t.required.raw)}),t=>this.rackController.rack.children.every((i,s)=>i.importState(t.children[s])))}exportState(){return te(()=>super.exportState(),{children:this.rackController.rack.children.map(e=>e.exportState())})}};function xi(n){return"rackController"in n}let Xc=class{constructor(e){this.emitter=new A,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const t of this.allItems())if(e(t))return t;return null}includes(e){return this.cache_.has(e)}add(e,t){if(this.includes(e))throw F.shouldNeverHappen();const i=t!==void 0?t:this.items_.length;this.items_.splice(i,0,e),this.cache_.add(e);const s=this.extract_(e);s&&(s.emitter.on("add",this.onSubListAdd_),s.emitter.on("remove",this.onSubListRemove_),s.allItems().forEach(r=>{this.cache_.add(r)})),this.emitter.emit("add",{index:i,item:e,root:this,target:this})}remove(e){const t=this.items_.indexOf(e);if(t<0)return;this.items_.splice(t,1),this.cache_.delete(e);const i=this.extract_(e);i&&(i.allItems().forEach(s=>{this.cache_.delete(s)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:t,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}};function Qc(n,e){for(let t=0;t!s.viewProps.get("hidden")),t=e[0],i=e[e.length-1];this.bcSet_.items.forEach(s=>{const r=[];s===t&&(r.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&r.push("veryfirst")),s===i&&(r.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&r.push("verylast")),s.blade.set("positions",r)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(t=>t.viewProps.get("disposed")).forEach(t=>{this.bcSet_.remove(t)})}onChildValueChange_(e){const t=Qc(this.find(Ye),e.sender);if(!t)throw F.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:t,options:e.options,sender:this})}onRackLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(e){this.emitter.emit("valuechange",{bladeController:e.bladeController,options:e.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}},Ui=class{constructor(e){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=e.element,this.viewProps=e.viewProps;const t=new Jc({blade:e.root?void 0:e.blade,viewProps:e.viewProps});t.emitter.on("add",this.onRackAdd_),t.emitter.on("remove",this.onRackRemove_),this.rack=t,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(e){e.root&&xo(this.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.root&&Fi(e.bladeController.view.element)}};function kt(){return new v({positions:k([],{equals:Ll})})}let Hi=class Lo extends v{constructor(e){super(e)}static create(e){const t={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=v.createCore(t);return new Lo(i)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!P(e)?`${e}px`:"auto"}bindExpandedClass(e,t){const i=()=>{this.styleExpanded?e.classList.add(t):e.classList.remove(t)};be(this,"expanded",i),be(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}};function ep(n,e){let t=0;return gc(e,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),En(e),t=e.clientHeight,n.set("temporaryExpanded",null),En(e)}),t}function Js(n,e){e.style.height=n.styleHeight}function Gi(n,e){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),P(n.get("expandedHeight"))){const t=ep(n,e);t>0&&n.set("expandedHeight",t)}n.set("shouldFixHeight",!0),En(e)}),n.emitter.on("change",()=>{Js(n,e)}),Js(n,e),e.addEventListener("transitionend",t=>{t.propertyName==="height"&&n.cleanUpTransition()})}let $o=class extends Ki{constructor(e,t){super(e,t),this.emitter_=new A,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new hc(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(e){this.controller.foldable.set("expanded",e)}get title(){return this.controller.props.get("title")}set title(e){this.controller.props.set("title",e)}get children(){return this.rackApi_.children}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){return this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}};const Ao=f("cnt");let tp=class{constructor(e,t){var i;this.className_=f((i=t.viewName)!==null&&i!==void 0?i:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),Ao()),t.viewProps.bindClassModifiers(this.element),this.foldable_=t.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),be(this.foldable_,"completed",Pt(this.element,this.className_(void 0,"cpl")));const s=e.createElement("button");s.classList.add(this.className_("b")),be(t.props,"title",c=>{P(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s;const r=e.createElement("div");r.classList.add(this.className_("i")),this.element.appendChild(r);const o=e.createElement("div");o.classList.add(this.className_("t")),zi(t.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=e.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=e.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}},yi=class extends qi{constructor(e,t){var i;const s=Hi.create((i=t.expanded)!==null&&i!==void 0?i:!0),r=new tp(e,{foldable:s,props:t.props,viewName:t.root?"rot":void 0,viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Ui({blade:t.blade,element:r.containerElement,root:t.root,viewProps:t.viewProps}),view:r})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=t.props,this.foldable=s,Gi(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(e){return ee(e,t=>super.importState(t),t=>({expanded:t.required.boolean,title:t.optional.string}),t=>(this.foldable.set("expanded",t.expanded),this.props.set("title",t.title),!0))}exportState(){return te(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}};const np=Y({id:"folder",type:"blade",accept(n){const e=T(n,t=>({title:t.required.string,view:t.required.constant("folder"),expanded:t.optional.boolean}));return e?{params:e}:null},controller(n){return new yi(n.document,{blade:n.blade,expanded:n.params.expanded,props:v.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof yi?new $o(n.controller,n.pool):null}}),ip=f("");function er(n,e){return Pt(n,ip(void 0,e))}let st=class Mo extends v{constructor(e){var t;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=Rl(k(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var t,i,s;const r=e??{};return new Mo(v.createCore({disabled:(t=r.disabled)!==null&&t!==void 0?t:!1,disposed:!1,hidden:(i=r.hidden)!==null&&i!==void 0?i:!1,parent:(s=r.parent)!==null&&s!==void 0?s:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){ye(this.globalDisabled_,er(e,"disabled")),be(this,"hidden",er(e,"hidden"))}bindDisabled(e){ye(this.globalDisabled_,t=>{e.disabled=t})}bindTabIndex(e){ye(this.globalDisabled_,t=>{e.tabIndex=t?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",t=>{t&&e()})}importState(e){this.set("disabled",e.disabled),this.set("hidden",e.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var t;const i=e.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}};const tr=f("tbp");let sp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(tr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(tr("c")),this.element.appendChild(i),this.containerElement=i}};const At=f("tbi");let rp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(At()),t.viewProps.bindClassModifiers(this.element),be(t.props,"selected",r=>{r?this.element.classList.add(At(void 0,"sel")):this.element.classList.remove(At(void 0,"sel"))});const i=e.createElement("button");i.classList.add(At("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(At("t")),zi(t.props.value("title"),s),this.buttonElement.appendChild(s),this.titleElement=s}},op=class{constructor(e,t){this.emitter=new A,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new rp(e,{props:t.props,viewProps:t.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}},Pi=class extends qi{constructor(e,t){const i=new sp(e,{viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Ui({blade:t.blade,element:i.containerElement,viewProps:t.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new op(e,{props:t.itemProps,viewProps:st.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=t.props,be(this.props,"selected",s=>{this.itemController.props.set("selected",s),this.viewProps.set("hidden",!s)})}get itemController(){return this.ic_}importState(e){return ee(e,t=>super.importState(t),t=>({selected:t.required.boolean,title:t.required.string}),t=>(this.ic_.props.set("selected",t.selected),this.ic_.props.set("title",t.title),!0))}exportState(){return te(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}},ap=class extends Ki{constructor(e,t){super(e,t),this.emitter_=new A,this.onSelect_=this.onSelect_.bind(this),this.pool_=t,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(e){const t=this.controller.view.element.ownerDocument,i=new Pi(t,{blade:kt(),itemProps:v.fromObject({selected:!1,title:e.title}),props:v.fromObject({selected:!1}),viewProps:st.create()}),s=this.pool_.createApi(i);return this.rackApi_.add(s,e.index)}removePage(e){this.rackApi_.remove(this.rackApi_.children[e])}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}onSelect_(e){this.emitter_.emit("select",new dc(this,e.rawValue))}},lp=class extends Ki{get title(){var e;return(e=this.controller.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.itemController.props.set("title",e)}get selected(){return this.controller.props.get("selected")}set selected(e){this.controller.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addBlade(e){return this.rackApi_.addBlade(e)}};const nr=-1;let cp=class{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=k(!0),this.selectedIndex=k(nr),this.items_=[]}add(e,t){const i=t??this.items_.length;this.items_.splice(i,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const t=this.items_.indexOf(e);t<0||(this.items_.splice(t,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=nr,this.empty.rawValue=!0;return}const e=this.items_.findIndex(t=>t.rawValue);e<0?(this.items_.forEach((t,i)=>{t.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((t,i)=>{t.rawValue=i===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const t=this.items_.findIndex(i=>i===e.sender);this.items_.forEach((i,s)=>{i.rawValue=s===t}),this.selectedIndex.rawValue=t}else this.keepSelection_()}};const Mt=f("tab");let pp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Mt(),Ao()),t.viewProps.bindClassModifiers(this.element),ye(t.empty,Pt(this.element,Mt(void 0,"nop")));const i=e.createElement("div");i.classList.add(Mt("t")),this.element.appendChild(i),this.itemsElement=i;const s=e.createElement("div");s.classList.add(Mt("i")),this.element.appendChild(s);const r=e.createElement("div");r.classList.add(Mt("c")),this.element.appendChild(r),this.contentsElement=r}},ir=class extends qi{constructor(e,t){const i=new cp,s=new pp(e,{empty:i.empty,viewProps:t.viewProps});super({blade:t.blade,rackController:new Ui({blade:t.blade,element:s.contentsElement,viewProps:t.viewProps}),view:s}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const r=this.rackController.rack;r.emitter.on("add",this.onRackAdd_),r.emitter.on("remove",this.onRackRemove_),this.tab=i}add(e,t){this.rackController.rack.add(e,t)}remove(e){this.rackController.rack.remove(this.rackController.rack.children[e])}onRackAdd_(e){if(!e.root)return;const t=e.bladeController;xo(this.view.itemsElement,t.itemController.view.element,e.index),t.itemController.viewProps.set("parent",this.viewProps),this.tab.add(t.props.value("selected"))}onRackRemove_(e){if(!e.root)return;const t=e.bladeController;Fi(t.itemController.view.element),t.itemController.viewProps.set("parent",null),this.tab.remove(t.props.value("selected"))}};const Oo=Y({id:"tab",type:"blade",accept(n){const e=T(n,t=>({pages:t.required.array(t.required.object({title:t.required.string})),view:t.required.constant("tab")}));return!e||e.pages.length===0?null:{params:e}},controller(n){const e=new ir(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(t=>{const i=new Pi(n.document,{blade:kt(),itemProps:v.fromObject({selected:!1,title:t.title}),props:v.fromObject({selected:!1}),viewProps:st.create()});e.add(i)}),e},api(n){return n.controller instanceof ir?new ap(n.controller,n.pool):n.controller instanceof Pi?new lp(n.controller,n.pool):null}});function up(n,e){const t=n.accept(e.params);if(!t)return null;const i=T(e.params,s=>({disabled:s.optional.boolean,hidden:s.optional.boolean}));return n.controller({blade:kt(),document:e.document,params:Object.assign(Object.assign({},t.params),{disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden}),viewProps:st.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}let Wi=class extends Gt{get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}},hp=class{constructor(){this.disabled=!1,this.emitter=new A}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}},dp=class{constructor(e,t){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new A,this.interval_=t,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}},sn=class{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((t,i)=>i.constrain(t),e)}};function kn(n,e){if(n instanceof e)return n;if(n instanceof sn){const t=n.constraints.reduce((i,s)=>i||(s instanceof e?s:null),null);if(t)return t}return null}let rn=class{constructor(e){this.values=v.fromObject({options:e})}constrain(e){const t=this.values.get("options");return t.length===0||t.filter(s=>s.value===e).length>0?e:t[0].value}};function on(n){var e;const t=Ci;if(Array.isArray(n))return(e=T({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||e===void 0?void 0:e.items;if(typeof n=="object")return t.required.raw(n).value}function Yi(n){if(Array.isArray(n))return n;const e=[];return Object.keys(n).forEach(t=>{e.push({text:t,value:n[t]})}),e}function Xi(n){return P(n)?null:new rn(Yi(n))}const Jn=f("lst");let mp=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.element=e.createElement("div"),this.element.classList.add(Jn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("select");i.classList.add(Jn("s")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const s=e.createElement("div");s.classList.add(Jn("m")),s.appendChild(jn(e,"dropdown")),this.element.appendChild(s),t.value.emitter.on("change",this.onValueChange_),this.value_=t.value,be(this.props_,"options",r=>{yo(this.selectElement),r.forEach(o=>{const a=e.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const e=this.props_.get("options").map(t=>t.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}},Fe=class{constructor(e,t){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new mp(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const t=e.currentTarget;this.value.rawValue=this.props.get("options")[t.selectedIndex].value}importProps(e){return ee(e,null,t=>({options:t.required.custom(on)}),t=>(this.props.set("options",Yi(t.options)),!0))}exportProps(){return te(null,{options:this.props.get("options")})}};const sr=f("pop");let vp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(sr()),t.viewProps.bindClassModifiers(this.element),ye(t.shows,Pt(this.element,sr(void 0,"v")))}},Ro=class{constructor(e,t){this.shows=k(!1),this.viewProps=t.viewProps,this.view=new vp(e,{shows:this.shows,viewProps:this.viewProps})}};const rr=f("txt");let bp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(rr()),t.viewProps.bindClassModifiers(this.element),this.props_=t.props,this.props_.emitter.on("change",this.onChange_);const i=e.createElement("input");i.classList.add(rr("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onChange_),this.value_=t.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}},Wt=class{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=t.parser,this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new bp(e,{props:t.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);P(s)||(this.value.rawValue=s),this.view.refresh()}};function fp(n){return String(n)}function Do(n){return n==="false"?!1:!!n}function or(n){return fp(n)}function wp(n){return e=>n.reduce((t,i)=>t!==null?t:i(e),null)}const _p=Z(0);function Vn(n){return _p(n)+"%"}function Bo(n){return String(n)}function Ei(n){return n}function Vt({primary:n,secondary:e,forward:t,backward:i}){let s=!1;function r(o){s||(s=!0,o(),s=!1)}n.emitter.on("change",o=>{r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),e.emitter.on("change",o=>{r(()=>{n.setRawValue(i(n.rawValue,e.rawValue),o.options)}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),{forceEmit:!1,last:!0})})}function X(n,e){const t=n*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+t:e.downKey?-t:0}function Yt(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function Ee(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function gp(n){return n==="ArrowUp"||n==="ArrowDown"}function No(n){return gp(n)||n==="ArrowLeft"||n==="ArrowRight"}function ei(n,e){var t,i;const s=e.ownerDocument.defaultView,r=e.getBoundingClientRect();return{x:n.pageX-(((t=s&&s.scrollX)!==null&&t!==void 0?t:0)+r.left),y:n.pageY-(((i=s&&s.scrollY)!==null&&i!==void 0?i:0)+r.top)}}let rt=class{constructor(e){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=e,this.emitter=new A,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const t=this.elem_.getBoundingClientRect();return{bounds:{width:t.width,height:t.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var t;e.preventDefault(),(t=e.currentTarget)===null||t===void 0||t.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(ei(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(ei(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const t=this.elem_.ownerDocument;t.removeEventListener("mousemove",this.onDocumentMouseMove_),t.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(ei(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchMove_(e){const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchEnd_(e){var t;const i=(t=e.targetTouches.item(0))!==null&&t!==void 0?t:this.lastTouch_,s=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(i?{x:i.clientX-s.left,y:i.clientY-s.top}:void 0),sender:this,shiftKey:e.shiftKey})}};const ne=f("txt");let Cp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ne(),ne(void 0,"num")),t.arrayPosition&&this.element.classList.add(ne(void 0,t.arrayPosition)),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(ne("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=t.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(ne()),this.inputElement.classList.add(ne("i"));const s=e.createElement("div");s.classList.add(ne("k")),this.element.appendChild(s),this.knobElement=s;const r=e.createElementNS(ve,"svg");r.classList.add(ne("g")),this.knobElement.appendChild(r);const o=e.createElementNS(ve,"path");o.classList.add(ne("gb")),r.appendChild(o),this.guideBodyElem_=o;const a=e.createElementNS(ve,"path");a.classList.add(ne("gh")),r.appendChild(a),this.guideHeadElem_=a;const l=e.createElement("div");l.classList.add(f("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(ne(void 0,"drg"));return}this.element.classList.add(ne(void 0,"drg"));const t=e.rawValue/this.props_.get("pointerScale"),i=t+(t>0?-1:t<0?1:0),s=M(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+s},0 L${i},4 L${i+s},8`,`M ${t},-1 L${t},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${t},4`);const r=this.props_.get("formatter");this.tooltipElem_.textContent=r(this.value.rawValue),this.tooltipElem_.style.left=`${t}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}},an=class{constructor(e,t){var i;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.parser_=t.parser,this.props=t.props,this.sliderProps_=(i=t.sliderProps)!==null&&i!==void 0?i:null,this.value=t.value,this.viewProps=t.viewProps,this.dragging_=k(null),this.view=new Cp(e,{arrayPosition:t.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const s=new rt(this.view.knobElement);s.emitter.on("down",this.onPointerDown_),s.emitter.on("move",this.onPointerMove_),s.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var t,i;const s=(t=this.sliderProps_)===null||t===void 0?void 0:t.get("min"),r=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=e;return s!==void 0&&(o=Math.max(o,s)),r!==void 0&&(o=Math.min(o,r)),o}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);P(s)||(this.value.rawValue=this.constrainValue_(s)),this.view.refresh()}onInputKeyDown_(e){const t=X(this.props.get("keyScale"),Yt(e));t!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+t),{forceEmit:!1,last:!1})}onInputKeyUp_(e){X(this.props.get("keyScale"),Yt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const t=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+t*this.props.get("pointerScale"))}onPointerMove_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}};const ti=f("sld");let xp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ti()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ti("t")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(ti("k")),this.trackElement.appendChild(s),this.knobElement=s,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.update_()}update_(){const e=M(g(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}},yp=class{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.props=t.props,this.view=new xp(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new rt(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){e.point&&this.value.setRawValue(g(M(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("min"),this.props.get("max")),t)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=X(this.props.get("keyScale"),Ee(e));t!==0&&this.value.setRawValue(this.value.rawValue+t,{forceEmit:!1,last:!1})}onKeyUp_(e){X(this.props.get("keyScale"),Ee(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ni=f("sldtxt");let Pp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ni());const i=e.createElement("div");i.classList.add(ni("s")),this.sliderView_=t.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ni("t")),this.textView_=t.textView,s.appendChild(this.textView_.element),this.element.appendChild(s)}},Tn=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sliderC_=new yp(e,{props:t.sliderProps,value:t.value,viewProps:this.viewProps}),this.textC_=new an(e,{parser:t.parser,props:t.textProps,sliderProps:t.sliderProps,value:t.value,viewProps:t.viewProps}),this.view=new Pp(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(e){return ee(e,null,t=>({max:t.required.number,min:t.required.number}),t=>{const i=this.sliderC_.props;return i.set("max",t.max),i.set("min",t.min),!0})}exportProps(){const e=this.sliderC_.props;return te(null,{max:e.get("max"),min:e.get("min")})}};function jo(n){return{sliderProps:new v({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new v({formatter:k(n.formatter),keyScale:n.keyScale,pointerScale:k(n.pointerScale)})}}const Ep={containerUnitSize:"cnt-usz"};function Io(n){return`--${Ep[n]}`}function Xt(n){return go(n)}function Be(n){if(gi(n))return T(n,Xt)}function Ce(n,e){if(!n)return;const t=[],i=fo(n,e);i&&t.push(i);const s=wo(n);return s&&t.push(s),new sn(t)}function kp(n){return n?n.major===Et.major:!1}function Fo(n){if(n==="inline"||n==="popup")return n}function ln(n,e){n.write(e)}const bn=f("ckb");let Vp=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(bn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(bn("l")),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("input");s.classList.add(bn("i")),s.type="checkbox",this.labelElement.appendChild(s),this.inputElement=s,t.viewProps.bindDisabled(this.inputElement);const r=e.createElement("div");r.classList.add(bn("w")),this.labelElement.appendChild(r);const o=jn(e,"check");r.appendChild(o),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}},Tp=class{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.onLabelMouseDown_=this.onLabelMouseDown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Vp(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.labelElement.addEventListener("mousedown",this.onLabelMouseDown_)}onInputChange_(e){const t=e.currentTarget;this.value.rawValue=t.checked,e.preventDefault(),e.stopPropagation()}onLabelMouseDown_(e){e.preventDefault()}};function Sp(n){const e=[],t=Xi(n.options);return t&&e.push(t),new sn(e)}const Lp=Y({id:"input-bool",type:"input",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=T(e,i=>({options:i.optional.custom(on),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Do,constraint:n=>Sp(n.params),writer:n=>ln},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&kn(i,rn);return s?new Fe(e,{props:new v({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Tp(e,{value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof Fe?new Wi(n.controller):null}}),Ue=f("col");let $p=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ue()),t.foldable.bindExpandedClass(this.element,Ue(void 0,"expanded")),be(t.foldable,"completed",Pt(this.element,Ue(void 0,"cpl")));const i=e.createElement("div");i.classList.add(Ue("h")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Ue("s")),i.appendChild(s),this.swatchElement=s;const r=e.createElement("div");if(r.classList.add(Ue("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(Ue("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}};function Ap(n,e,t){const i=M(n/255,0,1),s=M(e/255,0,1),r=M(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c=0,p=0;const u=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(s-r)/l:s===o?c=2+(r-i)/l:c=4+(i-s)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function Mp(n,e,t){const i=(n%360+360)%360,s=M(e/100,0,1),r=M(t/100,0,1),o=(1-Math.abs(2*r-1))*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o/2;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function Op(n,e,t){const i=M(n/255,0,1),s=M(e/255,0,1),r=M(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c;l===0?c=0:o===i?c=60*(((s-r)/l%6+6)%6):o===s?c=60*((r-i)/l+2):c=60*((i-s)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function zo(n,e,t){const i=mo(n,360),s=M(e/100,0,1),r=M(t/100,0,1),o=r*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function Rp(n,e,t){const i=t+e*(100-Math.abs(2*t-100))/200;return[n,i!==0?e*(100-Math.abs(2*t-100))/i:0,t+e*(100-Math.abs(2*t-100))/(2*100)]}function Dp(n,e,t){const i=100-Math.abs(t*(200-e)/100-100);return[n,i!==0?e*t/i:0,t*(200-e)/(2*100)]}function fe(n){return[n[0],n[1],n[2]]}function Fn(n,e){return[n[0],n[1],n[2],e]}const Bp={hsl:{hsl:(n,e,t)=>[n,e,t],hsv:Rp,rgb:Mp},hsv:{hsl:Dp,hsv:(n,e,t)=>[n,e,t],rgb:zo},rgb:{hsl:Ap,hsv:Op,rgb:(n,e,t)=>[n,e,t]}};function Ct(n,e){return[e==="float"?1:n==="rgb"?255:360,e==="float"?1:n==="rgb"?255:100,e==="float"?1:n==="rgb"?255:100]}function Np(n,e){return n===e?e:mo(n,e)}function Ko(n,e,t){var i;const s=Ct(e,t);return[e==="rgb"?M(n[0],0,s[0]):Np(n[0],s[0]),M(n[1],0,s[1]),M(n[2],0,s[2]),M((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function ar(n,e,t,i){const s=Ct(e,t),r=Ct(e,i);return n.map((o,a)=>o/s[a]*r[a])}function qo(n,e,t){const i=ar(n,e.mode,e.type,"int"),s=Bp[e.mode][t.mode](...i);return ar(s,t.mode,"int",t.type)}let C=class Uo{static black(){return new Uo([0,0,0],"rgb")}constructor(e,t){this.type="int",this.mode=t,this.comps_=Ko(e,t,this.type)}getComponents(e){return Fn(qo(fe(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}};const Se=f("colp");let jp=class{constructor(e,t){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(Se()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Se("hsv"));const s=e.createElement("div");s.classList.add(Se("sv")),this.svPaletteView_=t.svPaletteView,s.appendChild(this.svPaletteView_.element),i.appendChild(s);const r=e.createElement("div");r.classList.add(Se("h")),this.hPaletteView_=t.hPaletteView,r.appendChild(this.hPaletteView_.element),i.appendChild(r),this.element.appendChild(i);const o=e.createElement("div");if(o.classList.add(Se("rgb")),this.textsView_=t.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),t.alphaViews){this.alphaViews_={palette:t.alphaViews.palette,text:t.alphaViews.text};const a=e.createElement("div");a.classList.add(Se("a"));const l=e.createElement("div");l.classList.add(Se("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=e.createElement("div");c.classList.add(Se("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(t=>t.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}};function Ip(n){return n==="int"?"int":n==="float"?"float":void 0}function Qi(n){return T(n,e=>({color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(Ip)}),expanded:e.optional.boolean,picker:e.optional.custom(Fo),readonly:e.optional.constant(!1)}))}function Je(n){return n?.1:1}function Ho(n){var e;return(e=n.color)===null||e===void 0?void 0:e.type}let Zi=class{constructor(e,t){this.type="float",this.mode=t,this.comps_=Ko(e,t,this.type)}getComponents(e){return Fn(qo(fe(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}};const Fp={int:(n,e)=>new C(n,e),float:(n,e)=>new Zi(n,e)};function Ji(n,e,t){return Fp[t](n,e)}function zp(n){return n.type==="float"}function Kp(n){return n.type==="int"}function qp(n){const e=n.getComponents(),t=Ct(n.mode,"int");return new C([Math.round(g(e[0],0,1,0,t[0])),Math.round(g(e[1],0,1,0,t[1])),Math.round(g(e[2],0,1,0,t[2])),e[3]],n.mode)}function Up(n){const e=n.getComponents(),t=Ct(n.mode,"int");return new Zi([g(e[0],0,t[0],0,1),g(e[1],0,t[1],0,1),g(e[2],0,t[2],0,1),e[3]],n.mode)}function G(n,e){if(n.type===e)return n;if(Kp(n)&&e==="float")return Up(n);if(zp(n)&&e==="int")return qp(n);throw F.shouldNeverHappen()}function Hp(n,e){return n.alpha===e.alpha&&n.mode===e.mode&&n.notation===e.notation&&n.type===e.type}function re(n,e){const t=n.match(/^(.+)%$/);return Math.min(t?parseFloat(t[1])*.01*e:parseFloat(n),e)}const Gp={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Go(n){const e=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(n);const t=parseFloat(e[1]),i=e[2];return Gp[i](t)}function Wo(n){const e=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[re(e[1],255),re(e[2],255),re(e[3],255)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function Wp(n){const e=Wo(n);return e?new C(e,"rgb"):null}function Yo(n){const e=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[re(e[1],255),re(e[2],255),re(e[3],255),re(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Yp(n){const e=Yo(n);return e?new C(e,"rgb"):null}function Xo(n){const e=n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Go(e[1]),re(e[2],100),re(e[3],100)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function Xp(n){const e=Xo(n);return e?new C(e,"hsl"):null}function Qo(n){const e=n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Go(e[1]),re(e[2],100),re(e[3],100),re(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Qp(n){const e=Qo(n);return e?new C(e,"hsl"):null}function Zo(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const t=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function Zp(n){const e=Zo(n);return e?new C(e,"rgb"):null}function Jo(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),g(parseInt(e[4]+e[4],16),0,255,0,1)];const t=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),g(parseInt(t[4],16),0,255,0,1)]:null}function Jp(n){const e=Jo(n);return e?new C(e,"rgb"):null}function ea(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function lr(n){return e=>{const t=ea(e);return t?Ji(t,"rgb",n):null}}function ta(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function cr(n){return e=>{const t=ta(e);return t?Ji(t,"rgb",n):null}}const eu=[{parser:Zo,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:Jo,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:Wo,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:Yo,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Xo,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Qo,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:ea,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:ta,result:{alpha:!0,mode:"rgb",notation:"object"}}];function tu(n){return eu.reduce((e,{parser:t,result:i})=>e||(t(n)?i:null),null)}function nu(n,e="int"){const t=tu(n);return t?t.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},t),{type:"int"}):t.notation==="func"?Object.assign(Object.assign({},t),{type:e}):null:null}function cn(n){const e=[Zp,Jp,Wp,Yp,Xp,Qp];n==="int"&&e.push(lr("int"),cr("int")),n==="float"&&e.push(lr("float"),cr("float"));const t=wp(e);return i=>{const s=t(i);return s?G(s,n):null}}function iu(n){const e=cn("int");if(typeof n!="string")return C.black();const t=e(n);return t??C.black()}function na(n){const e=M(Math.floor(n),0,255).toString(16);return e.length===1?`0${e}`:e}function es(n,e="#"){const t=fe(n.getComponents("rgb")).map(na).join("");return`${e}${t}`}function ts(n,e="#"){const t=n.getComponents("rgb"),i=[t[0],t[1],t[2],t[3]*255].map(na).join("");return`${e}${i}`}function ia(n){const e=Z(0),t=G(n,"int");return`rgb(${fe(t.getComponents("rgb")).map(s=>e(s)).join(", ")})`}function wn(n){const e=Z(2),t=Z(0);return`rgba(${G(n,"int").getComponents("rgb").map((r,o)=>(o===3?e:t)(r)).join(", ")})`}function su(n){const e=[Z(0),Vn,Vn],t=G(n,"int");return`hsl(${fe(t.getComponents("hsl")).map((s,r)=>e[r](s)).join(", ")})`}function ru(n){const e=[Z(0),Vn,Vn,Z(2)];return`hsla(${G(n,"int").getComponents("hsl").map((s,r)=>e[r](s)).join(", ")})`}function sa(n,e){const t=Z(e==="float"?2:0),i=["r","g","b"],s=G(n,e);return`{${fe(s.getComponents("rgb")).map((o,a)=>`${i[a]}: ${t(o)}`).join(", ")}}`}function ou(n){return e=>sa(e,n)}function ra(n,e){const t=Z(2),i=Z(e==="float"?2:0),s=["r","g","b","a"];return`{${G(n,e).getComponents("rgb").map((a,l)=>{const c=l===3?t:i;return`${s[l]}: ${c(a)}`}).join(", ")}}`}function au(n){return e=>ra(e,n)}const lu=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:es},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:ts},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:ia},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:wn},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:su},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:ru},...["int","float"].reduce((n,e)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:ou(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:au(e)}],[])];function oa(n){return lu.reduce((e,t)=>e||(Hp(t.format,n)?t.stringifier:null),null)}const Ot=f("apl");let cu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Ot()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Ot("b")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Ot("c")),i.appendChild(s),this.colorElem_=s;const r=e.createElement("div");r.classList.add(Ot("m")),this.element.appendChild(r),this.markerElem_=r;const o=e.createElement("div");o.classList.add(Ot("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const e=this.value.rawValue,t=e.getComponents("rgb"),i=new C([t[0],t[1],t[2],0],"rgb"),s=new C([t[0],t[1],t[2],255],"rgb"),r=["to right",wn(i),wn(s)];this.colorElem_.style.background=`linear-gradient(${r.join(",")})`,this.previewElem_.style.backgroundColor=wn(e);const o=g(t[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}},pu=class{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new cu(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new rt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=e.point.x/e.bounds.width,s=this.value.rawValue,[r,o,a]=s.getComponents("hsv");this.value.setRawValue(new C([r,o,a,i],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=X(Je(!0),Ee(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new C([s,r,o,a+t],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){X(Je(!0),Ee(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ct=f("coltxt");function uu(n){const e=n.createElement("select"),t=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return e.appendChild(t.reduce((i,s)=>{const r=n.createElement("option");return r.textContent=s.text,r.value=s.value,i.appendChild(r),i},n.createDocumentFragment())),e}let hu=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ct()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ct("m")),this.modeElem_=uu(e),this.modeElem_.classList.add(ct("ms")),i.appendChild(this.modeSelectElement),t.viewProps.bindDisabled(this.modeElem_);const s=e.createElement("div");s.classList.add(ct("mm")),s.appendChild(jn(e,"dropdown")),i.appendChild(s),this.element.appendChild(i);const r=e.createElement("div");r.classList.add(ct("w")),this.element.appendChild(r),this.inputsElem_=r,this.inputViews_=t.inputViews,this.applyInputViews_(),ye(t.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(e){this.inputViews_=e,this.applyInputViews_()}applyInputViews_(){yo(this.inputsElem_);const e=this.element.ownerDocument;this.inputViews_.forEach(t=>{const i=e.createElement("div");i.classList.add(ct("c")),i.appendChild(t.element),this.inputsElem_.appendChild(i)})}};function du(n){return Z(n==="float"?2:0)}function mu(n,e,t){const i=Ct(n,e)[t];return new tn({min:0,max:i})}function vu(n,e,t){return new an(n,{arrayPosition:t===0?"fst":t===2?"lst":"mid",parser:e.parser,props:v.fromObject({formatter:du(e.colorType),keyScale:Je(!1),pointerScale:e.colorType==="float"?.01:1}),value:k(0,{constraint:mu(e.colorMode,e.colorType,t)}),viewProps:e.viewProps})}function bu(n,e){const t={colorMode:e.colorMode,colorType:e.colorType,parser:Pe,viewProps:e.viewProps};return[0,1,2].map(i=>{const s=vu(n,t,i);return Vt({primary:e.value,secondary:s.value,forward(r){return G(r,e.colorType).getComponents(e.colorMode)[i]},backward(r,o){const a=e.colorMode,c=G(r,e.colorType).getComponents(a);c[i]=o;const p=Ji(Fn(fe(c),c[3]),a,e.colorType);return G(p,"int")}}),s})}function fu(n,e){const t=new Wt(n,{parser:cn("int"),props:v.fromObject({formatter:es}),value:k(C.black()),viewProps:e.viewProps});return Vt({primary:e.value,secondary:t.value,forward:i=>new C(fe(i.getComponents()),i.mode),backward:(i,s)=>new C(Fn(fe(s.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[t]}function wu(n){return n!=="hex"}let _u=class{constructor(e,t){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=t.colorType,this.value=t.value,this.viewProps=t.viewProps,this.colorMode=k(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new hu(e,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(e){const t=this.colorMode.rawValue;return wu(t)?bu(e,{colorMode:t,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):fu(e,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(e){const t=e.currentTarget;this.colorMode.rawValue=t.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}};const ii=f("hpl");let gu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(ii()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(ii("c")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ii("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=this.value.rawValue,[t]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=ia(new C([t,100,100],"hsv"));const i=g(t,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}},Cu=class{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new gu(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new rt(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=g(M(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),s=this.value.rawValue,[,r,o,a]=s.getComponents("hsv");this.value.setRawValue(new C([i,r,o,a],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=X(Je(!1),Ee(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new C([s+t,r,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){X(Je(!1),Ee(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const si=f("svp"),pr=64;let xu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(si()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("canvas");i.height=pr,i.width=pr,i.classList.add(si("c")),this.element.appendChild(i),this.canvasElement=i;const s=e.createElement("div");s.classList.add(si("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=yc(this.canvasElement);if(!e)return;const i=this.value.rawValue.getComponents("hsv"),s=this.canvasElement.width,r=this.canvasElement.height,o=e.getImageData(0,0,s,r),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,s)=>{const r=i.getComponents();return r[3]=s,new C(r,i.mode)}}),this.textsC_=new _u(e,{colorType:t.colorType,value:this.value,viewProps:this.viewProps}),this.view=new jp(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:t.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}};const ri=f("colsw");let Eu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.element=e.createElement("div"),this.element.classList.add(ri()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ri("sw")),this.element.appendChild(i),this.swatchElem_=i;const s=e.createElement("button");s.classList.add(ri("b")),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=ts(e)}onValueChange_(){this.update_()}},ku=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Eu(e,{value:this.value,viewProps:this.viewProps})}},ns=class{constructor(e,t){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Hi.create(t.expanded),this.swatchC_=new ku(e,{value:this.value,viewProps:this.viewProps});const i=this.swatchC_.view.buttonElement;i.addEventListener("blur",this.onButtonBlur_),i.addEventListener("click",this.onButtonClick_),this.textC_=new Wt(e,{parser:t.parser,props:v.fromObject({formatter:t.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new $p(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=t.pickerLayout==="popup"?new Ro(e,{viewProps:this.viewProps}):null;const s=new Pu(e,{colorType:t.colorType,supportsAlpha:t.supportsAlpha,value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(r=>{r.addEventListener("blur",this.onPopupChildBlur_),r.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(s.view.element),Vt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:r=>r,backward:(r,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Gi(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=Po(e);i&&t.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Ii(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}};function Vu(n){return fe(n.getComponents("rgb")).reduce((e,t)=>e<<8|Math.floor(t)&255,0)}function Tu(n){return n.getComponents("rgb").reduce((e,t,i)=>{const s=Math.floor(i===3?t*255:t)&255;return e<<8|s},0)>>>0}function Su(n){return new C([n>>16&255,n>>8&255,n&255],"rgb")}function Lu(n){return new C([n>>24&255,n>>16&255,n>>8&255,g(n&255,0,255,0,1)],"rgb")}function $u(n){return typeof n!="number"?C.black():Su(n)}function Au(n){return typeof n!="number"?C.black():Lu(n)}function _n(n,e){return typeof n!="object"||P(n)?!1:e in n&&typeof n[e]=="number"}function aa(n){return _n(n,"r")&&_n(n,"g")&&_n(n,"b")}function la(n){return aa(n)&&_n(n,"a")}function ca(n){return aa(n)}function is(n,e){if(n.mode!==e.mode||n.type!==e.type)return!1;const t=n.getComponents(),i=e.getComponents();for(let s=0;s{ln(t,e(i))}:null}function Ou(n){const e=n?Tu:Vu;return(t,i)=>{ln(t,e(i))}}function Ru(n,e,t){const s=G(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b),n.writeProperty("a",s.a)}function Du(n,e,t){const s=G(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b)}function Bu(n,e){return(t,i)=>{n?Ru(t,i,e):Du(t,i,e)}}function Nu(n){var e;return!!(!((e=n==null?void 0:n.color)===null||e===void 0)&&e.alpha)}function ju(n){return n?e=>ts(e,"0x"):e=>es(e,"0x")}function Iu(n){return"color"in n||n.view==="color"}const Fu=Y({id:"input-color-number",type:"input",accept:(n,e)=>{if(typeof n!="number"||!Iu(e))return null;const t=Qi(e);return t?{initialValue:n,params:Object.assign(Object.assign({},t),{supportsAlpha:Nu(e)})}:null},binding:{reader:n=>n.params.supportsAlpha?Au:$u,equals:is,writer:n=>Ou(n.params.supportsAlpha)},controller:n=>{var e,t;return new ns(n.document,{colorType:"int",expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:ju(n.params.supportsAlpha),parser:cn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function zu(n,e){if(!ca(n))return G(C.black(),e);if(e==="int"){const t=ur(n);return new C(t,"rgb")}if(e==="float"){const t=ur(n);return new Zi(t,"rgb")}return G(C.black(),"int")}function Ku(n){return la(n)}function qu(n){return e=>{const t=zu(e,n);return G(t,"int")}}function Uu(n,e){return t=>n?ra(t,e):sa(t,e)}const Hu=Y({id:"input-color-object",type:"input",accept:(n,e)=>{var t;if(!ca(n))return null;const i=Qi(e);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(t=Ho(e))!==null&&t!==void 0?t:"int"})}:null},binding:{reader:n=>qu(n.params.colorType),equals:is,writer:n=>Bu(Ku(n.initialValue),n.params.colorType)},controller:n=>{var e,t;const i=la(n.initialValue);return new ns(n.document,{colorType:n.params.colorType,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Uu(i,n.params.colorType),parser:cn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),Gu=Y({id:"input-color-string",type:"input",accept:(n,e)=>{if(typeof n!="string"||e.view==="text")return null;const t=nu(n,Ho(e));if(!t)return null;const i=oa(t);if(!i)return null;const s=Qi(e);return s?{initialValue:n,params:Object.assign(Object.assign({},s),{format:t,stringifier:i})}:null},binding:{reader:()=>iu,equals:is,writer:n=>{const e=Mu(n.params.format);if(!e)throw F.notBindable();return e}},controller:n=>{var e,t;return new ns(n.document,{colorType:n.params.format.type,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:n.params.stringifier,parser:cn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});let ss=class{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const t=this.asm_.toComponents(e).map((i,s)=>{var r,o;return(o=(r=this.components[s])===null||r===void 0?void 0:r.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(t)}};const hr=f("pndtxt");let Wu=class{constructor(e,t){this.textViews=t.textViews,this.element=e.createElement("div"),this.element.classList.add(hr()),this.textViews.forEach(i=>{const s=e.createElement("div");s.classList.add(hr("a")),s.appendChild(i.element),this.element.appendChild(s)})}};function Yu(n,e,t){return new an(n,{arrayPosition:t===0?"fst":t===e.axes.length-1?"lst":"mid",parser:e.parser,props:e.axes[t].textProps,value:k(0,{constraint:e.axes[t].constraint}),viewProps:e.viewProps})}let rs=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.acs_=t.axes.map((i,s)=>Yu(e,t,s)),this.acs_.forEach((i,s)=>{Vt({primary:this.value,secondary:i.value,forward:r=>t.assembly.toComponents(r)[s],backward:(r,o)=>{const a=t.assembly.toComponents(r);return a[s]=o,t.assembly.fromComponents(a)}})}),this.view=new Wu(e,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}},Xu=class extends Gt{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}};function Qu(n,e){const t=[],i=fo(n,e);i&&t.push(i);const s=wo(n);s&&t.push(s);const r=Xi(n.options);return r&&t.push(r),new sn(t)}const Zu=Y({id:"input-number",type:"input",accept:(n,e)=>{if(typeof n!="number")return null;const t=T(e,i=>Object.assign(Object.assign({},go(i)),{options:i.optional.custom(on),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>ho,constraint:n=>Qu(n.params,n.initialValue),writer:n=>ln},controller:n=>{const e=n.value,t=n.constraint,i=t&&kn(t,rn);if(i)return new Fe(n.document,{props:new v({options:i.values.value("options")}),value:e,viewProps:n.viewProps});const s=_o(n.params,e.rawValue),r=t&&kn(t,tn);return r?new Tn(n.document,Object.assign(Object.assign({},jo(Object.assign(Object.assign({},s),{keyScale:k(s.keyScale),max:r.values.value("max"),min:r.values.value("min")}))),{parser:Pe,value:e,viewProps:n.viewProps})):new an(n.document,{parser:Pe,props:v.fromObject(s),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof Tn?new Xu(n.controller):n.controller.valueController instanceof Fe?new Wi(n.controller):null}});let je=class{constructor(e=0,t=0){this.x=e,this.y=t}getComponents(){return[this.x,this.y]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y}toObject(){return{x:this.x,y:this.y}}};const pa={toComponents:n=>n.getComponents(),fromComponents:n=>new je(...n)},pt=f("p2d");let Ju=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(pt()),t.viewProps.bindClassModifiers(this.element),ye(t.expanded,Pt(this.element,pt(void 0,"expanded")));const i=e.createElement("div");i.classList.add(pt("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(pt("b")),s.appendChild(jn(e,"p2dpad")),t.viewProps.bindDisabled(s),i.appendChild(s),this.buttonElement=s;const r=e.createElement("div");if(r.classList.add(pt("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(pt("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}};const Le=f("p2dp");let eh=class{constructor(e,t){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=e.createElement("div"),this.element.classList.add(Le()),t.layout==="popup"&&this.element.classList.add(Le(void 0,"p")),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Le("p")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const s=e.createElementNS(ve,"svg");s.classList.add(Le("g")),this.padElement.appendChild(s),this.svgElem_=s;const r=e.createElementNS(ve,"line");r.classList.add(Le("ax")),r.setAttributeNS(null,"x1","0"),r.setAttributeNS(null,"y1","50%"),r.setAttributeNS(null,"x2","100%"),r.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(r);const o=e.createElementNS(ve,"line");o.classList.add(Le("ax")),o.setAttributeNS(null,"x1","50%"),o.setAttributeNS(null,"y1","0"),o.setAttributeNS(null,"x2","50%"),o.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(o);const a=e.createElementNS(ve,"line");a.classList.add(Le("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=e.createElement("div");l.classList.add(Le("m")),this.padElement.appendChild(l),this.markerElem_=l,t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,t]=this.value.rawValue.getComponents(),i=this.props_.get("max"),s=g(e,-i,+i,0,100),r=g(t,-i,+i,0,100),o=this.props_.get("invertsY")?100-r:r;this.lineElem_.setAttributeNS(null,"x2",`${s}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${s}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}};function dr(n,e,t){return[X(e[0],Ee(n)),X(e[1],Yt(n))*(t?1:-1)]}let th=class{constructor(e,t){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new eh(e,{layout:t.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new rt(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=this.props.get("max"),s=g(e.point.x,0,e.bounds.width,-i,+i),r=g(this.props.get("invertsY")?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-i,+i);this.value.setRawValue(new je(s,r),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){No(e.key)&&e.preventDefault();const[t,i]=dr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(new je(this.value.rawValue.x+t,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[t,i]=dr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}},nh=class{constructor(e,t){var i,s;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Hi.create(t.expanded),this.popC_=t.pickerLayout==="popup"?new Ro(e,{viewProps:this.viewProps}):null;const r=new th(e,{layout:t.pickerLayout,props:new v({invertsY:k(t.invertsY),max:k(t.max),xKeyScale:t.axes[0].textProps.value("keyScale"),yKeyScale:t.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.textC_=new rs(e,{assembly:pa,axes:t.axes,parser:t.parser,value:this.value,viewProps:this.viewProps}),this.view=new Ju(e,{expanded:this.foldable_.value("expanded"),pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(i=this.view.buttonElement)===null||i===void 0||i.addEventListener("blur",this.onPadButtonBlur_),(s=this.view.buttonElement)===null||s===void 0||s.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),Vt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:o=>o,backward:(o,a)=>a})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Gi(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=Po(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!Ii(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}};function ih(n){return je.isObject(n)?new je(n.x,n.y):new je}function sh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y)}function rh(n,e){return new ss({assembly:pa,components:[Ce(Object.assign(Object.assign({},n),n.x),e.x),Ce(Object.assign(Object.assign({},n),n.y),e.y)]})}function mr(n,e){var t,i;if(!P(n.min)||!P(n.max))return Math.max(Math.abs((t=n.min)!==null&&t!==void 0?t:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const s=vo(n);return Math.max(Math.abs(s)*10,Math.abs(e)*10)}function oh(n,e){var t,i;const s=mr(Qe(n,(t=n.x)!==null&&t!==void 0?t:{}),e.x),r=mr(Qe(n,(i=n.y)!==null&&i!==void 0?i:{}),e.y);return Math.max(s,r)}function ah(n){if(!("y"in n))return!1;const e=n.y;return e&&"inverted"in e?!!e.inverted:!1}const lh=Y({id:"input-point2d",type:"input",accept:(n,e)=>{if(!je.isObject(n))return null;const t=T(e,i=>Object.assign(Object.assign({},Xt(i)),{expanded:i.optional.boolean,picker:i.optional.custom(Fo),readonly:i.optional.constant(!1),x:i.optional.custom(Be),y:i.optional.object(Object.assign(Object.assign({},Xt(i)),{inverted:i.optional.boolean}))}));return t?{initialValue:n,params:t}:null},binding:{reader:()=>ih,constraint:n=>rh(n.params,n.initialValue),equals:je.equals,writer:()=>sh},controller:n=>{var e,t;const i=n.document,s=n.value,r=n.constraint,o=[n.params.x,n.params.y];return new nh(i,{axes:s.rawValue.getComponents().map((a,l)=>{var c;return ji({constraint:r.components[l],initialValue:a,params:Qe(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,invertsY:ah(n.params),max:oh(n.params,s.rawValue),parser:Pe,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps})}});let ft=class{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y,s=e.z;return!(typeof t!="number"||typeof i!="number"||typeof s!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}toObject(){return{x:this.x,y:this.y,z:this.z}}};const ua={toComponents:n=>n.getComponents(),fromComponents:n=>new ft(...n)};function ch(n){return ft.isObject(n)?new ft(n.x,n.y,n.z):new ft}function ph(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z)}function uh(n,e){return new ss({assembly:ua,components:[Ce(Object.assign(Object.assign({},n),n.x),e.x),Ce(Object.assign(Object.assign({},n),n.y),e.y),Ce(Object.assign(Object.assign({},n),n.z),e.z)]})}const hh=Y({id:"input-point3d",type:"input",accept:(n,e)=>{if(!ft.isObject(n))return null;const t=T(e,i=>Object.assign(Object.assign({},Xt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Be),y:i.optional.custom(Be),z:i.optional.custom(Be)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>ch,constraint:n=>uh(n.params,n.initialValue),equals:ft.equals,writer:n=>ph},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new rs(n.document,{assembly:ua,axes:e.rawValue.getComponents().map((s,r)=>{var o;return ji({constraint:t.components[r],initialValue:s,params:Qe(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:Pe,value:e,viewProps:n.viewProps})}});let wt=class{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y,s=e.z,r=e.w;return!(typeof t!="number"||typeof i!="number"||typeof s!="number"||typeof r!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}};const ha={toComponents:n=>n.getComponents(),fromComponents:n=>new wt(...n)};function dh(n){return wt.isObject(n)?new wt(n.x,n.y,n.z,n.w):new wt}function mh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z),n.writeProperty("w",e.w)}function vh(n,e){return new ss({assembly:ha,components:[Ce(Object.assign(Object.assign({},n),n.x),e.x),Ce(Object.assign(Object.assign({},n),n.y),e.y),Ce(Object.assign(Object.assign({},n),n.z),e.z),Ce(Object.assign(Object.assign({},n),n.w),e.w)]})}const bh=Y({id:"input-point4d",type:"input",accept:(n,e)=>{if(!wt.isObject(n))return null;const t=T(e,i=>Object.assign(Object.assign({},Xt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Be),x:i.optional.custom(Be),y:i.optional.custom(Be),z:i.optional.custom(Be)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>dh,constraint:n=>vh(n.params,n.initialValue),equals:wt.equals,writer:n=>mh},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new rs(n.document,{assembly:ha,axes:e.rawValue.getComponents().map((s,r)=>{var o;return ji({constraint:t.components[r],initialValue:s,params:Qe(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:Pe,value:e,viewProps:n.viewProps})}});function fh(n){const e=[],t=Xi(n.options);return t&&e.push(t),new sn(e)}const wh=Y({id:"input-string",type:"input",accept:(n,e)=>{if(typeof n!="string")return null;const t=T(e,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(on)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Bo,constraint:n=>fh(n.params),writer:n=>ln},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&kn(i,rn);return s?new Fe(e,{props:new v({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Wt(e,{parser:r=>r,props:v.fromObject({formatter:Ei}),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof Fe?new Wi(n.controller):null}}),pn={monitor:{defaultInterval:200,defaultRows:3}},vr=f("mll");let _h=class{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(vr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("textarea");i.classList.add(vr("i")),i.style.height=`calc(var(${Io("containerUnitSize")}) * ${t.rows})`,i.readOnly=!0,t.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.textareaElem_,t=e.scrollTop===e.scrollHeight-e.clientHeight,i=[];this.value.rawValue.forEach(s=>{s!==void 0&&i.push(this.formatter_(s))}),e.textContent=i.join(` -`),t&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}},os=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new _h(e,{formatter:t.formatter,rows:t.rows,value:this.value,viewProps:this.viewProps})}};const br=f("sgl");let gh=class{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(br()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(br("i")),i.readOnly=!0,i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.value.rawValue,t=e[e.length-1];this.inputElement.value=t!==void 0?this.formatter_(t):""}onValueUpdate_(){this.update_()}},as=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new gh(e,{formatter:t.formatter,value:this.value,viewProps:this.viewProps})}};const Ch=Y({id:"monitor-bool",type:"monitor",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=T(e,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Do},controller:n=>{var e;return n.value.rawValue.length===1?new as(n.document,{formatter:or,value:n.value,viewProps:n.viewProps}):new os(n.document,{formatter:or,rows:(e=n.params.rows)!==null&&e!==void 0?e:pn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});let xh=class extends Gt{get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}};const $e=f("grl");let yh=class{constructor(e,t){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add($e()),t.viewProps.bindClassModifiers(this.element),this.formatter_=t.formatter,this.props_=t.props,this.cursor_=t.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=e.createElementNS(ve,"svg");i.classList.add($e("g")),i.style.height=`calc(var(${Io("containerUnitSize")}) * ${t.rows})`,this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(ve,"polyline");this.svgElem_.appendChild(s),this.lineElem_=s;const r=e.createElement("div");r.classList.add($e("t"),f("tt")()),this.element.appendChild(r),this.tooltipElem_=r,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:e,clientHeight:t}=this.element,i=this.value.rawValue.length-1,s=this.props_.get("min"),r=this.props_.get("max"),o=[];this.value.rawValue.forEach((u,_)=>{if(u===void 0)return;const B=g(_,0,i,0,e),N=g(u,s,r,t,0);o.push([B,N].join(","))}),this.lineElem_.setAttributeNS(null,"points",o.join(" "));const a=this.tooltipElem_,l=this.value.rawValue[this.cursor_.rawValue];if(l===void 0){a.classList.remove($e("t","a"));return}const c=g(this.cursor_.rawValue,0,i,0,e),p=g(l,s,r,t,0);a.style.left=`${c}px`,a.style.top=`${p}px`,a.textContent=`${this.formatter_(l)}`,a.classList.contains($e("t","a"))||(a.classList.add($e("t","a"),$e("t","in")),En(a),a.classList.remove($e("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}},da=class{constructor(e,t){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.cursor_=k(-1),this.view=new yh(e,{cursor:this.cursor_,formatter:t.formatter,rows:t.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Ii(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new rt(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(e){return ee(e,null,t=>({max:t.required.number,min:t.required.number}),t=>(this.props.set("max",t.max),this.props.set("min",t.min),!0))}exportProps(){return te(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const{clientWidth:t}=this.view.element;this.cursor_.rawValue=Math.floor(g(e.offsetX,0,t,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(g(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}};function ki(n){return P(n.format)?Z(2):n.format}function Ph(n){var e;return n.value.rawValue.length===1?new as(n.document,{formatter:ki(n.params),value:n.value,viewProps:n.viewProps}):new os(n.document,{formatter:ki(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:pn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function Eh(n){var e,t,i;return new da(n.document,{formatter:ki(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:pn.monitor.defaultRows,props:v.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function fr(n){return n.view==="graph"}const kh=Y({id:"monitor-number",type:"monitor",accept:(n,e)=>{if(typeof n!="number")return null;const t=T(e,i=>({format:i.optional.function,max:i.optional.number,min:i.optional.number,readonly:i.required.constant(!0),rows:i.optional.number,view:i.optional.string}));return t?{initialValue:n,params:t}:null},binding:{defaultBufferSize:n=>fr(n)?64:1,reader:n=>ho},controller:n=>fr(n.params)?Eh(n):Ph(n),api:n=>n.controller.valueController instanceof da?new xh(n.controller):null}),Vh=Y({id:"monitor-string",type:"monitor",accept:(n,e)=>{if(typeof n!="string")return null;const t=T(e,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Bo},controller:n=>{var e;const t=n.value;return t.rawValue.length>1||n.params.multiline?new os(n.document,{formatter:Ei,rows:(e=n.params.rows)!==null&&e!==void 0?e:pn.monitor.defaultRows,value:t,viewProps:n.viewProps}):new as(n.document,{formatter:Ei,value:t,viewProps:n.viewProps})}});class Th{constructor(){this.map_=new Map}get(e){var t;return(t=this.map_.get(e))!==null&&t!==void 0?t:null}has(e){return this.map_.has(e)}add(e,t){return this.map_.set(e,t),e.viewProps.handleDispose(()=>{this.map_.delete(e)}),t}}class Sh{constructor(e){this.target=e.target,this.reader_=e.reader,this.writer_=e.writer}read(){return this.reader_(this.target.read())}write(e){this.writer_(this.target,e)}inject(e){this.write(this.reader_(e))}}function Lh(n,e){var t;const i=n.accept(e.target.read(),e.params);if(P(i))return null;const s={target:e.target,initialValue:i.initialValue,params:i.params},r=T(e.params,u=>({disabled:u.optional.boolean,hidden:u.optional.boolean,label:u.optional.string,tag:u.optional.string})),o=n.binding.reader(s),a=n.binding.constraint?n.binding.constraint(s):void 0,l=new Sh({reader:o,target:e.target,writer:n.binding.writer(s)}),c=new vc(k(o(i.initialValue),{constraint:a,equals:n.binding.equals}),l),p=n.controller({constraint:a,document:e.document,initialValue:i.initialValue,params:i.params,value:c,viewProps:st.create({disabled:r==null?void 0:r.disabled,hidden:r==null?void 0:r.hidden})});return new Lc(e.document,{blade:kt(),props:v.fromObject({label:"label"in e.params?(t=r==null?void 0:r.label)!==null&&t!==void 0?t:null:e.target.key}),tag:r==null?void 0:r.tag,value:c,valueController:p})}class $h{constructor(e){this.target=e.target,this.reader_=e.reader}read(){return this.reader_(this.target.read())}}function Ah(n,e){return e===0?new hp:new dp(n,e??pn.monitor.defaultInterval)}function Mh(n,e){var t,i,s;const r=n.accept(e.target.read(),e.params);if(P(r))return null;const o={target:e.target,initialValue:r.initialValue,params:r.params},a=T(e.params,_=>({bufferSize:_.optional.number,disabled:_.optional.boolean,hidden:_.optional.boolean,interval:_.optional.number,label:_.optional.string})),l=n.binding.reader(o),c=(i=(t=a==null?void 0:a.bufferSize)!==null&&t!==void 0?t:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(r.params))!==null&&i!==void 0?i:1,p=new Rc({binding:new $h({reader:l,target:e.target}),bufferSize:c,ticker:Ah(e.document,a==null?void 0:a.interval)}),u=n.controller({document:e.document,params:r.params,value:p,viewProps:st.create({disabled:a==null?void 0:a.disabled,hidden:a==null?void 0:a.hidden})});return u.viewProps.bindDisabled(p.ticker),u.viewProps.handleDispose(()=>{p.ticker.dispose()}),new Bc(e.document,{blade:kt(),props:v.fromObject({label:"label"in e.params?(s=a==null?void 0:a.label)!==null&&s!==void 0?s:null:e.target.key}),value:p,valueController:u})}class Oh{constructor(e){this.pluginsMap_={blades:[],inputs:[],monitors:[]},this.apiCache_=e}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(e,t){if(!kp(t.core))throw F.notCompatible(e,t.id);t.type==="blade"?this.pluginsMap_.blades.unshift(t):t.type==="input"?this.pluginsMap_.inputs.unshift(t):t.type==="monitor"&&this.pluginsMap_.monitors.unshift(t)}createInput_(e,t,i){return this.pluginsMap_.inputs.reduce((s,r)=>s??Lh(r,{document:e,target:t,params:i}),null)}createMonitor_(e,t,i){return this.pluginsMap_.monitors.reduce((s,r)=>s??Mh(r,{document:e,params:i,target:t}),null)}createBinding(e,t,i){const s=t.read();if(P(s))throw new F({context:{key:t.key},type:"nomatchingcontroller"});const r=this.createInput_(e,t,i);if(r)return r;const o=this.createMonitor_(e,t,i);if(o)return o;throw new F({context:{key:t.key},type:"nomatchingcontroller"})}createBlade(e,t){const i=this.pluginsMap_.blades.reduce((s,r)=>s??up(r,{document:e,params:t}),null);if(!i)throw new F({type:"nomatchingview",context:{params:t}});return i}createInputBindingApi_(e){const t=this.pluginsMap_.inputs.reduce((i,s)=>{var r,o;return i||((o=(r=s.api)===null||r===void 0?void 0:r.call(s,{controller:e}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(e,t??new Gt(e))}createMonitorBindingApi_(e){const t=this.pluginsMap_.monitors.reduce((i,s)=>{var r,o;return i||((o=(r=s.api)===null||r===void 0?void 0:r.call(s,{controller:e}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(e,t??new Gt(e))}createBindingApi(e){if(this.apiCache_.has(e))return this.apiCache_.get(e);if($c(e))return this.createInputBindingApi_(e);if(Nc(e))return this.createMonitorBindingApi_(e);throw F.shouldNeverHappen()}createApi(e){if(this.apiCache_.has(e))return this.apiCache_.get(e);if(Sc(e))return this.createBindingApi(e);const t=this.pluginsMap_.blades.reduce((i,s)=>i??s.api({controller:e,pool:this}),null);if(!t)throw F.shouldNeverHappen();return this.apiCache_.add(e,t)}}const Rh=new Th;function Dh(){const n=new Oh(Rh);return[lh,hh,bh,wh,Zu,Gu,Hu,Fu,Lp,Ch,Vh,kh,Kc,np,Oo].forEach(e=>{n.register("core",e)}),n}class Bh extends it{constructor(e){super(e),this.emitter_=new A,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new nn(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}class Nh extends it{}class jh extends it{constructor(e){super(e),this.emitter_=new A,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new nn(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}class Ih extends it{constructor(e){super(e),this.emitter_=new A,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new nn(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get formatter(){return this.controller.valueController.props.get("formatter")}set formatter(e){this.controller.valueController.props.set("formatter",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}const Fh=function(){return{id:"list",type:"blade",core:Et,accept(n){const e=T(n,t=>({options:t.required.custom(on),value:t.required.raw,view:t.required.constant("list"),label:t.optional.string}));return e?{params:e}:null},controller(n){const e=new rn(Yi(n.params.options)),t=k(n.params.value,{constraint:e}),i=new Fe(n.document,{props:new v({options:e.values.value("options")}),value:t,viewProps:n.viewProps});return new Ze(n.document,{blade:n.blade,props:v.fromObject({label:n.params.label}),value:t,valueController:i})},api(n){return!(n.controller instanceof Ze)||!(n.controller.valueController instanceof Fe)?null:new Bh(n.controller)}}}();class zh extends $o{constructor(e,t){super(e,t)}get element(){return this.controller.view.element}}class Kh extends yi{constructor(e,t){super(e,{expanded:t.expanded,blade:t.blade,props:t.props,root:!0,viewProps:t.viewProps})}}const wr=f("spr");class qh{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(wr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("hr");i.classList.add(wr("r")),this.element.appendChild(i)}}class _r extends In{constructor(e,t){super(Object.assign(Object.assign({},t),{view:new qh(e,{viewProps:t.viewProps})}))}}const Uh={id:"separator",type:"blade",core:Et,accept(n){const e=T(n,t=>({view:t.required.constant("separator")}));return e?{params:e}:null},controller(n){return new _r(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof _r?new Nh(n.controller):null}},Hh={id:"slider",type:"blade",core:Et,accept(n){const e=T(n,t=>({max:t.required.number,min:t.required.number,view:t.required.constant("slider"),format:t.optional.function,label:t.optional.string,value:t.optional.number}));return e?{params:e}:null},controller(n){var e,t;const i=(e=n.params.value)!==null&&e!==void 0?e:0,s=new tn({max:n.params.max,min:n.params.min}),r=k(i,{constraint:s}),o=new Tn(n.document,Object.assign(Object.assign({},jo({formatter:(t=n.params.format)!==null&&t!==void 0?t:pc,keyScale:k(1),max:s.values.value("max"),min:s.values.value("min"),pointerScale:bo(n.params,i)})),{parser:Pe,value:r,viewProps:n.viewProps}));return new Ze(n.document,{blade:n.blade,props:v.fromObject({label:n.params.label}),value:r,valueController:o})},api(n){return!(n.controller instanceof Ze)||!(n.controller.valueController instanceof Tn)?null:new jh(n.controller)}},Gh=function(){return{id:"text",type:"blade",core:Et,accept(n){const e=T(n,t=>({parse:t.required.function,value:t.required.raw,view:t.required.constant("text"),format:t.optional.function,label:t.optional.string}));return e?{params:e}:null},controller(n){var e;const t=k(n.params.value),i=new Wt(n.document,{parser:n.params.parse,props:v.fromObject({formatter:(e=n.params.format)!==null&&e!==void 0?e:s=>String(s)}),value:t,viewProps:n.viewProps});return new Ze(n.document,{blade:n.blade,props:v.fromObject({label:n.params.label}),value:t,valueController:i})},api(n){return!(n.controller instanceof Ze)||!(n.controller.valueController instanceof Wt)?null:new Ih(n.controller)}}}();function Wh(n){const e=n.createElement("div");return e.classList.add(f("dfw")()),n.body&&n.body.appendChild(e),e}function Yh(n,e,t){if(n.querySelector(`style[data-tp-style=${e}]`))return;const i=n.createElement("style");i.dataset.tpStyle=e,i.textContent=t,n.head.appendChild(i)}class Xh extends zh{constructor(e){var t,i;const s=e??{},r=(t=s.document)!==null&&t!==void 0?t:xc(),o=Dh(),a=new Kh(r,{expanded:s.expanded,blade:kt(),props:v.fromObject({title:s.title}),viewProps:st.create()});super(a,o),this.pool_=o,this.containerElem_=(i=s.container)!==null&&i!==void 0?i:Wh(r),this.containerElem_.appendChild(this.element),this.doc_=r,this.usesDefaultWrapper_=!s.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw F.alreadyDisposed();return this.doc_}dispose(){const e=this.containerElem_;if(!e)throw F.alreadyDisposed();if(this.usesDefaultWrapper_){const t=e.parentElement;t&&t.removeChild(e)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(e){e.css&&Yh(this.document,`plugin-${e.id}`,e.css),("plugin"in e?[e.plugin]:"plugins"in e?e.plugins:[]).forEach(i=>{this.pool_.register(e.id,i)})}setUpDefaultPlugins_(){this.registerPlugin({id:"default",css:'.tp-tbiv_b,.tp-coltxtv_ms,.tp-colswv_b,.tp-ckbv_i,.tp-sglv_i,.tp-mllv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-rotv_b,.tp-fldv_b,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--bld-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--cnt-usz);line-height:var(--cnt-usz);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tbpv_c>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-vp))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tbpv_c>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--cnt-usp)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tbpv_c>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tbpv_c>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tbpv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tbpv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tbpv_c>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tbpv_c>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--bld-br);border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tbpv_c .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tbpv_c>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tbpv_c>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--bld-br)}.tp-tbpv_c .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--bld-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);overflow:hidden;padding-left:var(--cnt-hp);padding-right:calc(4px + var(--cnt-usz) + var(--cnt-hp));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-hp) + (var(--cnt-usz) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-vp);padding-top:var(--cnt-vp);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-sglv_i,.tp-mllv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--mo-fg);height:var(--cnt-usz);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-sglv_i::-webkit-scrollbar,.tp-mllv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-sglv_i::-webkit-scrollbar-corner,.tp-mllv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-sglv_i::-webkit-scrollbar-thumb,.tp-mllv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-rotv{--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-br: var(--tp-base-border-radius, 6px);--bs-ff: var(--tp-base-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--bld-br: var(--tp-blade-border-radius, 2px);--bld-hp: var(--tp-blade-horizontal-padding, 4px);--bld-vw: var(--tp-blade-value-width, 160px);--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--cnt-hp: var(--tp-container-horizontal-padding, 4px);--cnt-vp: var(--tp-container-vertical-padding, 4px);--cnt-usp: var(--tp-container-unit-spacing, 4px);--cnt-usz: var(--tp-container-unit-size, 20px);--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--bld-br);cursor:pointer;display:block;height:var(--cnt-usz);position:relative;width:var(--cnt-usz)}.tp-ckbv_w svg{display:block;height:16px;inset:0;margin:auto;opacity:0;position:absolute;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--cnt-usz)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--cnt-usp);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--cnt-usp)}.tp-colpv_rgb{display:flex;margin-top:var(--cnt-usp);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-vp);padding-top:calc(var(--cnt-vp) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-hp));position:absolute;right:calc(-1*var(--cnt-hp));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--bld-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--cnt-usz)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{inset:0;position:absolute}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--bld-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;inset:0;position:absolute}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--bld-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{cursor:pointer;display:block;height:var(--cnt-usz);left:0;position:absolute;top:0;width:var(--cnt-usz)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--bld-br);content:"";display:block;inset:0;position:absolute}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--bld-br);color:var(--lbl-fg);cursor:pointer;height:var(--cnt-usz);line-height:var(--cnt-usz);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--cnt-usz)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-hp);padding-right:var(--cnt-hp)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:var(--bld-vw)}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 var(--bld-hp);width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--cnt-usz)*3);line-height:var(--cnt-usz);padding-left:var(--bld-hp);padding-right:var(--bld-hp);resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--cnt-usz);margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--cnt-usp);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-p2dpv{padding-left:calc(var(--cnt-usz) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:var(--bld-vw);padding:var(--cnt-vp) var(--cnt-hp);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--cnt-usz);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin:auto;position:absolute}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin-bottom:auto;margin-top:auto;position:absolute}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--bld-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--cnt-usz) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-hp) + 4px);padding-right:calc(var(--cnt-hp) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);content:"";inset:0 0 2px;pointer-events:none;position:absolute}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);opacity:.5;overflow:hidden;position:relative;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-tbpv_c{padding-bottom:var(--cnt-vp);padding-left:4px;padding-top:var(--cnt-vp)}.tp-txtv{position:relative}.tp-txtv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:calc(var(--bld-hp) - 5px);position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--cnt-usz) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--bld-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--bs-ff);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--cnt-usz) + var(--cnt-hp));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0;transition-delay:0s;transition-duration:0s}.tp-rotv.tp-rotv-not>.tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst.tp-fldv-expanded>.tp-fldv_b{transition-delay:0s;transition-duration:0s}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}',plugins:[Fh,Uh,Hh,Oo,Gh]})}}new So("4.0.4");function E(n){return n==null}function ls(n){return n!==null&&typeof n=="object"}function Vi(n){return n!==null&&typeof n=="object"}function Qh(n,e){if(n.length!==e.length)return!1;for(let t=0;t{const r=n[s],o=e[s];return Vi(r)&&Vi(o)?Object.assign(Object.assign({},i),{[s]:et(r,o)}):Object.assign(Object.assign({},i),{[s]:s in e?o:r})},{})}function Zh(n){return ls(n)?"target"in n:!1}const Jh={alreadydisposed:()=>"View has been already disposed",invalidparams:n=>`Invalid parameters for '${n.name}'`,nomatchingcontroller:n=>`No matching controller for '${n.key}'`,nomatchingview:n=>`No matching view for '${JSON.stringify(n.params)}'`,notbindable:()=>"Value is not bindable",notcompatible:n=>`Not compatible with plugin '${n.id}'`,propertynotfound:n=>`Property '${n.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class H{static alreadyDisposed(){return new H({type:"alreadydisposed"})}static notBindable(){return new H({type:"notbindable"})}static notCompatible(e,t){return new H({type:"notcompatible",context:{id:`${e}.${t}`}})}static propertyNotFound(e){return new H({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new H({type:"shouldneverhappen"})}constructor(e){var t;this.message=(t=Jh[e.type](e.context))!==null&&t!==void 0?t:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}toString(){return this.message}}class Sn{constructor(e,t){this.obj_=e,this.key=t}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}read(){return this.obj_[this.key]}write(e){this.obj_[this.key]=e}writeProperty(e,t){const i=this.read();if(!Sn.isBindable(i))throw H.notBindable();if(!(e in i))throw H.propertyNotFound(e);i[e]=t}}class z{constructor(){this.observers_={}}on(e,t){let i=this.observers_[e];return i||(i=this.observers_[e]=[]),i.push({handler:t}),this}off(e,t){const i=this.observers_[e];return i&&(this.observers_[e]=i.filter(s=>s.handler!==t)),this}emit(e,t){const i=this.observers_[e];i&&i.forEach(s=>{s.handler(t)})}}class ed{constructor(e,t){var i;this.constraint_=t==null?void 0:t.constraint,this.equals_=(i=t==null?void 0:t.equals)!==null&&i!==void 0?i:(s,r)=>s===r,this.emitter=new z,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.constraint_?this.constraint_.constrain(e):e,r=this.rawValue_;this.equals_(r,s)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=s,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:s,sender:this}))}}class td{constructor(e){this.emitter=new z,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.value_;s===e&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:this.value_,sender:this}))}}class nd{constructor(e){this.emitter=new z,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function S(n,e){const t=e==null?void 0:e.constraint,i=e==null?void 0:e.equals;return!t&&!i?new td(n):new ed(n,e)}function id(n){return[new nd(n),(e,t)=>{n.setRawValue(e,t)}]}class d{constructor(e){this.emitter=new z,this.valMap_=e;for(const t in this.valMap_)this.valMap_[t].emitter.on("change",()=>{this.emitter.emit("change",{key:t,sender:this})})}static createCore(e){return Object.keys(e).reduce((i,s)=>Object.assign(i,{[s]:S(e[s])}),{})}static fromObject(e){const t=this.createCore(e);return new d(t)}get(e){return this.valMap_[e].rawValue}set(e,t){this.valMap_[e].rawValue=t}value(e){return this.valMap_[e]}}class un{constructor(e){this.values=d.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(e,i),t)}}class cs{constructor(e){this.values=d.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");let s=e;return E(i)||(s=Math.max(s,i)),E(t)||(s=Math.min(s,t)),s}}class sd{constructor(e,t=0){this.step=e,this.origin=t}constrain(e){const t=this.origin%this.step,i=Math.round((e-t)/this.step);return t+i*this.step}}class rd{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}}const od={"**":(n,e)=>Math.pow(n,e),"*":(n,e)=>n*e,"/":(n,e)=>n/e,"%":(n,e)=>n%e,"+":(n,e)=>n+e,"-":(n,e)=>n-e,"<<":(n,e)=>n<>":(n,e)=>n>>e,">>>":(n,e)=>n>>>e,"&":(n,e)=>n&e,"^":(n,e)=>n^e,"|":(n,e)=>n|e};class ad{constructor(e,t,i){this.left=t,this.operator=e,this.right=i}evaluate(){const e=od[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const ld={"+":n=>n,"-":n=>-n,"~":n=>~n};class cd{constructor(e,t){this.operator=e,this.expression=t}evaluate(){const e=ld[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function ps(n){return(e,t)=>{for(let i=0;ie.startsWith(s,t))[0];return i?(t+=i.length,t+=Qt(e,t).length,{cursor:t,operator:i}):null}function Td(n,e){return(t,i)=>{const s=n(t,i);if(!s)return null;i=s.cursor;let r=s.evaluable;for(;;){const o=Vd(e,t,i);if(!o)break;i=o.cursor;const a=n(t,i);if(!a)return null;i=a.cursor,r=new ad(o.operator,r,a.evaluable)}return r?{cursor:i,evaluable:r}:null}}const Sd=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,e)=>Td(n,e),va);function ba(n,e){return e+=Qt(n,e).length,Sd(n,e)}function Ld(n){const e=ba(n,0);return!e||e.cursor+Qt(n,e.cursor).length!==n.length?null:e.evaluable}function ue(n){var e;const t=Ld(n);return(e=t==null?void 0:t.evaluate())!==null&&e!==void 0?e:null}function hs(n){if(typeof n=="number")return n;if(typeof n=="string"){const e=ue(n);if(!E(e))return e}return 0}function j(n){return e=>e.toFixed(Math.max(Math.min(n,20),0))}function h(n,e,t,i,s){const r=(n-e)/(t-e);return i+r*(s-i)}function gr(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function V(n,e,t){return Math.min(Math.max(n,e),t)}function fa(n,e){return(n%e+e)%e}function $d(n,e){return E(n.step)?Math.max(gr(e),2):gr(n.step)}function wa(n){var e;return(e=n.step)!==null&&e!==void 0?e:1}function Ad(n,e){var t;const i=Math.abs((t=n.step)!==null&&t!==void 0?t:e);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function ds(n,e){return E(n.step)?null:new sd(n.step,e)}function ms(n){return!E(n.max)&&!E(n.min)?new un({max:n.max,min:n.min}):!E(n.max)||!E(n.min)?new cs({max:n.max,min:n.min}):null}function vs(n,e){var t,i,s;return{formatter:(t=n.format)!==null&&t!==void 0?t:j($d(n,e)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:wa(n),pointerScale:(s=n.pointerScale)!==null&&s!==void 0?s:Ad(n,e)}}function bs(n){return{format:n.optional.function,keyScale:n.optional.number,max:n.optional.number,min:n.optional.number,pointerScale:n.optional.number,step:n.optional.number}}function fs(n){return{constraint:n.constraint,textProps:d.fromObject(vs(n.params,n.initialValue))}}class ot{constructor(e){this.controller=e}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(e){this.controller.viewProps.set("disabled",e)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(e){this.controller.viewProps.set("hidden",e)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(e){return this.controller.importState(e)}exportState(){return this.controller.exportState()}}class at{constructor(e){this.target=e}}class zn extends at{constructor(e,t,i){super(e),this.value=t,this.last=i??!0}}class Md extends at{constructor(e,t){super(e),this.expanded=t}}class Od extends at{constructor(e,t){super(e),this.index=t}}class ws extends ot{constructor(e){super(e),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new z,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(e){this.controller.tag=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.controller.value.fetch()}onValueChange_(e){const t=this.controller.value;this.emitter_.emit("change",new zn(this,t.binding.target.read(),e.options.last))}}function Rd(n,e){const i=Object.keys(e).reduce((s,r)=>{if(s===void 0)return;const o=e[r],a=o(n[r]);return a.succeeded?Object.assign(Object.assign({},s),{[r]:a.value}):void 0},{});return i}function Dd(n,e){return n.reduce((t,i)=>{if(t===void 0)return;const s=e(i);if(!(!s.succeeded||s.value===void 0))return[...t,s.value]},[])}function Bd(n){return n===null?!1:typeof n=="object"}function ge(n){return e=>t=>{if(!e&&t===void 0)return{succeeded:!1,value:void 0};if(e&&t===void 0)return{succeeded:!0,value:void 0};const i=n(t);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function Cr(n){return{custom:e=>ge(e)(n),boolean:ge(e=>typeof e=="boolean"?e:void 0)(n),number:ge(e=>typeof e=="number"?e:void 0)(n),string:ge(e=>typeof e=="string"?e:void 0)(n),function:ge(e=>typeof e=="function"?e:void 0)(n),constant:e=>ge(t=>t===e?e:void 0)(n),raw:ge(e=>e)(n),object:e=>ge(t=>{if(Bd(t))return Rd(t,e)})(n),array:e=>ge(t=>{if(Array.isArray(t))return Dd(t,e)})(n)}}const Ti={optional:Cr(!0),required:Cr(!1)};function L(n,e){const t=e(Ti),i=Ti.required.object(t)(n);return i.succeeded?i.value:void 0}function de(n,e,t,i){if(e&&!e(n))return!1;const s=L(n,t);return s?i(s):!1}function me(n,e){var t;return et((t=n==null?void 0:n())!==null&&t!==void 0?t:{},e)}function gn(n){return"value"in n}function Nd(n){if(!ls(n)||!("binding"in n))return!1;const e=n.binding;return Zh(e)}const R="http://www.w3.org/2000/svg";function Ln(n){n.offsetHeight}function jd(n,e){const t=n.style.transition;n.style.transition="none",e(),n.style.transition=t}function Kn(n){return n.ontouchstart!==void 0}function Id(n){const e=n.ownerDocument.defaultView;return e&&"document"in e?n.getContext("2d",{willReadFrequently:!0}):null}const Fd={check:'',dropdown:'',p2dpad:''};function qn(n,e){const t=n.createElementNS(R,"svg");return t.innerHTML=Fd[e],t}function _a(n,e,t){n.insertBefore(e,n.children[t])}function _s(n){n.parentElement&&n.parentElement.removeChild(n)}function ga(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function zd(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function gs(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function le(n,e){n.emitter.on("change",t=>{e(t.rawValue)}),e(n.rawValue)}function ce(n,e,t){le(n.value(e),t)}const Kd="tp";function m(n){return(t,i)=>[Kd,"-",n,"v",t?`_${t}`:"",i?`-${i}`:""].join("")}const Rt=m("lbl");function qd(n,e){const t=n.createDocumentFragment();return e.split(` -`).map(s=>n.createTextNode(s)).forEach((s,r)=>{r>0&&t.appendChild(n.createElement("br")),t.appendChild(s)}),t}class Ca{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Rt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Rt("l")),ce(t.props,"label",r=>{E(r)?this.element.classList.add(Rt(void 0,"nol")):(this.element.classList.remove(Rt(void 0,"nol")),zd(i),i.appendChild(qd(e,r)))}),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("div");s.classList.add(Rt("v")),this.element.appendChild(s),this.valueElement=s}}class Un{constructor(e,t){this.props=t.props,this.valueController=t.valueController,this.viewProps=t.valueController.viewProps,this.view=new Ca(e,{props:t.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(e){return de(e,null,t=>({label:t.optional.string}),t=>(this.props.set("label",t.label),!0))}exportProps(){return me(null,{label:this.props.get("label")})}}function Ud(){return["veryfirst","first","last","verylast"]}const xr=m(""),yr={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class hn{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const t=this.view.element;this.blade.value("positions").emitter.on("change",()=>{Ud().forEach(i=>{t.classList.remove(xr(void 0,yr[i]))}),this.blade.get("positions").forEach(i=>{t.classList.add(xr(void 0,yr[i]))})}),this.viewProps.handleDispose(()=>{_s(t)})}get parent(){return this.parent_}set parent(e){this.parent_=e,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(e){return de(e,null,t=>({disabled:t.required.boolean,hidden:t.required.boolean}),t=>(this.viewProps.importState(t),!0))}exportState(){return me(null,Object.assign({},this.viewProps.exportState()))}}class $n extends hn{constructor(e,t){if(t.value!==t.valueController.value)throw H.shouldNeverHappen();const i=t.valueController.viewProps,s=new Un(e,{blade:t.blade,props:t.props,valueController:t.valueController});super(Object.assign(Object.assign({},t),{view:new Ca(e,{props:t.props,viewProps:i}),viewProps:i})),this.labelController=s,this.value=t.value,this.valueController=t.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(e){return de(e,t=>{var i,s,r;return super.importState(t)&&this.labelController.importProps(t)&&((r=(s=(i=this.valueController).importProps)===null||s===void 0?void 0:s.call(i,e))!==null&&r!==void 0?r:!0)},t=>({value:t.optional.raw}),t=>(t.value&&(this.value.rawValue=t.value),!0))}exportState(){var e,t,i;return me(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(t=(e=this.valueController).exportProps)===null||t===void 0?void 0:t.call(e))!==null&&i!==void 0?i:{}))}}function xa(n,e){for(;n.lengthn.length?t.splice(0,t.length-n.length):xa(t,n.length),t}class Yd extends ot{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get title(){var e;return(e=this.controller.buttonController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.buttonController.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller.buttonController.emitter.on(e,()=>{i(new at(this))}),this}}function Xd(n,e,t){t?n.classList.add(e):n.classList.remove(e)}function Ke(n,e){return t=>{Xd(n,e,t)}}function Cs(n,e){le(n,t=>{e.textContent=t??""})}const oi=m("btn");class Qd{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(oi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("button");i.classList.add(oi("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(oi("t")),Cs(t.props.value("title"),s),this.buttonElement.appendChild(s)}}class ya{constructor(e,t){this.emitter=new z,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new Qd(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(e){return de(e,null,t=>({title:t.optional.string}),t=>(this.props.set("title",t.title),!0))}exportProps(){return me(null,{title:this.props.get("title")})}onClick_(){this.emitter.emit("click",{sender:this})}}class Pr extends hn{constructor(e,t){const i=new ya(e,{props:t.buttonProps,viewProps:t.viewProps}),s=new Un(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:t.viewProps}),this.buttonController=i,this.labelController=s}importState(e){return de(e,t=>super.importState(t)&&this.buttonController.importProps(t)&&this.labelController.importProps(t),()=>({}),()=>!0)}exportState(){return me(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class Zd{constructor(e){const[t,i]=e.split("-"),s=t.split(".");this.major=parseInt(s[0],10),this.minor=parseInt(s[1],10),this.patch=parseInt(s[2],10),this.prerelease=i??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}}const Jd=new Zd("2.0.0-beta.2");function $(n){return Object.assign({core:Jd},n)}$({id:"button",type:"blade",accept(n){const e=L(n,t=>({title:t.required.string,view:t.required.constant("button"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new Pr(n.document,{blade:n.blade,buttonProps:d.fromObject({title:n.params.title}),labelProps:d.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof Pr?new Yd(n.controller):null}});function em(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function tm(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function nm(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}function im(n){return ls(n)?"refresh"in n&&typeof n.refresh=="function":!1}function sm(n,e){if(!Sn.isBindable(n))throw H.notBindable();return new Sn(n,e)}class rm{constructor(e,t){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=e,this.emitter_=new z,this.pool_=t,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(e=>this.pool_.createApi(e))}addBinding(e,t,i){const s=i??{},r=this.controller_.element.ownerDocument,o=this.pool_.createBinding(r,sm(e,t),s),a=this.pool_.createBindingApi(o);return this.add(a,s.index)}addFolder(e){return tm(this,e)}addButton(e){return em(this,e)}addTab(e){return nm(this,e)}add(e,t){const i=e.controller;return this.controller_.rack.add(i,t),e}remove(e){this.controller_.rack.remove(e.controller)}addBlade(e){const t=this.controller_.element.ownerDocument,i=this.pool_.createBlade(t,e),s=this.pool_.createApi(i);return this.add(s,e.index)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.children.forEach(e=>{im(e)&&e.refresh()})}onRackValueChange_(e){const t=e.bladeController,i=this.pool_.createApi(t),s=Nd(t.value)?t.value.binding:null;this.emitter_.emit("change",new zn(i,s?s.target.read():t.value.rawValue,e.options.last))}}class xs extends ot{constructor(e,t){super(e),this.rackApi_=new rm(e.rackController,t)}}class ys extends hn{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}importState(e){return de(e,t=>super.importState(t),t=>({children:t.required.array(t.required.raw)}),t=>this.rackController.rack.children.every((i,s)=>i.importState(t.children[s])))}exportState(){return me(()=>super.exportState(),{children:this.rackController.rack.children.map(e=>e.exportState())})}}function Si(n){return"rackController"in n}class om{constructor(e){this.emitter=new z,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const t of this.allItems())if(e(t))return t;return null}includes(e){return this.cache_.has(e)}add(e,t){if(this.includes(e))throw H.shouldNeverHappen();const i=t!==void 0?t:this.items_.length;this.items_.splice(i,0,e),this.cache_.add(e);const s=this.extract_(e);s&&(s.emitter.on("add",this.onSubListAdd_),s.emitter.on("remove",this.onSubListRemove_),s.allItems().forEach(r=>{this.cache_.add(r)})),this.emitter.emit("add",{index:i,item:e,root:this,target:this})}remove(e){const t=this.items_.indexOf(e);if(t<0)return;this.items_.splice(t,1),this.cache_.delete(e);const i=this.extract_(e);i&&(i.allItems().forEach(s=>{this.cache_.delete(s)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:t,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}}function am(n,e){for(let t=0;t!s.viewProps.get("hidden")),t=e[0],i=e[e.length-1];this.bcSet_.items.forEach(s=>{const r=[];s===t&&(r.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&r.push("veryfirst")),s===i&&(r.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&r.push("verylast")),s.blade.set("positions",r)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(t=>t.viewProps.get("disposed")).forEach(t=>{this.bcSet_.remove(t)})}onChildValueChange_(e){const t=am(this.find(gn),e.sender);if(!t)throw H.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:t,options:e.options,sender:this})}onRackLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(e){this.emitter.emit("valuechange",{bladeController:e.bladeController,options:e.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class Ps{constructor(e){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=e.element,this.viewProps=e.viewProps;const t=new cm({blade:e.root?void 0:e.blade,viewProps:e.viewProps});t.emitter.on("add",this.onRackAdd_),t.emitter.on("remove",this.onRackRemove_),this.rack=t,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(e){e.root&&_a(this.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.root&&_s(e.bladeController.view.element)}}function Pa(){return new d({positions:S([],{equals:Qh})})}class Tt extends d{constructor(e){super(e)}static create(e){const t={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=d.createCore(t);return new Tt(i)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!E(e)?`${e}px`:"auto"}bindExpandedClass(e,t){const i=()=>{this.styleExpanded?e.classList.add(t):e.classList.remove(t)};ce(this,"expanded",i),ce(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function pm(n,e){let t=0;return jd(e,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Ln(e),t=e.clientHeight,n.set("temporaryExpanded",null),Ln(e)}),t}function Er(n,e){e.style.height=n.styleHeight}function Hn(n,e){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),E(n.get("expandedHeight"))){const t=pm(n,e);t>0&&n.set("expandedHeight",t)}n.set("shouldFixHeight",!0),Ln(e)}),n.emitter.on("change",()=>{Er(n,e)}),Er(n,e),e.addEventListener("transitionend",t=>{t.propertyName==="height"&&n.cleanUpTransition()})}class um extends xs{constructor(e,t){super(e,t),this.emitter_=new z,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Md(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(e){this.controller.foldable.set("expanded",e)}get title(){return this.controller.props.get("title")}set title(e){this.controller.props.set("title",e)}get children(){return this.rackApi_.children}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){return this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.rackApi_.refresh()}}const Ea=m("cnt");class hm{constructor(e,t){var i;this.className_=m((i=t.viewName)!==null&&i!==void 0?i:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),Ea()),t.viewProps.bindClassModifiers(this.element),this.foldable_=t.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),ce(this.foldable_,"completed",Ke(this.element,this.className_(void 0,"cpl")));const s=e.createElement("button");s.classList.add(this.className_("b")),ce(t.props,"title",c=>{E(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s;const r=e.createElement("div");r.classList.add(this.className_("i")),this.element.appendChild(r);const o=e.createElement("div");o.classList.add(this.className_("t")),Cs(t.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=e.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=e.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}}class kr extends ys{constructor(e,t){var i;const s=Tt.create((i=t.expanded)!==null&&i!==void 0?i:!0),r=new hm(e,{foldable:s,props:t.props,viewName:t.root?"rot":void 0,viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Ps({blade:t.blade,element:r.containerElement,root:t.root,viewProps:t.viewProps}),view:r})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=t.props,this.foldable=s,Hn(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(e){return de(e,t=>super.importState(t),t=>({expanded:t.required.boolean,title:t.optional.string}),t=>(this.foldable.set("expanded",t.expanded),this.props.set("title",t.title),!0))}exportState(){return me(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}$({id:"folder",type:"blade",accept(n){const e=L(n,t=>({title:t.required.string,view:t.required.constant("folder"),expanded:t.optional.boolean}));return e?{params:e}:null},controller(n){return new kr(n.document,{blade:n.blade,expanded:n.params.expanded,props:d.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof kr?new um(n.controller,n.pool):null}});const dm=m("");function Vr(n,e){return Ke(n,dm(void 0,e))}class ke extends d{constructor(e){var t;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=id(S(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var t,i,s;const r=e??{};return new ke(d.createCore({disabled:(t=r.disabled)!==null&&t!==void 0?t:!1,disposed:!1,hidden:(i=r.hidden)!==null&&i!==void 0?i:!1,parent:(s=r.parent)!==null&&s!==void 0?s:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){le(this.globalDisabled_,Vr(e,"disabled")),ce(this,"hidden",Vr(e,"hidden"))}bindDisabled(e){le(this.globalDisabled_,t=>{e.disabled=t})}bindTabIndex(e){le(this.globalDisabled_,t=>{e.tabIndex=t?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",t=>{t&&e()})}importState(e){this.set("disabled",e.disabled),this.set("hidden",e.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var t;const i=e.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const Tr=m("tbp");class mm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Tr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Tr("c")),this.element.appendChild(i),this.containerElement=i}}const Dt=m("tbi");class vm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Dt()),t.viewProps.bindClassModifiers(this.element),ce(t.props,"selected",r=>{r?this.element.classList.add(Dt(void 0,"sel")):this.element.classList.remove(Dt(void 0,"sel"))});const i=e.createElement("button");i.classList.add(Dt("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(Dt("t")),Cs(t.props.value("title"),s),this.buttonElement.appendChild(s),this.titleElement=s}}class bm{constructor(e,t){this.emitter=new z,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new vm(e,{props:t.props,viewProps:t.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class Li extends ys{constructor(e,t){const i=new mm(e,{viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Ps({blade:t.blade,element:i.containerElement,viewProps:t.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new bm(e,{props:t.itemProps,viewProps:ke.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=t.props,ce(this.props,"selected",s=>{this.itemController.props.set("selected",s),this.viewProps.set("hidden",!s)})}get itemController(){return this.ic_}importState(e){return de(e,t=>super.importState(t),t=>({selected:t.required.boolean,title:t.required.string}),t=>(this.ic_.props.set("selected",t.selected),this.ic_.props.set("title",t.title),!0))}exportState(){return me(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class fm extends xs{constructor(e,t){super(e,t),this.emitter_=new z,this.onSelect_=this.onSelect_.bind(this),this.pool_=t,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(e){const t=this.controller.view.element.ownerDocument,i=new Li(t,{blade:Pa(),itemProps:d.fromObject({selected:!1,title:e.title}),props:d.fromObject({selected:!1}),viewProps:ke.create()}),s=this.pool_.createApi(i);return this.rackApi_.add(s,e.index)}removePage(e){this.rackApi_.remove(this.rackApi_.children[e])}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}onSelect_(e){this.emitter_.emit("select",new Od(this,e.rawValue))}}class wm extends xs{get title(){var e;return(e=this.controller.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.itemController.props.set("title",e)}get selected(){return this.controller.props.get("selected")}set selected(e){this.controller.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addBlade(e){return this.rackApi_.addBlade(e)}refresh(){this.rackApi_.refresh()}}const Sr=-1;class _m{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=S(!0),this.selectedIndex=S(Sr),this.items_=[]}add(e,t){const i=t??this.items_.length;this.items_.splice(i,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const t=this.items_.indexOf(e);t<0||(this.items_.splice(t,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=Sr,this.empty.rawValue=!0;return}const e=this.items_.findIndex(t=>t.rawValue);e<0?(this.items_.forEach((t,i)=>{t.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((t,i)=>{t.rawValue=i===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const t=this.items_.findIndex(i=>i===e.sender);this.items_.forEach((i,s)=>{i.rawValue=s===t}),this.selectedIndex.rawValue=t}else this.keepSelection_()}}const Bt=m("tab");class gm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Bt(),Ea()),t.viewProps.bindClassModifiers(this.element),le(t.empty,Ke(this.element,Bt(void 0,"nop")));const i=e.createElement("div");i.classList.add(Bt("t")),this.element.appendChild(i),this.itemsElement=i;const s=e.createElement("div");s.classList.add(Bt("i")),this.element.appendChild(s);const r=e.createElement("div");r.classList.add(Bt("c")),this.element.appendChild(r),this.contentsElement=r}}class Lr extends ys{constructor(e,t){const i=new _m,s=new gm(e,{empty:i.empty,viewProps:t.viewProps});super({blade:t.blade,rackController:new Ps({blade:t.blade,element:s.contentsElement,viewProps:t.viewProps}),view:s}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const r=this.rackController.rack;r.emitter.on("add",this.onRackAdd_),r.emitter.on("remove",this.onRackRemove_),this.tab=i}add(e,t){this.rackController.rack.add(e,t)}remove(e){this.rackController.rack.remove(this.rackController.rack.children[e])}onRackAdd_(e){if(!e.root)return;const t=e.bladeController;_a(this.view.itemsElement,t.itemController.view.element,e.index),t.itemController.viewProps.set("parent",this.viewProps),this.tab.add(t.props.value("selected"))}onRackRemove_(e){if(!e.root)return;const t=e.bladeController;_s(t.itemController.view.element),t.itemController.viewProps.set("parent",null),this.tab.remove(t.props.value("selected"))}}$({id:"tab",type:"blade",accept(n){const e=L(n,t=>({pages:t.required.array(t.required.object({title:t.required.string})),view:t.required.constant("tab")}));return!e||e.pages.length===0?null:{params:e}},controller(n){const e=new Lr(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(t=>{const i=new Li(n.document,{blade:Pa(),itemProps:d.fromObject({selected:!1,title:t.title}),props:d.fromObject({selected:!1}),viewProps:ke.create()});e.add(i)}),e},api(n){return n.controller instanceof Lr?new fm(n.controller,n.pool):n.controller instanceof Li?new wm(n.controller,n.pool):null}});class Es extends ws{get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}}class Cm{constructor(){this.disabled=!1,this.emitter=new z}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class xm{constructor(e,t){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new z,this.interval_=t,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class St{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((t,i)=>i.constrain(t),e)}}function Jt(n,e){if(n instanceof e)return n;if(n instanceof St){const t=n.constraints.reduce((i,s)=>i||(s instanceof e?s:null),null);if(t)return t}return null}class Gn{constructor(e){this.values=d.fromObject({options:e})}constrain(e){const t=this.values.get("options");return t.length===0||t.filter(s=>s.value===e).length>0?e:t[0].value}}function Wn(n){var e;const t=Ti;if(Array.isArray(n))return(e=L({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||e===void 0?void 0:e.items;if(typeof n=="object")return t.required.raw(n).value}function ka(n){if(Array.isArray(n))return n;const e=[];return Object.keys(n).forEach(t=>{e.push({text:t,value:n[t]})}),e}function ks(n){return E(n)?null:new Gn(ka(n))}const ai=m("lst");class ym{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.element=e.createElement("div"),this.element.classList.add(ai()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("select");i.classList.add(ai("s")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const s=e.createElement("div");s.classList.add(ai("m")),s.appendChild(qn(e,"dropdown")),this.element.appendChild(s),t.value.emitter.on("change",this.onValueChange_),this.value_=t.value,ce(this.props_,"options",r=>{ga(this.selectElement),r.forEach(o=>{const a=e.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const e=this.props_.get("options").map(t=>t.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class xt{constructor(e,t){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new ym(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const t=e.currentTarget;this.value.rawValue=this.props.get("options")[t.selectedIndex].value}importProps(e){return de(e,null,t=>({options:t.required.custom(Wn)}),t=>(this.props.set("options",ka(t.options)),!0))}exportProps(){return me(null,{options:this.props.get("options")})}}const $r=m("pop");class Pm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add($r()),t.viewProps.bindClassModifiers(this.element),le(t.shows,Ke(this.element,$r(void 0,"v")))}}class Vs{constructor(e,t){this.shows=S(!1),this.viewProps=t.viewProps,this.view=new Pm(e,{shows:this.shows,viewProps:this.viewProps})}}const Ar=m("txt");class Em{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Ar()),t.viewProps.bindClassModifiers(this.element),this.props_=t.props,this.props_.emitter.on("change",this.onChange_);const i=e.createElement("input");i.classList.add(Ar("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onChange_),this.value_=t.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}}class Yn{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=t.parser,this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new Em(e,{props:t.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);E(s)||(this.value.rawValue=s),this.view.refresh()}}function km(n){return String(n)}function Ts(n){return n==="false"?!1:!!n}function Mr(n){return km(n)}function Vm(n){return e=>n.reduce((t,i)=>t!==null?t:i(e),null)}const Tm=j(0);function An(n){return Tm(n)+"%"}function Ss(n){return String(n)}function $i(n){return n}function lt({primary:n,secondary:e,forward:t,backward:i}){let s=!1;function r(o){s||(s=!0,o(),s=!1)}n.emitter.on("change",o=>{r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),e.emitter.on("change",o=>{r(()=>{n.setRawValue(i(n.rawValue,e.rawValue),o.options)}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),{forceEmit:!1,last:!0})})}function D(n,e){const t=n*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+t:e.downKey?-t:0}function tt(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function he(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function Sm(n){return n==="ArrowUp"||n==="ArrowDown"}function Mn(n){return Sm(n)||n==="ArrowLeft"||n==="ArrowRight"}function li(n,e){var t,i;const s=e.ownerDocument.defaultView,r=e.getBoundingClientRect();return{x:n.pageX-(((t=s&&s.scrollX)!==null&&t!==void 0?t:0)+r.left),y:n.pageY-(((i=s&&s.scrollY)!==null&&i!==void 0?i:0)+r.top)}}class Ve{constructor(e){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=e,this.emitter=new z,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const t=this.elem_.getBoundingClientRect();return{bounds:{width:t.width,height:t.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var t;e.preventDefault(),(t=e.currentTarget)===null||t===void 0||t.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(li(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(li(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const t=this.elem_.ownerDocument;t.removeEventListener("mousemove",this.onDocumentMouseMove_),t.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(li(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchMove_(e){const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchEnd_(e){var t;const i=(t=e.targetTouches.item(0))!==null&&t!==void 0?t:this.lastTouch_,s=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(i?{x:i.clientX-s.left,y:i.clientY-s.top}:void 0),sender:this,shiftKey:e.shiftKey})}}const ie=m("txt");class Lm{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ie(),ie(void 0,"num")),t.arrayPosition&&this.element.classList.add(ie(void 0,t.arrayPosition)),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(ie("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=t.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(ie()),this.inputElement.classList.add(ie("i"));const s=e.createElement("div");s.classList.add(ie("k")),this.element.appendChild(s),this.knobElement=s;const r=e.createElementNS(R,"svg");r.classList.add(ie("g")),this.knobElement.appendChild(r);const o=e.createElementNS(R,"path");o.classList.add(ie("gb")),r.appendChild(o),this.guideBodyElem_=o;const a=e.createElementNS(R,"path");a.classList.add(ie("gh")),r.appendChild(a),this.guideHeadElem_=a;const l=e.createElement("div");l.classList.add(m("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(ie(void 0,"drg"));return}this.element.classList.add(ie(void 0,"drg"));const t=e.rawValue/this.props_.get("pointerScale"),i=t+(t>0?-1:t<0?1:0),s=V(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+s},0 L${i},4 L${i+s},8`,`M ${t},-1 L${t},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${t},4`);const r=this.props_.get("formatter");this.tooltipElem_.textContent=r(this.value.rawValue),this.tooltipElem_.style.left=`${t}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}}class dn{constructor(e,t){var i;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.parser_=t.parser,this.props=t.props,this.sliderProps_=(i=t.sliderProps)!==null&&i!==void 0?i:null,this.value=t.value,this.viewProps=t.viewProps,this.dragging_=S(null),this.view=new Lm(e,{arrayPosition:t.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const s=new Ve(this.view.knobElement);s.emitter.on("down",this.onPointerDown_),s.emitter.on("move",this.onPointerMove_),s.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var t,i;const s=(t=this.sliderProps_)===null||t===void 0?void 0:t.get("min"),r=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=e;return s!==void 0&&(o=Math.max(o,s)),r!==void 0&&(o=Math.min(o,r)),o}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);E(s)||(this.value.rawValue=this.constrainValue_(s)),this.view.refresh()}onInputKeyDown_(e){const t=D(this.props.get("keyScale"),tt(e));t!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+t),{forceEmit:!1,last:!1})}onInputKeyUp_(e){D(this.props.get("keyScale"),tt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const t=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+t*this.props.get("pointerScale"))}onPointerMove_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const ci=m("sld");class $m{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ci()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ci("t")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(ci("k")),this.trackElement.appendChild(s),this.knobElement=s,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.update_()}update_(){const e=V(h(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}}class Am{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.props=t.props,this.view=new $m(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){e.point&&this.value.setRawValue(h(V(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("min"),this.props.get("max")),t)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=D(this.props.get("keyScale"),he(e));t!==0&&this.value.setRawValue(this.value.rawValue+t,{forceEmit:!1,last:!1})}onKeyUp_(e){D(this.props.get("keyScale"),he(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const pi=m("sldtxt");class Mm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(pi());const i=e.createElement("div");i.classList.add(pi("s")),this.sliderView_=t.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(pi("t")),this.textView_=t.textView,s.appendChild(this.textView_.element),this.element.appendChild(s)}}class Or{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sliderC_=new Am(e,{props:t.sliderProps,value:t.value,viewProps:this.viewProps}),this.textC_=new dn(e,{parser:t.parser,props:t.textProps,sliderProps:t.sliderProps,value:t.value,viewProps:t.viewProps}),this.view=new Mm(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(e){return de(e,null,t=>({max:t.required.number,min:t.required.number}),t=>{const i=this.sliderC_.props;return i.set("max",t.max),i.set("min",t.min),!0})}exportProps(){const e=this.sliderC_.props;return me(null,{max:e.get("max"),min:e.get("min")})}}function Om(n){return{sliderProps:new d({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new d({formatter:S(n.formatter),keyScale:n.keyScale,pointerScale:S(n.pointerScale)})}}const Rm={containerUnitSize:"cnt-usz"};function Va(n){return`--${Rm[n]}`}class Ta{constructor(e,t){const i=m(t.viewName);this.element=e.createElement("div"),this.element.classList.add(i()),t.viewProps.bindClassModifiers(this.element)}}function en(n){return bs(n)}function Ne(n){if(Vi(n))return L(n,en)}function xe(n,e){if(!n)return;const t=[],i=ds(n,e);i&&t.push(i);const s=ms(n);return s&&t.push(s),new St(t)}function Sa(n){if(n==="inline"||n==="popup")return n}function qe(n,e){n.write(e)}const fn=m("ckb");class Dm{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(fn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(fn("l")),this.element.appendChild(i);const s=e.createElement("input");s.classList.add(fn("i")),s.type="checkbox",i.appendChild(s),this.inputElement=s,t.viewProps.bindDisabled(this.inputElement);const r=e.createElement("div");r.classList.add(fn("w")),i.appendChild(r);const o=qn(e,"check");r.appendChild(o),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class Bm{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Dm(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const t=e.currentTarget;this.value.rawValue=t.checked}}function Nm(n){const e=[],t=ks(n.options);return t&&e.push(t),new St(e)}$({id:"input-bool",type:"input",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=L(e,i=>({options:i.optional.custom(Wn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Ts,constraint:n=>Nm(n.params),writer:n=>qe},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&Jt(i,Gn);return s?new xt(e,{props:new d({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Bm(e,{value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof xt?new Es(n.controller):null}});const He=m("col");class jm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(He()),t.foldable.bindExpandedClass(this.element,He(void 0,"expanded")),ce(t.foldable,"completed",Ke(this.element,He(void 0,"cpl")));const i=e.createElement("div");i.classList.add(He("h")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(He("s")),i.appendChild(s),this.swatchElement=s;const r=e.createElement("div");if(r.classList.add(He("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(He("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function Im(n,e,t){const i=V(n/255,0,1),s=V(e/255,0,1),r=V(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c=0,p=0;const u=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(s-r)/l:s===o?c=2+(r-i)/l:c=4+(i-s)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function Fm(n,e,t){const i=(n%360+360)%360,s=V(e/100,0,1),r=V(t/100,0,1),o=(1-Math.abs(2*r-1))*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o/2;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function zm(n,e,t){const i=V(n/255,0,1),s=V(e/255,0,1),r=V(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c;l===0?c=0:o===i?c=60*(((s-r)/l%6+6)%6):o===s?c=60*((r-i)/l+2):c=60*((i-s)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function La(n,e,t){const i=fa(n,360),s=V(e/100,0,1),r=V(t/100,0,1),o=r*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function Km(n,e,t){const i=t+e*(100-Math.abs(2*t-100))/200;return[n,i!==0?e*(100-Math.abs(2*t-100))/i:0,t+e*(100-Math.abs(2*t-100))/(2*100)]}function qm(n,e,t){const i=100-Math.abs(t*(200-e)/100-100);return[n,i!==0?e*t/i:0,t*(200-e)/(2*100)]}function we(n){return[n[0],n[1],n[2]]}function Xn(n,e){return[n[0],n[1],n[2],e]}const Um={hsl:{hsl:(n,e,t)=>[n,e,t],hsv:Km,rgb:Fm},hsv:{hsl:qm,hsv:(n,e,t)=>[n,e,t],rgb:La},rgb:{hsl:Im,hsv:zm,rgb:(n,e,t)=>[n,e,t]}};function yt(n,e){return[e==="float"?1:n==="rgb"?255:360,e==="float"?1:n==="rgb"?255:100,e==="float"?1:n==="rgb"?255:100]}function Hm(n,e){return n===e?e:fa(n,e)}function $a(n,e,t){var i;const s=yt(e,t);return[e==="rgb"?V(n[0],0,s[0]):Hm(n[0],s[0]),V(n[1],0,s[1]),V(n[2],0,s[2]),V((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function Rr(n,e,t,i){const s=yt(e,t),r=yt(e,i);return n.map((o,a)=>o/s[a]*r[a])}function Aa(n,e,t){const i=Rr(n,e.mode,e.type,"int"),s=Um[e.mode][t.mode](...i);return Rr(s,t.mode,"int",t.type)}class w{static black(){return new w([0,0,0],"rgb")}constructor(e,t){this.type="int",this.mode=t,this.comps_=$a(e,t,this.type)}getComponents(e){return Xn(Aa(we(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}}const Ae=m("colp");class Gm{constructor(e,t){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(Ae()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Ae("hsv"));const s=e.createElement("div");s.classList.add(Ae("sv")),this.svPaletteView_=t.svPaletteView,s.appendChild(this.svPaletteView_.element),i.appendChild(s);const r=e.createElement("div");r.classList.add(Ae("h")),this.hPaletteView_=t.hPaletteView,r.appendChild(this.hPaletteView_.element),i.appendChild(r),this.element.appendChild(i);const o=e.createElement("div");if(o.classList.add(Ae("rgb")),this.textsView_=t.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),t.alphaViews){this.alphaViews_={palette:t.alphaViews.palette,text:t.alphaViews.text};const a=e.createElement("div");a.classList.add(Ae("a"));const l=e.createElement("div");l.classList.add(Ae("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=e.createElement("div");c.classList.add(Ae("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(t=>t.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}}function Wm(n){return n==="int"?"int":n==="float"?"float":void 0}function Ls(n){return L(n,e=>({color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(Wm)}),expanded:e.optional.boolean,picker:e.optional.custom(Sa),readonly:e.optional.constant(!1)}))}function nt(n){return n?.1:1}function Ma(n){var e;return(e=n.color)===null||e===void 0?void 0:e.type}class $s{constructor(e,t){this.type="float",this.mode=t,this.comps_=$a(e,t,this.type)}getComponents(e){return Xn(Aa(we(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}}const Ym={int:(n,e)=>new w(n,e),float:(n,e)=>new $s(n,e)};function As(n,e,t){return Ym[t](n,e)}function Xm(n){return n.type==="float"}function Qm(n){return n.type==="int"}function Zm(n){const e=n.getComponents(),t=yt(n.mode,"int");return new w([Math.round(h(e[0],0,1,0,t[0])),Math.round(h(e[1],0,1,0,t[1])),Math.round(h(e[2],0,1,0,t[2])),e[3]],n.mode)}function Jm(n){const e=n.getComponents(),t=yt(n.mode,"int");return new $s([h(e[0],0,t[0],0,1),h(e[1],0,t[1],0,1),h(e[2],0,t[2],0,1),e[3]],n.mode)}function W(n,e){if(n.type===e)return n;if(Qm(n)&&e==="float")return Jm(n);if(Xm(n)&&e==="int")return Zm(n);throw H.shouldNeverHappen()}function ev(n,e){return n.alpha===e.alpha&&n.mode===e.mode&&n.notation===e.notation&&n.type===e.type}function oe(n,e){const t=n.match(/^(.+)%$/);return Math.min(t?parseFloat(t[1])*.01*e:parseFloat(n),e)}const tv={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Oa(n){const e=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(n);const t=parseFloat(e[1]),i=e[2];return tv[i](t)}function Ra(n){const e=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[oe(e[1],255),oe(e[2],255),oe(e[3],255)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function nv(n){const e=Ra(n);return e?new w(e,"rgb"):null}function Da(n){const e=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[oe(e[1],255),oe(e[2],255),oe(e[3],255),oe(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function iv(n){const e=Da(n);return e?new w(e,"rgb"):null}function Ba(n){const e=n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Oa(e[1]),oe(e[2],100),oe(e[3],100)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function sv(n){const e=Ba(n);return e?new w(e,"hsl"):null}function Na(n){const e=n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Oa(e[1]),oe(e[2],100),oe(e[3],100),oe(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function rv(n){const e=Na(n);return e?new w(e,"hsl"):null}function ja(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const t=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function ov(n){const e=ja(n);return e?new w(e,"rgb"):null}function Ia(n){const e=n.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),h(parseInt(e[4]+e[4],16),0,255,0,1)];const t=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),h(parseInt(t[4],16),0,255,0,1)]:null}function av(n){const e=Ia(n);return e?new w(e,"rgb"):null}function Fa(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function Dr(n){return e=>{const t=Fa(e);return t?As(t,"rgb",n):null}}function za(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Br(n){return e=>{const t=za(e);return t?As(t,"rgb",n):null}}const lv=[{parser:ja,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:Ia,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:Ra,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:Da,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Ba,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Na,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:Fa,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:za,result:{alpha:!0,mode:"rgb",notation:"object"}}];function cv(n){return lv.reduce((e,{parser:t,result:i})=>e||(t(n)?i:null),null)}function pv(n,e="int"){const t=cv(n);return t?t.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},t),{type:"int"}):t.notation==="func"?Object.assign(Object.assign({},t),{type:e}):null:null}function mn(n){const e=[ov,av,nv,iv,sv,rv];n==="int"&&e.push(Dr("int"),Br("int")),n==="float"&&e.push(Dr("float"),Br("float"));const t=Vm(e);return i=>{const s=t(i);return s?W(s,n):null}}function uv(n){const e=mn("int");if(typeof n!="string")return w.black();const t=e(n);return t??w.black()}function Ka(n){const e=V(Math.floor(n),0,255).toString(16);return e.length===1?`0${e}`:e}function Ms(n,e="#"){const t=we(n.getComponents("rgb")).map(Ka).join("");return`${e}${t}`}function Os(n,e="#"){const t=n.getComponents("rgb"),i=[t[0],t[1],t[2],t[3]*255].map(Ka).join("");return`${e}${i}`}function qa(n){const e=j(0),t=W(n,"int");return`rgb(${we(t.getComponents("rgb")).map(s=>e(s)).join(", ")})`}function Cn(n){const e=j(2),t=j(0);return`rgba(${W(n,"int").getComponents("rgb").map((r,o)=>(o===3?e:t)(r)).join(", ")})`}function hv(n){const e=[j(0),An,An],t=W(n,"int");return`hsl(${we(t.getComponents("hsl")).map((s,r)=>e[r](s)).join(", ")})`}function dv(n){const e=[j(0),An,An,j(2)];return`hsla(${W(n,"int").getComponents("hsl").map((s,r)=>e[r](s)).join(", ")})`}function Ua(n,e){const t=j(e==="float"?2:0),i=["r","g","b"],s=W(n,e);return`{${we(s.getComponents("rgb")).map((o,a)=>`${i[a]}: ${t(o)}`).join(", ")}}`}function mv(n){return e=>Ua(e,n)}function Ha(n,e){const t=j(2),i=j(e==="float"?2:0),s=["r","g","b","a"];return`{${W(n,e).getComponents("rgb").map((a,l)=>{const c=l===3?t:i;return`${s[l]}: ${c(a)}`}).join(", ")}}`}function vv(n){return e=>Ha(e,n)}const bv=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:Ms},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Os},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:qa},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:Cn},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:hv},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:dv},...["int","float"].reduce((n,e)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:mv(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:vv(e)}],[])];function Ga(n){return bv.reduce((e,t)=>e||(ev(t.format,n)?t.stringifier:null),null)}const Nt=m("apl");class fv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Nt()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Nt("b")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Nt("c")),i.appendChild(s),this.colorElem_=s;const r=e.createElement("div");r.classList.add(Nt("m")),this.element.appendChild(r),this.markerElem_=r;const o=e.createElement("div");o.classList.add(Nt("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const e=this.value.rawValue,t=e.getComponents("rgb"),i=new w([t[0],t[1],t[2],0],"rgb"),s=new w([t[0],t[1],t[2],255],"rgb"),r=["to right",Cn(i),Cn(s)];this.colorElem_.style.background=`linear-gradient(${r.join(",")})`,this.previewElem_.style.backgroundColor=Cn(e);const o=h(t[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class wv{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new fv(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=e.point.x/e.bounds.width,s=this.value.rawValue,[r,o,a]=s.getComponents("hsv");this.value.setRawValue(new w([r,o,a,i],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=D(nt(!0),he(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new w([s,r,o,a+t],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){D(nt(!0),he(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const ut=m("coltxt");function _v(n){const e=n.createElement("select"),t=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return e.appendChild(t.reduce((i,s)=>{const r=n.createElement("option");return r.textContent=s.text,r.value=s.value,i.appendChild(r),i},n.createDocumentFragment())),e}class gv{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ut()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ut("m")),this.modeElem_=_v(e),this.modeElem_.classList.add(ut("ms")),i.appendChild(this.modeSelectElement),t.viewProps.bindDisabled(this.modeElem_);const s=e.createElement("div");s.classList.add(ut("mm")),s.appendChild(qn(e,"dropdown")),i.appendChild(s),this.element.appendChild(i);const r=e.createElement("div");r.classList.add(ut("w")),this.element.appendChild(r),this.inputsElem_=r,this.inputViews_=t.inputViews,this.applyInputViews_(),le(t.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(e){this.inputViews_=e,this.applyInputViews_()}applyInputViews_(){ga(this.inputsElem_);const e=this.element.ownerDocument;this.inputViews_.forEach(t=>{const i=e.createElement("div");i.classList.add(ut("c")),i.appendChild(t.element),this.inputsElem_.appendChild(i)})}}function Cv(n){return j(n==="float"?2:0)}function xv(n,e,t){const i=yt(n,e)[t];return new un({min:0,max:i})}function yv(n,e,t){return new dn(n,{arrayPosition:t===0?"fst":t===2?"lst":"mid",parser:e.parser,props:d.fromObject({formatter:Cv(e.colorType),keyScale:nt(!1),pointerScale:e.colorType==="float"?.01:1}),value:S(0,{constraint:xv(e.colorMode,e.colorType,t)}),viewProps:e.viewProps})}function Pv(n,e){const t={colorMode:e.colorMode,colorType:e.colorType,parser:ue,viewProps:e.viewProps};return[0,1,2].map(i=>{const s=yv(n,t,i);return lt({primary:e.value,secondary:s.value,forward(r){return W(r,e.colorType).getComponents(e.colorMode)[i]},backward(r,o){const a=e.colorMode,c=W(r,e.colorType).getComponents(a);c[i]=o;const p=As(Xn(we(c),c[3]),a,e.colorType);return W(p,"int")}}),s})}function Ev(n,e){const t=new Yn(n,{parser:mn("int"),props:d.fromObject({formatter:Ms}),value:S(w.black()),viewProps:e.viewProps});return lt({primary:e.value,secondary:t.value,forward:i=>new w(we(i.getComponents()),i.mode),backward:(i,s)=>new w(Xn(we(s.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[t]}function kv(n){return n!=="hex"}class Vv{constructor(e,t){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=t.colorType,this.value=t.value,this.viewProps=t.viewProps,this.colorMode=S(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new gv(e,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(e){const t=this.colorMode.rawValue;return kv(t)?Pv(e,{colorMode:t,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):Ev(e,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(e){const t=e.currentTarget;this.colorMode.rawValue=t.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}}const ui=m("hpl");class Tv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(ui()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(ui("c")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ui("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=this.value.rawValue,[t]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=qa(new w([t,100,100],"hsv"));const i=h(t,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class Sv{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Tv(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=h(V(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),s=this.value.rawValue,[,r,o,a]=s.getComponents("hsv");this.value.setRawValue(new w([i,r,o,a],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=D(nt(!1),he(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new w([s+t,r,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){D(nt(!1),he(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const hi=m("svp"),Nr=64;class Lv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(hi()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("canvas");i.height=Nr,i.width=Nr,i.classList.add(hi("c")),this.element.appendChild(i),this.canvasElement=i;const s=e.createElement("div");s.classList.add(hi("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=Id(this.canvasElement);if(!e)return;const i=this.value.rawValue.getComponents("hsv"),s=this.canvasElement.width,r=this.canvasElement.height,o=e.getImageData(0,0,s,r),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,s)=>{const r=i.getComponents();return r[3]=s,new w(r,i.mode)}}),this.textsC_=new Vv(e,{colorType:t.colorType,value:this.value,viewProps:this.viewProps}),this.view=new Gm(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:t.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}}const di=m("colsw");class Mv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.element=e.createElement("div"),this.element.classList.add(di()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(di("sw")),this.element.appendChild(i),this.swatchElem_=i;const s=e.createElement("button");s.classList.add(di("b")),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=Os(e)}onValueChange_(){this.update_()}}class Ov{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Mv(e,{value:this.value,viewProps:this.viewProps})}}class Rs{constructor(e,t){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Tt.create(t.expanded),this.swatchC_=new Ov(e,{value:this.value,viewProps:this.viewProps});const i=this.swatchC_.view.buttonElement;i.addEventListener("blur",this.onButtonBlur_),i.addEventListener("click",this.onButtonClick_),this.textC_=new Yn(e,{parser:t.parser,props:d.fromObject({formatter:t.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new jm(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=t.pickerLayout==="popup"?new Vs(e,{viewProps:this.viewProps}):null;const s=new Av(e,{colorType:t.colorType,supportsAlpha:t.supportsAlpha,value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(r=>{r.addEventListener("blur",this.onPopupChildBlur_),r.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(s.view.element),lt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:r=>r,backward:(r,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Hn(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=gs(e);i&&t.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Kn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function Rv(n){return we(n.getComponents("rgb")).reduce((e,t)=>e<<8|Math.floor(t)&255,0)}function Dv(n){return n.getComponents("rgb").reduce((e,t,i)=>{const s=Math.floor(i===3?t*255:t)&255;return e<<8|s},0)>>>0}function Bv(n){return new w([n>>16&255,n>>8&255,n&255],"rgb")}function Nv(n){return new w([n>>24&255,n>>16&255,n>>8&255,h(n&255,0,255,0,1)],"rgb")}function jv(n){return typeof n!="number"?w.black():Bv(n)}function Iv(n){return typeof n!="number"?w.black():Nv(n)}function xn(n,e){return typeof n!="object"||E(n)?!1:e in n&&typeof n[e]=="number"}function Wa(n){return xn(n,"r")&&xn(n,"g")&&xn(n,"b")}function Ya(n){return Wa(n)&&xn(n,"a")}function Xa(n){return Wa(n)}function Ds(n,e){if(n.mode!==e.mode||n.type!==e.type)return!1;const t=n.getComponents(),i=e.getComponents();for(let s=0;s{qe(t,e(i))}:null}function zv(n){const e=n?Dv:Rv;return(t,i)=>{qe(t,e(i))}}function Kv(n,e,t){const s=W(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b),n.writeProperty("a",s.a)}function qv(n,e,t){const s=W(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b)}function Uv(n,e){return(t,i)=>{n?Kv(t,i,e):qv(t,i,e)}}function Hv(n){var e;return!!(!((e=n==null?void 0:n.color)===null||e===void 0)&&e.alpha)}function Gv(n){return n?e=>Os(e,"0x"):e=>Ms(e,"0x")}function Wv(n){return"color"in n||n.view==="color"}$({id:"input-color-number",type:"input",accept:(n,e)=>{if(typeof n!="number"||!Wv(e))return null;const t=Ls(e);return t?{initialValue:n,params:Object.assign(Object.assign({},t),{supportsAlpha:Hv(e)})}:null},binding:{reader:n=>n.params.supportsAlpha?Iv:jv,equals:Ds,writer:n=>zv(n.params.supportsAlpha)},controller:n=>{var e,t;return new Rs(n.document,{colorType:"int",expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Gv(n.params.supportsAlpha),parser:mn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function Yv(n,e){if(!Xa(n))return W(w.black(),e);if(e==="int"){const t=jr(n);return new w(t,"rgb")}if(e==="float"){const t=jr(n);return new $s(t,"rgb")}return W(w.black(),"int")}function Xv(n){return Ya(n)}function Qv(n){return e=>{const t=Yv(e,n);return W(t,"int")}}function Zv(n,e){return t=>n?Ha(t,e):Ua(t,e)}$({id:"input-color-object",type:"input",accept:(n,e)=>{var t;if(!Xa(n))return null;const i=Ls(e);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(t=Ma(e))!==null&&t!==void 0?t:"int"})}:null},binding:{reader:n=>Qv(n.params.colorType),equals:Ds,writer:n=>Uv(Xv(n.initialValue),n.params.colorType)},controller:n=>{var e,t;const i=Ya(n.initialValue);return new Rs(n.document,{colorType:n.params.colorType,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Zv(i,n.params.colorType),parser:mn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}});$({id:"input-color-string",type:"input",accept:(n,e)=>{if(typeof n!="string"||e.view==="text")return null;const t=pv(n,Ma(e));if(!t)return null;const i=Ga(t);if(!i)return null;const s=Ls(e);return s?{initialValue:n,params:Object.assign(Object.assign({},s),{format:t,stringifier:i})}:null},binding:{reader:()=>uv,equals:Ds,writer:n=>{const e=Fv(n.params.format);if(!e)throw H.notBindable();return e}},controller:n=>{var e,t;return new Rs(n.document,{colorType:n.params.format.type,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:n.params.stringifier,parser:mn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class Qn{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const t=this.asm_.toComponents(e).map((i,s)=>{var r,o;return(o=(r=this.components[s])===null||r===void 0?void 0:r.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(t)}}const Ir=m("pndtxt");class Jv{constructor(e,t){this.textViews=t.textViews,this.element=e.createElement("div"),this.element.classList.add(Ir()),this.textViews.forEach(i=>{const s=e.createElement("div");s.classList.add(Ir("a")),s.appendChild(i.element),this.element.appendChild(s)})}}function eb(n,e,t){return new dn(n,{arrayPosition:t===0?"fst":t===e.axes.length-1?"lst":"mid",parser:e.parser,props:e.axes[t].textProps,value:S(0,{constraint:e.axes[t].constraint}),viewProps:e.viewProps})}class Lt{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.acs_=t.axes.map((i,s)=>eb(e,t,s)),this.acs_.forEach((i,s)=>{lt({primary:this.value,secondary:i.value,forward:r=>t.assembly.toComponents(r)[s],backward:(r,o)=>{const a=t.assembly.toComponents(r);return a[s]=o,t.assembly.fromComponents(a)}})}),this.view=new Jv(e,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class tb extends ws{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}}function nb(n,e){const t=[],i=ds(n,e);i&&t.push(i);const s=ms(n);s&&t.push(s);const r=ks(n.options);return r&&t.push(r),new St(t)}$({id:"input-number",type:"input",accept:(n,e)=>{if(typeof n!="number")return null;const t=L(e,i=>Object.assign(Object.assign({},bs(i)),{options:i.optional.custom(Wn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>hs,constraint:n=>nb(n.params,n.initialValue),writer:n=>qe},controller:n=>{const e=n.value,t=n.constraint,i=t&&Jt(t,Gn);if(i)return new xt(n.document,{props:new d({options:i.values.value("options")}),value:e,viewProps:n.viewProps});const s=vs(n.params,e.rawValue),r=t&&Jt(t,un);return r?new Or(n.document,Object.assign(Object.assign({},Om(Object.assign(Object.assign({},s),{keyScale:S(s.keyScale),max:r.values.value("max"),min:r.values.value("min")}))),{parser:ue,value:e,viewProps:n.viewProps})):new dn(n.document,{parser:ue,props:d.fromObject(s),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof Or?new tb(n.controller):n.controller.valueController instanceof xt?new Es(n.controller):null}});class Ie{constructor(e=0,t=0){this.x=e,this.y=t}getComponents(){return[this.x,this.y]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y}toObject(){return{x:this.x,y:this.y}}}const Qa={toComponents:n=>n.getComponents(),fromComponents:n=>new Ie(...n)},ht=m("p2d");class ib{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ht()),t.viewProps.bindClassModifiers(this.element),le(t.expanded,Ke(this.element,ht(void 0,"expanded")));const i=e.createElement("div");i.classList.add(ht("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(ht("b")),s.appendChild(qn(e,"p2dpad")),t.viewProps.bindDisabled(s),i.appendChild(s),this.buttonElement=s;const r=e.createElement("div");if(r.classList.add(ht("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(ht("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const Me=m("p2dp");class sb{constructor(e,t){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=e.createElement("div"),this.element.classList.add(Me()),t.layout==="popup"&&this.element.classList.add(Me(void 0,"p")),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Me("p")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const s=e.createElementNS(R,"svg");s.classList.add(Me("g")),this.padElement.appendChild(s),this.svgElem_=s;const r=e.createElementNS(R,"line");r.classList.add(Me("ax")),r.setAttributeNS(null,"x1","0"),r.setAttributeNS(null,"y1","50%"),r.setAttributeNS(null,"x2","100%"),r.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(r);const o=e.createElementNS(R,"line");o.classList.add(Me("ax")),o.setAttributeNS(null,"x1","50%"),o.setAttributeNS(null,"y1","0"),o.setAttributeNS(null,"x2","50%"),o.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(o);const a=e.createElementNS(R,"line");a.classList.add(Me("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=e.createElement("div");l.classList.add(Me("m")),this.padElement.appendChild(l),this.markerElem_=l,t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,t]=this.value.rawValue.getComponents(),i=this.props_.get("max"),s=h(e,-i,+i,0,100),r=h(t,-i,+i,0,100),o=this.props_.get("invertsY")?100-r:r;this.lineElem_.setAttributeNS(null,"x2",`${s}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${s}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function Fr(n,e,t){return[D(e[0],he(n)),D(e[1],tt(n))*(t?1:-1)]}class rb{constructor(e,t){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new sb(e,{layout:t.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=this.props.get("max"),s=h(e.point.x,0,e.bounds.width,-i,+i),r=h(this.props.get("invertsY")?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-i,+i);this.value.setRawValue(new Ie(s,r),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){Mn(e.key)&&e.preventDefault();const[t,i]=Fr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(new Ie(this.value.rawValue.x+t,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[t,i]=Fr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class ob{constructor(e,t){var i,s;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Tt.create(t.expanded),this.popC_=t.pickerLayout==="popup"?new Vs(e,{viewProps:this.viewProps}):null;const r=new rb(e,{layout:t.pickerLayout,props:new d({invertsY:S(t.invertsY),max:S(t.max),xKeyScale:t.axes[0].textProps.value("keyScale"),yKeyScale:t.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.textC_=new Lt(e,{assembly:Qa,axes:t.axes,parser:t.parser,value:this.value,viewProps:this.viewProps}),this.view=new ib(e,{expanded:this.foldable_.value("expanded"),pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(i=this.view.buttonElement)===null||i===void 0||i.addEventListener("blur",this.onPadButtonBlur_),(s=this.view.buttonElement)===null||s===void 0||s.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),lt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:o=>o,backward:(o,a)=>a})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Hn(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=gs(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!Kn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}}function ab(n){return Ie.isObject(n)?new Ie(n.x,n.y):new Ie}function lb(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y)}function cb(n,e){return new Qn({assembly:Qa,components:[xe(Object.assign(Object.assign({},n),n.x),e.x),xe(Object.assign(Object.assign({},n),n.y),e.y)]})}function zr(n,e){var t,i;if(!E(n.min)||!E(n.max))return Math.max(Math.abs((t=n.min)!==null&&t!==void 0?t:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const s=wa(n);return Math.max(Math.abs(s)*10,Math.abs(e)*10)}function pb(n,e){var t,i;const s=zr(et(n,(t=n.x)!==null&&t!==void 0?t:{}),e.x),r=zr(et(n,(i=n.y)!==null&&i!==void 0?i:{}),e.y);return Math.max(s,r)}function ub(n){if(!("y"in n))return!1;const e=n.y;return e&&"inverted"in e?!!e.inverted:!1}$({id:"input-point2d",type:"input",accept:(n,e)=>{if(!Ie.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},en(i)),{expanded:i.optional.boolean,picker:i.optional.custom(Sa),readonly:i.optional.constant(!1),x:i.optional.custom(Ne),y:i.optional.object(Object.assign(Object.assign({},en(i)),{inverted:i.optional.boolean}))}));return t?{initialValue:n,params:t}:null},binding:{reader:()=>ab,constraint:n=>cb(n.params,n.initialValue),equals:Ie.equals,writer:()=>lb},controller:n=>{var e,t;const i=n.document,s=n.value,r=n.constraint,o=[n.params.x,n.params.y];return new ob(i,{axes:s.rawValue.getComponents().map((a,l)=>{var c;return fs({constraint:r.components[l],initialValue:a,params:et(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,invertsY:ub(n.params),max:pb(n.params,s.rawValue),parser:ue,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps})}});class _t{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y,s=e.z;return!(typeof t!="number"||typeof i!="number"||typeof s!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const Za={toComponents:n=>n.getComponents(),fromComponents:n=>new _t(...n)};function hb(n){return _t.isObject(n)?new _t(n.x,n.y,n.z):new _t}function db(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z)}function mb(n,e){return new Qn({assembly:Za,components:[xe(Object.assign(Object.assign({},n),n.x),e.x),xe(Object.assign(Object.assign({},n),n.y),e.y),xe(Object.assign(Object.assign({},n),n.z),e.z)]})}$({id:"input-point3d",type:"input",accept:(n,e)=>{if(!_t.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},en(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Ne),y:i.optional.custom(Ne),z:i.optional.custom(Ne)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>hb,constraint:n=>mb(n.params,n.initialValue),equals:_t.equals,writer:n=>db},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new Lt(n.document,{assembly:Za,axes:e.rawValue.getComponents().map((s,r)=>{var o;return fs({constraint:t.components[r],initialValue:s,params:et(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:ue,value:e,viewProps:n.viewProps})}});class gt{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y,s=e.z,r=e.w;return!(typeof t!="number"||typeof i!="number"||typeof s!="number"||typeof r!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const Ja={toComponents:n=>n.getComponents(),fromComponents:n=>new gt(...n)};function vb(n){return gt.isObject(n)?new gt(n.x,n.y,n.z,n.w):new gt}function bb(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z),n.writeProperty("w",e.w)}function fb(n,e){return new Qn({assembly:Ja,components:[xe(Object.assign(Object.assign({},n),n.x),e.x),xe(Object.assign(Object.assign({},n),n.y),e.y),xe(Object.assign(Object.assign({},n),n.z),e.z),xe(Object.assign(Object.assign({},n),n.w),e.w)]})}$({id:"input-point4d",type:"input",accept:(n,e)=>{if(!gt.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},en(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Ne),x:i.optional.custom(Ne),y:i.optional.custom(Ne),z:i.optional.custom(Ne)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>vb,constraint:n=>fb(n.params,n.initialValue),equals:gt.equals,writer:n=>bb},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new Lt(n.document,{assembly:Ja,axes:e.rawValue.getComponents().map((s,r)=>{var o;return fs({constraint:t.components[r],initialValue:s,params:et(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:ue,value:e,viewProps:n.viewProps})}});function wb(n){const e=[],t=ks(n.options);return t&&e.push(t),new St(e)}$({id:"input-string",type:"input",accept:(n,e)=>{if(typeof n!="string")return null;const t=L(e,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(Wn)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Ss,constraint:n=>wb(n.params),writer:n=>qe},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&Jt(i,Gn);return s?new xt(e,{props:new d({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Yn(e,{parser:r=>r,props:d.fromObject({formatter:$i}),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof xt?new Es(n.controller):null}});const vn={monitor:{defaultInterval:200,defaultRows:3}},Kr=m("mll");class _b{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(Kr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("textarea");i.classList.add(Kr("i")),i.style.height=`calc(var(${Va("containerUnitSize")}) * ${t.rows})`,i.readOnly=!0,t.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.textareaElem_,t=e.scrollTop===e.scrollHeight-e.clientHeight,i=[];this.value.rawValue.forEach(s=>{s!==void 0&&i.push(this.formatter_(s))}),e.textContent=i.join(` -`),t&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}}class Bs{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new _b(e,{formatter:t.formatter,rows:t.rows,value:this.value,viewProps:this.viewProps})}}const qr=m("sgl");class gb{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(qr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(qr("i")),i.readOnly=!0,i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.value.rawValue,t=e[e.length-1];this.inputElement.value=t!==void 0?this.formatter_(t):""}onValueUpdate_(){this.update_()}}class Ns{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new gb(e,{formatter:t.formatter,value:this.value,viewProps:this.viewProps})}}$({id:"monitor-bool",type:"monitor",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=L(e,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Ts},controller:n=>{var e;return n.value.rawValue.length===1?new Ns(n.document,{formatter:Mr,value:n.value,viewProps:n.viewProps}):new Bs(n.document,{formatter:Mr,rows:(e=n.params.rows)!==null&&e!==void 0?e:vn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class Cb extends ws{get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}}const Oe=m("grl");class xb{constructor(e,t){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Oe()),t.viewProps.bindClassModifiers(this.element),this.formatter_=t.formatter,this.props_=t.props,this.cursor_=t.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=e.createElementNS(R,"svg");i.classList.add(Oe("g")),i.style.height=`calc(var(${Va("containerUnitSize")}) * ${t.rows})`,this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(R,"polyline");this.svgElem_.appendChild(s),this.lineElem_=s;const r=e.createElement("div");r.classList.add(Oe("t"),m("tt")()),this.element.appendChild(r),this.tooltipElem_=r,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const e=this.svgElem_.getBoundingClientRect(),t=this.value.rawValue.length-1,i=this.props_.get("min"),s=this.props_.get("max"),r=[];this.value.rawValue.forEach((p,u)=>{if(p===void 0)return;const _=h(u,0,t,0,e.width),B=h(p,i,s,e.height,0);r.push([_,B].join(","))}),this.lineElem_.setAttributeNS(null,"points",r.join(" "));const o=this.tooltipElem_,a=this.value.rawValue[this.cursor_.rawValue];if(a===void 0){o.classList.remove(Oe("t","a"));return}const l=h(this.cursor_.rawValue,0,t,0,e.width),c=h(a,i,s,e.height,0);o.style.left=`${l}px`,o.style.top=`${c}px`,o.textContent=`${this.formatter_(a)}`,o.classList.contains(Oe("t","a"))||(o.classList.add(Oe("t","a"),Oe("t","in")),Ln(o),o.classList.remove(Oe("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class js{constructor(e,t){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.cursor_=S(-1),this.view=new xb(e,{cursor:this.cursor_,formatter:t.formatter,rows:t.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Kn(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new Ve(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(e){return de(e,null,t=>({max:t.required.number,min:t.required.number}),t=>(this.props.set("max",t.max),this.props.set("min",t.min),!0))}exportProps(){return me(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const t=this.view.element.getBoundingClientRect();this.cursor_.rawValue=Math.floor(h(e.offsetX,0,t.width,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(h(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Ai(n){return E(n.format)?j(2):n.format}function yb(n){var e;return n.value.rawValue.length===1?new Ns(n.document,{formatter:Ai(n.params),value:n.value,viewProps:n.viewProps}):new Bs(n.document,{formatter:Ai(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:vn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function Pb(n){var e,t,i;return new js(n.document,{formatter:Ai(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:vn.monitor.defaultRows,props:d.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Ur(n){return n.view==="graph"}$({id:"monitor-number",type:"monitor",accept:(n,e)=>{if(typeof n!="number")return null;const t=L(e,i=>({format:i.optional.function,max:i.optional.number,min:i.optional.number,readonly:i.required.constant(!0),rows:i.optional.number,view:i.optional.string}));return t?{initialValue:n,params:t}:null},binding:{defaultBufferSize:n=>Ur(n)?64:1,reader:n=>hs},controller:n=>Ur(n.params)?Pb(n):yb(n),api:n=>n.controller.valueController instanceof js?new Cb(n.controller):null});$({id:"monitor-string",type:"monitor",accept:(n,e)=>{if(typeof n!="string")return null;const t=L(e,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Ss},controller:n=>{var e;const t=n.value;return t.rawValue.length>1||n.params.multiline?new Bs(n.document,{formatter:$i,rows:(e=n.params.rows)!==null&&e!==void 0?e:vn.monitor.defaultRows,value:t,viewProps:n.viewProps}):new Ns(n.document,{formatter:$i,value:t,viewProps:n.viewProps})}});class el{constructor(e){this.controller_=e}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get title(){var e;return(e=this.controller_.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller_.emitter.on(e,()=>{i(new at(this))}),this}}class Eb extends at{constructor(e,t,i){super(e),this.cell=t,this.index=i}}class tl extends ot{constructor(e){super(e),this.cellToApiMap_=new Map,this.emitter_=new z;const t=this.controller.valueController;t.cellControllers.forEach((i,s)=>{const r=new el(i);this.cellToApiMap_.set(i,r),i.emitter.on("click",()=>{const o=s%t.size[0],a=Math.floor(s/t.size[0]);this.emitter_.emit("click",{event:new Eb(this,r,[o,a])})})})}cell(e,t){const i=this.controller.valueController,s=i.cellControllers[t*i.size[0]+e];return this.cellToApiMap_.get(s)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s.event)}),this}}class nl{constructor(e,t){this.size=t.size;const[i,s]=this.size,r=[];for(let o=0;o{this.cellCs_.forEach(o=>{o.viewProps.set("disposed",!0)})}),this.view=new Ta(e,{viewProps:this.viewProps,viewName:"btngrid"}),this.view.element.style.gridTemplateColumns=`repeat(${i}, 1fr)`,this.cellCs_.forEach(o=>{this.view.element.appendChild(o.view.element)})}get cellControllers(){return this.cellCs_}}class Hr extends hn{constructor(e,t){const i=t.valueController,s=new Un(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:i.viewProps}),this.valueController=i,this.labelController=s}}const kb=$({id:"buttongrid",type:"blade",accept(n){const e=L(n,t=>({cells:t.required.function,size:t.required.array(t.required.number),view:t.required.constant("buttongrid"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new Hr(n.document,{blade:n.blade,labelProps:d.fromObject({label:n.params.label}),valueController:new nl(n.document,{cellConfig:n.params.cells,size:n.params.size})})},api(n){return n.controller instanceof Hr?new tl(n.controller):null}});class il extends ot{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get value(){return this.controller.valueController.value.rawValue}set value(e){this.controller.valueController.value.rawValue=e}on(e,t){const i=t.bind(this);return this.controller.valueController.value.emitter.on(e,s=>{i(new zn(this,s.rawValue,s.options.last))}),this}}function se(n,e,t){return n*(1-t)+e*t}const Vb=20,Tb=.001,mi=100;function Sb(n,e){let t=.25,i=.5,s=-1;for(let r=0;rn.toObject(),fromComponents:n=>new ze(...n)};function Lb(n){const e=j(2);return`cubic-bezier(${n.toObject().map(i=>e(i)).join(", ")})`}const Gr=[0,.5,.5,1];function $b(n){const e=n.match(/^cubic-bezier\s*\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*\)$/);if(!e)return new ze(...Gr);const t=[e[1],e[2],e[3],e[4]].reduce((i,s)=>{if(!i)return null;const r=Number(s);return isNaN(r)?null:[...i,r]},[]);return new ze(...t??Gr)}const Ge=m("cbz");class sl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ge()),t.viewProps.bindClassModifiers(this.element),t.foldable.bindExpandedClass(this.element,Ge(void 0,"expanded")),ce(t.foldable,"completed",Ke(this.element,Ge(void 0,"cpl")));const i=e.createElement("div");i.classList.add(Ge("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(Ge("b")),t.viewProps.bindDisabled(s);const r=e.createElementNS(R,"svg");r.innerHTML='',s.appendChild(r),i.appendChild(s),this.buttonElement=s;const o=e.createElement("div");if(o.classList.add(Ge("t")),i.appendChild(o),this.textElement=o,t.pickerLayout==="inline"){const a=e.createElement("div");a.classList.add(Ge("p")),this.element.appendChild(a),this.pickerElement=a}else this.pickerElement=null}}const vi=m("cbzp");class rl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(vi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(vi("g")),this.element.appendChild(i),this.graphElement=i;const s=e.createElement("div");s.classList.add(vi("t")),this.element.appendChild(s),this.textElement=s}}function ol(n,e){const t=new MutationObserver(s=>{for(const r of s)r.type==="childList"&&r.addedNodes.forEach(o=>{o.contains(o)&&(e(),t.disconnect())})}),i=n.ownerDocument;t.observe(i.body,{attributes:!0,childList:!0,subtree:!0})}const Re=m("cbzg");function Ab(n,e){return t=>e(n(t))}class al{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Re()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Re("p")),this.element.appendChild(i),this.previewElement=i;const s=e.createElementNS(R,"svg");s.classList.add(Re("g")),this.element.appendChild(s),this.svgElem_=s;const r=e.createElementNS(R,"path");r.classList.add(Re("u")),this.svgElem_.appendChild(r),this.guideElem_=r;const o=e.createElementNS(R,"polyline");o.classList.add(Re("l")),this.svgElem_.appendChild(o),this.lineElem_=o,this.handleElems_=[e.createElement("div"),e.createElement("div")],this.handleElems_.forEach(a=>{a.classList.add(Re("h")),this.element.appendChild(a)}),this.vectorElems_=[e.createElementNS(R,"line"),e.createElementNS(R,"line")],this.vectorElems_.forEach(a=>{a.classList.add(Re("v")),this.svgElem_.appendChild(a)}),this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_.bind(this)),this.sel_=t.selection,this.handleElems_.forEach((a,l)=>{le(this.sel_,Ab(c=>c===l,Ke(a,Re("h","sel"))))}),ol(this.element,()=>{this.refresh()})}getVertMargin_(e){return e*.25}valueToPosition(e,t){const{clientWidth:i,clientHeight:s}=this.element,r=this.getVertMargin_(s);return{x:h(e,0,1,0,i),y:h(t,0,1,s-r,r)}}positionToValue(e,t){const i=this.element.getBoundingClientRect(),s=i.width,r=i.height,o=this.getVertMargin_(r);return{x:V(h(e,0,s,0,1),0,1),y:h(t,r-o,o,0,1)}}refresh(){this.guideElem_.setAttributeNS(null,"d",[0,1].map(r=>{const o=this.valueToPosition(0,r),a=this.valueToPosition(1,r);return[`M ${o.x},${o.y}`,`L ${a.x},${a.y}`].join(" ")}).join(" "));const e=this.value_.rawValue,t=[];let i=0;for(;;){const r=this.valueToPosition(...e.curve(i));if(t.push([r.x,r.y].join(",")),i>=1)break;i=Math.min(i+.05,1)}this.lineElem_.setAttributeNS(null,"points",t.join(" "));const s=e.toObject();[0,1].forEach(r=>{const o=this.valueToPosition(r,r),a=this.valueToPosition(s[r*2],s[r*2+1]),l=this.vectorElems_[r];l.setAttributeNS(null,"x1",String(o.x)),l.setAttributeNS(null,"y1",String(o.y)),l.setAttributeNS(null,"x2",String(a.x)),l.setAttributeNS(null,"y2",String(a.y));const c=this.handleElems_[r];c.style.left=`${a.x}px`,c.style.top=`${a.y}px`})}onValueChange_(){this.refresh()}}const Wr=24,Yr=400,Xr=1e3,dt=m("cbzprv");class ll{constructor(e,t){this.stopped_=!0,this.startTime_=-1,this.onDispose_=this.onDispose_.bind(this),this.onTimer_=this.onTimer_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(dt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElementNS(R,"svg");i.classList.add(dt("g")),this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(R,"path");s.classList.add(dt("t")),this.svgElem_.appendChild(s),this.ticksElem_=s;const r=e.createElement("div");r.classList.add(dt("m")),this.element.appendChild(r),this.markerElem_=r,this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_),t.viewProps.handleDispose(this.onDispose_),ol(this.element,()=>{this.refresh()})}play(){this.stop(),this.updateMarker_(0),this.markerElem_.classList.add(dt("m","a")),this.startTime_=new Date().getTime()+Yr,this.stopped_=!1,requestAnimationFrame(this.onTimer_)}stop(){this.stopped_=!0,this.markerElem_.classList.remove(dt("m","a"))}onDispose_(){this.stop()}updateMarker_(e){const t=this.value_.rawValue.y(V(e,0,1));this.markerElem_.style.left=`${t*100}%`}refresh(){const{clientWidth:e,clientHeight:t}=this.svgElem_,i=[],s=this.value_.rawValue;for(let r=0;rXr+Yr&&this.stop(),this.stopped_||requestAnimationFrame(this.onTimer_)}onValueChange_(){this.refresh(),this.play()}}function Mi(n,e,t,i){const s=t-n,r=i-e;return Math.sqrt(s*s+r*r)}function Mb(n,e,t,i){const s=Mi(n,e,t,i),r=Math.atan2(i-e,t-n),o=Math.round(r/(Math.PI/4))*Math.PI/4;return{x:n+Math.cos(o)*s,y:e+Math.sin(o)*s}}class cl{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.keyScale_=t.keyScale,this.value=t.value,this.sel_=S(0),this.viewProps=t.viewProps,this.view=new al(e,{selection:this.sel_,value:this.value,viewProps:this.viewProps}),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_),this.prevView_=new ll(e,{value:this.value,viewProps:this.viewProps}),this.prevView_.element.addEventListener("mousedown",s=>{s.stopImmediatePropagation(),s.preventDefault(),this.prevView_.play()}),this.view.previewElement.appendChild(this.prevView_.element);const i=new Ve(this.view.element);i.emitter.on("down",this.onPointerDown_),i.emitter.on("move",this.onPointerMove_),i.emitter.on("up",this.onPointerUp_)}refresh(){this.view.refresh(),this.prevView_.refresh(),this.prevView_.play()}updateValue_(e,t,i){const s=this.sel_.rawValue,r=this.value.rawValue.toObject(),o=this.view.positionToValue(e.x,e.y),a=t?Mb(s,s,o.x,o.y):o;r[s*2]=a.x,r[s*2+1]=a.y,this.value.setRawValue(new ze(...r),i)}onPointerDown_(e){const t=e.data;if(!t.point)return;const i=this.value.rawValue,s=this.view.valueToPosition(i.x1,i.y1),r=Mi(t.point.x,t.point.y,s.x,s.y),o=this.view.valueToPosition(i.x2,i.y2),a=Mi(t.point.x,t.point.y,o.x,o.y);this.sel_.rawValue=r<=a?0:1,this.updateValue_(t.point,e.shiftKey,{forceEmit:!1,last:!1})}onPointerMove_(e){const t=e.data;t.point&&this.updateValue_(t.point,e.shiftKey,{forceEmit:!1,last:!1})}onPointerUp_(e){const t=e.data;t.point&&this.updateValue_(t.point,e.shiftKey,{forceEmit:!0,last:!0})}onKeyDown_(e){Mn(e.key)&&e.preventDefault();const t=this.sel_.rawValue,i=this.value.rawValue.toObject(),s=this.keyScale_.rawValue;i[t*2]+=D(s,he(e)),i[t*2+1]+=D(s,tt(e)),this.value.setRawValue(new ze(...i),{forceEmit:!1,last:!1})}onKeyUp_(e){Mn(e.key)&&e.preventDefault();const t=this.keyScale_.rawValue,i=D(t,he(e)),s=D(t,tt(e));i===0&&s===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class pl{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new rl(e,{viewProps:this.viewProps}),this.gc_=new cl(e,{keyScale:t.axis.textProps.value("keyScale"),value:this.value,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.gc_.view.element);const i=Object.assign(Object.assign({},t.axis),{constraint:new cs({max:1,min:0})}),s=Object.assign(Object.assign({},t.axis),{constraint:void 0});this.tc_=new Lt(e,{assembly:Is,axes:[i,s,i,s],parser:ue,value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element)}get allFocusableElements(){return[this.gc_.view.element,...this.tc_.view.textViews.map(e=>e.inputElement)]}refresh(){this.gc_.refresh()}}class Oi{constructor(e,t){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Tt.create(t.expanded),this.view=new sl(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("blur",this.onButtonBlur_),this.view.buttonElement.addEventListener("click",this.onButtonClick_),this.tc_=new Yn(e,{parser:$b,props:d.fromObject({formatter:Lb}),value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element),this.popC_=t.pickerLayout==="popup"?new Vs(e,{viewProps:this.viewProps}):null;const i=new pl(e,{axis:t.axis,value:this.value,viewProps:this.viewProps});i.allFocusableElements.forEach(s=>{s.addEventListener("blur",this.onPopupChildBlur_),s.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=i,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),le(this.popC_.shows,s=>{s&&i.refresh()}),lt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:s=>s,backward:(s,r)=>r})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Hn(this.foldable_,this.view.pickerElement))}onButtonBlur_(e){if(!this.popC_)return;const t=e.relatedTarget;(!t||!this.popC_.view.element.contains(t))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=gs(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!Kn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_&&e.key==="Escape"&&(this.popC_.shows.rawValue=!1)}}function Ob(){return new Qn({assembly:Is,components:[0,1,2,3].map(n=>n%2===0?new cs({min:0,max:1}):void 0)})}const Rb=$({id:"cubicbezier",type:"blade",accept(n){const e=L(n,t=>({value:t.required.array(t.required.number),view:t.required.constant("cubicbezier"),expanded:t.optional.boolean,label:t.optional.string,picker:t.optional.custom(i=>i==="inline"||i==="popup"?i:void 0)}));return e?{params:e}:null},controller(n){var e,t;const i=new ze(...n.params.value),s=S(i,{constraint:Ob(),equals:ze.equals}),r=new Oi(n.document,{axis:{textProps:d.fromObject({keyScale:.1,pointerScale:.01,formatter:j(2)})},expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps});return new $n(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:s,valueController:r})},api(n){return!(n.controller instanceof $n)||!(n.controller.valueController instanceof Oi)?null:new il(n.controller)}});class ul extends ot{get fps(){return this.controller.valueController.fps}get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}begin(){this.controller.valueController.begin()}end(){this.controller.valueController.end()}on(e,t){const i=t.bind(this);return this.controller.valueController.ticker.emitter.on(e,()=>{i(new at(this))}),this}}const Qr=20;class hl{constructor(){this.start_=null,this.duration_=0,this.fps_=null,this.frameCount_=0,this.timestamps_=[]}get duration(){return this.duration_}get fps(){return this.fps_}begin(e){this.start_=e.getTime()}calculateFps_(e){if(this.timestamps_.length===0)return null;const t=this.timestamps_[0];return 1e3*(this.frameCount_-t.frameCount)/(e-t.time)}compactTimestamps_(){if(this.timestamps_.length<=Qr)return;const e=this.timestamps_.length-Qr;this.timestamps_.splice(0,e);const t=this.timestamps_[0].frameCount;this.timestamps_.forEach(i=>{i.frameCount-=t}),this.frameCount_-=t}end(e){if(this.start_===null)return;const t=e.getTime();this.duration_=t-this.start_,this.start_=null,this.fps_=this.calculateFps_(t),this.timestamps_.push({frameCount:this.frameCount_,time:t}),++this.frameCount_,this.compactTimestamps_()}}const jt=m("fps");class dl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(jt()),t.viewProps.bindClassModifiers(this.element),this.graphElement=e.createElement("div"),this.graphElement.classList.add(jt("g")),this.element.appendChild(this.graphElement);const i=e.createElement("div");i.classList.add(jt("l")),this.element.appendChild(i);const s=e.createElement("span");s.classList.add(jt("v")),s.textContent="--",i.appendChild(s),this.valueElement=s;const r=e.createElement("span");r.classList.add(jt("u")),r.textContent="FPS",i.appendChild(r)}}class ml{constructor(e,t){this.stopwatch_=new hl,this.onTick_=this.onTick_.bind(this),this.ticker=t.ticker,this.ticker.emitter.on("tick",this.onTick_),this.props=t.props,this.value_=t.value,this.viewProps=t.viewProps,this.view=new dl(e,{viewProps:this.viewProps}),this.graphC_=new js(e,{formatter:j(0),props:this.props,rows:t.rows,value:this.value_,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.graphC_.view.element),this.viewProps.handleDispose(()=>{this.graphC_.viewProps.set("disposed",!0),this.ticker.dispose()})}get fps(){return this.stopwatch_.fps}begin(){this.stopwatch_.begin(new Date)}end(){this.stopwatch_.end(new Date)}onTick_(){const e=this.fps;if(e!==null){const t=this.value_.rawValue;this.value_.rawValue=Wd(t,e),this.view.valueElement.textContent=e.toFixed(0)}}}class Zr extends hn{constructor(e,t){const i=t.valueController,s=new Un(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:i.viewProps}),this.valueController=i,this.labelController=s}}function Db(n,e){return e===0?new Cm:new xm(n,e??vn.monitor.defaultInterval)}const Bb=$({id:"fpsgraph",type:"blade",accept(n){const e=L(n,t=>({view:t.required.constant("fpsgraph"),interval:t.optional.number,label:t.optional.string,rows:t.optional.number,max:t.optional.number,min:t.optional.number}));return e?{params:e}:null},controller(n){var e,t,i,s;const r=(e=n.params.interval)!==null&&e!==void 0?e:500;return new Zr(n.document,{blade:n.blade,labelProps:d.fromObject({label:n.params.label}),valueController:new ml(n.document,{props:d.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:90,min:(i=n.params.min)!==null&&i!==void 0?i:0}),rows:(s=n.params.rows)!==null&&s!==void 0?s:2,ticker:Db(n.document,r),value:S(Hd(80)),viewProps:n.viewProps})})},api(n){return n.controller instanceof Zr?new ul(n.controller):null}});class J{constructor(e,t){this.min=e,this.max=t}static isObject(e){if(typeof e!="object"||e===null)return!1;const t=e.min,i=e.max;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.min===t.min&&e.max===t.max}get length(){return this.max-this.min}toObject(){return{min:this.min,max:this.max}}}const Fs={fromComponents:n=>new J(n[0],n[1]),toComponents:n=>[n.min,n.max]};class zs{constructor(e){this.edge=e}constrain(e){var t,i,s,r,o,a,l,c;if(e.min<=e.max)return new J((i=(t=this.edge)===null||t===void 0?void 0:t.constrain(e.min))!==null&&i!==void 0?i:e.min,(r=(s=this.edge)===null||s===void 0?void 0:s.constrain(e.max))!==null&&r!==void 0?r:e.max);const p=(e.min+e.max)/2;return new J((a=(o=this.edge)===null||o===void 0?void 0:o.constrain(p))!==null&&a!==void 0?a:p,(c=(l=this.edge)===null||l===void 0?void 0:l.constrain(p))!==null&&c!==void 0?c:p)}}const bi=m("rsltxt");class vl{constructor(e,t){this.sliderView_=t.sliderView,this.textView_=t.textView,this.element=e.createElement("div"),this.element.classList.add(bi());const i=e.createElement("div");i.classList.add(bi("s")),i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(bi("t")),s.appendChild(this.textView_.element),this.element.appendChild(s)}}const We=m("rsl");class bl{constructor(e,t){this.onSliderPropsChange_=this.onSliderPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.sliderProps_=t.sliderProps,this.sliderProps_.emitter.on("change",this.onSliderPropsChange_),this.element=e.createElement("div"),this.element.classList.add(We()),t.viewProps.bindClassModifiers(this.element),this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_);const i=e.createElement("div");i.classList.add(We("t")),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(We("b")),i.appendChild(s),this.barElement=s;const r=["min","max"].map(o=>{const a=e.createElement("div");return a.classList.add(We("k"),We("k",o)),i.appendChild(a),a});this.knobElements=[r[0],r[1]],this.update_()}valueToX_(e){const t=this.sliderProps_.get("min"),i=this.sliderProps_.get("max");return V(h(e,t,i,0,1),0,1)*100}update_(){const e=this.value_.rawValue;e.length===0?this.element.classList.add(We(void 0,"zero")):this.element.classList.remove(We(void 0,"zero"));const t=[this.valueToX_(e.min),this.valueToX_(e.max)];this.barElement.style.left=`${t[0]}%`,this.barElement.style.right=`${100-t[1]}%`,this.knobElements.forEach((i,s)=>{i.style.left=`${t[s]}%`})}onSliderPropsChange_(){this.update_()}onValueChange_(){this.update_()}}class fl{constructor(e,t){this.grabbing_=null,this.grabOffset_=0,this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.sliderProps=t.sliderProps,this.viewProps=t.viewProps,this.value=t.value,this.view=new bl(e,{sliderProps:this.sliderProps,value:this.value,viewProps:t.viewProps});const i=new Ve(this.view.trackElement);i.emitter.on("down",this.onPointerDown_),i.emitter.on("move",this.onPointerMove_),i.emitter.on("up",this.onPointerUp_)}ofs_(){return this.grabbing_==="min"?this.view.knobElements[0].getBoundingClientRect().width/2:this.grabbing_==="max"?-this.view.knobElements[1].getBoundingClientRect().width/2:0}valueFromData_(e){if(!e.point)return null;const t=(e.point.x+this.ofs_())/e.bounds.width,i=this.sliderProps.get("min"),s=this.sliderProps.get("max");return h(t,0,1,i,s)}onPointerDown_(e){if(!e.data.point)return;const t=e.data.point.x/e.data.bounds.width,i=this.value.rawValue,s=this.sliderProps.get("min"),r=this.sliderProps.get("max"),o=h(i.min,s,r,0,1),a=h(i.max,s,r,0,1);Math.abs(a-t)<=.025?this.grabbing_="max":Math.abs(o-t)<=.025?this.grabbing_="min":t>=o&&t<=a?(this.grabbing_="length",this.grabOffset_=h(t-o,0,1,0,r-s)):ta&&(this.grabbing_="max",this.onPointerMove_(e))}applyPointToValue_(e,t){const i=this.valueFromData_(e);if(i===null)return;const s=this.sliderProps.get("min"),r=this.sliderProps.get("max");if(this.grabbing_==="min")this.value.setRawValue(new J(i,this.value.rawValue.max),t);else if(this.grabbing_==="max")this.value.setRawValue(new J(this.value.rawValue.min,i),t);else if(this.grabbing_==="length"){const o=this.value.rawValue.length;let a=i-this.grabOffset_,l=a+o;ar&&(a=r-o,l=r),this.value.setRawValue(new J(a,l),t)}}onPointerMove_(e){this.applyPointToValue_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.applyPointToValue_(e.data,{forceEmit:!0,last:!0}),this.grabbing_=null}}class wl{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sc_=new fl(e,t);const i={constraint:t.constraint,textProps:t.textProps};this.tc_=new Lt(e,{assembly:Fs,axes:[i,i],parser:t.parser,value:this.value,viewProps:t.viewProps}),this.view=new vl(e,{sliderView:this.sc_.view,textView:this.tc_.view})}get textController(){return this.tc_}}function Nb(n){return J.isObject(n)?new J(n.min,n.max):new J(0,0)}function jb(n,e){n.writeProperty("max",e.max),n.writeProperty("min",e.min)}function Ib(n){const e=[],t=ms(n);t&&e.push(t);const i=ds(n);return i&&e.push(i),new zs(new St(e))}const Fb=$({id:"input-interval",type:"input",accept:(n,e)=>{if(!J.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},bs(i)),{readonly:i.optional.constant(!1)}));return t?{initialValue:new J(n.min,n.max),params:t}:null},binding:{reader:n=>Nb,constraint:n=>Ib(n.params),equals:J.equals,writer:n=>jb},controller(n){const e=n.value,t=n.constraint;if(!(t instanceof zs))throw H.shouldNeverHappen();const i=(e.rawValue.min+e.rawValue.max)/2,s=d.fromObject(vs(n.params,i)),r=t.edge&&Jt(t.edge,un);if(r)return new wl(n.document,{constraint:t.edge,parser:ue,sliderProps:new d({keyScale:s.value("keyScale"),max:r.values.value("max"),min:r.values.value("min")}),textProps:s,value:e,viewProps:n.viewProps});const o={constraint:t.edge,textProps:s};return new Lt(n.document,{assembly:Fs,axes:[o,o],parser:ue,value:e,viewProps:n.viewProps})}});class _l{constructor(e){this.controller_=e}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get title(){var e;return(e=this.controller_.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.props.set("title",e)}}class gl extends zn{constructor(e,t,i,s,r){super(e,s,r),this.cell=t,this.index=i}}class Cl extends ot{constructor(e){super(e),this.cellToApiMap_=new Map,this.controller.valueController.cellControllers.forEach(i=>{const s=new _l(i);this.cellToApiMap_.set(i,s)})}get value(){return this.controller.value}cell(e,t){const i=this.controller.valueController,s=i.cellControllers[t*i.size[0]+e];return this.cellToApiMap_.get(s)}on(e,t){const i=t.bind(this);this.controller.value.emitter.on(e,s=>{const r=this.controller.valueController,o=r.findCellByValue(s.rawValue);if(!o)return;const a=this.cellToApiMap_.get(o);if(!a)return;const l=r.cellControllers.indexOf(o);i(new gl(this,a,[l%r.size[0],Math.floor(l/r.size[0])],s.rawValue))})}}const It=m("rad");class xl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(It()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(It("l")),this.element.appendChild(i);const s=e.createElement("input");s.classList.add(It("i")),s.name=t.name,s.type="radio",t.viewProps.bindDisabled(s),i.appendChild(s),this.inputElement=s;const r=e.createElement("div");r.classList.add(It("b")),i.appendChild(r);const o=e.createElement("div");o.classList.add(It("t")),r.appendChild(o),ce(t.props,"title",a=>{o.textContent=a})}}class yl{constructor(e,t){this.props=t.props,this.viewProps=t.viewProps,this.view=new xl(e,{name:t.name,props:this.props,viewProps:this.viewProps})}}class On{constructor(e,t){this.cellCs_=[],this.cellValues_=[],this.onCellInputChange_=this.onCellInputChange_.bind(this),this.size=t.size;const[i,s]=this.size;for(let r=0;r{const o=this.findCellByValue(r);o&&(o.view.inputElement.checked=!0)}),this.viewProps=ke.create(),this.view=new Ta(e,{viewProps:this.viewProps,viewName:"radgrid"}),this.view.element.style.gridTemplateColumns=`repeat(${i}, 1fr)`,this.cellCs_.forEach(r=>{r.view.inputElement.addEventListener("change",this.onCellInputChange_),this.view.element.appendChild(r.view.element)})}get cellControllers(){return this.cellCs_}findCellByValue(e){const t=this.cellValues_.findIndex(i=>i===e);return t<0?null:this.cellCs_[t]}onCellInputChange_(e){const t=e.currentTarget,i=this.cellCs_.findIndex(s=>s.view.inputElement===t);i<0||(this.value.rawValue=this.cellValues_[i])}}const zb=function(){return $({id:"radiogrid",type:"blade",accept(n){const e=L(n,t=>({cells:t.required.function,groupName:t.required.string,size:t.required.array(t.required.number),value:t.required.raw,view:t.required.constant("radiogrid"),label:t.optional.string}));return e?{params:e}:null},controller(n){const e=S(n.params.value);return new $n(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:e,valueController:new On(n.document,{groupName:n.params.groupName,cellConfig:n.params.cells,size:n.params.size,value:e})})},api(n){return!(n.controller instanceof $n)||!(n.controller.valueController instanceof On)?null:new Cl(n.controller)}})}();function Ks(n){return $({id:"input-radiogrid",type:"input",accept(e,t){if(!n.isType(e))return null;const i=L(t,s=>({cells:s.required.function,groupName:s.required.string,size:s.required.array(s.required.number),view:s.required.constant("radiogrid")}));return i?{initialValue:e,params:i}:null},binding:n.binding,controller:e=>new On(e.document,{cellConfig:e.params.cells,groupName:e.params.groupName,size:e.params.size,value:e.value})})}const Kb=Ks({isType:n=>typeof n=="number",binding:{reader:n=>hs,writer:n=>qe}}),qb=Ks({isType:n=>typeof n=="string",binding:{reader:n=>Ss,writer:n=>qe}}),Ub=Ks({isType:n=>typeof n=="boolean",binding:{reader:n=>Ts,writer:n=>qe}}),Hb="essentials",Gb='.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--bld-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--cnt-usz);line-height:var(--cnt-usz);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--bld-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--cnt-usp);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1 * var(--cnt-hp));position:absolute;right:calc(-1 * var(--cnt-hp));top:var(--cnt-usz)}.tp-cbzpv_t{margin-top:var(--cnt-usp)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--cnt-usz) * 5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--cnt-usz));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--cnt-usz) - 8px);margin-top:calc((var(--cnt-usz) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--bld-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',Wb=[kb,Rb,Bb,Fb,zb,Ub,Kb,qb],Yb=Object.freeze(Object.defineProperty({__proto__:null,ButtonCellApi:el,ButtonGridApi:tl,ButtonGridController:nl,CubicBezier:ze,CubicBezierApi:il,CubicBezierAssembly:Is,CubicBezierController:Oi,CubicBezierGraphController:cl,CubicBezierGraphView:al,CubicBezierPickerController:pl,CubicBezierPickerView:rl,CubicBezierPreviewView:ll,CubicBezierView:sl,FpsGraphBladeApi:ul,FpsGraphController:ml,FpsView:dl,Fpswatch:hl,Interval:J,IntervalAssembly:Fs,IntervalConstraint:zs,RadioCellApi:_l,RadioController:yl,RadioGridApi:Cl,RadioGridController:On,RadioView:xl,RangeSliderController:fl,RangeSliderTextController:wl,RangeSliderTextView:vl,RangeSliderView:bl,TpRadioGridChangeEvent:gl,css:Gb,id:Hb,plugins:Wb},Symbol.toStringTag,{value:"Module"})),Xe={sceneChange:"scene-change",instrumentPlayed:"instrument-played"},zt=class zt{constructor(e){b(this,"pane");b(this,"settings");b(this,"sceneControls",{});this.game=e;const t=document.getElementById("settings");if(!t)throw new Error("No settings container found");this.pane=new Xh({title:"settings",expanded:!1,container:t}),this.pane.registerPlugin(Yb),this.pane.on("change",s=>{var o,a;const r=s.target.key;this.settings&&s.last&&r in this.settings&&((a=(o=this.settings).onChange)==null||a.call(o,{[r]:s.value}))}),e.events.on(Xe.sceneChange,s=>{this.deleteSettings(),this.settings=s,s&&this.addSettings(s)}),window.onerror=function(s,r,o,a,l){Q.error(` -`+s+" "+r+" "+o+" "+a+" "+l)},this.pane.addButton({title:"Show logs"}).on("click",()=>{i.hidden=!i.hidden});const i=this.pane.addBinding(zt.logsParams,"logs",{label:"",readonly:!0,multiline:!0,rows:10,hidden:!0,interval:1e3});this.resize()}static log(e){zt.logsParams.logs+=` -`+e}deleteSettings(){Object.values(this.sceneControls).filter(Boolean).forEach(e=>{e.dispose(),this.pane.remove(e)})}addSettings(e){this.sceneControls.deleteInstrument=this.pane.addButton({title:"Delete instrument & loop",index:0}).on("click",()=>ae.deleteCurrentInstrumentScene()),this.sceneControls.deleteLoop=this.pane.addButton({title:"Delete current loop",index:0}).on("click",()=>ae.deleteCurrentTrack()),e.noteDuration&&(this.sceneControls.noteDuration=this.pane.addBinding(e,"noteDuration",{label:"Note duration",min:.1,max:5,step:.1,index:0})),e.octaveRange&&(this.sceneControls.octaveRange=this.pane.addBinding(e,"octaveRange",{label:"Octave range",min:1,max:6,step:1,index:0})),this.sceneControls.volume=this.pane.addBinding(e,"volume",{min:0,max:100,step:1,index:0})}resize(){const e=Math.min(this.game.canvas.width,this.game.canvas.height),t=e/40+"px",i=e/10+"px";document.querySelectorAll("button").forEach(s=>{s.style.fontSize=t,s.style.height=i})}};b(zt,"logsParams",{logs:""});let Rn=zt;const fi=(n,e)=>{Rn.log(e.map(t=>t.toString()).join(", ")),console[n](...e)},Q={log:(n,...e)=>{fi("log",[n,...e])},error:(n,...e)=>{fi("error",[n,...e])},warn:(n,...e)=>{fi("warn",[n,...e])}};let q=null;const Xb=window.AudioContext||window.webkitAudioContext,Te=()=>(q||(q=new Xb),(q==null?void 0:q.state)==="suspended"&&(Q.log("Resuming AudioContext"),q==null||q.resume()),q);document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(q==null?void 0:q.state)==="suspended"&&(Q.log("Resuming AudioContext after visibility change"),q==null||q.resume().catch(n=>Q.error("Error resuming AudioContext:",n)))});function Qb(n=100){const e=Te(),t=e.sampleRate*.05,i=e.createBuffer(1,t,e.sampleRate),s=i.getChannelData(0);for(let p=0;p{if(e!==0)try{Jr[n](e)}catch(t){Q.error(`Error playing ${n}`,t),Jr[n](e)}},cf=(n,e,t)=>{const i=[];for(let r=0;ri.map(a=>a[o]).reverse()).flat()};class Us extends U.Scene{constructor(t,i){super();b(this,"pads",[]);b(this,"settings",{volume:50,onChange:t=>this.onSettingChange(t)});b(this,"canRecord",!0);b(this,"canPlay",!0);b(this,"sceneText","");b(this,"sceneTextColor",O.white);this.cols=t,this.rows=i}create({color:t,text:i}){this.sceneText=i,this.sceneTextColor=t,this.createPads(),this.game.events.emit(Xe.sceneChange,this.settings)}changePadNumber(t,i){this.cols=t,this.rows=i,this.scene.restart()}createPads(){const t=this.cols*this.rows;this.pads=new Array(t).fill(0).map((s,r)=>this.createPad(r,t));const i=()=>{const s=window.innerWidth{const B=_%r*a,N=Math.floor(_/r)*l,I=s?0:ae.sceneWidthHeight,kl=s?ae.sceneWidthHeight:0;p.setSize(a,l).setPosition(I+B,kl+N),u&&u.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(qt.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(t,i){const s=this.getPadColor(i,t),r=this.getHitColor(i,t),o=this.getPadText(t),a=this.getBorderColor(t),l=this.add.rectangle().setFillStyle(s.color).setStrokeStyle(1,a.color,.8).setInteractive().setOrigin(0,0);let c;o&&(c=this.add.text(0,0,o.text,{fontFamily:Kt.Text,fontSize:qt.tiny,color:o.color?Pn(o.color):_i.white}).setAlpha(o.alpha??.5).setOrigin(.5,.5).setResolution(2).setPosition(l.getCenter().x,l.getCenter().y).setDepth(1));let p=!1;const u=()=>{p||(this.playSound(t),l.setFillStyle(r.color),this.game.events.emit(Xe.instrumentPlayed,{callback:()=>this.playSound(t),scene:this}),p=!0)},_=()=>{l.setFillStyle(s.color),p=!1};return l.on("pointerdown",B=>{var N,I;((I=(N=B.downElement)==null?void 0:N.tagName)==null?void 0:I.toLowerCase())==="canvas"&&u()}).on("pointermove",B=>{B.isDown&&u()}).on("pointerup",()=>_()).on("pointerout",()=>_()),{instrument:t,button:l,text:c}}getPadColor(t,i){return U.Display.Color.HSLToColor((t-i)/(t*1.5),1,.5)}getPadText(t){}onSettingChange(t){Q.log("Setting changed",JSON.stringify(t))}getHitColor(t,i){return this.getPadColor(t,i).brighten(40)}getBorderColor(t){return O.darkGrey}}const eo={hihat:x.orange,kick:x.red,snare:x.blue,crash:x.green,"hihat-open":x.yellow,ride:x.yellow2,"tom-low":x.orange2,"tom-high":x.purple,"tom-mid":x.pink};class pf extends Us{constructor(){super(2,5);b(this,"instruments",["crash","crash","ride","hihat-open","hihat","snare","tom-high","tom-mid","tom-low","kick"])}getPadColor(t,i){return O.black}getHitColor(t,i){return K(eo[this.instruments[i]])}getPadText(t){return{text:this.instruments[t],color:K(eo[this.instruments[t]])}}playSound(t){lf(this.instruments[t],this.settings.volume)}}let Ft=null,wi=null;const to=()=>{Ft&&(Q.log("stopping note...",Ft),Ft.stop(),wi.stop()),Q.log("testing note...");const n=22050,e=Freeverb({input:Bus2(),roomSize:.975,damping:.5}).connect(),t=Synth({gain:.15,attack:44,decay:5512,Q:.8,filterType:2,saturation:2,filterMult:3.25,antialias:!0,cutoff:Add(1,Sine({frequency:.1,gain:.75}))}).connect(Gibberish.output).connect(e.input,.5),i=[55,110,165,220];wi=Sequencer.make([55,110,165,220],[n/4],t,"note").start(),Ft=Sequencer.make([i.map(s=>s*1.25),i.map(s=>s*1.25*.8),i.map(s=>s*1.25*.8*.8),i.map(s=>s*1.25*.8*.8*1.25)],[n*16],wi,"values"),Ft.start()};class uf extends Us{constructor(){super(1,1);b(this,"canRecord",!1);b(this,"canPlay",!1);b(this,"isGibberishLoaded",!1)}playSound(t){this.isGibberishLoaded?to():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",Q.log("loading Gibberish 2..."),Gibberish.init().then(()=>{Q.log("Gibberish is ready!"),Gibberish.export(window),to()}).catch(i=>Q.error("oops",i)))}getPadColor(t,i){return O.black}getPadText(t){return{text:"Play Gibberish",color:O.green}}}function hf(){const n=[];for(let e=0;e<9;e++)n[e]={};return n[2].C=65.40639132514966,n[2]["C#"]=69.29565774421802,n[2].D=73.4161919793519,n[2]["D#"]=77.78174593052023,n[2].E=82.40688922821748,n[2].F=87.30705785825097,n[2]["F#"]=92.4986056779086,n[2].G=97.99885899543732,n[2]["G#"]=103.82617439498628,n[2].A=110,n[2]["A#"]=116.54094037952248,n[2].B=123.47082531403103,n[3].C=130.8127826502993,n[3]["C#"]=138.59131548843604,n[3].D=146.8323839587038,n[3]["D#"]=155.56349186104046,n[3].E=164.81377845643496,n[3].F=174.61411571650194,n[3]["F#"]=184.9972113558172,n[3].G=195.99771799087463,n[3]["G#"]=207.65234878997256,n[3].A=220,n[3]["A#"]=233.08188075904496,n[3].B=246.94165062806206,n[4].C=261.6255653005986,n[4]["C#"]=277.1826309768721,n[4].D=293.6647679174076,n[4]["D#"]=311.1269837220809,n[4].E=329.6275569128699,n[4].F=349.2282314330039,n[4]["F#"]=369.9944227116344,n[4].G=391.99543598174927,n[4]["G#"]=415.3046975799451,n[4].A=440,n[4]["A#"]=466.1637615180899,n[4].B=493.8833012561241,n[5].C=523.2511306011972,n[5]["C#"]=554.3652619537442,n[5].D=587.3295358348151,n[5]["D#"]=622.2539674441618,n[5].E=659.2551138257398,n[5].F=698.4564628660078,n[5]["F#"]=739.9888454232688,n[5].G=783.9908719634985,n[5]["G#"]=830.6093951598903,n[5].A=880,n[5]["A#"]=932.3275230361799,n[5].B=987.7666025122483,n[6].C=1046.5022612023945,n[6]["C#"]=1108.7305239074883,n[6].D=1174.6590716696303,n[6]["D#"]=1244.5079348883237,n[6].E=1318.5102276514797,n[6].F=1396.9129257320155,n[6]["F#"]=1479.9776908465376,n[6].G=1567.981743926997,n[6]["G#"]=1661.2187903197805,n[6].A=1760,n[6]["A#"]=1864.6550460723597,n[6].B=1975.5332050244965,n[7].C=2093.004522404789,n[7]["C#"]=2217.4610478149766,n[7].D=2349.3181433392606,n[7]["D#"]=2489.0158697766474,n[7].E=2637.0204553029594,n[7].F=2793.825851464031,n[7]["F#"]=2959.955381693075,n[7].G=3135.963487853994,n[7]["G#"]=3322.437580639561,n[7].A=3520,n[7]["A#"]=3729.3100921447194,n[7].B=3951.066410048993,n}const df=hf(),yn=df.flatMap(n=>Object.entries(n)).map(([n,e])=>({key:n,freq:e})).filter(({freq:n})=>!!n).sort((n,e)=>n.freq-e.freq),Dn=12,Pl=6,mf=Dn*Pl,no=n=>n.max+1-n.min,vf=()=>Dn,io={min:2,max:Pl-2};class El extends Us{constructor(){super(no(io),vf()),this.settings.noteDuration=1.5,this.settings.octaveRange=io}getNoteColor(e){return super.getPadColor(mf,e+this.getNoteIndexOffset())}getPadText(e){const t=yn[e];return t!=null&&t.key?{text:t==null?void 0:t.key,color:this.getNoteColor(e)}:void 0}getPadColor(e,t){return this.isSharpKey(t)?O.black:this.getNoteColor(t).darken(90)}isSharpKey(e){var t;return(t=this.getKey(e))==null?void 0:t.includes("#")}getHitColor(e,t){return this.isSharpKey(t)?this.getNoteColor(t).darken(50):this.getNoteColor(t)}getKey(e){var t;return(t=yn[e+this.getNoteIndexOffset()])==null?void 0:t.key}getNoteIndexOffset(){return this.getLowerRangeIndex()*Dn}getLowerRangeIndex(){return this.settings.octaveRange.min-1}playSound(e){e+=this.getNoteIndexOffset();const t=yn[e].freq;return bf({frequency:t,...this.settings})}onSettingChange(e){super.onSettingChange(e),e.octaveRange&&super.changePadNumber(no(e.octaveRange),Dn)}}const bf=({frequency:n,volume:e=50,noteDuration:t=1.5})=>{const i=Te(),s=i.createOscillator();s.type="sine";const r=i.createGain();s.frequency.setValueAtTime(n,i.currentTime),s.connect(r),r.connect(i.destination);const o=.02;r.gain.setValueAtTime(0,i.currentTime),r.gain.linearRampToValueAtTime(e/100,i.currentTime+o),r.gain.exponentialRampToValueAtTime(1e-4,i.currentTime+t),s.start(i.currentTime),s.stop(i.currentTime+t*2)};class ff extends El{constructor(){super(),this.settings.noteDuration=2}getPadColor(e,t){return super.getPadColor(e,t).saturate(50)}playSound(e){e+=this.getNoteIndexOffset();const t=yn[e].freq;return wf({frequency:t,...this.settings})}}function wf({frequency:n,volume:e=50,noteDuration:t=1}){const i=Te(),s=i.createOscillator();s.type="sawtooth",s.frequency.setValueAtTime(n,i.currentTime);const r=i.createGain();r.gain.value=e/100,r.gain.exponentialRampToValueAtTime(.001,i.currentTime+t);const o=i.createBiquadFilter();o.type="lowpass",o.frequency.setValueAtTime(800,i.currentTime),o.Q.value=1;const a=i.createWaveShaper();a.curve=_f(400),a.oversample="4x";const l=i.createOscillator();l.type="sine",l.frequency.setValueAtTime(3,i.currentTime);const c=i.createGain();c.gain.value=200,l.connect(c),c.connect(o.frequency),s.connect(o),o.connect(a),a.connect(r),r.connect(i.destination),s.start(),l.start(),s.stop(i.currentTime+1),l.stop(i.currentTime+1)}function _f(n){const e=typeof n=="number"?n:50,t=44100,i=new Float32Array(t),s=Math.PI/180;for(let r=0;r{this.scene.setVisible(!1),this.scene.add(l,r,!0,{color:o,text:s})})}create({index:t}){this.trackIndex=t,this.scene.bringToTop(),this.game.events.emit(Xe.sceneChange),this.cameras.main.setOrigin(0,0).setBackgroundColor(x.black),this.createButtonsTable(),this.activateButton(0,0,"Synth",El,O.blue),this.activateButton(1,0,"Daft synth",ff,O.purple),this.activateButton(0,1,"Drums",pf,O.red),this.activateButton(0,2,"Gibberish",uf,O.green),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createButtonsTable(){this.instrumentButtons=[];for(let t=0;t{p.forEach((_,B)=>{_.setSize(s,r).setPosition(s*u,r*B);const N=_.getData("text");if(N){const I=Math.min(_.height,_.width)/5;N.setFontSize(I).setResolution(2).setWordWrapWidth(_.width,!0).setSize(_.width,_.height).setPosition(_.getCenter().x,_.getCenter().y)}})});const o=t?window.innerWidth:window.innerWidth-i,a=t?window.innerHeight-i:window.innerHeight,l=t?0:i,c=t?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};b(bt,"key","EmptyScene"),b(bt,"sceneText","+"),b(bt,"sceneTextColor",O.white);let De=bt;const pe=class pe{constructor(e){b(this,"state","readyToRecord");b(this,"events",[]);b(this,"eventEmitter",new U.Events.EventEmitter);b(this,"startRecordingTime");b(this,"startPlayingTime",0);b(this,"currentLoopIndex",0);b(this,"loopTimeout",null);this.trackIndex=e,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var e;return(e=this.events.find(({callback:t})=>t==="endOfLoop"))==null?void 0:e.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(e){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=pe.masterLoop.getStartPlayingTime());const t=Date.now()-this.startRecordingTime;this.events.push({callback:e,time:t}),this.log(`Recording ${e} at time ${t}ms`)}}isPlaying(){return this.state==="playing"}isReadyToPlay(){return this.state==="readyToPlay"}isRecording(){return this.state==="recording"}isReadyToRecord(){return this.state==="readyToRecord"}destroy(){this.eventEmitter.removeAllListeners(),this.isPlaying()&&this.stopPlaying(),this.events=[],this.isMasterLoop()&&(pe.masterLoop=null),this.log("Loop destroyed")}addEventListener(e,t){this.eventEmitter.once(e,t)}nextState(){switch(this.state){case"readyToRecord":this.state="recording";break;case"recording":this.state=this.stopRecording();break;case"readyToPlay":this.state="playing";break;case"playing":this.state="readyToPlay";break}}startRecording(){this.events=[],this.log("Recording started"),pe.masterLoop?this.startRecordingTime||(this.log("no startRecordingTime !"),this.startRecordingTime=Date.now()):(pe.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var t;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const e=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:e});const i=this.events[0].time;this.events=this.events.map(({time:s,callback:r})=>({time:s-i,callback:r}))}else{Q.log("events: "+this.events.length,this.events);const i=(t=pe.masterLoop)==null?void 0:t.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const r=Math.floor(e/i)*i;this.events=this.events.filter(({time:o})=>o<=r),this.events.push({callback:"endOfLoop",time:r})}return this.log(`Recording stopped at ${e} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var t;const e=()=>{this.currentLoopIndex>=this.events.length&&(this.currentLoopIndex=0),this.currentLoopIndex===0&&(this.log("Loop play (re)-started","#0F0"),this.startPlayingTime=Date.now());const{callback:i,time:s}=this.events[this.currentLoopIndex],r=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,e()},s-r)};this.log("Loop play starting"),!this.isMasterLoop()&&((t=pe.masterLoop)!=null&&t.isPlaying())?pe.masterLoop.addEventListener("endOfLoop",()=>{e()}):e()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===pe.masterLoop}log(e,t){const i=`Loop ${this.trackIndex+1}: ${e}`;t?Q.log(`%c${i}`,`color: ${t}`):Q.log(i)}};b(pe,"masterLoop",null);let Bn=pe;const so={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},mt={idle:x.white,readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},y=class y extends U.Scene{constructor(){super(y.key);b(this,"resizeTracks",()=>{const t=window.innerWidth{const c=t?i*l:0,p=t?0:s*l;r.setSize(i,s).setPosition(c,p);const u=t?r.getCenter().x:r.getCenter().x-i/4,_=t?r.getCenter().y-s/4:r.getCenter().y,B=Math.min(s,i);o.setResolution(3).setSize(i,s).setFontSize(B/4).setPosition(u,_).setWordWrapWidth(i-10,!0).setRotation(t?0:-Math.PI/2),a.setOrigin(t?.5:1,t?1:.5).setPosition(t?r.getCenter().x:r.getRightCenter().x,t?r.getBottomCenter().y:r.getCenter().y)}),this.cameras.main.setViewport(0,0,t?window.innerWidth:i,t?s:window.innerHeight)});y.instance=this}static get sceneWidthHeight(){const t=window.innerWidth,i=window.innerHeight;return Math.max(i,t)/10}static deleteCurrentTrack(){const t=y.tracks.find(i=>i.selected);if(t){const i=y.tracks.indexOf(t);return t.loop.destroy(),t.loopProgressArc.clear(),t.loop=new Bn(i),this.instance.updateControlsState(),i}throw new Error("No track selected")}static deleteCurrentInstrumentScene(){const t=y.deleteCurrentTrack(),i=y.getTrackSceneKey(t);this.instance.game.scene.remove(i),this.instance.game.scene.start(De.key,{index:t}),this.instance.updateControlsState()}static getTrackSceneKey(t){return`track_scene_${t}`}create(){this.createTracks(),this.game.events.on(Xe.sceneChange,()=>{this.updateControlsState()}),this.game.events.on(Xe.instrumentPlayed,({callback:t})=>{var i,s;(s=(i=y.tracks.find(r=>r.selected))==null?void 0:i.loop)==null||s.addLoopEvent(t)})}update(){for(const t of y.tracks)t.loop.isPlaying()&&this.updateProgressArc(t)}getTrackScene(t){return this.scene.get(y.getTrackSceneKey(t))}updateProgressArc(t){const i=t.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const r=(Date.now()-t.loop.getStartPlayingTime())/i;t.loopProgressArc.clear(),t.loopProgressArc.lineStyle(4,65280,1);const o=U.Math.DegToRad(-90),a=o+U.Math.DegToRad(360*r);t.loopProgressArc.beginPath(),t.loopProgressArc.arc(t.buttonText.x,t.buttonText.y,t.buttonSelectedCircle.width/2,o,a,!1),t.loopProgressArc.strokePath()}createTracks(){y.tracks=new Array(y.numTracks).fill(null).map((t,i)=>({loop:new Bn(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(1,O.darkGrey.color).setInteractive().on(U.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,O.white.color,0).setVisible(!1),buttonText:this.add.text(0,0,"+",{fontFamily:Kt.Text,fontSize:qt.medium,color:_i.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:Kt.Icons,fontSize:qt.medium,color:_i.white}).setOrigin(.5,.5).setResolution(2).setInteractive().on(U.Input.Events.POINTER_DOWN,()=>{this.handleControlClicked(i)}),loopProgressArc:this.add.graphics()})),window.addEventListener("resize",()=>this.resizeTracks()),this.resizeTracks(),this.selectTrack(0)}handleControlClicked(t){y.tracks[t].loop.handleClick(),this.updateControlsState()}selectTrack(t){const i=y.tracks[t];if(i.selected)i.loop.handleClick(),this.updateControlsState();else{const s=y.tracks.find(o=>o.selected);s&&(s.selected=!1,s.loop.isRecording()&&s.loop.handleClick()),i.selected=!0,this.updateControlsState();const r=this.getTrackScene(t);if(r){r.scene.bringToTop();const o=r.settings;i.buttonText.setColor(Pn(r.sceneTextColor)).setText(r.sceneText),this.game.events.emit(Xe.sceneChange,o)}else this.game.scene.start(De.key,{index:t})}this.scene.bringToTop()}updateControlsState(){y.tracks.forEach((t,i)=>{const s=this.getTrackScene(i),r=(s==null?void 0:s.sceneTextColor.color)??De.sceneTextColor.color;t.button.setDepth(t.selected?0:-1).setFillStyle(O.black.color).setStrokeStyle(1,t.selected?r:O.darkGrey.color),t.buttonText.setText((s==null?void 0:s.sceneText)??De.sceneText).setColor(Pn((s==null?void 0:s.sceneTextColor)??De.sceneTextColor)).setAlpha(t.selected?1:.5),t.buttonSelectedCircle.setVisible(!1).setFillStyle(t.selected?O.white.color:O.black.color),(s==null?void 0:s.canRecord)||(s==null?void 0:s.canPlay)?s!=null&&s.canRecord&&t.selected&&(t.loop.isRecording()||t.loop.isReadyToRecord())?t.controlIcon.setText(so.record).setColor(t.loop.isRecording()?mt.recording:mt.idle):s!=null&&s.canPlay&&(t.loop.isPlaying()||t.loop.isReadyToPlay())?t.controlIcon.setText(so.play).setColor(t.loop.isPlaying()?mt.playing:mt.idle):t.controlIcon.setText("").setColor(mt.idle):t.controlIcon.setText("").setColor(mt.idle)})}};b(y,"key","LoopTracksScene"),b(y,"numTracks",5),b(y,"tracks"),b(y,"instance");let ae=y;const gf=()=>window.matchMedia("(prefers-color-scheme: dark)").matches;function ro(n){const e=window.innerWidth,t=window.innerHeight;n.scale.resize(e,t),n.scene.scenes.forEach(i=>{var s,r;return(r=(s=i.sys)==null?void 0:s.scale)==null?void 0:r.refresh()})}let oo=!1;const Cf=()=>{oo||(oo=!0,Sl().then(()=>{const n=new U.Game({type:U.AUTO,mode:U.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:gf()?x.black:x.white,scene:[ae,De],input:{activePointers:8}}),e=new Rn(n);window.addEventListener("resize",()=>{ro(n),e.resize()}),n.scene.start(ae.key),ro(n)}))};Cf(); +var Tl=Object.defineProperty;var Sl=(n,e,t)=>e in n?Tl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var v=(n,e,t)=>(Sl(n,typeof e!="symbol"?e+"":e,t),t);import{P as U}from"./phaser-4DlKUGm0.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();const x={white:"#D3D3D3",black:"#1F2023FF",grey:"#2C2C2C",darkGrey:"#1F2023",orange:"#FDA341",red:"#F24E1E",blue:"#4A90E2",green:"#A0D8C5",yellow:"#F9F871",yellow2:"#F5C542",orange2:"#FF7F50",purple:"#9B59B6",pink:"#FFC0CB"},O={get white(){return K(x.white)},get black(){return K(x.black)},get grey(){return K(x.grey)},get darkGrey(){return K(x.darkGrey)},get orange(){return K(x.orange)},get red(){return K(x.red)},get blue(){return K(x.blue)},get green(){return K(x.green)},get yellow(){return K(x.yellow)},get yellow2(){return K(x.yellow2)},get orange2(){return K(x.orange2)},get purple(){return K(x.purple)},get pink(){return K(x.pink)}},K=n=>U.Display.Color.HexStringToColor(n),kn=n=>U.Display.Color.RGBToString(n.red,n.green,n.blue),Ut={Icons:"Icons",Text:"Verdana, Geneva, sans-serif"},Ht={tiny:"15px",small:"30px",medium:"50px",big:"90px"},xi={white:x.white},Ll=async()=>{const n=new FontFace(Ut.Icons,"url(./fonts/material.woff2)");return document.fonts.add(n),n.load().catch(e=>console.error(e))},Xe={sceneChange:"scene-change",instrumentPlayed:"instrument-played"};/*! Tweakpane 4.0.4 (c) 2016 cocopon, licensed under the MIT license. */function P(n){return n==null}function Ni(n){return n!==null&&typeof n=="object"}function yi(n){return n!==null&&typeof n=="object"}function $l(n,e){if(n.length!==e.length)return!1;for(let t=0;t{const r=n[s],o=e[s];return yi(r)&&yi(o)?Object.assign(Object.assign({},i),{[s]:Ze(r,o)}):Object.assign(Object.assign({},i),{[s]:s in e?o:r})},{})}function ji(n){return Ni(n)?"target"in n:!1}const Al={alreadydisposed:()=>"View has been already disposed",invalidparams:n=>`Invalid parameters for '${n.name}'`,nomatchingcontroller:n=>`No matching controller for '${n.key}'`,nomatchingview:n=>`No matching view for '${JSON.stringify(n.params)}'`,notbindable:()=>"Value is not bindable",notcompatible:n=>`Not compatible with plugin '${n.id}'`,propertynotfound:n=>`Property '${n.name}' not found`,shouldneverhappen:()=>"This error should never happen"};let F=class bt{static alreadyDisposed(){return new bt({type:"alreadydisposed"})}static notBindable(){return new bt({type:"notbindable"})}static notCompatible(e,t){return new bt({type:"notcompatible",context:{id:`${e}.${t}`}})}static propertyNotFound(e){return new bt({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new bt({type:"shouldneverhappen"})}constructor(e){var t;this.message=(t=Al[e.type](e.context))!==null&&t!==void 0?t:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}toString(){return this.message}},Ys=class lo{constructor(e,t){this.obj_=e,this.key=t}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}read(){return this.obj_[this.key]}write(e){this.obj_[this.key]=e}writeProperty(e,t){const i=this.read();if(!lo.isBindable(i))throw F.notBindable();if(!(e in i))throw F.propertyNotFound(e);i[e]=t}},A=class{constructor(){this.observers_={}}on(e,t,i){var s;let r=this.observers_[e];return r||(r=this.observers_[e]=[]),r.push({handler:t,key:(s=i==null?void 0:i.key)!==null&&s!==void 0?s:t}),this}off(e,t){const i=this.observers_[e];return i&&(this.observers_[e]=i.filter(s=>s.key!==t)),this}emit(e,t){const i=this.observers_[e];i&&i.forEach(s=>{s.handler(t)})}},Ml=class{constructor(e,t){var i;this.constraint_=t==null?void 0:t.constraint,this.equals_=(i=t==null?void 0:t.equals)!==null&&i!==void 0?i:(s,r)=>s===r,this.emitter=new A,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.constraint_?this.constraint_.constrain(e):e,r=this.rawValue_;this.equals_(r,s)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=s,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:s,sender:this}))}},Ol=class{constructor(e){this.emitter=new A,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.value_;s===e&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:this.value_,sender:this}))}},Rl=class{constructor(e){this.emitter=new A,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}};function k(n,e){const t=e==null?void 0:e.constraint,i=e==null?void 0:e.equals;return!t&&!i?new Ol(n):new Ml(n,e)}function Dl(n){return[new Rl(n),(e,t)=>{n.setRawValue(e,t)}]}let b=class co{constructor(e){this.emitter=new A,this.valMap_=e;for(const t in this.valMap_)this.valMap_[t].emitter.on("change",()=>{this.emitter.emit("change",{key:t,sender:this})})}static createCore(e){return Object.keys(e).reduce((i,s)=>Object.assign(i,{[s]:k(e[s])}),{})}static fromObject(e){const t=this.createCore(e);return new co(t)}get(e){return this.valMap_[e].rawValue}set(e,t){this.valMap_[e].rawValue=t}value(e){return this.valMap_[e]}},sn=class{constructor(e){this.values=b.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(e,i),t)}},Bl=class{constructor(e){this.values=b.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");let s=e;return P(i)||(s=Math.max(s,i)),P(t)||(s=Math.min(s,t)),s}},Nl=class{constructor(e,t=0){this.step=e,this.origin=t}constrain(e){const t=this.origin%this.step,i=Math.round((e-t)/this.step);return t+i*this.step}},jl=class{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}};const Il={"**":(n,e)=>Math.pow(n,e),"*":(n,e)=>n*e,"/":(n,e)=>n/e,"%":(n,e)=>n%e,"+":(n,e)=>n+e,"-":(n,e)=>n-e,"<<":(n,e)=>n<>":(n,e)=>n>>e,">>>":(n,e)=>n>>>e,"&":(n,e)=>n&e,"^":(n,e)=>n^e,"|":(n,e)=>n|e};let Fl=class{constructor(e,t,i){this.left=t,this.operator=e,this.right=i}evaluate(){const e=Il[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}};const zl={"+":n=>n,"-":n=>-n,"~":n=>~n};let Kl=class{constructor(e,t){this.operator=e,this.expression=t}evaluate(){const e=zl[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}};function Ii(n){return(e,t)=>{for(let i=0;ie.startsWith(s,t))[0];return i?(t+=i.length,t+=Gt(e,t).length,{cursor:t,operator:i}):null}function lc(n,e){return(t,i)=>{const s=n(t,i);if(!s)return null;i=s.cursor;let r=s.evaluable;for(;;){const o=ac(e,t,i);if(!o)break;i=o.cursor;const a=n(t,i);if(!a)return null;i=a.cursor,r=new Fl(o.operator,r,a.evaluable)}return r?{cursor:i,evaluable:r}:null}}const cc=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,e)=>lc(n,e),uo);function ho(n,e){return e+=Gt(n,e).length,cc(n,e)}function pc(n){const e=ho(n,0);return!e||e.cursor+Gt(n,e.cursor).length!==n.length?null:e.evaluable}function Pe(n){var e;const t=pc(n);return(e=t==null?void 0:t.evaluate())!==null&&e!==void 0?e:null}function mo(n){if(typeof n=="number")return n;if(typeof n=="string"){const e=Pe(n);if(!P(e))return e}return 0}function uc(n){return String(n)}function Z(n){return e=>e.toFixed(Math.max(Math.min(n,20),0))}function g(n,e,t,i,s){const r=(n-e)/(t-e);return i+r*(s-i)}function Xs(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function M(n,e,t){return Math.min(Math.max(n,e),t)}function vo(n,e){return(n%e+e)%e}function hc(n,e){return P(n.step)?Math.max(Xs(e),2):Xs(n.step)}function bo(n){var e;return(e=n.step)!==null&&e!==void 0?e:1}function fo(n,e){var t;const i=Math.abs((t=n.step)!==null&&t!==void 0?t:e);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function wo(n,e){return P(n.step)?null:new Nl(n.step,e)}function _o(n){return!P(n.max)&&!P(n.min)?new sn({max:n.max,min:n.min}):!P(n.max)||!P(n.min)?new Bl({max:n.max,min:n.min}):null}function go(n,e){var t,i,s;return{formatter:(t=n.format)!==null&&t!==void 0?t:Z(hc(n,e)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:bo(n),pointerScale:(s=n.pointerScale)!==null&&s!==void 0?s:fo(n,e)}}function Co(n){return{format:n.optional.function,keyScale:n.optional.number,max:n.optional.number,min:n.optional.number,pointerScale:n.optional.number,step:n.optional.number}}function zi(n){return{constraint:n.constraint,textProps:b.fromObject(go(n.params,n.initialValue))}}let st=class{constructor(e){this.controller=e}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(e){this.controller.viewProps.set("disabled",e)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(e){this.controller.viewProps.set("hidden",e)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(e){return this.controller.importState(e)}exportState(){return this.controller.exportState()}},Fn=class{constructor(e){this.target=e}},rn=class extends Fn{constructor(e,t,i){super(e),this.value=t,this.last=i??!0}},dc=class extends Fn{constructor(e,t){super(e),this.expanded=t}},mc=class extends Fn{constructor(e,t){super(e),this.index=t}};class vc extends Fn{constructor(e,t){super(e),this.native=t}}let Yt=class extends st{constructor(e){super(e),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new A,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(e){this.controller.tag=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}refresh(){this.controller.value.fetch()}onValueChange_(e){const t=this.controller.value;this.emitter_.emit("change",new rn(this,t.binding.target.read(),e.options.last))}};class bc{constructor(e,t){this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=t,this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.emitter=new A}get rawValue(){return this.value_.rawValue}set rawValue(e){this.value_.rawValue=e}setRawValue(e,t){this.value_.setRawValue(e,t)}fetch(){this.value_.rawValue=this.binding.read()}push(){this.binding.write(this.value_.rawValue)}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.push(),this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function fc(n){if(!("binding"in n))return!1;const e=n.binding;return ji(e)&&"read"in e&&"write"in e}function wc(n,e){const i=Object.keys(e).reduce((s,r)=>{if(s===void 0)return;const o=e[r],a=o(n[r]);return a.succeeded?Object.assign(Object.assign({},s),{[r]:a.value}):void 0},{});return i}function _c(n,e){return n.reduce((t,i)=>{if(t===void 0)return;const s=e(i);if(!(!s.succeeded||s.value===void 0))return[...t,s.value]},[])}function gc(n){return n===null?!1:typeof n=="object"}function _e(n){return e=>t=>{if(!e&&t===void 0)return{succeeded:!1,value:void 0};if(e&&t===void 0)return{succeeded:!0,value:void 0};const i=n(t);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function Qs(n){return{custom:e=>_e(e)(n),boolean:_e(e=>typeof e=="boolean"?e:void 0)(n),number:_e(e=>typeof e=="number"?e:void 0)(n),string:_e(e=>typeof e=="string"?e:void 0)(n),function:_e(e=>typeof e=="function"?e:void 0)(n),constant:e=>_e(t=>t===e?e:void 0)(n),raw:_e(e=>e)(n),object:e=>_e(t=>{if(gc(t))return wc(t,e)})(n),array:e=>_e(t=>{if(Array.isArray(t))return _c(t,e)})(n)}}const Pi={optional:Qs(!0),required:Qs(!1)};function T(n,e){const t=e(Pi),i=Pi.required.object(t)(n);return i.succeeded?i.value:void 0}function ee(n,e,t,i){if(e&&!e(n))return!1;const s=T(n,t);return s?i(s):!1}function te(n,e){var t;return Ze((t=n==null?void 0:n())!==null&&t!==void 0?t:{},e)}function Qe(n){return"value"in n}function xo(n){if(!Ni(n)||!("binding"in n))return!1;const e=n.binding;return ji(e)}const ve="http://www.w3.org/2000/svg";function Vn(n){n.offsetHeight}function Cc(n,e){const t=n.style.transition;n.style.transition="none",e(),n.style.transition=t}function Ki(n){return n.ontouchstart!==void 0}function xc(){return globalThis}function yc(){return xc().document}function Pc(n){const e=n.ownerDocument.defaultView;return e&&"document"in e?n.getContext("2d",{willReadFrequently:!0}):null}const Ec={check:'',dropdown:'',p2dpad:''};function zn(n,e){const t=n.createElementNS(ve,"svg");return t.innerHTML=Ec[e],t}function yo(n,e,t){n.insertBefore(e,n.children[t])}function qi(n){n.parentElement&&n.parentElement.removeChild(n)}function Po(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function kc(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function Eo(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function ye(n,e){n.emitter.on("change",t=>{e(t.rawValue)}),e(n.rawValue)}function be(n,e,t){ye(n.value(e),t)}const Vc="tp";function f(n){return(t,i)=>[Vc,"-",n,"v",t?`_${t}`:"",i?`-${i}`:""].join("")}const Mt=f("lbl");function Tc(n,e){const t=n.createDocumentFragment();return e.split(` +`).map(s=>n.createTextNode(s)).forEach((s,r)=>{r>0&&t.appendChild(n.createElement("br")),t.appendChild(s)}),t}let ko=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Mt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Mt("l")),be(t.props,"label",r=>{P(r)?this.element.classList.add(Mt(void 0,"nol")):(this.element.classList.remove(Mt(void 0,"nol")),kc(i),i.appendChild(Tc(e,r)))}),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("div");s.classList.add(Mt("v")),this.element.appendChild(s),this.valueElement=s}},Vo=class{constructor(e,t){this.props=t.props,this.valueController=t.valueController,this.viewProps=t.valueController.viewProps,this.view=new ko(e,{props:t.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(e){return ee(e,null,t=>({label:t.optional.string}),t=>(this.props.set("label",t.label),!0))}exportProps(){return te(null,{label:this.props.get("label")})}};function Sc(){return["veryfirst","first","last","verylast"]}const Zs=f(""),Js={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};let Kn=class{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const t=this.view.element;this.blade.value("positions").emitter.on("change",()=>{Sc().forEach(i=>{t.classList.remove(Zs(void 0,Js[i]))}),this.blade.get("positions").forEach(i=>{t.classList.add(Zs(void 0,Js[i]))})}),this.viewProps.handleDispose(()=>{qi(t)})}get parent(){return this.parent_}set parent(e){this.parent_=e,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(e){return ee(e,null,t=>({disabled:t.required.boolean,hidden:t.required.boolean}),t=>(this.viewProps.importState(t),!0))}exportState(){return te(null,Object.assign({},this.viewProps.exportState()))}},Je=class extends Kn{constructor(e,t){if(t.value!==t.valueController.value)throw F.shouldNeverHappen();const i=t.valueController.viewProps,s=new Vo(e,{blade:t.blade,props:t.props,valueController:t.valueController});super(Object.assign(Object.assign({},t),{view:new ko(e,{props:t.props,viewProps:i}),viewProps:i})),this.labelController=s,this.value=t.value,this.valueController=t.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(e){return ee(e,t=>{var i,s,r;return super.importState(t)&&this.labelController.importProps(t)&&((r=(s=(i=this.valueController).importProps)===null||s===void 0?void 0:s.call(i,e))!==null&&r!==void 0?r:!0)},t=>({value:t.optional.raw}),t=>(t.value&&(this.value.rawValue=t.value),!0))}exportState(){var e,t,i;return te(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(t=(e=this.valueController).exportProps)===null||t===void 0?void 0:t.call(e))!==null&&i!==void 0?i:{}))}};function er(n){const e=Object.assign({},n);return delete e.value,e}class To extends Je{constructor(e,t){super(e,t),this.tag=t.tag}importState(e){return ee(e,t=>super.importState(er(e)),t=>({tag:t.optional.string}),t=>(this.tag=t.tag,!0))}exportState(){return te(()=>er(super.exportState()),{binding:{key:this.value.binding.target.key,value:this.value.binding.target.read()},tag:this.tag})}}function Lc(n){return Qe(n)&&xo(n.value)}class $c extends To{importState(e){return ee(e,t=>super.importState(t),t=>({binding:t.required.object({value:t.required.raw})}),t=>(this.value.binding.inject(t.binding.value),this.value.fetch(),!0))}}function Ac(n){return Qe(n)&&fc(n.value)}function So(n,e){for(;n.lengthn.length?t.splice(0,t.length-n.length):So(t,n.length),t}class Dc{constructor(e){this.emitter=new A,this.onTick_=this.onTick_.bind(this),this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.binding=e.binding,this.value_=k(Mc(e.bufferSize)),this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_),this.ticker=e.ticker,this.ticker.emitter.on("tick",this.onTick_),this.fetch()}get rawValue(){return this.value_.rawValue}set rawValue(e){this.value_.rawValue=e}setRawValue(e,t){this.value_.setRawValue(e,t)}fetch(){this.value_.rawValue=Rc(this.value_.rawValue,this.binding.read())}onTick_(){this.fetch()}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function Bc(n){if(!("binding"in n))return!1;const e=n.binding;return ji(e)&&"read"in e&&!("write"in e)}class Nc extends To{exportState(){return te(()=>super.exportState(),{binding:{readonly:!0}})}}function jc(n){return Qe(n)&&Bc(n.value)}let Ic=class extends st{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get title(){var e;return(e=this.controller.buttonController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.buttonController.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller.buttonController.emitter.on(e,r=>{i(new vc(this,r.nativeEvent))}),this}off(e,t){return this.controller.buttonController.emitter.off(e,t),this}};function Fc(n,e,t){t?n.classList.add(e):n.classList.remove(e)}function kt(n,e){return t=>{Fc(n,e,t)}}function Ui(n,e){ye(n,t=>{e.textContent=t??""})}const ti=f("btn");let zc=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ti()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("button");i.classList.add(ti("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(ti("t")),Ui(t.props.value("title"),s),this.buttonElement.appendChild(s)}},Kc=class{constructor(e,t){this.emitter=new A,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new zc(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(e){return ee(e,null,t=>({title:t.optional.string}),t=>(this.props.set("title",t.title),!0))}exportProps(){return te(null,{title:this.props.get("title")})}onClick_(e){this.emitter.emit("click",{nativeEvent:e,sender:this})}},tr=class extends Kn{constructor(e,t){const i=new Kc(e,{props:t.buttonProps,viewProps:t.viewProps}),s=new Vo(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:t.viewProps}),this.buttonController=i,this.labelController=s}importState(e){return ee(e,t=>super.importState(t)&&this.buttonController.importProps(t)&&this.labelController.importProps(t),()=>({}),()=>!0)}exportState(){return te(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}},Lo=class{constructor(e){const[t,i]=e.split("-"),s=t.split(".");this.major=parseInt(s[0],10),this.minor=parseInt(s[1],10),this.patch=parseInt(s[2],10),this.prerelease=i??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}};const Vt=new Lo("2.0.4");function Y(n){return Object.assign({core:Vt},n)}const qc=Y({id:"button",type:"blade",accept(n){const e=T(n,t=>({title:t.required.string,view:t.required.constant("button"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new tr(n.document,{blade:n.blade,buttonProps:b.fromObject({title:n.params.title}),labelProps:b.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof tr?new Ic(n.controller):null}});function Uc(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function Hc(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function Gc(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}function Wc(n){return Ni(n)?"refresh"in n&&typeof n.refresh=="function":!1}function Yc(n,e){if(!Ys.isBindable(n))throw F.notBindable();return new Ys(n,e)}let Xc=class{constructor(e,t){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=e,this.emitter_=new A,this.pool_=t,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(e=>this.pool_.createApi(e))}addBinding(e,t,i){const s=i??{},r=this.controller_.element.ownerDocument,o=this.pool_.createBinding(r,Yc(e,t),s),a=this.pool_.createBindingApi(o);return this.add(a,s.index)}addFolder(e){return Hc(this,e)}addButton(e){return Uc(this,e)}addTab(e){return Gc(this,e)}add(e,t){const i=e.controller;return this.controller_.rack.add(i,t),e}remove(e){this.controller_.rack.remove(e.controller)}addBlade(e){const t=this.controller_.element.ownerDocument,i=this.pool_.createBlade(t,e),s=this.pool_.createApi(i);return this.add(s,e.index)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}refresh(){this.children.forEach(e=>{Wc(e)&&e.refresh()})}onRackValueChange_(e){const t=e.bladeController,i=this.pool_.createApi(t),s=xo(t.value)?t.value.binding:null;this.emitter_.emit("change",new rn(i,s?s.target.read():t.value.rawValue,e.options.last))}},Hi=class extends st{constructor(e,t){super(e),this.rackApi_=new Xc(e.rackController,t)}refresh(){this.rackApi_.refresh()}},Gi=class extends Kn{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}importState(e){return ee(e,t=>super.importState(t),t=>({children:t.required.array(t.required.raw)}),t=>this.rackController.rack.children.every((i,s)=>i.importState(t.children[s])))}exportState(){return te(()=>super.exportState(),{children:this.rackController.rack.children.map(e=>e.exportState())})}};function Ei(n){return"rackController"in n}let Qc=class{constructor(e){this.emitter=new A,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const t of this.allItems())if(e(t))return t;return null}includes(e){return this.cache_.has(e)}add(e,t){if(this.includes(e))throw F.shouldNeverHappen();const i=t!==void 0?t:this.items_.length;this.items_.splice(i,0,e),this.cache_.add(e);const s=this.extract_(e);s&&(s.emitter.on("add",this.onSubListAdd_),s.emitter.on("remove",this.onSubListRemove_),s.allItems().forEach(r=>{this.cache_.add(r)})),this.emitter.emit("add",{index:i,item:e,root:this,target:this})}remove(e){const t=this.items_.indexOf(e);if(t<0)return;this.items_.splice(t,1),this.cache_.delete(e);const i=this.extract_(e);i&&(i.allItems().forEach(s=>{this.cache_.delete(s)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:t,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}};function Zc(n,e){for(let t=0;t!s.viewProps.get("hidden")),t=e[0],i=e[e.length-1];this.bcSet_.items.forEach(s=>{const r=[];s===t&&(r.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&r.push("veryfirst")),s===i&&(r.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&r.push("verylast")),s.blade.set("positions",r)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(t=>t.viewProps.get("disposed")).forEach(t=>{this.bcSet_.remove(t)})}onChildValueChange_(e){const t=Zc(this.find(Qe),e.sender);if(!t)throw F.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:t,options:e.options,sender:this})}onRackLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(e){this.emitter.emit("valuechange",{bladeController:e.bladeController,options:e.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}},Wi=class{constructor(e){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=e.element,this.viewProps=e.viewProps;const t=new ep({blade:e.root?void 0:e.blade,viewProps:e.viewProps});t.emitter.on("add",this.onRackAdd_),t.emitter.on("remove",this.onRackRemove_),this.rack=t,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(e){e.root&&yo(this.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.root&&qi(e.bladeController.view.element)}};function Tt(){return new b({positions:k([],{equals:$l})})}let Yi=class $o extends b{constructor(e){super(e)}static create(e){const t={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=b.createCore(t);return new $o(i)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!P(e)?`${e}px`:"auto"}bindExpandedClass(e,t){const i=()=>{this.styleExpanded?e.classList.add(t):e.classList.remove(t)};be(this,"expanded",i),be(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}};function tp(n,e){let t=0;return Cc(e,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),Vn(e),t=e.clientHeight,n.set("temporaryExpanded",null),Vn(e)}),t}function nr(n,e){e.style.height=n.styleHeight}function Xi(n,e){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),P(n.get("expandedHeight"))){const t=tp(n,e);t>0&&n.set("expandedHeight",t)}n.set("shouldFixHeight",!0),Vn(e)}),n.emitter.on("change",()=>{nr(n,e)}),nr(n,e),e.addEventListener("transitionend",t=>{t.propertyName==="height"&&n.cleanUpTransition()})}let Ao=class extends Hi{constructor(e,t){super(e,t),this.emitter_=new A,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new dc(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(e){this.controller.foldable.set("expanded",e)}get title(){return this.controller.props.get("title")}set title(e){this.controller.props.set("title",e)}get children(){return this.rackApi_.children}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){return this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}};const Mo=f("cnt");let np=class{constructor(e,t){var i;this.className_=f((i=t.viewName)!==null&&i!==void 0?i:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),Mo()),t.viewProps.bindClassModifiers(this.element),this.foldable_=t.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),be(this.foldable_,"completed",kt(this.element,this.className_(void 0,"cpl")));const s=e.createElement("button");s.classList.add(this.className_("b")),be(t.props,"title",c=>{P(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s;const r=e.createElement("div");r.classList.add(this.className_("i")),this.element.appendChild(r);const o=e.createElement("div");o.classList.add(this.className_("t")),Ui(t.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=e.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=e.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}},ki=class extends Gi{constructor(e,t){var i;const s=Yi.create((i=t.expanded)!==null&&i!==void 0?i:!0),r=new np(e,{foldable:s,props:t.props,viewName:t.root?"rot":void 0,viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Wi({blade:t.blade,element:r.containerElement,root:t.root,viewProps:t.viewProps}),view:r})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=t.props,this.foldable=s,Xi(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(e){return ee(e,t=>super.importState(t),t=>({expanded:t.required.boolean,title:t.optional.string}),t=>(this.foldable.set("expanded",t.expanded),this.props.set("title",t.title),!0))}exportState(){return te(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}};const ip=Y({id:"folder",type:"blade",accept(n){const e=T(n,t=>({title:t.required.string,view:t.required.constant("folder"),expanded:t.optional.boolean}));return e?{params:e}:null},controller(n){return new ki(n.document,{blade:n.blade,expanded:n.params.expanded,props:b.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof ki?new Ao(n.controller,n.pool):null}}),sp=f("");function ir(n,e){return kt(n,sp(void 0,e))}let rt=class Oo extends b{constructor(e){var t;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=Dl(k(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var t,i,s;const r=e??{};return new Oo(b.createCore({disabled:(t=r.disabled)!==null&&t!==void 0?t:!1,disposed:!1,hidden:(i=r.hidden)!==null&&i!==void 0?i:!1,parent:(s=r.parent)!==null&&s!==void 0?s:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){ye(this.globalDisabled_,ir(e,"disabled")),be(this,"hidden",ir(e,"hidden"))}bindDisabled(e){ye(this.globalDisabled_,t=>{e.disabled=t})}bindTabIndex(e){ye(this.globalDisabled_,t=>{e.tabIndex=t?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",t=>{t&&e()})}importState(e){this.set("disabled",e.disabled),this.set("hidden",e.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var t;const i=e.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}};const sr=f("tbp");let rp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(sr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(sr("c")),this.element.appendChild(i),this.containerElement=i}};const Ot=f("tbi");let op=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ot()),t.viewProps.bindClassModifiers(this.element),be(t.props,"selected",r=>{r?this.element.classList.add(Ot(void 0,"sel")):this.element.classList.remove(Ot(void 0,"sel"))});const i=e.createElement("button");i.classList.add(Ot("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(Ot("t")),Ui(t.props.value("title"),s),this.buttonElement.appendChild(s),this.titleElement=s}},ap=class{constructor(e,t){this.emitter=new A,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new op(e,{props:t.props,viewProps:t.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}},Vi=class extends Gi{constructor(e,t){const i=new rp(e,{viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Wi({blade:t.blade,element:i.containerElement,viewProps:t.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new ap(e,{props:t.itemProps,viewProps:rt.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=t.props,be(this.props,"selected",s=>{this.itemController.props.set("selected",s),this.viewProps.set("hidden",!s)})}get itemController(){return this.ic_}importState(e){return ee(e,t=>super.importState(t),t=>({selected:t.required.boolean,title:t.required.string}),t=>(this.ic_.props.set("selected",t.selected),this.ic_.props.set("title",t.title),!0))}exportState(){return te(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}},lp=class extends Hi{constructor(e,t){super(e,t),this.emitter_=new A,this.onSelect_=this.onSelect_.bind(this),this.pool_=t,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(e){const t=this.controller.view.element.ownerDocument,i=new Vi(t,{blade:Tt(),itemProps:b.fromObject({selected:!1,title:e.title}),props:b.fromObject({selected:!1}),viewProps:rt.create()}),s=this.pool_.createApi(i);return this.rackApi_.add(s,e.index)}removePage(e){this.rackApi_.remove(this.rackApi_.children[e])}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}onSelect_(e){this.emitter_.emit("select",new mc(this,e.rawValue))}},cp=class extends Hi{get title(){var e;return(e=this.controller.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.itemController.props.set("title",e)}get selected(){return this.controller.props.get("selected")}set selected(e){this.controller.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addBlade(e){return this.rackApi_.addBlade(e)}};const rr=-1;let pp=class{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=k(!0),this.selectedIndex=k(rr),this.items_=[]}add(e,t){const i=t??this.items_.length;this.items_.splice(i,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const t=this.items_.indexOf(e);t<0||(this.items_.splice(t,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=rr,this.empty.rawValue=!0;return}const e=this.items_.findIndex(t=>t.rawValue);e<0?(this.items_.forEach((t,i)=>{t.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((t,i)=>{t.rawValue=i===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const t=this.items_.findIndex(i=>i===e.sender);this.items_.forEach((i,s)=>{i.rawValue=s===t}),this.selectedIndex.rawValue=t}else this.keepSelection_()}};const Rt=f("tab");let up=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Rt(),Mo()),t.viewProps.bindClassModifiers(this.element),ye(t.empty,kt(this.element,Rt(void 0,"nop")));const i=e.createElement("div");i.classList.add(Rt("t")),this.element.appendChild(i),this.itemsElement=i;const s=e.createElement("div");s.classList.add(Rt("i")),this.element.appendChild(s);const r=e.createElement("div");r.classList.add(Rt("c")),this.element.appendChild(r),this.contentsElement=r}},or=class extends Gi{constructor(e,t){const i=new pp,s=new up(e,{empty:i.empty,viewProps:t.viewProps});super({blade:t.blade,rackController:new Wi({blade:t.blade,element:s.contentsElement,viewProps:t.viewProps}),view:s}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const r=this.rackController.rack;r.emitter.on("add",this.onRackAdd_),r.emitter.on("remove",this.onRackRemove_),this.tab=i}add(e,t){this.rackController.rack.add(e,t)}remove(e){this.rackController.rack.remove(this.rackController.rack.children[e])}onRackAdd_(e){if(!e.root)return;const t=e.bladeController;yo(this.view.itemsElement,t.itemController.view.element,e.index),t.itemController.viewProps.set("parent",this.viewProps),this.tab.add(t.props.value("selected"))}onRackRemove_(e){if(!e.root)return;const t=e.bladeController;qi(t.itemController.view.element),t.itemController.viewProps.set("parent",null),this.tab.remove(t.props.value("selected"))}};const Ro=Y({id:"tab",type:"blade",accept(n){const e=T(n,t=>({pages:t.required.array(t.required.object({title:t.required.string})),view:t.required.constant("tab")}));return!e||e.pages.length===0?null:{params:e}},controller(n){const e=new or(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(t=>{const i=new Vi(n.document,{blade:Tt(),itemProps:b.fromObject({selected:!1,title:t.title}),props:b.fromObject({selected:!1}),viewProps:rt.create()});e.add(i)}),e},api(n){return n.controller instanceof or?new lp(n.controller,n.pool):n.controller instanceof Vi?new cp(n.controller,n.pool):null}});function hp(n,e){const t=n.accept(e.params);if(!t)return null;const i=T(e.params,s=>({disabled:s.optional.boolean,hidden:s.optional.boolean}));return n.controller({blade:Tt(),document:e.document,params:Object.assign(Object.assign({},t.params),{disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden}),viewProps:rt.create({disabled:i==null?void 0:i.disabled,hidden:i==null?void 0:i.hidden})})}let Qi=class extends Yt{get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}},dp=class{constructor(){this.disabled=!1,this.emitter=new A}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}},mp=class{constructor(e,t){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new A,this.interval_=t,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}},on=class{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((t,i)=>i.constrain(t),e)}};function Tn(n,e){if(n instanceof e)return n;if(n instanceof on){const t=n.constraints.reduce((i,s)=>i||(s instanceof e?s:null),null);if(t)return t}return null}let an=class{constructor(e){this.values=b.fromObject({options:e})}constrain(e){const t=this.values.get("options");return t.length===0||t.filter(s=>s.value===e).length>0?e:t[0].value}};function ln(n){var e;const t=Pi;if(Array.isArray(n))return(e=T({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||e===void 0?void 0:e.items;if(typeof n=="object")return t.required.raw(n).value}function Zi(n){if(Array.isArray(n))return n;const e=[];return Object.keys(n).forEach(t=>{e.push({text:t,value:n[t]})}),e}function Ji(n){return P(n)?null:new an(Zi(n))}const ni=f("lst");let vp=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.element=e.createElement("div"),this.element.classList.add(ni()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("select");i.classList.add(ni("s")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const s=e.createElement("div");s.classList.add(ni("m")),s.appendChild(zn(e,"dropdown")),this.element.appendChild(s),t.value.emitter.on("change",this.onValueChange_),this.value_=t.value,be(this.props_,"options",r=>{Po(this.selectElement),r.forEach(o=>{const a=e.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const e=this.props_.get("options").map(t=>t.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}},Fe=class{constructor(e,t){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new vp(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const t=e.currentTarget;this.value.rawValue=this.props.get("options")[t.selectedIndex].value}importProps(e){return ee(e,null,t=>({options:t.required.custom(ln)}),t=>(this.props.set("options",Zi(t.options)),!0))}exportProps(){return te(null,{options:this.props.get("options")})}};const ar=f("pop");let bp=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ar()),t.viewProps.bindClassModifiers(this.element),ye(t.shows,kt(this.element,ar(void 0,"v")))}},Do=class{constructor(e,t){this.shows=k(!1),this.viewProps=t.viewProps,this.view=new bp(e,{shows:this.shows,viewProps:this.viewProps})}};const lr=f("txt");let fp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(lr()),t.viewProps.bindClassModifiers(this.element),this.props_=t.props,this.props_.emitter.on("change",this.onChange_);const i=e.createElement("input");i.classList.add(lr("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onChange_),this.value_=t.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}},Xt=class{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=t.parser,this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new fp(e,{props:t.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);P(s)||(this.value.rawValue=s),this.view.refresh()}};function wp(n){return String(n)}function Bo(n){return n==="false"?!1:!!n}function cr(n){return wp(n)}function _p(n){return e=>n.reduce((t,i)=>t!==null?t:i(e),null)}const gp=Z(0);function Sn(n){return gp(n)+"%"}function No(n){return String(n)}function Ti(n){return n}function St({primary:n,secondary:e,forward:t,backward:i}){let s=!1;function r(o){s||(s=!0,o(),s=!1)}n.emitter.on("change",o=>{r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),e.emitter.on("change",o=>{r(()=>{n.setRawValue(i(n.rawValue,e.rawValue),o.options)}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),{forceEmit:!1,last:!0})})}function X(n,e){const t=n*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+t:e.downKey?-t:0}function Qt(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function Ee(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function Cp(n){return n==="ArrowUp"||n==="ArrowDown"}function jo(n){return Cp(n)||n==="ArrowLeft"||n==="ArrowRight"}function ii(n,e){var t,i;const s=e.ownerDocument.defaultView,r=e.getBoundingClientRect();return{x:n.pageX-(((t=s&&s.scrollX)!==null&&t!==void 0?t:0)+r.left),y:n.pageY-(((i=s&&s.scrollY)!==null&&i!==void 0?i:0)+r.top)}}let ot=class{constructor(e){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=e,this.emitter=new A,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const t=this.elem_.getBoundingClientRect();return{bounds:{width:t.width,height:t.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var t;e.preventDefault(),(t=e.currentTarget)===null||t===void 0||t.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(ii(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(ii(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const t=this.elem_.ownerDocument;t.removeEventListener("mousemove",this.onDocumentMouseMove_),t.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(ii(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchMove_(e){const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchEnd_(e){var t;const i=(t=e.targetTouches.item(0))!==null&&t!==void 0?t:this.lastTouch_,s=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(i?{x:i.clientX-s.left,y:i.clientY-s.top}:void 0),sender:this,shiftKey:e.shiftKey})}};const ne=f("txt");let xp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ne(),ne(void 0,"num")),t.arrayPosition&&this.element.classList.add(ne(void 0,t.arrayPosition)),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(ne("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=t.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(ne()),this.inputElement.classList.add(ne("i"));const s=e.createElement("div");s.classList.add(ne("k")),this.element.appendChild(s),this.knobElement=s;const r=e.createElementNS(ve,"svg");r.classList.add(ne("g")),this.knobElement.appendChild(r);const o=e.createElementNS(ve,"path");o.classList.add(ne("gb")),r.appendChild(o),this.guideBodyElem_=o;const a=e.createElementNS(ve,"path");a.classList.add(ne("gh")),r.appendChild(a),this.guideHeadElem_=a;const l=e.createElement("div");l.classList.add(f("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(ne(void 0,"drg"));return}this.element.classList.add(ne(void 0,"drg"));const t=e.rawValue/this.props_.get("pointerScale"),i=t+(t>0?-1:t<0?1:0),s=M(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+s},0 L${i},4 L${i+s},8`,`M ${t},-1 L${t},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${t},4`);const r=this.props_.get("formatter");this.tooltipElem_.textContent=r(this.value.rawValue),this.tooltipElem_.style.left=`${t}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}},cn=class{constructor(e,t){var i;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.parser_=t.parser,this.props=t.props,this.sliderProps_=(i=t.sliderProps)!==null&&i!==void 0?i:null,this.value=t.value,this.viewProps=t.viewProps,this.dragging_=k(null),this.view=new xp(e,{arrayPosition:t.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const s=new ot(this.view.knobElement);s.emitter.on("down",this.onPointerDown_),s.emitter.on("move",this.onPointerMove_),s.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var t,i;const s=(t=this.sliderProps_)===null||t===void 0?void 0:t.get("min"),r=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=e;return s!==void 0&&(o=Math.max(o,s)),r!==void 0&&(o=Math.min(o,r)),o}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);P(s)||(this.value.rawValue=this.constrainValue_(s)),this.view.refresh()}onInputKeyDown_(e){const t=X(this.props.get("keyScale"),Qt(e));t!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+t),{forceEmit:!1,last:!1})}onInputKeyUp_(e){X(this.props.get("keyScale"),Qt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const t=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+t*this.props.get("pointerScale"))}onPointerMove_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}};const si=f("sld");let yp=class{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(si()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(si("t")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(si("k")),this.trackElement.appendChild(s),this.knobElement=s,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.update_()}update_(){const e=M(g(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}},Pp=class{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.props=t.props,this.view=new yp(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ot(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){e.point&&this.value.setRawValue(g(M(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("min"),this.props.get("max")),t)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=X(this.props.get("keyScale"),Ee(e));t!==0&&this.value.setRawValue(this.value.rawValue+t,{forceEmit:!1,last:!1})}onKeyUp_(e){X(this.props.get("keyScale"),Ee(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ri=f("sldtxt");let Ep=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ri());const i=e.createElement("div");i.classList.add(ri("s")),this.sliderView_=t.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(ri("t")),this.textView_=t.textView,s.appendChild(this.textView_.element),this.element.appendChild(s)}},Ln=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sliderC_=new Pp(e,{props:t.sliderProps,value:t.value,viewProps:this.viewProps}),this.textC_=new cn(e,{parser:t.parser,props:t.textProps,sliderProps:t.sliderProps,value:t.value,viewProps:t.viewProps}),this.view=new Ep(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(e){return ee(e,null,t=>({max:t.required.number,min:t.required.number}),t=>{const i=this.sliderC_.props;return i.set("max",t.max),i.set("min",t.min),!0})}exportProps(){const e=this.sliderC_.props;return te(null,{max:e.get("max"),min:e.get("min")})}};function Io(n){return{sliderProps:new b({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new b({formatter:k(n.formatter),keyScale:n.keyScale,pointerScale:k(n.pointerScale)})}}const kp={containerUnitSize:"cnt-usz"};function Fo(n){return`--${kp[n]}`}function Zt(n){return Co(n)}function Be(n){if(yi(n))return T(n,Zt)}function Ce(n,e){if(!n)return;const t=[],i=wo(n,e);i&&t.push(i);const s=_o(n);return s&&t.push(s),new on(t)}function Vp(n){return n?n.major===Vt.major:!1}function zo(n){if(n==="inline"||n==="popup")return n}function pn(n,e){n.write(e)}const wn=f("ckb");let Tp=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(wn()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(wn("l")),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("input");s.classList.add(wn("i")),s.type="checkbox",this.labelElement.appendChild(s),this.inputElement=s,t.viewProps.bindDisabled(this.inputElement);const r=e.createElement("div");r.classList.add(wn("w")),this.labelElement.appendChild(r);const o=zn(e,"check");r.appendChild(o),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}},Sp=class{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.onLabelMouseDown_=this.onLabelMouseDown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Tp(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.labelElement.addEventListener("mousedown",this.onLabelMouseDown_)}onInputChange_(e){const t=e.currentTarget;this.value.rawValue=t.checked,e.preventDefault(),e.stopPropagation()}onLabelMouseDown_(e){e.preventDefault()}};function Lp(n){const e=[],t=Ji(n.options);return t&&e.push(t),new on(e)}const $p=Y({id:"input-bool",type:"input",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=T(e,i=>({options:i.optional.custom(ln),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Bo,constraint:n=>Lp(n.params),writer:n=>pn},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&Tn(i,an);return s?new Fe(e,{props:new b({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Sp(e,{value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof Fe?new Qi(n.controller):null}}),Ue=f("col");let Ap=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ue()),t.foldable.bindExpandedClass(this.element,Ue(void 0,"expanded")),be(t.foldable,"completed",kt(this.element,Ue(void 0,"cpl")));const i=e.createElement("div");i.classList.add(Ue("h")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Ue("s")),i.appendChild(s),this.swatchElement=s;const r=e.createElement("div");if(r.classList.add(Ue("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(Ue("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}};function Mp(n,e,t){const i=M(n/255,0,1),s=M(e/255,0,1),r=M(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c=0,p=0;const u=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(s-r)/l:s===o?c=2+(r-i)/l:c=4+(i-s)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function Op(n,e,t){const i=(n%360+360)%360,s=M(e/100,0,1),r=M(t/100,0,1),o=(1-Math.abs(2*r-1))*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o/2;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function Rp(n,e,t){const i=M(n/255,0,1),s=M(e/255,0,1),r=M(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c;l===0?c=0:o===i?c=60*(((s-r)/l%6+6)%6):o===s?c=60*((r-i)/l+2):c=60*((i-s)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function Ko(n,e,t){const i=vo(n,360),s=M(e/100,0,1),r=M(t/100,0,1),o=r*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function Dp(n,e,t){const i=t+e*(100-Math.abs(2*t-100))/200;return[n,i!==0?e*(100-Math.abs(2*t-100))/i:0,t+e*(100-Math.abs(2*t-100))/(2*100)]}function Bp(n,e,t){const i=100-Math.abs(t*(200-e)/100-100);return[n,i!==0?e*t/i:0,t*(200-e)/(2*100)]}function fe(n){return[n[0],n[1],n[2]]}function qn(n,e){return[n[0],n[1],n[2],e]}const Np={hsl:{hsl:(n,e,t)=>[n,e,t],hsv:Dp,rgb:Op},hsv:{hsl:Bp,hsv:(n,e,t)=>[n,e,t],rgb:Ko},rgb:{hsl:Mp,hsv:Rp,rgb:(n,e,t)=>[n,e,t]}};function yt(n,e){return[e==="float"?1:n==="rgb"?255:360,e==="float"?1:n==="rgb"?255:100,e==="float"?1:n==="rgb"?255:100]}function jp(n,e){return n===e?e:vo(n,e)}function qo(n,e,t){var i;const s=yt(e,t);return[e==="rgb"?M(n[0],0,s[0]):jp(n[0],s[0]),M(n[1],0,s[1]),M(n[2],0,s[2]),M((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function pr(n,e,t,i){const s=yt(e,t),r=yt(e,i);return n.map((o,a)=>o/s[a]*r[a])}function Uo(n,e,t){const i=pr(n,e.mode,e.type,"int"),s=Np[e.mode][t.mode](...i);return pr(s,t.mode,"int",t.type)}let C=class Ho{static black(){return new Ho([0,0,0],"rgb")}constructor(e,t){this.type="int",this.mode=t,this.comps_=qo(e,t,this.type)}getComponents(e){return qn(Uo(fe(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}};const Se=f("colp");let Ip=class{constructor(e,t){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(Se()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Se("hsv"));const s=e.createElement("div");s.classList.add(Se("sv")),this.svPaletteView_=t.svPaletteView,s.appendChild(this.svPaletteView_.element),i.appendChild(s);const r=e.createElement("div");r.classList.add(Se("h")),this.hPaletteView_=t.hPaletteView,r.appendChild(this.hPaletteView_.element),i.appendChild(r),this.element.appendChild(i);const o=e.createElement("div");if(o.classList.add(Se("rgb")),this.textsView_=t.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),t.alphaViews){this.alphaViews_={palette:t.alphaViews.palette,text:t.alphaViews.text};const a=e.createElement("div");a.classList.add(Se("a"));const l=e.createElement("div");l.classList.add(Se("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=e.createElement("div");c.classList.add(Se("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(t=>t.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}};function Fp(n){return n==="int"?"int":n==="float"?"float":void 0}function es(n){return T(n,e=>({color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(Fp)}),expanded:e.optional.boolean,picker:e.optional.custom(zo),readonly:e.optional.constant(!1)}))}function et(n){return n?.1:1}function Go(n){var e;return(e=n.color)===null||e===void 0?void 0:e.type}let ts=class{constructor(e,t){this.type="float",this.mode=t,this.comps_=qo(e,t,this.type)}getComponents(e){return qn(Uo(fe(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}};const zp={int:(n,e)=>new C(n,e),float:(n,e)=>new ts(n,e)};function ns(n,e,t){return zp[t](n,e)}function Kp(n){return n.type==="float"}function qp(n){return n.type==="int"}function Up(n){const e=n.getComponents(),t=yt(n.mode,"int");return new C([Math.round(g(e[0],0,1,0,t[0])),Math.round(g(e[1],0,1,0,t[1])),Math.round(g(e[2],0,1,0,t[2])),e[3]],n.mode)}function Hp(n){const e=n.getComponents(),t=yt(n.mode,"int");return new ts([g(e[0],0,t[0],0,1),g(e[1],0,t[1],0,1),g(e[2],0,t[2],0,1),e[3]],n.mode)}function G(n,e){if(n.type===e)return n;if(qp(n)&&e==="float")return Hp(n);if(Kp(n)&&e==="int")return Up(n);throw F.shouldNeverHappen()}function Gp(n,e){return n.alpha===e.alpha&&n.mode===e.mode&&n.notation===e.notation&&n.type===e.type}function re(n,e){const t=n.match(/^(.+)%$/);return Math.min(t?parseFloat(t[1])*.01*e:parseFloat(n),e)}const Wp={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Wo(n){const e=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(n);const t=parseFloat(e[1]),i=e[2];return Wp[i](t)}function Yo(n){const e=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[re(e[1],255),re(e[2],255),re(e[3],255)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function Yp(n){const e=Yo(n);return e?new C(e,"rgb"):null}function Xo(n){const e=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[re(e[1],255),re(e[2],255),re(e[3],255),re(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Xp(n){const e=Xo(n);return e?new C(e,"rgb"):null}function Qo(n){const e=n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Wo(e[1]),re(e[2],100),re(e[3],100)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function Qp(n){const e=Qo(n);return e?new C(e,"hsl"):null}function Zo(n){const e=n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Wo(e[1]),re(e[2],100),re(e[3],100),re(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Zp(n){const e=Zo(n);return e?new C(e,"hsl"):null}function Jo(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const t=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function Jp(n){const e=Jo(n);return e?new C(e,"rgb"):null}function ea(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),g(parseInt(e[4]+e[4],16),0,255,0,1)];const t=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),g(parseInt(t[4],16),0,255,0,1)]:null}function eu(n){const e=ea(n);return e?new C(e,"rgb"):null}function ta(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function ur(n){return e=>{const t=ta(e);return t?ns(t,"rgb",n):null}}function na(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function hr(n){return e=>{const t=na(e);return t?ns(t,"rgb",n):null}}const tu=[{parser:Jo,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:ea,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:Yo,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:Xo,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Qo,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:Zo,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:ta,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:na,result:{alpha:!0,mode:"rgb",notation:"object"}}];function nu(n){return tu.reduce((e,{parser:t,result:i})=>e||(t(n)?i:null),null)}function iu(n,e="int"){const t=nu(n);return t?t.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},t),{type:"int"}):t.notation==="func"?Object.assign(Object.assign({},t),{type:e}):null:null}function un(n){const e=[Jp,eu,Yp,Xp,Qp,Zp];n==="int"&&e.push(ur("int"),hr("int")),n==="float"&&e.push(ur("float"),hr("float"));const t=_p(e);return i=>{const s=t(i);return s?G(s,n):null}}function su(n){const e=un("int");if(typeof n!="string")return C.black();const t=e(n);return t??C.black()}function ia(n){const e=M(Math.floor(n),0,255).toString(16);return e.length===1?`0${e}`:e}function is(n,e="#"){const t=fe(n.getComponents("rgb")).map(ia).join("");return`${e}${t}`}function ss(n,e="#"){const t=n.getComponents("rgb"),i=[t[0],t[1],t[2],t[3]*255].map(ia).join("");return`${e}${i}`}function sa(n){const e=Z(0),t=G(n,"int");return`rgb(${fe(t.getComponents("rgb")).map(s=>e(s)).join(", ")})`}function gn(n){const e=Z(2),t=Z(0);return`rgba(${G(n,"int").getComponents("rgb").map((r,o)=>(o===3?e:t)(r)).join(", ")})`}function ru(n){const e=[Z(0),Sn,Sn],t=G(n,"int");return`hsl(${fe(t.getComponents("hsl")).map((s,r)=>e[r](s)).join(", ")})`}function ou(n){const e=[Z(0),Sn,Sn,Z(2)];return`hsla(${G(n,"int").getComponents("hsl").map((s,r)=>e[r](s)).join(", ")})`}function ra(n,e){const t=Z(e==="float"?2:0),i=["r","g","b"],s=G(n,e);return`{${fe(s.getComponents("rgb")).map((o,a)=>`${i[a]}: ${t(o)}`).join(", ")}}`}function au(n){return e=>ra(e,n)}function oa(n,e){const t=Z(2),i=Z(e==="float"?2:0),s=["r","g","b","a"];return`{${G(n,e).getComponents("rgb").map((a,l)=>{const c=l===3?t:i;return`${s[l]}: ${c(a)}`}).join(", ")}}`}function lu(n){return e=>oa(e,n)}const cu=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:is},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:ss},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:sa},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:gn},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:ru},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:ou},...["int","float"].reduce((n,e)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:au(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:lu(e)}],[])];function aa(n){return cu.reduce((e,t)=>e||(Gp(t.format,n)?t.stringifier:null),null)}const Dt=f("apl");let pu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Dt()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Dt("b")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(Dt("c")),i.appendChild(s),this.colorElem_=s;const r=e.createElement("div");r.classList.add(Dt("m")),this.element.appendChild(r),this.markerElem_=r;const o=e.createElement("div");o.classList.add(Dt("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const e=this.value.rawValue,t=e.getComponents("rgb"),i=new C([t[0],t[1],t[2],0],"rgb"),s=new C([t[0],t[1],t[2],255],"rgb"),r=["to right",gn(i),gn(s)];this.colorElem_.style.background=`linear-gradient(${r.join(",")})`,this.previewElem_.style.backgroundColor=gn(e);const o=g(t[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}},uu=class{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new pu(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ot(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=e.point.x/e.bounds.width,s=this.value.rawValue,[r,o,a]=s.getComponents("hsv");this.value.setRawValue(new C([r,o,a,i],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=X(et(!0),Ee(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new C([s,r,o,a+t],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){X(et(!0),Ee(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const pt=f("coltxt");function hu(n){const e=n.createElement("select"),t=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return e.appendChild(t.reduce((i,s)=>{const r=n.createElement("option");return r.textContent=s.text,r.value=s.value,i.appendChild(r),i},n.createDocumentFragment())),e}let du=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(pt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(pt("m")),this.modeElem_=hu(e),this.modeElem_.classList.add(pt("ms")),i.appendChild(this.modeSelectElement),t.viewProps.bindDisabled(this.modeElem_);const s=e.createElement("div");s.classList.add(pt("mm")),s.appendChild(zn(e,"dropdown")),i.appendChild(s),this.element.appendChild(i);const r=e.createElement("div");r.classList.add(pt("w")),this.element.appendChild(r),this.inputsElem_=r,this.inputViews_=t.inputViews,this.applyInputViews_(),ye(t.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(e){this.inputViews_=e,this.applyInputViews_()}applyInputViews_(){Po(this.inputsElem_);const e=this.element.ownerDocument;this.inputViews_.forEach(t=>{const i=e.createElement("div");i.classList.add(pt("c")),i.appendChild(t.element),this.inputsElem_.appendChild(i)})}};function mu(n){return Z(n==="float"?2:0)}function vu(n,e,t){const i=yt(n,e)[t];return new sn({min:0,max:i})}function bu(n,e,t){return new cn(n,{arrayPosition:t===0?"fst":t===2?"lst":"mid",parser:e.parser,props:b.fromObject({formatter:mu(e.colorType),keyScale:et(!1),pointerScale:e.colorType==="float"?.01:1}),value:k(0,{constraint:vu(e.colorMode,e.colorType,t)}),viewProps:e.viewProps})}function fu(n,e){const t={colorMode:e.colorMode,colorType:e.colorType,parser:Pe,viewProps:e.viewProps};return[0,1,2].map(i=>{const s=bu(n,t,i);return St({primary:e.value,secondary:s.value,forward(r){return G(r,e.colorType).getComponents(e.colorMode)[i]},backward(r,o){const a=e.colorMode,c=G(r,e.colorType).getComponents(a);c[i]=o;const p=ns(qn(fe(c),c[3]),a,e.colorType);return G(p,"int")}}),s})}function wu(n,e){const t=new Xt(n,{parser:un("int"),props:b.fromObject({formatter:is}),value:k(C.black()),viewProps:e.viewProps});return St({primary:e.value,secondary:t.value,forward:i=>new C(fe(i.getComponents()),i.mode),backward:(i,s)=>new C(qn(fe(s.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[t]}function _u(n){return n!=="hex"}let gu=class{constructor(e,t){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=t.colorType,this.value=t.value,this.viewProps=t.viewProps,this.colorMode=k(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new du(e,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(e){const t=this.colorMode.rawValue;return _u(t)?fu(e,{colorMode:t,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):wu(e,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(e){const t=e.currentTarget;this.colorMode.rawValue=t.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}};const oi=f("hpl");let Cu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(oi()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(oi("c")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(oi("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=this.value.rawValue,[t]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=sa(new C([t,100,100],"hsv"));const i=g(t,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}},xu=class{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Cu(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ot(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=g(M(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),s=this.value.rawValue,[,r,o,a]=s.getComponents("hsv");this.value.setRawValue(new C([i,r,o,a],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=X(et(!1),Ee(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new C([s+t,r,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){X(et(!1),Ee(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}};const ai=f("svp"),dr=64;let yu=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(ai()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("canvas");i.height=dr,i.width=dr,i.classList.add(ai("c")),this.element.appendChild(i),this.canvasElement=i;const s=e.createElement("div");s.classList.add(ai("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=Pc(this.canvasElement);if(!e)return;const i=this.value.rawValue.getComponents("hsv"),s=this.canvasElement.width,r=this.canvasElement.height,o=e.getImageData(0,0,s,r),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,s)=>{const r=i.getComponents();return r[3]=s,new C(r,i.mode)}}),this.textsC_=new gu(e,{colorType:t.colorType,value:this.value,viewProps:this.viewProps}),this.view=new Ip(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:t.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}};const li=f("colsw");let ku=class{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.element=e.createElement("div"),this.element.classList.add(li()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(li("sw")),this.element.appendChild(i),this.swatchElem_=i;const s=e.createElement("button");s.classList.add(li("b")),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=ss(e)}onValueChange_(){this.update_()}},Vu=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new ku(e,{value:this.value,viewProps:this.viewProps})}},rs=class{constructor(e,t){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Yi.create(t.expanded),this.swatchC_=new Vu(e,{value:this.value,viewProps:this.viewProps});const i=this.swatchC_.view.buttonElement;i.addEventListener("blur",this.onButtonBlur_),i.addEventListener("click",this.onButtonClick_),this.textC_=new Xt(e,{parser:t.parser,props:b.fromObject({formatter:t.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new Ap(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=t.pickerLayout==="popup"?new Do(e,{viewProps:this.viewProps}):null;const s=new Eu(e,{colorType:t.colorType,supportsAlpha:t.supportsAlpha,value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(r=>{r.addEventListener("blur",this.onPopupChildBlur_),r.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(s.view.element),St({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:r=>r,backward:(r,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Xi(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=Eo(e);i&&t.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Ki(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}};function Tu(n){return fe(n.getComponents("rgb")).reduce((e,t)=>e<<8|Math.floor(t)&255,0)}function Su(n){return n.getComponents("rgb").reduce((e,t,i)=>{const s=Math.floor(i===3?t*255:t)&255;return e<<8|s},0)>>>0}function Lu(n){return new C([n>>16&255,n>>8&255,n&255],"rgb")}function $u(n){return new C([n>>24&255,n>>16&255,n>>8&255,g(n&255,0,255,0,1)],"rgb")}function Au(n){return typeof n!="number"?C.black():Lu(n)}function Mu(n){return typeof n!="number"?C.black():$u(n)}function Cn(n,e){return typeof n!="object"||P(n)?!1:e in n&&typeof n[e]=="number"}function la(n){return Cn(n,"r")&&Cn(n,"g")&&Cn(n,"b")}function ca(n){return la(n)&&Cn(n,"a")}function pa(n){return la(n)}function os(n,e){if(n.mode!==e.mode||n.type!==e.type)return!1;const t=n.getComponents(),i=e.getComponents();for(let s=0;s{pn(t,e(i))}:null}function Ru(n){const e=n?Su:Tu;return(t,i)=>{pn(t,e(i))}}function Du(n,e,t){const s=G(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b),n.writeProperty("a",s.a)}function Bu(n,e,t){const s=G(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b)}function Nu(n,e){return(t,i)=>{n?Du(t,i,e):Bu(t,i,e)}}function ju(n){var e;return!!(!((e=n==null?void 0:n.color)===null||e===void 0)&&e.alpha)}function Iu(n){return n?e=>ss(e,"0x"):e=>is(e,"0x")}function Fu(n){return"color"in n||n.view==="color"}const zu=Y({id:"input-color-number",type:"input",accept:(n,e)=>{if(typeof n!="number"||!Fu(e))return null;const t=es(e);return t?{initialValue:n,params:Object.assign(Object.assign({},t),{supportsAlpha:ju(e)})}:null},binding:{reader:n=>n.params.supportsAlpha?Mu:Au,equals:os,writer:n=>Ru(n.params.supportsAlpha)},controller:n=>{var e,t;return new rs(n.document,{colorType:"int",expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Iu(n.params.supportsAlpha),parser:un("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function Ku(n,e){if(!pa(n))return G(C.black(),e);if(e==="int"){const t=mr(n);return new C(t,"rgb")}if(e==="float"){const t=mr(n);return new ts(t,"rgb")}return G(C.black(),"int")}function qu(n){return ca(n)}function Uu(n){return e=>{const t=Ku(e,n);return G(t,"int")}}function Hu(n,e){return t=>n?oa(t,e):ra(t,e)}const Gu=Y({id:"input-color-object",type:"input",accept:(n,e)=>{var t;if(!pa(n))return null;const i=es(e);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(t=Go(e))!==null&&t!==void 0?t:"int"})}:null},binding:{reader:n=>Uu(n.params.colorType),equals:os,writer:n=>Nu(qu(n.initialValue),n.params.colorType)},controller:n=>{var e,t;const i=ca(n.initialValue);return new rs(n.document,{colorType:n.params.colorType,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Hu(i,n.params.colorType),parser:un("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}}),Wu=Y({id:"input-color-string",type:"input",accept:(n,e)=>{if(typeof n!="string"||e.view==="text")return null;const t=iu(n,Go(e));if(!t)return null;const i=aa(t);if(!i)return null;const s=es(e);return s?{initialValue:n,params:Object.assign(Object.assign({},s),{format:t,stringifier:i})}:null},binding:{reader:()=>su,equals:os,writer:n=>{const e=Ou(n.params.format);if(!e)throw F.notBindable();return e}},controller:n=>{var e,t;return new rs(n.document,{colorType:n.params.format.type,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:n.params.stringifier,parser:un("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});let as=class{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const t=this.asm_.toComponents(e).map((i,s)=>{var r,o;return(o=(r=this.components[s])===null||r===void 0?void 0:r.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(t)}};const vr=f("pndtxt");let Yu=class{constructor(e,t){this.textViews=t.textViews,this.element=e.createElement("div"),this.element.classList.add(vr()),this.textViews.forEach(i=>{const s=e.createElement("div");s.classList.add(vr("a")),s.appendChild(i.element),this.element.appendChild(s)})}};function Xu(n,e,t){return new cn(n,{arrayPosition:t===0?"fst":t===e.axes.length-1?"lst":"mid",parser:e.parser,props:e.axes[t].textProps,value:k(0,{constraint:e.axes[t].constraint}),viewProps:e.viewProps})}let ls=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.acs_=t.axes.map((i,s)=>Xu(e,t,s)),this.acs_.forEach((i,s)=>{St({primary:this.value,secondary:i.value,forward:r=>t.assembly.toComponents(r)[s],backward:(r,o)=>{const a=t.assembly.toComponents(r);return a[s]=o,t.assembly.fromComponents(a)}})}),this.view=new Yu(e,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}},Qu=class extends Yt{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}};function Zu(n,e){const t=[],i=wo(n,e);i&&t.push(i);const s=_o(n);s&&t.push(s);const r=Ji(n.options);return r&&t.push(r),new on(t)}const Ju=Y({id:"input-number",type:"input",accept:(n,e)=>{if(typeof n!="number")return null;const t=T(e,i=>Object.assign(Object.assign({},Co(i)),{options:i.optional.custom(ln),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>mo,constraint:n=>Zu(n.params,n.initialValue),writer:n=>pn},controller:n=>{const e=n.value,t=n.constraint,i=t&&Tn(t,an);if(i)return new Fe(n.document,{props:new b({options:i.values.value("options")}),value:e,viewProps:n.viewProps});const s=go(n.params,e.rawValue),r=t&&Tn(t,sn);return r?new Ln(n.document,Object.assign(Object.assign({},Io(Object.assign(Object.assign({},s),{keyScale:k(s.keyScale),max:r.values.value("max"),min:r.values.value("min")}))),{parser:Pe,value:e,viewProps:n.viewProps})):new cn(n.document,{parser:Pe,props:b.fromObject(s),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof Ln?new Qu(n.controller):n.controller.valueController instanceof Fe?new Qi(n.controller):null}});let je=class{constructor(e=0,t=0){this.x=e,this.y=t}getComponents(){return[this.x,this.y]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y}toObject(){return{x:this.x,y:this.y}}};const ua={toComponents:n=>n.getComponents(),fromComponents:n=>new je(...n)},ut=f("p2d");let eh=class{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ut()),t.viewProps.bindClassModifiers(this.element),ye(t.expanded,kt(this.element,ut(void 0,"expanded")));const i=e.createElement("div");i.classList.add(ut("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(ut("b")),s.appendChild(zn(e,"p2dpad")),t.viewProps.bindDisabled(s),i.appendChild(s),this.buttonElement=s;const r=e.createElement("div");if(r.classList.add(ut("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(ut("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}};const Le=f("p2dp");let th=class{constructor(e,t){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=e.createElement("div"),this.element.classList.add(Le()),t.layout==="popup"&&this.element.classList.add(Le(void 0,"p")),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Le("p")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const s=e.createElementNS(ve,"svg");s.classList.add(Le("g")),this.padElement.appendChild(s),this.svgElem_=s;const r=e.createElementNS(ve,"line");r.classList.add(Le("ax")),r.setAttributeNS(null,"x1","0"),r.setAttributeNS(null,"y1","50%"),r.setAttributeNS(null,"x2","100%"),r.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(r);const o=e.createElementNS(ve,"line");o.classList.add(Le("ax")),o.setAttributeNS(null,"x1","50%"),o.setAttributeNS(null,"y1","0"),o.setAttributeNS(null,"x2","50%"),o.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(o);const a=e.createElementNS(ve,"line");a.classList.add(Le("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=e.createElement("div");l.classList.add(Le("m")),this.padElement.appendChild(l),this.markerElem_=l,t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,t]=this.value.rawValue.getComponents(),i=this.props_.get("max"),s=g(e,-i,+i,0,100),r=g(t,-i,+i,0,100),o=this.props_.get("invertsY")?100-r:r;this.lineElem_.setAttributeNS(null,"x2",`${s}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${s}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}};function br(n,e,t){return[X(e[0],Ee(n)),X(e[1],Qt(n))*(t?1:-1)]}let nh=class{constructor(e,t){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new th(e,{layout:t.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new ot(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=this.props.get("max"),s=g(e.point.x,0,e.bounds.width,-i,+i),r=g(this.props.get("invertsY")?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-i,+i);this.value.setRawValue(new je(s,r),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){jo(e.key)&&e.preventDefault();const[t,i]=br(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(new je(this.value.rawValue.x+t,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[t,i]=br(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}},ih=class{constructor(e,t){var i,s;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Yi.create(t.expanded),this.popC_=t.pickerLayout==="popup"?new Do(e,{viewProps:this.viewProps}):null;const r=new nh(e,{layout:t.pickerLayout,props:new b({invertsY:k(t.invertsY),max:k(t.max),xKeyScale:t.axes[0].textProps.value("keyScale"),yKeyScale:t.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.textC_=new ls(e,{assembly:ua,axes:t.axes,parser:t.parser,value:this.value,viewProps:this.viewProps}),this.view=new eh(e,{expanded:this.foldable_.value("expanded"),pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(i=this.view.buttonElement)===null||i===void 0||i.addEventListener("blur",this.onPadButtonBlur_),(s=this.view.buttonElement)===null||s===void 0||s.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),St({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:o=>o,backward:(o,a)=>a})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Xi(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=Eo(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!Ki(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}};function sh(n){return je.isObject(n)?new je(n.x,n.y):new je}function rh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y)}function oh(n,e){return new as({assembly:ua,components:[Ce(Object.assign(Object.assign({},n),n.x),e.x),Ce(Object.assign(Object.assign({},n),n.y),e.y)]})}function fr(n,e){var t,i;if(!P(n.min)||!P(n.max))return Math.max(Math.abs((t=n.min)!==null&&t!==void 0?t:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const s=bo(n);return Math.max(Math.abs(s)*10,Math.abs(e)*10)}function ah(n,e){var t,i;const s=fr(Ze(n,(t=n.x)!==null&&t!==void 0?t:{}),e.x),r=fr(Ze(n,(i=n.y)!==null&&i!==void 0?i:{}),e.y);return Math.max(s,r)}function lh(n){if(!("y"in n))return!1;const e=n.y;return e&&"inverted"in e?!!e.inverted:!1}const ch=Y({id:"input-point2d",type:"input",accept:(n,e)=>{if(!je.isObject(n))return null;const t=T(e,i=>Object.assign(Object.assign({},Zt(i)),{expanded:i.optional.boolean,picker:i.optional.custom(zo),readonly:i.optional.constant(!1),x:i.optional.custom(Be),y:i.optional.object(Object.assign(Object.assign({},Zt(i)),{inverted:i.optional.boolean}))}));return t?{initialValue:n,params:t}:null},binding:{reader:()=>sh,constraint:n=>oh(n.params,n.initialValue),equals:je.equals,writer:()=>rh},controller:n=>{var e,t;const i=n.document,s=n.value,r=n.constraint,o=[n.params.x,n.params.y];return new ih(i,{axes:s.rawValue.getComponents().map((a,l)=>{var c;return zi({constraint:r.components[l],initialValue:a,params:Ze(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,invertsY:lh(n.params),max:ah(n.params,s.rawValue),parser:Pe,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps})}});let _t=class{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y,s=e.z;return!(typeof t!="number"||typeof i!="number"||typeof s!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}toObject(){return{x:this.x,y:this.y,z:this.z}}};const ha={toComponents:n=>n.getComponents(),fromComponents:n=>new _t(...n)};function ph(n){return _t.isObject(n)?new _t(n.x,n.y,n.z):new _t}function uh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z)}function hh(n,e){return new as({assembly:ha,components:[Ce(Object.assign(Object.assign({},n),n.x),e.x),Ce(Object.assign(Object.assign({},n),n.y),e.y),Ce(Object.assign(Object.assign({},n),n.z),e.z)]})}const dh=Y({id:"input-point3d",type:"input",accept:(n,e)=>{if(!_t.isObject(n))return null;const t=T(e,i=>Object.assign(Object.assign({},Zt(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Be),y:i.optional.custom(Be),z:i.optional.custom(Be)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>ph,constraint:n=>hh(n.params,n.initialValue),equals:_t.equals,writer:n=>uh},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new ls(n.document,{assembly:ha,axes:e.rawValue.getComponents().map((s,r)=>{var o;return zi({constraint:t.components[r],initialValue:s,params:Ze(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:Pe,value:e,viewProps:n.viewProps})}});let gt=class{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(P(e))return!1;const t=e.x,i=e.y,s=e.z,r=e.w;return!(typeof t!="number"||typeof i!="number"||typeof s!="number"||typeof r!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}};const da={toComponents:n=>n.getComponents(),fromComponents:n=>new gt(...n)};function mh(n){return gt.isObject(n)?new gt(n.x,n.y,n.z,n.w):new gt}function vh(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z),n.writeProperty("w",e.w)}function bh(n,e){return new as({assembly:da,components:[Ce(Object.assign(Object.assign({},n),n.x),e.x),Ce(Object.assign(Object.assign({},n),n.y),e.y),Ce(Object.assign(Object.assign({},n),n.z),e.z),Ce(Object.assign(Object.assign({},n),n.w),e.w)]})}const fh=Y({id:"input-point4d",type:"input",accept:(n,e)=>{if(!gt.isObject(n))return null;const t=T(e,i=>Object.assign(Object.assign({},Zt(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Be),x:i.optional.custom(Be),y:i.optional.custom(Be),z:i.optional.custom(Be)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>mh,constraint:n=>bh(n.params,n.initialValue),equals:gt.equals,writer:n=>vh},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new ls(n.document,{assembly:da,axes:e.rawValue.getComponents().map((s,r)=>{var o;return zi({constraint:t.components[r],initialValue:s,params:Ze(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:Pe,value:e,viewProps:n.viewProps})}});function wh(n){const e=[],t=Ji(n.options);return t&&e.push(t),new on(e)}const _h=Y({id:"input-string",type:"input",accept:(n,e)=>{if(typeof n!="string")return null;const t=T(e,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(ln)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>No,constraint:n=>wh(n.params),writer:n=>pn},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&Tn(i,an);return s?new Fe(e,{props:new b({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Xt(e,{parser:r=>r,props:b.fromObject({formatter:Ti}),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof Fe?new Qi(n.controller):null}}),hn={monitor:{defaultInterval:200,defaultRows:3}},wr=f("mll");let gh=class{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(wr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("textarea");i.classList.add(wr("i")),i.style.height=`calc(var(${Fo("containerUnitSize")}) * ${t.rows})`,i.readOnly=!0,t.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.textareaElem_,t=e.scrollTop===e.scrollHeight-e.clientHeight,i=[];this.value.rawValue.forEach(s=>{s!==void 0&&i.push(this.formatter_(s))}),e.textContent=i.join(` +`),t&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}},cs=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new gh(e,{formatter:t.formatter,rows:t.rows,value:this.value,viewProps:this.viewProps})}};const _r=f("sgl");let Ch=class{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(_r()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(_r("i")),i.readOnly=!0,i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.value.rawValue,t=e[e.length-1];this.inputElement.value=t!==void 0?this.formatter_(t):""}onValueUpdate_(){this.update_()}},ps=class{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Ch(e,{formatter:t.formatter,value:this.value,viewProps:this.viewProps})}};const xh=Y({id:"monitor-bool",type:"monitor",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=T(e,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>Bo},controller:n=>{var e;return n.value.rawValue.length===1?new ps(n.document,{formatter:cr,value:n.value,viewProps:n.viewProps}):new cs(n.document,{formatter:cr,rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});let yh=class extends Yt{get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}};const $e=f("grl");let Ph=class{constructor(e,t){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add($e()),t.viewProps.bindClassModifiers(this.element),this.formatter_=t.formatter,this.props_=t.props,this.cursor_=t.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=e.createElementNS(ve,"svg");i.classList.add($e("g")),i.style.height=`calc(var(${Fo("containerUnitSize")}) * ${t.rows})`,this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(ve,"polyline");this.svgElem_.appendChild(s),this.lineElem_=s;const r=e.createElement("div");r.classList.add($e("t"),f("tt")()),this.element.appendChild(r),this.tooltipElem_=r,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const{clientWidth:e,clientHeight:t}=this.element,i=this.value.rawValue.length-1,s=this.props_.get("min"),r=this.props_.get("max"),o=[];this.value.rawValue.forEach((u,_)=>{if(u===void 0)return;const B=g(_,0,i,0,e),N=g(u,s,r,t,0);o.push([B,N].join(","))}),this.lineElem_.setAttributeNS(null,"points",o.join(" "));const a=this.tooltipElem_,l=this.value.rawValue[this.cursor_.rawValue];if(l===void 0){a.classList.remove($e("t","a"));return}const c=g(this.cursor_.rawValue,0,i,0,e),p=g(l,s,r,t,0);a.style.left=`${c}px`,a.style.top=`${p}px`,a.textContent=`${this.formatter_(l)}`,a.classList.contains($e("t","a"))||(a.classList.add($e("t","a"),$e("t","in")),Vn(a),a.classList.remove($e("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}},ma=class{constructor(e,t){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.cursor_=k(-1),this.view=new Ph(e,{cursor:this.cursor_,formatter:t.formatter,rows:t.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Ki(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new ot(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(e){return ee(e,null,t=>({max:t.required.number,min:t.required.number}),t=>(this.props.set("max",t.max),this.props.set("min",t.min),!0))}exportProps(){return te(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const{clientWidth:t}=this.view.element;this.cursor_.rawValue=Math.floor(g(e.offsetX,0,t,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(g(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}};function Si(n){return P(n.format)?Z(2):n.format}function Eh(n){var e;return n.value.rawValue.length===1?new ps(n.document,{formatter:Si(n.params),value:n.value,viewProps:n.viewProps}):new cs(n.document,{formatter:Si(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function kh(n){var e,t,i;return new ma(n.document,{formatter:Si(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,props:b.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function gr(n){return n.view==="graph"}const Vh=Y({id:"monitor-number",type:"monitor",accept:(n,e)=>{if(typeof n!="number")return null;const t=T(e,i=>({format:i.optional.function,max:i.optional.number,min:i.optional.number,readonly:i.required.constant(!0),rows:i.optional.number,view:i.optional.string}));return t?{initialValue:n,params:t}:null},binding:{defaultBufferSize:n=>gr(n)?64:1,reader:n=>mo},controller:n=>gr(n.params)?kh(n):Eh(n),api:n=>n.controller.valueController instanceof ma?new yh(n.controller):null}),Th=Y({id:"monitor-string",type:"monitor",accept:(n,e)=>{if(typeof n!="string")return null;const t=T(e,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>No},controller:n=>{var e;const t=n.value;return t.rawValue.length>1||n.params.multiline?new cs(n.document,{formatter:Ti,rows:(e=n.params.rows)!==null&&e!==void 0?e:hn.monitor.defaultRows,value:t,viewProps:n.viewProps}):new ps(n.document,{formatter:Ti,value:t,viewProps:n.viewProps})}});class Sh{constructor(){this.map_=new Map}get(e){var t;return(t=this.map_.get(e))!==null&&t!==void 0?t:null}has(e){return this.map_.has(e)}add(e,t){return this.map_.set(e,t),e.viewProps.handleDispose(()=>{this.map_.delete(e)}),t}}class Lh{constructor(e){this.target=e.target,this.reader_=e.reader,this.writer_=e.writer}read(){return this.reader_(this.target.read())}write(e){this.writer_(this.target,e)}inject(e){this.write(this.reader_(e))}}function $h(n,e){var t;const i=n.accept(e.target.read(),e.params);if(P(i))return null;const s={target:e.target,initialValue:i.initialValue,params:i.params},r=T(e.params,u=>({disabled:u.optional.boolean,hidden:u.optional.boolean,label:u.optional.string,tag:u.optional.string})),o=n.binding.reader(s),a=n.binding.constraint?n.binding.constraint(s):void 0,l=new Lh({reader:o,target:e.target,writer:n.binding.writer(s)}),c=new bc(k(o(i.initialValue),{constraint:a,equals:n.binding.equals}),l),p=n.controller({constraint:a,document:e.document,initialValue:i.initialValue,params:i.params,value:c,viewProps:rt.create({disabled:r==null?void 0:r.disabled,hidden:r==null?void 0:r.hidden})});return new $c(e.document,{blade:Tt(),props:b.fromObject({label:"label"in e.params?(t=r==null?void 0:r.label)!==null&&t!==void 0?t:null:e.target.key}),tag:r==null?void 0:r.tag,value:c,valueController:p})}class Ah{constructor(e){this.target=e.target,this.reader_=e.reader}read(){return this.reader_(this.target.read())}}function Mh(n,e){return e===0?new dp:new mp(n,e??hn.monitor.defaultInterval)}function Oh(n,e){var t,i,s;const r=n.accept(e.target.read(),e.params);if(P(r))return null;const o={target:e.target,initialValue:r.initialValue,params:r.params},a=T(e.params,_=>({bufferSize:_.optional.number,disabled:_.optional.boolean,hidden:_.optional.boolean,interval:_.optional.number,label:_.optional.string})),l=n.binding.reader(o),c=(i=(t=a==null?void 0:a.bufferSize)!==null&&t!==void 0?t:n.binding.defaultBufferSize&&n.binding.defaultBufferSize(r.params))!==null&&i!==void 0?i:1,p=new Dc({binding:new Ah({reader:l,target:e.target}),bufferSize:c,ticker:Mh(e.document,a==null?void 0:a.interval)}),u=n.controller({document:e.document,params:r.params,value:p,viewProps:rt.create({disabled:a==null?void 0:a.disabled,hidden:a==null?void 0:a.hidden})});return u.viewProps.bindDisabled(p.ticker),u.viewProps.handleDispose(()=>{p.ticker.dispose()}),new Nc(e.document,{blade:Tt(),props:b.fromObject({label:"label"in e.params?(s=a==null?void 0:a.label)!==null&&s!==void 0?s:null:e.target.key}),value:p,valueController:u})}class Rh{constructor(e){this.pluginsMap_={blades:[],inputs:[],monitors:[]},this.apiCache_=e}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(e,t){if(!Vp(t.core))throw F.notCompatible(e,t.id);t.type==="blade"?this.pluginsMap_.blades.unshift(t):t.type==="input"?this.pluginsMap_.inputs.unshift(t):t.type==="monitor"&&this.pluginsMap_.monitors.unshift(t)}createInput_(e,t,i){return this.pluginsMap_.inputs.reduce((s,r)=>s??$h(r,{document:e,target:t,params:i}),null)}createMonitor_(e,t,i){return this.pluginsMap_.monitors.reduce((s,r)=>s??Oh(r,{document:e,params:i,target:t}),null)}createBinding(e,t,i){const s=t.read();if(P(s))throw new F({context:{key:t.key},type:"nomatchingcontroller"});const r=this.createInput_(e,t,i);if(r)return r;const o=this.createMonitor_(e,t,i);if(o)return o;throw new F({context:{key:t.key},type:"nomatchingcontroller"})}createBlade(e,t){const i=this.pluginsMap_.blades.reduce((s,r)=>s??hp(r,{document:e,params:t}),null);if(!i)throw new F({type:"nomatchingview",context:{params:t}});return i}createInputBindingApi_(e){const t=this.pluginsMap_.inputs.reduce((i,s)=>{var r,o;return i||((o=(r=s.api)===null||r===void 0?void 0:r.call(s,{controller:e}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(e,t??new Yt(e))}createMonitorBindingApi_(e){const t=this.pluginsMap_.monitors.reduce((i,s)=>{var r,o;return i||((o=(r=s.api)===null||r===void 0?void 0:r.call(s,{controller:e}))!==null&&o!==void 0?o:null)},null);return this.apiCache_.add(e,t??new Yt(e))}createBindingApi(e){if(this.apiCache_.has(e))return this.apiCache_.get(e);if(Ac(e))return this.createInputBindingApi_(e);if(jc(e))return this.createMonitorBindingApi_(e);throw F.shouldNeverHappen()}createApi(e){if(this.apiCache_.has(e))return this.apiCache_.get(e);if(Lc(e))return this.createBindingApi(e);const t=this.pluginsMap_.blades.reduce((i,s)=>i??s.api({controller:e,pool:this}),null);if(!t)throw F.shouldNeverHappen();return this.apiCache_.add(e,t)}}const Dh=new Sh;function Bh(){const n=new Rh(Dh);return[ch,dh,fh,_h,Ju,Wu,Gu,zu,$p,xh,Th,Vh,qc,ip,Ro].forEach(e=>{n.register("core",e)}),n}class Nh extends st{constructor(e){super(e),this.emitter_=new A,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new rn(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}class jh extends st{}class Ih extends st{constructor(e){super(e),this.emitter_=new A,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new rn(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}class Fh extends st{constructor(e){super(e),this.emitter_=new A,this.controller.value.emitter.on("change",t=>{this.emitter_.emit("change",new rn(this,t.rawValue))})}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get formatter(){return this.controller.valueController.props.get("formatter")}set formatter(e){this.controller.valueController.props.set("formatter",e)}get value(){return this.controller.value.rawValue}set value(e){this.controller.value.rawValue=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)},{key:t}),this}off(e,t){return this.emitter_.off(e,t),this}}const zh=function(){return{id:"list",type:"blade",core:Vt,accept(n){const e=T(n,t=>({options:t.required.custom(ln),value:t.required.raw,view:t.required.constant("list"),label:t.optional.string}));return e?{params:e}:null},controller(n){const e=new an(Zi(n.params.options)),t=k(n.params.value,{constraint:e}),i=new Fe(n.document,{props:new b({options:e.values.value("options")}),value:t,viewProps:n.viewProps});return new Je(n.document,{blade:n.blade,props:b.fromObject({label:n.params.label}),value:t,valueController:i})},api(n){return!(n.controller instanceof Je)||!(n.controller.valueController instanceof Fe)?null:new Nh(n.controller)}}}();class Kh extends Ao{constructor(e,t){super(e,t)}get element(){return this.controller.view.element}}class qh extends ki{constructor(e,t){super(e,{expanded:t.expanded,blade:t.blade,props:t.props,root:!0,viewProps:t.viewProps})}}const Cr=f("spr");class Uh{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Cr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("hr");i.classList.add(Cr("r")),this.element.appendChild(i)}}class xr extends Kn{constructor(e,t){super(Object.assign(Object.assign({},t),{view:new Uh(e,{viewProps:t.viewProps})}))}}const Hh={id:"separator",type:"blade",core:Vt,accept(n){const e=T(n,t=>({view:t.required.constant("separator")}));return e?{params:e}:null},controller(n){return new xr(n.document,{blade:n.blade,viewProps:n.viewProps})},api(n){return n.controller instanceof xr?new jh(n.controller):null}},Gh={id:"slider",type:"blade",core:Vt,accept(n){const e=T(n,t=>({max:t.required.number,min:t.required.number,view:t.required.constant("slider"),format:t.optional.function,label:t.optional.string,value:t.optional.number}));return e?{params:e}:null},controller(n){var e,t;const i=(e=n.params.value)!==null&&e!==void 0?e:0,s=new sn({max:n.params.max,min:n.params.min}),r=k(i,{constraint:s}),o=new Ln(n.document,Object.assign(Object.assign({},Io({formatter:(t=n.params.format)!==null&&t!==void 0?t:uc,keyScale:k(1),max:s.values.value("max"),min:s.values.value("min"),pointerScale:fo(n.params,i)})),{parser:Pe,value:r,viewProps:n.viewProps}));return new Je(n.document,{blade:n.blade,props:b.fromObject({label:n.params.label}),value:r,valueController:o})},api(n){return!(n.controller instanceof Je)||!(n.controller.valueController instanceof Ln)?null:new Ih(n.controller)}},Wh=function(){return{id:"text",type:"blade",core:Vt,accept(n){const e=T(n,t=>({parse:t.required.function,value:t.required.raw,view:t.required.constant("text"),format:t.optional.function,label:t.optional.string}));return e?{params:e}:null},controller(n){var e;const t=k(n.params.value),i=new Xt(n.document,{parser:n.params.parse,props:b.fromObject({formatter:(e=n.params.format)!==null&&e!==void 0?e:s=>String(s)}),value:t,viewProps:n.viewProps});return new Je(n.document,{blade:n.blade,props:b.fromObject({label:n.params.label}),value:t,valueController:i})},api(n){return!(n.controller instanceof Je)||!(n.controller.valueController instanceof Xt)?null:new Fh(n.controller)}}}();function Yh(n){const e=n.createElement("div");return e.classList.add(f("dfw")()),n.body&&n.body.appendChild(e),e}function Xh(n,e,t){if(n.querySelector(`style[data-tp-style=${e}]`))return;const i=n.createElement("style");i.dataset.tpStyle=e,i.textContent=t,n.head.appendChild(i)}class Qh extends Kh{constructor(e){var t,i;const s=e??{},r=(t=s.document)!==null&&t!==void 0?t:yc(),o=Bh(),a=new qh(r,{expanded:s.expanded,blade:Tt(),props:b.fromObject({title:s.title}),viewProps:rt.create()});super(a,o),this.pool_=o,this.containerElem_=(i=s.container)!==null&&i!==void 0?i:Yh(r),this.containerElem_.appendChild(this.element),this.doc_=r,this.usesDefaultWrapper_=!s.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw F.alreadyDisposed();return this.doc_}dispose(){const e=this.containerElem_;if(!e)throw F.alreadyDisposed();if(this.usesDefaultWrapper_){const t=e.parentElement;t&&t.removeChild(e)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(e){e.css&&Xh(this.document,`plugin-${e.id}`,e.css),("plugin"in e?[e.plugin]:"plugins"in e?e.plugins:[]).forEach(i=>{this.pool_.register(e.id,i)})}setUpDefaultPlugins_(){this.registerPlugin({id:"default",css:'.tp-tbiv_b,.tp-coltxtv_ms,.tp-colswv_b,.tp-ckbv_i,.tp-sglv_i,.tp-mllv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-rotv_b,.tp-fldv_b,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--bld-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--cnt-usz);line-height:var(--cnt-usz);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tbpv_c>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-vp))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tbpv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tbpv_c>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--cnt-usp)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tbpv_c>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tbpv_c>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tbpv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-vp)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tbpv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tbpv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tbpv_c>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tbpv_c>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--bld-br);border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tbpv_c .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--bld-br)}.tp-tbpv_c>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tbpv_c>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tbpv_c>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--bld-br)}.tp-tbpv_c .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--bld-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);overflow:hidden;padding-left:var(--cnt-hp);padding-right:calc(4px + var(--cnt-usz) + var(--cnt-hp));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-hp) + (var(--cnt-usz) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-vp);padding-top:var(--cnt-vp);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-sglv_i,.tp-mllv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--mo-fg);height:var(--cnt-usz);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-sglv_i::-webkit-scrollbar,.tp-mllv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-sglv_i::-webkit-scrollbar-corner,.tp-mllv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-sglv_i::-webkit-scrollbar-thumb,.tp-mllv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-rotv{--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-br: var(--tp-base-border-radius, 6px);--bs-ff: var(--tp-base-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--bld-br: var(--tp-blade-border-radius, 2px);--bld-hp: var(--tp-blade-horizontal-padding, 4px);--bld-vw: var(--tp-blade-value-width, 160px);--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--cnt-hp: var(--tp-container-horizontal-padding, 4px);--cnt-vp: var(--tp-container-vertical-padding, 4px);--cnt-usp: var(--tp-container-unit-spacing, 4px);--cnt-usz: var(--tp-container-unit-size, 20px);--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--bld-br);cursor:pointer;display:block;height:var(--cnt-usz);position:relative;width:var(--cnt-usz)}.tp-ckbv_w svg{display:block;height:16px;inset:0;margin:auto;opacity:0;position:absolute;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--cnt-usz)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--cnt-usp);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--cnt-usp)}.tp-colpv_rgb{display:flex;margin-top:var(--cnt-usp);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-vp);padding-top:calc(var(--cnt-vp) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-hp));position:absolute;right:calc(-1*var(--cnt-hp));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--bld-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--cnt-usz)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--cnt-usz);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{inset:0;position:absolute}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--bld-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--bld-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;inset:0;position:absolute}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--bld-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{cursor:pointer;display:block;height:var(--cnt-usz);left:0;position:absolute;top:0;width:var(--cnt-usz)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--bld-br);content:"";display:block;inset:0;position:absolute}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--bld-br);color:var(--lbl-fg);cursor:pointer;height:var(--cnt-usz);line-height:var(--cnt-usz);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--cnt-usz)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-hp);padding-right:var(--cnt-hp)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:var(--bld-vw)}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 var(--bld-hp);width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--cnt-usz)*3);line-height:var(--cnt-usz);padding-left:var(--bld-hp);padding-right:var(--bld-hp);resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--cnt-usz);margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--cnt-usp);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-hp));right:calc(-1*var(--cnt-hp));top:var(--cnt-usz)}.tp-p2dpv{padding-left:calc(var(--cnt-usz) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:var(--bld-vw);padding:var(--cnt-vp) var(--cnt-hp);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--cnt-usz);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin:auto;position:absolute}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;content:"";display:block;height:2px;inset:0;margin-bottom:auto;margin-top:auto;position:absolute}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--bld-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--cnt-usz) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--cnt-usz) + 4px);width:max(var(--bs-br),4px)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-hp) + 4px);padding-right:calc(var(--cnt-hp) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);content:"";inset:0 0 2px;pointer-events:none;position:absolute}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--cnt-usz) + 4px);line-height:calc(var(--cnt-usz) + 4px);opacity:.5;overflow:hidden;position:relative;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-tbpv_c{padding-bottom:var(--cnt-vp);padding-left:4px;padding-top:var(--cnt-vp)}.tp-txtv{position:relative}.tp-txtv_i{padding-left:var(--bld-hp);padding-right:var(--bld-hp)}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:calc(var(--bld-hp) - 5px);position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--cnt-usz) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--bld-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--bs-ff);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--cnt-usz) + var(--cnt-hp));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0;transition-delay:0s;transition-duration:0s}.tp-rotv.tp-rotv-not>.tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst.tp-fldv-expanded>.tp-fldv_b{transition-delay:0s;transition-duration:0s}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-vp))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}',plugins:[zh,Hh,Gh,Ro,Wh]})}}new Lo("4.0.4");function E(n){return n==null}function us(n){return n!==null&&typeof n=="object"}function Li(n){return n!==null&&typeof n=="object"}function Zh(n,e){if(n.length!==e.length)return!1;for(let t=0;t{const r=n[s],o=e[s];return Li(r)&&Li(o)?Object.assign(Object.assign({},i),{[s]:tt(r,o)}):Object.assign(Object.assign({},i),{[s]:s in e?o:r})},{})}function Jh(n){return us(n)?"target"in n:!1}const ed={alreadydisposed:()=>"View has been already disposed",invalidparams:n=>`Invalid parameters for '${n.name}'`,nomatchingcontroller:n=>`No matching controller for '${n.key}'`,nomatchingview:n=>`No matching view for '${JSON.stringify(n.params)}'`,notbindable:()=>"Value is not bindable",notcompatible:n=>`Not compatible with plugin '${n.id}'`,propertynotfound:n=>`Property '${n.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class H{static alreadyDisposed(){return new H({type:"alreadydisposed"})}static notBindable(){return new H({type:"notbindable"})}static notCompatible(e,t){return new H({type:"notcompatible",context:{id:`${e}.${t}`}})}static propertyNotFound(e){return new H({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new H({type:"shouldneverhappen"})}constructor(e){var t;this.message=(t=ed[e.type](e.context))!==null&&t!==void 0?t:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}toString(){return this.message}}class $n{constructor(e,t){this.obj_=e,this.key=t}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}read(){return this.obj_[this.key]}write(e){this.obj_[this.key]=e}writeProperty(e,t){const i=this.read();if(!$n.isBindable(i))throw H.notBindable();if(!(e in i))throw H.propertyNotFound(e);i[e]=t}}class z{constructor(){this.observers_={}}on(e,t){let i=this.observers_[e];return i||(i=this.observers_[e]=[]),i.push({handler:t}),this}off(e,t){const i=this.observers_[e];return i&&(this.observers_[e]=i.filter(s=>s.handler!==t)),this}emit(e,t){const i=this.observers_[e];i&&i.forEach(s=>{s.handler(t)})}}class td{constructor(e,t){var i;this.constraint_=t==null?void 0:t.constraint,this.equals_=(i=t==null?void 0:t.equals)!==null&&i!==void 0?i:(s,r)=>s===r,this.emitter=new z,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.constraint_?this.constraint_.constrain(e):e,r=this.rawValue_;this.equals_(r,s)&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=s,this.emitter.emit("change",{options:i,previousRawValue:r,rawValue:s,sender:this}))}}class nd{constructor(e){this.emitter=new z,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,t){const i=t??{forceEmit:!1,last:!0},s=this.value_;s===e&&!i.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:i,previousRawValue:s,rawValue:this.value_,sender:this}))}}class id{constructor(e){this.emitter=new z,this.onValueBeforeChange_=this.onValueBeforeChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.value_=e,this.value_.emitter.on("beforechange",this.onValueBeforeChange_),this.value_.emitter.on("change",this.onValueChange_)}get rawValue(){return this.value_.rawValue}onValueBeforeChange_(e){this.emitter.emit("beforechange",Object.assign(Object.assign({},e),{sender:this}))}onValueChange_(e){this.emitter.emit("change",Object.assign(Object.assign({},e),{sender:this}))}}function S(n,e){const t=e==null?void 0:e.constraint,i=e==null?void 0:e.equals;return!t&&!i?new nd(n):new td(n,e)}function sd(n){return[new id(n),(e,t)=>{n.setRawValue(e,t)}]}class d{constructor(e){this.emitter=new z,this.valMap_=e;for(const t in this.valMap_)this.valMap_[t].emitter.on("change",()=>{this.emitter.emit("change",{key:t,sender:this})})}static createCore(e){return Object.keys(e).reduce((i,s)=>Object.assign(i,{[s]:S(e[s])}),{})}static fromObject(e){const t=this.createCore(e);return new d(t)}get(e){return this.valMap_[e].rawValue}set(e,t){this.valMap_[e].rawValue=t}value(e){return this.valMap_[e]}}class dn{constructor(e){this.values=d.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");return Math.min(Math.max(e,i),t)}}class hs{constructor(e){this.values=d.fromObject({max:e.max,min:e.min})}constrain(e){const t=this.values.get("max"),i=this.values.get("min");let s=e;return E(i)||(s=Math.max(s,i)),E(t)||(s=Math.min(s,t)),s}}class rd{constructor(e,t=0){this.step=e,this.origin=t}constrain(e){const t=this.origin%this.step,i=Math.round((e-t)/this.step);return t+i*this.step}}class od{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}}const ad={"**":(n,e)=>Math.pow(n,e),"*":(n,e)=>n*e,"/":(n,e)=>n/e,"%":(n,e)=>n%e,"+":(n,e)=>n+e,"-":(n,e)=>n-e,"<<":(n,e)=>n<>":(n,e)=>n>>e,">>>":(n,e)=>n>>>e,"&":(n,e)=>n&e,"^":(n,e)=>n^e,"|":(n,e)=>n|e};class ld{constructor(e,t,i){this.left=t,this.operator=e,this.right=i}evaluate(){const e=ad[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const cd={"+":n=>n,"-":n=>-n,"~":n=>~n};class pd{constructor(e,t){this.operator=e,this.expression=t}evaluate(){const e=cd[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function ds(n){return(e,t)=>{for(let i=0;ie.startsWith(s,t))[0];return i?(t+=i.length,t+=Jt(e,t).length,{cursor:t,operator:i}):null}function Sd(n,e){return(t,i)=>{const s=n(t,i);if(!s)return null;i=s.cursor;let r=s.evaluable;for(;;){const o=Td(e,t,i);if(!o)break;i=o.cursor;const a=n(t,i);if(!a)return null;i=a.cursor,r=new ld(o.operator,r,a.evaluable)}return r?{cursor:i,evaluable:r}:null}}const Ld=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((n,e)=>Sd(n,e),ba);function fa(n,e){return e+=Jt(n,e).length,Ld(n,e)}function $d(n){const e=fa(n,0);return!e||e.cursor+Jt(n,e.cursor).length!==n.length?null:e.evaluable}function ue(n){var e;const t=$d(n);return(e=t==null?void 0:t.evaluate())!==null&&e!==void 0?e:null}function vs(n){if(typeof n=="number")return n;if(typeof n=="string"){const e=ue(n);if(!E(e))return e}return 0}function j(n){return e=>e.toFixed(Math.max(Math.min(n,20),0))}function h(n,e,t,i,s){const r=(n-e)/(t-e);return i+r*(s-i)}function yr(n){return String(n.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function V(n,e,t){return Math.min(Math.max(n,e),t)}function wa(n,e){return(n%e+e)%e}function Ad(n,e){return E(n.step)?Math.max(yr(e),2):yr(n.step)}function _a(n){var e;return(e=n.step)!==null&&e!==void 0?e:1}function Md(n,e){var t;const i=Math.abs((t=n.step)!==null&&t!==void 0?t:e);return i===0?.1:Math.pow(10,Math.floor(Math.log10(i))-1)}function bs(n,e){return E(n.step)?null:new rd(n.step,e)}function fs(n){return!E(n.max)&&!E(n.min)?new dn({max:n.max,min:n.min}):!E(n.max)||!E(n.min)?new hs({max:n.max,min:n.min}):null}function ws(n,e){var t,i,s;return{formatter:(t=n.format)!==null&&t!==void 0?t:j(Ad(n,e)),keyScale:(i=n.keyScale)!==null&&i!==void 0?i:_a(n),pointerScale:(s=n.pointerScale)!==null&&s!==void 0?s:Md(n,e)}}function _s(n){return{format:n.optional.function,keyScale:n.optional.number,max:n.optional.number,min:n.optional.number,pointerScale:n.optional.number,step:n.optional.number}}function gs(n){return{constraint:n.constraint,textProps:d.fromObject(ws(n.params,n.initialValue))}}class at{constructor(e){this.controller=e}get element(){return this.controller.view.element}get disabled(){return this.controller.viewProps.get("disabled")}set disabled(e){this.controller.viewProps.set("disabled",e)}get hidden(){return this.controller.viewProps.get("hidden")}set hidden(e){this.controller.viewProps.set("hidden",e)}dispose(){this.controller.viewProps.set("disposed",!0)}importState(e){return this.controller.importState(e)}exportState(){return this.controller.exportState()}}class lt{constructor(e){this.target=e}}class Un extends lt{constructor(e,t,i){super(e),this.value=t,this.last=i??!0}}class Od extends lt{constructor(e,t){super(e),this.expanded=t}}class Rd extends lt{constructor(e,t){super(e),this.index=t}}class Cs extends at{constructor(e){super(e),this.onValueChange_=this.onValueChange_.bind(this),this.emitter_=new z,this.controller.value.emitter.on("change",this.onValueChange_)}get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get key(){return this.controller.value.binding.target.key}get tag(){return this.controller.tag}set tag(e){this.controller.tag=e}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.controller.value.fetch()}onValueChange_(e){const t=this.controller.value;this.emitter_.emit("change",new Un(this,t.binding.target.read(),e.options.last))}}function Dd(n,e){const i=Object.keys(e).reduce((s,r)=>{if(s===void 0)return;const o=e[r],a=o(n[r]);return a.succeeded?Object.assign(Object.assign({},s),{[r]:a.value}):void 0},{});return i}function Bd(n,e){return n.reduce((t,i)=>{if(t===void 0)return;const s=e(i);if(!(!s.succeeded||s.value===void 0))return[...t,s.value]},[])}function Nd(n){return n===null?!1:typeof n=="object"}function ge(n){return e=>t=>{if(!e&&t===void 0)return{succeeded:!1,value:void 0};if(e&&t===void 0)return{succeeded:!0,value:void 0};const i=n(t);return i!==void 0?{succeeded:!0,value:i}:{succeeded:!1,value:void 0}}}function Pr(n){return{custom:e=>ge(e)(n),boolean:ge(e=>typeof e=="boolean"?e:void 0)(n),number:ge(e=>typeof e=="number"?e:void 0)(n),string:ge(e=>typeof e=="string"?e:void 0)(n),function:ge(e=>typeof e=="function"?e:void 0)(n),constant:e=>ge(t=>t===e?e:void 0)(n),raw:ge(e=>e)(n),object:e=>ge(t=>{if(Nd(t))return Dd(t,e)})(n),array:e=>ge(t=>{if(Array.isArray(t))return Bd(t,e)})(n)}}const $i={optional:Pr(!0),required:Pr(!1)};function L(n,e){const t=e($i),i=$i.required.object(t)(n);return i.succeeded?i.value:void 0}function de(n,e,t,i){if(e&&!e(n))return!1;const s=L(n,t);return s?i(s):!1}function me(n,e){var t;return tt((t=n==null?void 0:n())!==null&&t!==void 0?t:{},e)}function xn(n){return"value"in n}function jd(n){if(!us(n)||!("binding"in n))return!1;const e=n.binding;return Jh(e)}const R="http://www.w3.org/2000/svg";function An(n){n.offsetHeight}function Id(n,e){const t=n.style.transition;n.style.transition="none",e(),n.style.transition=t}function Hn(n){return n.ontouchstart!==void 0}function Fd(n){const e=n.ownerDocument.defaultView;return e&&"document"in e?n.getContext("2d",{willReadFrequently:!0}):null}const zd={check:'',dropdown:'',p2dpad:''};function Gn(n,e){const t=n.createElementNS(R,"svg");return t.innerHTML=zd[e],t}function ga(n,e,t){n.insertBefore(e,n.children[t])}function xs(n){n.parentElement&&n.parentElement.removeChild(n)}function Ca(n){for(;n.children.length>0;)n.removeChild(n.children[0])}function Kd(n){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}function ys(n){return n.relatedTarget?n.relatedTarget:"explicitOriginalTarget"in n?n.explicitOriginalTarget:null}function le(n,e){n.emitter.on("change",t=>{e(t.rawValue)}),e(n.rawValue)}function ce(n,e,t){le(n.value(e),t)}const qd="tp";function m(n){return(t,i)=>[qd,"-",n,"v",t?`_${t}`:"",i?`-${i}`:""].join("")}const Bt=m("lbl");function Ud(n,e){const t=n.createDocumentFragment();return e.split(` +`).map(s=>n.createTextNode(s)).forEach((s,r)=>{r>0&&t.appendChild(n.createElement("br")),t.appendChild(s)}),t}class xa{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Bt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Bt("l")),ce(t.props,"label",r=>{E(r)?this.element.classList.add(Bt(void 0,"nol")):(this.element.classList.remove(Bt(void 0,"nol")),Kd(i),i.appendChild(Ud(e,r)))}),this.element.appendChild(i),this.labelElement=i;const s=e.createElement("div");s.classList.add(Bt("v")),this.element.appendChild(s),this.valueElement=s}}class Wn{constructor(e,t){this.props=t.props,this.valueController=t.valueController,this.viewProps=t.valueController.viewProps,this.view=new xa(e,{props:t.props,viewProps:this.viewProps}),this.view.valueElement.appendChild(this.valueController.view.element)}importProps(e){return de(e,null,t=>({label:t.optional.string}),t=>(this.props.set("label",t.label),!0))}exportProps(){return me(null,{label:this.props.get("label")})}}function Hd(){return["veryfirst","first","last","verylast"]}const Er=m(""),kr={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class mn{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const t=this.view.element;this.blade.value("positions").emitter.on("change",()=>{Hd().forEach(i=>{t.classList.remove(Er(void 0,kr[i]))}),this.blade.get("positions").forEach(i=>{t.classList.add(Er(void 0,kr[i]))})}),this.viewProps.handleDispose(()=>{xs(t)})}get parent(){return this.parent_}set parent(e){this.parent_=e,this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}importState(e){return de(e,null,t=>({disabled:t.required.boolean,hidden:t.required.boolean}),t=>(this.viewProps.importState(t),!0))}exportState(){return me(null,Object.assign({},this.viewProps.exportState()))}}class Mn extends mn{constructor(e,t){if(t.value!==t.valueController.value)throw H.shouldNeverHappen();const i=t.valueController.viewProps,s=new Wn(e,{blade:t.blade,props:t.props,valueController:t.valueController});super(Object.assign(Object.assign({},t),{view:new xa(e,{props:t.props,viewProps:i}),viewProps:i})),this.labelController=s,this.value=t.value,this.valueController=t.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}importState(e){return de(e,t=>{var i,s,r;return super.importState(t)&&this.labelController.importProps(t)&&((r=(s=(i=this.valueController).importProps)===null||s===void 0?void 0:s.call(i,e))!==null&&r!==void 0?r:!0)},t=>({value:t.optional.raw}),t=>(t.value&&(this.value.rawValue=t.value),!0))}exportState(){var e,t,i;return me(()=>super.exportState(),Object.assign(Object.assign({value:this.value.rawValue},this.labelController.exportProps()),(i=(t=(e=this.valueController).exportProps)===null||t===void 0?void 0:t.call(e))!==null&&i!==void 0?i:{}))}}function ya(n,e){for(;n.lengthn.length?t.splice(0,t.length-n.length):ya(t,n.length),t}class Xd extends at{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get title(){var e;return(e=this.controller.buttonController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.buttonController.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller.buttonController.emitter.on(e,()=>{i(new lt(this))}),this}}function Qd(n,e,t){t?n.classList.add(e):n.classList.remove(e)}function Ke(n,e){return t=>{Qd(n,e,t)}}function Ps(n,e){le(n,t=>{e.textContent=t??""})}const ci=m("btn");class Zd{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ci()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("button");i.classList.add(ci("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(ci("t")),Ps(t.props.value("title"),s),this.buttonElement.appendChild(s)}}class Pa{constructor(e,t){this.emitter=new z,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new Zd(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}importProps(e){return de(e,null,t=>({title:t.optional.string}),t=>(this.props.set("title",t.title),!0))}exportProps(){return me(null,{title:this.props.get("title")})}onClick_(){this.emitter.emit("click",{sender:this})}}class Vr extends mn{constructor(e,t){const i=new Pa(e,{props:t.buttonProps,viewProps:t.viewProps}),s=new Wn(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:t.viewProps}),this.buttonController=i,this.labelController=s}importState(e){return de(e,t=>super.importState(t)&&this.buttonController.importProps(t)&&this.labelController.importProps(t),()=>({}),()=>!0)}exportState(){return me(()=>super.exportState(),Object.assign(Object.assign({},this.buttonController.exportProps()),this.labelController.exportProps()))}}class Jd{constructor(e){const[t,i]=e.split("-"),s=t.split(".");this.major=parseInt(s[0],10),this.minor=parseInt(s[1],10),this.patch=parseInt(s[2],10),this.prerelease=i??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}}const em=new Jd("2.0.0-beta.2");function $(n){return Object.assign({core:em},n)}$({id:"button",type:"blade",accept(n){const e=L(n,t=>({title:t.required.string,view:t.required.constant("button"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new Vr(n.document,{blade:n.blade,buttonProps:d.fromObject({title:n.params.title}),labelProps:d.fromObject({label:n.params.label}),viewProps:n.viewProps})},api(n){return n.controller instanceof Vr?new Xd(n.controller):null}});function tm(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function nm(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function im(n,e){return n.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}function sm(n){return us(n)?"refresh"in n&&typeof n.refresh=="function":!1}function rm(n,e){if(!$n.isBindable(n))throw H.notBindable();return new $n(n,e)}class om{constructor(e,t){this.onRackValueChange_=this.onRackValueChange_.bind(this),this.controller_=e,this.emitter_=new z,this.pool_=t,this.controller_.rack.emitter.on("valuechange",this.onRackValueChange_)}get children(){return this.controller_.rack.children.map(e=>this.pool_.createApi(e))}addBinding(e,t,i){const s=i??{},r=this.controller_.element.ownerDocument,o=this.pool_.createBinding(r,rm(e,t),s),a=this.pool_.createBindingApi(o);return this.add(a,s.index)}addFolder(e){return nm(this,e)}addButton(e){return tm(this,e)}addTab(e){return im(this,e)}add(e,t){const i=e.controller;return this.controller_.rack.add(i,t),e}remove(e){this.controller_.rack.remove(e.controller)}addBlade(e){const t=this.controller_.element.ownerDocument,i=this.pool_.createBlade(t,e),s=this.pool_.createApi(i);return this.add(s,e.index)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.children.forEach(e=>{sm(e)&&e.refresh()})}onRackValueChange_(e){const t=e.bladeController,i=this.pool_.createApi(t),s=jd(t.value)?t.value.binding:null;this.emitter_.emit("change",new Un(i,s?s.target.read():t.value.rawValue,e.options.last))}}class Es extends at{constructor(e,t){super(e),this.rackApi_=new om(e.rackController,t)}}class ks extends mn{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}importState(e){return de(e,t=>super.importState(t),t=>({children:t.required.array(t.required.raw)}),t=>this.rackController.rack.children.every((i,s)=>i.importState(t.children[s])))}exportState(){return me(()=>super.exportState(),{children:this.rackController.rack.children.map(e=>e.exportState())})}}function Ai(n){return"rackController"in n}class am{constructor(e){this.emitter=new z,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const t of this.allItems())if(e(t))return t;return null}includes(e){return this.cache_.has(e)}add(e,t){if(this.includes(e))throw H.shouldNeverHappen();const i=t!==void 0?t:this.items_.length;this.items_.splice(i,0,e),this.cache_.add(e);const s=this.extract_(e);s&&(s.emitter.on("add",this.onSubListAdd_),s.emitter.on("remove",this.onSubListRemove_),s.allItems().forEach(r=>{this.cache_.add(r)})),this.emitter.emit("add",{index:i,item:e,root:this,target:this})}remove(e){const t=this.items_.indexOf(e);if(t<0)return;this.items_.splice(t,1),this.cache_.delete(e);const i=this.extract_(e);i&&(i.allItems().forEach(s=>{this.cache_.delete(s)}),i.emitter.off("add",this.onSubListAdd_),i.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:t,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}}function lm(n,e){for(let t=0;t!s.viewProps.get("hidden")),t=e[0],i=e[e.length-1];this.bcSet_.items.forEach(s=>{const r=[];s===t&&(r.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&r.push("veryfirst")),s===i&&(r.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&r.push("verylast")),s.blade.set("positions",r)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(t=>t.viewProps.get("disposed")).forEach(t=>{this.bcSet_.remove(t)})}onChildValueChange_(e){const t=lm(this.find(xn),e.sender);if(!t)throw H.alreadyDisposed();this.emitter.emit("valuechange",{bladeController:t,options:e.options,sender:this})}onRackLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onRackValueChange_(e){this.emitter.emit("valuechange",{bladeController:e.bladeController,options:e.options,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class Vs{constructor(e){this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.element=e.element,this.viewProps=e.viewProps;const t=new pm({blade:e.root?void 0:e.blade,viewProps:e.viewProps});t.emitter.on("add",this.onRackAdd_),t.emitter.on("remove",this.onRackRemove_),this.rack=t,this.viewProps.handleDispose(()=>{for(let i=this.rack.children.length-1;i>=0;i--)this.rack.children[i].viewProps.set("disposed",!0)})}onRackAdd_(e){e.root&&ga(this.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.root&&xs(e.bladeController.view.element)}}function Ea(){return new d({positions:S([],{equals:Zh})})}class Lt extends d{constructor(e){super(e)}static create(e){const t={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},i=d.createCore(t);return new Lt(i)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!E(e)?`${e}px`:"auto"}bindExpandedClass(e,t){const i=()=>{this.styleExpanded?e.classList.add(t):e.classList.remove(t)};ce(this,"expanded",i),ce(this,"temporaryExpanded",i)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function um(n,e){let t=0;return Id(e,()=>{n.set("expandedHeight",null),n.set("temporaryExpanded",!0),An(e),t=e.clientHeight,n.set("temporaryExpanded",null),An(e)}),t}function Tr(n,e){e.style.height=n.styleHeight}function Yn(n,e){n.value("expanded").emitter.on("beforechange",()=>{if(n.set("completed",!1),E(n.get("expandedHeight"))){const t=um(n,e);t>0&&n.set("expandedHeight",t)}n.set("shouldFixHeight",!0),An(e)}),n.emitter.on("change",()=>{Tr(n,e)}),Tr(n,e),e.addEventListener("transitionend",t=>{t.propertyName==="height"&&n.cleanUpTransition()})}class hm extends Es{constructor(e,t){super(e,t),this.emitter_=new z,this.controller.foldable.value("expanded").emitter.on("change",i=>{this.emitter_.emit("fold",new Od(this,i.sender.rawValue))}),this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)})}get expanded(){return this.controller.foldable.get("expanded")}set expanded(e){this.controller.foldable.set("expanded",e)}get title(){return this.controller.props.get("title")}set title(e){this.controller.props.set("title",e)}get children(){return this.rackApi_.children}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){return this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}refresh(){this.rackApi_.refresh()}}const ka=m("cnt");class dm{constructor(e,t){var i;this.className_=m((i=t.viewName)!==null&&i!==void 0?i:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),ka()),t.viewProps.bindClassModifiers(this.element),this.foldable_=t.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),ce(this.foldable_,"completed",Ke(this.element,this.className_(void 0,"cpl")));const s=e.createElement("button");s.classList.add(this.className_("b")),ce(t.props,"title",c=>{E(c)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s;const r=e.createElement("div");r.classList.add(this.className_("i")),this.element.appendChild(r);const o=e.createElement("div");o.classList.add(this.className_("t")),Ps(t.props.value("title"),o),this.buttonElement.appendChild(o),this.titleElement=o;const a=e.createElement("div");a.classList.add(this.className_("m")),this.buttonElement.appendChild(a);const l=e.createElement("div");l.classList.add(this.className_("c")),this.element.appendChild(l),this.containerElement=l}}class Sr extends ks{constructor(e,t){var i;const s=Lt.create((i=t.expanded)!==null&&i!==void 0?i:!0),r=new dm(e,{foldable:s,props:t.props,viewName:t.root?"rot":void 0,viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Vs({blade:t.blade,element:r.containerElement,root:t.root,viewProps:t.viewProps}),view:r})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=t.props,this.foldable=s,Yn(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}importState(e){return de(e,t=>super.importState(t),t=>({expanded:t.required.boolean,title:t.optional.string}),t=>(this.foldable.set("expanded",t.expanded),this.props.set("title",t.title),!0))}exportState(){return me(()=>super.exportState(),{expanded:this.foldable.get("expanded"),title:this.props.get("title")})}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}$({id:"folder",type:"blade",accept(n){const e=L(n,t=>({title:t.required.string,view:t.required.constant("folder"),expanded:t.optional.boolean}));return e?{params:e}:null},controller(n){return new Sr(n.document,{blade:n.blade,expanded:n.params.expanded,props:d.fromObject({title:n.params.title}),viewProps:n.viewProps})},api(n){return n.controller instanceof Sr?new hm(n.controller,n.pool):null}});const mm=m("");function Lr(n,e){return Ke(n,mm(void 0,e))}class ke extends d{constructor(e){var t;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=sd(S(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var t,i,s;const r=e??{};return new ke(d.createCore({disabled:(t=r.disabled)!==null&&t!==void 0?t:!1,disposed:!1,hidden:(i=r.hidden)!==null&&i!==void 0?i:!1,parent:(s=r.parent)!==null&&s!==void 0?s:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){le(this.globalDisabled_,Lr(e,"disabled")),ce(this,"hidden",Lr(e,"hidden"))}bindDisabled(e){le(this.globalDisabled_,t=>{e.disabled=t})}bindTabIndex(e){le(this.globalDisabled_,t=>{e.tabIndex=t?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",t=>{t&&e()})}importState(e){this.set("disabled",e.disabled),this.set("hidden",e.hidden)}exportState(){return{disabled:this.get("disabled"),hidden:this.get("hidden")}}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var t;const i=e.previousRawValue;i==null||i.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(t=this.get("parent"))===null||t===void 0||t.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}const $r=m("tbp");class vm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add($r()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add($r("c")),this.element.appendChild(i),this.containerElement=i}}const Nt=m("tbi");class bm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Nt()),t.viewProps.bindClassModifiers(this.element),ce(t.props,"selected",r=>{r?this.element.classList.add(Nt(void 0,"sel")):this.element.classList.remove(Nt(void 0,"sel"))});const i=e.createElement("button");i.classList.add(Nt("b")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.buttonElement=i;const s=e.createElement("div");s.classList.add(Nt("t")),Ps(t.props.value("title"),s),this.buttonElement.appendChild(s),this.titleElement=s}}class fm{constructor(e,t){this.emitter=new z,this.onClick_=this.onClick_.bind(this),this.props=t.props,this.viewProps=t.viewProps,this.view=new bm(e,{props:t.props,viewProps:t.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class Mi extends ks{constructor(e,t){const i=new vm(e,{viewProps:t.viewProps});super(Object.assign(Object.assign({},t),{rackController:new Vs({blade:t.blade,element:i.containerElement,viewProps:t.viewProps}),view:i})),this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new fm(e,{props:t.itemProps,viewProps:ke.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.props=t.props,ce(this.props,"selected",s=>{this.itemController.props.set("selected",s),this.viewProps.set("hidden",!s)})}get itemController(){return this.ic_}importState(e){return de(e,t=>super.importState(t),t=>({selected:t.required.boolean,title:t.required.string}),t=>(this.ic_.props.set("selected",t.selected),this.ic_.props.set("title",t.title),!0))}exportState(){return me(()=>super.exportState(),{selected:this.ic_.props.get("selected"),title:this.ic_.props.get("title")})}onItemClick_(){this.props.set("selected",!0)}}class wm extends Es{constructor(e,t){super(e,t),this.emitter_=new z,this.onSelect_=this.onSelect_.bind(this),this.pool_=t,this.rackApi_.on("change",i=>{this.emitter_.emit("change",i)}),this.controller.tab.selectedIndex.emitter.on("change",this.onSelect_)}get pages(){return this.rackApi_.children}addPage(e){const t=this.controller.view.element.ownerDocument,i=new Mi(t,{blade:Ea(),itemProps:d.fromObject({selected:!1,title:e.title}),props:d.fromObject({selected:!1}),viewProps:ke.create()}),s=this.pool_.createApi(i);return this.rackApi_.add(s,e.index)}removePage(e){this.rackApi_.remove(this.rackApi_.children[e])}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s)}),this}onSelect_(e){this.emitter_.emit("select",new Rd(this,e.rawValue))}}class _m extends Es{get title(){var e;return(e=this.controller.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller.itemController.props.set("title",e)}get selected(){return this.controller.props.get("selected")}set selected(e){this.controller.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,t){this.rackApi_.add(e,t)}remove(e){this.rackApi_.remove(e)}addBinding(e,t,i){return this.rackApi_.addBinding(e,t,i)}addBlade(e){return this.rackApi_.addBlade(e)}refresh(){this.rackApi_.refresh()}}const Ar=-1;class gm{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=S(!0),this.selectedIndex=S(Ar),this.items_=[]}add(e,t){const i=t??this.items_.length;this.items_.splice(i,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const t=this.items_.indexOf(e);t<0||(this.items_.splice(t,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=Ar,this.empty.rawValue=!0;return}const e=this.items_.findIndex(t=>t.rawValue);e<0?(this.items_.forEach((t,i)=>{t.rawValue=i===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((t,i)=>{t.rawValue=i===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const t=this.items_.findIndex(i=>i===e.sender);this.items_.forEach((i,s)=>{i.rawValue=s===t}),this.selectedIndex.rawValue=t}else this.keepSelection_()}}const jt=m("tab");class Cm{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(jt(),ka()),t.viewProps.bindClassModifiers(this.element),le(t.empty,Ke(this.element,jt(void 0,"nop")));const i=e.createElement("div");i.classList.add(jt("t")),this.element.appendChild(i),this.itemsElement=i;const s=e.createElement("div");s.classList.add(jt("i")),this.element.appendChild(s);const r=e.createElement("div");r.classList.add(jt("c")),this.element.appendChild(r),this.contentsElement=r}}class Mr extends ks{constructor(e,t){const i=new gm,s=new Cm(e,{empty:i.empty,viewProps:t.viewProps});super({blade:t.blade,rackController:new Vs({blade:t.blade,element:s.contentsElement,viewProps:t.viewProps}),view:s}),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const r=this.rackController.rack;r.emitter.on("add",this.onRackAdd_),r.emitter.on("remove",this.onRackRemove_),this.tab=i}add(e,t){this.rackController.rack.add(e,t)}remove(e){this.rackController.rack.remove(this.rackController.rack.children[e])}onRackAdd_(e){if(!e.root)return;const t=e.bladeController;ga(this.view.itemsElement,t.itemController.view.element,e.index),t.itemController.viewProps.set("parent",this.viewProps),this.tab.add(t.props.value("selected"))}onRackRemove_(e){if(!e.root)return;const t=e.bladeController;xs(t.itemController.view.element),t.itemController.viewProps.set("parent",null),this.tab.remove(t.props.value("selected"))}}$({id:"tab",type:"blade",accept(n){const e=L(n,t=>({pages:t.required.array(t.required.object({title:t.required.string})),view:t.required.constant("tab")}));return!e||e.pages.length===0?null:{params:e}},controller(n){const e=new Mr(n.document,{blade:n.blade,viewProps:n.viewProps});return n.params.pages.forEach(t=>{const i=new Mi(n.document,{blade:Ea(),itemProps:d.fromObject({selected:!1,title:t.title}),props:d.fromObject({selected:!1}),viewProps:ke.create()});e.add(i)}),e},api(n){return n.controller instanceof Mr?new wm(n.controller,n.pool):n.controller instanceof Mi?new _m(n.controller,n.pool):null}});class Ts extends Cs{get options(){return this.controller.valueController.props.get("options")}set options(e){this.controller.valueController.props.set("options",e)}}class xm{constructor(){this.disabled=!1,this.emitter=new z}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class ym{constructor(e,t){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new z,this.interval_=t,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class $t{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((t,i)=>i.constrain(t),e)}}function tn(n,e){if(n instanceof e)return n;if(n instanceof $t){const t=n.constraints.reduce((i,s)=>i||(s instanceof e?s:null),null);if(t)return t}return null}class Xn{constructor(e){this.values=d.fromObject({options:e})}constrain(e){const t=this.values.get("options");return t.length===0||t.filter(s=>s.value===e).length>0?e:t[0].value}}function Qn(n){var e;const t=$i;if(Array.isArray(n))return(e=L({items:n},i=>({items:i.required.array(i.required.object({text:i.required.string,value:i.required.raw}))})))===null||e===void 0?void 0:e.items;if(typeof n=="object")return t.required.raw(n).value}function Va(n){if(Array.isArray(n))return n;const e=[];return Object.keys(n).forEach(t=>{e.push({text:t,value:n[t]})}),e}function Ss(n){return E(n)?null:new Xn(Va(n))}const pi=m("lst");class Pm{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.element=e.createElement("div"),this.element.classList.add(pi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("select");i.classList.add(pi("s")),t.viewProps.bindDisabled(i),this.element.appendChild(i),this.selectElement=i;const s=e.createElement("div");s.classList.add(pi("m")),s.appendChild(Gn(e,"dropdown")),this.element.appendChild(s),t.value.emitter.on("change",this.onValueChange_),this.value_=t.value,ce(this.props_,"options",r=>{Ca(this.selectElement),r.forEach(o=>{const a=e.createElement("option");a.textContent=o.text,this.selectElement.appendChild(a)}),this.update_()})}update_(){const e=this.props_.get("options").map(t=>t.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class Pt{constructor(e,t){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new Pm(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const t=e.currentTarget;this.value.rawValue=this.props.get("options")[t.selectedIndex].value}importProps(e){return de(e,null,t=>({options:t.required.custom(Qn)}),t=>(this.props.set("options",Va(t.options)),!0))}exportProps(){return me(null,{options:this.props.get("options")})}}const Or=m("pop");class Em{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Or()),t.viewProps.bindClassModifiers(this.element),le(t.shows,Ke(this.element,Or(void 0,"v")))}}class Ls{constructor(e,t){this.shows=S(!1),this.viewProps=t.viewProps,this.view=new Em(e,{shows:this.shows,viewProps:this.viewProps})}}const Rr=m("txt");class km{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Rr()),t.viewProps.bindClassModifiers(this.element),this.props_=t.props,this.props_.emitter.on("change",this.onChange_);const i=e.createElement("input");i.classList.add(Rr("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onChange_),this.value_=t.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}}class Zn{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=t.parser,this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new km(e,{props:t.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);E(s)||(this.value.rawValue=s),this.view.refresh()}}function Vm(n){return String(n)}function $s(n){return n==="false"?!1:!!n}function Dr(n){return Vm(n)}function Tm(n){return e=>n.reduce((t,i)=>t!==null?t:i(e),null)}const Sm=j(0);function On(n){return Sm(n)+"%"}function As(n){return String(n)}function Oi(n){return n}function ct({primary:n,secondary:e,forward:t,backward:i}){let s=!1;function r(o){s||(s=!0,o(),s=!1)}n.emitter.on("change",o=>{r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),e.emitter.on("change",o=>{r(()=>{n.setRawValue(i(n.rawValue,e.rawValue),o.options)}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),o.options)})}),r(()=>{e.setRawValue(t(n.rawValue,e.rawValue),{forceEmit:!1,last:!0})})}function D(n,e){const t=n*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+t:e.downKey?-t:0}function nt(n){return{altKey:n.altKey,downKey:n.key==="ArrowDown",shiftKey:n.shiftKey,upKey:n.key==="ArrowUp"}}function he(n){return{altKey:n.altKey,downKey:n.key==="ArrowLeft",shiftKey:n.shiftKey,upKey:n.key==="ArrowRight"}}function Lm(n){return n==="ArrowUp"||n==="ArrowDown"}function Rn(n){return Lm(n)||n==="ArrowLeft"||n==="ArrowRight"}function ui(n,e){var t,i;const s=e.ownerDocument.defaultView,r=e.getBoundingClientRect();return{x:n.pageX-(((t=s&&s.scrollX)!==null&&t!==void 0?t:0)+r.left),y:n.pageY-(((i=s&&s.scrollY)!==null&&i!==void 0?i:0)+r.top)}}class Ve{constructor(e){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=e,this.emitter=new z,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const t=this.elem_.getBoundingClientRect();return{bounds:{width:t.width,height:t.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var t;e.preventDefault(),(t=e.currentTarget)===null||t===void 0||t.focus();const i=this.elem_.ownerDocument;i.addEventListener("mousemove",this.onDocumentMouseMove_),i.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(ui(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(ui(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const t=this.elem_.ownerDocument;t.removeEventListener("mousemove",this.onDocumentMouseMove_),t.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(ui(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchMove_(e){const t=e.targetTouches.item(0),i=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(t?{x:t.clientX-i.left,y:t.clientY-i.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=t}onTouchEnd_(e){var t;const i=(t=e.targetTouches.item(0))!==null&&t!==void 0?t:this.lastTouch_,s=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(i?{x:i.clientX-s.left,y:i.clientY-s.top}:void 0),sender:this,shiftKey:e.shiftKey})}}const ie=m("txt");class $m{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(ie(),ie(void 0,"num")),t.arrayPosition&&this.element.classList.add(ie(void 0,t.arrayPosition)),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(ie("i")),i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=t.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(ie()),this.inputElement.classList.add(ie("i"));const s=e.createElement("div");s.classList.add(ie("k")),this.element.appendChild(s),this.knobElement=s;const r=e.createElementNS(R,"svg");r.classList.add(ie("g")),this.knobElement.appendChild(r);const o=e.createElementNS(R,"path");o.classList.add(ie("gb")),r.appendChild(o),this.guideBodyElem_=o;const a=e.createElementNS(R,"path");a.classList.add(ie("gh")),r.appendChild(a),this.guideHeadElem_=a;const l=e.createElement("div");l.classList.add(m("tt")()),this.knobElement.appendChild(l),this.tooltipElem_=l,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(ie(void 0,"drg"));return}this.element.classList.add(ie(void 0,"drg"));const t=e.rawValue/this.props_.get("pointerScale"),i=t+(t>0?-1:t<0?1:0),s=V(-i,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${i+s},0 L${i},4 L${i+s},8`,`M ${t},-1 L${t},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${t},4`);const r=this.props_.get("formatter");this.tooltipElem_.textContent=r(this.value.rawValue),this.tooltipElem_.style.left=`${t}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}}class vn{constructor(e,t){var i;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.parser_=t.parser,this.props=t.props,this.sliderProps_=(i=t.sliderProps)!==null&&i!==void 0?i:null,this.value=t.value,this.viewProps=t.viewProps,this.dragging_=S(null),this.view=new $m(e,{arrayPosition:t.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const s=new Ve(this.view.knobElement);s.emitter.on("down",this.onPointerDown_),s.emitter.on("move",this.onPointerMove_),s.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var t,i;const s=(t=this.sliderProps_)===null||t===void 0?void 0:t.get("min"),r=(i=this.sliderProps_)===null||i===void 0?void 0:i.get("max");let o=e;return s!==void 0&&(o=Math.max(o,s)),r!==void 0&&(o=Math.min(o,r)),o}onInputChange_(e){const i=e.currentTarget.value,s=this.parser_(i);E(s)||(this.value.rawValue=this.constrainValue_(s)),this.view.refresh()}onInputKeyDown_(e){const t=D(this.props.get("keyScale"),nt(e));t!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+t),{forceEmit:!1,last:!1})}onInputKeyUp_(e){D(this.props.get("keyScale"),nt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const t=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+t*this.props.get("pointerScale"))}onPointerMove_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const t=this.computeDraggingValue_(e.data);t!==null&&(this.value.setRawValue(t,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const hi=m("sld");class Am{constructor(e,t){this.onChange_=this.onChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(hi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(hi("t")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(hi("k")),this.trackElement.appendChild(s),this.knobElement=s,t.value.emitter.on("change",this.onChange_),this.value=t.value,this.update_()}update_(){const e=V(h(this.value.rawValue,this.props_.get("min"),this.props_.get("max"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}}class Mm{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.props=t.props,this.view=new Am(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){e.point&&this.value.setRawValue(h(V(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("min"),this.props.get("max")),t)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=D(this.props.get("keyScale"),he(e));t!==0&&this.value.setRawValue(this.value.rawValue+t,{forceEmit:!1,last:!1})}onKeyUp_(e){D(this.props.get("keyScale"),he(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const di=m("sldtxt");class Om{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(di());const i=e.createElement("div");i.classList.add(di("s")),this.sliderView_=t.sliderView,i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(di("t")),this.textView_=t.textView,s.appendChild(this.textView_.element),this.element.appendChild(s)}}class Br{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sliderC_=new Mm(e,{props:t.sliderProps,value:t.value,viewProps:this.viewProps}),this.textC_=new vn(e,{parser:t.parser,props:t.textProps,sliderProps:t.sliderProps,value:t.value,viewProps:t.viewProps}),this.view=new Om(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}importProps(e){return de(e,null,t=>({max:t.required.number,min:t.required.number}),t=>{const i=this.sliderC_.props;return i.set("max",t.max),i.set("min",t.min),!0})}exportProps(){const e=this.sliderC_.props;return me(null,{max:e.get("max"),min:e.get("min")})}}function Rm(n){return{sliderProps:new d({keyScale:n.keyScale,max:n.max,min:n.min}),textProps:new d({formatter:S(n.formatter),keyScale:n.keyScale,pointerScale:S(n.pointerScale)})}}const Dm={containerUnitSize:"cnt-usz"};function Ta(n){return`--${Dm[n]}`}class Sa{constructor(e,t){const i=m(t.viewName);this.element=e.createElement("div"),this.element.classList.add(i()),t.viewProps.bindClassModifiers(this.element)}}function nn(n){return _s(n)}function Ne(n){if(Li(n))return L(n,nn)}function xe(n,e){if(!n)return;const t=[],i=bs(n,e);i&&t.push(i);const s=fs(n);return s&&t.push(s),new $t(t)}function La(n){if(n==="inline"||n==="popup")return n}function qe(n,e){n.write(e)}const _n=m("ckb");class Bm{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(_n()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(_n("l")),this.element.appendChild(i);const s=e.createElement("input");s.classList.add(_n("i")),s.type="checkbox",i.appendChild(s),this.inputElement=s,t.viewProps.bindDisabled(this.inputElement);const r=e.createElement("div");r.classList.add(_n("w")),i.appendChild(r);const o=Gn(e,"check");r.appendChild(o),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class Nm{constructor(e,t){this.onInputChange_=this.onInputChange_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Bm(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const t=e.currentTarget;this.value.rawValue=t.checked}}function jm(n){const e=[],t=Ss(n.options);return t&&e.push(t),new $t(e)}$({id:"input-bool",type:"input",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=L(e,i=>({options:i.optional.custom(Qn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>$s,constraint:n=>jm(n.params),writer:n=>qe},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&tn(i,Xn);return s?new Pt(e,{props:new d({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Nm(e,{value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="boolean"?null:n.controller.valueController instanceof Pt?new Ts(n.controller):null}});const He=m("col");class Im{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(He()),t.foldable.bindExpandedClass(this.element,He(void 0,"expanded")),ce(t.foldable,"completed",Ke(this.element,He(void 0,"cpl")));const i=e.createElement("div");i.classList.add(He("h")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(He("s")),i.appendChild(s),this.swatchElement=s;const r=e.createElement("div");if(r.classList.add(He("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(He("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}function Fm(n,e,t){const i=V(n/255,0,1),s=V(e/255,0,1),r=V(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c=0,p=0;const u=(a+o)/2;return l!==0&&(p=l/(1-Math.abs(o+a-1)),i===o?c=(s-r)/l:s===o?c=2+(r-i)/l:c=4+(i-s)/l,c=c/6+(c<0?1:0)),[c*360,p*100,u*100]}function zm(n,e,t){const i=(n%360+360)%360,s=V(e/100,0,1),r=V(t/100,0,1),o=(1-Math.abs(2*r-1))*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o/2;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function Km(n,e,t){const i=V(n/255,0,1),s=V(e/255,0,1),r=V(t/255,0,1),o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a;let c;l===0?c=0:o===i?c=60*(((s-r)/l%6+6)%6):o===s?c=60*((r-i)/l+2):c=60*((i-s)/l+4);const p=o===0?0:l/o,u=o;return[c,p*100,u*100]}function $a(n,e,t){const i=wa(n,360),s=V(e/100,0,1),r=V(t/100,0,1),o=r*s,a=o*(1-Math.abs(i/60%2-1)),l=r-o;let c,p,u;return i>=0&&i<60?[c,p,u]=[o,a,0]:i>=60&&i<120?[c,p,u]=[a,o,0]:i>=120&&i<180?[c,p,u]=[0,o,a]:i>=180&&i<240?[c,p,u]=[0,a,o]:i>=240&&i<300?[c,p,u]=[a,0,o]:[c,p,u]=[o,0,a],[(c+l)*255,(p+l)*255,(u+l)*255]}function qm(n,e,t){const i=t+e*(100-Math.abs(2*t-100))/200;return[n,i!==0?e*(100-Math.abs(2*t-100))/i:0,t+e*(100-Math.abs(2*t-100))/(2*100)]}function Um(n,e,t){const i=100-Math.abs(t*(200-e)/100-100);return[n,i!==0?e*t/i:0,t*(200-e)/(2*100)]}function we(n){return[n[0],n[1],n[2]]}function Jn(n,e){return[n[0],n[1],n[2],e]}const Hm={hsl:{hsl:(n,e,t)=>[n,e,t],hsv:qm,rgb:zm},hsv:{hsl:Um,hsv:(n,e,t)=>[n,e,t],rgb:$a},rgb:{hsl:Fm,hsv:Km,rgb:(n,e,t)=>[n,e,t]}};function Et(n,e){return[e==="float"?1:n==="rgb"?255:360,e==="float"?1:n==="rgb"?255:100,e==="float"?1:n==="rgb"?255:100]}function Gm(n,e){return n===e?e:wa(n,e)}function Aa(n,e,t){var i;const s=Et(e,t);return[e==="rgb"?V(n[0],0,s[0]):Gm(n[0],s[0]),V(n[1],0,s[1]),V(n[2],0,s[2]),V((i=n[3])!==null&&i!==void 0?i:1,0,1)]}function Nr(n,e,t,i){const s=Et(e,t),r=Et(e,i);return n.map((o,a)=>o/s[a]*r[a])}function Ma(n,e,t){const i=Nr(n,e.mode,e.type,"int"),s=Hm[e.mode][t.mode](...i);return Nr(s,t.mode,"int",t.type)}class w{static black(){return new w([0,0,0],"rgb")}constructor(e,t){this.type="int",this.mode=t,this.comps_=Aa(e,t,this.type)}getComponents(e){return Jn(Ma(we(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}}const Ae=m("colp");class Wm{constructor(e,t){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(Ae()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Ae("hsv"));const s=e.createElement("div");s.classList.add(Ae("sv")),this.svPaletteView_=t.svPaletteView,s.appendChild(this.svPaletteView_.element),i.appendChild(s);const r=e.createElement("div");r.classList.add(Ae("h")),this.hPaletteView_=t.hPaletteView,r.appendChild(this.hPaletteView_.element),i.appendChild(r),this.element.appendChild(i);const o=e.createElement("div");if(o.classList.add(Ae("rgb")),this.textsView_=t.textsView,o.appendChild(this.textsView_.element),this.element.appendChild(o),t.alphaViews){this.alphaViews_={palette:t.alphaViews.palette,text:t.alphaViews.text};const a=e.createElement("div");a.classList.add(Ae("a"));const l=e.createElement("div");l.classList.add(Ae("ap")),l.appendChild(this.alphaViews_.palette.element),a.appendChild(l);const c=e.createElement("div");c.classList.add(Ae("at")),c.appendChild(this.alphaViews_.text.element),a.appendChild(c),this.element.appendChild(a)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textsView_.modeSelectElement,...this.textsView_.inputViews.map(t=>t.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}}function Ym(n){return n==="int"?"int":n==="float"?"float":void 0}function Ms(n){return L(n,e=>({color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(Ym)}),expanded:e.optional.boolean,picker:e.optional.custom(La),readonly:e.optional.constant(!1)}))}function it(n){return n?.1:1}function Oa(n){var e;return(e=n.color)===null||e===void 0?void 0:e.type}class Os{constructor(e,t){this.type="float",this.mode=t,this.comps_=Aa(e,t,this.type)}getComponents(e){return Jn(Ma(we(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:this.type}),this.comps_[3])}toRgbaObject(){const e=this.getComponents("rgb");return{r:e[0],g:e[1],b:e[2],a:e[3]}}}const Xm={int:(n,e)=>new w(n,e),float:(n,e)=>new Os(n,e)};function Rs(n,e,t){return Xm[t](n,e)}function Qm(n){return n.type==="float"}function Zm(n){return n.type==="int"}function Jm(n){const e=n.getComponents(),t=Et(n.mode,"int");return new w([Math.round(h(e[0],0,1,0,t[0])),Math.round(h(e[1],0,1,0,t[1])),Math.round(h(e[2],0,1,0,t[2])),e[3]],n.mode)}function ev(n){const e=n.getComponents(),t=Et(n.mode,"int");return new Os([h(e[0],0,t[0],0,1),h(e[1],0,t[1],0,1),h(e[2],0,t[2],0,1),e[3]],n.mode)}function W(n,e){if(n.type===e)return n;if(Zm(n)&&e==="float")return ev(n);if(Qm(n)&&e==="int")return Jm(n);throw H.shouldNeverHappen()}function tv(n,e){return n.alpha===e.alpha&&n.mode===e.mode&&n.notation===e.notation&&n.type===e.type}function oe(n,e){const t=n.match(/^(.+)%$/);return Math.min(t?parseFloat(t[1])*.01*e:parseFloat(n),e)}const nv={deg:n=>n,grad:n=>n*360/400,rad:n=>n*360/(2*Math.PI),turn:n=>n*360};function Ra(n){const e=n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(n);const t=parseFloat(e[1]),i=e[2];return nv[i](t)}function Da(n){const e=n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[oe(e[1],255),oe(e[2],255),oe(e[3],255)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function iv(n){const e=Da(n);return e?new w(e,"rgb"):null}function Ba(n){const e=n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[oe(e[1],255),oe(e[2],255),oe(e[3],255),oe(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function sv(n){const e=Ba(n);return e?new w(e,"rgb"):null}function Na(n){const e=n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Ra(e[1]),oe(e[2],100),oe(e[3],100)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function rv(n){const e=Na(n);return e?new w(e,"hsl"):null}function ja(n){const e=n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const t=[Ra(e[1]),oe(e[2],100),oe(e[3],100),oe(e[4],1)];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function ov(n){const e=ja(n);return e?new w(e,"hsl"):null}function Ia(n){const e=n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const t=n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function av(n){const e=Ia(n);return e?new w(e,"rgb"):null}function Fa(n){const e=n.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),h(parseInt(e[4]+e[4],16),0,255,0,1)];const t=n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),h(parseInt(t[4],16),0,255,0,1)]:null}function lv(n){const e=Fa(n);return e?new w(e,"rgb"):null}function za(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])?null:t}function jr(n){return e=>{const t=za(e);return t?Rs(t,"rgb",n):null}}function Ka(n){const e=n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const t=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(t[0])||isNaN(t[1])||isNaN(t[2])||isNaN(t[3])?null:t}function Ir(n){return e=>{const t=Ka(e);return t?Rs(t,"rgb",n):null}}const cv=[{parser:Ia,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:Fa,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:Da,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:Ba,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:Na,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:ja,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:za,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:Ka,result:{alpha:!0,mode:"rgb",notation:"object"}}];function pv(n){return cv.reduce((e,{parser:t,result:i})=>e||(t(n)?i:null),null)}function uv(n,e="int"){const t=pv(n);return t?t.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},t),{type:"int"}):t.notation==="func"?Object.assign(Object.assign({},t),{type:e}):null:null}function bn(n){const e=[av,lv,iv,sv,rv,ov];n==="int"&&e.push(jr("int"),Ir("int")),n==="float"&&e.push(jr("float"),Ir("float"));const t=Tm(e);return i=>{const s=t(i);return s?W(s,n):null}}function hv(n){const e=bn("int");if(typeof n!="string")return w.black();const t=e(n);return t??w.black()}function qa(n){const e=V(Math.floor(n),0,255).toString(16);return e.length===1?`0${e}`:e}function Ds(n,e="#"){const t=we(n.getComponents("rgb")).map(qa).join("");return`${e}${t}`}function Bs(n,e="#"){const t=n.getComponents("rgb"),i=[t[0],t[1],t[2],t[3]*255].map(qa).join("");return`${e}${i}`}function Ua(n){const e=j(0),t=W(n,"int");return`rgb(${we(t.getComponents("rgb")).map(s=>e(s)).join(", ")})`}function yn(n){const e=j(2),t=j(0);return`rgba(${W(n,"int").getComponents("rgb").map((r,o)=>(o===3?e:t)(r)).join(", ")})`}function dv(n){const e=[j(0),On,On],t=W(n,"int");return`hsl(${we(t.getComponents("hsl")).map((s,r)=>e[r](s)).join(", ")})`}function mv(n){const e=[j(0),On,On,j(2)];return`hsla(${W(n,"int").getComponents("hsl").map((s,r)=>e[r](s)).join(", ")})`}function Ha(n,e){const t=j(e==="float"?2:0),i=["r","g","b"],s=W(n,e);return`{${we(s.getComponents("rgb")).map((o,a)=>`${i[a]}: ${t(o)}`).join(", ")}}`}function vv(n){return e=>Ha(e,n)}function Ga(n,e){const t=j(2),i=j(e==="float"?2:0),s=["r","g","b","a"];return`{${W(n,e).getComponents("rgb").map((a,l)=>{const c=l===3?t:i;return`${s[l]}: ${c(a)}`}).join(", ")}}`}function bv(n){return e=>Ga(e,n)}const fv=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:Ds},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:Bs},{format:{alpha:!1,mode:"rgb",notation:"func",type:"int"},stringifier:Ua},{format:{alpha:!0,mode:"rgb",notation:"func",type:"int"},stringifier:yn},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:dv},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:mv},...["int","float"].reduce((n,e)=>[...n,{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:vv(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:bv(e)}],[])];function Wa(n){return fv.reduce((e,t)=>e||(tv(t.format,n)?t.stringifier:null),null)}const It=m("apl");class wv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(It()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(It("b")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(It("c")),i.appendChild(s),this.colorElem_=s;const r=e.createElement("div");r.classList.add(It("m")),this.element.appendChild(r),this.markerElem_=r;const o=e.createElement("div");o.classList.add(It("p")),this.markerElem_.appendChild(o),this.previewElem_=o,this.update_()}update_(){const e=this.value.rawValue,t=e.getComponents("rgb"),i=new w([t[0],t[1],t[2],0],"rgb"),s=new w([t[0],t[1],t[2],255],"rgb"),r=["to right",yn(i),yn(s)];this.colorElem_.style.background=`linear-gradient(${r.join(",")})`,this.previewElem_.style.backgroundColor=yn(e);const o=h(t[3],0,1,0,100);this.markerElem_.style.left=`${o}%`}onValueChange_(){this.update_()}}class _v{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new wv(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=e.point.x/e.bounds.width,s=this.value.rawValue,[r,o,a]=s.getComponents("hsv");this.value.setRawValue(new w([r,o,a,i],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=D(it(!0),he(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new w([s,r,o,a+t],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){D(it(!0),he(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const ht=m("coltxt");function gv(n){const e=n.createElement("select"),t=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"},{text:"HEX",value:"hex"}];return e.appendChild(t.reduce((i,s)=>{const r=n.createElement("option");return r.textContent=s.text,r.value=s.value,i.appendChild(r),i},n.createDocumentFragment())),e}class Cv{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(ht()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(ht("m")),this.modeElem_=gv(e),this.modeElem_.classList.add(ht("ms")),i.appendChild(this.modeSelectElement),t.viewProps.bindDisabled(this.modeElem_);const s=e.createElement("div");s.classList.add(ht("mm")),s.appendChild(Gn(e,"dropdown")),i.appendChild(s),this.element.appendChild(i);const r=e.createElement("div");r.classList.add(ht("w")),this.element.appendChild(r),this.inputsElem_=r,this.inputViews_=t.inputViews,this.applyInputViews_(),le(t.mode,o=>{this.modeElem_.value=o})}get modeSelectElement(){return this.modeElem_}get inputViews(){return this.inputViews_}set inputViews(e){this.inputViews_=e,this.applyInputViews_()}applyInputViews_(){Ca(this.inputsElem_);const e=this.element.ownerDocument;this.inputViews_.forEach(t=>{const i=e.createElement("div");i.classList.add(ht("c")),i.appendChild(t.element),this.inputsElem_.appendChild(i)})}}function xv(n){return j(n==="float"?2:0)}function yv(n,e,t){const i=Et(n,e)[t];return new dn({min:0,max:i})}function Pv(n,e,t){return new vn(n,{arrayPosition:t===0?"fst":t===2?"lst":"mid",parser:e.parser,props:d.fromObject({formatter:xv(e.colorType),keyScale:it(!1),pointerScale:e.colorType==="float"?.01:1}),value:S(0,{constraint:yv(e.colorMode,e.colorType,t)}),viewProps:e.viewProps})}function Ev(n,e){const t={colorMode:e.colorMode,colorType:e.colorType,parser:ue,viewProps:e.viewProps};return[0,1,2].map(i=>{const s=Pv(n,t,i);return ct({primary:e.value,secondary:s.value,forward(r){return W(r,e.colorType).getComponents(e.colorMode)[i]},backward(r,o){const a=e.colorMode,c=W(r,e.colorType).getComponents(a);c[i]=o;const p=Rs(Jn(we(c),c[3]),a,e.colorType);return W(p,"int")}}),s})}function kv(n,e){const t=new Zn(n,{parser:bn("int"),props:d.fromObject({formatter:Ds}),value:S(w.black()),viewProps:e.viewProps});return ct({primary:e.value,secondary:t.value,forward:i=>new w(we(i.getComponents()),i.mode),backward:(i,s)=>new w(Jn(we(s.getComponents(i.mode)),i.getComponents()[3]),i.mode)}),[t]}function Vv(n){return n!=="hex"}class Tv{constructor(e,t){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=t.colorType,this.value=t.value,this.viewProps=t.viewProps,this.colorMode=S(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new Cv(e,{mode:this.colorMode,inputViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(e){const t=this.colorMode.rawValue;return Vv(t)?Ev(e,{colorMode:t,colorType:this.colorType_,value:this.value,viewProps:this.viewProps}):kv(e,{value:this.value,viewProps:this.viewProps})}onModeSelectChange_(e){const t=e.currentTarget;this.colorMode.rawValue=t.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.inputViews=this.ccs_.map(i=>i.view)}}const mi=m("hpl");class Sv{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(mi()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(mi("c")),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(mi("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=this.value.rawValue,[t]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=Ua(new w([t,100,100],"hsv"));const i=h(t,0,360,0,100);this.markerElem_.style.left=`${i}%`}onValueChange_(){this.update_()}}class Lv{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.view=new Sv(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=h(V(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),s=this.value.rawValue,[,r,o,a]=s.getComponents("hsv");this.value.setRawValue(new w([i,r,o,a],"hsv"),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const t=D(it(!1),he(e));if(t===0)return;const i=this.value.rawValue,[s,r,o,a]=i.getComponents("hsv");this.value.setRawValue(new w([s+t,r,o,a],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){D(it(!1),he(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const vi=m("svp"),Fr=64;class $v{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),this.value=t.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(vi()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("canvas");i.height=Fr,i.width=Fr,i.classList.add(vi("c")),this.element.appendChild(i),this.canvasElement=i;const s=e.createElement("div");s.classList.add(vi("m")),this.element.appendChild(s),this.markerElem_=s,this.update_()}update_(){const e=Fd(this.canvasElement);if(!e)return;const i=this.value.rawValue.getComponents("hsv"),s=this.canvasElement.width,r=this.canvasElement.height,o=e.getImageData(0,0,s,r),a=o.data;for(let p=0;pi.getComponents()[3],backward:(i,s)=>{const r=i.getComponents();return r[3]=s,new w(r,i.mode)}}),this.textsC_=new Tv(e,{colorType:t.colorType,value:this.value,viewProps:this.viewProps}),this.view=new Wm(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:t.supportsAlpha,svPaletteView:this.svPaletteC_.view,textsView:this.textsC_.view,viewProps:this.viewProps})}get textsController(){return this.textsC_}}const bi=m("colsw");class Ov{constructor(e,t){this.onValueChange_=this.onValueChange_.bind(this),t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.element=e.createElement("div"),this.element.classList.add(bi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(bi("sw")),this.element.appendChild(i),this.swatchElem_=i;const s=e.createElement("button");s.classList.add(bi("b")),t.viewProps.bindDisabled(s),this.element.appendChild(s),this.buttonElement=s,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=Bs(e)}onValueChange_(){this.update_()}}class Rv{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Ov(e,{value:this.value,viewProps:this.viewProps})}}class Ns{constructor(e,t){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Lt.create(t.expanded),this.swatchC_=new Rv(e,{value:this.value,viewProps:this.viewProps});const i=this.swatchC_.view.buttonElement;i.addEventListener("blur",this.onButtonBlur_),i.addEventListener("click",this.onButtonClick_),this.textC_=new Zn(e,{parser:t.parser,props:d.fromObject({formatter:t.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new Im(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=t.pickerLayout==="popup"?new Ls(e,{viewProps:this.viewProps}):null;const s=new Mv(e,{colorType:t.colorType,supportsAlpha:t.supportsAlpha,value:this.value,viewProps:this.viewProps});s.view.allFocusableElements.forEach(r=>{r.addEventListener("blur",this.onPopupChildBlur_),r.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=s,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(s.view.element),ct({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:r=>r,backward:(r,o)=>o})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Yn(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=ys(e);i&&t.contains(i)||i&&i===this.swatchC_.view.buttonElement&&!Hn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function Dv(n){return we(n.getComponents("rgb")).reduce((e,t)=>e<<8|Math.floor(t)&255,0)}function Bv(n){return n.getComponents("rgb").reduce((e,t,i)=>{const s=Math.floor(i===3?t*255:t)&255;return e<<8|s},0)>>>0}function Nv(n){return new w([n>>16&255,n>>8&255,n&255],"rgb")}function jv(n){return new w([n>>24&255,n>>16&255,n>>8&255,h(n&255,0,255,0,1)],"rgb")}function Iv(n){return typeof n!="number"?w.black():Nv(n)}function Fv(n){return typeof n!="number"?w.black():jv(n)}function Pn(n,e){return typeof n!="object"||E(n)?!1:e in n&&typeof n[e]=="number"}function Ya(n){return Pn(n,"r")&&Pn(n,"g")&&Pn(n,"b")}function Xa(n){return Ya(n)&&Pn(n,"a")}function Qa(n){return Ya(n)}function js(n,e){if(n.mode!==e.mode||n.type!==e.type)return!1;const t=n.getComponents(),i=e.getComponents();for(let s=0;s{qe(t,e(i))}:null}function Kv(n){const e=n?Bv:Dv;return(t,i)=>{qe(t,e(i))}}function qv(n,e,t){const s=W(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b),n.writeProperty("a",s.a)}function Uv(n,e,t){const s=W(e,t).toRgbaObject();n.writeProperty("r",s.r),n.writeProperty("g",s.g),n.writeProperty("b",s.b)}function Hv(n,e){return(t,i)=>{n?qv(t,i,e):Uv(t,i,e)}}function Gv(n){var e;return!!(!((e=n==null?void 0:n.color)===null||e===void 0)&&e.alpha)}function Wv(n){return n?e=>Bs(e,"0x"):e=>Ds(e,"0x")}function Yv(n){return"color"in n||n.view==="color"}$({id:"input-color-number",type:"input",accept:(n,e)=>{if(typeof n!="number"||!Yv(e))return null;const t=Ms(e);return t?{initialValue:n,params:Object.assign(Object.assign({},t),{supportsAlpha:Gv(e)})}:null},binding:{reader:n=>n.params.supportsAlpha?Fv:Iv,equals:js,writer:n=>Kv(n.params.supportsAlpha)},controller:n=>{var e,t;return new Ns(n.document,{colorType:"int",expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Wv(n.params.supportsAlpha),parser:bn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.supportsAlpha,value:n.value,viewProps:n.viewProps})}});function Xv(n,e){if(!Qa(n))return W(w.black(),e);if(e==="int"){const t=zr(n);return new w(t,"rgb")}if(e==="float"){const t=zr(n);return new Os(t,"rgb")}return W(w.black(),"int")}function Qv(n){return Xa(n)}function Zv(n){return e=>{const t=Xv(e,n);return W(t,"int")}}function Jv(n,e){return t=>n?Ga(t,e):Ha(t,e)}$({id:"input-color-object",type:"input",accept:(n,e)=>{var t;if(!Qa(n))return null;const i=Ms(e);return i?{initialValue:n,params:Object.assign(Object.assign({},i),{colorType:(t=Oa(e))!==null&&t!==void 0?t:"int"})}:null},binding:{reader:n=>Zv(n.params.colorType),equals:js,writer:n=>Hv(Qv(n.initialValue),n.params.colorType)},controller:n=>{var e,t;const i=Xa(n.initialValue);return new Ns(n.document,{colorType:n.params.colorType,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:Jv(i,n.params.colorType),parser:bn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:i,value:n.value,viewProps:n.viewProps})}});$({id:"input-color-string",type:"input",accept:(n,e)=>{if(typeof n!="string"||e.view==="text")return null;const t=uv(n,Oa(e));if(!t)return null;const i=Wa(t);if(!i)return null;const s=Ms(e);return s?{initialValue:n,params:Object.assign(Object.assign({},s),{format:t,stringifier:i})}:null},binding:{reader:()=>hv,equals:js,writer:n=>{const e=zv(n.params.format);if(!e)throw H.notBindable();return e}},controller:n=>{var e,t;return new Ns(n.document,{colorType:n.params.format.type,expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,formatter:n.params.stringifier,parser:bn("int"),pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",supportsAlpha:n.params.format.alpha,value:n.value,viewProps:n.viewProps})}});class ei{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const t=this.asm_.toComponents(e).map((i,s)=>{var r,o;return(o=(r=this.components[s])===null||r===void 0?void 0:r.constrain(i))!==null&&o!==void 0?o:i});return this.asm_.fromComponents(t)}}const Kr=m("pndtxt");class eb{constructor(e,t){this.textViews=t.textViews,this.element=e.createElement("div"),this.element.classList.add(Kr()),this.textViews.forEach(i=>{const s=e.createElement("div");s.classList.add(Kr("a")),s.appendChild(i.element),this.element.appendChild(s)})}}function tb(n,e,t){return new vn(n,{arrayPosition:t===0?"fst":t===e.axes.length-1?"lst":"mid",parser:e.parser,props:e.axes[t].textProps,value:S(0,{constraint:e.axes[t].constraint}),viewProps:e.viewProps})}class At{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.acs_=t.axes.map((i,s)=>tb(e,t,s)),this.acs_.forEach((i,s)=>{ct({primary:this.value,secondary:i.value,forward:r=>t.assembly.toComponents(r)[s],backward:(r,o)=>{const a=t.assembly.toComponents(r);return a[s]=o,t.assembly.fromComponents(a)}})}),this.view=new eb(e,{textViews:this.acs_.map(i=>i.view)})}get textControllers(){return this.acs_}}class nb extends Cs{get max(){return this.controller.valueController.sliderController.props.get("max")}set max(e){this.controller.valueController.sliderController.props.set("max",e)}get min(){return this.controller.valueController.sliderController.props.get("min")}set min(e){this.controller.valueController.sliderController.props.set("min",e)}}function ib(n,e){const t=[],i=bs(n,e);i&&t.push(i);const s=fs(n);s&&t.push(s);const r=Ss(n.options);return r&&t.push(r),new $t(t)}$({id:"input-number",type:"input",accept:(n,e)=>{if(typeof n!="number")return null;const t=L(e,i=>Object.assign(Object.assign({},_s(i)),{options:i.optional.custom(Qn),readonly:i.optional.constant(!1)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>vs,constraint:n=>ib(n.params,n.initialValue),writer:n=>qe},controller:n=>{const e=n.value,t=n.constraint,i=t&&tn(t,Xn);if(i)return new Pt(n.document,{props:new d({options:i.values.value("options")}),value:e,viewProps:n.viewProps});const s=ws(n.params,e.rawValue),r=t&&tn(t,dn);return r?new Br(n.document,Object.assign(Object.assign({},Rm(Object.assign(Object.assign({},s),{keyScale:S(s.keyScale),max:r.values.value("max"),min:r.values.value("min")}))),{parser:ue,value:e,viewProps:n.viewProps})):new vn(n.document,{parser:ue,props:d.fromObject(s),value:e,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="number"?null:n.controller.valueController instanceof Br?new nb(n.controller):n.controller.valueController instanceof Pt?new Ts(n.controller):null}});class Ie{constructor(e=0,t=0){this.x=e,this.y=t}getComponents(){return[this.x,this.y]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y}toObject(){return{x:this.x,y:this.y}}}const Za={toComponents:n=>n.getComponents(),fromComponents:n=>new Ie(...n)},dt=m("p2d");class sb{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(dt()),t.viewProps.bindClassModifiers(this.element),le(t.expanded,Ke(this.element,dt(void 0,"expanded")));const i=e.createElement("div");i.classList.add(dt("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(dt("b")),s.appendChild(Gn(e,"p2dpad")),t.viewProps.bindDisabled(s),i.appendChild(s),this.buttonElement=s;const r=e.createElement("div");if(r.classList.add(dt("t")),i.appendChild(r),this.textElement=r,t.pickerLayout==="inline"){const o=e.createElement("div");o.classList.add(dt("p")),this.element.appendChild(o),this.pickerElement=o}else this.pickerElement=null}}const Me=m("p2dp");class rb{constructor(e,t){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onPropsChange_=this.onPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.props_=t.props,this.props_.emitter.on("change",this.onPropsChange_),this.element=e.createElement("div"),this.element.classList.add(Me()),t.layout==="popup"&&this.element.classList.add(Me(void 0,"p")),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(Me("p")),t.viewProps.bindTabIndex(i),this.element.appendChild(i),this.padElement=i;const s=e.createElementNS(R,"svg");s.classList.add(Me("g")),this.padElement.appendChild(s),this.svgElem_=s;const r=e.createElementNS(R,"line");r.classList.add(Me("ax")),r.setAttributeNS(null,"x1","0"),r.setAttributeNS(null,"y1","50%"),r.setAttributeNS(null,"x2","100%"),r.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(r);const o=e.createElementNS(R,"line");o.classList.add(Me("ax")),o.setAttributeNS(null,"x1","50%"),o.setAttributeNS(null,"y1","0"),o.setAttributeNS(null,"x2","50%"),o.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(o);const a=e.createElementNS(R,"line");a.classList.add(Me("l")),a.setAttributeNS(null,"x1","50%"),a.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(a),this.lineElem_=a;const l=e.createElement("div");l.classList.add(Me("m")),this.padElement.appendChild(l),this.markerElem_=l,t.value.emitter.on("change",this.onValueChange_),this.value=t.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,t]=this.value.rawValue.getComponents(),i=this.props_.get("max"),s=h(e,-i,+i,0,100),r=h(t,-i,+i,0,100),o=this.props_.get("invertsY")?100-r:r;this.lineElem_.setAttributeNS(null,"x2",`${s}%`),this.lineElem_.setAttributeNS(null,"y2",`${o}%`),this.markerElem_.style.left=`${s}%`,this.markerElem_.style.top=`${o}%`}onValueChange_(){this.update_()}onPropsChange_(){this.update_()}onFoldableChange_(){this.update_()}}function qr(n,e,t){return[D(e[0],he(n)),D(e[1],nt(n))*(t?1:-1)]}class ob{constructor(e,t){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.view=new rb(e,{layout:t.layout,props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ve(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(e,t){if(!e.point)return;const i=this.props.get("max"),s=h(e.point.x,0,e.bounds.width,-i,+i),r=h(this.props.get("invertsY")?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-i,+i);this.value.setRawValue(new Ie(s,r),t)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){Rn(e.key)&&e.preventDefault();const[t,i]=qr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(new Ie(this.value.rawValue.x+t,this.value.rawValue.y+i),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[t,i]=qr(e,[this.props.get("xKeyScale"),this.props.get("yKeyScale")],this.props.get("invertsY"));t===0&&i===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class ab{constructor(e,t){var i,s;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Lt.create(t.expanded),this.popC_=t.pickerLayout==="popup"?new Ls(e,{viewProps:this.viewProps}):null;const r=new ob(e,{layout:t.pickerLayout,props:new d({invertsY:S(t.invertsY),max:S(t.max),xKeyScale:t.axes[0].textProps.value("keyScale"),yKeyScale:t.axes[1].textProps.value("keyScale")}),value:this.value,viewProps:this.viewProps});r.view.allFocusableElements.forEach(o=>{o.addEventListener("blur",this.onPopupChildBlur_),o.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=r,this.textC_=new At(e,{assembly:Za,axes:t.axes,parser:t.parser,value:this.value,viewProps:this.viewProps}),this.view=new sb(e,{expanded:this.foldable_.value("expanded"),pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(i=this.view.buttonElement)===null||i===void 0||i.addEventListener("blur",this.onPadButtonBlur_),(s=this.view.buttonElement)===null||s===void 0||s.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),ct({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:o=>o,backward:(o,a)=>a})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Yn(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onPadButtonBlur_(e){if(!this.popC_)return;const t=this.view.element,i=e.relatedTarget;(!i||!t.contains(i))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=ys(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!Hn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}}function lb(n){return Ie.isObject(n)?new Ie(n.x,n.y):new Ie}function cb(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y)}function pb(n,e){return new ei({assembly:Za,components:[xe(Object.assign(Object.assign({},n),n.x),e.x),xe(Object.assign(Object.assign({},n),n.y),e.y)]})}function Ur(n,e){var t,i;if(!E(n.min)||!E(n.max))return Math.max(Math.abs((t=n.min)!==null&&t!==void 0?t:0),Math.abs((i=n.max)!==null&&i!==void 0?i:0));const s=_a(n);return Math.max(Math.abs(s)*10,Math.abs(e)*10)}function ub(n,e){var t,i;const s=Ur(tt(n,(t=n.x)!==null&&t!==void 0?t:{}),e.x),r=Ur(tt(n,(i=n.y)!==null&&i!==void 0?i:{}),e.y);return Math.max(s,r)}function hb(n){if(!("y"in n))return!1;const e=n.y;return e&&"inverted"in e?!!e.inverted:!1}$({id:"input-point2d",type:"input",accept:(n,e)=>{if(!Ie.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},nn(i)),{expanded:i.optional.boolean,picker:i.optional.custom(La),readonly:i.optional.constant(!1),x:i.optional.custom(Ne),y:i.optional.object(Object.assign(Object.assign({},nn(i)),{inverted:i.optional.boolean}))}));return t?{initialValue:n,params:t}:null},binding:{reader:()=>lb,constraint:n=>pb(n.params,n.initialValue),equals:Ie.equals,writer:()=>cb},controller:n=>{var e,t;const i=n.document,s=n.value,r=n.constraint,o=[n.params.x,n.params.y];return new ab(i,{axes:s.rawValue.getComponents().map((a,l)=>{var c;return gs({constraint:r.components[l],initialValue:a,params:tt(n.params,(c=o[l])!==null&&c!==void 0?c:{})})}),expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,invertsY:hb(n.params),max:ub(n.params,s.rawValue),parser:ue,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps})}});class Ct{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y,s=e.z;return!(typeof t!="number"||typeof i!="number"||typeof s!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const Ja={toComponents:n=>n.getComponents(),fromComponents:n=>new Ct(...n)};function db(n){return Ct.isObject(n)?new Ct(n.x,n.y,n.z):new Ct}function mb(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z)}function vb(n,e){return new ei({assembly:Ja,components:[xe(Object.assign(Object.assign({},n),n.x),e.x),xe(Object.assign(Object.assign({},n),n.y),e.y),xe(Object.assign(Object.assign({},n),n.z),e.z)]})}$({id:"input-point3d",type:"input",accept:(n,e)=>{if(!Ct.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},nn(i)),{readonly:i.optional.constant(!1),x:i.optional.custom(Ne),y:i.optional.custom(Ne),z:i.optional.custom(Ne)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>db,constraint:n=>vb(n.params,n.initialValue),equals:Ct.equals,writer:n=>mb},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z];return new At(n.document,{assembly:Ja,axes:e.rawValue.getComponents().map((s,r)=>{var o;return gs({constraint:t.components[r],initialValue:s,params:tt(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:ue,value:e,viewProps:n.viewProps})}});class xt{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(E(e))return!1;const t=e.x,i=e.y,s=e.z,r=e.w;return!(typeof t!="number"||typeof i!="number"||typeof s!="number"||typeof r!="number")}static equals(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const el={toComponents:n=>n.getComponents(),fromComponents:n=>new xt(...n)};function bb(n){return xt.isObject(n)?new xt(n.x,n.y,n.z,n.w):new xt}function fb(n,e){n.writeProperty("x",e.x),n.writeProperty("y",e.y),n.writeProperty("z",e.z),n.writeProperty("w",e.w)}function wb(n,e){return new ei({assembly:el,components:[xe(Object.assign(Object.assign({},n),n.x),e.x),xe(Object.assign(Object.assign({},n),n.y),e.y),xe(Object.assign(Object.assign({},n),n.z),e.z),xe(Object.assign(Object.assign({},n),n.w),e.w)]})}$({id:"input-point4d",type:"input",accept:(n,e)=>{if(!xt.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},nn(i)),{readonly:i.optional.constant(!1),w:i.optional.custom(Ne),x:i.optional.custom(Ne),y:i.optional.custom(Ne),z:i.optional.custom(Ne)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>bb,constraint:n=>wb(n.params,n.initialValue),equals:xt.equals,writer:n=>fb},controller:n=>{const e=n.value,t=n.constraint,i=[n.params.x,n.params.y,n.params.z,n.params.w];return new At(n.document,{assembly:el,axes:e.rawValue.getComponents().map((s,r)=>{var o;return gs({constraint:t.components[r],initialValue:s,params:tt(n.params,(o=i[r])!==null&&o!==void 0?o:{})})}),parser:ue,value:e,viewProps:n.viewProps})}});function _b(n){const e=[],t=Ss(n.options);return t&&e.push(t),new $t(e)}$({id:"input-string",type:"input",accept:(n,e)=>{if(typeof n!="string")return null;const t=L(e,i=>({readonly:i.optional.constant(!1),options:i.optional.custom(Qn)}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>As,constraint:n=>_b(n.params),writer:n=>qe},controller:n=>{const e=n.document,t=n.value,i=n.constraint,s=i&&tn(i,Xn);return s?new Pt(e,{props:new d({options:s.values.value("options")}),value:t,viewProps:n.viewProps}):new Zn(e,{parser:r=>r,props:d.fromObject({formatter:Oi}),value:t,viewProps:n.viewProps})},api(n){return typeof n.controller.value.rawValue!="string"?null:n.controller.valueController instanceof Pt?new Ts(n.controller):null}});const fn={monitor:{defaultInterval:200,defaultRows:3}},Hr=m("mll");class gb{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(Hr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("textarea");i.classList.add(Hr("i")),i.style.height=`calc(var(${Ta("containerUnitSize")}) * ${t.rows})`,i.readOnly=!0,t.viewProps.bindDisabled(i),this.element.appendChild(i),this.textareaElem_=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.textareaElem_,t=e.scrollTop===e.scrollHeight-e.clientHeight,i=[];this.value.rawValue.forEach(s=>{s!==void 0&&i.push(this.formatter_(s))}),e.textContent=i.join(` +`),t&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}}class Is{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new gb(e,{formatter:t.formatter,rows:t.rows,value:this.value,viewProps:this.viewProps})}}const Gr=m("sgl");class Cb{constructor(e,t){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=t.formatter,this.element=e.createElement("div"),this.element.classList.add(Gr()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("input");i.classList.add(Gr("i")),i.readOnly=!0,i.type="text",t.viewProps.bindDisabled(i),this.element.appendChild(i),this.inputElement=i,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}update_(){const e=this.value.rawValue,t=e[e.length-1];this.inputElement.value=t!==void 0?this.formatter_(t):""}onValueUpdate_(){this.update_()}}class Fs{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new Cb(e,{formatter:t.formatter,value:this.value,viewProps:this.viewProps})}}$({id:"monitor-bool",type:"monitor",accept:(n,e)=>{if(typeof n!="boolean")return null;const t=L(e,i=>({readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>$s},controller:n=>{var e;return n.value.rawValue.length===1?new Fs(n.document,{formatter:Dr,value:n.value,viewProps:n.viewProps}):new Is(n.document,{formatter:Dr,rows:(e=n.params.rows)!==null&&e!==void 0?e:fn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}});class xb extends Cs{get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}}const Oe=m("grl");class yb{constructor(e,t){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Oe()),t.viewProps.bindClassModifiers(this.element),this.formatter_=t.formatter,this.props_=t.props,this.cursor_=t.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const i=e.createElementNS(R,"svg");i.classList.add(Oe("g")),i.style.height=`calc(var(${Ta("containerUnitSize")}) * ${t.rows})`,this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(R,"polyline");this.svgElem_.appendChild(s),this.lineElem_=s;const r=e.createElement("div");r.classList.add(Oe("t"),m("tt")()),this.element.appendChild(r),this.tooltipElem_=r,t.value.emitter.on("change",this.onValueUpdate_),this.value=t.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const e=this.svgElem_.getBoundingClientRect(),t=this.value.rawValue.length-1,i=this.props_.get("min"),s=this.props_.get("max"),r=[];this.value.rawValue.forEach((p,u)=>{if(p===void 0)return;const _=h(u,0,t,0,e.width),B=h(p,i,s,e.height,0);r.push([_,B].join(","))}),this.lineElem_.setAttributeNS(null,"points",r.join(" "));const o=this.tooltipElem_,a=this.value.rawValue[this.cursor_.rawValue];if(a===void 0){o.classList.remove(Oe("t","a"));return}const l=h(this.cursor_.rawValue,0,t,0,e.width),c=h(a,i,s,e.height,0);o.style.left=`${l}px`,o.style.top=`${c}px`,o.textContent=`${this.formatter_(a)}`,o.classList.contains(Oe("t","a"))||(o.classList.add(Oe("t","a"),Oe("t","in")),An(o),o.classList.remove(Oe("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class zs{constructor(e,t){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props=t.props,this.value=t.value,this.viewProps=t.viewProps,this.cursor_=S(-1),this.view=new yb(e,{cursor:this.cursor_,formatter:t.formatter,rows:t.rows,props:this.props,value:this.value,viewProps:this.viewProps}),!Hn(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const i=new Ve(this.view.element);i.emitter.on("down",this.onGraphPointerDown_),i.emitter.on("move",this.onGraphPointerMove_),i.emitter.on("up",this.onGraphPointerUp_)}}importProps(e){return de(e,null,t=>({max:t.required.number,min:t.required.number}),t=>(this.props.set("max",t.max),this.props.set("min",t.min),!0))}exportProps(){return me(null,{max:this.props.get("max"),min:this.props.get("min")})}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const t=this.view.element.getBoundingClientRect();this.cursor_.rawValue=Math.floor(h(e.offsetX,0,t.width,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(h(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function Ri(n){return E(n.format)?j(2):n.format}function Pb(n){var e;return n.value.rawValue.length===1?new Fs(n.document,{formatter:Ri(n.params),value:n.value,viewProps:n.viewProps}):new Is(n.document,{formatter:Ri(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:fn.monitor.defaultRows,value:n.value,viewProps:n.viewProps})}function Eb(n){var e,t,i;return new zs(n.document,{formatter:Ri(n.params),rows:(e=n.params.rows)!==null&&e!==void 0?e:fn.monitor.defaultRows,props:d.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:100,min:(i=n.params.min)!==null&&i!==void 0?i:0}),value:n.value,viewProps:n.viewProps})}function Wr(n){return n.view==="graph"}$({id:"monitor-number",type:"monitor",accept:(n,e)=>{if(typeof n!="number")return null;const t=L(e,i=>({format:i.optional.function,max:i.optional.number,min:i.optional.number,readonly:i.required.constant(!0),rows:i.optional.number,view:i.optional.string}));return t?{initialValue:n,params:t}:null},binding:{defaultBufferSize:n=>Wr(n)?64:1,reader:n=>vs},controller:n=>Wr(n.params)?Eb(n):Pb(n),api:n=>n.controller.valueController instanceof zs?new xb(n.controller):null});$({id:"monitor-string",type:"monitor",accept:(n,e)=>{if(typeof n!="string")return null;const t=L(e,i=>({multiline:i.optional.boolean,readonly:i.required.constant(!0),rows:i.optional.number}));return t?{initialValue:n,params:t}:null},binding:{reader:n=>As},controller:n=>{var e;const t=n.value;return t.rawValue.length>1||n.params.multiline?new Is(n.document,{formatter:Oi,rows:(e=n.params.rows)!==null&&e!==void 0?e:fn.monitor.defaultRows,value:t,viewProps:n.viewProps}):new Fs(n.document,{formatter:Oi,value:t,viewProps:n.viewProps})}});class tl{constructor(e){this.controller_=e}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get title(){var e;return(e=this.controller_.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.props.set("title",e)}on(e,t){const i=t.bind(this);return this.controller_.emitter.on(e,()=>{i(new lt(this))}),this}}class kb extends lt{constructor(e,t,i){super(e),this.cell=t,this.index=i}}class nl extends at{constructor(e){super(e),this.cellToApiMap_=new Map,this.emitter_=new z;const t=this.controller.valueController;t.cellControllers.forEach((i,s)=>{const r=new tl(i);this.cellToApiMap_.set(i,r),i.emitter.on("click",()=>{const o=s%t.size[0],a=Math.floor(s/t.size[0]);this.emitter_.emit("click",{event:new kb(this,r,[o,a])})})})}cell(e,t){const i=this.controller.valueController,s=i.cellControllers[t*i.size[0]+e];return this.cellToApiMap_.get(s)}on(e,t){const i=t.bind(this);return this.emitter_.on(e,s=>{i(s.event)}),this}}class il{constructor(e,t){this.size=t.size;const[i,s]=this.size,r=[];for(let o=0;o{this.cellCs_.forEach(o=>{o.viewProps.set("disposed",!0)})}),this.view=new Sa(e,{viewProps:this.viewProps,viewName:"btngrid"}),this.view.element.style.gridTemplateColumns=`repeat(${i}, 1fr)`,this.cellCs_.forEach(o=>{this.view.element.appendChild(o.view.element)})}get cellControllers(){return this.cellCs_}}class Yr extends mn{constructor(e,t){const i=t.valueController,s=new Wn(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:i.viewProps}),this.valueController=i,this.labelController=s}}const Vb=$({id:"buttongrid",type:"blade",accept(n){const e=L(n,t=>({cells:t.required.function,size:t.required.array(t.required.number),view:t.required.constant("buttongrid"),label:t.optional.string}));return e?{params:e}:null},controller(n){return new Yr(n.document,{blade:n.blade,labelProps:d.fromObject({label:n.params.label}),valueController:new il(n.document,{cellConfig:n.params.cells,size:n.params.size})})},api(n){return n.controller instanceof Yr?new nl(n.controller):null}});class sl extends at{get label(){return this.controller.labelController.props.get("label")}set label(e){this.controller.labelController.props.set("label",e)}get value(){return this.controller.valueController.value.rawValue}set value(e){this.controller.valueController.value.rawValue=e}on(e,t){const i=t.bind(this);return this.controller.valueController.value.emitter.on(e,s=>{i(new Un(this,s.rawValue,s.options.last))}),this}}function se(n,e,t){return n*(1-t)+e*t}const Tb=20,Sb=.001,fi=100;function Lb(n,e){let t=.25,i=.5,s=-1;for(let r=0;rn.toObject(),fromComponents:n=>new ze(...n)};function $b(n){const e=j(2);return`cubic-bezier(${n.toObject().map(i=>e(i)).join(", ")})`}const Xr=[0,.5,.5,1];function Ab(n){const e=n.match(/^cubic-bezier\s*\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*\)$/);if(!e)return new ze(...Xr);const t=[e[1],e[2],e[3],e[4]].reduce((i,s)=>{if(!i)return null;const r=Number(s);return isNaN(r)?null:[...i,r]},[]);return new ze(...t??Xr)}const Ge=m("cbz");class rl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ge()),t.viewProps.bindClassModifiers(this.element),t.foldable.bindExpandedClass(this.element,Ge(void 0,"expanded")),ce(t.foldable,"completed",Ke(this.element,Ge(void 0,"cpl")));const i=e.createElement("div");i.classList.add(Ge("h")),this.element.appendChild(i);const s=e.createElement("button");s.classList.add(Ge("b")),t.viewProps.bindDisabled(s);const r=e.createElementNS(R,"svg");r.innerHTML='',s.appendChild(r),i.appendChild(s),this.buttonElement=s;const o=e.createElement("div");if(o.classList.add(Ge("t")),i.appendChild(o),this.textElement=o,t.pickerLayout==="inline"){const a=e.createElement("div");a.classList.add(Ge("p")),this.element.appendChild(a),this.pickerElement=a}else this.pickerElement=null}}const wi=m("cbzp");class ol{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(wi()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("div");i.classList.add(wi("g")),this.element.appendChild(i),this.graphElement=i;const s=e.createElement("div");s.classList.add(wi("t")),this.element.appendChild(s),this.textElement=s}}function al(n,e){const t=new MutationObserver(s=>{for(const r of s)r.type==="childList"&&r.addedNodes.forEach(o=>{o.contains(o)&&(e(),t.disconnect())})}),i=n.ownerDocument;t.observe(i.body,{attributes:!0,childList:!0,subtree:!0})}const Re=m("cbzg");function Mb(n,e){return t=>e(n(t))}class ll{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Re()),t.viewProps.bindClassModifiers(this.element),t.viewProps.bindTabIndex(this.element);const i=e.createElement("div");i.classList.add(Re("p")),this.element.appendChild(i),this.previewElement=i;const s=e.createElementNS(R,"svg");s.classList.add(Re("g")),this.element.appendChild(s),this.svgElem_=s;const r=e.createElementNS(R,"path");r.classList.add(Re("u")),this.svgElem_.appendChild(r),this.guideElem_=r;const o=e.createElementNS(R,"polyline");o.classList.add(Re("l")),this.svgElem_.appendChild(o),this.lineElem_=o,this.handleElems_=[e.createElement("div"),e.createElement("div")],this.handleElems_.forEach(a=>{a.classList.add(Re("h")),this.element.appendChild(a)}),this.vectorElems_=[e.createElementNS(R,"line"),e.createElementNS(R,"line")],this.vectorElems_.forEach(a=>{a.classList.add(Re("v")),this.svgElem_.appendChild(a)}),this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_.bind(this)),this.sel_=t.selection,this.handleElems_.forEach((a,l)=>{le(this.sel_,Mb(c=>c===l,Ke(a,Re("h","sel"))))}),al(this.element,()=>{this.refresh()})}getVertMargin_(e){return e*.25}valueToPosition(e,t){const{clientWidth:i,clientHeight:s}=this.element,r=this.getVertMargin_(s);return{x:h(e,0,1,0,i),y:h(t,0,1,s-r,r)}}positionToValue(e,t){const i=this.element.getBoundingClientRect(),s=i.width,r=i.height,o=this.getVertMargin_(r);return{x:V(h(e,0,s,0,1),0,1),y:h(t,r-o,o,0,1)}}refresh(){this.guideElem_.setAttributeNS(null,"d",[0,1].map(r=>{const o=this.valueToPosition(0,r),a=this.valueToPosition(1,r);return[`M ${o.x},${o.y}`,`L ${a.x},${a.y}`].join(" ")}).join(" "));const e=this.value_.rawValue,t=[];let i=0;for(;;){const r=this.valueToPosition(...e.curve(i));if(t.push([r.x,r.y].join(",")),i>=1)break;i=Math.min(i+.05,1)}this.lineElem_.setAttributeNS(null,"points",t.join(" "));const s=e.toObject();[0,1].forEach(r=>{const o=this.valueToPosition(r,r),a=this.valueToPosition(s[r*2],s[r*2+1]),l=this.vectorElems_[r];l.setAttributeNS(null,"x1",String(o.x)),l.setAttributeNS(null,"y1",String(o.y)),l.setAttributeNS(null,"x2",String(a.x)),l.setAttributeNS(null,"y2",String(a.y));const c=this.handleElems_[r];c.style.left=`${a.x}px`,c.style.top=`${a.y}px`})}onValueChange_(){this.refresh()}}const Qr=24,Zr=400,Jr=1e3,mt=m("cbzprv");class cl{constructor(e,t){this.stopped_=!0,this.startTime_=-1,this.onDispose_=this.onDispose_.bind(this),this.onTimer_=this.onTimer_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(mt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElementNS(R,"svg");i.classList.add(mt("g")),this.element.appendChild(i),this.svgElem_=i;const s=e.createElementNS(R,"path");s.classList.add(mt("t")),this.svgElem_.appendChild(s),this.ticksElem_=s;const r=e.createElement("div");r.classList.add(mt("m")),this.element.appendChild(r),this.markerElem_=r,this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_),t.viewProps.handleDispose(this.onDispose_),al(this.element,()=>{this.refresh()})}play(){this.stop(),this.updateMarker_(0),this.markerElem_.classList.add(mt("m","a")),this.startTime_=new Date().getTime()+Zr,this.stopped_=!1,requestAnimationFrame(this.onTimer_)}stop(){this.stopped_=!0,this.markerElem_.classList.remove(mt("m","a"))}onDispose_(){this.stop()}updateMarker_(e){const t=this.value_.rawValue.y(V(e,0,1));this.markerElem_.style.left=`${t*100}%`}refresh(){const{clientWidth:e,clientHeight:t}=this.svgElem_,i=[],s=this.value_.rawValue;for(let r=0;rJr+Zr&&this.stop(),this.stopped_||requestAnimationFrame(this.onTimer_)}onValueChange_(){this.refresh(),this.play()}}function Di(n,e,t,i){const s=t-n,r=i-e;return Math.sqrt(s*s+r*r)}function Ob(n,e,t,i){const s=Di(n,e,t,i),r=Math.atan2(i-e,t-n),o=Math.round(r/(Math.PI/4))*Math.PI/4;return{x:n+Math.cos(o)*s,y:e+Math.sin(o)*s}}class pl{constructor(e,t){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.keyScale_=t.keyScale,this.value=t.value,this.sel_=S(0),this.viewProps=t.viewProps,this.view=new ll(e,{selection:this.sel_,value:this.value,viewProps:this.viewProps}),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_),this.prevView_=new cl(e,{value:this.value,viewProps:this.viewProps}),this.prevView_.element.addEventListener("mousedown",s=>{s.stopImmediatePropagation(),s.preventDefault(),this.prevView_.play()}),this.view.previewElement.appendChild(this.prevView_.element);const i=new Ve(this.view.element);i.emitter.on("down",this.onPointerDown_),i.emitter.on("move",this.onPointerMove_),i.emitter.on("up",this.onPointerUp_)}refresh(){this.view.refresh(),this.prevView_.refresh(),this.prevView_.play()}updateValue_(e,t,i){const s=this.sel_.rawValue,r=this.value.rawValue.toObject(),o=this.view.positionToValue(e.x,e.y),a=t?Ob(s,s,o.x,o.y):o;r[s*2]=a.x,r[s*2+1]=a.y,this.value.setRawValue(new ze(...r),i)}onPointerDown_(e){const t=e.data;if(!t.point)return;const i=this.value.rawValue,s=this.view.valueToPosition(i.x1,i.y1),r=Di(t.point.x,t.point.y,s.x,s.y),o=this.view.valueToPosition(i.x2,i.y2),a=Di(t.point.x,t.point.y,o.x,o.y);this.sel_.rawValue=r<=a?0:1,this.updateValue_(t.point,e.shiftKey,{forceEmit:!1,last:!1})}onPointerMove_(e){const t=e.data;t.point&&this.updateValue_(t.point,e.shiftKey,{forceEmit:!1,last:!1})}onPointerUp_(e){const t=e.data;t.point&&this.updateValue_(t.point,e.shiftKey,{forceEmit:!0,last:!0})}onKeyDown_(e){Rn(e.key)&&e.preventDefault();const t=this.sel_.rawValue,i=this.value.rawValue.toObject(),s=this.keyScale_.rawValue;i[t*2]+=D(s,he(e)),i[t*2+1]+=D(s,nt(e)),this.value.setRawValue(new ze(...i),{forceEmit:!1,last:!1})}onKeyUp_(e){Rn(e.key)&&e.preventDefault();const t=this.keyScale_.rawValue,i=D(t,he(e)),s=D(t,nt(e));i===0&&s===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class ul{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new ol(e,{viewProps:this.viewProps}),this.gc_=new pl(e,{keyScale:t.axis.textProps.value("keyScale"),value:this.value,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.gc_.view.element);const i=Object.assign(Object.assign({},t.axis),{constraint:new hs({max:1,min:0})}),s=Object.assign(Object.assign({},t.axis),{constraint:void 0});this.tc_=new At(e,{assembly:Ks,axes:[i,s,i,s],parser:ue,value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element)}get allFocusableElements(){return[this.gc_.view.element,...this.tc_.view.textViews.map(e=>e.inputElement)]}refresh(){this.gc_.refresh()}}class Bi{constructor(e,t){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=t.value,this.viewProps=t.viewProps,this.foldable_=Lt.create(t.expanded),this.view=new rl(e,{foldable:this.foldable_,pickerLayout:t.pickerLayout,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("blur",this.onButtonBlur_),this.view.buttonElement.addEventListener("click",this.onButtonClick_),this.tc_=new Zn(e,{parser:Ab,props:d.fromObject({formatter:$b}),value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element),this.popC_=t.pickerLayout==="popup"?new Ls(e,{viewProps:this.viewProps}):null;const i=new ul(e,{axis:t.axis,value:this.value,viewProps:this.viewProps});i.allFocusableElements.forEach(s=>{s.addEventListener("blur",this.onPopupChildBlur_),s.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=i,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),le(this.popC_.shows,s=>{s&&i.refresh()}),ct({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:s=>s,backward:(s,r)=>r})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Yn(this.foldable_,this.view.pickerElement))}onButtonBlur_(e){if(!this.popC_)return;const t=e.relatedTarget;(!t||!this.popC_.view.element.contains(t))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const t=this.popC_.view.element,i=ys(e);i&&t.contains(i)||i&&i===this.view.buttonElement&&!Hn(t.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_&&e.key==="Escape"&&(this.popC_.shows.rawValue=!1)}}function Rb(){return new ei({assembly:Ks,components:[0,1,2,3].map(n=>n%2===0?new hs({min:0,max:1}):void 0)})}const Db=$({id:"cubicbezier",type:"blade",accept(n){const e=L(n,t=>({value:t.required.array(t.required.number),view:t.required.constant("cubicbezier"),expanded:t.optional.boolean,label:t.optional.string,picker:t.optional.custom(i=>i==="inline"||i==="popup"?i:void 0)}));return e?{params:e}:null},controller(n){var e,t;const i=new ze(...n.params.value),s=S(i,{constraint:Rb(),equals:ze.equals}),r=new Bi(n.document,{axis:{textProps:d.fromObject({keyScale:.1,pointerScale:.01,formatter:j(2)})},expanded:(e=n.params.expanded)!==null&&e!==void 0?e:!1,pickerLayout:(t=n.params.picker)!==null&&t!==void 0?t:"popup",value:s,viewProps:n.viewProps});return new Mn(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:s,valueController:r})},api(n){return!(n.controller instanceof Mn)||!(n.controller.valueController instanceof Bi)?null:new sl(n.controller)}});class hl extends at{get fps(){return this.controller.valueController.fps}get max(){return this.controller.valueController.props.get("max")}set max(e){this.controller.valueController.props.set("max",e)}get min(){return this.controller.valueController.props.get("min")}set min(e){this.controller.valueController.props.set("min",e)}begin(){this.controller.valueController.begin()}end(){this.controller.valueController.end()}on(e,t){const i=t.bind(this);return this.controller.valueController.ticker.emitter.on(e,()=>{i(new lt(this))}),this}}const eo=20;class dl{constructor(){this.start_=null,this.duration_=0,this.fps_=null,this.frameCount_=0,this.timestamps_=[]}get duration(){return this.duration_}get fps(){return this.fps_}begin(e){this.start_=e.getTime()}calculateFps_(e){if(this.timestamps_.length===0)return null;const t=this.timestamps_[0];return 1e3*(this.frameCount_-t.frameCount)/(e-t.time)}compactTimestamps_(){if(this.timestamps_.length<=eo)return;const e=this.timestamps_.length-eo;this.timestamps_.splice(0,e);const t=this.timestamps_[0].frameCount;this.timestamps_.forEach(i=>{i.frameCount-=t}),this.frameCount_-=t}end(e){if(this.start_===null)return;const t=e.getTime();this.duration_=t-this.start_,this.start_=null,this.fps_=this.calculateFps_(t),this.timestamps_.push({frameCount:this.frameCount_,time:t}),++this.frameCount_,this.compactTimestamps_()}}const Ft=m("fps");class ml{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(Ft()),t.viewProps.bindClassModifiers(this.element),this.graphElement=e.createElement("div"),this.graphElement.classList.add(Ft("g")),this.element.appendChild(this.graphElement);const i=e.createElement("div");i.classList.add(Ft("l")),this.element.appendChild(i);const s=e.createElement("span");s.classList.add(Ft("v")),s.textContent="--",i.appendChild(s),this.valueElement=s;const r=e.createElement("span");r.classList.add(Ft("u")),r.textContent="FPS",i.appendChild(r)}}class vl{constructor(e,t){this.stopwatch_=new dl,this.onTick_=this.onTick_.bind(this),this.ticker=t.ticker,this.ticker.emitter.on("tick",this.onTick_),this.props=t.props,this.value_=t.value,this.viewProps=t.viewProps,this.view=new ml(e,{viewProps:this.viewProps}),this.graphC_=new zs(e,{formatter:j(0),props:this.props,rows:t.rows,value:this.value_,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.graphC_.view.element),this.viewProps.handleDispose(()=>{this.graphC_.viewProps.set("disposed",!0),this.ticker.dispose()})}get fps(){return this.stopwatch_.fps}begin(){this.stopwatch_.begin(new Date)}end(){this.stopwatch_.end(new Date)}onTick_(){const e=this.fps;if(e!==null){const t=this.value_.rawValue;this.value_.rawValue=Yd(t,e),this.view.valueElement.textContent=e.toFixed(0)}}}class to extends mn{constructor(e,t){const i=t.valueController,s=new Wn(e,{blade:t.blade,props:t.labelProps,valueController:i});super({blade:t.blade,view:s.view,viewProps:i.viewProps}),this.valueController=i,this.labelController=s}}function Bb(n,e){return e===0?new xm:new ym(n,e??fn.monitor.defaultInterval)}const Nb=$({id:"fpsgraph",type:"blade",accept(n){const e=L(n,t=>({view:t.required.constant("fpsgraph"),interval:t.optional.number,label:t.optional.string,rows:t.optional.number,max:t.optional.number,min:t.optional.number}));return e?{params:e}:null},controller(n){var e,t,i,s;const r=(e=n.params.interval)!==null&&e!==void 0?e:500;return new to(n.document,{blade:n.blade,labelProps:d.fromObject({label:n.params.label}),valueController:new vl(n.document,{props:d.fromObject({max:(t=n.params.max)!==null&&t!==void 0?t:90,min:(i=n.params.min)!==null&&i!==void 0?i:0}),rows:(s=n.params.rows)!==null&&s!==void 0?s:2,ticker:Bb(n.document,r),value:S(Gd(80)),viewProps:n.viewProps})})},api(n){return n.controller instanceof to?new hl(n.controller):null}});class J{constructor(e,t){this.min=e,this.max=t}static isObject(e){if(typeof e!="object"||e===null)return!1;const t=e.min,i=e.max;return!(typeof t!="number"||typeof i!="number")}static equals(e,t){return e.min===t.min&&e.max===t.max}get length(){return this.max-this.min}toObject(){return{min:this.min,max:this.max}}}const qs={fromComponents:n=>new J(n[0],n[1]),toComponents:n=>[n.min,n.max]};class Us{constructor(e){this.edge=e}constrain(e){var t,i,s,r,o,a,l,c;if(e.min<=e.max)return new J((i=(t=this.edge)===null||t===void 0?void 0:t.constrain(e.min))!==null&&i!==void 0?i:e.min,(r=(s=this.edge)===null||s===void 0?void 0:s.constrain(e.max))!==null&&r!==void 0?r:e.max);const p=(e.min+e.max)/2;return new J((a=(o=this.edge)===null||o===void 0?void 0:o.constrain(p))!==null&&a!==void 0?a:p,(c=(l=this.edge)===null||l===void 0?void 0:l.constrain(p))!==null&&c!==void 0?c:p)}}const _i=m("rsltxt");class bl{constructor(e,t){this.sliderView_=t.sliderView,this.textView_=t.textView,this.element=e.createElement("div"),this.element.classList.add(_i());const i=e.createElement("div");i.classList.add(_i("s")),i.appendChild(this.sliderView_.element),this.element.appendChild(i);const s=e.createElement("div");s.classList.add(_i("t")),s.appendChild(this.textView_.element),this.element.appendChild(s)}}const We=m("rsl");class fl{constructor(e,t){this.onSliderPropsChange_=this.onSliderPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.sliderProps_=t.sliderProps,this.sliderProps_.emitter.on("change",this.onSliderPropsChange_),this.element=e.createElement("div"),this.element.classList.add(We()),t.viewProps.bindClassModifiers(this.element),this.value_=t.value,this.value_.emitter.on("change",this.onValueChange_);const i=e.createElement("div");i.classList.add(We("t")),this.element.appendChild(i),this.trackElement=i;const s=e.createElement("div");s.classList.add(We("b")),i.appendChild(s),this.barElement=s;const r=["min","max"].map(o=>{const a=e.createElement("div");return a.classList.add(We("k"),We("k",o)),i.appendChild(a),a});this.knobElements=[r[0],r[1]],this.update_()}valueToX_(e){const t=this.sliderProps_.get("min"),i=this.sliderProps_.get("max");return V(h(e,t,i,0,1),0,1)*100}update_(){const e=this.value_.rawValue;e.length===0?this.element.classList.add(We(void 0,"zero")):this.element.classList.remove(We(void 0,"zero"));const t=[this.valueToX_(e.min),this.valueToX_(e.max)];this.barElement.style.left=`${t[0]}%`,this.barElement.style.right=`${100-t[1]}%`,this.knobElements.forEach((i,s)=>{i.style.left=`${t[s]}%`})}onSliderPropsChange_(){this.update_()}onValueChange_(){this.update_()}}class wl{constructor(e,t){this.grabbing_=null,this.grabOffset_=0,this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.sliderProps=t.sliderProps,this.viewProps=t.viewProps,this.value=t.value,this.view=new fl(e,{sliderProps:this.sliderProps,value:this.value,viewProps:t.viewProps});const i=new Ve(this.view.trackElement);i.emitter.on("down",this.onPointerDown_),i.emitter.on("move",this.onPointerMove_),i.emitter.on("up",this.onPointerUp_)}ofs_(){return this.grabbing_==="min"?this.view.knobElements[0].getBoundingClientRect().width/2:this.grabbing_==="max"?-this.view.knobElements[1].getBoundingClientRect().width/2:0}valueFromData_(e){if(!e.point)return null;const t=(e.point.x+this.ofs_())/e.bounds.width,i=this.sliderProps.get("min"),s=this.sliderProps.get("max");return h(t,0,1,i,s)}onPointerDown_(e){if(!e.data.point)return;const t=e.data.point.x/e.data.bounds.width,i=this.value.rawValue,s=this.sliderProps.get("min"),r=this.sliderProps.get("max"),o=h(i.min,s,r,0,1),a=h(i.max,s,r,0,1);Math.abs(a-t)<=.025?this.grabbing_="max":Math.abs(o-t)<=.025?this.grabbing_="min":t>=o&&t<=a?(this.grabbing_="length",this.grabOffset_=h(t-o,0,1,0,r-s)):ta&&(this.grabbing_="max",this.onPointerMove_(e))}applyPointToValue_(e,t){const i=this.valueFromData_(e);if(i===null)return;const s=this.sliderProps.get("min"),r=this.sliderProps.get("max");if(this.grabbing_==="min")this.value.setRawValue(new J(i,this.value.rawValue.max),t);else if(this.grabbing_==="max")this.value.setRawValue(new J(this.value.rawValue.min,i),t);else if(this.grabbing_==="length"){const o=this.value.rawValue.length;let a=i-this.grabOffset_,l=a+o;ar&&(a=r-o,l=r),this.value.setRawValue(new J(a,l),t)}}onPointerMove_(e){this.applyPointToValue_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.applyPointToValue_(e.data,{forceEmit:!0,last:!0}),this.grabbing_=null}}class _l{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.sc_=new wl(e,t);const i={constraint:t.constraint,textProps:t.textProps};this.tc_=new At(e,{assembly:qs,axes:[i,i],parser:t.parser,value:this.value,viewProps:t.viewProps}),this.view=new bl(e,{sliderView:this.sc_.view,textView:this.tc_.view})}get textController(){return this.tc_}}function jb(n){return J.isObject(n)?new J(n.min,n.max):new J(0,0)}function Ib(n,e){n.writeProperty("max",e.max),n.writeProperty("min",e.min)}function Fb(n){const e=[],t=fs(n);t&&e.push(t);const i=bs(n);return i&&e.push(i),new Us(new $t(e))}const zb=$({id:"input-interval",type:"input",accept:(n,e)=>{if(!J.isObject(n))return null;const t=L(e,i=>Object.assign(Object.assign({},_s(i)),{readonly:i.optional.constant(!1)}));return t?{initialValue:new J(n.min,n.max),params:t}:null},binding:{reader:n=>jb,constraint:n=>Fb(n.params),equals:J.equals,writer:n=>Ib},controller(n){const e=n.value,t=n.constraint;if(!(t instanceof Us))throw H.shouldNeverHappen();const i=(e.rawValue.min+e.rawValue.max)/2,s=d.fromObject(ws(n.params,i)),r=t.edge&&tn(t.edge,dn);if(r)return new _l(n.document,{constraint:t.edge,parser:ue,sliderProps:new d({keyScale:s.value("keyScale"),max:r.values.value("max"),min:r.values.value("min")}),textProps:s,value:e,viewProps:n.viewProps});const o={constraint:t.edge,textProps:s};return new At(n.document,{assembly:qs,axes:[o,o],parser:ue,value:e,viewProps:n.viewProps})}});class gl{constructor(e){this.controller_=e}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get title(){var e;return(e=this.controller_.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.props.set("title",e)}}class Cl extends Un{constructor(e,t,i,s,r){super(e,s,r),this.cell=t,this.index=i}}class xl extends at{constructor(e){super(e),this.cellToApiMap_=new Map,this.controller.valueController.cellControllers.forEach(i=>{const s=new gl(i);this.cellToApiMap_.set(i,s)})}get value(){return this.controller.value}cell(e,t){const i=this.controller.valueController,s=i.cellControllers[t*i.size[0]+e];return this.cellToApiMap_.get(s)}on(e,t){const i=t.bind(this);this.controller.value.emitter.on(e,s=>{const r=this.controller.valueController,o=r.findCellByValue(s.rawValue);if(!o)return;const a=this.cellToApiMap_.get(o);if(!a)return;const l=r.cellControllers.indexOf(o);i(new Cl(this,a,[l%r.size[0],Math.floor(l/r.size[0])],s.rawValue))})}}const zt=m("rad");class yl{constructor(e,t){this.element=e.createElement("div"),this.element.classList.add(zt()),t.viewProps.bindClassModifiers(this.element);const i=e.createElement("label");i.classList.add(zt("l")),this.element.appendChild(i);const s=e.createElement("input");s.classList.add(zt("i")),s.name=t.name,s.type="radio",t.viewProps.bindDisabled(s),i.appendChild(s),this.inputElement=s;const r=e.createElement("div");r.classList.add(zt("b")),i.appendChild(r);const o=e.createElement("div");o.classList.add(zt("t")),r.appendChild(o),ce(t.props,"title",a=>{o.textContent=a})}}class Pl{constructor(e,t){this.props=t.props,this.viewProps=t.viewProps,this.view=new yl(e,{name:t.name,props:this.props,viewProps:this.viewProps})}}class Dn{constructor(e,t){this.cellCs_=[],this.cellValues_=[],this.onCellInputChange_=this.onCellInputChange_.bind(this),this.size=t.size;const[i,s]=this.size;for(let r=0;r{const o=this.findCellByValue(r);o&&(o.view.inputElement.checked=!0)}),this.viewProps=ke.create(),this.view=new Sa(e,{viewProps:this.viewProps,viewName:"radgrid"}),this.view.element.style.gridTemplateColumns=`repeat(${i}, 1fr)`,this.cellCs_.forEach(r=>{r.view.inputElement.addEventListener("change",this.onCellInputChange_),this.view.element.appendChild(r.view.element)})}get cellControllers(){return this.cellCs_}findCellByValue(e){const t=this.cellValues_.findIndex(i=>i===e);return t<0?null:this.cellCs_[t]}onCellInputChange_(e){const t=e.currentTarget,i=this.cellCs_.findIndex(s=>s.view.inputElement===t);i<0||(this.value.rawValue=this.cellValues_[i])}}const Kb=function(){return $({id:"radiogrid",type:"blade",accept(n){const e=L(n,t=>({cells:t.required.function,groupName:t.required.string,size:t.required.array(t.required.number),value:t.required.raw,view:t.required.constant("radiogrid"),label:t.optional.string}));return e?{params:e}:null},controller(n){const e=S(n.params.value);return new Mn(n.document,{blade:n.blade,props:d.fromObject({label:n.params.label}),value:e,valueController:new Dn(n.document,{groupName:n.params.groupName,cellConfig:n.params.cells,size:n.params.size,value:e})})},api(n){return!(n.controller instanceof Mn)||!(n.controller.valueController instanceof Dn)?null:new xl(n.controller)}})}();function Hs(n){return $({id:"input-radiogrid",type:"input",accept(e,t){if(!n.isType(e))return null;const i=L(t,s=>({cells:s.required.function,groupName:s.required.string,size:s.required.array(s.required.number),view:s.required.constant("radiogrid")}));return i?{initialValue:e,params:i}:null},binding:n.binding,controller:e=>new Dn(e.document,{cellConfig:e.params.cells,groupName:e.params.groupName,size:e.params.size,value:e.value})})}const qb=Hs({isType:n=>typeof n=="number",binding:{reader:n=>vs,writer:n=>qe}}),Ub=Hs({isType:n=>typeof n=="string",binding:{reader:n=>As,writer:n=>qe}}),Hb=Hs({isType:n=>typeof n=="boolean",binding:{reader:n=>$s,writer:n=>qe}}),Gb="essentials",Wb='.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--bld-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--cnt-usz);line-height:var(--cnt-usz);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--bld-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--cnt-usz)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--cnt-usp);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1 * var(--cnt-hp));position:absolute;right:calc(-1 * var(--cnt-hp));top:var(--cnt-usz)}.tp-cbzpv_t{margin-top:var(--cnt-usp)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--cnt-usz) * 5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--cnt-usz));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--cnt-usz) - 8px);margin-top:calc((var(--cnt-usz) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--bld-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',Yb=[Vb,Db,Nb,zb,Kb,Hb,qb,Ub],Xb=Object.freeze(Object.defineProperty({__proto__:null,ButtonCellApi:tl,ButtonGridApi:nl,ButtonGridController:il,CubicBezier:ze,CubicBezierApi:sl,CubicBezierAssembly:Ks,CubicBezierController:Bi,CubicBezierGraphController:pl,CubicBezierGraphView:ll,CubicBezierPickerController:ul,CubicBezierPickerView:ol,CubicBezierPreviewView:cl,CubicBezierView:rl,FpsGraphBladeApi:hl,FpsGraphController:vl,FpsView:ml,Fpswatch:dl,Interval:J,IntervalAssembly:qs,IntervalConstraint:Us,RadioCellApi:gl,RadioController:Pl,RadioGridApi:xl,RadioGridController:Dn,RadioView:yl,RangeSliderController:wl,RangeSliderTextController:_l,RangeSliderTextView:bl,RangeSliderView:fl,TpRadioGridChangeEvent:Cl,css:Wb,id:Gb,plugins:Yb},Symbol.toStringTag,{value:"Module"})),qt=class qt{constructor(e){v(this,"pane");v(this,"settings");v(this,"sceneControls",{});this.game=e;const t=document.getElementById("settings");if(!t)throw new Error("No settings container found");this.pane=new Qh({title:"settings",expanded:!1,container:t}),this.pane.registerPlugin(Xb),this.pane.on("change",s=>{var o,a;const r=s.target.key;this.settings&&s.last&&r in this.settings&&((a=(o=this.settings).onChange)==null||a.call(o,{[r]:s.value}))}),e.events.on(Xe.sceneChange,s=>{this.deleteSettings(),this.settings=s,s&&this.addSettings(s)}),window.onerror=function(s,r,o,a,l){Q.error(` +`+s+" "+r+" "+o+" "+a+" "+l)},this.pane.addButton({title:"Show logs"}).on("click",()=>{i.hidden=!i.hidden});const i=this.pane.addBinding(qt.logsParams,"logs",{label:"",readonly:!0,multiline:!0,rows:10,hidden:!0,interval:1e3});this.resize()}static log(e){qt.logsParams.logs+=` +`+e}deleteSettings(){Object.values(this.sceneControls).filter(Boolean).forEach(e=>{e.dispose(),this.pane.remove(e)})}addSettings(e){this.sceneControls.deleteInstrument=this.pane.addButton({title:"Delete instrument & loop",index:0}).on("click",()=>ae.deleteCurrentInstrumentScene()),this.sceneControls.deleteLoop=this.pane.addButton({title:"Delete current loop",index:0}).on("click",()=>ae.deleteCurrentTrack()),e.noteDuration&&(this.sceneControls.noteDuration=this.pane.addBinding(e,"noteDuration",{label:"Note duration",min:.1,max:5,step:.1,index:0})),e.octaveRange&&(this.sceneControls.octaveRange=this.pane.addBinding(e,"octaveRange",{label:"Octave range",min:1,max:6,step:1,index:0})),this.sceneControls.volume=this.pane.addBinding(e,"volume",{min:0,max:100,step:1,index:0})}resize(){const e=Math.min(this.game.canvas.width,this.game.canvas.height),t=e/40+"px",i=e/10+"px";document.querySelectorAll("button").forEach(s=>{s.style.fontSize=t,s.style.height=i})}};v(qt,"logsParams",{logs:""});let Bn=qt;const gi=(n,e)=>{Bn.log(e.map(t=>t.toString()).join(", ")),console[n](...e)},Q={log:(n,...e)=>{gi("log",[n,...e])},error:(n,...e)=>{gi("error",[n,...e])},warn:(n,...e)=>{gi("warn",[n,...e])}},Qb=(n,e,t)=>{const i=[];for(let r=0;ri.map(a=>a[o]).reverse()).flat()};class Gs extends U.Scene{constructor(t,i){super();v(this,"pads",[]);v(this,"settings",{volume:50,onChange:t=>this.onSettingChange(t)});v(this,"canRecord",!0);v(this,"canPlay",!0);v(this,"sceneText","");v(this,"sceneTextColor",O.white);this.cols=t,this.rows=i}create({color:t,text:i}){this.sceneText=i,this.sceneTextColor=t,this.createPads(),this.game.events.emit(Xe.sceneChange,this.settings)}changePadNumber(t,i){this.cols=t,this.rows=i,this.scene.restart()}createPads(){const t=this.cols*this.rows;this.pads=new Array(t).fill(0).map((s,r)=>this.createPad(r,t));const i=()=>{const s=window.innerWidth{const B=_%r*a,N=Math.floor(_/r)*l,I=s?0:ae.sceneWidthHeight,Vl=s?ae.sceneWidthHeight:0;p.setSize(a,l).setPosition(I+B,Vl+N),u&&u.setPosition(p.getCenter().x,p.getCenter().y).setFontSize(Ht.tiny).setResolution(2)})};window.addEventListener("resize",i),i()}createPad(t,i){const s=this.getPadColor(i,t),r=this.getHitColor(i,t),o=this.getPadText(t),a=this.getBorderColor(t),l=this.add.rectangle().setFillStyle(s.color).setStrokeStyle(1,a.color,.8).setInteractive().setOrigin(0,0);let c;o&&(c=this.add.text(0,0,o.text,{fontFamily:Ut.Text,fontSize:Ht.tiny,color:o.color?kn(o.color):xi.white}).setAlpha(o.alpha??.5).setOrigin(.5,.5).setResolution(2).setPosition(l.getCenter().x,l.getCenter().y).setDepth(1));let p=!1;const u=()=>{p||(this.playSound(t),l.setFillStyle(r.color),this.game.events.emit(Xe.instrumentPlayed,{callback:()=>this.playSound(t),scene:this}),p=!0)},_=()=>{l.setFillStyle(s.color),p=!1};return l.on("pointerdown",B=>{var N,I;((I=(N=B.downElement)==null?void 0:N.tagName)==null?void 0:I.toLowerCase())==="canvas"&&u()}).on("pointermove",B=>{B.isDown&&u()}).on("pointerup",()=>_()).on("pointerout",()=>_()),{instrument:t,button:l,text:c}}getPadColor(t,i){return U.Display.Color.HSLToColor((t-i)/(t*1.5),1,.5)}getPadText(t){}onSettingChange(t){Q.log("Setting changed",JSON.stringify(t))}getHitColor(t,i){return this.getPadColor(t,i).brighten(40)}getBorderColor(t){return O.darkGrey}}let Kt=null,Ci=null;const no=()=>{Kt&&(Q.log("stopping note...",Kt),Kt.stop(),Ci.stop()),Q.log("testing note...");const n=22050,e=Freeverb({input:Bus2(),roomSize:.975,damping:.5}).connect(),t=Synth({gain:.15,attack:44,decay:5512,Q:.8,filterType:2,saturation:2,filterMult:3.25,antialias:!0,cutoff:Add(1,Sine({frequency:.1,gain:.75}))}).connect(Gibberish.output).connect(e.input,.5),i=[55,110,165,220];Ci=Sequencer.make([55,110,165,220],[n/4],t,"note").start(),Kt=Sequencer.make([i.map(s=>s*1.25),i.map(s=>s*1.25*.8),i.map(s=>s*1.25*.8*.8),i.map(s=>s*1.25*.8*.8*1.25)],[n*16],Ci,"values"),Kt.start()};class Zb extends Gs{constructor(){super(1,1);v(this,"canRecord",!1);v(this,"canPlay",!1);v(this,"isGibberishLoaded",!1)}playSound(t){this.isGibberishLoaded?no():(this.isGibberishLoaded=!0,Gibberish.workletPath="./worklet.js",Q.log("loading Gibberish 2..."),Gibberish.init().then(()=>{Q.log("Gibberish is ready!"),Gibberish.export(window),no()}).catch(i=>Q.error("oops",i)))}getPadColor(t,i){return O.black}getPadText(t){return{text:"Play Gibberish",color:O.green}}}let q=null;const Jb=window.AudioContext||window.webkitAudioContext,Te=()=>(q||(q=new Jb),(q==null?void 0:q.state)==="suspended"&&(Q.log("Resuming AudioContext"),q==null||q.resume()),q);document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(q==null?void 0:q.state)==="suspended"&&(Q.log("Resuming AudioContext after visibility change"),q==null||q.resume().catch(n=>Q.error("Error resuming AudioContext:",n)))});function ef(n=100){const e=Te(),t=e.sampleRate*.05,i=e.createBuffer(1,t,e.sampleRate),s=i.getChannelData(0);for(let p=0;p{if(e!==0)try{io[n](e)}catch(t){Q.error(`Error playing ${n}`,t),io[n](e)}},so={hihat:x.orange,kick:x.red,snare:x.blue,crash:x.green,"hihat-open":x.yellow,ride:x.yellow2,"tom-low":x.orange2,"tom-high":x.purple,"tom-mid":x.pink};class hf extends Gs{constructor(){super(2,5);v(this,"instruments",["crash","crash","ride","hihat-open","hihat","snare","tom-high","tom-mid","tom-low","kick"])}getPadColor(t,i){return O.black}getHitColor(t,i){return K(so[this.instruments[i]])}getPadText(t){return{text:this.instruments[t],color:K(so[this.instruments[t]])}}playSound(t){uf(this.instruments[t],this.settings.volume)}}function df(){const n=[];for(let e=0;e<9;e++)n[e]={};return n[2].C=65.40639132514966,n[2]["C#"]=69.29565774421802,n[2].D=73.4161919793519,n[2]["D#"]=77.78174593052023,n[2].E=82.40688922821748,n[2].F=87.30705785825097,n[2]["F#"]=92.4986056779086,n[2].G=97.99885899543732,n[2]["G#"]=103.82617439498628,n[2].A=110,n[2]["A#"]=116.54094037952248,n[2].B=123.47082531403103,n[3].C=130.8127826502993,n[3]["C#"]=138.59131548843604,n[3].D=146.8323839587038,n[3]["D#"]=155.56349186104046,n[3].E=164.81377845643496,n[3].F=174.61411571650194,n[3]["F#"]=184.9972113558172,n[3].G=195.99771799087463,n[3]["G#"]=207.65234878997256,n[3].A=220,n[3]["A#"]=233.08188075904496,n[3].B=246.94165062806206,n[4].C=261.6255653005986,n[4]["C#"]=277.1826309768721,n[4].D=293.6647679174076,n[4]["D#"]=311.1269837220809,n[4].E=329.6275569128699,n[4].F=349.2282314330039,n[4]["F#"]=369.9944227116344,n[4].G=391.99543598174927,n[4]["G#"]=415.3046975799451,n[4].A=440,n[4]["A#"]=466.1637615180899,n[4].B=493.8833012561241,n[5].C=523.2511306011972,n[5]["C#"]=554.3652619537442,n[5].D=587.3295358348151,n[5]["D#"]=622.2539674441618,n[5].E=659.2551138257398,n[5].F=698.4564628660078,n[5]["F#"]=739.9888454232688,n[5].G=783.9908719634985,n[5]["G#"]=830.6093951598903,n[5].A=880,n[5]["A#"]=932.3275230361799,n[5].B=987.7666025122483,n[6].C=1046.5022612023945,n[6]["C#"]=1108.7305239074883,n[6].D=1174.6590716696303,n[6]["D#"]=1244.5079348883237,n[6].E=1318.5102276514797,n[6].F=1396.9129257320155,n[6]["F#"]=1479.9776908465376,n[6].G=1567.981743926997,n[6]["G#"]=1661.2187903197805,n[6].A=1760,n[6]["A#"]=1864.6550460723597,n[6].B=1975.5332050244965,n[7].C=2093.004522404789,n[7]["C#"]=2217.4610478149766,n[7].D=2349.3181433392606,n[7]["D#"]=2489.0158697766474,n[7].E=2637.0204553029594,n[7].F=2793.825851464031,n[7]["F#"]=2959.955381693075,n[7].G=3135.963487853994,n[7]["G#"]=3322.437580639561,n[7].A=3520,n[7]["A#"]=3729.3100921447194,n[7].B=3951.066410048993,n}const mf=df(),En=mf.flatMap(n=>Object.entries(n)).map(([n,e])=>({key:n,freq:e})).filter(({freq:n})=>!!n).sort((n,e)=>n.freq-e.freq),Nn=12,El=6,vf=Nn*El,ro=n=>n.max+1-n.min,bf=()=>Nn,oo={min:2,max:El-2};class kl extends Gs{constructor(){super(ro(oo),bf()),this.settings.noteDuration=1.5,this.settings.octaveRange=oo}getNoteColor(e){return super.getPadColor(vf,e+this.getNoteIndexOffset())}getPadText(e){const t=En[e];return t!=null&&t.key?{text:t==null?void 0:t.key,color:this.getNoteColor(e)}:void 0}getPadColor(e,t){return this.isSharpKey(t)?O.black:this.getNoteColor(t).darken(90)}isSharpKey(e){var t;return(t=this.getKey(e))==null?void 0:t.includes("#")}getHitColor(e,t){return this.isSharpKey(t)?this.getNoteColor(t).darken(50):this.getNoteColor(t)}getKey(e){var t;return(t=En[e+this.getNoteIndexOffset()])==null?void 0:t.key}getNoteIndexOffset(){return this.getLowerRangeIndex()*Nn}getLowerRangeIndex(){return this.settings.octaveRange.min-1}playSound(e){e+=this.getNoteIndexOffset();const t=En[e].freq;return ff({frequency:t,...this.settings})}onSettingChange(e){super.onSettingChange(e),e.octaveRange&&super.changePadNumber(ro(e.octaveRange),Nn)}}const ff=({frequency:n,volume:e=50,noteDuration:t=1.5})=>{const i=Te(),s=i.createOscillator();s.type="sine";const r=i.createGain();s.frequency.setValueAtTime(n,i.currentTime),s.connect(r),r.connect(i.destination);const o=.02;r.gain.setValueAtTime(0,i.currentTime),r.gain.linearRampToValueAtTime(e/100,i.currentTime+o),r.gain.exponentialRampToValueAtTime(1e-4,i.currentTime+t),s.start(i.currentTime),s.stop(i.currentTime+t*2)};class wf extends kl{constructor(){super(),this.settings.noteDuration=2}getPadColor(e,t){return super.getPadColor(e,t).saturate(50)}playSound(e){e+=this.getNoteIndexOffset();const t=En[e].freq;return _f({frequency:t,...this.settings})}}function _f({frequency:n,volume:e=50,noteDuration:t=1}){const i=Te(),s=i.createOscillator();s.type="sawtooth",s.frequency.setValueAtTime(n,i.currentTime);const r=i.createGain();r.gain.value=e/100,r.gain.exponentialRampToValueAtTime(.001,i.currentTime+t);const o=i.createBiquadFilter();o.type="lowpass",o.frequency.setValueAtTime(800,i.currentTime),o.Q.value=1;const a=i.createWaveShaper();a.curve=gf(400),a.oversample="4x";const l=i.createOscillator();l.type="sine",l.frequency.setValueAtTime(3,i.currentTime);const c=i.createGain();c.gain.value=200,l.connect(c),c.connect(o.frequency),s.connect(o),o.connect(a),a.connect(r),r.connect(i.destination),s.start(),l.start(),s.stop(i.currentTime+1),l.stop(i.currentTime+1)}function gf(n){const e=typeof n=="number"?n:50,t=44100,i=new Float32Array(t),s=Math.PI/180;for(let r=0;r{this.scene.setVisible(!1),In.instance.startInstrumentScene(this.trackIndex,s)})}create({index:t}){this.trackIndex=t,this.scene.bringToTop(),this.game.events.emit(Xe.sceneChange),this.cameras.main.setOrigin(0,0).setBackgroundColor(x.black),this.createButtonsTable(),this.activateButton(0,0,Ye.synth),this.activateButton(1,0,Ye.electroSynth),this.activateButton(0,1,Ye.drums),this.activateButton(0,2,Ye.gibberish),window.addEventListener("resize",()=>this.resizeScene()),this.resizeScene()}createButtonsTable(){this.instrumentButtons=[];for(let t=0;t{p.forEach((_,B)=>{_.setSize(s,r).setPosition(s*u,r*B);const N=_.getData("text");if(N){const I=Math.min(_.height,_.width)/5;N.setFontSize(I).setResolution(2).setWordWrapWidth(_.width,!0).setSize(_.width,_.height).setPosition(_.getCenter().x,_.getCenter().y)}})});const o=t?window.innerWidth:window.innerWidth-i,a=t?window.innerHeight-i:window.innerHeight,l=t?0:i,c=t?i:0;this.cameras.main.setPosition(l,c).setViewport(l,c,o,a)}};v(ft,"key","EmptyScene"),v(ft,"sceneText","+"),v(ft,"sceneTextColor",O.white);let De=ft;const pe=class pe{constructor(e){v(this,"state","readyToRecord");v(this,"events",[]);v(this,"eventEmitter",new U.Events.EventEmitter);v(this,"startRecordingTime");v(this,"startPlayingTime",0);v(this,"currentLoopIndex",0);v(this,"loopTimeout",null);this.trackIndex=e,this.log("Loop created")}getStartPlayingTime(){return this.startPlayingTime}getLoopLength(){var e;return(e=this.events.find(({callback:t})=>t==="endOfLoop"))==null?void 0:e.time}handleClick(){switch(this.nextState(),this.state){case"recording":this.startRecording();break;case"playing":this.startPlaying();break;case"readyToPlay":this.stopPlaying();break}}addLoopEvent(e){if(this.isRecording()){this.startRecordingTime||(this.startRecordingTime=pe.masterLoop.getStartPlayingTime());const t=Date.now()-this.startRecordingTime;this.events.push({callback:e,time:t}),this.log(`Recording ${e} at time ${t}ms`)}}isPlaying(){return this.state==="playing"}isReadyToPlay(){return this.state==="readyToPlay"}isRecording(){return this.state==="recording"}isReadyToRecord(){return this.state==="readyToRecord"}destroy(){this.eventEmitter.removeAllListeners(),this.isPlaying()&&this.stopPlaying(),this.events=[],this.isMasterLoop()&&(pe.masterLoop=null),this.log("Loop destroyed")}addEventListener(e,t){this.eventEmitter.once(e,t)}nextState(){switch(this.state){case"readyToRecord":this.state="recording";break;case"recording":this.state=this.stopRecording();break;case"readyToPlay":this.state="playing";break;case"playing":this.state="readyToPlay";break}}startRecording(){this.events=[],this.log("Recording started"),pe.masterLoop?this.startRecordingTime||(this.log("no startRecordingTime !"),this.startRecordingTime=Date.now()):(pe.masterLoop=this,this.startRecordingTime=Date.now())}stopRecording(){var t;if(this.events.length===0)return this.log("No events recorded"),"readyToRecord";if(!this.startRecordingTime)throw new Error("startRecordingTime is not set");const e=Date.now()-this.startRecordingTime;if(this.isMasterLoop()){this.events.push({callback:"endOfLoop",time:e});const i=this.events[0].time;this.events=this.events.map(({time:s,callback:r})=>({time:s-i,callback:r}))}else{Q.log("events: "+this.events.length,this.events);const i=(t=pe.masterLoop)==null?void 0:t.getLoopLength();if(!i)throw new Error("masterLoopLength is not set");const r=Math.floor(e/i)*i;this.events=this.events.filter(({time:o})=>o<=r),this.events.push({callback:"endOfLoop",time:r})}return this.log(`Recording stopped at ${e} with ${this.events.length} events, start playing`),"playing"}startPlaying(){var t;const e=()=>{this.currentLoopIndex>=this.events.length&&(this.currentLoopIndex=0),this.currentLoopIndex===0&&(this.log("Loop play (re)-started","#0F0"),this.startPlayingTime=Date.now());const{callback:i,time:s}=this.events[this.currentLoopIndex],r=this.currentLoopIndex===0?0:this.events[this.currentLoopIndex-1].time;this.loopTimeout=setTimeout(()=>{i!=="endOfLoop"?i():this.eventEmitter.emit("endOfLoop"),this.currentLoopIndex++,e()},s-r)};this.log("Loop play starting"),!this.isMasterLoop()&&((t=pe.masterLoop)!=null&&t.isPlaying())?pe.masterLoop.addEventListener("endOfLoop",()=>{e()}):e()}stopPlaying(){this.loopTimeout&&clearTimeout(this.loopTimeout),this.currentLoopIndex=0,this.log("Loop stopped")}isMasterLoop(){return this===pe.masterLoop}log(e,t){const i=`Loop ${this.trackIndex+1}: ${e}`;t?Q.log(`%c${i}`,`color: ${t}`):Q.log(i)}};v(pe,"masterLoop",null);let jn=pe;const ao={play:"play_arrow",record:"fiber_manual_record",stop:"stop"},vt={idle:x.white,readyToRecord:"#0FF",recording:"#FD0041",playing:"#0F0"},y=class y extends U.Scene{constructor(){super(y.key);v(this,"resizeTracks",()=>{const t=window.innerWidth{const c=t?i*l:0,p=t?0:s*l;r.setSize(i,s).setPosition(c,p);const u=t?r.getCenter().x:r.getCenter().x-i/4,_=t?r.getCenter().y-s/4:r.getCenter().y,B=Math.min(s,i);o.setResolution(3).setSize(i,s).setFontSize(B/4).setPosition(u,_).setWordWrapWidth(i-10,!0).setRotation(t?0:-Math.PI/2),a.setOrigin(t?.5:1,t?1:.5).setPosition(t?r.getCenter().x:r.getRightCenter().x,t?r.getBottomCenter().y:r.getCenter().y)}),this.cameras.main.setViewport(0,0,t?window.innerWidth:i,t?s:window.innerHeight)});y.instance=this}static get sceneWidthHeight(){const t=window.innerWidth,i=window.innerHeight;return Math.max(i,t)/10}static deleteCurrentTrack(){const t=y.tracks.find(i=>i.selected);if(t){const i=y.tracks.indexOf(t);return t.loop.destroy(),t.loopProgressArc.clear(),t.loop=new jn(i),this.instance.updateControlsState(),i}throw new Error("No track selected")}static deleteCurrentInstrumentScene(){const t=y.deleteCurrentTrack(),i=y.getTrackSceneKey(t);this.instance.game.scene.remove(i),this.instance.game.scene.start(De.key,{index:t}),this.instance.updateControlsState()}static getTrackSceneKey(t){return`track_scene_${t}`}create(){this.createTracks(),this.game.events.on(Xe.sceneChange,()=>{this.updateControlsState()}),this.game.events.on(Xe.instrumentPlayed,({callback:t})=>{var i,s;(s=(i=y.tracks.find(r=>r.selected))==null?void 0:i.loop)==null||s.addLoopEvent(t)})}update(){for(const t of y.tracks)t.loop.isPlaying()&&this.updateProgressArc(t)}getTrackScene(t){return this.scene.get(y.getTrackSceneKey(t))}updateProgressArc(t){const i=t.loop.getLoopLength();if(!i)throw new Error("Loop length is not defined");const r=(Date.now()-t.loop.getStartPlayingTime())/i;t.loopProgressArc.clear(),t.loopProgressArc.lineStyle(4,65280,1);const o=U.Math.DegToRad(-90),a=o+U.Math.DegToRad(360*r);t.loopProgressArc.beginPath(),t.loopProgressArc.arc(t.buttonText.x,t.buttonText.y,t.buttonSelectedCircle.width/2,o,a,!1),t.loopProgressArc.strokePath()}createTracks(){y.tracks=new Array(y.numTracks).fill(null).map((t,i)=>({loop:new jn(i),button:this.add.rectangle().setOrigin(0,0).setStrokeStyle(1,O.darkGrey.color).setInteractive().on(U.Input.Events.POINTER_DOWN,()=>this.selectTrack(i)),selected:!1,buttonSelectedCircle:this.add.ellipse(0,0,0,0,O.white.color,0).setVisible(!1),buttonText:this.add.text(0,0,"+",{fontFamily:Ut.Text,fontSize:Ht.medium,color:xi.white}).setOrigin(.5,.5).setResolution(2),controlIcon:this.add.text(0,0,"",{fontFamily:Ut.Icons,fontSize:Ht.medium,color:xi.white}).setOrigin(.5,.5).setResolution(2).setInteractive().on(U.Input.Events.POINTER_DOWN,()=>{this.handleControlClicked(i)}),loopProgressArc:this.add.graphics()})),window.addEventListener("resize",()=>this.resizeTracks()),this.resizeTracks(),this.selectTrack(0)}handleControlClicked(t){y.tracks[t].loop.handleClick(),this.updateControlsState()}selectTrack(t){const i=y.tracks[t];if(i.selected)i.loop.handleClick(),this.updateControlsState();else{const s=y.tracks.find(o=>o.selected);s&&(s.selected=!1,s.loop.isRecording()&&s.loop.handleClick()),i.selected=!0,this.updateControlsState();const r=this.getTrackScene(t);if(r){r.scene.bringToTop();const o=r.settings;i.buttonText.setColor(kn(r.sceneTextColor)).setText(r.sceneText),this.game.events.emit(Xe.sceneChange,o)}else this.game.scene.start(De.key,{index:t})}this.scene.bringToTop()}updateControlsState(){y.tracks.forEach((t,i)=>{const s=this.getTrackScene(i),r=(s==null?void 0:s.sceneTextColor.color)??De.sceneTextColor.color;t.button.setDepth(t.selected?0:-1).setFillStyle(O.black.color).setStrokeStyle(1,t.selected?r:O.darkGrey.color),t.buttonText.setText((s==null?void 0:s.sceneText)??De.sceneText).setColor(kn((s==null?void 0:s.sceneTextColor)??De.sceneTextColor)).setAlpha(t.selected?1:.5),t.buttonSelectedCircle.setVisible(!1).setFillStyle(t.selected?O.white.color:O.black.color),(s==null?void 0:s.canRecord)||(s==null?void 0:s.canPlay)?s!=null&&s.canRecord&&t.selected&&(t.loop.isRecording()||t.loop.isReadyToRecord())?t.controlIcon.setText(ao.record).setColor(t.loop.isRecording()?vt.recording:vt.idle):s!=null&&s.canPlay&&(t.loop.isPlaying()||t.loop.isReadyToPlay())?t.controlIcon.setText(ao.play).setColor(t.loop.isPlaying()?vt.playing:vt.idle):t.controlIcon.setText("").setColor(vt.idle):t.controlIcon.setText("").setColor(vt.idle)})}};v(y,"key","LoopTracksScene"),v(y,"numTracks",5),v(y,"tracks"),v(y,"instance");let ae=y;const Cf=()=>window.matchMedia("(prefers-color-scheme: dark)").matches,wt=class wt extends U.Game{static async createGame(){wt.isInitialized||(await Ll(),this.instance=new wt)}constructor(){super({type:U.AUTO,mode:U.Scale.RESIZE,parent:"phaser-container",width:window.innerWidth,height:window.innerHeight,backgroundColor:Cf()?x.black:x.white,scene:[ae,De],input:{activePointers:8}});const e=new Bn(this);window.addEventListener("resize",()=>{this.resizeGame(),e.resize()}),this.scene.start(ae.key),this.events.on("ready",()=>{console.log("ready"),this.startInstrumentScene(2,Ye.electroSynth),this.startInstrumentScene(1,Ye.synth),this.startInstrumentScene(0,Ye.drums)}),this.resizeGame()}resizeGame(){const e=window.innerWidth,t=window.innerHeight;this.scale.resize(e,t),this.scene.scenes.forEach(i=>{var s,r;return(r=(s=i.sys)==null?void 0:s.scale)==null?void 0:r.refresh()})}startInstrumentScene(e,t){const{clazz:i,...s}=t;this.scene.add(ae.getTrackSceneKey(e),i,!0,{...s})}};v(wt,"isInitialized",!1),v(wt,"instance");let In=wt;(async()=>await In.createGame())(); diff --git a/index.html b/index.html index e9b104f..5ab8144 100644 --- a/index.html +++ b/index.html @@ -84,7 +84,7 @@ --tp-monitor-foreground-color: hsla(0, 0%, 100%, 0.3); } - + diff --git a/sw.js b/sw.js index d5a4ea7..4c4ec0d 100644 --- a/sw.js +++ b/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(i,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let a={};const t=e=>n(e,o),c={module:{uri:o},exports:a,require:t};s[o]=Promise.all(i.map((e=>c[e]||t(e)))).then((e=>(r(...e),a)))}}define(["./workbox-209e5686"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-EpgoMCE5.js",revision:null},{url:"assets/phaser-4DlKUGm0.js",revision:null},{url:"icons/favicon-32x32.png",revision:"385f8ba6daaec15480b890f5f7343438"},{url:"icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"index.html",revision:"70a69dbbdf2fb8679ba9cf1772f79541"},{url:"registerSW.js",revision:"402b66900e731ca748771b6fc5e7a068"},{url:"worklet.js",revision:"f2c0e5a03d55601209b3308c32a251aa"},{url:"./icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"./icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"manifest.webmanifest",revision:"7f72e7a7dd56296347bb1d27f4279e27"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute((({url:e})=>"https://docs.google.com"===e.origin&&e.pathname.startsWith("/spreadsheets/")),new e.NetworkFirst({cacheName:"api-cache",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:50,maxAgeSeconds:86400}),new e.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")})); +if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(i,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let a={};const t=e=>n(e,o),c={module:{uri:o},exports:a,require:t};s[o]=Promise.all(i.map((e=>c[e]||t(e)))).then((e=>(r(...e),a)))}}define(["./workbox-209e5686"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-wNIA1T8-.js",revision:null},{url:"assets/phaser-4DlKUGm0.js",revision:null},{url:"icons/favicon-32x32.png",revision:"385f8ba6daaec15480b890f5f7343438"},{url:"icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"index.html",revision:"f35e6647bce7625e01042954afe7f28e"},{url:"registerSW.js",revision:"402b66900e731ca748771b6fc5e7a068"},{url:"worklet.js",revision:"f2c0e5a03d55601209b3308c32a251aa"},{url:"./icons/pwa-192x192.png",revision:"eabf4d19df264df1374b6b8ec103ece3"},{url:"./icons/pwa-512x512.png",revision:"a6a962c6a584754622ba3a30d845f540"},{url:"manifest.webmanifest",revision:"7f72e7a7dd56296347bb1d27f4279e27"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"))),e.registerRoute((({url:e})=>"https://docs.google.com"===e.origin&&e.pathname.startsWith("/spreadsheets/")),new e.NetworkFirst({cacheName:"api-cache",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:50,maxAgeSeconds:86400}),new e.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")}));