@riddix/hamh 2.1.0-alpha.651 → 2.1.0-alpha.652

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -460,7 +460,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
460
460
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
461
461
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(Y4(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=$4(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Y4(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Z4(t.key)&&!Y4(t.sep,`newline`)){let e=$4(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Y4(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!Y4(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||Y4(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=$4(Q4(t));e3(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
462
462
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
463
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=$4(Q4(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=$4(Q4(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function n3(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new J4||null,prettyErrors:t}}function bqe(e,t={}){let{lineCounter:n,prettyErrors:r}=n3(t),i=new t3(n?.addNewLine),a=new N4(t),o=Array.from(a.compose(i.parse(e)));if(r&&n)for(let t of o)t.errors.forEach(h4(e,n)),t.warnings.forEach(h4(e,n));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function r3(e,t={}){let{lineCounter:n,prettyErrors:r}=n3(t),i=new t3(n?.addNewLine),a=new N4(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new p4(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(h4(e,n)),o.warnings.forEach(h4(e,n))),o}function xqe(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=r3(e,n);if(!i)return null;if(i.warnings.forEach(e=>l2(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Sqe(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return h0(e)&&!r?e.toString(n):new u4(e,r,n).toString(n)}var Cqe=c({Alias:()=>B0,CST:()=>mqe,Composer:()=>N4,Document:()=>u4,Lexer:()=>q4,LineCounter:()=>J4,Pair:()=>g2,Parser:()=>t3,Scalar:()=>U0,Schema:()=>l4,YAMLError:()=>f4,YAMLMap:()=>b2,YAMLParseError:()=>p4,YAMLSeq:()=>S2,YAMLWarning:()=>m4,isAlias:()=>m0,isCollection:()=>b0,isDocument:()=>h0,isMap:()=>g0,isNode:()=>x0,isPair:()=>_0,isScalar:()=>v0,isSeq:()=>y0,parse:()=>xqe,parseAllDocuments:()=>bqe,parseDocument:()=>r3,stringify:()=>Sqe,visit:()=>E0,visitAsync:()=>O0});function wqe(e){let t=null;try{t=Cqe.parse(e.doc.toString())}catch{}let n=xJ(e,_J.YAML);return{data:t,pointers:n}}var i3=e=>{switch(e){case _J.JSON:return dKe;case _J.JSON5:return pKe;case _J.YAML:return wqe}};function Tqe(e){return Object.entries(e)}function a3(e,t){if(typeof e==`string`||typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>a3(e,t));if(e instanceof Map){let n=new Map;for(let[r,i]of e){let e=r,a=a3(i,t);n.set(e,a)}return n}if(e instanceof Set){let n=new Set;for(let r of e){let e=a3(r,t);n.add(e)}return n}let n={};function r(e,r,i,a){i===e&&a===r?n[i]=a3(r,t):n[i]=a}for(let[n,i]of Tqe(e)){let e=t(n,i);if(e.length===2&&typeof e[0]==`string`)r(n,i,e[0],e[1]);else for(let[t,a]of e)r(n,i,t,a)}return n}var Eqe=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Dqe=class{constructor(){this.completions=new Map,this.reservedKeys=new Set}reserve(e){this.reservedKeys.add(e)}add(e){this.reservedKeys.has(e.label)||this.completions.set(e.label,e)}};function o3(e){return!(!e||BJ(e)||e.name===`UnknownPropertyError`||e.type===`undefined`)}var Oqe=class{constructor(e){this.opts=e,this.originalSchema=null,this.schema=null,this.laxSchema=null,this.mode=_J.JSON,this.mode=e.mode??_J.JSON,this.parser=this.opts?.jsonParser??i3(this.mode)}doComplete(e){let t=PJ(e.state);if(this.originalSchema!==t&&(this.schema=l3(t,t)??t,this.laxSchema=Aqe(this.schema)),!this.schema||!this.laxSchema)return[];pJ.log(`xxx`,`trying with original schema`);let n=this.doCompleteForSchema(e,this.schema);return n.options.length===0?(pJ.log(`xxx`,`no completions with original schema, trying with lax schema`),this.doCompleteForSchema(e,this.laxSchema)):n}doCompleteForSchema(e,t){let n={from:e.pos,to:e.pos,options:[],filter:!1},r=e.state.doc.sliceString(0),i=SJ(e.state,e.pos),a=e.state.sliceDoc(i.from,e.pos).replace(/^(["'])/,``);if(pJ.log(`xxx`,`node`,i,`prefix`,a,`ctx`,e),!(EJ(i,this.mode)||DJ(i,this.mode))&&!e.explicit)return pJ.log(`xxx`,`no completions for non-word/primitive`,i),n;let o=wJ(e.state.doc,i),s=wJ(e.state.doc,i,!1);if(i&&(EJ(i,this.mode)||DJ(i,this.mode)))n.from=i.from,n.to=i.to;else{let t=e.matchBefore(/[A-Za-z0-9._]*/),a=e.pos-o.length;pJ.log(`xxx`,`overwriteStart after`,a,`ctx.pos`,e.pos,`word`,t,`currentWord`,o,`=>`,r[a-1],`..`,r[a],`..`,r),n.from=i.name===mJ.INVALID?t?.from??e.pos:a,n.to=e.pos}let c=new Dqe,l=!0,u=MJ(i,mJ.PROPERTY_NAME,this.mode);if(u&&(pJ.log(`xxx`,`closestPropertyNameNode`,u,`node`,i),i=u),DJ(i,this.mode)){pJ.log(`xxx`,`isPropertyNameNode`,i);let e=i.parent;if(e){let t=AJ(e,this.mode);l=!t||t.name===mJ.INVALID&&t.from-t.to===0||(t.parent?OJ(t.parent).length<=1:!1),pJ.log(`xxx`,`addValue`,l,AJ(e,this.mode),i),i=MJ(e,mJ.OBJECT,this.mode)??null}}if(pJ.log(`xxx`,i,o,e,`node at pos`,SJ(e.state,e.pos)),i&&[mJ.OBJECT,mJ.JSON_TEXT].includes(vJ(i.name,this.mode))&&(DJ(SJ(e.state,e.pos),this.mode)||u)){if(i.from===e.pos)return pJ.log(`xxx`,`no completions for just before opening brace`),n;this.getPropertyCompletions(t,e,i,c,l,s)}else{let n=this.getValueCompletions(t,e,{},c);pJ.log(`xxx`,`getValueCompletions res`,n)}return n.options=Array.from(c.completions.values()).filter(e=>CJ(e.label).startsWith(a)),pJ.log(`xxx`,`result`,n,`prefix`,a,`collector.completions`,c.completions,`reservedKeys`,c.reservedKeys),n}applySnippetCompletion(e){return ALe(typeof e.apply==`string`?e.apply:e.label,e)}getPropertyCompletions(e,t,n,r,i,a){let o=fRe(n,mJ.PROPERTY,this.mode);pJ.log(`xxx`,`getPropertyCompletions`,n,t,o),o.forEach(e=>{let n=wJ(t.state.doc,kJ(e,mJ.PROPERTY_NAME,this.mode));r.reserve(CJ(n))});let s=this.getSchemas(e,t);pJ.log(`xxx`,`propertyCompletion schemas`,s),s.forEach(t=>{if(typeof t!=`object`)return;let n=t.properties;n&&Object.entries(n).forEach(([t,n])=>{if(typeof n==`object`){let o=n.description??``,s=n.type??``,c=Array.isArray(s)?s.toString():s,l={label:t,apply:this.getInsertTextForProperty(t,i,a,e,n),type:`property`,detail:c,info:()=>VX(`div`,{inner:a0(o)})};r.add(this.applySnippetCompletion(l))}});let o=t.propertyNames;if(typeof o==`object`&&(o.enum&&o.enum.forEach(t=>{let n=t?.toString();if(n){let t={label:n,apply:this.getInsertTextForProperty(n,i,a,e),type:`property`};r.add(this.applySnippetCompletion(t))}}),o.const)){let t=o.const.toString(),n={label:t,apply:this.getInsertTextForProperty(t,i,a,e),type:`property`};r.add(this.applySnippetCompletion(n))}})}getInsertTextForProperty(e,t,n,r,i){i&&=l3(i,r);let a=this.getInsertTextForPropertyName(e,n);if(!t)return a;a+=`: `;let o,s=0;if(typeof i==`object`){if(i.default!==void 0)o||=this.getInsertTextForGuessedValue(i.default,``),s++;else if(i.enum&&(!o&&i.enum.length===1&&(o=this.getInsertTextForGuessedValue(i.enum[0],``)),s+=i.enum.length),i.const!==void 0&&(o||=this.getInsertTextForGuessedValue(i.const,``),s++),Array.isArray(i.examples)&&i.examples.length&&(o||=this.getInsertTextForGuessedValue(i.examples[0],``),s+=i.examples.length),o===void 0&&s===0){let e=Array.isArray(i.type)?i.type[0]:i.type;switch(e||(i.properties?e=`object`:i.items&&(e=`array`)),e){case`boolean`:o=`#{}`;break;case`string`:o=this.getInsertTextForString(``);break;case`object`:switch(this.mode){case _J.JSON5:o=`{#{}}`;break;case _J.YAML:o=`#{}`;break;default:o=`{#{}}`;break}break;case`array`:o=`[#{}]`;break;case`number`:case`integer`:o=`#{0}`;break;case`null`:o=`#{null}`;break;default:o=`#{}`;break}}}return(!o||s>1)&&(pJ.log(`xxx`,`value`,o,`nValueProposals`,s,i),o=`#{}`),a+o}getInsertTextForPropertyName(e,t){switch(this.mode){case _J.JSON5:case _J.YAML:return t.startsWith(`"`)?`"${e}"`:t.startsWith(`'`)?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t=`#`){switch(this.mode){case _J.JSON5:return`'${t}{${e}}'`;case _J.YAML:return`${t}{${e}}`;default:return`"${t}{${e}}"`}}getInsertTextForGuessedValue(e,t=``){switch(typeof e){case`object`:return e===null?"${null}"+t:this.getInsertTextForValue(e,t);case`string`:{let n=JSON.stringify(e);return n=n.substr(1,n.length-2),n=this.getInsertTextForPlainText(n),this.getInsertTextForString(n,`$`)+t}case`number`:case`boolean`:return"${"+JSON.stringify(e)+`}`+t}return this.getInsertTextForValue(e,t)}getInsertTextForPlainText(e){return e.replace(/[\\$}]/g,`\\$&`)}getInsertTextForValue(e,t){let n=JSON.stringify(e,null,` `);return n===`{}`?`{#{}}`+t:n===`[]`?`[#{}]`+t:this.getInsertTextForPlainText(n+t)}getValueCompletions(e,t,n,r){let i=LH(t.state).resolveInner(t.pos,-1),a=null,o;if(pJ.log(`xxx`,`getValueCompletions`,i,t),i&&EJ(i,this.mode)&&(a=i,i=i.parent),!i){this.addSchemaValueCompletions(e,n,r);return}if(vJ(i.name,this.mode)===mJ.PROPERTY){let e=kJ(i,mJ.PROPERTY_NAME,this.mode);e&&(o=wJ(t.state.doc,e),i=i.parent)}if(pJ.log(`xxx`,`node`,i,`parentKey`,o),i&&(o!==void 0||vJ(i.name,this.mode)===mJ.ARRAY)){let s=this.getSchemas(e,t);for(let e of s){if(typeof e!=`object`)return;if(vJ(i.name,this.mode)===mJ.ARRAY&&e.items){let t=r;if(e.uniqueItems&&(t=Object.assign(Object.assign({},t),{add(e){t.completions.has(e.label)||r.add(e)},reserve(e){r.reserve(e)}})),Array.isArray(e.items)){let r=0;if(a){let e=jJ(i,a,this.mode);e>=0&&(r=e)}let o=e.items[r];o&&this.addSchemaValueCompletions(o,n,t)}else this.addSchemaValueCompletions(e.items,n,t)}if((e.type==null||e.type!==`object`)&&this.addSchemaValueCompletions(e,n,r),o!==void 0){let t=!1;if(e.properties){let i=e.properties[o];i&&(t=!0,this.addSchemaValueCompletions(i,n,r))}if(e.patternProperties&&!t){for(let i of Object.keys(e.patternProperties))if(this.extendedRegExp(i)?.test(o)){t=!0;let a=e.patternProperties[i];a&&this.addSchemaValueCompletions(a,n,r)}}if(e.additionalProperties&&!t){let t=e.additionalProperties;this.addSchemaValueCompletions(t,n,r)}}n.boolean&&(this.addBooleanValueCompletion(!0,r),this.addBooleanValueCompletion(!1,r)),n.null&&this.addNullValueCompletion(r)}}return{valuePrefix:a?wJ(t.state.doc,a,!0,!1):``}}addSchemaValueCompletions(e,t,n){typeof e==`object`&&(this.addEnumValueCompletions(e,n),this.addDefaultValueCompletions(e,n),this.collectTypes(e,t),Array.isArray(e.allOf)&&e.allOf.forEach(e=>this.addSchemaValueCompletions(e,t,n)),Array.isArray(e.anyOf)&&e.anyOf.forEach(e=>this.addSchemaValueCompletions(e,t,n)),Array.isArray(e.oneOf)&&e.oneOf.forEach(e=>this.addSchemaValueCompletions(e,t,n)))}addDefaultValueCompletions(e,t,n=0){let r=!1;if(e.default!==void 0){let i=e.type,a=e.default;for(let e=n;e>0;e--)a=[a],i=`array`;let o=Object.assign(Object.assign({type:i?.toString()},this.getAppliedValue(a)),{detail:`Default value`});t.add(o),r=!0}Array.isArray(e.examples)&&e.examples.forEach(i=>{let a=e.type,o=i;for(let e=n;e>0;e--)o=[o],a=`array`;t.add(Object.assign({type:a?.toString()},this.getAppliedValue(o))),r=!0}),!r&&typeof e.items==`object`&&!Array.isArray(e.items)&&n<5&&this.addDefaultValueCompletions(e.items,t,n+1)}addEnumValueCompletions(e,t){if(e.const!==void 0&&t.add(Object.assign(Object.assign({type:e.type?.toString()},this.getAppliedValue(e.const)),{info:e.description})),Array.isArray(e.enum))for(let n=0,r=e.enum.length;n<r;n++){let r=e.enum[n];t.add(Object.assign(Object.assign({type:e.type?.toString()},this.getAppliedValue(r)),{info:e.description}))}}addBooleanValueCompletion(e,t){t.add({type:`boolean`,label:e?`true`:`false`})}addNullValueCompletion(e){e.add({type:`null`,label:`null`})}collectTypes(e,t){if(Array.isArray(e.enum)||e.const!==void 0)return;let n=e.type;Array.isArray(n)?n.forEach(e=>t[e]=!0):n&&(t[n]=!0)}getSchemas(e,t){let{data:n}=this.parser(t.state),r=new BX(e),i=bJ(t.state,t.pos,-1,this.mode);if(i===``&&(i=void 0),i!=null&&i.endsWith(`/`)){i=i.substring(0,i.length-1);let t=s3(e,n,i);if(t!=null)return[t]}let a=i?.replace(/\/[^/]*$/,``);a===``&&(a=void 0);let o=s3(e,n,a),s=i?.split(`/`).pop(),c=s==null||s in(o?.properties??{}),l=r.getSchema({pointer:i,data:n??void 0});return!c&&l?.type===`null`&&this.mode===`yaml`&&(l=void 0),pJ.log(`xxxx`,`draft.getSchema`,l,`data`,n,`pointer`,i,`pointerPointsToKnownProperty`,c),BJ(l)&&(l=l.data?.schema),!o3(l)&&o?[o]:(o3(l)||(l=r.getSchema({pointer:a}),i=a),pJ.log(`xxx`,`pointer..`,JSON.stringify(i)),!o3(l)&&(!i||i===`/`)&&(l=l3(e,e)??e),pJ.log(`xxx`,`subSchema..`,l),l?Array.isArray(l.allOf)?[l,...l.allOf.map(t=>l3(t,e))]:Array.isArray(l.oneOf)?[l,...l.oneOf.map(t=>l3(t,e))]:Array.isArray(l.anyOf)?[l,...l.anyOf.map(t=>l3(t,e))]:[l]:[])}getAppliedValue(e){let t=CJ(JSON.stringify(e));switch(this.mode){case _J.JSON5:return{label:t,apply:uRe(JSON.stringify(e))};case _J.YAML:return{label:t,apply:t};default:return{label:t,apply:JSON.stringify(e)}}}getValueFromLabel(e){return JSON.parse(e)}extendedRegExp(e){let t=``;e.startsWith(`(?i)`)&&(e=e.substring(4),t=`i`);try{return new RegExp(e,t+`u`)}catch{try{return new RegExp(e,t)}catch{return}}}};function kqe(e={}){let t=new Oqe(e);return function(e){return t.doComplete(e)}}function Aqe(e){return a3(e,(e,t)=>e===`additionalProperties`&&t===!1||e===`required`&&Array.isArray(t)||e===`unevaluatedProperties`&&t===!1||e===`unevaluatedItems`&&t===!1?[]:[e,t])}function s3(e,t,n){let r=new BX(e),i=r.getSchema({pointer:n,data:t??void 0});if(!o3(i))return;let a=c3(r,i),o={};for(let e of a){let i=Mqe(n,e),a=r.getSchema({pointer:i,data:t??void 0});o3(a)&&Object.assign(o,{[e]:a})}if(a.length===0||Object.keys(o).length===0)return;let s=i,{allOf:c,anyOf:l,oneOf:u}=s,d=Eqe(s,[`allOf`,`anyOf`,`oneOf`]);return Object.assign(Object.assign({},d),{properties:o})}function c3(e,t){if(t=l3(t,e.rootSchema),typeof t!=`object`||!t)return[];let n=[];function r(t){let r=c3(e,t);n.push(...r)}if(typeof t.properties==`object`&&t.properties!=null&&n.push(...Object.keys(t.properties)),typeof t.then==`object`&&t.then!=null&&r(t.then),Array.isArray(t.allOf))for(let e of t.allOf)r(e);if(Array.isArray(t.anyOf))for(let e of t.anyOf)r(e);if(Array.isArray(t.oneOf))for(let e of t.oneOf)r(e);return n}function l3(e,t){if(typeof e==`object`&&e.$ref){let n=jqe(t,e.$ref);if(typeof n==`object`){let t=Object.assign(Object.assign({},e),n);return Reflect.deleteProperty(t,`$ref`),t}}return e}function jqe(e,t){let n=t.split(`/`),r=e;return n.forEach(t=>{if(t){if(t===`#`){r=e;return}typeof r==`object`&&(r=r[t])}}),r}function Mqe(e,t){return e===void 0?`/${t}`:`${e}/${t}`}var u3=(e,t)=>{let n=e.length>2,r=e.map((n,r)=>{let i="`"+(t?t(n):n)+"`";return r===e.length-1?`or `+i:i});return n?r.join(`, `):r.join(` `)},Nqe=e=>e?.data?.pointer&&e?.data?.pointer!==`#`?e.data.pointer.slice(1):e?.data?.property?`/${e.data.property}`:``,Pqe=e=>e.startState.field(NJ)!==e.state.field(NJ);function Fqe(e){let t=new Lqe(e);return e=>t.doValidation(e)}var Iqe=[`NoAdditionalPropertiesError`,`RequiredPropertyError`,`InvalidPropertyNameError`,`ForbiddenPropertyError`,`UndefinedValueError`],Lqe=class{constructor(e){this.options=e,this.schema=null,this.mode=_J.JSON,this.rewriteError=e=>{let t=e?.data?.errors;return e.code===`one-of-error`&&t?.length?`Expected one of ${u3(t,e=>e.data.expected)}`:e.code===`type-error`?`Expected \`${e?.data?.expected&&Array.isArray(e?.data?.expected)?u3(e?.data?.expected):e?.data?.expected}\` but received \`${e?.data?.received}\``:e.message.replaceAll("in `#` ",``).replaceAll("at `#`",``).replaceAll(`/`,`.`).replaceAll(`#.`,``)},this.mode=this.options?.mode??_J.JSON,this.parser=this.options?.jsonParser??i3(this.mode)}get schemaTitle(){return this.schema?.getSchema()?.title??`json-schema`}doValidation(e){let t=PJ(e.state);if(!t||(this.schema=new IX(t),!this.schema)||!e.state.doc.toString()?.length)return[];let n=this.parser(e.state);if(n.data==null)return[];let r=[];try{r=this.schema.validate(n.data)}catch{}return pJ.log(`xxx`,`validation errors`,r,n.data),r.length?r.reduce((e,t)=>{let r=()=>{let n=this.rewriteError(t);e.push({from:0,to:0,message:n,severity:`error`,source:this.schemaTitle,renderMessage:()=>{let e=VX(`div`,{});return e.innerHTML=a0(n),e}})},i=Nqe(t),a=n.pointers.get(i);if(t.name===`MaxPropertiesError`||t.name===`MinPropertiesError`||i===``)r();else if(a){let n=Iqe.includes(t.name),r=this.rewriteError(t),i=n?a.keyFrom:a.valueFrom,o=n?a.keyTo:a.valueTo;o!==void 0&&i!==void 0&&e.push({from:i,to:o,message:r,renderMessage:()=>{let e=VX(`div`,{});return e.innerHTML=a0(r),e},severity:`error`,source:this.schemaTitle})}else r();return e},[]):[]}};function Rqe(e){let t=new Bqe(e);return async function(e,n,r){return t.doHover(e,n,r)}}function zqe(e){if(e.type)return e.$ref?`${e.$ref} (${e.type})`:e.type;if(e.$ref)return`${e.$ref}`}function d3(e,t,n){return`${t}: ${u3(e[t].map(e=>{try{let{data:t}=n.resolveRef({data:e,pointer:e.$ref});return zqe(t||e)}catch{return e.type}}))}`}var Bqe=class{constructor(e){this.opts=e,this.schema=null,this.mode=_J.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=this.opts?.mode??_J.JSON}getDataForCursor(e,t,n){let r=PJ(e.state);if(!r)return null;this.schema=new IX(r);let i=bJ(e.state,t,n,this.mode),a;try{a=this.opts.parser(e.state.doc.toString())}catch{}if(!i)return null;let o=this.schema.getSchema({pointer:i,data:a,withSchemaWarning:!0});return BJ(o)&&(o=o?.data.schema.$ref?this.schema.resolveRef(o):o?.data.schema),{schema:o,pointer:i}}formatMessage(e){let{message:t,typeInfo:n}=e;return t?VX(`div`,{class:`cm6-json-schema-hover`},[VX(`div`,{class:`cm6-json-schema-hover--description`,inner:a0(t,!1)}),VX(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[VX(`div`,{class:`cm6-json-schema-hover--code`,inner:a0(n,!1)})])]):VX(`div`,{class:`cm6-json-schema-hover`},[VX(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[VX(`code`,{class:`cm6-json-schema-hover--code`,inner:a0(n,!1)})])])}getHoverTexts(e,t){let n=``,r=null,{schema:i}=e;return i.oneOf&&(n=d3(i,`oneOf`,t)),i.anyOf&&(n=d3(i,`anyOf`,t)),i.allOf&&(n=d3(i,`allOf`,t)),i.type&&(n=Array.isArray(i.type)?u3(i.type):i.type),i.$ref&&(n=` Reference: ${i.$ref}`),i.enum&&(n=`\`enum\`: ${u3(i.enum)}`),i.format&&(n+=`\`format\`: ${i.format}`),i.pattern&&(n+=`\`pattern\`: ${i.pattern}`),i.description&&(r=i.description),{message:r,typeInfo:n}}async doHover(e,t,n){let r=t,i=t;try{let a=this.getDataForCursor(e,t,n);if(pJ.log(`cursorData`,a),!a?.schema)return null;let o=(this.opts?.getHoverTexts??this.getHoverTexts)(a,this.schema),s=(this.opts?.formatHover??this.formatMessage)(o);return{pos:r,end:i,arrow:!0,above:!0,create:e=>({dom:s})}}catch(e){return pJ.log(e),null}}},Vqe=e=>(0,G.jsx)(Yv,{disablePadding:!0,children:e.validationErrors.map((e,t)=>(0,G.jsx)(Qv,{disableGutters:!0,disablePadding:!0,children:(0,G.jsxs)(Rv,{direction:`row`,spacing:1,children:[(0,G.jsx)(Q,{variant:`body2`,children:`•`}),(0,G.jsx)(Q,{variant:`caption`,children:e.instancePath.length===0?`/`:e.instancePath}),(0,G.jsx)(Q,{variant:`body2`,children:e.message})]})},t.toString()))}),f3=e=>{let t;try{t=JSON.parse(e)}catch{t=void 0}return t};function Hqe({schema:e,customValidate:t}){let n=(0,C.useMemo)(()=>new qP.default({allErrors:!0}),[]);return(0,C.useCallback)(r=>{let i=[];return n.validate(e,r),i.push(...n.errors??[]),i.push(...t?.(r)??[]),i},[n,e,t])}var Uqe=e=>{let t=Wqe(),[n,r]=(0,C.useState)(()=>JSON.stringify(e.value,null,2)),i=Hqe(e),[a,o]=(0,C.useState)([]);(0,C.useEffect)(()=>{o(i(e.value))},[i,e.value]);let s=e.onChange,c=(0,C.useCallback)(e=>{let t=f3(e),n=i(t);s(t,n.length===0),r(e),o(n)},[i,s]),l=()=>{let e=f3(n);e&&r(JSON.stringify(e,null,2))};return(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Z,{position:`relative`,children:[(0,G.jsx)(dJ,{value:n,onChange:e=>c(e),extensions:[_Pe(),VU(hPe(),{delay:100}),VU(Fqe(),{delay:100,needsRefresh:Pqe}),kU.data.of({autocomplete:kqe({mode:`json4`})}),pH(Rqe()),hRe(e.schema)],theme:t,height:`400px`}),(0,G.jsx)(uv,{sx:{position:`absolute`,right:`0`,bottom:`0`},onClick:()=>l(),children:`Prettify`})]}),a.length>0&&(0,G.jsx)(Uh,{severity:`error`,variant:`outlined`,children:(0,G.jsx)(Vqe,{validationErrors:a})})]})};function Wqe(){return wm().palette.mode===`dark`?zPe:FPe}var Gqe=[{value:``,label:`Auto (based on domain/name)`},{value:`light`,label:`💡 Light`},{value:`switch`,label:`🔌 Switch`},{value:`climate`,label:`🌡️ Climate`},{value:`cover`,label:`🪟 Cover`},{value:`fan`,label:`🌀 Fan`},{value:`lock`,label:`🔒 Lock`},{value:`sensor`,label:`📊 Sensor`},{value:`media_player`,label:`📺 Media Player`},{value:`vacuum`,label:`🧹 Vacuum`},{value:`remote`,label:`🎮 Remote`},{value:`humidifier`,label:`💧 Humidifier`},{value:`speaker`,label:`🔊 Speaker`},{value:`garage`,label:`🚗 Garage`},{value:`door`,label:`🚪 Door`},{value:`window`,label:`🪟 Window`},{value:`motion`,label:`🏃 Motion`},{value:`battery`,label:`🔋 Battery`},{value:`power`,label:`⚡ Power`},{value:`camera`,label:`📷 Camera`},{value:`default`,label:`🔗 Default`}],Kqe=({bridgeId:e,selectedIcon:t,onIconChange:n})=>{let r=(0,C.useRef)(null),[i,a]=(0,C.useState)(!1),[o,s]=(0,C.useState)(null),[c,l]=(0,C.useState)(!1),[u,d]=(0,C.useState)(null);(0,C.useEffect)(()=>{e&&pE(e).then(t=>{a(t),t&&s(`${mE(e)}?t=${Date.now()}`)}).catch(()=>{a(!1)})},[e]);let f=(0,C.useCallback)(async t=>{let i=t.target.files?.[0];if(!(!i||!e)){d(null),l(!0);try{await dge(e,i),a(!0),s(`${mE(e)}?t=${Date.now()}`),n(void 0)}catch(e){d(e instanceof Error?e.message:`Upload failed`)}finally{l(!1),r.current&&(r.current.value=``)}}},[e,n]),p=(0,C.useCallback)(async()=>{if(e){d(null);try{await fge(e),a(!1),s(null)}catch(e){d(e instanceof Error?e.message:`Delete failed`)}}},[e]),m=(0,C.useCallback)(e=>{n(e===``?void 0:e)},[n]);return(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Tv,{fullWidth:!0,size:`small`,children:[(0,G.jsx)(Fx,{id:`icon-select-label`,children:`Bridge Icon`}),(0,G.jsx)(_S,{labelId:`icon-select-label`,value:t??``,label:`Bridge Icon`,onChange:e=>m(e.target.value),disabled:i,children:Gqe.map(e=>(0,G.jsx)(vS,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(bS,{children:i?`Custom icon is set. Delete it to use preset icons.`:`Select a preset icon or upload a custom image`})]}),e&&(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,gutterBottom:!0,children:`Custom Icon`}),(0,G.jsxs)(Rv,{direction:`row`,spacing:2,alignItems:`center`,children:[i&&o&&(0,G.jsx)(Z,{component:`img`,src:o,alt:`Custom bridge icon`,sx:{width:48,height:48,objectFit:`contain`,borderRadius:1,border:`1px solid`,borderColor:`divider`}}),(0,G.jsx)(`input`,{ref:r,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp,image/svg+xml`,style:{display:`none`},onChange:f}),(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(She,{}),onClick:()=>r.current?.click(),disabled:c,children:c?`Uploading...`:`Upload Image`}),i&&(0,G.jsx)(uv,{variant:`outlined`,size:`small`,color:`error`,startIcon:(0,G.jsx)(MS,{}),onClick:p,children:`Delete`})]}),u&&(0,G.jsx)(Q,{variant:`caption`,color:`error`,sx:{mt:1},children:u}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{mt:1,display:`block`},children:`Supported formats: PNG, JPG, GIF, WebP, SVG (max 5MB)`})]}),!e&&(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:`Save the bridge first to upload a custom icon.`})]})},p3={light:`Light`,switch:`On/Off Plug-in Unit`,lock:`Door Lock`,fan:`Fan`,binary_sensor:`Sensor`,sensor:`Sensor`,cover:`Window Covering`,climate:`Thermostat`,media_player:`Speaker / Video Player`,vacuum:`Robot Vacuum Cleaner`,humidifier:`Humidifier`,valve:`Water Valve`,alarm_control_panel:`On/Off Plug-in Unit`,event:`Generic Switch`,button:`Generic Switch`,input_button:`Generic Switch`,automation:`On/Off Switch`,script:`On/Off Switch`,scene:`On/Off Switch`,remote:`On/Off`,water_heater:`Water Heater`,input_boolean:`On/Off Plug-in Unit`,select:`Mode Select`,input_select:`Mode Select`,siren:`On/Off Plug-in Unit`},m3=e=>{try{return JSON.parse(e)}catch{return}};function qqe({filter:e}){let[t,n]=(0,C.useState)(!1),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!1),l=(0,C.useRef)(null),u=(0,C.useRef)(``),d=(0,C.useCallback)(async()=>{n(!0),o(null);try{let t=await fetch(`api/matter/filter-preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=await t.text(),r=m3(n);if(!t.ok){let e=typeof r==`object`&&r&&`error`in r?String(r.error):n||`Failed to fetch preview`;throw Error(e)}i(r??m3(n)),c(!0)}catch(e){o(e instanceof Error?e.message:`Unknown error`)}finally{n(!1)}},[e]);(0,C.useEffect)(()=>{if(!(e.include.length>0&&e.include.some(e=>e.type&&e.value))){i(null),c(!1);return}let t=JSON.stringify(e);if(t!==u.current)return u.current=t,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{d()},800),()=>{l.current&&clearTimeout(l.current)}},[e,d]);let f=r?r.entities.reduce((e,t)=>(e[t.domain]=(e[t.domain]||0)+1,e),{}):{},p=[];if(r){r.entities.some(e=>e.domain===`vacuum`)&&p.push(`This filter includes a vacuum. Consider using Server Mode (single device per bridge) for Apple Home/Alexa compatibility.`),r.total>50&&p.push(`${r.total} entities is a large number. Consider splitting across multiple bridges for better stability.`);let e=Object.keys(f).filter(e=>!p3[e]);e.length>0&&p.push(`Unsupported domains will be skipped: ${e.join(`, `)}`)}return(0,G.jsxs)(Z,{sx:{mt:2},children:[(0,G.jsx)(uv,{variant:`outlined`,startIcon:t?(0,G.jsx)(Rh,{size:16}):(0,G.jsx)(Whe,{}),onClick:d,disabled:t,size:`small`,children:t?`Loading...`:`Preview Matching Entities`}),a&&(0,G.jsx)(Uh,{severity:`error`,sx:{mt:1},children:a}),(0,G.jsx)(qv,{in:s&&r!==null,children:r&&(0,G.jsxs)(Z,{sx:{mt:2},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsxs)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:[r.total,` entities match`]}),r.truncated&&(0,G.jsx)(Sv,{label:`Showing first 100`,size:`small`,color:`warning`,variant:`outlined`})]}),p.length>0&&(0,G.jsx)(Rv,{spacing:.5,sx:{mb:1.5},children:p.map(e=>(0,G.jsx)(Uh,{severity:`warning`,variant:`outlined`,icon:e.includes(`vacuum`)?(0,G.jsx)(ov,{fontSize:`small`}):(0,G.jsx)(vb,{fontSize:`small`}),sx:{py:0},children:(0,G.jsx)(Q,{variant:`caption`,children:e})},e))}),(0,G.jsx)(Z,{display:`flex`,gap:.5,flexWrap:`wrap`,mb:2,children:Object.entries(f).sort((e,t)=>t[1]-e[1]).map(([e,t])=>(0,G.jsx)(Sv,{label:`${e}: ${t}${p3[e]?` → ${p3[e]}`:``}`,size:`small`,variant:`outlined`,color:p3[e]?`default`:`warning`},e))}),(0,G.jsx)(Yv,{dense:!0,sx:{maxHeight:200,overflow:`auto`,bgcolor:`background.paper`,borderRadius:1,border:1,borderColor:`divider`},children:r.entities.map(e=>(0,G.jsx)(Qv,{divider:!0,children:(0,G.jsx)(ny,{primary:e.friendly_name||e.entity_id,secondary:`${e.entity_id}${p3[e.domain]?` → ${p3[e.domain]}`:``}`,primaryTypographyProps:{variant:`body2`},secondaryTypographyProps:{variant:`caption`,fontFamily:`monospace`}})},e.entity_id))}),(0,G.jsx)(uv,{size:`small`,onClick:()=>c(!1),sx:{mt:1},children:`Hide Preview`})]})})]})}var Jqe=eF().ObjectFieldTemplate;function Yqe(e){return(e.fieldPathId?.$id??``)===`root_filter`?(0,G.jsx)(Xqe,{...e}):(0,G.jsx)(Jqe,{...e})}function Xqe(e){let t=(e.formData?.include?.length??0)+(e.formData?.exclude?.length??0),[n,r]=(0,C.useState)(t>0);return(0,G.jsxs)(XS,{expanded:n,onChange:(e,t)=>r(t),variant:`outlined`,disableGutters:!0,sx:{borderRadius:2,"&::before":{display:`none`},overflow:`hidden`},children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),sx:{px:2,"& .MuiAccordionSummary-content":{alignItems:`center`,gap:1.5}},children:[(0,G.jsx)(pb,{fontSize:`small`,color:`action`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:600,children:`Entity Filters`}),(0,G.jsx)(Mx,{badgeContent:t,color:`primary`,sx:{ml:1},max:99,children:(0,G.jsx)(Z,{})}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{ml:1},children:n?`Click to collapse`:`${t} rule${t===1?``:`s`} configured`})]}),(0,G.jsx)(ZS,{sx:{px:2,pb:2},children:e.properties.map(e=>(0,G.jsx)(`div`,{children:e.content},e.name))})]})}function Zqe(e){let t=(0,C.useRef)(e),n=t.current;return t.current=e,n}function h3(e){let{items:t,canAdd:n,onAddClick:r,title:i,formData:a}=e,o=a??[],[s,c]=(0,C.useState)(()=>new Set),[l,u]=(0,C.useState)(``),d=Zqe(o.length);(0,C.useEffect)(()=>{if(o.length>d){let e=o.length-1,t=o[e];!t?.type&&!t?.value&&c(t=>new Set([...t,e]))}},[o,d]);let f=(0,C.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),p=(0,C.useMemo)(()=>{if(!l.trim())return null;let e=l.toLowerCase(),t=[];for(let n=0;n<o.length;n++){let r=o[n],i=r?.type??``,a=r?.value??``;(i.toLowerCase().includes(e)||a.toLowerCase().includes(e))&&t.push(n)}return new Set(t)},[l,o]),m=(0,C.useMemo)(()=>{let e=Array.from({length:t.length},(e,t)=>t);return p?e.filter(e=>p.has(e)):e},[t.length,p]);return(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:1,children:[(0,G.jsx)(Q,{variant:`subtitle2`,fontWeight:600,children:i}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Sv,{label:t.length,size:`small`,color:`default`,sx:{height:22,fontSize:`0.75rem`}}),n&&(0,G.jsx)(uv,{size:`small`,startIcon:(0,G.jsx)(cb,{}),onClick:r,children:`Add`})]})]}),t.length>3&&(0,G.jsx)(xS,{size:`small`,fullWidth:!0,placeholder:`Search rules...`,value:l,onChange:e=>u(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(ZP,{position:`start`,children:(0,G.jsx)(sE,{fontSize:`small`,color:`action`})})}},sx:{mb:1}}),p&&m.length===0&&(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,textAlign:`center`,py:2,children:`No matching rules`}),(0,G.jsx)(Rv,{spacing:.5,children:m.map(e=>{let n=o[e],r=n?.type??``,i=n?.value??``,a=s.has(e);return(0,G.jsxs)(Z,{sx:{border:1,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,sx:{px:1.5,py:.75,cursor:`pointer`,"&:hover":{bgcolor:`action.hover`},bgcolor:a?`action.selected`:`transparent`},onClick:()=>f(e),children:[a?(0,G.jsx)(fhe,{fontSize:`small`,color:`action`}):(0,G.jsx)(mhe,{fontSize:`small`,color:`action`}),r||i?(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,ml:.5,flex:1,minWidth:0,children:[(0,G.jsx)(Sv,{label:r,size:`small`,variant:`outlined`,sx:{height:22,fontSize:`0.75rem`,flexShrink:0}}),(0,G.jsx)(Q,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0},children:i})]}):(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,ml:.5,fontStyle:`italic`,children:`New rule (click to configure)`})]}),(0,G.jsx)(qv,{in:a,children:(0,G.jsx)(Z,{sx:{px:2,pb:1.5,pt:.5},children:t[e]})})]},e)})})]})}function Qqe(e){let{schema:t,formData:n={},onChange:r,disabled:i,readonly:a,fieldPathId:o}=e,s=t.properties??{},c=(0,C.useCallback)((e,t)=>{r({...n,[e]:t},o.path)},[n,r,o]);return(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`h6`,sx:{mb:2},children:`Feature Flags`}),(0,G.jsx)(jv,{container:!0,spacing:2,children:Object.entries(s).map(([e,t])=>{let r=n[e]??t.default??!1;return(0,G.jsx)(jv,{size:{xs:12,sm:6,lg:4},children:(0,G.jsx)(dv,{variant:`outlined`,sx:{height:`100%`,opacity:t.title?.toLowerCase().includes(`deprecated`)??!1?.6:1,transition:`border-color 0.2s, box-shadow 0.2s`,borderColor:r?`primary.main`:`divider`,"&:hover":{transform:`none`,boxShadow:`none`}},children:(0,G.jsx)(pv,{onClick:()=>{!i&&!a&&c(e,!r)},disabled:i||a,sx:{height:`100%`},children:(0,G.jsxs)(mv,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,p:2,"&:last-child":{pb:2}},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:1,children:[(0,G.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,G.jsx)(Q,{variant:`subtitle2`,fontWeight:600,sx:{lineHeight:1.3},children:t.title??e}),r&&(0,G.jsx)(Sv,{label:`Active`,size:`small`,color:`primary`,variant:`outlined`,sx:{mt:.5,height:20,fontSize:`0.7rem`}})]}),(0,G.jsx)(HS,{checked:r,size:`small`,disabled:i||a,tabIndex:-1,onClick:e=>e.stopPropagation(),onChange:t=>c(e,t.target.checked)})]}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{mt:1,lineHeight:1.4,flex:1},children:t.description})]})})})},e)})})]})}var g3=function(e){return e.JSON_EDITOR=`JSON_EDITOR`,e.FIELDS_EDITOR=`FIELDS_EDITOR`,e}(g3||{}),_3=e=>{let{t}=ms(),[n,r]=(0,C.useState)(g3.FIELDS_EDITOR),i=()=>{r(n===g3.FIELDS_EDITOR?g3.JSON_EDITOR:g3.FIELDS_EDITOR)},[a,o]=(0,C.useState)(e.bridge),[s,c]=(0,C.useState)(!0),l=(0,C.useCallback)(t=>{let n=t;if(!n?.port)return[];let r=e.usedPorts[n.port];return r!==void 0&&r!==e.bridgeId?[{instancePath:`/port`,message:`Port is already used by bridge with id ${r}`}]:[]},[e.bridgeId,e.usedPorts]),u=(e,t)=>{let n=e=>e?.icon;o(t=>{let r=n(t);return r==null?{...e}:{...e,icon:r}}),c(t)},d=(0,C.useCallback)(e=>{o(t=>{if(e!=null)return{...t,icon:e};let{icon:n,...r}=t??{};return r})},[]),f=(0,C.useMemo)(()=>{let e=a?.featureFlags,t=[];return e?.serverMode&&t.push({severity:`warning`,message:`Server Mode is enabled. Only ONE device should be in this bridge. Multiple devices will cause errors.`}),e?.serverMode&&e?.vacuumOnOff===!1&&t.push({severity:`warning`,message:`Server Mode with Vacuum OnOff disabled: Alexa REQUIRES the OnOff cluster (PowerController) for robotic vacuums. Without it, the vacuum commissions but never appears in Alexa. Only disable this for Apple Home.`}),!e?.serverMode&&e?.vacuumOnOff&&t.push({severity:`warning`,message:`Vacuum OnOff is enabled in bridge mode. This adds a non-standard cluster to the RVC device type which may cause issues with Apple Home and Google Home.`}),e?.autoForceSync&&e?.autoComposedDevices&&t.push({severity:`warning`,message:`Auto Force Sync with Auto Composed Devices increases network traffic. Composed devices have more clusters, so each sync cycle sends more data.`}),t},[a]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Uh,{severity:`warning`,variant:`outlined`,children:[`Please consult`,` `,(0,G.jsx)(Vv,{href:Y9.faq.bridgeConfig,target:`_blank`,children:`the documentation`}),` `,`for proper bridge configurations.`,` `,(0,G.jsx)(`strong`,{children:`Especially if you are using labels, see the "Labels" section.`})]}),(0,G.jsxs)(Uh,{severity:`info`,variant:`outlined`,children:[(0,G.jsx)(`strong`,{children:`Community tip:`}),` Users have reported that bridges with a large number of devices can become unstable depending on the controller. If you experience connectivity issues, consider splitting your devices across multiple bridges.`]}),f.map(e=>(0,G.jsx)(Uh,{severity:e.severity,variant:`outlined`,children:e.message},e.message)),(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsx)(Z,{display:`flex`,justifyContent:`flex-end`,children:(0,G.jsx)(uv,{onClick:()=>i(),title:n===g3.FIELDS_EDITOR?t(`bridge.jsonEditor`):t(`bridge.formEditor`),children:n===g3.FIELDS_EDITOR?(0,G.jsx)(Xhe,{}):(0,G.jsx)(Fhe,{})})}),n===g3.FIELDS_EDITOR&&(0,G.jsx)(Nke,{value:a??{},onChange:u,schema:rv,uiSchema:{icon:{"ui:widget":`hidden`},featureFlags:{"ui:field":`featureFlags`},filter:{include:{"ui:options":{ArrayFieldTemplate:h3}},exclude:{"ui:options":{ArrayFieldTemplate:h3}}}},customValidate:l,templates:{ObjectFieldTemplate:Yqe},fields:{featureFlags:Qqe}}),n===g3.JSON_EDITOR&&(0,G.jsx)(Uqe,{value:a??{},onChange:u,schema:rv,customValidate:l}),a?.filter&&(0,G.jsx)(qqe,{filter:a.filter}),(0,G.jsx)(dv,{variant:`outlined`,children:(0,G.jsxs)(mv,{children:[(0,G.jsx)(Q,{variant:`subtitle1`,gutterBottom:!0,fontWeight:600,children:t(`bridge.iconLabel`)}),(0,G.jsx)(Kqe,{bridgeId:e.bridgeId,selectedIcon:a?.icon,onIconChange:d})]})}),(0,G.jsxs)(jv,{container:!0,children:[(0,G.jsx)(jv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(uv,{fullWidth:!0,variant:`outlined`,color:`error`,onClick:e.onCancel,children:t(`common.cancel`)})}),(0,G.jsx)(jv,{size:{xs:0,sm:4,md:6},sx:{display:{xs:`none`,sm:`block`}}}),(0,G.jsx)(jv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(uv,{fullWidth:!0,variant:`outlined`,disabled:!s,onClick:async()=>{s&&await e.onSave(a)},children:t(`common.save`)})})]})]})]})},$qe={name:``,featureFlags:{},filter:{include:[],exclude:[]}};function eJe(e){let t=5540;for(;e[t];)t++;return t}var tJe=()=>{let{t:e}=ms(),t=Uv(),n=Sr(),[r,i]=(0,C.useState)(),a=!!AT().content?.length,o=jT(),s=(0,C.useCallback)(e=>{i(e?.id)},[]),c=(0,C.useMemo)(()=>{if(!o)return;let e=eJe(o);if(r){let t=Z_.find(e=>e.id===r);if(t)return{name:t.name,port:e,filter:{...t.filter},featureFlags:{...t.featureFlags},icon:t.icon}}return{...$qe,port:e}},[o,r]),l=Wme(),u=()=>{n(-1)};return!c||!o?e(`common.loading`):(0,G.jsxs)(Rv,{spacing:4,children:[(0,G.jsx)(Hv,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:e(`common.create`),to:Y9.createBridge}]}),a&&(0,G.jsx)(Uh,{severity:`info`,variant:`outlined`,children:(0,G.jsxs)(Q,{children:[`Did you know that you can connect the same bridge with multiple assistants?`,` `,(0,G.jsx)(Vv,{href:Y9.faq.multiFabric,target:`_blank`,children:`Learn more.`})]})}),(0,G.jsx)(wE,{selectedTemplate:r,onSelect:s}),(0,G.jsx)(_3,{bridge:c,usedPorts:o,onSave:async n=>{await l({...n}).then(()=>t.show({message:e(`bridge.saveSuccess`),severity:`success`})).then(()=>u()).catch(e=>t.show({message:e.message,severity:`error`}))},onCancel:u},r??`custom`)]})},nJe=()=>{let{t:e}=ms(),t=Uv(),n=Sr(),{bridgeId:r}=Er(),{content:i,isLoading:a}=MT(r),o=jT(),s=Gme(),c=(0,C.useMemo)(()=>{if(!(a||!i))return{name:i.name,port:i.port,filter:i.filter,...i.countryCode!=null&&{countryCode:i.countryCode},...i.featureFlags!=null&&{featureFlags:i.featureFlags},...i.icon!=null&&{icon:i.icon},...i.priority!=null&&{priority:i.priority}}},[a,i]),l=()=>{n(-1)};return a||!o?e(`common.loading`):!i||!c?e(`notFound.title`):(0,G.jsxs)(Rv,{spacing:4,children:[(0,G.jsx)(Hv,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:i.name,to:Y9.bridge(r)},{name:e(`common.edit`),to:Y9.editBridge(r)}]}),(0,G.jsx)(_3,{bridgeId:r,bridge:c,usedPorts:o,onSave:async n=>{await s({...n,id:r}).then(()=>t.show({message:e(`bridge.updateSuccess`),severity:`success`})).then(()=>l()).catch(e=>t.show({message:e.message,severity:`error`}))},onCancel:l})]})};async function rJe(){let e=await fetch(`api/backup/snapshots`);return await P_(e,`Failed to fetch backups`),N_(e)}async function iJe(){let e=await fetch(`api/backup/snapshots/create`,{method:`POST`});return await P_(e,`Failed to create backup`),N_(e)}async function aJe(e){let t=await fetch(`api/backup/snapshots/${encodeURIComponent(e)}/download`);if(!t.ok)throw Error(`Failed to download backup`);let n=await t.blob(),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i)}async function oJe(e,t){let n=await fetch(`api/backup/snapshots/${encodeURIComponent(e)}/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({overwriteExisting:!0,includeMappings:!0,restoreIdentity:!0,...t})});return await P_(n,`Failed to restore backup`),N_(n)}async function sJe(e){await P_(await fetch(`api/backup/snapshots/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete backup`)}async function cJe(){let e=await fetch(`api/backup/settings`);return await P_(e,`Failed to fetch backup settings`),N_(e)}async function lJe(e){let t=await fetch(`api/backup/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return await P_(t,`Failed to update backup settings`),N_(t)}function uJe(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function v3(){let{t:e}=ms(),[t,n]=(0,C.useState)(!1),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(new Set),[d,f]=(0,C.useState)(!1),[p,m]=(0,C.useState)(!0),[h,g]=(0,C.useState)(!0),[_,v]=(0,C.useState)(!1),[y,b]=(0,C.useState)(!1),[x,S]=(0,C.useState)(null),w=(0,C.useRef)(null),[T,E]=(0,C.useState)([]),[D,O]=(0,C.useState)(!0),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(null),[F,I]=(0,C.useState)(!1),L=(0,C.useCallback)(async()=>{try{O(!0);let[e,t]=await Promise.all([rJe(),cJe()]);E(e),A(t)}catch(e){i(e instanceof Error?e.message:`Failed to load backups`)}finally{O(!1)}},[]);(0,C.useEffect)(()=>{L()},[L]);let R=async()=>{I(!0),i(null);try{await iJe(),o(e(`backup.snapshotCreated`)),await L()}catch(e){i(e instanceof Error?e.message:`Failed to create backup`)}finally{I(!1)}},ee=async e=>{try{await aJe(e)}catch(e){i(e instanceof Error?e.message:`Failed to download backup`)}},z=async t=>{n(!0),i(null);try{let n=await oJe(t);n.errors.length>0?i(`Restored ${n.bridgesRestored} bridges with ${n.errors.length} errors`):o(e(`backup.snapshotRestored`,{bridges:n.bridgesRestored,mappings:n.mappingsRestored,identities:n.identitiesRestored})),M(null),n.restartRequired&&b(!0)}catch(e){i(e instanceof Error?e.message:`Failed to restore backup`)}finally{n(!1)}},te=async e=>{try{await sJe(e),P(null),await L()}catch(e){i(e instanceof Error?e.message:`Failed to delete backup`)}},B=async e=>{try{A(await lJe(e))}catch(e){i(e instanceof Error?e.message:`Failed to update settings`)}},V=async(t=!1)=>{n(!0),i(null);try{let n=await fetch(t?`api/backup/download?includeIdentity=true`:`api/backup/download`);if(!n.ok)throw Error(`Failed to create backup`);let r=await n.blob(),i=window.URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.headers.get(`Content-Disposition`)?.match(/filename="(.+)"/)?.[1]||`hamh-backup.zip`,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(i),document.body.removeChild(a),o(e(`backup.downloadSuccess`))}catch(e){i(e instanceof Error?e.message:`Unknown error`)}finally{n(!1)}},ne=async e=>{let t=e.target.files?.[0];if(t){S(t),n(!0),i(null);try{let e=new FormData;e.append(`file`,t);let n=await fetch(`api/backup/restore/preview`,{method:`POST`,body:e});if(!n.ok){let e=await n.text(),t=`Failed to parse backup`;try{let n=JSON.parse(e);n.error&&(t=n.error)}catch{e&&(t=`${t} (HTTP ${n.status}: ${e.slice(0,120)})`)}throw Error(t)}let r=await n.json();c(r),u(new Set(r.bridges.map(e=>e.id))),v(!0)}catch(e){i(e instanceof Error?e.message:`Unknown error`)}finally{n(!1),w.current&&(w.current.value=``)}}},re=async()=>{if(x){n(!0),i(null);try{let e=new FormData;e.append(`file`,x),e.append(`options`,JSON.stringify({bridgeIds:Array.from(l),overwriteExisting:d,includeMappings:p,restoreIdentity:h&&s?.includesIdentity}));let t=await fetch(`api/backup/restore`,{method:`POST`,body:e});if(!t.ok){let e=await t.text(),n=`Failed to restore backup`;try{let t=JSON.parse(e);t.error&&(n=t.error)}catch{e&&(n=`${n} (HTTP ${t.status}: ${e.slice(0,120)})`)}throw Error(n)}let n=await t.json();if(n.errors.length>0)i(`Restored ${n.bridgesRestored} bridges with ${n.errors.length} errors`);else{let e=[`Restored ${n.bridgesRestored} bridges`];n.mappingsRestored>0&&e.push(`${n.mappingsRestored} entity mappings`),n.identitiesRestored>0&&e.push(`${n.identitiesRestored} identities`),o(`${e.join(`, `)}!`)}v(!1),c(null),S(null),n.restartRequired&&b(!0)}catch(e){i(e instanceof Error?e.message:`Unknown error`)}finally{n(!1)}}},ie=e=>{let t=new Set(l);t.has(e)?t.delete(e):t.add(e),u(t)};return(0,G.jsxs)(dv,{children:[(0,G.jsxs)(mv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,children:[(0,G.jsx)(HT,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.title`)]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`backup.description`)}),r&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:2},onClose:()=>i(null),children:r}),a&&(0,G.jsx)(Uh,{severity:`success`,sx:{mb:2},onClose:()=>o(null),children:a}),(0,G.jsxs)(jv,{container:!0,spacing:2,children:[(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2,height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(HT,{color:`primary`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.configBackup`)})]}),(0,G.jsxs)(Z,{sx:{flexGrow:1},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.configBackupDesc`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.configBackupNote`)})]}),(0,G.jsx)(uv,{variant:`contained`,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):(0,G.jsx)(HT,{}),onClick:()=>V(!1),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.configBackup`)})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2,height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(Khe,{color:`warning`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.fullBackup`)})]}),(0,G.jsxs)(Z,{sx:{flexGrow:1},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.fullBackupDesc`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.fullBackupWarning`)})]}),(0,G.jsx)(uv,{variant:`contained`,color:`warning`,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):(0,G.jsx)(HT,{}),onClick:()=>V(!0),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.fullBackup`)})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2,height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(aE,{color:`info`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.restoreFromBackup`)})]}),(0,G.jsx)(Z,{sx:{flexGrow:1},children:(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.restoreDesc`)})}),(0,G.jsxs)(uv,{variant:`outlined`,color:`info`,startIcon:(0,G.jsx)(aE,{}),component:`label`,disabled:t,fullWidth:!0,sx:{mt:2},children:[e(`backup.restoreFromBackup`),(0,G.jsx)(`input`,{ref:w,type:`file`,accept:`.zip`,hidden:!0,onChange:ne})]})]})})]}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(HT,{color:`primary`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.storedBackups`)}),T.length>0&&(0,G.jsx)(Sv,{label:T.length,size:`small`,color:`primary`,variant:`outlined`})]}),(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:F?(0,G.jsx)(Rh,{size:16,color:`inherit`}):(0,G.jsx)(cb,{}),onClick:R,disabled:F,children:e(`backup.createSnapshot`)})]}),D?(0,G.jsx)(Z,{display:`flex`,justifyContent:`center`,p:2,children:(0,G.jsx)(Rh,{size:24})}):T.length===0?(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{textAlign:`center`,py:2},children:e(`backup.noSnapshots`)}):(0,G.jsx)(Yv,{dense:!0,children:T.map(t=>(0,G.jsxs)(Qv,{secondaryAction:(0,G.jsxs)(Z,{display:`flex`,gap:.5,children:[(0,G.jsx)(sb,{title:e(`backup.downloadSnapshot`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>ee(t.filename),children:(0,G.jsx)(ET,{fontSize:`small`})})}),(0,G.jsx)(sb,{title:e(`backup.restoreSnapshot`),children:(0,G.jsx)(Bh,{size:`small`,color:`warning`,onClick:()=>M(t.filename),children:(0,G.jsx)(aE,{fontSize:`small`})})}),(0,G.jsx)(sb,{title:e(`common.delete`),children:(0,G.jsx)(Bh,{size:`small`,color:`error`,onClick:()=>P(t.filename),children:(0,G.jsx)(MS,{fontSize:`small`})})})]}),children:[(0,G.jsx)(ey,{sx:{minWidth:36},children:(0,G.jsx)(HT,{fontSize:`small`,color:t.auto?`action`:`primary`})}),(0,G.jsx)(ny,{primary:(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsxs)(Q,{variant:`body2`,children:[`v`,t.version]}),(0,G.jsx)(Sv,{label:t.auto?e(`backup.auto`):e(`backup.manual`),size:`small`,variant:`outlined`,color:t.auto?`default`:`primary`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:uJe(t.sizeBytes)})]}),secondary:new Date(t.createdAt).toLocaleString()})]},t.filename))}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:2,children:[(0,G.jsx)(DT,{color:`action`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.settings`)})]}),k&&(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,maxWidth:400},children:[(0,G.jsx)(Av,{control:(0,G.jsx)(HS,{checked:k.autoBackup,onChange:e=>B({autoBackup:e.target.checked})}),label:e(`backup.autoBackupLabel`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:-1},children:e(`backup.autoBackupDesc`)}),(0,G.jsx)(xS,{label:e(`backup.retentionCount`),type:`number`,size:`small`,value:k.backupRetentionCount,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=100&&B({backupRetentionCount:t})},inputProps:{min:1,max:100},helperText:e(`backup.retentionCountDesc`),sx:{maxWidth:200}})]})]}),(0,G.jsxs)(Pb,{open:_,onClose:()=>v(!1),maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Lb,{children:e(`backup.restoreTitle`)}),(0,G.jsx)(Ib,{children:s&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:[`Backup created: `,new Date(s.createdAt).toLocaleString()]}),s.includesIdentity&&(0,G.jsx)(Uh,{severity:`info`,sx:{mt:1},children:`This backup includes Matter identity data (keypairs, fabric credentials). Restoring identities allows bridges to reconnect without re-commissioning.`}),(0,G.jsxs)(Q,{variant:`subtitle2`,sx:{mt:2,mb:1},children:[e(`backup.selectBridges`),`:`]}),(0,G.jsx)(Yv,{dense:!0,children:s.bridges.map(e=>(0,G.jsxs)(Qv,{onClick:()=>ie(e.id),sx:{cursor:`pointer`},children:[(0,G.jsx)(ey,{children:(0,G.jsx)(yv,{edge:`start`,checked:l.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,G.jsx)(ny,{primary:e.name,secondary:(0,G.jsxs)(G.Fragment,{children:[`Port: `,e.port,e.hasMappings&&` • ${e.mappingCount} entity mappings`,e.exists&&(0,G.jsx)(Q,{component:`span`,color:`warning.main`,sx:{ml:1},children:`(exists)`})]})})]},e.id))}),(0,G.jsxs)(Z,{sx:{mt:2},children:[(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{checked:d,onChange:e=>f(e.target.checked)}),label:e(`backup.overwriteExisting`)}),(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{checked:p,onChange:e=>m(e.target.checked)}),label:e(`backup.includeMappings`)}),s?.includesIdentity&&(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{checked:h,onChange:e=>g(e.target.checked)}),label:e(`backup.restoreIdentities`)})]})]})}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>v(!1),children:e(`common.cancel`)}),(0,G.jsx)(uv,{variant:`contained`,onClick:re,disabled:t||l.size===0,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Pb,{open:y,onClose:()=>b(!1),children:[(0,G.jsxs)(Lb,{children:[(0,G.jsx)(iE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.restartRequired`)]}),(0,G.jsxs)(Ib,{children:[(0,G.jsx)(Q,{children:e(`backup.restartMessage`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:e(`backup.restartNote`)})]}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>b(!1),children:e(`common.later`)}),(0,G.jsx)(uv,{variant:`contained`,color:`warning`,onClick:async()=>{n(!0);try{await fetch(`api/backup/restart`,{method:`POST`}),o(`Application is restarting...`)}catch(e){i(e instanceof Error?e.message:`Failed to restart`)}finally{n(!1),b(!1)}},disabled:t,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):(0,G.jsx)(iE,{}),children:e(`backup.restartNow`)})]})]}),(0,G.jsxs)(Pb,{open:j!==null,onClose:()=>M(null),children:[(0,G.jsxs)(Lb,{children:[(0,G.jsx)(aE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmRestore`)]}),(0,G.jsxs)(Ib,{children:[(0,G.jsx)(Q,{children:e(`backup.confirmRestoreMessage`,{filename:j})}),(0,G.jsx)(Uh,{severity:`warning`,sx:{mt:2},children:e(`backup.restoreWarning`)})]}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>M(null),children:e(`common.cancel`)}),(0,G.jsx)(uv,{variant:`contained`,color:`warning`,onClick:()=>j&&z(j),disabled:t,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Pb,{open:N!==null,onClose:()=>P(null),children:[(0,G.jsxs)(Lb,{children:[(0,G.jsx)(MS,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmDelete`)]}),(0,G.jsx)(Ib,{children:(0,G.jsx)(Q,{children:e(`backup.confirmDeleteMessage`,{filename:N})})}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>P(null),children:e(`common.cancel`)}),(0,G.jsx)(uv,{variant:`contained`,color:`error`,onClick:()=>N&&te(N),children:e(`common.delete`)})]})]})]})}var dJe=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`};function fJe(e={}){let{t}=ms(),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(!0),[o,s]=(0,C.useState)(null),[c,l]=(0,C.useState)(`name`),[u,d]=(0,C.useState)(`asc`),f=e.sortField??c,p=e.sortDirection??u,m=e.onSortFieldChange??l,h=e.onSortDirectionChange??d,g=(0,C.useCallback)(async()=>{try{let e=await fetch(`api/health/detailed`);e.ok?(r(await e.json()),s(null)):s(t(`health.fetchFailed`))}catch{s(t(`health.connectionError`))}finally{a(!1)}},[t]);(0,C.useEffect)(()=>{g();let e=setInterval(g,1e4);return()=>clearInterval(e)},[g]);let _=(0,C.useCallback)(async()=>{try{let e=await fetch(`api/diagnostic/export`);if(e.ok){let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.headers.get(`Content-Disposition`)?.match(/filename="(.+)"/)?.[1]??`hamh-diagnostic-${new Date().toISOString().replace(/[:.]/g,`-`)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}}catch{s(t(`health.exportFailed`))}},[t]),v=async e=>{try{await fetch(`api/matter/bridges/${e}/actions/restart`,{method:`POST`}),g()}catch{s(t(`health.restartFailed`))}};return i?(0,G.jsx)(Z,{display:`flex`,justifyContent:`center`,p:4,children:(0,G.jsx)(Rh,{})}):o||!n?(0,G.jsx)(Uh,{severity:`error`,sx:{m:2},children:o??t(`health.unableToLoad`)}):(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[n.status===`healthy`?(0,G.jsx)(av,{color:`success`}):n.status===`degraded`?(0,G.jsx)(Gv,{color:`warning`}):(0,G.jsx)(vx,{color:`error`}),(0,G.jsx)(Q,{variant:`h5`,children:t(`health.systemHealth`)}),(0,G.jsx)(Sv,{label:n.status.toUpperCase(),color:n.status===`healthy`?`success`:n.status===`degraded`?`warning`:`error`,size:`small`})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(UT,{}),onClick:_,children:t(`health.exportDiagnostic`)}),(0,G.jsx)(sb,{title:t(`common.refresh`),children:(0,G.jsx)(Bh,{onClick:g,"aria-label":`Refresh health data`,children:(0,G.jsx)(rE,{})})})]})]}),(0,G.jsxs)(jv,{container:!0,spacing:2,children:[(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.version`)}),(0,G.jsx)(Q,{variant:`h6`,children:n.version})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.uptime`)}),(0,G.jsx)(Q,{variant:`h6`,children:dJe(n.uptime)})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.homeAssistant`)}),(0,G.jsx)(Sv,{label:n.services.homeAssistant.connected?t(`health.connected`):t(`health.disconnected`),color:n.services.homeAssistant.connected?`success`:`error`,size:`small`})]})})]}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,flexWrap:`wrap`,gap:1,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(tE,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.bridgeStatus`)}),(0,G.jsx)(Sv,{label:`${n.services.bridges.running}/${n.services.bridges.total} ${t(`common.running`)}`,size:`small`,variant:`outlined`})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Dx,{fontSize:`small`,color:`action`}),(0,G.jsxs)(Tv,{size:`small`,sx:{minWidth:120},children:[(0,G.jsx)(Fx,{children:t(`health.sortBy`)}),(0,G.jsxs)(_S,{value:f,label:t(`health.sortBy`),onChange:e=>m(e.target.value),children:[(0,G.jsx)(vS,{value:`name`,children:t(`common.name`)}),(0,G.jsx)(vS,{value:`created`,children:t(`health.created`)})]})]}),(0,G.jsx)(sb,{title:t(p===`asc`?`health.ascending`:`health.descending`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>h(p===`asc`?`desc`:`asc`),"aria-label":`Sort ${p===`asc`?`descending`:`ascending`}`,children:p===`asc`?(0,G.jsx)(zT,{fontSize:`small`}):(0,G.jsx)(RT,{fontSize:`small`})})})]})]}),(0,G.jsx)(jv,{container:!0,spacing:2,alignItems:`stretch`,children:[...n.bridgeDetails].sort((e,t)=>{let n=0;return n=f===`name`?e.name.localeCompare(t.name):e.id.localeCompare(t.id),p===`asc`?n:-n}).map(e=>(0,G.jsx)(jv,{size:{xs:12,sm:6,md:6,lg:4,xl:3},sx:{display:`flex`},children:(0,G.jsx)(dv,{variant:`outlined`,sx:{width:`100%`,height:`100%`,minWidth:280,maxWidth:480,display:`flex`,flexDirection:`column`,borderColor:e.status===`running`?`success.main`:e.status===`failed`?`error.main`:`warning.main`},children:(0,G.jsxs)(mv,{sx:{flex:1,display:`flex`,flexDirection:`column`,p:2,"&:last-child":{pb:2}},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,flexShrink:0,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,minWidth:0,children:[(0,G.jsx)(ub,{}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,noWrap:!0,sx:{maxWidth:140},children:e.name})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:.5,flexShrink:0,children:[(0,G.jsx)(Sv,{label:e.status.toUpperCase(),color:e.status===`running`?`success`:e.status===`failed`?`error`:`warning`,size:`small`}),e.status===`failed`&&(0,G.jsx)(sb,{title:t(`bridge.restart`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>v(e.id),children:(0,G.jsx)(VT,{})})})]})]}),e.statusReason&&(0,G.jsx)(Q,{variant:`body2`,color:`error`,sx:{mt:1,flexShrink:0},children:e.statusReason}),(0,G.jsx)(Z,{sx:{mt:`auto`,pt:1,flexShrink:0},children:(0,G.jsxs)(Z,{display:`flex`,flexWrap:`wrap`,gap:.5,alignItems:`center`,children:[(0,G.jsx)(Sv,{label:`${t(`common.port`)} ${e.port}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Sv,{label:`${e.deviceCount} ${t(`common.devices`)}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Sv,{label:`${e.fabricCount} ${t(`common.fabrics`)}`,size:`small`,variant:`outlined`,color:`default`}),e.failedEntityCount>0&&(0,G.jsx)(Sv,{label:`${e.failedEntityCount} failed`,color:`error`,size:`small`})]})}),e.connectivity&&e.status===`running`&&(0,G.jsx)(Z,{sx:{mt:1,flexShrink:0},children:(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,children:[t(`health.sessions`),`:`,` `,e.connectivity.totalSessions,` |`,` `,t(`health.subscriptions`),`:`,` `,e.connectivity.totalSubscriptions,e.connectivity.fabricSummary&&e.connectivity.fabricSummary.length>1&&` (${e.connectivity.fabricSummary.length} ${t(`health.fabrics`)})`]})}),e.fabrics.length>0&&(0,G.jsxs)(Z,{sx:{mt:1,flexShrink:0},children:[(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,children:[t(`health.connectedTo`),`:`]}),(0,G.jsx)(Z,{display:`flex`,gap:.5,flexWrap:`wrap`,mt:.5,children:e.fabrics.map(e=>(0,G.jsx)(sb,{title:(0,G.jsxs)(Z,{sx:{fontSize:`0.75rem`},children:[(0,G.jsxs)(`div`,{children:[`Fabric #`,e.fabricIndex]}),(0,G.jsxs)(`div`,{children:[`Vendor: `,gx(e.rootVendorId),` `,`(0x`,e.rootVendorId.toString(16).toUpperCase().padStart(4,`0`),`)`]}),(0,G.jsxs)(`div`,{children:[`Fabric ID: `,e.fabricId]}),(0,G.jsxs)(`div`,{children:[`Node ID: `,e.nodeId]}),(0,G.jsxs)(`div`,{children:[`Root Node ID: `,e.rootNodeId]})]}),children:(0,G.jsx)(Sv,{icon:(0,G.jsx)(_x,{fabric:e}),label:e.label||gx(e.rootVendorId),size:`small`,variant:`outlined`})},e.fabricIndex))})]})]})})},e.id))}),n.recovery.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(VT,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.autoRecovery`)}),(0,G.jsx)(Sv,{label:t(`common.enabled`),color:`success`,size:`small`})]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[t(`health.recoveryAttempts`),`: `,n.recovery.recoveryCount,n.recovery.lastRecoveryAttempt&&` | Last attempt: ${new Date(n.recovery.lastRecoveryAttempt).toLocaleString()}`]})]}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsx)(v3,{})]})}var y3=e=>e===`pass`?`success`:e===`warn`?`warning`:`error`;function pJe(){let{t:e}=ms(),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!1),l=(0,C.useCallback)(async()=>{i(!0),o(null);try{let t=await fetch(`api/network`);t.ok?n(await t.json()):o(e(`health.fetchFailed`))}catch{o(e(`health.connectionError`))}finally{i(!1)}},[e]);(0,C.useEffect)(()=>{l()},[l]);let u=t?.checks.filter(e=>e.status===`pass`).length??0,d=t?.checks.filter(e=>e.status===`warn`).length??0,f=t?.checks.filter(e=>e.status===`fail`).length??0;return(0,G.jsxs)(Wm,{variant:`outlined`,sx:{p:2},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`center`,mb:1,children:[(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`health.networkDiagnostics`)}),(0,G.jsx)(uv,{size:`small`,onClick:l,disabled:r,children:r?(0,G.jsx)(Rh,{size:16}):e(`health.refresh`)})]}),a&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:1},children:a}),t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:1.5,flexWrap:`wrap`,children:[u>0&&(0,G.jsx)(Sv,{label:`${u} ${e(`health.checksPassed`)}`,color:`success`,size:`small`,variant:`outlined`}),d>0&&(0,G.jsx)(Sv,{label:`${d} ${e(`health.checksWarning`)}`,color:`warning`,size:`small`,variant:`outlined`}),f>0&&(0,G.jsx)(Sv,{label:`${f} ${e(`health.checksFailed`)}`,color:`error`,size:`small`,variant:`outlined`}),(0,G.jsx)(Sv,{label:t.matterConfig.boundInterface?`mDNS: ${t.matterConfig.boundInterface}`:`mDNS: all interfaces`,size:`small`,variant:`outlined`}),(0,G.jsx)(Sv,{label:`IPv4: ${t.matterConfig.ipv4Enabled?`on`:`off`}`,size:`small`,variant:`outlined`})]}),t.checks.filter(e=>e.status!==`pass`).map(e=>(0,G.jsxs)(Uh,{severity:y3(e.status),sx:{mb:1},children:[(0,G.jsx)(`strong`,{children:e.message}),e.detail&&(0,G.jsx)(Q,{variant:`body2`,sx:{mt:.5},children:e.detail})]},e.name)),(0,G.jsx)(uv,{size:`small`,onClick:()=>c(!s),sx:{mt:.5},children:e(s?`health.hideDetails`:`health.showDetails`)}),(0,G.jsxs)(qv,{in:s,children:[(0,G.jsx)(Q,{variant:`subtitle2`,sx:{mt:1,mb:.5},children:e(`health.allChecks`)}),(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:e(`health.check`)}),(0,G.jsx)(oC,{children:e(`health.statusLabel`)}),(0,G.jsx)(oC,{children:e(`health.message`)})]})}),(0,G.jsx)(aC,{children:t.checks.map(e=>(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:(0,G.jsx)(Q,{variant:`body2`,children:e.name})}),(0,G.jsx)(oC,{children:(0,G.jsx)(Sv,{label:e.status,color:y3(e.status),size:`small`})}),(0,G.jsxs)(oC,{children:[(0,G.jsx)(Q,{variant:`body2`,children:e.message}),e.detail&&(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,children:e.detail})]})]},e.name))})]}),(0,G.jsx)(Q,{variant:`subtitle2`,sx:{mt:2,mb:.5},children:e(`health.networkInterfaces`)}),(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:e(`health.interfaceName`)}),(0,G.jsx)(oC,{children:`IPv4`}),(0,G.jsx)(oC,{children:`IPv6`}),(0,G.jsx)(oC,{children:`MAC`})]})}),(0,G.jsx)(aC,{children:t.interfaces.filter(e=>!e.internal).map(e=>(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:e.name}),(0,G.jsx)(oC,{children:e.ipv4.join(`, `)||`-`}),(0,G.jsx)(oC,{children:(0,G.jsx)(Q,{variant:`body2`,sx:{wordBreak:`break-all`,maxWidth:240},children:e.ipv6.join(`, `)||`-`})}),(0,G.jsx)(oC,{children:e.mac})]},e.name))})]})]})]})]})}var b3=`hamh-translation-overrides`;function x3(e,t=``){let n={};for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(n,x3(i,e)):n[e]=String(i??``)}return n}function S3(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.split(`.`),i=t;for(let t=0;t<e.length-1;t++)e[t]in i||(i[e[t]]={}),i=i[e[t]];i[e[e.length-1]]=r}return t}function C3(e){try{let t=localStorage.getItem(b3);return t?JSON.parse(t)[e]??{}:{}}catch{return{}}}function w3(e,t){try{let n=localStorage.getItem(b3),r=n?JSON.parse(n):{};Object.keys(t).length===0?delete r[e]:r[e]=t,localStorage.setItem(b3,JSON.stringify(r))}catch{}}var T3=`hamh-custom-languages`;function mJe(){try{let e=localStorage.getItem(T3);return e?JSON.parse(e):[]}catch{return[]}}function E3(e){localStorage.setItem(T3,JSON.stringify(e))}var D3=[{code:`de`,name:`Deutsch`},{code:`fr`,name:`Français`},{code:`es`,name:`Español`},{code:`it`,name:`Italiano`},{code:`zh`,name:`中文`},{code:`zh-TW`,name:`繁體中文`},{code:`ja`,name:`日本語`},{code:`th`,name:`ไทย`},{code:`sv`,name:`Svenska`},{code:`tr`,name:`Türkçe`},{code:`ru`,name:`Русский`}];function hJe(){let{t:e,i18n:t}=ms(),n=t.language??`en`,r=D3.some(e=>e.code===n)?n:n.split(`-`)[0]??`en`,[i,a]=(0,C.useState)(()=>r===`en`?`de`:r),[o,s]=(0,C.useState)(``),[c,l]=(0,C.useState)(()=>C3(i)),[u,d]=(0,C.useState)(!1),[f,p]=(0,C.useState)(`all`),[m,h]=(0,C.useState)(mJe),[g,_]=(0,C.useState)(!1),[v,y]=(0,C.useState)(``),[b,x]=(0,C.useState)(``),[S,w]=(0,C.useState)(``),[T,E]=(0,C.useState)(``),D=(0,C.useMemo)(()=>[...D3,...m],[m]),O=(0,C.useCallback)(e=>m.some(t=>t.code===e),[m]),k=(0,C.useMemo)(()=>x3(gs),[]),A=(0,C.useMemo)(()=>{let e=t.getResourceBundle(i,`translation`);return e?x3(e):{}},[i,t]),j=(0,C.useMemo)(()=>Object.keys(k).map(e=>({key:e,section:e.split(`.`)[0],enValue:k[e],currentValue:c[e]??A[e]??``,isOverridden:e in c})),[k,A,c]),M=(0,C.useMemo)(()=>{let e=j;if(o){let t=o.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||e.enValue.toLowerCase().includes(t)||e.currentValue.toLowerCase().includes(t))}return f===`missing`?e=e.filter(e=>!e.currentValue):f===`edited`&&(e=e.filter(e=>e.isOverridden)),e},[j,o,f]),N=(0,C.useMemo)(()=>[...new Set(M.map(e=>e.section))],[M]),P=Object.keys(k).length,F=j.filter(e=>e.currentValue).length,I=Object.keys(c).length,L=P>0?F/P*100:0;(0,C.useEffect)(()=>{l(C3(i))},[i]);let R=(0,C.useCallback)(e=>{l(e),w3(i,e);let n=t.getResourceBundle(i,`translation`),r=n?x3(n):{},a={};for(let[t,n]of Object.entries(e))n&&n!==r[t]&&(a[t]=n);if(Object.keys(a).length>0){let e=S3({...r,...a});t.addResourceBundle(i,`translation`,e,!0,!0)}},[i,t]),ee=(0,C.useCallback)((e,t)=>{let n={...c,[e]:t};t||delete n[e],R(n)},[c,R]),z=(0,C.useCallback)(e=>{let t={...c};delete t[e],R(t)},[c,R]),te=(0,C.useCallback)(()=>{R({})},[R]),B=(0,C.useCallback)(()=>{let e={};for(let t of Object.keys(k))e[t]=c[t]??A[t]??``;let t=S3(e),n=JSON.stringify(t,null,2),r=new Blob([n],{type:`application/json`}),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=`${i}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},[k,A,c,i]),V=(0,C.useCallback)(()=>{let e={};for(let t of Object.keys(k))e[t]=c[t]??A[t]??``;let t=S3(e);navigator.clipboard.writeText(JSON.stringify(t,null,2)),d(!0),setTimeout(()=>d(!1),2e3)},[k,A,c]),ne=(0,C.useCallback)(()=>{let n=v.trim().toLowerCase(),r=b.trim();if(!n){w(e(`translationEditor.codeRequired`));return}if(!r){w(e(`translationEditor.nameRequired`));return}if(D3.some(e=>e.code===n)||m.some(e=>e.code===n)||n===`en`){w(e(`translationEditor.languageExists`));return}let i=[...m,{code:n,name:r}];h(i),E3(i),t.addResourceBundle(n,`translation`,{},!0,!0),a(n),_(!1),y(``),x(``),w(``)},[v,b,m,t,e]),re=(0,C.useCallback)(()=>{if(!O(i))return;let e=m.filter(e=>e.code!==i);h(e),E3(e),w3(i,{}),a(D3[0].code)},[i,m,O]),ie=(0,C.useCallback)(()=>{let t=document.createElement(`input`);t.type=`file`,t.accept=`.json`,t.onchange=()=>{let n=t.files?.[0];if(!n)return;let r=new FileReader;r.onload=()=>{try{let t=JSON.parse(r.result);if(typeof t!=`object`||!t)throw Error();let n=x3(t),i=new Set(Object.keys(k)),a={},o=0;for(let[e,t]of Object.entries(n))i.has(e)&&t&&(a[e]=t,o++);R({...c,...a}),E(e(`translationEditor.importSuccess`,{count:o}))}catch{E(e(`translationEditor.importFailed`))}},r.readAsText(n)},t.click()},[k,c,R,e]);return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,flexWrap:`wrap`,gap:1,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Qhe,{}),(0,G.jsx)(Q,{variant:`h5`,children:e(`translationEditor.title`)})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsxs)(Tv,{size:`small`,sx:{minWidth:140},children:[(0,G.jsx)(Fx,{children:e(`translationEditor.editLanguage`)}),(0,G.jsx)(_S,{value:i,label:e(`translationEditor.editLanguage`),onChange:e=>a(e.target.value),children:D.map(e=>(0,G.jsxs)(vS,{value:e.code,children:[(0,G.jsx)(ny,{primary:e.name}),O(e.code)&&(0,G.jsx)(ey,{sx:{minWidth:`auto`,ml:1},children:(0,G.jsx)(qT,{fontSize:`small`,color:`disabled`})})]},e.code))})]}),(0,G.jsx)(sb,{title:e(`translationEditor.addLanguage`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>_(e=>!e),children:(0,G.jsx)(cb,{fontSize:`small`})})}),O(i)&&(0,G.jsx)(sb,{title:e(`translationEditor.removeLanguage`),children:(0,G.jsx)(Bh,{size:`small`,color:`error`,onClick:re,children:(0,G.jsx)(qT,{fontSize:`small`})})})]})]}),(0,G.jsx)(qv,{in:g,children:(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:2,alignItems:`flex-start`,flexWrap:`wrap`,children:[(0,G.jsx)(xS,{size:`small`,label:e(`translationEditor.newLanguageCode`),value:v,onChange:e=>y(e.target.value),error:!!S,sx:{width:180}}),(0,G.jsx)(xS,{size:`small`,label:e(`translationEditor.newLanguageName`),value:b,onChange:e=>x(e.target.value),sx:{width:220}}),(0,G.jsx)(uv,{variant:`contained`,size:`small`,onClick:ne,children:e(`translationEditor.addLanguageButton`)}),S&&(0,G.jsx)(Q,{variant:`caption`,color:`error`,sx:{mt:.5},children:S})]})}),(0,G.jsx)(Uh,{severity:`info`,sx:{mb:2},children:e(`translationEditor.info`)}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:2,mb:2,flexWrap:`wrap`,children:[(0,G.jsxs)(Z,{sx:{flexGrow:1,minWidth:200},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:.5,children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`translationEditor.progress`,{translated:F,total:P})}),(0,G.jsxs)(Q,{variant:`body2`,fontWeight:600,children:[Math.round(L),`%`]})]}),(0,G.jsx)(Lv,{variant:`determinate`,value:L,sx:{height:8,borderRadius:4}})]}),I>0&&(0,G.jsx)(Sv,{label:e(`translationEditor.localEdits`,{count:I}),color:`primary`,size:`small`})]}),(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:2,flexWrap:`wrap`,children:[(0,G.jsx)(xS,{size:`small`,placeholder:e(`translationEditor.searchPlaceholder`),value:o,onChange:e=>s(e.target.value),sx:{flexGrow:1,minWidth:200},slotProps:{input:{startAdornment:(0,G.jsx)(ZP,{position:`start`,children:(0,G.jsx)(sE,{fontSize:`small`})})}}}),(0,G.jsx)(Tv,{size:`small`,sx:{minWidth:130},children:(0,G.jsxs)(_S,{value:f,onChange:e=>p(e.target.value),children:[(0,G.jsx)(vS,{value:`all`,children:e(`translationEditor.filterAll`)}),(0,G.jsx)(vS,{value:`missing`,children:e(`translationEditor.filterMissing`)}),(0,G.jsx)(vS,{value:`edited`,children:e(`translationEditor.filterEdited`)})]})})]}),(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:3,flexWrap:`wrap`,children:[(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(tge,{}),onClick:B,children:e(`translationEditor.exportJson`)}),(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(ET,{}),onClick:ie,children:e(`translationEditor.importJson`)}),(0,G.jsx)(sb,{title:u?e(`translationEditor.copied`):``,children:(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(lb,{}),onClick:V,children:e(`translationEditor.copyJson`)})}),I>0&&(0,G.jsx)(uv,{variant:`outlined`,size:`small`,color:`warning`,startIcon:(0,G.jsx)(aE,{}),onClick:te,children:e(`translationEditor.resetAll`)})]}),N.map(t=>(0,G.jsxs)(Z,{sx:{mb:3},children:[(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:600,sx:{mb:1,textTransform:`capitalize`},children:t}),(0,G.jsx)(zb,{sx:{mb:1.5}}),M.filter(e=>e.section===t).map(t=>(0,G.jsxs)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`1fr 1fr auto`},gap:1,mb:1.5,alignItems:`start`},children:[(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{fontFamily:`monospace`},children:t.key}),(0,G.jsx)(Q,{variant:`body2`,sx:{mt:.25},children:t.enValue})]}),(0,G.jsx)(xS,{size:`small`,fullWidth:!0,multiline:t.enValue.length>60,minRows:1,maxRows:4,value:t.currentValue,onChange:e=>ee(t.key,e.target.value),placeholder:t.enValue,sx:{"& .MuiOutlinedInput-root":t.isOverridden?{borderColor:`primary.main`,"& fieldset":{borderColor:`primary.main`,borderWidth:2}}:{}}}),t.isOverridden&&(0,G.jsx)(sb,{title:e(`translationEditor.resetKey`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>z(t.key),children:(0,G.jsx)(aE,{fontSize:`small`})})})]},t.key))]},t)),M.length===0&&(0,G.jsx)(Q,{color:`text.secondary`,sx:{textAlign:`center`,py:4},children:e(`translationEditor.noResults`)}),(0,G.jsx)($h,{open:!!T,autoHideDuration:3e3,onClose:()=>E(``),message:T})]})}var O3=e=>{let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(1)} ${t[r]}`},k3=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`},gJe=()=>{let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(!0),[i,a]=(0,C.useState)(!0);if((0,C.useEffect)(()=>{let e=null,n=async()=>{try{let n=await fetch(`api/system/info`);n.ok?(t(await n.json()),a(!0)):n.status===404&&(a(!1),e&&=(clearInterval(e),null))}catch{}finally{r(!1)}};return n(),e=setInterval(n,3e4),()=>{e&&clearInterval(e)}},[]),!i)return null;if(n)return(0,G.jsx)(dv,{children:(0,G.jsx)(mv,{children:(0,G.jsx)(Q,{children:`Loading system information...`})})});if(!e)return(0,G.jsx)(dv,{children:(0,G.jsx)(mv,{children:(0,G.jsx)(Q,{color:`error`,children:`Failed to load system information`})})});let o=e.memory.used/e.memory.total*100,s=e.storage.used/e.storage.total*100;return(0,G.jsx)(dv,{children:(0,G.jsxs)(mv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Che,{}),`System Information`]}),(0,G.jsxs)(jv,{container:!0,spacing:3,children:[(0,G.jsx)(jv,{size:{xs:12,md:6},children:(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`Application`}),(0,G.jsxs)(Rv,{spacing:1,sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Version:`}),(0,G.jsx)(Sv,{label:e.version,size:`small`,color:`primary`})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Environment:`}),(0,G.jsx)(Sv,{label:e.environment,size:`small`,variant:`outlined`,color:e.environment===`Home Assistant Add-on`?`success`:`default`})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Node.js:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e.nodeVersion})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Process Uptime:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:k3(e.process.uptime)})]})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`System`}),(0,G.jsxs)(Rv,{spacing:1,sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Hostname:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e.hostname})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Platform:`}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[e.platform,` (`,e.arch,`)`]})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`CPU:`}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,sx:{maxWidth:200,textAlign:`right`},noWrap:!0,title:e.cpuModel,children:[e.cpuCount,`x`,` `,e.cpuModel.split(`@`)[0].trim()]})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`System Uptime:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:k3(e.uptime)})]})]})]})]})}),(0,G.jsx)(jv,{size:{xs:12,md:6},children:(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(tE,{}),`Memory Usage`]}),(0,G.jsxs)(Z,{sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,mb:1},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[O3(e.memory.used),` /`,` `,O3(e.memory.total)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[o.toFixed(1),`%`]})]}),(0,G.jsx)(Z,{sx:{height:8,backgroundColor:`action.hover`,borderRadius:4,overflow:`hidden`},children:(0,G.jsx)(Z,{sx:{height:`100%`,width:`${o}%`,backgroundColor:o>80?`error.main`:o>60?`warning.main`:`success.main`,transition:`width 0.3s ease`}})})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(tE,{}),`HAMH Process Memory`]}),(0,G.jsxs)(Z,{sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[`RSS: `,O3(e.process.rss)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[`Heap: `,O3(e.process.heapUsed),` /`,` `,O3(e.process.heapSizeLimit)]})]}),(0,G.jsx)(Z,{sx:{height:8,backgroundColor:`action.hover`,borderRadius:4,overflow:`hidden`},children:(0,G.jsx)(Z,{sx:{height:`100%`,width:`${Math.min(e.process.heapUsed/e.process.heapSizeLimit*100,100)}%`,backgroundColor:e.process.heapUsed/e.process.heapSizeLimit>.85?`error.main`:e.process.heapUsed/e.process.heapSizeLimit>.6?`warning.main`:`success.main`,transition:`width 0.3s ease`}})})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Yhe,{}),`Storage Usage`]}),(0,G.jsxs)(Z,{sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,mb:1},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[O3(e.storage.used),` /`,` `,O3(e.storage.total)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[s.toFixed(1),`%`]})]}),(0,G.jsx)(Z,{sx:{height:8,backgroundColor:`action.hover`,borderRadius:4,overflow:`hidden`},children:(0,G.jsx)(Z,{sx:{height:`100%`,width:`${s}%`,backgroundColor:s>80?`error.main`:s>60?`warning.main`:`success.main`,transition:`width 0.3s ease`}})})]})]})]})}),(0,G.jsxs)(jv,{size:{xs:12},children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Rhe,{}),`Network Interfaces`]}),(0,G.jsx)(Rv,{spacing:1,sx:{mt:1},children:e.network.interfaces.map(e=>(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(Q,{variant:`body2`,children:e.name}),(0,G.jsx)(Sv,{label:`${e.address} (${e.family})`,size:`small`,variant:`outlined`})]},`${e.name}-${e.address}`))})]})]})]})})},A3=200;function _Je(){let[e,t]=(0,C.useState)([]),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(!1),o=(0,C.useRef)(null),s=(0,C.useRef)(void 0),c=(0,C.useCallback)(()=>{if(o.current?.readyState===WebSocket.OPEN)return;let e=window.location.protocol===`https:`?`wss:`:`ws:`,n=document.querySelector(`base`)?.href||window.location.origin,i=new URL(n),l=`${e}//${i.host}${i.pathname}api/ws`.replace(/\/+/g,`/`).replace(`:/`,`://`),u=new WebSocket(l);o.current=u,u.onopen=()=>{a(!0),u.send(JSON.stringify({type:`subscribe_diagnostics`}))},u.onmessage=e=>{try{let n=JSON.parse(e.data);if(n.type===`diagnostic_event`){let e=n.data;t(t=>{let n=[...t,e];return n.length>A3?n.slice(-A3):n})}else if(n.type===`diagnostic_snapshot`){let e=n.data;r(e),t(e.recentEvents??[])}}catch{}},u.onclose=()=>{a(!1),o.current=null,s.current=setTimeout(c,3e3)},u.onerror=()=>u.close()},[]);return(0,C.useEffect)(()=>(c(),()=>{clearTimeout(s.current),o.current&&(o.current.send(JSON.stringify({type:`unsubscribe_diagnostics`})),o.current.close())}),[c]),{events:e,snapshot:n,connected:i,clearEvents:(0,C.useCallback)(()=>t([]),[])}}function j3(e){let t=e.replace(`#`,``),n=Number.parseInt(t.substring(0,2),16)/255,r=Number.parseInt(t.substring(2,4),16)/255,i=Number.parseInt(t.substring(4,6),16)/255;return .2126*(n<=.03928?n/12.92:((n+.055)/1.055)**2.4)+.7152*(r<=.03928?r/12.92:((r+.055)/1.055)**2.4)+.0722*(i<=.03928?i/12.92:((i+.055)/1.055)**2.4)>.179?`#000`:`#fff`}var M3={state_update:`#4caf50`,command_received:`#2196f3`,entity_error:`#f44336`,session_opened:`#ff9800`,session_closed:`#9e9e9e`,subscription_changed:`#9c27b0`,bridge_started:`#00bcd4`,bridge_stopped:`#795548`,entity_warning:`#ff9800`},N3={state_update:`diagnostics.stateUpdate`,command_received:`diagnostics.command`,entity_error:`diagnostics.entityError`,session_opened:`diagnostics.sessionOpen`,session_closed:`diagnostics.sessionClose`,subscription_changed:`diagnostics.subscription`,bridge_started:`diagnostics.bridgeStart`,bridge_stopped:`diagnostics.bridgeStop`,entity_warning:`diagnostics.entityWarning`};function vJe(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}var P3=Object.keys(M3);function yJe({sortField:e,sortDirection:t}={}){let{t:n}=ms(),r=wm(),{events:i,snapshot:a,connected:o,clearEvents:s}=_Je(),[c,l]=(0,C.useState)(new Set(P3)),[u,d]=(0,C.useState)(!1),f=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=i.filter(e=>c.has(e.type)),m=(0,C.useMemo)(()=>{let n=a?.bridges??[];return e?[...n].sort((n,r)=>{let i=0;return i=e===`name`?n.bridgeName.localeCompare(r.bridgeName):n.bridgeId.localeCompare(r.bridgeId),t===`desc`?-i:i}):n},[a?.bridges,e,t]),h={};for(let e of i)h[e.type]=(h[e.type]??0)+1;return(0,G.jsx)(dv,{children:(0,G.jsxs)(mv,{children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Zhe,{}),(0,G.jsx)(Q,{variant:`h6`,children:n(`diagnostics.title`)}),(0,G.jsx)(Sv,{icon:(0,G.jsx)(khe,{sx:{fontSize:10,color:o?r.palette.success.main:r.palette.error.main}}),label:n(o?`common.live`:`common.offline`),size:`small`,variant:`outlined`})]}),(0,G.jsxs)(Rv,{direction:`row`,spacing:.5,alignItems:`center`,children:[(0,G.jsx)(sb,{title:n(`diagnostics.filterEvents`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>d(e=>!e),color:u?`primary`:`default`,children:(0,G.jsx)(pb,{})})}),(0,G.jsx)(sb,{title:n(`diagnostics.clearEvents`),children:(0,G.jsx)(Bh,{size:`small`,onClick:s,children:(0,G.jsx)(xhe,{})})})]})]}),(0,G.jsxs)(Rv,{direction:`row`,spacing:.5,flexWrap:`wrap`,sx:{mb:2,gap:.5},children:[P3.map(e=>{let t=h[e]??0;if(t===0&&!u)return null;let r=M3[e];return(0,G.jsx)(Sv,{label:`${n(N3[e])}: ${t}`,size:`small`,sx:{bgcolor:c.has(e)?r:`action.disabledBackground`,color:c.has(e)?j3(r):`text.disabled`,fontSize:`0.7rem`,height:22,cursor:`pointer`,opacity:c.has(e)?1:.5},onClick:()=>f(e)},e)}),a?.system&&(0,G.jsx)(Sv,{label:`Total: ${a.system.eventCount}`,size:`small`,variant:`outlined`,sx:{fontSize:`0.7rem`,height:22}})]}),(0,G.jsx)(qv,{in:u,children:(0,G.jsx)(Wm,{variant:`outlined`,sx:{p:1.5,mb:2},children:(0,G.jsx)(jv,{container:!0,spacing:0,children:P3.map(e=>{let t=M3[e];return(0,G.jsx)(jv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{size:`small`,checked:c.has(e),onChange:()=>f(e),sx:{color:t,"&.Mui-checked":{color:t}}}),label:(0,G.jsx)(Q,{variant:`caption`,children:n(N3[e])})})},e)})})})}),m.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jv,{container:!0,spacing:1,sx:{mb:2},children:m.map(e=>(0,G.jsx)(bJe,{bridge:e},e.bridgeId))}),(0,G.jsx)(zb,{sx:{mb:2}})]}),(0,G.jsx)(Z,{sx:{maxHeight:400,overflow:`auto`,bgcolor:`background.default`,borderRadius:1,p:1},children:p.length===0?(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{textAlign:`center`,py:4},children:i.length===0?`Waiting for diagnostic events…`:n(`diagnostics.noEvents`)}):p.map(e=>{let t=M3[e.type];return(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`flex-start`,gap:1,py:.4,px:.5,minWidth:0,borderBottom:`1px solid`,borderColor:`divider`,"&:hover":{bgcolor:`action.hover`},"&:last-child":{borderBottom:`none`}},children:[(0,G.jsx)(Q,{variant:`caption`,sx:{color:`text.secondary`,whiteSpace:`nowrap`,fontFamily:`monospace`,fontSize:`0.72rem`,minWidth:85,pt:.1},children:vJe(e.timestamp)}),(0,G.jsx)(Sv,{label:N3[e.type]?n(N3[e.type]):e.type,size:`small`,sx:{bgcolor:t??`#757575`,color:j3(t??`#757575`),fontSize:`0.62rem`,fontWeight:600,height:18,minWidth:90}}),e.bridgeName&&(0,G.jsxs)(Q,{variant:`caption`,sx:{color:`primary.main`,fontWeight:600,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`0.72rem`,maxWidth:140,flexShrink:0},children:[`[`,e.bridgeName,`]`]}),e.entityId&&(0,G.jsx)(Q,{variant:`caption`,sx:{color:`warning.main`,fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`0.72rem`,maxWidth:220,flexShrink:1},children:e.entityId}),(0,G.jsx)(Q,{variant:`caption`,sx:{color:`text.primary`,flex:1,wordBreak:`break-word`,fontSize:`0.72rem`},children:e.message})]},e.id)})})]})})}function bJe({bridge:e}){let[t,n]=(0,C.useState)(!1);return(0,G.jsx)(jv,{size:{xs:12,sm:6},children:(0,G.jsxs)(Wm,{variant:`outlined`,sx:{p:1.5,overflow:`hidden`,minWidth:0},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`center`,sx:{cursor:`pointer`},onClick:()=>n(e=>!e),children:[(0,G.jsxs)(Z,{sx:{minWidth:0,overflow:`hidden`},children:[(0,G.jsx)(Q,{variant:`body2`,fontWeight:500,noWrap:!0,children:e.bridgeName}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:[e.entityCount,` devices · `,e.sessionCount,` sessions`]})]}),(0,G.jsxs)(Rv,{direction:`row`,spacing:.5,alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`,sx:{flexShrink:0,ml:1},children:[Object.entries(e.featureFlags).filter(([,e])=>e).map(([e])=>(0,G.jsx)(Sv,{label:e.replace(/^auto/,``).replace(/([A-Z])/g,` $1`).trim(),size:`small`,variant:`outlined`,sx:{fontSize:`0.6rem`,height:18}},e)),(0,G.jsx)(Sv,{label:e.status,size:`small`,color:e.status===`running`?`success`:e.status===`failed`?`error`:`default`,sx:{height:20}}),(0,G.jsx)(GS,{sx:{transform:t?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`,fontSize:18,color:`text.secondary`}})]})]}),(0,G.jsx)(qv,{in:t,children:(0,G.jsx)(Z,{sx:{mt:1,maxHeight:200,overflow:`auto`},children:e.entities.map(e=>(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`baseline`,gap:.5,py:.3,borderBottom:`1px solid`,borderColor:`divider`},children:[(0,G.jsx)(Q,{variant:`caption`,sx:{fontFamily:`monospace`,fontSize:`0.68rem`,minWidth:180,flexShrink:0,color:e.available?`text.primary`:`error.main`},noWrap:!0,children:e.entityId}),(0,G.jsx)(Z,{display:`flex`,gap:.3,flexWrap:`wrap`,children:e.matterClusters.map(e=>(0,G.jsx)(Sv,{label:e,size:`small`,variant:`outlined`,sx:{fontSize:`0.58rem`,height:16,"& .MuiChip-label":{px:.5}}},e))})]},e.entityId))})})]})})}var xJe=()=>{let[e,t]=(0,C.useState)(`name`),[n,r]=(0,C.useState)(`asc`);return(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,G.jsx)(fJe,{sortField:e,sortDirection:n,onSortFieldChange:t,onSortDirectionChange:r}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(yJe,{sortField:e,sortDirection:n})}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(pJe,{})}),(0,G.jsx)(Z,{sx:{px:2,pb:2},children:(0,G.jsx)(gJe,{})}),(0,G.jsx)(zb,{}),(0,G.jsx)(hJe,{})]})};async function SJe(){let e=await fetch(`api/matter/labels?_s=${Date.now()}`);return await P_(e,`Failed to fetch labels`),N_(e)}async function CJe(){let e=await fetch(`api/matter/areas?_s=${Date.now()}`);return await P_(e,`Failed to fetch areas`),N_(e)}async function wJe(){let e=await fetch(`api/matter/filter-values?_s=${Date.now()}`);return await P_(e,`Failed to fetch filter values`),N_(e)}var F3=({values:e,copiedId:t,onCopy:n,searchable:r})=>{let[i,a]=(0,C.useState)(``),o=(0,C.useMemo)(()=>{if(!i)return e;let t=i.toLowerCase();return e.filter(e=>e.toLowerCase().includes(t))},[e,i]);return e.length===0?(0,G.jsx)(Z,{sx:{p:2,textAlign:`center`},children:(0,G.jsx)(Q,{color:`text.secondary`,variant:`body2`,children:`No values found.`})}):(0,G.jsxs)(Z,{children:[r&&e.length>10&&(0,G.jsx)(Z,{sx:{px:2,pt:1,pb:.5},children:(0,G.jsx)(xS,{size:`small`,fullWidth:!0,placeholder:`Search...`,value:i,onChange:e=>a(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(ZP,{position:`start`,children:(0,G.jsx)(sE,{fontSize:`small`})})}}})}),(0,G.jsxs)(Z,{sx:{p:1.5,display:`flex`,flexWrap:`wrap`,gap:.75},children:[o.map(e=>(0,G.jsx)(Sv,{label:e,size:`small`,variant:t===e?`filled`:`outlined`,color:t===e?`success`:`default`,onClick:()=>n(e),sx:{fontFamily:`monospace`,fontSize:`0.8rem`}},e)),i&&o.length===0&&(0,G.jsxs)(Q,{color:`text.secondary`,variant:`body2`,sx:{p:1},children:[`No matches for "`,i,`"`]})]})]})},TJe=()=>{let{t:e}=ms(),[t,n]=(0,C.useState)([]),[r,i]=(0,C.useState)([]),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!0),[l,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(null),p=(0,C.useCallback)(async()=>{c(!0);try{let[e,t,r]=await Promise.all([SJe(),CJe(),wJe()]);n(e),i(t),o(r),u(null)}catch(t){u(t instanceof Error?t.message:e(`labels.loadFailed`))}finally{c(!1)}},[e]);(0,C.useEffect)(()=>{p()},[p]);let m=e=>{navigator.clipboard.writeText(e),f(e),setTimeout(()=>f(null),2e3)};return s?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(Rh,{})}):(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,sx:{mb:3},children:[(0,G.jsx)(pb,{sx:{mr:1,verticalAlign:`middle`}}),e(`labels.title`)]}),(0,G.jsx)(Uh,{severity:`info`,sx:{mb:3},children:e(`labels.info`)}),l&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:2},children:l}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)($T,{sx:{mr:.5,fontSize:20,verticalAlign:`middle`}}),e(`labels.labelsSection`),` (`,t.length,`)`]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`labels.labelsHint`)}),(0,G.jsx)(dv,{sx:{mb:4},children:t.length===0?(0,G.jsx)(Z,{sx:{p:3,textAlign:`center`},children:(0,G.jsx)(Q,{color:`text.secondary`,children:e(`labels.noLabels`)})}):(0,G.jsx)(sC,{children:(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.labelId`)}),(0,G.jsx)(oC,{width:48})]})}),(0,G.jsx)(aC,{children:t.map(t=>(0,G.jsxs)(fC,{hover:!0,children:[(0,G.jsxs)(oC,{children:[t.color&&(0,G.jsx)(Z,{component:`span`,sx:{display:`inline-block`,width:12,height:12,borderRadius:`50%`,backgroundColor:t.color,mr:1,verticalAlign:`middle`}}),t.name]}),(0,G.jsx)(oC,{children:(0,G.jsx)(`code`,{children:t.label_id})}),(0,G.jsx)(oC,{children:(0,G.jsx)(sb,{title:d===t.label_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>m(t.label_id),children:(0,G.jsx)(lb,{fontSize:`small`})})})})]},t.label_id))})]})})}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)(yT,{sx:{mr:.5,fontSize:20,verticalAlign:`middle`}}),e(`labels.areasSection`),` (`,r.length,`)`]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`labels.areasHint`)}),(0,G.jsx)(dv,{sx:{mb:4},children:r.length===0?(0,G.jsx)(Z,{sx:{p:3,textAlign:`center`},children:(0,G.jsx)(Q,{color:`text.secondary`,children:e(`labels.noAreas`)})}):(0,G.jsx)(sC,{children:(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.areaId`)}),(0,G.jsx)(oC,{width:48})]})}),(0,G.jsx)(aC,{children:r.map(t=>(0,G.jsxs)(fC,{hover:!0,children:[(0,G.jsx)(oC,{children:t.name}),(0,G.jsx)(oC,{children:(0,G.jsx)(`code`,{children:t.area_id})}),(0,G.jsx)(oC,{children:(0,G.jsx)(sb,{title:d===t.area_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>m(t.area_id),children:(0,G.jsx)(lb,{fontSize:`small`})})})})]},t.area_id))})]})})}),a&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{variant:`h6`,sx:{mb:2},children:e(`labels.otherFilterValues`)}),(0,G.jsxs)(XS,{defaultExpanded:!0,children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(nge,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.domains`),` (`,a.domains.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.domainsHint`)}),(0,G.jsx)(F3,{values:a.domains,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(YT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.platforms`),` (`,a.platforms.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.platformsHint`)}),(0,G.jsx)(F3,{values:a.platforms,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(WT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.entityCategories`),` (`,a.entityCategories.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.entityCategoriesHint`)}),(0,G.jsx)(F3,{values:a.entityCategories,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(WT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceClasses`),` (`,a.deviceClasses.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.deviceClassesHint`)}),(0,G.jsx)(F3,{values:a.deviceClasses,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(ub,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceNames`),` (`,a.deviceNames.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.deviceNamesHint`)}),(0,G.jsx)(F3,{values:a.deviceNames,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(ub,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.productNames`),` (`,a.productNames.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.productNamesHint`)}),(0,G.jsx)(F3,{values:a.productNames,copiedId:d,onCopy:m,searchable:!0})]})]})]})]})};async function EJe(){let e=await fetch(`api/lock-credentials`);return await P_(e,`Failed to fetch lock credentials`),N_(e)}async function DJe(e,t){let n=await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return await P_(n,`Failed to update lock credential`),N_(n)}async function OJe(e,t){let n=await fetch(`api/lock-credentials/${encodeURIComponent(e)}/enabled`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})});return await P_(n,`Failed to toggle credential`),N_(n)}async function kJe(e){await P_(await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete lock credential`)}var AJe=({open:e,onClose:t,onSave:n,initialEntityId:r=``,initialName:i=``,isEdit:a=!1})=>{let{t:o}=ms(),[s,c]=(0,C.useState)(r),[l,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(i),[p,m]=(0,C.useState)(``),[h,g]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{e&&(c(r),f(i),u(``),m(``))},[e,r,i]),(0,G.jsxs)(Pb,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Lb,{children:o(a?`lockCredentials.editCredential`:`lockCredentials.addCredential`)}),(0,G.jsx)(Ib,{children:(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,mt:1},children:[p&&(0,G.jsx)(Uh,{severity:`error`,children:p}),(0,G.jsx)(xS,{label:o(`lockCredentials.lockEntityId`),placeholder:`lock.front_door`,value:s,onChange:e=>c(e.target.value),disabled:a,fullWidth:!0,helperText:o(`lockCredentials.lockEntityHelperText`)}),(0,G.jsx)(xS,{label:o(`lockCredentials.pinCode`),type:`password`,placeholder:`1234`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,8)),fullWidth:!0,helperText:`4-8 digit PIN code for this lock`,inputProps:{inputMode:`numeric`,pattern:`[0-9]*`}}),(0,G.jsx)(xS,{label:o(`lockCredentials.nameOptional`),placeholder:o(`lockCredentials.namePlaceholder`),value:d,onChange:e=>f(e.target.value),fullWidth:!0,helperText:o(`lockCredentials.nameHelperText`)})]})}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:t,disabled:h,children:o(`common.cancel`)}),(0,G.jsx)(uv,{onClick:async()=>{if(!s.trim()){m(o(`lockCredentials.entityRequired`));return}if(!l||l.length<4||l.length>8){m(o(`lockCredentials.pinLength`));return}if(!/^\d+$/.test(l)){m(o(`lockCredentials.pinDigitsOnly`));return}g(!0);try{await n(s.trim(),l,d.trim()),t()}catch(e){m(e instanceof Error?e.message:o(`lockCredentials.saveFailed`))}finally{g(!1)}},variant:`contained`,disabled:h,startIcon:h?(0,G.jsx)(Rh,{size:16}):(0,G.jsx)(oE,{}),children:o(`common.save`)})]})]})},jJe=()=>{let{t:e}=ms(),[t,n]=(0,C.useState)([]),[r,i]=(0,C.useState)(!0),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!1),[l,u]=(0,C.useState)(null),d=(0,C.useCallback)(async()=>{i(!0);try{n((await EJe()).credentials),o(null)}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.loadFailed`))}finally{i(!1)}},[e]);(0,C.useEffect)(()=>{d()},[d]);let f=async(e,t,n)=>{await DJe(e,{entityId:e,pinCode:t,name:n||void 0,enabled:!0}),await d()},[p,m]=(0,C.useState)(null),h=async t=>{m(null);try{await kJe(t),await d()}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.deleteFailed`))}},g=async t=>{try{await OJe(t.entityId,!t.enabled),await d()}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.updateFailed`))}},_=e=>{u(e),c(!0)},v=()=>{u(null),c(!0)};return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,mb:3},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,children:[(0,G.jsx)(vT,{sx:{mr:1,verticalAlign:`middle`}}),e(`lockCredentials.title`)]}),(0,G.jsx)(uv,{variant:`contained`,startIcon:(0,G.jsx)(cb,{}),onClick:v,children:e(`lockCredentials.addCredential`)})]}),(0,G.jsx)(Uh,{severity:`info`,sx:{mb:3},children:`Configure PIN codes for locks that require authentication for remote lock/unlock operations. The PIN will be sent with lock/unlock commands to Matter locks.`}),a&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:2},children:a}),r?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(Rh,{})}):t.length===0?(0,G.jsx)(dv,{children:(0,G.jsxs)(mv,{sx:{textAlign:`center`,py:4},children:[(0,G.jsx)(vT,{sx:{fontSize:48,color:`text.secondary`,mb:2}}),(0,G.jsx)(Q,{variant:`h6`,color:`text.secondary`,children:`No lock credentials configured`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:`Add a PIN code for your Matter locks to enable remote lock/unlock`}),(0,G.jsx)(uv,{variant:`outlined`,startIcon:(0,G.jsx)(cb,{}),onClick:v,children:`Add Your First Credential`})]})}):(0,G.jsx)(dv,{children:(0,G.jsx)(Yv,{children:t.map((n,r)=>(0,G.jsxs)(Qv,{divider:r<t.length-1,onClick:()=>_(n),sx:{cursor:`pointer`,"&:hover":{bgcolor:`action.hover`}},children:[(0,G.jsx)(ey,{children:(0,G.jsx)(vT,{color:n.enabled?`primary`:`disabled`})}),(0,G.jsx)(ny,{primary:n.name||n.entityId,secondary:(0,G.jsxs)(G.Fragment,{children:[n.name&&(0,G.jsx)(Q,{component:`span`,variant:`body2`,color:`text.secondary`,children:n.entityId}),(0,G.jsx)(Q,{component:`span`,variant:`body2`,color:`text.secondary`,sx:{ml:n.name?2:0},children:`PIN: ****`})]})}),(0,G.jsxs)(Zv,{children:[(0,G.jsx)(sb,{title:n.enabled?e(`lockCredentials.disable`):e(`lockCredentials.enable`),children:(0,G.jsx)(HS,{edge:`end`,checked:n.enabled,onChange:e=>{e.stopPropagation(),g(n)}})}),(0,G.jsx)(sb,{title:e(`common.delete`),children:(0,G.jsx)(Bh,{edge:`end`,onClick:e=>{e.stopPropagation(),m(n.entityId)},sx:{ml:1},children:(0,G.jsx)(MS,{})})})]})]},n.entityId))})}),(0,G.jsx)(AJe,{open:s,onClose:()=>c(!1),onSave:f,initialEntityId:l?.entityId,initialName:l?.name,isEdit:!!l}),(0,G.jsx)(PT,{open:p!==null,title:e(`lockCredentials.confirmDeleteTitle`),message:e(`lockCredentials.confirmDeleteMessage`,{entity:p??``}),confirmLabel:e(`common.delete`),confirmColor:`error`,onConfirm:()=>{p&&h(p)},onCancel:()=>m(null)})]})},MJe=()=>{let e=Sr(),{t}=ms();return(0,G.jsxs)(Z,{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,minHeight:`60vh`,gap:2,p:4,children:[(0,G.jsx)(Ghe,{color:`disabled`,sx:{fontSize:64}}),(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:t(`notFound.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:t(`notFound.description`)}),(0,G.jsx)(uv,{variant:`contained`,startIcon:(0,G.jsx)(ZT,{}),onClick:()=>e(Y9.dashboard),children:t(`notFound.backToDashboard`)})]})};function I3(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=I3(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var NJe={value:()=>{}};function L3(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new R3(n)}function R3(e){this._=e}function PJe(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}R3.prototype=L3.prototype={constructor:R3,on:function(e,t){var n=this._,r=PJe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=FJe(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=z3(n[i],e.name,t);else if(t==null)for(i in n)n[i]=z3(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new R3(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function FJe(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function z3(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=NJe,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var B3={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function V3(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),B3.hasOwnProperty(t)?{space:B3[t],local:e}:e}function IJe(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function LJe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function H3(e){var t=V3(e);return(t.local?LJe:IJe)(t)}function RJe(){}function U3(e){return e==null?RJe:function(){return this.querySelector(e)}}function zJe(e){typeof e!=`function`&&(e=U3(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new i6(r,this._parents)}function BJe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function VJe(){return[]}function W3(e){return e==null?VJe:function(){return this.querySelectorAll(e)}}function HJe(e){return function(){return BJe(e.apply(this,arguments))}}function UJe(e){e=typeof e==`function`?HJe(e):W3(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new i6(r,i)}function G3(e){return function(){return this.matches(e)}}function K3(e){return function(t){return t.matches(e)}}var WJe=Array.prototype.find;function GJe(e){return function(){return WJe.call(this.children,e)}}function KJe(){return this.firstElementChild}function qJe(e){return this.select(e==null?KJe:GJe(typeof e==`function`?e:K3(e)))}var JJe=Array.prototype.filter;function YJe(){return Array.from(this.children)}function XJe(e){return function(){return JJe.call(this.children,e)}}function ZJe(e){return this.selectAll(e==null?YJe:XJe(typeof e==`function`?e:K3(e)))}function QJe(e){typeof e!=`function`&&(e=G3(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new i6(r,this._parents)}function q3(e){return Array(e.length)}function $Je(){return new i6(this._enter||this._groups.map(q3),this._parents)}function J3(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}J3.prototype={constructor:J3,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function eYe(e){return function(){return e}}function tYe(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new J3(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function nYe(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new J3(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function rYe(e){return e.__data__}function iYe(e,t){if(!arguments.length)return Array.from(this,rYe);var n=t?nYe:tYe,r=this._parents,i=this._groups;typeof e!=`function`&&(e=eYe(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=aYe(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new i6(o,r),o._enter=s,o._exit=c,o}function aYe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function oYe(){return new i6(this._exit||this._groups.map(q3),this._parents)}function sYe(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function cYe(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new i6(s,this._parents)}function lYe(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function uYe(e){e||=dYe;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new i6(i,this._parents).order()}function dYe(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function fYe(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function pYe(){return Array.from(this)}function mYe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function hYe(){let e=0;for(let t of this)++e;return e}function gYe(){return!this.node()}function _Ye(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function vYe(e){return function(){this.removeAttribute(e)}}function yYe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function bYe(e,t){return function(){this.setAttribute(e,t)}}function xYe(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function SYe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function CYe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function wYe(e,t){var n=V3(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?yYe:vYe:typeof t==`function`?n.local?CYe:SYe:n.local?xYe:bYe)(n,t))}function Y3(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function TYe(e){return function(){this.style.removeProperty(e)}}function EYe(e,t,n){return function(){this.style.setProperty(e,t,n)}}function DYe(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function OYe(e,t,n){return arguments.length>1?this.each((t==null?TYe:typeof t==`function`?DYe:EYe)(e,t,n??``)):X3(this.node(),e)}function X3(e,t){return e.style.getPropertyValue(t)||Y3(e).getComputedStyle(e,null).getPropertyValue(t)}function kYe(e){return function(){delete this[e]}}function AYe(e,t){return function(){this[e]=t}}function jYe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function MYe(e,t){return arguments.length>1?this.each((t==null?kYe:typeof t==`function`?jYe:AYe)(e,t)):this.node()[e]}function Z3(e){return e.trim().split(/^|\s+/)}function Q3(e){return e.classList||new $3(e)}function $3(e){this._node=e,this._names=Z3(e.getAttribute(`class`)||``)}$3.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function e6(e,t){for(var n=Q3(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function t6(e,t){for(var n=Q3(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function NYe(e){return function(){e6(this,e)}}function PYe(e){return function(){t6(this,e)}}function FYe(e,t){return function(){(t.apply(this,arguments)?e6:t6)(this,e)}}function IYe(e,t){var n=Z3(e+``);if(arguments.length<2){for(var r=Q3(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?FYe:t?NYe:PYe)(n,t))}function LYe(){this.textContent=``}function RYe(e){return function(){this.textContent=e}}function zYe(e){return function(){this.textContent=e.apply(this,arguments)??``}}function BYe(e){return arguments.length?this.each(e==null?LYe:(typeof e==`function`?zYe:RYe)(e)):this.node().textContent}function VYe(){this.innerHTML=``}function HYe(e){return function(){this.innerHTML=e}}function UYe(e){return function(){this.innerHTML=e.apply(this,arguments)??``}}function WYe(e){return arguments.length?this.each(e==null?VYe:(typeof e==`function`?UYe:HYe)(e)):this.node().innerHTML}function GYe(){this.nextSibling&&this.parentNode.appendChild(this)}function KYe(){return this.each(GYe)}function qYe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function JYe(){return this.each(qYe)}function YYe(e){var t=typeof e==`function`?e:H3(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function XYe(){return null}function ZYe(e,t){var n=typeof e==`function`?e:H3(e),r=t==null?XYe:typeof t==`function`?t:U3(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function QYe(){var e=this.parentNode;e&&e.removeChild(this)}function $Ye(){return this.each(QYe)}function eXe(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tXe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nXe(e){return this.select(e?tXe:eXe)}function rXe(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function iXe(e){return function(t){e.call(this,t,this.__data__)}}function aXe(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function oXe(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function sXe(e,t,n){return function(){var r=this.__on,i,a=iXe(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function cXe(e,t,n){var r=aXe(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?sXe:oXe,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function n6(e,t,n){var r=Y3(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function lXe(e,t){return function(){return n6(this,e,t)}}function uXe(e,t){return function(){return n6(this,e,t.apply(this,arguments))}}function dXe(e,t){return this.each((typeof t==`function`?uXe:lXe)(e,t))}function*fXe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var r6=[null];function i6(e,t){this._groups=e,this._parents=t}function a6(){return new i6([[document.documentElement]],r6)}function pXe(){return this}i6.prototype=a6.prototype={constructor:i6,select:zJe,selectAll:UJe,selectChild:qJe,selectChildren:ZJe,filter:QJe,data:iYe,enter:$Je,exit:oYe,join:sYe,merge:cYe,selection:pXe,order:lYe,sort:uYe,call:fYe,nodes:pYe,node:mYe,size:hYe,empty:gYe,each:_Ye,attr:wYe,style:OYe,property:MYe,classed:IYe,text:BYe,html:WYe,raise:KYe,lower:JYe,append:YYe,insert:ZYe,remove:$Ye,clone:nXe,datum:rXe,on:cXe,dispatch:dXe,[Symbol.iterator]:fXe};function o6(e){return typeof e==`string`?new i6([[document.querySelector(e)]],[document.documentElement]):new i6([[e]],r6)}function mXe(e){let t;for(;t=e.sourceEvent;)e=t;return e}function s6(e,t){if(e=mXe(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var hXe={passive:!1},c6={capture:!0,passive:!1};function l6(e){e.stopImmediatePropagation()}function u6(e){e.preventDefault(),e.stopImmediatePropagation()}function d6(e){var t=e.document.documentElement,n=o6(e).on(`dragstart.drag`,u6,c6);`onselectstart`in t?n.on(`selectstart.drag`,u6,c6):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function f6(e,t){var n=e.document.documentElement,r=o6(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,u6,c6),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var p6=e=>()=>e;function m6(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}m6.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gXe(e){return!e.ctrlKey&&!e.button}function _Xe(){return this.parentNode}function vXe(e,t){return t??{x:e.x,y:e.y}}function yXe(){return navigator.maxTouchPoints||`ontouchstart`in this}function h6(){var e=gXe,t=_Xe,n=vXe,r=yXe,i={},a=L3(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,hXe).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(o6(n.view).on(`mousemove.drag`,m,c6).on(`mouseup.drag`,h,c6),d6(n.view),l6(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(u6(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){o6(e.view).on(`mousemove.drag mouseup.drag`,null),f6(e.view,l),u6(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(l6(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(u6(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(l6(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=s6(l||r,t),p,m,h;if((h=n.call(e,new m6(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=s6(l||a,t),_=o;break}u.call(r,e,new m6(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:p6(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:p6(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:p6(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:p6(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function g6(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _6(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function v6(){}var y6=.7,b6=1/y6,x6=`\\s*([+-]?\\d+)\\s*`,S6=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,C6=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,bXe=/^#([0-9a-f]{3,8})$/,xXe=RegExp(`^rgb\\(${x6},${x6},${x6}\\)$`),SXe=RegExp(`^rgb\\(${C6},${C6},${C6}\\)$`),CXe=RegExp(`^rgba\\(${x6},${x6},${x6},${S6}\\)$`),wXe=RegExp(`^rgba\\(${C6},${C6},${C6},${S6}\\)$`),TXe=RegExp(`^hsl\\(${S6},${C6},${C6}\\)$`),EXe=RegExp(`^hsla\\(${S6},${C6},${C6},${S6}\\)$`),w6={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};g6(v6,D6,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:T6,formatHex:T6,formatHex8:DXe,formatHsl:OXe,formatRgb:E6,toString:E6});function T6(){return this.rgb().formatHex()}function DXe(){return this.rgb().formatHex8()}function OXe(){return R6(this).formatHsl()}function E6(){return this.rgb().formatRgb()}function D6(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=bXe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?O6(t):n===3?new j6(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?k6(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?k6(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=xXe.exec(e))?new j6(t[1],t[2],t[3],1):(t=SXe.exec(e))?new j6(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=CXe.exec(e))?k6(t[1],t[2],t[3],t[4]):(t=wXe.exec(e))?k6(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=TXe.exec(e))?L6(t[1],t[2]/100,t[3]/100,1):(t=EXe.exec(e))?L6(t[1],t[2]/100,t[3]/100,t[4]):w6.hasOwnProperty(e)?O6(w6[e]):e===`transparent`?new j6(NaN,NaN,NaN,0):null}function O6(e){return new j6(e>>16&255,e>>8&255,e&255,1)}function k6(e,t,n,r){return r<=0&&(e=t=n=NaN),new j6(e,t,n,r)}function kXe(e){return e instanceof v6||(e=D6(e)),e?(e=e.rgb(),new j6(e.r,e.g,e.b,e.opacity)):new j6}function A6(e,t,n,r){return arguments.length===1?kXe(e):new j6(e,t,n,r??1)}function j6(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}g6(j6,A6,_6(v6,{brighter(e){return e=e==null?b6:b6**+e,new j6(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?y6:y6**+e,new j6(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new j6(F6(this.r),F6(this.g),F6(this.b),P6(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:M6,formatHex:M6,formatHex8:AXe,formatRgb:N6,toString:N6}));function M6(){return`#${I6(this.r)}${I6(this.g)}${I6(this.b)}`}function AXe(){return`#${I6(this.r)}${I6(this.g)}${I6(this.b)}${I6((isNaN(this.opacity)?1:this.opacity)*255)}`}function N6(){let e=P6(this.opacity);return`${e===1?`rgb(`:`rgba(`}${F6(this.r)}, ${F6(this.g)}, ${F6(this.b)}${e===1?`)`:`, ${e})`}`}function P6(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function F6(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function I6(e){return e=F6(e),(e<16?`0`:``)+e.toString(16)}function L6(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new z6(e,t,n,r)}function R6(e){if(e instanceof z6)return new z6(e.h,e.s,e.l,e.opacity);if(e instanceof v6||(e=D6(e)),!e)return new z6;if(e instanceof z6)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new z6(o,s,c,e.opacity)}function jXe(e,t,n,r){return arguments.length===1?R6(e):new z6(e,t,n,r??1)}function z6(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}g6(z6,jXe,_6(v6,{brighter(e){return e=e==null?b6:b6**+e,new z6(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?y6:y6**+e,new z6(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new j6(H6(e>=240?e-240:e+120,i,r),H6(e,i,r),H6(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new z6(B6(this.h),V6(this.s),V6(this.l),P6(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=P6(this.opacity);return`${e===1?`hsl(`:`hsla(`}${B6(this.h)}, ${V6(this.s)*100}%, ${V6(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function B6(e){return e=(e||0)%360,e<0?e+360:e}function V6(e){return Math.max(0,Math.min(1,e||0))}function H6(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var U6=e=>()=>e;function MXe(e,t){return function(n){return e+n*t}}function NXe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function PXe(e){return(e=+e)==1?W6:function(t,n){return n-t?NXe(t,n,e):U6(isNaN(t)?n:t)}}function W6(e,t){var n=t-e;return n?MXe(e,n):U6(isNaN(e)?t:e)}var G6=(function e(t){var n=PXe(t);function r(e,t){var r=n((e=A6(e)).r,(t=A6(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=W6(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function FXe(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function IXe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function LXe(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=X6(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function RXe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function K6(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function zXe(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=X6(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var q6=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,J6=new RegExp(q6.source,`g`);function BXe(e){return function(){return e}}function VXe(e){return function(t){return e(t)+``}}function Y6(e,t){var n=q6.lastIndex=J6.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=q6.exec(e))&&(i=J6.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:K6(r,i)})),n=J6.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?VXe(c[0].x):BXe(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function X6(e,t){var n=typeof t,r;return t==null||n===`boolean`?U6(t):(n===`number`?K6:n===`string`?(r=D6(t))?(t=r,G6):Y6:t instanceof D6?G6:t instanceof Date?RXe:IXe(t)?FXe:Array.isArray(t)?LXe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?zXe:K6)(e,t)}var Z6=180/Math.PI,Q6={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $6(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Z6,skewX:Math.atan(c)*Z6,scaleX:o,scaleY:s}}var e8;function HXe(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?Q6:$6(t.a,t.b,t.c,t.d,t.e,t.f)}function UXe(e){return e==null||(e8||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),e8.setAttribute(`transform`,e),!(e=e8.transform.baseVal.consolidate()))?Q6:(e=e.matrix,$6(e.a,e.b,e.c,e.d,e.e,e.f))}function t8(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:K6(e,i)},{i:c-2,x:K6(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:K6(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:K6(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:K6(e,n)},{i:s-2,x:K6(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var WXe=t8(HXe,`px, `,`px)`,`deg)`),GXe=t8(UXe,`, `,`)`,`)`),KXe=1e-12;function n8(e){return((e=Math.exp(e))+1/e)/2}function qXe(e){return((e=Math.exp(e))-1/e)/2}function JXe(e){return((e=Math.exp(2*e))-1)/(e+1)}var r8=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<KXe)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=n8(y),c=s/(n*g)*(i*JXe(t*r+y)-qXe(y));return[a+c*d,o+c*f,s*i/n8(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),i8=0,a8=0,o8=0,s8=1e3,c8,l8,u8=0,d8=0,f8=0,p8=typeof performance==`object`&&performance.now?performance:Date,m8=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function h8(){return d8||=(m8(YXe),p8.now()+f8)}function YXe(){d8=0}function g8(){this._call=this._time=this._next=null}g8.prototype=_8.prototype={constructor:g8,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?h8():+n)+(t==null?0:+t),!this._next&&l8!==this&&(l8?l8._next=this:c8=this,l8=this),this._call=e,this._time=n,y8()},stop:function(){this._call&&(this._call=null,this._time=1/0,y8())}};function _8(e,t,n){var r=new g8;return r.restart(e,t,n),r}function XXe(){h8(),++i8;for(var e=c8,t;e;)(t=d8-e._time)>=0&&e._call.call(void 0,t),e=e._next;--i8}function v8(){d8=(u8=p8.now())+f8,i8=a8=0;try{XXe()}finally{i8=0,QXe(),d8=0}}function ZXe(){var e=p8.now(),t=e-u8;t>s8&&(f8-=t,u8=e)}function QXe(){for(var e,t=c8,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:c8=n);l8=e,y8(r)}function y8(e){i8||(a8&&=clearTimeout(a8),e-d8>24?(e<1/0&&(a8=setTimeout(v8,e-p8.now()-f8)),o8&&=clearInterval(o8)):(o8||=(u8=p8.now(),setInterval(ZXe,s8)),i8=1,m8(v8)))}function b8(e,t,n){var r=new g8;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var $Xe=L3(`start`,`end`,`cancel`,`interrupt`),eZe=[];function x8(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;tZe(e,n,{name:t,index:r,group:i,on:$Xe,tween:eZe,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function S8(e,t){var n=w8(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function C8(e,t){var n=w8(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function w8(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function tZe(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=_8(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return b8(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(b8(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function T8(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function nZe(e){return this.each(function(){T8(this,e)})}function rZe(e,t){var n,r;return function(){var i=C8(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function iZe(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=C8(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function aZe(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=w8(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?rZe:iZe)(n,e,t))}function E8(e,t,n){var r=e._id;return e.each(function(){var e=C8(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return w8(e,r).value[t]}}function D8(e,t){var n;return(typeof t==`number`?K6:t instanceof D6?G6:(n=D6(t))?(t=n,G6):Y6)(e,t)}function oZe(e){return function(){this.removeAttribute(e)}}function sZe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cZe(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function lZe(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function uZe(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function dZe(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function fZe(e,t){var n=V3(e),r=n===`transform`?GXe:D8;return this.attrTween(e,typeof t==`function`?(n.local?dZe:uZe)(n,r,E8(this,`attr.`+e,t)):t==null?(n.local?sZe:oZe)(n):(n.local?lZe:cZe)(n,r,t))}function pZe(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function mZe(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&mZe(e,i)),n}return i._value=t,i}function gZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&pZe(e,i)),n}return i._value=t,i}function _Ze(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=V3(e);return this.tween(n,(r.local?hZe:gZe)(r,t))}function vZe(e,t){return function(){S8(this,e).delay=+t.apply(this,arguments)}}function yZe(e,t){return t=+t,function(){S8(this,e).delay=t}}function bZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?vZe:yZe)(t,e)):w8(this.node(),t).delay}function xZe(e,t){return function(){C8(this,e).duration=+t.apply(this,arguments)}}function SZe(e,t){return t=+t,function(){C8(this,e).duration=t}}function CZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?xZe:SZe)(t,e)):w8(this.node(),t).duration}function wZe(e,t){if(typeof t!=`function`)throw Error();return function(){C8(this,e).ease=t}}function TZe(e){var t=this._id;return arguments.length?this.each(wZe(t,e)):w8(this.node(),t).ease}function EZe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();C8(this,e).ease=n}}function DZe(e){if(typeof e!=`function`)throw Error();return this.each(EZe(this._id,e))}function OZe(e){typeof e!=`function`&&(e=G3(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new k8(r,this._parents,this._name,this._id)}function kZe(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new k8(o,this._parents,this._name,this._id)}function AZe(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function jZe(e,t,n){var r,i,a=AZe(t)?S8:C8;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function MZe(e,t){var n=this._id;return arguments.length<2?w8(this.node(),n).on.on(e):this.each(jZe(n,e,t))}function NZe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function PZe(){return this.on(`end.remove`,NZe(this._id))}function FZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=U3(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,x8(l[f],t,n,f,l,w8(u,n)));return new k8(a,this._parents,t,n)}function IZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=W3(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=w8(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&x8(p,t,n,h,f,m);a.push(f),o.push(u)}return new k8(a,o,t,n)}var LZe=a6.prototype.constructor;function RZe(){return new LZe(this._groups,this._parents)}function zZe(e,t){var n,r,i;return function(){var a=X3(this,e),o=(this.style.removeProperty(e),X3(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function O8(e){return function(){this.style.removeProperty(e)}}function BZe(e,t,n){var r,i=n+``,a;return function(){var o=X3(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function VZe(e,t,n){var r,i,a;return function(){var o=X3(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),X3(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function HZe(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=C8(this,e),l=c.on,u=c.value[a]==null?s||=O8(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function UZe(e,t,n){var r=(e+=``)==`transform`?WXe:D8;return t==null?this.styleTween(e,zZe(e,r)).on(`end.style.`+e,O8(e)):typeof t==`function`?this.styleTween(e,VZe(e,r,E8(this,`style.`+e,t))).each(HZe(this._id,e)):this.styleTween(e,BZe(e,r,t),n).on(`end.style.`+e,null)}function WZe(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function GZe(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&WZe(e,a,n)),r}return a._value=t,a}function KZe(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,GZe(e,t,n??``))}function qZe(e){return function(){this.textContent=e}}function JZe(e){return function(){this.textContent=e(this)??``}}function YZe(e){return this.tween(`text`,typeof e==`function`?JZe(E8(this,`text`,e)):qZe(e==null?``:e+``))}function XZe(e){return function(t){this.textContent=e.call(this,t)}}function ZZe(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&XZe(r)),t}return r._value=e,r}function QZe(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,ZZe(e))}function $Ze(){for(var e=this._name,t=this._id,n=A8(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=w8(c,t);x8(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new k8(r,this._parents,e,n)}function eQe(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=C8(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var tQe=0;function k8(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function nQe(e){return a6().transition(e)}function A8(){return++tQe}var j8=a6.prototype;k8.prototype=nQe.prototype={constructor:k8,select:FZe,selectAll:IZe,selectChild:j8.selectChild,selectChildren:j8.selectChildren,filter:OZe,merge:kZe,selection:RZe,transition:$Ze,call:j8.call,nodes:j8.nodes,node:j8.node,size:j8.size,empty:j8.empty,each:j8.each,on:MZe,attr:fZe,attrTween:_Ze,style:UZe,styleTween:KZe,text:YZe,textTween:QZe,remove:PZe,tween:aZe,delay:bZe,duration:CZe,ease:TZe,easeVarying:DZe,end:eQe,[Symbol.iterator]:j8[Symbol.iterator]};function rQe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var iQe={time:null,delay:0,duration:250,ease:rQe};function aQe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function oQe(e){var t,n;e instanceof k8?(t=e._id,e=e._name):(t=A8(),(n=iQe).time=h8(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&x8(c,e,t,l,o,n||aQe(c,t));return new k8(r,this._parents,e,t)}a6.prototype.interrupt=nZe,a6.prototype.transition=oQe;var M8=e=>()=>e;function sQe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function N8(e,t,n){this.k=e,this.x=t,this.y=n}N8.prototype={constructor:N8,scale:function(e){return e===1?this:new N8(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new N8(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var P8=new N8(1,0,0);F8.prototype=N8.prototype;function F8(e){for(;!e.__zoom;)if(!(e=e.parentNode))return P8;return e.__zoom}function I8(e){e.stopImmediatePropagation()}function L8(e){e.preventDefault(),e.stopImmediatePropagation()}function cQe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function lQe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function R8(){return this.__zoom||P8}function uQe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function dQe(){return navigator.maxTouchPoints||`ontouchstart`in this}function fQe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function z8(){var e=cQe,t=lQe,n=fQe,r=uQe,i=dQe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=r8,l=L3(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,R8).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,R8),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(P8.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new N8(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new N8(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new N8(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=o6(this.that).datum();l.call(e,this.that,new sQe(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=s6(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],T8(this),s.start();L8(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=o6(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=s6(t,i),l=t.clientX,u=t.clientY;d6(t.view),I8(t),a.mouse=[c,this.__zoom.invert(c)],T8(this),a.start();function d(e){if(L8(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=s6(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),f6(e.view,a.moved),L8(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=s6(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);L8(r),s>0?o6(this).transition().duration(s).call(x,d,c,r):o6(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(I8(t),s=0;s<i;++s)c=r[s],l=s6(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),T8(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(L8(e),s=0;s<a;++s)c=i[s],l=s6(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(I8(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=s6(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=o6(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:M8(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:M8(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:M8(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:M8([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var B8={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},V8=[[-1/0,-1/0],[1/0,1/0]],H8=[`Enter`,` `,`Escape`],U8={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},W8;(function(e){e.Strict=`strict`,e.Loose=`loose`})(W8||={});var G8;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(G8||={});var K8;(function(e){e.Partial=`partial`,e.Full=`full`})(K8||={});var q8={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},J8;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(J8||={});var Y8;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(Y8||={});var X8;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(X8||={});var Z8={[X8.Left]:X8.Right,[X8.Right]:X8.Left,[X8.Top]:X8.Bottom,[X8.Bottom]:X8.Top};function Q8(e){return e===null?null:e?`valid`:`invalid`}var $8=e=>`id`in e&&`source`in e&&`target`in e,pQe=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),e5=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),t5=(e,t=[0,0])=>{let{width:n,height:r}=E5(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},mQe=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:f5(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):e5(n)?n:t.nodeLookup.get(n.id)),u5(e,i?m5(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),n5=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=u5(n,m5(e)),r=!0)}),r?f5(n):{x:0,y:0,width:0,height:0}},r5=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...b5(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=g5(s,p5(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},hQe=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function gQe(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function _Qe({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=C5(n5(gQe(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function i5({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,B8.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&T5(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=T5(d)?o5(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,B8.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function vQe({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=hQe(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var a5=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),o5=(e={x:0,y:0},t,n)=>({x:a5(e.x,t[0][0],t[1][0]-(n?.width??0)),y:a5(e.y,t[0][1],t[1][1]-(n?.height??0))});function s5(e,t,n){let{width:r,height:i}=E5(n),{x:a,y:o}=n.internals.positionAbsolute;return o5(e,[[a,o],[a+r,o+i]],t)}var c5=(e,t,n)=>e<t?a5(Math.abs(e-t),1,t)/t:e>n?-a5(Math.abs(e-n),1,t)/t:0,l5=(e,t,n=15,r=40)=>[c5(e.x,r,t.width-r)*n,c5(e.y,r,t.height-r)*n],u5=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),d5=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),f5=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),p5=(e,t=[0,0])=>{let{x:n,y:r}=e5(e)?e.internals.positionAbsolute:t5(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},m5=(e,t=[0,0])=>{let{x:n,y:r}=e5(e)?e.internals.positionAbsolute:t5(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},h5=(e,t)=>f5(u5(d5(e),d5(t))),g5=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},_5=e=>v5(e.width)&&v5(e.height)&&v5(e.x)&&v5(e.y),v5=e=>!isNaN(e)&&isFinite(e),yQe=(e,t)=>{},y5=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),b5=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?y5(s,o):s},x5=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function S5(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function bQe(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=S5(e,n),i=S5(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=S5(e.top??e.y??0,n),i=S5(e.bottom??e.y??0,n),a=S5(e.left??e.x??0,t),o=S5(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xQe(e,t,n,r,i,a){let{x:o,y:s}=x5(e,[t,n,r]),{x:c,y:l}=x5({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var C5=(e,t,n,r,i,a)=>{let o=bQe(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=a5(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=xQe(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},w5=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function T5(e){return e!=null&&e!==`parent`}function E5(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function D5(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function O5(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function k5(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function SQe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function CQe(e){return{...U8,...e||{}}}function A5(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=F5(e),s=b5({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?y5(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var j5=e=>({width:e.offsetWidth,height:e.offsetHeight}),M5=e=>e?.getRootNode?.()||window?.document,wQe=[`INPUT`,`SELECT`,`TEXTAREA`];function N5(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?wQe.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var P5=e=>`clientX`in e,F5=(e,t)=>{let n=P5(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},I5=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...j5(t)}})};function L5({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function R5(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function z5({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case X8.Left:return[t-R5(t-r,a),n];case X8.Right:return[t+R5(r-t,a),n];case X8.Top:return[t,n-R5(n-i,a)];case X8.Bottom:return[t,n+R5(i-n,a)]}}function B5({sourceX:e,sourceY:t,sourcePosition:n=X8.Bottom,targetX:r,targetY:i,targetPosition:a=X8.Top,curvature:o=.25}){let[s,c]=z5({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=z5({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=L5({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function V5({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function TQe({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function EQe({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=u5(m5(e),m5(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),g5({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},f5(a))>0}var DQe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,OQe=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),kQe=(e,t,n={})=>{if(!e.source||!e.target)return B8.error006(),t;let r=n.getEdgeId||DQe,i;return i=$8(e)?{...e}:{...e,id:r(e)},OQe(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function H5({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=V5({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var U5={[X8.Left]:{x:-1,y:0},[X8.Right]:{x:1,y:0},[X8.Top]:{x:0,y:-1},[X8.Bottom]:{x:0,y:1}},AQe=({source:e,sourcePosition:t=X8.Bottom,target:n})=>t===X8.Left||t===X8.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},W5=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function jQe({source:e,sourcePosition:t=X8.Bottom,target:n,targetPosition:r=X8.Top,center:i,offset:a,stepPosition:o}){let s=U5[t],c=U5[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=AQe({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=V5({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function MQe(e,t,n,r){let i=Math.min(W5(e,t)/2,W5(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function G5({sourceX:e,sourceY:t,sourcePosition:n=X8.Bottom,targetX:r,targetY:i,targetPosition:a=X8.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=jQe({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=MQe(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function K5(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function NQe(e){let{sourceNode:t,targetNode:n}=e;if(!K5(t)||!K5(n))return null;let r=t.internals.handleBounds||q5(t.handles),i=n.internals.handleBounds||q5(n.handles),a=Y5(r?.source??[],e.sourceHandle),o=Y5(e.connectionMode===W8.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,B8.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||X8.Bottom,c=o?.position||X8.Top,l=J5(t,a,s),u=J5(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function q5(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function J5(e,t,n=X8.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??E5(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case X8.Top:return{x:i+o/2,y:a};case X8.Right:return{x:i+o,y:a+s/2};case X8.Bottom:return{x:i+o/2,y:a+s};case X8.Left:return{x:i,y:a+s/2}}}function Y5(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function X5(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function PQe(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=X5(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Z5=1e3,FQe=10,Q5={nodeOrigin:[0,0],nodeExtent:V8,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},IQe={...Q5,checkEquality:!0};function $5(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function LQe(e,t,n){let r=$5(Q5,n);for(let n of e.values())if(n.parentId)n7(n,e,t,r);else{let e=o5(t5(n,r.nodeOrigin),T5(n.extent)?n.extent:r.nodeExtent,E5(n));n.internals.positionAbsolute=e}}function RQe(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function e7(e){return e===`manual`}function t7(e,t,n,r={}){let i=$5(IQe,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!e7(i.zIndexMode)?Z5:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=o5(t5(u,i.nodeOrigin),T5(u.extent)?u.extent:i.nodeExtent,E5(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:RQe(u,e),z:r7(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&n7(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function zQe(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function n7(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=$5(Q5,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}zQe(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*FQe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=BQe(e,u,o,s,a&&!e7(c)?Z5:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function r7(e,t,n){let r=v5(e.zIndex)?e.zIndex:0;return e7(n)?r:r+(e.selected?t:0)}function BQe(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=E5(e),l=t5(e,n),u=T5(e.extent)?o5(l,e.extent,c):l,d=o5({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=s5(d,c,t));let f=r7(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function i7(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=h5(a.get(n.parentId)?.expandedRect??p5(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=E5(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function VQe(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=j5(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=T5(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=s5(h,s,t.get(e.parentId)):m&&(h=o5(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:I5(`source`,r.nodeElement,p,d,e.id),target:I5(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&n7(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:p5(g,i)}))}}if(f.length>0){let e=i7(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function HQe({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function a7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function o7(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;a7(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),a7(`target`,s,c,e,i,o),t.set(r.id,r)}}function s7(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:s7(n,t):!1}function c7(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function UQe(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!s7(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function l7({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function WQe({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=y5(a,t);return{x:o.x-a.x,y:o.y-a.y}}function GQe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=o6(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?d5(n5(s)):null,x=v&&l?WQe({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:y5(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=i5({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=l7({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=l5(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=A5(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=UQe(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=l7({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=h6().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=A5(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=F5(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=A5(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=F5(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=F5(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=l7({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!c7(t,`.${g}`,v))&&(!_||c7(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function KQe(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())g5(i,p5(e))>0&&r.push(e);return r}var qQe=250;function JQe(e,t,n,r){let i=[],a=1/0,o=KQe(e,n,t+qQe);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=J5(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function u7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...J5(o,c,c.position,!0)}:c}function d7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function YQe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var f7=()=>!0;function XQe(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=f7,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=M5(e.target),E=0,D,{x:O,y:k}=F5(e),A=d7(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=u7(i,A,r,c,t);if(!N)return;let P=F5(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=l5(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},te=c.get(i),B={inProgress:!0,isValid:null,from:J5(te,z,X8.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:te,to:P,toHandle:null,toPosition:Z8[z.position],toNode:null,pointer:P};function V(){M=!0,y(B),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&V();function ne(e){if(!M){let{x:t,y:n}=F5(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;V()}if(!x()||!z){re(e);return}let a=b();P=F5(e,j),D=JQe(b5(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=p7(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=YQe(!!D,s.isValid);let u=c.get(i),f=u?J5(u,z,X8.Left,!0):B.from,p={...B,from:f,isValid:L,to:s.toHandle&&L?x5({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Z8[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),B=p}function re(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ne),T.removeEventListener(`mouseup`,re),T.removeEventListener(`touchmove`,ne),T.removeEventListener(`touchend`,re)}}T.addEventListener(`mousemove`,ne),T.addEventListener(`mouseup`,re),T.addEventListener(`touchmove`,ne),T.addEventListener(`touchend`,re)}function p7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=f7,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=F5(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=d7(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===W8.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=u7(t,e,a,u,n,!0)}return _}var m7={onPointerDown:XQe,isValid:p7};function ZQe({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=o6(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&w5()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=z8().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:s6}}var h7=e=>({x:e.x,y:e.y,zoom:e.k}),g7=({x:e,y:t,zoom:n})=>P8.translate(e,t).scale(n),_7=(e,t)=>e.target.closest(`.${t}`),v7=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),QQe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,y7=(e,t=0,n=QQe,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},b7=e=>{let t=e.ctrlKey&&w5()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function $Qe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(_7(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=s6(u),t=d*2**b7(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===G8.Vertical?0:u.deltaX*f,m=i===G8.Horizontal?0:u.deltaY*f;!w5()&&u.shiftKey&&i!==G8.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=h7(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function e$e({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=_7(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function t$e({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=h7(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function n$e({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&v7(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,h7(a.transform))}}function r$e({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&v7(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=h7(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function i$e({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(_7(d,`${l}-flow__node`)||_7(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||_7(d,s)&&m||_7(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function a$e({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=z8().scaleExtent([t,n]).translateExtent(r),f=o6(e).call(d);v({x:i.x,y:i.y,zoom:a5(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(b7);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?X6:r8).transform(y7(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!v5(E)||E<0?0:E);let k=O?$Qe({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):e$e({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=t$e({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=n$e({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=r$e({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=i$e({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=g7(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=g7(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=g7(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?F8(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?X6:r8).scaleTo(y7(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?X6:r8).scaleBy(y7(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!v5(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var x7;(function(e){e.Line=`line`,e.Handle=`handle`})(x7||={});function o$e({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function S7(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function C7(e,t){return Math.max(0,t-e)}function w7(e,t){return Math.max(0,e-t)}function T7(e,t,n){return Math.max(0,t-e,e-n)}function E7(e,t){return e?!t:t}function s$e(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=T7(E,h,g),j=T7(D,_,v);if(o){let e=0,t=0;c&&w<0?e=C7(y+w+O,o[0][0]):!c&&w>0&&(e=w7(y+E+O,o[1][0])),l&&T<0?t=C7(b+T+k,o[0][1]):!l&&T>0&&(t=w7(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=w7(y+w,s[0][0]):!c&&w<0&&(e=C7(y+E,s[1][0])),l&&T>0?t=w7(b+T,s[0][1]):!l&&T<0&&(t=C7(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=T7(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?w7(b+k+E/C,o[1][1])*C:C7(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?C7(b+E/C,s[1][1])*C:w7(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=T7(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?w7(y+D*C+O,o[1][0])/C:C7(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?C7(y+D*C,s[1][0])/C:w7(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(E7(c,l)?-w:w)/C:w=(E7(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var c$e={width:0,height:0,x:0,y:0},l$e={...c$e,pointerX:0,pointerY:0,aspectRatio:1};function u$e(e){return[[0,0],[e.measured.width,e.measured.height]]}function d$e(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function f$e({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=o6(e),o={controlDirection:S7(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...c$e},h={...l$e};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:S7(e)};let g,_=null,v=[],y,b,x,S=!1,C=h6().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=A5(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?u$e(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=d$e(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=A5(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=s$e(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=o$e({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var p$e=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},m$e=e=>e?p$e(e):p$e,{useDebugValue:h$e}=C.default,{useSyncExternalStoreWithSelector:g$e}=LC.default,_$e=e=>e;function v$e(e,t=_$e,n){let r=g$e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return h$e(r),r}var y$e=(e,t)=>{let n=m$e(e),r=(e,r=t)=>v$e(n,e,r);return Object.assign(r,n),r},b$e=(e,t)=>e?y$e(e,t):y$e;function D7(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var O7=(0,C.createContext)(null),x$e=O7.Provider,S$e=B8.error001();function k7(e,t){let n=(0,C.useContext)(O7);if(n===null)throw Error(S$e);return v$e(n,e,t)}function A7(){let e=(0,C.useContext)(O7);if(e===null)throw Error(S$e);return(0,C.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var C$e={display:`none`},w$e={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},T$e=`react-flow__node-desc`,E$e=`react-flow__edge-desc`,D$e=`react-flow__aria-live`,O$e=e=>e.ariaLiveMessage,k$e=e=>e.ariaLabelConfig;function A$e({rfId:e}){let t=k7(O$e);return(0,G.jsx)(`div`,{id:`${D$e}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:w$e,children:t})}function j$e({rfId:e,disableKeyboardA11y:t}){let n=k7(k$e);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{id:`${T$e}-${e}`,style:C$e,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,G.jsx)(`div`,{id:`${E$e}-${e}`,style:C$e,children:n[`edge.a11yDescription.default`]}),!t&&(0,G.jsx)(A$e,{rfId:e})]})}var j7=(0,C.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,G.jsx)(`div`,{className:I3([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));j7.displayName=`Panel`;function M$e({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,G.jsx)(j7,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,G.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var N$e=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},M7=e=>e.id;function P$e(e,t){return D7(e.selectedNodes.map(M7),t.selectedNodes.map(M7))&&D7(e.selectedEdges.map(M7),t.selectedEdges.map(M7))}function F$e({onSelectionChange:e}){let t=A7(),{selectedNodes:n,selectedEdges:r}=k7(N$e,P$e);return(0,C.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var I$e=e=>!!e.onSelectionChangeHandlers;function L$e({onSelectionChange:e}){let t=k7(I$e);return e||t?(0,G.jsx)(F$e,{onSelectionChange:e}):null}var N7=typeof window<`u`?C.useLayoutEffect:C.useEffect,R$e=[0,0],z$e={x:0,y:0,zoom:1},B$e=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],V$e=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),H$e={translateExtent:V8,nodeOrigin:R$e,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function U$e(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=k7(V$e,D7),l=A7();N7(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=H$e,s()}),[]);let u=(0,C.useRef)(H$e);return N7(()=>{for(let s of B$e){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:CQe(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},B$e.map(t=>e[t])),null}function W$e(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function G$e(e){let[t,n]=(0,C.useState)(e===`system`?null:e);return(0,C.useEffect)(()=>{if(e!==`system`){n(e);return}let t=W$e(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?W$e()?.matches?`dark`:`light`:t}var K$e=typeof document<`u`?document:null;function P7(e=null,t={target:K$e,actInsideInputWithModifier:!0}){let[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(!1),a=(0,C.useRef)(new Set([])),[o,s]=(0,C.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
463
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=$4(Q4(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=$4(Q4(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function n3(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new J4||null,prettyErrors:t}}function bqe(e,t={}){let{lineCounter:n,prettyErrors:r}=n3(t),i=new t3(n?.addNewLine),a=new N4(t),o=Array.from(a.compose(i.parse(e)));if(r&&n)for(let t of o)t.errors.forEach(h4(e,n)),t.warnings.forEach(h4(e,n));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function r3(e,t={}){let{lineCounter:n,prettyErrors:r}=n3(t),i=new t3(n?.addNewLine),a=new N4(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new p4(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(h4(e,n)),o.warnings.forEach(h4(e,n))),o}function xqe(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=r3(e,n);if(!i)return null;if(i.warnings.forEach(e=>l2(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function Sqe(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return h0(e)&&!r?e.toString(n):new u4(e,r,n).toString(n)}var Cqe=c({Alias:()=>B0,CST:()=>mqe,Composer:()=>N4,Document:()=>u4,Lexer:()=>q4,LineCounter:()=>J4,Pair:()=>g2,Parser:()=>t3,Scalar:()=>U0,Schema:()=>l4,YAMLError:()=>f4,YAMLMap:()=>b2,YAMLParseError:()=>p4,YAMLSeq:()=>S2,YAMLWarning:()=>m4,isAlias:()=>m0,isCollection:()=>b0,isDocument:()=>h0,isMap:()=>g0,isNode:()=>x0,isPair:()=>_0,isScalar:()=>v0,isSeq:()=>y0,parse:()=>xqe,parseAllDocuments:()=>bqe,parseDocument:()=>r3,stringify:()=>Sqe,visit:()=>E0,visitAsync:()=>O0});function wqe(e){let t=null;try{t=Cqe.parse(e.doc.toString())}catch{}let n=xJ(e,_J.YAML);return{data:t,pointers:n}}var i3=e=>{switch(e){case _J.JSON:return dKe;case _J.JSON5:return pKe;case _J.YAML:return wqe}};function Tqe(e){return Object.entries(e)}function a3(e,t){if(typeof e==`string`||typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>a3(e,t));if(e instanceof Map){let n=new Map;for(let[r,i]of e){let e=r,a=a3(i,t);n.set(e,a)}return n}if(e instanceof Set){let n=new Set;for(let r of e){let e=a3(r,t);n.add(e)}return n}let n={};function r(e,r,i,a){i===e&&a===r?n[i]=a3(r,t):n[i]=a}for(let[n,i]of Tqe(e)){let e=t(n,i);if(e.length===2&&typeof e[0]==`string`)r(n,i,e[0],e[1]);else for(let[t,a]of e)r(n,i,t,a)}return n}var Eqe=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Dqe=class{constructor(){this.completions=new Map,this.reservedKeys=new Set}reserve(e){this.reservedKeys.add(e)}add(e){this.reservedKeys.has(e.label)||this.completions.set(e.label,e)}};function o3(e){return!(!e||BJ(e)||e.name===`UnknownPropertyError`||e.type===`undefined`)}var Oqe=class{constructor(e){this.opts=e,this.originalSchema=null,this.schema=null,this.laxSchema=null,this.mode=_J.JSON,this.mode=e.mode??_J.JSON,this.parser=this.opts?.jsonParser??i3(this.mode)}doComplete(e){let t=PJ(e.state);if(this.originalSchema!==t&&(this.schema=l3(t,t)??t,this.laxSchema=Aqe(this.schema)),!this.schema||!this.laxSchema)return[];pJ.log(`xxx`,`trying with original schema`);let n=this.doCompleteForSchema(e,this.schema);return n.options.length===0?(pJ.log(`xxx`,`no completions with original schema, trying with lax schema`),this.doCompleteForSchema(e,this.laxSchema)):n}doCompleteForSchema(e,t){let n={from:e.pos,to:e.pos,options:[],filter:!1},r=e.state.doc.sliceString(0),i=SJ(e.state,e.pos),a=e.state.sliceDoc(i.from,e.pos).replace(/^(["'])/,``);if(pJ.log(`xxx`,`node`,i,`prefix`,a,`ctx`,e),!(EJ(i,this.mode)||DJ(i,this.mode))&&!e.explicit)return pJ.log(`xxx`,`no completions for non-word/primitive`,i),n;let o=wJ(e.state.doc,i),s=wJ(e.state.doc,i,!1);if(i&&(EJ(i,this.mode)||DJ(i,this.mode)))n.from=i.from,n.to=i.to;else{let t=e.matchBefore(/[A-Za-z0-9._]*/),a=e.pos-o.length;pJ.log(`xxx`,`overwriteStart after`,a,`ctx.pos`,e.pos,`word`,t,`currentWord`,o,`=>`,r[a-1],`..`,r[a],`..`,r),n.from=i.name===mJ.INVALID?t?.from??e.pos:a,n.to=e.pos}let c=new Dqe,l=!0,u=MJ(i,mJ.PROPERTY_NAME,this.mode);if(u&&(pJ.log(`xxx`,`closestPropertyNameNode`,u,`node`,i),i=u),DJ(i,this.mode)){pJ.log(`xxx`,`isPropertyNameNode`,i);let e=i.parent;if(e){let t=AJ(e,this.mode);l=!t||t.name===mJ.INVALID&&t.from-t.to===0||(t.parent?OJ(t.parent).length<=1:!1),pJ.log(`xxx`,`addValue`,l,AJ(e,this.mode),i),i=MJ(e,mJ.OBJECT,this.mode)??null}}if(pJ.log(`xxx`,i,o,e,`node at pos`,SJ(e.state,e.pos)),i&&[mJ.OBJECT,mJ.JSON_TEXT].includes(vJ(i.name,this.mode))&&(DJ(SJ(e.state,e.pos),this.mode)||u)){if(i.from===e.pos)return pJ.log(`xxx`,`no completions for just before opening brace`),n;this.getPropertyCompletions(t,e,i,c,l,s)}else{let n=this.getValueCompletions(t,e,{},c);pJ.log(`xxx`,`getValueCompletions res`,n)}return n.options=Array.from(c.completions.values()).filter(e=>CJ(e.label).startsWith(a)),pJ.log(`xxx`,`result`,n,`prefix`,a,`collector.completions`,c.completions,`reservedKeys`,c.reservedKeys),n}applySnippetCompletion(e){return ALe(typeof e.apply==`string`?e.apply:e.label,e)}getPropertyCompletions(e,t,n,r,i,a){let o=fRe(n,mJ.PROPERTY,this.mode);pJ.log(`xxx`,`getPropertyCompletions`,n,t,o),o.forEach(e=>{let n=wJ(t.state.doc,kJ(e,mJ.PROPERTY_NAME,this.mode));r.reserve(CJ(n))});let s=this.getSchemas(e,t);pJ.log(`xxx`,`propertyCompletion schemas`,s),s.forEach(t=>{if(typeof t!=`object`)return;let n=t.properties;n&&Object.entries(n).forEach(([t,n])=>{if(typeof n==`object`){let o=n.description??``,s=n.type??``,c=Array.isArray(s)?s.toString():s,l={label:t,apply:this.getInsertTextForProperty(t,i,a,e,n),type:`property`,detail:c,info:()=>VX(`div`,{inner:a0(o)})};r.add(this.applySnippetCompletion(l))}});let o=t.propertyNames;if(typeof o==`object`&&(o.enum&&o.enum.forEach(t=>{let n=t?.toString();if(n){let t={label:n,apply:this.getInsertTextForProperty(n,i,a,e),type:`property`};r.add(this.applySnippetCompletion(t))}}),o.const)){let t=o.const.toString(),n={label:t,apply:this.getInsertTextForProperty(t,i,a,e),type:`property`};r.add(this.applySnippetCompletion(n))}})}getInsertTextForProperty(e,t,n,r,i){i&&=l3(i,r);let a=this.getInsertTextForPropertyName(e,n);if(!t)return a;a+=`: `;let o,s=0;if(typeof i==`object`){if(i.default!==void 0)o||=this.getInsertTextForGuessedValue(i.default,``),s++;else if(i.enum&&(!o&&i.enum.length===1&&(o=this.getInsertTextForGuessedValue(i.enum[0],``)),s+=i.enum.length),i.const!==void 0&&(o||=this.getInsertTextForGuessedValue(i.const,``),s++),Array.isArray(i.examples)&&i.examples.length&&(o||=this.getInsertTextForGuessedValue(i.examples[0],``),s+=i.examples.length),o===void 0&&s===0){let e=Array.isArray(i.type)?i.type[0]:i.type;switch(e||(i.properties?e=`object`:i.items&&(e=`array`)),e){case`boolean`:o=`#{}`;break;case`string`:o=this.getInsertTextForString(``);break;case`object`:switch(this.mode){case _J.JSON5:o=`{#{}}`;break;case _J.YAML:o=`#{}`;break;default:o=`{#{}}`;break}break;case`array`:o=`[#{}]`;break;case`number`:case`integer`:o=`#{0}`;break;case`null`:o=`#{null}`;break;default:o=`#{}`;break}}}return(!o||s>1)&&(pJ.log(`xxx`,`value`,o,`nValueProposals`,s,i),o=`#{}`),a+o}getInsertTextForPropertyName(e,t){switch(this.mode){case _J.JSON5:case _J.YAML:return t.startsWith(`"`)?`"${e}"`:t.startsWith(`'`)?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t=`#`){switch(this.mode){case _J.JSON5:return`'${t}{${e}}'`;case _J.YAML:return`${t}{${e}}`;default:return`"${t}{${e}}"`}}getInsertTextForGuessedValue(e,t=``){switch(typeof e){case`object`:return e===null?"${null}"+t:this.getInsertTextForValue(e,t);case`string`:{let n=JSON.stringify(e);return n=n.substr(1,n.length-2),n=this.getInsertTextForPlainText(n),this.getInsertTextForString(n,`$`)+t}case`number`:case`boolean`:return"${"+JSON.stringify(e)+`}`+t}return this.getInsertTextForValue(e,t)}getInsertTextForPlainText(e){return e.replace(/[\\$}]/g,`\\$&`)}getInsertTextForValue(e,t){let n=JSON.stringify(e,null,` `);return n===`{}`?`{#{}}`+t:n===`[]`?`[#{}]`+t:this.getInsertTextForPlainText(n+t)}getValueCompletions(e,t,n,r){let i=LH(t.state).resolveInner(t.pos,-1),a=null,o;if(pJ.log(`xxx`,`getValueCompletions`,i,t),i&&EJ(i,this.mode)&&(a=i,i=i.parent),!i){this.addSchemaValueCompletions(e,n,r);return}if(vJ(i.name,this.mode)===mJ.PROPERTY){let e=kJ(i,mJ.PROPERTY_NAME,this.mode);e&&(o=wJ(t.state.doc,e),i=i.parent)}if(pJ.log(`xxx`,`node`,i,`parentKey`,o),i&&(o!==void 0||vJ(i.name,this.mode)===mJ.ARRAY)){let s=this.getSchemas(e,t);for(let e of s){if(typeof e!=`object`)return;if(vJ(i.name,this.mode)===mJ.ARRAY&&e.items){let t=r;if(e.uniqueItems&&(t=Object.assign(Object.assign({},t),{add(e){t.completions.has(e.label)||r.add(e)},reserve(e){r.reserve(e)}})),Array.isArray(e.items)){let r=0;if(a){let e=jJ(i,a,this.mode);e>=0&&(r=e)}let o=e.items[r];o&&this.addSchemaValueCompletions(o,n,t)}else this.addSchemaValueCompletions(e.items,n,t)}if((e.type==null||e.type!==`object`)&&this.addSchemaValueCompletions(e,n,r),o!==void 0){let t=!1;if(e.properties){let i=e.properties[o];i&&(t=!0,this.addSchemaValueCompletions(i,n,r))}if(e.patternProperties&&!t){for(let i of Object.keys(e.patternProperties))if(this.extendedRegExp(i)?.test(o)){t=!0;let a=e.patternProperties[i];a&&this.addSchemaValueCompletions(a,n,r)}}if(e.additionalProperties&&!t){let t=e.additionalProperties;this.addSchemaValueCompletions(t,n,r)}}n.boolean&&(this.addBooleanValueCompletion(!0,r),this.addBooleanValueCompletion(!1,r)),n.null&&this.addNullValueCompletion(r)}}return{valuePrefix:a?wJ(t.state.doc,a,!0,!1):``}}addSchemaValueCompletions(e,t,n){typeof e==`object`&&(this.addEnumValueCompletions(e,n),this.addDefaultValueCompletions(e,n),this.collectTypes(e,t),Array.isArray(e.allOf)&&e.allOf.forEach(e=>this.addSchemaValueCompletions(e,t,n)),Array.isArray(e.anyOf)&&e.anyOf.forEach(e=>this.addSchemaValueCompletions(e,t,n)),Array.isArray(e.oneOf)&&e.oneOf.forEach(e=>this.addSchemaValueCompletions(e,t,n)))}addDefaultValueCompletions(e,t,n=0){let r=!1;if(e.default!==void 0){let i=e.type,a=e.default;for(let e=n;e>0;e--)a=[a],i=`array`;let o=Object.assign(Object.assign({type:i?.toString()},this.getAppliedValue(a)),{detail:`Default value`});t.add(o),r=!0}Array.isArray(e.examples)&&e.examples.forEach(i=>{let a=e.type,o=i;for(let e=n;e>0;e--)o=[o],a=`array`;t.add(Object.assign({type:a?.toString()},this.getAppliedValue(o))),r=!0}),!r&&typeof e.items==`object`&&!Array.isArray(e.items)&&n<5&&this.addDefaultValueCompletions(e.items,t,n+1)}addEnumValueCompletions(e,t){if(e.const!==void 0&&t.add(Object.assign(Object.assign({type:e.type?.toString()},this.getAppliedValue(e.const)),{info:e.description})),Array.isArray(e.enum))for(let n=0,r=e.enum.length;n<r;n++){let r=e.enum[n];t.add(Object.assign(Object.assign({type:e.type?.toString()},this.getAppliedValue(r)),{info:e.description}))}}addBooleanValueCompletion(e,t){t.add({type:`boolean`,label:e?`true`:`false`})}addNullValueCompletion(e){e.add({type:`null`,label:`null`})}collectTypes(e,t){if(Array.isArray(e.enum)||e.const!==void 0)return;let n=e.type;Array.isArray(n)?n.forEach(e=>t[e]=!0):n&&(t[n]=!0)}getSchemas(e,t){let{data:n}=this.parser(t.state),r=new BX(e),i=bJ(t.state,t.pos,-1,this.mode);if(i===``&&(i=void 0),i!=null&&i.endsWith(`/`)){i=i.substring(0,i.length-1);let t=s3(e,n,i);if(t!=null)return[t]}let a=i?.replace(/\/[^/]*$/,``);a===``&&(a=void 0);let o=s3(e,n,a),s=i?.split(`/`).pop(),c=s==null||s in(o?.properties??{}),l=r.getSchema({pointer:i,data:n??void 0});return!c&&l?.type===`null`&&this.mode===`yaml`&&(l=void 0),pJ.log(`xxxx`,`draft.getSchema`,l,`data`,n,`pointer`,i,`pointerPointsToKnownProperty`,c),BJ(l)&&(l=l.data?.schema),!o3(l)&&o?[o]:(o3(l)||(l=r.getSchema({pointer:a}),i=a),pJ.log(`xxx`,`pointer..`,JSON.stringify(i)),!o3(l)&&(!i||i===`/`)&&(l=l3(e,e)??e),pJ.log(`xxx`,`subSchema..`,l),l?Array.isArray(l.allOf)?[l,...l.allOf.map(t=>l3(t,e))]:Array.isArray(l.oneOf)?[l,...l.oneOf.map(t=>l3(t,e))]:Array.isArray(l.anyOf)?[l,...l.anyOf.map(t=>l3(t,e))]:[l]:[])}getAppliedValue(e){let t=CJ(JSON.stringify(e));switch(this.mode){case _J.JSON5:return{label:t,apply:uRe(JSON.stringify(e))};case _J.YAML:return{label:t,apply:t};default:return{label:t,apply:JSON.stringify(e)}}}getValueFromLabel(e){return JSON.parse(e)}extendedRegExp(e){let t=``;e.startsWith(`(?i)`)&&(e=e.substring(4),t=`i`);try{return new RegExp(e,t+`u`)}catch{try{return new RegExp(e,t)}catch{return}}}};function kqe(e={}){let t=new Oqe(e);return function(e){return t.doComplete(e)}}function Aqe(e){return a3(e,(e,t)=>e===`additionalProperties`&&t===!1||e===`required`&&Array.isArray(t)||e===`unevaluatedProperties`&&t===!1||e===`unevaluatedItems`&&t===!1?[]:[e,t])}function s3(e,t,n){let r=new BX(e),i=r.getSchema({pointer:n,data:t??void 0});if(!o3(i))return;let a=c3(r,i),o={};for(let e of a){let i=Mqe(n,e),a=r.getSchema({pointer:i,data:t??void 0});o3(a)&&Object.assign(o,{[e]:a})}if(a.length===0||Object.keys(o).length===0)return;let s=i,{allOf:c,anyOf:l,oneOf:u}=s,d=Eqe(s,[`allOf`,`anyOf`,`oneOf`]);return Object.assign(Object.assign({},d),{properties:o})}function c3(e,t){if(t=l3(t,e.rootSchema),typeof t!=`object`||!t)return[];let n=[];function r(t){let r=c3(e,t);n.push(...r)}if(typeof t.properties==`object`&&t.properties!=null&&n.push(...Object.keys(t.properties)),typeof t.then==`object`&&t.then!=null&&r(t.then),Array.isArray(t.allOf))for(let e of t.allOf)r(e);if(Array.isArray(t.anyOf))for(let e of t.anyOf)r(e);if(Array.isArray(t.oneOf))for(let e of t.oneOf)r(e);return n}function l3(e,t){if(typeof e==`object`&&e.$ref){let n=jqe(t,e.$ref);if(typeof n==`object`){let t=Object.assign(Object.assign({},e),n);return Reflect.deleteProperty(t,`$ref`),t}}return e}function jqe(e,t){let n=t.split(`/`),r=e;return n.forEach(t=>{if(t){if(t===`#`){r=e;return}typeof r==`object`&&(r=r[t])}}),r}function Mqe(e,t){return e===void 0?`/${t}`:`${e}/${t}`}var u3=(e,t)=>{let n=e.length>2,r=e.map((n,r)=>{let i="`"+(t?t(n):n)+"`";return r===e.length-1?`or `+i:i});return n?r.join(`, `):r.join(` `)},Nqe=e=>e?.data?.pointer&&e?.data?.pointer!==`#`?e.data.pointer.slice(1):e?.data?.property?`/${e.data.property}`:``,Pqe=e=>e.startState.field(NJ)!==e.state.field(NJ);function Fqe(e){let t=new Lqe(e);return e=>t.doValidation(e)}var Iqe=[`NoAdditionalPropertiesError`,`RequiredPropertyError`,`InvalidPropertyNameError`,`ForbiddenPropertyError`,`UndefinedValueError`],Lqe=class{constructor(e){this.options=e,this.schema=null,this.mode=_J.JSON,this.rewriteError=e=>{let t=e?.data?.errors;return e.code===`one-of-error`&&t?.length?`Expected one of ${u3(t,e=>e.data.expected)}`:e.code===`type-error`?`Expected \`${e?.data?.expected&&Array.isArray(e?.data?.expected)?u3(e?.data?.expected):e?.data?.expected}\` but received \`${e?.data?.received}\``:e.message.replaceAll("in `#` ",``).replaceAll("at `#`",``).replaceAll(`/`,`.`).replaceAll(`#.`,``)},this.mode=this.options?.mode??_J.JSON,this.parser=this.options?.jsonParser??i3(this.mode)}get schemaTitle(){return this.schema?.getSchema()?.title??`json-schema`}doValidation(e){let t=PJ(e.state);if(!t||(this.schema=new IX(t),!this.schema)||!e.state.doc.toString()?.length)return[];let n=this.parser(e.state);if(n.data==null)return[];let r=[];try{r=this.schema.validate(n.data)}catch{}return pJ.log(`xxx`,`validation errors`,r,n.data),r.length?r.reduce((e,t)=>{let r=()=>{let n=this.rewriteError(t);e.push({from:0,to:0,message:n,severity:`error`,source:this.schemaTitle,renderMessage:()=>{let e=VX(`div`,{});return e.innerHTML=a0(n),e}})},i=Nqe(t),a=n.pointers.get(i);if(t.name===`MaxPropertiesError`||t.name===`MinPropertiesError`||i===``)r();else if(a){let n=Iqe.includes(t.name),r=this.rewriteError(t),i=n?a.keyFrom:a.valueFrom,o=n?a.keyTo:a.valueTo;o!==void 0&&i!==void 0&&e.push({from:i,to:o,message:r,renderMessage:()=>{let e=VX(`div`,{});return e.innerHTML=a0(r),e},severity:`error`,source:this.schemaTitle})}else r();return e},[]):[]}};function Rqe(e){let t=new Bqe(e);return async function(e,n,r){return t.doHover(e,n,r)}}function zqe(e){if(e.type)return e.$ref?`${e.$ref} (${e.type})`:e.type;if(e.$ref)return`${e.$ref}`}function d3(e,t,n){return`${t}: ${u3(e[t].map(e=>{try{let{data:t}=n.resolveRef({data:e,pointer:e.$ref});return zqe(t||e)}catch{return e.type}}))}`}var Bqe=class{constructor(e){this.opts=e,this.schema=null,this.mode=_J.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=this.opts?.mode??_J.JSON}getDataForCursor(e,t,n){let r=PJ(e.state);if(!r)return null;this.schema=new IX(r);let i=bJ(e.state,t,n,this.mode),a;try{a=this.opts.parser(e.state.doc.toString())}catch{}if(!i)return null;let o=this.schema.getSchema({pointer:i,data:a,withSchemaWarning:!0});return BJ(o)&&(o=o?.data.schema.$ref?this.schema.resolveRef(o):o?.data.schema),{schema:o,pointer:i}}formatMessage(e){let{message:t,typeInfo:n}=e;return t?VX(`div`,{class:`cm6-json-schema-hover`},[VX(`div`,{class:`cm6-json-schema-hover--description`,inner:a0(t,!1)}),VX(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[VX(`div`,{class:`cm6-json-schema-hover--code`,inner:a0(n,!1)})])]):VX(`div`,{class:`cm6-json-schema-hover`},[VX(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[VX(`code`,{class:`cm6-json-schema-hover--code`,inner:a0(n,!1)})])])}getHoverTexts(e,t){let n=``,r=null,{schema:i}=e;return i.oneOf&&(n=d3(i,`oneOf`,t)),i.anyOf&&(n=d3(i,`anyOf`,t)),i.allOf&&(n=d3(i,`allOf`,t)),i.type&&(n=Array.isArray(i.type)?u3(i.type):i.type),i.$ref&&(n=` Reference: ${i.$ref}`),i.enum&&(n=`\`enum\`: ${u3(i.enum)}`),i.format&&(n+=`\`format\`: ${i.format}`),i.pattern&&(n+=`\`pattern\`: ${i.pattern}`),i.description&&(r=i.description),{message:r,typeInfo:n}}async doHover(e,t,n){let r=t,i=t;try{let a=this.getDataForCursor(e,t,n);if(pJ.log(`cursorData`,a),!a?.schema)return null;let o=(this.opts?.getHoverTexts??this.getHoverTexts)(a,this.schema),s=(this.opts?.formatHover??this.formatMessage)(o);return{pos:r,end:i,arrow:!0,above:!0,create:e=>({dom:s})}}catch(e){return pJ.log(e),null}}},Vqe=e=>(0,G.jsx)(Yv,{disablePadding:!0,children:e.validationErrors.map((e,t)=>(0,G.jsx)(Qv,{disableGutters:!0,disablePadding:!0,children:(0,G.jsxs)(Rv,{direction:`row`,spacing:1,children:[(0,G.jsx)(Q,{variant:`body2`,children:`•`}),(0,G.jsx)(Q,{variant:`caption`,children:e.instancePath.length===0?`/`:e.instancePath}),(0,G.jsx)(Q,{variant:`body2`,children:e.message})]})},t.toString()))}),f3=e=>{let t;try{t=JSON.parse(e)}catch{t=void 0}return t};function Hqe({schema:e,customValidate:t}){let n=(0,C.useMemo)(()=>new qP.default({allErrors:!0}),[]);return(0,C.useCallback)(r=>{let i=[];return n.validate(e,r),i.push(...n.errors??[]),i.push(...t?.(r)??[]),i},[n,e,t])}var Uqe=e=>{let t=Wqe(),[n,r]=(0,C.useState)(()=>JSON.stringify(e.value,null,2)),i=Hqe(e),[a,o]=(0,C.useState)([]);(0,C.useEffect)(()=>{o(i(e.value))},[i,e.value]);let s=e.onChange,c=(0,C.useCallback)(e=>{let t=f3(e),n=i(t);s(t,n.length===0),r(e),o(n)},[i,s]),l=()=>{let e=f3(n);e&&r(JSON.stringify(e,null,2))};return(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Z,{position:`relative`,children:[(0,G.jsx)(dJ,{value:n,onChange:e=>c(e),extensions:[_Pe(),VU(hPe(),{delay:100}),VU(Fqe(),{delay:100,needsRefresh:Pqe}),kU.data.of({autocomplete:kqe({mode:`json4`})}),pH(Rqe()),hRe(e.schema)],theme:t,height:`400px`}),(0,G.jsx)(uv,{sx:{position:`absolute`,right:`0`,bottom:`0`},onClick:()=>l(),children:`Prettify`})]}),a.length>0&&(0,G.jsx)(Uh,{severity:`error`,variant:`outlined`,children:(0,G.jsx)(Vqe,{validationErrors:a})})]})};function Wqe(){return wm().palette.mode===`dark`?zPe:FPe}var Gqe=[{value:``,label:`Auto (based on domain/name)`},{value:`light`,label:`💡 Light`},{value:`switch`,label:`🔌 Switch`},{value:`climate`,label:`🌡️ Climate`},{value:`cover`,label:`🪟 Cover`},{value:`fan`,label:`🌀 Fan`},{value:`lock`,label:`🔒 Lock`},{value:`sensor`,label:`📊 Sensor`},{value:`media_player`,label:`📺 Media Player`},{value:`vacuum`,label:`🧹 Vacuum`},{value:`remote`,label:`🎮 Remote`},{value:`humidifier`,label:`💧 Humidifier`},{value:`speaker`,label:`🔊 Speaker`},{value:`garage`,label:`🚗 Garage`},{value:`door`,label:`🚪 Door`},{value:`window`,label:`🪟 Window`},{value:`motion`,label:`🏃 Motion`},{value:`battery`,label:`🔋 Battery`},{value:`power`,label:`⚡ Power`},{value:`camera`,label:`📷 Camera`},{value:`default`,label:`🔗 Default`}],Kqe=({bridgeId:e,selectedIcon:t,onIconChange:n})=>{let r=(0,C.useRef)(null),[i,a]=(0,C.useState)(!1),[o,s]=(0,C.useState)(null),[c,l]=(0,C.useState)(!1),[u,d]=(0,C.useState)(null);(0,C.useEffect)(()=>{e&&pE(e).then(t=>{a(t),t&&s(`${mE(e)}?t=${Date.now()}`)}).catch(()=>{a(!1)})},[e]);let f=(0,C.useCallback)(async t=>{let i=t.target.files?.[0];if(!(!i||!e)){d(null),l(!0);try{await dge(e,i),a(!0),s(`${mE(e)}?t=${Date.now()}`),n(void 0)}catch(e){d(e instanceof Error?e.message:`Upload failed`)}finally{l(!1),r.current&&(r.current.value=``)}}},[e,n]),p=(0,C.useCallback)(async()=>{if(e){d(null);try{await fge(e),a(!1),s(null)}catch(e){d(e instanceof Error?e.message:`Delete failed`)}}},[e]),m=(0,C.useCallback)(e=>{n(e===``?void 0:e)},[n]);return(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Tv,{fullWidth:!0,size:`small`,children:[(0,G.jsx)(Fx,{id:`icon-select-label`,children:`Bridge Icon`}),(0,G.jsx)(_S,{labelId:`icon-select-label`,value:t??``,label:`Bridge Icon`,onChange:e=>m(e.target.value),disabled:i,children:Gqe.map(e=>(0,G.jsx)(vS,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(bS,{children:i?`Custom icon is set. Delete it to use preset icons.`:`Select a preset icon or upload a custom image`})]}),e&&(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,gutterBottom:!0,children:`Custom Icon`}),(0,G.jsxs)(Rv,{direction:`row`,spacing:2,alignItems:`center`,children:[i&&o&&(0,G.jsx)(Z,{component:`img`,src:o,alt:`Custom bridge icon`,sx:{width:48,height:48,objectFit:`contain`,borderRadius:1,border:`1px solid`,borderColor:`divider`}}),(0,G.jsx)(`input`,{ref:r,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp,image/svg+xml`,style:{display:`none`},onChange:f}),(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(She,{}),onClick:()=>r.current?.click(),disabled:c,children:c?`Uploading...`:`Upload Image`}),i&&(0,G.jsx)(uv,{variant:`outlined`,size:`small`,color:`error`,startIcon:(0,G.jsx)(MS,{}),onClick:p,children:`Delete`})]}),u&&(0,G.jsx)(Q,{variant:`caption`,color:`error`,sx:{mt:1},children:u}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{mt:1,display:`block`},children:`Supported formats: PNG, JPG, GIF, WebP, SVG (max 5MB)`})]}),!e&&(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:`Save the bridge first to upload a custom icon.`})]})},p3={light:`Light`,switch:`On/Off Plug-in Unit`,lock:`Door Lock`,fan:`Fan`,binary_sensor:`Sensor`,sensor:`Sensor`,cover:`Window Covering`,climate:`Thermostat`,media_player:`Speaker / Video Player`,vacuum:`Robot Vacuum Cleaner`,humidifier:`Humidifier`,valve:`Water Valve`,alarm_control_panel:`On/Off Plug-in Unit`,event:`Generic Switch`,button:`Generic Switch`,input_button:`Generic Switch`,automation:`On/Off Switch`,script:`On/Off Switch`,scene:`On/Off Switch`,remote:`On/Off`,water_heater:`Water Heater`,input_boolean:`On/Off Plug-in Unit`,select:`Mode Select`,input_select:`Mode Select`,siren:`On/Off Plug-in Unit`},m3=e=>{try{return JSON.parse(e)}catch{return}};function qqe({filter:e}){let[t,n]=(0,C.useState)(!1),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!1),l=(0,C.useRef)(null),u=(0,C.useRef)(``),d=(0,C.useCallback)(async()=>{n(!0),o(null);try{let t=await fetch(`api/matter/filter-preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=await t.text(),r=m3(n);if(!t.ok){let e=typeof r==`object`&&r&&`error`in r?String(r.error):n||`Failed to fetch preview`;throw Error(e)}i(r??m3(n)),c(!0)}catch(e){o(e instanceof Error?e.message:`Unknown error`)}finally{n(!1)}},[e]);(0,C.useEffect)(()=>{if(!(e.include.length>0&&e.include.some(e=>e.type&&e.value))){i(null),c(!1);return}let t=JSON.stringify(e);if(t!==u.current)return u.current=t,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{d()},800),()=>{l.current&&clearTimeout(l.current)}},[e,d]);let f=r?r.entities.reduce((e,t)=>(e[t.domain]=(e[t.domain]||0)+1,e),{}):{},p=[];if(r){r.entities.some(e=>e.domain===`vacuum`)&&p.push(`This filter includes a vacuum. Consider using Server Mode (single device per bridge) for Apple Home/Alexa compatibility.`),r.total>50&&p.push(`${r.total} entities is a large number. Consider splitting across multiple bridges for better stability.`);let e=Object.keys(f).filter(e=>!p3[e]);e.length>0&&p.push(`Unsupported domains will be skipped: ${e.join(`, `)}`)}return(0,G.jsxs)(Z,{sx:{mt:2},children:[(0,G.jsx)(uv,{variant:`outlined`,startIcon:t?(0,G.jsx)(Rh,{size:16}):(0,G.jsx)(Whe,{}),onClick:d,disabled:t,size:`small`,children:t?`Loading...`:`Preview Matching Entities`}),a&&(0,G.jsx)(Uh,{severity:`error`,sx:{mt:1},children:a}),(0,G.jsx)(qv,{in:s&&r!==null,children:r&&(0,G.jsxs)(Z,{sx:{mt:2},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsxs)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:[r.total,` entities match`]}),r.truncated&&(0,G.jsx)(Sv,{label:`Showing first 100`,size:`small`,color:`warning`,variant:`outlined`})]}),p.length>0&&(0,G.jsx)(Rv,{spacing:.5,sx:{mb:1.5},children:p.map(e=>(0,G.jsx)(Uh,{severity:`warning`,variant:`outlined`,icon:e.includes(`vacuum`)?(0,G.jsx)(ov,{fontSize:`small`}):(0,G.jsx)(vb,{fontSize:`small`}),sx:{py:0},children:(0,G.jsx)(Q,{variant:`caption`,children:e})},e))}),(0,G.jsx)(Z,{display:`flex`,gap:.5,flexWrap:`wrap`,mb:2,children:Object.entries(f).sort((e,t)=>t[1]-e[1]).map(([e,t])=>(0,G.jsx)(Sv,{label:`${e}: ${t}${p3[e]?` → ${p3[e]}`:``}`,size:`small`,variant:`outlined`,color:p3[e]?`default`:`warning`},e))}),(0,G.jsx)(Yv,{dense:!0,sx:{maxHeight:200,overflow:`auto`,bgcolor:`background.paper`,borderRadius:1,border:1,borderColor:`divider`},children:r.entities.map(e=>(0,G.jsx)(Qv,{divider:!0,children:(0,G.jsx)(ny,{primary:e.friendly_name||e.entity_id,secondary:`${e.entity_id}${p3[e.domain]?` → ${p3[e.domain]}`:``}`,primaryTypographyProps:{variant:`body2`},secondaryTypographyProps:{variant:`caption`,fontFamily:`monospace`}})},e.entity_id))}),(0,G.jsx)(uv,{size:`small`,onClick:()=>c(!1),sx:{mt:1},children:`Hide Preview`})]})})]})}var Jqe=eF().ObjectFieldTemplate;function Yqe(e){return(e.fieldPathId?.$id??``)===`root_filter`?(0,G.jsx)(Xqe,{...e}):(0,G.jsx)(Jqe,{...e})}function Xqe(e){let t=(e.formData?.include?.length??0)+(e.formData?.exclude?.length??0),[n,r]=(0,C.useState)(t>0);return(0,G.jsxs)(XS,{expanded:n,onChange:(e,t)=>r(t),variant:`outlined`,disableGutters:!0,sx:{borderRadius:2,"&::before":{display:`none`},overflow:`hidden`},children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),sx:{px:2,"& .MuiAccordionSummary-content":{alignItems:`center`,gap:1.5}},children:[(0,G.jsx)(pb,{fontSize:`small`,color:`action`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:600,children:`Entity Filters`}),(0,G.jsx)(Mx,{badgeContent:t,color:`primary`,sx:{ml:1},max:99,children:(0,G.jsx)(Z,{})}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{ml:1},children:n?`Click to collapse`:`${t} rule${t===1?``:`s`} configured`})]}),(0,G.jsx)(ZS,{sx:{px:2,pb:2},children:e.properties.map(e=>(0,G.jsx)(`div`,{children:e.content},e.name))})]})}function Zqe(e){let t=(0,C.useRef)(e),n=t.current;return t.current=e,n}function h3(e){let{items:t,canAdd:n,onAddClick:r,title:i,formData:a}=e,o=a??[],[s,c]=(0,C.useState)(()=>new Set),[l,u]=(0,C.useState)(``),d=Zqe(o.length);(0,C.useEffect)(()=>{if(o.length>d){let e=o.length-1,t=o[e];!t?.type&&!t?.value&&c(t=>new Set([...t,e]))}},[o,d]);let f=(0,C.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),p=(0,C.useMemo)(()=>{if(!l.trim())return null;let e=l.toLowerCase(),t=[];for(let n=0;n<o.length;n++){let r=o[n],i=r?.type??``,a=r?.value??``;(i.toLowerCase().includes(e)||a.toLowerCase().includes(e))&&t.push(n)}return new Set(t)},[l,o]),m=(0,C.useMemo)(()=>{let e=Array.from({length:t.length},(e,t)=>t);return p?e.filter(e=>p.has(e)):e},[t.length,p]);return(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:1,children:[(0,G.jsx)(Q,{variant:`subtitle2`,fontWeight:600,children:i}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Sv,{label:t.length,size:`small`,color:`default`,sx:{height:22,fontSize:`0.75rem`}}),n&&(0,G.jsx)(uv,{size:`small`,startIcon:(0,G.jsx)(cb,{}),onClick:r,children:`Add`})]})]}),t.length>3&&(0,G.jsx)(xS,{size:`small`,fullWidth:!0,placeholder:`Search rules...`,value:l,onChange:e=>u(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(ZP,{position:`start`,children:(0,G.jsx)(sE,{fontSize:`small`,color:`action`})})}},sx:{mb:1}}),p&&m.length===0&&(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,textAlign:`center`,py:2,children:`No matching rules`}),(0,G.jsx)(Rv,{spacing:.5,children:m.map(e=>{let n=o[e],r=n?.type??``,i=n?.value??``,a=s.has(e);return(0,G.jsxs)(Z,{sx:{border:1,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,sx:{px:1.5,py:.75,cursor:`pointer`,"&:hover":{bgcolor:`action.hover`},bgcolor:a?`action.selected`:`transparent`},onClick:()=>f(e),children:[a?(0,G.jsx)(fhe,{fontSize:`small`,color:`action`}):(0,G.jsx)(mhe,{fontSize:`small`,color:`action`}),r||i?(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,ml:.5,flex:1,minWidth:0,children:[(0,G.jsx)(Sv,{label:r,size:`small`,variant:`outlined`,sx:{height:22,fontSize:`0.75rem`,flexShrink:0}}),(0,G.jsx)(Q,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0},children:i})]}):(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,ml:.5,fontStyle:`italic`,children:`New rule (click to configure)`})]}),(0,G.jsx)(qv,{in:a,children:(0,G.jsx)(Z,{sx:{px:2,pb:1.5,pt:.5},children:t[e]})})]},e)})})]})}function Qqe(e){let{schema:t,formData:n={},onChange:r,disabled:i,readonly:a,fieldPathId:o}=e,s=t.properties??{},c=(0,C.useCallback)((e,t)=>{r({...n,[e]:t},o.path)},[n,r,o]);return(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`h6`,sx:{mb:2},children:`Feature Flags`}),(0,G.jsx)(jv,{container:!0,spacing:2,children:Object.entries(s).map(([e,t])=>{let r=n[e]??t.default??!1;return(0,G.jsx)(jv,{size:{xs:12,sm:6,lg:4},children:(0,G.jsx)(dv,{variant:`outlined`,sx:{height:`100%`,opacity:t.title?.toLowerCase().includes(`deprecated`)??!1?.6:1,transition:`border-color 0.2s, box-shadow 0.2s`,borderColor:r?`primary.main`:`divider`,"&:hover":{transform:`none`,boxShadow:`none`}},children:(0,G.jsx)(pv,{onClick:()=>{!i&&!a&&c(e,!r)},disabled:i||a,sx:{height:`100%`},children:(0,G.jsxs)(mv,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,p:2,"&:last-child":{pb:2}},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:1,children:[(0,G.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,G.jsx)(Q,{variant:`subtitle2`,fontWeight:600,sx:{lineHeight:1.3},children:t.title??e}),r&&(0,G.jsx)(Sv,{label:`Active`,size:`small`,color:`primary`,variant:`outlined`,sx:{mt:.5,height:20,fontSize:`0.7rem`}})]}),(0,G.jsx)(HS,{checked:r,size:`small`,disabled:i||a,tabIndex:-1,onClick:e=>e.stopPropagation(),onChange:t=>c(e,t.target.checked)})]}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{mt:1,lineHeight:1.4,flex:1},children:t.description})]})})})},e)})})]})}var g3=function(e){return e.JSON_EDITOR=`JSON_EDITOR`,e.FIELDS_EDITOR=`FIELDS_EDITOR`,e}(g3||{}),_3=e=>{let{t}=ms(),[n,r]=(0,C.useState)(g3.FIELDS_EDITOR),i=()=>{r(n===g3.FIELDS_EDITOR?g3.JSON_EDITOR:g3.FIELDS_EDITOR)},[a,o]=(0,C.useState)(e.bridge),[s,c]=(0,C.useState)(!0),l=(0,C.useCallback)(t=>{let n=t;if(!n?.port)return[];let r=e.usedPorts[n.port];return r!==void 0&&r!==e.bridgeId?[{instancePath:`/port`,message:`Port is already used by bridge with id ${r}`}]:[]},[e.bridgeId,e.usedPorts]),u=(e,t)=>{let n=e=>e?.icon;o(t=>{let r=n(t);return r==null?{...e}:{...e,icon:r}}),c(t)},d=(0,C.useCallback)(e=>{o(t=>{if(e!=null)return{...t,icon:e};let{icon:n,...r}=t??{};return r})},[]),f=(0,C.useMemo)(()=>{let e=a?.featureFlags,t=[];return e?.serverMode&&t.push({severity:`warning`,message:`Server Mode is enabled. Only ONE device should be in this bridge. Multiple devices will cause errors.`}),e?.serverMode&&e?.vacuumOnOff===!1&&t.push({severity:`warning`,message:`Server Mode with Vacuum OnOff disabled: Alexa REQUIRES the OnOff cluster (PowerController) for robotic vacuums. Without it, the vacuum commissions but never appears in Alexa. Only disable this for Apple Home.`}),!e?.serverMode&&e?.vacuumOnOff&&t.push({severity:`warning`,message:`Vacuum OnOff is enabled in bridge mode. This adds a non-standard cluster to the RVC device type which may cause issues with Apple Home and Google Home.`}),e?.autoForceSync&&e?.autoComposedDevices&&t.push({severity:`warning`,message:`Auto Force Sync with Auto Composed Devices increases network traffic. Composed devices have more clusters, so each sync cycle sends more data.`}),t},[a]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Uh,{severity:`warning`,variant:`outlined`,children:[`Please consult`,` `,(0,G.jsx)(Vv,{href:Y9.faq.bridgeConfig,target:`_blank`,children:`the documentation`}),` `,`for proper bridge configurations.`,` `,(0,G.jsx)(`strong`,{children:`Especially if you are using labels, see the "Labels" section.`})]}),(0,G.jsxs)(Uh,{severity:`info`,variant:`outlined`,children:[(0,G.jsx)(`strong`,{children:`Community tip:`}),` Users have reported that bridges with a large number of devices can become unstable depending on the controller. If you experience connectivity issues, consider splitting your devices across multiple bridges.`]}),f.map(e=>(0,G.jsx)(Uh,{severity:e.severity,variant:`outlined`,children:e.message},e.message)),(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsx)(Z,{display:`flex`,justifyContent:`flex-end`,children:(0,G.jsx)(uv,{onClick:()=>i(),title:n===g3.FIELDS_EDITOR?t(`bridge.jsonEditor`):t(`bridge.formEditor`),children:n===g3.FIELDS_EDITOR?(0,G.jsx)(Xhe,{}):(0,G.jsx)(Fhe,{})})}),n===g3.FIELDS_EDITOR&&(0,G.jsx)(Nke,{value:a??{},onChange:u,schema:rv,uiSchema:{icon:{"ui:widget":`hidden`},featureFlags:{"ui:field":`featureFlags`},filter:{include:{"ui:options":{ArrayFieldTemplate:h3}},exclude:{"ui:options":{ArrayFieldTemplate:h3}}}},customValidate:l,templates:{ObjectFieldTemplate:Yqe},fields:{featureFlags:Qqe}}),n===g3.JSON_EDITOR&&(0,G.jsx)(Uqe,{value:a??{},onChange:u,schema:rv,customValidate:l}),a?.filter&&(0,G.jsx)(qqe,{filter:a.filter}),(0,G.jsx)(dv,{variant:`outlined`,children:(0,G.jsxs)(mv,{children:[(0,G.jsx)(Q,{variant:`subtitle1`,gutterBottom:!0,fontWeight:600,children:t(`bridge.iconLabel`)}),(0,G.jsx)(Kqe,{bridgeId:e.bridgeId,selectedIcon:a?.icon,onIconChange:d})]})}),(0,G.jsxs)(jv,{container:!0,children:[(0,G.jsx)(jv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(uv,{fullWidth:!0,variant:`outlined`,color:`error`,onClick:e.onCancel,children:t(`common.cancel`)})}),(0,G.jsx)(jv,{size:{xs:0,sm:4,md:6},sx:{display:{xs:`none`,sm:`block`}}}),(0,G.jsx)(jv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(uv,{fullWidth:!0,variant:`outlined`,disabled:!s,onClick:async()=>{s&&await e.onSave(a)},children:t(`common.save`)})})]})]})]})},$qe={name:``,featureFlags:{},filter:{include:[],exclude:[]}};function eJe(e){let t=5540;for(;e[t];)t++;return t}var tJe=()=>{let{t:e}=ms(),t=Uv(),n=Sr(),[r,i]=(0,C.useState)(),a=!!AT().content?.length,o=jT(),s=(0,C.useCallback)(e=>{i(e?.id)},[]),c=(0,C.useMemo)(()=>{if(!o)return;let e=eJe(o);if(r){let t=Z_.find(e=>e.id===r);if(t)return{name:t.name,port:e,filter:{...t.filter},featureFlags:{...t.featureFlags},icon:t.icon}}return{...$qe,port:e}},[o,r]),l=Wme(),u=()=>{n(-1)};return!c||!o?e(`common.loading`):(0,G.jsxs)(Rv,{spacing:4,children:[(0,G.jsx)(Hv,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:e(`common.create`),to:Y9.createBridge}]}),a&&(0,G.jsx)(Uh,{severity:`info`,variant:`outlined`,children:(0,G.jsxs)(Q,{children:[`Did you know that you can connect the same bridge with multiple assistants?`,` `,(0,G.jsx)(Vv,{href:Y9.faq.multiFabric,target:`_blank`,children:`Learn more.`})]})}),(0,G.jsx)(wE,{selectedTemplate:r,onSelect:s}),(0,G.jsx)(_3,{bridge:c,usedPorts:o,onSave:async n=>{await l({...n}).then(()=>t.show({message:e(`bridge.saveSuccess`),severity:`success`})).then(()=>u()).catch(e=>t.show({message:e.message,severity:`error`}))},onCancel:u},r??`custom`)]})},nJe=()=>{let{t:e}=ms(),t=Uv(),n=Sr(),{bridgeId:r}=Er(),{content:i,isLoading:a}=MT(r),o=jT(),s=Gme(),c=(0,C.useMemo)(()=>{if(!(a||!i))return{name:i.name,port:i.port,filter:i.filter,...i.countryCode!=null&&{countryCode:i.countryCode},...i.featureFlags!=null&&{featureFlags:i.featureFlags},...i.icon!=null&&{icon:i.icon},...i.priority!=null&&{priority:i.priority},...i.serialNumberSuffix!=null&&{serialNumberSuffix:i.serialNumberSuffix}}},[a,i]),l=()=>{n(-1)};return a||!o?e(`common.loading`):!i||!c?e(`notFound.title`):(0,G.jsxs)(Rv,{spacing:4,children:[(0,G.jsx)(Hv,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:i.name,to:Y9.bridge(r)},{name:e(`common.edit`),to:Y9.editBridge(r)}]}),(0,G.jsx)(_3,{bridgeId:r,bridge:c,usedPorts:o,onSave:async n=>{await s({...n,id:r}).then(()=>t.show({message:e(`bridge.updateSuccess`),severity:`success`})).then(()=>l()).catch(e=>t.show({message:e.message,severity:`error`}))},onCancel:l})]})};async function rJe(){let e=await fetch(`api/backup/snapshots`);return await P_(e,`Failed to fetch backups`),N_(e)}async function iJe(){let e=await fetch(`api/backup/snapshots/create`,{method:`POST`});return await P_(e,`Failed to create backup`),N_(e)}async function aJe(e){let t=await fetch(`api/backup/snapshots/${encodeURIComponent(e)}/download`);if(!t.ok)throw Error(`Failed to download backup`);let n=await t.blob(),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i)}async function oJe(e,t){let n=await fetch(`api/backup/snapshots/${encodeURIComponent(e)}/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({overwriteExisting:!0,includeMappings:!0,restoreIdentity:!0,...t})});return await P_(n,`Failed to restore backup`),N_(n)}async function sJe(e){await P_(await fetch(`api/backup/snapshots/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete backup`)}async function cJe(){let e=await fetch(`api/backup/settings`);return await P_(e,`Failed to fetch backup settings`),N_(e)}async function lJe(e){let t=await fetch(`api/backup/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return await P_(t,`Failed to update backup settings`),N_(t)}function uJe(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function v3(){let{t:e}=ms(),[t,n]=(0,C.useState)(!1),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(new Set),[d,f]=(0,C.useState)(!1),[p,m]=(0,C.useState)(!0),[h,g]=(0,C.useState)(!0),[_,v]=(0,C.useState)(!1),[y,b]=(0,C.useState)(!1),[x,S]=(0,C.useState)(null),w=(0,C.useRef)(null),[T,E]=(0,C.useState)([]),[D,O]=(0,C.useState)(!0),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(null),[F,I]=(0,C.useState)(!1),L=(0,C.useCallback)(async()=>{try{O(!0);let[e,t]=await Promise.all([rJe(),cJe()]);E(e),A(t)}catch(e){i(e instanceof Error?e.message:`Failed to load backups`)}finally{O(!1)}},[]);(0,C.useEffect)(()=>{L()},[L]);let R=async()=>{I(!0),i(null);try{await iJe(),o(e(`backup.snapshotCreated`)),await L()}catch(e){i(e instanceof Error?e.message:`Failed to create backup`)}finally{I(!1)}},ee=async e=>{try{await aJe(e)}catch(e){i(e instanceof Error?e.message:`Failed to download backup`)}},z=async t=>{n(!0),i(null);try{let n=await oJe(t);n.errors.length>0?i(`Restored ${n.bridgesRestored} bridges with ${n.errors.length} errors`):o(e(`backup.snapshotRestored`,{bridges:n.bridgesRestored,mappings:n.mappingsRestored,identities:n.identitiesRestored})),M(null),n.restartRequired&&b(!0)}catch(e){i(e instanceof Error?e.message:`Failed to restore backup`)}finally{n(!1)}},te=async e=>{try{await sJe(e),P(null),await L()}catch(e){i(e instanceof Error?e.message:`Failed to delete backup`)}},B=async e=>{try{A(await lJe(e))}catch(e){i(e instanceof Error?e.message:`Failed to update settings`)}},V=async(t=!1)=>{n(!0),i(null);try{let n=await fetch(t?`api/backup/download?includeIdentity=true`:`api/backup/download`);if(!n.ok)throw Error(`Failed to create backup`);let r=await n.blob(),i=window.URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.headers.get(`Content-Disposition`)?.match(/filename="(.+)"/)?.[1]||`hamh-backup.zip`,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(i),document.body.removeChild(a),o(e(`backup.downloadSuccess`))}catch(e){i(e instanceof Error?e.message:`Unknown error`)}finally{n(!1)}},ne=async e=>{let t=e.target.files?.[0];if(t){S(t),n(!0),i(null);try{let e=new FormData;e.append(`file`,t);let n=await fetch(`api/backup/restore/preview`,{method:`POST`,body:e});if(!n.ok){let e=await n.text(),t=`Failed to parse backup`;try{let n=JSON.parse(e);n.error&&(t=n.error)}catch{e&&(t=`${t} (HTTP ${n.status}: ${e.slice(0,120)})`)}throw Error(t)}let r=await n.json();c(r),u(new Set(r.bridges.map(e=>e.id))),v(!0)}catch(e){i(e instanceof Error?e.message:`Unknown error`)}finally{n(!1),w.current&&(w.current.value=``)}}},re=async()=>{if(x){n(!0),i(null);try{let e=new FormData;e.append(`file`,x),e.append(`options`,JSON.stringify({bridgeIds:Array.from(l),overwriteExisting:d,includeMappings:p,restoreIdentity:h&&s?.includesIdentity}));let t=await fetch(`api/backup/restore`,{method:`POST`,body:e});if(!t.ok){let e=await t.text(),n=`Failed to restore backup`;try{let t=JSON.parse(e);t.error&&(n=t.error)}catch{e&&(n=`${n} (HTTP ${t.status}: ${e.slice(0,120)})`)}throw Error(n)}let n=await t.json();if(n.errors.length>0)i(`Restored ${n.bridgesRestored} bridges with ${n.errors.length} errors`);else{let e=[`Restored ${n.bridgesRestored} bridges`];n.mappingsRestored>0&&e.push(`${n.mappingsRestored} entity mappings`),n.identitiesRestored>0&&e.push(`${n.identitiesRestored} identities`),o(`${e.join(`, `)}!`)}v(!1),c(null),S(null),n.restartRequired&&b(!0)}catch(e){i(e instanceof Error?e.message:`Unknown error`)}finally{n(!1)}}},ie=e=>{let t=new Set(l);t.has(e)?t.delete(e):t.add(e),u(t)};return(0,G.jsxs)(dv,{children:[(0,G.jsxs)(mv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,children:[(0,G.jsx)(HT,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.title`)]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`backup.description`)}),r&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:2},onClose:()=>i(null),children:r}),a&&(0,G.jsx)(Uh,{severity:`success`,sx:{mb:2},onClose:()=>o(null),children:a}),(0,G.jsxs)(jv,{container:!0,spacing:2,children:[(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2,height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(HT,{color:`primary`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.configBackup`)})]}),(0,G.jsxs)(Z,{sx:{flexGrow:1},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.configBackupDesc`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.configBackupNote`)})]}),(0,G.jsx)(uv,{variant:`contained`,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):(0,G.jsx)(HT,{}),onClick:()=>V(!1),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.configBackup`)})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2,height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(Khe,{color:`warning`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.fullBackup`)})]}),(0,G.jsxs)(Z,{sx:{flexGrow:1},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.fullBackupDesc`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.fullBackupWarning`)})]}),(0,G.jsx)(uv,{variant:`contained`,color:`warning`,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):(0,G.jsx)(HT,{}),onClick:()=>V(!0),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.fullBackup`)})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2,height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(aE,{color:`info`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.restoreFromBackup`)})]}),(0,G.jsx)(Z,{sx:{flexGrow:1},children:(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`backup.restoreDesc`)})}),(0,G.jsxs)(uv,{variant:`outlined`,color:`info`,startIcon:(0,G.jsx)(aE,{}),component:`label`,disabled:t,fullWidth:!0,sx:{mt:2},children:[e(`backup.restoreFromBackup`),(0,G.jsx)(`input`,{ref:w,type:`file`,accept:`.zip`,hidden:!0,onChange:ne})]})]})})]}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(HT,{color:`primary`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.storedBackups`)}),T.length>0&&(0,G.jsx)(Sv,{label:T.length,size:`small`,color:`primary`,variant:`outlined`})]}),(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:F?(0,G.jsx)(Rh,{size:16,color:`inherit`}):(0,G.jsx)(cb,{}),onClick:R,disabled:F,children:e(`backup.createSnapshot`)})]}),D?(0,G.jsx)(Z,{display:`flex`,justifyContent:`center`,p:2,children:(0,G.jsx)(Rh,{size:24})}):T.length===0?(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{textAlign:`center`,py:2},children:e(`backup.noSnapshots`)}):(0,G.jsx)(Yv,{dense:!0,children:T.map(t=>(0,G.jsxs)(Qv,{secondaryAction:(0,G.jsxs)(Z,{display:`flex`,gap:.5,children:[(0,G.jsx)(sb,{title:e(`backup.downloadSnapshot`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>ee(t.filename),children:(0,G.jsx)(ET,{fontSize:`small`})})}),(0,G.jsx)(sb,{title:e(`backup.restoreSnapshot`),children:(0,G.jsx)(Bh,{size:`small`,color:`warning`,onClick:()=>M(t.filename),children:(0,G.jsx)(aE,{fontSize:`small`})})}),(0,G.jsx)(sb,{title:e(`common.delete`),children:(0,G.jsx)(Bh,{size:`small`,color:`error`,onClick:()=>P(t.filename),children:(0,G.jsx)(MS,{fontSize:`small`})})})]}),children:[(0,G.jsx)(ey,{sx:{minWidth:36},children:(0,G.jsx)(HT,{fontSize:`small`,color:t.auto?`action`:`primary`})}),(0,G.jsx)(ny,{primary:(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsxs)(Q,{variant:`body2`,children:[`v`,t.version]}),(0,G.jsx)(Sv,{label:t.auto?e(`backup.auto`):e(`backup.manual`),size:`small`,variant:`outlined`,color:t.auto?`default`:`primary`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:uJe(t.sizeBytes)})]}),secondary:new Date(t.createdAt).toLocaleString()})]},t.filename))}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:2,children:[(0,G.jsx)(DT,{color:`action`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.settings`)})]}),k&&(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,maxWidth:400},children:[(0,G.jsx)(Av,{control:(0,G.jsx)(HS,{checked:k.autoBackup,onChange:e=>B({autoBackup:e.target.checked})}),label:e(`backup.autoBackupLabel`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:-1},children:e(`backup.autoBackupDesc`)}),(0,G.jsx)(xS,{label:e(`backup.retentionCount`),type:`number`,size:`small`,value:k.backupRetentionCount,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=100&&B({backupRetentionCount:t})},inputProps:{min:1,max:100},helperText:e(`backup.retentionCountDesc`),sx:{maxWidth:200}})]})]}),(0,G.jsxs)(Pb,{open:_,onClose:()=>v(!1),maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Lb,{children:e(`backup.restoreTitle`)}),(0,G.jsx)(Ib,{children:s&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:[`Backup created: `,new Date(s.createdAt).toLocaleString()]}),s.includesIdentity&&(0,G.jsx)(Uh,{severity:`info`,sx:{mt:1},children:`This backup includes Matter identity data (keypairs, fabric credentials). Restoring identities allows bridges to reconnect without re-commissioning.`}),(0,G.jsxs)(Q,{variant:`subtitle2`,sx:{mt:2,mb:1},children:[e(`backup.selectBridges`),`:`]}),(0,G.jsx)(Yv,{dense:!0,children:s.bridges.map(e=>(0,G.jsxs)(Qv,{onClick:()=>ie(e.id),sx:{cursor:`pointer`},children:[(0,G.jsx)(ey,{children:(0,G.jsx)(yv,{edge:`start`,checked:l.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,G.jsx)(ny,{primary:e.name,secondary:(0,G.jsxs)(G.Fragment,{children:[`Port: `,e.port,e.hasMappings&&` • ${e.mappingCount} entity mappings`,e.exists&&(0,G.jsx)(Q,{component:`span`,color:`warning.main`,sx:{ml:1},children:`(exists)`})]})})]},e.id))}),(0,G.jsxs)(Z,{sx:{mt:2},children:[(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{checked:d,onChange:e=>f(e.target.checked)}),label:e(`backup.overwriteExisting`)}),(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{checked:p,onChange:e=>m(e.target.checked)}),label:e(`backup.includeMappings`)}),s?.includesIdentity&&(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{checked:h,onChange:e=>g(e.target.checked)}),label:e(`backup.restoreIdentities`)})]})]})}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>v(!1),children:e(`common.cancel`)}),(0,G.jsx)(uv,{variant:`contained`,onClick:re,disabled:t||l.size===0,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Pb,{open:y,onClose:()=>b(!1),children:[(0,G.jsxs)(Lb,{children:[(0,G.jsx)(iE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.restartRequired`)]}),(0,G.jsxs)(Ib,{children:[(0,G.jsx)(Q,{children:e(`backup.restartMessage`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:e(`backup.restartNote`)})]}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>b(!1),children:e(`common.later`)}),(0,G.jsx)(uv,{variant:`contained`,color:`warning`,onClick:async()=>{n(!0);try{await fetch(`api/backup/restart`,{method:`POST`}),o(`Application is restarting...`)}catch(e){i(e instanceof Error?e.message:`Failed to restart`)}finally{n(!1),b(!1)}},disabled:t,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):(0,G.jsx)(iE,{}),children:e(`backup.restartNow`)})]})]}),(0,G.jsxs)(Pb,{open:j!==null,onClose:()=>M(null),children:[(0,G.jsxs)(Lb,{children:[(0,G.jsx)(aE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmRestore`)]}),(0,G.jsxs)(Ib,{children:[(0,G.jsx)(Q,{children:e(`backup.confirmRestoreMessage`,{filename:j})}),(0,G.jsx)(Uh,{severity:`warning`,sx:{mt:2},children:e(`backup.restoreWarning`)})]}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>M(null),children:e(`common.cancel`)}),(0,G.jsx)(uv,{variant:`contained`,color:`warning`,onClick:()=>j&&z(j),disabled:t,startIcon:t?(0,G.jsx)(Rh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Pb,{open:N!==null,onClose:()=>P(null),children:[(0,G.jsxs)(Lb,{children:[(0,G.jsx)(MS,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmDelete`)]}),(0,G.jsx)(Ib,{children:(0,G.jsx)(Q,{children:e(`backup.confirmDeleteMessage`,{filename:N})})}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:()=>P(null),children:e(`common.cancel`)}),(0,G.jsx)(uv,{variant:`contained`,color:`error`,onClick:()=>N&&te(N),children:e(`common.delete`)})]})]})]})}var dJe=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`};function fJe(e={}){let{t}=ms(),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(!0),[o,s]=(0,C.useState)(null),[c,l]=(0,C.useState)(`name`),[u,d]=(0,C.useState)(`asc`),f=e.sortField??c,p=e.sortDirection??u,m=e.onSortFieldChange??l,h=e.onSortDirectionChange??d,g=(0,C.useCallback)(async()=>{try{let e=await fetch(`api/health/detailed`);e.ok?(r(await e.json()),s(null)):s(t(`health.fetchFailed`))}catch{s(t(`health.connectionError`))}finally{a(!1)}},[t]);(0,C.useEffect)(()=>{g();let e=setInterval(g,1e4);return()=>clearInterval(e)},[g]);let _=(0,C.useCallback)(async()=>{try{let e=await fetch(`api/diagnostic/export`);if(e.ok){let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e.headers.get(`Content-Disposition`)?.match(/filename="(.+)"/)?.[1]??`hamh-diagnostic-${new Date().toISOString().replace(/[:.]/g,`-`)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}}catch{s(t(`health.exportFailed`))}},[t]),v=async e=>{try{await fetch(`api/matter/bridges/${e}/actions/restart`,{method:`POST`}),g()}catch{s(t(`health.restartFailed`))}};return i?(0,G.jsx)(Z,{display:`flex`,justifyContent:`center`,p:4,children:(0,G.jsx)(Rh,{})}):o||!n?(0,G.jsx)(Uh,{severity:`error`,sx:{m:2},children:o??t(`health.unableToLoad`)}):(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[n.status===`healthy`?(0,G.jsx)(av,{color:`success`}):n.status===`degraded`?(0,G.jsx)(Gv,{color:`warning`}):(0,G.jsx)(vx,{color:`error`}),(0,G.jsx)(Q,{variant:`h5`,children:t(`health.systemHealth`)}),(0,G.jsx)(Sv,{label:n.status.toUpperCase(),color:n.status===`healthy`?`success`:n.status===`degraded`?`warning`:`error`,size:`small`})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(UT,{}),onClick:_,children:t(`health.exportDiagnostic`)}),(0,G.jsx)(sb,{title:t(`common.refresh`),children:(0,G.jsx)(Bh,{onClick:g,"aria-label":`Refresh health data`,children:(0,G.jsx)(rE,{})})})]})]}),(0,G.jsxs)(jv,{container:!0,spacing:2,children:[(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.version`)}),(0,G.jsx)(Q,{variant:`h6`,children:n.version})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.uptime`)}),(0,G.jsx)(Q,{variant:`h6`,children:dJe(n.uptime)})]})}),(0,G.jsx)(jv,{size:{xs:12,md:4},children:(0,G.jsxs)(Wm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.homeAssistant`)}),(0,G.jsx)(Sv,{label:n.services.homeAssistant.connected?t(`health.connected`):t(`health.disconnected`),color:n.services.homeAssistant.connected?`success`:`error`,size:`small`})]})})]}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,flexWrap:`wrap`,gap:1,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(tE,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.bridgeStatus`)}),(0,G.jsx)(Sv,{label:`${n.services.bridges.running}/${n.services.bridges.total} ${t(`common.running`)}`,size:`small`,variant:`outlined`})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Dx,{fontSize:`small`,color:`action`}),(0,G.jsxs)(Tv,{size:`small`,sx:{minWidth:120},children:[(0,G.jsx)(Fx,{children:t(`health.sortBy`)}),(0,G.jsxs)(_S,{value:f,label:t(`health.sortBy`),onChange:e=>m(e.target.value),children:[(0,G.jsx)(vS,{value:`name`,children:t(`common.name`)}),(0,G.jsx)(vS,{value:`created`,children:t(`health.created`)})]})]}),(0,G.jsx)(sb,{title:t(p===`asc`?`health.ascending`:`health.descending`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>h(p===`asc`?`desc`:`asc`),"aria-label":`Sort ${p===`asc`?`descending`:`ascending`}`,children:p===`asc`?(0,G.jsx)(zT,{fontSize:`small`}):(0,G.jsx)(RT,{fontSize:`small`})})})]})]}),(0,G.jsx)(jv,{container:!0,spacing:2,alignItems:`stretch`,children:[...n.bridgeDetails].sort((e,t)=>{let n=0;return n=f===`name`?e.name.localeCompare(t.name):e.id.localeCompare(t.id),p===`asc`?n:-n}).map(e=>(0,G.jsx)(jv,{size:{xs:12,sm:6,md:6,lg:4,xl:3},sx:{display:`flex`},children:(0,G.jsx)(dv,{variant:`outlined`,sx:{width:`100%`,height:`100%`,minWidth:280,maxWidth:480,display:`flex`,flexDirection:`column`,borderColor:e.status===`running`?`success.main`:e.status===`failed`?`error.main`:`warning.main`},children:(0,G.jsxs)(mv,{sx:{flex:1,display:`flex`,flexDirection:`column`,p:2,"&:last-child":{pb:2}},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,flexShrink:0,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,minWidth:0,children:[(0,G.jsx)(ub,{}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,noWrap:!0,sx:{maxWidth:140},children:e.name})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:.5,flexShrink:0,children:[(0,G.jsx)(Sv,{label:e.status.toUpperCase(),color:e.status===`running`?`success`:e.status===`failed`?`error`:`warning`,size:`small`}),e.status===`failed`&&(0,G.jsx)(sb,{title:t(`bridge.restart`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>v(e.id),children:(0,G.jsx)(VT,{})})})]})]}),e.statusReason&&(0,G.jsx)(Q,{variant:`body2`,color:`error`,sx:{mt:1,flexShrink:0},children:e.statusReason}),(0,G.jsx)(Z,{sx:{mt:`auto`,pt:1,flexShrink:0},children:(0,G.jsxs)(Z,{display:`flex`,flexWrap:`wrap`,gap:.5,alignItems:`center`,children:[(0,G.jsx)(Sv,{label:`${t(`common.port`)} ${e.port}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Sv,{label:`${e.deviceCount} ${t(`common.devices`)}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Sv,{label:`${e.fabricCount} ${t(`common.fabrics`)}`,size:`small`,variant:`outlined`,color:`default`}),e.failedEntityCount>0&&(0,G.jsx)(Sv,{label:`${e.failedEntityCount} failed`,color:`error`,size:`small`})]})}),e.connectivity&&e.status===`running`&&(0,G.jsx)(Z,{sx:{mt:1,flexShrink:0},children:(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,children:[t(`health.sessions`),`:`,` `,e.connectivity.totalSessions,` |`,` `,t(`health.subscriptions`),`:`,` `,e.connectivity.totalSubscriptions,e.connectivity.fabricSummary&&e.connectivity.fabricSummary.length>1&&` (${e.connectivity.fabricSummary.length} ${t(`health.fabrics`)})`]})}),e.fabrics.length>0&&(0,G.jsxs)(Z,{sx:{mt:1,flexShrink:0},children:[(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,children:[t(`health.connectedTo`),`:`]}),(0,G.jsx)(Z,{display:`flex`,gap:.5,flexWrap:`wrap`,mt:.5,children:e.fabrics.map(e=>(0,G.jsx)(sb,{title:(0,G.jsxs)(Z,{sx:{fontSize:`0.75rem`},children:[(0,G.jsxs)(`div`,{children:[`Fabric #`,e.fabricIndex]}),(0,G.jsxs)(`div`,{children:[`Vendor: `,gx(e.rootVendorId),` `,`(0x`,e.rootVendorId.toString(16).toUpperCase().padStart(4,`0`),`)`]}),(0,G.jsxs)(`div`,{children:[`Fabric ID: `,e.fabricId]}),(0,G.jsxs)(`div`,{children:[`Node ID: `,e.nodeId]}),(0,G.jsxs)(`div`,{children:[`Root Node ID: `,e.rootNodeId]})]}),children:(0,G.jsx)(Sv,{icon:(0,G.jsx)(_x,{fabric:e}),label:e.label||gx(e.rootVendorId),size:`small`,variant:`outlined`})},e.fabricIndex))})]})]})})},e.id))}),n.recovery.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(VT,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.autoRecovery`)}),(0,G.jsx)(Sv,{label:t(`common.enabled`),color:`success`,size:`small`})]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[t(`health.recoveryAttempts`),`: `,n.recovery.recoveryCount,n.recovery.lastRecoveryAttempt&&` | Last attempt: ${new Date(n.recovery.lastRecoveryAttempt).toLocaleString()}`]})]}),(0,G.jsx)(zb,{sx:{my:3}}),(0,G.jsx)(v3,{})]})}var y3=e=>e===`pass`?`success`:e===`warn`?`warning`:`error`;function pJe(){let{t:e}=ms(),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!1),l=(0,C.useCallback)(async()=>{i(!0),o(null);try{let t=await fetch(`api/network`);t.ok?n(await t.json()):o(e(`health.fetchFailed`))}catch{o(e(`health.connectionError`))}finally{i(!1)}},[e]);(0,C.useEffect)(()=>{l()},[l]);let u=t?.checks.filter(e=>e.status===`pass`).length??0,d=t?.checks.filter(e=>e.status===`warn`).length??0,f=t?.checks.filter(e=>e.status===`fail`).length??0;return(0,G.jsxs)(Wm,{variant:`outlined`,sx:{p:2},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`center`,mb:1,children:[(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`health.networkDiagnostics`)}),(0,G.jsx)(uv,{size:`small`,onClick:l,disabled:r,children:r?(0,G.jsx)(Rh,{size:16}):e(`health.refresh`)})]}),a&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:1},children:a}),t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:1.5,flexWrap:`wrap`,children:[u>0&&(0,G.jsx)(Sv,{label:`${u} ${e(`health.checksPassed`)}`,color:`success`,size:`small`,variant:`outlined`}),d>0&&(0,G.jsx)(Sv,{label:`${d} ${e(`health.checksWarning`)}`,color:`warning`,size:`small`,variant:`outlined`}),f>0&&(0,G.jsx)(Sv,{label:`${f} ${e(`health.checksFailed`)}`,color:`error`,size:`small`,variant:`outlined`}),(0,G.jsx)(Sv,{label:t.matterConfig.boundInterface?`mDNS: ${t.matterConfig.boundInterface}`:`mDNS: all interfaces`,size:`small`,variant:`outlined`}),(0,G.jsx)(Sv,{label:`IPv4: ${t.matterConfig.ipv4Enabled?`on`:`off`}`,size:`small`,variant:`outlined`})]}),t.checks.filter(e=>e.status!==`pass`).map(e=>(0,G.jsxs)(Uh,{severity:y3(e.status),sx:{mb:1},children:[(0,G.jsx)(`strong`,{children:e.message}),e.detail&&(0,G.jsx)(Q,{variant:`body2`,sx:{mt:.5},children:e.detail})]},e.name)),(0,G.jsx)(uv,{size:`small`,onClick:()=>c(!s),sx:{mt:.5},children:e(s?`health.hideDetails`:`health.showDetails`)}),(0,G.jsxs)(qv,{in:s,children:[(0,G.jsx)(Q,{variant:`subtitle2`,sx:{mt:1,mb:.5},children:e(`health.allChecks`)}),(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:e(`health.check`)}),(0,G.jsx)(oC,{children:e(`health.statusLabel`)}),(0,G.jsx)(oC,{children:e(`health.message`)})]})}),(0,G.jsx)(aC,{children:t.checks.map(e=>(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:(0,G.jsx)(Q,{variant:`body2`,children:e.name})}),(0,G.jsx)(oC,{children:(0,G.jsx)(Sv,{label:e.status,color:y3(e.status),size:`small`})}),(0,G.jsxs)(oC,{children:[(0,G.jsx)(Q,{variant:`body2`,children:e.message}),e.detail&&(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,children:e.detail})]})]},e.name))})]}),(0,G.jsx)(Q,{variant:`subtitle2`,sx:{mt:2,mb:.5},children:e(`health.networkInterfaces`)}),(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:e(`health.interfaceName`)}),(0,G.jsx)(oC,{children:`IPv4`}),(0,G.jsx)(oC,{children:`IPv6`}),(0,G.jsx)(oC,{children:`MAC`})]})}),(0,G.jsx)(aC,{children:t.interfaces.filter(e=>!e.internal).map(e=>(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{children:e.name}),(0,G.jsx)(oC,{children:e.ipv4.join(`, `)||`-`}),(0,G.jsx)(oC,{children:(0,G.jsx)(Q,{variant:`body2`,sx:{wordBreak:`break-all`,maxWidth:240},children:e.ipv6.join(`, `)||`-`})}),(0,G.jsx)(oC,{children:e.mac})]},e.name))})]})]})]})]})}var b3=`hamh-translation-overrides`;function x3(e,t=``){let n={};for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(n,x3(i,e)):n[e]=String(i??``)}return n}function S3(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.split(`.`),i=t;for(let t=0;t<e.length-1;t++)e[t]in i||(i[e[t]]={}),i=i[e[t]];i[e[e.length-1]]=r}return t}function C3(e){try{let t=localStorage.getItem(b3);return t?JSON.parse(t)[e]??{}:{}}catch{return{}}}function w3(e,t){try{let n=localStorage.getItem(b3),r=n?JSON.parse(n):{};Object.keys(t).length===0?delete r[e]:r[e]=t,localStorage.setItem(b3,JSON.stringify(r))}catch{}}var T3=`hamh-custom-languages`;function mJe(){try{let e=localStorage.getItem(T3);return e?JSON.parse(e):[]}catch{return[]}}function E3(e){localStorage.setItem(T3,JSON.stringify(e))}var D3=[{code:`de`,name:`Deutsch`},{code:`fr`,name:`Français`},{code:`es`,name:`Español`},{code:`it`,name:`Italiano`},{code:`zh`,name:`中文`},{code:`zh-TW`,name:`繁體中文`},{code:`ja`,name:`日本語`},{code:`th`,name:`ไทย`},{code:`sv`,name:`Svenska`},{code:`tr`,name:`Türkçe`},{code:`ru`,name:`Русский`}];function hJe(){let{t:e,i18n:t}=ms(),n=t.language??`en`,r=D3.some(e=>e.code===n)?n:n.split(`-`)[0]??`en`,[i,a]=(0,C.useState)(()=>r===`en`?`de`:r),[o,s]=(0,C.useState)(``),[c,l]=(0,C.useState)(()=>C3(i)),[u,d]=(0,C.useState)(!1),[f,p]=(0,C.useState)(`all`),[m,h]=(0,C.useState)(mJe),[g,_]=(0,C.useState)(!1),[v,y]=(0,C.useState)(``),[b,x]=(0,C.useState)(``),[S,w]=(0,C.useState)(``),[T,E]=(0,C.useState)(``),D=(0,C.useMemo)(()=>[...D3,...m],[m]),O=(0,C.useCallback)(e=>m.some(t=>t.code===e),[m]),k=(0,C.useMemo)(()=>x3(gs),[]),A=(0,C.useMemo)(()=>{let e=t.getResourceBundle(i,`translation`);return e?x3(e):{}},[i,t]),j=(0,C.useMemo)(()=>Object.keys(k).map(e=>({key:e,section:e.split(`.`)[0],enValue:k[e],currentValue:c[e]??A[e]??``,isOverridden:e in c})),[k,A,c]),M=(0,C.useMemo)(()=>{let e=j;if(o){let t=o.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||e.enValue.toLowerCase().includes(t)||e.currentValue.toLowerCase().includes(t))}return f===`missing`?e=e.filter(e=>!e.currentValue):f===`edited`&&(e=e.filter(e=>e.isOverridden)),e},[j,o,f]),N=(0,C.useMemo)(()=>[...new Set(M.map(e=>e.section))],[M]),P=Object.keys(k).length,F=j.filter(e=>e.currentValue).length,I=Object.keys(c).length,L=P>0?F/P*100:0;(0,C.useEffect)(()=>{l(C3(i))},[i]);let R=(0,C.useCallback)(e=>{l(e),w3(i,e);let n=t.getResourceBundle(i,`translation`),r=n?x3(n):{},a={};for(let[t,n]of Object.entries(e))n&&n!==r[t]&&(a[t]=n);if(Object.keys(a).length>0){let e=S3({...r,...a});t.addResourceBundle(i,`translation`,e,!0,!0)}},[i,t]),ee=(0,C.useCallback)((e,t)=>{let n={...c,[e]:t};t||delete n[e],R(n)},[c,R]),z=(0,C.useCallback)(e=>{let t={...c};delete t[e],R(t)},[c,R]),te=(0,C.useCallback)(()=>{R({})},[R]),B=(0,C.useCallback)(()=>{let e={};for(let t of Object.keys(k))e[t]=c[t]??A[t]??``;let t=S3(e),n=JSON.stringify(t,null,2),r=new Blob([n],{type:`application/json`}),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=`${i}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},[k,A,c,i]),V=(0,C.useCallback)(()=>{let e={};for(let t of Object.keys(k))e[t]=c[t]??A[t]??``;let t=S3(e);navigator.clipboard.writeText(JSON.stringify(t,null,2)),d(!0),setTimeout(()=>d(!1),2e3)},[k,A,c]),ne=(0,C.useCallback)(()=>{let n=v.trim().toLowerCase(),r=b.trim();if(!n){w(e(`translationEditor.codeRequired`));return}if(!r){w(e(`translationEditor.nameRequired`));return}if(D3.some(e=>e.code===n)||m.some(e=>e.code===n)||n===`en`){w(e(`translationEditor.languageExists`));return}let i=[...m,{code:n,name:r}];h(i),E3(i),t.addResourceBundle(n,`translation`,{},!0,!0),a(n),_(!1),y(``),x(``),w(``)},[v,b,m,t,e]),re=(0,C.useCallback)(()=>{if(!O(i))return;let e=m.filter(e=>e.code!==i);h(e),E3(e),w3(i,{}),a(D3[0].code)},[i,m,O]),ie=(0,C.useCallback)(()=>{let t=document.createElement(`input`);t.type=`file`,t.accept=`.json`,t.onchange=()=>{let n=t.files?.[0];if(!n)return;let r=new FileReader;r.onload=()=>{try{let t=JSON.parse(r.result);if(typeof t!=`object`||!t)throw Error();let n=x3(t),i=new Set(Object.keys(k)),a={},o=0;for(let[e,t]of Object.entries(n))i.has(e)&&t&&(a[e]=t,o++);R({...c,...a}),E(e(`translationEditor.importSuccess`,{count:o}))}catch{E(e(`translationEditor.importFailed`))}},r.readAsText(n)},t.click()},[k,c,R,e]);return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,flexWrap:`wrap`,gap:1,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Qhe,{}),(0,G.jsx)(Q,{variant:`h5`,children:e(`translationEditor.title`)})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsxs)(Tv,{size:`small`,sx:{minWidth:140},children:[(0,G.jsx)(Fx,{children:e(`translationEditor.editLanguage`)}),(0,G.jsx)(_S,{value:i,label:e(`translationEditor.editLanguage`),onChange:e=>a(e.target.value),children:D.map(e=>(0,G.jsxs)(vS,{value:e.code,children:[(0,G.jsx)(ny,{primary:e.name}),O(e.code)&&(0,G.jsx)(ey,{sx:{minWidth:`auto`,ml:1},children:(0,G.jsx)(qT,{fontSize:`small`,color:`disabled`})})]},e.code))})]}),(0,G.jsx)(sb,{title:e(`translationEditor.addLanguage`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>_(e=>!e),children:(0,G.jsx)(cb,{fontSize:`small`})})}),O(i)&&(0,G.jsx)(sb,{title:e(`translationEditor.removeLanguage`),children:(0,G.jsx)(Bh,{size:`small`,color:`error`,onClick:re,children:(0,G.jsx)(qT,{fontSize:`small`})})})]})]}),(0,G.jsx)(qv,{in:g,children:(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:2,alignItems:`flex-start`,flexWrap:`wrap`,children:[(0,G.jsx)(xS,{size:`small`,label:e(`translationEditor.newLanguageCode`),value:v,onChange:e=>y(e.target.value),error:!!S,sx:{width:180}}),(0,G.jsx)(xS,{size:`small`,label:e(`translationEditor.newLanguageName`),value:b,onChange:e=>x(e.target.value),sx:{width:220}}),(0,G.jsx)(uv,{variant:`contained`,size:`small`,onClick:ne,children:e(`translationEditor.addLanguageButton`)}),S&&(0,G.jsx)(Q,{variant:`caption`,color:`error`,sx:{mt:.5},children:S})]})}),(0,G.jsx)(Uh,{severity:`info`,sx:{mb:2},children:e(`translationEditor.info`)}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:2,mb:2,flexWrap:`wrap`,children:[(0,G.jsxs)(Z,{sx:{flexGrow:1,minWidth:200},children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:.5,children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`translationEditor.progress`,{translated:F,total:P})}),(0,G.jsxs)(Q,{variant:`body2`,fontWeight:600,children:[Math.round(L),`%`]})]}),(0,G.jsx)(Lv,{variant:`determinate`,value:L,sx:{height:8,borderRadius:4}})]}),I>0&&(0,G.jsx)(Sv,{label:e(`translationEditor.localEdits`,{count:I}),color:`primary`,size:`small`})]}),(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:2,flexWrap:`wrap`,children:[(0,G.jsx)(xS,{size:`small`,placeholder:e(`translationEditor.searchPlaceholder`),value:o,onChange:e=>s(e.target.value),sx:{flexGrow:1,minWidth:200},slotProps:{input:{startAdornment:(0,G.jsx)(ZP,{position:`start`,children:(0,G.jsx)(sE,{fontSize:`small`})})}}}),(0,G.jsx)(Tv,{size:`small`,sx:{minWidth:130},children:(0,G.jsxs)(_S,{value:f,onChange:e=>p(e.target.value),children:[(0,G.jsx)(vS,{value:`all`,children:e(`translationEditor.filterAll`)}),(0,G.jsx)(vS,{value:`missing`,children:e(`translationEditor.filterMissing`)}),(0,G.jsx)(vS,{value:`edited`,children:e(`translationEditor.filterEdited`)})]})})]}),(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:3,flexWrap:`wrap`,children:[(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(tge,{}),onClick:B,children:e(`translationEditor.exportJson`)}),(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(ET,{}),onClick:ie,children:e(`translationEditor.importJson`)}),(0,G.jsx)(sb,{title:u?e(`translationEditor.copied`):``,children:(0,G.jsx)(uv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(lb,{}),onClick:V,children:e(`translationEditor.copyJson`)})}),I>0&&(0,G.jsx)(uv,{variant:`outlined`,size:`small`,color:`warning`,startIcon:(0,G.jsx)(aE,{}),onClick:te,children:e(`translationEditor.resetAll`)})]}),N.map(t=>(0,G.jsxs)(Z,{sx:{mb:3},children:[(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:600,sx:{mb:1,textTransform:`capitalize`},children:t}),(0,G.jsx)(zb,{sx:{mb:1.5}}),M.filter(e=>e.section===t).map(t=>(0,G.jsxs)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`1fr 1fr auto`},gap:1,mb:1.5,alignItems:`start`},children:[(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{fontFamily:`monospace`},children:t.key}),(0,G.jsx)(Q,{variant:`body2`,sx:{mt:.25},children:t.enValue})]}),(0,G.jsx)(xS,{size:`small`,fullWidth:!0,multiline:t.enValue.length>60,minRows:1,maxRows:4,value:t.currentValue,onChange:e=>ee(t.key,e.target.value),placeholder:t.enValue,sx:{"& .MuiOutlinedInput-root":t.isOverridden?{borderColor:`primary.main`,"& fieldset":{borderColor:`primary.main`,borderWidth:2}}:{}}}),t.isOverridden&&(0,G.jsx)(sb,{title:e(`translationEditor.resetKey`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>z(t.key),children:(0,G.jsx)(aE,{fontSize:`small`})})})]},t.key))]},t)),M.length===0&&(0,G.jsx)(Q,{color:`text.secondary`,sx:{textAlign:`center`,py:4},children:e(`translationEditor.noResults`)}),(0,G.jsx)($h,{open:!!T,autoHideDuration:3e3,onClose:()=>E(``),message:T})]})}var O3=e=>{let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(1)} ${t[r]}`},k3=e=>{let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`},gJe=()=>{let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(!0),[i,a]=(0,C.useState)(!0);if((0,C.useEffect)(()=>{let e=null,n=async()=>{try{let n=await fetch(`api/system/info`);n.ok?(t(await n.json()),a(!0)):n.status===404&&(a(!1),e&&=(clearInterval(e),null))}catch{}finally{r(!1)}};return n(),e=setInterval(n,3e4),()=>{e&&clearInterval(e)}},[]),!i)return null;if(n)return(0,G.jsx)(dv,{children:(0,G.jsx)(mv,{children:(0,G.jsx)(Q,{children:`Loading system information...`})})});if(!e)return(0,G.jsx)(dv,{children:(0,G.jsx)(mv,{children:(0,G.jsx)(Q,{color:`error`,children:`Failed to load system information`})})});let o=e.memory.used/e.memory.total*100,s=e.storage.used/e.storage.total*100;return(0,G.jsx)(dv,{children:(0,G.jsxs)(mv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Che,{}),`System Information`]}),(0,G.jsxs)(jv,{container:!0,spacing:3,children:[(0,G.jsx)(jv,{size:{xs:12,md:6},children:(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`Application`}),(0,G.jsxs)(Rv,{spacing:1,sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Version:`}),(0,G.jsx)(Sv,{label:e.version,size:`small`,color:`primary`})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Environment:`}),(0,G.jsx)(Sv,{label:e.environment,size:`small`,variant:`outlined`,color:e.environment===`Home Assistant Add-on`?`success`:`default`})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Node.js:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e.nodeVersion})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Process Uptime:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:k3(e.process.uptime)})]})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`System`}),(0,G.jsxs)(Rv,{spacing:1,sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Hostname:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e.hostname})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`Platform:`}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[e.platform,` (`,e.arch,`)`]})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`CPU:`}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,sx:{maxWidth:200,textAlign:`right`},noWrap:!0,title:e.cpuModel,children:[e.cpuCount,`x`,` `,e.cpuModel.split(`@`)[0].trim()]})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,G.jsx)(Q,{variant:`body2`,children:`System Uptime:`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:k3(e.uptime)})]})]})]})]})}),(0,G.jsx)(jv,{size:{xs:12,md:6},children:(0,G.jsxs)(Rv,{spacing:2,children:[(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(tE,{}),`Memory Usage`]}),(0,G.jsxs)(Z,{sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,mb:1},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[O3(e.memory.used),` /`,` `,O3(e.memory.total)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[o.toFixed(1),`%`]})]}),(0,G.jsx)(Z,{sx:{height:8,backgroundColor:`action.hover`,borderRadius:4,overflow:`hidden`},children:(0,G.jsx)(Z,{sx:{height:`100%`,width:`${o}%`,backgroundColor:o>80?`error.main`:o>60?`warning.main`:`success.main`,transition:`width 0.3s ease`}})})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(tE,{}),`HAMH Process Memory`]}),(0,G.jsxs)(Z,{sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[`RSS: `,O3(e.process.rss)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[`Heap: `,O3(e.process.heapUsed),` /`,` `,O3(e.process.heapSizeLimit)]})]}),(0,G.jsx)(Z,{sx:{height:8,backgroundColor:`action.hover`,borderRadius:4,overflow:`hidden`},children:(0,G.jsx)(Z,{sx:{height:`100%`,width:`${Math.min(e.process.heapUsed/e.process.heapSizeLimit*100,100)}%`,backgroundColor:e.process.heapUsed/e.process.heapSizeLimit>.85?`error.main`:e.process.heapUsed/e.process.heapSizeLimit>.6?`warning.main`:`success.main`,transition:`width 0.3s ease`}})})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Yhe,{}),`Storage Usage`]}),(0,G.jsxs)(Z,{sx:{mt:1},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,mb:1},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[O3(e.storage.used),` /`,` `,O3(e.storage.total)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[s.toFixed(1),`%`]})]}),(0,G.jsx)(Z,{sx:{height:8,backgroundColor:`action.hover`,borderRadius:4,overflow:`hidden`},children:(0,G.jsx)(Z,{sx:{height:`100%`,width:`${s}%`,backgroundColor:s>80?`error.main`:s>60?`warning.main`:`success.main`,transition:`width 0.3s ease`}})})]})]})]})}),(0,G.jsxs)(jv,{size:{xs:12},children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Rhe,{}),`Network Interfaces`]}),(0,G.jsx)(Rv,{spacing:1,sx:{mt:1},children:e.network.interfaces.map(e=>(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(Q,{variant:`body2`,children:e.name}),(0,G.jsx)(Sv,{label:`${e.address} (${e.family})`,size:`small`,variant:`outlined`})]},`${e.name}-${e.address}`))})]})]})]})})},A3=200;function _Je(){let[e,t]=(0,C.useState)([]),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(!1),o=(0,C.useRef)(null),s=(0,C.useRef)(void 0),c=(0,C.useCallback)(()=>{if(o.current?.readyState===WebSocket.OPEN)return;let e=window.location.protocol===`https:`?`wss:`:`ws:`,n=document.querySelector(`base`)?.href||window.location.origin,i=new URL(n),l=`${e}//${i.host}${i.pathname}api/ws`.replace(/\/+/g,`/`).replace(`:/`,`://`),u=new WebSocket(l);o.current=u,u.onopen=()=>{a(!0),u.send(JSON.stringify({type:`subscribe_diagnostics`}))},u.onmessage=e=>{try{let n=JSON.parse(e.data);if(n.type===`diagnostic_event`){let e=n.data;t(t=>{let n=[...t,e];return n.length>A3?n.slice(-A3):n})}else if(n.type===`diagnostic_snapshot`){let e=n.data;r(e),t(e.recentEvents??[])}}catch{}},u.onclose=()=>{a(!1),o.current=null,s.current=setTimeout(c,3e3)},u.onerror=()=>u.close()},[]);return(0,C.useEffect)(()=>(c(),()=>{clearTimeout(s.current),o.current&&(o.current.send(JSON.stringify({type:`unsubscribe_diagnostics`})),o.current.close())}),[c]),{events:e,snapshot:n,connected:i,clearEvents:(0,C.useCallback)(()=>t([]),[])}}function j3(e){let t=e.replace(`#`,``),n=Number.parseInt(t.substring(0,2),16)/255,r=Number.parseInt(t.substring(2,4),16)/255,i=Number.parseInt(t.substring(4,6),16)/255;return .2126*(n<=.03928?n/12.92:((n+.055)/1.055)**2.4)+.7152*(r<=.03928?r/12.92:((r+.055)/1.055)**2.4)+.0722*(i<=.03928?i/12.92:((i+.055)/1.055)**2.4)>.179?`#000`:`#fff`}var M3={state_update:`#4caf50`,command_received:`#2196f3`,entity_error:`#f44336`,session_opened:`#ff9800`,session_closed:`#9e9e9e`,subscription_changed:`#9c27b0`,bridge_started:`#00bcd4`,bridge_stopped:`#795548`,entity_warning:`#ff9800`},N3={state_update:`diagnostics.stateUpdate`,command_received:`diagnostics.command`,entity_error:`diagnostics.entityError`,session_opened:`diagnostics.sessionOpen`,session_closed:`diagnostics.sessionClose`,subscription_changed:`diagnostics.subscription`,bridge_started:`diagnostics.bridgeStart`,bridge_stopped:`diagnostics.bridgeStop`,entity_warning:`diagnostics.entityWarning`};function vJe(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}var P3=Object.keys(M3);function yJe({sortField:e,sortDirection:t}={}){let{t:n}=ms(),r=wm(),{events:i,snapshot:a,connected:o,clearEvents:s}=_Je(),[c,l]=(0,C.useState)(new Set(P3)),[u,d]=(0,C.useState)(!1),f=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=i.filter(e=>c.has(e.type)),m=(0,C.useMemo)(()=>{let n=a?.bridges??[];return e?[...n].sort((n,r)=>{let i=0;return i=e===`name`?n.bridgeName.localeCompare(r.bridgeName):n.bridgeId.localeCompare(r.bridgeId),t===`desc`?-i:i}):n},[a?.bridges,e,t]),h={};for(let e of i)h[e.type]=(h[e.type]??0)+1;return(0,G.jsx)(dv,{children:(0,G.jsxs)(mv,{children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,children:[(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsx)(Zhe,{}),(0,G.jsx)(Q,{variant:`h6`,children:n(`diagnostics.title`)}),(0,G.jsx)(Sv,{icon:(0,G.jsx)(khe,{sx:{fontSize:10,color:o?r.palette.success.main:r.palette.error.main}}),label:n(o?`common.live`:`common.offline`),size:`small`,variant:`outlined`})]}),(0,G.jsxs)(Rv,{direction:`row`,spacing:.5,alignItems:`center`,children:[(0,G.jsx)(sb,{title:n(`diagnostics.filterEvents`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>d(e=>!e),color:u?`primary`:`default`,children:(0,G.jsx)(pb,{})})}),(0,G.jsx)(sb,{title:n(`diagnostics.clearEvents`),children:(0,G.jsx)(Bh,{size:`small`,onClick:s,children:(0,G.jsx)(xhe,{})})})]})]}),(0,G.jsxs)(Rv,{direction:`row`,spacing:.5,flexWrap:`wrap`,sx:{mb:2,gap:.5},children:[P3.map(e=>{let t=h[e]??0;if(t===0&&!u)return null;let r=M3[e];return(0,G.jsx)(Sv,{label:`${n(N3[e])}: ${t}`,size:`small`,sx:{bgcolor:c.has(e)?r:`action.disabledBackground`,color:c.has(e)?j3(r):`text.disabled`,fontSize:`0.7rem`,height:22,cursor:`pointer`,opacity:c.has(e)?1:.5},onClick:()=>f(e)},e)}),a?.system&&(0,G.jsx)(Sv,{label:`Total: ${a.system.eventCount}`,size:`small`,variant:`outlined`,sx:{fontSize:`0.7rem`,height:22}})]}),(0,G.jsx)(qv,{in:u,children:(0,G.jsx)(Wm,{variant:`outlined`,sx:{p:1.5,mb:2},children:(0,G.jsx)(jv,{container:!0,spacing:0,children:P3.map(e=>{let t=M3[e];return(0,G.jsx)(jv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(Av,{control:(0,G.jsx)(yv,{size:`small`,checked:c.has(e),onChange:()=>f(e),sx:{color:t,"&.Mui-checked":{color:t}}}),label:(0,G.jsx)(Q,{variant:`caption`,children:n(N3[e])})})},e)})})})}),m.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jv,{container:!0,spacing:1,sx:{mb:2},children:m.map(e=>(0,G.jsx)(bJe,{bridge:e},e.bridgeId))}),(0,G.jsx)(zb,{sx:{mb:2}})]}),(0,G.jsx)(Z,{sx:{maxHeight:400,overflow:`auto`,bgcolor:`background.default`,borderRadius:1,p:1},children:p.length===0?(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{textAlign:`center`,py:4},children:i.length===0?`Waiting for diagnostic events…`:n(`diagnostics.noEvents`)}):p.map(e=>{let t=M3[e.type];return(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`flex-start`,gap:1,py:.4,px:.5,minWidth:0,borderBottom:`1px solid`,borderColor:`divider`,"&:hover":{bgcolor:`action.hover`},"&:last-child":{borderBottom:`none`}},children:[(0,G.jsx)(Q,{variant:`caption`,sx:{color:`text.secondary`,whiteSpace:`nowrap`,fontFamily:`monospace`,fontSize:`0.72rem`,minWidth:85,pt:.1},children:vJe(e.timestamp)}),(0,G.jsx)(Sv,{label:N3[e.type]?n(N3[e.type]):e.type,size:`small`,sx:{bgcolor:t??`#757575`,color:j3(t??`#757575`),fontSize:`0.62rem`,fontWeight:600,height:18,minWidth:90}}),e.bridgeName&&(0,G.jsxs)(Q,{variant:`caption`,sx:{color:`primary.main`,fontWeight:600,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`0.72rem`,maxWidth:140,flexShrink:0},children:[`[`,e.bridgeName,`]`]}),e.entityId&&(0,G.jsx)(Q,{variant:`caption`,sx:{color:`warning.main`,fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`0.72rem`,maxWidth:220,flexShrink:1},children:e.entityId}),(0,G.jsx)(Q,{variant:`caption`,sx:{color:`text.primary`,flex:1,wordBreak:`break-word`,fontSize:`0.72rem`},children:e.message})]},e.id)})})]})})}function bJe({bridge:e}){let[t,n]=(0,C.useState)(!1);return(0,G.jsx)(jv,{size:{xs:12,sm:6},children:(0,G.jsxs)(Wm,{variant:`outlined`,sx:{p:1.5,overflow:`hidden`,minWidth:0},children:[(0,G.jsxs)(Z,{display:`flex`,justifyContent:`space-between`,alignItems:`center`,sx:{cursor:`pointer`},onClick:()=>n(e=>!e),children:[(0,G.jsxs)(Z,{sx:{minWidth:0,overflow:`hidden`},children:[(0,G.jsx)(Q,{variant:`body2`,fontWeight:500,noWrap:!0,children:e.bridgeName}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:[e.entityCount,` devices · `,e.sessionCount,` sessions`]})]}),(0,G.jsxs)(Rv,{direction:`row`,spacing:.5,alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`,sx:{flexShrink:0,ml:1},children:[Object.entries(e.featureFlags).filter(([,e])=>e).map(([e])=>(0,G.jsx)(Sv,{label:e.replace(/^auto/,``).replace(/([A-Z])/g,` $1`).trim(),size:`small`,variant:`outlined`,sx:{fontSize:`0.6rem`,height:18}},e)),(0,G.jsx)(Sv,{label:e.status,size:`small`,color:e.status===`running`?`success`:e.status===`failed`?`error`:`default`,sx:{height:20}}),(0,G.jsx)(GS,{sx:{transform:t?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`,fontSize:18,color:`text.secondary`}})]})]}),(0,G.jsx)(qv,{in:t,children:(0,G.jsx)(Z,{sx:{mt:1,maxHeight:200,overflow:`auto`},children:e.entities.map(e=>(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`baseline`,gap:.5,py:.3,borderBottom:`1px solid`,borderColor:`divider`},children:[(0,G.jsx)(Q,{variant:`caption`,sx:{fontFamily:`monospace`,fontSize:`0.68rem`,minWidth:180,flexShrink:0,color:e.available?`text.primary`:`error.main`},noWrap:!0,children:e.entityId}),(0,G.jsx)(Z,{display:`flex`,gap:.3,flexWrap:`wrap`,children:e.matterClusters.map(e=>(0,G.jsx)(Sv,{label:e,size:`small`,variant:`outlined`,sx:{fontSize:`0.58rem`,height:16,"& .MuiChip-label":{px:.5}}},e))})]},e.entityId))})})]})})}var xJe=()=>{let[e,t]=(0,C.useState)(`name`),[n,r]=(0,C.useState)(`asc`);return(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,G.jsx)(fJe,{sortField:e,sortDirection:n,onSortFieldChange:t,onSortDirectionChange:r}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(yJe,{sortField:e,sortDirection:n})}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(pJe,{})}),(0,G.jsx)(Z,{sx:{px:2,pb:2},children:(0,G.jsx)(gJe,{})}),(0,G.jsx)(zb,{}),(0,G.jsx)(hJe,{})]})};async function SJe(){let e=await fetch(`api/matter/labels?_s=${Date.now()}`);return await P_(e,`Failed to fetch labels`),N_(e)}async function CJe(){let e=await fetch(`api/matter/areas?_s=${Date.now()}`);return await P_(e,`Failed to fetch areas`),N_(e)}async function wJe(){let e=await fetch(`api/matter/filter-values?_s=${Date.now()}`);return await P_(e,`Failed to fetch filter values`),N_(e)}var F3=({values:e,copiedId:t,onCopy:n,searchable:r})=>{let[i,a]=(0,C.useState)(``),o=(0,C.useMemo)(()=>{if(!i)return e;let t=i.toLowerCase();return e.filter(e=>e.toLowerCase().includes(t))},[e,i]);return e.length===0?(0,G.jsx)(Z,{sx:{p:2,textAlign:`center`},children:(0,G.jsx)(Q,{color:`text.secondary`,variant:`body2`,children:`No values found.`})}):(0,G.jsxs)(Z,{children:[r&&e.length>10&&(0,G.jsx)(Z,{sx:{px:2,pt:1,pb:.5},children:(0,G.jsx)(xS,{size:`small`,fullWidth:!0,placeholder:`Search...`,value:i,onChange:e=>a(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(ZP,{position:`start`,children:(0,G.jsx)(sE,{fontSize:`small`})})}}})}),(0,G.jsxs)(Z,{sx:{p:1.5,display:`flex`,flexWrap:`wrap`,gap:.75},children:[o.map(e=>(0,G.jsx)(Sv,{label:e,size:`small`,variant:t===e?`filled`:`outlined`,color:t===e?`success`:`default`,onClick:()=>n(e),sx:{fontFamily:`monospace`,fontSize:`0.8rem`}},e)),i&&o.length===0&&(0,G.jsxs)(Q,{color:`text.secondary`,variant:`body2`,sx:{p:1},children:[`No matches for "`,i,`"`]})]})]})},TJe=()=>{let{t:e}=ms(),[t,n]=(0,C.useState)([]),[r,i]=(0,C.useState)([]),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!0),[l,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(null),p=(0,C.useCallback)(async()=>{c(!0);try{let[e,t,r]=await Promise.all([SJe(),CJe(),wJe()]);n(e),i(t),o(r),u(null)}catch(t){u(t instanceof Error?t.message:e(`labels.loadFailed`))}finally{c(!1)}},[e]);(0,C.useEffect)(()=>{p()},[p]);let m=e=>{navigator.clipboard.writeText(e),f(e),setTimeout(()=>f(null),2e3)};return s?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(Rh,{})}):(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,sx:{mb:3},children:[(0,G.jsx)(pb,{sx:{mr:1,verticalAlign:`middle`}}),e(`labels.title`)]}),(0,G.jsx)(Uh,{severity:`info`,sx:{mb:3},children:e(`labels.info`)}),l&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:2},children:l}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)($T,{sx:{mr:.5,fontSize:20,verticalAlign:`middle`}}),e(`labels.labelsSection`),` (`,t.length,`)`]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`labels.labelsHint`)}),(0,G.jsx)(dv,{sx:{mb:4},children:t.length===0?(0,G.jsx)(Z,{sx:{p:3,textAlign:`center`},children:(0,G.jsx)(Q,{color:`text.secondary`,children:e(`labels.noLabels`)})}):(0,G.jsx)(sC,{children:(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.labelId`)}),(0,G.jsx)(oC,{width:48})]})}),(0,G.jsx)(aC,{children:t.map(t=>(0,G.jsxs)(fC,{hover:!0,children:[(0,G.jsxs)(oC,{children:[t.color&&(0,G.jsx)(Z,{component:`span`,sx:{display:`inline-block`,width:12,height:12,borderRadius:`50%`,backgroundColor:t.color,mr:1,verticalAlign:`middle`}}),t.name]}),(0,G.jsx)(oC,{children:(0,G.jsx)(`code`,{children:t.label_id})}),(0,G.jsx)(oC,{children:(0,G.jsx)(sb,{title:d===t.label_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>m(t.label_id),children:(0,G.jsx)(lb,{fontSize:`small`})})})})]},t.label_id))})]})})}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)(yT,{sx:{mr:.5,fontSize:20,verticalAlign:`middle`}}),e(`labels.areasSection`),` (`,r.length,`)`]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`labels.areasHint`)}),(0,G.jsx)(dv,{sx:{mb:4},children:r.length===0?(0,G.jsx)(Z,{sx:{p:3,textAlign:`center`},children:(0,G.jsx)(Q,{color:`text.secondary`,children:e(`labels.noAreas`)})}):(0,G.jsx)(sC,{children:(0,G.jsxs)(nC,{size:`small`,children:[(0,G.jsx)(lC,{children:(0,G.jsxs)(fC,{children:[(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(oC,{sx:{fontWeight:`bold`},children:e(`labels.areaId`)}),(0,G.jsx)(oC,{width:48})]})}),(0,G.jsx)(aC,{children:r.map(t=>(0,G.jsxs)(fC,{hover:!0,children:[(0,G.jsx)(oC,{children:t.name}),(0,G.jsx)(oC,{children:(0,G.jsx)(`code`,{children:t.area_id})}),(0,G.jsx)(oC,{children:(0,G.jsx)(sb,{title:d===t.area_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Bh,{size:`small`,onClick:()=>m(t.area_id),children:(0,G.jsx)(lb,{fontSize:`small`})})})})]},t.area_id))})]})})}),a&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{variant:`h6`,sx:{mb:2},children:e(`labels.otherFilterValues`)}),(0,G.jsxs)(XS,{defaultExpanded:!0,children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(nge,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.domains`),` (`,a.domains.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.domainsHint`)}),(0,G.jsx)(F3,{values:a.domains,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(YT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.platforms`),` (`,a.platforms.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.platformsHint`)}),(0,G.jsx)(F3,{values:a.platforms,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(WT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.entityCategories`),` (`,a.entityCategories.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.entityCategoriesHint`)}),(0,G.jsx)(F3,{values:a.entityCategories,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(WT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceClasses`),` (`,a.deviceClasses.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.deviceClassesHint`)}),(0,G.jsx)(F3,{values:a.deviceClasses,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(ub,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceNames`),` (`,a.deviceNames.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.deviceNamesHint`)}),(0,G.jsx)(F3,{values:a.deviceNames,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(XS,{children:[(0,G.jsxs)($S,{expandIcon:(0,G.jsx)(GS,{}),children:[(0,G.jsx)(ub,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.productNames`),` (`,a.productNames.length,`)`]})]}),(0,G.jsxs)(ZS,{sx:{p:0},children:[(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{px:2,pb:1},children:e(`labels.productNamesHint`)}),(0,G.jsx)(F3,{values:a.productNames,copiedId:d,onCopy:m,searchable:!0})]})]})]})]})};async function EJe(){let e=await fetch(`api/lock-credentials`);return await P_(e,`Failed to fetch lock credentials`),N_(e)}async function DJe(e,t){let n=await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return await P_(n,`Failed to update lock credential`),N_(n)}async function OJe(e,t){let n=await fetch(`api/lock-credentials/${encodeURIComponent(e)}/enabled`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})});return await P_(n,`Failed to toggle credential`),N_(n)}async function kJe(e){await P_(await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete lock credential`)}var AJe=({open:e,onClose:t,onSave:n,initialEntityId:r=``,initialName:i=``,isEdit:a=!1})=>{let{t:o}=ms(),[s,c]=(0,C.useState)(r),[l,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(i),[p,m]=(0,C.useState)(``),[h,g]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{e&&(c(r),f(i),u(``),m(``))},[e,r,i]),(0,G.jsxs)(Pb,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Lb,{children:o(a?`lockCredentials.editCredential`:`lockCredentials.addCredential`)}),(0,G.jsx)(Ib,{children:(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,mt:1},children:[p&&(0,G.jsx)(Uh,{severity:`error`,children:p}),(0,G.jsx)(xS,{label:o(`lockCredentials.lockEntityId`),placeholder:`lock.front_door`,value:s,onChange:e=>c(e.target.value),disabled:a,fullWidth:!0,helperText:o(`lockCredentials.lockEntityHelperText`)}),(0,G.jsx)(xS,{label:o(`lockCredentials.pinCode`),type:`password`,placeholder:`1234`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,8)),fullWidth:!0,helperText:`4-8 digit PIN code for this lock`,inputProps:{inputMode:`numeric`,pattern:`[0-9]*`}}),(0,G.jsx)(xS,{label:o(`lockCredentials.nameOptional`),placeholder:o(`lockCredentials.namePlaceholder`),value:d,onChange:e=>f(e.target.value),fullWidth:!0,helperText:o(`lockCredentials.nameHelperText`)})]})}),(0,G.jsxs)(Fb,{children:[(0,G.jsx)(uv,{onClick:t,disabled:h,children:o(`common.cancel`)}),(0,G.jsx)(uv,{onClick:async()=>{if(!s.trim()){m(o(`lockCredentials.entityRequired`));return}if(!l||l.length<4||l.length>8){m(o(`lockCredentials.pinLength`));return}if(!/^\d+$/.test(l)){m(o(`lockCredentials.pinDigitsOnly`));return}g(!0);try{await n(s.trim(),l,d.trim()),t()}catch(e){m(e instanceof Error?e.message:o(`lockCredentials.saveFailed`))}finally{g(!1)}},variant:`contained`,disabled:h,startIcon:h?(0,G.jsx)(Rh,{size:16}):(0,G.jsx)(oE,{}),children:o(`common.save`)})]})]})},jJe=()=>{let{t:e}=ms(),[t,n]=(0,C.useState)([]),[r,i]=(0,C.useState)(!0),[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(!1),[l,u]=(0,C.useState)(null),d=(0,C.useCallback)(async()=>{i(!0);try{n((await EJe()).credentials),o(null)}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.loadFailed`))}finally{i(!1)}},[e]);(0,C.useEffect)(()=>{d()},[d]);let f=async(e,t,n)=>{await DJe(e,{entityId:e,pinCode:t,name:n||void 0,enabled:!0}),await d()},[p,m]=(0,C.useState)(null),h=async t=>{m(null);try{await kJe(t),await d()}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.deleteFailed`))}},g=async t=>{try{await OJe(t.entityId,!t.enabled),await d()}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.updateFailed`))}},_=e=>{u(e),c(!0)},v=()=>{u(null),c(!0)};return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,mb:3},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,children:[(0,G.jsx)(vT,{sx:{mr:1,verticalAlign:`middle`}}),e(`lockCredentials.title`)]}),(0,G.jsx)(uv,{variant:`contained`,startIcon:(0,G.jsx)(cb,{}),onClick:v,children:e(`lockCredentials.addCredential`)})]}),(0,G.jsx)(Uh,{severity:`info`,sx:{mb:3},children:`Configure PIN codes for locks that require authentication for remote lock/unlock operations. The PIN will be sent with lock/unlock commands to Matter locks.`}),a&&(0,G.jsx)(Uh,{severity:`error`,sx:{mb:2},children:a}),r?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(Rh,{})}):t.length===0?(0,G.jsx)(dv,{children:(0,G.jsxs)(mv,{sx:{textAlign:`center`,py:4},children:[(0,G.jsx)(vT,{sx:{fontSize:48,color:`text.secondary`,mb:2}}),(0,G.jsx)(Q,{variant:`h6`,color:`text.secondary`,children:`No lock credentials configured`}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:`Add a PIN code for your Matter locks to enable remote lock/unlock`}),(0,G.jsx)(uv,{variant:`outlined`,startIcon:(0,G.jsx)(cb,{}),onClick:v,children:`Add Your First Credential`})]})}):(0,G.jsx)(dv,{children:(0,G.jsx)(Yv,{children:t.map((n,r)=>(0,G.jsxs)(Qv,{divider:r<t.length-1,onClick:()=>_(n),sx:{cursor:`pointer`,"&:hover":{bgcolor:`action.hover`}},children:[(0,G.jsx)(ey,{children:(0,G.jsx)(vT,{color:n.enabled?`primary`:`disabled`})}),(0,G.jsx)(ny,{primary:n.name||n.entityId,secondary:(0,G.jsxs)(G.Fragment,{children:[n.name&&(0,G.jsx)(Q,{component:`span`,variant:`body2`,color:`text.secondary`,children:n.entityId}),(0,G.jsx)(Q,{component:`span`,variant:`body2`,color:`text.secondary`,sx:{ml:n.name?2:0},children:`PIN: ****`})]})}),(0,G.jsxs)(Zv,{children:[(0,G.jsx)(sb,{title:n.enabled?e(`lockCredentials.disable`):e(`lockCredentials.enable`),children:(0,G.jsx)(HS,{edge:`end`,checked:n.enabled,onChange:e=>{e.stopPropagation(),g(n)}})}),(0,G.jsx)(sb,{title:e(`common.delete`),children:(0,G.jsx)(Bh,{edge:`end`,onClick:e=>{e.stopPropagation(),m(n.entityId)},sx:{ml:1},children:(0,G.jsx)(MS,{})})})]})]},n.entityId))})}),(0,G.jsx)(AJe,{open:s,onClose:()=>c(!1),onSave:f,initialEntityId:l?.entityId,initialName:l?.name,isEdit:!!l}),(0,G.jsx)(PT,{open:p!==null,title:e(`lockCredentials.confirmDeleteTitle`),message:e(`lockCredentials.confirmDeleteMessage`,{entity:p??``}),confirmLabel:e(`common.delete`),confirmColor:`error`,onConfirm:()=>{p&&h(p)},onCancel:()=>m(null)})]})},MJe=()=>{let e=Sr(),{t}=ms();return(0,G.jsxs)(Z,{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,minHeight:`60vh`,gap:2,p:4,children:[(0,G.jsx)(Ghe,{color:`disabled`,sx:{fontSize:64}}),(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:t(`notFound.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:t(`notFound.description`)}),(0,G.jsx)(uv,{variant:`contained`,startIcon:(0,G.jsx)(ZT,{}),onClick:()=>e(Y9.dashboard),children:t(`notFound.backToDashboard`)})]})};function I3(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=I3(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var NJe={value:()=>{}};function L3(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new R3(n)}function R3(e){this._=e}function PJe(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}R3.prototype=L3.prototype={constructor:R3,on:function(e,t){var n=this._,r=PJe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=FJe(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=z3(n[i],e.name,t);else if(t==null)for(i in n)n[i]=z3(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new R3(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function FJe(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function z3(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=NJe,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var B3={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function V3(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),B3.hasOwnProperty(t)?{space:B3[t],local:e}:e}function IJe(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function LJe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function H3(e){var t=V3(e);return(t.local?LJe:IJe)(t)}function RJe(){}function U3(e){return e==null?RJe:function(){return this.querySelector(e)}}function zJe(e){typeof e!=`function`&&(e=U3(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new i6(r,this._parents)}function BJe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function VJe(){return[]}function W3(e){return e==null?VJe:function(){return this.querySelectorAll(e)}}function HJe(e){return function(){return BJe(e.apply(this,arguments))}}function UJe(e){e=typeof e==`function`?HJe(e):W3(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new i6(r,i)}function G3(e){return function(){return this.matches(e)}}function K3(e){return function(t){return t.matches(e)}}var WJe=Array.prototype.find;function GJe(e){return function(){return WJe.call(this.children,e)}}function KJe(){return this.firstElementChild}function qJe(e){return this.select(e==null?KJe:GJe(typeof e==`function`?e:K3(e)))}var JJe=Array.prototype.filter;function YJe(){return Array.from(this.children)}function XJe(e){return function(){return JJe.call(this.children,e)}}function ZJe(e){return this.selectAll(e==null?YJe:XJe(typeof e==`function`?e:K3(e)))}function QJe(e){typeof e!=`function`&&(e=G3(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new i6(r,this._parents)}function q3(e){return Array(e.length)}function $Je(){return new i6(this._enter||this._groups.map(q3),this._parents)}function J3(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}J3.prototype={constructor:J3,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function eYe(e){return function(){return e}}function tYe(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new J3(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function nYe(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new J3(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function rYe(e){return e.__data__}function iYe(e,t){if(!arguments.length)return Array.from(this,rYe);var n=t?nYe:tYe,r=this._parents,i=this._groups;typeof e!=`function`&&(e=eYe(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=aYe(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new i6(o,r),o._enter=s,o._exit=c,o}function aYe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function oYe(){return new i6(this._exit||this._groups.map(q3),this._parents)}function sYe(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function cYe(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new i6(s,this._parents)}function lYe(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function uYe(e){e||=dYe;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new i6(i,this._parents).order()}function dYe(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function fYe(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function pYe(){return Array.from(this)}function mYe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function hYe(){let e=0;for(let t of this)++e;return e}function gYe(){return!this.node()}function _Ye(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function vYe(e){return function(){this.removeAttribute(e)}}function yYe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function bYe(e,t){return function(){this.setAttribute(e,t)}}function xYe(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function SYe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function CYe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function wYe(e,t){var n=V3(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?yYe:vYe:typeof t==`function`?n.local?CYe:SYe:n.local?xYe:bYe)(n,t))}function Y3(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function TYe(e){return function(){this.style.removeProperty(e)}}function EYe(e,t,n){return function(){this.style.setProperty(e,t,n)}}function DYe(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function OYe(e,t,n){return arguments.length>1?this.each((t==null?TYe:typeof t==`function`?DYe:EYe)(e,t,n??``)):X3(this.node(),e)}function X3(e,t){return e.style.getPropertyValue(t)||Y3(e).getComputedStyle(e,null).getPropertyValue(t)}function kYe(e){return function(){delete this[e]}}function AYe(e,t){return function(){this[e]=t}}function jYe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function MYe(e,t){return arguments.length>1?this.each((t==null?kYe:typeof t==`function`?jYe:AYe)(e,t)):this.node()[e]}function Z3(e){return e.trim().split(/^|\s+/)}function Q3(e){return e.classList||new $3(e)}function $3(e){this._node=e,this._names=Z3(e.getAttribute(`class`)||``)}$3.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function e6(e,t){for(var n=Q3(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function t6(e,t){for(var n=Q3(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function NYe(e){return function(){e6(this,e)}}function PYe(e){return function(){t6(this,e)}}function FYe(e,t){return function(){(t.apply(this,arguments)?e6:t6)(this,e)}}function IYe(e,t){var n=Z3(e+``);if(arguments.length<2){for(var r=Q3(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?FYe:t?NYe:PYe)(n,t))}function LYe(){this.textContent=``}function RYe(e){return function(){this.textContent=e}}function zYe(e){return function(){this.textContent=e.apply(this,arguments)??``}}function BYe(e){return arguments.length?this.each(e==null?LYe:(typeof e==`function`?zYe:RYe)(e)):this.node().textContent}function VYe(){this.innerHTML=``}function HYe(e){return function(){this.innerHTML=e}}function UYe(e){return function(){this.innerHTML=e.apply(this,arguments)??``}}function WYe(e){return arguments.length?this.each(e==null?VYe:(typeof e==`function`?UYe:HYe)(e)):this.node().innerHTML}function GYe(){this.nextSibling&&this.parentNode.appendChild(this)}function KYe(){return this.each(GYe)}function qYe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function JYe(){return this.each(qYe)}function YYe(e){var t=typeof e==`function`?e:H3(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function XYe(){return null}function ZYe(e,t){var n=typeof e==`function`?e:H3(e),r=t==null?XYe:typeof t==`function`?t:U3(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function QYe(){var e=this.parentNode;e&&e.removeChild(this)}function $Ye(){return this.each(QYe)}function eXe(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tXe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nXe(e){return this.select(e?tXe:eXe)}function rXe(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function iXe(e){return function(t){e.call(this,t,this.__data__)}}function aXe(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function oXe(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function sXe(e,t,n){return function(){var r=this.__on,i,a=iXe(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function cXe(e,t,n){var r=aXe(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?sXe:oXe,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function n6(e,t,n){var r=Y3(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function lXe(e,t){return function(){return n6(this,e,t)}}function uXe(e,t){return function(){return n6(this,e,t.apply(this,arguments))}}function dXe(e,t){return this.each((typeof t==`function`?uXe:lXe)(e,t))}function*fXe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var r6=[null];function i6(e,t){this._groups=e,this._parents=t}function a6(){return new i6([[document.documentElement]],r6)}function pXe(){return this}i6.prototype=a6.prototype={constructor:i6,select:zJe,selectAll:UJe,selectChild:qJe,selectChildren:ZJe,filter:QJe,data:iYe,enter:$Je,exit:oYe,join:sYe,merge:cYe,selection:pXe,order:lYe,sort:uYe,call:fYe,nodes:pYe,node:mYe,size:hYe,empty:gYe,each:_Ye,attr:wYe,style:OYe,property:MYe,classed:IYe,text:BYe,html:WYe,raise:KYe,lower:JYe,append:YYe,insert:ZYe,remove:$Ye,clone:nXe,datum:rXe,on:cXe,dispatch:dXe,[Symbol.iterator]:fXe};function o6(e){return typeof e==`string`?new i6([[document.querySelector(e)]],[document.documentElement]):new i6([[e]],r6)}function mXe(e){let t;for(;t=e.sourceEvent;)e=t;return e}function s6(e,t){if(e=mXe(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var hXe={passive:!1},c6={capture:!0,passive:!1};function l6(e){e.stopImmediatePropagation()}function u6(e){e.preventDefault(),e.stopImmediatePropagation()}function d6(e){var t=e.document.documentElement,n=o6(e).on(`dragstart.drag`,u6,c6);`onselectstart`in t?n.on(`selectstart.drag`,u6,c6):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function f6(e,t){var n=e.document.documentElement,r=o6(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,u6,c6),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var p6=e=>()=>e;function m6(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}m6.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gXe(e){return!e.ctrlKey&&!e.button}function _Xe(){return this.parentNode}function vXe(e,t){return t??{x:e.x,y:e.y}}function yXe(){return navigator.maxTouchPoints||`ontouchstart`in this}function h6(){var e=gXe,t=_Xe,n=vXe,r=yXe,i={},a=L3(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,hXe).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(o6(n.view).on(`mousemove.drag`,m,c6).on(`mouseup.drag`,h,c6),d6(n.view),l6(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(u6(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){o6(e.view).on(`mousemove.drag mouseup.drag`,null),f6(e.view,l),u6(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(l6(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(u6(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(l6(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=s6(l||r,t),p,m,h;if((h=n.call(e,new m6(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=s6(l||a,t),_=o;break}u.call(r,e,new m6(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:p6(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:p6(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:p6(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:p6(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function g6(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _6(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function v6(){}var y6=.7,b6=1/y6,x6=`\\s*([+-]?\\d+)\\s*`,S6=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,C6=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,bXe=/^#([0-9a-f]{3,8})$/,xXe=RegExp(`^rgb\\(${x6},${x6},${x6}\\)$`),SXe=RegExp(`^rgb\\(${C6},${C6},${C6}\\)$`),CXe=RegExp(`^rgba\\(${x6},${x6},${x6},${S6}\\)$`),wXe=RegExp(`^rgba\\(${C6},${C6},${C6},${S6}\\)$`),TXe=RegExp(`^hsl\\(${S6},${C6},${C6}\\)$`),EXe=RegExp(`^hsla\\(${S6},${C6},${C6},${S6}\\)$`),w6={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};g6(v6,D6,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:T6,formatHex:T6,formatHex8:DXe,formatHsl:OXe,formatRgb:E6,toString:E6});function T6(){return this.rgb().formatHex()}function DXe(){return this.rgb().formatHex8()}function OXe(){return R6(this).formatHsl()}function E6(){return this.rgb().formatRgb()}function D6(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=bXe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?O6(t):n===3?new j6(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?k6(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?k6(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=xXe.exec(e))?new j6(t[1],t[2],t[3],1):(t=SXe.exec(e))?new j6(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=CXe.exec(e))?k6(t[1],t[2],t[3],t[4]):(t=wXe.exec(e))?k6(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=TXe.exec(e))?L6(t[1],t[2]/100,t[3]/100,1):(t=EXe.exec(e))?L6(t[1],t[2]/100,t[3]/100,t[4]):w6.hasOwnProperty(e)?O6(w6[e]):e===`transparent`?new j6(NaN,NaN,NaN,0):null}function O6(e){return new j6(e>>16&255,e>>8&255,e&255,1)}function k6(e,t,n,r){return r<=0&&(e=t=n=NaN),new j6(e,t,n,r)}function kXe(e){return e instanceof v6||(e=D6(e)),e?(e=e.rgb(),new j6(e.r,e.g,e.b,e.opacity)):new j6}function A6(e,t,n,r){return arguments.length===1?kXe(e):new j6(e,t,n,r??1)}function j6(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}g6(j6,A6,_6(v6,{brighter(e){return e=e==null?b6:b6**+e,new j6(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?y6:y6**+e,new j6(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new j6(F6(this.r),F6(this.g),F6(this.b),P6(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:M6,formatHex:M6,formatHex8:AXe,formatRgb:N6,toString:N6}));function M6(){return`#${I6(this.r)}${I6(this.g)}${I6(this.b)}`}function AXe(){return`#${I6(this.r)}${I6(this.g)}${I6(this.b)}${I6((isNaN(this.opacity)?1:this.opacity)*255)}`}function N6(){let e=P6(this.opacity);return`${e===1?`rgb(`:`rgba(`}${F6(this.r)}, ${F6(this.g)}, ${F6(this.b)}${e===1?`)`:`, ${e})`}`}function P6(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function F6(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function I6(e){return e=F6(e),(e<16?`0`:``)+e.toString(16)}function L6(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new z6(e,t,n,r)}function R6(e){if(e instanceof z6)return new z6(e.h,e.s,e.l,e.opacity);if(e instanceof v6||(e=D6(e)),!e)return new z6;if(e instanceof z6)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new z6(o,s,c,e.opacity)}function jXe(e,t,n,r){return arguments.length===1?R6(e):new z6(e,t,n,r??1)}function z6(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}g6(z6,jXe,_6(v6,{brighter(e){return e=e==null?b6:b6**+e,new z6(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?y6:y6**+e,new z6(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new j6(H6(e>=240?e-240:e+120,i,r),H6(e,i,r),H6(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new z6(B6(this.h),V6(this.s),V6(this.l),P6(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=P6(this.opacity);return`${e===1?`hsl(`:`hsla(`}${B6(this.h)}, ${V6(this.s)*100}%, ${V6(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function B6(e){return e=(e||0)%360,e<0?e+360:e}function V6(e){return Math.max(0,Math.min(1,e||0))}function H6(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var U6=e=>()=>e;function MXe(e,t){return function(n){return e+n*t}}function NXe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function PXe(e){return(e=+e)==1?W6:function(t,n){return n-t?NXe(t,n,e):U6(isNaN(t)?n:t)}}function W6(e,t){var n=t-e;return n?MXe(e,n):U6(isNaN(e)?t:e)}var G6=(function e(t){var n=PXe(t);function r(e,t){var r=n((e=A6(e)).r,(t=A6(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=W6(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function FXe(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function IXe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function LXe(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=X6(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function RXe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function K6(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function zXe(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=X6(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var q6=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,J6=new RegExp(q6.source,`g`);function BXe(e){return function(){return e}}function VXe(e){return function(t){return e(t)+``}}function Y6(e,t){var n=q6.lastIndex=J6.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=q6.exec(e))&&(i=J6.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:K6(r,i)})),n=J6.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?VXe(c[0].x):BXe(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function X6(e,t){var n=typeof t,r;return t==null||n===`boolean`?U6(t):(n===`number`?K6:n===`string`?(r=D6(t))?(t=r,G6):Y6:t instanceof D6?G6:t instanceof Date?RXe:IXe(t)?FXe:Array.isArray(t)?LXe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?zXe:K6)(e,t)}var Z6=180/Math.PI,Q6={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $6(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Z6,skewX:Math.atan(c)*Z6,scaleX:o,scaleY:s}}var e8;function HXe(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?Q6:$6(t.a,t.b,t.c,t.d,t.e,t.f)}function UXe(e){return e==null||(e8||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),e8.setAttribute(`transform`,e),!(e=e8.transform.baseVal.consolidate()))?Q6:(e=e.matrix,$6(e.a,e.b,e.c,e.d,e.e,e.f))}function t8(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:K6(e,i)},{i:c-2,x:K6(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:K6(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:K6(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:K6(e,n)},{i:s-2,x:K6(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var WXe=t8(HXe,`px, `,`px)`,`deg)`),GXe=t8(UXe,`, `,`)`,`)`),KXe=1e-12;function n8(e){return((e=Math.exp(e))+1/e)/2}function qXe(e){return((e=Math.exp(e))-1/e)/2}function JXe(e){return((e=Math.exp(2*e))-1)/(e+1)}var r8=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<KXe)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=n8(y),c=s/(n*g)*(i*JXe(t*r+y)-qXe(y));return[a+c*d,o+c*f,s*i/n8(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),i8=0,a8=0,o8=0,s8=1e3,c8,l8,u8=0,d8=0,f8=0,p8=typeof performance==`object`&&performance.now?performance:Date,m8=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function h8(){return d8||=(m8(YXe),p8.now()+f8)}function YXe(){d8=0}function g8(){this._call=this._time=this._next=null}g8.prototype=_8.prototype={constructor:g8,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?h8():+n)+(t==null?0:+t),!this._next&&l8!==this&&(l8?l8._next=this:c8=this,l8=this),this._call=e,this._time=n,y8()},stop:function(){this._call&&(this._call=null,this._time=1/0,y8())}};function _8(e,t,n){var r=new g8;return r.restart(e,t,n),r}function XXe(){h8(),++i8;for(var e=c8,t;e;)(t=d8-e._time)>=0&&e._call.call(void 0,t),e=e._next;--i8}function v8(){d8=(u8=p8.now())+f8,i8=a8=0;try{XXe()}finally{i8=0,QXe(),d8=0}}function ZXe(){var e=p8.now(),t=e-u8;t>s8&&(f8-=t,u8=e)}function QXe(){for(var e,t=c8,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:c8=n);l8=e,y8(r)}function y8(e){i8||(a8&&=clearTimeout(a8),e-d8>24?(e<1/0&&(a8=setTimeout(v8,e-p8.now()-f8)),o8&&=clearInterval(o8)):(o8||=(u8=p8.now(),setInterval(ZXe,s8)),i8=1,m8(v8)))}function b8(e,t,n){var r=new g8;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var $Xe=L3(`start`,`end`,`cancel`,`interrupt`),eZe=[];function x8(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;tZe(e,n,{name:t,index:r,group:i,on:$Xe,tween:eZe,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function S8(e,t){var n=w8(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function C8(e,t){var n=w8(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function w8(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function tZe(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=_8(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return b8(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(b8(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function T8(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function nZe(e){return this.each(function(){T8(this,e)})}function rZe(e,t){var n,r;return function(){var i=C8(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function iZe(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=C8(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function aZe(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=w8(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?rZe:iZe)(n,e,t))}function E8(e,t,n){var r=e._id;return e.each(function(){var e=C8(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return w8(e,r).value[t]}}function D8(e,t){var n;return(typeof t==`number`?K6:t instanceof D6?G6:(n=D6(t))?(t=n,G6):Y6)(e,t)}function oZe(e){return function(){this.removeAttribute(e)}}function sZe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cZe(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function lZe(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function uZe(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function dZe(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function fZe(e,t){var n=V3(e),r=n===`transform`?GXe:D8;return this.attrTween(e,typeof t==`function`?(n.local?dZe:uZe)(n,r,E8(this,`attr.`+e,t)):t==null?(n.local?sZe:oZe)(n):(n.local?lZe:cZe)(n,r,t))}function pZe(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function mZe(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&mZe(e,i)),n}return i._value=t,i}function gZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&pZe(e,i)),n}return i._value=t,i}function _Ze(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=V3(e);return this.tween(n,(r.local?hZe:gZe)(r,t))}function vZe(e,t){return function(){S8(this,e).delay=+t.apply(this,arguments)}}function yZe(e,t){return t=+t,function(){S8(this,e).delay=t}}function bZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?vZe:yZe)(t,e)):w8(this.node(),t).delay}function xZe(e,t){return function(){C8(this,e).duration=+t.apply(this,arguments)}}function SZe(e,t){return t=+t,function(){C8(this,e).duration=t}}function CZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?xZe:SZe)(t,e)):w8(this.node(),t).duration}function wZe(e,t){if(typeof t!=`function`)throw Error();return function(){C8(this,e).ease=t}}function TZe(e){var t=this._id;return arguments.length?this.each(wZe(t,e)):w8(this.node(),t).ease}function EZe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();C8(this,e).ease=n}}function DZe(e){if(typeof e!=`function`)throw Error();return this.each(EZe(this._id,e))}function OZe(e){typeof e!=`function`&&(e=G3(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new k8(r,this._parents,this._name,this._id)}function kZe(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new k8(o,this._parents,this._name,this._id)}function AZe(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function jZe(e,t,n){var r,i,a=AZe(t)?S8:C8;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function MZe(e,t){var n=this._id;return arguments.length<2?w8(this.node(),n).on.on(e):this.each(jZe(n,e,t))}function NZe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function PZe(){return this.on(`end.remove`,NZe(this._id))}function FZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=U3(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,x8(l[f],t,n,f,l,w8(u,n)));return new k8(a,this._parents,t,n)}function IZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=W3(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=w8(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&x8(p,t,n,h,f,m);a.push(f),o.push(u)}return new k8(a,o,t,n)}var LZe=a6.prototype.constructor;function RZe(){return new LZe(this._groups,this._parents)}function zZe(e,t){var n,r,i;return function(){var a=X3(this,e),o=(this.style.removeProperty(e),X3(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function O8(e){return function(){this.style.removeProperty(e)}}function BZe(e,t,n){var r,i=n+``,a;return function(){var o=X3(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function VZe(e,t,n){var r,i,a;return function(){var o=X3(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),X3(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function HZe(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=C8(this,e),l=c.on,u=c.value[a]==null?s||=O8(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function UZe(e,t,n){var r=(e+=``)==`transform`?WXe:D8;return t==null?this.styleTween(e,zZe(e,r)).on(`end.style.`+e,O8(e)):typeof t==`function`?this.styleTween(e,VZe(e,r,E8(this,`style.`+e,t))).each(HZe(this._id,e)):this.styleTween(e,BZe(e,r,t),n).on(`end.style.`+e,null)}function WZe(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function GZe(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&WZe(e,a,n)),r}return a._value=t,a}function KZe(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,GZe(e,t,n??``))}function qZe(e){return function(){this.textContent=e}}function JZe(e){return function(){this.textContent=e(this)??``}}function YZe(e){return this.tween(`text`,typeof e==`function`?JZe(E8(this,`text`,e)):qZe(e==null?``:e+``))}function XZe(e){return function(t){this.textContent=e.call(this,t)}}function ZZe(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&XZe(r)),t}return r._value=e,r}function QZe(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,ZZe(e))}function $Ze(){for(var e=this._name,t=this._id,n=A8(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=w8(c,t);x8(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new k8(r,this._parents,e,n)}function eQe(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=C8(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var tQe=0;function k8(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function nQe(e){return a6().transition(e)}function A8(){return++tQe}var j8=a6.prototype;k8.prototype=nQe.prototype={constructor:k8,select:FZe,selectAll:IZe,selectChild:j8.selectChild,selectChildren:j8.selectChildren,filter:OZe,merge:kZe,selection:RZe,transition:$Ze,call:j8.call,nodes:j8.nodes,node:j8.node,size:j8.size,empty:j8.empty,each:j8.each,on:MZe,attr:fZe,attrTween:_Ze,style:UZe,styleTween:KZe,text:YZe,textTween:QZe,remove:PZe,tween:aZe,delay:bZe,duration:CZe,ease:TZe,easeVarying:DZe,end:eQe,[Symbol.iterator]:j8[Symbol.iterator]};function rQe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var iQe={time:null,delay:0,duration:250,ease:rQe};function aQe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function oQe(e){var t,n;e instanceof k8?(t=e._id,e=e._name):(t=A8(),(n=iQe).time=h8(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&x8(c,e,t,l,o,n||aQe(c,t));return new k8(r,this._parents,e,t)}a6.prototype.interrupt=nZe,a6.prototype.transition=oQe;var M8=e=>()=>e;function sQe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function N8(e,t,n){this.k=e,this.x=t,this.y=n}N8.prototype={constructor:N8,scale:function(e){return e===1?this:new N8(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new N8(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var P8=new N8(1,0,0);F8.prototype=N8.prototype;function F8(e){for(;!e.__zoom;)if(!(e=e.parentNode))return P8;return e.__zoom}function I8(e){e.stopImmediatePropagation()}function L8(e){e.preventDefault(),e.stopImmediatePropagation()}function cQe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function lQe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function R8(){return this.__zoom||P8}function uQe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function dQe(){return navigator.maxTouchPoints||`ontouchstart`in this}function fQe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function z8(){var e=cQe,t=lQe,n=fQe,r=uQe,i=dQe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=r8,l=L3(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,R8).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,R8),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(P8.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new N8(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new N8(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new N8(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=o6(this.that).datum();l.call(e,this.that,new sQe(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=s6(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],T8(this),s.start();L8(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=o6(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=s6(t,i),l=t.clientX,u=t.clientY;d6(t.view),I8(t),a.mouse=[c,this.__zoom.invert(c)],T8(this),a.start();function d(e){if(L8(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=s6(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),f6(e.view,a.moved),L8(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=s6(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);L8(r),s>0?o6(this).transition().duration(s).call(x,d,c,r):o6(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(I8(t),s=0;s<i;++s)c=r[s],l=s6(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),T8(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(L8(e),s=0;s<a;++s)c=i[s],l=s6(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(I8(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=s6(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=o6(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:M8(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:M8(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:M8(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:M8([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var B8={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},V8=[[-1/0,-1/0],[1/0,1/0]],H8=[`Enter`,` `,`Escape`],U8={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},W8;(function(e){e.Strict=`strict`,e.Loose=`loose`})(W8||={});var G8;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(G8||={});var K8;(function(e){e.Partial=`partial`,e.Full=`full`})(K8||={});var q8={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},J8;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(J8||={});var Y8;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(Y8||={});var X8;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(X8||={});var Z8={[X8.Left]:X8.Right,[X8.Right]:X8.Left,[X8.Top]:X8.Bottom,[X8.Bottom]:X8.Top};function Q8(e){return e===null?null:e?`valid`:`invalid`}var $8=e=>`id`in e&&`source`in e&&`target`in e,pQe=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),e5=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),t5=(e,t=[0,0])=>{let{width:n,height:r}=E5(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},mQe=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:f5(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):e5(n)?n:t.nodeLookup.get(n.id)),u5(e,i?m5(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),n5=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=u5(n,m5(e)),r=!0)}),r?f5(n):{x:0,y:0,width:0,height:0}},r5=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...b5(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=g5(s,p5(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},hQe=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function gQe(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function _Qe({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=C5(n5(gQe(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function i5({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,B8.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&T5(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=T5(d)?o5(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,B8.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function vQe({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=hQe(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var a5=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),o5=(e={x:0,y:0},t,n)=>({x:a5(e.x,t[0][0],t[1][0]-(n?.width??0)),y:a5(e.y,t[0][1],t[1][1]-(n?.height??0))});function s5(e,t,n){let{width:r,height:i}=E5(n),{x:a,y:o}=n.internals.positionAbsolute;return o5(e,[[a,o],[a+r,o+i]],t)}var c5=(e,t,n)=>e<t?a5(Math.abs(e-t),1,t)/t:e>n?-a5(Math.abs(e-n),1,t)/t:0,l5=(e,t,n=15,r=40)=>[c5(e.x,r,t.width-r)*n,c5(e.y,r,t.height-r)*n],u5=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),d5=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),f5=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),p5=(e,t=[0,0])=>{let{x:n,y:r}=e5(e)?e.internals.positionAbsolute:t5(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},m5=(e,t=[0,0])=>{let{x:n,y:r}=e5(e)?e.internals.positionAbsolute:t5(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},h5=(e,t)=>f5(u5(d5(e),d5(t))),g5=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},_5=e=>v5(e.width)&&v5(e.height)&&v5(e.x)&&v5(e.y),v5=e=>!isNaN(e)&&isFinite(e),yQe=(e,t)=>{},y5=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),b5=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?y5(s,o):s},x5=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function S5(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function bQe(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=S5(e,n),i=S5(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=S5(e.top??e.y??0,n),i=S5(e.bottom??e.y??0,n),a=S5(e.left??e.x??0,t),o=S5(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xQe(e,t,n,r,i,a){let{x:o,y:s}=x5(e,[t,n,r]),{x:c,y:l}=x5({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var C5=(e,t,n,r,i,a)=>{let o=bQe(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=a5(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=xQe(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},w5=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function T5(e){return e!=null&&e!==`parent`}function E5(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function D5(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function O5(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function k5(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function SQe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function CQe(e){return{...U8,...e||{}}}function A5(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=F5(e),s=b5({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?y5(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var j5=e=>({width:e.offsetWidth,height:e.offsetHeight}),M5=e=>e?.getRootNode?.()||window?.document,wQe=[`INPUT`,`SELECT`,`TEXTAREA`];function N5(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?wQe.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var P5=e=>`clientX`in e,F5=(e,t)=>{let n=P5(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},I5=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...j5(t)}})};function L5({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function R5(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function z5({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case X8.Left:return[t-R5(t-r,a),n];case X8.Right:return[t+R5(r-t,a),n];case X8.Top:return[t,n-R5(n-i,a)];case X8.Bottom:return[t,n+R5(i-n,a)]}}function B5({sourceX:e,sourceY:t,sourcePosition:n=X8.Bottom,targetX:r,targetY:i,targetPosition:a=X8.Top,curvature:o=.25}){let[s,c]=z5({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=z5({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=L5({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function V5({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function TQe({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function EQe({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=u5(m5(e),m5(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),g5({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},f5(a))>0}var DQe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,OQe=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),kQe=(e,t,n={})=>{if(!e.source||!e.target)return B8.error006(),t;let r=n.getEdgeId||DQe,i;return i=$8(e)?{...e}:{...e,id:r(e)},OQe(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function H5({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=V5({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var U5={[X8.Left]:{x:-1,y:0},[X8.Right]:{x:1,y:0},[X8.Top]:{x:0,y:-1},[X8.Bottom]:{x:0,y:1}},AQe=({source:e,sourcePosition:t=X8.Bottom,target:n})=>t===X8.Left||t===X8.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},W5=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function jQe({source:e,sourcePosition:t=X8.Bottom,target:n,targetPosition:r=X8.Top,center:i,offset:a,stepPosition:o}){let s=U5[t],c=U5[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=AQe({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=V5({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function MQe(e,t,n,r){let i=Math.min(W5(e,t)/2,W5(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function G5({sourceX:e,sourceY:t,sourcePosition:n=X8.Bottom,targetX:r,targetY:i,targetPosition:a=X8.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=jQe({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=MQe(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function K5(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function NQe(e){let{sourceNode:t,targetNode:n}=e;if(!K5(t)||!K5(n))return null;let r=t.internals.handleBounds||q5(t.handles),i=n.internals.handleBounds||q5(n.handles),a=Y5(r?.source??[],e.sourceHandle),o=Y5(e.connectionMode===W8.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,B8.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||X8.Bottom,c=o?.position||X8.Top,l=J5(t,a,s),u=J5(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function q5(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function J5(e,t,n=X8.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??E5(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case X8.Top:return{x:i+o/2,y:a};case X8.Right:return{x:i+o,y:a+s/2};case X8.Bottom:return{x:i+o/2,y:a+s};case X8.Left:return{x:i,y:a+s/2}}}function Y5(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function X5(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function PQe(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=X5(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Z5=1e3,FQe=10,Q5={nodeOrigin:[0,0],nodeExtent:V8,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},IQe={...Q5,checkEquality:!0};function $5(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function LQe(e,t,n){let r=$5(Q5,n);for(let n of e.values())if(n.parentId)n7(n,e,t,r);else{let e=o5(t5(n,r.nodeOrigin),T5(n.extent)?n.extent:r.nodeExtent,E5(n));n.internals.positionAbsolute=e}}function RQe(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function e7(e){return e===`manual`}function t7(e,t,n,r={}){let i=$5(IQe,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!e7(i.zIndexMode)?Z5:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=o5(t5(u,i.nodeOrigin),T5(u.extent)?u.extent:i.nodeExtent,E5(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:RQe(u,e),z:r7(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&n7(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function zQe(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function n7(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=$5(Q5,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}zQe(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*FQe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=BQe(e,u,o,s,a&&!e7(c)?Z5:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function r7(e,t,n){let r=v5(e.zIndex)?e.zIndex:0;return e7(n)?r:r+(e.selected?t:0)}function BQe(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=E5(e),l=t5(e,n),u=T5(e.extent)?o5(l,e.extent,c):l,d=o5({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=s5(d,c,t));let f=r7(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function i7(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=h5(a.get(n.parentId)?.expandedRect??p5(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=E5(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function VQe(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=j5(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=T5(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=s5(h,s,t.get(e.parentId)):m&&(h=o5(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:I5(`source`,r.nodeElement,p,d,e.id),target:I5(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&n7(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:p5(g,i)}))}}if(f.length>0){let e=i7(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function HQe({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function a7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function o7(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;a7(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),a7(`target`,s,c,e,i,o),t.set(r.id,r)}}function s7(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:s7(n,t):!1}function c7(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function UQe(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!s7(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function l7({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function WQe({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=y5(a,t);return{x:o.x-a.x,y:o.y-a.y}}function GQe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=o6(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?d5(n5(s)):null,x=v&&l?WQe({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:y5(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=i5({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=l7({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=l5(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=A5(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=UQe(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=l7({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=h6().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=A5(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=F5(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=A5(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=F5(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=F5(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=l7({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!c7(t,`.${g}`,v))&&(!_||c7(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function KQe(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())g5(i,p5(e))>0&&r.push(e);return r}var qQe=250;function JQe(e,t,n,r){let i=[],a=1/0,o=KQe(e,n,t+qQe);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=J5(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function u7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...J5(o,c,c.position,!0)}:c}function d7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function YQe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var f7=()=>!0;function XQe(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=f7,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=M5(e.target),E=0,D,{x:O,y:k}=F5(e),A=d7(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=u7(i,A,r,c,t);if(!N)return;let P=F5(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=l5(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},te=c.get(i),B={inProgress:!0,isValid:null,from:J5(te,z,X8.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:te,to:P,toHandle:null,toPosition:Z8[z.position],toNode:null,pointer:P};function V(){M=!0,y(B),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&V();function ne(e){if(!M){let{x:t,y:n}=F5(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;V()}if(!x()||!z){re(e);return}let a=b();P=F5(e,j),D=JQe(b5(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=p7(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=YQe(!!D,s.isValid);let u=c.get(i),f=u?J5(u,z,X8.Left,!0):B.from,p={...B,from:f,isValid:L,to:s.toHandle&&L?x5({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Z8[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),B=p}function re(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ne),T.removeEventListener(`mouseup`,re),T.removeEventListener(`touchmove`,ne),T.removeEventListener(`touchend`,re)}}T.addEventListener(`mousemove`,ne),T.addEventListener(`mouseup`,re),T.addEventListener(`touchmove`,ne),T.addEventListener(`touchend`,re)}function p7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=f7,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=F5(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=d7(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===W8.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=u7(t,e,a,u,n,!0)}return _}var m7={onPointerDown:XQe,isValid:p7};function ZQe({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=o6(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&w5()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=z8().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:s6}}var h7=e=>({x:e.x,y:e.y,zoom:e.k}),g7=({x:e,y:t,zoom:n})=>P8.translate(e,t).scale(n),_7=(e,t)=>e.target.closest(`.${t}`),v7=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),QQe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,y7=(e,t=0,n=QQe,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},b7=e=>{let t=e.ctrlKey&&w5()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function $Qe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(_7(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=s6(u),t=d*2**b7(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===G8.Vertical?0:u.deltaX*f,m=i===G8.Horizontal?0:u.deltaY*f;!w5()&&u.shiftKey&&i!==G8.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=h7(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function e$e({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=_7(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function t$e({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=h7(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function n$e({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&v7(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,h7(a.transform))}}function r$e({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&v7(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=h7(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function i$e({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(_7(d,`${l}-flow__node`)||_7(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||_7(d,s)&&m||_7(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function a$e({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=z8().scaleExtent([t,n]).translateExtent(r),f=o6(e).call(d);v({x:i.x,y:i.y,zoom:a5(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(b7);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?X6:r8).transform(y7(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!v5(E)||E<0?0:E);let k=O?$Qe({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):e$e({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=t$e({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=n$e({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=r$e({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=i$e({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=g7(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=g7(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=g7(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?F8(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?X6:r8).scaleTo(y7(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?X6:r8).scaleBy(y7(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!v5(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var x7;(function(e){e.Line=`line`,e.Handle=`handle`})(x7||={});function o$e({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function S7(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function C7(e,t){return Math.max(0,t-e)}function w7(e,t){return Math.max(0,e-t)}function T7(e,t,n){return Math.max(0,t-e,e-n)}function E7(e,t){return e?!t:t}function s$e(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=T7(E,h,g),j=T7(D,_,v);if(o){let e=0,t=0;c&&w<0?e=C7(y+w+O,o[0][0]):!c&&w>0&&(e=w7(y+E+O,o[1][0])),l&&T<0?t=C7(b+T+k,o[0][1]):!l&&T>0&&(t=w7(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=w7(y+w,s[0][0]):!c&&w<0&&(e=C7(y+E,s[1][0])),l&&T>0?t=w7(b+T,s[0][1]):!l&&T<0&&(t=C7(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=T7(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?w7(b+k+E/C,o[1][1])*C:C7(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?C7(b+E/C,s[1][1])*C:w7(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=T7(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?w7(y+D*C+O,o[1][0])/C:C7(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?C7(y+D*C,s[1][0])/C:w7(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(E7(c,l)?-w:w)/C:w=(E7(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var c$e={width:0,height:0,x:0,y:0},l$e={...c$e,pointerX:0,pointerY:0,aspectRatio:1};function u$e(e){return[[0,0],[e.measured.width,e.measured.height]]}function d$e(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function f$e({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=o6(e),o={controlDirection:S7(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...c$e},h={...l$e};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:S7(e)};let g,_=null,v=[],y,b,x,S=!1,C=h6().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=A5(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?u$e(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=d$e(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=A5(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=s$e(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=o$e({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var p$e=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},m$e=e=>e?p$e(e):p$e,{useDebugValue:h$e}=C.default,{useSyncExternalStoreWithSelector:g$e}=LC.default,_$e=e=>e;function v$e(e,t=_$e,n){let r=g$e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return h$e(r),r}var y$e=(e,t)=>{let n=m$e(e),r=(e,r=t)=>v$e(n,e,r);return Object.assign(r,n),r},b$e=(e,t)=>e?y$e(e,t):y$e;function D7(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var O7=(0,C.createContext)(null),x$e=O7.Provider,S$e=B8.error001();function k7(e,t){let n=(0,C.useContext)(O7);if(n===null)throw Error(S$e);return v$e(n,e,t)}function A7(){let e=(0,C.useContext)(O7);if(e===null)throw Error(S$e);return(0,C.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var C$e={display:`none`},w$e={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},T$e=`react-flow__node-desc`,E$e=`react-flow__edge-desc`,D$e=`react-flow__aria-live`,O$e=e=>e.ariaLiveMessage,k$e=e=>e.ariaLabelConfig;function A$e({rfId:e}){let t=k7(O$e);return(0,G.jsx)(`div`,{id:`${D$e}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:w$e,children:t})}function j$e({rfId:e,disableKeyboardA11y:t}){let n=k7(k$e);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{id:`${T$e}-${e}`,style:C$e,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,G.jsx)(`div`,{id:`${E$e}-${e}`,style:C$e,children:n[`edge.a11yDescription.default`]}),!t&&(0,G.jsx)(A$e,{rfId:e})]})}var j7=(0,C.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,G.jsx)(`div`,{className:I3([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));j7.displayName=`Panel`;function M$e({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,G.jsx)(j7,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,G.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var N$e=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},M7=e=>e.id;function P$e(e,t){return D7(e.selectedNodes.map(M7),t.selectedNodes.map(M7))&&D7(e.selectedEdges.map(M7),t.selectedEdges.map(M7))}function F$e({onSelectionChange:e}){let t=A7(),{selectedNodes:n,selectedEdges:r}=k7(N$e,P$e);return(0,C.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var I$e=e=>!!e.onSelectionChangeHandlers;function L$e({onSelectionChange:e}){let t=k7(I$e);return e||t?(0,G.jsx)(F$e,{onSelectionChange:e}):null}var N7=typeof window<`u`?C.useLayoutEffect:C.useEffect,R$e=[0,0],z$e={x:0,y:0,zoom:1},B$e=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],V$e=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),H$e={translateExtent:V8,nodeOrigin:R$e,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function U$e(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=k7(V$e,D7),l=A7();N7(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=H$e,s()}),[]);let u=(0,C.useRef)(H$e);return N7(()=>{for(let s of B$e){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:CQe(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},B$e.map(t=>e[t])),null}function W$e(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function G$e(e){let[t,n]=(0,C.useState)(e===`system`?null:e);return(0,C.useEffect)(()=>{if(e!==`system`){n(e);return}let t=W$e(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?W$e()?.matches?`dark`:`light`:t}var K$e=typeof document<`u`?document:null;function P7(e=null,t={target:K$e,actInsideInputWithModifier:!0}){let[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(!1),a=(0,C.useRef)(new Set([])),[o,s]=(0,C.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
464
464
  `).replace(`
465
465
 
466
466
  `,`
@@ -470,4 +470,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
470
470
  To pick up a draggable item, press the space bar.
471
471
  While dragging, use the arrow keys to move the item.
472
472
  Press space again to drop the item in its new position, or press escape to cancel.
473
- `},I4e={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function L4e(e){let{announcements:t=I4e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=F4e}=e,{announce:a,announcement:o}=j4e(),s=p9(`DndLiveRegion`),[c,l]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{l(!0)},[]),N4e((0,C.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=C.createElement(C.Fragment,null,C.createElement(k4e,{id:r,value:i.draggable}),C.createElement(A4e,{id:s,announcement:o}));return n?(0,ya.createPortal)(u,n):u}var y9;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(y9||={});function b9(){}function R4e(e,t){return(0,C.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function z4e(){var e=[...arguments];return(0,C.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var x9=Object.freeze({x:0,y:0});function B4e(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function V4e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function H4e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function U4e(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function W4e(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function G4e(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var K4e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=G4e(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=B4e(G4e(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(V4e)},q4e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=U4e(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=U4e(r),o=i.reduce((e,t,r)=>e+B4e(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(V4e)};function J4e(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Y4e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=J4e(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(H4e)};function X4e(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Z4e(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:x9}function Q4e(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var $4e=Q4e(1);function e3e(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function t3e(e,t,n){let r=e3e(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var n3e={ignoreTransform:!1};function S9(e,t){t===void 0&&(t=n3e);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=n9(e).getComputedStyle(e);t&&(n=t3e(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function r3e(e){return S9(e,{ignoreTransform:!0})}function i3e(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function a3e(e,t){return t===void 0&&(t=n9(e).getComputedStyle(e)),t.position===`fixed`}function o3e(e,t){t===void 0&&(t=n9(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function C9(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(r9(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!i9(i)||x4e(i)||n.includes(i))return n;let a=n9(e).getComputedStyle(i);return i!==e&&o3e(i,a)&&n.push(i),a3e(i,a)?n:r(i.parentNode)}return e?r(e):n}function s3e(e){let[t]=C9(e,1);return t??null}function w9(e){return!$7||!e?null:e9(e)?e:t9(e)?r9(e)||e===a9(e).scrollingElement?window:i9(e)?e:null:null}function c3e(e){return e9(e)?e.scrollX:e.scrollLeft}function l3e(e){return e9(e)?e.scrollY:e.scrollTop}function T9(e){return{x:c3e(e),y:l3e(e)}}var E9;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(E9||={});function u3e(e){return!$7||!e?!1:e===document.scrollingElement}function d3e(e){let t={x:0,y:0},n=u3e(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var f3e={x:.2,y:.2};function p3e(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=f3e);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=d3e(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=E9.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=E9.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=E9.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=E9.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function m3e(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function h3e(e){return e.reduce((e,t)=>m9(e,T9(t)),x9)}function g3e(e){return e.reduce((e,t)=>e+c3e(t),0)}function _3e(e){return e.reduce((e,t)=>e+l3e(t),0)}function v3e(e,t){if(t===void 0&&(t=S9),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);s3e(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var y3e=[[`x`,[`left`,`right`],g3e],[`y`,[`top`,`bottom`],_3e]],D9=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=C9(t),r=h3e(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of y3e)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},O9=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function b3e(e){let{EventTarget:t}=n9(e);return e instanceof t?e:a9(e)}function k9(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var A9;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(A9||={});function x3e(e){e.preventDefault()}function S3e(e){e.stopPropagation()}var j9;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(j9||={});var C3e={start:[j9.Space,j9.Enter],cancel:[j9.Esc],end:[j9.Space,j9.Enter,j9.Tab]},w3e=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case j9.Right:return{...n,x:n.x+25};case j9.Left:return{...n,x:n.x-25};case j9.Down:return{...n,y:n.y+25};case j9.Up:return{...n,y:n.y-25}}},M9=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new O9(a9(t)),this.windowListeners=new O9(n9(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(A9.Resize,this.handleCancel),this.windowListeners.add(A9.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(A9.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&v3e(n),t(x9)}handleKeyDown(e){if(g9(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=C3e,coordinateGetter:a=w3e,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:x9;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=h9(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=d3e(n),p=m3e(n),m={x:Math.min(i===j9.Right?p.right-p.width/2:p.right,Math.max(i===j9.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===j9.Down?p.bottom-p.height/2:p.bottom,Math.max(i===j9.Down?p.top:p.top+p.height/2,u.y))},h=i===j9.Right&&!s||i===j9.Left&&!c,g=i===j9.Down&&!l||i===j9.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===j9.Right&&e<=d.x||i===j9.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===j9.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===j9.Down&&e<=d.y||i===j9.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===j9.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,m9(h9(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};M9.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=C3e,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function T3e(e){return!!(e&&`distance`in e)}function E3e(e){return!!(e&&`delay`in e)}var N9=class{constructor(e,t,n){n===void 0&&(n=b3e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=a9(i),this.documentListeners=new O9(this.document),this.listeners=new O9(n),this.windowListeners=new O9(n9(i)),this.initialCoordinates=_9(r)??x9,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(A9.Resize,this.handleCancel),this.windowListeners.add(A9.DragStart,x3e),this.windowListeners.add(A9.VisibilityChange,this.handleCancel),this.windowListeners.add(A9.ContextMenu,x3e),this.documentListeners.add(A9.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(E3e(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(T3e(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(A9.Click,S3e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(A9.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=_9(e)??x9,s=h9(n,o);if(!t&&a){if(T3e(a)){if(a.tolerance!=null&&k9(s,a.tolerance))return this.handleCancel();if(k9(s,a.distance))return this.handleStart()}if(E3e(a)&&k9(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===j9.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},D3e={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},P9=class extends N9{constructor(e){let{event:t}=e,n=a9(t.target);super(e,D3e,n)}};P9.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var O3e={move:{name:`mousemove`},end:{name:`mouseup`}},k3e;(function(e){e[e.RightClick=2]=`RightClick`})(k3e||={});var A3e=class extends N9{constructor(e){super(e,O3e,a9(e.event.target))}};A3e.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===k3e.RightClick?!1:(r?.({event:n}),!0)}}];var F9={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},j3e=class extends N9{constructor(e){super(e,F9)}static setup(){return window.addEventListener(F9.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(F9.move.name,e)};function e(){}}};j3e.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var I9;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(I9||={});var L9;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(L9||={});function M3e(e){let{acceleration:t,activator:n=I9.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=L9.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=P3e({delta:d,disabled:!a}),[m,h]=S4e(),g=(0,C.useRef)({x:0,y:0}),_=(0,C.useRef)({x:0,y:0}),v=(0,C.useMemo)(()=>{switch(n){case I9.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case I9.DraggableRect:return i}},[n,i,c]),y=(0,C.useRef)(null),b=(0,C.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,C.useMemo)(()=>s===L9.TreeOrder?[...l].reverse():l,[s,l]);(0,C.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=p3e(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var N3e={x:{[E9.Backward]:!1,[E9.Forward]:!1},y:{[E9.Backward]:!1,[E9.Forward]:!1}};function P3e(e){let{delta:t,disabled:n}=e,r=d9(t);return l9(e=>{if(n||!r||!e)return N3e;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[E9.Backward]:e.x[E9.Backward]||i.x===-1,[E9.Forward]:e.x[E9.Forward]||i.x===1},y:{[E9.Backward]:e.y[E9.Backward]||i.y===-1,[E9.Forward]:e.y[E9.Forward]||i.y===1}}},[n,t,r])}function F3e(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return l9(e=>t==null?null:r??e??null,[r,t])}function I3e(e,t){return(0,C.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var R9;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(R9||={});var L3e;(function(e){e.Optimized=`optimized`})(L3e||={});var R3e=new Map;function z3e(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,C.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,C.useRef)(e),d=g(),f=c9(d),p=(0,C.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,C.useRef)(null),h=l9(t=>{if(d&&!n)return R3e;if(!t||t===R3e||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new D9(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,C.useEffect)(()=>{u.current=e},[e]),(0,C.useEffect)(()=>{d||p()},[n,d]),(0,C.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,C.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case R9.Always:return!1;case R9.BeforeDragging:return n;default:return!n}}}function B3e(e,t){return l9(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function V3e(e,t){return B3e(e,t)}function H3e(e){let{callback:t,disabled:n}=e,r=s9(t),i=(0,C.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,C.useEffect)(()=>()=>i?.disconnect(),[i]),i}function z9(e){let{callback:t,disabled:n}=e,r=s9(t),i=(0,C.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,C.useEffect)(()=>()=>i?.disconnect(),[i]),i}function U3e(e){return new D9(S9(e),e)}function W3e(e,t,n){t===void 0&&(t=U3e);let[r,i]=(0,C.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=H3e({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=z9({callback:a});return o9(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function G3e(e){return Z4e(e,B3e(e))}var K3e=[];function q3e(e){let t=(0,C.useRef)(e),n=l9(n=>e?n&&n!==K3e&&e&&t.current&&e.parentNode===t.current.parentNode?n:C9(e):K3e,[e]);return(0,C.useEffect)(()=>{t.current=e},[e]),n}function J3e(e){let[t,n]=(0,C.useState)(null),r=(0,C.useRef)(e),i=(0,C.useCallback)(e=>{let t=w9(e.target);t&&n(e=>e?(e.set(t,T9(t)),new Map(e)):null)},[]);return(0,C.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=w9(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,T9(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{w9(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,C.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>m9(e,t),x9):h3e(e):x9,[e,t])}function Y3e(e,t){t===void 0&&(t=[]);let n=(0,C.useRef)(null);return(0,C.useEffect)(()=>{n.current=null},t),(0,C.useEffect)(()=>{let t=e!==x9;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?h9(e,n.current):x9}function X3e(e){(0,C.useEffect)(()=>{if(!$7)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Z3e(e,t){return(0,C.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Q3e(e){return(0,C.useMemo)(()=>e?i3e(e):null,[e])}var $3e=[];function e6e(e,t){t===void 0&&(t=S9);let[n]=e,r=Q3e(n?n9(n):null),[i,a]=(0,C.useState)($3e);function o(){a(()=>e.length?e.map(e=>u3e(e)?r:new D9(t(e),e)):$3e)}let s=z9({callback:o});return o9(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function t6e(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return i9(t)?t:e}function n6e(e){let{measure:t}=e,[n,r]=(0,C.useState)(null),i=z9({callback:(0,C.useCallback)(e=>{for(let{target:n}of e)if(i9(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=u9((0,C.useCallback)(e=>{let n=t6e(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,C.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var r6e=[{sensor:P9,options:{}},{sensor:M9,options:{}}],i6e={current:{}},B9={draggable:{measure:r3e},droppable:{measure:r3e,strategy:R9.WhileDragging,frequency:L3e.Optimized},dragOverlay:{measure:S9}},V9=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},a6e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new V9,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:b9},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:B9,measureDroppableContainers:b9,windowRect:null,measuringScheduled:!1},o6e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:b9,draggableNodes:new Map,over:null,measureDroppableContainers:b9},H9=(0,C.createContext)(o6e),s6e=(0,C.createContext)(a6e);function c6e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new V9}}}function l6e(e,t){switch(t.type){case y9.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case y9.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case y9.DragEnd:case y9.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case y9.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new V9(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case y9.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new V9(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case y9.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new V9(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function u6e(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,C.useContext)(H9),a=d9(r),o=d9(n?.id);return(0,C.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!g9(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=D4e(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function d6e(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function f6e(e){return(0,C.useMemo)(()=>({draggable:{...B9.draggable,...e?.draggable},droppable:{...B9.droppable,...e?.droppable},dragOverlay:{...B9.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function p6e(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,C.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;o9(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=Z4e(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=s3e(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var m6e=(0,C.createContext)({...x9,scaleX:1,scaleY:1}),U9;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(U9||={});var h6e=(0,C.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=r6e,collisionDetection:o=Y4e,measuring:s,modifiers:c,...l}=e,[u,d]=(0,C.useReducer)(l6e,void 0,c6e),[f,p]=P4e(),[m,h]=(0,C.useState)(U9.Uninitialized),g=m===U9.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,C.useRef)({initial:null,translated:null}),w=(0,C.useMemo)(()=>_==null?null:{id:_,data:x?.data??i6e,rect:S},[_,x]),T=(0,C.useRef)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),A=c9(l,Object.values(l)),j=p9(`DndDescribedBy`,t),M=(0,C.useMemo)(()=>b.getEnabled(),[b]),N=f6e(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=z3e(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=F3e(v,_),R=(0,C.useMemo)(()=>O?_9(O):null,[O]),ee=Te(),z=V3e(L,N.draggable.measure);p6e({activeNode:_==null?null:v.get(_),config:ee.layoutShiftCompensation,initialRect:z,measure:N.draggable.measure});let te=W3e(L,N.draggable.measure,z),B=W3e(L?L.parentElement:null),V=(0,C.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=b.getNodeFor(V.current.over?.id),re=n6e({measure:N.dragOverlay.measure}),ie=re.nodeRef.current??L,ae=g?re.rect??te:null,oe=!!(re.nodeRef.current&&re.rect),se=G3e(oe?null:te),ce=Q3e(ie?n9(ie):null),le=q3e(g?ne??L:null),ue=e6e(le),H=d6e(c,{transform:{x:y.x-se.x,y:y.y-se.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:te,containerNodeRect:B,draggingNodeRect:ae,over:V.current.over,overlayNodeRect:re.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),de=R?m9(R,y):null,fe=J3e(le),U=Y3e(fe),pe=Y3e(fe,[te]),me=m9(H,U),W=ae?$4e(ae,H):null,he=w&&W?o({active:w,collisionRect:W,droppableRects:P,droppableContainers:M,pointerCoordinates:de}):null,ge=W4e(he,`id`),[_e,ve]=(0,C.useState)(null),ye=X4e(oe?H:m9(H,pe),_e?.rect??null,te),be=(0,C.useRef)(null),xe=(0,C.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;be.current=new n({active:T.current,activeNode:i,event:a,options:r,context:V,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ya.unstable_batchedUpdates)(()=>{r?.(i),h(U9.Initializing),d({type:y9.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(be.current),k(a)})},onMove(e){d({type:y9.DragMove,coordinates:e})},onEnd:o(y9.DragEnd),onCancel:o(y9.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=V.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===y9.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=y9.DragCancel)}T.current=null,(0,ya.unstable_batchedUpdates)(()=>{d({type:e}),h(U9.Uninitialized),ve(null),D(null),k(null),be.current=null;let t=e===y9.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Se=I3e(a,(0,C.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,xe(n,t))},[v,xe]));X3e(a),o9(()=>{te&&m===U9.Initializing&&h(U9.Initialized)},[te,m]),(0,C.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=V.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:me.x,y:me.y},over:i};(0,ya.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[me.x,me.y]),(0,C.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=V.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(ge),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ya.unstable_batchedUpdates)(()=>{ve(s),a?.(c),f({type:`onDragOver`,event:c})})},[ge]),o9(()=>{V.current={activatorEvent:O,active:w,activeNode:L,collisionRect:W,collisions:he,droppableRects:P,draggableNodes:v,draggingNode:ie,draggingNodeRect:ae,droppableContainers:b,over:_e,scrollableAncestors:le,scrollAdjustedTranslate:me},S.current={initial:ae,translated:W}},[w,L,he,W,v,ie,ae,P,b,_e,le,me]),M3e({...ee,delta:y,draggingRect:W,pointerCoordinates:de,scrollableAncestors:le,scrollableAncestorRects:ue});let Ce=(0,C.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:te,activatorEvent:O,collisions:he,containerNodeRect:B,dragOverlay:re,draggableNodes:v,droppableContainers:b,droppableRects:P,over:_e,measureDroppableContainers:F,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:N,measuringScheduled:I,windowRect:ce}),[w,L,te,O,he,B,re,v,b,P,_e,F,le,ue,N,I,ce]),we=(0,C.useMemo)(()=>({activatorEvent:O,activators:Se,active:w,activeNodeRect:te,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:_e,measureDroppableContainers:F}),[O,Se,w,te,d,j,v,_e,F]);return C.createElement(M4e.Provider,{value:p},C.createElement(H9.Provider,{value:we},C.createElement(s6e.Provider,{value:Ce},C.createElement(m6e.Provider,{value:ye},i)),C.createElement(u6e,{disabled:n?.restoreFocus===!1})),C.createElement(L4e,{...n,hiddenTextDescribedById:j}));function Te(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),g6e=(0,C.createContext)(null),_6e=`button`,v6e=`Draggable`;function y6e(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=p9(v6e),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,C.useContext)(H9),{role:p=_6e,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,C.useContext)(g?m6e:g6e),[v,y]=u9(),[b,x]=u9(),S=Z3e(o,t),w=c9(n);return o9(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,C.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===_6e?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function b6e(){return(0,C.useContext)(s6e)}var x6e=`Droppable`,S6e={timeout:25};function C6e(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=p9(x6e),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,C.useContext)(H9),u=(0,C.useRef)({disabled:n}),d=(0,C.useRef)(!1),f=(0,C.useRef)(null),p=(0,C.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...S6e,...i},_=c9(h??r),v=z9({callback:(0,C.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=u9((0,C.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=c9(t);return(0,C.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,C.useEffect)(()=>(s({type:y9.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:y9.UnregisterDroppable,key:a,id:r})),[r]),(0,C.useEffect)(()=>{n!==u.current.disabled&&(s({type:y9.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function W9(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function w6e(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function G9(e){return e!==null&&e>=0}function T6e(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function E6e(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var D6e=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=W9(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},K9={scaleX:1,scaleY:1},O6e=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...K9}:null}let s=k6e(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...K9}:r<t&&r>=a?{x:0,y:o.height+s,...K9}:{x:0,y:0,...K9}};function k6e(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var A6e=`Sortable`,j6e=C.createContext({activeIndex:-1,containerId:A6e,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:D6e,disabled:{draggable:!1,droppable:!1}});function M6e(e){let{children:t,id:n,items:r,strategy:i=D6e,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=b6e(),d=p9(A6e,n),f=s.rect!==null,p=(0,C.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,C.useRef)(p),v=!T6e(p,_.current),y=g!==-1&&h===-1||v,b=E6e(a);o9(()=>{v&&m&&u(p)},[v,p,m,u]),(0,C.useEffect)(()=>{_.current=p},[p]);let x=(0,C.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:w6e(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return C.createElement(j6e.Provider,{value:x},t)}var N6e=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return W9(n,r,i).indexOf(t)},P6e=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},F6e={duration:200,easing:`ease`},I6e=`transform`,L6e=v9.Transition.toString({property:I6e,duration:0,easing:`linear`}),R6e={roleDescription:`sortable`};function z6e(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,C.useState)(null),s=(0,C.useRef)(n);return o9(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=S9(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,C.useEffect)(()=>{a&&o(null)},[a]),a}function B6e(e){let{animateLayoutChanges:t=P6e,attributes:n,disabled:r,data:i,getNewIndex:a=N6e,id:o,strategy:s,resizeObserverConfig:c,transition:l=F6e}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,C.useContext)(j6e),y=V6e(r,p),b=u.indexOf(o),x=(0,C.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,C.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=C6e({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=y6e({id:o,data:x,attributes:{...R6e,...n},disabled:y.draggable}),R=b4e(D,M),ee=!!O,z=ee&&!m&&G9(f)&&G9(g),te=!_&&P,B=z?(te&&z?L:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,V=G9(f)&&G9(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ne=O?.id,re=(0,C.useRef)({activeId:ne,items:u,newIndex:V,containerId:d}),ie=u!==re.current.items,ae=t({active:O,containerId:d,isDragging:P,isSorting:ee,id:o,index:b,items:u,newIndex:re.current.newIndex,previousItems:re.current.items,previousContainerId:re.current.containerId,transition:l,wasDragging:re.current.activeId!=null}),oe=z6e({disabled:!ae,index:b,node:T,rect:w});return(0,C.useEffect)(()=>{ee&&re.current.newIndex!==V&&(re.current.newIndex=V),d!==re.current.containerId&&(re.current.containerId=d),u!==re.current.items&&(re.current.items=u)},[ee,V,d,u]),(0,C.useEffect)(()=>{if(ne===re.current.activeId)return;if(ne!=null&&re.current.activeId==null){re.current.activeId=ne;return}let e=setTimeout(()=>{re.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:O,activeIndex:f,attributes:j,data:x,rect:w,index:b,newIndex:V,items:u,isOver:E,isSorting:ee,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:R,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:oe??B,transition:se()};function se(){if(oe||ie&&re.current.newIndex===b)return L6e;if(!(te&&!g9(k)||!l)&&(ee||ae))return v9.Transition.toString({...l,property:I6e})}}function V6e(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function q9(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var H6e=[j9.Down,j9.Right,j9.Up,j9.Left],U6e=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(H6e.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case j9.Down:r.top<a.top&&t.push(n);break;case j9.Up:r.top>a.top&&t.push(n);break;case j9.Left:r.left>a.left&&t.push(n);break;case j9.Right:r.left<a.left&&t.push(n);break}});let c=q4e({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=W4e(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=C9(c).some((e,t)=>s[t]!==e),i=W6e(e,t),a=G6e(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:h9(u,l)}}}};function W6e(e,t){return!q9(e)||!q9(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function G6e(e,t){return!q9(e)||!q9(t)||!W6e(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var K6e=({bridge:e,index:t})=>{let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=B6e({id:e.id}),[c,l]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{pE(e.id).then(l)},[e.id]),(0,G.jsx)(dv,{ref:i,style:{transform:v9.Transform.toString(a),transition:o,opacity:s?.5:1},variant:`outlined`,sx:{cursor:`grab`,"&:active":{cursor:`grabbing`},bgcolor:s?`action.selected`:`background.paper`,width:`fit-content`},children:(0,G.jsxs)(mv,{sx:{display:`flex`,alignItems:`center`,gap:1.5,py:1,"&:last-child":{pb:1}},children:[(0,G.jsx)(Z,{...n,...r,sx:{display:`flex`,alignItems:`center`,color:`text.secondary`},children:(0,G.jsx)(Dhe,{})}),(0,G.jsx)(Sv,{label:t+1,size:`small`,color:`primary`,sx:{minWidth:32,fontWeight:`bold`}}),c?(0,G.jsx)(Z,{component:`img`,src:mE(e.id),alt:e.name,sx:{width:40,height:40,borderRadius:`50%`,objectFit:`cover`,boxShadow:2}}):(0,G.jsx)(bb,{sx:{bgcolor:gE(e),width:40,height:40,boxShadow:2},children:(0,G.jsx)(hE(e),{sx:{fontSize:24}})}),(0,G.jsxs)(Z,{sx:{flex:1},children:[(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:500,children:e.name}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,children:[`Port: `,e.port,` • Priority: `,e.priority??100]})]})]})})},q6e=()=>{let{t:e}=ms(),t=Uv(),{content:n,isLoading:r}=AT(),i=Jme(),[a,o]=(0,C.useState)([]),[s,c]=(0,C.useState)(!1);(0,C.useEffect)(()=>{n&&(o([...n].sort((e,t)=>(e.priority??100)-(t.priority??100))),c(!1))},[n]);let l=z4e(R4e(P9),R4e(M9,{coordinateGetter:U6e})),u=(0,C.useCallback)(e=>{let{active:t,over:n}=e;n&&t.id!==n.id&&(o(e=>W9(e,e.findIndex(e=>e.id===t.id),e.findIndex(e=>e.id===n.id))),c(!0))},[]),d=(0,C.useCallback)(async()=>{let n=a.map((e,t)=>({id:e.id,priority:(t+1)*10}));try{await i(n),t.show({message:e(`startup.saveSuccess`),severity:`success`}),c(!1)}catch(n){t.show({message:n instanceof Error?n.message:e(`startup.saveFailed`),severity:`error`})}},[a,i,t,e]),f=(0,C.useMemo)(()=>a.map(e=>e.id),[a]);return r?(0,G.jsxs)(Q,{children:[e(`common.loading`),`...`]}):(0,G.jsxs)(Rv,{spacing:3,children:[(0,G.jsx)(Hv,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:e(`startup.title`),to:Y9.startup}]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:2,children:[(0,G.jsx)(ov,{color:`primary`,fontSize:`large`}),(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:e(`startup.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`startup.description`)})]})]}),s&&(0,G.jsx)(Uh,{severity:`info`,action:(0,G.jsx)(uv,{color:`inherit`,size:`small`,startIcon:(0,G.jsx)(oE,{}),onClick:d,children:e(`startup.saveChanges`)}),children:e(`startup.unsavedChanges`)}),(0,G.jsx)(h6e,{sensors:l,collisionDetection:K4e,onDragEnd:u,children:(0,G.jsx)(M6e,{items:f,strategy:O6e,children:(0,G.jsx)(Rv,{spacing:1,children:a.map((e,t)=>(0,G.jsx)(K6e,{bridge:e,index:t},e.id))})})}),a.length===0&&(0,G.jsx)(Q,{color:`text.secondary`,textAlign:`center`,py:4,children:e(`startup.noBridges`)}),s&&a.length>0&&(0,G.jsx)(Z,{display:`flex`,justifyContent:`flex-end`,children:(0,G.jsx)(uv,{variant:`contained`,startIcon:(0,G.jsx)(oE,{}),onClick:d,children:e(`startup.saveOrder`)})})]})},J9=`https://riddix.github.io/home-assistant-matter-hub`,Y9={dashboard:`/`,bridges:`/bridges`,bridge:e=>`/bridges/${e}`,createBridge:`/bridges/create`,areaSetup:`/bridges/area-setup`,editBridge:e=>`/bridges/${e}/edit`,devices:`/devices`,networkMap:`/network-map`,health:`/health`,labels:`/labels`,lockCredentials:`/lock-credentials`,plugins:`/plugins`,settings:`/settings`,startup:`/startup`,githubRepository:`https://github.com/riddix/home-assistant-matter-hub/`,documentation:J9,support:`${J9}/support`,faq:{multiFabric:`${J9}/connect-multiple-fabrics`,bridgeConfig:`${J9}/bridge-configuration`}},J6e=[{path:``,element:(0,G.jsx)(Dre,{}),children:[{path:``,element:(0,G.jsx)(t_e,{})},{path:Y9.bridges,element:(0,G.jsx)(Yge,{})},{path:Y9.createBridge,element:(0,G.jsx)(tJe,{})},{path:Y9.areaSetup,element:(0,G.jsx)(wae,{})},{path:Y9.bridge(`:bridgeId`),element:(0,G.jsx)(uhe,{})},{path:Y9.editBridge(`:bridgeId`),element:(0,G.jsx)(nJe,{})},{path:Y9.devices,element:(0,G.jsx)(b_e,{})},{path:Y9.networkMap,element:(0,G.jsx)(H2e,{})},{path:Y9.health,element:(0,G.jsx)(xJe,{})},{path:Y9.labels,element:(0,G.jsx)(TJe,{})},{path:Y9.lockCredentials,element:(0,G.jsx)(jJe,{})},{path:Y9.plugins,element:(0,G.jsx)(m4e,{})},{path:Y9.settings,element:(0,G.jsx)(y4e,{})},{path:Y9.startup,element:(0,G.jsx)(q6e,{})},{path:`*`,element:(0,G.jsx)(MJe,{})}]}],Y6e=D_({items:{isInitialized:!1,isLoading:!1}},e=>{e.addCase(R_.pending,e=>{e.items.isLoading=!0}).addCase(R_.rejected,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=void 0,e.items.error=t.error}).addCase(R_.fulfilled,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(z_.fulfilled,(e,t)=>{e.items.content?.push(t.payload)}).addCase(V_.fulfilled,(e,t)=>{let n=e.items.content?.findIndex(e=>e.id===t.payload.id)??-1;n!==-1&&(e.items.content[n]=t.payload)}).addCase(H_.fulfilled,(e,t)=>{let n=e.items.content?.findIndex(e=>e.id===t.payload.id)??-1;n!==-1&&(e.items.content[n]=t.payload)}).addCase(B_.fulfilled,(e,t)=>{if(e.items.content){let n=e.items.content.findIndex(e=>e.id===t.meta.arg);n!==-1&&e.items.content.splice(n,1)}}).addCase(U_,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(W_,(e,t)=>{if(e.items.content){let n=e.items.content.findIndex(e=>e.id===t.payload.id);n===-1?e.items.content.push(t.payload):e.items.content[n]=t.payload}})}),X6e=D_({byBridge:{}},e=>{e.addCase(NT.pending,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(NT.rejected,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(NT.fulfilled,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)})}),X9=D_({isInitialized:!1,isLoading:!1,content:void 0,error:void 0},e=>{e.addCase(NT.pending,e=>{e.isLoading=!0}).addCase(NT.rejected,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=void 0,e.error=t.error}).addCase(NT.fulfilled,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=t.payload,e.error=void 0})}),Z6e=Zne({reducer:{bridges:Y6e,devices:X6e}}),Z9=hp({createStyledComponent:J(`div`,{name:`MuiContainer`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`maxWidth${Y(String(n.maxWidth))}`],n.fixed&&t.fixed,n.disableGutters&&t.disableGutters]}}),useThemeProps:e=>km({props:e,name:`MuiContainer`})});function Q6e(e){return Fd(`MuiToolbar`,e)}Id(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var $6e=e=>{let{classes:t,disableGutters:n,variant:r}=e;return up({root:[`root`,!n&&`gutters`,r]},Q6e,t)},e8e=J(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(Fm(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up(`sm`)]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:`dense`},style:{minHeight:48}},{props:{variant:`regular`},style:e.mixins.toolbar}]}))),t8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiToolbar`}),{className:r,component:i=`div`,disableGutters:a=!1,variant:o=`regular`,...s}=n,c={...n,component:i,disableGutters:a,variant:o};return(0,G.jsx)(e8e,{as:i,className:K($6e(c).root,r),ref:t,ownerState:c,...s})}),n8e=class extends C.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught:`,e,t.componentStack)}render(){return this.state.hasError?(0,G.jsxs)(Z,{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,minHeight:`60vh`,gap:2,p:4,children:[(0,G.jsx)(fb,{color:`error`,sx:{fontSize:64}}),(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:Ps.t(`errorBoundary.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,textAlign:`center`,maxWidth:480,children:this.state.error?.message??Ps.t(`errorBoundary.fallbackMessage`)}),(0,G.jsx)(uv,{variant:`contained`,onClick:()=>{this.setState({hasError:!1,error:null}),window.location.reload()},children:Ps.t(`errorBoundary.reload`)})]}):this.props.children}};function r8e(e){return Fd(`MuiFab`,e)}var i8e=Id(`MuiFab`,[`root`,`primary`,`secondary`,`extended`,`circular`,`focusVisible`,`disabled`,`colorInherit`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`info`,`error`,`warning`,`success`]),a8e=e=>{let{color:t,variant:n,classes:r,size:i}=e,a=up({root:[`root`,n,`size${Y(i)}`,t===`inherit`?`colorInherit`:t]},r8e,r);return{...r,...a}},o8e=J(Nh,{name:`MuiFab`,slot:`Root`,shouldForwardProp:e=>Dm(e)||e===`classes`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`size${Y(n.size)}`],n.color===`inherit`&&t.colorInherit,t[Y(n.size)],t[n.color]]}})(Fm(({theme:e})=>({...e.typography.button,minHeight:36,transition:e.transitions.create([`background-color`,`box-shadow`,`border-color`],{duration:e.transitions.duration.short}),borderRadius:`50%`,padding:0,minWidth:0,width:56,height:56,zIndex:(e.vars||e).zIndex.fab,boxShadow:(e.vars||e).shadows[6],"&:active":{boxShadow:(e.vars||e).shadows[12]},color:e.vars?e.vars.palette.grey[900]:e.palette.getContrastText?.(e.palette.grey[300]),backgroundColor:(e.vars||e).palette.grey[300],"&:hover":{backgroundColor:(e.vars||e).palette.grey.A100,"@media (hover: none)":{backgroundColor:(e.vars||e).palette.grey[300]},textDecoration:`none`},[`&.${i8e.focusVisible}`]:{boxShadow:(e.vars||e).shadows[6]},variants:[{props:{size:`small`},style:{width:40,height:40}},{props:{size:`medium`},style:{width:48,height:48}},{props:{variant:`extended`},style:{borderRadius:48/2,padding:`0 16px`,width:`auto`,minHeight:`auto`,minWidth:48,height:48}},{props:{variant:`extended`,size:`small`},style:{width:`auto`,padding:`0 8px`,borderRadius:34/2,minWidth:34,height:34}},{props:{variant:`extended`,size:`medium`},style:{width:`auto`,padding:`0 16px`,borderRadius:40/2,minWidth:40,height:40}},{props:{color:`inherit`},style:{color:`inherit`}}]})),Fm(({theme:e})=>({variants:[...Object.entries(e.palette).filter(Um([`dark`,`contrastText`])).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].contrastText,backgroundColor:(e.vars||e).palette[t].main,"&:hover":{backgroundColor:(e.vars||e).palette[t].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[t].main}}}}))]})),Fm(({theme:e})=>({[`&.${i8e.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}))),s8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiFab`}),{children:r,className:i,color:a=`default`,component:o=`button`,disabled:s=!1,disableFocusRipple:c=!1,focusVisibleClassName:l,size:u=`large`,variant:d=`circular`,...f}=n,p={...n,color:a,component:o,disabled:s,disableFocusRipple:c,size:u,variant:d},m=a8e(p);return(0,G.jsx)(o8e,{className:K(m.root,i),component:o,disabled:s,focusRipple:!c,focusVisibleClassName:K(m.focusVisible,l),ownerState:p,ref:t,...f,classes:m,children:r})}),c8e=[{code:`en`,flag:`🇬🇧`,name:`English`},{code:`de`,flag:`🇩🇪`,name:`Deutsch`},{code:`fr`,flag:`🇫🇷`,name:`Français`},{code:`es`,flag:`🇪🇸`,name:`Español`},{code:`it`,flag:`🇮🇹`,name:`Italiano`},{code:`zh`,flag:`🇨🇳`,name:`中文`},{code:`zh-TW`,flag:`🇹🇼`,name:`繁體中文`},{code:`ja`,flag:`🇯🇵`,name:`日本語`},{code:`th`,flag:`🇹🇭`,name:`ไทย`},{code:`sv`,flag:`🇸🇪`,name:`Svenska`},{code:`tr`,flag:`🇹🇷`,name:`Türkçe`},{code:`ru`,flag:`🇷🇺`,name:`Русский`}],l8e=`hamh-custom-languages`;function u8e(){try{let e=localStorage.getItem(l8e);return e?JSON.parse(e).map(e=>({code:e.code,flag:`🌐`,name:e.name})):[]}catch{return[]}}var d8e=`https://github.com/RiDDiX/home-assistant-matter-hub/issues/new?labels=translation&title=Translation+improvement`;function f8e(){let{t:e,i18n:t}=ms(),[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(null),a=(0,C.useMemo)(()=>[...c8e,...u8e()],[]),o=t.language??`en`,s=a.some(e=>e.code===o)?o:o.split(`-`)[0]??`en`,c=(0,C.useCallback)(()=>{r(e=>!e)},[]),l=(0,C.useCallback)(e=>{t.changeLanguage(e),r(!1)},[t]);return(0,G.jsx)(Kh,{onClickAway:(0,C.useCallback)(()=>{r(!1)},[]),children:(0,G.jsxs)(Z,{children:[(0,G.jsx)(s8e,{ref:i,size:`small`,color:`primary`,onClick:c,"aria-label":`Change language`,sx:{position:`fixed`,bottom:24,right:24,zIndex:1300},children:(0,G.jsx)(Phe,{})}),(0,G.jsx)(tb,{open:n,anchorEl:i.current,placement:`top-end`,transition:!0,sx:{zIndex:1300},children:({TransitionProps:t})=>(0,G.jsx)(Db,{...t,timeout:200,children:(0,G.jsxs)(Wm,{elevation:8,sx:{mb:1,py:.5,minWidth:160,borderRadius:2,overflow:`hidden`},children:[a.map(e=>(0,G.jsxs)(Z,{onClick:()=>l(e.code),sx:{display:`flex`,alignItems:`center`,gap:1.5,px:2,py:1,cursor:`pointer`,bgcolor:s===e.code?`action.selected`:`transparent`,"&:hover":{bgcolor:`action.hover`},transition:`background-color 0.15s`},children:[(0,G.jsx)(Q,{sx:{fontSize:`1.4rem`,lineHeight:1,userSelect:`none`},children:e.flag}),(0,G.jsx)(Q,{variant:`body2`,fontWeight:s===e.code?600:400,children:e.name})]},e.code)),(0,G.jsx)(zb,{}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`flex-start`,gap:.75,px:2,py:1},children:[(0,G.jsx)(Wv,{sx:{fontSize:14,mt:.25,color:`text.secondary`}}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,sx:{lineHeight:1.4},children:[e(`languageSwitcher.disclaimer`),` `,(0,G.jsx)(Vv,{href:d8e,target:`_blank`,rel:`noopener`,sx:{fontSize:`inherit`},children:e(`languageSwitcher.contribute`)})]})]})]})})})]})})}var p8e={name:`home-assistant-matter-hub`,description:``,version:`2.1.0-alpha.651`,private:!1,type:`module`,bin:{"home-assistant-matter-hub":`./dist/backend/cli.js`},author:{name:`riddix`,url:`https://github.com/riddix`},keywords:[`home-assistant`,`homeassistant`,`home`,`assistant`,`apple home`,`google home`,`apple`,`google`,`alexa`,`matter`,`matter.js`,`matterjs`,`project-chip`,`smart`,`smarthome`,`smart-home`],bugs:{url:`https://github.com/riddix/home-assistant-matter-hub/issues`},license:`Apache-2.0`,repository:`github:riddix/home-assistant-matter-hub`,scripts:{cleanup:`npx rimraf node_modules dist pack LICENSE README.md`,build:`node build.js`,bundle:`pnpm pack --out package.tgz`,postbuild:`pnpm run bundle`,test:`vitest run`,prestart:`pnpm run build`,start:`dotenvx run -f ../../.env -- ./dist/backend/cli.js start`},dependencies:{"@matter/main":`0.16.11`,"@matter/nodejs":`0.16.11`,"@matter/general":`0.16.11`,ajv:`8.18.0`,archiver:`7.0.1`,color:`5.0.3`,debounce:`3.0.0`,express:`5.2.1`,"express-basic-auth":`1.2.1`,"express-ip-access-control":`1.1.3`,"home-assistant-js-websocket":`9.6.0`,"lodash-es":`4.18.1`,multer:`2.1.1`,nocache:`4.0.0`,unzipper:`0.12.3`,ws:`8.20.0`,yargs:`18.0.0`},devDependencies:{"@home-assistant-matter-hub/backend":`workspace:*`,"@home-assistant-matter-hub/frontend":`workspace:*`,"@home-assistant-matter-hub/common":`workspace:*`,"@types/lodash-es":`^4.17.12`},overrides:{minimatch:`9.0.7`,"path-to-regexp":`^8.4.0`,glob:`^13.0.0`},nx:{targets:{start:{cache:!1,dependsOn:[`build`]},pack:{cache:!0,dependsOn:[`build`],outputs:[`{projectRoot}/pack`]},build:{inputs:[`^default`,`default`,`{workspaceRoot}/README.md`,`{workspaceRoot}/LICENSE`],outputs:[`{projectRoot}/dist`,`{projectRoot}/README.md`,`{projectRoot}/LICENSE`]}}}};function m8e(){let e=`2.1.0-alpha.651`,[t,n]=(0,C.useState)(null);(0,C.useEffect)(()=>{fetch(`api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.version&&n(e.version)}).catch(()=>{})},[]);let r=(0,C.useMemo)(()=>!t||e===`0.0.0-dev`?!1:e!==t,[t]);return(0,C.useMemo)(()=>({name:p8e.name,version:t??e,frontendVersion:e,backendVersion:t,versionMismatch:r}),[t,r])}var h8e=()=>{let{t:e}=ms(),t=[{name:e(`footer.github`),url:Y9.githubRepository},{name:e(`footer.documentation`),url:Y9.documentation},{name:e(`footer.support`),url:Y9.support}];return(0,G.jsxs)(Z9,{sx:{mt:16,mb:4},children:[(0,G.jsx)(zb,{sx:{mt:4,mb:4}}),(0,G.jsx)(jv,{container:!0,spacing:2,justifyContent:`center`,children:t.map((e,t)=>(0,G.jsx)(jv,{size:{xs:12,sm:`auto`},children:(0,G.jsx)(uv,{fullWidth:!0,size:`small`,variant:`outlined`,component:Vv,href:e.url,target:`_blank`,children:e.name})},t.toString()))})]})};function g8e(e){return Fd(`MuiAppBar`,e)}Id(`MuiAppBar`,[`root`,`positionFixed`,`positionAbsolute`,`positionSticky`,`positionStatic`,`positionRelative`,`colorDefault`,`colorPrimary`,`colorSecondary`,`colorInherit`,`colorTransparent`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`]);var _8e=e=>{let{color:t,position:n,classes:r}=e;return up({root:[`root`,`color${Y(t)}`,`position${Y(n)}`]},g8e,r)},v8e=(e,t)=>e?`${e.replace(`)`,``)}, ${t})`:t,y8e=J(Wm,{name:`MuiAppBar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${Y(n.position)}`],t[`color${Y(n.color)}`]]}})(Fm(({theme:e})=>({display:`flex`,flexDirection:`column`,width:`100%`,boxSizing:`border-box`,flexShrink:0,variants:[{props:{position:`fixed`},style:{position:`fixed`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0,"@media print":{position:`absolute`}}},{props:{position:`absolute`},style:{position:`absolute`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0}},{props:{position:`sticky`},style:{position:`sticky`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0}},{props:{position:`static`},style:{position:`static`}},{props:{position:`relative`},style:{position:`relative`}},{props:{color:`inherit`},style:{"--AppBar-color":`inherit`,color:`var(--AppBar-color)`}},{props:{color:`default`},style:{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[100],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[100]),...e.applyStyles(`dark`,{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[900],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[900])})}},...Object.entries(e.palette).filter(Um([`contrastText`])).map(([t])=>({props:{color:t},style:{"--AppBar-background":(e.vars??e).palette[t].main,"--AppBar-color":(e.vars??e).palette[t].contrastText}})),{props:e=>e.enableColorOnDark===!0&&![`inherit`,`transparent`].includes(e.color),style:{backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`}},{props:e=>e.enableColorOnDark===!1&&![`inherit`,`transparent`].includes(e.color),style:{backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`,...e.applyStyles(`dark`,{backgroundColor:e.vars?v8e(e.vars.palette.AppBar.darkBg,`var(--AppBar-background)`):null,color:e.vars?v8e(e.vars.palette.AppBar.darkColor,`var(--AppBar-color)`):null})}},{props:{color:`transparent`},style:{"--AppBar-background":`transparent`,"--AppBar-color":`inherit`,backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`,...e.applyStyles(`dark`,{backgroundImage:`none`})}}]}))),b8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiAppBar`}),{className:r,color:i=`primary`,enableColorOnDark:a=!1,position:o=`fixed`,...s}=n,c={...n,color:i,position:o,enableColorOnDark:a};return(0,G.jsx)(y8e,{square:!0,component:`header`,ownerState:c,elevation:4,className:K(_8e(c).root,r,o===`fixed`&&`mui-fixed`),ref:t,...s})}),x8e={visibility:`hidden`};function S8e(e,t,n){let r=n&&n.getBoundingClientRect(),i=eh(t),a=t.style.transform,o=t.style.transition;t.style.transition=``,t.style.transform=``;let s=t.getBoundingClientRect(),c=i.getComputedStyle(t).getPropertyValue(`transform`);t.style.transform=a,t.style.transition=o;let l=0,u=0;if(c&&c!==`none`&&typeof c==`string`){let e=c.split(`(`)[1].split(`)`)[0].split(`,`);l=parseInt(e[4],10),u=parseInt(e[5],10)}return e===`left`?r?`translateX(${r.right+l-s.left}px)`:`translateX(${i.innerWidth+l-s.left}px)`:e===`right`?r?`translateX(-${s.right-r.left-l}px)`:`translateX(-${s.left+s.width-l}px)`:e===`up`?r?`translateY(${r.bottom+u-s.top}px)`:`translateY(${i.innerHeight+u-s.top}px)`:r?`translateY(-${s.top-r.top+s.height-u}px)`:`translateY(-${s.top+s.height-u}px)`}function C8e(e){return typeof e==`function`?e():e}function Q9(e,t,n){let r=S8e(e,t,C8e(n));r&&(t.style.transform=r)}var w8e=C.forwardRef(function(e,t){let n=wm(),r={enter:n.transitions.easing.easeOut,exit:n.transitions.easing.sharp},i={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:a,appear:o=!0,children:s,container:c,direction:l=`down`,easing:u=r,in:d,onEnter:f,onEntered:p,onEntering:m,onExit:h,onExited:g,onExiting:_,style:v,timeout:y=i,...b}=e,x=C.useRef(null),S=ch(Wh(s),x,t),w=Jh(x,(e,t)=>{Q9(l,e,c),qh(e),f&&f(e,t)}),T=Jh(x,(e,t)=>{let r=Xh({timeout:y,style:v,easing:u},{mode:`enter`});e.style.transition=n.transitions.create(`transform`,r),e.style.transform=`none`,m&&m(e,t)}),E=Jh(x,p),D=Jh(x,_),O=Jh(x,e=>{let t=Xh({timeout:y,style:v,easing:u},{mode:`exit`});e.style.transition=n.transitions.create(`transform`,t),Q9(l,e,c),h&&h(e)}),k=Jh(x,e=>{e.style.transition=``,g&&g(e)}),A=e=>{a&&a(x.current,e)},j=C.useCallback(()=>{x.current&&Q9(l,x.current,c)},[l,c]);return C.useEffect(()=>{if(d||l===`down`||l===`right`)return;let e=Ym(()=>{x.current&&Q9(l,x.current,c)}),t=eh(x.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[l,d,c]),C.useEffect(()=>{d||j()},[d,j]),(0,G.jsx)(wh,{nodeRef:x,onEnter:w,onEntered:E,onEntering:T,onExit:O,onExited:k,onExiting:D,addEndListener:A,appear:o,in:d,timeout:y,...b,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!d?v||s.props.style?{visibility:`hidden`,...v,...s.props.style}:x8e:v&&s.props.style?{...v,...s.props.style}:v||s.props.style,C.cloneElement(s,{ref:S,style:r,...n})}})});function T8e(e){return Fd(`MuiDrawer`,e)}Id(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`paperAnchorLeft`,`paperAnchorRight`,`paperAnchorTop`,`paperAnchorBottom`,`paperAnchorDockedLeft`,`paperAnchorDockedRight`,`paperAnchorDockedTop`,`paperAnchorDockedBottom`,`modal`]);var E8e=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},D8e=e=>{let{classes:t,anchor:n,variant:r}=e;return up({root:[`root`,`anchor${Y(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`,`paperAnchor${Y(n)}`,r!==`temporary`&&`paperAnchorDocked${Y(n)}`]},T8e,t)},O8e=J(jb,{name:`MuiDrawer`,slot:`Root`,overridesResolver:E8e})(Fm(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),k8e=J(`div`,{shouldForwardProp:Dm,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:E8e})({flex:`0 0 auto`}),A8e=J(Wm,{name:`MuiDrawer`,slot:`Paper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.paper,t[`paperAnchor${Y(n.anchor)}`],n.variant!==`temporary`&&t[`paperAnchorDocked${Y(n.anchor)}`]]}})(Fm(({theme:e})=>({overflowY:`auto`,display:`flex`,flexDirection:`column`,height:`100%`,flex:`1 0 auto`,zIndex:(e.vars||e).zIndex.drawer,WebkitOverflowScrolling:`touch`,position:`fixed`,top:0,outline:0,variants:[{props:{anchor:`left`},style:{left:0}},{props:{anchor:`top`},style:{top:0,left:0,right:0,height:`auto`,maxHeight:`100%`}},{props:{anchor:`right`},style:{right:0}},{props:{anchor:`bottom`},style:{top:`auto`,left:0,bottom:0,right:0,height:`auto`,maxHeight:`100%`}},{props:({ownerState:e})=>e.anchor===`left`&&e.variant!==`temporary`,style:{borderRight:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`top`&&e.variant!==`temporary`,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`right`&&e.variant!==`temporary`,style:{borderLeft:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`bottom`&&e.variant!==`temporary`,style:{borderTop:`1px solid ${(e.vars||e).palette.divider}`}}]}))),j8e={left:`right`,right:`left`,top:`down`,bottom:`up`};function M8e(e){return[`left`,`right`].includes(e)}function N8e({direction:e},t){return e===`rtl`&&M8e(t)?j8e[t]:t}var P8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiDrawer`}),r=wm(),i=kf(),a={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{anchor:o=`left`,BackdropProps:s,children:c,className:l,elevation:u=16,hideBackdrop:d=!1,ModalProps:{BackdropProps:f,...p}={},onClose:m,open:h=!1,PaperProps:g={},SlideProps:_,TransitionComponent:v,transitionDuration:y=a,variant:b=`temporary`,slots:x={},slotProps:S={},...w}=n,T=C.useRef(!1);C.useEffect(()=>{T.current=!0},[]);let E=N8e({direction:i?`rtl`:`ltr`},o),D=o,O={...n,anchor:D,elevation:u,open:h,variant:b,...w},k=D8e(O),A={slots:{transition:v,...x},slotProps:{paper:g,transition:_,...S,backdrop:lh(S.backdrop||{...s,...f},{transitionDuration:y})}},[j,M]=Hm(`root`,{ref:t,elementType:O8e,className:K(k.root,k.modal,l),shouldForwardComponentProp:!0,ownerState:O,externalForwardedProps:{...A,...w,...p},additionalProps:{open:h,onClose:m,hideBackdrop:d,slots:{backdrop:A.slots.backdrop},slotProps:{backdrop:A.slotProps.backdrop}}}),[N,P]=Hm(`paper`,{elementType:A8e,shouldForwardComponentProp:!0,className:K(k.paper,g.className),ownerState:O,externalForwardedProps:A,additionalProps:{elevation:b===`temporary`?u:0,square:!0,...b===`temporary`&&{role:`dialog`,"aria-modal":`true`}}}),[F,I]=Hm(`docked`,{elementType:k8e,ref:t,className:K(k.root,k.docked,l),ownerState:O,externalForwardedProps:A,additionalProps:w}),[L,R]=Hm(`transition`,{elementType:w8e,ownerState:O,externalForwardedProps:A,additionalProps:{in:h,direction:j8e[E],timeout:y,appear:T.current}}),ee=(0,G.jsx)(N,{...P,children:c});if(b===`permanent`)return(0,G.jsx)(F,{...I,children:ee});let z=(0,G.jsx)(L,{...R,children:ee});return b===`persistent`?(0,G.jsx)(F,{...I,children:z}):(0,G.jsx)(j,{...M,children:z})}),F8e=rf({themeId:Cm}),I8e={error:vx,warn:Gv,info:mb,debug:UT},L8e=({open:e,onClose:t})=>{let{t:n}=ms(),r=wm(),i=(0,C.useMemo)(()=>({error:r.palette.error.main,warn:r.palette.warning.main,info:r.palette.info.main,debug:r.palette.secondary.main}),[r]),[a,o]=(0,C.useState)([]),[s,c]=(0,C.useState)(!0),[l,u]=(0,C.useState)(`error,warn,info`.split(`,`)),[d,f]=(0,C.useState)(``),[p,m]=(0,C.useState)(!0),h=(0,C.useCallback)(async()=>{try{let e=new URLSearchParams({level:l.join(`,`),limit:`500`,...d&&{search:d}}),t=await fetch(`api/logs?${e}`);t.ok&&o((await t.json()).entries)}catch(e){console.error(`Failed to fetch logs:`,e)}finally{c(!1)}},[l,d]);(0,C.useEffect)(()=>{e&&h()},[e,h]),(0,C.useEffect)(()=>{if(!p||!e)return;let t=setInterval(h,5e3);return()=>clearInterval(t)},[p,e,h]);let g=e=>{u(Array.isArray(e.target.value)?e.target.value:[e.target.value])},_=e=>{f(e.target.value)},v=async()=>{try{await fetch(`api/logs`,{method:`DELETE`}),o([])}catch(e){console.error(`Failed to clear logs:`,e)}},y=e=>(0,G.jsx)(I8e[e]||mb,{sx:{fontSize:16,color:i[e]}});return(0,G.jsxs)(Pb,{open:e,onClose:t,maxWidth:`lg`,fullWidth:!0,children:[(0,G.jsxs)(Lb,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(UT,{}),n(`logs.title`),(0,G.jsx)(Z,{sx:{flexGrow:1}}),(0,G.jsx)(sb,{title:n(`logs.autoRefresh`),children:(0,G.jsx)(Sv,{label:p?`Auto`:`Manual`,color:p?`success`:`default`,size:`small`,onClick:()=>m(!p),sx:{cursor:`pointer`}})}),(0,G.jsx)(Bh,{onClick:t,children:(0,G.jsx)(KT,{})})]}),(0,G.jsxs)(Ib,{children:[(0,G.jsx)(Rv,{spacing:2,sx:{mb:2},children:(0,G.jsxs)(Rv,{direction:`row`,spacing:2,alignItems:`center`,children:[(0,G.jsxs)(Tv,{size:`small`,sx:{minWidth:200},children:[(0,G.jsx)(Fx,{children:n(`logs.logLevel`)}),(0,G.jsxs)(_S,{value:l,label:n(`logs.logLevel`),onChange:g,multiple:!0,renderValue:e=>(0,G.jsx)(Z,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:(Array.isArray(e)?e:[e]).map(e=>(0,G.jsx)(Sv,{label:e.toUpperCase(),size:`small`,sx:{backgroundColor:i[e],color:`white`}},e))}),children:[(0,G.jsx)(vS,{value:`error`,children:n(`logs.error`)}),(0,G.jsx)(vS,{value:`warn`,children:n(`logs.warning`)}),(0,G.jsx)(vS,{value:`info`,children:n(`logs.info`)}),(0,G.jsx)(vS,{value:`debug`,children:n(`logs.debug`)})]})]}),(0,G.jsx)(xS,{size:`small`,placeholder:n(`logs.searchPlaceholder`),value:d,onChange:_,sx:{flexGrow:1}}),(0,G.jsx)(uv,{variant:`outlined`,onClick:h,children:n(`common.refresh`)}),(0,G.jsx)(uv,{variant:`outlined`,color:`error`,onClick:v,children:n(`common.delete`)})]})}),(0,G.jsx)(Z,{sx:{height:400,overflow:`auto`,backgroundColor:`background.paper`,border:1,borderColor:`divider`,borderRadius:1,p:1},children:s?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsxs)(Q,{children:[n(`common.loading`),`...`]})}):a.length===0?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(Q,{color:`text.secondary`,children:n(`logs.noResults`)})}):(0,G.jsx)(Rv,{spacing:1,children:a.map((e,t)=>(0,G.jsxs)(Z,{sx:{p:1,borderRadius:1,backgroundColor:`action.hover`,fontFamily:`monospace`,fontSize:`0.875rem`,wordBreak:`break-all`},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1,mb:.5},children:[y(e.level),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),(0,G.jsx)(Sv,{label:e.level.toUpperCase(),size:`small`,sx:{backgroundColor:i[e.level],color:r.palette.getContrastText(i[e.level]??r.palette.grey[500]),fontSize:`0.7rem`,height:20}})]}),(0,G.jsx)(Q,{sx:{ml:3},children:e.message}),e.context&&(0,G.jsx)(Q,{sx:{ml:3,color:`text.secondary`,fontSize:`0.8rem`},children:JSON.stringify(e.context,null,2)})]},`${e.timestamp}-${e.level}-${t}`))})})]}),(0,G.jsx)(Fb,{children:(0,G.jsx)(uv,{onClick:t,children:n(`common.close`)})})]})};function R8e(){let{t:e}=ms(),{isConnected:t}=J_(),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(!1);(0,C.useEffect)(()=>{let e=async()=>{try{let e=await fetch(`api/health`);e.ok?(r(await e.json()),a(!1)):a(!0)}catch{a(!0)}};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]);let o=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${n}m`},s=n?.status===`healthy`&&!i,c=n?.services?.bridges,l=c&&c.total>0&&c.running===c.total,u=c&&c.total===0,d=n?(0,G.jsxs)(Z,{sx:{p:.5},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`health.version`),`:`]}),` `,n.version??e(`status.unknown`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`health.uptime`),`:`]}),` `,o(n.uptime??0)]}),n.services?.bridges&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`nav.bridges`),`:`]}),` `,n.services.bridges.running??0,`/`,n.services.bridges.total??0,` `,e(`common.running`).toLowerCase(),(n.services.bridges.stopped??0)>0&&` (${n.services.bridges.stopped} ${e(`common.stopped`).toLowerCase()})`]}),n.services?.homeAssistant&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`health.homeAssistant`),`:`]}),` `,n.services.homeAssistant.connected?e(`health.connected`):e(`health.disconnected`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`WebSocket:`}),` `,e(t?`health.connected`:`health.disconnected`)]})]}):e(`status.loadingHealth`);return(0,G.jsx)(sb,{title:d,arrow:!0,children:(0,G.jsx)(Sv,{icon:i||!s?(0,G.jsx)(vx,{fontSize:`small`}):l?(0,G.jsx)(av,{fontSize:`small`}):(0,G.jsx)(_b,{fontSize:`small`}),label:e(i?`status.error`:s?t?u?`status.noBridges`:l?`common.online`:`common.starting`:`common.offline`:`status.unhealthy`),color:i||!s?`error`:!l||!t?`warning`:`success`,size:`small`,variant:`filled`,sx:{borderRadius:1,fontWeight:600,"& .MuiChip-icon":{color:`inherit`}}})})}var z8e=e=>(0,G.jsx)(`svg`,{viewBox:`0 0 91 89`,xmlSpace:`preserve`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,G.jsxs)(`g`,{style:{display:`inline`},children:[(0,G.jsx)(`path`,{style:{fill:`#18bcf2`,fillOpacity:1,strokeWidth:.266194},d:`m 49.149143,1.473171 38.513568,38.536435 c 0,0 1.248354,1.186052 2.207681,3.092371 0.959329,1.906323 1.10864,4.600698 1.10864,4.600698 v 36.786372 c 0,0 -0.01549,1.748506 -1.49842,3.050572 -1.482931,1.302064 -3.333077,1.362947 -3.333077,1.362947 l -81.325658,7.7e-5 c 0,0 -1.7523855,-0.0091 -3.17112,-1.352526 C -0.07808495,85.913164 0.05953025,84.487808 0.05953025,84.487808 V 47.704546 c 0,0 -0.0018381,-2.218618 0.95921785,-4.315832 0.9610554,-2.097209 2.3010618,-3.355005 2.3010618,-3.355005 L 41.545959,1.4719546 c 0,0 1.465224,-1.46837077 3.753488,-1.46837077 2.288268,0 3.849696,1.46958717 3.849696,1.46958717 z`}),(0,G.jsx)(`path`,{style:{fill:`#ffffff`,fillOpacity:1,strokeWidth:.175841},d:`m 31.689717,32.051124 c 2.813363,2.331095 6.157331,3.89845 9.721813,4.556421 V 17.180647 l 3.873694,-2.282955 3.870527,2.282955 V 36.60772 c 3.565364,-0.658847 6.910387,-2.226204 9.725159,-4.556417 l 7.032345,4.154609 c -11.437354,11.557779 -29.852321,11.557779 -41.290025,0 z m 8.546732,49.60988 C 44.314996,65.760441 35.09933,49.470196 19.574984,45.139543 v 8.312381 c 3.383916,1.32244 6.386113,3.496288 8.728705,6.320026 L 11.83076,69.485301 v 4.56907 l 3.873697,2.270836 16.469936,-9.713534 c 1.224356,3.48294 1.56683,7.225375 0.996449,10.879778 z M 70.977694,45.139543 c -15.515726,4.34014 -24.72189,20.626696 -20.643519,36.521461 l 7.047658,-4.15742 c -0.569325,-3.654411 -0.2265,-7.3965 0.996449,-10.87979 l 16.457611,9.701233 3.870711,-2.283125 v -4.55677 L 62.233673,59.77195 c 2.342772,-2.822684 5.34497,-4.996533 8.728708,-6.320026 z`})]})}),B8e=e=>{let t=m8e();return(0,G.jsxs)(Z,{component:ea,to:Y9.dashboard,sx:{display:`flex`,alignItems:`center`,justifyContent:e.large?`flex-start`:`center`,flexGrow:1,textDecoration:`none`,color:`inherit`},children:[(0,G.jsx)(z8e,{style:{height:`40px`}}),(0,G.jsx)(Q,{variant:`inherit`,component:`span`,sx:{mr:1,ml:1},children:t.name.split(`-`).map(Y).join(`-`)}),e.large&&(0,G.jsx)(Q,{variant:`caption`,component:`span`,children:t.version})]})},V8e=()=>{let e=F8e(`(min-width:600px)`),{mode:t,setMode:n}=Pm(),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(!1),s=Sr(),c=yr(),l=e=>e?e===`/`?c.pathname===`/`:c.pathname.startsWith(e):!1,u=()=>{n(t===`dark`?`light`:`dark`)},{t:d}=ms(),f=[{label:d(`dashboard.title`),icon:(0,G.jsx)(ZT,{}),to:Y9.dashboard},{label:d(`nav.bridges`),icon:(0,G.jsx)(QT,{}),to:Y9.bridges},{label:d(`nav.devices`),icon:(0,G.jsx)(ub,{}),to:Y9.devices},{label:d(`nav.networkMap`),icon:(0,G.jsx)(LT,{}),to:Y9.networkMap},{label:d(`nav.startupOrder`),icon:(0,G.jsx)(ov,{}),to:Y9.startup},{label:d(`nav.lockCredentials`),icon:(0,G.jsx)(vT,{}),to:Y9.lockCredentials},{label:d(`nav.filterReference`),icon:(0,G.jsx)($T,{}),to:Y9.labels},{label:`Plugins`,icon:(0,G.jsx)(YT,{}),to:Y9.plugins},{label:d(`nav.settings`),icon:(0,G.jsx)(DT,{}),to:Y9.settings},{label:d(t===`dark`?`nav.lightMode`:`nav.darkMode`),icon:t===`dark`?(0,G.jsx)(Ihe,{}):(0,G.jsx)(whe,{}),onClick:u},{label:d(`nav.systemLogs`),icon:(0,G.jsx)(UT,{}),onClick:()=>i(!0)},{label:d(`nav.health`),icon:(0,G.jsx)(wx,{}),to:Y9.health}],p=e=>{o(!1),e.onClick?e.onClick():e.to&&s(e.to)};return(0,G.jsxs)(Z,{children:[(0,G.jsx)(b8e,{sx:{height:`72px`},children:(0,G.jsx)(t8e,{sx:{paddingLeft:`0 !important`,paddingRight:`0 !important`},children:(0,G.jsxs)(Z9,{sx:{padding:2,height:`100%`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(B8e,{large:e}),e?(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[f.map(e=>e.to?(0,G.jsx)(sb,{title:e.label,children:(0,G.jsx)(Bh,{component:ea,to:e.to,sx:{color:`inherit`,bgcolor:l(e.to)?`rgba(255,255,255,0.15)`:`transparent`,borderRadius:1},children:e.icon})},e.label):(0,G.jsx)(sb,{title:e.label,children:(0,G.jsx)(Bh,{onClick:e.onClick,sx:{color:`inherit`},children:e.icon})},e.label)),(0,G.jsx)(R8e,{})]}):(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(R8e,{}),(0,G.jsx)(Bh,{onClick:()=>o(!0),sx:{color:`inherit`},children:(0,G.jsx)(Lhe,{})})]})]})})}),(0,G.jsx)(P8e,{anchor:`right`,open:a,onClose:()=>o(!1),children:(0,G.jsx)(Yv,{sx:{width:250},children:f.map(e=>(0,G.jsxs)(Vae,{selected:l(e.to),onClick:()=>p(e),children:[(0,G.jsx)(ey,{children:e.icon}),(0,G.jsx)(ny,{primary:e.label})]},e.label))})}),(0,G.jsx)(L8e,{open:r,onClose:()=>i(!1)})]})},H8e=()=>{let{versionMismatch:e,frontendVersion:t,backendVersion:n}=m8e(),{isConnected:r}=J_();return(0,G.jsxs)(Z,{children:[(0,G.jsx)(V8e,{}),(0,G.jsx)(t8e,{}),e&&(0,G.jsxs)(Uh,{severity:`warning`,variant:`filled`,sx:{borderRadius:0},action:(0,G.jsx)(uv,{color:`inherit`,size:`small`,onClick:()=>window.location.reload(),children:`Reload`}),children:[`Version mismatch: frontend `,t,`, backend `,n,`. Please reload to get the latest UI.`]}),!r&&(0,G.jsx)(Uh,{severity:`error`,variant:`filled`,sx:{borderRadius:0},children:`Connection lost, data may be outdated. Reconnecting…`}),(0,G.jsx)(Z9,{sx:{p:2},children:(0,G.jsx)(n8e,{children:(0,G.jsx)(oi,{})})}),(0,G.jsx)(h8e,{}),(0,G.jsx)(f8e,{})]})},U8e=xm({colorSchemes:{light:{palette:{primary:{main:`#1976d2`,light:`#42a5f5`,dark:`#1565c0`},secondary:{main:`#9c27b0`,light:`#ba68c8`,dark:`#7b1fa2`},background:{default:`#f5f5f5`,paper:`#ffffff`}}},dark:{palette:{primary:{main:`#90caf9`,light:`#e3f2fd`,dark:`#42a5f5`},secondary:{main:`#ce93d8`,light:`#f3e5f5`,dark:`#ab47bc`},background:{default:`#121212`,paper:`#1e1e1e`}}}},typography:{fontFamily:`"Roboto", "Helvetica", "Arial", sans-serif`,h1:{fontSize:`2.5rem`,fontWeight:500},h2:{fontSize:`2rem`,fontWeight:500},h3:{fontSize:`1.75rem`,fontWeight:500},h4:{fontSize:`1.5rem`,fontWeight:500},h5:{fontSize:`1.25rem`,fontWeight:500},h6:{fontSize:`1rem`,fontWeight:500}},shape:{borderRadius:8},components:{MuiCard:{styleOverrides:{root:{transition:`transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out`,"&:hover":{transform:`translateY(-2px)`,boxShadow:`0 4px 20px rgba(0,0,0,0.12)`}}}},MuiButton:{styleOverrides:{root:{textTransform:`none`,fontWeight:500}}},MuiChip:{styleOverrides:{root:{fontWeight:500}}},MuiAppBar:{styleOverrides:{root:{backgroundImage:`none`}}}}}),$9=document.getElementsByTagName(`base`)[0]?.href?.replace(/\/$/,``);$9?.startsWith(`http`)&&($9=new URL($9).pathname);var W8e=Yi([{path:`/`,element:(0,G.jsx)(H8e,{}),children:J6e}],{basename:$9});(0,S.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(C.StrictMode,{children:(0,G.jsx)(L,{store:Z6e,children:(0,G.jsxs)(Kee,{theme:U8e,children:[(0,G.jsx)(Bee,{}),(0,G.jsx)(Tm,{styles:{".rjsf-field-array > .MuiFormControl-root > .MuiPaper-root > .MuiBox-root > .MuiGrid-root > .MuiGrid-root:has(> .MuiBox-root > .MuiPaper-root > .MuiBox-root > .rjsf-field)":{overflow:`initial !important`,flexGrow:1}}}),(0,G.jsx)(Ere,{children:(0,G.jsx)(lne,{children:(0,G.jsx)(ba,{router:W8e})})})]})})}));
473
+ `},I4e={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function L4e(e){let{announcements:t=I4e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=F4e}=e,{announce:a,announcement:o}=j4e(),s=p9(`DndLiveRegion`),[c,l]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{l(!0)},[]),N4e((0,C.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=C.createElement(C.Fragment,null,C.createElement(k4e,{id:r,value:i.draggable}),C.createElement(A4e,{id:s,announcement:o}));return n?(0,ya.createPortal)(u,n):u}var y9;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(y9||={});function b9(){}function R4e(e,t){return(0,C.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function z4e(){var e=[...arguments];return(0,C.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var x9=Object.freeze({x:0,y:0});function B4e(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function V4e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function H4e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function U4e(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function W4e(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function G4e(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var K4e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=G4e(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=B4e(G4e(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(V4e)},q4e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=U4e(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=U4e(r),o=i.reduce((e,t,r)=>e+B4e(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(V4e)};function J4e(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Y4e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=J4e(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(H4e)};function X4e(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Z4e(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:x9}function Q4e(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var $4e=Q4e(1);function e3e(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function t3e(e,t,n){let r=e3e(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var n3e={ignoreTransform:!1};function S9(e,t){t===void 0&&(t=n3e);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=n9(e).getComputedStyle(e);t&&(n=t3e(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function r3e(e){return S9(e,{ignoreTransform:!0})}function i3e(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function a3e(e,t){return t===void 0&&(t=n9(e).getComputedStyle(e)),t.position===`fixed`}function o3e(e,t){t===void 0&&(t=n9(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function C9(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(r9(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!i9(i)||x4e(i)||n.includes(i))return n;let a=n9(e).getComputedStyle(i);return i!==e&&o3e(i,a)&&n.push(i),a3e(i,a)?n:r(i.parentNode)}return e?r(e):n}function s3e(e){let[t]=C9(e,1);return t??null}function w9(e){return!$7||!e?null:e9(e)?e:t9(e)?r9(e)||e===a9(e).scrollingElement?window:i9(e)?e:null:null}function c3e(e){return e9(e)?e.scrollX:e.scrollLeft}function l3e(e){return e9(e)?e.scrollY:e.scrollTop}function T9(e){return{x:c3e(e),y:l3e(e)}}var E9;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(E9||={});function u3e(e){return!$7||!e?!1:e===document.scrollingElement}function d3e(e){let t={x:0,y:0},n=u3e(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var f3e={x:.2,y:.2};function p3e(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=f3e);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=d3e(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=E9.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=E9.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=E9.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=E9.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function m3e(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function h3e(e){return e.reduce((e,t)=>m9(e,T9(t)),x9)}function g3e(e){return e.reduce((e,t)=>e+c3e(t),0)}function _3e(e){return e.reduce((e,t)=>e+l3e(t),0)}function v3e(e,t){if(t===void 0&&(t=S9),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);s3e(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var y3e=[[`x`,[`left`,`right`],g3e],[`y`,[`top`,`bottom`],_3e]],D9=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=C9(t),r=h3e(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of y3e)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},O9=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function b3e(e){let{EventTarget:t}=n9(e);return e instanceof t?e:a9(e)}function k9(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var A9;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(A9||={});function x3e(e){e.preventDefault()}function S3e(e){e.stopPropagation()}var j9;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(j9||={});var C3e={start:[j9.Space,j9.Enter],cancel:[j9.Esc],end:[j9.Space,j9.Enter,j9.Tab]},w3e=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case j9.Right:return{...n,x:n.x+25};case j9.Left:return{...n,x:n.x-25};case j9.Down:return{...n,y:n.y+25};case j9.Up:return{...n,y:n.y-25}}},M9=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new O9(a9(t)),this.windowListeners=new O9(n9(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(A9.Resize,this.handleCancel),this.windowListeners.add(A9.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(A9.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&v3e(n),t(x9)}handleKeyDown(e){if(g9(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=C3e,coordinateGetter:a=w3e,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:x9;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=h9(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=d3e(n),p=m3e(n),m={x:Math.min(i===j9.Right?p.right-p.width/2:p.right,Math.max(i===j9.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===j9.Down?p.bottom-p.height/2:p.bottom,Math.max(i===j9.Down?p.top:p.top+p.height/2,u.y))},h=i===j9.Right&&!s||i===j9.Left&&!c,g=i===j9.Down&&!l||i===j9.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===j9.Right&&e<=d.x||i===j9.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===j9.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===j9.Down&&e<=d.y||i===j9.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===j9.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,m9(h9(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};M9.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=C3e,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function T3e(e){return!!(e&&`distance`in e)}function E3e(e){return!!(e&&`delay`in e)}var N9=class{constructor(e,t,n){n===void 0&&(n=b3e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=a9(i),this.documentListeners=new O9(this.document),this.listeners=new O9(n),this.windowListeners=new O9(n9(i)),this.initialCoordinates=_9(r)??x9,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(A9.Resize,this.handleCancel),this.windowListeners.add(A9.DragStart,x3e),this.windowListeners.add(A9.VisibilityChange,this.handleCancel),this.windowListeners.add(A9.ContextMenu,x3e),this.documentListeners.add(A9.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(E3e(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(T3e(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(A9.Click,S3e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(A9.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=_9(e)??x9,s=h9(n,o);if(!t&&a){if(T3e(a)){if(a.tolerance!=null&&k9(s,a.tolerance))return this.handleCancel();if(k9(s,a.distance))return this.handleStart()}if(E3e(a)&&k9(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===j9.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},D3e={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},P9=class extends N9{constructor(e){let{event:t}=e,n=a9(t.target);super(e,D3e,n)}};P9.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var O3e={move:{name:`mousemove`},end:{name:`mouseup`}},k3e;(function(e){e[e.RightClick=2]=`RightClick`})(k3e||={});var A3e=class extends N9{constructor(e){super(e,O3e,a9(e.event.target))}};A3e.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===k3e.RightClick?!1:(r?.({event:n}),!0)}}];var F9={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},j3e=class extends N9{constructor(e){super(e,F9)}static setup(){return window.addEventListener(F9.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(F9.move.name,e)};function e(){}}};j3e.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var I9;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(I9||={});var L9;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(L9||={});function M3e(e){let{acceleration:t,activator:n=I9.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=L9.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=P3e({delta:d,disabled:!a}),[m,h]=S4e(),g=(0,C.useRef)({x:0,y:0}),_=(0,C.useRef)({x:0,y:0}),v=(0,C.useMemo)(()=>{switch(n){case I9.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case I9.DraggableRect:return i}},[n,i,c]),y=(0,C.useRef)(null),b=(0,C.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,C.useMemo)(()=>s===L9.TreeOrder?[...l].reverse():l,[s,l]);(0,C.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=p3e(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var N3e={x:{[E9.Backward]:!1,[E9.Forward]:!1},y:{[E9.Backward]:!1,[E9.Forward]:!1}};function P3e(e){let{delta:t,disabled:n}=e,r=d9(t);return l9(e=>{if(n||!r||!e)return N3e;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[E9.Backward]:e.x[E9.Backward]||i.x===-1,[E9.Forward]:e.x[E9.Forward]||i.x===1},y:{[E9.Backward]:e.y[E9.Backward]||i.y===-1,[E9.Forward]:e.y[E9.Forward]||i.y===1}}},[n,t,r])}function F3e(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return l9(e=>t==null?null:r??e??null,[r,t])}function I3e(e,t){return(0,C.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var R9;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(R9||={});var L3e;(function(e){e.Optimized=`optimized`})(L3e||={});var R3e=new Map;function z3e(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,C.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,C.useRef)(e),d=g(),f=c9(d),p=(0,C.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,C.useRef)(null),h=l9(t=>{if(d&&!n)return R3e;if(!t||t===R3e||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new D9(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,C.useEffect)(()=>{u.current=e},[e]),(0,C.useEffect)(()=>{d||p()},[n,d]),(0,C.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,C.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case R9.Always:return!1;case R9.BeforeDragging:return n;default:return!n}}}function B3e(e,t){return l9(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function V3e(e,t){return B3e(e,t)}function H3e(e){let{callback:t,disabled:n}=e,r=s9(t),i=(0,C.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,C.useEffect)(()=>()=>i?.disconnect(),[i]),i}function z9(e){let{callback:t,disabled:n}=e,r=s9(t),i=(0,C.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,C.useEffect)(()=>()=>i?.disconnect(),[i]),i}function U3e(e){return new D9(S9(e),e)}function W3e(e,t,n){t===void 0&&(t=U3e);let[r,i]=(0,C.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=H3e({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=z9({callback:a});return o9(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function G3e(e){return Z4e(e,B3e(e))}var K3e=[];function q3e(e){let t=(0,C.useRef)(e),n=l9(n=>e?n&&n!==K3e&&e&&t.current&&e.parentNode===t.current.parentNode?n:C9(e):K3e,[e]);return(0,C.useEffect)(()=>{t.current=e},[e]),n}function J3e(e){let[t,n]=(0,C.useState)(null),r=(0,C.useRef)(e),i=(0,C.useCallback)(e=>{let t=w9(e.target);t&&n(e=>e?(e.set(t,T9(t)),new Map(e)):null)},[]);return(0,C.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=w9(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,T9(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{w9(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,C.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>m9(e,t),x9):h3e(e):x9,[e,t])}function Y3e(e,t){t===void 0&&(t=[]);let n=(0,C.useRef)(null);return(0,C.useEffect)(()=>{n.current=null},t),(0,C.useEffect)(()=>{let t=e!==x9;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?h9(e,n.current):x9}function X3e(e){(0,C.useEffect)(()=>{if(!$7)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Z3e(e,t){return(0,C.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Q3e(e){return(0,C.useMemo)(()=>e?i3e(e):null,[e])}var $3e=[];function e6e(e,t){t===void 0&&(t=S9);let[n]=e,r=Q3e(n?n9(n):null),[i,a]=(0,C.useState)($3e);function o(){a(()=>e.length?e.map(e=>u3e(e)?r:new D9(t(e),e)):$3e)}let s=z9({callback:o});return o9(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function t6e(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return i9(t)?t:e}function n6e(e){let{measure:t}=e,[n,r]=(0,C.useState)(null),i=z9({callback:(0,C.useCallback)(e=>{for(let{target:n}of e)if(i9(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=u9((0,C.useCallback)(e=>{let n=t6e(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,C.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var r6e=[{sensor:P9,options:{}},{sensor:M9,options:{}}],i6e={current:{}},B9={draggable:{measure:r3e},droppable:{measure:r3e,strategy:R9.WhileDragging,frequency:L3e.Optimized},dragOverlay:{measure:S9}},V9=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},a6e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new V9,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:b9},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:B9,measureDroppableContainers:b9,windowRect:null,measuringScheduled:!1},o6e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:b9,draggableNodes:new Map,over:null,measureDroppableContainers:b9},H9=(0,C.createContext)(o6e),s6e=(0,C.createContext)(a6e);function c6e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new V9}}}function l6e(e,t){switch(t.type){case y9.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case y9.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case y9.DragEnd:case y9.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case y9.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new V9(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case y9.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new V9(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case y9.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new V9(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function u6e(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,C.useContext)(H9),a=d9(r),o=d9(n?.id);return(0,C.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!g9(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=D4e(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function d6e(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function f6e(e){return(0,C.useMemo)(()=>({draggable:{...B9.draggable,...e?.draggable},droppable:{...B9.droppable,...e?.droppable},dragOverlay:{...B9.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function p6e(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,C.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;o9(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=Z4e(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=s3e(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var m6e=(0,C.createContext)({...x9,scaleX:1,scaleY:1}),U9;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(U9||={});var h6e=(0,C.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=r6e,collisionDetection:o=Y4e,measuring:s,modifiers:c,...l}=e,[u,d]=(0,C.useReducer)(l6e,void 0,c6e),[f,p]=P4e(),[m,h]=(0,C.useState)(U9.Uninitialized),g=m===U9.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,C.useRef)({initial:null,translated:null}),w=(0,C.useMemo)(()=>_==null?null:{id:_,data:x?.data??i6e,rect:S},[_,x]),T=(0,C.useRef)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),A=c9(l,Object.values(l)),j=p9(`DndDescribedBy`,t),M=(0,C.useMemo)(()=>b.getEnabled(),[b]),N=f6e(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=z3e(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=F3e(v,_),R=(0,C.useMemo)(()=>O?_9(O):null,[O]),ee=Te(),z=V3e(L,N.draggable.measure);p6e({activeNode:_==null?null:v.get(_),config:ee.layoutShiftCompensation,initialRect:z,measure:N.draggable.measure});let te=W3e(L,N.draggable.measure,z),B=W3e(L?L.parentElement:null),V=(0,C.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=b.getNodeFor(V.current.over?.id),re=n6e({measure:N.dragOverlay.measure}),ie=re.nodeRef.current??L,ae=g?re.rect??te:null,oe=!!(re.nodeRef.current&&re.rect),se=G3e(oe?null:te),ce=Q3e(ie?n9(ie):null),le=q3e(g?ne??L:null),ue=e6e(le),H=d6e(c,{transform:{x:y.x-se.x,y:y.y-se.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:te,containerNodeRect:B,draggingNodeRect:ae,over:V.current.over,overlayNodeRect:re.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),de=R?m9(R,y):null,fe=J3e(le),U=Y3e(fe),pe=Y3e(fe,[te]),me=m9(H,U),W=ae?$4e(ae,H):null,he=w&&W?o({active:w,collisionRect:W,droppableRects:P,droppableContainers:M,pointerCoordinates:de}):null,ge=W4e(he,`id`),[_e,ve]=(0,C.useState)(null),ye=X4e(oe?H:m9(H,pe),_e?.rect??null,te),be=(0,C.useRef)(null),xe=(0,C.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;be.current=new n({active:T.current,activeNode:i,event:a,options:r,context:V,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ya.unstable_batchedUpdates)(()=>{r?.(i),h(U9.Initializing),d({type:y9.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(be.current),k(a)})},onMove(e){d({type:y9.DragMove,coordinates:e})},onEnd:o(y9.DragEnd),onCancel:o(y9.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=V.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===y9.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=y9.DragCancel)}T.current=null,(0,ya.unstable_batchedUpdates)(()=>{d({type:e}),h(U9.Uninitialized),ve(null),D(null),k(null),be.current=null;let t=e===y9.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Se=I3e(a,(0,C.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,xe(n,t))},[v,xe]));X3e(a),o9(()=>{te&&m===U9.Initializing&&h(U9.Initialized)},[te,m]),(0,C.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=V.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:me.x,y:me.y},over:i};(0,ya.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[me.x,me.y]),(0,C.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=V.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(ge),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ya.unstable_batchedUpdates)(()=>{ve(s),a?.(c),f({type:`onDragOver`,event:c})})},[ge]),o9(()=>{V.current={activatorEvent:O,active:w,activeNode:L,collisionRect:W,collisions:he,droppableRects:P,draggableNodes:v,draggingNode:ie,draggingNodeRect:ae,droppableContainers:b,over:_e,scrollableAncestors:le,scrollAdjustedTranslate:me},S.current={initial:ae,translated:W}},[w,L,he,W,v,ie,ae,P,b,_e,le,me]),M3e({...ee,delta:y,draggingRect:W,pointerCoordinates:de,scrollableAncestors:le,scrollableAncestorRects:ue});let Ce=(0,C.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:te,activatorEvent:O,collisions:he,containerNodeRect:B,dragOverlay:re,draggableNodes:v,droppableContainers:b,droppableRects:P,over:_e,measureDroppableContainers:F,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:N,measuringScheduled:I,windowRect:ce}),[w,L,te,O,he,B,re,v,b,P,_e,F,le,ue,N,I,ce]),we=(0,C.useMemo)(()=>({activatorEvent:O,activators:Se,active:w,activeNodeRect:te,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:_e,measureDroppableContainers:F}),[O,Se,w,te,d,j,v,_e,F]);return C.createElement(M4e.Provider,{value:p},C.createElement(H9.Provider,{value:we},C.createElement(s6e.Provider,{value:Ce},C.createElement(m6e.Provider,{value:ye},i)),C.createElement(u6e,{disabled:n?.restoreFocus===!1})),C.createElement(L4e,{...n,hiddenTextDescribedById:j}));function Te(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),g6e=(0,C.createContext)(null),_6e=`button`,v6e=`Draggable`;function y6e(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=p9(v6e),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,C.useContext)(H9),{role:p=_6e,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,C.useContext)(g?m6e:g6e),[v,y]=u9(),[b,x]=u9(),S=Z3e(o,t),w=c9(n);return o9(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,C.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===_6e?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function b6e(){return(0,C.useContext)(s6e)}var x6e=`Droppable`,S6e={timeout:25};function C6e(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=p9(x6e),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,C.useContext)(H9),u=(0,C.useRef)({disabled:n}),d=(0,C.useRef)(!1),f=(0,C.useRef)(null),p=(0,C.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...S6e,...i},_=c9(h??r),v=z9({callback:(0,C.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=u9((0,C.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=c9(t);return(0,C.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,C.useEffect)(()=>(s({type:y9.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:y9.UnregisterDroppable,key:a,id:r})),[r]),(0,C.useEffect)(()=>{n!==u.current.disabled&&(s({type:y9.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function W9(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function w6e(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function G9(e){return e!==null&&e>=0}function T6e(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function E6e(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var D6e=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=W9(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},K9={scaleX:1,scaleY:1},O6e=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...K9}:null}let s=k6e(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...K9}:r<t&&r>=a?{x:0,y:o.height+s,...K9}:{x:0,y:0,...K9}};function k6e(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var A6e=`Sortable`,j6e=C.createContext({activeIndex:-1,containerId:A6e,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:D6e,disabled:{draggable:!1,droppable:!1}});function M6e(e){let{children:t,id:n,items:r,strategy:i=D6e,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=b6e(),d=p9(A6e,n),f=s.rect!==null,p=(0,C.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,C.useRef)(p),v=!T6e(p,_.current),y=g!==-1&&h===-1||v,b=E6e(a);o9(()=>{v&&m&&u(p)},[v,p,m,u]),(0,C.useEffect)(()=>{_.current=p},[p]);let x=(0,C.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:w6e(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return C.createElement(j6e.Provider,{value:x},t)}var N6e=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return W9(n,r,i).indexOf(t)},P6e=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},F6e={duration:200,easing:`ease`},I6e=`transform`,L6e=v9.Transition.toString({property:I6e,duration:0,easing:`linear`}),R6e={roleDescription:`sortable`};function z6e(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,C.useState)(null),s=(0,C.useRef)(n);return o9(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=S9(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,C.useEffect)(()=>{a&&o(null)},[a]),a}function B6e(e){let{animateLayoutChanges:t=P6e,attributes:n,disabled:r,data:i,getNewIndex:a=N6e,id:o,strategy:s,resizeObserverConfig:c,transition:l=F6e}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,C.useContext)(j6e),y=V6e(r,p),b=u.indexOf(o),x=(0,C.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,C.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=C6e({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=y6e({id:o,data:x,attributes:{...R6e,...n},disabled:y.draggable}),R=b4e(D,M),ee=!!O,z=ee&&!m&&G9(f)&&G9(g),te=!_&&P,B=z?(te&&z?L:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,V=G9(f)&&G9(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ne=O?.id,re=(0,C.useRef)({activeId:ne,items:u,newIndex:V,containerId:d}),ie=u!==re.current.items,ae=t({active:O,containerId:d,isDragging:P,isSorting:ee,id:o,index:b,items:u,newIndex:re.current.newIndex,previousItems:re.current.items,previousContainerId:re.current.containerId,transition:l,wasDragging:re.current.activeId!=null}),oe=z6e({disabled:!ae,index:b,node:T,rect:w});return(0,C.useEffect)(()=>{ee&&re.current.newIndex!==V&&(re.current.newIndex=V),d!==re.current.containerId&&(re.current.containerId=d),u!==re.current.items&&(re.current.items=u)},[ee,V,d,u]),(0,C.useEffect)(()=>{if(ne===re.current.activeId)return;if(ne!=null&&re.current.activeId==null){re.current.activeId=ne;return}let e=setTimeout(()=>{re.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:O,activeIndex:f,attributes:j,data:x,rect:w,index:b,newIndex:V,items:u,isOver:E,isSorting:ee,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:R,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:oe??B,transition:se()};function se(){if(oe||ie&&re.current.newIndex===b)return L6e;if(!(te&&!g9(k)||!l)&&(ee||ae))return v9.Transition.toString({...l,property:I6e})}}function V6e(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function q9(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var H6e=[j9.Down,j9.Right,j9.Up,j9.Left],U6e=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(H6e.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case j9.Down:r.top<a.top&&t.push(n);break;case j9.Up:r.top>a.top&&t.push(n);break;case j9.Left:r.left>a.left&&t.push(n);break;case j9.Right:r.left<a.left&&t.push(n);break}});let c=q4e({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=W4e(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=C9(c).some((e,t)=>s[t]!==e),i=W6e(e,t),a=G6e(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:h9(u,l)}}}};function W6e(e,t){return!q9(e)||!q9(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function G6e(e,t){return!q9(e)||!q9(t)||!W6e(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var K6e=({bridge:e,index:t})=>{let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=B6e({id:e.id}),[c,l]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{pE(e.id).then(l)},[e.id]),(0,G.jsx)(dv,{ref:i,style:{transform:v9.Transform.toString(a),transition:o,opacity:s?.5:1},variant:`outlined`,sx:{cursor:`grab`,"&:active":{cursor:`grabbing`},bgcolor:s?`action.selected`:`background.paper`,width:`fit-content`},children:(0,G.jsxs)(mv,{sx:{display:`flex`,alignItems:`center`,gap:1.5,py:1,"&:last-child":{pb:1}},children:[(0,G.jsx)(Z,{...n,...r,sx:{display:`flex`,alignItems:`center`,color:`text.secondary`},children:(0,G.jsx)(Dhe,{})}),(0,G.jsx)(Sv,{label:t+1,size:`small`,color:`primary`,sx:{minWidth:32,fontWeight:`bold`}}),c?(0,G.jsx)(Z,{component:`img`,src:mE(e.id),alt:e.name,sx:{width:40,height:40,borderRadius:`50%`,objectFit:`cover`,boxShadow:2}}):(0,G.jsx)(bb,{sx:{bgcolor:gE(e),width:40,height:40,boxShadow:2},children:(0,G.jsx)(hE(e),{sx:{fontSize:24}})}),(0,G.jsxs)(Z,{sx:{flex:1},children:[(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:500,children:e.name}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,children:[`Port: `,e.port,` • Priority: `,e.priority??100]})]})]})})},q6e=()=>{let{t:e}=ms(),t=Uv(),{content:n,isLoading:r}=AT(),i=Jme(),[a,o]=(0,C.useState)([]),[s,c]=(0,C.useState)(!1);(0,C.useEffect)(()=>{n&&(o([...n].sort((e,t)=>(e.priority??100)-(t.priority??100))),c(!1))},[n]);let l=z4e(R4e(P9),R4e(M9,{coordinateGetter:U6e})),u=(0,C.useCallback)(e=>{let{active:t,over:n}=e;n&&t.id!==n.id&&(o(e=>W9(e,e.findIndex(e=>e.id===t.id),e.findIndex(e=>e.id===n.id))),c(!0))},[]),d=(0,C.useCallback)(async()=>{let n=a.map((e,t)=>({id:e.id,priority:(t+1)*10}));try{await i(n),t.show({message:e(`startup.saveSuccess`),severity:`success`}),c(!1)}catch(n){t.show({message:n instanceof Error?n.message:e(`startup.saveFailed`),severity:`error`})}},[a,i,t,e]),f=(0,C.useMemo)(()=>a.map(e=>e.id),[a]);return r?(0,G.jsxs)(Q,{children:[e(`common.loading`),`...`]}):(0,G.jsxs)(Rv,{spacing:3,children:[(0,G.jsx)(Hv,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:e(`startup.title`),to:Y9.startup}]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:2,children:[(0,G.jsx)(ov,{color:`primary`,fontSize:`large`}),(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:e(`startup.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:e(`startup.description`)})]})]}),s&&(0,G.jsx)(Uh,{severity:`info`,action:(0,G.jsx)(uv,{color:`inherit`,size:`small`,startIcon:(0,G.jsx)(oE,{}),onClick:d,children:e(`startup.saveChanges`)}),children:e(`startup.unsavedChanges`)}),(0,G.jsx)(h6e,{sensors:l,collisionDetection:K4e,onDragEnd:u,children:(0,G.jsx)(M6e,{items:f,strategy:O6e,children:(0,G.jsx)(Rv,{spacing:1,children:a.map((e,t)=>(0,G.jsx)(K6e,{bridge:e,index:t},e.id))})})}),a.length===0&&(0,G.jsx)(Q,{color:`text.secondary`,textAlign:`center`,py:4,children:e(`startup.noBridges`)}),s&&a.length>0&&(0,G.jsx)(Z,{display:`flex`,justifyContent:`flex-end`,children:(0,G.jsx)(uv,{variant:`contained`,startIcon:(0,G.jsx)(oE,{}),onClick:d,children:e(`startup.saveOrder`)})})]})},J9=`https://riddix.github.io/home-assistant-matter-hub`,Y9={dashboard:`/`,bridges:`/bridges`,bridge:e=>`/bridges/${e}`,createBridge:`/bridges/create`,areaSetup:`/bridges/area-setup`,editBridge:e=>`/bridges/${e}/edit`,devices:`/devices`,networkMap:`/network-map`,health:`/health`,labels:`/labels`,lockCredentials:`/lock-credentials`,plugins:`/plugins`,settings:`/settings`,startup:`/startup`,githubRepository:`https://github.com/riddix/home-assistant-matter-hub/`,documentation:J9,support:`${J9}/support`,faq:{multiFabric:`${J9}/connect-multiple-fabrics`,bridgeConfig:`${J9}/bridge-configuration`}},J6e=[{path:``,element:(0,G.jsx)(Dre,{}),children:[{path:``,element:(0,G.jsx)(t_e,{})},{path:Y9.bridges,element:(0,G.jsx)(Yge,{})},{path:Y9.createBridge,element:(0,G.jsx)(tJe,{})},{path:Y9.areaSetup,element:(0,G.jsx)(wae,{})},{path:Y9.bridge(`:bridgeId`),element:(0,G.jsx)(uhe,{})},{path:Y9.editBridge(`:bridgeId`),element:(0,G.jsx)(nJe,{})},{path:Y9.devices,element:(0,G.jsx)(b_e,{})},{path:Y9.networkMap,element:(0,G.jsx)(H2e,{})},{path:Y9.health,element:(0,G.jsx)(xJe,{})},{path:Y9.labels,element:(0,G.jsx)(TJe,{})},{path:Y9.lockCredentials,element:(0,G.jsx)(jJe,{})},{path:Y9.plugins,element:(0,G.jsx)(m4e,{})},{path:Y9.settings,element:(0,G.jsx)(y4e,{})},{path:Y9.startup,element:(0,G.jsx)(q6e,{})},{path:`*`,element:(0,G.jsx)(MJe,{})}]}],Y6e=D_({items:{isInitialized:!1,isLoading:!1}},e=>{e.addCase(R_.pending,e=>{e.items.isLoading=!0}).addCase(R_.rejected,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=void 0,e.items.error=t.error}).addCase(R_.fulfilled,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(z_.fulfilled,(e,t)=>{e.items.content?.push(t.payload)}).addCase(V_.fulfilled,(e,t)=>{let n=e.items.content?.findIndex(e=>e.id===t.payload.id)??-1;n!==-1&&(e.items.content[n]=t.payload)}).addCase(H_.fulfilled,(e,t)=>{let n=e.items.content?.findIndex(e=>e.id===t.payload.id)??-1;n!==-1&&(e.items.content[n]=t.payload)}).addCase(B_.fulfilled,(e,t)=>{if(e.items.content){let n=e.items.content.findIndex(e=>e.id===t.meta.arg);n!==-1&&e.items.content.splice(n,1)}}).addCase(U_,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(W_,(e,t)=>{if(e.items.content){let n=e.items.content.findIndex(e=>e.id===t.payload.id);n===-1?e.items.content.push(t.payload):e.items.content[n]=t.payload}})}),X6e=D_({byBridge:{}},e=>{e.addCase(NT.pending,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(NT.rejected,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(NT.fulfilled,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)})}),X9=D_({isInitialized:!1,isLoading:!1,content:void 0,error:void 0},e=>{e.addCase(NT.pending,e=>{e.isLoading=!0}).addCase(NT.rejected,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=void 0,e.error=t.error}).addCase(NT.fulfilled,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=t.payload,e.error=void 0})}),Z6e=Zne({reducer:{bridges:Y6e,devices:X6e}}),Z9=hp({createStyledComponent:J(`div`,{name:`MuiContainer`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`maxWidth${Y(String(n.maxWidth))}`],n.fixed&&t.fixed,n.disableGutters&&t.disableGutters]}}),useThemeProps:e=>km({props:e,name:`MuiContainer`})});function Q6e(e){return Fd(`MuiToolbar`,e)}Id(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var $6e=e=>{let{classes:t,disableGutters:n,variant:r}=e;return up({root:[`root`,!n&&`gutters`,r]},Q6e,t)},e8e=J(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(Fm(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up(`sm`)]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:`dense`},style:{minHeight:48}},{props:{variant:`regular`},style:e.mixins.toolbar}]}))),t8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiToolbar`}),{className:r,component:i=`div`,disableGutters:a=!1,variant:o=`regular`,...s}=n,c={...n,component:i,disableGutters:a,variant:o};return(0,G.jsx)(e8e,{as:i,className:K($6e(c).root,r),ref:t,ownerState:c,...s})}),n8e=class extends C.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught:`,e,t.componentStack)}render(){return this.state.hasError?(0,G.jsxs)(Z,{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,minHeight:`60vh`,gap:2,p:4,children:[(0,G.jsx)(fb,{color:`error`,sx:{fontSize:64}}),(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:Ps.t(`errorBoundary.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,textAlign:`center`,maxWidth:480,children:this.state.error?.message??Ps.t(`errorBoundary.fallbackMessage`)}),(0,G.jsx)(uv,{variant:`contained`,onClick:()=>{this.setState({hasError:!1,error:null}),window.location.reload()},children:Ps.t(`errorBoundary.reload`)})]}):this.props.children}};function r8e(e){return Fd(`MuiFab`,e)}var i8e=Id(`MuiFab`,[`root`,`primary`,`secondary`,`extended`,`circular`,`focusVisible`,`disabled`,`colorInherit`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`info`,`error`,`warning`,`success`]),a8e=e=>{let{color:t,variant:n,classes:r,size:i}=e,a=up({root:[`root`,n,`size${Y(i)}`,t===`inherit`?`colorInherit`:t]},r8e,r);return{...r,...a}},o8e=J(Nh,{name:`MuiFab`,slot:`Root`,shouldForwardProp:e=>Dm(e)||e===`classes`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`size${Y(n.size)}`],n.color===`inherit`&&t.colorInherit,t[Y(n.size)],t[n.color]]}})(Fm(({theme:e})=>({...e.typography.button,minHeight:36,transition:e.transitions.create([`background-color`,`box-shadow`,`border-color`],{duration:e.transitions.duration.short}),borderRadius:`50%`,padding:0,minWidth:0,width:56,height:56,zIndex:(e.vars||e).zIndex.fab,boxShadow:(e.vars||e).shadows[6],"&:active":{boxShadow:(e.vars||e).shadows[12]},color:e.vars?e.vars.palette.grey[900]:e.palette.getContrastText?.(e.palette.grey[300]),backgroundColor:(e.vars||e).palette.grey[300],"&:hover":{backgroundColor:(e.vars||e).palette.grey.A100,"@media (hover: none)":{backgroundColor:(e.vars||e).palette.grey[300]},textDecoration:`none`},[`&.${i8e.focusVisible}`]:{boxShadow:(e.vars||e).shadows[6]},variants:[{props:{size:`small`},style:{width:40,height:40}},{props:{size:`medium`},style:{width:48,height:48}},{props:{variant:`extended`},style:{borderRadius:48/2,padding:`0 16px`,width:`auto`,minHeight:`auto`,minWidth:48,height:48}},{props:{variant:`extended`,size:`small`},style:{width:`auto`,padding:`0 8px`,borderRadius:34/2,minWidth:34,height:34}},{props:{variant:`extended`,size:`medium`},style:{width:`auto`,padding:`0 16px`,borderRadius:40/2,minWidth:40,height:40}},{props:{color:`inherit`},style:{color:`inherit`}}]})),Fm(({theme:e})=>({variants:[...Object.entries(e.palette).filter(Um([`dark`,`contrastText`])).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].contrastText,backgroundColor:(e.vars||e).palette[t].main,"&:hover":{backgroundColor:(e.vars||e).palette[t].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[t].main}}}}))]})),Fm(({theme:e})=>({[`&.${i8e.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}))),s8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiFab`}),{children:r,className:i,color:a=`default`,component:o=`button`,disabled:s=!1,disableFocusRipple:c=!1,focusVisibleClassName:l,size:u=`large`,variant:d=`circular`,...f}=n,p={...n,color:a,component:o,disabled:s,disableFocusRipple:c,size:u,variant:d},m=a8e(p);return(0,G.jsx)(o8e,{className:K(m.root,i),component:o,disabled:s,focusRipple:!c,focusVisibleClassName:K(m.focusVisible,l),ownerState:p,ref:t,...f,classes:m,children:r})}),c8e=[{code:`en`,flag:`🇬🇧`,name:`English`},{code:`de`,flag:`🇩🇪`,name:`Deutsch`},{code:`fr`,flag:`🇫🇷`,name:`Français`},{code:`es`,flag:`🇪🇸`,name:`Español`},{code:`it`,flag:`🇮🇹`,name:`Italiano`},{code:`zh`,flag:`🇨🇳`,name:`中文`},{code:`zh-TW`,flag:`🇹🇼`,name:`繁體中文`},{code:`ja`,flag:`🇯🇵`,name:`日本語`},{code:`th`,flag:`🇹🇭`,name:`ไทย`},{code:`sv`,flag:`🇸🇪`,name:`Svenska`},{code:`tr`,flag:`🇹🇷`,name:`Türkçe`},{code:`ru`,flag:`🇷🇺`,name:`Русский`}],l8e=`hamh-custom-languages`;function u8e(){try{let e=localStorage.getItem(l8e);return e?JSON.parse(e).map(e=>({code:e.code,flag:`🌐`,name:e.name})):[]}catch{return[]}}var d8e=`https://github.com/RiDDiX/home-assistant-matter-hub/issues/new?labels=translation&title=Translation+improvement`;function f8e(){let{t:e,i18n:t}=ms(),[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(null),a=(0,C.useMemo)(()=>[...c8e,...u8e()],[]),o=t.language??`en`,s=a.some(e=>e.code===o)?o:o.split(`-`)[0]??`en`,c=(0,C.useCallback)(()=>{r(e=>!e)},[]),l=(0,C.useCallback)(e=>{t.changeLanguage(e),r(!1)},[t]);return(0,G.jsx)(Kh,{onClickAway:(0,C.useCallback)(()=>{r(!1)},[]),children:(0,G.jsxs)(Z,{children:[(0,G.jsx)(s8e,{ref:i,size:`small`,color:`primary`,onClick:c,"aria-label":`Change language`,sx:{position:`fixed`,bottom:24,right:24,zIndex:1300},children:(0,G.jsx)(Phe,{})}),(0,G.jsx)(tb,{open:n,anchorEl:i.current,placement:`top-end`,transition:!0,sx:{zIndex:1300},children:({TransitionProps:t})=>(0,G.jsx)(Db,{...t,timeout:200,children:(0,G.jsxs)(Wm,{elevation:8,sx:{mb:1,py:.5,minWidth:160,borderRadius:2,overflow:`hidden`},children:[a.map(e=>(0,G.jsxs)(Z,{onClick:()=>l(e.code),sx:{display:`flex`,alignItems:`center`,gap:1.5,px:2,py:1,cursor:`pointer`,bgcolor:s===e.code?`action.selected`:`transparent`,"&:hover":{bgcolor:`action.hover`},transition:`background-color 0.15s`},children:[(0,G.jsx)(Q,{sx:{fontSize:`1.4rem`,lineHeight:1,userSelect:`none`},children:e.flag}),(0,G.jsx)(Q,{variant:`body2`,fontWeight:s===e.code?600:400,children:e.name})]},e.code)),(0,G.jsx)(zb,{}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`flex-start`,gap:.75,px:2,py:1},children:[(0,G.jsx)(Wv,{sx:{fontSize:14,mt:.25,color:`text.secondary`}}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,sx:{lineHeight:1.4},children:[e(`languageSwitcher.disclaimer`),` `,(0,G.jsx)(Vv,{href:d8e,target:`_blank`,rel:`noopener`,sx:{fontSize:`inherit`},children:e(`languageSwitcher.contribute`)})]})]})]})})})]})})}var p8e={name:`home-assistant-matter-hub`,description:``,version:`2.1.0-alpha.652`,private:!1,type:`module`,bin:{"home-assistant-matter-hub":`./dist/backend/cli.js`},author:{name:`riddix`,url:`https://github.com/riddix`},keywords:[`home-assistant`,`homeassistant`,`home`,`assistant`,`apple home`,`google home`,`apple`,`google`,`alexa`,`matter`,`matter.js`,`matterjs`,`project-chip`,`smart`,`smarthome`,`smart-home`],bugs:{url:`https://github.com/riddix/home-assistant-matter-hub/issues`},license:`Apache-2.0`,repository:`github:riddix/home-assistant-matter-hub`,scripts:{cleanup:`npx rimraf node_modules dist pack LICENSE README.md`,build:`node build.js`,bundle:`pnpm pack --out package.tgz`,postbuild:`pnpm run bundle`,test:`vitest run`,prestart:`pnpm run build`,start:`dotenvx run -f ../../.env -- ./dist/backend/cli.js start`},dependencies:{"@matter/main":`0.16.11`,"@matter/nodejs":`0.16.11`,"@matter/general":`0.16.11`,ajv:`8.18.0`,archiver:`7.0.1`,color:`5.0.3`,debounce:`3.0.0`,express:`5.2.1`,"express-basic-auth":`1.2.1`,"express-ip-access-control":`1.1.3`,"home-assistant-js-websocket":`9.6.0`,"lodash-es":`4.18.1`,multer:`2.1.1`,nocache:`4.0.0`,unzipper:`0.12.3`,ws:`8.20.0`,yargs:`18.0.0`},devDependencies:{"@home-assistant-matter-hub/backend":`workspace:*`,"@home-assistant-matter-hub/frontend":`workspace:*`,"@home-assistant-matter-hub/common":`workspace:*`,"@types/lodash-es":`^4.17.12`},overrides:{minimatch:`9.0.7`,"path-to-regexp":`^8.4.0`,glob:`^13.0.0`},nx:{targets:{start:{cache:!1,dependsOn:[`build`]},pack:{cache:!0,dependsOn:[`build`],outputs:[`{projectRoot}/pack`]},build:{inputs:[`^default`,`default`,`{workspaceRoot}/README.md`,`{workspaceRoot}/LICENSE`],outputs:[`{projectRoot}/dist`,`{projectRoot}/README.md`,`{projectRoot}/LICENSE`]}}}};function m8e(){let e=`2.1.0-alpha.652`,[t,n]=(0,C.useState)(null);(0,C.useEffect)(()=>{fetch(`api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.version&&n(e.version)}).catch(()=>{})},[]);let r=(0,C.useMemo)(()=>!t||e===`0.0.0-dev`?!1:e!==t,[t]);return(0,C.useMemo)(()=>({name:p8e.name,version:t??e,frontendVersion:e,backendVersion:t,versionMismatch:r}),[t,r])}var h8e=()=>{let{t:e}=ms(),t=[{name:e(`footer.github`),url:Y9.githubRepository},{name:e(`footer.documentation`),url:Y9.documentation},{name:e(`footer.support`),url:Y9.support}];return(0,G.jsxs)(Z9,{sx:{mt:16,mb:4},children:[(0,G.jsx)(zb,{sx:{mt:4,mb:4}}),(0,G.jsx)(jv,{container:!0,spacing:2,justifyContent:`center`,children:t.map((e,t)=>(0,G.jsx)(jv,{size:{xs:12,sm:`auto`},children:(0,G.jsx)(uv,{fullWidth:!0,size:`small`,variant:`outlined`,component:Vv,href:e.url,target:`_blank`,children:e.name})},t.toString()))})]})};function g8e(e){return Fd(`MuiAppBar`,e)}Id(`MuiAppBar`,[`root`,`positionFixed`,`positionAbsolute`,`positionSticky`,`positionStatic`,`positionRelative`,`colorDefault`,`colorPrimary`,`colorSecondary`,`colorInherit`,`colorTransparent`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`]);var _8e=e=>{let{color:t,position:n,classes:r}=e;return up({root:[`root`,`color${Y(t)}`,`position${Y(n)}`]},g8e,r)},v8e=(e,t)=>e?`${e.replace(`)`,``)}, ${t})`:t,y8e=J(Wm,{name:`MuiAppBar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${Y(n.position)}`],t[`color${Y(n.color)}`]]}})(Fm(({theme:e})=>({display:`flex`,flexDirection:`column`,width:`100%`,boxSizing:`border-box`,flexShrink:0,variants:[{props:{position:`fixed`},style:{position:`fixed`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0,"@media print":{position:`absolute`}}},{props:{position:`absolute`},style:{position:`absolute`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0}},{props:{position:`sticky`},style:{position:`sticky`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0}},{props:{position:`static`},style:{position:`static`}},{props:{position:`relative`},style:{position:`relative`}},{props:{color:`inherit`},style:{"--AppBar-color":`inherit`,color:`var(--AppBar-color)`}},{props:{color:`default`},style:{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[100],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[100]),...e.applyStyles(`dark`,{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[900],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[900])})}},...Object.entries(e.palette).filter(Um([`contrastText`])).map(([t])=>({props:{color:t},style:{"--AppBar-background":(e.vars??e).palette[t].main,"--AppBar-color":(e.vars??e).palette[t].contrastText}})),{props:e=>e.enableColorOnDark===!0&&![`inherit`,`transparent`].includes(e.color),style:{backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`}},{props:e=>e.enableColorOnDark===!1&&![`inherit`,`transparent`].includes(e.color),style:{backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`,...e.applyStyles(`dark`,{backgroundColor:e.vars?v8e(e.vars.palette.AppBar.darkBg,`var(--AppBar-background)`):null,color:e.vars?v8e(e.vars.palette.AppBar.darkColor,`var(--AppBar-color)`):null})}},{props:{color:`transparent`},style:{"--AppBar-background":`transparent`,"--AppBar-color":`inherit`,backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`,...e.applyStyles(`dark`,{backgroundImage:`none`})}}]}))),b8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiAppBar`}),{className:r,color:i=`primary`,enableColorOnDark:a=!1,position:o=`fixed`,...s}=n,c={...n,color:i,position:o,enableColorOnDark:a};return(0,G.jsx)(y8e,{square:!0,component:`header`,ownerState:c,elevation:4,className:K(_8e(c).root,r,o===`fixed`&&`mui-fixed`),ref:t,...s})}),x8e={visibility:`hidden`};function S8e(e,t,n){let r=n&&n.getBoundingClientRect(),i=eh(t),a=t.style.transform,o=t.style.transition;t.style.transition=``,t.style.transform=``;let s=t.getBoundingClientRect(),c=i.getComputedStyle(t).getPropertyValue(`transform`);t.style.transform=a,t.style.transition=o;let l=0,u=0;if(c&&c!==`none`&&typeof c==`string`){let e=c.split(`(`)[1].split(`)`)[0].split(`,`);l=parseInt(e[4],10),u=parseInt(e[5],10)}return e===`left`?r?`translateX(${r.right+l-s.left}px)`:`translateX(${i.innerWidth+l-s.left}px)`:e===`right`?r?`translateX(-${s.right-r.left-l}px)`:`translateX(-${s.left+s.width-l}px)`:e===`up`?r?`translateY(${r.bottom+u-s.top}px)`:`translateY(${i.innerHeight+u-s.top}px)`:r?`translateY(-${s.top-r.top+s.height-u}px)`:`translateY(-${s.top+s.height-u}px)`}function C8e(e){return typeof e==`function`?e():e}function Q9(e,t,n){let r=S8e(e,t,C8e(n));r&&(t.style.transform=r)}var w8e=C.forwardRef(function(e,t){let n=wm(),r={enter:n.transitions.easing.easeOut,exit:n.transitions.easing.sharp},i={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:a,appear:o=!0,children:s,container:c,direction:l=`down`,easing:u=r,in:d,onEnter:f,onEntered:p,onEntering:m,onExit:h,onExited:g,onExiting:_,style:v,timeout:y=i,...b}=e,x=C.useRef(null),S=ch(Wh(s),x,t),w=Jh(x,(e,t)=>{Q9(l,e,c),qh(e),f&&f(e,t)}),T=Jh(x,(e,t)=>{let r=Xh({timeout:y,style:v,easing:u},{mode:`enter`});e.style.transition=n.transitions.create(`transform`,r),e.style.transform=`none`,m&&m(e,t)}),E=Jh(x,p),D=Jh(x,_),O=Jh(x,e=>{let t=Xh({timeout:y,style:v,easing:u},{mode:`exit`});e.style.transition=n.transitions.create(`transform`,t),Q9(l,e,c),h&&h(e)}),k=Jh(x,e=>{e.style.transition=``,g&&g(e)}),A=e=>{a&&a(x.current,e)},j=C.useCallback(()=>{x.current&&Q9(l,x.current,c)},[l,c]);return C.useEffect(()=>{if(d||l===`down`||l===`right`)return;let e=Ym(()=>{x.current&&Q9(l,x.current,c)}),t=eh(x.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[l,d,c]),C.useEffect(()=>{d||j()},[d,j]),(0,G.jsx)(wh,{nodeRef:x,onEnter:w,onEntered:E,onEntering:T,onExit:O,onExited:k,onExiting:D,addEndListener:A,appear:o,in:d,timeout:y,...b,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!d?v||s.props.style?{visibility:`hidden`,...v,...s.props.style}:x8e:v&&s.props.style?{...v,...s.props.style}:v||s.props.style,C.cloneElement(s,{ref:S,style:r,...n})}})});function T8e(e){return Fd(`MuiDrawer`,e)}Id(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`paperAnchorLeft`,`paperAnchorRight`,`paperAnchorTop`,`paperAnchorBottom`,`paperAnchorDockedLeft`,`paperAnchorDockedRight`,`paperAnchorDockedTop`,`paperAnchorDockedBottom`,`modal`]);var E8e=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},D8e=e=>{let{classes:t,anchor:n,variant:r}=e;return up({root:[`root`,`anchor${Y(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`,`paperAnchor${Y(n)}`,r!==`temporary`&&`paperAnchorDocked${Y(n)}`]},T8e,t)},O8e=J(jb,{name:`MuiDrawer`,slot:`Root`,overridesResolver:E8e})(Fm(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),k8e=J(`div`,{shouldForwardProp:Dm,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:E8e})({flex:`0 0 auto`}),A8e=J(Wm,{name:`MuiDrawer`,slot:`Paper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.paper,t[`paperAnchor${Y(n.anchor)}`],n.variant!==`temporary`&&t[`paperAnchorDocked${Y(n.anchor)}`]]}})(Fm(({theme:e})=>({overflowY:`auto`,display:`flex`,flexDirection:`column`,height:`100%`,flex:`1 0 auto`,zIndex:(e.vars||e).zIndex.drawer,WebkitOverflowScrolling:`touch`,position:`fixed`,top:0,outline:0,variants:[{props:{anchor:`left`},style:{left:0}},{props:{anchor:`top`},style:{top:0,left:0,right:0,height:`auto`,maxHeight:`100%`}},{props:{anchor:`right`},style:{right:0}},{props:{anchor:`bottom`},style:{top:`auto`,left:0,bottom:0,right:0,height:`auto`,maxHeight:`100%`}},{props:({ownerState:e})=>e.anchor===`left`&&e.variant!==`temporary`,style:{borderRight:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`top`&&e.variant!==`temporary`,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`right`&&e.variant!==`temporary`,style:{borderLeft:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`bottom`&&e.variant!==`temporary`,style:{borderTop:`1px solid ${(e.vars||e).palette.divider}`}}]}))),j8e={left:`right`,right:`left`,top:`down`,bottom:`up`};function M8e(e){return[`left`,`right`].includes(e)}function N8e({direction:e},t){return e===`rtl`&&M8e(t)?j8e[t]:t}var P8e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiDrawer`}),r=wm(),i=kf(),a={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{anchor:o=`left`,BackdropProps:s,children:c,className:l,elevation:u=16,hideBackdrop:d=!1,ModalProps:{BackdropProps:f,...p}={},onClose:m,open:h=!1,PaperProps:g={},SlideProps:_,TransitionComponent:v,transitionDuration:y=a,variant:b=`temporary`,slots:x={},slotProps:S={},...w}=n,T=C.useRef(!1);C.useEffect(()=>{T.current=!0},[]);let E=N8e({direction:i?`rtl`:`ltr`},o),D=o,O={...n,anchor:D,elevation:u,open:h,variant:b,...w},k=D8e(O),A={slots:{transition:v,...x},slotProps:{paper:g,transition:_,...S,backdrop:lh(S.backdrop||{...s,...f},{transitionDuration:y})}},[j,M]=Hm(`root`,{ref:t,elementType:O8e,className:K(k.root,k.modal,l),shouldForwardComponentProp:!0,ownerState:O,externalForwardedProps:{...A,...w,...p},additionalProps:{open:h,onClose:m,hideBackdrop:d,slots:{backdrop:A.slots.backdrop},slotProps:{backdrop:A.slotProps.backdrop}}}),[N,P]=Hm(`paper`,{elementType:A8e,shouldForwardComponentProp:!0,className:K(k.paper,g.className),ownerState:O,externalForwardedProps:A,additionalProps:{elevation:b===`temporary`?u:0,square:!0,...b===`temporary`&&{role:`dialog`,"aria-modal":`true`}}}),[F,I]=Hm(`docked`,{elementType:k8e,ref:t,className:K(k.root,k.docked,l),ownerState:O,externalForwardedProps:A,additionalProps:w}),[L,R]=Hm(`transition`,{elementType:w8e,ownerState:O,externalForwardedProps:A,additionalProps:{in:h,direction:j8e[E],timeout:y,appear:T.current}}),ee=(0,G.jsx)(N,{...P,children:c});if(b===`permanent`)return(0,G.jsx)(F,{...I,children:ee});let z=(0,G.jsx)(L,{...R,children:ee});return b===`persistent`?(0,G.jsx)(F,{...I,children:z}):(0,G.jsx)(j,{...M,children:z})}),F8e=rf({themeId:Cm}),I8e={error:vx,warn:Gv,info:mb,debug:UT},L8e=({open:e,onClose:t})=>{let{t:n}=ms(),r=wm(),i=(0,C.useMemo)(()=>({error:r.palette.error.main,warn:r.palette.warning.main,info:r.palette.info.main,debug:r.palette.secondary.main}),[r]),[a,o]=(0,C.useState)([]),[s,c]=(0,C.useState)(!0),[l,u]=(0,C.useState)(`error,warn,info`.split(`,`)),[d,f]=(0,C.useState)(``),[p,m]=(0,C.useState)(!0),h=(0,C.useCallback)(async()=>{try{let e=new URLSearchParams({level:l.join(`,`),limit:`500`,...d&&{search:d}}),t=await fetch(`api/logs?${e}`);t.ok&&o((await t.json()).entries)}catch(e){console.error(`Failed to fetch logs:`,e)}finally{c(!1)}},[l,d]);(0,C.useEffect)(()=>{e&&h()},[e,h]),(0,C.useEffect)(()=>{if(!p||!e)return;let t=setInterval(h,5e3);return()=>clearInterval(t)},[p,e,h]);let g=e=>{u(Array.isArray(e.target.value)?e.target.value:[e.target.value])},_=e=>{f(e.target.value)},v=async()=>{try{await fetch(`api/logs`,{method:`DELETE`}),o([])}catch(e){console.error(`Failed to clear logs:`,e)}},y=e=>(0,G.jsx)(I8e[e]||mb,{sx:{fontSize:16,color:i[e]}});return(0,G.jsxs)(Pb,{open:e,onClose:t,maxWidth:`lg`,fullWidth:!0,children:[(0,G.jsxs)(Lb,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(UT,{}),n(`logs.title`),(0,G.jsx)(Z,{sx:{flexGrow:1}}),(0,G.jsx)(sb,{title:n(`logs.autoRefresh`),children:(0,G.jsx)(Sv,{label:p?`Auto`:`Manual`,color:p?`success`:`default`,size:`small`,onClick:()=>m(!p),sx:{cursor:`pointer`}})}),(0,G.jsx)(Bh,{onClick:t,children:(0,G.jsx)(KT,{})})]}),(0,G.jsxs)(Ib,{children:[(0,G.jsx)(Rv,{spacing:2,sx:{mb:2},children:(0,G.jsxs)(Rv,{direction:`row`,spacing:2,alignItems:`center`,children:[(0,G.jsxs)(Tv,{size:`small`,sx:{minWidth:200},children:[(0,G.jsx)(Fx,{children:n(`logs.logLevel`)}),(0,G.jsxs)(_S,{value:l,label:n(`logs.logLevel`),onChange:g,multiple:!0,renderValue:e=>(0,G.jsx)(Z,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:(Array.isArray(e)?e:[e]).map(e=>(0,G.jsx)(Sv,{label:e.toUpperCase(),size:`small`,sx:{backgroundColor:i[e],color:`white`}},e))}),children:[(0,G.jsx)(vS,{value:`error`,children:n(`logs.error`)}),(0,G.jsx)(vS,{value:`warn`,children:n(`logs.warning`)}),(0,G.jsx)(vS,{value:`info`,children:n(`logs.info`)}),(0,G.jsx)(vS,{value:`debug`,children:n(`logs.debug`)})]})]}),(0,G.jsx)(xS,{size:`small`,placeholder:n(`logs.searchPlaceholder`),value:d,onChange:_,sx:{flexGrow:1}}),(0,G.jsx)(uv,{variant:`outlined`,onClick:h,children:n(`common.refresh`)}),(0,G.jsx)(uv,{variant:`outlined`,color:`error`,onClick:v,children:n(`common.delete`)})]})}),(0,G.jsx)(Z,{sx:{height:400,overflow:`auto`,backgroundColor:`background.paper`,border:1,borderColor:`divider`,borderRadius:1,p:1},children:s?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsxs)(Q,{children:[n(`common.loading`),`...`]})}):a.length===0?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(Q,{color:`text.secondary`,children:n(`logs.noResults`)})}):(0,G.jsx)(Rv,{spacing:1,children:a.map((e,t)=>(0,G.jsxs)(Z,{sx:{p:1,borderRadius:1,backgroundColor:`action.hover`,fontFamily:`monospace`,fontSize:`0.875rem`,wordBreak:`break-all`},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1,mb:.5},children:[y(e.level),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),(0,G.jsx)(Sv,{label:e.level.toUpperCase(),size:`small`,sx:{backgroundColor:i[e.level],color:r.palette.getContrastText(i[e.level]??r.palette.grey[500]),fontSize:`0.7rem`,height:20}})]}),(0,G.jsx)(Q,{sx:{ml:3},children:e.message}),e.context&&(0,G.jsx)(Q,{sx:{ml:3,color:`text.secondary`,fontSize:`0.8rem`},children:JSON.stringify(e.context,null,2)})]},`${e.timestamp}-${e.level}-${t}`))})})]}),(0,G.jsx)(Fb,{children:(0,G.jsx)(uv,{onClick:t,children:n(`common.close`)})})]})};function R8e(){let{t:e}=ms(),{isConnected:t}=J_(),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(!1);(0,C.useEffect)(()=>{let e=async()=>{try{let e=await fetch(`api/health`);e.ok?(r(await e.json()),a(!1)):a(!0)}catch{a(!0)}};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]);let o=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${n}m`},s=n?.status===`healthy`&&!i,c=n?.services?.bridges,l=c&&c.total>0&&c.running===c.total,u=c&&c.total===0,d=n?(0,G.jsxs)(Z,{sx:{p:.5},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`health.version`),`:`]}),` `,n.version??e(`status.unknown`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`health.uptime`),`:`]}),` `,o(n.uptime??0)]}),n.services?.bridges&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`nav.bridges`),`:`]}),` `,n.services.bridges.running??0,`/`,n.services.bridges.total??0,` `,e(`common.running`).toLowerCase(),(n.services.bridges.stopped??0)>0&&` (${n.services.bridges.stopped} ${e(`common.stopped`).toLowerCase()})`]}),n.services?.homeAssistant&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[e(`health.homeAssistant`),`:`]}),` `,n.services.homeAssistant.connected?e(`health.connected`):e(`health.disconnected`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`WebSocket:`}),` `,e(t?`health.connected`:`health.disconnected`)]})]}):e(`status.loadingHealth`);return(0,G.jsx)(sb,{title:d,arrow:!0,children:(0,G.jsx)(Sv,{icon:i||!s?(0,G.jsx)(vx,{fontSize:`small`}):l?(0,G.jsx)(av,{fontSize:`small`}):(0,G.jsx)(_b,{fontSize:`small`}),label:e(i?`status.error`:s?t?u?`status.noBridges`:l?`common.online`:`common.starting`:`common.offline`:`status.unhealthy`),color:i||!s?`error`:!l||!t?`warning`:`success`,size:`small`,variant:`filled`,sx:{borderRadius:1,fontWeight:600,"& .MuiChip-icon":{color:`inherit`}}})})}var z8e=e=>(0,G.jsx)(`svg`,{viewBox:`0 0 91 89`,xmlSpace:`preserve`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,G.jsxs)(`g`,{style:{display:`inline`},children:[(0,G.jsx)(`path`,{style:{fill:`#18bcf2`,fillOpacity:1,strokeWidth:.266194},d:`m 49.149143,1.473171 38.513568,38.536435 c 0,0 1.248354,1.186052 2.207681,3.092371 0.959329,1.906323 1.10864,4.600698 1.10864,4.600698 v 36.786372 c 0,0 -0.01549,1.748506 -1.49842,3.050572 -1.482931,1.302064 -3.333077,1.362947 -3.333077,1.362947 l -81.325658,7.7e-5 c 0,0 -1.7523855,-0.0091 -3.17112,-1.352526 C -0.07808495,85.913164 0.05953025,84.487808 0.05953025,84.487808 V 47.704546 c 0,0 -0.0018381,-2.218618 0.95921785,-4.315832 0.9610554,-2.097209 2.3010618,-3.355005 2.3010618,-3.355005 L 41.545959,1.4719546 c 0,0 1.465224,-1.46837077 3.753488,-1.46837077 2.288268,0 3.849696,1.46958717 3.849696,1.46958717 z`}),(0,G.jsx)(`path`,{style:{fill:`#ffffff`,fillOpacity:1,strokeWidth:.175841},d:`m 31.689717,32.051124 c 2.813363,2.331095 6.157331,3.89845 9.721813,4.556421 V 17.180647 l 3.873694,-2.282955 3.870527,2.282955 V 36.60772 c 3.565364,-0.658847 6.910387,-2.226204 9.725159,-4.556417 l 7.032345,4.154609 c -11.437354,11.557779 -29.852321,11.557779 -41.290025,0 z m 8.546732,49.60988 C 44.314996,65.760441 35.09933,49.470196 19.574984,45.139543 v 8.312381 c 3.383916,1.32244 6.386113,3.496288 8.728705,6.320026 L 11.83076,69.485301 v 4.56907 l 3.873697,2.270836 16.469936,-9.713534 c 1.224356,3.48294 1.56683,7.225375 0.996449,10.879778 z M 70.977694,45.139543 c -15.515726,4.34014 -24.72189,20.626696 -20.643519,36.521461 l 7.047658,-4.15742 c -0.569325,-3.654411 -0.2265,-7.3965 0.996449,-10.87979 l 16.457611,9.701233 3.870711,-2.283125 v -4.55677 L 62.233673,59.77195 c 2.342772,-2.822684 5.34497,-4.996533 8.728708,-6.320026 z`})]})}),B8e=e=>{let t=m8e();return(0,G.jsxs)(Z,{component:ea,to:Y9.dashboard,sx:{display:`flex`,alignItems:`center`,justifyContent:e.large?`flex-start`:`center`,flexGrow:1,textDecoration:`none`,color:`inherit`},children:[(0,G.jsx)(z8e,{style:{height:`40px`}}),(0,G.jsx)(Q,{variant:`inherit`,component:`span`,sx:{mr:1,ml:1},children:t.name.split(`-`).map(Y).join(`-`)}),e.large&&(0,G.jsx)(Q,{variant:`caption`,component:`span`,children:t.version})]})},V8e=()=>{let e=F8e(`(min-width:600px)`),{mode:t,setMode:n}=Pm(),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(!1),s=Sr(),c=yr(),l=e=>e?e===`/`?c.pathname===`/`:c.pathname.startsWith(e):!1,u=()=>{n(t===`dark`?`light`:`dark`)},{t:d}=ms(),f=[{label:d(`dashboard.title`),icon:(0,G.jsx)(ZT,{}),to:Y9.dashboard},{label:d(`nav.bridges`),icon:(0,G.jsx)(QT,{}),to:Y9.bridges},{label:d(`nav.devices`),icon:(0,G.jsx)(ub,{}),to:Y9.devices},{label:d(`nav.networkMap`),icon:(0,G.jsx)(LT,{}),to:Y9.networkMap},{label:d(`nav.startupOrder`),icon:(0,G.jsx)(ov,{}),to:Y9.startup},{label:d(`nav.lockCredentials`),icon:(0,G.jsx)(vT,{}),to:Y9.lockCredentials},{label:d(`nav.filterReference`),icon:(0,G.jsx)($T,{}),to:Y9.labels},{label:`Plugins`,icon:(0,G.jsx)(YT,{}),to:Y9.plugins},{label:d(`nav.settings`),icon:(0,G.jsx)(DT,{}),to:Y9.settings},{label:d(t===`dark`?`nav.lightMode`:`nav.darkMode`),icon:t===`dark`?(0,G.jsx)(Ihe,{}):(0,G.jsx)(whe,{}),onClick:u},{label:d(`nav.systemLogs`),icon:(0,G.jsx)(UT,{}),onClick:()=>i(!0)},{label:d(`nav.health`),icon:(0,G.jsx)(wx,{}),to:Y9.health}],p=e=>{o(!1),e.onClick?e.onClick():e.to&&s(e.to)};return(0,G.jsxs)(Z,{children:[(0,G.jsx)(b8e,{sx:{height:`72px`},children:(0,G.jsx)(t8e,{sx:{paddingLeft:`0 !important`,paddingRight:`0 !important`},children:(0,G.jsxs)(Z9,{sx:{padding:2,height:`100%`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsx)(B8e,{large:e}),e?(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[f.map(e=>e.to?(0,G.jsx)(sb,{title:e.label,children:(0,G.jsx)(Bh,{component:ea,to:e.to,sx:{color:`inherit`,bgcolor:l(e.to)?`rgba(255,255,255,0.15)`:`transparent`,borderRadius:1},children:e.icon})},e.label):(0,G.jsx)(sb,{title:e.label,children:(0,G.jsx)(Bh,{onClick:e.onClick,sx:{color:`inherit`},children:e.icon})},e.label)),(0,G.jsx)(R8e,{})]}):(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(R8e,{}),(0,G.jsx)(Bh,{onClick:()=>o(!0),sx:{color:`inherit`},children:(0,G.jsx)(Lhe,{})})]})]})})}),(0,G.jsx)(P8e,{anchor:`right`,open:a,onClose:()=>o(!1),children:(0,G.jsx)(Yv,{sx:{width:250},children:f.map(e=>(0,G.jsxs)(Vae,{selected:l(e.to),onClick:()=>p(e),children:[(0,G.jsx)(ey,{children:e.icon}),(0,G.jsx)(ny,{primary:e.label})]},e.label))})}),(0,G.jsx)(L8e,{open:r,onClose:()=>i(!1)})]})},H8e=()=>{let{versionMismatch:e,frontendVersion:t,backendVersion:n}=m8e(),{isConnected:r}=J_();return(0,G.jsxs)(Z,{children:[(0,G.jsx)(V8e,{}),(0,G.jsx)(t8e,{}),e&&(0,G.jsxs)(Uh,{severity:`warning`,variant:`filled`,sx:{borderRadius:0},action:(0,G.jsx)(uv,{color:`inherit`,size:`small`,onClick:()=>window.location.reload(),children:`Reload`}),children:[`Version mismatch: frontend `,t,`, backend `,n,`. Please reload to get the latest UI.`]}),!r&&(0,G.jsx)(Uh,{severity:`error`,variant:`filled`,sx:{borderRadius:0},children:`Connection lost, data may be outdated. Reconnecting…`}),(0,G.jsx)(Z9,{sx:{p:2},children:(0,G.jsx)(n8e,{children:(0,G.jsx)(oi,{})})}),(0,G.jsx)(h8e,{}),(0,G.jsx)(f8e,{})]})},U8e=xm({colorSchemes:{light:{palette:{primary:{main:`#1976d2`,light:`#42a5f5`,dark:`#1565c0`},secondary:{main:`#9c27b0`,light:`#ba68c8`,dark:`#7b1fa2`},background:{default:`#f5f5f5`,paper:`#ffffff`}}},dark:{palette:{primary:{main:`#90caf9`,light:`#e3f2fd`,dark:`#42a5f5`},secondary:{main:`#ce93d8`,light:`#f3e5f5`,dark:`#ab47bc`},background:{default:`#121212`,paper:`#1e1e1e`}}}},typography:{fontFamily:`"Roboto", "Helvetica", "Arial", sans-serif`,h1:{fontSize:`2.5rem`,fontWeight:500},h2:{fontSize:`2rem`,fontWeight:500},h3:{fontSize:`1.75rem`,fontWeight:500},h4:{fontSize:`1.5rem`,fontWeight:500},h5:{fontSize:`1.25rem`,fontWeight:500},h6:{fontSize:`1rem`,fontWeight:500}},shape:{borderRadius:8},components:{MuiCard:{styleOverrides:{root:{transition:`transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out`,"&:hover":{transform:`translateY(-2px)`,boxShadow:`0 4px 20px rgba(0,0,0,0.12)`}}}},MuiButton:{styleOverrides:{root:{textTransform:`none`,fontWeight:500}}},MuiChip:{styleOverrides:{root:{fontWeight:500}}},MuiAppBar:{styleOverrides:{root:{backgroundImage:`none`}}}}}),$9=document.getElementsByTagName(`base`)[0]?.href?.replace(/\/$/,``);$9?.startsWith(`http`)&&($9=new URL($9).pathname);var W8e=Yi([{path:`/`,element:(0,G.jsx)(H8e,{}),children:J6e}],{basename:$9});(0,S.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(C.StrictMode,{children:(0,G.jsx)(L,{store:Z6e,children:(0,G.jsxs)(Kee,{theme:U8e,children:[(0,G.jsx)(Bee,{}),(0,G.jsx)(Tm,{styles:{".rjsf-field-array > .MuiFormControl-root > .MuiPaper-root > .MuiBox-root > .MuiGrid-root > .MuiGrid-root:has(> .MuiBox-root > .MuiPaper-root > .MuiBox-root > .rjsf-field)":{overflow:`initial !important`,flexGrow:1}}}),(0,G.jsx)(Ere,{children:(0,G.jsx)(lne,{children:(0,G.jsx)(ba,{router:W8e})})})]})})}));